Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/ant/ant/antPropertiesPage.cc
Original file line number Diff line number Diff line change
Expand Up @@ -375,8 +375,9 @@ PropertiesPage::count () const
void
PropertiesPage::select_entries (const std::vector<size_t> &entries)
{
tl_assert (entries.size () == 1);
m_index = entries.front ();
if (! entries.empty ()) {
m_index = entries.front ();
}
}

std::string
Expand Down
41 changes: 41 additions & 0 deletions src/db/db/dbShape.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
20 changes: 20 additions & 0 deletions src/db/db/dbShape.h
Original file line number Diff line number Diff line change
Expand Up @@ -1098,6 +1098,26 @@ class DB_PUBLIC Shape
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
*/
Expand Down
29 changes: 29 additions & 0 deletions src/db/unit_tests/dbShapeTests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
20 changes: 17 additions & 3 deletions src/edt/edt/BoxPropertiesPage.ui
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -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>
Expand Down Expand Up @@ -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>
Expand Down
17 changes: 13 additions & 4 deletions src/edt/edt/EditablePathPropertiesPage.ui
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@
<font>
<family>Sans Serif</family>
<pointsize>12</pointsize>
<weight>75</weight>
<italic>false</italic>
<bold>true</bold>
<underline>false</underline>
Expand All @@ -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>
Expand All @@ -124,6 +123,9 @@
</property>
</widget>
</item>
<item>
<widget class="lay::LayerSelectionComboBox" name="layer_cbx"/>
</item>
</layout>
</widget>
</item>
Expand Down Expand Up @@ -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>
Expand Down
21 changes: 17 additions & 4 deletions src/edt/edt/PathPropertiesPage.ui
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,6 @@
<font>
<family>Sans Serif</family>
<pointsize>12</pointsize>
<weight>75</weight>
<italic>false</italic>
<bold>true</bold>
<underline>false</underline>
Expand All @@ -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>
Expand All @@ -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>
Expand All @@ -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>
Expand Down
20 changes: 17 additions & 3 deletions src/edt/edt/PointPropertiesPage.ui
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -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>
Expand Down Expand Up @@ -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>
Expand Down
21 changes: 17 additions & 4 deletions src/edt/edt/PolygonPropertiesPage.ui
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@
<font>
<family>Sans Serif</family>
<pointsize>12</pointsize>
<weight>75</weight>
<italic>false</italic>
<bold>true</bold>
<underline>false</underline>
Expand All @@ -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>
Expand All @@ -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>
Expand Down Expand Up @@ -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>
Expand Down
Loading
Loading