Skip to content

Commit

Permalink
Merge pull request KLayout#1686 from KLayout/feature/issue-1666
Browse files Browse the repository at this point in the history
Feature/issue 1666
  • Loading branch information
klayoutmatthias authored Apr 17, 2024
2 parents 6bc314a + 0eb3c22 commit 840beea
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 3 deletions.
8 changes: 8 additions & 0 deletions src/plugins/tools/view_25d/lay_plugin/D25View.ui
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,14 @@ See here for more information: <a href="int:/about/25d_view.xml"&gt
<string>Hide Selected</string>
</property>
</action>
<action name="visibility_follows_selection_action">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Visibility Follows Selection</string>
</property>
</action>
</widget>
<customwidgets>
<customwidget>
Expand Down
33 changes: 30 additions & 3 deletions src/plugins/tools/view_25d/lay_plugin/layD25View.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -85,10 +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);
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 *)));
Expand Down Expand Up @@ -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 ()
{
Expand Down
3 changes: 3 additions & 0 deletions src/plugins/tools/view_25d/lay_plugin/layD25View.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<D25View> dm_rerun_macro;
tl::DeferredMethod<D25View> dm_fit;
std::string m_generator;
bool m_visibility_follows_selection;

void cellviews_changed ();
void layer_properties_changed (int);
Expand Down

0 comments on commit 840beea

Please sign in to comment.