Some refactoring (generalizing edt:: functions, basing move tool on lay::EditorService and support for 'tab' key (calls 'move by')

This commit is contained in:
Matthias Koefferlein 2025-09-08 18:54:00 +02:00
parent e9584c289a
commit 20a3dbeaf8
25 changed files with 122 additions and 142 deletions

View File

@ -80,7 +80,6 @@ HEADERS += \
edtPartialService.h \ edtPartialService.h \
edtPlugin.h \ edtPlugin.h \
edtService.h \ edtService.h \
edtUtils.h \
edtCommon.h \ edtCommon.h \
edtDistribute.h \ edtDistribute.h \
@ -91,7 +90,6 @@ SOURCES += \
edtPartialService.cc \ edtPartialService.cc \
edtPlugin.cc \ edtPlugin.cc \
edtService.cc \ edtService.cc \
edtUtils.cc \
gsiDeclEdt.cc \ gsiDeclEdt.cc \
edtDistribute.cc \ edtDistribute.cc \

View File

@ -28,11 +28,6 @@
namespace edt namespace edt
{ {
int snap_range_pixels ()
{
return 8; // TODO: make variable
}
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
std::string cfg_edit_grid ("edit-grid"); std::string cfg_edit_grid ("edit-grid");

View File

@ -118,8 +118,6 @@ struct EDT_PUBLIC VAlignConverter
void from_string (const std::string &s, db::VAlign &a); void from_string (const std::string &s, db::VAlign &a);
}; };
int EDT_PUBLIC snap_range_pixels ();
} }
#endif #endif

View File

@ -26,7 +26,7 @@
#include "dbLayout.h" #include "dbLayout.h"
#include "edtDialogs.h" #include "edtDialogs.h"
#include "edtUtils.h" #include "layEditorUtils.h"
#include "layObjectInstPath.h" #include "layObjectInstPath.h"
#include "layCellView.h" #include "layCellView.h"
#include "layLayoutViewBase.h" #include "layLayoutViewBase.h"

View File

@ -725,7 +725,7 @@ EditorOptionsInstPCellParam::apply (lay::Dispatcher *root)
if (pc.first) { if (pc.first) {
const db::PCellDeclaration *pc_decl = layout->pcell_declaration (pc.second); const db::PCellDeclaration *pc_decl = layout->pcell_declaration (pc.second);
if (pc_decl) { if (pc_decl) {
param = pcell_parameters_to_string (pc_decl->named_parameters (mp_pcell_parameters->get_parameters (&ok))); param = lay::pcell_parameters_to_string (pc_decl->named_parameters (mp_pcell_parameters->get_parameters (&ok)));
} }
} }
} }

View File

