mirror of https://github.com/KLayout/klayout.git
Interactive manipulation of PCell parameters on editoptions page.
This commit is contained in:
parent
b8c33f1b59
commit
e12746526f
|
|
@ -52,7 +52,7 @@ namespace edt
|
|||
// EditorOptionsPage implementation
|
||||
|
||||
EditorOptionsPage::EditorOptionsPage (lay::Dispatcher *dispatcher)
|
||||
: mp_owner (0), m_active (true), mp_plugin_declaration (0), mp_dispatcher (dispatcher)
|
||||
: QWidget (0), mp_owner (0), m_active (true), mp_plugin_declaration (0), mp_dispatcher (dispatcher)
|
||||
{
|
||||
// nothing yet ..
|
||||
}
|
||||
|
|
@ -131,6 +131,15 @@ EditorOptionsPages::~EditorOptionsPages ()
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
EditorOptionsPages::focusInEvent (QFocusEvent * /*event*/)
|
||||
{
|
||||
// Sends the focus to the current page's last focus owner
|
||||
if (mp_pages->currentWidget () && mp_pages->currentWidget ()->focusWidget ()) {
|
||||
mp_pages->currentWidget ()->focusWidget ()->setFocus ();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
EditorOptionsPages::unregister_page (edt::EditorOptionsPage *page)
|
||||
{
|
||||
|
|
@ -266,7 +275,7 @@ static void configure_from_line_edit (lay::Dispatcher *dispatcher, QLineEdit *le
|
|||
// EditorOptionsGeneric implementation
|
||||
|
||||
EditorOptionsGeneric::EditorOptionsGeneric (lay::Dispatcher *dispatcher)
|
||||
: QWidget (), EditorOptionsPage (dispatcher)
|
||||
: EditorOptionsPage (dispatcher)
|
||||
{
|
||||
mp_ui = new Ui::EditorOptionsGeneric ();
|
||||
mp_ui->setupUi (this);
|
||||
|
|
@ -388,7 +397,7 @@ EditorOptionsGeneric::setup (lay::Dispatcher *root)
|
|||
// EditorOptionsText implementation
|
||||
|
||||
EditorOptionsText::EditorOptionsText (lay::Dispatcher *dispatcher)
|
||||
: QWidget (), EditorOptionsPage (dispatcher)
|
||||
: EditorOptionsPage (dispatcher)
|
||||
{
|
||||
mp_ui = new Ui::EditorOptionsText ();
|
||||
mp_ui->setupUi (this);
|
||||
|
|
@ -461,7 +470,7 @@ EditorOptionsText::setup (lay::Dispatcher *root)
|
|||
// EditorOptionsPath implementation
|
||||
|
||||
EditorOptionsPath::EditorOptionsPath (lay::Dispatcher *dispatcher)
|
||||
: QWidget (), EditorOptionsPage (dispatcher)
|
||||
: EditorOptionsPage (dispatcher)
|
||||
{
|
||||
mp_ui = new Ui::EditorOptionsPath ();
|
||||
mp_ui->setupUi (this);
|
||||
|
|
@ -560,7 +569,7 @@ EditorOptionsPath::setup (lay::Dispatcher *root)
|
|||
// EditorOptionsInst implementation
|
||||
|
||||
EditorOptionsInst::EditorOptionsInst (lay::Dispatcher *dispatcher)
|
||||
: QWidget (), EditorOptionsPage (dispatcher)
|
||||
: EditorOptionsPage (dispatcher)
|
||||
{
|
||||
mp_ui = new Ui::EditorOptionsInst ();
|
||||
mp_ui->setupUi (this);
|
||||
|
|
@ -684,12 +693,6 @@ BEGIN_PROTECTED
|
|||
END_PROTECTED
|
||||
}
|
||||
|
||||
void
|
||||
EditorOptionsInst::edited ()
|
||||
{
|
||||
apply (dispatcher ());
|
||||
}
|
||||
|
||||
void
|
||||
EditorOptionsInst::array_changed ()
|
||||
{
|
||||
|
|
@ -821,7 +824,7 @@ EditorOptionsInst::setup (lay::Dispatcher *root)
|
|||
// EditorOptionsInstPCellParam implementation
|
||||
|
||||
EditorOptionsInstPCellParam::EditorOptionsInstPCellParam (lay::Dispatcher *dispatcher)
|
||||
: QWidget (), EditorOptionsPage (dispatcher), mp_pcell_parameters (0), mp_placeholder_label (0)
|
||||
: EditorOptionsPage (dispatcher), mp_pcell_parameters (0), mp_placeholder_label (0)
|
||||
{
|
||||
mp_ui = new Ui::EditorOptionsInstPCellParam ();
|
||||
mp_ui->setupUi (this);
|
||||
|
|
@ -853,17 +856,21 @@ EditorOptionsInstPCellParam::apply (lay::Dispatcher *root)
|
|||
layout = &lay::LayoutView::current ()->cellview (m_cv_index)->layout ();
|
||||
}
|
||||
|
||||
bool ok = true;
|
||||
|
||||
if (layout && mp_pcell_parameters) {
|
||||
std::pair<bool, db::pcell_id_type> pc = layout->pcell_by_name (tl::to_string (m_cell_name).c_str ());
|
||||
if (pc.first) {
|
||||
const db::PCellDeclaration *pc_decl = layout->pcell_declaration (pc.second);
|
||||
if (pc_decl) {
|
||||
param = pcell_parameters_to_string (pc_decl->named_parameters (mp_pcell_parameters->get_parameters ()));
|
||||
param = pcell_parameters_to_string (pc_decl->named_parameters (mp_pcell_parameters->get_parameters (&ok)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
root->config_set (cfg_edit_inst_pcell_parameters, param);
|
||||
if (ok) {
|
||||
root->config_set (cfg_edit_inst_pcell_parameters, param);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -874,11 +881,24 @@ EditorOptionsInstPCellParam::setup (lay::Dispatcher *root)
|
|||
m_cv_index = lay::LayoutView::current ()->active_cellview_index ();
|
||||
}
|
||||
|
||||
bool needs_update = (mp_pcell_parameters == 0);
|
||||
|
||||
// cell name
|
||||
root->config_get (cfg_edit_inst_cell_name, m_cell_name);
|
||||
std::string cn;
|
||||
root->config_get (cfg_edit_inst_cell_name, cn);
|
||||
if (cn != m_cell_name) {
|
||||
m_cell_name = cn;
|
||||
needs_update = true;
|
||||
}
|
||||
|
||||
// library
|
||||
root->config_get (cfg_edit_inst_lib_name, m_lib_name);
|
||||
std::string ln;
|
||||
root->config_get (cfg_edit_inst_lib_name, ln);
|
||||
if (ln != m_lib_name) {
|
||||
m_lib_name = ln;
|
||||
needs_update = true;
|
||||
}
|
||||
|
||||
db::Library *lib = db::LibraryManager::instance ().lib_ptr_by_name (m_lib_name);
|
||||
|
||||
// pcell parameters
|
||||
|
|
@ -932,8 +952,17 @@ EditorOptionsInstPCellParam::setup (lay::Dispatcher *root)
|
|||
|
||||
}
|
||||
|
||||
if (! needs_update) {
|
||||
bool ok = false;
|
||||
if (mp_pcell_parameters->get_parameters (&ok) != pv || ! ok) {
|
||||
needs_update = true;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
update_pcell_parameters (pv);
|
||||
if (needs_update) {
|
||||
update_pcell_parameters (pv);
|
||||
}
|
||||
} catch (...) { }
|
||||
}
|
||||
|
||||
|
|
@ -985,10 +1014,12 @@ EditorOptionsInstPCellParam::update_pcell_parameters (const std::vector <tl::Var
|
|||
|
||||
if (pc.first && layout->pcell_declaration (pc.second) && view && view->cellview (m_cv_index).is_valid ()) {
|
||||
|
||||
mp_pcell_parameters = new PCellParametersPage (this, &view->cellview (m_cv_index)->layout (), view, m_cv_index, layout->pcell_declaration (pc.second), parameters);
|
||||
mp_pcell_parameters = new PCellParametersPage (this, true /*dense*/);
|
||||
mp_pcell_parameters->setup (&view->cellview (m_cv_index)->layout (), view, m_cv_index, layout->pcell_declaration (pc.second), parameters);
|
||||
this->layout ()->addWidget (mp_pcell_parameters);
|
||||
|
||||
mp_pcell_parameters->set_state (pcp_state);
|
||||
connect (mp_pcell_parameters, SIGNAL (edited ()), this, SLOT (edited ()));
|
||||
|
||||
} else {
|
||||
|
||||
|
|
|
|||
|
|
@ -63,7 +63,10 @@ class EditorOptionsPages;
|
|||
* @brief The base class for a object properties page
|
||||
*/
|
||||
class EditorOptionsPage
|
||||
: public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
EditorOptionsPage (lay::Dispatcher *dispatcher);
|
||||
virtual ~EditorOptionsPage ();
|
||||
|
|
@ -81,6 +84,12 @@ public:
|
|||
const lay::PluginDeclaration *plugin_declaration () const { return mp_plugin_declaration; }
|
||||
void set_plugin_declaration (const lay::PluginDeclaration *pd) { mp_plugin_declaration = pd; }
|
||||
|
||||
protected slots:
|
||||
void edited ()
|
||||
{
|
||||
apply (dispatcher ());
|
||||
}
|
||||
|
||||
protected:
|
||||
lay::Dispatcher *dispatcher () const
|
||||
{
|
||||
|
|
@ -108,6 +117,7 @@ public:
|
|||
|
||||
void unregister_page (edt::EditorOptionsPage *page);
|
||||
void activate_page (edt::EditorOptionsPage *page);
|
||||
void focusInEvent (QFocusEvent *event);
|
||||
|
||||
const std::vector <edt::EditorOptionsPage *> &pages () const
|
||||
{
|
||||
|
|
@ -131,7 +141,7 @@ private:
|
|||
* @brief The generic properties page
|
||||
*/
|
||||
class EditorOptionsGeneric
|
||||
: public QWidget, public EditorOptionsPage
|
||||
: public EditorOptionsPage
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
|
@ -158,7 +168,7 @@ private:
|
|||
* @brief The text properties page
|
||||
*/
|
||||
class EditorOptionsText
|
||||
: public QWidget, public EditorOptionsPage
|
||||
: public EditorOptionsPage
|
||||
{
|
||||
public:
|
||||
EditorOptionsText (lay::Dispatcher *dispatcher);
|
||||
|
|
@ -179,7 +189,7 @@ private:
|
|||
* @brief The path properties page
|
||||
*/
|
||||
class EditorOptionsPath
|
||||
: public QWidget, public EditorOptionsPage
|
||||
: public EditorOptionsPage
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
|
@ -205,7 +215,7 @@ private:
|
|||
* @brief The instance properties page
|
||||
*/
|
||||
class EditorOptionsInst
|
||||
: public QWidget, public EditorOptionsPage
|
||||
: public EditorOptionsPage
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
|
@ -220,14 +230,13 @@ public:
|
|||
void apply (lay::Dispatcher *root);
|
||||
void setup (lay::Dispatcher *root);
|
||||
|
||||
public slots:
|
||||
private slots:
|
||||
void array_changed ();
|
||||
void browse_cell ();
|
||||
void update_pcell_parameters ();
|
||||
void library_changed ();
|
||||
void cell_name_changed ();
|
||||
void update_cell_edits ();
|
||||
void edited ();
|
||||
|
||||
private:
|
||||
Ui::EditorOptionsInst *mp_ui;
|
||||
|
|
@ -241,7 +250,7 @@ private:
|
|||
* @brief The instance properties page (PCell parameters)
|
||||
*/
|
||||
class EditorOptionsInstPCellParam
|
||||
: public QWidget, public EditorOptionsPage
|
||||
: public EditorOptionsPage
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
|
@ -256,7 +265,7 @@ public:
|
|||
void apply (lay::Dispatcher *root);
|
||||
void setup (lay::Dispatcher *root);
|
||||
|
||||
public slots:
|
||||
private slots:
|
||||
void update_pcell_parameters ();
|
||||
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -686,7 +686,8 @@ InstPropertiesPage::update_pcell_parameters ()
|
|||
mp_pcell_parameters->deleteLater ();
|
||||
}
|
||||
|
||||
mp_pcell_parameters = new PCellParametersPage (pcell_tab, &cv->layout (), mp_service->view (), pos->cv_index (), layout->pcell_declaration (pc.second), parameters);
|
||||
mp_pcell_parameters = new PCellParametersPage (pcell_tab);
|
||||
mp_pcell_parameters->setup (&cv->layout (), mp_service->view (), pos->cv_index (), layout->pcell_declaration (pc.second), parameters);
|
||||
pcell_tab->layout ()->addWidget (mp_pcell_parameters);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,6 +38,24 @@
|
|||
namespace edt
|
||||
{
|
||||
|
||||
static void indicate_error (QLineEdit *le, const tl::Exception *ex)
|
||||
{
|
||||
// by the way, update the foreground color of the cell edit box as well (red, if not valid)
|
||||
QPalette pl = le->palette ();
|
||||
if (ex) {
|
||||
pl.setColor (QPalette::Active, QPalette::Text, Qt::red);
|
||||
pl.setColor (QPalette::Active, QPalette::Base, QColor (Qt::red).lighter (180));
|
||||
le->setToolTip (tl::to_qstring (ex->msg ()));
|
||||
} else {
|
||||
QWidget *pw = dynamic_cast<QWidget *> (le->parent ());
|
||||
tl_assert (pw != 0);
|
||||
pl.setColor (QPalette::Active, QPalette::Text, pw->palette ().color (QPalette::Text));
|
||||
pl.setColor (QPalette::Active, QPalette::Base, pw->palette ().color (QPalette::Base));
|
||||
le->setToolTip (QString ());
|
||||
}
|
||||
le->setPalette (pl);
|
||||
}
|
||||
|
||||
static void set_value (const db::PCellParameterDeclaration &p, const db::Layout * /*layout*/, QWidget *widget, const tl::Variant &value)
|
||||
{
|
||||
if (p.get_choices ().empty ()) {
|
||||
|
|
@ -142,15 +160,8 @@ static void set_value (const db::PCellParameterDeclaration &p, const db::Layout
|
|||
}
|
||||
}
|
||||
|
||||
PCellParametersPage::PCellParametersPage (QWidget *parent, const db::Layout *layout, lay::LayoutView *view, int cv_index, const db::PCellDeclaration *pcell_decl, const db::pcell_parameters_type ¶meters)
|
||||
: QFrame (parent)
|
||||
{
|
||||
init ();
|
||||
setup (layout, view, cv_index, pcell_decl, parameters);
|
||||
}
|
||||
|
||||
PCellParametersPage::PCellParametersPage (QWidget *parent)
|
||||
: QFrame (parent)
|
||||
PCellParametersPage::PCellParametersPage (QWidget *parent, bool dense)
|
||||
: QFrame (parent), m_dense (dense), dm_parameter_changed (this, &PCellParametersPage::do_parameter_changed)
|
||||
{
|
||||
init ();
|
||||
}
|
||||
|
|
@ -175,6 +186,7 @@ PCellParametersPage::init ()
|
|||
frame_layout->addWidget (mp_error_icon, 1, 0, 1, 1);
|
||||
|
||||
mp_error_label = new QLabel (this);
|
||||
mp_error_label->setWordWrap (true);
|
||||
QPalette palette = mp_error_label->palette ();
|
||||
palette.setColor (QPalette::Foreground, Qt::red);
|
||||
mp_error_label->setPalette (palette);
|
||||
|
|
@ -214,9 +226,11 @@ PCellParametersPage::setup (const db::Layout *layout, lay::LayoutView *view, int
|
|||
|
||||
QGridLayout *inner_grid = new QGridLayout (inner_frame);
|
||||
inner_frame->setLayout (inner_grid);
|
||||
inner_grid->setMargin (4);
|
||||
inner_grid->setHorizontalSpacing (6);
|
||||
inner_grid->setVerticalSpacing (2);
|
||||
if (m_dense) {
|
||||
inner_grid->setMargin (4);
|
||||
inner_grid->setHorizontalSpacing (6);
|
||||
inner_grid->setVerticalSpacing (2);
|
||||
}
|
||||
|
||||
QWidget *main_frame = inner_frame;
|
||||
QGridLayout *main_grid = inner_grid;
|
||||
|
|
@ -253,9 +267,11 @@ PCellParametersPage::setup (const db::Layout *layout, lay::LayoutView *view, int
|
|||
main_grid->addWidget (gb, main_row, 0, 1, 2);
|
||||
|
||||
inner_grid = new QGridLayout (gb);
|
||||
inner_grid->setMargin (4);
|
||||
inner_grid->setHorizontalSpacing (6);
|
||||
inner_grid->setVerticalSpacing (2);
|
||||
if (m_dense) {
|
||||
inner_grid->setMargin (4);
|
||||
inner_grid->setHorizontalSpacing (6);
|
||||
inner_grid->setVerticalSpacing (2);
|
||||
}
|
||||
gb->setLayout (inner_grid);
|
||||
inner_frame = gb;
|
||||
|
||||
|
|
@ -301,6 +317,7 @@ PCellParametersPage::setup (const db::Layout *layout, lay::LayoutView *view, int
|
|||
le->setEnabled (! p->is_readonly ());
|
||||
hb->addWidget (le);
|
||||
le->setMaximumWidth (150);
|
||||
le->setObjectName (tl::to_qstring (p->get_name ()));
|
||||
m_widgets.push_back (le);
|
||||
|
||||
QLabel *ul = new QLabel (f);
|
||||
|
|
@ -309,7 +326,7 @@ PCellParametersPage::setup (const db::Layout *layout, lay::LayoutView *view, int
|
|||
|
||||
inner_grid->addWidget (f, row, 1);
|
||||
|
||||
connect (le, SIGNAL (editingFinished ()), this, SLOT (activated ()));
|
||||
connect (le, SIGNAL (editingFinished ()), this, SLOT (parameter_changed ()));
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
@ -319,10 +336,11 @@ PCellParametersPage::setup (const db::Layout *layout, lay::LayoutView *view, int
|
|||
{
|
||||
QLineEdit *le = new QLineEdit (inner_frame);
|
||||
le->setEnabled (! p->is_readonly ());
|
||||
le->setObjectName (tl::to_qstring (p->get_name ()));
|
||||
m_widgets.push_back (le);
|
||||
inner_grid->addWidget (le, row, 1);
|
||||
|
||||
connect (le, SIGNAL (editingFinished ()), this, SLOT (activated ()));
|
||||
connect (le, SIGNAL (editingFinished ()), this, SLOT (parameter_changed ()));
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
@ -332,19 +350,25 @@ PCellParametersPage::setup (const db::Layout *layout, lay::LayoutView *view, int
|
|||
ly->setEnabled (! p->is_readonly ());
|
||||
ly->set_no_layer_available (true);
|
||||
ly->set_view (mp_view, m_cv_index, true /*all layers*/);
|
||||
ly->setObjectName (tl::to_qstring (p->get_name ()));
|
||||
m_widgets.push_back (ly);
|
||||
inner_grid->addWidget (ly, row, 1);
|
||||
|
||||
connect (ly, SIGNAL (activated (int)), this, SLOT (parameter_changed ()));
|
||||
}
|
||||
break;
|
||||
|
||||
case db::PCellParameterDeclaration::t_boolean:
|
||||
{
|
||||
QCheckBox *cbx = new QCheckBox (inner_frame);
|
||||
// this makes the checkbox not stretch over the full width - better when navigating with tab
|
||||
cbx->setSizePolicy (QSizePolicy (QSizePolicy::Fixed, QSizePolicy::Preferred));
|
||||
cbx->setEnabled (! p->is_readonly ());
|
||||
cbx->setObjectName (tl::to_qstring (p->get_name ()));
|
||||
m_widgets.push_back (cbx);
|
||||
inner_grid->addWidget (cbx, row, 1);
|
||||
|
||||
connect (cbx, SIGNAL (stateChanged (int)), this, SLOT (activated ()));
|
||||
connect (cbx, SIGNAL (stateChanged (int)), this, SLOT (parameter_changed ()));
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
@ -356,6 +380,7 @@ PCellParametersPage::setup (const db::Layout *layout, lay::LayoutView *view, int
|
|||
} else {
|
||||
|
||||
QComboBox *cb = new QComboBox (inner_frame);
|
||||
cb->setObjectName (tl::to_qstring (p->get_name ()));
|
||||
|
||||
int i = 0;
|
||||
for (std::vector<tl::Variant>::const_iterator c = p->get_choices ().begin (); c != p->get_choices ().end (); ++c, ++i) {
|
||||
|
|
@ -366,7 +391,8 @@ PCellParametersPage::setup (const db::Layout *layout, lay::LayoutView *view, int
|
|||
}
|
||||
}
|
||||
|
||||
connect (cb, SIGNAL (activated (int)), this, SLOT (activated ()));
|
||||
connect (cb, SIGNAL (activated (int)), this, SLOT (parameter_changed ()));
|
||||
|
||||
cb->setEnabled (! p->is_readonly ());
|
||||
cb->setMinimumContentsLength (30);
|
||||
cb->setSizeAdjustPolicy (QComboBox::AdjustToMinimumContentsLengthWithIcon);
|
||||
|
|
@ -387,17 +413,24 @@ PCellParametersPage::setup (const db::Layout *layout, lay::LayoutView *view, int
|
|||
mp_parameters_area->setWidget (main_frame);
|
||||
main_frame->show ();
|
||||
|
||||
// does a first coerce and update
|
||||
get_parameters ();
|
||||
// does a first coerce and update. Ignore errors for now.
|
||||
bool ok = false;
|
||||
get_parameters (&ok);
|
||||
}
|
||||
|
||||
PCellParametersPage::State
|
||||
PCellParametersPage::get_state ()
|
||||
{
|
||||
State s;
|
||||
|
||||
s.valid = true;
|
||||
s.vScrollPosition = mp_parameters_area->verticalScrollBar ()->value ();
|
||||
s.hScrollPosition = mp_parameters_area->horizontalScrollBar ()->value ();
|
||||
|
||||
if (focusWidget ()) {
|
||||
s.focusWidget = focusWidget ()->objectName ();
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
|
|
@ -405,29 +438,42 @@ void
|
|||
PCellParametersPage::set_state (const State &s)
|
||||
{
|
||||
if (s.valid) {
|
||||
|
||||
mp_parameters_area->verticalScrollBar ()->setValue (s.vScrollPosition);
|
||||
mp_parameters_area->horizontalScrollBar ()->setValue (s.hScrollPosition);
|
||||
|
||||
if (! s.focusWidget.isEmpty ()) {
|
||||
QWidget *c = findChild<QWidget *> (s.focusWidget);
|
||||
if (c) {
|
||||
c->setFocus ();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
PCellParametersPage::activated ()
|
||||
PCellParametersPage::parameter_changed ()
|
||||
{
|
||||
// does a coerce and update
|
||||
get_parameters ();
|
||||
dm_parameter_changed ();
|
||||
}
|
||||
|
||||
void
|
||||
PCellParametersPage::clicked ()
|
||||
void
|
||||
PCellParametersPage::do_parameter_changed ()
|
||||
{
|
||||
// does a coerce and update
|
||||
get_parameters ();
|
||||
bool ok = false;
|
||||
get_parameters (&ok);
|
||||
if (ok) {
|
||||
emit edited ();
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<tl::Variant>
|
||||
PCellParametersPage::get_parameters ()
|
||||
PCellParametersPage::get_parameters (bool *ok)
|
||||
{
|
||||
std::vector<tl::Variant> parameters;
|
||||
bool edit_error = true;
|
||||
|
||||
int r = 0;
|
||||
const std::vector<db::PCellParameterDeclaration> &pcp = mp_pcell_decl->parameter_declarations ();
|
||||
|
|
@ -453,9 +499,22 @@ PCellParametersPage::get_parameters ()
|
|||
{
|
||||
QLineEdit *le = dynamic_cast<QLineEdit *> (m_widgets [r]);
|
||||
if (le) {
|
||||
int v = 0;
|
||||
tl::from_string (tl::to_string (le->text ()), v);
|
||||
parameters.back () = tl::Variant (v);
|
||||
|
||||
try {
|
||||
|
||||
int v = 0;
|
||||
tl::from_string (tl::to_string (le->text ()), v);
|
||||
|
||||
parameters.back () = tl::Variant (v);
|
||||
indicate_error (le, 0);
|
||||
|
||||
} catch (tl::Exception &ex) {
|
||||
|
||||
indicate_error (le, &ex);
|
||||
edit_error = false;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
|
@ -464,9 +523,22 @@ PCellParametersPage::get_parameters ()
|
|||
{
|
||||
QLineEdit *le = dynamic_cast<QLineEdit *> (m_widgets [r]);
|
||||
if (le) {
|
||||
double v = 0;
|
||||
tl::from_string (tl::to_string (le->text ()), v);
|
||||
parameters.back () = tl::Variant (v);
|
||||
|
||||
try {
|
||||
|
||||
double v = 0;
|
||||
tl::from_string (tl::to_string (le->text ()), v);
|
||||
|
||||
parameters.back () = tl::Variant (v);
|
||||
indicate_error (le, 0);
|
||||
|
||||
} catch (tl::Exception &ex) {
|
||||
|
||||
indicate_error (le, &ex);
|
||||
edit_error = false;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
|
@ -526,22 +598,43 @@ PCellParametersPage::get_parameters ()
|
|||
|
||||
try {
|
||||
|
||||
if (! edit_error) {
|
||||
throw tl::Exception (tl::to_string (tr ("There are errors. See the highlighted edit fields for details.")));
|
||||
}
|
||||
|
||||
// coerce the parameters
|
||||
mp_pcell_decl->coerce_parameters (*mp_layout, parameters);
|
||||
set_parameters (parameters);
|
||||
|
||||
mp_error_label->hide ();
|
||||
mp_error_icon->hide ();
|
||||
|
||||
if (ok) {
|
||||
*ok = true;
|
||||
}
|
||||
|
||||
} catch (tl::ScriptError &ex) {
|
||||
|
||||
mp_error_label->setText (tl::to_qstring (ex.basic_msg ()));
|
||||
mp_error_label->setToolTip (tl::to_qstring (ex.msg ()));
|
||||
mp_error_icon->show ();
|
||||
mp_error_label->show ();
|
||||
if (ok) {
|
||||
mp_error_label->setText (tl::to_qstring (ex.basic_msg ()));
|
||||
mp_error_label->setToolTip (tl::to_qstring (ex.msg ()));
|
||||
mp_error_icon->show ();
|
||||
mp_error_label->show ();
|
||||
*ok = false;
|
||||
} else {
|
||||
throw;
|
||||
}
|
||||
|
||||
} catch (tl::Exception &ex) {
|
||||
|
||||
mp_error_label->setText (tl::to_qstring (ex.msg ()));
|
||||
mp_error_icon->show ();
|
||||
mp_error_label->show ();
|
||||
if (ok) {
|
||||
mp_error_label->setText (tl::to_qstring (ex.msg ()));
|
||||
mp_error_icon->show ();
|
||||
mp_error_label->show ();
|
||||
*ok = false;
|
||||
} else {
|
||||
throw;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -549,7 +642,7 @@ PCellParametersPage::get_parameters ()
|
|||
}
|
||||
|
||||
void
|
||||
PCellParametersPage::set_parameters (const std::vector<tl::Variant> ¶meters)
|
||||
PCellParametersPage::set_parameters (const std::vector<tl::Variant> ¶meters)
|
||||
{
|
||||
// write the changed value back
|
||||
size_t r = 0;
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@
|
|||
#define HDR_edtPCellParametersPage
|
||||
|
||||
#include "dbPCellDeclaration.h"
|
||||
#include "tlDeferredExecution.h"
|
||||
|
||||
#include <QFrame>
|
||||
#include <QScrollArea>
|
||||
|
|
@ -42,7 +43,7 @@ namespace edt
|
|||
* @brief A QScrollArea that displays and allows editing PCell parameters
|
||||
*/
|
||||
class PCellParametersPage
|
||||
: public QFrame
|
||||
: public QFrame, public tl::Object
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
|
@ -54,31 +55,28 @@ public:
|
|||
bool valid;
|
||||
int hScrollPosition;
|
||||
int vScrollPosition;
|
||||
QString focusWidget;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Constructor: creates a page showing the given parameters
|
||||
*
|
||||
* @param parent The parent widget
|
||||
* @param layout The layout in which the PCell instance resides
|
||||
* @param view The layout view from which to take layers for example
|
||||
* @param cv_index The index of the cellview in "view"
|
||||
* @param pcell_decl The PCell declaration
|
||||
* @param parameters The parameter values to show (if empty, the default values are used)
|
||||
*/
|
||||
PCellParametersPage (QWidget *parent, const db::Layout *layout, lay::LayoutView *view, int cv_index, const db::PCellDeclaration *pcell_decl, const db::pcell_parameters_type ¶meters);
|
||||
|
||||
/**
|
||||
* @brief Default constructor
|
||||
*
|
||||
* Use "setup" to configure the page.
|
||||
*
|
||||
* @param dense Use a dense layout if true
|
||||
*/
|
||||
PCellParametersPage (QWidget *parent);
|
||||
PCellParametersPage (QWidget *parent, bool dense = false);
|
||||
|
||||
/**
|
||||
* @brief Delayed initialization
|
||||
* @brief initialization
|
||||
*
|
||||
* Use this method to setup when the arguments are not available in the constructor
|
||||
*
|
||||
* @param layout The layout in which the PCell instance resides
|
||||
* @param view The layout view from which to take layers for example
|
||||
* @param cv_index The index of the cellview in "view"
|
||||
* @param pcell_decl The PCell declaration
|
||||
* @param parameters The parameter values to show (if empty, the default values are used)
|
||||
*/
|
||||
void setup (const db::Layout *layout, lay::LayoutView *view, int cv_index, const db::PCellDeclaration *pcell_decl, const db::pcell_parameters_type ¶meters);
|
||||
|
||||
|
|
@ -94,8 +92,12 @@ public:
|
|||
|
||||
/**
|
||||
* @brief Get the current parameters
|
||||
*
|
||||
* *ok is set to true, if there is no error. In case of an error it's set to false.
|
||||
* The error is indicated in the error label in the editor page.
|
||||
* If ok is null, an exception is thrown.
|
||||
*/
|
||||
std::vector<tl::Variant> get_parameters ();
|
||||
std::vector<tl::Variant> get_parameters (bool *ok = 0);
|
||||
|
||||
/**
|
||||
* @brief Get the PCell declaration pointer
|
||||
|
|
@ -110,10 +112,12 @@ public:
|
|||
*/
|
||||
void set_parameters (const std::vector<tl::Variant> &values);
|
||||
|
||||
public slots:
|
||||
void activated ();
|
||||
void clicked ();
|
||||
|
||||
signals:
|
||||
void edited ();
|
||||
|
||||
private slots:
|
||||
void parameter_changed ();
|
||||
|
||||
private:
|
||||
QScrollArea *mp_parameters_area;
|
||||
QLabel *mp_error_label;
|
||||
|
|
@ -124,8 +128,11 @@ private:
|
|||
lay::LayoutView *mp_view;
|
||||
int m_cv_index;
|
||||
db::pcell_parameters_type m_parameters;
|
||||
bool m_dense;
|
||||
tl::DeferredMethod<PCellParametersPage> dm_parameter_changed;
|
||||
|
||||
void init ();
|
||||
void do_parameter_changed ();
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -379,6 +379,7 @@ show_editor_options_page (lay::LayoutView *view)
|
|||
|
||||
edt::EditorOptionsPages *pages = new edt::EditorOptionsPages (view->editor_options_frame (), prop_dialog_pages, view);
|
||||
view->editor_options_frame ()->layout ()->addWidget (pages);
|
||||
view->editor_options_frame ()->setFocusProxy (pages);
|
||||
}
|
||||
|
||||
static
|
||||
|
|
|
|||
|
|
@ -176,6 +176,16 @@ public:
|
|||
mp_bglabel->show ();
|
||||
}
|
||||
|
||||
void focusInEvent (QFocusEvent *)
|
||||
{
|
||||
for (size_t i = 0; i < m_widgets.size (); ++i) {
|
||||
if (m_widgets [i]->isVisible ()) {
|
||||
m_widgets [i]->setFocus ();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void addWidget (QWidget *w)
|
||||
{
|
||||
m_widgets.push_back (w);
|
||||
|
|
@ -422,6 +432,7 @@ show_dock_widget (QDockWidget *dock_widget, bool visible)
|
|||
if (visible) {
|
||||
|
||||
dock_widget->show ();
|
||||
dock_widget->setFocus ();
|
||||
|
||||
// NOTE: this is a clumsy way to make sure the dock widget is made the current tab if it's in a tabbed dock
|
||||
// TODO: is there a better way to do this?
|
||||
|
|
@ -526,6 +537,7 @@ MainWindow::MainWindow (QApplication *app, lay::Plugin *plugin_parent, const cha
|
|||
mp_hp_dock_widget->setObjectName (QString::fromUtf8 ("hp_dock_widget"));
|
||||
mp_hp_stack = new ControlWidgetStack (mp_hp_dock_widget, "hp_stack");
|
||||
mp_hp_dock_widget->setWidget (mp_hp_stack);
|
||||
mp_hp_dock_widget->setFocusProxy (mp_hp_stack);
|
||||
connect (mp_hp_dock_widget, SIGNAL (visibilityChanged (bool)), this, SLOT (dock_widget_visibility_changed (bool)));
|
||||
m_hp_visible = true;
|
||||
|
||||
|
|
@ -533,6 +545,7 @@ MainWindow::MainWindow (QApplication *app, lay::Plugin *plugin_parent, const cha
|
|||
mp_libs_dock_widget->setObjectName (QString::fromUtf8 ("libs_dock_widget"));
|
||||
mp_libs_stack = new ControlWidgetStack (mp_libs_dock_widget, "libs_stack");
|
||||
mp_libs_dock_widget->setWidget (mp_libs_stack);
|
||||
mp_libs_dock_widget->setFocusProxy (mp_libs_stack);
|
||||
connect (mp_libs_dock_widget, SIGNAL (visibilityChanged (bool)), this, SLOT (dock_widget_visibility_changed (bool)));
|
||||
m_libs_visible = true;
|
||||
|
||||
|
|
@ -540,6 +553,7 @@ MainWindow::MainWindow (QApplication *app, lay::Plugin *plugin_parent, const cha
|
|||
mp_eo_dock_widget->setObjectName (QString::fromUtf8 ("eo_dock_widget"));
|
||||
mp_eo_stack = new ControlWidgetStack (mp_eo_dock_widget, "eo_stack");
|
||||
mp_eo_dock_widget->setWidget (mp_eo_stack);
|
||||
mp_eo_dock_widget->setFocusProxy (mp_eo_stack);
|
||||
connect (mp_eo_dock_widget, SIGNAL (visibilityChanged (bool)), this, SLOT (dock_widget_visibility_changed (bool)));
|
||||
m_eo_visible = true;
|
||||
|
||||
|
|
@ -547,6 +561,7 @@ MainWindow::MainWindow (QApplication *app, lay::Plugin *plugin_parent, const cha
|
|||
mp_bm_dock_widget->setObjectName (QString::fromUtf8 ("bookmarks_dock_widget"));
|
||||
mp_bm_stack = new ControlWidgetStack (mp_bm_dock_widget, "bookmarks_stack");
|
||||
mp_bm_dock_widget->setWidget (mp_bm_stack);
|
||||
mp_bm_dock_widget->setFocusProxy (mp_bm_stack);
|
||||
connect (mp_bm_dock_widget, SIGNAL (visibilityChanged (bool)), this, SLOT (dock_widget_visibility_changed (bool)));
|
||||
m_bm_visible = true;
|
||||
|
||||
|
|
@ -558,6 +573,7 @@ MainWindow::MainWindow (QApplication *app, lay::Plugin *plugin_parent, const cha
|
|||
mp_layer_toolbox_dock_widget->setObjectName (QString::fromUtf8 ("lt_dock_widget"));
|
||||
mp_layer_toolbox = new LayerToolbox (mp_layer_toolbox_dock_widget, "layer_toolbox");
|
||||
mp_layer_toolbox_dock_widget->setWidget (mp_layer_toolbox);
|
||||
mp_layer_toolbox_dock_widget->setFocusProxy (mp_layer_toolbox);
|
||||
connect (mp_layer_toolbox_dock_widget, SIGNAL (visibilityChanged (bool)), this, SLOT (dock_widget_visibility_changed (bool)));
|
||||
m_layer_toolbox_visible = true;
|
||||
|
||||
|
|
@ -565,6 +581,7 @@ MainWindow::MainWindow (QApplication *app, lay::Plugin *plugin_parent, const cha
|
|||
mp_lp_dock_widget->setObjectName (QString::fromUtf8 ("lp_dock_widget"));
|
||||
mp_lp_stack = new ControlWidgetStack (mp_lp_dock_widget, "lp_stack");
|
||||
mp_lp_dock_widget->setWidget (mp_lp_stack);
|
||||
mp_lp_dock_widget->setFocusProxy (mp_lp_stack);
|
||||
connect (mp_lp_dock_widget, SIGNAL (visibilityChanged (bool)), this, SLOT (dock_widget_visibility_changed (bool)));
|
||||
m_lp_visible = true;
|
||||
|
||||
|
|
@ -572,6 +589,7 @@ MainWindow::MainWindow (QApplication *app, lay::Plugin *plugin_parent, const cha
|
|||
mp_navigator_dock_widget->setObjectName (QString::fromUtf8 ("navigator_dock_widget"));
|
||||
mp_navigator = new Navigator (this);
|
||||
mp_navigator_dock_widget->setWidget (mp_navigator);
|
||||
mp_navigator_dock_widget->setFocusProxy (mp_navigator);
|
||||
connect (mp_navigator_dock_widget, SIGNAL (visibilityChanged (bool)), this, SLOT (dock_widget_visibility_changed (bool)));
|
||||
m_navigator_visible = true;
|
||||
|
||||
|
|
@ -3916,10 +3934,8 @@ MainWindow::menu_activated (const std::string &symbol)
|
|||
cm_help_about_qt ();
|
||||
} else if (symbol == "cm_edit_options") {
|
||||
|
||||
if (!m_eo_visible) {
|
||||
m_eo_visible = true;
|
||||
show_dock_widget (mp_eo_dock_widget, m_eo_visible);
|
||||
}
|
||||
m_eo_visible = true;
|
||||
show_dock_widget (mp_eo_dock_widget, m_eo_visible);
|
||||
|
||||
} else {
|
||||
|
||||
|
|
@ -4371,8 +4387,8 @@ public:
|
|||
menu_entries.push_back (lay::separator ("macros_group", at));
|
||||
|
||||
at = "@toolbar.end";
|
||||
menu_entries.push_back (lay::menu_item ("cm_prev_display_state", "prev_display_state", at, tl::to_string (QObject::tr ("Back(Shift+Tab)<:/back.png>"))));
|
||||
menu_entries.push_back (lay::menu_item ("cm_next_display_state", "next_display_state", at, tl::to_string (QObject::tr ("Forward(Tab)<:/forward.png>"))));
|
||||
menu_entries.push_back (lay::menu_item ("cm_prev_display_state", "prev_display_state", at, tl::to_string (QObject::tr ("Back<:/back.png>"))));
|
||||
menu_entries.push_back (lay::menu_item ("cm_next_display_state", "next_display_state", at, tl::to_string (QObject::tr ("Forward<:/forward.png>"))));
|
||||
menu_entries.push_back (lay::separator ("toolbar_post_navigation_group", at));
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -2185,8 +2185,8 @@ public:
|
|||
menu_entries.push_back (lay::separator ("zoom_group", at));
|
||||
menu_entries.push_back (lay::menu_item ("cm_zoom_fit", "zoom_fit", at, tl::to_string (QObject::tr ("Zoom Fit(F2)"))));
|
||||
menu_entries.push_back (lay::menu_item ("cm_zoom_fit_sel", "zoom_fit_sel", at, tl::to_string (QObject::tr ("Zoom Fit Selection(Shift+F2)"))));
|
||||
menu_entries.push_back (lay::menu_item ("cm_zoom_in", "zoom_in", at, tl::to_string (QObject::tr ("Zoom In(Return)"))));
|
||||
menu_entries.push_back (lay::menu_item ("cm_zoom_out", "zoom_out", at, tl::to_string (QObject::tr ("Zoom Out(Shift+Return)"))));
|
||||
menu_entries.push_back (lay::menu_item ("cm_zoom_in", "zoom_in", at, tl::to_string (QObject::tr ("Zoom In(Ctrl++)"))));
|
||||
menu_entries.push_back (lay::menu_item ("cm_zoom_out", "zoom_out", at, tl::to_string (QObject::tr ("Zoom Out(Ctrl+-)"))));
|
||||
/* disabled because that interferes with the use of the arrow keys for moving the selection
|
||||
MenuLayoutEntry::separator ("pan_group");
|
||||
menu_entries.push_back (lay::menu_item ("cm_pan_up", "pan_up", at, tl::to_string (QObject::tr ("Pan Up(Up)"))));
|
||||
|
|
|
|||
|
|
@ -590,7 +590,7 @@ LibrarySelectionComboBox::set_technology_filter (const std::string &tech, bool e
|
|||
void
|
||||
LibrarySelectionComboBox::update_list ()
|
||||
{
|
||||
blockSignals (true);
|
||||
bool wasBlocked = blockSignals (true);
|
||||
|
||||
db::Library *lib = current_library ();
|
||||
|
||||
|
|
@ -620,7 +620,7 @@ LibrarySelectionComboBox::update_list ()
|
|||
|
||||
set_current_library (lib);
|
||||
|
||||
blockSignals (false);
|
||||
blockSignals (wasBlocked);
|
||||
}
|
||||
|
||||
LibrarySelectionComboBox::~LibrarySelectionComboBox ()
|
||||
|
|
|
|||
Loading…
Reference in New Issue