From 9fd791a6039c98568bbcfe51934531f19eeae178 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sun, 14 Apr 2024 21:39:49 +0200 Subject: [PATCH 1/2] Implemented solution for issue-1666 ('Visibility Follows Selection' option for the 2.5d view) --- .../tools/view_25d/lay_plugin/D25View.ui | 8 +++++ .../tools/view_25d/lay_plugin/layD25View.cc | 29 ++++++++++++++++++- .../tools/view_25d/lay_plugin/layD25View.h | 3 ++ 3 files changed, 39 insertions(+), 1 deletion(-) diff --git a/src/plugins/tools/view_25d/lay_plugin/D25View.ui b/src/plugins/tools/view_25d/lay_plugin/D25View.ui index 35bc1cd49..6ca61f47b 100644 --- a/src/plugins/tools/view_25d/lay_plugin/D25View.ui +++ b/src/plugins/tools/view_25d/lay_plugin/D25View.ui @@ -619,6 +619,14 @@ See here for more information: <a href="int:/about/25d_view.xml"> Hide Selected + + + true + + + Visibility Follows Selection + + diff --git a/src/plugins/tools/view_25d/lay_plugin/layD25View.cc b/src/plugins/tools/view_25d/lay_plugin/layD25View.cc index 856392a7d..b842b4242 100644 --- a/src/plugins/tools/view_25d/lay_plugin/layD25View.cc +++ b/src/plugins/tools/view_25d/lay_plugin/layD25View.cc @@ -43,7 +43,8 @@ const double initial_elevation = 15.0; D25View::D25View (Dispatcher *root, LayoutViewBase *view) : lay::Browser (root, view, "d25_view"), dm_rerun_macro (this, &D25View::rerun_macro), - dm_fit (this, &D25View::fit) + dm_fit (this, &D25View::fit), + m_visibility_follows_selection (false) { mp_ui = new Ui::D25View (); mp_ui->setupUi (this); @@ -69,6 +70,8 @@ D25View::D25View (Dispatcher *root, LayoutViewBase *view) connect (mp_ui->hide_selected_action, SIGNAL (triggered()), this, SLOT (hide_selected_triggered())); connect (mp_ui->show_all_action, SIGNAL (triggered()), this, SLOT (show_all_triggered())); connect (mp_ui->show_selected_action, SIGNAL (triggered()), this, SLOT (show_selected_triggered())); + connect (mp_ui->visibility_follows_selection_action, SIGNAL (toggled(bool)), this, SLOT (visibility_follows_selection_changed(bool))); + connect (mp_ui->material_list, SIGNAL (itemSelectionChanged()), this, SLOT (update_visibility())); mp_ui->gl_stack->setCurrentIndex (2); mp_ui->rerun_button->setEnabled (false); @@ -89,6 +92,10 @@ D25View::D25View (Dispatcher *root, LayoutViewBase *view) mp_ui->material_list->addAction (mp_ui->show_selected_action); mp_ui->material_list->addAction (mp_ui->hide_all_action); mp_ui->material_list->addAction (mp_ui->hide_selected_action); + QAction *sep = new QAction (this); + sep->setSeparator (true); + mp_ui->material_list->addAction (sep); + mp_ui->material_list->addAction (mp_ui->visibility_follows_selection_action); mp_ui->material_list->setContextMenuPolicy (Qt::ActionsContextMenu); connect (mp_ui->material_list, SIGNAL (itemChanged(QListWidgetItem *)), this, SLOT (material_item_changed(QListWidgetItem *))); @@ -515,6 +522,26 @@ D25View::show_selected_triggered () } } +void +D25View::visibility_follows_selection_changed (bool checked) +{ + m_visibility_follows_selection = checked; + update_visibility (); +} + +void +D25View::update_visibility () +{ + if (! m_visibility_follows_selection) { + return; + } + + for (int i = 0; i < mp_ui->material_list->count (); ++i) { + QListWidgetItem *item = mp_ui->material_list->item (i); + item->setCheckState (item->isSelected () ? Qt::Checked : Qt::Unchecked); + } +} + void D25View::accept () { diff --git a/src/plugins/tools/view_25d/lay_plugin/layD25View.h b/src/plugins/tools/view_25d/lay_plugin/layD25View.h index 8e130b765..e7e23009d 100644 --- a/src/plugins/tools/view_25d/lay_plugin/layD25View.h +++ b/src/plugins/tools/view_25d/lay_plugin/layD25View.h @@ -95,12 +95,15 @@ private slots: void hide_selected_triggered (); void show_all_triggered (); void show_selected_triggered (); + void visibility_follows_selection_changed (bool checked); + void update_visibility (); private: Ui::D25View *mp_ui; tl::DeferredMethod dm_rerun_macro; tl::DeferredMethod dm_fit; std::string m_generator; + bool m_visibility_follows_selection; void cellviews_changed (); void layer_properties_changed (int); From 0eb3c22ec2b2beb12793c2c30e3d478e56e6d74e Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sun, 14 Apr 2024 21:42:59 +0200 Subject: [PATCH 2/2] Aligning menu layout of materials list with layer list --- src/plugins/tools/view_25d/lay_plugin/layD25View.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/plugins/tools/view_25d/lay_plugin/layD25View.cc b/src/plugins/tools/view_25d/lay_plugin/layD25View.cc index b842b4242..9dc853d6e 100644 --- a/src/plugins/tools/view_25d/lay_plugin/layD25View.cc +++ b/src/plugins/tools/view_25d/lay_plugin/layD25View.cc @@ -88,14 +88,14 @@ D25View::D25View (Dispatcher *root, LayoutViewBase *view) mp_ui->material_list->addAction (mp_ui->select_all_action); mp_ui->material_list->addAction (mp_ui->unselect_all_action); - mp_ui->material_list->addAction (mp_ui->show_all_action); - mp_ui->material_list->addAction (mp_ui->show_selected_action); - mp_ui->material_list->addAction (mp_ui->hide_all_action); - mp_ui->material_list->addAction (mp_ui->hide_selected_action); QAction *sep = new QAction (this); sep->setSeparator (true); mp_ui->material_list->addAction (sep); mp_ui->material_list->addAction (mp_ui->visibility_follows_selection_action); + mp_ui->material_list->addAction (mp_ui->hide_all_action); + mp_ui->material_list->addAction (mp_ui->hide_selected_action); + mp_ui->material_list->addAction (mp_ui->show_all_action); + mp_ui->material_list->addAction (mp_ui->show_selected_action); mp_ui->material_list->setContextMenuPolicy (Qt::ActionsContextMenu); connect (mp_ui->material_list, SIGNAL (itemChanged(QListWidgetItem *)), this, SLOT (material_item_changed(QListWidgetItem *)));