diff --git a/src/db/db/dbShape.cc b/src/db/db/dbShape.cc
index 75de096c5..374bec909 100644
--- a/src/db/db/dbShape.cc
+++ b/src/db/db/dbShape.cc
@@ -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) {
diff --git a/src/db/db/dbShape.h b/src/db/db/dbShape.h
index a3d34cbef..f2740a385 100644
--- a/src/db/db/dbShape.h
+++ b/src/db/db/dbShape.h
@@ -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
*/
diff --git a/src/db/unit_tests/dbShapeTests.cc b/src/db/unit_tests/dbShapeTests.cc
index 92a58ba7a..185a13ffb 100644
--- a/src/db/unit_tests/dbShapeTests.cc
+++ b/src/db/unit_tests/dbShapeTests.cc
@@ -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));
+}
diff --git a/src/edt/edt/BoxPropertiesPage.ui b/src/edt/edt/BoxPropertiesPage.ui
index 03f7d3493..0973cb844 100644
--- a/src/edt/edt/BoxPropertiesPage.ui
+++ b/src/edt/edt/BoxPropertiesPage.ui
@@ -53,10 +53,10 @@
-
-
+
-
- 0
+
+ 1
0
@@ -68,6 +68,13 @@
+ -
+
+
+ QComboBox::AdjustToContents
+
+
+
@@ -576,6 +583,13 @@
+
+
+ lay::LayerSelectionComboBox
+ QComboBox
+
+
+
mode_tab
x1_le_1
diff --git a/src/edt/edt/EditablePathPropertiesPage.ui b/src/edt/edt/EditablePathPropertiesPage.ui
index f752c308d..b044be92c 100644
--- a/src/edt/edt/EditablePathPropertiesPage.ui
+++ b/src/edt/edt/EditablePathPropertiesPage.ui
@@ -96,7 +96,6 @@
Sans Serif
12
- 75
false
true
false
@@ -109,10 +108,10 @@
-
-
+
-
- 0
+
+ 1
0
@@ -124,6 +123,9 @@
+ -
+
+
@@ -334,6 +336,13 @@
+
+
+ lay::LayerSelectionComboBox
+ QComboBox
+
+
+
width_le
ptlist_le
diff --git a/src/edt/edt/PathPropertiesPage.ui b/src/edt/edt/PathPropertiesPage.ui
index a033ebb35..c75bad9e2 100644
--- a/src/edt/edt/PathPropertiesPage.ui
+++ b/src/edt/edt/PathPropertiesPage.ui
@@ -264,7 +264,6 @@
Sans Serif
12
- 75
false
true
false
@@ -277,10 +276,10 @@
-
-
+
-
- 0
+
+ 1
0
@@ -292,6 +291,13 @@
+ -
+
+
+ QComboBox::AdjustToContents
+
+
+
@@ -304,6 +310,13 @@
+
+
+ lay::LayerSelectionComboBox
+ QComboBox
+
+
+
width_le
ptlist_le
diff --git a/src/edt/edt/PointPropertiesPage.ui b/src/edt/edt/PointPropertiesPage.ui
index 2cef295b1..525092719 100644
--- a/src/edt/edt/PointPropertiesPage.ui
+++ b/src/edt/edt/PointPropertiesPage.ui
@@ -53,10 +53,10 @@
-
-
+
-
- 0
+
+ 1
0
@@ -68,6 +68,13 @@
+ -
+
+
+ QComboBox::AdjustToContents
+
+
+
@@ -271,6 +278,13 @@
+
+
+ lay::LayerSelectionComboBox
+ QComboBox
+
+
+
x_le
y_le
diff --git a/src/edt/edt/PolygonPropertiesPage.ui b/src/edt/edt/PolygonPropertiesPage.ui
index 4267391d8..ca9766ec7 100644
--- a/src/edt/edt/PolygonPropertiesPage.ui
+++ b/src/edt/edt/PolygonPropertiesPage.ui
@@ -109,7 +109,6 @@
Sans Serif
12
- 75
false
true
false
@@ -122,10 +121,10 @@
-
-
+
-
- 0
+
+ 1
0
@@ -137,6 +136,13 @@
+ -
+
+
+ QComboBox::AdjustToContents
+
+
+
@@ -225,6 +231,13 @@
+
+
+ lay::LayerSelectionComboBox
+ QComboBox
+
+
+
pointListEdit
dbu_cb
diff --git a/src/edt/edt/TextPropertiesPage.ui b/src/edt/edt/TextPropertiesPage.ui
index 125981400..4de325d6f 100644
--- a/src/edt/edt/TextPropertiesPage.ui
+++ b/src/edt/edt/TextPropertiesPage.ui
@@ -7,7 +7,7 @@
0
0
568
- 375
+ 378
@@ -245,10 +245,10 @@ to show text objects scaled and rotated
-
-
+
-
- 0
+
+ 1
0
@@ -260,6 +260,13 @@ to show text objects scaled and rotated
+ -
+
+
+ QComboBox::AdjustToContents
+
+
+
@@ -413,6 +420,13 @@ to show text objects scaled and rotated
+
+
+ lay::LayerSelectionComboBox
+ QComboBox
+
+
+
text_le
x_le
diff --git a/src/edt/edt/edtPropertiesPageUtils.cc b/src/edt/edt/edtPropertiesPageUtils.cc
index 2bb359eae..b79b56b78 100644
--- a/src/edt/edt/edtPropertiesPageUtils.cc
+++ b/src/edt/edt/edtPropertiesPageUtils.cc
@@ -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::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,24 @@ db::Instance ChangePropertiesApplicator::do_apply_inst (db::Cell &cell, const db
return cell.replace_prop_id (instance, m_prop_id);
}
+// -------------------------------------------------------------------------
+// ChangeLayerApplicator implementation
+
+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) {
+ s.set_layer (m_new_layer);
+ }
+ return s;
+}
+
// -------------------------------------------------------------------------
// BoxDimensionsChangeApplicator implementation
@@ -126,7 +144,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 +225,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 +261,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 +274,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 +298,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 +324,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 +361,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 +387,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 +413,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 +439,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 +465,7 @@ PathPointsChangeApplicator::PathPointsChangeApplicator (const std::vector &points, const std::vector &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 m_points, m_org_points;
@@ -285,7 +301,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 +317,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 +333,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 +349,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;
diff --git a/src/edt/edt/edtPropertiesPages.cc b/src/edt/edt/edtPropertiesPages.cc
index 5cdbeb85d..b538775f6 100644
--- a/src/edt/edt/edtPropertiesPages.cc
+++ b/src/edt/edt/edtPropertiesPages.cc
@@ -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;
}
@@ -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 ()
{
@@ -260,6 +278,11 @@ 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)));
}
+
+ int new_layer = layer_selector ()->current_layer ();
+ if (new_layer >= 0 && int (pos->layer ()) != new_layer) {
+ applicator.reset (new CombinedChangeApplicator (applicator.release (), new ChangeLayerApplicator (cv_index, (unsigned int) new_layer)));
+ }
}
if (! applicator.get ()) {
@@ -320,7 +343,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,9 +356,10 @@ 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);
+ mp_service->select (new_sel[index], lay::Editable::Add);
update_required = true;
@@ -348,7 +372,7 @@ ShapePropertiesPage::do_apply (bool current_only, bool relative, bool commit)
new_sel[index] = gs.second;
mp_service->select (*pos, lay::Editable::Reset);
- mp_service->select (new_sel [index], lay::Editable::Add);
+ mp_service->select (new_sel[index], lay::Editable::Add);
update_required = true;
@@ -379,7 +403,7 @@ ShapePropertiesPage::apply (bool commit)
bool
ShapePropertiesPage::can_apply_to_all () const
{
- return m_selection_ptrs.size () > 1;
+ return true;
}
void
@@ -397,31 +421,28 @@ 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 ();
- 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);
+ 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 +528,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 +646,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 +701,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 +929,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 +1056,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 +1206,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 +1308,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);
diff --git a/src/edt/edt/edtPropertiesPages.h b/src/edt/edt/edtPropertiesPages.h
index 5e575cb16..237c601b1 100644
--- a/src/edt/edt/edtPropertiesPages.h
+++ b/src/edt/edt/edtPropertiesPages.h
@@ -28,6 +28,7 @@
#include "layPlugin.h"
#include "layProperties.h"
+#include "layWidgets.h"
#include "edtService.h"
#include "ui_PolygonPropertiesPage.h"
#include "ui_BoxPropertiesPage.h"
@@ -78,10 +79,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 +98,7 @@ public slots:
void show_props ();
void display_mode_changed (bool);
void update_shape ();
+ void current_layer_changed ();
};
@@ -109,12 +113,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 +140,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 +149,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 +173,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 +182,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 +203,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 +224,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 +248,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);
diff --git a/src/layui/layui/layPropertiesDialog.cc b/src/layui/layui/layPropertiesDialog.cc
index c08e2f30d..6c1e2100c 100644
--- a/src/layui/layui/layPropertiesDialog.cc
+++ b/src/layui/layui/layPropertiesDialog.cc
@@ -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 ()
diff --git a/src/layui/layui/layWidgets.cc b/src/layui/layui/layWidgets.cc
index d0f1eda6b..915a106b7 100644
--- a/src/layui/layui/layWidgets.cc
+++ b/src/layui/layui/layWidgets.cc
@@ -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;
diff --git a/src/layui/layui/layWidgets.h b/src/layui/layui/layWidgets.h
index 0793e7bab..b5261d9d8 100644
--- a/src/layui/layui/layWidgets.h
+++ b/src/layui/layui/layWidgets.h
@@ -310,6 +310,13 @@ public:
*/
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);