From dd9d2bfddd9677c340aba1ea6b2a9676b95d684c Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sat, 3 Feb 2024 22:42:21 +0100 Subject: [PATCH] First proposal for feature --- src/db/db/dbTechnology.cc | 23 ++ src/db/db/dbTechnology.h | 25 ++ src/lay/lay/TechBaseEditorPage.ui | 342 +++++++++++++++---------- src/lay/lay/layMainWindow.cc | 113 +++++--- src/lay/lay/layMainWindow.h | 1 + src/lay/lay/layTechSetupDialog.cc | 2 + src/lay/lay/layTechnologyController.cc | 15 +- 7 files changed, 340 insertions(+), 181 deletions(-) diff --git a/src/db/db/dbTechnology.cc b/src/db/db/dbTechnology.cc index 2801b29e10..2910fbbabd 100644 --- a/src/db/db/dbTechnology.cc +++ b/src/db/db/dbTechnology.cc @@ -283,6 +283,7 @@ Technology::~Technology () Technology::Technology (const Technology &d) : tl::Object (), m_name (d.m_name), m_description (d.m_description), m_group (d.m_group), m_grain_name (d.m_grain_name), m_dbu (d.m_dbu), + m_default_grids (d.m_default_grids), m_explicit_base_path (d.m_explicit_base_path), m_default_base_path (d.m_default_base_path), m_load_layout_options (d.m_load_layout_options), m_save_layout_options (d.m_save_layout_options), @@ -303,6 +304,7 @@ Technology &Technology::operator= (const Technology &d) m_group = d.m_group; m_grain_name = d.m_grain_name; m_dbu = d.m_dbu; + m_default_grids = d.m_default_grids; m_default_base_path = d.m_default_base_path; m_explicit_base_path = d.m_explicit_base_path; m_load_layout_options = d.m_load_layout_options; @@ -345,6 +347,26 @@ Technology::get_display_string () const return d; } +std::vector +Technology::default_grid_list () const +{ + tl::Extractor ex (m_default_grids.c_str ()); + + std::vector grids; + + // convert the list of grids to a list of doubles + while (! ex.at_end ()) { + double g = 0.0; + if (! ex.try_read (g)) { + break; + } + grids.push_back (g); + ex.test (","); + } + + return grids; +} + tl::XMLElementList Technology::xml_elements () { @@ -353,6 +375,7 @@ Technology::xml_elements () tl::make_member (&Technology::description, &Technology::set_description, "description") + tl::make_member (&Technology::group, &Technology::set_group, "group") + tl::make_member (&Technology::dbu, &Technology::set_dbu, "dbu") + + tl::make_member (&Technology::default_grids, &Technology::set_default_grids, "default-grids") + tl::make_member (&Technology::explicit_base_path, &Technology::set_explicit_base_path, "base-path") + tl::make_member (&Technology::default_base_path, &Technology::set_default_base_path, "original-base-path") + tl::make_member (&Technology::layer_properties_file, &Technology::set_layer_properties_file, "layer-properties_file") + diff --git a/src/db/db/dbTechnology.h b/src/db/db/dbTechnology.h index 2f8c88d760..e06ddca14d 100644 --- a/src/db/db/dbTechnology.h +++ b/src/db/db/dbTechnology.h @@ -467,6 +467,30 @@ class DB_PUBLIC Technology } } + /** + * @brief Gets the default grids + */ + const std::string &default_grids () const + { + return m_default_grids; + } + + /** + * @brief Gets the default grids, parsed as a list of double values + */ + std::vector default_grid_list () const; + + /** + * @brief Sets the default default grids + */ + void set_default_grids (const std::string &default_grids) + { + if (default_grids != m_default_grids) { + m_default_grids = default_grids; + technology_changed (); + } + } + /** * @brief Gets the layer properties file path (empty if none is specified) */ @@ -650,6 +674,7 @@ class DB_PUBLIC Technology std::string m_name, m_description, m_group; std::string m_grain_name; double m_dbu; + std::string m_default_grids; std::string m_explicit_base_path, m_default_base_path; db::LoadLayoutOptions m_load_layout_options; db::SaveLayoutOptions m_save_layout_options; diff --git a/src/lay/lay/TechBaseEditorPage.ui b/src/lay/lay/TechBaseEditorPage.ui index b2ab513756..668e04ffee 100644 --- a/src/lay/lay/TechBaseEditorPage.ui +++ b/src/lay/lay/TechBaseEditorPage.ui @@ -6,57 +6,177 @@ 0 0 - 604 - 498 + 625 + 587 Form - - + + Qt::Horizontal - - + + Qt::Horizontal - - + + + + + - Base path + Database +unit + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - + + + + Qt::Horizontal + + + + + - Description + ... - - + + + + QAbstractItemView::NoSelection + + + + + - Name + (Use the rename button to change this) - - + + + + + - Database -unit + The base path is used to locate auxiliary files if those are specified with a relative path. If none is specified, the default path is used. The default path is the one from which a technology was imported. - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + true + + + + + + + QFrame::NoFrame + + + QFrame::Raised + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + + + + + µm + + + + + + + + + + + + + (Used for creating tech groups) + + + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 5 + + + + + + + + Technology +specific +libraries + + + + + + + Grids + + + + + + + Base path + + + + + + + Description @@ -74,6 +194,53 @@ unit + + + QFrame::NoFrame + + + QFrame::Raised + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + + + µm (g1,g2,...) + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + Load layer properties file @@ -127,10 +294,7 @@ unit - - - - + Layer @@ -141,6 +305,13 @@ properties + + + + Name + + + @@ -148,75 +319,13 @@ properties - - - - (Use the rename button to change this) - - - - - + + - ... - - - - - - - Qt::Horizontal - - - - - - - QAbstractItemView::NoSelection + Group - - - - QFrame::NoFrame - - - QFrame::Raised - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - 0 - 0 - - - - - - - - µm - - - - - - @@ -224,7 +333,7 @@ properties - + Qt::Vertical @@ -240,55 +349,10 @@ properties - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - The base path is used to locate auxiliary files if those are specified with a relative path. If none is specified, the default path is used. The default path is the one from which a technology was imported. - - - true - - - - - - - - + + - Technology -specific -libraries - - - - - - - - - - Group - - - - - - - (Used for creating tech groups) + These grids are available for selection from the "View" menu diff --git a/src/lay/lay/layMainWindow.cc b/src/lay/lay/layMainWindow.cc index 1adfb3bb7c..0e705c3e9f 100644 --- a/src/lay/lay/layMainWindow.cc +++ b/src/lay/lay/layMainWindow.cc @@ -458,6 +458,12 @@ MainWindow::MainWindow (QApplication *app, const char *name, bool undo_enabled) connect (&lay::LayoutHandle::file_watcher (), SIGNAL (fileChanged (const QString &)), this, SLOT (file_changed (const QString &))); connect (&lay::LayoutHandle::file_watcher (), SIGNAL (fileRemoved (const QString &)), this, SLOT (file_removed (const QString &))); + lay::TechnologyController *tc = lay::TechnologyController::instance (); + if (tc) { + connect (tc, SIGNAL (active_technology_changed ()), this, SLOT (technology_changed ())); + connect (tc, SIGNAL (technologies_edited ()), this, SLOT (technology_changed ())); + } + // make the main window accept drops setAcceptDrops (true); } @@ -555,6 +561,31 @@ MainWindow::init_menu () } } +static std::string tech_string_from_name (const std::string &tn) +{ + if (tn.empty ()) { + return tl::to_string (QObject::tr ("(Default)")); + } else { + return tn; + } +} + +void +MainWindow::technology_changed () +{ + lay::TechnologyController *tc = lay::TechnologyController::instance (); + if (tc) { + if (tc->active_technology ()) { + tech_message (tech_string_from_name (tc->active_technology ()->name ())); + } else { + tech_message (std::string ()); + } + } + + m_default_grids_updated = true; // potentially ... + dm_do_update_menu (); +} + void MainWindow::dock_widget_visibility_changed (bool visible) { @@ -908,36 +939,7 @@ MainWindow::config_finalize () // Update the default grids menu if necessary if (m_default_grids_updated) { - - m_default_grids_updated = false; - - std::vector group = menu ()->group ("default_grids_group"); - - for (std::vector::const_iterator t = group.begin (); t != group.end (); ++t) { - std::vector items = menu ()->items (*t); - for (std::vector::const_iterator i = items.begin (); i != items.end (); ++i) { - menu ()->delete_item (*i); - } - } - - int i = 1; - for (std::vector::const_iterator g = m_default_grids.begin (); g != m_default_grids.end (); ++g, ++i) { - - std::string name = "default_grid_" + tl::to_string (i); - - lay::Action *ga = new lay::ConfigureAction (tl::to_string (*g) + tl::to_string (QObject::tr (" um")), cfg_grid, tl::to_string (*g)); - ga->set_checkable (true); - ga->set_checked (fabs (*g - m_grid_micron) < 1e-10); - - for (std::vector::const_iterator t = group.begin (); t != group.end (); ++t) { - menu ()->insert_item (*t + ".end", name, ga); - } - - } - - // re-apply key bindings for the default grids - apply_key_bindings (); - + dm_do_update_menu (); } // make the changes visible in the setup form if the form is visible @@ -4038,6 +4040,57 @@ MainWindow::menu_changed () void MainWindow::do_update_menu () { + if (m_default_grids_updated) { + + m_default_grids_updated = false; + + const std::vector *grids = &m_default_grids; + std::vector tech_grids; + lay::TechnologyController *tc = lay::TechnologyController::instance (); + if (tc && tc->active_technology ()) { + tech_grids = tc->active_technology ()->default_grid_list (); + if (! tech_grids.empty ()) { + grids = &tech_grids; + } + } + + std::vector group = menu ()->group ("default_grids_group"); + + for (std::vector::const_iterator t = group.begin (); t != group.end (); ++t) { + std::vector items = menu ()->items (*t); + for (std::vector::const_iterator i = items.begin (); i != items.end (); ++i) { + menu ()->delete_item (*i); + } + } + + int i = 1; + for (std::vector::const_iterator g = grids->begin (); g != grids->end (); ++g, ++i) { + + std::string name = "default_grid_" + tl::to_string (i); + + std::string gs; + if (*g < 0.4) { + // pick nm units below 400nm + gs = tl::to_string (*g * 1000.0) + tl::to_string (QObject::tr (" nm")); + } else { + gs = tl::to_string (*g) + tl::to_string (QObject::tr (" um")); + } + + lay::Action *ga = new lay::ConfigureAction (gs, cfg_grid, tl::to_string (*g)); + ga->set_checkable (true); + ga->set_checked (fabs (*g - m_grid_micron) < 1e-10); + + for (std::vector::const_iterator t = group.begin (); t != group.end (); ++t) { + menu ()->insert_item (*t + ".end", name, ga); + } + + } + + // re-apply key bindings for the default grids + apply_key_bindings (); + + } + menu ()->build (menuBar (), mp_tool_bar); lay::GuiApplication *app = dynamic_cast (qApp); if (app) { diff --git a/src/lay/lay/layMainWindow.h b/src/lay/lay/layMainWindow.h index a0e9e6d62d..326bc3c07d 100644 --- a/src/lay/lay/layMainWindow.h +++ b/src/lay/lay/layMainWindow.h @@ -697,6 +697,7 @@ protected slots: void message_timer (); void edits_enabled_changed (); void menu_needs_update (); + void technology_changed (); void file_changed_timer (); void file_changed (const QString &path); diff --git a/src/lay/lay/layTechSetupDialog.cc b/src/lay/lay/layTechSetupDialog.cc index 4bcaa2ec36..b690ce8c1b 100644 --- a/src/lay/lay/layTechSetupDialog.cc +++ b/src/lay/lay/layTechSetupDialog.cc @@ -114,6 +114,7 @@ TechBaseEditorPage::setup () mp_ui->desc_le->setText (tl::to_qstring (tech ()->description ())); mp_ui->group_le->setText (tl::to_qstring (tech ()->group ())); mp_ui->dbu_le->setText (tl::to_qstring (tl::to_string (tech ()->dbu ()))); + mp_ui->grids_le->setText (tl::to_qstring (tl::to_string (tech ()->default_grids ()))); mp_ui->desc_le->setEnabled (! tech ()->name ().empty ()); mp_ui->base_path_le->setText (tl::to_qstring (tech ()->explicit_base_path ())); #if QT_VERSION >= 0x040700 @@ -164,6 +165,7 @@ TechBaseEditorPage::commit () tech ()->set_description (tl::to_string (mp_ui->desc_le->text ())); tech ()->set_group (tl::to_string (mp_ui->group_le->text ())); tech ()->set_explicit_base_path (tl::to_string (mp_ui->base_path_le->text ())); + tech ()->set_default_grids (tl::to_string (mp_ui->grids_le->text ())); double d = 0.001; tl::from_string_ext (tl::to_string (mp_ui->dbu_le->text ()), d); diff --git a/src/lay/lay/layTechnologyController.cc b/src/lay/lay/layTechnologyController.cc index 169afa3839..8e493de2d7 100644 --- a/src/lay/lay/layTechnologyController.cc +++ b/src/lay/lay/layTechnologyController.cc @@ -40,7 +40,7 @@ namespace lay static const std::string cfg_tech_editor_window_state ("tech-editor-window-state"); -std::string tech_string_from_name (const std::string &tn) +static std::string tech_string_from_name (const std::string &tn) { if (tn.empty ()) { return tl::to_string (QObject::tr ("(Default)")); @@ -179,21 +179,12 @@ TechnologyController::update_active_technology () } - mp_active_technology = active_tech; - - if (mp_mw) { - if (active_tech) { - mp_mw->tech_message (tech_string_from_name (active_tech->name ())); - } else { - mp_mw->tech_message (std::string ()); - } - } - if (mp_active_technology != active_tech) { + mp_active_technology = active_tech; emit active_technology_changed (); } -#if 0 +#if 0 // Hint with this implementation, the current technology follows the current layout. // Although that's a nice way to display the current technology, it's pretty confusing lay::Dispatcher *pr = mp_plugin_root;