diff --git a/src/edt/edt/edtPlugin.cc b/src/edt/edt/edtPlugin.cc index c404ffffa..c9e24b263 100644 --- a/src/edt/edt/edtPlugin.cc +++ b/src/edt/edt/edtPlugin.cc @@ -523,6 +523,23 @@ commit_recent (lay::LayoutViewBase *view) #endif } +void +config_recent_for_layer (lay::LayoutViewBase *view, const db::LayerProperties &lp, int cv_index) +{ +#if defined(HAVE_QT) + lay::EditorOptionsPages *eo_pages = view->editor_options_pages (); + if (!eo_pages) { + return; + } + + for (std::vector::const_iterator op = eo_pages->pages ().begin (); op != eo_pages->pages ().end (); ++op) { + if ((*op)->active ()) { + (*op)->config_recent_for_layer (view, lp, cv_index); + } + } +#endif +} + class PartialPluginDeclaration : public PluginDeclarationBase { diff --git a/src/edt/edt/edtPlugin.h b/src/edt/edt/edtPlugin.h index 230c55dce..3e1488c15 100644 --- a/src/edt/edt/edtPlugin.h +++ b/src/edt/edt/edtPlugin.h @@ -62,6 +62,11 @@ namespace edt * @brief Commits the current configuration for the recently used configuration list */ void commit_recent (lay::LayoutViewBase *view); + + /** + * @brief Configure attributes for the most-recent entry with the given layer + */ + void config_recent_for_layer (lay::LayoutViewBase *view, const db::LayerProperties &lp, int cv_index); } #endif diff --git a/src/edt/edt/edtRecentConfigurationPage.cc b/src/edt/edt/edtRecentConfigurationPage.cc index 672dc31e0..b0eb20414 100644 --- a/src/edt/edt/edtRecentConfigurationPage.cc +++ b/src/edt/edt/edtRecentConfigurationPage.cc @@ -141,7 +141,7 @@ lp_iter_from_string (lay::LayoutViewBase *view, const std::string &s) db::LayerProperties lp; tl::Extractor ex (s.c_str ()); lp.read (ex); - int cv_index = 0; + int cv_index = view->active_cellview_index (); if (ex.test ("@")) { ex.read (cv_index); } @@ -413,7 +413,7 @@ RecentConfigurationPage::item_clicked (QTreeWidgetItem *item) db::LayerProperties lp; tl::Extractor ex (v.c_str ()); lp.read (ex); - int cv_index = 0; + int cv_index = view ()->active_cellview_index (); if (ex.test ("@")) { ex.read (cv_index); } @@ -447,7 +447,7 @@ RecentConfigurationPage::commit_recent (lay::Dispatcher *root) int li = view ()->current_layer ()->layer_index (); if (cv.is_valid () && cv->layout ().is_valid_layer (li)) { s = cv->layout ().get_properties (li).to_string (); - if (cv_index > 0) { + if (cv_index != view ()->active_cellview_index ()) { s += "@" + tl::to_string (cv_index); } } @@ -482,6 +482,55 @@ RecentConfigurationPage::commit_recent (lay::Dispatcher *root) update_list (stored_values); } +void +RecentConfigurationPage::config_recent_for_layer (lay::Dispatcher *root, const db::LayerProperties &lp, int cv_index) +{ + std::list > stored_values = get_stored_values (); + + auto v = stored_values.begin (); + for ( ; v != stored_values.end (); ++v) { + + bool match = false; + auto vv = v->begin (); + for (std::list::const_iterator c = m_cfg.begin (); c != m_cfg.end () && ! match && vv != v->end (); ++c, ++vv) { + + if (c->rendering == Layer) { + + // "getting" a layer means making it current + db::LayerProperties lp_stored; + tl::Extractor ex (vv->c_str ()); + lp_stored.read (ex); + int cv_index_stored = view ()->active_cellview_index (); + if (ex.test ("@")) { + ex.read (cv_index_stored); + } + + match = (lp.log_equal (lp_stored) && (cv_index < 0 || cv_index_stored == cv_index)); + + } + + } + + if (match) { + break; + } + + } + + if (v != stored_values.end ()) { + + auto vv = v->begin (); + for (std::list::const_iterator c = m_cfg.begin (); c != m_cfg.end () && vv != v->end (); ++c, ++vv) { + if (c->rendering != Layer) { + root->config_set (c->cfg_name, *vv); + } + } + + root->config_end (); + + } +} + } #endif diff --git a/src/edt/edt/edtRecentConfigurationPage.h b/src/edt/edt/edtRecentConfigurationPage.h index 7e993a36f..8d3045cfd 100644 --- a/src/edt/edt/edtRecentConfigurationPage.h +++ b/src/edt/edt/edtRecentConfigurationPage.h @@ -37,6 +37,11 @@ namespace lay class LayoutViewBase; } +namespace db +{ + class LayerProperties; +} + namespace edt { @@ -92,6 +97,7 @@ public: virtual void apply (lay::Dispatcher * /*root*/) { } virtual void setup (lay::Dispatcher * /*root*/) { } virtual void commit_recent (lay::Dispatcher *root); + virtual void config_recent_for_layer (lay::Dispatcher *root, const db::LayerProperties &lp, int cv_index); private slots: void item_clicked (QTreeWidgetItem *item); diff --git a/src/edt/edt/edtServiceImpl.cc b/src/edt/edt/edtServiceImpl.cc index 2e6bbf95e..70ed8b900 100644 --- a/src/edt/edt/edtServiceImpl.cc +++ b/src/edt/edt/edtServiceImpl.cc @@ -140,15 +140,19 @@ ShapeEditService::get_edit_layer () } } + if (cv.cell ()->is_proxy ()) { + throw tl::Exception (tl::to_string (tr ("Cannot put a shape into a PCell or library cell"))); + } + m_layer = (unsigned int) layer; m_cv_index = (unsigned int) cv_index; m_trans = (cl->trans ().front () * db::CplxTrans (cv->layout ().dbu ()) * cv.context_trans ()).inverted (); mp_layout = &(cv->layout ()); mp_cell = cv.cell (); - if (mp_cell->is_proxy ()) { - throw tl::Exception (tl::to_string (tr ("Cannot put a shape into a PCell or library cell"))); - } + // fetches the last configuration for the given layer + view ()->set_active_cellview_index (cv_index); + edt::config_recent_for_layer (view (), cv->layout ().get_properties ((unsigned int) layer), cv_index); } void @@ -213,6 +217,10 @@ ShapeEditService::update_edit_layer (const lay::LayerPropertiesConstIterator &cl mp_layout = &(cv->layout ()); mp_cell = cv.cell (); + // fetches the last configuration for the given layer + view ()->set_active_cellview_index (cv_index); + edt::config_recent_for_layer (view (), cv->layout ().get_properties ((unsigned int) layer), cv_index); + current_layer_changed (); } diff --git a/src/layui/layui/layEditorOptionsPage.h b/src/layui/layui/layEditorOptionsPage.h index 08598784e..c54f4e31a 100644 --- a/src/layui/layui/layEditorOptionsPage.h +++ b/src/layui/layui/layEditorOptionsPage.h @@ -31,6 +31,11 @@ #include +namespace db +{ + class LayerProperties; +} + namespace lay { @@ -58,6 +63,7 @@ public: virtual void apply (lay::Dispatcher * /*root*/) { } virtual void setup (lay::Dispatcher * /*root*/) { } virtual void commit_recent (lay::Dispatcher * /*root*/) { } + virtual void config_recent_for_layer (lay::Dispatcher * /*root*/, const db::LayerProperties & /*lp*/, int /*cv_index*/) { } bool active () const { return m_active; } void activate (bool active);