[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
gEDA-cvs: pcb.git: branch: master updated (b0fd3fe6acc9fe632b6c0cd3d5a8485f293d7889)
The branch, master has been updated
via b0fd3fe6acc9fe632b6c0cd3d5a8485f293d7889 (commit)
from ba3a56929b240c5c3ab1ee1af7149b30dcdbb8cf (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
=========
Summary
=========
src/crosshair.c | 161 ++++++++++++++++++++++++++++++++-----------------------
1 files changed, 93 insertions(+), 68 deletions(-)
=================
Commit Messages
=================
commit b0fd3fe6acc9fe632b6c0cd3d5a8485f293d7889
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Commit: Peter Clifton <pcjc2@xxxxxxxxx>
crosshair.c: Revise heuristic for snapping on off-grid lines
Only snap to an off-grid section of a line when:
Drawing lines on the same layer as the one being snapped to
When manipulating the end-point of a _different) line on the
same layer as the one being snapped to.
This should hopefully reduce the tendancy of the off-grid-line
code to cause lots of unnecessary snapping.
:100644 100644 4024881... bb0a87b... M src/crosshair.c
=========
Changes
=========
commit b0fd3fe6acc9fe632b6c0cd3d5a8485f293d7889
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Commit: Peter Clifton <pcjc2@xxxxxxxxx>
crosshair.c: Revise heuristic for snapping on off-grid lines
Only snap to an off-grid section of a line when:
Drawing lines on the same layer as the one being snapped to
When manipulating the end-point of a _different) line on the
same layer as the one being snapped to.
This should hopefully reduce the tendancy of the off-grid-line
code to cause lots of unnecessary snapping.
diff --git a/src/crosshair.c b/src/crosshair.c
index 4024881..bb0a87b 100644
--- a/src/crosshair.c
+++ b/src/crosshair.c
@@ -819,6 +819,98 @@ check_snap_object (struct snap_data *snap_data, LocationType x, LocationType y,
}
}
+static void
+check_snap_offgrid_line (struct snap_data *snap_data,
+ LocationType nearest_grid_x,
+ LocationType nearest_grid_y)
+{
+ void *ptr1, *ptr2, *ptr3;
+ int ans;
+ LineType *line;
+ LocationType try_x, try_y;
+ double dx, dy;
+ double dist;
+
+ if (!TEST_FLAG (SNAPPINFLAG, PCB))
+ return;
+
+ /* Code to snap at some sensible point along a line */
+ /* Pick the nearest grid-point in the x or y direction
+ * to align with, then adjust until we hit the line
+ */
+ ans = SearchScreenGridSlop (Crosshair.X, Crosshair.Y,
+ LINE_TYPE, &ptr1, &ptr2, &ptr3);
+
+ if (ans == NO_TYPE)
+ return;
+
+ line = (LineType *)ptr2;
+
+ /* Allow snapping to off-grid lines when drawing new lines (on
+ * the same layer), and when moving a line end-point
+ * (but don't snap to the same line)
+ */
+ if ((Settings.Mode != LINE_MODE ||
+ Crosshair.AttachedObject.Ptr1 != ptr1) &&
+ (Settings.Mode != MOVE_MODE ||
+ Crosshair.AttachedObject.Ptr1 != ptr1 ||
+ Crosshair.AttachedObject.Type != LINEPOINT_TYPE ||
+ Crosshair.AttachedObject.Ptr2 == line))
+ return;
+
+ dx = line->Point2.X - line->Point1.X;
+ dy = line->Point2.Y - line->Point1.Y;
+
+ /* Try snapping along the X axis */
+ if (dy != 0.)
+ {
+ /* Move in the X direction until we hit the line */
+ try_x = (nearest_grid_y - line->Point1.Y) / dy * dx + line->Point1.X;
+ try_y = nearest_grid_y;
+ check_snap_object (snap_data, try_x, try_y, true);
+ }
+
+ /* Try snapping along the Y axis */
+ if (dx != 0.)
+ {
+ try_x = nearest_grid_x;
+ try_y = (nearest_grid_x - line->Point1.X) / dx * dy + line->Point1.Y;
+ check_snap_object (snap_data, try_x, try_y, true);
+ }
+
+ if (dx != dy) /* If line not parallel with dX = dY direction.. */
+ {
+ /* Try snapping diagonally towards the line in the dX = dY direction */
+
+ if (dy == 0)
+ dist = line->Point1.Y - nearest_grid_y;
+ else
+ dist = ((line->Point1.X - nearest_grid_x) -
+ (line->Point1.Y - nearest_grid_y) * dx / dy) / (1 - dx / dy);
+
+ try_x = nearest_grid_x + dist;
+ try_y = nearest_grid_y + dist;
+
+ check_snap_object (snap_data, try_x, try_y, true);
+ }
+
+ if (dx != -dy) /* If line not parallel with dX = -dY direction.. */
+ {
+ /* Try snapping diagonally towards the line in the dX = -dY direction */
+
+ if (dy == 0)
+ dist = nearest_grid_y - line->Point1.Y;
+ else
+ dist = ((line->Point1.X - nearest_grid_x) -
+ (line->Point1.Y - nearest_grid_y) * dx / dy) / (1 + dx / dy);
+
+ try_x = nearest_grid_x + dist;
+ try_y = nearest_grid_y - dist;
+
+ check_snap_object (snap_data, try_x, try_y, true);
+ }
+}
+
/* ---------------------------------------------------------------------------
* recalculates the passed coordinates to fit the current grid setting
*/
@@ -976,74 +1068,7 @@ FitCrosshairIntoGrid (LocationType X, LocationType Y)
check_snap_object (&snap_data, pnt->X, pnt->Y, true);
}
- /* Code to snap at some sensible point along a line */
- /* Pick the nearest grid-point in the x or y direction
- * to align with, then adjust until we hit the line
- */
- ans = NO_TYPE;
- if (TEST_FLAG (SNAPPINFLAG, PCB))
- ans = SearchScreenGridSlop (Crosshair.X, Crosshair.Y,
- LINE_TYPE, &ptr1, &ptr2, &ptr3);
-
- if (ans != NO_TYPE)
- {
- LineType *line = (LineType *)ptr2;
- LocationType try_x, try_y;
- double dx, dy;
- double dist;
-
- dx = line->Point2.X - line->Point1.X;
- dy = line->Point2.Y - line->Point1.Y;
-
- /* Try snapping along the X axis */
- if (dy != 0.)
- {
- /* Move in the X direction until we hit the line */
- try_x = (nearest_grid_y - line->Point1.Y) / dy * dx + line->Point1.X;
- try_y = nearest_grid_y;
- check_snap_object (&snap_data, try_x, try_y, true);
- }
-
- /* Try snapping along the Y axis */
- if (dx != 0.)
- {
- try_x = nearest_grid_x;
- try_y = (nearest_grid_x - line->Point1.X) / dx * dy + line->Point1.Y;
- check_snap_object (&snap_data, try_x, try_y, true);
- }
-
- if (dx != dy) /* If line not parallel with dX = dY direction.. */
- {
- /* Try snapping diagonally towards the line in the dX = dY direction */
-
- if (dy == 0)
- dist = line->Point1.Y - nearest_grid_y;
- else
- dist = ((line->Point1.X - nearest_grid_x) -
- (line->Point1.Y - nearest_grid_y) * dx / dy) / (1 - dx / dy);
-
- try_x = nearest_grid_x + dist;
- try_y = nearest_grid_y + dist;
-
- check_snap_object (&snap_data, try_x, try_y, true);
- }
-
- if (dx != -dy) /* If line not parallel with dX = -dY direction.. */
- {
- /* Try snapping diagonally towards the line in the dX = -dY direction */
-
- if (dy == 0)
- dist = nearest_grid_y - line->Point1.Y;
- else
- dist = ((line->Point1.X - nearest_grid_x) -
- (line->Point1.Y - nearest_grid_y) * dx / dy) / (1 + dx / dy);
-
- try_x = nearest_grid_x + dist;
- try_y = nearest_grid_y - dist;
-
- check_snap_object (&snap_data, try_x, try_y, true);
- }
- }
+ check_snap_offgrid_line (&snap_data, nearest_grid_x, nearest_grid_y);
ans = NO_TYPE;
if (TEST_FLAG (SNAPPINFLAG, PCB))
_______________________________________________
geda-cvs mailing list
geda-cvs@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-cvs