diff --git a/src/ant/ant/RulerPropertiesPage.ui b/src/ant/ant/RulerPropertiesPage.ui
index ad86d29e0..5e4497bbd 100644
--- a/src/ant/ant/RulerPropertiesPage.ui
+++ b/src/ant/ant/RulerPropertiesPage.ui
@@ -53,141 +53,125 @@
6
- -
-
-
-
- 1
- 0
-
-
-
- true
-
-
-
- -
-
+
-
+
- First point (x/y)
+ Second point (x/y)
- -
-
-
- QFrame::NoFrame
-
-
- QFrame::Raised
-
-
-
- 0
-
-
- 0
-
-
- 0
-
-
- 0
-
-
-
-
-
- Qt::Horizontal
-
-
-
- 40
- 20
-
-
-
-
- -
-
-
- ...
-
-
-
- :/down.png:/down.png
-
-
- false
-
-
-
- -
-
-
- ...
-
-
-
- :/up.png:/up.png
-
-
- false
-
-
-
- -
-
-
- Qt::Horizontal
-
-
-
- 40
- 20
-
-
-
-
-
-
-
- -
-
-
-
- 1
- 0
-
-
-
-
- -
-
-
-
- 1
- 0
-
-
-
- true
-
-
-
- -
-
+
-
+
- y =
+ Style
- -
-
+
-
+
- X label format
+ <html>(See <a href="int:/manual/ruler_properties.xml">here</a> for a description of the properties)</html>
+ -
+
+
+ ... position
+
+
+
+ -
+
+
+ Qt::Vertical
+
+
+
+ 20
+ 5
+
+
+
+
+ -
+
+
+ -
+
+
-
+
+ Diagonal
+
+
+ -
+
+ Horizonal and vertical (in this order)
+
+
+ -
+
+ Diagonal plus horizonal and vertical (triangle)
+
+
+ -
+
+ Vertical and horizonal (in this order)
+
+
+ -
+
+ Diagonal plus vertical and horizontal (triangle)
+
+
+ -
+
+ Box
+
+
+ -
+
+ Ellipse
+
+
+
+
+ -
+
+
+ d =
+
+
+
+ -
+
+
+ Qt::Vertical
+
+
+
+ 20
+ 5
+
+
+
+
+ -
+
+
+ Qt::Vertical
+
+
+ QSizePolicy::Fixed
+
+
+
+ 456
+ 16
+
+
+
+
-
-
@@ -232,278 +216,6 @@
- -
-
-
-
- 1
- 0
-
-
-
-
- -
-
-
- x =
-
-
-
- -
-
-
- x =
-
-
-
- -
-
-
- Delta (x/y)
-
-
-
- -
-
-
- ... position
-
-
-
- -
-
-
- Qt::Vertical
-
-
-
- 20
- 5
-
-
-
-
- -
-
-
- Second point (x/y)
-
-
-
- -
-
-
-
-
- Diagonal
-
-
- -
-
- Horizonal and vertical (in this order)
-
-
- -
-
- Diagonal plus horizonal and vertical (triangle)
-
-
- -
-
- Vertical and horizonal (in this order)
-
-
- -
-
- Diagonal plus vertical and horizontal (triangle)
-
-
- -
-
- Box
-
-
- -
-
- Ellipse
-
-
-
-
- -
-
-
- Qt::Vertical
-
-
-
- 20
- 5
-
-
-
-
- -
-
-
-
- 1
- 0
-
-
-
-
- -
-
-
- Outline
-
-
-
- -
-
-
- QFrame::NoFrame
-
-
- QFrame::Raised
-
-
-
- 0
-
-
- 0
-
-
- 0
-
-
- 0
-
-
-
-
-
- Qt::Horizontal
-
-
-
- 223
- 20
-
-
-
-
- -
-
-
- H
-
-
-
- -
-
-
-
- 0
- 0
-
-
-
-
-
- Auto
-
-
- -
-
- H. center
-
-
- -
-
- Left
-
-
- -
-
- Right
-
-
-
-
- -
-
-
- V
-
-
-
- -
-
-
-
- 0
- 0
-
-
-
-
-
- Auto
-
-
- -
-
- V. center
-
-
- -
-
- Bottom
-
-
- -
-
- Top
-
-
-
-
-
-
-
- -
-
-
- -
-
-
-
- 0
- 0
-
-
-
-
- Sans Serif
- 12
- 75
- false
- true
- false
- false
-
-
-
- Ruler Properties
-
-
-
- -
-
-
- d =
-
-
-
-
@@ -514,283 +226,13 @@
- -
-
-
- -
-
+
-
+
- x =
+ Delta (x/y)
- -
-
-
- -
-
-
- Qt::Vertical
-
-
-
- 20
- 5
-
-
-
-
- -
-
-
- QFrame::NoFrame
-
-
- QFrame::Raised
-
-
-
- 0
-
-
- 0
-
-
- 0
-
-
- 0
-
-
-
-
-
- Qt::Horizontal
-
-
-
- 223
- 20
-
-
-
-
- -
-
-
- H
-
-
-
- -
-
-
-
- 0
- 0
-
-
-
-
-
- Auto
-
-
- -
-
- H. center
-
-
- -
-
- Left
-
-
- -
-
- Right
-
-
-
-
- -
-
-
- V
-
-
-
- -
-
-
-
- 0
- 0
-
-
-
-
-
- Auto
-
-
- -
-
- V. center
-
-
- -
-
- Bottom
-
-
- -
-
- Top
-
-
-
-
-
-
-
- -
-
-
- ... position
-
-
-
- -
-
-
- Y label format
-
-
-
- -
-
-
-
- 1
- 0
-
-
-
- true
-
-
-
- -
-
-
- Qt::Horizontal
-
-
-
- -
-
-
- ... position
-
-
-
- -
-
-
- Style
-
-
-
- -
-
-
- <html>(See <a href="int:/manual/ruler_properties.xml">here</a> for a description of the properties)</html>
-
-
-
- -
-
-
- Label format
-
-
-
- -
-
-
- QFrame::NoFrame
-
-
- QFrame::Raised
-
-
-
- 0
-
-
- 0
-
-
- 0
-
-
- 0
-
-
-
-
-
- Qt::Horizontal
-
-
-
- 40
- 20
-
-
-
-
- -
-
-
- ...
-
-
-
- :/down.png:/down.png
-
-
- false
-
-
-
- -
-
-
- ...
-
-
-
- :/up.png:/up.png
-
-
- false
-
-
-
- -
-
-
- Qt::Horizontal
-
-
-
- 40
- 20
-
-
-
-
-
-
-
-
@@ -936,44 +378,203 @@
- -
-
-
- y =
+
-
+
+
+ Qt::Horizontal
- -
+
-
+
+
+ x =
+
+
+
+ -
+
+
+ Label format
+
+
+
+ -
Length
- -
-
-
- Qt::Vertical
+
-
+
+
+ Outline
-
- QSizePolicy::Fixed
-
-
-
- 456
- 16
-
-
-
+
- -
+
-
+
+
+ QFrame::NoFrame
+
+
+ QFrame::Raised
+
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
-
+
+
+ Qt::Horizontal
+
+
+
+ 223
+ 20
+
+
+
+
+ -
+
+
+ H
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
-
+
+ Auto
+
+
+ -
+
+ H. center
+
+
+ -
+
+ Left
+
+
+ -
+
+ Right
+
+
+
+
+ -
+
+
+ V
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
-
+
+ Auto
+
+
+ -
+
+ V. center
+
+
+ -
+
+ Bottom
+
+
+ -
+
+ Top
+
+
+
+
+
+
+
+ -
+
+
+
+ 1
+ 0
+
+
+
+ true
+
+
+
+ -
+
+
+
+ 1
+ 0
+
+
+
+ true
+
+
+
+ -
+
+
+ First point (x/y)
+
+
+
+ -
+
+
+
+ 1
+ 0
+
+
+
+
+ -
y =
- -
+
-
QFrame::NoFrame
@@ -994,10 +595,33 @@
0
+
-
+
+
+ Swap points
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+ QSizePolicy::Fixed
+
+
+
+ 10
+ 20
+
+
+
+
-
- Snap to layout:
+ Snap to layout:
@@ -1047,6 +671,249 @@
+ -
+
+
+ Qt::Vertical
+
+
+
+ 20
+ 5
+
+
+
+
+ -
+
+
+ y =
+
+
+
+ -
+
+
+ -
+
+
+
+ 1
+ 0
+
+
+
+ true
+
+
+
+ -
+
+
+
+ 1
+ 0
+
+
+
+
+ -
+
+
+ ... position
+
+
+
+ -
+
+
+ -
+
+
+ QFrame::NoFrame
+
+
+ QFrame::Raised
+
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
-
+
+
+ Qt::Horizontal
+
+
+
+ 223
+ 20
+
+
+
+
+ -
+
+
+ H
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
-
+
+ Auto
+
+
+ -
+
+ H. center
+
+
+ -
+
+ Left
+
+
+ -
+
+ Right
+
+
+
+
+ -
+
+
+ V
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
-
+
+ Auto
+
+
+ -
+
+ V. center
+
+
+ -
+
+ Bottom
+
+
+ -
+
+ Top
+
+
+
+
+
+
+
+ -
+
+
+ ... position
+
+
+
+ -
+
+
+ x =
+
+
+
+ -
+
+
+
+ 1
+ 0
+
+
+
+
+ -
+
+
+ Y label format
+
+
+
+ -
+
+
+ X label format
+
+
+
+ -
+
+
+ y =
+
+
+
+ -
+
+
+ x =
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+
+ Sans Serif
+ 12
+ 75
+ false
+ true
+ false
+ false
+
+
+
+ Ruler Properties
+
+
+
@@ -1078,8 +945,6 @@
dy
dd
-
-
-
+
diff --git a/src/ant/ant/antPropertiesPage.cc b/src/ant/ant/antPropertiesPage.cc
index ad1c3df0e..847e58754 100644
--- a/src/ant/ant/antPropertiesPage.cc
+++ b/src/ant/ant/antPropertiesPage.cc
@@ -39,20 +39,13 @@ PropertiesPage::PropertiesPage (ant::Service *rulers, db::Manager *manager, QWid
setupUi (this);
- connect (p1x_to_p2x, SIGNAL (clicked ()), this, SLOT (xfer_coord_clicked ()));
- connect (p2x_to_p1x, SIGNAL (clicked ()), this, SLOT (xfer_coord_clicked ()));
- connect (p1y_to_p2y, SIGNAL (clicked ()), this, SLOT (xfer_coord_clicked ()));
- connect (p2y_to_p1y, SIGNAL (clicked ()), this, SLOT (xfer_coord_clicked ()));
+ connect (swap_points, SIGNAL (clicked ()), this, SLOT (swap_points_clicked ()));
connect (p1_to_layout, SIGNAL (clicked ()), this, SLOT (snap_to_layout_clicked ()));
connect (p2_to_layout, SIGNAL (clicked ()), this, SLOT (snap_to_layout_clicked ()));
connect (both_to_layout, SIGNAL (clicked ()), this, SLOT (snap_to_layout_clicked ()));
- p1x_to_p2x->setEnabled (! readonly());
- p2x_to_p1x->setEnabled (! readonly());
- p1y_to_p2y->setEnabled (! readonly());
- p2y_to_p1y->setEnabled (! readonly());
-
+ swap_points->setEnabled (! readonly());
p1_to_layout->setEnabled (! readonly());
p2_to_layout->setEnabled (! readonly());
both_to_layout->setEnabled (! readonly());
@@ -80,23 +73,24 @@ PropertiesPage::front ()
}
void
-PropertiesPage::xfer_coord_clicked ()
+PropertiesPage::swap_points_clicked ()
{
if (readonly ()) {
return;
}
- if (sender () == p1x_to_p2x) {
- x2->setText (x1->text ());
- } else if (sender () == p2x_to_p1x) {
- x1->setText (x2->text ());
- } else if (sender () == p1y_to_p2y) {
- y2->setText (y1->text ());
- } else if (sender () == p2y_to_p1y) {
- y1->setText (y2->text ());
- }
+ QString tx1 = x1->text (), tx2 = x2->text ();
+ QString ty1 = y1->text (), ty2 = y2->text ();
- db::Transaction t (manager (), tl::to_string (QObject::tr ("Copy ruler coordinates")));
+ std::swap (tx1, tx2);
+ std::swap (ty1, ty2);
+
+ x1->setText (tx1);
+ x2->setText (tx2);
+ y1->setText (ty1);
+ y2->setText (ty2);
+
+ db::Transaction t (manager (), tl::to_string (QObject::tr ("Swap ruler points")));
apply ();
}
@@ -136,12 +130,14 @@ PropertiesPage::snap_to_layout_clicked ()
if (sender () == p1_to_layout || sender () == p2_to_layout) {
+ bool snap_p1 = sender () == p1_to_layout;
+
double snap_range = service->widget ()->mouse_event_trans ().inverted ().ctrans (service->snap_range ());
double max_range = 1000 * snap_range;
while (snap_range < max_range) {
- std::pair pp = lay::obj_snap (service->view (), p1, p1, g, ac, snap_range);
+ std::pair pp = lay::obj_snap (service->view (), snap_p1 ? p2 : p1, snap_p1 ? p1 : p2, g, ac, snap_range);
if (pp.first) {
QString xs = tl::to_qstring (tl::micron_to_string (pp.second.x ()));
@@ -155,7 +151,7 @@ PropertiesPage::snap_to_layout_clicked ()
y2->setText (ys);
}
- db::Transaction t (manager (), tl::to_string (sender () == p1_to_layout ? QObject::tr ("Snap first ruler point") : QObject::tr ("Snap second ruler point")));
+ db::Transaction t (manager (), tl::to_string (snap_p1 ? QObject::tr ("Snap first ruler point") : QObject::tr ("Snap second ruler point")));
apply ();
break;
@@ -172,7 +168,7 @@ PropertiesPage::snap_to_layout_clicked ()
double snap_range = service->widget ()->mouse_event_trans ().inverted ().ctrans (service->snap_range ());
snap_range *= 0.5;
- std::pair ee = lay::obj_snap2 (service->view (), p1, g, ac, snap_range, snap_range * 1000.0);
+ std::pair ee = lay::obj_snap2 (service->view (), p1, p2, g, ac, snap_range, snap_range * 1000.0);
if (ee.first) {
x1->setText (tl::to_qstring (tl::micron_to_string (ee.second.p1 ().x ())));
diff --git a/src/ant/ant/antPropertiesPage.h b/src/ant/ant/antPropertiesPage.h
index 0a4555c0d..5cb1d2a06 100644
--- a/src/ant/ant/antPropertiesPage.h
+++ b/src/ant/ant/antPropertiesPage.h
@@ -54,7 +54,7 @@ public:
virtual void apply ();
private slots:
- void xfer_coord_clicked ();
+ void swap_points_clicked ();
void snap_to_layout_clicked ();
private:
diff --git a/src/laybasic/laybasic/laySnap.cc b/src/laybasic/laybasic/laySnap.cc
index a524ec607..3c2c3bd12 100644
--- a/src/laybasic/laybasic/laySnap.cc
+++ b/src/laybasic/laybasic/laySnap.cc
@@ -441,7 +441,7 @@ private:
if (m_directed) {
for (std::vector::const_iterator cl = m_cutlines.begin (); cl != m_cutlines.end (); ++cl) {
- if (db::sprod_sign (p - cl->p1 (), cl->d ()) <= 0) {
+ if (db::sprod_sign (p - m_original, cl->d ()) <= 0) {
return;
}
}
@@ -462,7 +462,7 @@ private:
if (m_directed) {
for (std::vector::const_iterator cl = m_cutlines.begin (); cl != m_cutlines.end (); ++cl) {
- if (db::sprod_sign (p - cl->p1 (), cl->d ()) < 0) {
+ if (db::sprod_sign (p - m_original, cl->d ()) < 0) {
return;
}
}
@@ -765,10 +765,12 @@ do_obj_snap (lay::LayoutView *view, const db::DPoint &pt, const db::DVector &gri
}
std::pair
-do_obj_snap2 (lay::LayoutView *view, const db::DPoint &pt, const db::DVector &grid, double min_search_range, double max_search_range, const std::vector &cutlines)
+do_obj_snap2 (lay::LayoutView *view, const db::DPoint &pt1, const db::DPoint &pt2, const db::DVector &grid, double min_search_range, double max_search_range, const std::vector &cutlines)
{
- db::DPoint dp (pt);
- ContourFinder finder (dp, grid, cutlines, false /*no vertex snap*/);
+ db::DPoint dp1 (pt1);
+ db::DPoint dp2 (pt2);
+
+ ContourFinder finder (dp1, grid, cutlines, false /*no vertex snap*/);
double sr = min_search_range;
while (sr < max_search_range + 1e-6) {
@@ -788,9 +790,9 @@ do_obj_snap2 (lay::LayoutView *view, const db::DPoint &pt, const db::DVector &gr
for (std::vector::const_iterator i = cutlines.begin (); i != cutlines.end (); ++i) {
db::DVector n = i->d ();
- db::DVector d = dp - p1;
+ db::DVector d = dp2 - p1;
if (fabs (db::vprod (n, d)) < 1e-6 * n.length () * d.length ()) {
- if (db::sprod (n, d) < 0.0) {
+ if (db::sprod_sign (n, d) < 0) {
n = -n;
}
cl.push_back (db::DEdge (p1, p1 + n));
@@ -801,14 +803,14 @@ do_obj_snap2 (lay::LayoutView *view, const db::DPoint &pt, const db::DVector &gr
} else if (finder.has_found_edge ()) {
n = finder.get_found_edge ().d ().transformed (db::DTrans (db::DTrans::r90));
- if (db::sprod (n, dp - p1) < 0.0) {
+ if (db::sprod_sign (n, dp2 - p1) < 0) {
n = -n;
}
cl.push_back (db::DEdge (p1, p1 + n));
}
- ContourFinder finder2 (dp, grid, cl, false /*no vertex snap*/, true /*directional cutlines*/);
+ ContourFinder finder2 (dp2, grid, cl, false /*no vertex snap*/, true /*directional cutlines*/);
double sr2 = min_search_range;
while (sr2 < max_search_range + 1e-6) {
@@ -872,17 +874,33 @@ obj_snap (lay::LayoutView *view, const db::DPoint &p1, const db::DPoint &p2, con
std::pair
obj_snap2 (lay::LayoutView *view, const db::DPoint &pt, const db::DVector &grid, double min_search_range, double max_search_range)
{
- return do_obj_snap2 (view, lay::snap_xy (pt, grid), db::DVector (), min_search_range, max_search_range, std::vector ());
+ return obj_snap2 (view, pt, pt, grid, min_search_range, max_search_range);
}
std::pair
-obj_snap2 (lay::LayoutView *view, const db::DPoint &pt, const db::DVector &grid, lay::angle_constraint_type snap_mode, double min_search_range, double max_search_range)
+obj_snap2 (lay::LayoutView *view, const db::DPoint &pt, const db::DVector &grid, lay::angle_constraint_type ac, double min_search_range, double max_search_range)
{
- db::DPoint dp = lay::snap_xy (pt, grid);
+ return obj_snap2 (view, pt, pt, grid, ac, min_search_range, max_search_range);
+}
+
+std::pair
+obj_snap2 (lay::LayoutView *view, const db::DPoint &pt1, const db::DPoint &pt2, const db::DVector &grid, double min_search_range, double max_search_range)
+{
+ db::DPoint dp1 = lay::snap_xy (pt1, grid);
+ db::DPoint dp2 = lay::snap_xy (pt2, grid);
+
+ return do_obj_snap2 (view, dp1, dp2, db::DVector (), min_search_range, max_search_range, std::vector ());
+}
+
+std::pair
+obj_snap2 (lay::LayoutView *view, const db::DPoint &pt1, const db::DPoint &pt2, const db::DVector &grid, lay::angle_constraint_type snap_mode, double min_search_range, double max_search_range)
+{
+ db::DPoint dp1 = lay::snap_xy (pt1, grid);
+ db::DPoint dp2 = lay::snap_xy (pt2, grid);
std::vector cutlines;
- make_cutlines (snap_mode, dp, cutlines);
- return do_obj_snap2 (view, dp, db::DVector (), min_search_range, max_search_range, cutlines);
+ make_cutlines (snap_mode, dp1, cutlines);
+ return do_obj_snap2 (view, dp1, dp2, db::DVector (), min_search_range, max_search_range, cutlines);
}
}
diff --git a/src/laybasic/laybasic/laySnap.h b/src/laybasic/laybasic/laySnap.h
index 9e7248446..1913887da 100644
--- a/src/laybasic/laybasic/laySnap.h
+++ b/src/laybasic/laybasic/laySnap.h
@@ -143,6 +143,16 @@ namespace lay
*/
LAYBASIC_PUBLIC std::pair obj_snap2 (lay::LayoutView *view, const db::DPoint &pt, const db::DVector &grid, double min_search_range, double max_search_range);
+ /**
+ * @brief Same than obj_snap, but delivers two points on two opposite sides of the initial points
+ *
+ * This method basically implements "auto measure". The first value of the returned pair
+ * is true if such an edge could be found. Otherwise it's false.
+ *
+ * This version accepts two points defining different search regions for first and second edge.
+ */
+ LAYBASIC_PUBLIC std::pair obj_snap2 (lay::LayoutView *view, const db::DPoint &pt1, const db::DPoint &pt2, const db::DVector &grid, double min_search_range, double max_search_range);
+
/**
* @brief Same than the previous obj_snap2, but allows specification of an angle constraint
*
@@ -150,6 +160,15 @@ namespace lay
*/
LAYBASIC_PUBLIC std::pair obj_snap2 (lay::LayoutView *view, const db::DPoint &pt, const db::DVector &grid, lay::angle_constraint_type ac, double min_search_range, double max_search_range);
+ /**
+ * @brief Same than the previous obj_snap2, but allows specification of an angle constraint
+ *
+ * Measurements will be confined to the direction specified.
+ *
+ * This version accepts two points defining different search regions for first and second edge.
+ */
+ LAYBASIC_PUBLIC std::pair obj_snap2 (lay::LayoutView *view, const db::DPoint &pt1, const db::DPoint &pt2, const db::DVector &grid, lay::angle_constraint_type ac, double min_search_range, double max_search_range);
+
/**
* @brief Reduce a given vector according to the angle constraint
*/