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

Method do_load_layer_props

src/laybasic/laybasic/layLayoutViewBase.cc:2788–2862  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2786}
2787
2788void
2789LayoutViewBase::do_load_layer_props (const std::string &fn, bool map_cv, int cv_index, bool add_default)
2790{
2791 std::vector<lay::LayerPropertiesList> props;
2792 bool single_list = false;
2793
2794 // read the layer properties from the file
2795 try {
2796 tl::XMLFileSource in (fn);
2797 props.push_back (lay::LayerPropertiesList ());
2798 props.back ().load (in);
2799 single_list = true;
2800 } catch (...) {
2801 props.clear ();
2802 tl::XMLFileSource in (fn);
2803 lay::LayerPropertiesList::load (in, props);
2804 }
2805
2806 // expand the wildcards and map to the target cv.
2807 for (std::vector<lay::LayerPropertiesList>::iterator p = props.begin (); p != props.end (); ++p) {
2808 std::map <int, int> cv_map;
2809 if (map_cv) {
2810 cv_map.insert (std::make_pair (-1, cv_index));
2811 }
2812 p->attach_view (this, p - props.begin ());
2813 p->expand (cv_map, add_default);
2814 }
2815
2816 transaction (tl::to_string (tr ("Load layer properties")));
2817
2818 if (single_list) {
2819
2820 // a single list will only replace the current tab
2821 if (map_cv && cv_index >= 0) {
2822 lay::LayerPropertiesList new_props (get_properties ());
2823 new_props.remove_cv_references (cv_index);
2824 new_props.append (props [0]);
2825 set_properties (new_props);
2826 } else {
2827 set_properties (props [0]);
2828 }
2829
2830 } else {
2831
2832 for (unsigned int i = 0; i < props.size (); ++i) {
2833
2834 if (i < layer_lists ()) {
2835
2836 if (map_cv && cv_index >= 0) {
2837 lay::LayerPropertiesList new_props (get_properties (i));
2838 new_props.remove_cv_references (cv_index);
2839 new_props.append (props [i]);
2840 set_properties (i, new_props);
2841 } else {
2842 set_properties (i, props [i]);
2843 }
2844
2845 } else {

Callers

nothing calls this directly

Calls 15

LayerPropertiesListClass · 0.85
layer_listsFunction · 0.85
insert_layer_listFunction · 0.85
remove_cv_referencesMethod · 0.80
loadFunction · 0.70
transactionFunction · 0.70
set_propertiesFunction · 0.70
commitFunction · 0.70
to_stringFunction · 0.50
trFunction · 0.50
get_propertiesFunction · 0.50
push_backMethod · 0.45

Tested by

no test coverage detected