mirror of https://github.com/KLayout/klayout.git
Merge remote-tracking branch 'origin/issue-1240'
This commit is contained in:
commit
6136e4f8a0
|
|
@ -1856,6 +1856,22 @@ Layout::delete_layer (unsigned int n)
|
||||||
layer_properties_changed ();
|
layer_properties_changed ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned int
|
||||||
|
Layout::get_layer (const db::LayerProperties &props)
|
||||||
|
{
|
||||||
|
int li = get_layer_maybe (props);
|
||||||
|
if (li >= 0) {
|
||||||
|
return (unsigned int) li;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (props.is_null ()) {
|
||||||
|
// for a null layer info always create a layer
|
||||||
|
return insert_layer ();
|
||||||
|
} else {
|
||||||
|
return insert_layer (props);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
unsigned int
|
unsigned int
|
||||||
Layout::insert_layer (const LayerProperties &props)
|
Layout::insert_layer (const LayerProperties &props)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1644,15 +1644,12 @@ public:
|
||||||
* If there already is a layer matching the given properties, it's index will be
|
* If there already is a layer matching the given properties, it's index will be
|
||||||
* returned. Otherwise a new layer with these properties is created.
|
* returned. Otherwise a new layer with these properties is created.
|
||||||
*/
|
*/
|
||||||
unsigned int get_layer (const db::LayerProperties &props)
|
unsigned int get_layer (const db::LayerProperties &props);
|
||||||
{
|
|
||||||
return m_layers.get_layer (props);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Gets the layer with the given properties or -1 if such a layer does not exist
|
* @brief Gets the layer with the given properties or -1 if such a layer does not exist
|
||||||
*/
|
*/
|
||||||
int get_layer_maybe (const db::LayerProperties &props)
|
int get_layer_maybe (const db::LayerProperties &props) const
|
||||||
{
|
{
|
||||||
return m_layers.get_layer_maybe (props);
|
return m_layers.get_layer_maybe (props);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -157,25 +157,8 @@ LayoutLayers::insert_layer (unsigned int index, const LayerProperties &props)
|
||||||
set_properties (index, props);
|
set_properties (index, props);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int
|
|
||||||
LayoutLayers::get_layer (const db::LayerProperties &lp)
|
|
||||||
{
|
|
||||||
if (lp.is_null ()) {
|
|
||||||
// for a null layer info always create a layer
|
|
||||||
return insert_layer ();
|
|
||||||
} else {
|
|
||||||
auto i = m_layers_by_props.find (lp);
|
|
||||||
if (i != m_layers_by_props.end () && i->first.log_equal (lp)) {
|
|
||||||
return i->second;
|
|
||||||
} else {
|
|
||||||
// otherwise create a new layer
|
|
||||||
return insert_layer (lp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
LayoutLayers::get_layer_maybe (const db::LayerProperties &lp)
|
LayoutLayers::get_layer_maybe (const db::LayerProperties &lp) const
|
||||||
{
|
{
|
||||||
if (lp.is_null ()) {
|
if (lp.is_null ()) {
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
||||||
|
|
@ -187,7 +187,7 @@ public:
|
||||||
/**
|
/**
|
||||||
* @brief Gets the layer with the given properties or -1 if such a layer does not exist.
|
* @brief Gets the layer with the given properties or -1 if such a layer does not exist.
|
||||||
*/
|
*/
|
||||||
int get_layer_maybe (const db::LayerProperties &props);
|
int get_layer_maybe (const db::LayerProperties &props) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Insert a new special layer with the given properties
|
* @brief Insert a new special layer with the given properties
|
||||||
|
|
|
||||||
|
|
@ -478,6 +478,12 @@ TEST(4)
|
||||||
ps.insert (std::make_pair (g.properties_repository ().prop_name_id (tl::Variant (1)), tl::Variant ("XXX")));
|
ps.insert (std::make_pair (g.properties_repository ().prop_name_id (tl::Variant (1)), tl::Variant ("XXX")));
|
||||||
prop_id = g.properties_repository ().properties_id (ps);
|
prop_id = g.properties_repository ().properties_id (ps);
|
||||||
EXPECT_EQ (el.property_ids_dirty, true);
|
EXPECT_EQ (el.property_ids_dirty, true);
|
||||||
|
|
||||||
|
el.layer_properties_dirty = false;
|
||||||
|
EXPECT_EQ (g.get_layer_maybe (db::LayerProperties (42, 17)), -1);
|
||||||
|
EXPECT_EQ (el.layer_properties_dirty, false);
|
||||||
|
EXPECT_EQ (g.get_layer (db::LayerProperties (42, 17)) >= 0, true);
|
||||||
|
EXPECT_EQ (el.layer_properties_dirty, true); // new layer got inserted
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::string l2s (const db::Layout &layout)
|
static std::string l2s (const db::Layout &layout)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue