10#include <MRMesh/MRphmap.h>
11#include <unordered_map>
28 int widgetContourCloseMod = GLFW_MOD_CONTROL;
31 int widgetDeletePointMod = GLFW_MOD_SHIFT;
50 MR::Color closeContourPointColor = Color::transparent();
88 [[nodiscard]] MRVIEWER_API
bool isClosedCountour(
const std::shared_ptr<VisualObject>& obj )
const;
91 [[nodiscard]] MRVIEWER_API std::shared_ptr<SurfacePointWidget>
getPointWidget(
const std::shared_ptr<VisualObject>& obj,
int index )
const;
100 MRVIEWER_API
bool removePoint(
const std::shared_ptr<VisualObject>& obj,
int pickedIndex );
105 MRVIEWER_API
bool closeContour(
const std::shared_ptr<VisualObject>& obj,
bool makeClosed =
true );
124 MRVIEWER_API
bool onMouseDown_(
MouseButton button,
int modifier )
override;
125 MRVIEWER_API
bool onMouseMove_(
int mouse_x,
int mouse_y )
override;
131 void colorLast2Points_(
const std::shared_ptr<VisualObject>& obj );
134 [[nodiscard]] std::shared_ptr<SurfacePointWidget> createPickWidget_(
const std::shared_ptr<MR::VisualObject>& obj,
const PickedPoint& pt );
137 void clearNoHistory_();
141 void swapStateNoHistory_(
FullState& s );
145 int insertPointNoHistory_(
const std::shared_ptr<VisualObject>& obj,
int index,
const PickedPoint& point );
148 PickedPoint removePointNoHistory_(
const std::shared_ptr<VisualObject>& obj,
int index );
151 bool moveClosedPoint_ =
false;
163 HashSet<const VisualObject*> myPickSpheres_;
166 struct ConnectionHolder
168 boost::signals2::scoped_connection onMeshChanged;
169 boost::signals2::scoped_connection onPointsChanged;
174 class SetStateHistoryAction;
175 class AddRemovePointHistoryAction;
176 class MovePointHistoryAction;
std::pair< std::shared_ptr< MR::VisualObject >, MR::PointOnObject > ObjAndPick
Definition MRViewport.h:21
Definition MRHistoryAction.h:12
Definition MRPickPointManager.h:21
MRVIEWER_API FullState getFullState() const
returns the state of this
std::vector< ObjectState > FullState
Definition MRPickPointManager.h:112
MRVIEWER_API ~PickPointManager()
destroy this and remove the undo/redo actions referring this from the history.
std::unordered_map< std::shared_ptr< MR::VisualObject >, SurfaceContour > SurfaceContours
Definition MRPickPointManager.h:73
SurfacePointWidget * draggedPointWidget() const
returns point widget currently dragged by mouse
Definition MRPickPointManager.h:94
std::vector< std::shared_ptr< SurfacePointWidget > > SurfaceContour
Definition MRPickPointManager.h:72
MRVIEWER_API bool appendPoint(const std::shared_ptr< VisualObject > &obj, const PickedPoint &triPoint)
Add a point to the end of non closed contour connected with obj.
const SurfaceContours & getSurfaceContours() const
return all contours, i.e. per object unorderd_map of ordered surface points [vector].
Definition MRPickPointManager.h:85
MRVIEWER_API bool removePoint(const std::shared_ptr< VisualObject > &obj, int pickedIndex)
Remove point with pickedIndex index from contour connected with obj.
MRVIEWER_API void clear()
removes all points from all objects
MRVIEWER_API PickPointManager()
create an object and starts listening for mouse events
MRVIEWER_API void setFullState(FullState s)
removes all current points, then adds pick points on all objects as prescribed by given state
std::function< void(std::shared_ptr< MR::VisualObject > obj, int index)> PickerPointCallBack
Definition MRPickPointManager.h:23
Params params
Definition MRPickPointManager.h:67
MRVIEWER_API bool isClosedCountour(const std::shared_ptr< VisualObject > &obj) const
check whether the contour is closed for a particular object.
MRVIEWER_API std::shared_ptr< SurfacePointWidget > getPointWidget(const std::shared_ptr< VisualObject > &obj, int index) const
returns point widget by index from given object or nullptr if no such widget exists
MRVIEWER_API bool closeContour(const std::shared_ptr< VisualObject > &obj, bool makeClosed=true)
const SurfaceContour & getSurfaceContour(const std::shared_ptr< MR::VisualObject > &obj)
return contour for specific object (creating new one if necessary)
Definition MRPickPointManager.h:82
std::function< bool(const VisualObject *, ViewportMask)> PickRenderObjectPredicate
Definition MRViewport.h:155
MouseButton
Definition MRMouse.h:9
std::variant< MeshTriPoint, EdgePoint, VertId, int > PickedPoint
Definition MRPointOnObject.h:40
phmap::flat_hash_map< K, V, Hash, Eq > HashMap
Definition MRMesh/MRMeshFwd.h:482
Definition MRMesh/MRColor.h:9
Definition MRViewerEventsListener.h:20
Definition MRViewerEventsListener.h:29
Definition MRPickPointManager.h:108
std::vector< PickedPoint > pickedPoints
Definition MRPickPointManager.h:110
std::weak_ptr< VisualObject > objPtr
Definition MRPickPointManager.h:109
Definition MRPickPointManager.h:26
PickerPointCallBack onPointMoveFinish
This callback is invoked when point's dragging is completed.
Definition MRPickPointManager.h:62
PickerPointCallBack onPointRemove
This callback is invoked when a point is removed with its index before deletion.
Definition MRPickPointManager.h:65
SurfacePointWidget::Parameters surfacePointParams
Definition MRPickPointManager.h:38
PickerPointCallBack onPointAdd
This callback is invoked after a point is added with its index.
Definition MRPickPointManager.h:56
Viewport::PickRenderObjectPredicate pickPredicate
Predicate to additionally filter objects that should be treated as pickable.
Definition MRPickPointManager.h:53
PickerPointCallBack onPointMoveStart
This callback is invoked when a point starts being dragged.
Definition MRPickPointManager.h:59
std::string historyNameSuffix
This is appended to the names of all undo/redo actions.
Definition MRPickPointManager.h:34
A common base class for all history actions of this widget.
Definition MRPickPointManager.h:70