Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 1662 #1664

Merged
merged 3 commits into from
Mar 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 23 additions & 5 deletions src/db/db/dbTechnology.cc
Original file line number Diff line number Diff line change
Expand Up @@ -347,12 +347,10 @@ Technology::get_display_string () const
return d;
}

std::vector<double>
Technology::default_grid_list () const
static void
parse_default_grids (const std::string &s, std::vector<double> &grids, double &default_grid)
{
tl::Extractor ex (m_default_grids.c_str ());

std::vector<double> grids;
tl::Extractor ex (s.c_str ());

// convert the list of grids to a list of doubles
while (! ex.at_end ()) {
Expand All @@ -361,12 +359,32 @@ Technology::default_grid_list () const
break;
}
grids.push_back (g);
if (ex.test ("!")) {
default_grid = g;
}
ex.test (",");
}
}

std::vector<double>
Technology::default_grid_list () const
{
std::vector<double> grids;
double default_grid = 0.0;
parse_default_grids (m_default_grids, grids, default_grid);
return grids;
}

double
Technology::default_grid () const
{
std::vector<double> grids;
double default_grid = 0.0;
parse_default_grids (m_default_grids, grids, default_grid);
return default_grid;
}


tl::XMLElementList
Technology::xml_elements ()
{
Expand Down
9 changes: 9 additions & 0 deletions src/db/db/dbTechnology.h
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,15 @@ class DB_PUBLIC Technology
*/
std::vector<double> default_grid_list () const;

/**
* @brief Gets the default grid (strong grid), parsed from the list
*
* The default grid is the one marked with an exclamation mark in the
* grid list (e.g. "0.01!,0.02,0.05"). If there is not such default
* grid, this method returns zero.
*/
double default_grid () const;

/**
* @brief Sets the default default grids
*/
Expand Down
31 changes: 30 additions & 1 deletion src/db/db/gsiDeclDbTechnologies.cc
Original file line number Diff line number Diff line change
Expand Up @@ -136,18 +136,27 @@ gsi::Class<db::TechnologyComponent> technology_component_decl ("db", "Technology
DB_PUBLIC gsi::Class<db::TechnologyComponent> &decl_dbTechnologyComponent () { return technology_component_decl; }

static void
set_default_grid_list (db::Technology *tech, const std::vector<double> &grids)
set_default_grid_list2 (db::Technology *tech, const std::vector<double> &grids, double default_grid)
{
std::string r;
for (auto g = grids.begin (); g != grids.end (); ++g) {
if (! r.empty ()) {
r += ",";
}
r += tl::micron_to_string (*g);
if (db::coord_traits<db::DCoord>::equals (*g, default_grid)) {
r += "!";
}
}
tech->set_default_grids (r);
}

static void
set_default_grid_list (db::Technology *tech, const std::vector<double> &grids)
{
set_default_grid_list2 (tech, grids, 0.0);
}

gsi::Class<db::Technology> technology_decl ("db", "Technology",
gsi::method ("name", &db::Technology::name,
"@brief Gets the name of the technology"
Expand Down Expand Up @@ -238,12 +247,32 @@ gsi::Class<db::Technology> technology_decl ("db", "Technology",
"\n"
"This property has been introduced in version 0.28.17."
) +
gsi::method ("default_grid", &db::Technology::default_grid,
"@brief Gets the default grid\n"
"\n"
"The default grid is a specific one from the default grid list.\n"
"It indicates the one that is taken if the current grid is not matching one of "
"the default grids.\n"
"\n"
"To set the default grid, use \\set_default_grids.\n"
"\n"
"This property has been introduced in version 0.29."
) +
gsi::method_ext ("default_grids=", &set_default_grid_list, gsi::arg ("grids"),
"@brief Sets the default grids\n"
"If not empty, this list replaces the global grid list for this technology.\n"
"Note that this method will reset the default grid (see \\default_grid). Use "
"\\set_default_grids to set the default grids and the strong default one.\n"
"\n"
"This property has been introduced in version 0.28.17."
) +
gsi::method_ext ("set_default_grids", &set_default_grid_list2, gsi::arg ("grids"), gsi::arg ("default_grid", 0.0),
"@brief Sets the default grids and the strong default one\n"
"See \\default_grids and \\default_grid for a description of this property.\n"
"Note that the default grid has to be a member of the 'grids' array to become active.\n"
"\n"
"This method has been introduced in version 0.29."
) +
gsi::method ("layer_properties_file", &db::Technology::layer_properties_file,
"@brief Gets the path of the layer properties file\n"
"\n"
Expand Down
82 changes: 45 additions & 37 deletions src/lay/lay/MainConfigPage3.ui
Original file line number Diff line number Diff line change
@@ -1,67 +1,75 @@
<ui version="4.0" >
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainConfigPage3</class>
<widget class="QFrame" name="MainConfigPage3" >
<property name="geometry" >
<widget class="QFrame" name="MainConfigPage3">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>475</width>
<height>81</height>
<width>504</width>
<height>180</height>
</rect>
</property>
<property name="windowTitle" >
<property name="windowTitle">
<string>Settings</string>
</property>
<layout class="QVBoxLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" >
<layout class="QVBoxLayout">
<property name="spacing">
<number>6</number>
</property>
<property name="margin" stdset="0">
<number>9</number>
</property>
<item>
<widget class="QGroupBox" name="groupBox" >
<property name="title" >
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Default Grids</string>
</property>
<layout class="QGridLayout" >
<property name="margin" >
<layout class="QGridLayout">
<property name="margin" stdset="0">
<number>9</number>
</property>
<property name="spacing" >
<property name="spacing">
<number>6</number>
</property>
<item row="0" column="2" >
<widget class="QLabel" name="textLabel1_4" >
<property name="text" >
<item row="0" column="0">
<widget class="QLabel" name="textLabel1">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Grids for &quot;View&quot; menu</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="textLabel1_4">
<property name="text">
<string>µm (g1,g2,...)</string>
</property>
</widget>
</item>
<item row="0" column="1" >
<widget class="QLineEdit" name="grids_edit" >
<property name="sizePolicy" >
<sizepolicy>
<hsizetype>7</hsizetype>
<vsizetype>0</vsizetype>
<item row="0" column="1">
<widget class="QLineEdit" name="grids_edit">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="0" column="0" >
<widget class="QLabel" name="textLabel1" >
<property name="sizePolicy" >
<sizepolicy>
<hsizetype>5</hsizetype>
<vsizetype>5</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
<item row="1" column="0" colspan="3">
<widget class="QLabel" name="label">
<property name="text">
<string>&lt;html&gt;You can declare one grid a strong default to enforce an editing grid from this list. To do so, add an exclamation mark - e.g. &quot;0.01!,0.02,0.05&quot;.
&lt;br/&gt;&lt;b&gt;Note&lt;/b&gt;: the general default grids can be overridden by technology specific default grids.&lt;/html&gt;</string>
</property>
<property name="text" >
<string>Grids for "View" menu</string>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
Expand All @@ -70,7 +78,7 @@
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11" />
<layoutdefault spacing="6" margin="11"/>
<resources/>
<connections/>
</ui>
10 changes: 8 additions & 2 deletions src/lay/lay/TechBaseEditorPage.ui
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>625</width>
<height>587</height>
<height>616</height>
</rect>
</property>
<property name="windowTitle">
Expand Down Expand Up @@ -331,6 +331,9 @@ properties</string>
<property name="text">
<string>The default database unit is used as database unit for freshly created layouts</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="12" column="0" colspan="4">
Expand All @@ -352,7 +355,10 @@ properties</string>
<item row="11" column="1" colspan="3">
<widget class="QLabel" name="label_15">
<property name="text">
<string>These grids are available for selection from the &quot;View&quot; menu</string>
<string>These grids are available for selection from the &quot;View&quot; menu and will override the general ones. You can declare one grid as a strong default to enforce an editing grid from this list. To do so, add an exclamation mark to the grid - e.g. &quot;0.01!,0.02,0.05&quot;.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
Expand Down
2 changes: 1 addition & 1 deletion src/lay/lay/layMainConfigPages.cc
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ CustomizeMenuConfigPage::commit (lay::Dispatcher *dispatcher)
std::map<std::string, std::string>::iterator cb = m_current_bindings.find (kb->first);
if (cb != m_current_bindings.end ()) {
lay::Action *a = dispatcher->menu ()->action (kb->first);
if (cb->second != a->get_default_shortcut ()) {
if (a && cb->second != a->get_default_shortcut ()) {
if (cb->second.empty ()) {
kb->second = lay::Action::no_shortcut ();
} else {
Expand Down
44 changes: 41 additions & 3 deletions src/lay/lay/layMainWindow.cc
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,11 @@ MainWindow::MainWindow (QApplication *app, const char *name, bool undo_enabled)
m_disable_tab_selected (false),
m_exited (false),
dm_do_update_menu (this, &MainWindow::do_update_menu),
dm_do_update_grids (this, &MainWindow::do_update_grids),
dm_do_update_mru_menus (this, &MainWindow::do_update_mru_menus),
dm_exit (this, &MainWindow::exit),
m_grid_micron (0.001),
m_default_grid (0.0),
m_default_grids_updated (true),
m_new_layout_current_panel (false),
m_synchronized_views (false),
Expand Down Expand Up @@ -583,7 +585,7 @@ MainWindow::technology_changed ()
}

m_default_grids_updated = true; // potentially ...
dm_do_update_menu ();
dm_do_update_grids ();
}

void
Expand Down Expand Up @@ -939,7 +941,7 @@ MainWindow::config_finalize ()

// Update the default grids menu if necessary
if (m_default_grids_updated) {
dm_do_update_menu ();
dm_do_update_grids ();
}

// make the changes visible in the setup form if the form is visible
Expand Down Expand Up @@ -972,6 +974,7 @@ MainWindow::configure (const std::string &name, const std::string &value)

tl::Extractor ex (value.c_str ());
m_default_grids.clear ();
m_default_grid = 0.0;
m_default_grids_updated = true;

// convert the list of grids to a list of doubles
Expand All @@ -980,6 +983,9 @@ MainWindow::configure (const std::string &name, const std::string &value)
if (! ex.try_read (g)) {
break;
}
if (ex.test ("!")) {
m_default_grid = g;
}
m_default_grids.push_back (g);
ex.test (",");
}
Expand Down Expand Up @@ -4041,6 +4047,38 @@ MainWindow::menu_changed ()
dm_do_update_menu ();
}

void
MainWindow::do_update_grids ()
{
const std::vector<double> *grids = &m_default_grids;
double default_grid = m_default_grid;

std::vector<double> 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;
default_grid = tc->active_technology ()->default_grid ();
}
}

if (default_grid > db::epsilon) {
for (auto g = grids->begin (); g != grids->end (); ++g) {
if (db::coord_traits<db::DCoord>::equals (*g, m_grid_micron)) {
default_grid = 0.0;
break;
}
}
}

if (default_grid > db::epsilon) {
dispatcher ()->config_set (cfg_grid, default_grid);
}

do_update_menu ();
}

void
MainWindow::do_update_menu ()
{
Expand Down Expand Up @@ -4082,7 +4120,7 @@ MainWindow::do_update_menu ()

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);
ga->set_checked (db::coord_traits<db::DCoord>::equals (*g, m_grid_micron));

for (std::vector<std::string>::const_iterator t = group.begin (); t != group.end (); ++t) {
menu ()->insert_item (*t + ".end", name, ga);
Expand Down
Loading
Loading