From 67d8518926241f089be3dec0892542fde560f6e8 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sat, 27 Aug 2022 17:51:14 +0200 Subject: [PATCH] Shapes#cell and Shapes#layout --- src/db/db/gsiDeclDbShapes.cc | 21 +++++++++++++++++++++ testdata/ruby/dbShapesTest.rb | 8 ++++++++ 2 files changed, 29 insertions(+) diff --git a/src/db/db/gsiDeclDbShapes.cc b/src/db/db/gsiDeclDbShapes.cc index ffadd12f4..c8603c736 100644 --- a/src/db/db/gsiDeclDbShapes.cc +++ b/src/db/db/gsiDeclDbShapes.cc @@ -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 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" diff --git a/testdata/ruby/dbShapesTest.rb b/testdata/ruby/dbShapesTest.rb index 5c29c85b4..d59c38229 100644 --- a/testdata/ruby/dbShapesTest.rb +++ b/testdata/ruby/dbShapesTest.rb @@ -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)"] )