draw.c: Collapse line and arc drawing wrapper functions into only callers
[geda-pcb/pcjc2.git] / src / draw.c
blobd70963edefb7c34e698db40c593f31c28ac7cf4c
1 /*
2 * COPYRIGHT
4 * PCB, interactive printed circuit board design
5 * Copyright (C) 1994,1995,1996, 2003, 2004 Thomas Nau
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 * Contact addresses for paper mail and Email:
22 * Thomas Nau, Schlehenweg 15, 88471 Baustetten, Germany
23 * Thomas.Nau@rz.uni-ulm.de
28 /* drawing routines
31 #ifdef HAVE_CONFIG_H
32 #include "config.h"
33 #endif
35 #include "global.h"
36 #include "hid_draw.h"
38 /*#include "clip.h"*/
39 #include "compat.h"
40 #include "crosshair.h"
41 #include "data.h"
42 #include "draw.h"
43 #include "error.h"
44 #include "mymem.h"
45 #include "misc.h"
46 #include "rotate.h"
47 #include "rtree.h"
48 #include "search.h"
49 #include "select.h"
50 #include "print.h"
52 #ifdef HAVE_LIBDMALLOC
53 #include <dmalloc.h>
54 #endif
56 #undef NDEBUG
57 #include <assert.h>
59 #ifndef MAXINT
60 #define MAXINT (((unsigned int)(~0))>>1)
61 #endif
63 #define SMALL_SMALL_TEXT_SIZE 0
64 #define SMALL_TEXT_SIZE 1
65 #define NORMAL_TEXT_SIZE 2
66 #define LARGE_TEXT_SIZE 3
67 #define N_TEXT_SIZES 4
70 /* ---------------------------------------------------------------------------
71 * some local identifiers
73 static BoxType Block = {MAXINT, MAXINT, -MAXINT, -MAXINT};
75 static int doing_pinout = 0;
76 static bool doing_assy = false;
78 /* ---------------------------------------------------------------------------
79 * some local prototypes
81 static void DrawEverything (const BoxType *);
82 static void DrawPPV (int group, const BoxType *);
83 static void AddPart (void *);
84 static void DrawEMark (ElementType *, Coord, Coord, bool);
85 static void DrawRats (const BoxType *);
87 static void
88 set_object_color (AnyObjectType *obj,
89 char *warn_color, char *selected_color,
90 char *found_color, char *normal_color)
92 char *color;
94 if (warn_color != NULL && TEST_FLAG (WARNFLAG, obj)) color = warn_color;
95 else if (selected_color != NULL && TEST_FLAG (SELECTEDFLAG, obj)) color = selected_color;
96 else if (found_color != NULL && TEST_FLAG (FOUNDFLAG, obj)) color = found_color;
97 else color = normal_color;
99 gui->graphics->set_color (Output.fgGC, color);
102 static void
103 set_layer_object_color (LayerType *layer, AnyObjectType *obj)
105 set_object_color (obj, NULL, layer->SelectedColor, PCB->ConnectedColor, layer->Color);
108 /*---------------------------------------------------------------------------
109 * Adds the update rect to the update region
111 static void
112 AddPart (void *b)
114 BoxType *box = (BoxType *) b;
116 Block.X1 = MIN (Block.X1, box->X1);
117 Block.X2 = MAX (Block.X2, box->X2);
118 Block.Y1 = MIN (Block.Y1, box->Y1);
119 Block.Y2 = MAX (Block.Y2, box->Y2);
123 * initiate the actual redrawing of the updated area
125 void
126 Draw (void)
128 if (Block.X1 <= Block.X2 && Block.Y1 <= Block.Y2)
129 gui->invalidate_lr (Block.X1, Block.X2, Block.Y1, Block.Y2);
131 /* shrink the update block */
132 Block.X1 = Block.Y1 = MAXINT;
133 Block.X2 = Block.Y2 = -MAXINT;
136 /* ----------------------------------------------------------------------
137 * redraws all the data by the event handlers
139 void
140 Redraw (void)
142 gui->invalidate_all ();
145 static void
146 _draw_pv_name (PinType *pv)
148 BoxType box;
149 bool vert;
150 TextType text;
152 if (!pv->Name || !pv->Name[0])
153 text.TextString = EMPTY (pv->Number);
154 else
155 text.TextString = EMPTY (TEST_FLAG (SHOWNUMBERFLAG, PCB) ? pv->Number : pv->Name);
157 vert = TEST_FLAG (EDGE2FLAG, pv);
159 if (vert)
161 box.X1 = pv->X - pv->Thickness / 2 + Settings.PinoutTextOffsetY;
162 box.Y1 = pv->Y - pv->DrillingHole / 2 - Settings.PinoutTextOffsetX;
164 else
166 box.X1 = pv->X + pv->DrillingHole / 2 + Settings.PinoutTextOffsetX;
167 box.Y1 = pv->Y - pv->Thickness / 2 + Settings.PinoutTextOffsetY;
170 gui->graphics->set_color (Output.fgGC, PCB->PinNameColor);
172 text.Flags = NoFlags ();
173 /* Set font height to approx 56% of pin thickness */
174 text.Scale = 56 * pv->Thickness / FONT_CAPHEIGHT;
175 text.X = box.X1;
176 text.Y = box.Y1;
177 text.Direction = vert ? 1 : 0;
179 if (gui->gui)
180 doing_pinout++;
181 gui->graphics->draw_pcb_text (Output.fgGC, &text, 0);
182 if (gui->gui)
183 doing_pinout--;
186 static void
187 _draw_pv (PinType *pv, bool draw_hole)
189 if (TEST_FLAG (THINDRAWFLAG, PCB))
190 gui->graphics->thindraw_pcb_pv (Output.fgGC, Output.fgGC, pv, draw_hole, false);
191 else
192 gui->graphics->fill_pcb_pv (Output.fgGC, Output.bgGC, pv, draw_hole, false);
194 if (!TEST_FLAG (HOLEFLAG, pv) && TEST_FLAG (DISPLAYNAMEFLAG, pv))
195 _draw_pv_name (pv);
198 static void
199 draw_pin (PinType *pin, bool draw_hole)
201 if (doing_pinout)
202 gui->graphics->set_color (Output.fgGC, PCB->PinColor);
203 else
204 set_object_color ((AnyObjectType *)pin,
205 PCB->WarnColor, PCB->PinSelectedColor,
206 PCB->ConnectedColor, PCB->PinColor);
208 _draw_pv (pin, draw_hole);
211 static int
212 pin_callback (const BoxType * b, void *cl)
214 draw_pin ((PinType *)b, false);
215 return 1;
218 static void
219 draw_via (PinType *via, bool draw_hole)
221 if (doing_pinout)
222 gui->graphics->set_color (Output.fgGC, PCB->ViaColor);
223 else
224 set_object_color ((AnyObjectType *)via,
225 PCB->WarnColor, PCB->ViaSelectedColor,
226 PCB->ConnectedColor, PCB->ViaColor);
228 _draw_pv (via, draw_hole);
231 static int
232 via_callback (const BoxType * b, void *cl)
234 draw_via ((PinType *)b, false);
235 return 1;
238 static void
239 draw_pad_name (PadType *pad)
241 BoxType box;
242 bool vert;
243 TextType text;
245 if (!pad->Name || !pad->Name[0])
246 text.TextString = EMPTY (pad->Number);
247 else
248 text.TextString = EMPTY (TEST_FLAG (SHOWNUMBERFLAG, PCB) ? pad->Number : pad->Name);
250 /* should text be vertical ? */
251 vert = (pad->Point1.X == pad->Point2.X);
253 if (vert)
255 box.X1 = pad->Point1.X - pad->Thickness / 2;
256 box.Y1 = MAX (pad->Point1.Y, pad->Point2.Y) + pad->Thickness / 2;
257 box.X1 += Settings.PinoutTextOffsetY;
258 box.Y1 -= Settings.PinoutTextOffsetX;
260 else
262 box.X1 = MIN (pad->Point1.X, pad->Point2.X) - pad->Thickness / 2;
263 box.Y1 = pad->Point1.Y - pad->Thickness / 2;
264 box.X1 += Settings.PinoutTextOffsetX;
265 box.Y1 += Settings.PinoutTextOffsetY;
268 gui->graphics->set_color (Output.fgGC, PCB->PinNameColor);
270 text.Flags = NoFlags ();
271 /* Set font height to approx 90% of pin thickness */
272 text.Scale = 90 * pad->Thickness / FONT_CAPHEIGHT;
273 text.X = box.X1;
274 text.Y = box.Y1;
275 text.Direction = vert ? 1 : 0;
277 gui->graphics->draw_pcb_text (Output.fgGC, &text, 0);
280 static void
281 _draw_pad (hidGC gc, PadType *pad, bool clear, bool mask)
283 if (clear && !mask && pad->Clearance <= 0)
284 return;
286 if (TEST_FLAG (THINDRAWFLAG, PCB) ||
287 (clear && TEST_FLAG (THINDRAWPOLYFLAG, PCB)))
288 gui->graphics->thindraw_pcb_pad (gc, pad, clear, mask);
289 else
290 gui->graphics->fill_pcb_pad (gc, pad, clear, mask);
293 static void
294 draw_pad (PadType *pad)
296 if (doing_pinout)
297 gui->graphics->set_color (Output.fgGC, PCB->PinColor);
298 else
299 set_object_color ((AnyObjectType *)pad, PCB->WarnColor,
300 PCB->PinSelectedColor, PCB->ConnectedColor,
301 FRONT (pad) ? PCB->PinColor : PCB->InvisibleObjectsColor);
303 _draw_pad (Output.fgGC, pad, false, false);
305 if (doing_pinout || TEST_FLAG (DISPLAYNAMEFLAG, pad))
306 draw_pad_name (pad);
309 static int
310 pad_callback (const BoxType * b, void *cl)
312 PadType *pad = (PadType *) b;
313 int *side = cl;
315 if (ON_SIDE (pad, *side))
316 draw_pad (pad);
317 return 1;
320 static void
321 draw_element_name (ElementType *element)
323 if ((TEST_FLAG (HIDENAMESFLAG, PCB) && gui->gui) ||
324 TEST_FLAG (HIDENAMEFLAG, element))
325 return;
326 if (doing_pinout || doing_assy)
327 gui->graphics->set_color (Output.fgGC, PCB->ElementColor);
328 else if (TEST_FLAG (SELECTEDFLAG, &ELEMENT_TEXT (PCB, element)))
329 gui->graphics->set_color (Output.fgGC, PCB->ElementSelectedColor);
330 else if (FRONT (element))
331 gui->graphics->set_color (Output.fgGC, PCB->ElementColor);
332 else
333 gui->graphics->set_color (Output.fgGC, PCB->InvisibleObjectsColor);
334 gui->graphics->draw_pcb_text (Output.fgGC, &ELEMENT_TEXT (PCB, element), PCB->minSlk);
337 static int
338 name_callback (const BoxType * b, void *cl)
340 TextType *text = (TextType *) b;
341 ElementType *element = (ElementType *) text->Element;
342 int *side = cl;
344 if (TEST_FLAG (HIDENAMEFLAG, element))
345 return 0;
347 if (ON_SIDE (element, *side))
348 draw_element_name (element);
349 return 0;
352 static void
353 draw_element_pins_and_pads (ElementType *element)
355 PAD_LOOP (element);
357 if (doing_pinout || doing_assy || FRONT (pad) || PCB->InvisibleObjectsOn)
358 draw_pad (pad);
360 END_LOOP;
361 PIN_LOOP (element);
363 draw_pin (pin, true);
365 END_LOOP;
368 static int
369 EMark_callback (const BoxType * b, void *cl)
371 ElementType *element = (ElementType *) b;
373 DrawEMark (element, element->MarkX, element->MarkY, !FRONT (element));
374 return 1;
377 static int
378 hole_callback (const BoxType * b, void *cl)
380 PinType *pv = (PinType *) b;
381 int plated = cl ? *(int *) cl : -1;
383 if ((plated == 0 && !TEST_FLAG (HOLEFLAG, pv)) ||
384 (plated == 1 && TEST_FLAG (HOLEFLAG, pv)))
385 return 1;
387 if (TEST_FLAG (THINDRAWFLAG, PCB))
389 if (!TEST_FLAG (HOLEFLAG, pv))
391 gui->graphics->set_line_cap (Output.fgGC, Round_Cap);
392 gui->graphics->set_line_width (Output.fgGC, 0);
393 gui->graphics->draw_arc (Output.fgGC,
394 pv->X, pv->Y, pv->DrillingHole / 2,
395 pv->DrillingHole / 2, 0, 360);
398 else
399 gui->graphics->fill_circle (Output.bgGC, pv->X, pv->Y, pv->DrillingHole / 2);
401 if (TEST_FLAG (HOLEFLAG, pv))
403 set_object_color ((AnyObjectType *) pv,
404 PCB->WarnColor, PCB->ViaSelectedColor,
405 NULL, Settings.BlackColor);
407 gui->graphics->set_line_cap (Output.fgGC, Round_Cap);
408 gui->graphics->set_line_width (Output.fgGC, 0);
409 gui->graphics->draw_arc (Output.fgGC,
410 pv->X, pv->Y, pv->DrillingHole / 2,
411 pv->DrillingHole / 2, 0, 360);
413 return 1;
416 void
417 DrawHoles (bool draw_plated, bool draw_unplated, const BoxType *drawn_area)
419 int plated = -1;
421 if ( draw_plated && !draw_unplated) plated = 1;
422 if (!draw_plated && draw_unplated) plated = 0;
424 r_search (PCB->Data->pin_tree, drawn_area, NULL, hole_callback, &plated);
425 r_search (PCB->Data->via_tree, drawn_area, NULL, hole_callback, &plated);
428 static int
429 line_callback (const BoxType * b, void *cl)
431 LayerType *layer = (LayerType *) cl;
432 LineType *line = (LineType *) b;
434 set_layer_object_color (layer, (AnyObjectType *) line);
435 gui->graphics->draw_pcb_line (Output.fgGC, line);
437 return 1;
440 static int
441 rat_callback (const BoxType * b, void *cl)
443 RatType *rat = (RatType *)b;
445 set_object_color ((AnyObjectType *) rat, NULL, PCB->RatSelectedColor,
446 PCB->ConnectedColor, PCB->RatColor);
448 if (Settings.RatThickness < 100)
449 rat->Thickness = pixel_slop * Settings.RatThickness;
450 /* rats.c set VIAFLAG if this rat goes to a containing poly: draw a donut */
451 if (TEST_FLAG(VIAFLAG, rat))
453 int w = rat->Thickness;
455 if (TEST_FLAG (THINDRAWFLAG, PCB))
456 gui->graphics->set_line_width (Output.fgGC, 0);
457 else
458 gui->graphics->set_line_width (Output.fgGC, w);
459 gui->graphics->draw_arc (Output.fgGC, rat->Point1.X, rat->Point1.Y,
460 w * 2, w * 2, 0, 360);
462 else
463 gui->graphics->draw_pcb_line (Output.fgGC, (LineType *) rat);
464 return 1;
467 static int
468 arc_callback (const BoxType * b, void *cl)
470 LayerType *layer = (LayerType *) cl;
471 ArcType *arc = (ArcType *) b;
473 set_layer_object_color (layer, (AnyObjectType *) arc);
474 gui->graphics->draw_pcb_arc (Output.fgGC, arc);
476 return 1;
479 static void
480 draw_element_package (ElementType *element)
482 /* set color and draw lines, arcs, text and pins */
483 if (doing_pinout || doing_assy)
484 gui->graphics->set_color (Output.fgGC, PCB->ElementColor);
485 else if (TEST_FLAG (SELECTEDFLAG, element))
486 gui->graphics->set_color (Output.fgGC, PCB->ElementSelectedColor);
487 else if (FRONT (element))
488 gui->graphics->set_color (Output.fgGC, PCB->ElementColor);
489 else
490 gui->graphics->set_color (Output.fgGC, PCB->InvisibleObjectsColor);
492 /* draw lines, arcs, text and pins */
493 ELEMENTLINE_LOOP (element);
495 gui->graphics->draw_pcb_line (Output.fgGC, line);
497 END_LOOP;
498 ARC_LOOP (element);
500 gui->graphics->draw_pcb_arc (Output.fgGC, arc);
502 END_LOOP;
505 static int
506 element_callback (const BoxType * b, void *cl)
508 ElementType *element = (ElementType *) b;
509 int *side = cl;
511 if (ON_SIDE (element, *side))
512 draw_element_package (element);
513 return 1;
516 /* ---------------------------------------------------------------------------
517 * prints assembly drawing.
520 void
521 PrintAssembly (int side, const BoxType * drawn_area)
523 int side_group = GetLayerGroupNumberByNumber (max_copper_layer + side);
525 doing_assy = true;
526 gui->graphics->set_draw_faded (Output.fgGC, 1);
527 DrawLayerGroup (side_group, drawn_area);
528 gui->graphics->set_draw_faded (Output.fgGC, 0);
530 /* draw package */
531 DrawSilk (side, drawn_area);
532 doing_assy = false;
535 /* ---------------------------------------------------------------------------
536 * initializes some identifiers for a new zoom factor and redraws whole screen
538 static void
539 DrawEverything (const BoxType *drawn_area)
541 int i, ngroups, side;
542 int component, solder;
543 /* This is the list of layer groups we will draw. */
544 int do_group[MAX_LAYER];
545 /* This is the reverse of the order in which we draw them. */
546 int drawn_groups[MAX_LAYER];
547 int plated, unplated;
548 bool paste_empty;
550 PCB->Data->SILKLAYER.Color = PCB->ElementColor;
551 PCB->Data->BACKSILKLAYER.Color = PCB->InvisibleObjectsColor;
553 memset (do_group, 0, sizeof (do_group));
554 for (ngroups = 0, i = 0; i < max_copper_layer; i++)
556 LayerType *l = LAYER_ON_STACK (i);
557 int group = GetLayerGroupNumberByNumber (LayerStack[i]);
558 if (l->On && !do_group[group])
560 do_group[group] = 1;
561 drawn_groups[ngroups++] = group;
565 component = GetLayerGroupNumberByNumber (component_silk_layer);
566 solder = GetLayerGroupNumberByNumber (solder_silk_layer);
569 * first draw all 'invisible' stuff
571 if (!TEST_FLAG (CHECKPLANESFLAG, PCB)
572 && gui->set_layer ("invisible", SL (INVISIBLE, 0), 0))
574 side = SWAP_IDENT ? COMPONENT_LAYER : SOLDER_LAYER;
575 if (PCB->ElementOn)
577 r_search (PCB->Data->element_tree, drawn_area, NULL, element_callback, &side);
578 r_search (PCB->Data->name_tree[NAME_INDEX (PCB)], drawn_area, NULL, name_callback, &side);
579 DrawLayer (&(PCB->Data->Layer[max_copper_layer + side]), drawn_area);
581 r_search (PCB->Data->pad_tree, drawn_area, NULL, pad_callback, &side);
582 gui->end_layer ();
585 /* draw all layers in layerstack order */
586 for (i = ngroups - 1; i >= 0; i--)
588 int group = drawn_groups[i];
590 if (gui->set_layer (0, group, 0))
592 DrawLayerGroup (group, drawn_area);
593 gui->end_layer ();
597 if (TEST_FLAG (CHECKPLANESFLAG, PCB) && gui->gui)
598 return;
600 /* Draw pins, pads, vias below silk */
601 if (gui->gui)
602 DrawPPV (SWAP_IDENT ? solder : component, drawn_area);
603 else
605 CountHoles (&plated, &unplated, drawn_area);
607 if (plated && gui->set_layer ("plated-drill", SL (PDRILL, 0), 0))
609 DrawHoles (true, false, drawn_area);
610 gui->end_layer ();
613 if (unplated && gui->set_layer ("unplated-drill", SL (UDRILL, 0), 0))
615 DrawHoles (false, true, drawn_area);
616 gui->end_layer ();
620 /* Draw the solder mask if turned on */
621 if (gui->set_layer ("componentmask", SL (MASK, TOP), 0))
623 DrawMask (COMPONENT_LAYER, drawn_area);
624 gui->end_layer ();
627 if (gui->set_layer ("soldermask", SL (MASK, BOTTOM), 0))
629 DrawMask (SOLDER_LAYER, drawn_area);
630 gui->end_layer ();
633 if (gui->set_layer ("topsilk", SL (SILK, TOP), 0))
635 DrawSilk (COMPONENT_LAYER, drawn_area);
636 gui->end_layer ();
639 if (gui->set_layer ("bottomsilk", SL (SILK, BOTTOM), 0))
641 DrawSilk (SOLDER_LAYER, drawn_area);
642 gui->end_layer ();
645 if (gui->gui)
647 /* Draw element Marks */
648 if (PCB->PinOn)
649 r_search (PCB->Data->element_tree, drawn_area, NULL, EMark_callback,
650 NULL);
651 /* Draw rat lines on top */
652 if (gui->set_layer ("rats", SL (RATS, 0), 0))
654 DrawRats(drawn_area);
655 gui->end_layer ();
659 paste_empty = IsPasteEmpty (COMPONENT_LAYER);
660 if (gui->set_layer ("toppaste", SL (PASTE, TOP), paste_empty))
662 DrawPaste (COMPONENT_LAYER, drawn_area);
663 gui->end_layer ();
666 paste_empty = IsPasteEmpty (SOLDER_LAYER);
667 if (gui->set_layer ("bottompaste", SL (PASTE, BOTTOM), paste_empty))
669 DrawPaste (SOLDER_LAYER, drawn_area);
670 gui->end_layer ();
673 if (gui->set_layer ("topassembly", SL (ASSY, TOP), 0))
675 PrintAssembly (COMPONENT_LAYER, drawn_area);
676 gui->end_layer ();
679 if (gui->set_layer ("bottomassembly", SL (ASSY, BOTTOM), 0))
681 PrintAssembly (SOLDER_LAYER, drawn_area);
682 gui->end_layer ();
685 if (gui->set_layer ("fab", SL (FAB, 0), 0))
687 PrintFab (Output.fgGC);
688 gui->end_layer ();
692 static void
693 DrawEMark (ElementType *e, Coord X, Coord Y, bool invisible)
695 Coord mark_size = EMARK_SIZE;
696 if (!PCB->InvisibleObjectsOn && invisible)
697 return;
699 if (e->Pin != NULL)
701 PinType *pin0 = e->Pin->data;
702 if (TEST_FLAG (HOLEFLAG, pin0))
703 mark_size = MIN (mark_size, pin0->DrillingHole / 2);
704 else
705 mark_size = MIN (mark_size, pin0->Thickness / 2);
708 if (e->Pad != NULL)
710 PadType *pad0 = e->Pad->data;
711 mark_size = MIN (mark_size, pad0->Thickness / 2);
714 gui->graphics->set_color (Output.fgGC,
715 invisible ? PCB->InvisibleMarkColor : PCB->ElementColor);
716 gui->graphics->set_line_cap (Output.fgGC, Trace_Cap);
717 gui->graphics->set_line_width (Output.fgGC, 0);
718 gui->graphics->draw_line (Output.fgGC, X - mark_size, Y, X, Y - mark_size);
719 gui->graphics->draw_line (Output.fgGC, X + mark_size, Y, X, Y - mark_size);
720 gui->graphics->draw_line (Output.fgGC, X - mark_size, Y, X, Y + mark_size);
721 gui->graphics->draw_line (Output.fgGC, X + mark_size, Y, X, Y + mark_size);
724 * If an element is locked, place a "L" on top of the "diamond".
725 * This provides a nice visual indication that it is locked that
726 * works even for color blind users.
728 if (TEST_FLAG (LOCKFLAG, e) )
730 gui->graphics->draw_line (Output.fgGC, X, Y, X + 2 * mark_size, Y);
731 gui->graphics->draw_line (Output.fgGC, X, Y, X, Y - 4* mark_size);
735 /* ---------------------------------------------------------------------------
736 * Draws pins pads and vias - Always draws for non-gui HIDs,
737 * otherwise drawing depends on PCB->PinOn and PCB->ViaOn
739 static void
740 DrawPPV (int group, const BoxType *drawn_area)
742 int component_group = GetLayerGroupNumberByNumber (component_silk_layer);
743 int solder_group = GetLayerGroupNumberByNumber (solder_silk_layer);
744 int side;
746 if (PCB->PinOn || !gui->gui)
748 /* draw element pins */
749 r_search (PCB->Data->pin_tree, drawn_area, NULL, pin_callback, NULL);
751 /* draw element pads */
752 if (group == component_group)
754 side = COMPONENT_LAYER;
755 r_search (PCB->Data->pad_tree, drawn_area, NULL, pad_callback, &side);
758 if (group == solder_group)
760 side = SOLDER_LAYER;
761 r_search (PCB->Data->pad_tree, drawn_area, NULL, pad_callback, &side);
765 /* draw vias */
766 if (PCB->ViaOn || !gui->gui)
768 r_search (PCB->Data->via_tree, drawn_area, NULL, via_callback, NULL);
769 r_search (PCB->Data->via_tree, drawn_area, NULL, hole_callback, NULL);
771 if (PCB->PinOn || doing_assy)
772 r_search (PCB->Data->pin_tree, drawn_area, NULL, hole_callback, NULL);
775 static int
776 clearPin_callback (const BoxType * b, void *cl)
778 PinType *pin = (PinType *) b;
779 if (TEST_FLAG (THINDRAWFLAG, PCB) || TEST_FLAG (THINDRAWPOLYFLAG, PCB))
780 gui->graphics->thindraw_pcb_pv (Output.pmGC, Output.pmGC, pin, false, true);
781 else
782 gui->graphics->fill_pcb_pv (Output.pmGC, Output.pmGC, pin, false, true);
783 return 1;
786 struct poly_info {
787 const BoxType *drawn_area;
788 LayerType *layer;
791 static int
792 poly_callback (const BoxType * b, void *cl)
794 struct poly_info *i = cl;
795 PolygonType *polygon = (PolygonType *)b;
797 if (!polygon->Clipped)
798 return 0;
800 set_layer_object_color (i->layer, (AnyObjectType *) polygon);
802 if (gui->graphics->thindraw_pcb_polygon != NULL &&
803 (TEST_FLAG (THINDRAWFLAG, PCB) ||
804 TEST_FLAG (THINDRAWPOLYFLAG, PCB)))
805 gui->graphics->thindraw_pcb_polygon (Output.fgGC, polygon, i->drawn_area);
806 else
807 gui->graphics->fill_pcb_polygon (Output.fgGC, polygon, i->drawn_area);
809 /* If checking planes, thin-draw any pieces which have been clipped away */
810 if (gui->graphics->thindraw_pcb_polygon != NULL &&
811 TEST_FLAG (CHECKPLANESFLAG, PCB) &&
812 !TEST_FLAG (FULLPOLYFLAG, polygon))
814 PolygonType poly = *polygon;
816 for (poly.Clipped = polygon->Clipped->f;
817 poly.Clipped != polygon->Clipped;
818 poly.Clipped = poly.Clipped->f)
819 gui->graphics->thindraw_pcb_polygon (Output.fgGC, &poly, i->drawn_area);
822 return 1;
825 static int
826 clearPad_callback (const BoxType * b, void *cl)
828 PadType *pad = (PadType *) b;
829 int *side = cl;
830 if (ON_SIDE (pad, *side) && pad->Mask)
831 _draw_pad (Output.pmGC, pad, true, true);
832 return 1;
835 /* ---------------------------------------------------------------------------
836 * Draws silk layer.
839 void
840 DrawSilk (int side, const BoxType * drawn_area)
842 #if 0
843 /* This code is used when you want to mask silk to avoid exposed
844 pins and pads. We decided it was a bad idea to do this
845 unconditionally, but the code remains. */
846 #endif
848 #if 0
849 if (gui->poly_before)
851 gui->graphics->use_mask (HID_MASK_BEFORE);
852 #endif
853 DrawLayer (LAYER_PTR (max_copper_layer + side), drawn_area);
854 /* draw package */
855 r_search (PCB->Data->element_tree, drawn_area, NULL, element_callback, &side);
856 r_search (PCB->Data->name_tree[NAME_INDEX (PCB)], drawn_area, NULL, name_callback, &side);
857 #if 0
860 gui->graphics->use_mask (HID_MASK_CLEAR);
861 r_search (PCB->Data->pin_tree, drawn_area, NULL, clearPin_callback, NULL);
862 r_search (PCB->Data->via_tree, drawn_area, NULL, clearPin_callback, NULL);
863 r_search (PCB->Data->pad_tree, drawn_area, NULL, clearPad_callback, &side);
865 if (gui->poly_after)
867 gui->graphics->use_mask (HID_MASK_AFTER);
868 DrawLayer (LAYER_PTR (max_copper_layer + layer), drawn_area);
869 /* draw package */
870 r_search (PCB->Data->element_tree, drawn_area, NULL, element_callback, &side);
871 r_search (PCB->Data->name_tree[NAME_INDEX (PCB)], drawn_area, NULL, name_callback, &side);
873 gui->graphics->use_mask (HID_MASK_OFF);
874 #endif
878 static void
879 DrawMaskBoardArea (int mask_type, const BoxType *drawn_area)
881 /* Skip the mask drawing if the GUI doesn't want this type */
882 if ((mask_type == HID_MASK_BEFORE && !gui->poly_before) ||
883 (mask_type == HID_MASK_AFTER && !gui->poly_after))
884 return;
886 gui->graphics->use_mask (mask_type);
887 gui->graphics->set_color (Output.fgGC, PCB->MaskColor);
888 if (drawn_area == NULL)
889 gui->graphics->fill_rect (Output.fgGC, 0, 0, PCB->MaxWidth, PCB->MaxHeight);
890 else
891 gui->graphics->fill_rect (Output.fgGC, drawn_area->X1, drawn_area->Y1,
892 drawn_area->X2, drawn_area->Y2);
895 /* ---------------------------------------------------------------------------
896 * draws solder mask layer - this will cover nearly everything
898 void
899 DrawMask (int side, const BoxType *screen)
901 int thin = TEST_FLAG(THINDRAWFLAG, PCB) || TEST_FLAG(THINDRAWPOLYFLAG, PCB);
903 if (thin)
904 gui->graphics->set_color (Output.pmGC, PCB->MaskColor);
905 else
907 DrawMaskBoardArea (HID_MASK_BEFORE, screen);
908 gui->graphics->use_mask (HID_MASK_CLEAR);
911 r_search (PCB->Data->pin_tree, screen, NULL, clearPin_callback, NULL);
912 r_search (PCB->Data->via_tree, screen, NULL, clearPin_callback, NULL);
913 r_search (PCB->Data->pad_tree, screen, NULL, clearPad_callback, &side);
915 if (thin)
916 gui->graphics->set_color (Output.pmGC, "erase");
917 else
919 DrawMaskBoardArea (HID_MASK_AFTER, screen);
920 gui->graphics->use_mask (HID_MASK_OFF);
924 /* ---------------------------------------------------------------------------
925 * draws solder paste layer for a given side of the board
927 void
928 DrawPaste (int side, const BoxType *drawn_area)
930 gui->graphics->set_color (Output.fgGC, PCB->ElementColor);
931 ALLPAD_LOOP (PCB->Data);
933 if (ON_SIDE (pad, side) && !TEST_FLAG (NOPASTEFLAG, pad) && pad->Mask > 0)
935 if (pad->Mask < pad->Thickness)
936 _draw_pad (Output.fgGC, pad, true, true);
937 else
938 _draw_pad (Output.fgGC, pad, false, false);
941 ENDALL_LOOP;
944 static void
945 DrawRats (const BoxType *drawn_area)
948 * XXX lesstif allows positive AND negative drawing in HID_MASK_CLEAR.
949 * XXX gtk only allows negative drawing.
950 * XXX using the mask here is to get rat transparency
952 int can_mask = strcmp(gui->name, "lesstif") == 0;
954 if (can_mask)
955 gui->graphics->use_mask (HID_MASK_CLEAR);
956 r_search (PCB->Data->rat_tree, drawn_area, NULL, rat_callback, NULL);
957 if (can_mask)
958 gui->graphics->use_mask (HID_MASK_OFF);
961 static int
962 text_callback (const BoxType * b, void *cl)
964 LayerType *layer = cl;
965 TextType *text = (TextType *)b;
966 int min_silk_line;
968 if (TEST_FLAG (SELECTEDFLAG, text))
969 gui->graphics->set_color (Output.fgGC, layer->SelectedColor);
970 else
971 gui->graphics->set_color (Output.fgGC, layer->Color);
972 if (layer == &PCB->Data->SILKLAYER ||
973 layer == &PCB->Data->BACKSILKLAYER)
974 min_silk_line = PCB->minSlk;
975 else
976 min_silk_line = PCB->minWid;
977 gui->graphics->draw_pcb_text (Output.fgGC, text, min_silk_line);
978 return 1;
981 void
982 DrawLayer (LayerType *Layer, const BoxType *screen)
984 struct poly_info info = {screen, Layer};
986 /* print the non-clearing polys */
987 r_search (Layer->polygon_tree, screen, NULL, poly_callback, &info);
989 if (TEST_FLAG (CHECKPLANESFLAG, PCB))
990 return;
992 /* draw all visible lines this layer */
993 r_search (Layer->line_tree, screen, NULL, line_callback, Layer);
995 /* draw the layer arcs on screen */
996 r_search (Layer->arc_tree, screen, NULL, arc_callback, Layer);
998 /* draw the layer text on screen */
999 r_search (Layer->text_tree, screen, NULL, text_callback, Layer);
1001 /* We should check for gui->gui here, but it's kinda cool seeing the
1002 auto-outline magically disappear when you first add something to
1003 the "outline" layer. */
1004 if (IsLayerEmpty (Layer)
1005 && (strcmp (Layer->Name, "outline") == 0
1006 || strcmp (Layer->Name, "route") == 0))
1008 gui->graphics->set_color (Output.fgGC, Layer->Color);
1009 gui->graphics->set_line_width (Output.fgGC, PCB->minWid);
1010 gui->graphics->draw_rect (Output.fgGC,
1011 0, 0,
1012 PCB->MaxWidth, PCB->MaxHeight);
1016 /* ---------------------------------------------------------------------------
1017 * draws one layer group. If the exporter is not a GUI,
1018 * also draws the pins / pads / vias in this layer group.
1020 void
1021 DrawLayerGroup (int group, const BoxType *drawn_area)
1023 int i, rv = 1;
1024 int layernum;
1025 LayerType *Layer;
1026 int n_entries = PCB->LayerGroups.Number[group];
1027 Cardinal *layers = PCB->LayerGroups.Entries[group];
1029 for (i = n_entries - 1; i >= 0; i--)
1031 layernum = layers[i];
1032 Layer = PCB->Data->Layer + layers[i];
1033 if (strcmp (Layer->Name, "outline") == 0 ||
1034 strcmp (Layer->Name, "route") == 0)
1035 rv = 0;
1036 if (layernum < max_copper_layer && Layer->On)
1037 DrawLayer (Layer, drawn_area);
1039 if (n_entries > 1)
1040 rv = 1;
1042 if (rv && !gui->gui)
1043 DrawPPV (group, drawn_area);
1046 static void
1047 GatherPVName (PinType *Ptr)
1049 BoxType box;
1050 bool vert = TEST_FLAG (EDGE2FLAG, Ptr);
1052 if (vert)
1054 box.X1 = Ptr->X - Ptr->Thickness / 2 + Settings.PinoutTextOffsetY;
1055 box.Y1 = Ptr->Y - Ptr->DrillingHole / 2 - Settings.PinoutTextOffsetX;
1057 else
1059 box.X1 = Ptr->X + Ptr->DrillingHole / 2 + Settings.PinoutTextOffsetX;
1060 box.Y1 = Ptr->Y - Ptr->Thickness / 2 + Settings.PinoutTextOffsetY;
1063 if (vert)
1065 box.X2 = box.X1;
1066 box.Y2 = box.Y1;
1068 else
1070 box.X2 = box.X1;
1071 box.Y2 = box.Y1;
1073 AddPart (&box);
1076 static void
1077 GatherPadName (PadType *Pad)
1079 BoxType box;
1080 bool vert;
1082 /* should text be vertical ? */
1083 vert = (Pad->Point1.X == Pad->Point2.X);
1085 if (vert)
1087 box.X1 = Pad->Point1.X - Pad->Thickness / 2;
1088 box.Y1 = MAX (Pad->Point1.Y, Pad->Point2.Y) + Pad->Thickness / 2;
1089 box.X1 += Settings.PinoutTextOffsetY;
1090 box.Y1 -= Settings.PinoutTextOffsetX;
1091 box.X2 = box.X1;
1092 box.Y2 = box.Y1;
1094 else
1096 box.X1 = MIN (Pad->Point1.X, Pad->Point2.X) - Pad->Thickness / 2;
1097 box.Y1 = Pad->Point1.Y - Pad->Thickness / 2;
1098 box.X1 += Settings.PinoutTextOffsetX;
1099 box.Y1 += Settings.PinoutTextOffsetY;
1100 box.X2 = box.X1;
1101 box.Y2 = box.Y1;
1104 AddPart (&box);
1105 return;
1108 /* ---------------------------------------------------------------------------
1109 * draw a via object
1111 void
1112 DrawVia (PinType *Via)
1114 AddPart (Via);
1115 if (!TEST_FLAG (HOLEFLAG, Via) && TEST_FLAG (DISPLAYNAMEFLAG, Via))
1116 DrawViaName (Via);
1119 /* ---------------------------------------------------------------------------
1120 * draws the name of a via
1122 void
1123 DrawViaName (PinType *Via)
1125 GatherPVName (Via);
1128 /* ---------------------------------------------------------------------------
1129 * draw a pin object
1131 void
1132 DrawPin (PinType *Pin)
1134 AddPart (Pin);
1135 if ((!TEST_FLAG (HOLEFLAG, Pin) && TEST_FLAG (DISPLAYNAMEFLAG, Pin))
1136 || doing_pinout)
1137 DrawPinName (Pin);
1140 /* ---------------------------------------------------------------------------
1141 * draws the name of a pin
1143 void
1144 DrawPinName (PinType *Pin)
1146 GatherPVName (Pin);
1149 /* ---------------------------------------------------------------------------
1150 * draw a pad object
1152 void
1153 DrawPad (PadType *Pad)
1155 AddPart (Pad);
1156 if (doing_pinout || TEST_FLAG (DISPLAYNAMEFLAG, Pad))
1157 DrawPadName (Pad);
1160 /* ---------------------------------------------------------------------------
1161 * draws the name of a pad
1163 void
1164 DrawPadName (PadType *Pad)
1166 GatherPadName (Pad);
1169 /* ---------------------------------------------------------------------------
1170 * draws a line on a layer
1172 void
1173 DrawLine (LayerType *Layer, LineType *Line)
1175 AddPart (Line);
1178 /* ---------------------------------------------------------------------------
1179 * draws a ratline
1181 void
1182 DrawRat (RatType *Rat)
1184 if (Settings.RatThickness < 100)
1185 Rat->Thickness = pixel_slop * Settings.RatThickness;
1186 /* rats.c set VIAFLAG if this rat goes to a containing poly: draw a donut */
1187 if (TEST_FLAG(VIAFLAG, Rat))
1189 Coord w = Rat->Thickness;
1191 BoxType b;
1193 b.X1 = Rat->Point1.X - w * 2 - w / 2;
1194 b.X2 = Rat->Point1.X + w * 2 + w / 2;
1195 b.Y1 = Rat->Point1.Y - w * 2 - w / 2;
1196 b.Y2 = Rat->Point1.Y + w * 2 + w / 2;
1197 AddPart (&b);
1199 else
1200 DrawLine (NULL, (LineType *)Rat);
1203 /* ---------------------------------------------------------------------------
1204 * draws an arc on a layer
1206 void
1207 DrawArc (LayerType *Layer, ArcType *Arc)
1209 AddPart (Arc);
1212 /* ---------------------------------------------------------------------------
1213 * draws a text on a layer
1215 void
1216 DrawText (LayerType *Layer, TextType *Text)
1218 AddPart (Text);
1222 /* ---------------------------------------------------------------------------
1223 * draws a polygon on a layer
1225 void
1226 DrawPolygon (LayerType *Layer, PolygonType *Polygon)
1228 AddPart (Polygon);
1231 /* ---------------------------------------------------------------------------
1232 * draws an element
1234 void
1235 DrawElement (ElementType *Element)
1237 DrawElementPackage (Element);
1238 DrawElementName (Element);
1239 DrawElementPinsAndPads (Element);
1242 /* ---------------------------------------------------------------------------
1243 * draws the name of an element
1245 void
1246 DrawElementName (ElementType *Element)
1248 if (TEST_FLAG (HIDENAMEFLAG, Element))
1249 return;
1250 DrawText (NULL, &ELEMENT_TEXT (PCB, Element));
1253 /* ---------------------------------------------------------------------------
1254 * draws the package of an element
1256 void
1257 DrawElementPackage (ElementType *Element)
1259 ELEMENTLINE_LOOP (Element);
1261 DrawLine (NULL, line);
1263 END_LOOP;
1264 ARC_LOOP (Element);
1266 DrawArc (NULL, arc);
1268 END_LOOP;
1271 /* ---------------------------------------------------------------------------
1272 * draw pins of an element
1274 void
1275 DrawElementPinsAndPads (ElementType *Element)
1277 PAD_LOOP (Element);
1279 if (doing_pinout || doing_assy || FRONT (pad) || PCB->InvisibleObjectsOn)
1280 DrawPad (pad);
1282 END_LOOP;
1283 PIN_LOOP (Element);
1285 DrawPin (pin);
1287 END_LOOP;
1290 /* ---------------------------------------------------------------------------
1291 * erase a via
1293 void
1294 EraseVia (PinType *Via)
1296 AddPart (Via);
1297 if (TEST_FLAG (DISPLAYNAMEFLAG, Via))
1298 EraseViaName (Via);
1301 /* ---------------------------------------------------------------------------
1302 * erase a ratline
1304 void
1305 EraseRat (RatType *Rat)
1307 if (TEST_FLAG(VIAFLAG, Rat))
1309 Coord w = Rat->Thickness;
1311 BoxType b;
1313 b.X1 = Rat->Point1.X - w * 2 - w / 2;
1314 b.X2 = Rat->Point1.X + w * 2 + w / 2;
1315 b.Y1 = Rat->Point1.Y - w * 2 - w / 2;
1316 b.Y2 = Rat->Point1.Y + w * 2 + w / 2;
1317 AddPart (&b);
1319 else
1320 EraseLine ((LineType *)Rat);
1324 /* ---------------------------------------------------------------------------
1325 * erase a via name
1327 void
1328 EraseViaName (PinType *Via)
1330 GatherPVName (Via);
1333 /* ---------------------------------------------------------------------------
1334 * erase a pad object
1336 void
1337 ErasePad (PadType *Pad)
1339 AddPart (Pad);
1340 if (TEST_FLAG (DISPLAYNAMEFLAG, Pad))
1341 ErasePadName (Pad);
1344 /* ---------------------------------------------------------------------------
1345 * erase a pad name
1347 void
1348 ErasePadName (PadType *Pad)
1350 GatherPadName (Pad);
1353 /* ---------------------------------------------------------------------------
1354 * erase a pin object
1356 void
1357 ErasePin (PinType *Pin)
1359 AddPart (Pin);
1360 if (TEST_FLAG (DISPLAYNAMEFLAG, Pin))
1361 ErasePinName (Pin);
1364 /* ---------------------------------------------------------------------------
1365 * erase a pin name
1367 void
1368 ErasePinName (PinType *Pin)
1370 GatherPVName (Pin);
1373 /* ---------------------------------------------------------------------------
1374 * erases a line on a layer
1376 void
1377 EraseLine (LineType *Line)
1379 AddPart (Line);
1382 /* ---------------------------------------------------------------------------
1383 * erases an arc on a layer
1385 void
1386 EraseArc (ArcType *Arc)
1388 if (!Arc->Thickness)
1389 return;
1390 AddPart (Arc);
1393 /* ---------------------------------------------------------------------------
1394 * erases a text on a layer
1396 void
1397 EraseText (LayerType *Layer, TextType *Text)
1399 AddPart (Text);
1402 /* ---------------------------------------------------------------------------
1403 * erases a polygon on a layer
1405 void
1406 ErasePolygon (PolygonType *Polygon)
1408 AddPart (Polygon);
1411 /* ---------------------------------------------------------------------------
1412 * erases an element
1414 void
1415 EraseElement (ElementType *Element)
1417 ELEMENTLINE_LOOP (Element);
1419 EraseLine (line);
1421 END_LOOP;
1422 ARC_LOOP (Element);
1424 EraseArc (arc);
1426 END_LOOP;
1427 EraseElementName (Element);
1428 EraseElementPinsAndPads (Element);
1431 /* ---------------------------------------------------------------------------
1432 * erases all pins and pads of an element
1434 void
1435 EraseElementPinsAndPads (ElementType *Element)
1437 PIN_LOOP (Element);
1439 ErasePin (pin);
1441 END_LOOP;
1442 PAD_LOOP (Element);
1444 ErasePad (pad);
1446 END_LOOP;
1449 /* ---------------------------------------------------------------------------
1450 * erases the name of an element
1452 void
1453 EraseElementName (ElementType *Element)
1455 if (TEST_FLAG (HIDENAMEFLAG, Element))
1456 return;
1457 DrawText (NULL, &ELEMENT_TEXT (PCB, Element));
1461 void
1462 EraseObject (int type, void *lptr, void *ptr)
1464 switch (type)
1466 case VIA_TYPE:
1467 case PIN_TYPE:
1468 ErasePin ((PinType *) ptr);
1469 break;
1470 case TEXT_TYPE:
1471 case ELEMENTNAME_TYPE:
1472 EraseText ((LayerType *)lptr, (TextType *) ptr);
1473 break;
1474 case POLYGON_TYPE:
1475 ErasePolygon ((PolygonType *) ptr);
1476 break;
1477 case ELEMENT_TYPE:
1478 EraseElement ((ElementType *) ptr);
1479 break;
1480 case LINE_TYPE:
1481 case ELEMENTLINE_TYPE:
1482 case RATLINE_TYPE:
1483 EraseLine ((LineType *) ptr);
1484 break;
1485 case PAD_TYPE:
1486 ErasePad ((PadType *) ptr);
1487 break;
1488 case ARC_TYPE:
1489 case ELEMENTARC_TYPE:
1490 EraseArc ((ArcType *) ptr);
1491 break;
1492 default:
1493 Message ("hace: Internal ERROR, trying to erase an unknown type\n");
1499 void
1500 DrawObject (int type, void *ptr1, void *ptr2)
1502 switch (type)
1504 case VIA_TYPE:
1505 if (PCB->ViaOn)
1506 DrawVia ((PinType *) ptr2);
1507 break;
1508 case LINE_TYPE:
1509 if (((LayerType *) ptr1)->On)
1510 DrawLine ((LayerType *) ptr1, (LineType *) ptr2);
1511 break;
1512 case ARC_TYPE:
1513 if (((LayerType *) ptr1)->On)
1514 DrawArc ((LayerType *) ptr1, (ArcType *) ptr2);
1515 break;
1516 case TEXT_TYPE:
1517 if (((LayerType *) ptr1)->On)
1518 DrawText ((LayerType *) ptr1, (TextType *) ptr2);
1519 break;
1520 case POLYGON_TYPE:
1521 if (((LayerType *) ptr1)->On)
1522 DrawPolygon ((LayerType *) ptr1, (PolygonType *) ptr2);
1523 break;
1524 case ELEMENT_TYPE:
1525 if (PCB->ElementOn &&
1526 (FRONT ((ElementType *) ptr2) || PCB->InvisibleObjectsOn))
1527 DrawElement ((ElementType *) ptr2);
1528 break;
1529 case RATLINE_TYPE:
1530 if (PCB->RatOn)
1531 DrawRat ((RatType *) ptr2);
1532 break;
1533 case PIN_TYPE:
1534 if (PCB->PinOn)
1535 DrawPin ((PinType *) ptr2);
1536 break;
1537 case PAD_TYPE:
1538 if (PCB->PinOn)
1539 DrawPad ((PadType *) ptr2);
1540 break;
1541 case ELEMENTNAME_TYPE:
1542 if (PCB->ElementOn &&
1543 (FRONT ((ElementType *) ptr2) || PCB->InvisibleObjectsOn))
1544 DrawElementName ((ElementType *) ptr1);
1545 break;
1549 static void
1550 draw_element (ElementType *element)
1552 draw_element_package (element);
1553 draw_element_name (element);
1554 draw_element_pins_and_pads (element);
1557 /* ---------------------------------------------------------------------------
1558 * HID drawing callback.
1561 void
1562 hid_expose_callback (HID * hid, BoxType * region, void *item)
1564 HID *old_gui = gui;
1566 gui = hid;
1567 Output.fgGC = gui->graphics->make_gc ();
1568 Output.bgGC = gui->graphics->make_gc ();
1569 Output.pmGC = gui->graphics->make_gc ();
1571 hid->graphics->set_color (Output.pmGC, "erase");
1572 hid->graphics->set_color (Output.bgGC, "drill");
1574 if (item)
1576 doing_pinout = true;
1577 draw_element ((ElementType *)item);
1578 doing_pinout = false;
1580 else
1581 DrawEverything (region);
1583 gui->graphics->destroy_gc (Output.fgGC);
1584 gui->graphics->destroy_gc (Output.bgGC);
1585 gui->graphics->destroy_gc (Output.pmGC);
1586 gui = old_gui;