Skip to content

Commit 2acbbff

Browse files
Merge pull request #1991 from KLayout/feature/configure-lazy-pcell-evaluation
Feature/configure lazy pcell evaluation
2 parents 99008f4 + 50ab169 commit 2acbbff

File tree

5 files changed

+97
-16
lines changed

5 files changed

+97
-16
lines changed

src/edt/edt/edtConfig.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ std::string cfg_edit_hier_copy_mode ("edit-hier-copy-mode");
6262
std::string cfg_edit_show_shapes_of_instances ("edit-show-shapes-of-instances");
6363
std::string cfg_edit_max_shapes_of_instances ("edit-max-shapes-of-instances");
6464
std::string cfg_edit_pcell_show_parameter_names ("edit-pcell-show-parameter-names");
65+
std::string cfg_edit_pcell_lazy_eval_mode ("edit-pcell-lazy-eval-mode");
6566
std::string cfg_edit_global_grid ("grid-micron");
6667
std::string cfg_edit_combine_mode ("combine-mode");
6768

src/edt/edt/edtConfig.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ extern EDT_PUBLIC std::string cfg_edit_inst_column_y;
7070
extern EDT_PUBLIC std::string cfg_edit_inst_place_origin;
7171
extern EDT_PUBLIC std::string cfg_edit_top_level_selection;
7272
extern EDT_PUBLIC std::string cfg_edit_pcell_show_parameter_names;
73+
extern EDT_PUBLIC std::string cfg_edit_pcell_lazy_eval_mode;
7374
extern EDT_PUBLIC std::string cfg_edit_hier_copy_mode;
7475
extern EDT_PUBLIC std::string cfg_edit_combine_mode;
7576

src/edt/edt/edtPCellParametersPage.cc

Lines changed: 87 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -154,10 +154,11 @@ static void set_value (const db::PCellParameterDeclaration &p, QWidget *widget,
154154
}
155155

