MCPcopy Create free account
hub / github.com/KLayout/klayout / create_initial_layer_props

Method create_initial_layer_props

src/laybasic/laybasic/layLayoutViewBase.cc:3674–3742  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3672}
3673
3674void
3675LayoutViewBase::create_initial_layer_props (int cv_index, const std::string &lyp_file, bool add_missing)
3676{
3677 std::vector<lay::LayerPropertiesList> props;
3678 bool loaded = false;
3679
3680 if (! lyp_file.empty ()) {
3681
3682 // read the layer properties from the file
3683 try {
3684
3685 try {
3686 tl::XMLFileSource in (lyp_file);
3687 props.push_back (lay::LayerPropertiesList ());
3688 props.back ().load (in);
3689 loaded = true;
3690 } catch (...) {
3691 props.clear ();
3692 tl::XMLFileSource in (lyp_file);
3693 tl::log << tl::to_string (tr ("Loading layer properties file: ")) << lyp_file;
3694 lay::LayerPropertiesList::load (in, props);
3695 loaded = true;
3696 }
3697
3698 } catch (tl::Exception &ex) {
3699 tl::warn << tl::to_string (tr ("Initialization of layers failed: ")) << ex.msg ();
3700 } catch (...) {
3701 tl::warn << tl::to_string (tr ("Initialization of layers failed: unspecific error"));
3702 }
3703
3704 }
3705
3706 std::map <int, int> cv_map;
3707 cv_map.insert (std::make_pair (-1, cv_index));
3708
3709 if (! loaded) {
3710
3711 props.clear ();
3712 props.push_back (lay::LayerPropertiesList ());
3713
3714 } else {
3715
3716 // do't map cv's if the input file is a multi-cv one.
3717 std::set <int> cv;
3718 for (std::vector<lay::LayerPropertiesList>::const_iterator p = props.begin (); p != props.end (); ++p) {
3719 for (lay::LayerPropertiesConstIterator lp = p->begin_const_recursive (); ! lp.at_end (); ++lp) {
3720 if (! lp->has_children ()) {
3721 cv.insert (lp->source (true).cv_index ());
3722 if (cv.size () >= 2) {
3723 cv_map.clear ();
3724 cv_map.insert (std::make_pair (cv_index, cv_index));
3725 // erase the others:
3726 cv_map.insert (std::make_pair (-1, -2));
3727 break;
3728 }
3729 }
3730 }
3731 }

Callers 1

menu_activatedMethod · 0.80

Calls 15

LayerPropertiesListClass · 0.85
msgMethod · 0.80
begin_const_recursiveMethod · 0.80
loadFunction · 0.70
to_stringFunction · 0.50
trFunction · 0.50
emptyMethod · 0.45
push_backMethod · 0.45
loadMethod · 0.45
backMethod · 0.45
clearMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected