diff --git a/src/laybasic/laybasic/layLayoutViewConfig.cc b/src/laybasic/laybasic/layLayoutViewConfig.cc index 519458b67..12441857d 100644 --- a/src/laybasic/laybasic/layLayoutViewConfig.cc +++ b/src/laybasic/laybasic/layLayoutViewConfig.cc @@ -43,6 +43,7 @@ public: lay::ColorConverter cc; options.push_back (std::pair (cfg_default_lyp_file, "")); options.push_back (std::pair (cfg_default_add_other_layers, "false")); + options.push_back (std::pair (cfg_layer_visibility_follows_selection, "false")); options.push_back (std::pair (cfg_layers_always_show_source, "false")); options.push_back (std::pair (cfg_layers_always_show_ld, "true")); options.push_back (std::pair (cfg_layers_always_show_layout_index, "false")); diff --git a/src/laybasic/laybasic/laybasicConfig.h b/src/laybasic/laybasic/laybasicConfig.h index ba148ee60..d96913bee 100644 --- a/src/laybasic/laybasic/laybasicConfig.h +++ b/src/laybasic/laybasic/laybasicConfig.h @@ -117,6 +117,7 @@ static const std::string cfg_drop_small_cells_value ("drop-small-cells-value"); static const std::string cfg_array_border_instances ("draw-array-border-instances"); static const std::string cfg_default_lyp_file ("default-layer-properties"); static const std::string cfg_default_add_other_layers ("default-add-other-layers"); +static const std::string cfg_layer_visibility_follows_selection ("layer-visibility-follows-selection"); static const std::string cfg_layers_always_show_source ("layers-always-show-source"); static const std::string cfg_layers_always_show_ld ("layers-always-show-ld"); static const std::string cfg_layers_always_show_layout_index ("layers-always-show-layout-index"); diff --git a/src/layui/layui/layLayerControlPanel.cc b/src/layui/layui/layLayerControlPanel.cc index 05d53b135..761171640 100644 --- a/src/layui/layui/layLayerControlPanel.cc +++ b/src/layui/layui/layLayerControlPanel.cc @@ -213,7 +213,9 @@ LayerControlPanel::LayerControlPanel (lay::LayoutViewBase *view, db::Manager *ma m_oversampling (1), m_hrm (false), m_do_update_content_dm (this, &LayerControlPanel::do_update_content), - m_no_stipples (false) + m_do_update_visibility_dm (this, &LayerControlPanel::do_update_visibility), + m_no_stipples (false), + m_layer_visibility_follows_selection (false) { setObjectName (QString::fromUtf8 (name)); @@ -315,6 +317,7 @@ LayerControlPanel::LayerControlPanel (lay::LayoutViewBase *view, db::Manager *ma connect (mp_layer_list, SIGNAL (expanded (const QModelIndex &)), this, SLOT (group_expanded (const QModelIndex &))); connect (mp_layer_list, SIGNAL (search_triggered (const QString &)), this, SLOT (search_triggered (const QString &))); connect (mp_layer_list->selectionModel (), SIGNAL (currentChanged (const QModelIndex &, const QModelIndex &)), this, SLOT (current_index_changed (const QModelIndex &))); + connect (mp_layer_list->selectionModel (), SIGNAL (selectionChanged (const QItemSelection &, const QItemSelection &)), this, SLOT (selection_changed (const QItemSelection &, const QItemSelection &))); mp_layer_list->setContextMenuPolicy (Qt::CustomContextMenu); connect (mp_layer_list, SIGNAL(customContextMenuRequested (const QPoint &)), this, SLOT (context_menu (const QPoint &))); mp_layer_list->header ()->hide (); @@ -1699,6 +1702,21 @@ LayerControlPanel::update_hidden_flags () m_do_update_content_dm (); } +void +LayerControlPanel::set_layer_visibility_follows_selection (bool f) +{ + if (f != m_layer_visibility_follows_selection) { + m_layer_visibility_follows_selection = f; + m_do_update_visibility_dm (); + } +} + +bool +LayerControlPanel::layer_visibility_follows_selection () +{ + return m_layer_visibility_follows_selection; +} + void LayerControlPanel::set_hide_empty_layers (bool f) { @@ -1847,6 +1865,29 @@ LayerControlPanel::do_update_hidden_flags () } } +void +LayerControlPanel::do_update_visibility () +{ + if (! m_layer_visibility_follows_selection) { + return; + } + + std::set sel_uints; + + QModelIndexList selected = mp_layer_list->selectionModel ()->selectedIndexes (); + for (QModelIndexList::const_iterator i = selected.begin (); i != selected.end (); ++i) { + if (i->column () == 0) { + sel_uints.insert (mp_model->iterator (*i).uint ()); + } + } + + for (lay::LayerPropertiesConstIterator l = mp_view->begin_layers (); ! l.at_end (); ++l) { + lay::LayerProperties props (*l); + props.set_visible (sel_uints.find (l.uint ()) != sel_uints.end () || l->has_children ()); + mp_view->set_properties (l, props); + } +} + void LayerControlPanel::do_update_content () { @@ -2108,6 +2149,14 @@ LayerControlPanel::current_index_changed (const QModelIndex &index) } } +void +LayerControlPanel::selection_changed (const QItemSelection &, const QItemSelection &) +{ + if (m_layer_visibility_follows_selection) { + m_do_update_visibility_dm (); + } +} + void LayerControlPanel::group_collapsed (const QModelIndex &index) { @@ -2362,6 +2411,8 @@ public: } menu_entries.push_back (lay::separator ("visibility_group", at)); + menu_entries.push_back (lay::config_menu_item ("visibility_follows_selection", at, tl::to_string (QObject::tr ("Visibility Follows Selection")), cfg_layer_visibility_follows_selection, "?")); + menu_entries.push_back (lay::menu_item ("cm_lv_hide", "hide", at, tl::to_string (QObject::tr ("Hide")))); menu_entries.push_back (lay::menu_item ("cm_lv_hide", "hide", at, tl::to_string (QObject::tr ("Hide")))); menu_entries.push_back (lay::menu_item ("cm_lv_hide_all", "hide_all", at, tl::to_string (QObject::tr ("Hide All")))); menu_entries.push_back (lay::menu_item ("cm_lv_show", "show", at, tl::to_string (QObject::tr ("Show")))); diff --git a/src/layui/layui/layLayerControlPanel.h b/src/layui/layui/layLayerControlPanel.h index f115b6bf0..7a3c1dc5b 100644 --- a/src/layui/layui/layLayerControlPanel.h +++ b/src/layui/layui/layLayerControlPanel.h @@ -188,6 +188,18 @@ public: */ bool hide_empty_layers (); + /** + * @brief Set the "layer visibility follows selection" flag + * + * If this flag is set, only the selected layers are made visible. + */ + void set_layer_visibility_follows_selection (bool f); + + /** + * @brief Get the "layer visibility follows selection" flag + */ + bool layer_visibility_follows_selection (); + /** * @brief Set the "test_shapes_in_view" flag * @@ -334,6 +346,7 @@ public slots: void group_collapsed (const QModelIndex &index); void group_expanded (const QModelIndex &index); void current_index_changed (const QModelIndex &index); + void selection_changed (const QItemSelection &, const QItemSelection &); void up_clicked (); void upup_clicked (); void down_clicked (); @@ -363,7 +376,9 @@ private: int m_oversampling; bool m_hrm; tl::DeferredMethod m_do_update_content_dm; + tl::DeferredMethod m_do_update_visibility_dm; bool m_no_stipples; + bool m_layer_visibility_follows_selection; QLabel *m_no_stipples_label; lay::DecoratedLineEdit *mp_search_edit_box; QAction *mp_case_sensitive; @@ -384,6 +399,7 @@ private: void signal_vp_changed (); void do_update_content (); + void do_update_visibility (); void do_update_hidden_flags (); void do_delete (); void do_copy (); diff --git a/src/layview/layview/layLayoutView_qt.cc b/src/layview/layview/layLayoutView_qt.cc index 43df835f3..3dfc11a62 100644 --- a/src/layview/layview/layLayoutView_qt.cc +++ b/src/layview/layview/layLayoutView_qt.cc @@ -960,6 +960,24 @@ LayoutView::configure (const std::string &name, const std::string &value) } return true; + } else if (name == cfg_layer_visibility_follows_selection) { + + bool f; + tl::from_string (value, f); + if (mp_control_panel) { + mp_control_panel->set_layer_visibility_follows_selection (f); + } + return true; + + } else if (name == cfg_test_shapes_in_view) { + + bool f; + tl::from_string (value, f); + if (mp_control_panel) { + mp_control_panel->set_test_shapes_in_view (f); + } + return true; + } else if (name == cfg_test_shapes_in_view) { bool f;