Merge pull request #319 from KLayout/issue-316

Fixed issue #316 (Text capture box has zero dimension for move)
This commit is contained in:
Matthias Köfferlein 2019-08-18 17:30:54 +02:00 committed by GitHub
commit 46128e4141
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 86 additions and 28 deletions

View File

@ -641,11 +641,6 @@ draw_ruler (const ant::Object &ruler, const db::DCplxTrans &trans, bool sel, lay
}
// -------------------------------------------------------------
// search range for select in pixels
static unsigned int search_range = 5; // TODO: make variable?
// -------------------------------------------------------------
View::View (ant::Service *rulers, const ant::Object *ruler, bool selected)
@ -888,6 +883,12 @@ Service::clear_rulers ()
reduce_rulers (0);
}
double
Service::catch_distance ()
{
return double (view ()->search_range ()) / widget ()->mouse_event_trans ().mag ();
}
void
Service::drag_cancel ()
{
@ -1046,7 +1047,7 @@ Service::begin_move (lay::Editable::MoveMode mode, const db::DPoint &p, lay::ang
m_move_mode = MoveNone;
// compute search box
double l = double (search_range) / widget ()->mouse_event_trans ().mag ();
double l = catch_distance ();
db::DBox search_dbox = db::DBox (p, p).enlarged (db::DVector (l, l));
// test, whether we are moving a handle of one selected object
@ -1081,7 +1082,7 @@ Service::begin_move (lay::Editable::MoveMode mode, const db::DPoint &p, lay::ang
m_move_mode = MoveNone;
// compute search box
double l = double (search_range) / widget ()->mouse_event_trans ().mag ();
double l = catch_distance ();
db::DBox search_dbox = db::DBox (p, p).enlarged (db::DVector (l, l));
// box-selection
@ -1803,7 +1804,7 @@ double
Service::click_proximity (const db::DPoint &pos, lay::Editable::SelectionMode mode)
{
// compute search box
double l = double (search_range) / widget ()->mouse_event_trans ().mag ();
double l = catch_distance ();
db::DBox search_dbox = db::DBox (pos, pos).enlarged (db::DVector (l, l));
// for single-point selections either exclude the current selection or the
@ -1858,7 +1859,7 @@ Service::transient_select (const db::DPoint &pos)
bool any_selected = false;
// compute search box
double l = double (search_range) / widget ()->mouse_event_trans ().mag ();
double l = catch_distance ();
db::DBox search_dbox = db::DBox (pos, pos).enlarged (db::DVector (l, l));
// point selection: look for the "closest" ruler
@ -1963,7 +1964,7 @@ Service::select (const db::DBox &box, lay::Editable::SelectionMode mode)
} else {
// compute search box
double l = double (search_range) / widget ()->mouse_event_trans ().mag ();
double l = catch_distance ();
db::DBox search_dbox = box.enlarged (db::DVector (l, l));
if (! box.is_point ()) {

View File

@ -269,6 +269,11 @@ public:
*/
virtual double click_proximity (const db::DPoint &pos, lay::Editable::SelectionMode mode);
/**
* @brief Gets the catch distance
*/
virtual double catch_distance ();
/**
* @brief "select" operation
*/

View File

@ -1094,7 +1094,7 @@ PartialService::timeout ()
mp_view->clear_transient_selection ();
// compute search box
double l = double (view ()->search_range ()) / widget ()->mouse_event_trans ().mag ();
double l = catch_distance ();
db::DBox search_box = db::DBox (m_hover_point, m_hover_point).enlarged (db::DVector (l, l));
PartialShapeFinder finder (true, m_top_level_sel, db::ShapeIterator::All);
@ -1748,7 +1748,7 @@ PartialService::mouse_click_event (const db::DPoint &p, unsigned int buttons, bo
try {
// compute search box
double l = double (view ()->search_range ()) / widget ()->mouse_event_trans ().mag ();
double l = catch_distance ();
db::DBox search_box = db::DBox (p, p).enlarged (db::DVector (l, l));
// check, if there is a selected shape under the mouse - in this case, we do not do a new selection
@ -2324,6 +2324,12 @@ PartialService::enter_edge (const EdgeWithIndex &e, size_t &nmarker, partial_obj
}
double
PartialService::catch_distance ()
{
return double (view ()->search_range ()) / widget ()->mouse_event_trans ().mag ();
}
db::DPoint
PartialService::single_selected_point () const
{
@ -2551,7 +2557,7 @@ PartialService::partial_select (const db::DBox &box, lay::Editable::SelectionMod
clear_partial_transient_selection ();
// compute search box
double l = double (view ()->search_range ()) / widget ()->mouse_event_trans ().mag ();
double l = catch_distance ();
db::DBox search_box = box.enlarged (db::DVector (l, l));
bool needs_update = false;

View File

@ -238,6 +238,11 @@ public:
*/
virtual void transform (const db::DCplxTrans &tr);
/**
* @brief Gets the catch distance
*/
virtual double catch_distance ();
/**
* @brief Returns the number of selected objects
*/

View File

@ -825,11 +825,17 @@ Service::has_transient_selection ()
return ! m_transient_selection.empty ();
}
double
Service::catch_distance ()
{
return double (view ()->search_range ()) / widget ()->mouse_event_trans ().mag ();
}
double
Service::click_proximity (const db::DPoint &pos, lay::Editable::SelectionMode mode)
{
// compute search box
double l = double (view ()->search_range ()) / widget ()->mouse_event_trans ().mag ();
double l = catch_distance ();
db::DBox search_box = db::DBox (pos, pos).enlarged (db::DVector (l, l));
// for single-point selections either exclude the current selection or the
@ -889,7 +895,7 @@ Service::transient_select (const db::DPoint &pos)
}
// compute search box
double l = double (view ()->search_range ()) / widget ()->mouse_event_trans ().mag ();
double l = catch_distance ();
db::DBox search_box = db::DBox (pos, pos).enlarged (db::DVector (l, l));
if (m_cell_inst_service) {
@ -1152,7 +1158,7 @@ bool
Service::select (const db::DBox &box, lay::Editable::SelectionMode mode)
{
// compute search box
double l = double (view ()->search_range ()) / widget ()->mouse_event_trans ().mag ();
double l = catch_distance ();
db::DBox search_box = box.enlarged (db::DVector (l, l));
bool needs_update = false;

View File

@ -162,6 +162,11 @@ public:
*/
virtual double click_proximity (const db::DPoint &pos, lay::Editable::SelectionMode mode);
/**
* @brief Gets the catch distance
*/
virtual double catch_distance ();
/**
* @brief "select" operation
*/

View File

@ -428,11 +428,6 @@ View::render (const lay::Viewport &vp, lay::ViewObjectCanvas &canvas)
}
}
// -------------------------------------------------------------
// search range for select in pixels
static unsigned int search_range = 5; // TODO: make variable?
// -------------------------------------------------------------
// img::Service implementation
@ -599,7 +594,7 @@ Service::begin_move (lay::Editable::MoveMode mode, const db::DPoint &p, lay::ang
widget ()->drag_cancel (); // KLUDGE: every service does this to the same service manager
// compute search box
double l = double (search_range) / widget ()->mouse_event_trans ().mag ();
double l = catch_distance ();
db::DBox search_dbox = db::DBox (p, p).enlarged (db::DVector (l, l));
// choose move mode
@ -1104,11 +1099,17 @@ Service::clear_selection ()
clear_transient_selection ();
}
double
Service::catch_distance ()
{
return double (view ()->search_range ()) / widget ()->mouse_event_trans ().mag ();
}
double
Service::click_proximity (const db::DPoint &pos, lay::Editable::SelectionMode mode)
{
// compute search box
double l = double (search_range) / widget ()->mouse_event_trans ().mag ();
double l = catch_distance ();
db::DBox search_dbox = db::DBox (pos, pos).enlarged (db::DVector (l, l));
// for single-point selections either exclude the current selection or the
@ -1142,7 +1143,7 @@ Service::transient_select (const db::DPoint &pos)
bool any_selected = false;
// compute search box
double l = double (search_range) / widget ()->mouse_event_trans ().mag ();
double l = catch_distance ();
db::DBox search_dbox = db::DBox (pos, pos).enlarged (db::DVector (l, l));
// point selection: look for the "closest" image
@ -1240,7 +1241,7 @@ Service::select (const db::DBox &box, lay::Editable::SelectionMode mode)
} else {
// compute search box
double l = double (search_range) / widget ()->mouse_event_trans ().mag ();
double l = catch_distance ();
db::DBox search_dbox = box.enlarged (db::DVector (l, l));
if (! box.is_point ()) {

View File

@ -284,7 +284,12 @@ public:
*/
virtual double click_proximity (const db::DPoint &pos, lay::Editable::SelectionMode mode);
/**
/**
* @brief Gets the catch distance
*/
virtual double catch_distance ();
/**
* @brief "select" operation
*/
virtual bool select (const db::DBox &box, lay::Editable::SelectionMode mode);

View File

@ -143,7 +143,18 @@ Editables::selection_bbox ()
return sel_bbox;
}
void
db::DBox
Editables::selection_catch_bbox ()
{
db::DBox sel_bbox;
for (iterator e = begin (); e != end (); ++e) {
double l = e->catch_distance ();
sel_bbox += e->selection_bbox ().enlarged (db::DVector (l, l));
}
return sel_bbox;
}
void
Editables::transform (const db::DCplxTrans &tr)
{
if (selection_size () > 0) {
@ -434,7 +445,7 @@ Editables::begin_move (const db::DPoint &p, lay::angle_constraint_type ac)
// sort the plugins found by the proximity
std::sort (plugins.begin (), plugins.end (), first_of_pair_cmp_f<double, iterator> ());
if (selection_size () > 0 && selection_bbox ().contains (p)) {
if (selection_size () > 0 && selection_catch_bbox ().contains (p)) {
// if anything is selected and we are within the selection bbox,
// issue a move operation on all editables: first try a Partial mode begin_move

View File

@ -154,6 +154,17 @@ public:
return std::numeric_limits<double>::max ();
}
/**
* @brief The catch distance
*
* The catch distance is a typical value for the "fuzzyness" of a mouse click.
* It is given in micron.
*/
virtual double catch_distance ()
{
return 0.0;
}
/**
* @brief transient selection
*
@ -577,6 +588,8 @@ private:
bool m_move_selection;
bool m_any_move_operation;
db::DBox m_last_selected_point;
db::DBox selection_catch_bbox ();
};
}