156156
PCellParametersPage::PCellParametersPage (QWidget *parent, lay::Dispatcher *dispatcher, bool dense)
157-
: QFrame (parent), mp_dispatcher (dispatcher), m_dense (dense), m_show_parameter_names (false), dm_parameter_changed (this, &PCellParametersPage::do_parameter_changed)
157+
: 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)
158158
{
159159
if (mp_dispatcher) {
160160
mp_dispatcher->config_get (cfg_edit_pcell_show_parameter_names, m_show_parameter_names);
161+
mp_dispatcher->config_get (cfg_edit_pcell_lazy_eval_mode, m_lazy_evaluation);
161162
}
162163

163164
init ();
@@ -236,28 +237,99 @@ PCellParametersPage::init ()
236237

237238
error_frame_layout->setColumnStretch (2, 1);
238239

239-
QFrame *show_parameter_names_frame = new QFrame (this);
240-
show_parameter_names_frame->setFrameShape (QFrame::NoFrame);
241-
frame_layout->addWidget (show_parameter_names_frame, 3, 0, 1, 1);
240+
QFrame *options_frame = new QFrame (this);
241+
options_frame->setFrameShape (QFrame::NoFrame);
242+
frame_layout->addWidget (options_frame, 3, 0, 1, 1);
242243

243-
QHBoxLayout *show_parameter_names_frame_layout = new QHBoxLayout (show_parameter_names_frame);
244-
show_parameter_names_frame->setLayout (show_parameter_names_frame_layout);
244+
QHBoxLayout *options_frame_layout = new QHBoxLayout (options_frame);
245+
options_frame->setLayout (options_frame_layout);
245246
if (m_dense) {
246-
show_parameter_names_frame_layout->setContentsMargins (4, 4, 4, 4);
247+
options_frame_layout->setContentsMargins (4, 4, 4, 4);
247248
}
248249

249-
mp_show_parameter_names_cb = new QCheckBox (show_parameter_names_frame);
250-
mp_show_parameter_names_cb->setText (tr ("Show parameter names"));
251-
mp_show_parameter_names_cb->setChecked (m_show_parameter_names);
252-
show_parameter_names_frame_layout->addWidget (mp_show_parameter_names_cb);
253-
254-
connect (mp_show_parameter_names_cb, SIGNAL (clicked (bool)), this, SLOT (show_parameter_names (bool)));
250+
QToolButton *dot_menu_button = new QToolButton (options_frame);
251+
dot_menu_button->setText (tr ("Options "));
252+
dot_menu_button->setAutoRaise (true);
253+
dot_menu_button->setPopupMode (QToolButton::InstantPopup);
254+
dot_menu_button->setToolButtonStyle (Qt::ToolButtonTextOnly);
255+
options_frame_layout->addWidget (dot_menu_button);
256+
options_frame_layout->addStretch ();
257+
258+
QMenu *dot_menu = new QMenu (dot_menu_button);
259+
dot_menu_button->setMenu (dot_menu);
260+
mp_show_parameter_names_action = new QAction (dot_menu);
261+
dot_menu->addAction (mp_show_parameter_names_action);
262+
mp_show_parameter_names_action->setText (tr ("Show parameter names"));
263+
mp_show_parameter_names_action->setCheckable (true);
264+
mp_show_parameter_names_action->setChecked (m_show_parameter_names);
265+
connect (mp_show_parameter_names_action, SIGNAL (triggered (bool)), this, SLOT (show_parameter_names (bool)));
266+
267+
QMenu *lazy_eval_menu = new QMenu (dot_menu);
268+
lazy_eval_menu->setTitle (tr ("Lazy PCell evaluation"));
269+
dot_menu->addMenu (lazy_eval_menu);
270+
271+
mp_auto_lazy_eval_action = new QAction (lazy_eval_menu);
272+
lazy_eval_menu->addAction (mp_auto_lazy_eval_action);
273+
mp_auto_lazy_eval_action->setText (tr ("As requested by PCell"));
274+
mp_auto_lazy_eval_action->setCheckable (true);
275+
mp_auto_lazy_eval_action->setChecked (m_lazy_evaluation < 0);
276+
connect (mp_auto_lazy_eval_action, SIGNAL (triggered ()), this, SLOT (lazy_eval_mode_slot ()));
277+
278+
mp_always_lazy_eval_action = new QAction (lazy_eval_menu);
279+
lazy_eval_menu->addAction (mp_always_lazy_eval_action);
280+
mp_always_lazy_eval_action->setText (tr ("Always"));
281+
mp_always_lazy_eval_action->setCheckable (true);
282+
mp_always_lazy_eval_action->setChecked (m_lazy_evaluation > 0);
283+
connect (mp_always_lazy_eval_action, SIGNAL (triggered ()), this, SLOT (lazy_eval_mode_slot ()));
284+
285+
mp_never_lazy_eval_action = new QAction (lazy_eval_menu);
286+
lazy_eval_menu->addAction (mp_never_lazy_eval_action);
287+
mp_never_lazy_eval_action->setText (tr ("Never"));
288+
mp_never_lazy_eval_action->setCheckable (true);
289+
mp_never_lazy_eval_action->setChecked (m_lazy_evaluation == 0);
290+
connect (mp_never_lazy_eval_action, SIGNAL (triggered ()), this, SLOT (lazy_eval_mode_slot ()));
255291
}
256292

