mirror of https://github.com/KLayout/klayout.git
WIP: cleanup of handling of multi-CV cases for editing (use and switch to active CV), reuse previous configuration on switch or use of layer in editor features.
This commit is contained in:
parent
a1feb676ee
commit
0da4f694ca
|
|
@ -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<lay::EditorOptionsPage *>::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
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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<std::vector<std::string> > 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<ConfigurationDescriptor>::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<ConfigurationDescriptor>::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
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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 ();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -31,6 +31,11 @@
|
|||
|
||||
#include <QWidget>
|
||||
|
||||
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);
|
||||
|
|
|
|||
Loading…
Reference in New Issue