Merge pull request #344 from KLayout/issue-342

Issue 342
This commit is contained in:
Matthias Köfferlein 2019-09-06 23:24:05 +02:00 committed by GitHub
commit 6bf21681ed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
23 changed files with 651 additions and 336 deletions

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>622</width>
<height>502</height>
<height>621</height>
</rect>
</property>
<property name="windowTitle">
@ -53,6 +53,96 @@
<property name="spacing">
<number>6</number>
</property>
<item row="15" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Second point (x/y) </string>
</property>
</widget>
</item>
<item row="10" column="0" colspan="2">
<widget class="QLabel" name="label_16">
<property name="text">
<string>Style</string>
</property>
</widget>
</item>
<item row="12" column="2" colspan="3">
<widget class="QLabel" name="help_label">
<property name="text">
<string>&lt;html&gt;(See &lt;a href=&quot;int:/manual/ruler_properties.xml&quot;&gt;here&lt;/a&gt; for a description of the properties)&lt;/html&gt;</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_25">
<property name="text">
<string> ... position</string>
</property>
</widget>
</item>
<item row="9" column="0" colspan="5">
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>5</height>
</size>
</property>
</spacer>
</item>
<item row="7" column="2" colspan="3">
<widget class="QLineEdit" name="fmt_y_le"/>
</item>
<item row="11" column="2" colspan="3">
<widget class="QComboBox" name="outline_cb">
<item>
<property name="text">
<string>Diagonal</string>
</property>
</item>
<item>
<property name="text">
<string>Horizonal and vertical (in this order)</string>
</property>
</item>
<item>
<property name="text">
<string>Diagonal plus horizonal and vertical (triangle)</string>
</property>
</item>
<item>
<property name="text">
<string>Vertical and horizonal (in this order)</string>
</property>
</item>
<item>
<property name="text">
<string>Diagonal plus vertical and horizontal (triangle)</string>
</property>
</item>
<item>
<property name="text">
<string>Box</string>
</property>
</item>
<item>
<property name="text">
<string>Ellipse</string>
</property>
</item>
</widget>
</item>
<item row="19" column="1">
<widget class="QLabel" name="label_11">
<property name="text">
<string>d = </string>
</property>
</widget>
</item>
<item row="3" column="0" colspan="5">
<spacer name="verticalSpacer">
<property name="orientation">
@ -66,91 +156,22 @@
</property>
</spacer>
</item>
<item row="6" column="0" colspan="5">
<spacer name="verticalSpacer_2">
<item row="13" column="0" colspan="5">
<spacer>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>5</height>
<width>456</width>
<height>16</height>
</size>
</property>
</spacer>
</item>
<item row="15" column="2">
<widget class="QLineEdit" name="x2">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="15" column="1">
<widget class="QLabel" name="label_6">
<property name="text">
<string>x = </string>
</property>
</widget>
</item>
<item row="11" column="0" colspan="2">
<widget class="QLabel" name="label_17">
<property name="text">
<string>Outline</string>
</property>
</widget>
</item>
<item row="12" column="2" colspan="3">
<widget class="QLabel" name="help_label">
<property name="text">
<string>&lt;html&gt;(See &lt;a href=&quot;int:/manual/ruler_properties.xml&quot;&gt;here&lt;/a&gt; for a description of the properties)&lt;/html&gt;</string>
</property>
</widget>
</item>
<item row="17" column="2">
<widget class="QLineEdit" name="dx">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="4" column="0" colspan="2">
<widget class="QLabel" name="label_14">
<property name="text">
<string>X label format</string>
</property>
</widget>
</item>
<item row="14" column="3">
<widget class="QLabel" name="label_7">
<property name="text">
<string>y = </string>
</property>
</widget>
</item>
<item row="15" column="3">
<widget class="QLabel" name="label_8">
<property name="text">
<string>y = </string>
</property>
</widget>
</item>
<item row="18" column="1">
<widget class="QLabel" name="label_11">
<property name="text">
<string>d = </string>
</property>
</widget>
</item>
<item row="10" column="2" colspan="3">
<widget class="QComboBox" name="style_cb">
<item>
@ -195,10 +216,20 @@
</item>
</widget>
</item>
<item row="14" column="4">
<widget class="QLineEdit" name="y1">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="18" column="0">
<widget class="QLabel" name="label_4">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Length</string>
<string>Delta (x/y)</string>
</property>
</widget>
</item>
@ -347,83 +378,38 @@
</layout>
</widget>
</item>
<item row="18" column="2">
<widget class="QLineEdit" name="dd">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="16" column="0" colspan="5">
<item row="17" column="0" colspan="5">
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="15" column="4">
<widget class="QLineEdit" name="y2">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="4" column="2" colspan="3">
<widget class="QLineEdit" name="fmt_x_le"/>
</item>
<item row="17" column="1">
<widget class="QLabel" name="label_9">
<item row="14" column="1">
<widget class="QLabel" name="label_5">
<property name="text">
<string>x = </string>
</property>
</widget>
</item>
<item row="17" column="4">
<widget class="QLineEdit" name="dy">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="14" column="2">
<widget class="QLineEdit" name="x1">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="1" column="2" colspan="3">
<widget class="QLineEdit" name="fmt_le"/>
</item>
<item row="17" column="3">
<widget class="QLabel" name="label_10">
<item row="1" column="0">
<widget class="QLabel" name="label_13">
<property name="text">
<string>y = </string>
<string>Label format</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_25">
<item row="19" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string> ... position</string>
<string>Length</string>
</property>
</widget>
</item>
<item row="11" column="0" colspan="2">
<widget class="QLabel" name="label_17">
<property name="text">
<string>Outline</string>
</property>
</widget>
</item>
@ -538,94 +524,29 @@
</layout>
</widget>
</item>
<item row="14" column="1">
<widget class="QLabel" name="label_5">
<property name="text">
<string>x = </string>
</property>
</widget>
</item>
<item row="0" column="0" colspan="5">
<widget class="QLabel" name="label_12">
<item row="18" column="2">
<widget class="QLineEdit" name="dx">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<family>Sans Serif</family>
<pointsize>12</pointsize>
<weight>75</weight>
<italic>false</italic>
<bold>true</bold>
<underline>false</underline>
<strikeout>false</strikeout>
</font>
</property>
<property name="text">
<string>Ruler Properties</string>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="17" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Delta (x/y)</string>
<item row="19" column="2">
<widget class="QLineEdit" name="dd">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="11" column="2" colspan="3">
<widget class="QComboBox" name="outline_cb">
<item>
<property name="text">
<string>Diagonal</string>
</property>
</item>
<item>
<property name="text">
<string>Horizonal and vertical (in this order)</string>
</property>
</item>
<item>
<property name="text">
<string>Diagonal plus horizonal and vertical (triangle)</string>
</property>
</item>
<item>
<property name="text">
<string>Vertical and horizonal (in this order)</string>
</property>
</item>
<item>
<property name="text">
<string>Diagonal plus vertical and horizontal (triangle)</string>
</property>
</item>
<item>
<property name="text">
<string>Box</string>
</property>
</item>
<item>
<property name="text">
<string>Ellipse</string>
</property>
</item>
</widget>
</item>
<item row="15" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Second point (x/y) </string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_13">
<property name="text">
<string>Label format</string>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
@ -636,31 +557,8 @@
</property>
</widget>
</item>
<item row="13" column="0" colspan="5">
<spacer>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>456</width>
<height>16</height>
</size>
</property>
</spacer>
</item>
<item row="8" column="0">
<widget class="QLabel" name="label_26">
<property name="text">
<string> ... position</string>
</property>
</widget>
</item>
<item row="14" column="4">
<widget class="QLineEdit" name="y1">
<item row="15" column="2">
<widget class="QLineEdit" name="x2">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>1</horstretch>
@ -669,32 +567,112 @@
</property>
</widget>
</item>
<item row="10" column="0" colspan="2">
<widget class="QLabel" name="label_16">
<item row="18" column="3">
<widget class="QLabel" name="label_10">
<property name="text">
<string>Style</string>
<string>y = </string>
</property>
</widget>
</item>
<item row="7" column="2" colspan="3">
<widget class="QLineEdit" name="fmt_y_le"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_18">
<property name="text">
<string> ... position</string>
<item row="16" column="2" colspan="3">
<widget class="QFrame" name="frame_7">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QToolButton" name="swap_points">
<property name="text">
<string>Swap points</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_9">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>10</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label_24">
<property name="text">
<string>Snap to layout:</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="p1_to_layout">
<property name="text">
<string>P1</string>
</property>
<property name="autoRaise">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="p2_to_layout">
<property name="text">
<string>P2</string>
</property>
<property name="autoRaise">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="both_to_layout">
<property name="text">
<string>Both (auto-measure)</string>
</property>
<property name="autoRaise">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item row="7" column="0" colspan="2">
<widget class="QLabel" name="label_15">
<property name="text">
<string>Y label format</string>
</property>
</widget>
</item>
<item row="9" column="0" colspan="5">
<spacer name="verticalSpacer_3">
<item row="6" column="0" colspan="5">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
@ -706,6 +684,49 @@
</property>
</spacer>
</item>
<item row="14" column="3">
<widget class="QLabel" name="label_7">
<property name="text">
<string>y = </string>
</property>
</widget>
</item>
<item row="4" column="2" colspan="3">
<widget class="QLineEdit" name="fmt_x_le"/>
</item>
<item row="18" column="4">
<widget class="QLineEdit" name="dy">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="15" column="4">
<widget class="QLineEdit" name="y2">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_18">
<property name="text">
<string> ... position</string>
</property>
</widget>
</item>
<item row="1" column="2" colspan="3">
<widget class="QLineEdit" name="fmt_le"/>
</item>
<item row="8" column="2" colspan="3">
<widget class="QFrame" name="frame_4">
<property name="frameShape">
@ -817,6 +838,82 @@
</layout>
</widget>
</item>
<item row="8" column="0">
<widget class="QLabel" name="label_26">
<property name="text">
<string> ... position</string>
</property>
</widget>
</item>
<item row="18" column="1">
<widget class="QLabel" name="label_9">
<property name="text">
<string>x = </string>
</property>
</widget>
</item>
<item row="14" column="2">
<widget class="QLineEdit" name="x1">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="7" column="0" colspan="2">
<widget class="QLabel" name="label_15">
<property name="text">
<string>Y label format</string>
</property>
</widget>
</item>
<item row="4" column="0" colspan="2">
<widget class="QLabel" name="label_14">
<property name="text">
<string>X label format</string>
</property>
</widget>
</item>
<item row="15" column="3">
<widget class="QLabel" name="label_8">
<property name="text">
<string>y = </string>
</property>
</widget>
</item>
<item row="15" column="1">
<widget class="QLabel" name="label_6">
<property name="text">
<string>x = </string>
</property>
</widget>
</item>
<item row="0" column="0" colspan="5">
<widget class="QLabel" name="label_12">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<family>Sans Serif</family>
<pointsize>12</pointsize>
<weight>75</weight>
<italic>false</italic>
<bold>true</bold>
<underline>false</underline>
<strikeout>false</strikeout>
</font>
</property>
<property name="text">
<string>Ruler Properties</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>

View File

@ -31,14 +31,25 @@ namespace ant
// -------------------------------------------------------------------------
// PropertiesPage implementation
PropertiesPage::PropertiesPage (ant::Service *rulers, QWidget *parent)
: lay::PropertiesPage (parent, rulers), mp_rulers (rulers), m_enable_cb_callback (true)
PropertiesPage::PropertiesPage (ant::Service *rulers, db::Manager *manager, QWidget *parent)
: lay::PropertiesPage (parent, manager, rulers), mp_rulers (rulers), m_enable_cb_callback (true)
{
mp_rulers->get_selection (m_selection);
m_pos = m_selection.begin ();
setupUi (this);
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 ()));
swap_points->setEnabled (! readonly());
p1_to_layout->setEnabled (! readonly());
p2_to_layout->setEnabled (! readonly());
both_to_layout->setEnabled (! readonly());
lay::activate_help_links (help_label);
mp_rulers->clear_highlights ();
@ -61,6 +72,118 @@ PropertiesPage::front ()
m_pos = m_selection.begin ();
}
void
PropertiesPage::swap_points_clicked ()
{
if (readonly ()) {
return;
}
QString tx1 = x1->text (), tx2 = x2->text ();
QString ty1 = y1->text (), ty2 = y2->text ();
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 ();
}
void
PropertiesPage::snap_to_layout_clicked ()
{
if (readonly ()) {
return;
}
ant::Service *service = dynamic_cast<ant::Service *> (editable ());
tl_assert (service != 0);
double dx1 = 0.0, dy1 = 0.0, dx2 = 0.0, dy2 = 0.0;
tl::from_string (tl::to_string (x1->text ()), dx1);
tl::from_string (tl::to_string (x2->text ()), dx2);
tl::from_string (tl::to_string (y1->text ()), dy1);
tl::from_string (tl::to_string (y2->text ()), dy2);
db::DPoint p1 (dx1, dy1), p2 (dx2, dy2);
ant::Object r = current ();
// for auto-metric we need some cutline constraint - any or global won't do.
lay::angle_constraint_type ac = r.angle_constraint ();
if (ac == lay::AC_Global) {
ac = service->snap_mode ();
}
if (ac == lay::AC_Global) {
ac = lay::AC_Diagonal;
}
db::DVector g;
if (service->grid_snap ()) {
g = db::DVector (service->grid (), service->grid ());
}
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<bool, db::DPoint> 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 ()));
QString ys = tl::to_qstring (tl::micron_to_string (pp.second.y ()));
if (sender () == p1_to_layout) {
x1->setText (xs);
y1->setText (ys);
} else {
x2->setText (xs);
y2->setText (ys);
}
db::Transaction t (manager (), tl::to_string (snap_p1 ? QObject::tr ("Snap first ruler point") : QObject::tr ("Snap second ruler point")));
apply ();
break;
}
// no point found -> one more iteration with increased range
snap_range *= 2.0;
}
} else {
double snap_range = service->widget ()->mouse_event_trans ().inverted ().ctrans (service->snap_range ());
snap_range *= 0.5;
std::pair<bool, db::DEdge> 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 ())));
y1->setText (tl::to_qstring (tl::micron_to_string (ee.second.p1 ().y ())));
x2->setText (tl::to_qstring (tl::micron_to_string (ee.second.p2 ().x ())));
y2->setText (tl::to_qstring (tl::micron_to_string (ee.second.p2 ().y ())));
db::Transaction t (manager (), tl::to_string (QObject::tr ("Snap both ruler points")));
apply ();
}
}
}
const ant::Object &
PropertiesPage::current () const
{

View File

@ -39,7 +39,7 @@ class PropertiesPage
Q_OBJECT
public:
PropertiesPage (ant::Service *rulers, QWidget *parent);
PropertiesPage (ant::Service *rulers, db::Manager *manager, QWidget *parent);
~PropertiesPage ();
virtual void back ();
@ -53,6 +53,10 @@ public:
virtual bool readonly ();
virtual void apply ();
private slots:
void swap_points_clicked ();
void snap_to_layout_clicked ();
private:
std::vector <ant::Service::obj_iterator> m_selection;
std::vector <ant::Service::obj_iterator>::iterator m_pos;

View File

@ -2067,9 +2067,9 @@ Service::display_status (bool transient)
}
lay::PropertiesPage *
Service::properties_page (QWidget *parent)
Service::properties_page (db::Manager *manager, QWidget *parent)
{
return new PropertiesPage (this, parent);
return new PropertiesPage (this, manager, parent);
}
void

View File

@ -333,7 +333,7 @@ public:
/**
* @brief Create the properties page
*/
virtual lay::PropertiesPage *properties_page (QWidget * /*parent*/);
virtual lay::PropertiesPage *properties_page (db::Manager *manager, QWidget *parent);
/**
* @brief Get the selection for the properties page
@ -415,7 +415,39 @@ public:
{
return mp_view;
}
/**
* @brief Gets the snap range
*/
int snap_range () const
{
return m_snap_range;
}
/**
* @brief Gets the global snap mode
*/
lay::angle_constraint_type snap_mode () const
{
return m_snap_mode;
}
/**
* @brief Gets the grid
*/
double grid () const
{
return m_grid;
}
/**
* @brief Gets a value indicating whether to snap to grid
*/
bool grid_snap () const
{
return m_grid_snap;
}
/**
* @brief Implement the menu response function
*/

View File

@ -47,6 +47,7 @@ static int outline_diag_xy () { return int (ant::Object::OL_diag_xy); }
static int outline_yx () { return int (ant::Object::OL_yx); }
static int outline_diag_yx () { return int (ant::Object::OL_diag_yx); }
static int outline_box () { return int (ant::Object::OL_box); }
static int outline_ellipse () { return int (ant::Object::OL_ellipse); }
static int angle_any () { return int (lay::AC_Any); }
static int angle_diagonal () { return int (lay::AC_Diagonal); }
@ -552,6 +553,13 @@ gsi::Class<AnnotationRef> decl_Annotation (decl_BasicAnnotation, "lay", "Annotat
"start and end point. All box edges are drawn in the style specified with the \\style "
"attribute."
) +
gsi::method ("OutlineEllipse|#outline_ellipse", &gsi::outline_ellipse,
"@brief Gets the ellipse outline code for use with the \\outline method\n"
"When this outline style is specified, an ellipse is drawn with the extensions specified by the "
"start and end point. The contour drawn as a line.\n"
"\n"
"This constant has been introduced in version 0.26."
) +
gsi::method ("AngleAny|#angle_any", &gsi::angle_any,
"@brief Gets the any angle code for use with the \\angle_constraint method\n"
"If this value is specified for the angle constraint, all angles will be allowed."

View File

@ -44,8 +44,8 @@ namespace edt
// -------------------------------------------------------------------------
// InstPropertiesPage implementation
InstPropertiesPage::InstPropertiesPage (edt::Service *service, QWidget *parent)
: lay::PropertiesPage (parent, service), mp_service (service), m_enable_cb_callback (true), mp_pcell_parameters (0)
InstPropertiesPage::InstPropertiesPage (edt::Service *service, db::Manager *manager, QWidget *parent)
: lay::PropertiesPage (parent, manager, service), mp_service (service), m_enable_cb_callback (true), mp_pcell_parameters (0)
{
m_selection_ptrs.reserve (service->selection ().size ());
for (edt::Service::obj_iterator s = service->selection ().begin (); s != service->selection ().end (); ++s) {

View File

@ -43,7 +43,7 @@ class InstPropertiesPage
Q_OBJECT
public:
InstPropertiesPage (edt::Service *service, QWidget *parent);
InstPropertiesPage (edt::Service *service, db::Manager *manager, QWidget *parent);
~InstPropertiesPage ();
virtual void back ();

View File

@ -40,8 +40,8 @@ namespace edt
// -------------------------------------------------------------------------
// ShapePropertiesPage implementation
ShapePropertiesPage::ShapePropertiesPage (edt::Service *service, QWidget *parent)
: lay::PropertiesPage (parent, service),
ShapePropertiesPage::ShapePropertiesPage (edt::Service *service, db::Manager *manager, QWidget *parent)
: lay::PropertiesPage (parent, manager, service),
mp_service (service), m_enable_cb_callback (true)
{
m_selection_ptrs.reserve (service->selection ().size ());
@ -403,8 +403,8 @@ ShapePropertiesPage::readonly ()
// -------------------------------------------------------------------------
// PolygonPropertiesPage implementation
PolygonPropertiesPage::PolygonPropertiesPage (edt::Service *service, QWidget *parent)
: ShapePropertiesPage (service, parent)
PolygonPropertiesPage::PolygonPropertiesPage (edt::Service *service, db::Manager *manager, QWidget *parent)
: ShapePropertiesPage (service, manager, parent)
{
setupUi (this);
setup ();
@ -517,8 +517,8 @@ PolygonPropertiesPage::create_applicator (db::Shapes & /*shapes*/, const db::Sha
static bool s_coordinateMode = true;
BoxPropertiesPage::BoxPropertiesPage (edt::Service *service, QWidget *parent)
: ShapePropertiesPage (service, parent),
BoxPropertiesPage::BoxPropertiesPage (edt::Service *service, db::Manager *manager, QWidget *parent)
: ShapePropertiesPage (service, manager, parent),
m_recursion_sentinel (false), m_tab_index (0), m_dbu (1.0), m_lr_swapped (false), m_tb_swapped (false)
{
setupUi (this);
@ -669,8 +669,8 @@ BoxPropertiesPage::changed ()
// -------------------------------------------------------------------------
// TextPropertiesPage implementation
TextPropertiesPage::TextPropertiesPage (edt::Service *service, QWidget *parent)
: ShapePropertiesPage (service, parent)
TextPropertiesPage::TextPropertiesPage (edt::Service *service, db::Manager *manager, QWidget *parent)
: ShapePropertiesPage (service, manager, parent)
{
setupUi (this);
setup ();
@ -755,8 +755,8 @@ TextPropertiesPage::create_applicator (db::Shapes & /*shapes*/, const db::Shape
// -------------------------------------------------------------------------
// PathPropertiesPage implementation
PathPropertiesPage::PathPropertiesPage (edt::Service *service, QWidget *parent)
: ShapePropertiesPage (service, parent)
PathPropertiesPage::PathPropertiesPage (edt::Service *service, db::Manager *manager, QWidget *parent)
: ShapePropertiesPage (service, manager, parent)
{
setupUi (this);
setup ();
@ -857,8 +857,8 @@ PathPropertiesPage::create_applicator (db::Shapes & /*shapes*/, const db::Shape
// -------------------------------------------------------------------------
// EditablePathPropertiesPage implementation
EditablePathPropertiesPage::EditablePathPropertiesPage (edt::Service *service, QWidget *parent)
: ShapePropertiesPage (service, parent)
EditablePathPropertiesPage::EditablePathPropertiesPage (edt::Service *service, db::Manager *manager, QWidget *parent)
: ShapePropertiesPage (service, manager, parent)
{
setupUi (this);
setup ();

View File

@ -45,7 +45,7 @@ class ShapePropertiesPage
Q_OBJECT
public:
ShapePropertiesPage (edt::Service *service, QWidget *parent);
ShapePropertiesPage (edt::Service *service, db::Manager *manager, QWidget *parent);
~ShapePropertiesPage ();
virtual void back ();
@ -96,7 +96,7 @@ class PolygonPropertiesPage
Q_OBJECT
public:
PolygonPropertiesPage (edt::Service *service, QWidget *parent);
PolygonPropertiesPage (edt::Service *service, db::Manager *manager, QWidget *parent);
virtual void do_update (const db::Shape &shape, double dbu, const std::string &lname);
virtual ChangeApplicator *create_applicator (db::Shapes &shapes, const db::Shape &shape, double dbu);
@ -113,7 +113,7 @@ class BoxPropertiesPage
Q_OBJECT
public:
BoxPropertiesPage (edt::Service *service, QWidget *parent);
BoxPropertiesPage (edt::Service *service, db::Manager *manager, QWidget *parent);
virtual void do_update (const db::Shape &shape, double dbu, const std::string &lname);
virtual ChangeApplicator *create_applicator (db::Shapes &shapes, const db::Shape &shape, double dbu);
@ -142,7 +142,7 @@ class TextPropertiesPage
Q_OBJECT
public:
TextPropertiesPage (edt::Service *service, QWidget *parent);
TextPropertiesPage (edt::Service *service, db::Manager *manager, QWidget *parent);
virtual void do_update (const db::Shape &shape, double dbu, const std::string &lname);
virtual ChangeApplicator *create_applicator (db::Shapes &shapes, const db::Shape &shape, double dbu);
@ -159,7 +159,7 @@ class PathPropertiesPage
Q_OBJECT
public:
PathPropertiesPage (edt::Service *service, QWidget *parent);
PathPropertiesPage (edt::Service *service, db::Manager *manager, QWidget *parent);
virtual void do_update (const db::Shape &shape, double dbu, const std::string &lname);
virtual ChangeApplicator *create_applicator (db::Shapes &shapes, const db::Shape &shape, double dbu);
@ -176,7 +176,7 @@ class EditablePathPropertiesPage
Q_OBJECT
public:
EditablePathPropertiesPage (edt::Service *service, QWidget *parent);
EditablePathPropertiesPage (edt::Service *service, db::Manager *manager, QWidget *parent);
virtual void do_update (const db::Shape &shape, double dbu, const std::string &lname);
virtual ChangeApplicator *create_applicator (db::Shapes &shapes, const db::Shape &shape, double dbu);

View File

@ -296,9 +296,9 @@ PolygonService::PolygonService (db::Manager *manager, lay::LayoutView *view)
}
lay::PropertiesPage *
PolygonService::properties_page (QWidget *parent)
PolygonService::properties_page (db::Manager *manager, QWidget *parent)
{
return new edt::PolygonPropertiesPage (this, parent);
return new edt::PolygonPropertiesPage (this, manager, parent);
}
void
@ -624,9 +624,9 @@ BoxService::BoxService (db::Manager *manager, lay::LayoutView *view)
}
lay::PropertiesPage *
BoxService::properties_page (QWidget *parent)
BoxService::properties_page (db::Manager *manager, QWidget *parent)
{
return new edt::BoxPropertiesPage (this, parent);
return new edt::BoxPropertiesPage (this, manager, parent);
}
void
@ -712,9 +712,9 @@ TextService::~TextService ()
}
lay::PropertiesPage *
TextService::properties_page (QWidget *parent)
TextService::properties_page (db::Manager *manager, QWidget *parent)
{
return new edt::TextPropertiesPage (this, parent);
return new edt::TextPropertiesPage (this, manager, parent);
}
void
@ -895,12 +895,12 @@ PathService::~PathService ()
}
lay::PropertiesPage *
PathService::properties_page (QWidget *parent)
PathService::properties_page (db::Manager *manager, QWidget *parent)
{
if (view ()->is_editable ()) {
return new edt::EditablePathPropertiesPage (this, parent);
return new edt::EditablePathPropertiesPage (this, manager, parent);
} else {
return new edt::PathPropertiesPage (this, parent);
return new edt::PathPropertiesPage (this, manager, parent);
}
}
@ -1120,9 +1120,9 @@ InstService::InstService (db::Manager *manager, lay::LayoutView *view)
}
lay::PropertiesPage *
InstService::properties_page (QWidget *parent)
InstService::properties_page (db::Manager *manager, QWidget *parent)
{
return new edt::InstPropertiesPage (this, parent);
return new edt::InstPropertiesPage (this, manager, parent);
}
bool

View File

@ -85,7 +85,7 @@ class PolygonService
public:
PolygonService (db::Manager *manager, lay::LayoutView *view);
virtual lay::PropertiesPage *properties_page (QWidget *parent);
virtual lay::PropertiesPage *properties_page (db::Manager *manager, QWidget *parent);
virtual void do_begin_edit (const db::DPoint &p);
virtual void do_mouse_move (const db::DPoint &p);
virtual bool do_mouse_click (const db::DPoint &p);
@ -114,7 +114,7 @@ class BoxService
public:
BoxService (db::Manager *manager, lay::LayoutView *view);
virtual lay::PropertiesPage *properties_page (QWidget *parent);
virtual lay::PropertiesPage *properties_page (db::Manager *manager, QWidget *parent);
virtual void do_begin_edit (const db::DPoint &p);
virtual void do_mouse_move (const db::DPoint &p);
virtual bool do_mouse_click (const db::DPoint &p);
@ -139,7 +139,7 @@ public:
TextService (db::Manager *manager, lay::LayoutView *view);
~TextService ();
virtual lay::PropertiesPage *properties_page (QWidget *parent);
virtual lay::PropertiesPage *properties_page (db::Manager *manager, QWidget *parent);
virtual void do_begin_edit (const db::DPoint &p);
virtual void do_mouse_transform (const db::DPoint &p, db::DFTrans trans);
virtual void do_mouse_move (const db::DPoint &p);
@ -170,7 +170,7 @@ public:
PathService (db::Manager *manager, lay::LayoutView *view);
~PathService ();
virtual lay::PropertiesPage *properties_page (QWidget *parent);
virtual lay::PropertiesPage *properties_page (db::Manager *manager, QWidget *parent);
virtual void do_begin_edit (const db::DPoint &p);
virtual void do_mouse_move (const db::DPoint &p);
virtual bool do_mouse_click (const db::DPoint &p);
@ -204,7 +204,7 @@ class InstService
public:
InstService (db::Manager *manager, lay::LayoutView *view);
virtual lay::PropertiesPage *properties_page (QWidget *parent);
virtual lay::PropertiesPage *properties_page (db::Manager *manager, QWidget *parent);
virtual void do_begin_edit (const db::DPoint &p);
virtual void do_mouse_move (const db::DPoint &p);
virtual bool do_mouse_click (const db::DPoint &p);

View File

@ -36,8 +36,8 @@ const double max_gamma = 3.0;
// -------------------------------------------------------------------------
// PropertiesPage implementation
PropertiesPage::PropertiesPage (img::Service *service, QWidget *parent)
: lay::PropertiesPage (parent, service), mp_service (service), mp_direct_image (0)
PropertiesPage::PropertiesPage (img::Service *service, db::Manager *manager, QWidget *parent)
: lay::PropertiesPage (parent, manager, service), mp_service (service), mp_direct_image (0)
{
mp_service->get_selection (m_selection);
m_pos = m_selection.begin ();
@ -48,7 +48,7 @@ PropertiesPage::PropertiesPage (img::Service *service, QWidget *parent)
}
PropertiesPage::PropertiesPage (QWidget *parent)
: lay::PropertiesPage (parent, 0), mp_service (0), mp_direct_image (0)
: lay::PropertiesPage (parent, 0, 0), mp_service (0), mp_direct_image (0)
{
init ();
}

View File

@ -45,7 +45,7 @@ class PropertiesPage
Q_OBJECT
public:
PropertiesPage (img::Service *service, QWidget *parent);
PropertiesPage (img::Service *service, db::Manager *manager, QWidget *parent);
PropertiesPage (QWidget *parent);
~PropertiesPage ();

View File

@ -1312,9 +1312,9 @@ Service::display_status (bool transient)
}
lay::PropertiesPage *
Service::properties_page (QWidget *parent)
Service::properties_page (db::Manager *manager, QWidget *parent)
{
return new img::PropertiesPage (this, parent);
return new img::PropertiesPage (this, manager, parent);
}
void

View File

@ -352,7 +352,7 @@ public:
/**
* @brief Create the properties page
*/
virtual lay::PropertiesPage *properties_page (QWidget * /*parent*/);
virtual lay::PropertiesPage *properties_page (db::Manager *manager, QWidget *parent);
/**
* @brief Get the selection for the properties page

View File

@ -915,7 +915,7 @@ begin
view.transaction("Restyle annotations")
view.each_annotation do |a|
adup.style = RBA::Annotation::StyleArrowBoth
a.style = RBA::Annotation::StyleArrowBoth
end
ensure

View File

@ -331,7 +331,7 @@ public:
* by the caller. The return value is 0 if the Editable object does
* not support a properties page.
*/
virtual lay::PropertiesPage *properties_page (QWidget * /*parent*/)
virtual lay::PropertiesPage *properties_page (db::Manager * /*manager*/, QWidget * /*parent*/)
{
return 0;
}

View File

@ -27,8 +27,8 @@
namespace lay
{
PropertiesPage::PropertiesPage (QWidget *parent, lay::Editable *editable)
: QFrame (parent), mp_editable (editable)
PropertiesPage::PropertiesPage (QWidget *parent, db::Manager *manager, lay::Editable *editable)
: QFrame (parent), mp_manager (manager), mp_editable (editable)
{
// .. nothing else ..
}

View File

@ -57,7 +57,7 @@ public:
* empty, at_start () is supposed to return true then.
* The dialog will call update () to update the display accordingly.
*/
PropertiesPage (QWidget *parent, lay::Editable *editable);
PropertiesPage (QWidget *parent, db::Manager *manager, lay::Editable *editable);
/**
* @brief The destructor
@ -210,7 +210,17 @@ public:
return mp_editable;
}
/**
* @brief Gets the transaction manager object
* Use this object to implement undable operations on the properties page.
*/
db::Manager *manager ()
{
return mp_manager;
}
private:
db::Manager *mp_manager;
lay::Editable *mp_editable;
};

View File

@ -46,7 +46,7 @@ PropertiesDialog::PropertiesDialog (QWidget * /*parent*/, db::Manager *manager,
mp_stack = new QStackedLayout;
for (lay::Editables::iterator e = mp_editables->begin (); e != mp_editables->end (); ++e) {
mp_properties_pages.push_back (e->properties_page (content_frame));
mp_properties_pages.push_back (e->properties_page (mp_manager, content_frame));
if (mp_properties_pages.back ()) {
mp_stack->addWidget (mp_properties_pages.back ());
}

View File

@ -441,7 +441,7 @@ private:
if (m_directed) {
for (std::vector<db::DEdge>::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<db::DEdge>::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;
}
}
@ -552,7 +552,7 @@ private:
std::pair<bool, db::DPoint> ip = e.intersect_point (db::DEdge (e1, e2));
if (ip.first) {
find_closest (ip.second, e);
find_closest_exact (ip.second, e);
}
}
@ -765,10 +765,12 @@ do_obj_snap (lay::LayoutView *view, const db::DPoint &pt, const db::DVector &gri
}
std::pair <bool, db::DEdge>
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 <db::DEdge> &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 <db::DEdge> &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, cutlines.empty () /*vertex snap on "any direction"*/);
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<db::DEdge>::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));
@ -798,17 +800,21 @@ do_obj_snap2 (lay::LayoutView *view, const db::DPoint &pt, const db::DVector &gr
}
} else if (finder.is_vertex ()) {
cl.push_back (db::DEdge (p1, dp2));
} 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 +878,33 @@ obj_snap (lay::LayoutView *view, const db::DPoint &p1, const db::DPoint &p2, con
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)
{
return do_obj_snap2 (view, lay::snap_xy (pt, grid), db::DVector (), min_search_range, max_search_range, std::vector<db::DEdge> ());
return obj_snap2 (view, pt, pt, grid, min_search_range, max_search_range);
}
std::pair <bool, db::DEdge>
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 <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)
{
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<db::DEdge> ());
}
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 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 <db::DEdge> 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);
}
}

View File

@ -143,6 +143,16 @@ namespace lay
*/
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);
/**
* @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 <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);
/**
* @brief Same than the previous obj_snap2, but allows specification of an angle constraint
*
@ -150,6 +160,15 @@ namespace lay
*/
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);
/**
* @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 <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);
/**
* @brief Reduce a given vector according to the angle constraint
*/