mirror of https://github.com/KLayout/klayout.git
Bugfix: update layer names in layer list (when used in secondary fashion) on reload
1. The readers will overwrite the layer names if given in secondary fashion (additionally to layer/datatype) 2. The layer properties nodes will update the "real source" according to the actual name if the name is used in addition to layer/datatypes
This commit is contained in:
parent
c8d307c914
commit
edad8f5221
|
|
@ -541,31 +541,58 @@ CommonReaderBase::open_dl_uncached (db::Layout &layout, const LDPair &dl)
|
|||
}
|
||||
|
||||
unsigned int nl = layout.insert_layer (lp);
|
||||
|
||||
// change OASIS layer name if a layer already exists by layer/datatype, but has a different name
|
||||
if (! lp.name.empty () && layout.get_properties (nl).name != lp.name) {
|
||||
layout.set_properties (nl, lp);
|
||||
}
|
||||
|
||||
m_layer_map_out.map (dl, nl, lp);
|
||||
|
||||
m_layers_created.insert (nl);
|
||||
|
||||
return std::make_pair (true, nl);
|
||||
|
||||
} else if (li.size () == 1) {
|
||||
|
||||
m_layer_map_out.map (dl, *li.begin (), layout.get_properties (*li.begin ()));
|
||||
|
||||
return std::make_pair (true, *li.begin ());
|
||||
|
||||
} else {
|
||||
|
||||
for (std::set<unsigned int>::const_iterator i = li.begin (); i != li.end (); ++i) {
|
||||
m_layer_map_out.mmap (dl, *i, layout.get_properties (*i));
|
||||
for (auto i = li.begin (); i != li.end (); ++i) {
|
||||
|
||||
// change OASIS layer name if a layer exists by layer/datatype, but has a different name
|
||||
const tl::interval_map <db::ld_type, std::string> *names_dmap = m_layer_names.mapped (dl.layer);
|
||||
if (names_dmap != 0) {
|
||||
const std::string *name = names_dmap->mapped (dl.datatype);
|
||||
if (name != 0) {
|
||||
db::LayerProperties lp_out = layout.get_properties (*i);
|
||||
if (lp_out.name != *name) {
|
||||
lp_out.name = *name;
|
||||
layout.set_properties (*i, lp_out);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
std::map<std::set<unsigned int>, unsigned int>::iterator mmp = m_multi_mapping_placeholders.find (li);
|
||||
if (mmp == m_multi_mapping_placeholders.end ()) {
|
||||
// create a placeholder layer
|
||||
mmp = m_multi_mapping_placeholders.insert (std::make_pair (li, layout.insert_layer ())).first;
|
||||
}
|
||||
if (li.size () == 1) {
|
||||
|
||||
return std::make_pair (true, mmp->second);
|
||||
m_layer_map_out.map (dl, *li.begin (), layout.get_properties (*li.begin ()));
|
||||
|
||||
return std::make_pair (true, *li.begin ());
|
||||
|
||||
} else {
|
||||
|
||||
for (std::set<unsigned int>::const_iterator i = li.begin (); i != li.end (); ++i) {
|
||||
m_layer_map_out.mmap (dl, *i, layout.get_properties (*i));
|
||||
}
|
||||
|
||||
std::map<std::set<unsigned int>, unsigned int>::iterator mmp = m_multi_mapping_placeholders.find (li);
|
||||
if (mmp == m_multi_mapping_placeholders.end ()) {
|
||||
// create a placeholder layer
|
||||
mmp = m_multi_mapping_placeholders.insert (std::make_pair (li, layout.insert_layer ())).first;
|
||||
}
|
||||
|
||||
return std::make_pair (true, mmp->second);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -640,6 +640,13 @@ LayerProperties::do_realize (const LayoutViewBase *view) const
|
|||
|
||||
}
|
||||
|
||||
if (m_layer_index >= 0) {
|
||||
const auto &lp = cv->layout ().get_properties (m_layer_index);
|
||||
if (! lp.name.empty () && m_source_real.name () != lp.name) {
|
||||
m_source_real.name (lp.name);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3383,6 +3383,7 @@ LayoutViewBase::reload_layout (unsigned int cv_index)
|
|||
}
|
||||
|
||||
set_properties (new_props);
|
||||
do_update_layer_sources ();
|
||||
|
||||
goto_view (state);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -131,3 +131,23 @@ TEST(variants)
|
|||
run_test (_this, tl::testdata (), "variants.lstr", "variants_au.oas");
|
||||
}
|
||||
|
||||
TEST(reload_layer_props)
|
||||
{
|
||||
db::LoadLayoutOptions options;
|
||||
|
||||
db::Layout layout;
|
||||
auto l1 = layout.insert_layer (db::LayerProperties (1, 0, "A"));
|
||||
auto l2 = layout.insert_layer (db::LayerProperties (2, 0, "B"));
|
||||
|
||||
{
|
||||
std::string fn (tl::testdata ());
|
||||
fn += "/lstream/layers.lstr";
|
||||
tl::InputStream stream (fn);
|
||||
db::Reader reader (stream);
|
||||
reader.read (layout, options);
|
||||
}
|
||||
|
||||
// layer 1 got renamed
|
||||
EXPECT_EQ (layout.get_properties (l1).to_string (), "ONE (1/0)");
|
||||
EXPECT_EQ (layout.get_properties (l2).to_string (), "B (2/0)");
|
||||
}
|
||||
|
|
|
|||
Binary file not shown.
Loading…
Reference in New Issue