pcb 4.1.1
An interactive printed circuit board layout editor.
|
Crosshair stuff. More...
#include <memory.h>
#include <math.h>
#include "global.h"
#include "hid_draw.h"
#include "crosshair.h"
#include "buffer.h"
#include "data.h"
#include "draw.h"
#include "error.h"
#include "line.h"
#include "misc.h"
#include "mymem.h"
#include "search.h"
#include "polygon.h"
Go to the source code of this file.
Data Structures | |
struct | point |
struct | snap_data |
Functions | |
static void | thindraw_moved_pv (hidGC gc, PinType *pv, Coord x, Coord y) |
Make a copy of the pin structure, moved to the correct position. | |
static void | draw_dashed_line (hidGC gc, Coord x1, Coord y1, Coord x2, Coord y2) |
Draw a dashed line. | |
static void | XORPolygon (hidGC gc, PolygonType *polygon, Coord dx, Coord dy, int dash_last) |
Creates a tmp polygon with coordinates converted to screen system. | |
static void | XORDrawAttachedArc (hidGC gc, Coord thick) |
Draws the outline of an arc. | |
static void | XORDrawAttachedLine (hidGC gc, Coord x1, Coord y1, Coord x2, Coord y2, Coord thick) |
Draws the outline of a line. | |
static void | XORDrawElement (hidGC gc, ElementType *Element, Coord DX, Coord DY) |
Draws the elements of a loaded circuit which is to be merged in. | |
static void | XORDrawBuffer (hidGC gc, BufferType *Buffer) |
Draws all visible and attached objects of the pastebuffer. | |
static void | XORDrawInsertPointObject (hidGC gc) |
Draws the rubberband to insert points into polygons/lines/... | |
static void | XORDrawMoveOrCopyObject (hidGC gc) |
Draws the attached object while in MOVE_MODE or COPY_MODE. | |
void | DrawAttached (hidGC gc) |
Draws additional stuff that follows the crosshair. | |
void | DrawMark (hidGC gc) |
Draw the marker position. | |
Coord | GridFit (Coord x, Coord grid_spacing, Coord grid_offset) |
Returns the nearest grid-point to the given Coord. | |
void | notify_crosshair_change (bool changes_complete) |
Notify the GUI that data relating to the crosshair is being changed. | |
void | notify_mark_change (bool changes_complete) |
Notify the GUI that data relating to the mark is being changed. | |
void | HideCrosshair (void) |
Convenience for plugins using the old {Hide,Restore}Crosshair API. | |
void | RestoreCrosshair (void) |
static double | square (double x) |
Returns the square of the given number. | |
static double | crosshair_sq_dist (CrosshairType *crosshair, Coord x, Coord y) |
static void | check_snap_object (struct snap_data *snap_data, Coord x, Coord y, bool prefer_to_grid) |
Snap to a given location if it is the closest thing we found so far. | |
static void | check_snap_offgrid_line (struct snap_data *snap_data, Coord nearest_grid_x, Coord nearest_grid_y) |
void | FitCrosshairIntoGrid (Coord X, Coord Y) |
Recalculates the passed coordinates to fit the current grid setting. | |
bool | MoveCrosshairAbsolute (Coord X, Coord Y) |
Move crosshair absolute. | |
void | crosshair_update_range (void) |
Update the valid range for the crosshair cursor. | |
void | SetCrosshairRange (Coord MinX, Coord MinY, Coord MaxX, Coord MaxY) |
Sets the valid range for the crosshair cursor. | |
void | InitCrosshair (void) |
Initializes crosshair stuff. | |
void | DestroyCrosshair (void) |
Exits crosshair routines, release GCs. |
Crosshair stuff.
PCB, interactive printed circuit board design
Copyright (C) 1994,1995,1996 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., 51 Franklin Street, 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
Definition in file crosshair.c.
static void check_snap_object | ( | struct snap_data * | snap_data, |
Coord | x, | ||
Coord | y, | ||
bool | prefer_to_grid | ||
) | [static] |
Snap to a given location if it is the closest thing we found so far.
If "prefer_to_grid" is set, the passed location will take preference over a closer grid points we already snapped to UNLESS the user is pressing the SHIFT key. If the SHIFT key is pressed, the closest object (including grid points), is always preferred.
Definition at line 884 of file crosshair.c.
References snap_data::crosshair, crosshair_sq_dist(), gui, snap_data::nearest_is_grid, snap_data::nearest_sq_dist, hid_st::shift_is_pressed, x, snap_data::x, y, and snap_data::y.
Referenced by check_snap_offgrid_line(), and FitCrosshairIntoGrid().
static void check_snap_offgrid_line | ( | struct snap_data * | snap_data, |
Coord | nearest_grid_x, | ||
Coord | nearest_grid_y | ||
) | [static] |
Definition at line 901 of file crosshair.c.
References CrosshairType::AttachedObject, check_snap_object(), Crosshair, CURRENT, dist(), PCBType::Grid, line, LINE_MODE, SettingType::Mode, MOVE_MODE, PCB, AttachedObjectType::Ptr1, ptr1, AttachedObjectType::Ptr2, ptr2, ptr3, SearchObjectByLocation(), Settings, TEST_FLAG, AttachedObjectType::Type, CrosshairType::X, and CrosshairType::Y.
Referenced by FitCrosshairIntoGrid().
static double crosshair_sq_dist | ( | CrosshairType * | crosshair, |
Coord | x, | ||
Coord | y | ||
) | [static] |
Definition at line 862 of file crosshair.c.
References square(), CrosshairType::X, and CrosshairType::Y.
Referenced by check_snap_object(), and FitCrosshairIntoGrid().
void crosshair_update_range | ( | void | ) |
Update the valid range for the crosshair cursor.
Definition at line 1273 of file crosshair.c.
References CrosshairType::AttachedObject, box, Crosshair, GetObjectBoundingBox(), MAX, PCBType::MaxHeight, PCBType::MaxWidth, MIN, SettingType::Mode, PASTEBUFFER, PASTEBUFFER_MODE, PCB, AttachedObjectType::Ptr1, AttachedObjectType::Ptr2, AttachedObjectType::Ptr3, SetBufferBoundingBox(), SetCrosshairRange(), Settings, AttachedObjectType::Type, AttachedObjectType::X, BoxType::X1, BoxType::X2, AttachedObjectType::Y, BoxType::Y1, and BoxType::Y2.
Referenced by ActionPasteBuffer(), AttachForCopy(), FreeRotateBuffer(), MirrorBuffer(), PCBChanged(), RotateBuffer(), SetBufferNumber(), SetMode(), sizes_set(), SwapBuffer(), and SwapBuffers().
void DestroyCrosshair | ( | void | ) |
Exits crosshair routines, release GCs.
Definition at line 1350 of file crosshair.c.
References CrosshairType::AttachedPolygon, Crosshair, and FreePolygonMemory().
Draw a dashed line.
Definition at line 83 of file crosshair.c.
References hid_draw_st::draw_line, hid_st::graphics, gui, and n.
Referenced by XORPolygon().
void DrawAttached | ( | hidGC | gc | ) |
Draws additional stuff that follows the crosshair.
Definition at line 594 of file crosshair.c.
References ARC_MODE, CrosshairType::AttachedBox, CrosshairType::AttachedLine, CrosshairType::AttachedPolygon, PCBType::Bloat, pin_st::Clearance, PCBType::Clipping, COPY_MODE, SettingType::CrossColor, Crosshair, SettingType::CrosshairColor, AttachedLineType::draw, hid_draw_st::draw_arc, hid_draw_st::draw_line, hid_draw_st::draw_rect, pin_st::DrillingHole, hid_st::graphics, gui, INSERTPOINT_MODE, SettingType::Keepaway, LINE_MODE, SettingType::LineThickness, pin_st::Mask, SettingType::Mode, MOVE_MODE, NoFlags, PASTEBUFFER, PASTEBUFFER_MODE, PCB, AttachedBoxType::Point1, AttachedLineType::Point1, AttachedBoxType::Point2, AttachedLineType::Point2, polygon_st::PointN, POLYGON_MODE, POLYGONHOLE_MODE, PCBType::RatDraw, Round_Cap, hid_draw_st::set_color, hid_draw_st::set_draw_xor, hid_draw_st::set_line_cap, hid_draw_st::set_line_width, Settings, AttachedBoxType::State, AttachedLineType::State, STATE_FIRST, STATE_SECOND, STATE_THIRD, TEST_FLAG, pin_st::Thickness, hid_draw_st::thindraw_pcb_pv, Trace_Cap, VIA_MODE, SettingType::ViaDrillingHole, SettingType::ViaThickness, PointType::X, CrosshairType::X, pin_st::X, XORDrawAttachedArc(), XORDrawAttachedLine(), XORDrawBuffer(), XORDrawInsertPointObject(), XORDrawMoveOrCopyObject(), XORPolygon(), PointType::Y, CrosshairType::Y, and pin_st::Y.
Referenced by ghid_drawing_area_expose_cb(), ghid_notify_crosshair_change(), idle_proc(), lesstif_flush_debug_draw(), lesstif_notify_crosshair_change(), and redraw_region().
void DrawMark | ( | hidGC | gc | ) |
Draw the marker position.
Definition at line 730 of file crosshair.c.
References SettingType::CrosshairColor, hid_draw_st::draw_line, hid_st::graphics, gui, MARK_SIZE, Marked, hid_draw_st::set_color, hid_draw_st::set_draw_xor, hid_draw_st::set_line_cap, hid_draw_st::set_line_width, Settings, MarkType::status, Trace_Cap, MarkType::X, and MarkType::Y.
Referenced by ghid_drawing_area_expose_cb(), ghid_notify_mark_change(), idle_proc(), lesstif_flush_debug_draw(), lesstif_notify_mark_change(), and redraw_region().
Recalculates the passed coordinates to fit the current grid setting.
Definition at line 997 of file crosshair.c.
References ARC_MODE, ARROW_MODE, CrosshairType::AttachedLine, CrosshairType::AttachedObject, bottom_group, BOTTOM_SIDE, check_snap_object(), check_snap_offgrid_line(), snap_data::crosshair, Crosshair, crosshair_sq_dist(), CURRENT, PCBType::Data, END_LOOP, EnforceLineDRC(), GetLayerGroupNumberBySide(), PCBType::Grid, GridFit(), PCBType::GridOffsetX, PCBType::GridOffsetY, GROUP_LOOP, gui, hid_action(), hid_actionl(), HID_SC_DO_NOTHING, layer, LINE_MODE, Marked, ElementType::MarkX, ElementType::MarkY, CrosshairType::MaxX, CrosshairType::MaxY, MIL_TO_COORD, CrosshairType::MinX, CrosshairType::MinY, SettingType::Mode, MOVE_MODE, snap_data::nearest_is_grid, snap_data::nearest_sq_dist, PCB, pin, AttachedObjectType::Ptr1, ptr1, ptr2, ptr3, PCBType::RatDraw, SearchObjectByLocation(), hid_st::set_crosshair, Settings, AttachedLineType::State, STATE_FIRST, MarkType::status, TEST_FLAG, top_group, TOP_SIDE, AttachedObjectType::Type, PointType::X, pin_st::X, snap_data::x, MarkType::X, CrosshairType::X, PointType::Y, pin_st::Y, snap_data::y, MarkType::Y, and CrosshairType::Y.
Referenced by ActionUndo(), MoveCrosshairAbsolute(), SetCrosshairRange(), and SetLineSize().
Returns the nearest grid-point to the given Coord.
Definition at line 755 of file crosshair.c.
References x.
Referenced by ActionSelect(), AttachForCopy(), Center(), FitCrosshairIntoGrid(), ghid_draw_grid(), hidgl_draw_grid(), and lesstif_draw_grid().
void HideCrosshair | ( | void | ) |
Convenience for plugins using the old {Hide,Restore}Crosshair API.
This links up to notify the GUI of the expected changes using the new APIs.
Use of this old API is deprecated, as the names don't necessarily reflect what all GUIs may do in response to the notifications. Keeping these APIs is aimed at easing transition to the newer API, they will emit a harmless warning at the time of their first use.
Definition at line 823 of file crosshair.c.
References _, Message(), notify_crosshair_change(), and notify_mark_change().
void InitCrosshair | ( | void | ) |
Initializes crosshair stuff.
Clears the struct, allocates to graphical contexts.
Definition at line 1332 of file crosshair.c.
References Basic_Crosshair_Shape, Crosshair, Marked, PCBType::MaxHeight, PCBType::MaxWidth, CrosshairType::MaxX, CrosshairType::MaxY, CrosshairType::MinX, CrosshairType::MinY, PCB, CrosshairType::shape, and MarkType::status.
Referenced by main().
Move crosshair absolute.
Definition at line 1242 of file crosshair.c.
References Crosshair, FitCrosshairIntoGrid(), notify_crosshair_change(), CrosshairType::X, and CrosshairType::Y.
Referenced by ActionDisplay(), CenterDisplay(), EventMoveCrosshair(), ghid_note_event_location(), and netnode_browse().
void notify_crosshair_change | ( | bool | changes_complete | ) |
Notify the GUI that data relating to the crosshair is being changed.
The argument passed is false to notify "changes are about to happen", and true to notify "changes have finished".
Each call with a 'false' parameter must be matched with a following one with a 'true' parameter. Unmatched 'true' calls are currently not permitted, but might be allowed in the future.
GUIs should not complain if they receive extra calls with 'true' as parameter. They should initiate a redraw of the crosshair attached objects - which may (if necessary) mean repainting the whole screen if the GUI hasn't tracked the location of existing attached drawing.
Definition at line 781 of file crosshair.c.
References gui, and hid_st::notify_crosshair_change.
Referenced by ActionDisplay(), ActionFreeRotateBuffer(), ActionLoadFrom(), ActionMode(), ActionNew(), ActionPasteBuffer(), ActionPolygon(), ActionRedo(), ActionSelect(), ActionSetSame(), ActionUndo(), ActionUnselect(), AddSelectedToBuffer(), CenterDisplay(), click_cb(), EventMoveCrosshair(), ghid_note_event_location(), HideCrosshair(), mod_changed(), MoveCrosshairAbsolute(), NotifyBlock(), RestoreCrosshair(), run_get_location_loop(), SetMode(), ShowCrosshair(), and work_area_input().
void notify_mark_change | ( | bool | changes_complete | ) |
Notify the GUI that data relating to the mark is being changed.
The argument passed is false to notify "changes are about to happen", and true to notify "changes have finished".
Each call with a 'false' parameter must be matched with a following one with a 'true' parameter. Unmatched 'true' calls are currently not permitted, but might be allowed in the future.
GUIs should not complain if they receive extra calls with 'true' as parameter. They should initiate a redraw of the mark - which may (if necessary) mean repainting the whole screen if the GUI hasn't tracked the mark's location.
Definition at line 803 of file crosshair.c.
References gui, and hid_st::notify_mark_change.
Referenced by ActionMarkCrosshair(), HideCrosshair(), RestoreCrosshair(), SetLocalRef(), and ShowCrosshair().
void RestoreCrosshair | ( | void | ) |
Definition at line 838 of file crosshair.c.
References _, Message(), notify_crosshair_change(), and notify_mark_change().
Sets the valid range for the crosshair cursor.
Definition at line 1315 of file crosshair.c.
References Crosshair, FitCrosshairIntoGrid(), MAX, PCBType::MaxHeight, PCBType::MaxWidth, CrosshairType::MaxX, CrosshairType::MaxY, MIN, CrosshairType::MinX, CrosshairType::MinY, PCB, CrosshairType::X, and CrosshairType::Y.
Referenced by crosshair_update_range().
static double square | ( | double | x | ) | [static] |
Returns the square of the given number.
Definition at line 856 of file crosshair.c.
References x.
Referenced by crosshair_sq_dist().
Make a copy of the pin structure, moved to the correct position.
Definition at line 70 of file crosshair.c.
References hid_st::graphics, gui, hid_draw_st::thindraw_pcb_pv, x, pin_st::X, y, and pin_st::Y.
Referenced by XORDrawBuffer(), XORDrawElement(), and XORDrawMoveOrCopyObject().
Draws the outline of an arc.
Definition at line 160 of file crosshair.c.
References abs, CrosshairType::AttachedBox, Crosshair, ArcType::Delta, hid_draw_st::draw_arc, GetArcEnds(), hid_st::graphics, gui, ArcType::Height, AttachedBoxType::otherway, pixel_slop, AttachedBoxType::Point1, SGN, SGNZ, ArcType::StartAngle, ArcType::Width, ArcType::X, PointType::X, CrosshairType::X, BoxType::X1, BoxType::X2, XOR, ArcType::Y, PointType::Y, CrosshairType::Y, BoxType::Y1, and BoxType::Y2.
Referenced by DrawAttached().
static void XORDrawAttachedLine | ( | hidGC | gc, |
Coord | x1, | ||
Coord | y1, | ||
Coord | x2, | ||
Coord | y2, | ||
Coord | thick | ||
) | [static] |
Draws the outline of a line.
Definition at line 216 of file crosshair.c.
References abs, hid_draw_st::draw_arc, hid_draw_st::draw_line, hid_st::graphics, gui, pixel_slop, and SGN.
Referenced by DrawAttached(), and XORDrawMoveOrCopyObject().
static void XORDrawBuffer | ( | hidGC | gc, |
BufferType * | Buffer | ||
) | [static] |
Draws all visible and attached objects of the pastebuffer.
Definition at line 341 of file crosshair.c.
References ARC_LOOP, box, Crosshair, BufferType::Data, PCBType::Data, hid_draw_st::draw_arc, hid_draw_st::draw_line, hid_draw_st::draw_rect, ELEMENT_LOOP, PCBType::ElementOn, END_LOOP, FRONT, hid_st::graphics, gui, PCBType::InvisibleObjectsOn, layer, DataType::Layer, line, LINE_LOOP, max_copper_layer, LayerType::On, PCB, PCBType::PinOn, POLYGON_LOOP, SILK_LAYER, TEXT_LOOP, thindraw_moved_pv(), VIA_LOOP, PCBType::ViaOn, BufferType::X, CrosshairType::X, x, BoxType::X1, BoxType::X2, XORDrawElement(), XORPolygon(), BufferType::Y, CrosshairType::Y, y, BoxType::Y1, and BoxType::Y2.
Referenced by DrawAttached().
static void XORDrawElement | ( | hidGC | gc, |
ElementType * | Element, | ||
Coord | DX, | ||
Coord | DY | ||
) | [static] |
Draws the elements of a loaded circuit which is to be merged in.
Definition at line 244 of file crosshair.c.
References ARC_LOOP, ElementType::ArcN, hid_draw_st::draw_arc, hid_draw_st::draw_line, ELEMENTLINE_LOOP, END_LOOP, hid_st::graphics, gui, PCBType::InvisibleObjectsOn, line, ElementType::LineN, ElementType::MarkX, ElementType::MarkY, PAD_LOOP, PCB, pin, PIN_LOOP, Settings, SettingType::ShowBottomSide, TEST_FLAG, thindraw_moved_pv(), and hid_draw_st::thindraw_pcb_pad.
Referenced by XORDrawBuffer(), and XORDrawMoveOrCopyObject().
static void XORDrawInsertPointObject | ( | hidGC | gc | ) | [static] |
Draws the rubberband to insert points into polygons/lines/...
Definition at line 416 of file crosshair.c.
References CrosshairType::AttachedObject, Crosshair, hid_draw_st::draw_line, hid_st::graphics, gui, line, AttachedObjectType::Ptr2, AttachedObjectType::Ptr3, and AttachedObjectType::Type.
Referenced by DrawAttached().
static void XORDrawMoveOrCopyObject | ( | hidGC | gc | ) | [static] |
Draws the attached object while in MOVE_MODE or COPY_MODE.
Definition at line 432 of file crosshair.c.
References CrosshairType::AttachedObject, box, Crosshair, ArcType::Delta, hid_draw_st::draw_arc, hid_draw_st::draw_line, hid_draw_st::draw_rect, hid_st::graphics, gui, ArcType::Height, RubberbandType::Line, line, ElementType::MarkX, ElementType::MarkY, RubberbandType::MovedPoint, next_contour_point(), polygon_st::Points, polygon_point_idx(), prev_contour_point(), ptr, AttachedObjectType::Ptr1, AttachedObjectType::Ptr2, AttachedObjectType::Ptr3, AttachedObjectType::Rubberband, AttachedObjectType::RubberbandN, ArcType::StartAngle, TEST_FLAG, thindraw_moved_pv(), AttachedObjectType::Type, ArcType::Width, PointType::X, ArcType::X, AttachedObjectType::X, CrosshairType::X, BoxType::X1, BoxType::X2, XORDrawAttachedLine(), XORDrawElement(), XORPolygon(), PointType::Y, ArcType::Y, AttachedObjectType::Y, CrosshairType::Y, BoxType::Y1, and BoxType::Y2.
Referenced by DrawAttached().
static void XORPolygon | ( | hidGC | gc, |
PolygonType * | polygon, | ||
Coord | dx, | ||
Coord | dy, | ||
int | dash_last | ||
) | [static] |
Creates a tmp polygon with coordinates converted to screen system.
Definition at line 123 of file crosshair.c.
References draw_dashed_line(), hid_draw_st::draw_line, hid_st::graphics, gui, next_contour_point(), polygon_st::PointN, polygon_st::Points, PointType::X, and PointType::Y.
Referenced by DrawAttached(), XORDrawBuffer(), and XORDrawMoveOrCopyObject().