MCPcopy Create free account
hub / github.com/MeshInspector/MeshLib / onMouseDown_

Method onMouseDown_

source/MRViewer/MRPickPointManager.cpp:463–570  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

461}
462
463bool PickPointManager::onMouseDown_( Viewer::MouseButton button, int mod )
464{
465 if ( button != Viewer::MouseButton::Left )
466 return false;
467
468 auto [obj, pick] = pick_();
469 if ( !obj )
470 return false;
471
472 if ( mod == 0 && myPickSpheres_.contains( obj.get() ) )
473 return false; // we can be here only if pick sphere under cursor was not properly hovered and thus ignored mouse down
474
475 if ( ( params.surfacePointParams.pickInBackFaceObject == false ) && ( SurfacePointWidget::isPickIntoBackFace( obj, pick, getViewerInstance().viewport().getCameraPoint() ) ) )
476 return false;
477
478 if ( !mod ) // just add new point
479 {
480 auto objVisual = std::dynamic_pointer_cast< VisualObject >( obj );
481 if ( !objVisual )
482 return false;
483
484 // all pick in point (without mod) must not comes here. Point widget must "eat" them.
485 if ( isClosedContour( objVisual ) )
486 return false;
487
488 assert( objVisual != nullptr ); // contoursWidget_ can join for mesh objects only
489
490 if ( params.canAddPoint && !params.canAddPoint( objVisual, -1 ) )
491 return false;
492 return appendPoint( objVisual, pointOnObjectToPickedPoint( objVisual.get(), pick ), params.startDraggingJustAddedPoint );
493 }
494 else if ( mod == params.widgetContourCloseMod ) // close contour case
495 {
496 // Try to find parent object
497 auto isFirstPointOnContourClicked = false;
498 std::shared_ptr<VisualObject> objectToCloseCoutour = nullptr;
499 for ( const auto& [parentObj, contour] : pickedPoints_ )
500 {
501 if ( contour.size() > 2 && obj == contour[0]->getPickSphere() )
502 {
503 isFirstPointOnContourClicked = true;
504 objectToCloseCoutour = parentObj;
505 break;
506 }
507 }
508 if ( !isFirstPointOnContourClicked )
509 return false;
510 return closeContour( objectToCloseCoutour );
511 }
512 else if ( mod == params.widgetDeletePointMod ) // remove point case
513 {
514 if ( pickedPoints_.empty() )
515 return false;
516
517 int pickedIndex = -1;
518 std::shared_ptr<MR::VisualObject> pickedObj = nullptr;
519
520 // try to find point to remove

Callers

nothing calls this directly

Calls 6

getCameraPointMethod · 0.80
containsMethod · 0.45
getMethod · 0.45
sizeMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected