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

Method start_move

src/laybasic/laybasic/layMove.cc:325–378  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

323}
324
325bool
326MoveService::start_move (db::Transaction *transaction, bool transient_selection)
327{
328 if (m_dragging) {
329 return false;
330 }
331
332 std::unique_ptr<db::Transaction> trans_holder (transaction);
333
334 bool drag_transient = false;
335
336 if (! transaction) {
337
338 // unless in "continue with move" use case try to establish a selection
339
340 if (! mp_editables->has_selection ()) {
341 // try to use the transient selection for the real one
342 mp_editables->transient_to_selection ();
343 drag_transient = true;
344 }
345
346 if (! mp_editables->has_selection ()) {
347 // still nothing selected
348 return false;
349 }
350
351 } else {
352
353 // inherit transient selection mode from previous operation
354 drag_transient = transient_selection;
355
356 }
357
358 db::DBox bbox = mp_editables->selection_bbox ();
359 if (bbox.empty ()) {
360 // nothing (useful) selected
361 return false;
362 }
363
364 set_cursor (lay::Cursor::size_all);
365
366 // emulate a "begin move" at the current mouse position if inside the box or the closest point
367 // of the box.
368
369 db::DPoint pstart = m_mouse_pos;
370 if (! bbox.contains (pstart)) {
371 pstart.set_x (std::max (pstart.x (), bbox.p1 ().x ()));
372 pstart.set_x (std::min (pstart.x (), bbox.p2 ().x ()));
373 pstart.set_y (std::max (pstart.y (), bbox.p1 ().y ()));
374 pstart.set_y (std::min (pstart.y (), bbox.p2 ().y ()));
375 }
376
377 return handle_click (pstart, 0, drag_transient, trans_holder.release ());
378}
379
380void
381MoveService::finish_move ()

Callers 4

mouse_press_eventMethod · 0.80
mouse_click_eventMethod · 0.80
paste_interactiveMethod · 0.80

Calls 13

maxFunction · 0.85
minFunction · 0.85
yMethod · 0.80
has_selectionMethod · 0.45
selection_bboxMethod · 0.45
emptyMethod · 0.45
containsMethod · 0.45
set_xMethod · 0.45
xMethod · 0.45
p1Method · 0.45
p2Method · 0.45

Tested by

no test coverage detected