mirror of
https://github.com/KLayout/klayout.git
synced 2026-08-30 09:49:21 +02:00
WIP: mouse cursor and snap highlighting
This commit is contained in:
@@ -726,7 +726,7 @@ private:
|
||||
bool m_directed;
|
||||
};
|
||||
|
||||
static std::pair <bool, db::DPoint>
|
||||
static PointSnapToObjectResult
|
||||
do_obj_snap (lay::LayoutView *view, const db::DPoint &pt, const db::DVector &grid, double snap_range, const std::vector <db::DEdge> &cutlines)
|
||||
{
|
||||
db::DPoint dp (pt);
|
||||
@@ -753,25 +753,45 @@ do_obj_snap (lay::LayoutView *view, const db::DPoint &pt, const db::DVector &gri
|
||||
}
|
||||
}
|
||||
|
||||
if (finder.any () && anyp) {
|
||||
// if both the projection and the finder are sucessful, decide by a heuristic criterion which to take
|
||||
// (the projection gets a penalty (of the snap range) to make it count less than the finder's choice)
|
||||
// This avoids extreme distortions of the ruler due to projection on long edges.
|
||||
if ((dp.distance (closest) + snap_range) * 5.0 < dp.distance (finder.get_found ())) {
|
||||
return std::make_pair (false, closest);
|
||||
} else {
|
||||
return std::make_pair (true, finder.get_found ());
|
||||
}
|
||||
// if both the projection and the finder are sucessful, decide by a heuristic criterion which to take
|
||||
// (the projection gets a penalty (of the snap range) to make it count less than the finder's choice)
|
||||
// This avoids extreme distortions of the ruler due to projection on long edges.
|
||||
if (finder.any () && anyp && (dp.distance (closest) + snap_range) * 5.0 < dp.distance (finder.get_found ())) {
|
||||
|
||||
PointSnapToObjectResult res;
|
||||
res.snapped_point = closest;
|
||||
return res;
|
||||
|
||||
} else if (finder.any ()) {
|
||||
return std::make_pair (true, finder.get_found ());
|
||||
|
||||
PointSnapToObjectResult res;
|
||||
res.snapped_point = finder.get_found ();
|
||||
res.object_ref = finder.get_found_edge ();
|
||||
if (finder.is_vertex ()) {
|
||||
res.object_snap = PointSnapToObjectResult::ObjectVertex;
|
||||
} else if (finder.has_found_edge ()) {
|
||||
res.object_snap = PointSnapToObjectResult::ObjectEdge;
|
||||
} else {
|
||||
res.object_snap = PointSnapToObjectResult::ObjectUnspecific;
|
||||
}
|
||||
return res;
|
||||
|
||||
} else if (anyp) {
|
||||
return std::make_pair (false, closest);
|
||||
|
||||
PointSnapToObjectResult res;
|
||||
res.snapped_point = closest;
|
||||
return res;
|
||||
|
||||
} else {
|
||||
return std::make_pair (false, dp);
|
||||
|
||||
PointSnapToObjectResult res;
|
||||
res.snapped_point = dp;
|
||||
return res;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
std::pair <bool, db::DEdge>
|
||||
static TwoPointSnapToObjectResult
|
||||
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 <db::DEdge> &cutlines)
|
||||
{
|
||||
db::DPoint dp1 (pt1);
|
||||
@@ -828,15 +848,41 @@ do_obj_snap2 (lay::LayoutView *view, const db::DPoint &pt1, const db::DPoint &pt
|
||||
|
||||
finder2.find (view, sr2);
|
||||
if (finder2.any_exact ()) {
|
||||
|
||||
db::DPoint p2 = finder2.get_found ();
|
||||
return std::make_pair (true, db::DEdge (p1, p2));
|
||||
|
||||
TwoPointSnapToObjectResult res;
|
||||
res.any = true;
|
||||
res.first = p1;
|
||||
res.second = p2;
|
||||
|
||||
res.object_ref_first = finder.get_found_edge ();
|
||||
if (finder.is_vertex ()) {
|
||||
res.object_snap_first = TwoPointSnapToObjectResult::ObjectVertex;
|
||||
} else if (finder.has_found_edge ()) {
|
||||
res.object_snap_first = TwoPointSnapToObjectResult::ObjectEdge;
|
||||
} else {
|
||||
res.object_snap_first = TwoPointSnapToObjectResult::ObjectUnspecific;
|
||||
}
|
||||
|
||||
res.object_ref_second = finder2.get_found_edge ();
|
||||
if (finder2.is_vertex ()) {
|
||||
res.object_snap_second = TwoPointSnapToObjectResult::ObjectVertex;
|
||||
} else if (finder2.has_found_edge ()) {
|
||||
res.object_snap_second = TwoPointSnapToObjectResult::ObjectEdge;
|
||||
} else {
|
||||
res.object_snap_second = TwoPointSnapToObjectResult::ObjectUnspecific;
|
||||
}
|
||||
|
||||
return res;
|
||||
|
||||
}
|
||||
|
||||
sr2 *= 2.0;
|
||||
|
||||
}
|
||||
|
||||
return std::make_pair (false, db::DEdge ());
|
||||
return TwoPointSnapToObjectResult ();
|
||||
|
||||
}
|
||||
|
||||
@@ -844,7 +890,7 @@ do_obj_snap2 (lay::LayoutView *view, const db::DPoint &pt1, const db::DPoint &pt
|
||||
|
||||
}
|
||||
|
||||
return std::make_pair (false, db::DEdge ());
|
||||
return TwoPointSnapToObjectResult ();
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -868,13 +914,13 @@ make_cutlines (lay::angle_constraint_type snap_mode, const db::DPoint &p1, std::
|
||||
}
|
||||
}
|
||||
|
||||
std::pair <bool, db::DPoint>
|
||||
PointSnapToObjectResult
|
||||
obj_snap (lay::LayoutView *view, const db::DPoint &pt, const db::DVector &grid, double snap_range)
|
||||
{
|
||||
return do_obj_snap (view, pt, grid, snap_range, std::vector<db::DEdge> ());
|
||||
}
|
||||
|
||||
std::pair <bool, db::DPoint>
|
||||
PointSnapToObjectResult
|
||||
obj_snap (lay::LayoutView *view, const db::DPoint &p1, const db::DPoint &p2, const db::DVector &grid, lay::angle_constraint_type snap_mode, double snap_range)
|
||||
{
|
||||
std::vector <db::DEdge> cutlines;
|
||||
@@ -882,19 +928,19 @@ obj_snap (lay::LayoutView *view, const db::DPoint &p1, const db::DPoint &p2, con
|
||||
return do_obj_snap (view, p2, grid, snap_range, cutlines);
|
||||
}
|
||||
|
||||
std::pair <bool, db::DEdge>
|
||||
TwoPointSnapToObjectResult
|
||||
obj_snap2 (lay::LayoutView *view, const db::DPoint &pt, const db::DVector &grid, double min_search_range, double max_search_range)
|
||||
{
|
||||
return obj_snap2 (view, pt, pt, grid, min_search_range, max_search_range);
|
||||
}
|
||||
|
||||
std::pair <bool, db::DEdge>
|
||||
TwoPointSnapToObjectResult
|
||||
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)
|
||||
{
|
||||
return obj_snap2 (view, pt, pt, grid, ac, min_search_range, max_search_range);
|
||||
}
|
||||
|
||||
std::pair <bool, db::DEdge>
|
||||
TwoPointSnapToObjectResult
|
||||
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);
|
||||
@@ -903,7 +949,7 @@ obj_snap2 (lay::LayoutView *view, const db::DPoint &pt1, const db::DPoint &pt2,
|
||||
return do_obj_snap2 (view, dp1, dp2, db::DVector (), min_search_range, max_search_range, std::vector<db::DEdge> ());
|
||||
}
|
||||
|
||||
std::pair <bool, db::DEdge>
|
||||
TwoPointSnapToObjectResult
|
||||
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);
|
||||
|
||||
@@ -108,6 +108,36 @@ namespace lay
|
||||
*/
|
||||
LAYBASIC_PUBLIC std::pair<db::DPoint, db::DPoint> snap (const db::DPoint &p1, const db::DPoint &p2, db::DCoord grid);
|
||||
|
||||
/**
|
||||
* @brief A structure describing the snap result for a point-wise snap
|
||||
*/
|
||||
struct LAYBASIC_PUBLIC PointSnapToObjectResult
|
||||
{
|
||||
enum ObjectSnap {
|
||||
NoObject = 0,
|
||||
ObjectVertex,
|
||||
ObjectEdge,
|
||||
ObjectUnspecific
|
||||
};
|
||||
|
||||
PointSnapToObjectResult () : object_snap (NoObject) { }
|
||||
|
||||
/**
|
||||
* @brief The result of the snap
|
||||
*/
|
||||
db::DPoint snapped_point;
|
||||
|
||||
/**
|
||||
* @brief Indicates whether and how the point was snapped to an object
|
||||
*/
|
||||
ObjectSnap object_snap;
|
||||
|
||||
/**
|
||||
* @brief Indicates the edge the point was snapped against unless in NoObject mode
|
||||
*/
|
||||
db::DEdge object_ref;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief combined grid-, projection- and object snapping provided to implementing "magnetic features"
|
||||
*
|
||||
@@ -115,17 +145,14 @@ namespace lay
|
||||
* to an object edge or point. It will use a heuristics to determine
|
||||
* what criterion is applied if a conflict is detected.
|
||||
*
|
||||
* The function will return a pair of the "stiffness" flag and the resulting point. The
|
||||
* "stiffness" is a measure if the result point can be moved if another snap will be applied.
|
||||
* It is true if the point is not intended to be moved further, i.e. because it snapped to
|
||||
* a grid point or a object vertex.
|
||||
* The function will return a PointSnapToObjectResult object.
|
||||
*
|
||||
* @param view The layout view used for object snapping. Can be 0 to disable object snapping
|
||||
* @param pt The point to snap
|
||||
* @param grid Either (0,0) to disable grid snapping or a (gx,gy) value for the (potentially anisotropic grid)
|
||||
* @param snap_range The search range for objects
|
||||
*/
|
||||
LAYBASIC_PUBLIC std::pair <bool, db::DPoint> obj_snap (lay::LayoutView *view, const db::DPoint &pt, const db::DVector &grid, double snap_range);
|
||||
LAYBASIC_PUBLIC PointSnapToObjectResult obj_snap (lay::LayoutView *view, const db::DPoint &pt, const db::DVector &grid, double snap_range);
|
||||
|
||||
/**
|
||||
* @brief combined grid-, projection- and object snapping provided to implementing "magnetic features"
|
||||
@@ -133,7 +160,45 @@ namespace lay
|
||||
* This is a convenience method that creates the projection axes from a reference point and an angle mode.
|
||||
* "pr" is the reference point, "pt" is the point to snap.
|
||||
*/
|
||||
LAYBASIC_PUBLIC std::pair <bool, db::DPoint> obj_snap (lay::LayoutView *view, const db::DPoint &pr, const db::DPoint &pt, const db::DVector &grid, lay::angle_constraint_type ac, double snap_range);
|
||||
LAYBASIC_PUBLIC PointSnapToObjectResult obj_snap (lay::LayoutView *view, const db::DPoint &pr, const db::DPoint &pt, const db::DVector &grid, lay::angle_constraint_type ac, double snap_range);
|
||||
|
||||
/**
|
||||
* @brief A structure describing the snap result for a two-sided object snap (distance measurement)
|
||||
*/
|
||||
struct LAYBASIC_PUBLIC TwoPointSnapToObjectResult
|
||||
{
|
||||
enum ObjectSnap {
|
||||
NoObject = 0,
|
||||
ObjectVertex,
|
||||
ObjectEdge,
|
||||
ObjectUnspecific
|
||||
};
|
||||
|
||||
TwoPointSnapToObjectResult () : any (false), object_snap_first (NoObject), object_snap_second (NoObject) { }
|
||||
|
||||
/**
|
||||
* @brief Indicates whether the two-sided snap was successful
|
||||
*/
|
||||
bool any;
|
||||
|
||||
/**
|
||||
* @brief The result of the snap
|
||||
* Two values are provided for the first and second snap.
|
||||
*/
|
||||
db::DPoint first, second;
|
||||
|
||||
/**
|
||||
* @brief Indicates whether and how the point was snapped to an object
|
||||
* Two values are provided for the first and second snap.
|
||||
*/
|
||||
ObjectSnap object_snap_first, object_snap_second;
|
||||
|
||||
/**
|
||||
* @brief Indicates the edge the point was snapped against unless in NoObject mode
|
||||
* Two values are provided for the first and second snap.
|
||||
*/
|
||||
db::DEdge object_ref_first, object_ref_second;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Same than obj_snap, but delivers two points on two opposite sides of the initial point
|
||||
@@ -141,7 +206,7 @@ namespace lay
|
||||
* 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.
|
||||
*/
|
||||
LAYBASIC_PUBLIC std::pair <bool, db::DEdge> obj_snap2 (lay::LayoutView *view, const db::DPoint &pt, const db::DVector &grid, double min_search_range, double max_search_range);
|
||||
LAYBASIC_PUBLIC TwoPointSnapToObjectResult 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
|
||||
@@ -151,14 +216,14 @@ namespace lay
|
||||
*
|
||||
* This version accepts two points defining different search regions for first and second edge.
|
||||
*/
|
||||
LAYBASIC_PUBLIC std::pair <bool, db::DEdge> 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);
|
||||
LAYBASIC_PUBLIC TwoPointSnapToObjectResult 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
|
||||
*
|
||||
* Measurements will be confined to the direction specified.
|
||||
*/
|
||||
LAYBASIC_PUBLIC std::pair <bool, db::DEdge> 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);
|
||||
LAYBASIC_PUBLIC TwoPointSnapToObjectResult 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
|
||||
@@ -167,7 +232,7 @@ namespace lay
|
||||
*
|
||||
* This version accepts two points defining different search regions for first and second edge.
|
||||
*/
|
||||
LAYBASIC_PUBLIC std::pair <bool, db::DEdge> 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);
|
||||
LAYBASIC_PUBLIC TwoPointSnapToObjectResult 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
|
||||
|
||||
@@ -51,95 +51,101 @@ TEST(1)
|
||||
|
||||
view.set_max_hier_levels (1);
|
||||
|
||||
std::pair<bool, db::DPoint> res;
|
||||
lay::PointSnapToObjectResult res;
|
||||
|
||||
// not hit
|
||||
res = lay::obj_snap (&view, db::DPoint (1.505, 1.505), db::DVector (), 0.1);
|
||||
EXPECT_EQ (res.first, false);
|
||||
EXPECT_EQ (res.second.to_string (), "1.505,1.505");
|
||||
EXPECT_EQ (res.object_snap, lay::PointSnapToObjectResult::NoObject);
|
||||
EXPECT_EQ (res.snapped_point.to_string (), "1.505,1.505");
|
||||
|
||||
res = lay::obj_snap (&view, db::DPoint (0.505, 0.505), db::DVector (), 0.1);
|
||||
EXPECT_EQ (res.first, true);
|
||||
EXPECT_EQ (res.second.to_string (), "0.5,0.5");
|
||||
EXPECT_EQ (res.object_snap, lay::PointSnapToObjectResult::ObjectEdge);
|
||||
EXPECT_EQ (res.snapped_point.to_string (), "0.5,0.5");
|
||||
|
||||
res = lay::obj_snap (&view, db::DPoint (0.485, 0.505), db::DVector (0.01, 0.01), 0.1);
|
||||
EXPECT_EQ (res.first, true);
|
||||
EXPECT_EQ (res.second.to_string (), "0.49,0.51");
|
||||
EXPECT_EQ (res.object_snap, lay::PointSnapToObjectResult::ObjectEdge);
|
||||
EXPECT_EQ (res.snapped_point.to_string (), "0.49,0.51");
|
||||
EXPECT_EQ (res.object_ref.to_string (), "(0,1;1,0)");
|
||||
|
||||
res = lay::obj_snap (&view, db::DPoint (0.205, 0.215), db::DVector (0.01, 0.025), 0.1);
|
||||
EXPECT_EQ (res.first, false);
|
||||
EXPECT_EQ (res.second.to_string (), "0.21,0.225");
|
||||
EXPECT_EQ (res.object_snap, lay::PointSnapToObjectResult::NoObject);
|
||||
EXPECT_EQ (res.snapped_point.to_string (), "0.21,0.225");
|
||||
|
||||
res = lay::obj_snap (&view, db::DPoint (0.505, 1.005), db::DVector (), 0.1);
|
||||
EXPECT_EQ (res.first, false);
|
||||
EXPECT_EQ (res.second.to_string (), "0.505,1.005");
|
||||
EXPECT_EQ (res.object_snap, lay::PointSnapToObjectResult::NoObject);
|
||||
EXPECT_EQ (res.snapped_point.to_string (), "0.505,1.005");
|
||||
|
||||
res = lay::obj_snap (&view, db::DPoint (0.005, 1.005), db::DVector (), 0.1);
|
||||
EXPECT_EQ (res.first, true);
|
||||
EXPECT_EQ (res.second.to_string (), "0,1");
|
||||
EXPECT_EQ (res.object_snap, lay::PointSnapToObjectResult::ObjectVertex);
|
||||
EXPECT_EQ (res.snapped_point.to_string (), "0,1");
|
||||
|
||||
res = lay::obj_snap (&view, db::DPoint (0.0, 1.005), db::DVector (), 0.1);
|
||||
EXPECT_EQ (res.object_snap, lay::PointSnapToObjectResult::ObjectVertex);
|
||||
EXPECT_EQ (res.snapped_point.to_string (), "0,1");
|
||||
|
||||
res = lay::obj_snap (&view, db::DPoint (1.000, 0.505), db::DPoint (0.505, 0.500), db::DVector (), lay::AC_Horizontal, 0.1);
|
||||
EXPECT_EQ (res.first, true);
|
||||
EXPECT_EQ (res.second.to_string (), "0.495,0.505");
|
||||
EXPECT_EQ (res.object_snap, lay::PointSnapToObjectResult::ObjectEdge);
|
||||
EXPECT_EQ (res.snapped_point.to_string (), "0.495,0.505");
|
||||
|
||||
// projected snapping
|
||||
res = lay::obj_snap (&view, db::DPoint (1.000, 0.505), db::DPoint (0.005, 1.005), db::DVector (), lay::AC_Horizontal, 0.1);
|
||||
EXPECT_EQ (res.first, true);
|
||||
EXPECT_EQ (res.second.to_string (), "0,0.505");
|
||||
EXPECT_EQ (res.object_snap, lay::PointSnapToObjectResult::ObjectUnspecific);
|
||||
EXPECT_EQ (res.snapped_point.to_string (), "0,0.505");
|
||||
EXPECT_EQ (res.object_ref.to_string (), "(0,1;0,1)");
|
||||
|
||||
std::pair<bool, db::DEdge> res2;
|
||||
lay::TwoPointSnapToObjectResult res2;
|
||||
|
||||
res2 = lay::obj_snap2 (&view, db::DPoint (1.5, 1.5), db::DVector (), 0.005, 1.0);
|
||||
EXPECT_EQ (res2.first, false);
|
||||
EXPECT_EQ (res2.second.to_string (), "(0,0;0,0)");
|
||||
EXPECT_EQ (res2.any, false);
|
||||
EXPECT_EQ (db::DEdge (res2.first, res2.second).to_string (), "(0,0;0,0)");
|
||||
|
||||
res2 = lay::obj_snap2 (&view, db::DPoint (0.205, 0.5), db::DVector (), 0.005, 1.0);
|
||||
EXPECT_EQ (res2.first, true);
|
||||
EXPECT_EQ (res2.second.to_string (), "(0.3525,0.6475;0,0.295)");
|
||||
EXPECT_EQ (res2.any, true);
|
||||
EXPECT_EQ (db::DEdge (res2.first, res2.second).to_string (), "(0.3525,0.6475;0,0.295)");
|
||||
|
||||
res2 = lay::obj_snap2 (&view, db::DPoint (0.205, 0.5), db::DVector (), lay::AC_Horizontal, 0.005, 1.0);
|
||||
EXPECT_EQ (res2.first, true);
|
||||
EXPECT_EQ (res2.second.to_string (), "(0,0.5;0.5,0.5)");
|
||||
EXPECT_EQ (res2.any, true);
|
||||
EXPECT_EQ (db::DEdge (res2.first, res2.second).to_string (), "(0,0.5;0.5,0.5)");
|
||||
|
||||
res2 = lay::obj_snap2 (&view, db::DPoint (0.205, 0.5), db::DVector (0.03, 0.03), lay::AC_Horizontal, 0.005, 1.0);
|
||||
EXPECT_EQ (res2.first, true);
|
||||
EXPECT_EQ (res2.second.to_string (), "(0,0.51;0.49,0.51)");
|
||||
EXPECT_EQ (res2.any, true);
|
||||
EXPECT_EQ (db::DEdge (res2.first, res2.second).to_string (), "(0,0.51;0.49,0.51)");
|
||||
|
||||
res2 = lay::obj_snap2 (&view, db::DPoint (0.205, 0.5), db::DVector (), lay::AC_Vertical, 0.005, 1.0);
|
||||
EXPECT_EQ (res2.first, true);
|
||||
EXPECT_EQ (res2.second.to_string (), "(0.205,0.795;0.205,0)");
|
||||
EXPECT_EQ (res2.any, true);
|
||||
EXPECT_EQ (db::DEdge (res2.first, res2.second).to_string (), "(0.205,0.795;0.205,0)");
|
||||
|
||||
res2 = lay::obj_snap2 (&view, db::DPoint (0.205, 0.5), db::DVector (), lay::AC_Diagonal, 0.005, 1.0);
|
||||
EXPECT_EQ (res2.first, true);
|
||||
EXPECT_EQ (res2.second.to_string (), "(0.3525,0.6475;0,0.295)");
|
||||
EXPECT_EQ (res2.any, true);
|
||||
EXPECT_EQ (db::DEdge (res2.first, res2.second).to_string (), "(0.3525,0.6475;0,0.295)");
|
||||
|
||||
res2 = lay::obj_snap2 (&view, db::DPoint (0.205, 0.505), db::DVector (), lay::AC_Ortho, 0.005, 1.0);
|
||||
EXPECT_EQ (res2.first, true);
|
||||
EXPECT_EQ (res2.second.to_string (), "(0,0.505;0.495,0.505)");
|
||||
EXPECT_EQ (res2.any, true);
|
||||
EXPECT_EQ (db::DEdge (res2.first, res2.second).to_string (), "(0,0.505;0.495,0.505)");
|
||||
|
||||
res2 = lay::obj_snap2 (&view, db::DPoint (0.205, 0.5), db::DVector (), lay::AC_Any, 0.005, 1.0);
|
||||
EXPECT_EQ (res2.first, true);
|
||||
EXPECT_EQ (res2.second.to_string (), "(0.3525,0.6475;0,0.295)");
|
||||
EXPECT_EQ (res2.any, true);
|
||||
EXPECT_EQ (db::DEdge (res2.first, res2.second).to_string (), "(0.3525,0.6475;0,0.295)");
|
||||
|
||||
res2 = lay::obj_snap2 (&view, db::DPoint (0.205, 0.495), db::DVector (0.01, 0.01), 0.005, 1.0);
|
||||
EXPECT_EQ (res2.first, true);
|
||||
EXPECT_EQ (res2.second.to_string (), "(0.355,0.645;0,0.29)");
|
||||
EXPECT_EQ (res2.any, true);
|
||||
EXPECT_EQ (db::DEdge (res2.first, res2.second).to_string (), "(0.355,0.645;0,0.29)");
|
||||
|
||||
res2 = lay::obj_snap2 (&view, db::DPoint (0.5, 0.5), db::DVector (), 0.005, 1.0);
|
||||
EXPECT_EQ (res2.first, false);
|
||||
EXPECT_EQ (res2.second.to_string (), "(0,0;0,0)");
|
||||
EXPECT_EQ (res2.any, false);
|
||||
EXPECT_EQ (db::DEdge (res2.first, res2.second).to_string (), "(0,0;0,0)");
|
||||
|
||||
res2 = lay::obj_snap2 (&view, db::DPoint (0.005, 0.5), db::DVector (), 0.005, 1.0);
|
||||
EXPECT_EQ (res2.first, true);
|
||||
EXPECT_EQ (res2.second.to_string (), "(0,0.5;0.5,0.5)");
|
||||
EXPECT_EQ (res2.any, true);
|
||||
EXPECT_EQ (db::DEdge (res2.first, res2.second).to_string (), "(0,0.5;0.5,0.5)");
|
||||
|
||||
res2 = lay::obj_snap2 (&view, db::DPoint (0.0, 0.5), db::DVector (), 0.005, 1.0);
|
||||
EXPECT_EQ (res2.first, false);
|
||||
EXPECT_EQ (res2.second.to_string (), "(0,0;0,0)");
|
||||
EXPECT_EQ (res2.any, false);
|
||||
EXPECT_EQ (db::DEdge (res2.first, res2.second).to_string (), "(0,0;0,0)");
|
||||
|
||||
res2 = lay::obj_snap2 (&view, db::DPoint (-0.2, 0.5), db::DVector (), 0.005, 1.0);
|
||||
EXPECT_EQ (res2.first, false);
|
||||
EXPECT_EQ (res2.second.to_string (), "(0,0;0,0)");
|
||||
EXPECT_EQ (res2.any, false);
|
||||
EXPECT_EQ (db::DEdge (res2.first, res2.second).to_string (), "(0,0;0,0)");
|
||||
|
||||
}
|
||||
|
||||
@@ -13,10 +13,10 @@ SOURCES = \
|
||||
layLayerProperties.cc \
|
||||
layParsedLayerSource.cc \
|
||||
layRenderer.cc \
|
||||
laySnap.cc \
|
||||
layNetlistBrowserModelTests.cc \
|
||||
layNetlistBrowserTreeModelTests.cc \
|
||||
layAbstractMenuTests.cc
|
||||
layAbstractMenuTests.cc \
|
||||
laySnapTests.cc
|
||||
|
||||
INCLUDEPATH += $$TL_INC $$LAYBASIC_INC $$DB_INC $$GSI_INC $$OUT_PWD/../laybasic
|
||||
DEPENDPATH += $$TL_INC $$LAYBASIC_INC $$DB_INC $$GSI_INC $$OUT_PWD/../laybasic
|
||||
|
||||
Reference in New Issue
Block a user