| 3672 | } |
| 3673 | |
| 3674 | void |
| 3675 | LayoutViewBase::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 | } |
no test coverage detected