mirror of https://github.com/KLayout/klayout.git
Merge pull request #1231 from KLayout/issue-1228
Implemented solution for issue #1228
This commit is contained in:
commit
975a752844
|
|
@ -60,6 +60,7 @@ std::string cfg_edit_top_level_selection ("edit-top-level-selection");
|
|||
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_global_grid ("grid-micron");
|
||||
std::string cfg_edit_combine_mode ("combine-mode");
|
||||
|
||||
|
|
|
|||
|
|
@ -68,6 +68,7 @@ extern EDT_PUBLIC std::string cfg_edit_inst_column_x;
|
|||
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_hier_copy_mode;
|
||||
extern EDT_PUBLIC std::string cfg_edit_combine_mode;
|
||||
|
||||
|
|
|
|||
|
|
@ -853,6 +853,8 @@ EditorOptionsInstPCellParam::update_pcell_parameters (const std::vector <tl::Var
|
|||
pc = layout->pcell_by_name (tl::to_string (m_cell_name).c_str ());
|
||||
}
|
||||
|
||||
// TODO: don't re-generate the PCellParametersPage unless the PCell has changed
|
||||
|
||||
PCellParametersPage::State pcp_state;
|
||||
|
||||
// Hint: we shall not delete the page immediately. This gives a segmentation fault in some cases.
|
||||
|
|
@ -872,7 +874,7 @@ EditorOptionsInstPCellParam::update_pcell_parameters (const std::vector <tl::Var
|
|||
|
||||
if (pc.first && layout->pcell_declaration (pc.second) && view ()->cellview (m_cv_index).is_valid ()) {
|
||||
|
||||
mp_pcell_parameters = new PCellParametersPage (this, true /*dense*/);
|
||||
mp_pcell_parameters = new PCellParametersPage (this, dispatcher (), true /*dense*/);
|
||||
mp_pcell_parameters->setup (view (), m_cv_index, layout->pcell_declaration (pc.second), parameters);
|
||||
this->layout ()->addWidget (mp_pcell_parameters);
|
||||
|
||||
|
|
|
|||
|
|
@ -1009,7 +1009,7 @@ InstPropertiesPage::update_pcell_parameters ()
|
|||
mp_pcell_parameters->deleteLater ();
|
||||
}
|
||||
|
||||
mp_pcell_parameters = new PCellParametersPage (pcell_tab);
|
||||
mp_pcell_parameters = new PCellParametersPage (pcell_tab, mp_service->view ()->dispatcher ());
|
||||
connect (mp_pcell_parameters, SIGNAL (edited ()), this, SIGNAL (edited ()));
|
||||
mp_pcell_parameters->setup (mp_service->view (), pos->cv_index (), layout->pcell_declaration (pc.second), parameters);
|
||||
pcell_tab->layout ()->addWidget (mp_pcell_parameters);
|
||||
|
|
|
|||
|
|
@ -24,9 +24,11 @@
|
|||
|
||||
#include "edtPCellParametersPage.h"
|
||||
#include "edtPropertiesPageUtils.h"
|
||||
#include "edtConfig.h"
|
||||
#include "layWidgets.h"
|
||||
#include "layQtTools.h"
|
||||
#include "layLayoutViewBase.h"
|
||||
#include "layDispatcher.h"
|
||||
#include "tlScriptError.h"
|
||||
|
||||
#include <QFrame>
|
||||
|
|
@ -148,9 +150,13 @@ static void set_value (const db::PCellParameterDeclaration &p, QWidget *widget,
|
|||
}
|
||||
}
|
||||
|
||||
PCellParametersPage::PCellParametersPage (QWidget *parent, bool dense)
|
||||
: QFrame (parent), m_dense (dense), m_show_parameter_names (false), dm_parameter_changed (this, &PCellParametersPage::do_parameter_changed)
|
||||
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)
|
||||
{
|
||||
if (mp_dispatcher) {
|
||||
mp_dispatcher->config_get (cfg_edit_pcell_show_parameter_names, m_show_parameter_names);
|
||||
}
|
||||
|
||||
init ();
|
||||
}
|
||||
|
||||
|
|
@ -168,6 +174,8 @@ PCellParametersPage::init ()
|
|||
QGridLayout *frame_layout = new QGridLayout (this);
|
||||
// spacing and margin for tool windows
|
||||
frame_layout->setContentsMargins (0, 0, 0, 0);
|
||||
frame_layout->setHorizontalSpacing (0);
|
||||
frame_layout->setVerticalSpacing (0);
|
||||
setLayout (frame_layout);
|
||||
|
||||
mp_update_frame = new QFrame (this);
|
||||
|
|
@ -209,11 +217,11 @@ PCellParametersPage::init ()
|
|||
error_frame_layout->setVerticalSpacing (2);
|
||||
}
|
||||
|
||||
mp_error_icon = new QLabel (mp_update_frame);
|
||||
mp_error_icon = new QLabel (mp_error_frame);
|
||||
mp_error_icon->setPixmap (QPixmap (":/warn_16px@2x.png"));
|
||||
error_frame_layout->addWidget (mp_error_icon, 1, 0, 1, 1);
|
||||
|
||||
mp_error_label = new QLabel (mp_update_frame);
|
||||
mp_error_label = new QLabel (mp_error_frame);
|
||||
mp_error_label->setWordWrap (true);
|
||||
palette = mp_error_label->palette ();
|
||||
palette.setColor (QPalette::WindowText, Qt::red);
|
||||
|
|
@ -225,10 +233,20 @@ PCellParametersPage::init ()
|
|||
|
||||
error_frame_layout->setColumnStretch (2, 1);
|
||||
|
||||
mp_show_parameter_names_cb = new QCheckBox (this);
|
||||
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);
|
||||
|
||||
QHBoxLayout *show_parameter_names_frame_layout = new QHBoxLayout (show_parameter_names_frame);
|
||||
show_parameter_names_frame->setLayout (show_parameter_names_frame_layout);
|
||||
if (m_dense) {
|
||||
show_parameter_names_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);
|
||||
frame_layout->addWidget (mp_show_parameter_names_cb, 3, 0, 1, 1);
|
||||
show_parameter_names_frame_layout->addWidget (mp_show_parameter_names_cb);
|
||||
|
||||
connect (mp_show_parameter_names_cb, SIGNAL (clicked (bool)), this, SLOT (show_parameter_names (bool)));
|
||||
}
|
||||
|
|
@ -248,6 +266,11 @@ PCellParametersPage::show_parameter_names (bool f)
|
|||
|
||||
m_show_parameter_names = f;
|
||||
mp_show_parameter_names_cb->setChecked (f);
|
||||
|
||||
if (mp_dispatcher) {
|
||||
mp_dispatcher->config_set (cfg_edit_pcell_show_parameter_names, m_show_parameter_names);
|
||||
}
|
||||
|
||||
setup (mp_view, m_cv_index, mp_pcell_decl.get (), get_parameters ());
|
||||
}
|
||||
|
||||
|
|
@ -528,6 +551,8 @@ PCellParametersPage::setup (lay::LayoutViewBase *view, int cv_index, const db::P
|
|||
}
|
||||
|
||||
m_initial_states = m_states;
|
||||
mp_error_frame->hide ();
|
||||
|
||||
update_widgets_from_states (m_states);
|
||||
|
||||
mp_parameters_area->setWidget (main_frame);
|
||||
|
|
@ -545,8 +570,6 @@ PCellParametersPage::get_state ()
|
|||
s.vScrollPosition = mp_parameters_area->verticalScrollBar ()->value ();
|
||||
s.hScrollPosition = mp_parameters_area->horizontalScrollBar ()->value ();
|
||||
|
||||
s.show_parameter_names = m_show_parameter_names;
|
||||
|
||||
if (focusWidget ()) {
|
||||
s.focusWidget = focusWidget ()->objectName ();
|
||||
}
|
||||
|
|
@ -562,10 +585,6 @@ PCellParametersPage::set_state (const State &s)
|
|||
mp_parameters_area->verticalScrollBar ()->setValue (s.vScrollPosition);
|
||||
mp_parameters_area->horizontalScrollBar ()->setValue (s.hScrollPosition);
|
||||
|
||||
if (s.show_parameter_names != m_show_parameter_names) {
|
||||
show_parameter_names (s.show_parameter_names);
|
||||
}
|
||||
|
||||
if (! s.focusWidget.isEmpty ()) {
|
||||
QWidget *c = findChild<QWidget *> (s.focusWidget);
|
||||
if (c) {
|
||||
|
|
@ -784,6 +803,7 @@ PCellParametersPage::get_parameters (db::ParameterStates &states, bool *ok)
|
|||
}
|
||||
|
||||
bool edit_error = false;
|
||||
mp_error_frame->hide ();
|
||||
|
||||
get_parameters_internal (states, edit_error);
|
||||
|
||||
|
|
@ -865,6 +885,8 @@ PCellParametersPage::set_parameters (const std::vector<tl::Variant> ¶meters)
|
|||
}
|
||||
|
||||
m_initial_states = m_states;
|
||||
mp_error_frame->hide ();
|
||||
|
||||
set_parameters_internal (m_states, false);
|
||||
}
|
||||
|
||||
|
|
@ -951,8 +973,6 @@ PCellParametersPage::set_parameters_internal (const db::ParameterStates &states,
|
|||
}
|
||||
}
|
||||
|
||||
mp_error_frame->hide ();
|
||||
|
||||
bool update_needed = false;
|
||||
|
||||
if (! tentatively) {
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@
|
|||
namespace lay
|
||||
{
|
||||
class LayoutViewBase;
|
||||
class Dispatcher;
|
||||
}
|
||||
|
||||
namespace edt
|
||||
|
|
@ -53,10 +54,9 @@ Q_OBJECT
|
|||
public:
|
||||
struct State
|
||||
{
|
||||
State () : valid (false), show_parameter_names (false), hScrollPosition (0), vScrollPosition (0) { }
|
||||
State () : valid (false), hScrollPosition (0), vScrollPosition (0) { }
|
||||
|
||||
bool valid;
|
||||
bool show_parameter_names;
|
||||
int hScrollPosition;
|
||||
int vScrollPosition;
|
||||
QString focusWidget;
|
||||
|
|
@ -69,7 +69,7 @@ public:
|
|||
*
|
||||
* @param dense Use a dense layout if true
|
||||
*/
|
||||
PCellParametersPage (QWidget *parent, bool dense = false);
|
||||
PCellParametersPage (QWidget *parent, lay::Dispatcher *dispatcher, bool dense = false);
|
||||
|
||||
/**
|
||||
* @brief initialization
|
||||
|
|
@ -148,6 +148,7 @@ private slots:
|
|||
void update_button_pressed ();
|
||||
|
||||
private:
|
||||
lay::Dispatcher *mp_dispatcher;
|
||||
QScrollArea *mp_parameters_area;
|
||||
QLabel *mp_error_label;
|
||||
QLabel *mp_error_icon;
|
||||
|
|
|
|||
|
|
@ -140,6 +140,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_x, "0.0"));
|
||||
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_max_shapes_of_instances, "1000"));
|
||||
options.push_back (std::pair<std::string, std::string> (cfg_edit_show_shapes_of_instances, "true"));
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue