Merge pull request #1991 from KLayout/feature/configure-lazy-pcell-evaluation

Feature/configure lazy pcell evaluation
This commit is contained in:
Matthias Köfferlein 2025-03-02 22:20:04 +01:00 committed by GitHub
commit 2acbbffe19
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 96 additions and 15 deletions

View File

@ -62,6 +62,7 @@ std::string cfg_edit_hier_copy_mode ("edit-hier-copy-mode");
std::string cfg_edit_show_shapes_of_instances ("edit-show-shapes-of-instances");
std::string cfg_edit_max_shapes_of_instances ("edit-max-shapes-of-instances");
std::string cfg_edit_pcell_show_parameter_names ("edit-pcell-show-parameter-names");
std::string cfg_edit_pcell_lazy_eval_mode ("edit-pcell-lazy-eval-mode");
std::string cfg_edit_global_grid ("grid-micron");
std::string cfg_edit_combine_mode ("combine-mode");

View File

@ -70,6 +70,7 @@ extern EDT_PUBLIC std::string cfg_edit_inst_column_y;
extern EDT_PUBLIC std::string cfg_edit_inst_place_origin;
extern EDT_PUBLIC std::string cfg_edit_top_level_selection;
extern EDT_PUBLIC std::string cfg_edit_pcell_show_parameter_names;
extern EDT_PUBLIC std::string cfg_edit_pcell_lazy_eval_mode;
extern EDT_PUBLIC std::string cfg_edit_hier_copy_mode;
extern EDT_PUBLIC std::string cfg_edit_combine_mode;

View File

@ -154,10 +154,11 @@ static void set_value (const db::PCellParameterDeclaration &p, QWidget *widget,
}
PCellParametersPage::PCellParametersPage (QWidget *parent, lay::Dispatcher *dispatcher, bool dense)
: QFrame (parent), mp_dispatcher (dispatcher), m_dense (dense), m_show_parameter_names (false), dm_parameter_changed (this, &PCellParametersPage::do_parameter_changed)
: QFrame (parent), mp_dispatcher (dispatcher), m_dense (dense), m_show_parameter_names (false), m_lazy_evaluation (-1), dm_parameter_changed (this, &PCellParametersPage::do_parameter_changed)
{
if (mp_dispatcher) {
mp_dispatcher->config_get (cfg_edit_pcell_show_parameter_names, m_show_parameter_names);
mp_dispatcher->config_get (cfg_edit_pcell_lazy_eval_mode, m_lazy_evaluation);
}
init ();
@ -236,28 +237,99 @@ PCellParametersPage::init ()
error_frame_layout->setColumnStretch (2, 1);
QFrame *show_parameter_names_frame = new QFrame (this);
show_parameter_names_frame->setFrameShape (QFrame::NoFrame);
frame_layout->addWidget (show_parameter_names_frame, 3, 0, 1, 1);
QFrame *options_frame = new QFrame (this);
options_frame->setFrameShape (QFrame::NoFrame);
frame_layout->addWidget (options_frame, 3, 0, 1, 1);
QHBoxLayout *show_parameter_names_frame_layout = new QHBoxLayout (show_parameter_names_frame);
show_parameter_names_frame->setLayout (show_parameter_names_frame_layout);
QHBoxLayout *options_frame_layout = new QHBoxLayout (options_frame);
options_frame->setLayout (options_frame_layout);
if (m_dense) {
show_parameter_names_frame_layout->setContentsMargins (4, 4, 4, 4);
options_frame_layout->setContentsMargins (4, 4, 4, 4);
}
mp_show_parameter_names_cb = new QCheckBox (show_parameter_names_frame);
mp_show_parameter_names_cb->setText (tr ("Show parameter names"));
mp_show_parameter_names_cb->setChecked (m_show_parameter_names);
show_parameter_names_frame_layout->addWidget (mp_show_parameter_names_cb);
QToolButton *dot_menu_button = new QToolButton (options_frame);
dot_menu_button->setText (tr ("Options "));
dot_menu_button->setAutoRaise (true);
dot_menu_button->setPopupMode (QToolButton::InstantPopup);
dot_menu_button->setToolButtonStyle (Qt::ToolButtonTextOnly);
options_frame_layout->addWidget (dot_menu_button);
options_frame_layout->addStretch ();
connect (mp_show_parameter_names_cb, SIGNAL (clicked (bool)), this, SLOT (show_parameter_names (bool)));
QMenu *dot_menu = new QMenu (dot_menu_button);
dot_menu_button->setMenu (dot_menu);
mp_show_parameter_names_action = new QAction (dot_menu);
dot_menu->addAction (mp_show_parameter_names_action);
mp_show_parameter_names_action->setText (tr ("Show parameter names"));
mp_show_parameter_names_action->setCheckable (true);
mp_show_parameter_names_action->setChecked (m_show_parameter_names);
connect (mp_show_parameter_names_action, SIGNAL (triggered (bool)), this, SLOT (show_parameter_names (bool)));
QMenu *lazy_eval_menu = new QMenu (dot_menu);
lazy_eval_menu->setTitle (tr ("Lazy PCell evaluation"));
dot_menu->addMenu (lazy_eval_menu);
mp_auto_lazy_eval_action = new QAction (lazy_eval_menu);
lazy_eval_menu->addAction (mp_auto_lazy_eval_action);
mp_auto_lazy_eval_action->setText (tr ("As requested by PCell"));
mp_auto_lazy_eval_action->setCheckable (true);
mp_auto_lazy_eval_action->setChecked (m_lazy_evaluation < 0);
connect (mp_auto_lazy_eval_action, SIGNAL (triggered ()), this, SLOT (lazy_eval_mode_slot ()));
mp_always_lazy_eval_action = new QAction (lazy_eval_menu);
lazy_eval_menu->addAction (mp_always_lazy_eval_action);
mp_always_lazy_eval_action->setText (tr ("Always"));
mp_always_lazy_eval_action->setCheckable (true);
mp_always_lazy_eval_action->setChecked (m_lazy_evaluation > 0);
connect (mp_always_lazy_eval_action, SIGNAL (triggered ()), this, SLOT (lazy_eval_mode_slot ()));
mp_never_lazy_eval_action = new QAction (lazy_eval_menu);
lazy_eval_menu->addAction (mp_never_lazy_eval_action);
mp_never_lazy_eval_action->setText (tr ("Never"));
mp_never_lazy_eval_action->setCheckable (true);
mp_never_lazy_eval_action->setChecked (m_lazy_evaluation == 0);
connect (mp_never_lazy_eval_action, SIGNAL (triggered ()), this, SLOT (lazy_eval_mode_slot ()));
}
bool
PCellParametersPage::lazy_evaluation ()
{
if (m_lazy_evaluation < 0) {
return mp_pcell_decl.get () && mp_pcell_decl->wants_lazy_evaluation ();
} else {
return m_lazy_evaluation > 0;
}
}
void
PCellParametersPage::lazy_eval_mode_slot ()
{
if (sender () == mp_always_lazy_eval_action) {
lazy_eval_mode (1);
} else if (sender () == mp_never_lazy_eval_action) {
lazy_eval_mode (0);
} else if (sender () == mp_auto_lazy_eval_action) {
lazy_eval_mode (-1);
}
}
void
PCellParametersPage::lazy_eval_mode (int mode)
{
if (mode == m_lazy_evaluation) {
return;
}
mp_never_lazy_eval_action->setChecked (mode == 0);
mp_always_lazy_eval_action->setChecked (mode > 0);
mp_auto_lazy_eval_action->setChecked (mode < 0);
m_lazy_evaluation = mode;
if (mp_dispatcher) {
mp_dispatcher->config_set (cfg_edit_pcell_lazy_eval_mode, m_lazy_evaluation);
}
setup (mp_view, m_cv_index, mp_pcell_decl.get (), get_parameters ());
}
void
@ -268,7 +340,7 @@ PCellParametersPage::show_parameter_names (bool f)
}
m_show_parameter_names = f;
mp_show_parameter_names_cb->setChecked (f);
mp_show_parameter_names_action->setChecked (f);
if (mp_dispatcher) {
mp_dispatcher->config_set (cfg_edit_pcell_show_parameter_names, m_show_parameter_names);

View File

@ -144,10 +144,12 @@ signals:
public slots:
void show_parameter_names (bool f);
void lazy_eval_mode (int);
private slots:
void parameter_changed ();
void update_button_pressed ();
void lazy_eval_mode_slot ();
private:
lay::Dispatcher *mp_dispatcher;
@ -160,7 +162,10 @@ private:
QLabel *mp_changed_icon;
QToolButton *mp_update_button;
QFrame *mp_error_frame, *mp_update_frame;
QCheckBox *mp_show_parameter_names_cb;
QAction *mp_show_parameter_names_action;
QAction *mp_auto_lazy_eval_action;
QAction *mp_always_lazy_eval_action;
QAction *mp_never_lazy_eval_action;
tl::weak_ptr<db::PCellDeclaration> mp_pcell_decl;
std::vector<QWidget *> m_widgets;
std::vector<QLabel *> m_icon_widgets;
@ -168,6 +173,7 @@ private:
lay::LayoutViewBase *mp_view;
int m_cv_index;
bool m_dense, m_show_parameter_names;
int m_lazy_evaluation;
tl::DeferredMethod<PCellParametersPage> dm_parameter_changed;
db::ParameterStates m_current_states, m_initial_states;
db::ParameterStates m_states;

View File

@ -142,6 +142,7 @@ void get_inst_options (std::vector < std::pair<std::string, std::string> > &opti
options.push_back (std::pair<std::string, std::string> (cfg_edit_inst_column_y, "0.0"));
options.push_back (std::pair<std::string, std::string> (cfg_edit_inst_place_origin, "false"));
options.push_back (std::pair<std::string, std::string> (cfg_edit_pcell_show_parameter_names, "false"));
options.push_back (std::pair<std::string, std::string> (cfg_edit_pcell_lazy_eval_mode, "-1"));
options.push_back (std::pair<std::string, std::string> (cfg_edit_max_shapes_of_instances, "1000"));
options.push_back (std::pair<std::string, std::string> (cfg_edit_show_shapes_of_instances, "true"));
}