Index: trunk/src/crosshair.c =================================================================== --- trunk/src/crosshair.c (revision 11027) +++ trunk/src/crosshair.c (revision 11028) @@ -34,6 +34,7 @@ #include "crosshair.h" #include "data.h" #include "draw.h" +#include "draw_wireframe.h" #include "search.h" #include "polygon.h" #include "hid_actions.h" @@ -115,25 +116,6 @@ } /*----------------------------------------------------------- - * Draws the outline of an arc - */ -static void XORDrawArc(pcb_arc_t * arc) -{ - pcb_coord_t wid = arc->Thickness / 2; - pcb_coord_t x1,y1,x2,y2; - - pcb_arc_get_end(arc, 0, &x1, &y1); - pcb_arc_get_end(arc, 1, &x2, &y2); - - pcb_gui->draw_arc(pcb_crosshair.GC, arc->X, arc->Y, arc->Width + wid, arc->Height + wid, arc->StartAngle, arc->Delta); - if (wid > pcb_pixel_slop) { - pcb_gui->draw_arc(pcb_crosshair.GC, arc->X, arc->Y, arc->Width - wid, arc->Height - wid, arc->StartAngle, arc->Delta); - pcb_gui->draw_arc(pcb_crosshair.GC, x1, y1, wid, wid, arc->StartAngle, -180 * SGN(arc->Delta)); - pcb_gui->draw_arc(pcb_crosshair.GC, x2, y2, wid, wid, arc->StartAngle + arc->Delta, 180 * SGN(arc->Delta)); - } -} - -/*----------------------------------------------------------- * Draws the outline of an attached arc */ static void XORDrawAttachedArc(pcb_coord_t thick) @@ -165,34 +147,9 @@ arc.Width = arc.Height = wy; arc.Thickness = thick; - XORDrawArc(&arc); + pcb_draw_wireframe_arc(pcb_crosshair.GC,&arc); } -/*----------------------------------------------------------- - * Draws the outline of a line - */ -void XORDrawAttachedLine(pcb_coord_t x1, pcb_coord_t y1, pcb_coord_t x2, pcb_coord_t y2, pcb_coord_t thick) -{ - pcb_coord_t dx, dy, ox, oy; - double h; - - dx = x2 - x1; - dy = y2 - y1; - if (dx != 0 || dy != 0) - h = 0.5 * thick / sqrt(PCB_SQUARE(dx) + PCB_SQUARE(dy)); - else - h = 0.0; - ox = dy * h + 0.5 * SGN(dy); - oy = -(dx * h + 0.5 * SGN(dx)); - pcb_gui->draw_line(pcb_crosshair.GC, x1 + ox, y1 + oy, x2 + ox, y2 + oy); - if (coord_abs(ox) >= pcb_pixel_slop || coord_abs(oy) >= pcb_pixel_slop) { - pcb_angle_t angle = atan2(dx, dy) * 57.295779; - pcb_gui->draw_line(pcb_crosshair.GC, x1 - ox, y1 - oy, x2 - ox, y2 - oy); - pcb_gui->draw_arc(pcb_crosshair.GC, x1, y1, thick / 2, thick / 2, angle - 180, 180); - pcb_gui->draw_arc(pcb_crosshair.GC, x2, y2, thick / 2, thick / 2, angle, 180); - } -} - /* --------------------------------------------------------------------------- * draws the elements of a loaded circuit which is to be merged in */ @@ -388,15 +345,17 @@ line.Point2.Y += dy; } - XORDrawAttachedLine(line.Point1.X, line.Point1.Y, - line.Point2.X, line.Point2.Y, line.Thickness); + pcb_draw_wireframe_line(pcb_crosshair.GC, + line.Point1.X, line.Point1.Y, + line.Point2.X, line.Point2.Y, + line.Thickness); /* Draw the DRC outline if it is enabled */ if (conf_core.editor.show_drc) { pcb_gui->set_color(pcb_crosshair.GC, conf_core.appearance.color.cross); - XORDrawAttachedLine(line.Point1.X, line.Point1.Y, - line.Point2.X, line.Point2.Y, - line.Thickness + 2 * (PCB->Bloat + 1) ); + pcb_draw_wireframe_line(pcb_crosshair.GC,line.Point1.X, line.Point1.Y, + line.Point2.X, line.Point2.Y, + line.Thickness + 2 * (PCB->Bloat + 1) ); pcb_gui->set_color(pcb_crosshair.GC, conf_core.appearance.color.crosshair); } break; @@ -409,13 +368,13 @@ arc.X += dx; arc.Y += dy; - XORDrawArc(&arc); + pcb_draw_wireframe_arc(pcb_crosshair.GC,&arc); /* Draw the DRC outline if it is enabled */ if (conf_core.editor.show_drc) { pcb_gui->set_color(pcb_crosshair.GC, conf_core.appearance.color.cross); arc.Thickness += 2 * (PCB->Bloat + 1); - XORDrawArc(&arc); + pcb_draw_wireframe_arc(pcb_crosshair.GC,&arc); pcb_gui->set_color(pcb_crosshair.GC, conf_core.appearance.color.crosshair); } break; @@ -445,12 +404,13 @@ point2.Y += dy; if(conf_core.editor.move_linepoint_uses_route == 0) {/* config setting for selecting new 45/90 method */ - XORDrawAttachedLine(point1->X, point1->Y, point2.X, point2.Y, line->Thickness); + pcb_draw_wireframe_line(pcb_crosshair.GC,point1->X, point1->Y, point2.X, point2.Y, line->Thickness); /* Draw the DRC outline if it is enabled */ if (conf_core.editor.show_drc) { pcb_gui->set_color(pcb_crosshair.GC, conf_core.appearance.color.cross); - XORDrawAttachedLine(point1->X, point1->Y, point2.X, point2.Y,line->Thickness + 2 * (PCB->Bloat + 1) ); + pcb_draw_wireframe_line(pcb_crosshair.GC,point1->X, point1->Y, point2.X, + point2.Y,line->Thickness + 2 * (PCB->Bloat + 1) ); pcb_gui->set_color(pcb_crosshair.GC, conf_core.appearance.color.crosshair); } } @@ -829,10 +789,11 @@ { /* draw only if starting point exists and the line has length */ if (pcb_crosshair.AttachedLine.State != PCB_CH_STATE_FIRST && pcb_crosshair.AttachedLine.draw) - XORDrawAttachedLine(pcb_crosshair.AttachedLine.Point1.X, - pcb_crosshair.AttachedLine.Point1.Y, - pcb_crosshair.AttachedLine.Point2.X, - pcb_crosshair.AttachedLine.Point2.Y, 10 ); + pcb_draw_wireframe_line(pcb_crosshair.GC, + pcb_crosshair.AttachedLine.Point1.X, + pcb_crosshair.AttachedLine.Point1.Y, + pcb_crosshair.AttachedLine.Point2.X, + pcb_crosshair.AttachedLine.Point2.Y, 10 ); } else if(pcb_crosshair.Route.size > 0) { Index: trunk/src/draw_wireframe.h =================================================================== --- trunk/src/draw_wireframe.h (nonexistent) +++ trunk/src/draw_wireframe.h (revision 11028) @@ -0,0 +1,82 @@ +/* + * COPYRIGHT + * + * PCB, interactive printed circuit board design + * Copyright (C) 1994,1995,1996 Thomas Nau + * 21 Aug 2017 : Draw functiuons extracted from crosshair.c + * + * 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * Contact addresses for paper mail and Email: + * Thomas Nau, Schlehenweg 15, 88471 Baustetten, Germany + * Thomas.Nau@rz.uni-ulm.de + * + */ +#ifndef PCB_DRAW_WIREFRAME_H +#define PCB_DRAW_WIREFRAME_H + + +#include "config.h" +#include "hid.h" +/*#include "board.h"*/ + +/*----------------------------------------------------------- + * Draws the outline of an arc + */ +static inline PCB_FUNC_UNUSED void +pcb_draw_wireframe_arc(pcb_hid_gc_t gc,pcb_arc_t * arc) +{ + pcb_coord_t wid = arc->Thickness / 2; + pcb_coord_t x1,y1,x2,y2; + + pcb_arc_get_end(arc, 0, &x1, &y1); + pcb_arc_get_end(arc, 1, &x2, &y2); + + pcb_gui->draw_arc(gc, arc->X, arc->Y, arc->Width + wid, arc->Height + wid, arc->StartAngle, arc->Delta); + if (wid > pcb_pixel_slop) { + pcb_gui->draw_arc(gc, arc->X, arc->Y, arc->Width - wid, arc->Height - wid, arc->StartAngle, arc->Delta); + pcb_gui->draw_arc(gc, x1, y1, wid, wid, arc->StartAngle, -180 * SGN(arc->Delta)); + pcb_gui->draw_arc(gc, x2, y2, wid, wid, arc->StartAngle + arc->Delta, 180 * SGN(arc->Delta)); + } +} + +/*----------------------------------------------------------- + * Draws the outline of a line + */ +static inline PCB_FUNC_UNUSED void +pcb_draw_wireframe_line(pcb_hid_gc_t gc,pcb_coord_t x1, pcb_coord_t y1, pcb_coord_t x2, pcb_coord_t y2, pcb_coord_t thick) +{ + pcb_coord_t dx, dy, ox, oy; + double h; + + dx = x2 - x1; + dy = y2 - y1; + if (dx != 0 || dy != 0) + h = 0.5 * thick / sqrt(PCB_SQUARE(dx) + PCB_SQUARE(dy)); + else + h = 0.0; + ox = dy * h + 0.5 * SGN(dy); + oy = -(dx * h + 0.5 * SGN(dx)); + pcb_gui->draw_line(gc, x1 + ox, y1 + oy, x2 + ox, y2 + oy); + if (coord_abs(ox) >= pcb_pixel_slop || coord_abs(oy) >= pcb_pixel_slop) { + pcb_angle_t angle = atan2(dx, dy) * 57.295779; + pcb_gui->draw_line(gc, x1 - ox, y1 - oy, x2 - ox, y2 - oy); + pcb_gui->draw_arc(gc, x1, y1, thick / 2, thick / 2, angle - 180, 180); + pcb_gui->draw_arc(gc, x2, y2, thick / 2, thick / 2, angle, 180); + } +} + +#endif /* ! defined PCB_DRAW_WIREFRAME_H */ + Index: trunk/src_plugins/rubberband_orig/rubberband.c =================================================================== --- trunk/src_plugins/rubberband_orig/rubberband.c (revision 11027) +++ trunk/src_plugins/rubberband_orig/rubberband.c (revision 11028) @@ -42,6 +42,7 @@ #include "operation.h" #include "rotate.h" #include "draw.h" +#include "draw_wireframe.h" #include "crosshair.h" #include "obj_rat_draw.h" #include "obj_line_op.h" @@ -1001,15 +1002,15 @@ if ((x1 != x2) || (y1 != y2)) { if (PCB_FLAG_TEST(PCB_FLAG_RAT, ptr->Line)) { pcb_gui->set_color(pcb_crosshair.GC, conf_core.appearance.color.rat); - XORDrawAttachedLine(x1,y1,x2,y2, ptr->Line->Thickness); + pcb_draw_wireframe_line(pcb_crosshair.GC,x1,y1,x2,y2, ptr->Line->Thickness); } else if(conf_core.editor.move_linepoint_uses_route == 0) { pcb_gui->set_color(pcb_crosshair.GC,ptr->Layer->meta.real.color); - XORDrawAttachedLine(x1,y1,x2,y2, ptr->Line->Thickness); + pcb_draw_wireframe_line(pcb_crosshair.GC,x1,y1,x2,y2, ptr->Line->Thickness); /* Draw the DRC outline if it is enabled */ if (conf_core.editor.show_drc) { pcb_gui->set_color(pcb_crosshair.GC, conf_core.appearance.color.cross); - XORDrawAttachedLine(x1,y1,x2,y2,ptr->Line->Thickness + 2 * (PCB->Bloat + 1) ); + pcb_draw_wireframe_line(pcb_crosshair.GC,x1,y1,x2,y2,ptr->Line->Thickness + 2 * (PCB->Bloat + 1) ); } } else {