Added a convenience method to RBA::Layout for creating a temp layer

This commit is contained in:
Matthias Koefferlein 2017-02-24 22:43:31 +01:00
parent 49be72e1a2
commit ede58ae728
2 changed files with 20 additions and 1 deletions

View File

@ -371,6 +371,11 @@ static unsigned int get_layer (db::Layout *l, const db::LayerProperties &lp)
} }
} }
static unsigned int get_layer0 (db::Layout *l)
{
return get_layer (l, db::LayerProperties ());
}
static unsigned int get_layer1 (db::Layout *l, const std::string &name) static unsigned int get_layer1 (db::Layout *l, const std::string &name)
{ {
return get_layer (l, db::LayerProperties (name)); return get_layer (l, db::LayerProperties (name));
@ -1268,6 +1273,15 @@ Class<db::Layout> decl_Layout ("Layout",
"You can convert coordinates to micrometers by multiplying the integer value with the database unit.\n" "You can convert coordinates to micrometers by multiplying the integer value with the database unit.\n"
"Typical values for the database unit are 0.001 micrometer (one nanometer).\n" "Typical values for the database unit are 0.001 micrometer (one nanometer).\n"
) + ) +
gsi::method_ext ("layer", &get_layer0,
"@brief Finds or creates a new internal layer\n"
"\n"
"This method will create a new internal layer and return the layer index for this layer.\n"
"The layer does not have any properties attached to it. That means, it is not going to be saved "
"to a layout file unless it is given database properties with \\set_info.\n"
"\n"
"This method has been introduced in version 0.25.\n"
) +
gsi::method_ext ("layer", &get_layer, gsi::method_ext ("layer", &get_layer,
"@brief Finds or creates a layer with the given properties\n" "@brief Finds or creates a layer with the given properties\n"
"@args info\n" "@args info\n"

View File

@ -162,12 +162,17 @@ class DBLayout_TestClass < TestBase
b = ly.layer(RBA::LayerInfo.new(3, 0)) b = ly.layer(RBA::LayerInfo.new(3, 0))
assert_equal(a, b) assert_equal(a, b)
assert_equal(ll(ly), "3/0") assert_equal(ll(ly), "3/0")
b = ly.layer(RBA::LayerInfo.new) bb = b
b = ly.layer
assert_equal(ll(ly), "3/0,") assert_equal(ll(ly), "3/0,")
assert_equal(b != bb, true)
bb = b
b = ly.layer(RBA::LayerInfo.new) b = ly.layer(RBA::LayerInfo.new)
assert_equal(ll(ly), "3/0,,") assert_equal(ll(ly), "3/0,,")
assert_equal(b != bb, true)
n = ly.layer(RBA::LayerInfo.new ("hallo")); n = ly.layer(RBA::LayerInfo.new ("hallo"));
assert_equal(ll(ly), "3/0,,,hallo") assert_equal(ll(ly), "3/0,,,hallo")
assert_equal(b != n, true)
ly = RBA::Layout.new ly = RBA::Layout.new
li = ly.layer(2, 0) li = ly.layer(2, 0)