Editor option for controlling snapping (snap to grid while moving), more consistent snap behavior, instance snapping

This commit is contained in:
Matthias Koefferlein
2023-10-05 22:25:30 +02:00
parent 99742581c2
commit 3fbdb065fd
12 changed files with 113 additions and 42 deletions
+8
View File
@@ -439,6 +439,14 @@ public:
*/
~InstanceMarker ();
/**
* @brief Gets the instance
*/
const db::Instance &instance () const
{
return m_inst;
}
/**
* @brief Set the instance the marker is to display
*
+8 -1
View File
@@ -183,7 +183,7 @@ draw_round_dbl (const db::DPoint &p1, const db::DPoint &p2, int /*h*/)
}
db::DVector
snap_angle (const db::DVector &in, lay::angle_constraint_type ac)
snap_angle (const db::DVector &in, lay::angle_constraint_type ac, db::DVector *snapped_to)
{
std::vector <db::DVector> ref_dir;
if (ac != lay::AC_Any) {
@@ -206,11 +206,17 @@ snap_angle (const db::DVector &in, lay::angle_constraint_type ac)
proj = db::sprod (*re, in) / (elen * re->length ());
if (proj > max_proj) {
max_proj = proj;
if (snapped_to) {
*snapped_to = *re;
}
out = *re * (elen * proj / re->length ());
}
proj = db::sprod (-*re, in) / (elen * re->length ());
if (proj > max_proj) {
max_proj = proj;
if (snapped_to) {
*snapped_to = *re;
}
out = -*re * (elen * proj / re->length ());
}
}
@@ -218,6 +224,7 @@ snap_angle (const db::DVector &in, lay::angle_constraint_type ac)
return out;
}
// ---------------------------------------------------------------------------------------
// obj_snap implementations
+5 -1
View File
@@ -238,8 +238,12 @@ namespace lay
/**
* @brief Reduce a given vector according to the angle constraint
*
* If the "snapped_to" pointer is non-null, it will receive the snap target
* vector (e.g. (1, 0) for snapping to horizontal axis. If no snapping happens,
* the value of this vector is not changed.
*/
LAYBASIC_PUBLIC db::DVector snap_angle (const db::DVector &in, lay::angle_constraint_type ac);
LAYBASIC_PUBLIC db::DVector snap_angle (const db::DVector &in, lay::angle_constraint_type ac, db::DVector *snapped_to = 0);
/**
* @brief rounding of a double value for drawing purposes