mirror of
https://github.com/KLayout/klayout.git
synced 2026-08-29 17:30:09 +02:00
Editor option for controlling snapping (snap to grid while moving), more consistent snap behavior, instance snapping
This commit is contained in:
@@ -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
|
||||
*
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user