mirror of https://github.com/KLayout/klayout.git
Enhancing Python/Ruby API for better support with properties
This commit is contained in:
parent
d9233caa42
commit
dfc7d6bef4
|
|
@ -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 << "...";
|
||||
|
|
|
|||
|
|
@ -110,6 +110,18 @@ public:
|
|||
*/
|
||||
PropertiesSet (const PropertiesSet &&other);
|
||||
|
||||
/**
|
||||
* @brief Constructor from tl::Variant pair iterator
|
||||
*/
|
||||
template <class Iter>
|
||||
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
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -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<tl::Variant, tl::Variant> &properties)
|
||||
{
|
||||
return new db::BoxWithProperties (path, db::properties_id (db::PropertiesSet (properties.begin (), properties.end ())));
|
||||
}
|
||||
|
||||
Class<db::BoxWithProperties> decl_BoxWithProperties (decl_Box, "db", "BoxWithProperties",
|
||||
gsi::properties_support_methods<db::BoxWithProperties> () +
|
||||
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<tl::Variant, tl::Variant> &properties)
|
||||
{
|
||||
return new db::DBoxWithProperties (path, db::properties_id (db::PropertiesSet (properties.begin (), properties.end ())));
|
||||
}
|
||||
|
||||
Class<db::DBoxWithProperties> decl_DBoxWithProperties (decl_DBox, "db", "DBoxWithProperties",
|
||||
gsi::properties_support_methods<db::DBoxWithProperties> () +
|
||||
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"
|
||||
|
|
|
|||
|
|
@ -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<tl::Variant, tl::Variant> &properties)
|
||||
{
|
||||
return new db::EdgeWithProperties (edge, db::properties_id (db::PropertiesSet (properties.begin (), properties.end ())));
|
||||
}
|
||||
|
||||
Class<db::EdgeWithProperties> decl_EdgeWithProperties (decl_Edge, "db", "EdgeWithProperties",
|
||||
gsi::properties_support_methods<db::EdgeWithProperties> () +
|
||||
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<tl::Variant, tl::Variant> &properties)
|
||||
{
|
||||
return new db::DEdgeWithProperties (edge, db::properties_id (db::PropertiesSet (properties.begin (), properties.end ())));
|
||||
}
|
||||
|
||||
Class<db::DEdgeWithProperties> decl_DEdgeWithProperties (decl_DEdge, "db", "DEdgeWithProperties",
|
||||
gsi::properties_support_methods<db::DEdgeWithProperties> () +
|
||||
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"
|
||||
|
|
|
|||
|
|
@ -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<tl::Variant, tl::Variant> &properties)
|
||||
{
|
||||
return new db::EdgePairWithProperties (edge_pair, db::properties_id (db::PropertiesSet (properties.begin (), properties.end ())));
|
||||
}
|
||||
|
||||
Class<db::EdgePairWithProperties> decl_EdgePairWithProperties (decl_EdgePair, "db", "EdgePairWithProperties",
|
||||
gsi::properties_support_methods<db::EdgePairWithProperties> () +
|
||||
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<tl::Variant, tl::Variant> &properties)
|
||||
{
|
||||
return new db::DEdgePairWithProperties (edge_pair, db::properties_id (db::PropertiesSet (properties.begin (), properties.end ())));
|
||||
}
|
||||
|
||||
Class<db::DEdgePairWithProperties> decl_DEdgePairWithProperties (decl_EdgePair, "db", "DEdgePairWithProperties",
|
||||
gsi::properties_support_methods<db::DEdgePairWithProperties> () +
|
||||
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"
|
||||
|
|
|
|||
|
|
@ -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<tl::Variant, tl::Variant> &properties)
|
||||
{
|
||||
return new db::PathWithProperties (path, db::properties_id (db::PropertiesSet (properties.begin (), properties.end ())));
|
||||
}
|
||||
|
||||
Class<db::PathWithProperties> decl_PathWithProperties (decl_Path, "db", "PathWithProperties",
|
||||
gsi::properties_support_methods<db::PathWithProperties> () +
|
||||
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<tl::Variant, tl::Variant> &properties)
|
||||
{
|
||||
return new db::DPathWithProperties (path, db::properties_id (db::PropertiesSet (properties.begin (), properties.end ())));
|
||||
}
|
||||
|
||||
Class<db::DPathWithProperties> decl_DPathWithProperties (decl_DPath, "db", "DPathWithProperties",
|
||||
gsi::properties_support_methods<db::DPathWithProperties> () +
|
||||
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"
|
||||
|
|
|
|||
|
|
@ -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<tl::Variant, tl::Variant> &properties)
|
||||
{
|
||||
return new db::SimplePolygonWithProperties (poly, db::properties_id (db::PropertiesSet (properties.begin (), properties.end ())));
|
||||
}
|
||||
|
||||
Class<db::SimplePolygonWithProperties> decl_SimplePolygonWithProperties (decl_SimplePolygon, "db", "SimplePolygonWithProperties",
|
||||
gsi::properties_support_methods<db::SimplePolygonWithProperties> () +
|
||||
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<tl::Variant, tl::Variant> &properties)
|
||||
{
|
||||
return new db::DSimplePolygonWithProperties (poly, db::properties_id (db::PropertiesSet (properties.begin (), properties.end ())));
|
||||
}
|
||||
|
||||
Class<db::DSimplePolygonWithProperties> decl_DSimplePolygonWithProperties (decl_DSimplePolygon, "db", "DSimplePolygonWithProperties",
|
||||
gsi::properties_support_methods<db::DSimplePolygonWithProperties> () +
|
||||
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<tl::Variant, tl::Variant> &properties)
|
||||
{
|
||||
return new db::PolygonWithProperties (poly, db::properties_id (db::PropertiesSet (properties.begin (), properties.end ())));
|
||||
}
|
||||
|
||||
Class<db::PolygonWithProperties> decl_PolygonWithProperties (decl_Polygon, "db", "PolygonWithProperties",
|
||||
gsi::properties_support_methods<db::PolygonWithProperties> () +
|
||||
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<tl::Variant, tl::Variant> &properties)
|
||||
{
|
||||
return new db::DPolygonWithProperties (poly, db::properties_id (db::PropertiesSet (properties.begin (), properties.end ())));
|
||||
}
|
||||
|
||||
Class<db::DPolygonWithProperties> decl_DPolygonWithProperties (decl_DPolygon, "db", "DPolygonWithProperties",
|
||||
gsi::properties_support_methods<db::DPolygonWithProperties> () +
|
||||
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"
|
||||
|
|
|
|||
|
|
@ -250,26 +250,51 @@ static db::Region *new_a (const std::vector <db::Polygon> &a)
|
|||
return new db::Region (a.begin (), a.end ());
|
||||
}
|
||||
|
||||
static db::Region *new_ap (const std::vector <db::PolygonWithProperties> &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 <db::Polygon> &a)
|
|||
}
|
||||
}
|
||||
|
||||
static void insert_ap (db::Region *r, const std::vector <db::PolygonWithProperties> &a)
|
||||
{
|
||||
for (std::vector <db::PolygonWithProperties>::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<db::Region> 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<db::Region> 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<db::Region> 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."
|
||||
|
|
|
|||
|
|
@ -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<tl::Variant, tl::Variant> &properties)
|
||||
{
|
||||
return new db::TextWithProperties (text, db::properties_id (db::PropertiesSet (properties.begin (), properties.end ())));
|
||||
}
|
||||
|
||||
Class<db::TextWithProperties> decl_TextWithProperties (decl_Text, "db", "TextWithProperties",
|
||||
gsi::properties_support_methods<db::TextWithProperties> () +
|
||||
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<tl::Variant, tl::Variant> &properties)
|
||||
{
|
||||
return new db::DTextWithProperties (text, db::properties_id (db::PropertiesSet (properties.begin (), properties.end ())));
|
||||
}
|
||||
|
||||
Class<db::DTextWithProperties> decl_DTextWithProperties (decl_DText, "db", "DTextWithProperties",
|
||||
gsi::properties_support_methods<db::DTextWithProperties> () +
|
||||
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"
|
||||
|
|
|
|||
|
|
@ -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}")
|
||||
|
|
|
|||
|
|
@ -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}")
|
||||
|
|
|
|||
|
|
@ -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}")
|
||||
|
|
|
|||
|
|
@ -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}")
|
||||
|
|
|
|||
|
|
@ -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}")
|
||||
|
|
|
|||
|
|
@ -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")
|
||||
|
|
|
|||
|
|
@ -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}")
|
||||
|
|
|
|||
Loading…
Reference in New Issue