Index: trunk/src/crosshair.c =================================================================== --- trunk/src/crosshair.c (revision 12639) +++ trunk/src/crosshair.c (revision 12640) @@ -53,6 +53,14 @@ #include "obj_arc_ui.h" #include "obj_all_op.h" +#include "tool.h" +#include "tool_arc.h" +#include "tool_buffer.h" +#include "tool_line.h" +#include "tool_poly.h" +#include "tool_polyhole.h" +#include "tool_via.h" + typedef struct { int x, y; } point; @@ -65,10 +73,6 @@ * some local prototypes */ static void XORDrawElement(pcb_element_t *, pcb_coord_t, pcb_coord_t); -static void XORDrawBuffer(pcb_buffer_t *); -static void XORDrawInsertPointObject(void); -static void XORDrawAttachedArc(pcb_coord_t); -static void XORDrawPinViaDRCOutline(pcb_pin_t * pv,pcb_coord_t clearance); static void XORDrawPadDRCOutline(pcb_pad_t * pv,pcb_coord_t clearance); static void thindraw_moved_pv(pcb_pin_t * pv, pcb_coord_t x, pcb_coord_t y) @@ -130,7 +134,7 @@ /*----------------------------------------------------------- * Draws the outline of an attached arc */ -static void XORDrawAttachedArc(pcb_coord_t thick) +void XORDrawAttachedArc(pcb_coord_t thick) { pcb_arc_t arc; pcb_coord_t wx, wy; @@ -239,7 +243,7 @@ /* --------------------------------------------------------------------------- * draws all visible and attached objects of the pastebuffer */ -static void XORDrawBuffer(pcb_buffer_t *Buffer) +void XORDrawBuffer(pcb_buffer_t *Buffer) { pcb_cardinal_t i; pcb_coord_t x, y; @@ -321,7 +325,7 @@ /* --------------------------------------------------------------------------- * draws the rubberband to insert points into polygons/lines/... */ -static void XORDrawInsertPointObject(void) +void XORDrawInsertPointObject(void) { pcb_line_t *line = (pcb_line_t *) pcb_crosshair.AttachedObject.Ptr2; pcb_point_t *point = (pcb_point_t *) pcb_crosshair.AttachedObject.Ptr3; @@ -335,7 +339,7 @@ /* --------------------------------------------------------------------------- * draws the attached object while in PCB_MODE_MOVE or PCB_MODE_COPY */ -static void XORDrawMoveOrCopy(void) +void XORDrawMoveOrCopy(void) { pcb_coord_t dx = pcb_crosshair.X - pcb_crosshair.AttachedObject.X; pcb_coord_t dy = pcb_crosshair.Y - pcb_crosshair.AttachedObject.Y; @@ -692,7 +696,7 @@ /* --------------------------------------------------------------------------- * draws the DRC Outline of a pin/via with the given clearance */ -static void +void XORDrawPinViaDRCOutline(pcb_pin_t * pv,pcb_coord_t clearance) { int style = PCB_FLAG_SQUARE_GET(pv); @@ -827,82 +831,39 @@ switch (conf_core.editor.mode) { case PCB_MODE_VIA: { - /* Make a dummy via structure to draw from */ - pcb_pin_t via; - via.X = pcb_crosshair.X; - via.Y = pcb_crosshair.Y; - via.Thickness = conf_core.design.via_thickness; - via.Clearance = 2 * conf_core.design.clearance; - via.DrillingHole = conf_core.design.via_drilling_hole; - via.Mask = 0; - via.Flags = pcb_no_flags(); - - pcb_gui->thindraw_pcb_pv(pcb_crosshair.GC, pcb_crosshair.GC, &via, pcb_true, pcb_false); - - if (conf_core.editor.show_drc) { - /* XXX: Naughty cheat - use the mask to draw DRC clearance! */ - pcb_gui->set_color(pcb_crosshair.GC, conf_core.appearance.color.cross); - XORDrawPinViaDRCOutline(&via,PCB->Bloat); - pcb_gui->set_color(pcb_crosshair.GC, conf_core.appearance.color.crosshair); - } + pcb_tool_via_draw_attached(); } break; /* the attached line is used by both LINEMODE, PCB_MODE_POLYGON and PCB_MODE_POLYGON_HOLE */ case PCB_MODE_POLYGON: + pcb_tool_poly_draw_attached(); + break; case PCB_MODE_POLYGON_HOLE: - /* draw only if starting point is set */ - if (pcb_crosshair.AttachedLine.State != PCB_CH_STATE_FIRST) - pcb_gui->draw_line(pcb_crosshair.GC, - pcb_crosshair.AttachedLine.Point1.X, - pcb_crosshair.AttachedLine.Point1.Y, pcb_crosshair.AttachedLine.Point2.X, pcb_crosshair.AttachedLine.Point2.Y); - - /* draw attached polygon only if in PCB_MODE_POLYGON or PCB_MODE_POLYGON_HOLE */ - if (pcb_crosshair.AttachedPolygon.PointN > 1) { - XORPolygon(&pcb_crosshair.AttachedPolygon, 0, 0, 1); - } + pcb_tool_polyhole_draw_attached(); break; case PCB_MODE_ARC: - if (pcb_crosshair.AttachedBox.State != PCB_CH_STATE_FIRST) { - XORDrawAttachedArc(conf_core.design.line_thickness); - if (conf_core.editor.show_drc) { - pcb_gui->set_color(pcb_crosshair.GC, conf_core.appearance.color.cross); - XORDrawAttachedArc(conf_core.design.line_thickness + 2 * (PCB->Bloat + 1)); - pcb_gui->set_color(pcb_crosshair.GC, conf_core.appearance.color.crosshair); - } - } + pcb_tool_arc_draw_attached(); break; case PCB_MODE_LINE: - if(PCB->RatDraw) { - /* draw only if starting point exists and the line has length */ - if (pcb_crosshair.AttachedLine.State != PCB_CH_STATE_FIRST && pcb_crosshair.AttachedLine.draw) - 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, 0); - } - else if(pcb_crosshair.Route.size > 0) { - pcb_route_draw(&pcb_crosshair.Route,pcb_crosshair.GC); - if(conf_core.editor.show_drc) - pcb_route_draw_drc(&pcb_crosshair.Route,pcb_crosshair.GC); - pcb_gui->set_color(pcb_crosshair.GC, conf_core.appearance.color.crosshair); - } + pcb_tool_line_draw_attached(); break; case PCB_MODE_PASTE_BUFFER: - XORDrawBuffer(PCB_PASTEBUFFER); + pcb_tool_buffer_draw_attached(); break; case PCB_MODE_COPY: + pcb_tool_copy_draw_attached(); + break; case PCB_MODE_MOVE: - XORDrawMoveOrCopy(); + pcb_tool_move_draw_attached(); break; case PCB_MODE_INSERT_POINT: - XORDrawInsertPointObject(); + pcb_tool_insert_draw_attached(); break; } Index: trunk/src/crosshair.h =================================================================== --- trunk/src/crosshair.h (revision 12639) +++ trunk/src/crosshair.h (revision 12640) @@ -128,6 +128,11 @@ /*** utility for plugins ***/ void XORDrawAttachedLine(pcb_coord_t, pcb_coord_t, pcb_coord_t, pcb_coord_t, pcb_coord_t); void XORPolygon(pcb_poly_t *polygon, pcb_coord_t dx, pcb_coord_t dy, int dash_last); +void XORDrawPinViaDRCOutline(pcb_pin_t * pv,pcb_coord_t clearance); +void XORDrawAttachedArc(pcb_coord_t thick); +void XORDrawBuffer(pcb_buffer_t *Buffer); +void XORDrawMoveOrCopy(void); +void XORDrawInsertPointObject(void); Index: trunk/src/tool.c =================================================================== --- trunk/src/tool.c (revision 12639) +++ trunk/src/tool.c (revision 12640) @@ -141,6 +141,11 @@ wrap_void(adjust_attached_objects, ()); } +void pcb_tool_draw_attached(void) +{ + wrap_void(adjust_attached_objects, ()); +} + pcb_bool pcb_tool_undo_act(void) { wrap_retv(undo_act, return pcb_true, ()); Index: trunk/src/tool.h =================================================================== --- trunk/src/tool.h (revision 12639) +++ trunk/src/tool.h (revision 12640) @@ -38,6 +38,7 @@ /* tool implementation */ void (*notify_mode)(void); void (*adjust_attached_objects)(void); + void (*draw_attached)(void); pcb_bool (*undo_act)(void); pcb_bool (*redo_act)(void); } pcb_tool_t; @@ -68,6 +69,7 @@ void pcb_tool_notify_mode(void); void pcb_tool_adjust_attached_objects(void); +void pcb_tool_draw_attached(void); pcb_bool pcb_tool_undo_act(void); pcb_bool pcb_tool_redo_act(void); Index: trunk/src/tool_arc.c =================================================================== --- trunk/src/tool_arc.c (revision 12639) +++ trunk/src/tool_arc.c (revision 12640) @@ -101,6 +101,18 @@ pcb_crosshair.AttachedBox.otherway = pcb_gui->shift_is_pressed(); } +void pcb_tool_arc_draw_attached(void) +{ + if (pcb_crosshair.AttachedBox.State != PCB_CH_STATE_FIRST) { + XORDrawAttachedArc(conf_core.design.line_thickness); + if (conf_core.editor.show_drc) { + pcb_gui->set_color(pcb_crosshair.GC, conf_core.appearance.color.cross); + XORDrawAttachedArc(conf_core.design.line_thickness + 2 * (PCB->Bloat + 1)); + pcb_gui->set_color(pcb_crosshair.GC, conf_core.appearance.color.crosshair); + } + } +} + pcb_bool pcb_tool_arc_undo_act(void) { if (pcb_crosshair.AttachedBox.State == PCB_CH_STATE_SECOND) { @@ -127,6 +139,7 @@ "arc", NULL, 100, pcb_tool_arc_notify_mode, pcb_tool_arc_adjust_attached_objects, + pcb_tool_arc_draw_attached, pcb_tool_arc_undo_act, NULL }; Index: trunk/src/tool_arc.h =================================================================== --- trunk/src/tool_arc.h (revision 12639) +++ trunk/src/tool_arc.h (revision 12640) @@ -2,4 +2,5 @@ void pcb_tool_arc_notify_mode(void); void pcb_tool_arc_adjust_attached_objects(void); +void pcb_tool_arc_draw_attached(void); pcb_bool pcb_tool_arc_undo_act(void); Index: trunk/src/tool_arrow.c =================================================================== --- trunk/src/tool_arrow.c (revision 12639) +++ trunk/src/tool_arrow.c (revision 12640) @@ -150,5 +150,6 @@ pcb_tool_arrow_notify_mode, pcb_tool_arrow_adjust_attached_objects, NULL, + NULL, NULL }; Index: trunk/src/tool_buffer.c =================================================================== --- trunk/src/tool_buffer.c (revision 12639) +++ trunk/src/tool_buffer.c (revision 12640) @@ -89,10 +89,16 @@ } } +void pcb_tool_buffer_draw_attached(void) +{ + XORDrawBuffer(PCB_PASTEBUFFER); +} + pcb_tool_t pcb_tool_buffer = { "buffer", NULL, 100, pcb_tool_buffer_notify_mode, NULL, + pcb_tool_buffer_draw_attached, NULL, NULL }; Index: trunk/src/tool_buffer.h =================================================================== --- trunk/src/tool_buffer.h (revision 12639) +++ trunk/src/tool_buffer.h (revision 12640) @@ -1,3 +1,4 @@ extern pcb_tool_t pcb_tool_buffer; void pcb_tool_buffer_notify_mode(void); +void pcb_tool_buffer_draw_attached(void); Index: trunk/src/tool_copy.c =================================================================== --- trunk/src/tool_copy.c (revision 12639) +++ trunk/src/tool_copy.c (revision 12640) @@ -68,6 +68,11 @@ } } +void pcb_tool_copy_draw_attached(void) +{ + XORDrawMoveOrCopy(); +} + pcb_bool pcb_tool_copy_undo_act(void) { /* don't allow undo in the middle of an operation */ @@ -80,6 +85,7 @@ "copy", NULL, 100, pcb_tool_copy_notify_mode, NULL, + pcb_tool_copy_draw_attached, pcb_tool_copy_undo_act, NULL }; Index: trunk/src/tool_copy.h =================================================================== --- trunk/src/tool_copy.h (revision 12639) +++ trunk/src/tool_copy.h (revision 12640) @@ -1,4 +1,5 @@ extern pcb_tool_t pcb_tool_copy; void pcb_tool_copy_notify_mode(void); +void pcb_tool_copy_draw_attached(void); pcb_bool pcb_tool_copy_undo_act(void); Index: trunk/src/tool_insert.c =================================================================== --- trunk/src/tool_insert.c (revision 12639) +++ trunk/src/tool_insert.c (revision 12640) @@ -106,6 +106,11 @@ InsertedPoint = *pnt; } +void pcb_tool_insert_draw_attached(void) +{ + XORDrawInsertPointObject(); +} + pcb_bool pcb_tool_insert_undo_act(void) { /* don't allow undo in the middle of an operation */ @@ -118,6 +123,7 @@ "insert", NULL, 100, pcb_tool_insert_notify_mode, pcb_tool_insert_adjust_attached_objects, + pcb_tool_insert_draw_attached, pcb_tool_insert_undo_act, NULL }; Index: trunk/src/tool_insert.h =================================================================== --- trunk/src/tool_insert.h (revision 12639) +++ trunk/src/tool_insert.h (revision 12640) @@ -2,4 +2,5 @@ void pcb_tool_insert_notify_mode(void); void pcb_tool_insert_adjust_attached_objects(void); +void pcb_tool_insert_draw_attached(void); pcb_bool pcb_tool_insert_undo_act(void); Index: trunk/src/tool_line.c =================================================================== --- trunk/src/tool_line.c (revision 12639) +++ trunk/src/tool_line.c (revision 12640) @@ -34,6 +34,7 @@ #include "crosshair.h" #include "data.h" #include "draw.h" +#include "draw_wireframe.h" #include "obj_line.h" #include "rats.h" #include "search.h" @@ -246,6 +247,25 @@ } } +void pcb_tool_line_draw_attached(void) +{ + if(PCB->RatDraw) { + /* draw only if starting point exists and the line has length */ + if (pcb_crosshair.AttachedLine.State != PCB_CH_STATE_FIRST && pcb_crosshair.AttachedLine.draw) + 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, 0); + } + else if(pcb_crosshair.Route.size > 0) { + pcb_route_draw(&pcb_crosshair.Route,pcb_crosshair.GC); + if(conf_core.editor.show_drc) + pcb_route_draw_drc(&pcb_crosshair.Route,pcb_crosshair.GC); + pcb_gui->set_color(pcb_crosshair.GC, conf_core.appearance.color.crosshair); + } +} + pcb_bool pcb_tool_line_undo_act(void) { if (pcb_crosshair.AttachedLine.State == PCB_CH_STATE_SECOND) { @@ -333,6 +353,7 @@ "line", NULL, 100, pcb_tool_line_notify_mode, pcb_tool_line_adjust_attached_objects, + pcb_tool_line_draw_attached, pcb_tool_line_undo_act, pcb_tool_line_redo_act }; Index: trunk/src/tool_line.h =================================================================== --- trunk/src/tool_line.h (revision 12639) +++ trunk/src/tool_line.h (revision 12640) @@ -2,5 +2,6 @@ void pcb_tool_line_notify_mode(void); void pcb_tool_line_adjust_attached_objects(void); +void pcb_tool_line_draw_attached(void); pcb_bool pcb_tool_line_undo_act(void); pcb_bool pcb_tool_line_redo_act(void); Index: trunk/src/tool_lock.c =================================================================== --- trunk/src/tool_lock.c (revision 12639) +++ trunk/src/tool_lock.c (revision 12640) @@ -98,5 +98,6 @@ pcb_tool_lock_notify_mode, NULL, NULL, + NULL, NULL }; Index: trunk/src/tool_move.c =================================================================== --- trunk/src/tool_move.c (revision 12639) +++ trunk/src/tool_move.c (revision 12640) @@ -76,6 +76,11 @@ } } +void pcb_tool_move_draw_attached(void) +{ + XORDrawMoveOrCopy(); +} + pcb_bool pcb_tool_move_undo_act(void) { /* don't allow undo in the middle of an operation */ @@ -88,6 +93,7 @@ "move", NULL, 100, pcb_tool_move_notify_mode, NULL, + pcb_tool_move_draw_attached, pcb_tool_move_undo_act, NULL }; Index: trunk/src/tool_move.h =================================================================== --- trunk/src/tool_move.h (revision 12639) +++ trunk/src/tool_move.h (revision 12640) @@ -1,4 +1,5 @@ extern pcb_tool_t pcb_tool_move; void pcb_tool_move_notify_mode(void); +void pcb_tool_move_draw_attached(void); pcb_bool pcb_tool_move_undo_act(void); Index: trunk/src/tool_poly.c =================================================================== --- trunk/src/tool_poly.c (revision 12639) +++ trunk/src/tool_poly.c (revision 12640) @@ -79,6 +79,20 @@ pcb_line_adjust_attached(); } +void pcb_tool_poly_draw_attached(void) +{ + /* draw only if starting point is set */ + if (pcb_crosshair.AttachedLine.State != PCB_CH_STATE_FIRST) + pcb_gui->draw_line(pcb_crosshair.GC, + pcb_crosshair.AttachedLine.Point1.X, + pcb_crosshair.AttachedLine.Point1.Y, pcb_crosshair.AttachedLine.Point2.X, pcb_crosshair.AttachedLine.Point2.Y); + + /* draw attached polygon only if in PCB_MODE_POLYGON or PCB_MODE_POLYGON_HOLE */ + if (pcb_crosshair.AttachedPolygon.PointN > 1) { + XORPolygon(&pcb_crosshair.AttachedPolygon, 0, 0, 1); + } +} + pcb_bool pcb_tool_poly_undo_act(void) { if (pcb_crosshair.AttachedPolygon.PointN) { @@ -100,7 +114,7 @@ "poly", NULL, 100, pcb_tool_poly_notify_mode, pcb_tool_poly_adjust_attached_objects, + pcb_tool_poly_draw_attached, pcb_tool_poly_undo_act, pcb_tool_poly_redo_act, - NULL }; Index: trunk/src/tool_poly.h =================================================================== --- trunk/src/tool_poly.h (revision 12639) +++ trunk/src/tool_poly.h (revision 12640) @@ -2,5 +2,6 @@ void pcb_tool_poly_notify_mode(void); void pcb_tool_poly_adjust_attached_objects(void); +void pcb_tool_poly_draw_attached(void); pcb_bool pcb_tool_poly_undo_act(void); pcb_bool pcb_tool_poly_redo_act(void); Index: trunk/src/tool_polyhole.c =================================================================== --- trunk/src/tool_polyhole.c (revision 12639) +++ trunk/src/tool_polyhole.c (revision 12640) @@ -109,6 +109,20 @@ pcb_line_adjust_attached(); } +void pcb_tool_polyhole_draw_attached(void) +{ + /* draw only if starting point is set */ + if (pcb_crosshair.AttachedLine.State != PCB_CH_STATE_FIRST) + pcb_gui->draw_line(pcb_crosshair.GC, + pcb_crosshair.AttachedLine.Point1.X, + pcb_crosshair.AttachedLine.Point1.Y, pcb_crosshair.AttachedLine.Point2.X, pcb_crosshair.AttachedLine.Point2.Y); + + /* draw attached polygon only if in PCB_MODE_POLYGON or PCB_MODE_POLYGON_HOLE */ + if (pcb_crosshair.AttachedPolygon.PointN > 1) { + XORPolygon(&pcb_crosshair.AttachedPolygon, 0, 0, 1); + } +} + pcb_bool pcb_tool_polyhole_undo_act(void) { if (pcb_crosshair.AttachedPolygon.PointN) { @@ -130,6 +144,7 @@ "polyhole", NULL, 100, pcb_tool_polyhole_notify_mode, pcb_tool_polyhole_adjust_attached_objects, + pcb_tool_polyhole_draw_attached, pcb_tool_polyhole_undo_act, pcb_tool_polyhole_redo_act, NULL Index: trunk/src/tool_polyhole.h =================================================================== --- trunk/src/tool_polyhole.h (revision 12639) +++ trunk/src/tool_polyhole.h (revision 12640) @@ -2,5 +2,6 @@ void pcb_tool_polyhole_notify_mode(void); void pcb_tool_polyhole_adjust_attached_objects(void); +void pcb_tool_polyhole_draw_attached(void); pcb_bool pcb_tool_polyhole_undo_act(void); pcb_bool pcb_tool_polyhole_redo_act(void); Index: trunk/src/tool_rectangle.c =================================================================== --- trunk/src/tool_rectangle.c (revision 12639) +++ trunk/src/tool_rectangle.c (revision 12640) @@ -102,6 +102,7 @@ "rectangle", NULL, 100, pcb_tool_rectangle_notify_mode, pcb_tool_rectangle_adjust_attached_objects, + NULL, pcb_tool_rectangle_undo_act, NULL }; Index: trunk/src/tool_remove.c =================================================================== --- trunk/src/tool_remove.c (revision 12639) +++ trunk/src/tool_remove.c (revision 12640) @@ -62,5 +62,6 @@ pcb_tool_remove_notify_mode, NULL, NULL, + NULL, NULL }; Index: trunk/src/tool_rotate.c =================================================================== --- trunk/src/tool_rotate.c (revision 12639) +++ trunk/src/tool_rotate.c (revision 12640) @@ -46,5 +46,6 @@ pcb_tool_rotate_notify_mode, NULL, NULL, + NULL, NULL }; Index: trunk/src/tool_text.c =================================================================== --- trunk/src/tool_text.c (revision 12639) +++ trunk/src/tool_text.c (revision 12640) @@ -69,5 +69,6 @@ pcb_tool_text_notify_mode, NULL, NULL, + NULL, NULL }; Index: trunk/src/tool_thermal.c =================================================================== --- trunk/src/tool_thermal.c (revision 12639) +++ trunk/src/tool_thermal.c (revision 12640) @@ -117,5 +117,6 @@ pcb_tool_thermal_notify_mode, NULL, NULL, + NULL, NULL }; Index: trunk/src/tool_via.c =================================================================== --- trunk/src/tool_via.c (revision 12639) +++ trunk/src/tool_via.c (revision 12640) @@ -62,10 +62,33 @@ } } +void pcb_tool_via_draw_attached(void) +{ + /* Make a dummy via structure to draw from */ + pcb_pin_t via; + via.X = pcb_crosshair.X; + via.Y = pcb_crosshair.Y; + via.Thickness = conf_core.design.via_thickness; + via.Clearance = 2 * conf_core.design.clearance; + via.DrillingHole = conf_core.design.via_drilling_hole; + via.Mask = 0; + via.Flags = pcb_no_flags(); + + pcb_gui->thindraw_pcb_pv(pcb_crosshair.GC, pcb_crosshair.GC, &via, pcb_true, pcb_false); + + if (conf_core.editor.show_drc) { + /* XXX: Naughty cheat - use the mask to draw DRC clearance! */ + pcb_gui->set_color(pcb_crosshair.GC, conf_core.appearance.color.cross); + XORDrawPinViaDRCOutline(&via,PCB->Bloat); + pcb_gui->set_color(pcb_crosshair.GC, conf_core.appearance.color.crosshair); + } +} + pcb_tool_t pcb_tool_via = { "via", NULL, 100, pcb_tool_via_notify_mode, NULL, + pcb_tool_via_draw_attached, NULL, NULL }; Index: trunk/src/tool_via.h =================================================================== --- trunk/src/tool_via.h (revision 12639) +++ trunk/src/tool_via.h (revision 12640) @@ -1,3 +1,4 @@ extern pcb_tool_t pcb_tool_via; void pcb_tool_via_notify_mode(void); +void pcb_tool_via_draw_attached(void);