257293
bool
258294
PCellParametersPage::lazy_evaluation ()
259295
{
260-
return mp_pcell_decl.get () && mp_pcell_decl->wants_lazy_evaluation ();
296+
if (m_lazy_evaluation < 0) {
297+
return mp_pcell_decl.get () && mp_pcell_decl->wants_lazy_evaluation ();
298+
} else {
299+
return m_lazy_evaluation > 0;
300+
}
301+
}
302+
303+
void
304+
PCellParametersPage::lazy_eval_mode_slot ()
305+
{
306+
if (sender () == mp_always_lazy_eval_action) {
307+
lazy_eval_mode (1);
308+
} else if (sender () == mp_never_lazy_eval_action) {
309+
lazy_eval_mode (0);
310+
} else if (sender () == mp_auto_lazy_eval_action) {
311+
lazy_eval_mode (-1);
312+
}
313+
}
314+
315+
void
316+
PCellParametersPage::lazy_eval_mode (int mode)
317+
{
318+
if (mode == m_lazy_evaluation) {
319+
return;
320+
}
321+
322+
mp_never_lazy_eval_action->setChecked (mode == 0);
323+
mp_always_lazy_eval_action->setChecked (mode > 0);
324+
mp_auto_lazy_eval_action->setChecked (mode < 0);
325+
326+
m_lazy_evaluation = mode;
327+
328+
if (mp_dispatcher) {
329+
mp_dispatcher->config_set (cfg_edit_pcell_lazy_eval_mode, m_lazy_evaluation);
330+
}
331+
332+
setup (mp_view, m_cv_index, mp_pcell_decl.get (), get_parameters ());
261333
}
262334

263335
void
@@ -268,7 +340,7 @@ PCellParametersPage::show_parameter_names (bool f)
268340
}
269341

270342
m_show_parameter_names = f;
271-
mp_show_parameter_names_cb->setChecked (f);
343+
mp_show_parameter_names_action->setChecked (f);
272344

273345
if (mp_dispatcher) {
274346
mp_dispatcher->config_set (cfg_edit_pcell_show_parameter_names, m_show_parameter_names);

src/edt/edt/edtPCellParametersPage.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,12 @@ Q_OBJECT
144144

145145
public slots:
146146
void show_parameter_names (bool f);
147+
void lazy_eval_mode (int);
147148

148149
private slots:
149150
void parameter_changed ();
150151
void update_button_pressed ();
152+
void lazy_eval_mode_slot ();
151153

152154
private:
153155
lay::Dispatcher *mp_dispatcher;
@@ -160,14 +162,18 @@ private slots:
160162
QLabel *mp_changed_icon;
161163
QToolButton *mp_update_button;
162164
QFrame *mp_error_frame, *mp_update_frame;
163-
QCheckBox *mp_show_parameter_names_cb;
165+
QAction *mp_show_parameter_names_action;
166+
QAction *mp_auto_lazy_eval_action;
167+
QAction *mp_always_lazy_eval_action;
168+
QAction *mp_never_lazy_eval_action;
164169
tl::weak_ptr<db::PCellDeclaration> mp_pcell_decl;
165170
std::vector<QWidget *> m_widgets;
166171
std::vector<QLabel *> m_icon_widgets;
167172
std::vector<std::vector<QWidget *> > m_all_widgets;
168173
lay::LayoutViewBase *mp_view;
169174
int m_cv_index;
170175
bool m_dense, m_show_parameter_names;
176+
int m_lazy_evaluation;
171177
tl::DeferredMethod<PCellParametersPage> dm_parameter_changed;
172178
db::ParameterStates m_current_states, m_initial_states;
173179
db::ParameterStates m_states;

src/edt/edt/edtPlugin.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ void get_inst_options (std::vector < std::pair<std::string, std::string> > &opti
142142
options.push_back (std::pair<std::string, std::string> (cfg_edit_inst_column_y, "0.0"));
143143
options.push_back (std::pair<std::string, std::string> (cfg_edit_inst_place_origin, "false"));
144144
options.push_back (std::pair<std::string, std::string> (cfg_edit_pcell_show_parameter_names, "false"));
145+
options.push_back (std::pair<std::string, std::string> (cfg_edit_pcell_lazy_eval_mode, "-1"));
145146
options.push_back (std::pair<std::string, std::string> (cfg_edit_max_shapes_of_instances, "1000"));
146147
options.push_back (std::pair<std::string, std::string> (cfg_edit_show_shapes_of_instances, "true"));
147148
}

0 commit comments

Comments
 (0)