diff --git a/src/db/db/dbAsIfFlatRegion.cc b/src/db/db/dbAsIfFlatRegion.cc index f74273f5a..c4cc80695 100644 --- a/src/db/db/dbAsIfFlatRegion.cc +++ b/src/db/db/dbAsIfFlatRegion.cc @@ -134,6 +134,9 @@ AsIfFlatRegion::to_string (size_t nmax) const } first = false; os << p->to_string (); + if (p.prop_id () != 0) { + os << db::properties (p.prop_id ()).to_dict_var ().to_string (); + } } if (! p.at_end ()) { os << "..."; diff --git a/src/db/db/dbPropertiesRepository.h b/src/db/db/dbPropertiesRepository.h index ed6848676..a5bbf7a9f 100644 --- a/src/db/db/dbPropertiesRepository.h +++ b/src/db/db/dbPropertiesRepository.h @@ -110,6 +110,18 @@ public: */ PropertiesSet (const PropertiesSet &&other); + /** + * @brief Constructor from tl::Variant pair iterator + */ + template + PropertiesSet (const Iter &from, const Iter &to) + : m_map (), m_hash (0) + { + for (auto i = from; i != to; ++i) { + insert (i->first, i->second); + } + } + /** * @brief Assignment */ diff --git a/src/db/db/gsiDeclDbBox.cc b/src/db/db/gsiDeclDbBox.cc index 1e70cc10b..a1493570a 100644 --- a/src/db/db/gsiDeclDbBox.cc +++ b/src/db/db/gsiDeclDbBox.cc @@ -596,10 +596,18 @@ static db::BoxWithProperties *new_box_with_properties (const db::Box &box, db::p return new db::BoxWithProperties (box, pid); } +static db::BoxWithProperties *new_box_with_properties2 (const db::Box &path, const std::map &properties) +{ + return new db::BoxWithProperties (path, db::properties_id (db::PropertiesSet (properties.begin (), properties.end ()))); +} + Class decl_BoxWithProperties (decl_Box, "db", "BoxWithProperties", gsi::properties_support_methods () + constructor ("new", &new_box_with_properties, gsi::arg ("box"), gsi::arg ("properties_id", db::properties_id_type (0)), "@brief Creates a new object from a property-less object and a properties ID." + ) + + constructor ("new", &new_box_with_properties2, gsi::arg ("box"), gsi::arg ("properties"), + "@brief Creates a new object from a property-less object and a properties hash." ) , "@brief A Box object with properties attached.\n" @@ -670,10 +678,18 @@ static db::DBoxWithProperties *new_dbox_with_properties (const db::DBox &box, db return new db::DBoxWithProperties (box, pid); } +static db::DBoxWithProperties *new_dbox_with_properties2 (const db::DBox &path, const std::map &properties) +{ + return new db::DBoxWithProperties (path, db::properties_id (db::PropertiesSet (properties.begin (), properties.end ()))); +} + Class decl_DBoxWithProperties (decl_DBox, "db", "DBoxWithProperties", gsi::properties_support_methods () + constructor ("new", &new_dbox_with_properties, gsi::arg ("box"), gsi::arg ("properties_id", db::properties_id_type (0)), "@brief Creates a new object from a property-less object and a properties ID." + ) + + constructor ("new", &new_dbox_with_properties2, gsi::arg ("box"), gsi::arg ("properties"), + "@brief Creates a new object from a property-less object and a properties hash." ) , "@brief A DBox object with properties attached.\n" diff --git a/src/db/db/gsiDeclDbEdge.cc b/src/db/db/gsiDeclDbEdge.cc index e981c351d..6bef103c3 100644 --- a/src/db/db/gsiDeclDbEdge.cc +++ b/src/db/db/gsiDeclDbEdge.cc @@ -700,10 +700,18 @@ static db::EdgeWithProperties *new_edge_with_properties (const db::Edge &edge, d return new db::EdgeWithProperties (edge, pid); } +static db::EdgeWithProperties *new_edge_with_properties2 (const db::Edge &edge, const std::map &properties) +{ + return new db::EdgeWithProperties (edge, db::properties_id (db::PropertiesSet (properties.begin (), properties.end ()))); +} + Class decl_EdgeWithProperties (decl_Edge, "db", "EdgeWithProperties", gsi::properties_support_methods () + constructor ("new", &new_edge_with_properties, gsi::arg ("edge"), gsi::arg ("properties_id", db::properties_id_type (0)), "@brief Creates a new object from a property-less object and a properties ID." + ) + + constructor ("new", &new_edge_with_properties2, gsi::arg ("edge"), gsi::arg ("properties"), + "@brief Creates a new object from a property-less object and a properties hash." ) , "@brief A Edge object with properties attached.\n" @@ -765,10 +773,18 @@ static db::DEdgeWithProperties *new_dedge_with_properties (const db::DEdge &edge return new db::DEdgeWithProperties (edge, pid); } +static db::DEdgeWithProperties *new_dedge_with_properties2 (const db::DEdge &edge, const std::map &properties) +{ + return new db::DEdgeWithProperties (edge, db::properties_id (db::PropertiesSet (properties.begin (), properties.end ()))); +} + Class decl_DEdgeWithProperties (decl_DEdge, "db", "DEdgeWithProperties", gsi::properties_support_methods () + constructor ("new", &new_dedge_with_properties, gsi::arg ("edge"), gsi::arg ("properties_id", db::properties_id_type (0)), "@brief Creates a new object from a property-less object and a properties ID." + ) + + constructor ("new", &new_dedge_with_properties2, gsi::arg ("edge"), gsi::arg ("properties"), + "@brief Creates a new object from a property-less object and a properties hash." ) , "@brief A DEdge object with properties attached.\n" diff --git a/src/db/db/gsiDeclDbEdgePair.cc b/src/db/db/gsiDeclDbEdgePair.cc index f3a2c6733..811c46dc5 100644 --- a/src/db/db/gsiDeclDbEdgePair.cc +++ b/src/db/db/gsiDeclDbEdgePair.cc @@ -290,10 +290,18 @@ static db::EdgePairWithProperties *new_edge_pair_with_properties (const db::Edge return new db::EdgePairWithProperties (edge_pair, pid); } +static db::EdgePairWithProperties *new_edge_pair_with_properties2 (const db::EdgePair &edge_pair, const std::map &properties) +{ + return new db::EdgePairWithProperties (edge_pair, db::properties_id (db::PropertiesSet (properties.begin (), properties.end ()))); +} + Class decl_EdgePairWithProperties (decl_EdgePair, "db", "EdgePairWithProperties", gsi::properties_support_methods () + constructor ("new", &new_edge_pair_with_properties, gsi::arg ("edge_pair"), gsi::arg ("properties_id", db::properties_id_type (0)), "@brief Creates a new object from a property-less object and a properties ID." + ) + + constructor ("new", &new_edge_pair_with_properties2, gsi::arg ("edge_pair"), gsi::arg ("properties"), + "@brief Creates a new object from a property-less object and a properties hash." ) , "@brief A EdgePair object with properties attached.\n" @@ -357,10 +365,18 @@ static db::DEdgePairWithProperties *new_dedge_pair_with_properties (const db::DE return new db::DEdgePairWithProperties (edge_pair, pid); } +static db::DEdgePairWithProperties *new_dedge_pair_with_properties2 (const db::DEdgePair &edge_pair, const std::map &properties) +{ + return new db::DEdgePairWithProperties (edge_pair, db::properties_id (db::PropertiesSet (properties.begin (), properties.end ()))); +} + Class decl_DEdgePairWithProperties (decl_EdgePair, "db", "DEdgePairWithProperties", gsi::properties_support_methods () + constructor ("new", &new_dedge_pair_with_properties, gsi::arg ("edge_pair"), gsi::arg ("properties_id", db::properties_id_type (0)), "@brief Creates a new object from a property-less object and a properties ID." + ) + + constructor ("new", &new_dedge_pair_with_properties2, gsi::arg ("edge_pair"), gsi::arg ("properties"), + "@brief Creates a new object from a property-less object and a properties hash." ) , "@brief A DEdgePair object with properties attached.\n" diff --git a/src/db/db/gsiDeclDbPath.cc b/src/db/db/gsiDeclDbPath.cc index c84e2b948..2a1f84665 100644 --- a/src/db/db/gsiDeclDbPath.cc +++ b/src/db/db/gsiDeclDbPath.cc @@ -390,10 +390,18 @@ static db::PathWithProperties *new_path_with_properties (const db::Path &path, d return new db::PathWithProperties (path, pid); } +static db::PathWithProperties *new_path_with_properties2 (const db::Path &path, const std::map &properties) +{ + return new db::PathWithProperties (path, db::properties_id (db::PropertiesSet (properties.begin (), properties.end ()))); +} + Class decl_PathWithProperties (decl_Path, "db", "PathWithProperties", gsi::properties_support_methods () + constructor ("new", &new_path_with_properties, gsi::arg ("path"), gsi::arg ("properties_id", db::properties_id_type (0)), "@brief Creates a new object from a property-less object and a properties ID." + ) + + constructor ("new", &new_path_with_properties2, gsi::arg ("path"), gsi::arg ("properties"), + "@brief Creates a new object from a property-less object and a properties hash." ) , "@brief A Path object with properties attached.\n" @@ -477,10 +485,18 @@ static db::DPathWithProperties *new_dpath_with_properties (const db::DPath &path return new db::DPathWithProperties (path, pid); } +static db::DPathWithProperties *new_dpath_with_properties2 (const db::DPath &path, const std::map &properties) +{ + return new db::DPathWithProperties (path, db::properties_id (db::PropertiesSet (properties.begin (), properties.end ()))); +} + Class decl_DPathWithProperties (decl_DPath, "db", "DPathWithProperties", gsi::properties_support_methods () + constructor ("new", &new_dpath_with_properties, gsi::arg ("path"), gsi::arg ("properties_id", db::properties_id_type (0)), "@brief Creates a new object from a property-less object and a properties ID." + ) + + constructor ("new", &new_dpath_with_properties2, gsi::arg ("path"), gsi::arg ("properties"), + "@brief Creates a new object from a property-less object and a properties hash." ) , "@brief A DPath object with properties attached.\n" diff --git a/src/db/db/gsiDeclDbPolygon.cc b/src/db/db/gsiDeclDbPolygon.cc index a5dcef5c0..636d66119 100644 --- a/src/db/db/gsiDeclDbPolygon.cc +++ b/src/db/db/gsiDeclDbPolygon.cc @@ -791,10 +791,18 @@ static db::SimplePolygonWithProperties *new_simple_polygon_with_properties (cons return new db::SimplePolygonWithProperties (poly, pid); } +static db::SimplePolygonWithProperties *new_simple_polygon_with_properties2 (const db::SimplePolygon &poly, const std::map &properties) +{ + return new db::SimplePolygonWithProperties (poly, db::properties_id (db::PropertiesSet (properties.begin (), properties.end ()))); +} + Class decl_SimplePolygonWithProperties (decl_SimplePolygon, "db", "SimplePolygonWithProperties", gsi::properties_support_methods () + constructor ("new", &new_simple_polygon_with_properties, gsi::arg ("polygon"), gsi::arg ("properties_id", db::properties_id_type (0)), "@brief Creates a new object from a property-less object and a properties ID." + ) + + constructor ("new", &new_simple_polygon_with_properties2, gsi::arg ("polygon"), gsi::arg ("properties"), + "@brief Creates a new object from a property-less object and a properties hash." ) , "@brief A SimplePolygon object with properties attached.\n" @@ -878,10 +886,18 @@ static db::DSimplePolygonWithProperties *new_dsimple_polygon_with_properties (co return new db::DSimplePolygonWithProperties (poly, pid); } +static db::DSimplePolygonWithProperties *new_dsimple_polygon_with_properties2 (const db::DSimplePolygon &poly, const std::map &properties) +{ + return new db::DSimplePolygonWithProperties (poly, db::properties_id (db::PropertiesSet (properties.begin (), properties.end ()))); +} + Class decl_DSimplePolygonWithProperties (decl_DSimplePolygon, "db", "DSimplePolygonWithProperties", gsi::properties_support_methods () + constructor ("new", &new_dsimple_polygon_with_properties, gsi::arg ("polygon"), gsi::arg ("properties_id", db::properties_id_type (0)), "@brief Creates a new object from a property-less object and a properties ID." + ) + + constructor ("new", &new_dsimple_polygon_with_properties2, gsi::arg ("polygon"), gsi::arg ("properties"), + "@brief Creates a new object from a property-less object and a properties hash." ) , "@brief A DSimplePolygon object with properties attached.\n" @@ -2070,10 +2086,18 @@ static db::PolygonWithProperties *new_polygon_with_properties (const db::Polygon return new db::PolygonWithProperties (poly, pid); } +static db::PolygonWithProperties *new_polygon_with_properties2 (const db::Polygon &poly, const std::map &properties) +{ + return new db::PolygonWithProperties (poly, db::properties_id (db::PropertiesSet (properties.begin (), properties.end ()))); +} + Class decl_PolygonWithProperties (decl_Polygon, "db", "PolygonWithProperties", gsi::properties_support_methods () + constructor ("new", &new_polygon_with_properties, gsi::arg ("polygon"), gsi::arg ("properties_id", db::properties_id_type (0)), "@brief Creates a new object from a property-less object and a properties ID." + ) + + constructor ("new", &new_polygon_with_properties2, gsi::arg ("polygon"), gsi::arg ("properties"), + "@brief Creates a new object from a property-less object and a properties hash." ) , "@brief A Polygon object with properties attached.\n" @@ -2184,10 +2208,18 @@ static db::DPolygonWithProperties *new_dpolygon_with_properties (const db::DPoly return new db::DPolygonWithProperties (poly, pid); } +static db::DPolygonWithProperties *new_dpolygon_with_properties2 (const db::DPolygon &poly, const std::map &properties) +{ + return new db::DPolygonWithProperties (poly, db::properties_id (db::PropertiesSet (properties.begin (), properties.end ()))); +} + Class decl_DPolygonWithProperties (decl_DPolygon, "db", "DPolygonWithProperties", gsi::properties_support_methods () + constructor ("new", &new_dpolygon_with_properties, gsi::arg ("polygon"), gsi::arg ("properties_id", db::properties_id_type (0)), "@brief Creates a new object from a property-less object and a properties ID." + ) + + constructor ("new", &new_dpolygon_with_properties2, gsi::arg ("polygon"), gsi::arg ("properties"), + "@brief Creates a new object from a property-less object and a properties hash." ) , "@brief A DPolygon object with properties attached.\n" diff --git a/src/db/db/gsiDeclDbRegion.cc b/src/db/db/gsiDeclDbRegion.cc index 9294f23d4..9ea181a82 100644 --- a/src/db/db/gsiDeclDbRegion.cc +++ b/src/db/db/gsiDeclDbRegion.cc @@ -250,26 +250,51 @@ static db::Region *new_a (const std::vector &a) return new db::Region (a.begin (), a.end ()); } +static db::Region *new_ap (const std::vector &a) +{ + return new db::Region (a.begin (), a.end ()); +} + static db::Region *new_b (const db::Box &o) { return new db::Region (o); } +static db::Region *new_bp (const db::BoxWithProperties &o) +{ + return new db::Region (o); +} + static db::Region *new_p (const db::Polygon &o) { return new db::Region (o); } +static db::Region *new_pp (const db::PolygonWithProperties &o) +{ + return new db::Region (o); +} + static db::Region *new_ps (const db::SimplePolygon &o) { return new db::Region (o); } +static db::Region *new_psp (const db::SimplePolygonWithProperties &o) +{ + return new db::Region (o); +} + static db::Region *new_path (const db::Path &o) { return new db::Region (o); } +static db::Region *new_pathp (const db::PathWithProperties &o) +{ + return new db::Region (o); +} + static db::Region *new_texts_as_boxes1 (const db::RecursiveShapeIterator &si, const std::string &pat, bool pattern, db::Coord enl) { return new db::Region (db::Region (si).texts_as_boxes (pat, pattern, enl)); @@ -382,6 +407,13 @@ static void insert_a (db::Region *r, const std::vector &a) } } +static void insert_ap (db::Region *r, const std::vector &a) +{ + for (std::vector ::const_iterator p = a.begin (); p != a.end (); ++p) { + r->insert (*p); + } +} + static void insert_r (db::Region *r, const db::Region &a) { for (db::Region::const_iterator p = a.begin (); ! p.at_end (); ++p) { @@ -1170,26 +1202,61 @@ Class decl_Region (decl_dbShapeCollection, "db", "Region", "\n" "This constructor creates a region from an array of polygons.\n" ) + + constructor ("new", &new_ap, gsi::arg ("array"), + "@brief Constructor from an array of polygons with properties\n" + "\n" + "This constructor creates a region from an array of polygons with properties.\n" + "\n" + "This variant has been introduced in version 0.30." + ) + constructor ("new", &new_b, gsi::arg ("box"), "@brief Box constructor\n" "\n" "This constructor creates a region from a box.\n" ) + + constructor ("new", &new_bp, gsi::arg ("box"), + "@brief Box constructor\n" + "\n" + "This constructor creates a region from a box with properties.\n" + "\n" + "This variant has been introduced in version 0.30." + ) + constructor ("new", &new_p, gsi::arg ("polygon"), "@brief Polygon constructor\n" "\n" "This constructor creates a region from a polygon.\n" ) + + constructor ("new", &new_pp, gsi::arg ("polygon"), + "@brief Polygon constructor\n" + "\n" + "This constructor creates a region from a polygon with properties.\n" + "\n" + "This variant has been introduced in version 0.30." + ) + constructor ("new", &new_ps, gsi::arg ("polygon"), "@brief Simple polygon constructor\n" "\n" "This constructor creates a region from a simple polygon.\n" ) + + constructor ("new", &new_psp, gsi::arg ("polygon"), + "@brief Simple polygon constructor\n" + "\n" + "This constructor creates a region from a simple polygon with properties.\n" + "\n" + "This variant has been introduced in version 0.30." + ) + constructor ("new", &new_path, gsi::arg ("path"), "@brief Path constructor\n" "\n" "This constructor creates a region from a path.\n" ) + + constructor ("new", &new_pathp, gsi::arg ("path"), + "@brief Path constructor\n" + "\n" + "This constructor creates a region from a path with properties.\n" + "\n" + "This variant has been introduced in version 0.30." + ) + constructor ("new", &new_si, gsi::arg ("shape_iterator"), "@brief Constructor from a hierarchical shape set\n" "\n" @@ -1697,21 +1764,49 @@ Class decl_Region (decl_dbShapeCollection, "db", "Region", "\n" "Inserts a box into the region.\n" ) + + method ("insert", (void (db::Region::*)(const db::BoxWithProperties &)) &db::Region::insert, gsi::arg ("box"), + "@brief Inserts a box\n" + "\n" + "Inserts a box with properties into the region.\n" + "\n" + "This variant has been introduced in version 0.30." + ) + method ("insert", (void (db::Region::*)(const db::Polygon &)) &db::Region::insert, gsi::arg ("polygon"), "@brief Inserts a polygon\n" "\n" "Inserts a polygon into the region.\n" ) + + method ("insert", (void (db::Region::*)(const db::PolygonWithProperties &)) &db::Region::insert, gsi::arg ("polygon"), + "@brief Inserts a polygon\n" + "\n" + "Inserts a polygon with properties into the region.\n" + "\n" + "This variant has been introduced in version 0.30." + ) + method ("insert", (void (db::Region::*)(const db::SimplePolygon &)) &db::Region::insert, gsi::arg ("polygon"), "@brief Inserts a simple polygon\n" "\n" "Inserts a simple polygon into the region.\n" ) + + method ("insert", (void (db::Region::*)(const db::SimplePolygonWithProperties &)) &db::Region::insert, gsi::arg ("polygon"), + "@brief Inserts a simple polygon\n" + "\n" + "Inserts a simple polygon with properties into the region.\n" + "\n" + "This variant has been introduced in version 0.30." + ) + method ("insert", (void (db::Region::*)(const db::Path &)) &db::Region::insert, gsi::arg ("path"), "@brief Inserts a path\n" "\n" "Inserts a path into the region.\n" ) + + method ("insert", (void (db::Region::*)(const db::PathWithProperties &)) &db::Region::insert, gsi::arg ("path"), + "@brief Inserts a path\n" + "\n" + "Inserts a path with properties into the region.\n" + "\n" + "This variant has been introduced in version 0.30." + ) + method_ext ("insert", &insert_si, gsi::arg ("shape_iterator"), "@brief Inserts all shapes delivered by the recursive shape iterator into this region\n" "\n" @@ -1729,6 +1824,11 @@ Class decl_Region (decl_dbShapeCollection, "db", "Region", method_ext ("insert", &insert_a, gsi::arg ("array"), "@brief Inserts all polygons from the array into this region\n" ) + + method_ext ("insert", &insert_ap, gsi::arg ("array"), + "@brief Inserts all polygons with properties from the array into this region\n" + "\n" + "This variant has been introduced in version 0.30." + ) + method_ext ("insert", &insert_r, gsi::arg ("region"), "@brief Inserts all polygons from the other region into this region\n" "This method has been introduced in version 0.25." diff --git a/src/db/db/gsiDeclDbText.cc b/src/db/db/gsiDeclDbText.cc index b8a669c97..ec665c9d5 100644 --- a/src/db/db/gsiDeclDbText.cc +++ b/src/db/db/gsiDeclDbText.cc @@ -454,10 +454,18 @@ static db::TextWithProperties *new_text_with_properties (const db::Text &text, d return new db::TextWithProperties (text, pid); } +static db::TextWithProperties *new_text_with_properties2 (const db::Text &text, const std::map &properties) +{ + return new db::TextWithProperties (text, db::properties_id (db::PropertiesSet (properties.begin (), properties.end ()))); +} + Class decl_TextWithProperties (decl_Text, "db", "TextWithProperties", gsi::properties_support_methods () + constructor ("new", &new_text_with_properties, gsi::arg ("text"), gsi::arg ("properties_id", db::properties_id_type (0)), "@brief Creates a new object from a property-less object and a properties ID." + ) + + constructor ("new", &new_text_with_properties2, gsi::arg ("text"), gsi::arg ("properties"), + "@brief Creates a new object from a property-less object and a properties hash." ) , "@brief A Text object with properties attached.\n" @@ -522,10 +530,18 @@ static db::DTextWithProperties *new_dtext_with_properties (const db::DText &text return new db::DTextWithProperties (text, pid); } +static db::DTextWithProperties *new_dtext_with_properties2 (const db::DText &text, const std::map &properties) +{ + return new db::DTextWithProperties (text, db::properties_id (db::PropertiesSet (properties.begin (), properties.end ()))); +} + Class decl_DTextWithProperties (decl_DText, "db", "DTextWithProperties", gsi::properties_support_methods () + constructor ("new", &new_dtext_with_properties, gsi::arg ("text"), gsi::arg ("properties_id", db::properties_id_type (0)), "@brief Creates a new object from a property-less object and a properties ID." + ) + + constructor ("new", &new_dtext_with_properties2, gsi::arg ("text"), gsi::arg ("properties"), + "@brief Creates a new object from a property-less object and a properties hash." ) , "@brief A DText object with properties attached.\n" diff --git a/testdata/ruby/dbBoxTest.rb b/testdata/ruby/dbBoxTest.rb index e7b630d59..a631af0e3 100644 --- a/testdata/ruby/dbBoxTest.rb +++ b/testdata/ruby/dbBoxTest.rb @@ -517,6 +517,9 @@ class DBBox_TestClass < TestBase s = RBA::BoxWithProperties::new assert_equal(s.to_s, "() props={}") + s = RBA::BoxWithProperties::new(RBA::Box::new(0, 0, 100, 200), { 1 => "one" }) + assert_equal(s.to_s, "(0,0;100,200) props={1=>one}") + 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}") @@ -532,6 +535,9 @@ class DBBox_TestClass < TestBase s = RBA::DBoxWithProperties::new assert_equal(s.to_s, "() props={}") + s = RBA::DBoxWithProperties::new(RBA::DBox::new(0, 0, 100, 200), { 1 => "one" }) + assert_equal(s.to_s, "(0,0;100,200) props={1=>one}") + 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}") diff --git a/testdata/ruby/dbEdgePairTest.rb b/testdata/ruby/dbEdgePairTest.rb index 3c5ccbdb8..0b0282c27 100644 --- a/testdata/ruby/dbEdgePairTest.rb +++ b/testdata/ruby/dbEdgePairTest.rb @@ -251,6 +251,9 @@ class DBEdgePair_TestClass < TestBase s = RBA::EdgePairWithProperties::new assert_equal(s.to_s, "(0,0;0,0)/(0,0;0,0) props={}") + s = RBA::EdgePairWithProperties::new(RBA::EdgePair::new(RBA::Edge::new(0, 0, 100, 200), RBA::Edge::new(10, 10, 110, 210)), { 1 => "one" }) + assert_equal(s.to_s, "(0,0;100,200)/(10,10;110,210) props={1=>one}") + 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}") @@ -266,6 +269,9 @@ class DBEdgePair_TestClass < TestBase s = RBA::DEdgePairWithProperties::new assert_equal(s.to_s, "(0,0;0,0)/(0,0;0,0) props={}") + s = RBA::DEdgePairWithProperties::new(RBA::DEdgePair::new(RBA::DEdge::new(0, 0, 100, 200), RBA::DEdge::new(10, 10, 110, 210)), { 1 => "one" }) + assert_equal(s.to_s, "(0,0;100,200)/(10,10;110,210) props={1=>one}") + 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}") diff --git a/testdata/ruby/dbEdgeTest.rb b/testdata/ruby/dbEdgeTest.rb index 67074a073..63a1074e3 100644 --- a/testdata/ruby/dbEdgeTest.rb +++ b/testdata/ruby/dbEdgeTest.rb @@ -338,6 +338,9 @@ class DBEdge_TestClass < TestBase s = RBA::EdgeWithProperties::new assert_equal(s.to_s, "(0,0;0,0) props={}") + s = RBA::EdgeWithProperties::new(RBA::Edge::new(0, 0, 100, 200), { 1 => "one" }) + assert_equal(s.to_s, "(0,0;100,200) props={1=>one}") + 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}") @@ -368,6 +371,9 @@ class DBEdge_TestClass < TestBase s = RBA::DEdgeWithProperties::new assert_equal(s.to_s, "(0,0;0,0) props={}") + s = RBA::DEdgeWithProperties::new(RBA::DEdge::new(0, 0, 100, 200), { 1 => "one" }) + assert_equal(s.to_s, "(0,0;100,200) props={1=>one}") + 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}") diff --git a/testdata/ruby/dbPathTest.rb b/testdata/ruby/dbPathTest.rb index 9e9924c08..ea0c2bffe 100644 --- a/testdata/ruby/dbPathTest.rb +++ b/testdata/ruby/dbPathTest.rb @@ -334,6 +334,9 @@ class DBPath_TestClass < TestBase s = RBA::PathWithProperties::new assert_equal(s.to_s, "() w=0 bx=0 ex=0 r=false props={}") + s = RBA::PathWithProperties::new(RBA::Path::new([ [0,0], [100, 0] ], 100), { 1 => "one" }) + assert_equal(s.to_s, "(0,0;100,0) w=100 bx=0 ex=0 r=false props={1=>one}") + 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}") @@ -349,6 +352,9 @@ class DBPath_TestClass < TestBase s = RBA::DPathWithProperties::new assert_equal(s.to_s, "() w=0 bx=0 ex=0 r=false props={}") + s = RBA::DPathWithProperties::new(RBA::DPath::new([ [0,0], [100, 0] ], 100), { 1 => "one" }) + assert_equal(s.to_s, "(0,0;100,0) w=100 bx=0 ex=0 r=false props={1=>one}") + 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}") diff --git a/testdata/ruby/dbPolygonTest.rb b/testdata/ruby/dbPolygonTest.rb index d9bf6f8c4..5c96489cd 100644 --- a/testdata/ruby/dbPolygonTest.rb +++ b/testdata/ruby/dbPolygonTest.rb @@ -899,6 +899,9 @@ class DBPolygon_TestClass < TestBase s = RBA::PolygonWithProperties::new assert_equal(s.to_s, "() props={}") + s = RBA::PolygonWithProperties::new(RBA::Polygon::new(RBA::Box::new(0, 0, 100, 200)), { 1 => "one" }) + assert_equal(s.to_s, "(0,0;0,200;100,200;100,0) props={1=>one}") + 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}") @@ -914,6 +917,9 @@ class DBPolygon_TestClass < TestBase s = RBA::DPolygonWithProperties::new assert_equal(s.to_s, "() props={}") + s = RBA::DPolygonWithProperties::new(RBA::DPolygon::new(RBA::DBox::new(0, 0, 100, 200)), { 1 => "one" }) + assert_equal(s.to_s, "(0,0;0,200;100,200;100,0) props={1=>one}") + 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}") @@ -929,6 +935,9 @@ class DBPolygon_TestClass < TestBase s = RBA::SimplePolygonWithProperties::new assert_equal(s.to_s, "() props={}") + s = RBA::SimplePolygonWithProperties::new(RBA::SimplePolygon::new(RBA::Box::new(0, 0, 100, 200)), { 1 => "one" }) + assert_equal(s.to_s, "(0,0;0,200;100,200;100,0) props={1=>one}") + 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}") @@ -944,6 +953,9 @@ class DBPolygon_TestClass < TestBase s = RBA::DSimplePolygonWithProperties::new assert_equal(s.to_s, "() props={}") + s = RBA::DSimplePolygonWithProperties::new(RBA::DSimplePolygon::new(RBA::DBox::new(0, 0, 100, 200)), { 1 => "one" }) + assert_equal(s.to_s, "(0,0;0,200;100,200;100,0) props={1=>one}") + 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}") diff --git a/testdata/ruby/dbRegionTest.rb b/testdata/ruby/dbRegionTest.rb index ea7b13feb..116fb190c 100644 --- a/testdata/ruby/dbRegionTest.rb +++ b/testdata/ruby/dbRegionTest.rb @@ -1280,12 +1280,12 @@ class DBRegion_TestClass < TestBase assert_equal(csort((r & rr).to_s), csort("(0,0;0,100;100,100;100,0);(200,0;200,100;300,100;300,0);(400,0;400,100;500,100;500,0)")) assert_equal(csort(r.and(rr).to_s), csort("(0,0;0,100;100,100;100,0);(200,0;200,100;300,100;300,0);(400,0;400,100;500,100;500,0)")) - assert_equal(csort(r.and(rr, RBA::Region::NoPropertyConstraint).to_s), csort("(0,0;0,100;100,100;100,0);(200,0;200,100;300,100;300,0);(400,0;400,100;500,100;500,0)")) - assert_equal(csort(r.and(rr, RBA::Region::SamePropertiesConstraint).to_s), csort("(0,0;0,50;100,50;100,0);(400,50;400,100;500,100;500,50)")) - assert_equal(csort(r.and(rr, RBA::Region::DifferentPropertiesConstraint).to_s), csort("(0,50;0,100;100,100;100,50);(200,0;200,100;300,100;300,0);(400,0;400,50;500,50;500,0)")) + assert_equal(csort(r.and(rr, RBA::Region::NoPropertyConstraint).to_s), csort("(200,0;200,100;300,100;300,0){1=>42};(0,0;0,100;100,100;100,0){1=>17};(400,0;400,100;500,100;500,0)")) + assert_equal(csort(r.and(rr, RBA::Region::SamePropertiesConstraint).to_s), csort("(0,0;0,50;100,50;100,0){1=>17};(400,50;400,100;500,100;500,50)")) + assert_equal(csort(r.and(rr, RBA::Region::DifferentPropertiesConstraint).to_s), csort("(200,0;200,100;300,100;300,0){1=>42};(0,50;0,100;100,100;100,50){1=>17};(400,0;400,50;500,50;500,0)")) assert_equal(csort(r.not(rr).to_s), csort("(0,100;0,200;100,200;100,100);(200,100;200,200;300,200;300,100);(400,100;400,200;500,200;500,100)")) - assert_equal(csort(r.not(rr, RBA::Region::SamePropertiesConstraint).to_s), csort("(0,50;0,200;100,200;100,50);(400,100;400,200;500,200;500,100);(200,0;200,200;300,200;300,0);(400,0;400,50;500,50;500,0)")) + assert_equal(csort(r.not(rr, RBA::Region::SamePropertiesConstraint).to_s), csort("(200,0;200,200;300,200;300,0){1=>42};(0,50;0,200;100,200;100,50){1=>17};(400,100;400,200;500,200;500,100);(400,0;400,50;500,50;500,0)")) r.remove_properties rr.remove_properties @@ -1528,6 +1528,42 @@ class DBRegion_TestClass < TestBase end + # properties + def test_props + + r = RBA::Region::new([ RBA::PolygonWithProperties::new(RBA::Box::new(0, 0, 100, 200), { 1 => "one" }) ]) + assert_equal(r.to_s, "(0,0;0,200;100,200;100,0){1=>one}") + + r = RBA::Region::new + r.insert([ RBA::PolygonWithProperties::new(RBA::Box::new(0, 0, 100, 200), { 1 => "one" }) ]) + assert_equal(r.to_s, "(0,0;0,200;100,200;100,0){1=>one}") + + r = RBA::Region::new(RBA::PolygonWithProperties::new(RBA::Box::new(0, 0, 100, 200), { 1 => "one" })) + assert_equal(r.to_s, "(0,0;0,200;100,200;100,0){1=>one}") + + r = RBA::Region::new + r.insert(RBA::PolygonWithProperties::new(RBA::Box::new(0, 0, 100, 200), { 1 => "one" })) + assert_equal(r.to_s, "(0,0;0,200;100,200;100,0){1=>one}") + + r = RBA::Region::new(RBA::SimplePolygonWithProperties::new(RBA::Box::new(0, 0, 100, 200), { 1 => "one" })) + assert_equal(r.to_s, "(0,0;0,200;100,200;100,0){1=>one}") + + r = RBA::Region::new + r.insert(RBA::SimplePolygonWithProperties::new(RBA::Box::new(0, 0, 100, 200), { 1 => "one" })) + assert_equal(r.to_s, "(0,0;0,200;100,200;100,0){1=>one}") + + r = RBA::Region::new(RBA::BoxWithProperties::new(RBA::Box::new(0, 0, 100, 200), { 1 => "one" })) + assert_equal(r.to_s, "(0,0;0,200;100,200;100,0){1=>one}") + + r = RBA::Region::new + r.insert(RBA::BoxWithProperties::new(RBA::Box::new(0, 0, 100, 200), { 1 => "one" })) + assert_equal(r.to_s, "(0,0;0,200;100,200;100,0){1=>one}") + + r = RBA::Region::new(RBA::PathWithProperties::new(RBA::Path::new([ RBA::Point::new(0, 0), RBA::Point::new(100, 0) ], 20), { 1 => "one" })) + assert_equal(r.to_s, "(0,-10;0,10;100,10;100,-10){1=>one}") + + end + end load("test_epilogue.rb") diff --git a/testdata/ruby/dbTextTest.rb b/testdata/ruby/dbTextTest.rb index 892b99042..b3f08d06e 100644 --- a/testdata/ruby/dbTextTest.rb +++ b/testdata/ruby/dbTextTest.rb @@ -259,6 +259,9 @@ class DBText_TestClass < TestBase s = RBA::TextWithProperties::new assert_equal(s.to_s, "('',r0 0,0) props={}") + s = RBA::TextWithProperties::new(RBA::Text::new("text", RBA::Trans::R90), { 1 => "one" }) + assert_equal(s.to_s, "('text',r90 0,0) props={1=>one}") + 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}") @@ -274,6 +277,9 @@ class DBText_TestClass < TestBase s = RBA::DTextWithProperties::new assert_equal(s.to_s, "('',r0 0,0) props={}") + s = RBA::DTextWithProperties::new(RBA::DText::new("text", RBA::Trans::R90), { 1 => "one" }) + assert_equal(s.to_s, "('text',r90 0,0) props={1=>one}") + 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}")