Compare commits

..

3 Commits

Author SHA1 Message Date
Matthias Köfferlein 701bd3b543
Merge ddc847ac1f into 8b010d61d2 2025-11-01 15:44:51 +00:00
Matthias Koefferlein ddc847ac1f Object snapping: now snapping to edge centers for polygons and boxes, snapping to box centers 2025-11-01 16:44:40 +01:00
Matthias Koefferlein 289facd5ee Merge branch 'master' into devel 2025-10-26 16:36:03 +01:00
1 changed files with 25 additions and 5 deletions

View File

@ -613,7 +613,7 @@ private:
if (shape->is_polygon ()) {
for (db::Shape::polygon_edge_iterator e = shape->begin_edge (); ! e.at_end (); ++e) {
test_edge (t * *e);
test_edge_with_center (t * *e);
}
} else if (shape->is_path ()) {
@ -649,16 +649,20 @@ private:
}
test_edge (db::DEdge (*p, pts [0]));
}
} else if (shape->is_box ()) {
const db::Box &box = shape->box ();
test_edge (t * db::Edge (box.p1 (), db::Point (box.left (), box.top ())));
test_edge (t * db::Edge (db::Point (box.left (), box.top ()), box.p2 ()));
test_edge (t * db::Edge (box.p2 (), db::Point (box.right (), box.bottom ())));
test_edge (t * db::Edge (db::Point (box.right (), box.bottom ()), box.p1 ()));
test_edge_with_center (t * db::Edge (box.p1 (), db::Point (box.left (), box.top ())));
test_edge_with_center (t * db::Edge (db::Point (box.left (), box.top ()), box.p2 ()));
test_edge_with_center (t * db::Edge (box.p2 (), db::Point (box.right (), box.bottom ())));
test_edge_with_center (t * db::Edge (db::Point (box.right (), box.bottom ()), box.p1 ()));
// test for box center
test_edge (t * db::Edge (box.center (), box.center ()));
} else if (shape->is_point ()) {
@ -697,6 +701,22 @@ private:
}
void
test_edge_with_center (const db::DEdge &edg)
{
if (m_with_vertex && ! edg.is_degenerate ()) {
db::DPoint c = edg.p1 () + (edg.p2 () - edg.p1 ()) * 0.5;
if (m_region.contains (c)) {
closest (c);
}
}
test_edge (edg);
}
void
test_edge (const db::DEdge &edg)
{