MCPcopy Create free account
hub / github.com/KLayout/klayout / transient_select

Method transient_select

src/laybasic/laybasic/layEditable.cc:251–313  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

249}
250
251void
252Editables::transient_select (const db::DPoint &pt)
253{
254 bool same_point = (m_last_selected_point.is_point () && m_last_selected_point.center ().sq_double_distance (pt) < 1e-10);
255 if (! same_point) {
256 clear_previous_selection ();
257 }
258
259 // in a first pass evaluate the point selection proximity value to select
260 // those plugins that are active. This code is a copy of the code for the single-point selection below.
261
262 std::vector< std::pair <double, iterator> > plugins;
263
264 for (iterator e = begin (); e != end (); ++e) {
265 if (m_enabled.find (&*e) != m_enabled.end ()) {
266 plugins.push_back (std::make_pair (e->click_proximity (pt, lay::Editable::Replace), e));
267 }
268 }
269
270 // sort the plugins found by the proximity
271 std::sort (plugins.begin (), plugins.end (), first_of_pair_cmp_f<double, iterator> ());
272
273 // and call select on those objects until the first one (with the least proximity)
274 // has something selected
275 std::vector< std::pair<double, iterator> >::const_iterator pi = plugins.begin ();
276 for ( ; pi != plugins.end (); ++pi) {
277 if (pi->second->transient_select (pt)) {
278 break;
279 }
280 }
281
282 // if no plugin has selected anything, try a reset (clear previous selection) and select again: this is supposed
283 // to implement the cycling protocol which allows the plugins to cycle through different
284 // selections for repeated clicks on the same point. Let this happen for replace mode
285 // only because otherwise clearing the selection does not make sense.
286 if (same_point && pi == plugins.end ()) {
287
288 clear_previous_selection ();
289
290 plugins.clear ();
291
292 for (iterator e = begin (); e != end (); ++e) {
293 if (m_enabled.find (&*e) != m_enabled.end ()) {
294 plugins.push_back (std::make_pair (e->click_proximity (pt, lay::Editable::Replace), e));
295 }
296 }
297
298 // sort the plugins found by the proximity
299 std::sort (plugins.begin (), plugins.end (), first_of_pair_cmp_f<double, iterator> ());
300
301 for (pi = plugins.begin (); pi != plugins.end (); ++pi) {
302 if (pi->second->transient_select (pt)) {
303 break;
304 }
305 }
306
307 }
308

Callers 1

timeoutMethod · 0.45

Calls 13

clear_previous_selectionFunction · 0.85
sortFunction · 0.85
is_pointMethod · 0.80
centerMethod · 0.80
beginFunction · 0.70
endFunction · 0.70
findMethod · 0.45
endMethod · 0.45
push_backMethod · 0.45
click_proximityMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected