mirror of https://github.com/KLayout/klayout.git
commit
6ad326e806
|
|
@ -375,9 +375,10 @@ PropertiesPage::count () const
|
|||
void
|
||||
PropertiesPage::select_entries (const std::vector<size_t> &entries)
|
||||
{
|
||||
tl_assert (entries.size () == 1);
|
||||
if (! entries.empty ()) {
|
||||
m_index = entries.front ();
|
||||
}
|
||||
}
|
||||
|
||||
std::string
|
||||
PropertiesPage::description (size_t entry) const
|
||||
|
|
|
|||
|
|
@ -73,6 +73,47 @@ static NO_RETURN void raise_invalid_hole_index_on_simple_polygon ()
|
|||
// -------------------------------------------------------------------------------
|
||||
// Shape implementation
|
||||
|
||||
int Shape::layer () const
|
||||
{
|
||||
const db::Shapes *sh = shapes ();
|
||||
if (! sh) {
|
||||
return -1;
|
||||
}
|
||||
const db::Cell *cell = sh->cell ();
|
||||
if (! cell) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
unsigned int li = cell->index_of_shapes (sh);
|
||||
return li < cell->layers () ? int (li) : -1;
|
||||
}
|
||||
|
||||
void Shape::set_layer (unsigned int layer_index)
|
||||
{
|
||||
db::Shapes *sh = shapes ();
|
||||
if (! sh) {
|
||||
return;
|
||||
}
|
||||
db::Cell *cell = sh->cell ();
|
||||
if (! cell) {
|
||||
return;
|
||||
}
|
||||
db::Layout *layout = cell->layout ();
|
||||
if (! layout || ! layout->is_valid_layer (layer_index)) {
|
||||
return;
|
||||
}
|
||||
|
||||
db::Shapes *target_sh = &cell->shapes (layer_index);
|
||||
if (target_sh != sh) {
|
||||
|
||||
// move the shape inside the cell
|
||||
db::Shape new_shape = target_sh->insert (*this);
|
||||
sh->erase_shape (*this);
|
||||
*this = new_shape;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
db::properties_id_type Shape::prop_id () const
|
||||
{
|
||||
if (m_with_props) {
|
||||
|
|
|
|||
|
|
@ -1098,6 +1098,26 @@ public:
|
|||
m_type = UserObject;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Gets the index of layer the shape sits in
|
||||
*
|
||||
* This getter only applies to shapes that are members of a cell
|
||||
* and a layout.
|
||||
* For other shapes this method returns -1.
|
||||
*/
|
||||
int layer () const;
|
||||
|
||||
/**
|
||||
* @brief Changes the layer the shape sits in
|
||||
*
|
||||
* This setter applies to shapes are are members of a cell
|
||||
* and a layout.
|
||||
* Changing the layer effectively moves the shape to a different
|
||||
* container. For invalid layer indexes or if the shape is
|
||||
* not member of a cell and layout, this method does nothing.
|
||||
*/
|
||||
void set_layer (unsigned int layer_index);
|
||||
|
||||
/**
|
||||
* @brief Get the properties Id associated with the shape
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -1047,3 +1047,32 @@ TEST(10)
|
|||
si = s.begin (db::ShapeIterator::All);
|
||||
EXPECT_EQ (si->rectangle ().empty (), true);
|
||||
}
|
||||
|
||||
// layer index setter/getter
|
||||
TEST(20)
|
||||
{
|
||||
db::Shape sh0;
|
||||
EXPECT_EQ (sh0.layer (), -1);
|
||||
|
||||
db::Layout ly (true);
|
||||
|
||||
unsigned int l1 = ly.get_layer (db::LayerProperties (1, 0));
|
||||
unsigned int l2 = ly.get_layer (db::LayerProperties (2, 0));
|
||||
|
||||
db::Cell &top = ly.cell (ly.add_cell ("TOP"));
|
||||
db::Shape sh = top.shapes (l1).insert (db::Box (0, 0, 1000, 2000));
|
||||
|
||||
EXPECT_EQ (top.shapes (l1).size (), size_t (1));
|
||||
EXPECT_EQ (top.shapes (l2).size (), size_t (0));
|
||||
|
||||
EXPECT_EQ (sh.layer (), int (l1));
|
||||
EXPECT_EQ (sh.to_string (), "box (0,0;1000,2000)");
|
||||
|
||||
sh.set_layer (l2);
|
||||
|
||||
EXPECT_EQ (sh.layer (), int (l2));
|
||||
EXPECT_EQ (sh.to_string (), "box (0,0;1000,2000)");
|
||||
|
||||
EXPECT_EQ (top.shapes (l1).size (), size_t (0));
|
||||
EXPECT_EQ (top.shapes (l2).size (), size_t (1));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,10 +53,10 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="layer_lbl">
|
||||
<widget class="QLabel" name="cell_lbl">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<sizepolicy hsizetype="Ignored" vsizetype="Preferred">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
|
|
@ -68,6 +68,13 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="lay::LayerSelectionComboBox" name="layer_cbx">
|
||||
<property name="sizeAdjustPolicy">
|
||||
<enum>QComboBox::AdjustToContents</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
@ -576,6 +583,13 @@
|
|||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>lay::LayerSelectionComboBox</class>
|
||||
<extends>QComboBox</extends>
|
||||
<header>layWidgets.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
<tabstop>mode_tab</tabstop>
|
||||
<tabstop>x1_le_1</tabstop>
|
||||
|
|
|
|||
|
|
@ -96,7 +96,6 @@
|
|||
<font>
|
||||
<family>Sans Serif</family>
|
||||
<pointsize>12</pointsize>
|
||||
<weight>75</weight>
|
||||
<italic>false</italic>
|
||||
<bold>true</bold>
|
||||
<underline>false</underline>
|
||||
|
|
@ -109,10 +108,10 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="layer_lbl">
|
||||
<widget class="QLabel" name="cell_lbl">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<sizepolicy hsizetype="Ignored" vsizetype="Preferred">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
|
|
@ -124,6 +123,9 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="lay::LayerSelectionComboBox" name="layer_cbx"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
@ -334,6 +336,13 @@
|
|||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>lay::LayerSelectionComboBox</class>
|
||||
<extends>QComboBox</extends>
|
||||
<header>layWidgets.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
<tabstop>width_le</tabstop>
|
||||
<tabstop>ptlist_le</tabstop>
|
||||
|
|
|
|||
|
|
@ -264,7 +264,6 @@
|
|||
<font>
|
||||
<family>Sans Serif</family>
|
||||
<pointsize>12</pointsize>
|
||||
<weight>75</weight>
|
||||
<italic>false</italic>
|
||||
<bold>true</bold>
|
||||
<underline>false</underline>
|
||||
|
|
@ -277,10 +276,10 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="layer_lbl">
|
||||
<widget class="QLabel" name="cell_lbl">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<sizepolicy hsizetype="Ignored" vsizetype="Preferred">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
|
|
@ -292,6 +291,13 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="lay::LayerSelectionComboBox" name="layer_cbx">
|
||||
<property name="sizeAdjustPolicy">
|
||||
<enum>QComboBox::AdjustToContents</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
@ -304,6 +310,13 @@
|
|||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>lay::LayerSelectionComboBox</class>
|
||||
<extends>QComboBox</extends>
|
||||
<header>layWidgets.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
<tabstop>width_le</tabstop>
|
||||
<tabstop>ptlist_le</tabstop>
|
||||
|
|
|
|||
|
|
@ -53,10 +53,10 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="layer_lbl">
|
||||
<widget class="QLabel" name="cell_lbl">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<sizepolicy hsizetype="Ignored" vsizetype="Preferred">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
|
|
@ -68,6 +68,13 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="lay::LayerSelectionComboBox" name="layer_cbx">
|
||||
<property name="sizeAdjustPolicy">
|
||||
<enum>QComboBox::AdjustToContents</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
@ -271,6 +278,13 @@
|
|||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>lay::LayerSelectionComboBox</class>
|
||||
<extends>QComboBox</extends>
|
||||
<header>layWidgets.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
<tabstop>x_le</tabstop>
|
||||
<tabstop>y_le</tabstop>
|
||||
|
|
|
|||
|
|
@ -109,7 +109,6 @@
|
|||
<font>
|
||||
<family>Sans Serif</family>
|
||||
<pointsize>12</pointsize>
|
||||
<weight>75</weight>
|
||||
<italic>false</italic>
|
||||
<bold>true</bold>
|
||||
<underline>false</underline>
|
||||
|
|
@ -122,10 +121,10 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="layer_lbl">
|
||||
<widget class="QLabel" name="cell_lbl">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<sizepolicy hsizetype="Ignored" vsizetype="Preferred">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
|
|
@ -137,6 +136,13 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="lay::LayerSelectionComboBox" name="layer_cbx">
|
||||
<property name="sizeAdjustPolicy">
|
||||
<enum>QComboBox::AdjustToContents</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
@ -225,6 +231,13 @@
|
|||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>lay::LayerSelectionComboBox</class>
|
||||
<extends>QComboBox</extends>
|
||||
<header>layWidgets.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
<tabstop>pointListEdit</tabstop>
|
||||
<tabstop>dbu_cb</tabstop>
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>568</width>
|
||||
<height>375</height>
|
||||
<height>378</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
|
|
@ -245,10 +245,10 @@ to show text objects scaled and rotated</string>
|
|||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="layer_lbl">
|
||||
<widget class="QLabel" name="cell_lbl">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<sizepolicy hsizetype="Ignored" vsizetype="Preferred">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
|
|
@ -260,6 +260,13 @@ to show text objects scaled and rotated</string>
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="lay::LayerSelectionComboBox" name="layer_cbx">
|
||||
<property name="sizeAdjustPolicy">
|
||||
<enum>QComboBox::AdjustToContents</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
@ -413,6 +420,13 @@ to show text objects scaled and rotated</string>
|
|||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>lay::LayerSelectionComboBox</class>
|
||||
<extends>QComboBox</extends>
|
||||
<header>layWidgets.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
<tabstop>text_le</tabstop>
|
||||
<tabstop>x_le</tabstop>
|
||||
|
|
|
|||
|
|
@ -76,12 +76,12 @@ bool CombinedChangeApplicator::supports_relative_mode () const
|
|||
return false;
|
||||
}
|
||||
|
||||
db::Shape CombinedChangeApplicator::do_apply (db::Shapes &shapes, const db::Shape &shape, double dbu, bool relative) const
|
||||
db::Shape CombinedChangeApplicator::do_apply (db::Shapes &shapes, const db::Shape &shape, double dbu, unsigned int cv_index, unsigned int layer, bool relative) const
|
||||
{
|
||||
db::Shape s = shape;
|
||||
for (std::vector<ChangeApplicator *>::const_iterator a = m_appl.begin (); a != m_appl.end (); ++a) {
|
||||
if (*a) {
|
||||
s = (*a)->do_apply (shapes, s, dbu, relative);
|
||||
s = (*a)->do_apply (shapes, s, dbu, cv_index, layer, relative);
|
||||
}
|
||||
}
|
||||
return s;
|
||||
|
|
@ -107,7 +107,7 @@ ChangePropertiesApplicator::ChangePropertiesApplicator (db::properties_id_type p
|
|||
// .. nothing yet ...
|
||||
}
|
||||
|
||||
db::Shape ChangePropertiesApplicator::do_apply (db::Shapes &shapes, const db::Shape &shape, double /*dbu*/, bool /*relative*/) const
|
||||
db::Shape ChangePropertiesApplicator::do_apply (db::Shapes &shapes, const db::Shape &shape, double /*dbu*/, unsigned int /*cv_index*/, unsigned int /*layer*/, bool /*relative*/) const
|
||||
{
|
||||
return shapes.replace_prop_id (shape, m_prop_id);
|
||||
}
|
||||
|
|
@ -117,6 +117,35 @@ db::Instance ChangePropertiesApplicator::do_apply_inst (db::Cell &cell, const db
|
|||
return cell.replace_prop_id (instance, m_prop_id);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// ChangeLayerApplicator implementation
|
||||
|
||||
ChangeLayerApplicator::ChangeLayerApplicator (const ChangeLayerApplicator &other)
|
||||
: ChangeApplicator (), m_cv_index (other.m_cv_index), m_new_layer (other.m_new_layer), m_skipped_layers (other.m_skipped_layers)
|
||||
{
|
||||
// .. nothing yet ...
|
||||
}
|
||||
|
||||
ChangeLayerApplicator::ChangeLayerApplicator (unsigned int cv_index, unsigned int new_layer)
|
||||
: m_cv_index (cv_index), m_new_layer (new_layer)
|
||||
{
|
||||
// .. nothing yet ...
|
||||
}
|
||||
|
||||
db::Shape ChangeLayerApplicator::do_apply (db::Shapes & /*shapes*/, const db::Shape &shape, double /*dbu*/, unsigned int cv_index, unsigned int layer, bool /*relative*/) const
|
||||
{
|
||||
db::Shape s = shape;
|
||||
if (m_cv_index == cv_index && layer != m_new_layer && m_skipped_layers.find (layer) == m_skipped_layers.end ()) {
|
||||
s.set_layer (m_new_layer);
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
void ChangeLayerApplicator::skip_layer (unsigned int l)
|
||||
{
|
||||
m_skipped_layers.insert (l);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// BoxDimensionsChangeApplicator implementation
|
||||
|
||||
|
|
@ -126,7 +155,7 @@ BoxDimensionsChangeApplicator::BoxDimensionsChangeApplicator (db::Coord dl, db::
|
|||
// .. nothing yet ..
|
||||
}
|
||||
|
||||
db::Shape BoxDimensionsChangeApplicator::do_apply (db::Shapes &shapes, const db::Shape &shape, double /*dbu*/, bool relative) const
|
||||
db::Shape BoxDimensionsChangeApplicator::do_apply (db::Shapes &shapes, const db::Shape &shape, double /*dbu*/, unsigned int /*cv_index*/, unsigned int /*layer*/, bool relative) const
|
||||
{
|
||||
db::Box org_box;
|
||||
shape.box (org_box);
|
||||
|
|
@ -207,7 +236,7 @@ PointDimensionsChangeApplicator::PointDimensionsChangeApplicator (const db::Poin
|
|||
// .. nothing yet ..
|
||||
}
|
||||
|
||||
db::Shape PointDimensionsChangeApplicator::do_apply (db::Shapes &shapes, const db::Shape &shape, double /*dbu*/, bool relative) const
|
||||
db::Shape PointDimensionsChangeApplicator::do_apply (db::Shapes &shapes, const db::Shape &shape, double /*dbu*/, unsigned int /*cv_index*/, unsigned int /*layer*/, bool relative) const
|
||||
{
|
||||
db::Point org_point;
|
||||
shape.point (org_point);
|
||||
|
|
@ -243,8 +272,10 @@ PolygonChangeApplicator::PolygonChangeApplicator (const db::Polygon &poly, const
|
|||
// .. nothing yet ..
|
||||
}
|
||||
|
||||
db::Shape PolygonChangeApplicator::do_apply (db::Shapes &shapes, const db::Shape &shape, double /*dbu*/, bool relative) const
|
||||
db::Shape PolygonChangeApplicator::do_apply (db::Shapes &shapes, const db::Shape &shape, double /*dbu*/, unsigned int /*cv_index*/, unsigned int /*layer*/, bool relative) const
|
||||
{
|
||||
db::Shape s = shape;
|
||||
|
||||
db::Polygon org_poly;
|
||||
shape.polygon (org_poly);
|
||||
|
||||
|
|
@ -254,19 +285,19 @@ db::Shape PolygonChangeApplicator::do_apply (db::Shapes &shapes, const db::Shape
|
|||
|
||||
if (new_poly != org_poly) {
|
||||
// shape changed - replace the old by the new one
|
||||
return shapes.replace (shape, new_poly);
|
||||
s = shapes.replace (shape, new_poly);
|
||||
} else {
|
||||
// shape did not change
|
||||
return shape;
|
||||
}
|
||||
|
||||
} else if (m_poly != org_poly) {
|
||||
// shape changed - replace the old by the new one
|
||||
return shapes.replace (shape, m_poly);
|
||||
s = shapes.replace (shape, m_poly);
|
||||
} else {
|
||||
// shape did not change
|
||||
return shape;
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
|
|
@ -278,7 +309,7 @@ TextOrientationChangeApplicator::TextOrientationChangeApplicator (const db::FTra
|
|||
// .. nothing yet ..
|
||||
}
|
||||
|
||||
db::Shape TextOrientationChangeApplicator::do_apply (db::Shapes &shapes, const db::Shape &shape, double /*dbu*/, bool /*relative*/) const
|
||||
db::Shape TextOrientationChangeApplicator::do_apply (db::Shapes &shapes, const db::Shape &shape, double /*dbu*/, unsigned int /*cv_index*/, unsigned int /*layer*/, bool /*relative*/) const
|
||||
{
|
||||
db::Text org_text;
|
||||
shape.text (org_text);
|
||||
|
|
@ -304,7 +335,7 @@ TextPositionChangeApplicator::TextPositionChangeApplicator (const db::Vector &di
|
|||
// .. nothing yet ..
|
||||
}
|
||||
|
||||
db::Shape TextPositionChangeApplicator::do_apply (db::Shapes &shapes, const db::Shape &shape, double /*dbu*/, bool relative) const
|
||||
db::Shape TextPositionChangeApplicator::do_apply (db::Shapes &shapes, const db::Shape &shape, double /*dbu*/, unsigned int /*cv_index*/, unsigned int /*layer*/, bool relative) const
|
||||
{
|
||||
db::Text org_text;
|
||||
shape.text (org_text);
|
||||
|
|
@ -341,7 +372,7 @@ TextHAlignChangeApplicator::TextHAlignChangeApplicator (db::HAlign halign)
|
|||
// .. nothing yet ..
|
||||
}
|
||||
|
||||
db::Shape TextHAlignChangeApplicator::do_apply (db::Shapes &shapes, const db::Shape &shape, double /*dbu*/, bool /*relative*/) const
|
||||
db::Shape TextHAlignChangeApplicator::do_apply (db::Shapes &shapes, const db::Shape &shape, double /*dbu*/, unsigned int /*cv_index*/, unsigned int /*layer*/, bool /*relative*/) const
|
||||
{
|
||||
db::Text org_text;
|
||||
shape.text (org_text);
|
||||
|
|
@ -367,7 +398,7 @@ TextVAlignChangeApplicator::TextVAlignChangeApplicator (db::VAlign valign)
|
|||
// .. nothing yet ..
|
||||
}
|
||||
|
||||
db::Shape TextVAlignChangeApplicator::do_apply (db::Shapes &shapes, const db::Shape &shape, double /*dbu*/, bool /*relative*/) const
|
||||
db::Shape TextVAlignChangeApplicator::do_apply (db::Shapes &shapes, const db::Shape &shape, double /*dbu*/, unsigned int /*cv_index*/, unsigned int /*layer*/, bool /*relative*/) const
|
||||
{
|
||||
db::Text org_text;
|
||||
shape.text (org_text);
|
||||
|
|
@ -393,7 +424,7 @@ TextSizeChangeApplicator::TextSizeChangeApplicator (db::Coord size)
|
|||
// .. nothing yet ..
|
||||
}
|
||||
|
||||
db::Shape TextSizeChangeApplicator::do_apply (db::Shapes &shapes, const db::Shape &shape, double /*dbu*/, bool /*relative*/) const
|
||||
db::Shape TextSizeChangeApplicator::do_apply (db::Shapes &shapes, const db::Shape &shape, double /*dbu*/, unsigned int /*cv_index*/, unsigned int /*layer*/, bool /*relative*/) const
|
||||
{
|
||||
db::Text org_text;
|
||||
shape.text (org_text);
|
||||
|
|
@ -419,7 +450,7 @@ TextStringChangeApplicator::TextStringChangeApplicator (const std::string &strin
|
|||
// .. nothing yet ..
|
||||
}
|
||||
|
||||
db::Shape TextStringChangeApplicator::do_apply (db::Shapes &shapes, const db::Shape &shape, double /*dbu*/, bool /*relative*/) const
|
||||
db::Shape TextStringChangeApplicator::do_apply (db::Shapes &shapes, const db::Shape &shape, double /*dbu*/, unsigned int /*cv_index*/, unsigned int /*layer*/, bool /*relative*/) const
|
||||
{
|
||||
db::Text org_text;
|
||||
shape.text (org_text);
|
||||
|
|
@ -445,7 +476,7 @@ PathPointsChangeApplicator::PathPointsChangeApplicator (const std::vector<db::Po
|
|||
// .. nothing yet ..
|
||||
}
|
||||
|
||||
db::Shape PathPointsChangeApplicator::do_apply (db::Shapes &shapes, const db::Shape &shape, double /*dbu*/, bool relative) const
|
||||
db::Shape PathPointsChangeApplicator::do_apply (db::Shapes &shapes, const db::Shape &shape, double /*dbu*/, unsigned int /*cv_index*/, unsigned int /*layer*/, bool relative) const
|
||||
{
|
||||
db::Path org_path;
|
||||
shape.path (org_path);
|
||||
|
|
@ -479,7 +510,7 @@ PathWidthChangeApplicator::PathWidthChangeApplicator (db::Coord w, db::Coord org
|
|||
// .. nothing yet ..
|
||||
}
|
||||
|
||||
db::Shape PathWidthChangeApplicator::do_apply (db::Shapes &shapes, const db::Shape &shape, double /*dbu*/, bool relative) const
|
||||
db::Shape PathWidthChangeApplicator::do_apply (db::Shapes &shapes, const db::Shape &shape, double /*dbu*/, unsigned int /*cv_index*/, unsigned int /*layer*/, bool relative) const
|
||||
{
|
||||
db::Path org_path;
|
||||
shape.path (org_path);
|
||||
|
|
@ -517,7 +548,7 @@ PathStartExtensionChangeApplicator::PathStartExtensionChangeApplicator (db::Coor
|
|||
// .. nothing yet ..
|
||||
}
|
||||
|
||||
db::Shape PathStartExtensionChangeApplicator::do_apply (db::Shapes &shapes, const db::Shape &shape, double /*dbu*/, bool /*relative*/) const
|
||||
db::Shape PathStartExtensionChangeApplicator::do_apply (db::Shapes &shapes, const db::Shape &shape, double /*dbu*/, unsigned int /*cv_index*/, unsigned int /*layer*/, bool /*relative*/) const
|
||||
{
|
||||
db::Path org_path;
|
||||
shape.path (org_path);
|
||||
|
|
@ -547,7 +578,7 @@ PathEndExtensionChangeApplicator::PathEndExtensionChangeApplicator (db::Coord e)
|
|||
// .. nothing yet ..
|
||||
}
|
||||
|
||||
db::Shape PathEndExtensionChangeApplicator::do_apply (db::Shapes &shapes, const db::Shape &shape, double /*dbu*/, bool /*relative*/) const
|
||||
db::Shape PathEndExtensionChangeApplicator::do_apply (db::Shapes &shapes, const db::Shape &shape, double /*dbu*/, unsigned int /*cv_index*/, unsigned int /*layer*/, bool /*relative*/) const
|
||||
{
|
||||
db::Path org_path;
|
||||
shape.path (org_path);
|
||||
|
|
@ -577,7 +608,7 @@ PathRoundEndChangeApplicator::PathRoundEndChangeApplicator (bool r)
|
|||
// .. nothing yet ..
|
||||
}
|
||||
|
||||
db::Shape PathRoundEndChangeApplicator::do_apply (db::Shapes &shapes, const db::Shape &shape, double /*dbu*/, bool /*relative*/) const
|
||||
db::Shape PathRoundEndChangeApplicator::do_apply (db::Shapes &shapes, const db::Shape &shape, double /*dbu*/, unsigned int /*cv_index*/, unsigned int /*layer*/, bool /*relative*/) const
|
||||
{
|
||||
db::Path org_path;
|
||||
shape.path (org_path);
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ public:
|
|||
return false;
|
||||
}
|
||||
|
||||
virtual db::Shape do_apply (db::Shapes & /*shapes*/, const db::Shape & /*shape*/, double /*dbu*/, bool /*relative*/) const
|
||||
virtual db::Shape do_apply (db::Shapes & /*shapes*/, const db::Shape & /*shape*/, double /*dbu*/, unsigned int /*cv_index*/, unsigned int /*layer*/, bool /*relative*/) const
|
||||
{
|
||||
return db::Shape ();
|
||||
}
|
||||
|
|
@ -90,7 +90,7 @@ public:
|
|||
void add (ChangeApplicator *a);
|
||||
|
||||
bool supports_relative_mode () const;
|
||||
db::Shape do_apply (db::Shapes &shapes, const db::Shape &shape, double dbu, bool relative) const;
|
||||
db::Shape do_apply (db::Shapes &shapes, const db::Shape &shape, double dbu, unsigned int cv_index, unsigned int layer, bool relative) const;
|
||||
db::Instance do_apply_inst (db::Cell &cell, const db::Instance &instance, double dbu, bool relative) const;
|
||||
|
||||
private:
|
||||
|
|
@ -107,13 +107,32 @@ public:
|
|||
ChangePropertiesApplicator (db::properties_id_type prop_id);
|
||||
|
||||
bool supports_relative_mode () const { return false; }
|
||||
db::Shape do_apply (db::Shapes &shapes, const db::Shape &shape, double dbu, bool relative) const;
|
||||
db::Shape do_apply (db::Shapes &shapes, const db::Shape &shape, double dbu, unsigned int cv_index, unsigned int layer, bool relative) const;
|
||||
db::Instance do_apply_inst (db::Cell &cell, const db::Instance &instance, double dbu, bool relative) const;
|
||||
|
||||
private:
|
||||
db::properties_id_type m_prop_id;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief A property ID change applicator
|
||||
*/
|
||||
class ChangeLayerApplicator
|
||||
: public ChangeApplicator
|
||||
{
|
||||
public:
|
||||
ChangeLayerApplicator (const ChangeLayerApplicator &other);
|
||||
ChangeLayerApplicator (unsigned int cv_index, unsigned int new_layer);
|
||||
|
||||
bool supports_relative_mode () const { return false; }
|
||||
db::Shape do_apply (db::Shapes &shapes, const db::Shape &shape, double dbu, unsigned int cv_index, unsigned int layer, bool relative) const;
|
||||
void skip_layer (unsigned int l);
|
||||
|
||||
private:
|
||||
unsigned int m_cv_index, m_new_layer;
|
||||
std::set<unsigned int> m_skipped_layers;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief A box change applicator
|
||||
*/
|
||||
|
|
@ -124,7 +143,7 @@ public:
|
|||
BoxDimensionsChangeApplicator (db::Coord dl, db::Coord db, db::Coord dr, db::Coord dt, db::Coord l, db::Coord b, db::Coord r, db::Coord t);
|
||||
|
||||
bool supports_relative_mode () const { return true; }
|
||||
db::Shape do_apply (db::Shapes &shapes, const db::Shape &shape, double dbu, bool relative) const;
|
||||
db::Shape do_apply (db::Shapes &shapes, const db::Shape &shape, double dbu, unsigned int cv_index, unsigned int layer, bool relative) const;
|
||||
|
||||
private:
|
||||
db::Coord m_dl, m_db, m_dr, m_dt;
|
||||
|
|
@ -141,7 +160,7 @@ public:
|
|||
PointDimensionsChangeApplicator (const db::Point &point, const db::Point &org_point);
|
||||
|
||||
bool supports_relative_mode () const { return true; }
|
||||
db::Shape do_apply (db::Shapes &shapes, const db::Shape &shape, double dbu, bool relative) const;
|
||||
db::Shape do_apply (db::Shapes &shapes, const db::Shape &shape, double dbu, unsigned int cv_index, unsigned int layer, bool relative) const;
|
||||
|
||||
private:
|
||||
db::Point m_point, m_org_point;
|
||||
|
|
@ -157,7 +176,7 @@ public:
|
|||
PolygonChangeApplicator (const db::Polygon &poly, const db::Polygon &org_poly);
|
||||
|
||||
bool supports_relative_mode () const { return true; }
|
||||
db::Shape do_apply (db::Shapes &shapes, const db::Shape &shape, double dbu, bool relative) const;
|
||||
db::Shape do_apply (db::Shapes &shapes, const db::Shape &shape, double dbu, unsigned int cv_index, unsigned int layer, bool relative) const;
|
||||
|
||||
private:
|
||||
db::Polygon m_poly, m_org_poly;
|
||||
|
|
@ -173,7 +192,7 @@ public:
|
|||
TextOrientationChangeApplicator (const db::FTrans &trans);
|
||||
|
||||
bool supports_relative_mode () const { return false; }
|
||||
db::Shape do_apply (db::Shapes &shapes, const db::Shape &shape, double dbu, bool relative) const;
|
||||
db::Shape do_apply (db::Shapes &shapes, const db::Shape &shape, double dbu, unsigned int cv_index, unsigned int layer, bool relative) const;
|
||||
|
||||
private:
|
||||
db::FTrans m_trans;
|
||||
|
|
@ -189,7 +208,7 @@ public:
|
|||
TextPositionChangeApplicator (const db::Vector &disp, const db::Vector &org_disp);
|
||||
|
||||
bool supports_relative_mode () const { return true; }
|
||||
db::Shape do_apply (db::Shapes &shapes, const db::Shape &shape, double dbu, bool relative) const;
|
||||
db::Shape do_apply (db::Shapes &shapes, const db::Shape &shape, double dbu, unsigned int cv_index, unsigned int layer, bool relative) const;
|
||||
|
||||
private:
|
||||
db::Vector m_disp, m_org_disp;
|
||||
|
|
@ -205,7 +224,7 @@ public:
|
|||
TextHAlignChangeApplicator (db::HAlign halign);
|
||||
|
||||
bool supports_relative_mode () const { return false; }
|
||||
db::Shape do_apply (db::Shapes &shapes, const db::Shape &shape, double dbu, bool relative) const;
|
||||
db::Shape do_apply (db::Shapes &shapes, const db::Shape &shape, double dbu, unsigned int cv_index, unsigned int layer, bool relative) const;
|
||||
|
||||
private:
|
||||
db::HAlign m_halign;
|
||||
|
|
@ -221,7 +240,7 @@ public:
|
|||
TextVAlignChangeApplicator (db::VAlign valign);
|
||||
|
||||
bool supports_relative_mode () const { return false; }
|
||||
db::Shape do_apply (db::Shapes &shapes, const db::Shape &shape, double dbu, bool relative) const;
|
||||
db::Shape do_apply (db::Shapes &shapes, const db::Shape &shape, double dbu, unsigned int cv_index, unsigned int layer, bool relative) const;
|
||||
|
||||
private:
|
||||
db::VAlign m_valign;
|
||||
|
|
@ -237,7 +256,7 @@ public:
|
|||
TextSizeChangeApplicator (db::Coord size);
|
||||
|
||||
bool supports_relative_mode () const { return false; }
|
||||
db::Shape do_apply (db::Shapes &shapes, const db::Shape &shape, double dbu, bool relative) const;
|
||||
db::Shape do_apply (db::Shapes &shapes, const db::Shape &shape, double dbu, unsigned int cv_index, unsigned int layer, bool relative) const;
|
||||
|
||||
private:
|
||||
db::Coord m_size;
|
||||
|
|
@ -253,7 +272,7 @@ public:
|
|||
TextStringChangeApplicator (const std::string &string);
|
||||
|
||||
bool supports_relative_mode () const { return false; }
|
||||
db::Shape do_apply (db::Shapes &shapes, const db::Shape &shape, double dbu, bool relative) const;
|
||||
db::Shape do_apply (db::Shapes &shapes, const db::Shape &shape, double dbu, unsigned int cv_index, unsigned int layer, bool relative) const;
|
||||
|
||||
private:
|
||||
std::string m_string;
|
||||
|
|
@ -269,7 +288,7 @@ public:
|
|||
PathPointsChangeApplicator (const std::vector<db::Point> &points, const std::vector<db::Point> &org_points);
|
||||
|
||||
bool supports_relative_mode () const { return true; }
|
||||
db::Shape do_apply (db::Shapes &shapes, const db::Shape &shape, double dbu, bool relative) const;
|
||||
db::Shape do_apply (db::Shapes &shapes, const db::Shape &shape, double dbu, unsigned int cv_index, unsigned int layer, bool relative) const;
|
||||
|
||||
private:
|
||||
std::vector<db::Point> m_points, m_org_points;
|
||||
|
|
@ -285,7 +304,7 @@ public:
|
|||
PathWidthChangeApplicator (db::Coord w, db::Coord org_w);
|
||||
|
||||
bool supports_relative_mode () const { return true; }
|
||||
db::Shape do_apply (db::Shapes &shapes, const db::Shape &shape, double dbu, bool relative) const;
|
||||
db::Shape do_apply (db::Shapes &shapes, const db::Shape &shape, double dbu, unsigned int cv_index, unsigned int layer, bool relative) const;
|
||||
|
||||
private:
|
||||
db::Coord m_width, m_org_width;
|
||||
|
|
@ -301,7 +320,7 @@ public:
|
|||
PathStartExtensionChangeApplicator (db::Coord e);
|
||||
|
||||
bool supports_relative_mode () const { return false; }
|
||||
db::Shape do_apply (db::Shapes &shapes, const db::Shape &shape, double dbu, bool relative) const;
|
||||
db::Shape do_apply (db::Shapes &shapes, const db::Shape &shape, double dbu, unsigned int cv_index, unsigned int layer, bool relative) const;
|
||||
|
||||
private:
|
||||
db::Coord m_ext;
|
||||
|
|
@ -317,7 +336,7 @@ public:
|
|||
PathEndExtensionChangeApplicator (db::Coord e);
|
||||
|
||||
bool supports_relative_mode () const { return false; }
|
||||
db::Shape do_apply (db::Shapes &shapes, const db::Shape &shape, double dbu, bool relative) const;
|
||||
db::Shape do_apply (db::Shapes &shapes, const db::Shape &shape, double dbu, unsigned int cv_index, unsigned int layer, bool relative) const;
|
||||
|
||||
private:
|
||||
db::Coord m_ext;
|
||||
|
|
@ -333,7 +352,7 @@ public:
|
|||
PathRoundEndChangeApplicator (bool r);
|
||||
|
||||
bool supports_relative_mode () const { return false; }
|
||||
db::Shape do_apply (db::Shapes &shapes, const db::Shape &shape, double dbu, bool relative) const;
|
||||
db::Shape do_apply (db::Shapes &shapes, const db::Shape &shape, double dbu, unsigned int cv_index, unsigned int layer, bool relative) const;
|
||||
|
||||
private:
|
||||
bool m_round;
|
||||
|
|
|
|||
|
|
@ -63,12 +63,18 @@ ShapePropertiesPage::~ShapePropertiesPage ()
|
|||
void
|
||||
ShapePropertiesPage::setup ()
|
||||
{
|
||||
m_enable_cb_callback = false;
|
||||
|
||||
layer_selector ()->set_new_layer_enabled (false);
|
||||
layer_selector ()->set_no_layer_available (false);
|
||||
|
||||
connect (dbu_checkbox (), SIGNAL (toggled (bool)), this, SLOT (display_mode_changed (bool)));
|
||||
connect (abs_checkbox (), SIGNAL (toggled (bool)), this, SLOT (display_mode_changed (bool)));
|
||||
connect (layer_selector (), SIGNAL (current_layer_changed ()), this, SLOT (current_layer_changed ()));
|
||||
|
||||
m_enable_cb_callback = false;
|
||||
dbu_checkbox ()->setChecked (mp_service->view ()->dbu_coordinates ());
|
||||
abs_checkbox ()->setChecked (mp_service->view ()->absolute_coordinates ());
|
||||
|
||||
m_enable_cb_callback = true;
|
||||
}
|
||||
|
||||
|
|
@ -131,7 +137,7 @@ ShapePropertiesPage::icon (size_t entry, int w, int h) const
|
|||
for (auto lp = view->begin_layers (view->current_layer_list ()); ! lp.at_end (); ++lp) {
|
||||
const lay::LayerPropertiesNode *ln = lp.operator-> ();
|
||||
if (ln->cellview_index () == cv_index && ln->layer_index () == layer) {
|
||||
return QIcon (QPixmap::fromImage (view->icon_for_layer (lp, w, h).to_image ()));
|
||||
return QIcon (QPixmap::fromImage (view->icon_for_layer (lp, w, h).to_image_copy ()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -206,6 +212,18 @@ BEGIN_PROTECTED
|
|||
END_PROTECTED
|
||||
}
|
||||
|
||||
void
|
||||
ShapePropertiesPage::current_layer_changed ()
|
||||
{
|
||||
if (m_enable_cb_callback) {
|
||||
try {
|
||||
emit edited ();
|
||||
} catch (tl::Exception &) {
|
||||
// ignore exceptions
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ShapePropertiesPage::update ()
|
||||
{
|
||||
|
|
@ -243,6 +261,7 @@ ShapePropertiesPage::do_apply (bool current_only, bool relative, bool commit)
|
|||
}
|
||||
|
||||
std::unique_ptr<ChangeApplicator> applicator;
|
||||
std::unique_ptr<ChangeApplicator> other_applicator;
|
||||
|
||||
unsigned int cv_index = m_selection_ptrs [m_indexes.front ()]->cv_index ();
|
||||
|
||||
|
|
@ -259,6 +278,20 @@ ShapePropertiesPage::do_apply (bool current_only, bool relative, bool commit)
|
|||
|
||||
if (m_prop_id != pos->shape ().prop_id ()) {
|
||||
applicator.reset (new CombinedChangeApplicator (applicator.release (), new ChangePropertiesApplicator (m_prop_id)));
|
||||
if (! current_only) {
|
||||
other_applicator.reset (new ChangePropertiesApplicator (m_prop_id));
|
||||
}
|
||||
}
|
||||
|
||||
int new_layer = layer_selector ()->current_layer_ensure ();
|
||||
if (new_layer >= 0 && int (pos->layer ()) != new_layer) {
|
||||
unsigned int gs_layer = cv->layout ().guiding_shape_layer ();
|
||||
ChangeLayerApplicator *cla = new ChangeLayerApplicator (cv_index, (unsigned int) new_layer);
|
||||
cla->skip_layer (gs_layer);
|
||||
applicator.reset (new CombinedChangeApplicator (applicator.release (), cla));
|
||||
if (! current_only) {
|
||||
other_applicator.reset (new CombinedChangeApplicator (other_applicator.release (), new ChangeLayerApplicator (*cla)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -266,6 +299,29 @@ ShapePropertiesPage::do_apply (bool current_only, bool relative, bool commit)
|
|||
return;
|
||||
}
|
||||
|
||||
apply_change (applicator.get (), cv_index, current_only, relative, commit);
|
||||
|
||||
if (other_applicator.get () && page_set ()) {
|
||||
|
||||
// apply to other pages
|
||||
auto pages = page_set ()->properties_pages ();
|
||||
for (auto p = pages.begin (); p != pages.end (); ++p) {
|
||||
ShapePropertiesPage *sp = dynamic_cast<ShapePropertiesPage *> (*p);
|
||||
if (sp && sp != this) {
|
||||
sp->apply_change (other_applicator.get (), cv_index, current_only, relative, commit);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ShapePropertiesPage::apply_change (const ChangeApplicator *applicator, unsigned int cv_index, bool current_only, bool relative, bool commit)
|
||||
{
|
||||
if (m_indexes.empty ()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Ask whether to use relative or absolute mode
|
||||
bool relative_mode = false;
|
||||
if (! current_only && applicator->supports_relative_mode ()) {
|
||||
|
|
@ -320,7 +376,7 @@ ShapePropertiesPage::do_apply (bool current_only, bool relative, bool commit)
|
|||
double dbu = layout.dbu ();
|
||||
|
||||
if (!current_only || pos->shape () == current) {
|
||||
new_shape = applicator->do_apply (shapes, pos->shape (), dbu, relative_mode);
|
||||
new_shape = applicator->do_apply (shapes, pos->shape (), dbu, pos->cv_index (), pos->layer (), relative_mode);
|
||||
}
|
||||
|
||||
shapes_seen.insert (std::make_pair (pos->shape (), new_shape));
|
||||
|
|
@ -333,6 +389,7 @@ ShapePropertiesPage::do_apply (bool current_only, bool relative, bool commit)
|
|||
|
||||
// change selection to new shape
|
||||
new_sel[index].set_shape (new_shape);
|
||||
new_sel[index].set_layer (new_shape.layer ());
|
||||
|
||||
mp_service->select (*pos, lay::Editable::Reset);
|
||||
mp_service->select (new_sel[index], lay::Editable::Add);
|
||||
|
|
@ -379,7 +436,7 @@ ShapePropertiesPage::apply (bool commit)
|
|||
bool
|
||||
ShapePropertiesPage::can_apply_to_all () const
|
||||
{
|
||||
return m_selection_ptrs.size () > 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -397,31 +454,35 @@ ShapePropertiesPage::update_shape ()
|
|||
|
||||
EditableSelectionIterator::pointer pos = m_selection_ptrs [m_indexes.front ()];
|
||||
|
||||
const lay::CellView &cv = mp_service->view ()->cellview (pos->cv_index ());
|
||||
double dbu = cv->layout ().dbu ();
|
||||
|
||||
tl_assert (! pos->is_cell_inst ());
|
||||
|
||||
std::string layer (tl::to_string (QObject::tr ("Layer ")));
|
||||
const lay::CellView &cv = view ()->cellview (pos->cv_index ());
|
||||
double dbu = cv->layout ().dbu ();
|
||||
unsigned int gs_layer = cv->layout ().guiding_shape_layer ();
|
||||
|
||||
std::string ln = cv->layout ().get_properties (pos->layer ()).to_string ();
|
||||
for (lay::LayerPropertiesConstIterator lp = mp_service->view ()->begin_layers (); ! lp.at_end (); ++lp) {
|
||||
if (lp->cellview_index () == int (pos->cv_index ()) && lp->layer_index () == int (pos->layer ())) {
|
||||
ln = lp->display_string (mp_service->view (), true, true);
|
||||
break;
|
||||
m_enable_cb_callback = false;
|
||||
layer_selector ()->set_view (view (), pos->cv_index (), true);
|
||||
if (pos->layer () == gs_layer) {
|
||||
layer_selector ()->setEnabled (false);
|
||||
layer_selector ()->set_current_layer (-1);
|
||||
} else {
|
||||
layer_selector ()->setEnabled (true);
|
||||
layer_selector ()->set_current_layer (pos->layer ());
|
||||
}
|
||||
m_enable_cb_callback = true;
|
||||
|
||||
std::string cell_str;
|
||||
if (pos->shape ().shapes () && pos->shape ().shapes ()->cell () && pos->shape ().shapes ()->cell ()->layout ()) {
|
||||
auto ci = pos->shape ().shapes ()->cell ()->cell_index ();
|
||||
cell_str = tl::to_string (tr ("Cell: ")) + pos->shape ().shapes ()->cell ()->layout ()->cell_name (ci);
|
||||
}
|
||||
layer += ln;
|
||||
cell_label ()->setText (tl::to_qstring (cell_str));
|
||||
|
||||
layer += ", ";
|
||||
layer += tl::to_string (QObject::tr ("Cell "));
|
||||
layer += cv->layout ().cell_name (pos->cell_index ());
|
||||
|
||||
mp_service->view ()->set_current_layer (pos->cv_index (), cv->layout ().get_properties (pos->layer ()));
|
||||
view ()->set_current_layer (pos->cv_index (), cv->layout ().get_properties (pos->layer ()));
|
||||
|
||||
m_prop_id = pos->shape ().prop_id ();
|
||||
|
||||
do_update (pos->shape (), dbu, layer);
|
||||
do_update (pos->shape (), dbu);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -507,10 +568,8 @@ PolygonPropertiesPage::description (size_t entry) const
|
|||
}
|
||||
|
||||
void
|
||||
PolygonPropertiesPage::do_update (const db::Shape &shape, double dbu, const std::string &lname)
|
||||
PolygonPropertiesPage::do_update (const db::Shape &shape, double dbu)
|
||||
{
|
||||
layer_lbl->setText (tl::to_qstring (lname));
|
||||
|
||||
db::Polygon poly;
|
||||
shape.polygon (poly);
|
||||
|
||||
|
|
@ -627,7 +686,6 @@ PolygonPropertiesPage::create_applicator (db::Shapes & /*shapes*/, const db::Sha
|
|||
db::Polygon org_poly;
|
||||
shape.polygon (org_poly);
|
||||
|
||||
// shape changed - replace the old by the new one
|
||||
return new PolygonChangeApplicator (poly, org_poly);
|
||||
}
|
||||
|
||||
|
|
@ -683,14 +741,12 @@ BoxPropertiesPage::description (size_t entry) const
|
|||
}
|
||||
|
||||
void
|
||||
BoxPropertiesPage::do_update (const db::Shape &shape, double dbu, const std::string &lname)
|
||||
BoxPropertiesPage::do_update (const db::Shape &shape, double dbu)
|
||||
{
|
||||
m_dbu = dbu;
|
||||
m_lr_swapped = false;
|
||||
m_tb_swapped = false;
|
||||
|
||||
layer_lbl->setText (tl::to_qstring (lname));
|
||||
|
||||
db::Box box;
|
||||
shape.box (box);
|
||||
set_box (box);
|
||||
|
|
@ -913,12 +969,10 @@ PointPropertiesPage::description (size_t entry) const
|
|||
}
|
||||
|
||||
void
|
||||
PointPropertiesPage::do_update (const db::Shape &shape, double dbu, const std::string &lname)
|
||||
PointPropertiesPage::do_update (const db::Shape &shape, double dbu)
|
||||
{
|
||||
m_dbu = dbu;
|
||||
|
||||
layer_lbl->setText (tl::to_qstring (lname));
|
||||
|
||||
db::Point point;
|
||||
shape.point (point);
|
||||
set_point (point);
|
||||
|
|
@ -1042,10 +1096,8 @@ TextPropertiesPage::description (size_t entry) const
|
|||
}
|
||||
|
||||
void
|
||||
TextPropertiesPage::do_update (const db::Shape &shape, double dbu, const std::string &lname)
|
||||
TextPropertiesPage::do_update (const db::Shape &shape, double dbu)
|
||||
{
|
||||
layer_lbl->setText (tl::to_qstring (lname));
|
||||
|
||||
db::Text text;
|
||||
shape.text (text);
|
||||
|
||||
|
|
@ -1194,10 +1246,8 @@ PathPropertiesPage::description (size_t entry) const
|
|||
}
|
||||
|
||||
void
|
||||
PathPropertiesPage::do_update (const db::Shape &shape, double dbu, const std::string &lname)
|
||||
PathPropertiesPage::do_update (const db::Shape &shape, double dbu)
|
||||
{
|
||||
layer_lbl->setText (tl::to_qstring (lname));
|
||||
|
||||
db::Path path;
|
||||
shape.path (path);
|
||||
|
||||
|
|
@ -1298,10 +1348,8 @@ EditablePathPropertiesPage::description (size_t entry) const
|
|||
}
|
||||
|
||||
void
|
||||
EditablePathPropertiesPage::do_update (const db::Shape &shape, double dbu, const std::string &lname)
|
||||
EditablePathPropertiesPage::do_update (const db::Shape &shape, double dbu)
|
||||
{
|
||||
layer_lbl->setText (tl::to_qstring (lname));
|
||||
|
||||
db::Path path;
|
||||
shape.path (path);
|
||||
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@
|
|||
|
||||
#include "layPlugin.h"
|
||||
#include "layProperties.h"
|
||||
#include "layWidgets.h"
|
||||
#include "edtService.h"
|
||||
#include "ui_PolygonPropertiesPage.h"
|
||||
#include "ui_BoxPropertiesPage.h"
|
||||
|
|
@ -67,8 +68,9 @@ private:
|
|||
virtual void apply (bool commit);
|
||||
virtual void apply_to_all (bool relative, bool commit);
|
||||
virtual bool can_apply_to_all () const;
|
||||
virtual void do_apply (bool current_only, bool relative, bool commit);
|
||||
void do_apply (bool current_only, bool relative, bool commit);
|
||||
void recompute_selection_ptrs (const std::vector<lay::ObjectInstPath> &new_sel);
|
||||
void apply_change (const ChangeApplicator *applicator, unsigned int cv_index, bool current_only, bool relative, bool commit);
|
||||
|
||||
protected:
|
||||
std::string m_description;
|
||||
|
|
@ -78,10 +80,12 @@ protected:
|
|||
bool m_enable_cb_callback;
|
||||
db::properties_id_type m_prop_id;
|
||||
|
||||
virtual void do_update (const db::Shape &shape, double dbu, const std::string &lname) = 0;
|
||||
virtual void do_update (const db::Shape &shape, double dbu) = 0;
|
||||
virtual ChangeApplicator *create_applicator (db::Shapes &shapes, const db::Shape &shape, double dbu) = 0;
|
||||
virtual QCheckBox *dbu_checkbox () const = 0;
|
||||
virtual QCheckBox *abs_checkbox () const = 0;
|
||||
virtual lay::LayerSelectionComboBox *layer_selector () const = 0;
|
||||
virtual QLabel *cell_label () const = 0;
|
||||
bool dbu_units () const;
|
||||
bool abs_trans () const;
|
||||
db::ICplxTrans trans () const;
|
||||
|
|
@ -95,6 +99,7 @@ public slots:
|
|||
void show_props ();
|
||||
void display_mode_changed (bool);
|
||||
void update_shape ();
|
||||
void current_layer_changed ();
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -109,12 +114,14 @@ public:
|
|||
|
||||
virtual std::string description (size_t entry) const;
|
||||
virtual std::string description () const { return ShapePropertiesPage::description (); }
|
||||
virtual void do_update (const db::Shape &shape, double dbu, const std::string &lname);
|
||||
virtual void do_update (const db::Shape &shape, double dbu);
|
||||
virtual ChangeApplicator *create_applicator (db::Shapes &shapes, const db::Shape &shape, double dbu);
|
||||
|
||||
protected:
|
||||
virtual QCheckBox *dbu_checkbox () const { return dbu_cb; }
|
||||
virtual QCheckBox *abs_checkbox () const { return abs_cb; }
|
||||
virtual lay::LayerSelectionComboBox *layer_selector () const { return layer_cbx; }
|
||||
virtual QLabel *cell_label () const { return cell_lbl; }
|
||||
|
||||
public slots:
|
||||
void text_changed ();
|
||||
|
|
@ -134,7 +141,7 @@ public:
|
|||
|
||||
virtual std::string description (size_t entry) const;
|
||||
virtual std::string description () const { return ShapePropertiesPage::description (); }
|
||||
virtual void do_update (const db::Shape &shape, double dbu, const std::string &lname);
|
||||
virtual void do_update (const db::Shape &shape, double dbu);
|
||||
virtual ChangeApplicator *create_applicator (db::Shapes &shapes, const db::Shape &shape, double dbu);
|
||||
|
||||
public slots:
|
||||
|
|
@ -143,6 +150,8 @@ public slots:
|
|||
protected:
|
||||
virtual QCheckBox *dbu_checkbox () const { return dbu_cb; }
|
||||
virtual QCheckBox *abs_checkbox () const { return abs_cb; }
|
||||
virtual lay::LayerSelectionComboBox *layer_selector () const { return layer_cbx; }
|
||||
virtual QLabel *cell_label () const { return cell_lbl; }
|
||||
|
||||
private:
|
||||
bool m_recursion_sentinel;
|
||||
|
|
@ -165,7 +174,7 @@ public:
|
|||
|
||||
virtual std::string description (size_t entry) const;
|
||||
virtual std::string description () const { return ShapePropertiesPage::description (); }
|
||||
virtual void do_update (const db::Shape &shape, double dbu, const std::string &lname);
|
||||
virtual void do_update (const db::Shape &shape, double dbu);
|
||||
virtual ChangeApplicator *create_applicator (db::Shapes &shapes, const db::Shape &shape, double dbu);
|
||||
|
||||
public slots:
|
||||
|
|
@ -174,6 +183,8 @@ public slots:
|
|||
protected:
|
||||
virtual QCheckBox *dbu_checkbox () const { return dbu_cb; }
|
||||
virtual QCheckBox *abs_checkbox () const { return abs_cb; }
|
||||
virtual lay::LayerSelectionComboBox *layer_selector () const { return layer_cbx; }
|
||||
virtual QLabel *cell_label () const { return cell_lbl; }
|
||||
|
||||
private:
|
||||
double m_dbu;
|
||||
|
|
@ -193,12 +204,14 @@ public:
|
|||
|
||||
virtual std::string description (size_t entry) const;
|
||||
virtual std::string description () const { return ShapePropertiesPage::description (); }
|
||||
virtual void do_update (const db::Shape &shape, double dbu, const std::string &lname);
|
||||
virtual void do_update (const db::Shape &shape, double dbu);
|
||||
virtual ChangeApplicator *create_applicator (db::Shapes &shapes, const db::Shape &shape, double dbu);
|
||||
|
||||
protected:
|
||||
virtual QCheckBox *dbu_checkbox () const { return dbu_cb; }
|
||||
virtual QCheckBox *abs_checkbox () const { return abs_cb; }
|
||||
virtual lay::LayerSelectionComboBox *layer_selector () const { return layer_cbx; }
|
||||
virtual QLabel *cell_label () const { return cell_lbl; }
|
||||
};
|
||||
|
||||
class PathPropertiesPage
|
||||
|
|
@ -212,12 +225,14 @@ public:
|
|||
|
||||
virtual std::string description (size_t entry) const;
|
||||
virtual std::string description () const { return ShapePropertiesPage::description (); }
|
||||
virtual void do_update (const db::Shape &shape, double dbu, const std::string &lname);
|
||||
virtual void do_update (const db::Shape &shape, double dbu);
|
||||
virtual ChangeApplicator *create_applicator (db::Shapes &shapes, const db::Shape &shape, double dbu);
|
||||
|
||||
protected:
|
||||
virtual QCheckBox *dbu_checkbox () const { return dbu_cb; }
|
||||
virtual QCheckBox *abs_checkbox () const { return abs_cb; }
|
||||
virtual lay::LayerSelectionComboBox *layer_selector () const { return layer_cbx; }
|
||||
virtual QLabel *cell_label () const { return cell_lbl; }
|
||||
|
||||
private:
|
||||
bool m_in_text_changed;
|
||||
|
|
@ -234,12 +249,14 @@ public:
|
|||
|
||||
virtual std::string description (size_t entry) const;
|
||||
virtual std::string description () const { return ShapePropertiesPage::description (); }
|
||||
virtual void do_update (const db::Shape &shape, double dbu, const std::string &lname);
|
||||
virtual void do_update (const db::Shape &shape, double dbu);
|
||||
virtual ChangeApplicator *create_applicator (db::Shapes &shapes, const db::Shape &shape, double dbu);
|
||||
|
||||
protected:
|
||||
virtual QCheckBox *dbu_checkbox () const { return dbu_cb; }
|
||||
virtual QCheckBox *abs_checkbox () const { return abs_cb; }
|
||||
virtual lay::LayerSelectionComboBox *layer_selector () const { return layer_cbx; }
|
||||
virtual QLabel *cell_label () const { return cell_lbl; }
|
||||
|
||||
public slots:
|
||||
void type_selected (int);
|
||||
|
|
|
|||
|
|
@ -181,10 +181,11 @@ PropertiesPage::count () const
|
|||
void
|
||||
PropertiesPage::select_entries (const std::vector<size_t> &entries)
|
||||
{
|
||||
tl_assert (entries.size () == 1);
|
||||
if (! entries.empty ()) {
|
||||
m_index = entries.front ();
|
||||
invalidate ();
|
||||
}
|
||||
}
|
||||
|
||||
std::string
|
||||
PropertiesPage::description (size_t entry) const
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ namespace lay
|
|||
{
|
||||
|
||||
PropertiesPage::PropertiesPage (QWidget *parent, db::Manager *manager, lay::Editable *editable)
|
||||
: QFrame (parent), mp_manager (manager), mp_editable (editable)
|
||||
: QFrame (parent), mp_manager (manager), mp_editable (editable), mp_page_set (0)
|
||||
{
|
||||
// .. nothing else ..
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,6 +41,16 @@ namespace lay
|
|||
|
||||
class Editable;
|
||||
|
||||
/**
|
||||
* @brief An interface delivering all properties pages
|
||||
*/
|
||||
class LAYBASIC_PUBLIC PropertiesPageSet
|
||||
{
|
||||
public:
|
||||
virtual ~PropertiesPageSet () { }
|
||||
virtual const std::vector<lay::PropertiesPage *> &properties_pages () const = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief The properties page object
|
||||
*
|
||||
|
|
@ -211,6 +221,22 @@ public:
|
|||
return mp_manager;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Gets the page set
|
||||
*/
|
||||
const PropertiesPageSet *page_set () const
|
||||
{
|
||||
return mp_page_set;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Sets the page set
|
||||
*/
|
||||
void set_page_set (PropertiesPageSet *page_set)
|
||||
{
|
||||
mp_page_set = page_set;
|
||||
}
|
||||
|
||||
signals:
|
||||
/**
|
||||
* @brief This signal is emitted if a value has been changed
|
||||
|
|
@ -220,6 +246,7 @@ signals:
|
|||
private:
|
||||
db::Manager *mp_manager;
|
||||
tl::weak_ptr<lay::Editable> mp_editable;
|
||||
PropertiesPageSet *mp_page_set;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -157,7 +157,17 @@ public:
|
|||
|
||||
void emit_data_changed ()
|
||||
{
|
||||
emit dataChanged (index (0, 0, QModelIndex ()), index (rowCount (QModelIndex ()) - 1, columnCount (QModelIndex ()) - 1, QModelIndex ()));
|
||||
int cc = columnCount (QModelIndex ());
|
||||
int rc = rowCount (QModelIndex ());
|
||||
|
||||
emit dataChanged (index (0, 0, QModelIndex ()), index (rc - 1, cc - 1, QModelIndex ()));
|
||||
|
||||
// data changes for the children too
|
||||
for (int i = 0; i < rc; ++i) {
|
||||
auto p = index (i, 0, QModelIndex ());
|
||||
int ec = rowCount (p);
|
||||
emit dataChanged (index (0, 0, p), index (ec - 1, cc - 1, p));
|
||||
}
|
||||
}
|
||||
|
||||
void begin_reset_model ()
|
||||
|
|
@ -204,6 +214,7 @@ PropertiesDialog::PropertiesDialog (QWidget * /*parent*/, db::Manager *manager,
|
|||
delete *p;
|
||||
} else {
|
||||
mp_properties_pages.push_back (*p);
|
||||
(*p)->set_page_set (this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -224,10 +235,11 @@ PropertiesDialog::PropertiesDialog (QWidget * /*parent*/, db::Manager *manager,
|
|||
m_current_object = 0;
|
||||
|
||||
// look for next usable editable
|
||||
m_object_indexes.resize (mp_properties_pages.size ());
|
||||
if (m_index >= int (mp_properties_pages.size ())) {
|
||||
m_index = -1;
|
||||
} else {
|
||||
m_object_indexes.push_back (0);
|
||||
m_object_indexes [m_index].push_back (0);
|
||||
}
|
||||
|
||||
update_title ();
|
||||
|
|
@ -251,12 +263,11 @@ PropertiesDialog::PropertiesDialog (QWidget * /*parent*/, db::Manager *manager,
|
|||
mp_ui->tree->setCurrentIndex (mp_tree_model->index_for (m_index, 0));
|
||||
m_signals_enabled = true;
|
||||
|
||||
update_controls ();
|
||||
|
||||
mp_ui->apply_to_all_cbx->setChecked (false);
|
||||
mp_ui->apply_to_all_cbx->setChecked (true); // TODO: persist
|
||||
mp_ui->relative_cbx->setChecked (true);
|
||||
|
||||
fetch_config ();
|
||||
update_controls ();
|
||||
|
||||
connect (mp_ui->ok_button, SIGNAL (clicked ()), this, SLOT (ok_pressed ()));
|
||||
connect (mp_ui->cancel_button, SIGNAL (clicked ()), this, SLOT (cancel_pressed ()));
|
||||
|
|
@ -311,13 +322,7 @@ PropertiesDialog::disconnect ()
|
|||
void
|
||||
PropertiesDialog::apply_to_all_pressed ()
|
||||
{
|
||||
m_signals_enabled = false;
|
||||
if (mp_ui->apply_to_all_cbx->isChecked ()) {
|
||||
mp_ui->tree->setCurrentIndex (mp_tree_model->index_for (m_index));
|
||||
} else if (! m_object_indexes.empty ()) {
|
||||
mp_ui->tree->setCurrentIndex (mp_tree_model->index_for (m_index, int (m_object_indexes.front ())));
|
||||
}
|
||||
m_signals_enabled = true;
|
||||
mp_ui->relative_cbx->setEnabled (mp_ui->apply_to_all_cbx->isEnabled () && mp_ui->apply_to_all_cbx->isChecked ());
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -379,6 +384,7 @@ BEGIN_PROTECTED
|
|||
delete *p;
|
||||
} else {
|
||||
mp_properties_pages.push_back (*p);
|
||||
(*p)->set_page_set (this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -394,10 +400,11 @@ BEGIN_PROTECTED
|
|||
// look for next usable editable
|
||||
m_index = 0;
|
||||
m_object_indexes.clear ();
|
||||
m_object_indexes.resize (mp_properties_pages.size ());
|
||||
if (m_index >= int (mp_properties_pages.size ())) {
|
||||
m_index = -1;
|
||||
} else {
|
||||
m_object_indexes.push_back (0);
|
||||
m_object_indexes [m_index].push_back (0);
|
||||
}
|
||||
|
||||
mp_tree_model->end_reset_model ();
|
||||
|
|
@ -432,6 +439,7 @@ PropertiesDialog::current_index_changed (const QModelIndex &index, const QModelI
|
|||
}
|
||||
|
||||
m_object_indexes.clear ();
|
||||
m_object_indexes.resize (mp_properties_pages.size ());
|
||||
|
||||
if (! index.isValid ()) {
|
||||
|
||||
|
|
@ -458,57 +466,66 @@ PropertiesDialog::current_index_changed (const QModelIndex &index, const QModelI
|
|||
|
||||
}
|
||||
|
||||
if (mp_tree_model->parent (index).isValid ()) {
|
||||
|
||||
m_index = mp_tree_model->page_index (index);
|
||||
|
||||
if (mp_properties_pages [m_index]->can_apply_to_all ()) {
|
||||
|
||||
m_object_indexes.push_back (size_t (mp_tree_model->object_index (index)));
|
||||
m_index = -1;
|
||||
|
||||
auto selection = mp_ui->tree->selectionModel ()->selectedIndexes ();
|
||||
|
||||
// establish a single-selection on the current item
|
||||
if (mp_tree_model->parent (index).isValid ()) {
|
||||
int oi = mp_tree_model->object_index (index);
|
||||
int pi = mp_tree_model->page_index (index);
|
||||
m_index = pi;
|
||||
m_object_indexes [pi].push_back (size_t (oi));
|
||||
}
|
||||
|
||||
// establish individual selections for the other items
|
||||
// as far as allowed by "can_apply_to_all"
|
||||
for (auto i = selection.begin (); i != selection.end (); ++i) {
|
||||
if (mp_tree_model->parent (*i).isValid () && mp_tree_model->page_index (*i) == m_index) {
|
||||
if (*i != index && mp_tree_model->parent (*i).isValid ()) {
|
||||
int oi = mp_tree_model->object_index (*i);
|
||||
if (oi != int (m_object_indexes.front ())) {
|
||||
m_object_indexes.push_back (size_t (oi));
|
||||
int pi = mp_tree_model->page_index (*i);
|
||||
if (mp_properties_pages [pi]->can_apply_to_all ()) {
|
||||
m_object_indexes [pi].push_back (size_t (oi));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
m_object_indexes.push_back (size_t (mp_tree_model->object_index (index)));
|
||||
|
||||
// establish group node selection as current item -> translate into "all" for "can_apply_to_all" pages
|
||||
// or first item unless an item is explicitly selected.
|
||||
if (! mp_tree_model->parent (index).isValid ()) {
|
||||
int pi = index.row ();
|
||||
m_index = pi;
|
||||
m_object_indexes [pi].clear ();
|
||||
if (mp_properties_pages [pi]->can_apply_to_all ()) {
|
||||
for (size_t oi = 0; oi < mp_properties_pages [pi]->count (); ++oi) {
|
||||
m_object_indexes [pi].push_back (oi);
|
||||
}
|
||||
} else if (mp_properties_pages [pi]->count () > 0 && m_object_indexes [pi].empty ()) {
|
||||
m_object_indexes [pi].push_back (0);
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
m_index = index.row ();
|
||||
mp_ui->apply_to_all_cbx->setChecked (mp_properties_pages [m_index]->can_apply_to_all ());
|
||||
|
||||
if (mp_properties_pages [m_index]->can_apply_to_all ()) {
|
||||
|
||||
for (size_t oi = 0; oi < mp_properties_pages [m_index]->count (); ++oi) {
|
||||
m_object_indexes.push_back (oi);
|
||||
// establish group node selection for other items -> translate into "all" for "can_apply_to_all" pages
|
||||
for (auto i = selection.begin (); i != selection.end (); ++i) {
|
||||
if (*i != index && ! mp_tree_model->parent (*i).isValid ()) {
|
||||
int pi = i->row ();
|
||||
m_object_indexes [pi].clear ();
|
||||
if (mp_properties_pages [pi]->can_apply_to_all ()) {
|
||||
for (size_t oi = 0; oi < mp_properties_pages [pi]->count (); ++oi) {
|
||||
m_object_indexes[pi].push_back (oi);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else if (mp_properties_pages [m_index]->count () > 0) {
|
||||
|
||||
m_object_indexes.push_back (0);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (! m_object_indexes.empty ()) {
|
||||
if (m_index >= 0 && ! m_object_indexes [m_index].empty ()) {
|
||||
m_current_object = 0;
|
||||
for (int i = 0; i < m_index; ++i) {
|
||||
m_current_object += mp_properties_pages [i]->count ();
|
||||
}
|
||||
m_current_object += int (m_object_indexes.front ());
|
||||
m_current_object += int (m_object_indexes [m_index].front ());
|
||||
} else {
|
||||
m_current_object = -1;
|
||||
}
|
||||
|
|
@ -527,8 +544,6 @@ PropertiesDialog::update_controls ()
|
|||
}
|
||||
m_prev_index = m_index;
|
||||
|
||||
mp_ui->apply_to_all_cbx->setChecked (m_object_indexes.size () > 1);
|
||||
|
||||
if (m_index < 0 || m_index >= int (mp_properties_pages.size ())) {
|
||||
|
||||
mp_stack->setCurrentWidget (mp_none);
|
||||
|
|
@ -551,7 +566,10 @@ PropertiesDialog::update_controls ()
|
|||
mp_ui->ok_button->setEnabled (! mp_properties_pages [m_index]->readonly ());
|
||||
mp_ui->tree->setEnabled (true);
|
||||
|
||||
mp_properties_pages [m_index]->select_entries (m_object_indexes);
|
||||
for (int i = 0; i < int (mp_properties_pages.size ()); ++i) {
|
||||
mp_properties_pages [i]->select_entries (m_object_indexes [i]);
|
||||
}
|
||||
|
||||
mp_properties_pages [m_index]->update ();
|
||||
|
||||
}
|
||||
|
|
@ -562,7 +580,7 @@ PropertiesDialog::next_pressed ()
|
|||
{
|
||||
BEGIN_PROTECTED
|
||||
|
||||
if (m_object_indexes.empty ()) {
|
||||
if (m_index < 0 || m_object_indexes [m_index].empty ()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -575,7 +593,7 @@ BEGIN_PROTECTED
|
|||
}
|
||||
|
||||
// advance the current entry
|
||||
int object_index = int (m_object_indexes.front ());
|
||||
int object_index = int (m_object_indexes [m_index].front ());
|
||||
++object_index;
|
||||
|
||||
// look for next usable editable if at end
|
||||
|
|
@ -592,7 +610,8 @@ BEGIN_PROTECTED
|
|||
}
|
||||
|
||||
m_object_indexes.clear ();
|
||||
m_object_indexes.push_back (object_index);
|
||||
m_object_indexes.resize (mp_properties_pages.size ());
|
||||
m_object_indexes [m_index].push_back (object_index);
|
||||
|
||||
++m_current_object;
|
||||
update_title ();
|
||||
|
|
@ -610,7 +629,7 @@ PropertiesDialog::prev_pressed ()
|
|||
{
|
||||
BEGIN_PROTECTED
|
||||
|
||||
if (m_object_indexes.empty ()) {
|
||||
if (m_index < 0 || m_object_indexes [m_index].empty ()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -623,7 +642,7 @@ BEGIN_PROTECTED
|
|||
}
|
||||
|
||||
// advance the current entry
|
||||
int object_index = int (m_object_indexes.front ());
|
||||
int object_index = int (m_object_indexes [m_index].front ());
|
||||
if (object_index == 0) {
|
||||
|
||||
// look for last usable editable if at end
|
||||
|
|
@ -642,7 +661,8 @@ BEGIN_PROTECTED
|
|||
--object_index;
|
||||
|
||||
m_object_indexes.clear ();
|
||||
m_object_indexes.push_back (object_index);
|
||||
m_object_indexes.resize (mp_properties_pages.size ());
|
||||
m_object_indexes [m_index].push_back (object_index);
|
||||
|
||||
--m_current_object;
|
||||
update_title ();
|
||||
|
|
@ -668,12 +688,12 @@ PropertiesDialog::update_title ()
|
|||
bool
|
||||
PropertiesDialog::any_next () const
|
||||
{
|
||||
if (m_object_indexes.empty ()) {
|
||||
if (m_index < 0 || m_object_indexes [m_index].empty ()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int index = m_index;
|
||||
if (m_object_indexes.front () + 1 >= mp_properties_pages [index]->count ()) {
|
||||
if (m_object_indexes [m_index].front () + 1 >= mp_properties_pages [index]->count ()) {
|
||||
++index;
|
||||
}
|
||||
|
||||
|
|
@ -684,12 +704,12 @@ PropertiesDialog::any_next () const
|
|||
bool
|
||||
PropertiesDialog::any_prev () const
|
||||
{
|
||||
if (m_object_indexes.empty ()) {
|
||||
if (m_index < 0 || m_object_indexes [m_index].empty ()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int index = m_index;
|
||||
if (m_object_indexes.front () == 0) {
|
||||
if (m_object_indexes [m_index].front () == 0) {
|
||||
--index;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@
|
|||
#define HDR_layPropertiesDialog
|
||||
|
||||
#include "layuiCommon.h"
|
||||
#include "layProperties.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
|
|
@ -52,7 +53,6 @@ namespace lay
|
|||
|
||||
class Editable;
|
||||
class Editables;
|
||||
class PropertiesPage;
|
||||
class MainWindow;
|
||||
class PropertiesTreeModel;
|
||||
|
||||
|
|
@ -65,7 +65,7 @@ class PropertiesTreeModel;
|
|||
*/
|
||||
|
||||
class LAYUI_PUBLIC PropertiesDialog
|
||||
: public QDialog
|
||||
: public QDialog, public lay::PropertiesPageSet
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
|
@ -80,6 +80,14 @@ public:
|
|||
*/
|
||||
~PropertiesDialog ();
|
||||
|
||||
/**
|
||||
* @brief Implementation of PropertiesPageSet
|
||||
*/
|
||||
virtual const std::vector<lay::PropertiesPage *> &properties_pages () const
|
||||
{
|
||||
return mp_properties_pages;
|
||||
}
|
||||
|
||||
private:
|
||||
friend class PropertiesTreeModel;
|
||||
|
||||
|
|
@ -87,7 +95,7 @@ private:
|
|||
db::Manager *mp_manager;
|
||||
lay::Editables *mp_editables;
|
||||
int m_index, m_prev_index;
|
||||
std::vector<size_t> m_object_indexes;
|
||||
std::vector<std::vector<size_t> > m_object_indexes;
|
||||
QStackedLayout *mp_stack;
|
||||
QLabel *mp_none;
|
||||
lay::MainWindow *mp_mw;
|
||||
|
|
|
|||
|
|
@ -514,7 +514,7 @@ struct LayerSelectionComboBoxPrivateData
|
|||
};
|
||||
|
||||
LayerSelectionComboBox::LayerSelectionComboBox (QWidget *parent)
|
||||
: QComboBox (parent), dm_update_layer_list (this, &LayerSelectionComboBox::do_update_layer_list)
|
||||
: QComboBox (parent), dm_update_layer_list (this, &LayerSelectionComboBox::do_update_layer_list), m_ignore_layer_list_changed (false)
|
||||
{
|
||||
mp_private = new LayerSelectionComboBoxPrivateData ();
|
||||
mp_private->no_layer_available = false;
|
||||
|
|
@ -608,8 +608,12 @@ BEGIN_PROTECTED
|
|||
// NOTE: add_new_layers has triggered update_layer_list which already added the new layer
|
||||
set_current_layer (lp);
|
||||
|
||||
emit current_layer_changed ();
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
emit current_layer_changed ();
|
||||
}
|
||||
|
||||
END_PROTECTED;
|
||||
|
|
@ -647,8 +651,10 @@ LayerSelectionComboBox::set_view (lay::LayoutViewBase *view, int cv_index, bool
|
|||
void
|
||||
LayerSelectionComboBox::on_layer_list_changed (int)
|
||||
{
|
||||
if (! m_ignore_layer_list_changed) {
|
||||
update_layer_list ();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
LayerSelectionComboBox::set_layout (const db::Layout *layout)
|
||||
|
|
@ -698,13 +704,25 @@ LayerSelectionComboBox::do_update_layer_list ()
|
|||
|
||||
} else {
|
||||
|
||||
int icon_width = iconSize ().width ();
|
||||
int icon_height = iconSize ().height ();
|
||||
|
||||
#if QT_VERSION >= 0x050000
|
||||
double dpr = devicePixelRatio ();
|
||||
#else
|
||||
double dpr = 1.0;
|
||||
#endif
|
||||
|
||||
LPIPairCompareOp cmp_op;
|
||||
std::map<std::pair<db::LayerProperties, int>, std::string, LPIPairCompareOp> name_for_layer (cmp_op);
|
||||
std::map<std::pair<db::LayerProperties, int>, QIcon, LPIPairCompareOp> icon_for_layer;
|
||||
LayerPropertiesConstIterator lp = mp_private->view->begin_layers ();
|
||||
while (! lp.at_end ()) {
|
||||
if (lp->cellview_index () == mp_private->cv_index && ! lp->has_children () && (mp_private->all_layers || lp->layer_index () >= 0) && lp->source (true).layer_props () != db::LayerProperties ()) {
|
||||
std::pair <db::LayerProperties, int> k (lp->source (true).layer_props (), lp->layer_index ());
|
||||
name_for_layer.insert (std::make_pair (k, lp->display_string (mp_private->view, true, true /*always show source*/)));
|
||||
QIcon icon = QIcon (QPixmap::fromImage (mp_private->view->icon_for_layer (lp, icon_width, icon_height, dpr, 0, true).to_image_copy ()));
|
||||
icon_for_layer.insert (std::make_pair (k, icon));
|
||||
mp_private->layers.push_back (k);
|
||||
}
|
||||
++lp;
|
||||
|
|
@ -724,11 +742,18 @@ LayerSelectionComboBox::do_update_layer_list ()
|
|||
std::sort (mp_private->layers.begin () + nk, mp_private->layers.end ());
|
||||
|
||||
for (std::vector <std::pair <db::LayerProperties, int> >::iterator ll = mp_private->layers.begin (); ll != mp_private->layers.end (); ++ll) {
|
||||
std::map<std::pair <db::LayerProperties, int>, std::string, LPIPairCompareOp>::const_iterator ln = name_for_layer.find (*ll);
|
||||
auto ln = name_for_layer.find (*ll);
|
||||
QString text;
|
||||
if (ln != name_for_layer.end ()) {
|
||||
addItem (tl::to_qstring (ln->second));
|
||||
text = tl::to_qstring (ln->second);
|
||||
} else {
|
||||
addItem (tl::to_qstring (ll->first.to_string ()));
|
||||
text = tl::to_qstring (ll->first.to_string ());
|
||||
}
|
||||
auto li = icon_for_layer.find (*ll);
|
||||
if (li != icon_for_layer.end ()) {
|
||||
addItem (li->second, text);
|
||||
} else {
|
||||
addItem (text);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -778,8 +803,8 @@ LayerSelectionComboBox::set_current_layer (const db::LayerProperties &props)
|
|||
setCurrentIndex (-1);
|
||||
}
|
||||
|
||||
void
|
||||
LayerSelectionComboBox::set_current_layer (int l)
|
||||
const db::Layout *
|
||||
LayerSelectionComboBox::layout () const
|
||||
{
|
||||
const db::Layout *layout = mp_private->layout;
|
||||
if (! layout && mp_private->view) {
|
||||
|
|
@ -788,9 +813,22 @@ LayerSelectionComboBox::set_current_layer (int l)
|
|||
layout = & cv->layout ();
|
||||
}
|
||||
}
|
||||
return layout;
|
||||
}
|
||||
|
||||
if (l >= 0 && layout && layout->is_valid_layer ((unsigned int) l)) {
|
||||
mp_private->last_props = layout->get_properties ((unsigned int) l);
|
||||
db::Layout *
|
||||
LayerSelectionComboBox::layout ()
|
||||
{
|
||||
return const_cast<db::Layout *> (((const LayerSelectionComboBox *) this)->layout ());
|
||||
}
|
||||
|
||||
void
|
||||
LayerSelectionComboBox::set_current_layer (int l)
|
||||
{
|
||||
const db::Layout *ly = layout ();
|
||||
|
||||
if (l >= 0 && ly && ly->is_valid_layer ((unsigned int) l)) {
|
||||
mp_private->last_props = ly->get_properties ((unsigned int) l);
|
||||
}
|
||||
|
||||
if (l < 0) {
|
||||
|
|
@ -804,6 +842,12 @@ LayerSelectionComboBox::set_current_layer (int l)
|
|||
}
|
||||
}
|
||||
|
||||
bool
|
||||
LayerSelectionComboBox::is_no_layer_selected () const
|
||||
{
|
||||
return currentIndex () < 0;
|
||||
}
|
||||
|
||||
int
|
||||
LayerSelectionComboBox::current_layer () const
|
||||
{
|
||||
|
|
@ -815,6 +859,39 @@ LayerSelectionComboBox::current_layer () const
|
|||
}
|
||||
}
|
||||
|
||||
int
|
||||
LayerSelectionComboBox::current_layer_ensure ()
|
||||
{
|
||||
int i = currentIndex ();
|
||||
if (i < 0 || i > int (mp_private->layers.size ())) {
|
||||
|
||||
return -1;
|
||||
|
||||
} else if (mp_private->layers [i].second < 0) {
|
||||
|
||||
db::Layout *ly = layout ();
|
||||
if (! ly) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
m_ignore_layer_list_changed = true;
|
||||
try {
|
||||
unsigned int l = ly->insert_layer (mp_private->layers [i].first);
|
||||
mp_private->layers [i].second = l;
|
||||
m_ignore_layer_list_changed = false;
|
||||
return l;
|
||||
} catch (...) {
|
||||
m_ignore_layer_list_changed = false;
|
||||
throw;
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
return mp_private->layers [i].second;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
db::LayerProperties
|
||||
LayerSelectionComboBox::current_layer_props () const
|
||||
{
|
||||
|
|
|
|||
|
|
@ -300,26 +300,60 @@ public:
|
|||
*/
|
||||
void set_current_layer (int l);
|
||||
|
||||
/**
|
||||
* @brief Gets a valid indicating whether a layer is selected
|
||||
*
|
||||
* This method returns true if "no layer" is selected
|
||||
*/
|
||||
bool is_no_layer_selected () const;
|
||||
|
||||
/**
|
||||
* @brief Get the current layer (index)
|
||||
*
|
||||
* NOTE: this method returns -1 if no layer is selected or
|
||||
* the current layer does not exist. Use "is_no_layer_selected"
|
||||
* for a value telling whether no layer is selected (true)
|
||||
* or a not-yet-existing layer is selected (false).
|
||||
*/
|
||||
int current_layer () const;
|
||||
|
||||
/**
|
||||
* @brief Get the current layer (index) and makes sure it exists
|
||||
*
|
||||
* This method ensures that the layer is created if it does not
|
||||
* exist yet. It returns -1 on "no layer" (if enabled).
|
||||
*/
|
||||
int current_layer_ensure ();
|
||||
|
||||
/**
|
||||
* @brief Get the current layer properties
|
||||
*
|
||||
* If "no layer" is selected, this method returns the last properties set
|
||||
* with "set_current_layer". Use "is_no_layer_selected" to get
|
||||
* a value indicating whether the "no layer" entry is selected.
|
||||
*/
|
||||
db::LayerProperties current_layer_props () const;
|
||||
|
||||
signals:
|
||||
/**
|
||||
* @brief Signal indicating that the user selected a new layer
|
||||
* This signal is emitted if the layer is edited. It is not emitted on programmatic changes.
|
||||
*/
|
||||
void current_layer_changed ();
|
||||
|
||||
protected slots:
|
||||
void item_selected (int index);
|
||||
|
||||
private:
|
||||
LayerSelectionComboBoxPrivateData *mp_private;
|
||||
tl::DeferredMethod<LayerSelectionComboBox> dm_update_layer_list;
|
||||
bool m_ignore_layer_list_changed;
|
||||
|
||||
void on_layer_list_changed (int);
|
||||
void update_layer_list ();
|
||||
void do_update_layer_list ();
|
||||
db::Layout *layout ();
|
||||
const db::Layout *layout () const;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in New Issue