mirror of https://github.com/KLayout/klayout.git
Merge pull request #774 from KLayout/issue-715
Fixes #715 (selection box larger than drawn)
This commit is contained in:
commit
7ef56c28c8
|
|
@ -887,7 +887,13 @@ Service::catch_distance ()
|
|||
return double (view ()->search_range ()) / widget ()->mouse_event_trans ().mag ();
|
||||
}
|
||||
|
||||
void
|
||||
double
|
||||
Service::catch_distance_box ()
|
||||
{
|
||||
return double (view ()->search_range_box ()) / widget ()->mouse_event_trans ().mag ();
|
||||
}
|
||||
|
||||
void
|
||||
Service::drag_cancel ()
|
||||
{
|
||||
if (m_drawing) {
|
||||
|
|
@ -2037,7 +2043,7 @@ Service::select (const db::DBox &box, lay::Editable::SelectionMode mode)
|
|||
} else {
|
||||
|
||||
// compute search box
|
||||
double l = catch_distance ();
|
||||
double l = box.is_point () ? catch_distance () : catch_distance_box ();
|
||||
db::DBox search_dbox = box.enlarged (db::DVector (l, l));
|
||||
|
||||
if (! box.is_point ()) {
|
||||
|
|
|
|||
|
|
@ -276,11 +276,16 @@ public:
|
|||
virtual double click_proximity (const db::DPoint &pos, lay::Editable::SelectionMode mode);
|
||||
|
||||
/**
|
||||
* @brief Gets the catch distance
|
||||
* @brief Gets the catch distance (for single click)
|
||||
*/
|
||||
virtual double catch_distance ();
|
||||
|
||||
/**
|
||||
/**
|
||||
* @brief Gets the catch distance (for box)
|
||||
*/
|
||||
virtual double catch_distance_box ();
|
||||
|
||||
/**
|
||||
* @brief "select" operation
|
||||
*/
|
||||
virtual bool select (const db::DBox &box, lay::Editable::SelectionMode mode);
|
||||
|
|
|
|||
|
|
@ -2349,7 +2349,13 @@ PartialService::catch_distance ()
|
|||
return double (view ()->search_range ()) / widget ()->mouse_event_trans ().mag ();
|
||||
}
|
||||
|
||||
db::DPoint
|
||||
double
|
||||
PartialService::catch_distance_box ()
|
||||
{
|
||||
return double (view ()->search_range_box ()) / widget ()->mouse_event_trans ().mag ();
|
||||
}
|
||||
|
||||
db::DPoint
|
||||
PartialService::single_selected_point () const
|
||||
{
|
||||
// build the transformation variants cache and
|
||||
|
|
@ -2576,7 +2582,7 @@ PartialService::partial_select (const db::DBox &box, lay::Editable::SelectionMod
|
|||
clear_partial_transient_selection ();
|
||||
|
||||
// compute search box
|
||||
double l = catch_distance ();
|
||||
double l = box.is_point () ? catch_distance () : catch_distance_box ();
|
||||
db::DBox search_box = box.enlarged (db::DVector (l, l));
|
||||
|
||||
bool needs_update = false;
|
||||
|
|
|
|||
|
|
@ -235,11 +235,16 @@ public:
|
|||
virtual void transform (const db::DCplxTrans &tr);
|
||||
|
||||
/**
|
||||
* @brief Gets the catch distance
|
||||
* @brief Gets the catch distance (for single click)
|
||||
*/
|
||||
virtual double catch_distance ();
|
||||
|
||||
/**
|
||||
/**
|
||||
* @brief Gets the catch distance (for box)
|
||||
*/
|
||||
virtual double catch_distance_box ();
|
||||
|
||||
/**
|
||||
* @brief Indicates whether objects are selected
|
||||
*/
|
||||
virtual bool has_selection ();
|
||||
|
|
|
|||
|
|
@ -895,7 +895,13 @@ Service::catch_distance ()
|
|||
return double (view ()->search_range ()) / widget ()->mouse_event_trans ().mag ();
|
||||
}
|
||||
|
||||
double
|
||||
double
|
||||
Service::catch_distance_box ()
|
||||
{
|
||||
return double (view ()->search_range_box ()) / widget ()->mouse_event_trans ().mag ();
|
||||
}
|
||||
|
||||
double
|
||||
Service::click_proximity (const db::DPoint &pos, lay::Editable::SelectionMode mode)
|
||||
{
|
||||
// compute search box
|
||||
|
|
@ -1231,7 +1237,7 @@ bool
|
|||
Service::select (const db::DBox &box, lay::Editable::SelectionMode mode)
|
||||
{
|
||||
// compute search box
|
||||
double l = catch_distance ();
|
||||
double l = box.is_point () ? catch_distance () : catch_distance_box ();
|
||||
db::DBox search_box = box.enlarged (db::DVector (l, l));
|
||||
|
||||
bool needs_update = false;
|
||||
|
|
|
|||
|
|
@ -179,11 +179,16 @@ public:
|
|||
virtual double click_proximity (const db::DPoint &pos, lay::Editable::SelectionMode mode);
|
||||
|
||||
/**
|
||||
* @brief Gets the catch distance
|
||||
* @brief Gets the catch distance (for single click)
|
||||
*/
|
||||
virtual double catch_distance ();
|
||||
|
||||
/**
|
||||
/**
|
||||
* @brief Gets the catch distance (for box)
|
||||
*/
|
||||
virtual double catch_distance_box ();
|
||||
|
||||
/**
|
||||
* @brief "select" operation
|
||||
*/
|
||||
virtual bool select (const db::DBox &box, lay::Editable::SelectionMode mode);
|
||||
|
|
|
|||
|
|
@ -1153,6 +1153,12 @@ Service::catch_distance ()
|
|||
return double (view ()->search_range ()) / widget ()->mouse_event_trans ().mag ();
|
||||
}
|
||||
|
||||
double
|
||||
Service::catch_distance_box ()
|
||||
{
|
||||
return double (view ()->search_range_box ()) / widget ()->mouse_event_trans ().mag ();
|
||||
}
|
||||
|
||||
double
|
||||
Service::click_proximity (const db::DPoint &pos, lay::Editable::SelectionMode mode)
|
||||
{
|
||||
|
|
@ -1293,7 +1299,7 @@ Service::select (const db::DBox &box, lay::Editable::SelectionMode mode)
|
|||
} else {
|
||||
|
||||
// compute search box
|
||||
double l = catch_distance ();
|
||||
double l = box.is_point () ? catch_distance () : catch_distance_box ();
|
||||
db::DBox search_dbox = box.enlarged (db::DVector (l, l));
|
||||
|
||||
if (! box.is_point ()) {
|
||||
|
|
|
|||
|
|
@ -295,10 +295,15 @@ public:
|
|||
virtual double click_proximity (const db::DPoint &pos, lay::Editable::SelectionMode mode);
|
||||
|
||||
/**
|
||||
* @brief Gets the catch distance
|
||||
* @brief Gets the catch distance for single click
|
||||
*/
|
||||
virtual double catch_distance ();
|
||||
|
||||
/**
|
||||
* @brief Gets the catch distance for box
|
||||
*/
|
||||
virtual double catch_distance_box ();
|
||||
|
||||
/**
|
||||
* @brief "select" operation
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -214,7 +214,7 @@
|
|||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
|
|
@ -227,28 +227,14 @@
|
|||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Capture range to mouse cursor</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="search_range_spinbx">
|
||||
<property name="maximum">
|
||||
<number>9999</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>pixel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<item row="0" column="3">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
|
|
@ -261,6 +247,41 @@
|
|||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QSpinBox" name="search_range_spinbx">
|
||||
<property name="maximum">
|
||||
<number>9999</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Capture range to mouse cursor (single click)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Capture range to mouse cursor (box)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QSpinBox" name="search_range_box_spinbx">
|
||||
<property name="maximum">
|
||||
<number>9999</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="text">
|
||||
<string>pixel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
|
|||
|
|
@ -156,7 +156,7 @@ public:
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief The catch distance
|
||||
* @brief The catch distance (for single click)
|
||||
*
|
||||
* The catch distance is a typical value for the "fuzzyness" of a mouse click.
|
||||
* It is given in micron.
|
||||
|
|
@ -166,6 +166,17 @@ public:
|
|||
return 0.0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief The catch distance (for box)
|
||||
*
|
||||
* The catch distance is a typical value for the "fuzzyness" of a box selection.
|
||||
* It is given in micron.
|
||||
*/
|
||||
virtual double catch_distance_box ()
|
||||
{
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief transient selection
|
||||
*
|
||||
|
|
|
|||
|
|
@ -463,6 +463,7 @@ LayoutView::init (db::Manager *mgr, QWidget * /*parent*/)
|
|||
m_always_show_ld = true;
|
||||
m_always_show_layout_index = false;
|
||||
m_search_range = 5;
|
||||
m_search_range_box = 0;
|
||||
|
||||
m_layer_properties_lists.push_back (new LayerPropertiesList ());
|
||||
m_layer_properties_lists.back ()->attach_view (this, (unsigned int) (m_layer_properties_lists.size () - 1));
|
||||
|
|
@ -1250,6 +1251,13 @@ LayoutView::configure (const std::string &name, const std::string &value)
|
|||
set_search_range (n);
|
||||
return true;
|
||||
|
||||
} else if (name == cfg_search_range_box) {
|
||||
|
||||
unsigned int n;
|
||||
tl::from_string (value, n);
|
||||
set_search_range_box (n);
|
||||
return true;
|
||||
|
||||
} else if (name == cfg_abstract_mode_enabled) {
|
||||
|
||||
bool e;
|
||||
|
|
@ -5882,6 +5890,18 @@ LayoutView::set_search_range (unsigned int sr)
|
|||
m_search_range = sr;
|
||||
}
|
||||
|
||||
unsigned int
|
||||
LayoutView::search_range_box ()
|
||||
{
|
||||
return m_search_range_box;
|
||||
}
|
||||
|
||||
void
|
||||
LayoutView::set_search_range_box (unsigned int sr)
|
||||
{
|
||||
m_search_range_box = sr;
|
||||
}
|
||||
|
||||
void
|
||||
LayoutView::message (const std::string &s, int timeout)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2277,17 +2277,29 @@ public:
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief Gets the "search range" in pixels
|
||||
* @brief Gets the "search range" in pixels (for single click)
|
||||
* The search range applies whenever some object is looked up in the vicinity of the
|
||||
* mouse cursor. This value gives the search range in pixels.
|
||||
*/
|
||||
unsigned int search_range ();
|
||||
|
||||
/**
|
||||
* @brief Sets the "search range" in pixels
|
||||
* @brief Sets the "search range" in pixels (for single click)
|
||||
*/
|
||||
void set_search_range (unsigned int sr);
|
||||
|
||||
/**
|
||||
* @brief Gets the "search range" in pixels (for box)
|
||||
* The search range applies whenever some object is looked up in the vicinity of the
|
||||
* mouse cursor. This value gives the search range in pixels.
|
||||
*/
|
||||
unsigned int search_range_box ();
|
||||
|
||||
/**
|
||||
* @brief Sets the "search range" in pixels (for box)
|
||||
*/
|
||||
void set_search_range_box (unsigned int sr);
|
||||
|
||||
/**
|
||||
* @brief Return true, if any cellview is editable
|
||||
*/
|
||||
|
|
@ -2808,6 +2820,7 @@ private:
|
|||
bool m_marker_halo;
|
||||
|
||||
unsigned int m_search_range;
|
||||
unsigned int m_search_range_box;
|
||||
|
||||
bool m_transient_selection_mode;
|
||||
bool m_sel_inside_pcells;
|
||||
|
|
|
|||
|
|
@ -374,6 +374,10 @@ LayoutViewConfigPage2c::setup (lay::Dispatcher *root)
|
|||
unsigned int sr = 0;
|
||||
root->config_get (cfg_search_range, sr);
|
||||
mp_ui->search_range_spinbx->setValue (sr);
|
||||
|
||||
unsigned int srbox = 0;
|
||||
root->config_get (cfg_search_range_box, srbox);
|
||||
mp_ui->search_range_box_spinbx->setValue (srbox);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -388,6 +392,7 @@ LayoutViewConfigPage2c::commit (lay::Dispatcher *root)
|
|||
root->config_set (cfg_sel_transient_mode, mp_ui->transient_mode_cb->isChecked ());
|
||||
root->config_set (cfg_sel_inside_pcells_mode, mp_ui->sel_inside_pcells_cb->isChecked ());
|
||||
root->config_set (cfg_search_range, (unsigned int) mp_ui->search_range_spinbx->value ());
|
||||
root->config_set (cfg_search_range_box, (unsigned int) mp_ui->search_range_box_spinbx->value ());
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------
|
||||
|
|
@ -1564,6 +1569,7 @@ public:
|
|||
options.push_back (std::pair<std::string, std::string> (cfg_child_ctx_hollow, "false"));
|
||||
options.push_back (std::pair<std::string, std::string> (cfg_child_ctx_enabled, "false"));
|
||||
options.push_back (std::pair<std::string, std::string> (cfg_search_range, "5"));
|
||||
options.push_back (std::pair<std::string, std::string> (cfg_search_range_box, "0"));
|
||||
options.push_back (std::pair<std::string, std::string> (cfg_abstract_mode_width, "10.0"));
|
||||
options.push_back (std::pair<std::string, std::string> (cfg_abstract_mode_enabled, "false"));
|
||||
options.push_back (std::pair<std::string, std::string> (cfg_fit_new_cell, "true"));
|
||||
|
|
|
|||
|
|
@ -62,6 +62,7 @@ static const std::string cfg_child_ctx_hollow ("child-context-hollow");
|
|||
static const std::string cfg_child_ctx_enabled ("child-context-enabled");
|
||||
|
||||
static const std::string cfg_search_range ("search-range");
|
||||
static const std::string cfg_search_range_box ("search-range-box");
|
||||
|
||||
static const std::string cfg_abstract_mode_enabled ("abstract-mode-enabled");
|
||||
static const std::string cfg_abstract_mode_width ("abstract-mode-width");
|
||||
|
|
|
|||
|
|
@ -183,6 +183,7 @@ class LAYLayoutView_TestClass < TestBase
|
|||
assert_equal(view.has_selection?, false)
|
||||
assert_equal(view.selection_size, 0)
|
||||
|
||||
view.set_config("search-range-box", "5")
|
||||
view.select_from(RBA::DBox::new(-1.0, -1.0, 1.0, 1.0))
|
||||
assert_equal(selection_changed, 1)
|
||||
assert_equal(view.selection_size, 4)
|
||||
|
|
|
|||
Loading…
Reference in New Issue