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,6 +887,12 @@ Service::catch_distance ()
|
||||||
return double (view ()->search_range ()) / widget ()->mouse_event_trans ().mag ();
|
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 ();
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Service::drag_cancel ()
|
Service::drag_cancel ()
|
||||||
{
|
{
|
||||||
|
|
@ -2037,7 +2043,7 @@ Service::select (const db::DBox &box, lay::Editable::SelectionMode mode)
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// compute search box
|
// 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));
|
db::DBox search_dbox = box.enlarged (db::DVector (l, l));
|
||||||
|
|
||||||
if (! box.is_point ()) {
|
if (! box.is_point ()) {
|
||||||
|
|
|
||||||
|
|
@ -276,10 +276,15 @@ public:
|
||||||
virtual double click_proximity (const db::DPoint &pos, lay::Editable::SelectionMode mode);
|
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 ();
|
virtual double catch_distance ();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Gets the catch distance (for box)
|
||||||
|
*/
|
||||||
|
virtual double catch_distance_box ();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief "select" operation
|
* @brief "select" operation
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -2349,6 +2349,12 @@ PartialService::catch_distance ()
|
||||||
return double (view ()->search_range ()) / widget ()->mouse_event_trans ().mag ();
|
return double (view ()->search_range ()) / widget ()->mouse_event_trans ().mag ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double
|
||||||
|
PartialService::catch_distance_box ()
|
||||||
|
{
|
||||||
|
return double (view ()->search_range_box ()) / widget ()->mouse_event_trans ().mag ();
|
||||||
|
}
|
||||||
|
|
||||||
db::DPoint
|
db::DPoint
|
||||||
PartialService::single_selected_point () const
|
PartialService::single_selected_point () const
|
||||||
{
|
{
|
||||||
|
|
@ -2576,7 +2582,7 @@ PartialService::partial_select (const db::DBox &box, lay::Editable::SelectionMod
|
||||||
clear_partial_transient_selection ();
|
clear_partial_transient_selection ();
|
||||||
|
|
||||||
// compute search box
|
// 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));
|
db::DBox search_box = box.enlarged (db::DVector (l, l));
|
||||||
|
|
||||||
bool needs_update = false;
|
bool needs_update = false;
|
||||||
|
|
|
||||||
|
|
@ -235,10 +235,15 @@ public:
|
||||||
virtual void transform (const db::DCplxTrans &tr);
|
virtual void transform (const db::DCplxTrans &tr);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Gets the catch distance
|
* @brief Gets the catch distance (for single click)
|
||||||
*/
|
*/
|
||||||
virtual double catch_distance ();
|
virtual double catch_distance ();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Gets the catch distance (for box)
|
||||||
|
*/
|
||||||
|
virtual double catch_distance_box ();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Indicates whether objects are selected
|
* @brief Indicates whether objects are selected
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -895,6 +895,12 @@ Service::catch_distance ()
|
||||||
return double (view ()->search_range ()) / widget ()->mouse_event_trans ().mag ();
|
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
|
double
|
||||||
Service::click_proximity (const db::DPoint &pos, lay::Editable::SelectionMode mode)
|
Service::click_proximity (const db::DPoint &pos, lay::Editable::SelectionMode mode)
|
||||||
{
|
{
|
||||||
|
|
@ -1231,7 +1237,7 @@ bool
|
||||||
Service::select (const db::DBox &box, lay::Editable::SelectionMode mode)
|
Service::select (const db::DBox &box, lay::Editable::SelectionMode mode)
|
||||||
{
|
{
|
||||||
// compute search box
|
// 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));
|
db::DBox search_box = box.enlarged (db::DVector (l, l));
|
||||||
|
|
||||||
bool needs_update = false;
|
bool needs_update = false;
|
||||||
|
|
|
||||||
|
|
@ -179,10 +179,15 @@ public:
|
||||||
virtual double click_proximity (const db::DPoint &pos, lay::Editable::SelectionMode mode);
|
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 ();
|
virtual double catch_distance ();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Gets the catch distance (for box)
|
||||||
|
*/
|
||||||
|
virtual double catch_distance_box ();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief "select" operation
|
* @brief "select" operation
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -1153,6 +1153,12 @@ Service::catch_distance ()
|
||||||
return double (view ()->search_range ()) / widget ()->mouse_event_trans ().mag ();
|
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
|
double
|
||||||
Service::click_proximity (const db::DPoint &pos, lay::Editable::SelectionMode mode)
|
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 {
|
} else {
|
||||||
|
|
||||||
// compute search box
|
// 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));
|
db::DBox search_dbox = box.enlarged (db::DVector (l, l));
|
||||||
|
|
||||||
if (! box.is_point ()) {
|
if (! box.is_point ()) {
|
||||||
|
|
|
||||||
|
|
@ -295,10 +295,15 @@ public:
|
||||||
virtual double click_proximity (const db::DPoint &pos, lay::Editable::SelectionMode mode);
|
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 ();
|
virtual double catch_distance ();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Gets the catch distance for box
|
||||||
|
*/
|
||||||
|
virtual double catch_distance_box ();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief "select" operation
|
* @brief "select" operation
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -214,7 +214,7 @@
|
||||||
<property name="frameShadow">
|
<property name="frameShadow">
|
||||||
<enum>QFrame::Raised</enum>
|
<enum>QFrame::Raised</enum>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<property name="leftMargin">
|
<property name="leftMargin">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
|
|
@ -227,28 +227,14 @@
|
||||||
<property name="bottomMargin">
|
<property name="bottomMargin">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
<item row="0" column="2">
|
||||||
<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>
|
|
||||||
<widget class="QLabel" name="label_3">
|
<widget class="QLabel" name="label_3">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>pixel</string>
|
<string>pixel</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item row="0" column="3">
|
||||||
<spacer name="horizontalSpacer">
|
<spacer name="horizontalSpacer">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
|
|
@ -261,6 +247,41 @@
|
||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</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>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</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.
|
* The catch distance is a typical value for the "fuzzyness" of a mouse click.
|
||||||
* It is given in micron.
|
* It is given in micron.
|
||||||
|
|
@ -166,6 +166,17 @@ public:
|
||||||
return 0.0;
|
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
|
* @brief transient selection
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -463,6 +463,7 @@ LayoutView::init (db::Manager *mgr, QWidget * /*parent*/)
|
||||||
m_always_show_ld = true;
|
m_always_show_ld = true;
|
||||||
m_always_show_layout_index = false;
|
m_always_show_layout_index = false;
|
||||||
m_search_range = 5;
|
m_search_range = 5;
|
||||||
|
m_search_range_box = 0;
|
||||||
|
|
||||||
m_layer_properties_lists.push_back (new LayerPropertiesList ());
|
m_layer_properties_lists.push_back (new LayerPropertiesList ());
|
||||||
m_layer_properties_lists.back ()->attach_view (this, (unsigned int) (m_layer_properties_lists.size () - 1));
|
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);
|
set_search_range (n);
|
||||||
return true;
|
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) {
|
} else if (name == cfg_abstract_mode_enabled) {
|
||||||
|
|
||||||
bool e;
|
bool e;
|
||||||
|
|
@ -5882,6 +5890,18 @@ LayoutView::set_search_range (unsigned int sr)
|
||||||
m_search_range = 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
|
void
|
||||||
LayoutView::message (const std::string &s, int timeout)
|
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
|
* 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.
|
* mouse cursor. This value gives the search range in pixels.
|
||||||
*/
|
*/
|
||||||
unsigned int search_range ();
|
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);
|
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
|
* @brief Return true, if any cellview is editable
|
||||||
*/
|
*/
|
||||||
|
|
@ -2808,6 +2820,7 @@ private:
|
||||||
bool m_marker_halo;
|
bool m_marker_halo;
|
||||||
|
|
||||||
unsigned int m_search_range;
|
unsigned int m_search_range;
|
||||||
|
unsigned int m_search_range_box;
|
||||||
|
|
||||||
bool m_transient_selection_mode;
|
bool m_transient_selection_mode;
|
||||||
bool m_sel_inside_pcells;
|
bool m_sel_inside_pcells;
|
||||||
|
|
|
||||||
|
|
@ -374,6 +374,10 @@ LayoutViewConfigPage2c::setup (lay::Dispatcher *root)
|
||||||
unsigned int sr = 0;
|
unsigned int sr = 0;
|
||||||
root->config_get (cfg_search_range, sr);
|
root->config_get (cfg_search_range, sr);
|
||||||
mp_ui->search_range_spinbx->setValue (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
|
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_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_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, (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_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_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, "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_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_abstract_mode_enabled, "false"));
|
||||||
options.push_back (std::pair<std::string, std::string> (cfg_fit_new_cell, "true"));
|
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_child_ctx_enabled ("child-context-enabled");
|
||||||
|
|
||||||
static const std::string cfg_search_range ("search-range");
|
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_enabled ("abstract-mode-enabled");
|
||||||
static const std::string cfg_abstract_mode_width ("abstract-mode-width");
|
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.has_selection?, false)
|
||||||
assert_equal(view.selection_size, 0)
|
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))
|
view.select_from(RBA::DBox::new(-1.0, -1.0, 1.0, 1.0))
|
||||||
assert_equal(selection_changed, 1)
|
assert_equal(selection_changed, 1)
|
||||||
assert_equal(view.selection_size, 4)
|
assert_equal(view.selection_size, 4)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue