MeshLib C++ Docs
Loading...
Searching...
No Matches
MRPlaneWidget.h
Go to the documentation of this file.
1#pragma once
2
5#include "MRMesh/MRBox.h"
6#include "MRMesh/MRPlane3.h"
7#include "MRMesh/MRVector2.h"
8
9namespace MR
10{
13
16class MRVIEWER_CLASS PlaneWidget : public MultiListener<DragStartListener, DragListener, DragEndListener, NameTagClickListener>
17{
18 std::shared_ptr<ObjectMesh> planeObj_;
19 Plane3f plane_;
20 Box3f box_;
21 Vector3f cameraUp3Old_;
22
24 bool localMode_{ false };
25 float localShift_{ 0.0f };
26
27 using OnPlaneUpdateCallback = std::function<void()>;
28 OnPlaneUpdateCallback onPlaneUpdate_;
29
30 bool pressed_ = false;
31 bool showPlaneByDefault_ = true;
32 Vector2f startMousePos_;
33 Vector2f endMousePos_;
34
35 std::shared_ptr<ObjectLines> line_;
36
37 bool importPlaneMode_ = false;
38public:
39
42 MRVIEWER_API void updatePlane( const Plane3f& plane, bool updateCameraRotation = true );
45 MRVIEWER_API void updateBox( const Box3f& box, bool updateCameraRotation = true );
47 MRVIEWER_API void definePlane();
49 MRVIEWER_API void undefinePlane();
50
53 MRVIEWER_API void setLocalMode( bool on );
54 bool isInLocalMode() const { return localMode_; }
55 void setLocalShift( float shift ) { localShift_ = shift; }
56 float getLocalShift() const { return localShift_; }
57
59 MRVIEWER_API const Plane3f& getPlane() const;
61 MRVIEWER_API const std::shared_ptr<ObjectMesh>& getPlaneObject() const;
64 MRVIEWER_API void setOnPlaneUpdateCallback( OnPlaneUpdateCallback callback );
65
67 MRVIEWER_API const Box3f& box() const;
69 MRVIEWER_API bool importPlaneMode() const;
71 MRVIEWER_API void setImportPlaneMode( bool val );
72
74 bool getShowPlaneByDefault() const { return showPlaneByDefault_; }
76 void setShowPlaneByDefault( bool val ) { showPlaneByDefault_ = val; }
77
78private:
79 MRVIEWER_API void updateWidget_( bool updateCameraRotation = true );
80
81 MRVIEWER_API virtual bool onDragStart_( MouseButton button, int modifier ) override;
82 MRVIEWER_API virtual bool onDragEnd_( MouseButton button, int modifier ) override;
83 MRVIEWER_API virtual bool onDrag_( int mouse_x, int mouse_y ) override;
84 MRVIEWER_API virtual bool onNameTagClicked_( Object& object, ImGuiMenu::NameTagSelectionMode ) override;
85
86 bool importPlaneObj_( Object& obj );
87};
88}
named object in the data model
Definition MRObject.h:62
Definition MRPlaneWidget.h:17
MRVIEWER_API const Plane3f & getPlane() const
returns plane
MouseButton
Definition MRMouse.h:12
MRVIEWER_API void setImportPlaneMode(bool val)
sets the flag importPlaneMode_, if it is true you can use a plain object from the scene
MRVIEWER_API void updatePlane(const Plane3f &plane, bool updateCameraRotation=true)
MRVIEWER_API void setOnPlaneUpdateCallback(OnPlaneUpdateCallback callback)
MRVIEWER_API const std::shared_ptr< ObjectMesh > & getPlaneObject() const
returns plane object
MRVIEWER_API void definePlane()
defines plane, adds plane object to scene
float getLocalShift() const
Definition MRPlaneWidget.h:56
void setLocalShift(float shift)
Definition MRPlaneWidget.h:55
bool getShowPlaneByDefault() const
returns the flag that is true if the plane is shown by default
Definition MRPlaneWidget.h:74
bool isInLocalMode() const
Definition MRPlaneWidget.h:54
MRVIEWER_API void updateBox(const Box3f &box, bool updateCameraRotation=true)
void setShowPlaneByDefault(bool val)
sets the flag that is true if the plane is shown by default
Definition MRPlaneWidget.h:76
MRVIEWER_API void undefinePlane()
undefines plane, removes PlaneObject from scene
NameTagSelectionMode
Definition ImGuiMenu.h:312
MRVIEWER_API const Box3f & box() const
returns box which is used to calculate size and position of the visualized plane part
MRVIEWER_API void setLocalMode(bool on)
MRVIEWER_API bool importPlaneMode() const
returns the flag importPlaneMode_, if it is true you can use a plain object from the scene
only for bindings generation
Definition MRCameraOrientationPlugin.h:8
Definition MRViewerEventsListener.h:32