| 249 | } |
| 250 | |
| 251 | void |
| 252 | Editables::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 |
no test coverage detected