|
From: <gi...@gp...> - 2011-10-05 22:08:54
|
The branch, master has been updated
via 3108a3ffe3dad4cc50372b672ed668a739bbddf5 (commit)
from 8301b4dbd5fec500c7e4ec59eba1a8a397e1d8e1 (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
=========
globalconst.h | 2 +
src/const.h | 1 +
src/crosshair.c | 6 +++-
src/global.h | 2 +
src/misc.c | 6 +++++
src/move.h | 2 +
src/rotate.c | 2 +
src/search.c | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
8 files changed, 79 insertions(+), 2 deletions(-)
=================
Commit Messages
=================
commit 3108a3ffe3dad4cc50372b672ed668a739bbddf5
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
Add snapping to arc end-points
:100755 100755 e8966ff... afba0d4... M globalconst.h
:100644 100644 f029821... 078f83f... M src/const.h
:100644 100644 d927cf8... b7bebec... M src/crosshair.c
:100644 100644 96c9cc9... 9f0390b... M src/global.h
:100644 100644 a2a678e... 3cc04a0... M src/misc.c
:100644 100644 e617eca... 3daec3d... M src/move.h
:100644 100644 11b8fd9... 1763406... M src/rotate.c
:100644 100644 60e8dde... 5d02a53... M src/search.c
=========
Changes
=========
commit 3108a3ffe3dad4cc50372b672ed668a739bbddf5
Author: Peter Clifton <pc...@ca...>
Commit: Peter Clifton <pc...@ca...>
Add snapping to arc end-points
diff --git a/globalconst.h b/globalconst.h
index e8966ff..afba0d4 100755
--- a/globalconst.h
+++ b/globalconst.h
@@ -123,6 +123,8 @@
/* line points */
#define MAX_POLYGON_POINT_DISTANCE 0 /* maximum distance when searching */
/* polygon points */
+#define MAX_ARC_POINT_DISTANCE 0 /* maximum distance when searching */
+ /* arc points */
#define MAX_ELEMENTNAMES 3 /* number of supported names of */
/* an element */
#define MAX_LIBRARY_LINE_LENGTH 255 /* maximum line length in the */
diff --git a/src/const.h b/src/const.h
index f029821..078f83f 100644
--- a/src/const.h
+++ b/src/const.h
@@ -320,6 +320,7 @@ When set, element names are not drawn.
#define LOCKED_TYPE 0x10000 /* used to tell search to include locked items. */
#define NET_TYPE 0x20000 /* used to select whole net. */
+#define ARCPOINT_TYPE 0x40000
#define PIN_TYPES (VIA_TYPE | PIN_TYPE)
#define LOCK_TYPES (VIA_TYPE | LINE_TYPE | ARC_TYPE | POLYGON_TYPE | ELEMENT_TYPE \
diff --git a/src/crosshair.c b/src/crosshair.c
index d927cf8..b7bebec 100644
--- a/src/crosshair.c
+++ b/src/crosshair.c
@@ -1069,7 +1069,8 @@ FitCrosshairIntoGrid (Coord X, Coord Y)
ans = NO_TYPE;
if (TEST_FLAG (SNAPPINFLAG, PCB))
ans = SearchScreenGridSlop (Crosshair.X, Crosshair.Y,
- LINEPOINT_TYPE, &ptr1, &ptr2, &ptr3);
+ LINEPOINT_TYPE | ARCPOINT_TYPE,
+ &ptr1, &ptr2, &ptr3);
if (ans != NO_TYPE)
{
@@ -1099,7 +1100,8 @@ FitCrosshairIntoGrid (Coord X, Coord Y)
if (Settings.Mode == ARROW_MODE)
{
ans = SearchScreenGridSlop (Crosshair.X, Crosshair.Y,
- LINEPOINT_TYPE, &ptr1, &ptr2, &ptr3);
+ LINEPOINT_TYPE | ARCPOINT_TYPE,
+ &ptr1, &ptr2, &ptr3);
if (ans == NO_TYPE)
hid_action("PointCursor");
else if (!TEST_FLAG(SELECTEDFLAG, (LineType *)ptr2))
diff --git a/src/global.h b/src/global.h
index 96c9cc9..9f0390b 100644
--- a/src/global.h
+++ b/src/global.h
@@ -284,6 +284,8 @@ typedef struct /* holds information about arcs */
{
ANYOBJECTFIELDS;
Coord Thickness, Clearance;
+ PointType Point1;
+ PointType Point2;
Coord Width, Height, /* length of axis */
X, Y; /* center coordinates */
Angle StartAngle, Delta; /* the two limiting angles in degrees */
diff --git a/src/misc.c b/src/misc.c
index a2a678e..3cc04a0 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -1529,6 +1529,12 @@ SetArcBoundingBox (ArcTypePtr Arc)
Arc->BoundingBox.Y1 -= width;
Arc->BoundingBox.Y2 += width;
close_box(&Arc->BoundingBox);
+
+ /* Update the arc end-points */
+ Arc->Point1.X = Arc->X - (double)Arc->Width * ca1;
+ Arc->Point1.Y = Arc->Y + (double)Arc->Height * sa1;
+ Arc->Point2.X = Arc->X - (double)Arc->Width * ca2;
+ Arc->Point2.Y = Arc->Y + (double)Arc->Height * sa2;
}
/* ---------------------------------------------------------------------------
diff --git a/src/move.h b/src/move.h
index e617eca..3daec3d 100644
--- a/src/move.h
+++ b/src/move.h
@@ -61,6 +61,8 @@
{ \
MOVE((a)->X,(a)->Y,(dx),(dy)) \
MOVE_BOX_LOWLEVEL(&((a)->BoundingBox),(dx),(dy)); \
+ MOVE((a)->Point1.X,(a)->Point1.Y,(dx),(dy)) \
+ MOVE((a)->Point2.X,(a)->Point2.Y,(dx),(dy)) \
}
/* Rather than mode the line bounding box, we set it so the point bounding
* boxes are updated too.
diff --git a/src/rotate.c b/src/rotate.c
index 11b8fd9..1763406 100644
--- a/src/rotate.c
+++ b/src/rotate.c
@@ -204,6 +204,8 @@ RotateArcLowLevel (ArcTypePtr Arc, Coord X, Coord Y, unsigned Number)
Arc->Height = save;
}
RotateBoxLowLevel (&Arc->BoundingBox, X, Y, Number);
+ ROTATE (Arc->Point1.X, Arc->Point1.Y, X, Y, Number);
+ ROTATE (Arc->Point2.X, Arc->Point2.Y, X, Y, Number);
}
/* ---------------------------------------------------------------------------
diff --git a/src/search.c b/src/search.c
index 60e8dde..5d02a53 100644
--- a/src/search.c
+++ b/src/search.c
@@ -322,6 +322,8 @@ SearchRatLineByLocation (int locked, RatTypePtr * Line, RatTypePtr * Dummy1,
struct arc_info
{
ArcTypePtr *Arc, *Dummy;
+ PointTypePtr *Point;
+ double least;
jmp_buf env;
int locked;
};
@@ -496,6 +498,56 @@ SearchLinePointByLocation (int locked, LayerTypePtr * Layer,
return false;
}
+static int
+arcpoint_callback (const BoxType * b, void *cl)
+{
+ ArcTypePtr arc = (ArcTypePtr) b;
+ struct arc_info *i = (struct arc_info *) cl;
+ int ret_val = 0;
+ double d;
+
+ if (TEST_FLAG (i->locked, arc))
+ return 0;
+
+ d = Distance (PosX, PosY, arc->Point1.X, arc->Point1.Y);
+ if (d < i->least)
+ {
+ i->least = d;
+ *i->Arc = arc;
+ *i->Point = &arc->Point1;
+ ret_val = 1;
+ }
+
+ d = Distance (PosX, PosY, arc->Point2.X, arc->Point2.Y);
+ if (d < i->least)
+ {
+ i->least = d;
+ *i->Arc = arc;
+ *i->Point = &arc->Point2;
+ ret_val = 1;
+ }
+ return ret_val;
+}
+
+/* ---------------------------------------------------------------------------
+ * searches an arc-point on all the search layer
+ */
+static bool
+SearchArcPointByLocation (int locked, LayerType **Layer,
+ ArcType **arc, PointType **Point)
+{
+ struct arc_info info;
+ *Layer = SearchLayer;
+ info.Arc = arc;
+ info.Point = Point;
+ *Point = NULL;
+ info.least = MAX_ARC_POINT_DISTANCE + SearchRadius;
+ info.locked = (locked & LOCKED_TYPE) ? 0 : LOCKFLAG;
+ if (r_search
+ (SearchLayer->arc_tree, &SearchBox, NULL, arcpoint_callback, &info))
+ return true;
+ return false;
+}
/* ---------------------------------------------------------------------------
* searches a polygon-point on all layers that are switched on
* in layerstack order
@@ -1215,6 +1267,14 @@ SearchObjectByLocation (unsigned Type,
(LineTypePtr *) Result3))
return (LINE_TYPE);
+ if ((HigherAvail & (PIN_TYPE | PAD_TYPE)) == 0 &&
+ Type & ARCPOINT_TYPE &&
+ SearchArcPointByLocation (locked,
+ (LayerTypePtr *) Result1,
+ (ArcTypePtr *) Result2,
+ (PointTypePtr *) Result3))
+ return (ARCPOINT_TYPE);
+
if ((HigherAvail & (PIN_TYPE | PAD_TYPE)) == 0 && Type & ARC_TYPE &&
SearchArcByLocation (locked,
(LayerTypePtr *) Result1,
|