From 233d70d085009711f8f894604c60c935847721a5 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Wed, 1 Jan 2025 22:49:50 +0100 Subject: [PATCH] Transformation of objects with properties, GSI binding, bug fixing, tests --- src/db/db/dbNetShape.cc | 2 +- src/db/db/dbPCellVariant.cc | 2 +- src/db/db/dbPolygon.h | 36 +++++++++- src/db/db/dbPolygonTools.cc | 4 +- src/db/db/gsiDeclDbPolygon.cc | 20 +++--- src/db/db/gsiDeclDbShapes.cc | 112 ++++++++++++++++++++++++++++++++ src/db/db/gsiDeclDbTrans.cc | 105 ++++++++++++++++++++++++++++++ src/edt/edt/edtUtils.cc | 4 +- testdata/ruby/dbBoxTest.rb | 2 + testdata/ruby/dbEdgePairTest.rb | 2 + testdata/ruby/dbEdgeTest.rb | 2 + testdata/ruby/dbPathTest.rb | 2 + testdata/ruby/dbPolygonTest.rb | 4 ++ testdata/ruby/dbShapesTest.rb | 43 ++++++++++++ testdata/ruby/dbTextTest.rb | 2 + 15 files changed, 324 insertions(+), 18 deletions(-) diff --git a/src/db/db/dbNetShape.cc b/src/db/db/dbNetShape.cc index 3c46a87d9..a845ac9a1 100644 --- a/src/db/db/dbNetShape.cc +++ b/src/db/db/dbNetShape.cc @@ -134,7 +134,7 @@ bool NetShape::interacts_with (const db::NetShape &other) const // Polygon vs. polygon db::PolygonRef pr_other = other.polygon_ref (); db::PolygonRef pr = polygon_ref (); - db::Polygon p = pr_other.obj ().transformed (pr.trans ().inverted () * pr_other.trans (), false); + db::Polygon p = pr_other.obj ().transformed_ext (pr.trans ().inverted () * pr_other.trans (), false); return db::interact_pp (pr.obj (), p); } else { diff --git a/src/db/db/dbPCellVariant.cc b/src/db/db/dbPCellVariant.cc index 40954ab5a..38aedac3f 100644 --- a/src/db/db/dbPCellVariant.cc +++ b/src/db/db/dbPCellVariant.cc @@ -226,7 +226,7 @@ PCellVariant::update (ImportLayerMapping *layer_mapping) } else if (m_parameters[i].is_user ()) { db::complex_trans dbu_trans (1.0 / layout ()->dbu ()); - db::Polygon poly = m_parameters[i].to_user ().transformed (dbu_trans, false); + db::Polygon poly = m_parameters[i].to_user ().transformed_ext (dbu_trans, false); // Hint: we don't compress the polygon since we don't want to loose information shapes (layout ()->guiding_shape_layer ()).insert (db::PolygonWithProperties (poly, db::properties_id (props))); diff --git a/src/db/db/dbPolygon.h b/src/db/db/dbPolygon.h index cba1591fc..43dd5fadd 100644 --- a/src/db/db/dbPolygon.h +++ b/src/db/db/dbPolygon.h @@ -1928,7 +1928,7 @@ public: * @return The transformed polygon. */ template - polygon transformed (const Tr &t, bool compress = default_compression (), bool remove_reflected = false) const + polygon transformed_ext (const Tr &t, bool compress = default_compression (), bool remove_reflected = false) const { typedef typename Tr::target_coord_type target_coord_type; polygon poly; @@ -1942,6 +1942,22 @@ public: return poly; } + /** + * @brief Transform the polygon. + * + * Transforms the polygon with the given transformation. + * Does not modify the polygon but returns the transformed polygon. + * + * @param t The transformation to apply. + * + * @return The transformed polygon. + */ + template + polygon transformed (const Tr &t) const + { + return this->transformed_ext (t); + } + /** * @brief Returns the moved polyon * @@ -2821,7 +2837,7 @@ public: * @return The transformed polygon. */ template - simple_polygon transformed (const Tr &t, bool compress = default_compression (), bool remove_reflected = false) const + simple_polygon transformed_ext (const Tr &t, bool compress = default_compression (), bool remove_reflected = false) const { typedef typename Tr::target_coord_type target_coord_type; simple_polygon poly; @@ -2832,6 +2848,22 @@ public: return poly; } + /** + * @brief Transform the polygon. + * + * Transforms the polygon with the given transformation. + * Does not modify the polygon but returns the transformed polygon. + * + * @param t The transformation to apply. + * + * @return The transformed polygon. + */ + template + simple_polygon transformed (const Tr &t) const + { + return this->transformed_ext (t); + } + /** * @brief Returns the moved polyon * diff --git a/src/db/db/dbPolygonTools.cc b/src/db/db/dbPolygonTools.cc index 4b6383ace..4f8333d13 100644 --- a/src/db/db/dbPolygonTools.cc +++ b/src/db/db/dbPolygonTools.cc @@ -570,7 +570,7 @@ namespace virtual void put (const IPolygonType &p) { - PolygonType pp = p.transformed (m_tr, false); + PolygonType pp = p.transformed_ext (m_tr, false); mp_next->put (pp); } @@ -607,7 +607,7 @@ namespace rec.set_trans (tr); rec.set_next (right_of_line); - cut_polygon_internal_int (input.transformed (tr.inverted (), false), line.transformed (tr.inverted ()), &rec); + cut_polygon_internal_int (input.transformed_ext (tr.inverted (), false), line.transformed (tr.inverted ()), &rec); } } diff --git a/src/db/db/gsiDeclDbPolygon.cc b/src/db/db/gsiDeclDbPolygon.cc index 9edc1eab4..1c116d6d5 100644 --- a/src/db/db/gsiDeclDbPolygon.cc +++ b/src/db/db/gsiDeclDbPolygon.cc @@ -183,7 +183,7 @@ struct simple_polygon_defs static C scale (const C *p, double s) { - return C (p->transformed (icomplex_trans_type (s), false /*don't compress*/)); + return C (p->transformed_ext (icomplex_trans_type (s), false /*don't compress*/)); } static C *transform (C *poly, const simple_trans_type &t) @@ -194,12 +194,12 @@ struct simple_polygon_defs static C transformed (const C *poly, const simple_trans_type &t) { - return poly->transformed (t, false /*don't compress*/); + return poly->transformed_ext (t, false /*don't compress*/); } static db::simple_polygon transformed_cplx (const C *poly, const complex_trans_type &t) { - return poly->transformed (t, false /*don't compress*/); + return poly->transformed_ext (t, false /*don't compress*/); } #if defined(HAVE_64BIT_COORD) @@ -677,7 +677,7 @@ static db::SimplePolygon *transform_icplx_sp (db::SimplePolygon *p, const db::IC static db::SimplePolygon transformed_icplx_sp (const db::SimplePolygon *p, const db::ICplxTrans &t) { - return p->transformed (t, false /*no compression*/); + return p->transformed_ext (t, false /*no compression*/); } static db::SimplePolygon *spolygon_from_dspolygon (const db::DSimplePolygon &p) @@ -817,7 +817,7 @@ static db::SimplePolygon dspolygon_to_spolygon (const db::DSimplePolygon *p, dou static db::SimplePolygon transformed_vplx_sp (const db::DSimplePolygon *p, const db::VCplxTrans &t) { - return p->transformed (t, false /*no compression*/); + return p->transformed_ext (t, false /*no compression*/); } Class decl_DSimplePolygon ("db", "DSimplePolygon", @@ -1111,7 +1111,7 @@ struct polygon_defs static C scale (const C *p, double s) { - return C (p->transformed (icomplex_trans_type (s), false /*no compression*/)); + return C (p->transformed_ext (icomplex_trans_type (s), false /*no compression*/)); } static void compress (C *poly, bool remove_reflected) @@ -1127,12 +1127,12 @@ struct polygon_defs static C transformed (const C *poly, const simple_trans_type &t) { - return poly->transformed (t, false /*no compression*/); + return poly->transformed_ext (t, false /*no compression*/); } static db::polygon transformed_cplx (const C *poly, const complex_trans_type &t) { - return poly->transformed (t, false /*no compression*/); + return poly->transformed_ext (t, false /*no compression*/); } #if defined(HAVE_64BIT_COORD) @@ -1751,7 +1751,7 @@ static db::Polygon *transform_icplx_dp (db::Polygon *p, const db::ICplxTrans &t) static db::Polygon transformed_icplx_dp (const db::Polygon *p, const db::ICplxTrans &t) { - return p->transformed (t, false /*don't compress*/); + return p->transformed_ext (t, false /*don't compress*/); } static db::Polygon smooth (const db::Polygon *p, db::Coord d, bool keep_hv) @@ -2096,7 +2096,7 @@ static db::Polygon dpolygon_to_polygon (const db::DPolygon *p, double dbu) static db::Polygon transformed_vcplx_dp (const db::DPolygon *p, const db::VCplxTrans &t) { - return p->transformed (t, false /*don't compress*/); + return p->transformed_ext (t, false /*don't compress*/); } Class decl_DPolygon ("db", "DPolygon", diff --git a/src/db/db/gsiDeclDbShapes.cc b/src/db/db/gsiDeclDbShapes.cc index 7393f3a89..2cdb418eb 100644 --- a/src/db/db/gsiDeclDbShapes.cc +++ b/src/db/db/gsiDeclDbShapes.cc @@ -1195,6 +1195,118 @@ Class decl_Shapes ("db", "Shapes", "\n" "This variant has been introduced in version 0.25." ) + + gsi::method_ext ("insert", &insert, gsi::arg ("box"), + "@brief Inserts a box with properties into the shapes list\n" + "@return A reference to the new shape (a \\Shape object)\n" + "The property Id must be obtained from the \\Layout object's property_id method which " + "associates a property set with a property Id." + "\n" + "This variant has been introduced in version 0.30." + ) + + gsi::method_ext ("insert", &dinsert, gsi::arg ("box"), + "@brief Inserts a micrometer-unit box with properties into the shapes list\n" + "@return A reference to the new shape (a \\Shape object)\n" + "This method behaves like the \\insert version with a \\BoxWithProperties argument, except that it will " + "internally translate the box from micrometer to database units.\n" + "\n" + "This variant has been introduced in version 0.30." + ) + + gsi::method_ext ("insert", &insert, gsi::arg ("path"), + "@brief Inserts a path with properties into the shapes list\n" + "@return A reference to the new shape (a \\Shape object)\n" + "The property Id must be obtained from the \\Layout object's property_id method which " + "associates a property set with a property Id." + "\n" + "This variant has been introduced in version 0.30." + ) + + gsi::method_ext ("insert", &dinsert, gsi::arg ("path"), + "@brief Inserts a micrometer-unit path with properties into the shapes list\n" + "@return A reference to the new shape (a \\Shape object)\n" + "This method behaves like the \\insert version with a \\PathWithProperties argument, except that it will " + "internally translate the path from micrometer to database units.\n" + "\n" + "This variant has been introduced in version 0.30." + ) + + gsi::method_ext ("insert", &insert, gsi::arg ("edge"), + "@brief Inserts an edge with properties into the shapes list\n" + "@return A reference to the new shape (a \\Shape object)\n" + "The property Id must be obtained from the \\Layout object's property_id method which " + "associates a property set with a property Id." + "\n" + "This variant has been introduced in version 0.30." + ) + + gsi::method_ext ("insert", &dinsert, gsi::arg ("edge"), + "@brief Inserts a micrometer-unit edge with properties into the shapes list\n" + "@return A reference to the new shape (a \\Shape object)\n" + "This method behaves like the \\insert version with a \\EdgeWithProperties argument, except that it will " + "internally translate the edge from micrometer to database units.\n" + "\n" + "This variant has been introduced in version 0.30." + ) + + gsi::method_ext ("insert", &insert, gsi::arg ("edge_pair"), + "@brief Inserts an edge pair with properties into the shapes list\n" + "@return A reference to the new shape (a \\Shape object)\n" + "The property Id must be obtained from the \\Layout object's property_id method which " + "associates a property set with a property Id." + "\n" + "This variant has been introduced in version 0.30." + ) + + gsi::method_ext ("insert", &dinsert, gsi::arg ("edge_pair"), + "@brief Inserts a micrometer-unit edge pair with properties into the shapes list\n" + "@return A reference to the new shape (a \\Shape object)\n" + "This method behaves like the \\insert version with a \\EdgePairWithProperties argument, except that it will " + "internally translate the edge pair from micrometer to database units.\n" + "\n" + "This variant has been introduced in version 0.30." + ) + + gsi::method_ext ("insert", &insert, gsi::arg ("text"), + "@brief Inserts a text with properties into the shapes list\n" + "@return A reference to the new shape (a \\Shape object)\n" + "The property Id must be obtained from the \\Layout object's property_id method which " + "associates a property set with a property Id." + "\n" + "This variant has been introduced in version 0.30." + ) + + gsi::method_ext ("insert", &dinsert, gsi::arg ("text"), + "@brief Inserts a micrometer-unit text with properties into the shapes list\n" + "@return A reference to the new shape (a \\Shape object)\n" + "This method behaves like the \\insert version with a \\TextWithProperties argument, except that it will " + "internally translate the text from micrometer to database units.\n" + "\n" + "This variant has been introduced in version 0.30." + ) + + gsi::method_ext ("insert", &insert, gsi::arg ("simple_polygon"), + "@brief Inserts a simple polygon with properties into the shapes list\n" + "@return A reference to the new shape (a \\Shape object)\n" + "The property Id must be obtained from the \\Layout object's property_id method which " + "associates a property set with a property Id." + "\n" + "This variant has been introduced in version 0.30." + ) + + gsi::method_ext ("insert", &dinsert, gsi::arg ("simple_polygon"), + "@brief Inserts a micrometer-unit simple polygon with properties into the shapes list\n" + "@return A reference to the new shape (a \\Shape object)\n" + "This method behaves like the \\insert version with a \\SimplePolygonWithProperties argument, except that it will " + "internally translate the simple polygon from micrometer to database units.\n" + "\n" + "This variant has been introduced in version 0.30." + ) + + gsi::method_ext ("insert", &insert, gsi::arg ("polygon"), + "@brief Inserts a polygon with properties into the shapes list\n" + "@return A reference to the new shape (a \\Shape object)\n" + "The property Id must be obtained from the \\Layout object's property_id method which " + "associates a property set with a property Id." + "\n" + "This variant has been introduced in version 0.30." + ) + + gsi::method_ext ("insert", &dinsert, gsi::arg ("polygon"), + "@brief Inserts a micrometer-unit polygon with properties into the shapes list\n" + "@return A reference to the new shape (a \\Shape object)\n" + "This method behaves like the \\insert version with a \\PolygonWithProperties argument, except that it will " + "internally translate the polygon from micrometer to database units.\n" + "\n" + "This variant has been introduced in version 0.30." + ) + gsi::iterator_ext ("each", &begin, gsi::arg ("flags"), "@brief Gets all shapes\n" "\n" diff --git a/src/db/db/gsiDeclDbTrans.cc b/src/db/db/gsiDeclDbTrans.cc index da5f2a82b..6ab1bd7ba 100644 --- a/src/db/db/gsiDeclDbTrans.cc +++ b/src/db/db/gsiDeclDbTrans.cc @@ -816,6 +816,41 @@ struct cplx_trans_defs return text.transformed (*t); } + static db::object_with_properties > trans_edge_wp (const C *t, const db::object_with_properties > &edge) + { + return edge.transformed (*t); + } + + static db::object_with_properties > trans_edge_pair_wp (const C *t, const db::object_with_properties > &edge_pair) + { + return edge_pair.transformed (*t); + } + + static db::object_with_properties > trans_box_wp (const C *t, const db::object_with_properties > &box) + { + return box.transformed (*t); + } + + static db::object_with_properties > trans_polygon_wp (const C *t, const db::object_with_properties > &polygon) + { + return polygon.transformed (*t); + } + + static db::object_with_properties > trans_simple_polygon_wp (const C *t, const db::object_with_properties > &polygon) + { + return polygon.transformed (*t); + } + + static db::object_with_properties > trans_path_wp (const C *t, const db::object_with_properties > &path) + { + return path.transformed (*t); + } + + static db::object_with_properties > trans_text_wp (const C *t, const db::object_with_properties > &text) + { + return text.transformed (*t); + } + static size_t hash_value (const C *t) { return std::hfunc (*t); @@ -996,6 +1031,76 @@ struct cplx_trans_defs "\n" "This convenience method has been introduced in version 0.25." ) + + method_ext ("trans|*", &trans_box_wp, arg ("box"), + "@brief Transforms a box with properties\n" + "\n" + "'t*box' or 't.trans(box)' is equivalent to box.transformed(t).\n" + "\n" + "@param box The box to transform\n" + "@return The transformed box\n" + "\n" + "This convenience method has been introduced in version 0.30." + ) + + method_ext ("trans|*", &trans_edge_wp, arg ("edge"), + "@brief Transforms an edge with properties\n" + "\n" + "'t*edge' or 't.trans(edge)' is equivalent to edge.transformed(t).\n" + "\n" + "@param edge The edge to transform\n" + "@return The transformed edge\n" + "\n" + "This convenience method has been introduced in version 0.30." + ) + + method_ext ("trans|*", &trans_edge_pair_wp, arg ("edge_pair"), + "@brief Transforms an edge pair with properties\n" + "\n" + "'t*edge_pair' or 't.trans(edge_pair)' is equivalent to edge_pair.transformed(t).\n" + "\n" + "@param edge_pair The edge pair to transform\n" + "@return The transformed edge pair\n" + "\n" + "This convenience method has been introduced in version 0.30." + ) + + method_ext ("trans|*", &trans_polygon_wp, arg ("polygon"), + "@brief Transforms a polygon with properties\n" + "\n" + "'t*polygon' or 't.trans(polygon)' is equivalent to polygon.transformed(t).\n" + "\n" + "@param polygon The polygon to transform\n" + "@return The transformed polygon\n" + "\n" + "This convenience method has been introduced in version 0.30." + ) + + method_ext ("trans|*", &trans_simple_polygon_wp, arg ("simple_polygon"), + "@brief Transforms a simple polygon with properties\n" + "\n" + "'t*polygon' or 't.trans(simple_polygon)' is equivalent to simple_polygon.transformed(t).\n" + "\n" + "@param simple_polygon The simple polygon to transform\n" + "@return The transformed simple polygon\n" + "\n" + "This convenience method has been introduced in version 0.30." + ) + + method_ext ("trans|*", &trans_path_wp, arg ("path"), + "@brief Transforms a path with properties\n" + "\n" + "'t*path' or 't.trans(path)' is equivalent to path.transformed(t).\n" + "\n" + "@param path The path to transform\n" + "@return The transformed path\n" + "\n" + "This convenience method has been introduced in version 0.30." + ) + + method_ext ("trans|*", &trans_text_wp, arg ("text"), + "@brief Transforms a text with properties\n" + "\n" + "'t*text' or 't.trans(text)' is equivalent to text.transformed(t).\n" + "\n" + "@param text The text to transform\n" + "@return The transformed text\n" + "\n" + "This convenience method has been introduced in version 0.30." + ) + method ("*!", (C (C::*) (const C &c) const) &C::concat_same, arg ("t"), "@brief Returns the concatenated transformation\n" "\n" diff --git a/src/edt/edt/edtUtils.cc b/src/edt/edt/edtUtils.cc index 589a03dc6..303849427 100644 --- a/src/edt/edt/edtUtils.cc +++ b/src/edt/edt/edtUtils.cc @@ -202,7 +202,7 @@ get_parameters_from_pcell_and_guiding_shapes (db::Layout *layout, db::cell_index parameters_for_pcell [pnm->second] = tl::Variant (dbu_trans * sh->point ()); } else if (sh->is_polygon ()) { // Hint: we don't compress since we don't want to loose information - parameters_for_pcell [pnm->second] = tl::Variant (sh->polygon ().transformed (dbu_trans, false)); + parameters_for_pcell [pnm->second] = tl::Variant (sh->polygon ().transformed_ext (dbu_trans, false)); } else if (sh->is_path ()) { parameters_for_pcell [pnm->second] = tl::Variant (dbu_trans * sh->path ()); } @@ -253,7 +253,7 @@ get_parameters_from_pcell_and_guiding_shapes (db::Layout *layout, db::cell_index db::complex_trans dbu_trans (1.0 / layout->dbu ()); // Hint: we don't compress the polygon since we don't want to loose information - db::Polygon poly = org_parameters[i].to_user ().transformed (dbu_trans, false); + db::Polygon poly = org_parameters[i].to_user ().transformed_ext (dbu_trans, false); guiding_shapes.insert (db::PolygonWithProperties (poly, db::properties_id (props))); } else if (org_parameters[i].is_user ()) { diff --git a/testdata/ruby/dbBoxTest.rb b/testdata/ruby/dbBoxTest.rb index 77a5cdf57..4fabe6ccd 100644 --- a/testdata/ruby/dbBoxTest.rb +++ b/testdata/ruby/dbBoxTest.rb @@ -520,6 +520,7 @@ class DBBox_TestClass < TestBase pid = RBA::Layout::properties_id({ 1 => "one" }) s = RBA::BoxWithProperties::new(RBA::Box::new(0, 0, 100, 200), pid) assert_equal(s.to_s, "(0,0;100,200) props={1=>one}") + assert_equal((RBA::CplxTrans::new(0.001) * s).to_s, "(0,0;0.1,0.2) props={1=>one}") assert_equal(s.property(1), "one") assert_equal(s.properties, { 1 => "one" }) s.set_property(1, "xxx") @@ -534,6 +535,7 @@ class DBBox_TestClass < TestBase pid = RBA::Layout::properties_id({ 1 => "one" }) s = RBA::DBoxWithProperties::new(RBA::DBox::new(0, 0, 100, 200), pid) assert_equal(s.to_s, "(0,0;100,200) props={1=>one}") + assert_equal((RBA::VCplxTrans::new(2.5) * s).to_s, "(0,0;250,500) props={1=>one}") assert_equal(s.property(1), "one") assert_equal(s.properties, { 1 => "one" }) s.set_property(1, "xxx") diff --git a/testdata/ruby/dbEdgePairTest.rb b/testdata/ruby/dbEdgePairTest.rb index 61abb0010..9d34a3fce 100644 --- a/testdata/ruby/dbEdgePairTest.rb +++ b/testdata/ruby/dbEdgePairTest.rb @@ -254,6 +254,7 @@ class DBEdgePair_TestClass < TestBase pid = RBA::Layout::properties_id({ 1 => "one" }) s = RBA::EdgePairWithProperties::new(RBA::EdgePair::new(RBA::Edge::new(0, 0, 100, 200), RBA::Edge::new(10, 10, 110, 210)), pid) assert_equal(s.to_s, "(0,0;100,200)/(10,10;110,210) props={1=>one}") + assert_equal((RBA::CplxTrans::new(0.001) * s).to_s, "(0,0;0.1,0.2)/(0.01,0.01;0.11,0.21) props={1=>one}") assert_equal(s.property(1), "one") assert_equal(s.properties, { 1 => "one" }) s.set_property(1, "xxx") @@ -268,6 +269,7 @@ class DBEdgePair_TestClass < TestBase pid = RBA::Layout::properties_id({ 1 => "one" }) s = RBA::DEdgePairWithProperties::new(RBA::DEdgePair::new(RBA::DEdge::new(0, 0, 100, 200), RBA::DEdge::new(10, 10, 110, 210)), pid) assert_equal(s.to_s, "(0,0;100,200)/(10,10;110,210) props={1=>one}") + assert_equal((RBA::VCplxTrans::new(2.5) * s).to_s, "(0,0;250,500)/(25,25;275,525) props={1=>one}") assert_equal(s.property(1), "one") assert_equal(s.properties, { 1 => "one" }) s.set_property(1, "xxx") diff --git a/testdata/ruby/dbEdgeTest.rb b/testdata/ruby/dbEdgeTest.rb index 8c9f18a7c..e69dd09f9 100644 --- a/testdata/ruby/dbEdgeTest.rb +++ b/testdata/ruby/dbEdgeTest.rb @@ -341,6 +341,7 @@ class DBEdge_TestClass < TestBase pid = RBA::Layout::properties_id({ 1 => "one" }) s = RBA::EdgeWithProperties::new(RBA::Edge::new(0, 0, 100, 200), pid) assert_equal(s.to_s, "(0,0;100,200) props={1=>one}") + assert_equal((RBA::CplxTrans::new(0.001) * s).to_s, "(0,0;0.1,0.2) props={1=>one}") assert_equal(s.property(1), "one") assert_equal(s.properties, { 1 => "one" }) s.set_property(1, "xxx") @@ -355,6 +356,7 @@ class DBEdge_TestClass < TestBase pid = RBA::Layout::properties_id({ 1 => "one" }) s = RBA::DEdgeWithProperties::new(RBA::DEdge::new(0, 0, 100, 200), pid) assert_equal(s.to_s, "(0,0;100,200) props={1=>one}") + assert_equal((RBA::VCplxTrans::new(2.5) * s).to_s, "(0,0;250,500) props={1=>one}") assert_equal(s.property(1), "one") assert_equal(s.properties, { 1 => "one" }) s.set_property(1, "xxx") diff --git a/testdata/ruby/dbPathTest.rb b/testdata/ruby/dbPathTest.rb index f224b96c2..6930f928f 100644 --- a/testdata/ruby/dbPathTest.rb +++ b/testdata/ruby/dbPathTest.rb @@ -337,6 +337,7 @@ class DBPath_TestClass < TestBase pid = RBA::Layout::properties_id({ 1 => "one" }) s = RBA::PathWithProperties::new(RBA::Path::new([ [0,0], [100, 0] ], 100), pid) assert_equal(s.to_s, "(0,0;100,0) w=100 bx=0 ex=0 r=false props={1=>one}") + assert_equal((RBA::CplxTrans::new(0.001) * s).to_s, "(0,0;0.1,0) w=0.1 bx=0 ex=0 r=false props={1=>one}") assert_equal(s.property(1), "one") assert_equal(s.properties, { 1 => "one" }) s.set_property(1, "xxx") @@ -351,6 +352,7 @@ class DBPath_TestClass < TestBase pid = RBA::Layout::properties_id({ 1 => "one" }) s = RBA::DPathWithProperties::new(RBA::DPath::new([ [0,0], [100, 0] ], 100), pid) assert_equal(s.to_s, "(0,0;100,0) w=100 bx=0 ex=0 r=false props={1=>one}") + assert_equal((RBA::VCplxTrans::new(2.5) * s).to_s, "(0,0;250,0) w=250 bx=0 ex=0 r=false props={1=>one}") assert_equal(s.property(1), "one") assert_equal(s.properties, { 1 => "one" }) s.set_property(1, "xxx") diff --git a/testdata/ruby/dbPolygonTest.rb b/testdata/ruby/dbPolygonTest.rb index 13e825d1c..4af467622 100644 --- a/testdata/ruby/dbPolygonTest.rb +++ b/testdata/ruby/dbPolygonTest.rb @@ -902,6 +902,7 @@ class DBPolygon_TestClass < TestBase pid = RBA::Layout::properties_id({ 1 => "one" }) s = RBA::PolygonWithProperties::new(RBA::Polygon::new(RBA::Box::new(0, 0, 100, 200)), pid) assert_equal(s.to_s, "(0,0;0,200;100,200;100,0) props={1=>one}") + assert_equal((RBA::CplxTrans::new(0.001) * s).to_s, "(0,0;0,0.2;0.1,0.2;0.1,0) props={1=>one}") assert_equal(s.property(1), "one") assert_equal(s.properties, { 1 => "one" }) s.set_property(1, "xxx") @@ -916,6 +917,7 @@ class DBPolygon_TestClass < TestBase pid = RBA::Layout::properties_id({ 1 => "one" }) s = RBA::DPolygonWithProperties::new(RBA::DPolygon::new(RBA::DBox::new(0, 0, 100, 200)), pid) assert_equal(s.to_s, "(0,0;0,200;100,200;100,0) props={1=>one}") + assert_equal((RBA::VCplxTrans::new(2.5) * s).to_s, "(0,0;0,500;250,500;250,0) props={1=>one}") assert_equal(s.property(1), "one") assert_equal(s.properties, { 1 => "one" }) s.set_property(1, "xxx") @@ -930,6 +932,7 @@ class DBPolygon_TestClass < TestBase pid = RBA::Layout::properties_id({ 1 => "one" }) s = RBA::SimplePolygonWithProperties::new(RBA::SimplePolygon::new(RBA::Box::new(0, 0, 100, 200)), pid) assert_equal(s.to_s, "(0,0;0,200;100,200;100,0) props={1=>one}") + assert_equal((RBA::CplxTrans::new(0.001) * s).to_s, "(0,0;0,0.2;0.1,0.2;0.1,0) props={1=>one}") assert_equal(s.property(1), "one") assert_equal(s.properties, { 1 => "one" }) s.set_property(1, "xxx") @@ -944,6 +947,7 @@ class DBPolygon_TestClass < TestBase pid = RBA::Layout::properties_id({ 1 => "one" }) s = RBA::DSimplePolygonWithProperties::new(RBA::DSimplePolygon::new(RBA::DBox::new(0, 0, 100, 200)), pid) assert_equal(s.to_s, "(0,0;0,200;100,200;100,0) props={1=>one}") + assert_equal((RBA::VCplxTrans::new(2.5) * s).to_s, "(0,0;0,500;250,500;250,0) props={1=>one}") assert_equal(s.property(1), "one") assert_equal(s.properties, { 1 => "one" }) s.set_property(1, "xxx") diff --git a/testdata/ruby/dbShapesTest.rb b/testdata/ruby/dbShapesTest.rb index 16726a2a5..a59994440 100644 --- a/testdata/ruby/dbShapesTest.rb +++ b/testdata/ruby/dbShapesTest.rb @@ -1685,6 +1685,49 @@ class DBShapes_TestClass < TestBase end + # Shape objects with properties + + def test_14 + + ly = RBA::Layout::new + l1 = ly.layer(1, 0) + tc = ly.create_cell("TOP") + shapes = tc.shapes(l1) + + ps1 = RBA::Layout::properties_id({ 1 => "one" }) + + sh = shapes.insert(RBA::BoxWithProperties::new(RBA::Box::new(0, 0, 100, 200), ps1)) + assert_equal(sh.to_s, "box (0,0;100,200) props={1=>one}") + + sh = shapes.insert(RBA::PolygonWithProperties::new(RBA::Box::new(0, 0, 100, 200), ps1)) + assert_equal(sh.to_s, "polygon (0,0;0,200;100,200;100,0) props={1=>one}") + + sh = shapes.insert(RBA::SimplePolygonWithProperties::new(RBA::Box::new(0, 0, 100, 200), ps1)) + assert_equal(sh.to_s, "simple_polygon (0,0;0,200;100,200;100,0) props={1=>one}") + + sh = shapes.insert(RBA::PathWithProperties::new(RBA::Path::new([ [0, 0], [100, 200] ], 100), ps1)) + assert_equal(sh.to_s, "path (0,0;100,200) w=100 bx=0 ex=0 r=false props={1=>one}") + + sh = shapes.insert(RBA::TextWithProperties::new(RBA::Text::new("text", RBA::Trans::R90), ps1)) + assert_equal(sh.to_s, "text ('text',r90 0,0) props={1=>one}") + + sh = shapes.insert(RBA::DBoxWithProperties::new(RBA::DBox::new(0, 0, 0.1, 0.2), ps1)) + assert_equal(sh.to_s, "box (0,0;100,200) props={1=>one}") + + sh = shapes.insert(RBA::DPolygonWithProperties::new(RBA::DBox::new(0, 0, 0.1, 0.2), ps1)) + assert_equal(sh.to_s, "polygon (0,0;0,200;100,200;100,0) props={1=>one}") + + sh = shapes.insert(RBA::DSimplePolygonWithProperties::new(RBA::DBox::new(0, 0, 0.1, 0.2), ps1)) + assert_equal(sh.to_s, "simple_polygon (0,0;0,200;100,200;100,0) props={1=>one}") + + sh = shapes.insert(RBA::DPathWithProperties::new(RBA::DPath::new([ [0, 0], [0.1, 0.2] ], 0.1), ps1)) + assert_equal(sh.to_s, "path (0,0;100,200) w=100 bx=0 ex=0 r=false props={1=>one}") + + sh = shapes.insert(RBA::DTextWithProperties::new(RBA::DText::new("text", RBA::Trans::R90), ps1)) + assert_equal(sh.to_s, "text ('text',r90 0,0) props={1=>one}") + + end + end load("test_epilogue.rb") diff --git a/testdata/ruby/dbTextTest.rb b/testdata/ruby/dbTextTest.rb index ce00a852e..65dc24a42 100644 --- a/testdata/ruby/dbTextTest.rb +++ b/testdata/ruby/dbTextTest.rb @@ -262,6 +262,7 @@ class DBText_TestClass < TestBase pid = RBA::Layout::properties_id({ 1 => "one" }) s = RBA::TextWithProperties::new(RBA::Text::new("text", RBA::Trans::R90), pid) assert_equal(s.to_s, "('text',r90 0,0) props={1=>one}") + assert_equal((RBA::CplxTrans::new(0.001) * s).to_s, "('text',r90 0,0) props={1=>one}") assert_equal(s.property(1), "one") assert_equal(s.properties, { 1 => "one" }) s.set_property(1, "xxx") @@ -276,6 +277,7 @@ class DBText_TestClass < TestBase pid = RBA::Layout::properties_id({ 1 => "one" }) s = RBA::DTextWithProperties::new(RBA::DText::new("text", RBA::Trans::R90), pid) assert_equal(s.to_s, "('text',r90 0,0) props={1=>one}") + assert_equal((RBA::VCplxTrans::new(2.5) * s).to_s, "('text',r90 0,0) props={1=>one}") assert_equal(s.property(1), "one") assert_equal(s.properties, { 1 => "one" }) s.set_property(1, "xxx")