@ -197,7 +197,7 @@ InstService::sync_to_config ()
dispatcher ()->config_set (cfg_edit_inst_lib_name, m_lib_name); dispatcher ()->config_set (cfg_edit_inst_lib_name, m_lib_name);
dispatcher ()->config_set (cfg_edit_inst_cell_name, m_cell_or_pcell_name); dispatcher ()->config_set (cfg_edit_inst_cell_name, m_cell_or_pcell_name);
if (m_is_pcell) { if (m_is_pcell) {
dispatcher ()->config_set (cfg_edit_inst_pcell_parameters, pcell_parameters_to_string (m_pcell_parameters)); dispatcher ()->config_set (cfg_edit_inst_pcell_parameters, lay::pcell_parameters_to_string (m_pcell_parameters));
} else { } else {
dispatcher ()->config_set (cfg_edit_inst_pcell_parameters, std::string ()); dispatcher ()->config_set (cfg_edit_inst_pcell_parameters, std::string ());
} }
@ -531,7 +531,7 @@ InstService::configure (const std::string &name, const std::string &value)
if (name == cfg_edit_inst_pcell_parameters) { if (name == cfg_edit_inst_pcell_parameters) {
std::map<std::string, tl::Variant> pcp = pcell_parameters_from_string (value); std::map<std::string, tl::Variant> pcp = lay::pcell_parameters_from_string (value);
if (pcp != m_pcell_parameters) { if (pcp != m_pcell_parameters) {
m_pcell_parameters = pcp; m_pcell_parameters = pcp;
@ -772,7 +772,7 @@ InstService::config_finalize ()
// TODO: it's somewhat questionable to do this inside "config_finalize" as this method is supposed // TODO: it's somewhat questionable to do this inside "config_finalize" as this method is supposed
// to reflect changes rather than induce some. // to reflect changes rather than induce some.
if (m_is_pcell) { if (m_is_pcell) {
dispatcher ()->config_set (cfg_edit_inst_pcell_parameters, pcell_parameters_to_string (m_pcell_parameters)); dispatcher ()->config_set (cfg_edit_inst_pcell_parameters, lay::pcell_parameters_to_string (m_pcell_parameters));
} else { } else {
dispatcher ()->config_set (cfg_edit_inst_pcell_parameters, std::string ()); dispatcher ()->config_set (cfg_edit_inst_pcell_parameters, std::string ());
} }

View File

@ -29,10 +29,10 @@
#include "layPlugin.h" #include "layPlugin.h"
#include "layViewObject.h" #include "layViewObject.h"
#include "layMarker.h" #include "layMarker.h"
#include "layEditorUtils.h"
#include "dbLayout.h" #include "dbLayout.h"
#include "dbShape.h" #include "dbShape.h"
#include "dbClipboard.h" #include "dbClipboard.h"
#include "edtUtils.h"
#include <set> #include <set>
#include <vector> #include <vector>

View File

@ -61,7 +61,7 @@ MoveTrackerService::issue_edit_events ()
call_editor_hooks (m_editor_hooks, &edt::EditorHooks::begin_edits); call_editor_hooks (m_editor_hooks, &edt::EditorHooks::begin_edits);
// build the transformation variants cache // build the transformation variants cache
TransformationVariants tv (view ()); lay::TransformationVariants tv (view ());
std::vector<edt::Service *> services = view ()->get_plugins<edt::Service> (); std::vector<edt::Service *> services = view ()->get_plugins<edt::Service> ();
std::vector<lay::ObjectInstPath> sel; std::vector<lay::ObjectInstPath> sel;

View File

@ -1213,7 +1213,7 @@ PartialService::timeout ()
partial_objects::const_iterator r = transient_selection.begin (); partial_objects::const_iterator r = transient_selection.begin ();
// build the transformation variants cache // build the transformation variants cache
TransformationVariants tv (view ()); lay::TransformationVariants tv (view ());
const lay::CellView &cv = view ()->cellview (r->first.cv_index ()); const lay::CellView &cv = view ()->cellview (r->first.cv_index ());
@ -1468,7 +1468,7 @@ PartialService::issue_editor_hook_calls (const tl::weak_collection<edt::EditorHo
db::DTrans move_trans = db::DTrans (m_current - m_start); db::DTrans move_trans = db::DTrans (m_current - m_start);
// build the transformation variants cache // build the transformation variants cache
TransformationVariants tv (view ()); lay::TransformationVariants tv (view ());
// Issue editor hook calls for the shape modification events // Issue editor hook calls for the shape modification events
@ -1559,7 +1559,7 @@ PartialService::issue_editor_hook_calls (const tl::weak_collection<edt::EditorHo
} }
db::Shape db::Shape
PartialService::modify_shape (TransformationVariants &tv, const db::Shape &shape_in, const lay::ObjectInstPath &path, const std::set <EdgeWithIndex> &sel, const db::DTrans &move_trans, std::map <EdgeWithIndex, db::Edge> &new_edges, std::map <PointWithIndex, db::Point> &new_points) PartialService::modify_shape (lay::TransformationVariants &tv, const db::Shape &shape_in, const lay::ObjectInstPath &path, const std::set <EdgeWithIndex> &sel, const db::DTrans &move_trans, std::map <EdgeWithIndex, db::Edge> &new_edges, std::map <PointWithIndex, db::Point> &new_points)
{ {
tl_assert (shape_in.shapes () != 0); tl_assert (shape_in.shapes () != 0);
db::Shape shape = shape_in; db::Shape shape = shape_in;
@ -1642,7 +1642,7 @@ void
PartialService::transform_selection (const db::DTrans &move_trans) PartialService::transform_selection (const db::DTrans &move_trans)
{ {
// build the transformation variants cache // build the transformation variants cache
TransformationVariants tv (view ()); lay::TransformationVariants tv (view ());
// since a shape reference may become invalid while moving it and // since a shape reference may become invalid while moving it and
// because it creates ambiguities, we treat each shape separately: // because it creates ambiguities, we treat each shape separately:
@ -1798,7 +1798,7 @@ PartialService::mouse_move_event (const db::DPoint &p, unsigned int buttons, boo
set_cursor (lay::Cursor::size_all); set_cursor (lay::Cursor::size_all);
m_alt_ac = ac_from_buttons (buttons); m_alt_ac = lay::ac_from_buttons (buttons);
// drag the vertex or edge/segment // drag the vertex or edge/segment
if (is_single_point_selection () || is_single_edge_selection ()) { if (is_single_point_selection () || is_single_edge_selection ()) {
@ -1862,7 +1862,7 @@ PartialService::mouse_move_event (const db::DPoint &p, unsigned int buttons, boo
if (mp_box) { if (mp_box) {
m_alt_ac = ac_from_buttons (buttons); m_alt_ac = lay::ac_from_buttons (buttons);
m_p2 = p; m_p2 = p;
mp_box->set_points (m_p1, m_p2); mp_box->set_points (m_p1, m_p2);
@ -1922,7 +1922,7 @@ PartialService::mouse_press_event (const db::DPoint &p, unsigned int buttons, bo
} else if (! mp_box) { } else if (! mp_box) {
m_alt_ac = ac_from_buttons (buttons); m_alt_ac = lay::ac_from_buttons (buttons);
if (m_selection.empty ()) { if (m_selection.empty ()) {
@ -2015,7 +2015,7 @@ PartialService::mouse_click_event (const db::DPoint &p, unsigned int buttons, bo
if (m_dragging) { if (m_dragging) {
m_alt_ac = ac_from_buttons (buttons); m_alt_ac = lay::ac_from_buttons (buttons);
if (m_current != m_start) { if (m_current != m_start) {
@ -2059,7 +2059,7 @@ PartialService::mouse_click_event (const db::DPoint &p, unsigned int buttons, bo
view ()->clear_selection (); view ()->clear_selection ();
m_selection = selection; m_selection = selection;
m_alt_ac = ac_from_buttons (buttons); m_alt_ac = lay::ac_from_buttons (buttons);
lay::Editable::SelectionMode mode = lay::Editable::Replace; lay::Editable::SelectionMode mode = lay::Editable::Replace;
bool shift = ((buttons & lay::ShiftButton) != 0); bool shift = ((buttons & lay::ShiftButton) != 0);
@ -2192,7 +2192,7 @@ PartialService::mouse_double_click_event (const db::DPoint &p, unsigned int butt
if ((buttons & lay::LeftButton) != 0 && prio) { if ((buttons & lay::LeftButton) != 0 && prio) {
m_alt_ac = ac_from_buttons (buttons); m_alt_ac = lay::ac_from_buttons (buttons);
close_editor_hooks (false); close_editor_hooks (false);
@ -2215,7 +2215,7 @@ PartialService::mouse_double_click_event (const db::DPoint &p, unsigned int butt
db::DPoint new_point_d = snap (p); db::DPoint new_point_d = snap (p);
// build the transformation variants cache // build the transformation variants cache
TransformationVariants tv (view (), true /*per cv and layer*/, false /*per cv*/); lay::TransformationVariants tv (view (), true /*per cv and layer*/, false /*per cv*/);
const std::vector<db::DCplxTrans> *tv_list = tv.per_cv_and_layer (r->first.cv_index (), r->first.layer ()); const std::vector<db::DCplxTrans> *tv_list = tv.per_cv_and_layer (r->first.cv_index (), r->first.layer ());
if (tv_list && ! tv_list->empty ()) { if (tv_list && ! tv_list->empty ()) {
@ -2304,7 +2304,7 @@ PartialService::mouse_release_event (const db::DPoint &p, unsigned int buttons,
if (prio && mp_box) { if (prio && mp_box) {
m_alt_ac = ac_from_buttons (buttons); m_alt_ac = lay::ac_from_buttons (buttons);
ui ()->ungrab_mouse (this); ui ()->ungrab_mouse (this);
@ -2402,7 +2402,7 @@ PartialService::snap_marker_to_grid (const db::DVector &v, bool &snapped) const
db::DVector snapped_to (1.0, 1.0); db::DVector snapped_to (1.0, 1.0);
db::DVector vv = lay::snap_angle (v, move_ac (), &snapped_to); db::DVector vv = lay::snap_angle (v, move_ac (), &snapped_to);
TransformationVariants tv (view ()); lay::TransformationVariants tv (view ());
for (auto r = m_selection.begin (); r != m_selection.end (); ++r) { for (auto r = m_selection.begin (); r != m_selection.end (); ++r) {
@ -2548,7 +2548,7 @@ PartialService::selection_bbox ()
{ {
// build the transformation variants cache // build the transformation variants cache
// TODO: this is done multiple times - once for each service! // TODO: this is done multiple times - once for each service!
TransformationVariants tv (view ()); lay::TransformationVariants tv (view ());
const db::DCplxTrans &vp = view ()->viewport ().trans (); const db::DCplxTrans &vp = view ()->viewport ().trans ();
lay::TextInfo text_info (view ()); lay::TextInfo text_info (view ());
@ -2938,7 +2938,7 @@ PartialService::single_selected_point () const
// build the transformation variants cache and // build the transformation variants cache and
// use only the first one of the explicit transformations // use only the first one of the explicit transformations
// TODO: clarify how this can be implemented in a more generic form or leave it thus. // TODO: clarify how this can be implemented in a more generic form or leave it thus.
TransformationVariants tv (view ()); lay::TransformationVariants tv (view ());
const std::vector<db::DCplxTrans> *tv_list = tv.per_cv_and_layer (m_selection.begin ()->first.cv_index (), m_selection.begin ()->first.layer ()); const std::vector<db::DCplxTrans> *tv_list = tv.per_cv_and_layer (m_selection.begin ()->first.cv_index (), m_selection.begin ()->first.layer ());
const lay::CellView &cv = view ()->cellview (m_selection.begin ()->first.cv_index ()); const lay::CellView &cv = view ()->cellview (m_selection.begin ()->first.cv_index ());
@ -2960,7 +2960,7 @@ PartialService::single_selected_edge () const
// build the transformation variants cache and // build the transformation variants cache and
// use only the first one of the explicit transformations // use only the first one of the explicit transformations
// TODO: clarify how this can be implemented in a more generic form or leave it thus. // TODO: clarify how this can be implemented in a more generic form or leave it thus.
TransformationVariants tv (view ()); lay::TransformationVariants tv (view ());
const std::vector<db::DCplxTrans> *tv_list = tv.per_cv_and_layer (m_selection.begin ()->first.cv_index (), m_selection.begin ()->first.layer ()); const std::vector<db::DCplxTrans> *tv_list = tv.per_cv_and_layer (m_selection.begin ()->first.cv_index (), m_selection.begin ()->first.layer ());
const lay::CellView &cv = view ()->cellview (m_selection.begin ()->first.cv_index ()); const lay::CellView &cv = view ()->cellview (m_selection.begin ()->first.cv_index ());
@ -3042,7 +3042,7 @@ PartialService::do_selection_to_view ()
if (! m_selection.empty ()) { if (! m_selection.empty ()) {
// build the transformation variants cache // build the transformation variants cache
TransformationVariants tv (view ()); lay::TransformationVariants tv (view ());
for (partial_objects::const_iterator r = m_selection.begin (); r != m_selection.end (); ++r) { for (partial_objects::const_iterator r = m_selection.begin (); r != m_selection.end (); ++r) {
@ -3418,7 +3418,7 @@ PartialService::handle_guiding_shape_changes ()
// Hint: get_parameters_from_pcell_and_guiding_shapes invalidates the shapes because it resets the changed // Hint: get_parameters_from_pcell_and_guiding_shapes invalidates the shapes because it resets the changed
// guiding shapes. We must not access s->shape after that. // guiding shapes. We must not access s->shape after that.
if (! get_parameters_from_pcell_and_guiding_shapes (layout, s->first.cell_index (), parameters_for_pcell)) { if (! lay::get_parameters_from_pcell_and_guiding_shapes (layout, s->first.cell_index (), parameters_for_pcell)) {
return false; return false;
} }

View File

@ -30,9 +30,9 @@
#include "layViewObject.h" #include "layViewObject.h"
#include "layRubberBox.h" #include "layRubberBox.h"
#include "laySnap.h" #include "laySnap.h"
#include "layEditorUtils.h"
#include "tlAssert.h" #include "tlAssert.h"
#include "tlDeferredExecution.h" #include "tlDeferredExecution.h"
#include "edtUtils.h"
#include "edtConfig.h" #include "edtConfig.h"
#include "edtEditorHooks.h" #include "edtEditorHooks.h"
@ -400,7 +400,7 @@ private:
db::DEdge single_selected_edge () const; db::DEdge single_selected_edge () const;
bool handle_guiding_shape_changes (); bool handle_guiding_shape_changes ();
void transform_selection (const db::DTrans &move_trans); void transform_selection (const db::DTrans &move_trans);
db::Shape modify_shape (TransformationVariants &tv, const db::Shape &shape_in, const lay::ObjectInstPath &path, const std::set<EdgeWithIndex> &sel, const db::DTrans &move_trans, std::map <EdgeWithIndex, db::Edge> &new_edges, std::map <PointWithIndex, db::Point> &new_points); db::Shape modify_shape (lay::TransformationVariants &tv, const db::Shape &shape_in, const lay::ObjectInstPath &path, const std::set<EdgeWithIndex> &sel, const db::DTrans &move_trans, std::map <EdgeWithIndex, db::Edge> &new_edges, std::map <PointWithIndex, db::Point> &new_points);
void open_editor_hooks (); void open_editor_hooks ();
void close_editor_hooks (bool commit); void close_editor_hooks (bool commit);

View File

@ -325,7 +325,7 @@ db::Instance
PathService::make_via (const db::SelectedViaDefinition &via_def, double w_bottom, double h_bottom, double w_top, double h_top, const db::DPoint &via_pos) PathService::make_via (const db::SelectedViaDefinition &via_def, double w_bottom, double h_bottom, double w_top, double h_top, const db::DPoint &via_pos)
{ {
if (! via_def.via_type.cut.is_null ()) { if (! via_def.via_type.cut.is_null ()) {
edt::set_or_request_current_layer (view (), via_def.via_type.cut, cv_index (), false /*don't make current*/); lay::set_or_request_current_layer (view (), via_def.via_type.cut, cv_index (), false /*don't make current*/);
} }
std::map<std::string, tl::Variant> params; std::map<std::string, tl::Variant> params;

View File

@ -23,11 +23,11 @@
#if defined(HAVE_QT) #if defined(HAVE_QT)
#include "edtRecentConfigurationPage.h" #include "edtRecentConfigurationPage.h"
#include "edtUtils.h"
#include "layDispatcher.h" #include "layDispatcher.h"
#include "layLayoutViewBase.h" #include "layLayoutViewBase.h"
#include "layLayerTreeModel.h" #include "layLayerTreeModel.h"
#include "layBusy.h" #include "layBusy.h"
#include "layEditorUtils.h"
#include "dbLibraryManager.h" #include "dbLibraryManager.h"
#include "dbLibrary.h" #include "dbLibrary.h"
#include "tlLog.h" #include "tlLog.h"
@ -267,7 +267,7 @@ RecentConfigurationPage::render_to (QTreeWidgetItem *item, int column, const std
std::map<std::string, tl::Variant> pcp; std::map<std::string, tl::Variant> pcp;
for (std::list<ConfigurationDescriptor>::const_iterator c = m_cfg.begin (); c != m_cfg.end (); ++c, ++pcp_column) { for (std::list<ConfigurationDescriptor>::const_iterator c = m_cfg.begin (); c != m_cfg.end (); ++c, ++pcp_column) {
if (c->rendering == RecentConfigurationPage::PCellParameters) { if (c->rendering == RecentConfigurationPage::PCellParameters) {
pcp = pcell_parameters_from_string (values [pcp_column]); pcp = lay::pcell_parameters_from_string (values [pcp_column]);
break; break;
} }
} }
@ -296,7 +296,7 @@ RecentConfigurationPage::render_to (QTreeWidgetItem *item, int column, const std
{ {
std::map<std::string, tl::Variant> pcp; std::map<std::string, tl::Variant> pcp;
try { try {
pcp = pcell_parameters_from_string (values [column]); pcp = lay::pcell_parameters_from_string (values [column]);
} catch (tl::Exception &ex) { } catch (tl::Exception &ex) {
tl::error << tl::to_string (tr ("Configuration error (PCellParameters): ")) << ex.msg (); tl::error << tl::to_string (tr ("Configuration error (PCellParameters): ")) << ex.msg ();
} }
@ -384,7 +384,7 @@ RecentConfigurationPage::item_clicked (QTreeWidgetItem *item)
ex.read (cv_index); ex.read (cv_index);
} }
edt::set_or_request_current_layer (view (), lp, cv_index); lay::set_or_request_current_layer (view (), lp, cv_index);
} else { } else {
dispatcher ()->config_set (c->cfg_name, v); dispatcher ()->config_set (c->cfg_name, v);

View File

@ -283,7 +283,7 @@ Service::snap (const db::DPoint &p, const db::DPoint &plast, bool connect) const
lay::PointSnapToObjectResult lay::PointSnapToObjectResult
Service::snap2_details (const db::DPoint &p) const Service::snap2_details (const db::DPoint &p) const
{ {
double snap_range = ui ()->mouse_event_trans ().inverted ().ctrans (edt::snap_range_pixels ()); double snap_range = ui ()->mouse_event_trans ().inverted ().ctrans (lay::snap_range_pixels ());
return lay::obj_snap (m_snap_to_objects ? view () : 0, p, m_edit_grid == db::DVector () ? m_global_grid : m_edit_grid, snap_range); return lay::obj_snap (m_snap_to_objects ? view () : 0, p, m_edit_grid == db::DVector () ? m_global_grid : m_edit_grid, snap_range);
} }
@ -296,7 +296,7 @@ Service::snap2 (const db::DPoint &p) const
db::DPoint db::DPoint
Service::snap2 (const db::DPoint &p, const db::DPoint &plast, bool connect) const Service::snap2 (const db::DPoint &p, const db::DPoint &plast, bool connect) const
{ {
double snap_range = ui ()->mouse_event_trans ().inverted ().ctrans (edt::snap_range_pixels ()); double snap_range = ui ()->mouse_event_trans ().inverted ().ctrans (lay::snap_range_pixels ());
return lay::obj_snap (m_snap_to_objects ? view () : 0, plast, p, m_edit_grid == db::DVector () ? m_global_grid : m_edit_grid, connect ? connect_ac () : move_ac (), snap_range).snapped_point; return lay::obj_snap (m_snap_to_objects ? view () : 0, plast, p, m_edit_grid == db::DVector () ? m_global_grid : m_edit_grid, connect ? connect_ac () : move_ac (), snap_range).snapped_point;
} }
@ -593,7 +593,7 @@ Service::selection_bbox ()
{ {
// build the transformation variants cache // build the transformation variants cache
// TODO: this is done multiple times - once for each service! // TODO: this is done multiple times - once for each service!
TransformationVariants tv (view ()); lay::TransformationVariants tv (view ());
const db::DCplxTrans &vp = view ()->viewport ().trans (); const db::DCplxTrans &vp = view ()->viewport ().trans ();
lay::TextInfo text_info (view ()); lay::TextInfo text_info (view ());
@ -687,7 +687,7 @@ Service::transform (const db::DCplxTrans &trans, const std::vector<db::DCplxTran
} }
// build the transformation variants cache // build the transformation variants cache
TransformationVariants tv (view ()); lay::TransformationVariants tv (view ());
// 1.) first transform all shapes // 1.) first transform all shapes
@ -868,7 +868,7 @@ Service::mouse_move_event (const db::DPoint &p, unsigned int buttons, bool prio)
if (m_editing || m_immediate) { if (m_editing || m_immediate) {
m_alt_ac = ac_from_buttons (buttons); m_alt_ac = lay::ac_from_buttons (buttons);
if (! m_editing) { if (! m_editing) {
// in this mode, ignore exceptions here since it is rather annoying to have messages popping // in this mode, ignore exceptions here since it is rather annoying to have messages popping
@ -903,7 +903,7 @@ Service::mouse_press_event (const db::DPoint &p, unsigned int buttons, bool prio
if ((buttons & lay::LeftButton) != 0) { if ((buttons & lay::LeftButton) != 0) {
m_alt_ac = ac_from_buttons (buttons); m_alt_ac = lay::ac_from_buttons (buttons);
if (! m_editing) { if (! m_editing) {
@ -948,7 +948,7 @@ bool
Service::mouse_double_click_event (const db::DPoint & /*p*/, unsigned int buttons, bool prio) Service::mouse_double_click_event (const db::DPoint & /*p*/, unsigned int buttons, bool prio)
{ {
if (m_editing && prio && (buttons & lay::LeftButton) != 0) { if (m_editing && prio && (buttons & lay::LeftButton) != 0) {
m_alt_ac = ac_from_buttons (buttons); m_alt_ac = lay::ac_from_buttons (buttons);
do_finish_edit (); do_finish_edit ();
m_editing = false; m_editing = false;
set_edit_marker (0); set_edit_marker (0);
@ -963,7 +963,7 @@ bool
Service::mouse_click_event (const db::DPoint &p, unsigned int buttons, bool prio) Service::mouse_click_event (const db::DPoint &p, unsigned int buttons, bool prio)
{ {
if (view ()->is_editable () && prio && (buttons & lay::RightButton) != 0 && m_editing) { if (view ()->is_editable () && prio && (buttons & lay::RightButton) != 0 && m_editing) {
m_alt_ac = ac_from_buttons (buttons); m_alt_ac = lay::ac_from_buttons (buttons);
do_mouse_transform (p, db::DFTrans (db::DFTrans::r90)); do_mouse_transform (p, db::DFTrans (db::DFTrans::r90));
m_alt_ac = lay::AC_Global; m_alt_ac = lay::AC_Global;
return true; return true;
@ -1754,7 +1754,7 @@ Service::do_selection_to_view ()
m_markers.reserve (selection_size ()); m_markers.reserve (selection_size ());
// build the transformation variants cache // build the transformation variants cache
TransformationVariants tv (view ()); lay::TransformationVariants tv (view ());
// prepare a default transformation for empty variants // prepare a default transformation for empty variants
std::vector<db::DCplxTrans> empty_tv; std::vector<db::DCplxTrans> empty_tv;
@ -1932,7 +1932,7 @@ Service::handle_guiding_shape_changes (const lay::ObjectInstPath &obj, bool comm
// Hint: get_parameters_from_pcell_and_guiding_shapes invalidates the shapes because it resets the changed // Hint: get_parameters_from_pcell_and_guiding_shapes invalidates the shapes because it resets the changed
// guiding shapes. We must not access s->shape after that. // guiding shapes. We must not access s->shape after that.
if (! get_parameters_from_pcell_and_guiding_shapes (layout, obj.cell_index (), parameters_for_pcell)) { if (! lay::get_parameters_from_pcell_and_guiding_shapes (layout, obj.cell_index (), parameters_for_pcell)) {
return std::make_pair (false, lay::ObjectInstPath ()); return std::make_pair (false, lay::ObjectInstPath ());
} }

View File

@ -33,10 +33,10 @@
#include "laySnap.h" #include "laySnap.h"
#include "layObjectInstPath.h" #include "layObjectInstPath.h"
#include "layTextInfo.h" #include "layTextInfo.h"
#include "layEditorUtils.h"
#include "tlColor.h" #include "tlColor.h"
#include "dbLayout.h" #include "dbLayout.h"
#include "dbShape.h" #include "dbShape.h"
#include "edtUtils.h"
#include "edtConfig.h" #include "edtConfig.h"
#include "tlAssert.h" #include "tlAssert.h"
#include "tlException.h" #include "tlException.h"
@ -55,6 +55,18 @@ class PluginDeclarationBase;
// ------------------------------------------------------------- // -------------------------------------------------------------
/**
* @brief A helper class that identifies clipboard data for edt::
*/
class EDT_PUBLIC ClipboardData
: public db::ClipboardData
{
public:
ClipboardData () { }
};
// -------------------------------------------------------------
/** /**
* @brief A utility class to implement a selection iterator across all editor services * @brief A utility class to implement a selection iterator across all editor services
*/ */

View File

@ -167,7 +167,7 @@ ShapeEditService::change_edit_layer (const db::LayerProperties &lp)
} }
m_layer = (unsigned int) layer; m_layer = (unsigned int) layer;
edt::set_or_request_current_layer (view (), lp, m_cv_index); lay::set_or_request_current_layer (view (), lp, m_cv_index);
if (editing ()) { if (editing ()) {
close_editor_hooks (false); close_editor_hooks (false);

View File

@ -27,8 +27,8 @@
#include "gsiEnums.h" #include "gsiEnums.h"
#include "layEditorOptionsPages.h" #include "layEditorOptionsPages.h"
#include "layCursor.h" #include "layCursor.h"
#include "layEditorUtils.h"
#include "edtConfig.h" #include "edtConfig.h"
#include "edtUtils.h"
namespace gsi namespace gsi
{ {
@ -290,7 +290,7 @@ PluginImpl::snap_delta (const db::DVector &v, bool connect, lay::angle_constrain
db::DPoint db::DPoint
PluginImpl::snap2 (const db::DPoint &p, bool visualize) PluginImpl::snap2 (const db::DPoint &p, bool visualize)
{ {
double snap_range = ui ()->mouse_event_trans ().inverted ().ctrans (edt::snap_range_pixels ()); double snap_range = ui ()->mouse_event_trans ().inverted ().ctrans (lay::snap_range_pixels ());
auto details = lay::obj_snap (m_snap_to_objects ? view () : 0, p, m_edit_grid == db::DVector () ? m_global_grid : m_edit_grid, snap_range); auto details = lay::obj_snap (m_snap_to_objects ? view () : 0, p, m_edit_grid == db::DVector () ? m_global_grid : m_edit_grid, snap_range);
if (visualize) { if (visualize) {
mouse_cursor_from_snap_details (details); mouse_cursor_from_snap_details (details);
@ -301,7 +301,7 @@ PluginImpl::snap2 (const db::DPoint &p, bool visualize)
db::DPoint db::DPoint
PluginImpl::snap2_from_to (const db::DPoint &p, const db::DPoint &plast, bool connect, lay::angle_constraint_type ac, bool visualize) PluginImpl::snap2_from_to (const db::DPoint &p, const db::DPoint &plast, bool connect, lay::angle_constraint_type ac, bool visualize)
{ {
double snap_range = ui ()->mouse_event_trans ().inverted ().ctrans (edt::snap_range_pixels ()); double snap_range = ui ()->mouse_event_trans ().inverted ().ctrans (lay::snap_range_pixels ());
auto details = lay::obj_snap (m_snap_to_objects ? view () : 0, plast, p, m_edit_grid == db::DVector () ? m_global_grid : m_edit_grid, connect ? connect_ac (ac) : move_ac (ac), snap_range); auto details = lay::obj_snap (m_snap_to_objects ? view () : 0, plast, p, m_edit_grid == db::DVector () ? m_global_grid : m_edit_grid, connect ? connect_ac (ac) : move_ac (ac), snap_range);
if (visualize) { if (visualize) {
mouse_cursor_from_snap_details (details); mouse_cursor_from_snap_details (details);
@ -575,7 +575,7 @@ PluginImpl::add_mouse_cursor_point (const db::Point &p, int cv_index, const db::
return; return;
} }
edt::TransformationVariants tv (view ()); lay::TransformationVariants tv (view ());
const std::vector<db::DCplxTrans> *tv_list = tv.per_cv_and_layer (cv_index, (unsigned int) layer); const std::vector<db::DCplxTrans> *tv_list = tv.per_cv_and_layer (cv_index, (unsigned int) layer);
if (! tv_list || tv_list->empty ()) { if (! tv_list || tv_list->empty ()) {
return; return;
@ -603,7 +603,7 @@ PluginImpl::add_edge_marker_edge (const db::Edge &p, int cv_index, const db::Lay
return; return;
} }
edt::TransformationVariants tv (view ()); lay::TransformationVariants tv (view ());
const std::vector<db::DCplxTrans> *tv_list = tv.per_cv_and_layer (cv_index, (unsigned int) layer); const std::vector<db::DCplxTrans> *tv_list = tv.per_cv_and_layer (cv_index, (unsigned int) layer);
if (! tv_list || tv_list->empty ()) { if (! tv_list || tv_list->empty ()) {
return; return;
@ -861,7 +861,7 @@ Class<gsi::PluginImpl> decl_Plugin (decl_PluginBase, "lay", "Plugin",
"\n" "\n"
"This method has been added in version 0.30.4." "This method has been added in version 0.30.4."
) + ) +
method ("ac_from_buttons", &edt::ac_from_buttons, gsi::arg ("buttons"), method ("ac_from_buttons", &lay::ac_from_buttons, gsi::arg ("buttons"),
"@brief Creates an angle constraint from a button combination\n" "@brief Creates an angle constraint from a button combination\n"
"This method provides the angle constraints implied by a specific modifier combination, i.e. " "This method provides the angle constraints implied by a specific modifier combination, i.e. "
"'Shift' will render ortho snapping. Use this function to generate angle constraints following " "'Shift' will render ortho snapping. Use this function to generate angle constraints following "

View File

@ -123,6 +123,8 @@ EditorOptionsPage::show ()
} else { } else {
return mp_owner->exec_modal (this) ? 1 : 0; return mp_owner->exec_modal (this) ? 1 : 0;
} }
} else {
return -1;
} }
} }

View File

@ -379,10 +379,7 @@ bool
EditorServiceBase::key_event (unsigned int key, unsigned int buttons) EditorServiceBase::key_event (unsigned int key, unsigned int buttons)
{ {
if (is_active () && key == Qt::Key_Tab && buttons == 0) { if (is_active () && key == Qt::Key_Tab && buttons == 0) {
EditorOptionsPage *fp = focus_page (); focus_page_open (focus_page ());
if (fp) {
focus_page_open (fp);
}
return true; return true;
} else { } else {
return false; return false;
@ -392,7 +389,7 @@ EditorServiceBase::key_event (unsigned int key, unsigned int buttons)
int int
EditorServiceBase::focus_page_open (EditorOptionsPage *fp) EditorServiceBase::focus_page_open (EditorOptionsPage *fp)
{ {
return fp->show (); return fp ? fp->show () : 0;
} }
void void

View File

@ -25,8 +25,7 @@
#include "dbLayout.h" #include "dbLayout.h"
#include "dbLibrary.h" #include "dbLibrary.h"
#include "edtUtils.h" #include "layEditorUtils.h"
#include "edtService.h"
#include "layCellView.h" #include "layCellView.h"
#include "layLayoutViewBase.h" #include "layLayoutViewBase.h"
@ -38,10 +37,16 @@
# include <QMessageBox> # include <QMessageBox>
#endif #endif
namespace edt { namespace lay
{
// ------------------------------------------------------------- // -------------------------------------------------------------
int snap_range_pixels ()
{
return 8; // TODO: make variable
}
// Convert buttons to an angle constraint // Convert buttons to an angle constraint
lay::angle_constraint_type lay::angle_constraint_type
ac_from_buttons (unsigned int buttons) ac_from_buttons (unsigned int buttons)

View File

@ -21,15 +21,15 @@
*/ */
#ifndef HDR_edtUtils #ifndef HDR_layEditorUtils
#define HDR_edtUtils #define HDR_layEditorUtils
#include <limits> #include <limits>
#include <list> #include <list>
#include <utility> #include <utility>
#include <vector> #include <vector>
#include "edtCommon.h" #include "laybasicCommon.h"
#include "layObjectInstPath.h" #include "layObjectInstPath.h"
#include "laySnap.h" #include "laySnap.h"
@ -41,33 +41,34 @@
namespace lay namespace lay
{ {
class LayoutViewBase;
class Dispatcher;
}
namespace edt { class LayoutViewBase;
class Dispatcher;
class Service;
// ------------------------------------------------------------- // -------------------------------------------------------------
/**
* @brief Gets the snap range in pixels
*/
LAYBASIC_PUBLIC int snap_range_pixels ();
/** /**
* @brief Convert a button flag set to an angle constraint * @brief Convert a button flag set to an angle constraint
* *
* This implements the standard modifiers for angle constraints - i.e. * This implements the standard modifiers for angle constraints - i.e.
* ortho for "Shift". * ortho for "Shift".
*/ */
EDT_PUBLIC lay::angle_constraint_type ac_from_buttons (unsigned int buttons); LAYBASIC_PUBLIC lay::angle_constraint_type ac_from_buttons (unsigned int buttons);
/** /**
* @brief Serializes PCell parameters to a string * @brief Serializes PCell parameters to a string
*/ */
EDT_PUBLIC std::string pcell_parameters_to_string (const std::map<std::string, tl::Variant> &parameters); LAYBASIC_PUBLIC std::string pcell_parameters_to_string (const std::map<std::string, tl::Variant> &parameters);
/** /**
* @brief Deserializes PCell parameters from a string * @brief Deserializes PCell parameters from a string
*/ */
EDT_PUBLIC std::map<std::string, tl::Variant> pcell_parameters_from_string (const std::string &s); LAYBASIC_PUBLIC std::map<std::string, tl::Variant> pcell_parameters_from_string (const std::string &s);
/** /**
* @brief Fetch PCell parameters from a cell and merge the guiding shapes into them * @brief Fetch PCell parameters from a cell and merge the guiding shapes into them
@ -77,30 +78,22 @@ EDT_PUBLIC std::map<std::string, tl::Variant> pcell_parameters_from_string (cons
* @param parameters_for_pcell Will receive the parameters * @param parameters_for_pcell Will receive the parameters
* @return true, if the cell is a PCell and parameters have been fetched * @return true, if the cell is a PCell and parameters have been fetched
*/ */
EDT_PUBLIC bool LAYBASIC_PUBLIC
bool
get_parameters_from_pcell_and_guiding_shapes (db::Layout *layout, db::cell_index_type cell_index, db::pcell_parameters_type &parameters_for_pcell); get_parameters_from_pcell_and_guiding_shapes (db::Layout *layout, db::cell_index_type cell_index, db::pcell_parameters_type &parameters_for_pcell);
/** /**
* @brief Request to make the given layer the current one (asks whether to create the layer if needed) * @brief Request to make the given layer the current one (asks whether to create the layer if needed)
*/ */
LAYBASIC_PUBLIC
bool bool
set_or_request_current_layer (lay::LayoutViewBase *view, const db::LayerProperties &lp, unsigned int cv_index, bool make_current = true); set_or_request_current_layer (lay::LayoutViewBase *view, const db::LayerProperties &lp, unsigned int cv_index, bool make_current = true);
/**
* @brief A helper class that identifies clipboard data for edt::
*/
class EDT_PUBLIC ClipboardData
: public db::ClipboardData
{
public:
ClipboardData () { }
};
/** /**
* @brief A cache for the transformation variants for a certain layer and cell view index for a lay::LayoutView * @brief A cache for the transformation variants for a certain layer and cell view index for a lay::LayoutView
*/ */
class EDT_PUBLIC TransformationVariants class LAYBASIC_PUBLIC TransformationVariants
{ {
public: public:
TransformationVariants (const lay::LayoutViewBase *view, bool per_cv_and_layer = true, bool per_cv = true); TransformationVariants (const lay::LayoutViewBase *view, bool per_cv_and_layer = true, bool per_cv = true);

View File

@ -5506,7 +5506,7 @@ LayoutViewBase::paste_interactive (bool transient_mode)
// operations. // operations.
trans->close (); trans->close ();
if (mp_move_service && mp_move_service->begin_move (trans.release (), transient_mode)) { if (mp_move_service && mp_move_service->start_move (trans.release (), transient_mode)) {
switch_mode (-1); // move mode switch_mode (-1); // move mode
} }
} }

View File

@ -20,11 +20,10 @@
*/ */
#include "layMove.h" #include "layMove.h"
#include "layEditable.h" #include "layEditable.h"
#include "layLayoutViewBase.h" #include "layLayoutViewBase.h"
#include "layEditorUtils.h"
#include "laySelector.h" #include "laySelector.h"
#include "laybasicConfig.h" #include "laybasicConfig.h"
@ -35,11 +34,9 @@ namespace lay
// MoveService implementation // MoveService implementation
MoveService::MoveService (lay::LayoutViewBase *view) MoveService::MoveService (lay::LayoutViewBase *view)
: lay::ViewService (view->canvas ()), : lay::EditorServiceBase (view),
lay::Plugin (view),
m_dragging (false), m_dragging (false),
m_dragging_transient (false), m_dragging_transient (false),
m_active (false),
mp_editables (view), mp_editables (view),
mp_view (view), mp_view (view),
m_global_grid (0.001) m_global_grid (0.001)
@ -52,55 +49,33 @@ MoveService::~MoveService ()
drag_cancel (); drag_cancel ();
} }
void
MoveService::activated ()
{
m_active = true;
}
void void
MoveService::deactivated () MoveService::deactivated ()
{ {
EditorServiceBase::deactivated ();
m_shift = db::DPoint (); m_shift = db::DPoint ();
m_active = false; mp_editables->clear_transient_selection ();
mp_view->clear_transient_selection ();
drag_cancel (); drag_cancel ();
} }
lay::angle_constraint_type
ac_from_buttons (unsigned int buttons)
{
if ((buttons & lay::ShiftButton) != 0) {
if ((buttons & lay::ControlButton) != 0) {
return lay::AC_Any;
} else {
return lay::AC_Ortho;
}
} else {
if ((buttons & lay::ControlButton) != 0) {
return lay::AC_Diagonal;
} else {
return lay::AC_Global;
}
}
}
bool bool
MoveService::configure (const std::string &name, const std::string &value) MoveService::configure (const std::string &name, const std::string &value)
{ {
if (lay::EditorServiceBase::configure (name, value)) {
return true;
}
if (name == cfg_grid) { if (name == cfg_grid) {
tl::from_string (value, m_global_grid); tl::from_string (value, m_global_grid);
} }
return false; // not taken return false; // not taken
} }
bool bool
MoveService::key_event (unsigned int key, unsigned int buttons) MoveService::key_event (unsigned int key, unsigned int buttons)
{ {
if (m_active && key == Qt::Key_Tab && buttons == 0) { if (lay::EditorServiceBase::key_event (key, buttons)) {
if (dispatcher ()) {
dispatcher ()->menu_activated ("cm_sel_move");
}
return true; return true;
} }
@ -145,6 +120,16 @@ MoveService::key_event (unsigned int key, unsigned int buttons)
} }
} }
int
MoveService::focus_page_open (EditorOptionsPage * /*fp*/)
{
// This method is called on "Tab" by "key_event". "fp" is null as we don't have a focus page registered.
if (is_active () && dispatcher ()) {
dispatcher ()->menu_activated ("cm_sel_move");
}
return 0;
}
bool bool
MoveService::mouse_move_event (const db::DPoint &p, unsigned int buttons, bool prio) MoveService::mouse_move_event (const db::DPoint &p, unsigned int buttons, bool prio)
{ {
@ -256,7 +241,7 @@ MoveService::mouse_press_event (const db::DPoint &p, unsigned int buttons, bool
} }
bool bool
MoveService::begin_move (db::Transaction *transaction, bool transient_selection) MoveService::start_move (db::Transaction *transaction, bool transient_selection)
{ {
if (m_dragging) { if (m_dragging) {
return false; return false;
@ -324,7 +309,7 @@ MoveService::handle_click (const db::DPoint &p, unsigned int buttons, bool drag_
ui ()->hover_reset (); ui ()->hover_reset ();
mp_view->clear_transient_selection (); mp_editables->clear_transient_selection ();
m_dragging = true; m_dragging = true;
m_dragging_transient = drag_transient; m_dragging_transient = drag_transient;

View File

@ -24,34 +24,28 @@
#define HDR_layMove #define HDR_layMove
#include "laybasicCommon.h" #include "laybasicCommon.h"
#include "layViewObject.h" #include "layEditorServiceBase.h"
#include "layPlugin.h"
#include "dbManager.h" #include "dbManager.h"
#include <memory> #include <memory>
namespace lay { namespace lay {
class Editables;
class LayoutViewBase; class LayoutViewBase;
class LAYBASIC_PUBLIC MoveService : class LAYBASIC_PUBLIC MoveService :
public lay::ViewService, public lay::Plugin public lay::EditorServiceBase
{ {
public: public:
MoveService (lay::LayoutViewBase *view); MoveService (lay::LayoutViewBase *view);
~MoveService (); ~MoveService ();
bool start_move (db::Transaction *transaction = 0, bool transient_selection = false);
bool configure (const std::string &name, const std::string &value); bool configure (const std::string &name, const std::string &value);
bool begin_move (db::Transaction *transaction = 0, bool transient_selection = false);
void finish (); void finish ();
void cancel (); void cancel ();
lay::ViewService *view_service_interface ()
{
return this;
}
private: private:
virtual bool mouse_press_event (const db::DPoint &p, unsigned int buttons, bool prio); virtual bool mouse_press_event (const db::DPoint &p, unsigned int buttons, bool prio);
virtual bool mouse_click_event (const db::DPoint &p, unsigned int buttons, bool prio); virtual bool mouse_click_event (const db::DPoint &p, unsigned int buttons, bool prio);
@ -61,14 +55,13 @@ private:
virtual bool wheel_event (int delta, bool horizontal, const db::DPoint &p, unsigned int buttons, bool prio); virtual bool wheel_event (int delta, bool horizontal, const db::DPoint &p, unsigned int buttons, bool prio);
virtual bool key_event (unsigned int key, unsigned int buttons); virtual bool key_event (unsigned int key, unsigned int buttons);
virtual void drag_cancel (); virtual void drag_cancel ();
virtual void activated ();
virtual void deactivated (); virtual void deactivated ();
int focus_page_open (EditorOptionsPage *fp);
bool handle_click (const db::DPoint &p, unsigned int buttons, bool drag_transient, db::Transaction *transaction); bool handle_click (const db::DPoint &p, unsigned int buttons, bool drag_transient, db::Transaction *transaction);
bool m_dragging; bool m_dragging;
bool m_dragging_transient; bool m_dragging_transient;
bool m_active;
lay::Editables *mp_editables; lay::Editables *mp_editables;
lay::LayoutViewBase *mp_view; lay::LayoutViewBase *mp_view;
double m_global_grid; double m_global_grid;

View File

@ -37,6 +37,7 @@ SOURCES += \
layAbstractMenu.cc \ layAbstractMenu.cc \
layEditorOptionsPage.cc \ layEditorOptionsPage.cc \
layEditorOptionsPages.cc \ layEditorOptionsPages.cc \
layEditorUtils.cc \
layLayoutViewConfig.cc \ layLayoutViewConfig.cc \
layMargin.cc \ layMargin.cc \
laybasicForceLink.cc \ laybasicForceLink.cc \
@ -91,6 +92,7 @@ SOURCES += \
HEADERS += \ HEADERS += \
layEditorOptionsPage.h \ layEditorOptionsPage.h \
layEditorOptionsPages.h \ layEditorOptionsPages.h \
layEditorUtils.h \
layMargin.h \ layMargin.h \
laybasicConfig.h \ laybasicConfig.h \
laybasicForceLink.h \ laybasicForceLink.h \

View File

@ -1543,7 +1543,7 @@ void
LayoutViewFunctions::cm_sel_move_interactive () LayoutViewFunctions::cm_sel_move_interactive ()
{ {
view ()->cancel_edits (); view ()->cancel_edits ();
if (view ()->move_service ()->begin_move ()) { if (view ()->move_service ()->start_move ()) {
view ()->switch_mode (-1); // move mode view ()->switch_mode (-1); // move mode
} }
} }