Index: trunk/src/Makefile.dep =================================================================== --- trunk/src/Makefile.dep (revision 8423) +++ trunk/src/Makefile.dep (revision 8424) @@ -4780,7 +4780,7 @@ buffer.h draw.h rotate.h rtree.h stub_draw.h obj_all.h layer_ui.h \ obj_pad_draw.h obj_pinvia_draw.h obj_elem_draw.h obj_line_draw.h \ obj_arc_draw.h obj_rat_draw.h obj_poly_draw.h obj_text_draw.h \ - draw_composite.c + draw_composite.c draw_ly_spec.c error.o: error.c ../config.h data.h globalconst.h global_typedefs.h \ pcb_bool.h unit.h layer.h attrib.h obj_all_list.h obj_arc_list.h \ obj_common.h ../src_3rd/liblihata/genht/hash.h \ Index: trunk/src/draw.c =================================================================== --- trunk/src/draw.c (revision 8423) +++ trunk/src/draw.c (revision 8424) @@ -75,10 +75,16 @@ */ static void DrawEverything(const pcb_box_t *); static void DrawLayerGroup(int, const pcb_box_t *); -static void pcb_draw_mask(int side, const pcb_box_t *); + +/* In draw_ly_spec.c: */ +static void pcb_draw_paste(int side, const pcb_box_t *drawn_area); +static void pcb_draw_mask(int side, const pcb_box_t *screen); +static void pcb_draw_silk(unsigned int lyt_side, const pcb_box_t *drawn_area); static void DrawRats(const pcb_box_t *); -static void pcb_draw_silk(unsigned int lyt_side, const pcb_box_t *); +static void PrintAssembly(unsigned int lyt_side, const pcb_box_t * drawn_area); + + #warning TODO: this should be cached void pcb_lighten_color(const char *orig, char buf[8], double factor) { @@ -135,26 +141,6 @@ pcb_r_search(PCB->Data->via_tree, drawn_area, NULL, draw_hole_callback, &plated, NULL); } -/* --------------------------------------------------------------------------- - * prints assembly drawing. - */ -static void PrintAssembly(unsigned int lyt_side, const pcb_box_t * drawn_area) -{ - pcb_layergrp_id_t side_group; - - if (pcb_layergrp_list(PCB, PCB_LYT_COPPER | lyt_side, &side_group, 1) != 1) - return; - - pcb_draw_doing_assy = pcb_true; - pcb_gui->set_draw_faded(Output.fgGC, 1); - DrawLayerGroup(side_group, drawn_area); - pcb_gui->set_draw_faded(Output.fgGC, 0); - - /* draw package */ - pcb_draw_silk(lyt_side, drawn_area); - pcb_draw_doing_assy = pcb_false; -} - static void DrawEverything_holes(const pcb_box_t * drawn_area) { int plated, unplated; @@ -171,11 +157,6 @@ } } -void pcb_draw_paste(int side, const pcb_box_t * drawn_area) -{ - pcb_draw_paste_auto(side, drawn_area); -} - /* --------------------------------------------------------------------------- * initializes some identifiers for a new zoom factor and redraws whole screen */ @@ -372,85 +353,9 @@ pcb_r_search(PCB->Data->pin_tree, drawn_area, NULL, draw_hole_callback, NULL, NULL); } -/* --------------------------------------------------------------------------- - * Draws silk layer. - */ - -static void pcb_draw_silk_auto(unsigned int lyt_side, const pcb_box_t * drawn_area) -{ - int side = (lyt_side == PCB_LYT_TOP ? PCB_COMPONENT_SIDE : PCB_SOLDER_SIDE); - - /* draw package */ - pcb_r_search(PCB->Data->element_tree, drawn_area, NULL, draw_element_callback, &side, NULL); - pcb_r_search(PCB->Data->name_tree[PCB_ELEMNAME_IDX_VISIBLE()], drawn_area, NULL, draw_element_name_callback, &side, NULL); -} - -static void pcb_draw_silk(unsigned int lyt_side, const pcb_box_t * drawn_area) -{ - pcb_layer_id_t lid; - - if (pcb_layer_list(PCB_LYT_SILK | lyt_side, &lid, 1) == 0) - return; - - pcb_draw_layer(LAYER_PTR(lid), drawn_area); - - pcb_draw_silk_auto(lyt_side, drawn_area); -} - #include "draw_composite.c" +#include "draw_ly_spec.c" -/* --------------------------------------------------------------------------- - * draws solder mask layer - this will cover nearly everything - */ -static void pcb_draw_mask_auto(comp_ctx_t *ctx, void *side) -{ - pcb_r_search(PCB->Data->pin_tree, ctx->screen, NULL, clear_pin_callback, NULL, NULL); - pcb_r_search(PCB->Data->via_tree, ctx->screen, NULL, clear_pin_callback, NULL, NULL); - pcb_r_search(PCB->Data->pad_tree, ctx->screen, NULL, clear_pad_callback, side, NULL); -} - -static void pcb_draw_mask(int side, const pcb_box_t * screen) -{ - unsigned long side_lyt = side ? PCB_LYT_TOP : PCB_LYT_BOTTOM; - pcb_layergrp_id_t gid = -1; - comp_ctx_t cctx; - - pcb_layergrp_list(PCB, PCB_LYT_MASK | side_lyt, &gid, 1); - - cctx.pcb = PCB; - cctx.screen = screen; - cctx.grp = pcb_get_layergrp(PCB, gid); - cctx.thin = conf_core.editor.thin_draw || conf_core.editor.thin_draw_poly; - cctx.invert = pcb_gui->mask_invert; - cctx.poly_before = pcb_gui->poly_before; - cctx.poly_after = pcb_gui->poly_after; - - - if ((cctx.grp == NULL) || (cctx.grp->len == 0)) { /* fallback: no layers -> original code: draw a single auto-sub */ - comp_init(&cctx, 1); - comp_start_sub(&cctx); - pcb_draw_mask_auto(&cctx, &side); - comp_start_add(&cctx); - } - else - comp_draw_layer(&cctx, pcb_draw_mask_auto, &side); - comp_finish(&cctx); -} - -static void DrawRats(const pcb_box_t * drawn_area) -{ - /* - * lesstif allows positive AND negative drawing in HID_MASK_CLEAR. - * gtk only allows negative drawing. - * using the mask here is to get rat transparency - */ - if (pcb_gui->can_mask_clear_rats) - pcb_gui->use_mask(HID_MASK_CLEAR); - pcb_r_search(PCB->Data->rat_tree, drawn_area, NULL, draw_rat_callback, NULL, NULL); - if (pcb_gui->can_mask_clear_rats) - pcb_gui->use_mask(HID_MASK_OFF); -} - void pcb_draw_layer(pcb_layer_t *Layer, const pcb_box_t * screen) { pcb_draw_info_t info; @@ -694,5 +599,3 @@ conf_force_set_bool(conf_core.editor.view.flip_y, fy); } } - - Index: trunk/src/draw_ly_spec.c =================================================================== --- trunk/src/draw_ly_spec.c (nonexistent) +++ trunk/src/draw_ly_spec.c (revision 8424) @@ -0,0 +1,129 @@ +/* + * COPYRIGHT + * + * PCB, interactive printed circuit board design + * Copyright (C) 1994,1995,1996, 2003, 2004 Thomas Nau + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * Contact addresses for paper mail and Email: + * Thomas Nau, Schlehenweg 15, 88471 Baustetten, Germany + * Thomas.Nau@rz.uni-ulm.de + * + */ + +/* Local functions for special layer draw logics. This code is not generic; + instead it collects all the hardwired heuristics for the special layers. + Included from draw.c. */ + +/******** paste ********/ + +static void pcb_draw_paste(int side, const pcb_box_t *drawn_area) +{ + pcb_draw_paste_auto(side, drawn_area); +} + +/******** mask ********/ +static void pcb_draw_mask_auto(comp_ctx_t *ctx, void *side) +{ + pcb_r_search(PCB->Data->pin_tree, ctx->screen, NULL, clear_pin_callback, NULL, NULL); + pcb_r_search(PCB->Data->via_tree, ctx->screen, NULL, clear_pin_callback, NULL, NULL); + pcb_r_search(PCB->Data->pad_tree, ctx->screen, NULL, clear_pad_callback, side, NULL); +} + +static void pcb_draw_mask(int side, const pcb_box_t *screen) +{ + unsigned long side_lyt = side ? PCB_LYT_TOP : PCB_LYT_BOTTOM; + pcb_layergrp_id_t gid = -1; + comp_ctx_t cctx; + + pcb_layergrp_list(PCB, PCB_LYT_MASK | side_lyt, &gid, 1); + + cctx.pcb = PCB; + cctx.screen = screen; + cctx.grp = pcb_get_layergrp(PCB, gid); + cctx.thin = conf_core.editor.thin_draw || conf_core.editor.thin_draw_poly; + cctx.invert = pcb_gui->mask_invert; + cctx.poly_before = pcb_gui->poly_before; + cctx.poly_after = pcb_gui->poly_after; + + + if ((cctx.grp == NULL) || (cctx.grp->len == 0)) { /* fallback: no layers -> original code: draw a single auto-sub */ + comp_init(&cctx, 1); + comp_start_sub(&cctx); + pcb_draw_mask_auto(&cctx, &side); + comp_start_add(&cctx); + } + else + comp_draw_layer(&cctx, pcb_draw_mask_auto, &side); + comp_finish(&cctx); +} + +/******** silk ********/ + +static void pcb_draw_silk_auto(unsigned int lyt_side, const pcb_box_t * drawn_area) +{ + int side = (lyt_side == PCB_LYT_TOP ? PCB_COMPONENT_SIDE : PCB_SOLDER_SIDE); + + /* draw package */ + pcb_r_search(PCB->Data->element_tree, drawn_area, NULL, draw_element_callback, &side, NULL); + pcb_r_search(PCB->Data->name_tree[PCB_ELEMNAME_IDX_VISIBLE()], drawn_area, NULL, draw_element_name_callback, &side, NULL); +} + +static void pcb_draw_silk(unsigned int lyt_side, const pcb_box_t *drawn_area) +{ + pcb_layer_id_t lid; + + if (pcb_layer_list(PCB_LYT_SILK | lyt_side, &lid, 1) == 0) + return; + + pcb_draw_layer(LAYER_PTR(lid), drawn_area); + + pcb_draw_silk_auto(lyt_side, drawn_area); +} + + +/******** misc ********/ + +static void DrawRats(const pcb_box_t * drawn_area) +{ + /* + * lesstif allows positive AND negative drawing in HID_MASK_CLEAR. + * gtk only allows negative drawing. + * using the mask here is to get rat transparency + */ + if (pcb_gui->can_mask_clear_rats) + pcb_gui->use_mask(HID_MASK_CLEAR); + pcb_r_search(PCB->Data->rat_tree, drawn_area, NULL, draw_rat_callback, NULL, NULL); + if (pcb_gui->can_mask_clear_rats) + pcb_gui->use_mask(HID_MASK_OFF); +} + +static void PrintAssembly(unsigned int lyt_side, const pcb_box_t * drawn_area) +{ + pcb_layergrp_id_t side_group; + + if (pcb_layergrp_list(PCB, PCB_LYT_COPPER | lyt_side, &side_group, 1) != 1) + return; + + pcb_draw_doing_assy = pcb_true; + pcb_gui->set_draw_faded(Output.fgGC, 1); + DrawLayerGroup(side_group, drawn_area); + pcb_gui->set_draw_faded(Output.fgGC, 0); + + /* draw package */ + pcb_draw_silk(lyt_side, drawn_area); + pcb_draw_doing_assy = pcb_false; +}