First proposal for feature

This commit is contained in:
Matthias Koefferlein 2024-02-03 22:42:21 +01:00
parent 1e51cf6901
commit dd9d2bfddd
7 changed files with 343 additions and 184 deletions

View File

@ -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<double>
Technology::default_grid_list () const
{
tl::Extractor ex (m_default_grids.c_str ());
std::vector<double> 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") +

View File

@ -467,6 +467,30 @@ public:
}
}
/**
* @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<double> 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 @@ private:
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;

View File

@ -6,25 +6,163 @@
<rect>
<x>0</x>
<y>0</y>
<width>604</width>
<height>498</height>
<width>625</width>
<height>587</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="11" column="0" colspan="4">
<item row="6" column="0" colspan="4">
<widget class="Line" name="line_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="3" column="0" colspan="4">
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="group_le"/>
</item>
<item row="7" column="0" rowspan="2">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Database
unit</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
</widget>
</item>
<item row="14" column="0" colspan="4">
<widget class="Line" name="line_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="6" column="0" colspan="4">
<widget class="Line" name="line_2">
<item row="4" column="3">
<widget class="QToolButton" name="browse_pb">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item row="15" column="1" rowspan="2" colspan="3">
<widget class="QListWidget" name="libs_lw">
<property name="selectionMode">
<enum>QAbstractItemView::NoSelection</enum>
</property>
</widget>
</item>
<item row="0" column="2" colspan="2">
<widget class="QLabel" name="label_5">
<property name="text">
<string>(Use the rename button to change this)</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="desc_le"/>
</item>
<item row="5" column="1" colspan="3">
<widget class="QLabel" name="label_3">
<property name="text">
<string>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.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="7" column="1" colspan="3">
<widget class="QFrame" name="frame">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLineEdit" name="dbu_le">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_9">
<property name="text">
<string>µm</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="4" column="1" colspan="2">
<widget class="QLineEdit" name="base_path_le"/>
</item>
<item row="2" column="2" colspan="2">
<widget class="QLabel" name="label_12">
<property name="text">
<string>(Used for creating tech groups)</string>
</property>
</widget>
</item>
<item row="9" column="0" colspan="4">
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>5</height>
</size>
</property>
</spacer>
</item>
<item row="15" column="0">
<widget class="QLabel" name="libs_lbl">
<property name="text">
<string>Technology
specific
libraries</string>
</property>
</widget>
</item>
<item row="10" column="0">
<widget class="QLabel" name="label_13">
<property name="text">
<string>Grids</string>
</property>
</widget>
</item>
@ -42,24 +180,6 @@
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Name</string>
</property>
</widget>
</item>
<item row="7" column="0" rowspan="2">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Database
unit</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
</widget>
</item>
<item row="1" column="2" colspan="2">
<spacer>
<property name="orientation">
@ -74,6 +194,53 @@ unit</string>
</spacer>
</item>
<item row="10" column="1" colspan="3">
<widget class="QFrame" name="frame_2">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLineEdit" name="grids_le"/>
</item>
<item>
<widget class="QLabel" name="label_14">
<property name="text">
<string>µm (g1,g2,...)</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="16" column="0">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="13" column="1" colspan="3">
<widget class="QGroupBox" name="lyp_grp">
<property name="title">
<string>Load layer properties file</string>
@ -127,10 +294,7 @@ unit</string>
</layout>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="desc_le"/>
</item>
<item row="10" column="0">
<item row="13" column="0">
<widget class="QLabel" name="label_10">
<property name="text">
<string>Layer
@ -141,6 +305,13 @@ properties</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Name</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="name_le">
<property name="enabled">
@ -148,75 +319,13 @@ properties</string>
</property>
</widget>
</item>
<item row="0" column="2" colspan="2">
<widget class="QLabel" name="label_5">
<item row="2" column="0">
<widget class="QLabel" name="label_11">
<property name="text">
<string>(Use the rename button to change this)</string>
<string>Group</string>
</property>
</widget>
</item>
<item row="4" column="3">
<widget class="QToolButton" name="browse_pb">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item row="3" column="0" colspan="4">
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="12" column="1" rowspan="2" colspan="3">
<widget class="QListWidget" name="libs_lw">
<property name="selectionMode">
<enum>QAbstractItemView::NoSelection</enum>
</property>
</widget>
</item>
<item row="7" column="1" colspan="3">
<widget class="QFrame" name="frame">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLineEdit" name="dbu_le">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_9">
<property name="text">
<string>µm</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="8" column="1" colspan="3">
<widget class="QLabel" name="label_8">
<property name="text">
@ -224,7 +333,7 @@ properties</string>
</property>
</widget>
</item>
<item row="9" column="0" colspan="4">
<item row="12" column="0" colspan="4">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
@ -240,55 +349,10 @@ properties</string>
</property>
</spacer>
</item>
<item row="13" column="0">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="5" column="1" colspan="3">
<widget class="QLabel" name="label_3">
<item row="11" column="1" colspan="3">
<widget class="QLabel" name="label_15">
<property name="text">
<string>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.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="4" column="1" colspan="2">
<widget class="QLineEdit" name="base_path_le"/>
</item>
<item row="12" column="0">
<widget class="QLabel" name="libs_lbl">
<property name="text">
<string>Technology
specific
libraries</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="group_le"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_11">
<property name="text">
<string>Group</string>
</property>
</widget>
</item>
<item row="2" column="2" colspan="2">
<widget class="QLabel" name="label_12">
<property name="text">
<string>(Used for creating tech groups)</string>
<string>These grids are available for selection from the &quot;View&quot; menu</string>
</property>
</widget>
</item>

View File

@ -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<std::string> group = menu ()->group ("default_grids_group");
for (std::vector<std::string>::const_iterator t = group.begin (); t != group.end (); ++t) {
std::vector<std::string> items = menu ()->items (*t);
for (std::vector<std::string>::const_iterator i = items.begin (); i != items.end (); ++i) {
menu ()->delete_item (*i);
}
}
int i = 1;
for (std::vector<double>::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<std::string>::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<double> *grids = &m_default_grids;
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;
}
}
std::vector<std::string> group = menu ()->group ("default_grids_group");
for (std::vector<std::string>::const_iterator t = group.begin (); t != group.end (); ++t) {
std::vector<std::string> items = menu ()->items (*t);
for (std::vector<std::string>::const_iterator i = items.begin (); i != items.end (); ++i) {
menu ()->delete_item (*i);
}
}
int i = 1;
for (std::vector<double>::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<std::string>::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<lay::GuiApplication *> (qApp);
if (app) {

View File

@ -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);

View File

@ -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);

View File

@ -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,17 +179,8 @@ 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 ();
}