7#include "MRViewer/MRGladGlfw.h"
10#include <MRMesh/MRphmap.h>
11#include <unordered_map>
27 using AllowCallBack = std::function<bool(
const std::shared_ptr<VisualObject>& obj,
int index )>;
116 [[nodiscard]] MRVIEWER_API
bool isClosedContour(
const std::shared_ptr<VisualObject>& obj )
const;
119 [[nodiscard]] MRVIEWER_API
size_t numPickPoints(
const std::shared_ptr<VisualObject>& obj )
const;
122 [[nodiscard]] MRVIEWER_API std::shared_ptr<SurfacePointWidget>
getPointWidget(
const std::shared_ptr<VisualObject>& obj,
int index )
const;
140 MRVIEWER_API
bool removePoint(
const std::shared_ptr<VisualObject>& obj,
int pickedIndex );
145 MRVIEWER_API
bool closeContour(
const std::shared_ptr<VisualObject>& obj,
bool makeClosed =
true );
164 MRVIEWER_API
bool onMouseDown_(
MouseButton button,
int modifier )
override;
165 MRVIEWER_API
bool onMouseMove_(
int mouse_x,
int mouse_y )
override;
171 void colorLast2Points_(
const std::shared_ptr<VisualObject>& obj );
174 [[nodiscard]] std::shared_ptr<SurfacePointWidget> createPickWidget_(
const std::shared_ptr<VisualObject>& obj,
const PickedPoint& pt );
177 void clearNoHistory_();
181 void swapStateNoHistory_(
FullState& s );
185 int insertPointNoHistory_(
const std::shared_ptr<VisualObject>& obj,
int index,
const PickedPoint& point,
bool startDragging );
188 PickedPoint removePointNoHistory_(
const std::shared_ptr<VisualObject>& obj,
int index );
191 template<
class HistoryActionType,
typename... Args>
192 void appendHistory_( Args&&... args );
195 void appendHistory_( std::shared_ptr<HistoryAction> action )
const;
201 bool moveClosedPoint_ =
false;
213 HashSet<const VisualObject*> myPickSpheres_;
216 struct ConnectionHolder
224 class SetStateHistoryAction;
225 class AddRemovePointHistoryAction;
226 class MovePointHistoryAction;
Definition MRHistoryAction.h:15
static constexpr Color transparent() noexcept
Definition MRColor.h:37
static constexpr Color green() noexcept
Definition MRColor.h:32
const SurfaceContour & getSurfaceContour(const std::shared_ptr< VisualObject > &obj)
return contour for specific object (creating new one if necessary)
Definition MRPickPointManager.h:110
Color ordinaryPointColor
The color of all pick spheres except the one with the largest index on each object.
Definition MRPickPointManager.h:52
std::vector< ObjectState > FullState
Definition MRPickPointManager.h:152
bool insertPoint(const std::shared_ptr< VisualObject > &obj, int index, const PickedPoint &triPoint, bool startDragging=false)
MouseButton
Definition MRMouse.h:12
AllowCallBack canRemovePoint
Definition MRPickPointManager.h:85
boost::signals2::scoped_connection onPointsChanged
Definition MRPickPointManager.h:219
PickerPointCallBack onPointMoveFinish
This callback is invoked when point's dragging is completed.
Definition MRPickPointManager.h:81
void clear()
removes all points from all objects
PickerPointCallBack onPointRemove
This callback is invoked when a point is removed with its index before deletion.
Definition MRPickPointManager.h:88
bool writeHistory
Whether to write undo history of all operations including public modifying functions and user actions...
Definition MRPickPointManager.h:39
std::function< bool(const VisualObject *, ViewportMask)> PickRenderObjectPredicate
Predicate to additionally filter objects that should be treated as pickable.
Definition MRViewport.h:187
PickPointManager()
create an object and starts listening for mouse events
boost::signals2::scoped_connection onMeshChanged
Definition MRPickPointManager.h:218
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
int getPointIndex(const std::shared_ptr< VisualObject > &obj, SurfacePointWidget &pointWidget) const
returns index of given point widget on given object or -1 if this widget is not from given object
std::variant< std::monostate, MeshTriPoint, EdgePoint, VertId > PickedPoint
Definition MRPointOnObject.h:45
bool removePoint(const std::shared_ptr< VisualObject > &obj, int pickedIndex)
Remove point with pickedIndex index from contour connected with obj.
ChangeObjectCallBack onUpdatePoints
Definition MRPickPointManager.h:92
std::unordered_map< std::shared_ptr< VisualObject >, SurfaceContour > SurfaceContours
Definition MRPickPointManager.h:101
int widgetDeletePointMod
Modifier key for deleting a point using the widget.
Definition MRPickPointManager.h:36
SurfacePointWidget::Parameters surfacePointParams
Definition MRPickPointManager.h:49
int widgetContourCloseMod
Modifier key for closing a contour (ordered vector of points) using the widget.
Definition MRPickPointManager.h:33
SurfacePointWidget * draggedPointWidget() const
returns point widget currently dragged by mouse
Definition MRPickPointManager.h:128
PickerPointCallBack onPointAdd
This callback is invoked after a point is added with its index.
Definition MRPickPointManager.h:68
std::vector< std::shared_ptr< SurfacePointWidget > > SurfaceContour
Definition MRPickPointManager.h:100
size_t numPickPoints(const std::shared_ptr< VisualObject > &obj) const
returns the total number of pick points (including extra point if the contour is closed) on given obj...
std::pair< std::shared_ptr< MR::VisualObject >, MR::PointOnObject > ObjAndPick
Definition MRViewerFwd.h:85
std::vector< PickedPoint > pickedPoints
Definition MRPickPointManager.h:150
const SurfaceContours & getSurfaceContours() const
return all contours, i.e. per object unorderd_map of ordered surface points [vector].
Definition MRPickPointManager.h:113
Vector3f triPoint(const MeshTopology &topology, const VertCoords &points, const MeshTriPoint &p)
computes coordinates of point given as face and barycentric representation
bool appendPoint(const std::shared_ptr< VisualObject > &obj, const PickedPoint &triPoint, bool startDragging=false)
void setFullState(FullState s)
removes all current points, then adds pick points on all objects as prescribed by given state
Color closeContourPointColor
The color of last by index pick sphere in closed contour, which coincides in position with the first ...
Definition MRPickPointManager.h:58
Color lastPointColor
The color of last by index pick sphere in open contour.
Definition MRPickPointManager.h:55
static constexpr Color gray() noexcept
Definition MRColor.h:30
FullState getFullState() const
returns the state of this
Viewport::PickRenderObjectPredicate pickPredicate
Predicate to additionally filter objects that should be treated as pickable.
Definition MRPickPointManager.h:61
PickerPointCallBack onPointMove
This callback is invoked every time after currently dragged point is moved (in between onPointMoveSta...
Definition MRPickPointManager.h:78
Params params
Definition MRPickPointManager.h:95
~PickPointManager()
destroy this and remove the undo/redo actions referring this from the history.
std::function< bool(const std::shared_ptr< VisualObject > &obj, int index)> AllowCallBack
Definition MRPickPointManager.h:27
std::function< bool(const std::shared_ptr< VisualObject > &obj)> ChangeObjectCallBack
Definition MRPickPointManager.h:28
PickerPointCallBack onPointMoveStart
This callback is invoked when a point starts being dragged.
Definition MRPickPointManager.h:75
AllowCallBack canAddPoint
Definition MRPickPointManager.h:65
std::weak_ptr< VisualObject > objPtr
Definition MRPickPointManager.h:149
bool startDraggingJustAddedPoint
Whether to activate dragging new point immediately after its creation on mouse down.
Definition MRPickPointManager.h:45
std::function< void(std::shared_ptr< VisualObject > obj, int index)> PickerPointCallBack
Definition MRPickPointManager.h:26
bool closeContour(const std::shared_ptr< VisualObject > &obj, bool makeClosed=true)
phmap::flat_hash_map< K, V, Hash, Eq > HashMap
Definition MRMeshFwd.h:606
AllowCallBack canMovePoint
Definition MRPickPointManager.h:72
bool isClosedContour(const std::shared_ptr< VisualObject > &obj) const
check whether the contour is closed for a particular object.
std::string historyNameSuffix
This is appended to the names of all undo/redo actions.
Definition MRPickPointManager.h:42
only for bindings generation
Definition MRCameraOrientationPlugin.h:8
Definition MRViewerEventsListener.h:32
Definition MRPickPointManager.h:148
Definition MRPickPointManager.h:31
A common base class for all history actions of this widget.
Definition MRPickPointManager.h:98