mirror of https://github.com/KLayout/klayout.git
Some refactoring (generalizing edt:: functions, basing move tool on lay::EditorService and support for 'tab' key (calls 'move by')
This commit is contained in:
parent
e9584c289a
commit
20a3dbeaf8
|
|
@ -80,7 +80,6 @@ HEADERS += \
|
|||
edtPartialService.h \
|
||||
edtPlugin.h \
|
||||
edtService.h \
|
||||
edtUtils.h \
|
||||
edtCommon.h \
|
||||
edtDistribute.h \
|
||||
|
||||
|
|
@ -91,7 +90,6 @@ SOURCES += \
|
|||
edtPartialService.cc \
|
||||
edtPlugin.cc \
|
||||
edtService.cc \
|
||||
edtUtils.cc \
|
||||
gsiDeclEdt.cc \
|
||||
edtDistribute.cc \
|
||||
|
||||
|
|
|
|||
|
|
@ -28,11 +28,6 @@
|
|||
namespace edt
|
||||
{
|
||||
|
||||
int snap_range_pixels ()
|
||||
{
|
||||
return 8; // TODO: make variable
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
std::string cfg_edit_grid ("edit-grid");
|
||||
|
|
|
|||
|
|
@ -118,8 +118,6 @@ struct EDT_PUBLIC VAlignConverter
|
|||
void from_string (const std::string &s, db::VAlign &a);
|
||||
};
|
||||
|
||||
int EDT_PUBLIC snap_range_pixels ();
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@
|
|||
#include "dbLayout.h"
|
||||
|
||||
#include "edtDialogs.h"
|
||||
#include "edtUtils.h"
|
||||
#include "layEditorUtils.h"
|
||||
#include "layObjectInstPath.h"
|
||||
#include "layCellView.h"
|
||||
#include "layLayoutViewBase.h"
|
||||
|
|
|
|||
|
|
@ -725,7 +725,7 @@ EditorOptionsInstPCellParam::apply (lay::Dispatcher *root)
|
|||
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 (&ok)));
|
||||
param = lay::pcell_parameters_to_string (pc_decl->named_parameters (mp_pcell_parameters->get_parameters (&ok)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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_cell_name, m_cell_or_pcell_name);
|
||||
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 {
|
||||
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) {
|
||||
|
||||
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) {
|
||||
|
||||
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
|
||||
// to reflect changes rather than induce some.
|
||||
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 {
|
||||
dispatcher ()->config_set (cfg_edit_inst_pcell_parameters, std::string ());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,10 +29,10 @@
|
|||
#include "layPlugin.h"
|
||||
#include "layViewObject.h"
|
||||
#include "layMarker.h"
|
||||
#include "layEditorUtils.h"
|
||||
#include "dbLayout.h"
|
||||
#include "dbShape.h"
|
||||
#include "dbClipboard.h"
|
||||
#include "edtUtils.h"
|
||||
|
||||
#include <set>
|
||||
#include <vector>
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ MoveTrackerService::issue_edit_events ()
|
|||
call_editor_hooks (m_editor_hooks, &edt::EditorHooks::begin_edits);
|
||||
|
||||
// build the transformation variants cache
|
||||
TransformationVariants tv (view ());
|
||||
lay::TransformationVariants tv (view ());
|
||||
|
||||
std::vector<edt::Service *> services = view ()->get_plugins<edt::Service> ();
|
||||
std::vector<lay::ObjectInstPath> sel;
|
||||
|
|
|
|||
|
|
@ -1213,7 +1213,7 @@ PartialService::timeout ()
|
|||
partial_objects::const_iterator r = transient_selection.begin ();
|
||||
|
||||
// build the transformation variants cache
|
||||
TransformationVariants tv (view ());
|
||||
lay::TransformationVariants tv (view ());
|
||||
|
||||
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);
|
||||
|
||||
// build the transformation variants cache
|
||||
TransformationVariants tv (view ());
|
||||
lay::TransformationVariants tv (view ());
|
||||
|
||||
// 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
|
||||
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);
|
||||
db::Shape shape = shape_in;
|
||||
|
|
@ -1642,7 +1642,7 @@ void
|
|||
PartialService::transform_selection (const db::DTrans &move_trans)
|
||||
{
|
||||
// build the transformation variants cache
|
||||
TransformationVariants tv (view ());
|
||||
lay::TransformationVariants tv (view ());
|
||||
|
||||
// since a shape reference may become invalid while moving it and
|
||||
// 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);
|
||||
|
||||
m_alt_ac = ac_from_buttons (buttons);
|
||||
m_alt_ac = lay::ac_from_buttons (buttons);
|
||||
|
||||
// drag the vertex or edge/segment
|
||||
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) {
|
||||
|
||||
m_alt_ac = ac_from_buttons (buttons);
|
||||
m_alt_ac = lay::ac_from_buttons (buttons);
|
||||
|
||||
m_p2 = p;
|
||||
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) {
|
||||
|
||||
m_alt_ac = ac_from_buttons (buttons);
|
||||
m_alt_ac = lay::ac_from_buttons (buttons);
|
||||
|
||||
if (m_selection.empty ()) {
|
||||
|
||||
|
|
@ -2015,7 +2015,7 @@ PartialService::mouse_click_event (const db::DPoint &p, unsigned int buttons, bo
|
|||
|
||||
if (m_dragging) {
|
||||
|
||||
m_alt_ac = ac_from_buttons (buttons);
|
||||
m_alt_ac = lay::ac_from_buttons (buttons);
|
||||
|
||||
if (m_current != m_start) {
|
||||
|
||||
|
|
@ -2059,7 +2059,7 @@ PartialService::mouse_click_event (const db::DPoint &p, unsigned int buttons, bo
|
|||
view ()->clear_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;
|
||||
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) {
|
||||
|
||||
m_alt_ac = ac_from_buttons (buttons);
|
||||
m_alt_ac = lay::ac_from_buttons (buttons);
|
||||
|
||||
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);
|
||||
|
||||
// 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 ());
|
||||
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) {
|
||||
|
||||
m_alt_ac = ac_from_buttons (buttons);
|
||||
m_alt_ac = lay::ac_from_buttons (buttons);
|
||||
|
||||
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 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) {
|
||||
|
||||
|
|
@ -2548,7 +2548,7 @@ PartialService::selection_bbox ()
|
|||
{
|
||||
// build the transformation variants cache
|
||||
// TODO: this is done multiple times - once for each service!
|
||||
TransformationVariants tv (view ());
|
||||
lay::TransformationVariants tv (view ());
|
||||
const db::DCplxTrans &vp = view ()->viewport ().trans ();
|
||||
|
||||
lay::TextInfo text_info (view ());
|
||||
|
|
@ -2938,7 +2938,7 @@ PartialService::single_selected_point () const
|
|||
// build the transformation variants cache and
|
||||
// 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.
|
||||
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 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
|
||||
// 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.
|
||||
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 lay::CellView &cv = view ()->cellview (m_selection.begin ()->first.cv_index ());
|
||||
|
|
@ -3042,7 +3042,7 @@ PartialService::do_selection_to_view ()
|
|||
if (! m_selection.empty ()) {
|
||||
|
||||
// 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) {
|
||||
|
||||
|
|
@ -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
|
||||
// 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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -30,9 +30,9 @@
|
|||
#include "layViewObject.h"
|
||||
#include "layRubberBox.h"
|
||||
#include "laySnap.h"
|
||||
#include "layEditorUtils.h"
|
||||
#include "tlAssert.h"
|
||||
#include "tlDeferredExecution.h"
|
||||
#include "edtUtils.h"
|
||||
#include "edtConfig.h"
|
||||
#include "edtEditorHooks.h"
|
||||
|
||||
|
|
@ -400,7 +400,7 @@ private:
|
|||
db::DEdge single_selected_edge () const;
|
||||
bool handle_guiding_shape_changes ();
|
||||
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 close_editor_hooks (bool commit);
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
{
|
||||
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;
|
||||
|
|
|
|||
|
|
@ -23,11 +23,11 @@
|
|||
#if defined(HAVE_QT)
|
||||
|
||||
#include "edtRecentConfigurationPage.h"
|
||||
#include "edtUtils.h"
|
||||
#include "layDispatcher.h"
|
||||
#include "layLayoutViewBase.h"
|
||||
#include "layLayerTreeModel.h"
|
||||
#include "layBusy.h"
|
||||
#include "layEditorUtils.h"
|
||||
#include "dbLibraryManager.h"
|
||||
#include "dbLibrary.h"
|
||||
#include "tlLog.h"
|
||||
|
|
@ -267,7 +267,7 @@ RecentConfigurationPage::render_to (QTreeWidgetItem *item, int column, const std
|
|||
std::map<std::string, tl::Variant> pcp;
|
||||
for (std::list<ConfigurationDescriptor>::const_iterator c = m_cfg.begin (); c != m_cfg.end (); ++c, ++pcp_column) {
|
||||
if (c->rendering == RecentConfigurationPage::PCellParameters) {
|
||||
pcp = pcell_parameters_from_string (values [pcp_column]);
|
||||
pcp = lay::pcell_parameters_from_string (values [pcp_column]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -296,7 +296,7 @@ RecentConfigurationPage::render_to (QTreeWidgetItem *item, int column, const std
|
|||
{
|
||||
std::map<std::string, tl::Variant> pcp;
|
||||
try {
|
||||
pcp = pcell_parameters_from_string (values [column]);
|
||||
pcp = lay::pcell_parameters_from_string (values [column]);
|
||||
} catch (tl::Exception &ex) {
|
||||
tl::error << tl::to_string (tr ("Configuration error (PCellParameters): ")) << ex.msg ();
|
||||
}
|
||||
|
|
@ -384,7 +384,7 @@ RecentConfigurationPage::item_clicked (QTreeWidgetItem *item)
|
|||
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 {
|
||||
dispatcher ()->config_set (c->cfg_name, v);
|
||||
|
|
|
|||
|
|
@ -283,7 +283,7 @@ Service::snap (const db::DPoint &p, const db::DPoint &plast, bool connect) const
|
|||
lay::PointSnapToObjectResult
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
@ -296,7 +296,7 @@ Service::snap2 (const db::DPoint &p) const
|
|||
db::DPoint
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
@ -593,7 +593,7 @@ Service::selection_bbox ()
|
|||
{
|
||||
// build the transformation variants cache
|
||||
// TODO: this is done multiple times - once for each service!
|
||||
TransformationVariants tv (view ());
|
||||
lay::TransformationVariants tv (view ());
|
||||
const db::DCplxTrans &vp = view ()->viewport ().trans ();
|
||||
|
||||
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
|
||||
TransformationVariants tv (view ());
|
||||
lay::TransformationVariants tv (view ());
|
||||
|
||||
// 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) {
|
||||
|
||||
m_alt_ac = ac_from_buttons (buttons);
|
||||
m_alt_ac = lay::ac_from_buttons (buttons);
|
||||
|
||||
if (! m_editing) {
|
||||
// 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) {
|
||||
|
||||
m_alt_ac = ac_from_buttons (buttons);
|
||||
m_alt_ac = lay::ac_from_buttons (buttons);
|
||||
|
||||
if (! m_editing) {
|
||||
|
||||
|
|
@ -948,7 +948,7 @@ bool
|
|||
Service::mouse_double_click_event (const db::DPoint & /*p*/, unsigned int buttons, bool prio)
|
||||
{
|
||||
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 ();
|
||||
m_editing = false;
|
||||
set_edit_marker (0);
|
||||
|
|
@ -963,7 +963,7 @@ bool
|
|||
Service::mouse_click_event (const db::DPoint &p, unsigned int buttons, bool prio)
|
||||
{
|
||||
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));
|
||||
m_alt_ac = lay::AC_Global;
|
||||
return true;
|
||||
|
|
@ -1754,7 +1754,7 @@ Service::do_selection_to_view ()
|
|||
m_markers.reserve (selection_size ());
|
||||
|
||||
// build the transformation variants cache
|
||||
TransformationVariants tv (view ());
|
||||
lay::TransformationVariants tv (view ());
|
||||
|
||||
// prepare a default transformation for empty variants
|
||||
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
|
||||
// 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 ());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -33,10 +33,10 @@
|
|||
#include "laySnap.h"
|
||||
#include "layObjectInstPath.h"
|
||||
#include "layTextInfo.h"
|
||||
#include "layEditorUtils.h"
|
||||
#include "tlColor.h"
|
||||
#include "dbLayout.h"
|
||||
#include "dbShape.h"
|
||||
#include "edtUtils.h"
|
||||
#include "edtConfig.h"
|
||||
#include "tlAssert.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
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -167,7 +167,7 @@ ShapeEditService::change_edit_layer (const db::LayerProperties &lp)
|
|||
}
|
||||
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 ()) {
|
||||
close_editor_hooks (false);
|
||||
|
|
|
|||
|
|
@ -27,8 +27,8 @@
|
|||
#include "gsiEnums.h"
|
||||
#include "layEditorOptionsPages.h"
|
||||
#include "layCursor.h"
|
||||
#include "layEditorUtils.h"
|
||||
#include "edtConfig.h"
|
||||
#include "edtUtils.h"
|
||||
|
||||
namespace gsi
|
||||
{
|
||||
|
|
@ -290,7 +290,7 @@ PluginImpl::snap_delta (const db::DVector &v, bool connect, lay::angle_constrain
|
|||
db::DPoint
|
||||
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);
|
||||
if (visualize) {
|
||||
mouse_cursor_from_snap_details (details);
|
||||
|
|
@ -301,7 +301,7 @@ PluginImpl::snap2 (const db::DPoint &p, bool visualize)
|
|||
db::DPoint
|
||||
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);
|
||||
if (visualize) {
|
||||
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;
|
||||
}
|
||||
|
||||
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);
|
||||
if (! tv_list || tv_list->empty ()) {
|
||||
return;
|
||||
|
|
@ -603,7 +603,7 @@ PluginImpl::add_edge_marker_edge (const db::Edge &p, int cv_index, const db::Lay
|
|||
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);
|
||||
if (! tv_list || tv_list->empty ()) {
|
||||
return;
|
||||
|
|
@ -861,7 +861,7 @@ Class<gsi::PluginImpl> decl_Plugin (decl_PluginBase, "lay", "Plugin",
|
|||
"\n"
|
||||
"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"
|
||||
"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 "
|
||||
|
|
|
|||
|
|
@ -123,6 +123,8 @@ EditorOptionsPage::show ()
|
|||
} else {
|
||||
return mp_owner->exec_modal (this) ? 1 : 0;
|
||||
}
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -379,10 +379,7 @@ bool
|
|||
EditorServiceBase::key_event (unsigned int key, unsigned int buttons)
|
||||
{
|
||||
if (is_active () && key == Qt::Key_Tab && buttons == 0) {
|
||||
EditorOptionsPage *fp = focus_page ();
|
||||
if (fp) {
|
||||
focus_page_open (fp);
|
||||
}
|
||||
focus_page_open (focus_page ());
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
|
|
@ -392,7 +389,7 @@ EditorServiceBase::key_event (unsigned int key, unsigned int buttons)
|
|||
int
|
||||
EditorServiceBase::focus_page_open (EditorOptionsPage *fp)
|
||||
{
|
||||
return fp->show ();
|
||||
return fp ? fp->show () : 0;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
|
|
@ -25,8 +25,7 @@
|
|||
#include "dbLayout.h"
|
||||
#include "dbLibrary.h"
|
||||
|
||||
#include "edtUtils.h"
|
||||
#include "edtService.h"
|
||||
#include "layEditorUtils.h"
|
||||
|
||||
#include "layCellView.h"
|
||||
#include "layLayoutViewBase.h"
|
||||
|
|
@ -38,10 +37,16 @@
|
|||
# include <QMessageBox>
|
||||
#endif
|
||||
|
||||
namespace edt {
|
||||
namespace lay
|
||||
{
|
||||
|
||||
// -------------------------------------------------------------
|
||||
|
||||
int snap_range_pixels ()
|
||||
{
|
||||
return 8; // TODO: make variable
|
||||
}
|
||||
|
||||
// Convert buttons to an angle constraint
|
||||
lay::angle_constraint_type
|
||||
ac_from_buttons (unsigned int buttons)
|
||||
|
|
@ -21,15 +21,15 @@
|
|||
*/
|
||||
|
||||
|
||||
#ifndef HDR_edtUtils
|
||||
#define HDR_edtUtils
|
||||
#ifndef HDR_layEditorUtils
|
||||
#define HDR_layEditorUtils
|
||||
|
||||
#include <limits>
|
||||
#include <list>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "edtCommon.h"
|
||||
#include "laybasicCommon.h"
|
||||
|
||||
#include "layObjectInstPath.h"
|
||||
#include "laySnap.h"
|
||||
|
|
@ -41,33 +41,34 @@
|
|||
|
||||
namespace lay
|
||||
{
|
||||
class LayoutViewBase;
|
||||
class Dispatcher;
|
||||
}
|
||||
|
||||
namespace edt {
|
||||
|
||||
class Service;
|
||||
class LayoutViewBase;
|
||||
class Dispatcher;
|
||||
|
||||
// -------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* @brief Gets the snap range in pixels
|
||||
*/
|
||||
LAYBASIC_PUBLIC int snap_range_pixels ();
|
||||
|
||||
/**
|
||||
* @brief Convert a button flag set to an angle constraint
|
||||
*
|
||||
* This implements the standard modifiers for angle constraints - i.e.
|
||||
* 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
|
||||
*/
|
||||
EDT_PUBLIC std::string pcell_parameters_to_string (const std::map<std::string, tl::Variant> ¶meters);
|
||||
LAYBASIC_PUBLIC std::string pcell_parameters_to_string (const std::map<std::string, tl::Variant> ¶meters);
|
||||
|
||||
/**
|
||||
* @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
|
||||
|
|
@ -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
|
||||
* @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 ¶meters_for_pcell);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Request to make the given layer the current one (asks whether to create the layer if needed)
|
||||
*/
|
||||
LAYBASIC_PUBLIC
|
||||
bool
|
||||
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
|
||||
*/
|
||||
class EDT_PUBLIC TransformationVariants
|
||||
class LAYBASIC_PUBLIC TransformationVariants
|
||||
{
|
||||
public:
|
||||
TransformationVariants (const lay::LayoutViewBase *view, bool per_cv_and_layer = true, bool per_cv = true);
|
||||
|
|
@ -5506,7 +5506,7 @@ LayoutViewBase::paste_interactive (bool transient_mode)
|
|||
// operations.
|
||||
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
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,11 +20,10 @@
|
|||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "layMove.h"
|
||||
#include "layEditable.h"
|
||||
#include "layLayoutViewBase.h"
|
||||
#include "layEditorUtils.h"
|
||||
#include "laySelector.h"
|
||||
#include "laybasicConfig.h"
|
||||
|
||||
|
|
@ -35,11 +34,9 @@ namespace lay
|
|||
// MoveService implementation
|
||||
|
||||
MoveService::MoveService (lay::LayoutViewBase *view)
|
||||
: lay::ViewService (view->canvas ()),
|
||||
lay::Plugin (view),
|
||||
: lay::EditorServiceBase (view),
|
||||
m_dragging (false),
|
||||
m_dragging_transient (false),
|
||||
m_active (false),
|
||||
mp_editables (view),
|
||||
mp_view (view),
|
||||
m_global_grid (0.001)
|
||||
|
|
@ -52,55 +49,33 @@ MoveService::~MoveService ()
|
|||
drag_cancel ();
|
||||
}
|
||||
|
||||
void
|
||||
MoveService::activated ()
|
||||
{
|
||||
m_active = true;
|
||||
}
|
||||
|
||||
void
|
||||
MoveService::deactivated ()
|
||||
{
|
||||
EditorServiceBase::deactivated ();
|
||||
m_shift = db::DPoint ();
|
||||
m_active = false;
|
||||
mp_view->clear_transient_selection ();
|
||||
mp_editables->clear_transient_selection ();
|
||||
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
|
||||
MoveService::configure (const std::string &name, const std::string &value)
|
||||
{
|
||||
if (lay::EditorServiceBase::configure (name, value)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (name == cfg_grid) {
|
||||
tl::from_string (value, m_global_grid);
|
||||
}
|
||||
|
||||
return false; // not taken
|
||||
}
|
||||
|
||||
bool
|
||||
MoveService::key_event (unsigned int key, unsigned int buttons)
|
||||
{
|
||||
if (m_active && key == Qt::Key_Tab && buttons == 0) {
|
||||
if (dispatcher ()) {
|
||||
dispatcher ()->menu_activated ("cm_sel_move");
|
||||
}
|
||||
if (lay::EditorServiceBase::key_event (key, buttons)) {
|
||||
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
|
||||
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
|
||||
MoveService::begin_move (db::Transaction *transaction, bool transient_selection)
|
||||
MoveService::start_move (db::Transaction *transaction, bool transient_selection)
|
||||
{
|
||||
if (m_dragging) {
|
||||
return false;
|
||||
|
|
@ -324,7 +309,7 @@ MoveService::handle_click (const db::DPoint &p, unsigned int buttons, bool drag_
|
|||
|
||||
ui ()->hover_reset ();
|
||||
|
||||
mp_view->clear_transient_selection ();
|
||||
mp_editables->clear_transient_selection ();
|
||||
|
||||
m_dragging = true;
|
||||
m_dragging_transient = drag_transient;
|
||||
|
|
|
|||
|
|
@ -24,34 +24,28 @@
|
|||
#define HDR_layMove
|
||||
|
||||
#include "laybasicCommon.h"
|
||||
#include "layViewObject.h"
|
||||
#include "layPlugin.h"
|
||||
#include "layEditorServiceBase.h"
|
||||
#include "dbManager.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace lay {
|
||||
|
||||
class Editables;
|
||||
class LayoutViewBase;
|
||||
|
||||
class LAYBASIC_PUBLIC MoveService :
|
||||
public lay::ViewService, public lay::Plugin
|
||||
public lay::EditorServiceBase
|
||||
{
|
||||
public:
|
||||
MoveService (lay::LayoutViewBase *view);
|
||||
~MoveService ();
|
||||
|
||||
bool start_move (db::Transaction *transaction = 0, bool transient_selection = false);
|
||||
|
||||
bool configure (const std::string &name, const std::string &value);
|
||||
bool begin_move (db::Transaction *transaction = 0, bool transient_selection = false);
|
||||
void finish ();
|
||||
void cancel ();
|
||||
|
||||
lay::ViewService *view_service_interface ()
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
private:
|
||||
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);
|
||||
|
|
@ -61,14 +55,13 @@ private:
|
|||
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 void drag_cancel ();
|
||||
virtual void activated ();
|
||||
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 m_dragging;
|
||||
bool m_dragging_transient;
|
||||
bool m_active;
|
||||
lay::Editables *mp_editables;
|
||||
lay::LayoutViewBase *mp_view;
|
||||
double m_global_grid;
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ SOURCES += \
|
|||
layAbstractMenu.cc \
|
||||
layEditorOptionsPage.cc \
|
||||
layEditorOptionsPages.cc \
|
||||
layEditorUtils.cc \
|
||||
layLayoutViewConfig.cc \
|
||||
layMargin.cc \
|
||||
laybasicForceLink.cc \
|
||||
|
|
@ -91,6 +92,7 @@ SOURCES += \
|
|||
HEADERS += \
|
||||
layEditorOptionsPage.h \
|
||||
layEditorOptionsPages.h \
|
||||
layEditorUtils.h \
|
||||
layMargin.h \
|
||||
laybasicConfig.h \
|
||||
laybasicForceLink.h \
|
||||
|
|
|
|||
|
|
@ -1543,7 +1543,7 @@ void
|
|||
LayoutViewFunctions::cm_sel_move_interactive ()
|
||||
{
|
||||
view ()->cancel_edits ();
|
||||
if (view ()->move_service ()->begin_move ()) {
|
||||
if (view ()->move_service ()->start_move ()) {
|
||||
view ()->switch_mode (-1); // move mode
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue