Shapes#cell and Shapes#layout

This commit is contained in:
Matthias Koefferlein 2022-08-27 17:51:14 +02:00
parent bf9d8100f2
commit 67d8518926
2 changed files with 29 additions and 0 deletions

View File

@ -437,6 +437,15 @@ static void insert_texts_with_dtrans (db::Shapes *sh, const db::Texts &r, const
}
}
static db::Layout *layout (db::Shapes *sh)
{
if (sh->cell ()) {
return sh->cell ()->layout ();
} else {
return 0;
}
}
static unsigned int s_all () { return db::ShapeIterator::All; }
static unsigned int s_all_with_properties () { return db::ShapeIterator::AllWithProperties; }
static unsigned int s_properties () { return db::ShapeIterator::Properties; }
@ -1231,6 +1240,18 @@ Class<db::Shapes> decl_Shapes ("db", "Shapes",
"This method was introduced in version 0.16\n"
"@return The number of shapes in this container\n"
) +
gsi::method ("cell", &db::Shapes::cell,
"@brief Gets the cell the shape container belongs to\n"
"This method returns nil if the shape container does not belong to a cell.\n"
"\n"
"This method has been added in version 0.28."
) +
gsi::method_ext ("layout", &layout,
"@brief Gets the layout object the shape container belongs to\n"
"This method returns nil if the shape container does not belong to a layout.\n"
"\n"
"This method has been added in version 0.28."
) +
gsi::method ("replace_prop_id", (db::Shape (db::Shapes::*) (const db::Shape &, db::properties_id_type)) &db::Shapes::replace_prop_id, gsi::arg ("shape"), gsi::arg ("property_id"),
"@brief Replaces (or install) the properties of a shape\n"
"@return A \\Shape object representing the new shape\n"

View File

@ -33,6 +33,11 @@ class DBShapes_TestClass < TestBase
# Shapes
def test_7_Layout
shapes = RBA::Shapes::new
assert_equal(shapes.cell == nil, true)
assert_equal(shapes.layout == nil, true)
ly = RBA::Layout::new
ci1 = ly.add_cell( "c1" )
@ -57,6 +62,9 @@ class DBShapes_TestClass < TestBase
shapes = c1.shapes( lindex )
assert_equal(shapes.cell == c1, true)
assert_equal(shapes.layout == ly, true)
arr = []
shapes.each( RBA::Shapes::SAll ) { |s| arr.push( s.box.to_s ) }
assert_equal( arr, ["(10,-10;50,40)", "(100,-10;150,40)", "(200,-10;250,40)"] )