mirror of https://github.com/KLayout/klayout.git
Bonus track: 'visibility follows selection'
This commit is contained in:
parent
7bdb1c6cd1
commit
2a5b019730
|
|
@ -43,6 +43,7 @@ public:
|
||||||
lay::ColorConverter cc;
|
lay::ColorConverter cc;
|
||||||
options.push_back (std::pair<std::string, std::string> (cfg_default_lyp_file, ""));
|
options.push_back (std::pair<std::string, std::string> (cfg_default_lyp_file, ""));
|
||||||
options.push_back (std::pair<std::string, std::string> (cfg_default_add_other_layers, "false"));
|
options.push_back (std::pair<std::string, std::string> (cfg_default_add_other_layers, "false"));
|
||||||
|
options.push_back (std::pair<std::string, std::string> (cfg_layer_visibility_follows_selection, "false"));
|
||||||
options.push_back (std::pair<std::string, std::string> (cfg_layers_always_show_source, "false"));
|
options.push_back (std::pair<std::string, std::string> (cfg_layers_always_show_source, "false"));
|
||||||
options.push_back (std::pair<std::string, std::string> (cfg_layers_always_show_ld, "true"));
|
options.push_back (std::pair<std::string, std::string> (cfg_layers_always_show_ld, "true"));
|
||||||
options.push_back (std::pair<std::string, std::string> (cfg_layers_always_show_layout_index, "false"));
|
options.push_back (std::pair<std::string, std::string> (cfg_layers_always_show_layout_index, "false"));
|
||||||
|
|
|
||||||
|
|
@ -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_array_border_instances ("draw-array-border-instances");
|
||||||
static const std::string cfg_default_lyp_file ("default-layer-properties");
|
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_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_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_ld ("layers-always-show-ld");
|
||||||
static const std::string cfg_layers_always_show_layout_index ("layers-always-show-layout-index");
|
static const std::string cfg_layers_always_show_layout_index ("layers-always-show-layout-index");
|
||||||
|
|
|
||||||
|
|
@ -213,7 +213,9 @@ LayerControlPanel::LayerControlPanel (lay::LayoutViewBase *view, db::Manager *ma
|
||||||
m_oversampling (1),
|
m_oversampling (1),
|
||||||
m_hrm (false),
|
m_hrm (false),
|
||||||
m_do_update_content_dm (this, &LayerControlPanel::do_update_content),
|
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));
|
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 (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, 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 (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);
|
mp_layer_list->setContextMenuPolicy (Qt::CustomContextMenu);
|
||||||
connect (mp_layer_list, SIGNAL(customContextMenuRequested (const QPoint &)), this, SLOT (context_menu (const QPoint &)));
|
connect (mp_layer_list, SIGNAL(customContextMenuRequested (const QPoint &)), this, SLOT (context_menu (const QPoint &)));
|
||||||
mp_layer_list->header ()->hide ();
|
mp_layer_list->header ()->hide ();
|
||||||
|
|
@ -1699,6 +1702,21 @@ LayerControlPanel::update_hidden_flags ()
|
||||||
m_do_update_content_dm ();
|
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
|
void
|
||||||
LayerControlPanel::set_hide_empty_layers (bool f)
|
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<size_t> 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
|
void
|
||||||
LayerControlPanel::do_update_content ()
|
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
|
void
|
||||||
LayerControlPanel::group_collapsed (const QModelIndex &index)
|
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::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", "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_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"))));
|
menu_entries.push_back (lay::menu_item ("cm_lv_show", "show", at, tl::to_string (QObject::tr ("Show"))));
|
||||||
|
|
|
||||||
|
|
@ -188,6 +188,18 @@ public:
|
||||||
*/
|
*/
|
||||||
bool hide_empty_layers ();
|
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
|
* @brief Set the "test_shapes_in_view" flag
|
||||||
*
|
*
|
||||||
|
|
@ -334,6 +346,7 @@ public slots:
|
||||||
void group_collapsed (const QModelIndex &index);
|
void group_collapsed (const QModelIndex &index);
|
||||||
void group_expanded (const QModelIndex &index);
|
void group_expanded (const QModelIndex &index);
|
||||||
void current_index_changed (const QModelIndex &index);
|
void current_index_changed (const QModelIndex &index);
|
||||||
|
void selection_changed (const QItemSelection &, const QItemSelection &);
|
||||||
void up_clicked ();
|
void up_clicked ();
|
||||||
void upup_clicked ();
|
void upup_clicked ();
|
||||||
void down_clicked ();
|
void down_clicked ();
|
||||||
|
|
@ -363,7 +376,9 @@ private:
|
||||||
int m_oversampling;
|
int m_oversampling;
|
||||||
bool m_hrm;
|
bool m_hrm;
|
||||||
tl::DeferredMethod<LayerControlPanel> m_do_update_content_dm;
|
tl::DeferredMethod<LayerControlPanel> m_do_update_content_dm;
|
||||||
|
tl::DeferredMethod<LayerControlPanel> m_do_update_visibility_dm;
|
||||||
bool m_no_stipples;
|
bool m_no_stipples;
|
||||||
|
bool m_layer_visibility_follows_selection;
|
||||||
QLabel *m_no_stipples_label;
|
QLabel *m_no_stipples_label;
|
||||||
lay::DecoratedLineEdit *mp_search_edit_box;
|
lay::DecoratedLineEdit *mp_search_edit_box;
|
||||||
QAction *mp_case_sensitive;
|
QAction *mp_case_sensitive;
|
||||||
|
|
@ -384,6 +399,7 @@ private:
|
||||||
void signal_vp_changed ();
|
void signal_vp_changed ();
|
||||||
|
|
||||||
void do_update_content ();
|
void do_update_content ();
|
||||||
|
void do_update_visibility ();
|
||||||
void do_update_hidden_flags ();
|
void do_update_hidden_flags ();
|
||||||
void do_delete ();
|
void do_delete ();
|
||||||
void do_copy ();
|
void do_copy ();
|
||||||
|
|
|
||||||
|
|
@ -960,6 +960,24 @@ LayoutView::configure (const std::string &name, const std::string &value)
|
||||||
}
|
}
|
||||||
return true;
|
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) {
|
} else if (name == cfg_test_shapes_in_view) {
|
||||||
|
|
||||||
bool f;
|
bool f;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue