mirror of https://github.com/KLayout/klayout.git
WIP: reworked drag&drop from library view into canvas - now will switch to instance mode and take parameters from the instance options rather than popping up a PCell dialog and using mag 1, no mirror, no rotation etc.
This commit is contained in:
parent
701f690053
commit
4ffae9668e
|
|
@ -21,7 +21,6 @@ HEADERS = \
|
||||||
edtServiceImpl.h \
|
edtServiceImpl.h \
|
||||||
edtUtils.h \
|
edtUtils.h \
|
||||||
edtCommon.h \
|
edtCommon.h \
|
||||||
edtPCellParametersDialog.h \
|
|
||||||
edtDistribute.h
|
edtDistribute.h
|
||||||
|
|
||||||
FORMS = \
|
FORMS = \
|
||||||
|
|
@ -61,7 +60,6 @@ SOURCES = \
|
||||||
edtServiceImpl.cc \
|
edtServiceImpl.cc \
|
||||||
edtUtils.cc \
|
edtUtils.cc \
|
||||||
gsiDeclEdt.cc \
|
gsiDeclEdt.cc \
|
||||||
edtPCellParametersDialog.cc \
|
|
||||||
edtDistribute.cc
|
edtDistribute.cc
|
||||||
|
|
||||||
INCLUDEPATH += $$TL_INC $$GSI_INC $$LAYBASIC_INC $$DB_INC
|
INCLUDEPATH += $$TL_INC $$GSI_INC $$LAYBASIC_INC $$DB_INC
|
||||||
|
|
|
||||||
|
|
@ -1,65 +0,0 @@
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
KLayout Layout Viewer
|
|
||||||
Copyright (C) 2006-2020 Matthias Koefferlein
|
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation; either version 2 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#include "edtPCellParametersDialog.h"
|
|
||||||
|
|
||||||
#include <QPushButton>
|
|
||||||
|
|
||||||
namespace edt
|
|
||||||
{
|
|
||||||
|
|
||||||
PCellParametersDialog::PCellParametersDialog (QWidget *parent)
|
|
||||||
: QDialog (parent)
|
|
||||||
{
|
|
||||||
setupUi (this);
|
|
||||||
|
|
||||||
connect (buttons->button (QDialogButtonBox::Apply), SIGNAL (clicked ()), this, SLOT (apply_pressed ()));
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
PCellParametersDialog::apply_pressed ()
|
|
||||||
{
|
|
||||||
emit parameters_changed ();
|
|
||||||
parameters_changed_event ();
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<tl::Variant>
|
|
||||||
PCellParametersDialog::get_parameters ()
|
|
||||||
{
|
|
||||||
return parameters->get_parameters ();
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
PCellParametersDialog::set_parameters (const std::vector<tl::Variant> &p)
|
|
||||||
{
|
|
||||||
parameters->set_parameters (p);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
PCellParametersDialog::exec (const db::Layout *layout, lay::LayoutView *view, int cv_index, const db::PCellDeclaration *pcell_decl, const db::pcell_parameters_type &p)
|
|
||||||
{
|
|
||||||
parameters->setup (layout, view, cv_index, pcell_decl, p);
|
|
||||||
return QDialog::exec ();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,86 +0,0 @@
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
KLayout Layout Viewer
|
|
||||||
Copyright (C) 2006-2020 Matthias Koefferlein
|
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation; either version 2 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef HDR_edtPCellParametersDialog
|
|
||||||
#define HDR_edtPCellParametersDialog
|
|
||||||
|
|
||||||
#include "dbPCellDeclaration.h"
|
|
||||||
#include "ui_PCellParametersDialog.h"
|
|
||||||
|
|
||||||
#include <QDialog>
|
|
||||||
|
|
||||||
namespace lay
|
|
||||||
{
|
|
||||||
class LayoutView;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace edt
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief A QScrollArea that displays and allows editing PCell parameters
|
|
||||||
*/
|
|
||||||
class PCellParametersDialog
|
|
||||||
: public QDialog, private Ui::PCellParametersDialog
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
/**
|
|
||||||
* @brief Constructor: create a dialog showing the given parameters
|
|
||||||
* @param parent The parent widget
|
|
||||||
*/
|
|
||||||
PCellParametersDialog (QWidget *parent);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Executes the parameter dialog
|
|
||||||
* @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)
|
|
||||||
*/
|
|
||||||
int exec (const db::Layout *layout, lay::LayoutView *view, int cv_index, const db::PCellDeclaration *pcell_decl, const db::pcell_parameters_type &p);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Get the current parameters
|
|
||||||
*/
|
|
||||||
std::vector<tl::Variant> get_parameters ();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Sets the given parameters as values
|
|
||||||
*/
|
|
||||||
void set_parameters (const std::vector<tl::Variant> &values);
|
|
||||||
|
|
||||||
tl::Event parameters_changed_event;
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void parameters_changed ();
|
|
||||||
|
|
||||||
private slots:
|
|
||||||
void apply_pressed ();
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -25,7 +25,6 @@
|
||||||
#include "edtServiceImpl.h"
|
#include "edtServiceImpl.h"
|
||||||
#include "edtPropertiesPages.h"
|
#include "edtPropertiesPages.h"
|
||||||
#include "edtInstPropertiesPage.h"
|
#include "edtInstPropertiesPage.h"
|
||||||
#include "edtPCellParametersDialog.h"
|
|
||||||
#include "edtService.h"
|
#include "edtService.h"
|
||||||
#include "dbEdge.h"
|
#include "dbEdge.h"
|
||||||
#include "dbLibrary.h"
|
#include "dbLibrary.h"
|
||||||
|
|
@ -1130,17 +1129,14 @@ InstService::get_default_layer_for_pcell ()
|
||||||
|
|
||||||
bool
|
bool
|
||||||
InstService::drag_enter_event (const db::DPoint &p, const lay::DragDropDataBase *data)
|
InstService::drag_enter_event (const db::DPoint &p, const lay::DragDropDataBase *data)
|
||||||
{
|
{
|
||||||
const lay::CellDragDropData *cd = dynamic_cast <const lay::CellDragDropData *> (data);
|
const lay::CellDragDropData *cd = dynamic_cast <const lay::CellDragDropData *> (data);
|
||||||
if (view ()->is_editable () && cd && (cd->layout () == & view ()->active_cellview ()->layout () || cd->library ())) {
|
if (view ()->is_editable () && cd && (cd->layout () == & view ()->active_cellview ()->layout () || cd->library ())) {
|
||||||
|
|
||||||
view ()->cancel ();
|
view ()->cancel ();
|
||||||
|
|
||||||
set_edit_marker (0);
|
set_edit_marker (0);
|
||||||
|
|
||||||
m_cv_index = view ()->active_cellview_index ();
|
// configure from the drag/drop data
|
||||||
m_in_drag_drop = true;
|
|
||||||
|
|
||||||
if (cd->library ()) {
|
if (cd->library ()) {
|
||||||
if (m_lib_name != cd->library ()->get_name ()) {
|
if (m_lib_name != cd->library ()->get_name ()) {
|
||||||
m_lib_name = cd->library ()->get_name ();
|
m_lib_name = cd->library ()->get_name ();
|
||||||
|
|
@ -1155,38 +1151,45 @@ InstService::drag_enter_event (const db::DPoint &p, const lay::DragDropDataBase
|
||||||
if (cd->is_pcell ()) {
|
if (cd->is_pcell ()) {
|
||||||
|
|
||||||
const db::PCellDeclaration *pcell_decl = cd->layout ()->pcell_declaration (cd->cell_index ());
|
const db::PCellDeclaration *pcell_decl = cd->layout ()->pcell_declaration (cd->cell_index ());
|
||||||
if (pcell_decl) {
|
if (! pcell_decl) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (m_cell_or_pcell_name != pcell_decl->name ()) {
|
if (m_cell_or_pcell_name != pcell_decl->name ()) {
|
||||||
m_cell_or_pcell_name = pcell_decl->name ();
|
m_cell_or_pcell_name = pcell_decl->name ();
|
||||||
m_pcell_parameters.clear ();
|
m_pcell_parameters.clear ();
|
||||||
|
}
|
||||||
|
|
||||||
|
m_is_pcell = true;
|
||||||
|
|
||||||
|
// NOTE: we reuse previous parameters for convenience unless PCell or library has changed
|
||||||
|
const std::vector<db::PCellParameterDeclaration> &pd = pcell_decl->parameter_declarations();
|
||||||
|
for (std::vector<db::PCellParameterDeclaration>::const_iterator i = pd.begin (); i != pd.end (); ++i) {
|
||||||
|
if (i->get_type () == db::PCellParameterDeclaration::t_layer && !i->is_hidden () && !i->is_readonly () && i->get_default ().is_nil ()) {
|
||||||
|
m_pcell_parameters.insert (std::make_pair (i->get_name (), get_default_layer_for_pcell ()));
|
||||||
|
} else {
|
||||||
|
m_pcell_parameters.insert (std::make_pair (i->get_name (), i->get_default ()));
|
||||||
}
|
}
|
||||||
|
|
||||||
m_is_pcell = true;
|
|
||||||
|
|
||||||
// NOTE: we reuse previous parameters for convenience unless PCell or library has changed
|
|
||||||
const std::vector<db::PCellParameterDeclaration> &pd = pcell_decl->parameter_declarations();
|
|
||||||
for (std::vector<db::PCellParameterDeclaration>::const_iterator i = pd.begin (); i != pd.end (); ++i) {
|
|
||||||
if (i->get_type () == db::PCellParameterDeclaration::t_layer && !i->is_hidden () && !i->is_readonly () && i->get_default ().is_nil ()) {
|
|
||||||
m_pcell_parameters.insert (std::make_pair (i->get_name (), get_default_layer_for_pcell ()));
|
|
||||||
} else {
|
|
||||||
m_pcell_parameters.insert (std::make_pair (i->get_name (), i->get_default ()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
do_begin_edit (p);
|
|
||||||
return true;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (cd->layout ()->is_valid_cell_index (cd->cell_index ())) {
|
} else if (cd->layout ()->is_valid_cell_index (cd->cell_index ())) {
|
||||||
|
|
||||||
m_cell_or_pcell_name = cd->layout ()->cell_name (cd->cell_index ());
|
m_cell_or_pcell_name = cd->layout ()->cell_name (cd->cell_index ());
|
||||||
do_begin_edit (p);
|
|
||||||
return true;
|
|
||||||
|
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sync_to_config ();
|
||||||
|
m_in_drag_drop = true;
|
||||||
|
|
||||||
|
view ()->switch_mode (plugin_declaration ()->id ());
|
||||||
|
|
||||||
|
do_begin_edit (p);
|
||||||
|
|
||||||
|
// action taken.
|
||||||
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -1203,7 +1206,7 @@ InstService::drag_move_event (const db::DPoint &p, const lay::DragDropDataBase *
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
InstService::drag_leave_event ()
|
InstService::drag_leave_event ()
|
||||||
{
|
{
|
||||||
if (m_in_drag_drop) {
|
if (m_in_drag_drop) {
|
||||||
|
|
@ -1212,7 +1215,7 @@ InstService::drag_leave_event ()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
InstService::selection_applies (const lay::ObjectInstPath &sel) const
|
InstService::selection_applies (const lay::ObjectInstPath &sel) const
|
||||||
{
|
{
|
||||||
return sel.is_cell_inst ();
|
return sel.is_cell_inst ();
|
||||||
|
|
@ -1221,53 +1224,8 @@ InstService::selection_applies (const lay::ObjectInstPath &sel) const
|
||||||
bool
|
bool
|
||||||
InstService::drop_event (const db::DPoint & /*p*/, const lay::DragDropDataBase * /*data*/)
|
InstService::drop_event (const db::DPoint & /*p*/, const lay::DragDropDataBase * /*data*/)
|
||||||
{
|
{
|
||||||
if (m_in_drag_drop) {
|
m_in_drag_drop = false;
|
||||||
|
return false;
|
||||||
const lay::CellView &cv = view ()->cellview (m_cv_index);
|
|
||||||
if (! cv.is_valid ()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
make_cell (cv);
|
|
||||||
|
|
||||||
bool accepted = true;
|
|
||||||
|
|
||||||
if (m_has_valid_cell && mp_pcell_decl) {
|
|
||||||
|
|
||||||
std::vector<tl::Variant> pv = mp_pcell_decl->map_parameters (m_pcell_parameters);
|
|
||||||
|
|
||||||
// Turn off the drag cursor for the modal dialog
|
|
||||||
QApplication::restoreOverrideCursor ();
|
|
||||||
|
|
||||||
// for PCells dragged show the parameter dialog for a chance to edit the initial parameters
|
|
||||||
if (! mp_pcell_parameters_dialog.get ()) {
|
|
||||||
mp_pcell_parameters_dialog.reset (new edt::PCellParametersDialog (view ()));
|
|
||||||
mp_pcell_parameters_dialog->parameters_changed_event.add (this, &InstService::apply_edits);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (! mp_pcell_parameters_dialog->exec (mp_current_layout, view (), m_cv_index, mp_pcell_decl, pv)) {
|
|
||||||
accepted = false;
|
|
||||||
} else {
|
|
||||||
m_has_valid_cell = false;
|
|
||||||
m_pcell_parameters = mp_pcell_decl->named_parameters (mp_pcell_parameters_dialog->get_parameters ());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
set_edit_marker (0);
|
|
||||||
|
|
||||||
if (accepted) {
|
|
||||||
do_finish_edit ();
|
|
||||||
} else {
|
|
||||||
do_cancel_edit ();
|
|
||||||
}
|
|
||||||
|
|
||||||
sync_to_config ();
|
|
||||||
return true;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
@ -1538,6 +1496,8 @@ InstService::do_cancel_edit ()
|
||||||
m_has_valid_cell = false;
|
m_has_valid_cell = false;
|
||||||
m_in_drag_drop = false;
|
m_in_drag_drop = false;
|
||||||
|
|
||||||
|
set_edit_marker (0);
|
||||||
|
|
||||||
// clean up any proxy cells created so far
|
// clean up any proxy cells created so far
|
||||||
const lay::CellView &cv = view ()->cellview (m_cv_index);
|
const lay::CellView &cv = view ()->cellview (m_cv_index);
|
||||||
if (cv.is_valid ()) {
|
if (cv.is_valid ()) {
|
||||||
|
|
@ -1651,16 +1611,6 @@ InstService::config_finalize ()
|
||||||
edt::Service::config_finalize ();
|
edt::Service::config_finalize ();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
InstService::apply_edits()
|
|
||||||
{
|
|
||||||
if (mp_pcell_decl && mp_pcell_parameters_dialog.get ()) {
|
|
||||||
m_pcell_parameters = mp_pcell_decl->named_parameters (mp_pcell_parameters_dialog->get_parameters ());
|
|
||||||
}
|
|
||||||
|
|
||||||
sync_to_config ();
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
InstService::update_marker ()
|
InstService::update_marker ()
|
||||||
{
|
{
|
||||||
|
|
@ -1685,14 +1635,9 @@ InstService::get_inst (db::CellInstArray &inst)
|
||||||
|
|
||||||
// compute the instance's transformation
|
// compute the instance's transformation
|
||||||
db::VCplxTrans pt = (db::CplxTrans (cv->layout ().dbu ()) * m_trans).inverted ();
|
db::VCplxTrans pt = (db::CplxTrans (cv->layout ().dbu ()) * m_trans).inverted ();
|
||||||
db::ICplxTrans trans;
|
db::ICplxTrans trans = db::ICplxTrans (m_scale, m_angle, m_mirror, pt * m_disp - db::Point ());
|
||||||
if (m_in_drag_drop) {
|
|
||||||
trans = db::ICplxTrans (1.0, 0.0, false, pt * m_disp - db::Point ());
|
|
||||||
} else {
|
|
||||||
trans = db::ICplxTrans (m_scale, m_angle, m_mirror, pt * m_disp - db::Point ());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (! m_in_drag_drop && m_array && m_rows > 0 && m_columns > 0) {
|
if (m_array && m_rows > 0 && m_columns > 0) {
|
||||||
db::Vector row = db::Vector (pt * db::DVector (m_row_x, m_row_y));
|
db::Vector row = db::Vector (pt * db::DVector (m_row_x, m_row_y));
|
||||||
db::Vector column = db::Vector (pt * db::DVector (m_column_x, m_column_y));
|
db::Vector column = db::Vector (pt * db::DVector (m_column_x, m_column_y));
|
||||||
inst = db::CellInstArray (db::CellInst (ci.second), trans, row, column, m_rows, m_columns);
|
inst = db::CellInstArray (db::CellInst (ci.second), trans, row, column, m_rows, m_columns);
|
||||||
|
|
|
||||||
|
|
@ -38,8 +38,6 @@ namespace lay
|
||||||
namespace edt
|
namespace edt
|
||||||
{
|
{
|
||||||
|
|
||||||
class PCellParametersDialog;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Implementation of the edt::Service for generic shape editing
|
* @brief Implementation of the edt::Service for generic shape editing
|
||||||
*/
|
*/
|
||||||
|
|
@ -245,10 +243,8 @@ private:
|
||||||
const db::PCellDeclaration *mp_pcell_decl;
|
const db::PCellDeclaration *mp_pcell_decl;
|
||||||
int m_cv_index;
|
int m_cv_index;
|
||||||
db::ICplxTrans m_trans;
|
db::ICplxTrans m_trans;
|
||||||
std::auto_ptr<edt::PCellParametersDialog> mp_pcell_parameters_dialog;
|
|
||||||
|
|
||||||
void update_marker ();
|
void update_marker ();
|
||||||
void apply_edits ();
|
|
||||||
bool get_inst (db::CellInstArray &inst);
|
bool get_inst (db::CellInstArray &inst);
|
||||||
std::pair<bool, db::cell_index_type> make_cell (const lay::CellView &cv);
|
std::pair<bool, db::cell_index_type> make_cell (const lay::CellView &cv);
|
||||||
tl::Variant get_default_layer_for_pcell ();
|
tl::Variant get_default_layer_for_pcell ();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue