21#include <unordered_map>
35struct UiRenderManager;
36class SceneObjectsListDrawer;
37class ObjectComparableWithReference;
79 float userScaling_ = 1.0f;
82 ImGuiContext * context_ =
nullptr;
84 ImGuiWindow* prevFrameFocusPlugin_ =
nullptr;
87 bool pollEventsInPreDraw =
false;
89 bool showShortcuts_{
false };
90 bool showStatistics_{
false };
91 long long frameTimeMillisecThreshold_{ 25 };
92 bool showRenameModal_{
false };
95 bool needModalBgChange_{
false };
96 bool showInfoModal_{
false };
108 bool savedDialogPositionEnabled_{
false };
117 } coordType_{ CoordType::Local };
123 std::shared_ptr<ObjectLabel> obj{
nullptr };
126 bool allowRemoval_{
true };
127 bool uniformScale_{
true };
128 bool xfHistUpdated_{
false };
129 bool invertedRotation_{
false };
144 } viewportConfig_{ Single };
147 bool selectionChangedToSingleObj_{
false };
161 bool initHasFrontColor =
false;
162 bool hasFrontColor =
false;
168 bool showEditTag_ =
false;
173 MRVIEWER_API
static const std::shared_ptr<ImGuiMenu>&
instance();
185 MRVIEWER_API
virtual void load_font(
int font_size = 13);
212 const std::string& text,
214 bool clipByViewport );
242 MRVIEWER_API
void draw_scene_list_content(
const std::vector<std::shared_ptr<Object>>& selected,
const std::vector<std::shared_ptr<Object>>& all );
258 template<
typename ObjectT>
260 std::function<Vector4f(
const ObjectT* )> getter,
261 std::function<
void( ObjectT*,
const Vector4f& )> setter );
262 template<
typename ObjType,
typename ValueT>
263 void make_width( std::vector<std::shared_ptr<VisualObject>> selectedVisualObjs,
const char* label,
264 std::function<ValueT(
const ObjType* )> getter,
265 std::function<
void( ObjType*,
const ValueT& )> setter );
267 void make_light_strength( std::vector<std::shared_ptr<VisualObject>> selectedVisualObjs,
const char* label,
269 std::function<
void(
VisualObject*,
const float& )> setter);
271 template <
typename T,
typename ObjectType>
272 void make_slider( std::vector<std::shared_ptr<ObjectType>> selectedVisualObjs,
const char* label,
273 std::function<T(
const ObjectType* )> getter,
274 std::function<
void( ObjectType*, T )> setter, T min, T max );
282 MRVIEWER_API
void add_modifier( std::shared_ptr<MR::MeshModifier> modifier );
309 MRVIEWER_API
const std::shared_ptr<SceneObjectsListDrawer>&
getSceneObjectsList() {
return sceneObjectsList_; };
340 MRVIEWER_API
bool drawRemoveButton(
const std::vector<std::shared_ptr<Object>>& selectedObjs );
364 bool capturedMouse_{
false };
368 MRVIEWER_API
virtual bool onMouseMove_(
int mouse_x,
int mouse_y )
override;
372 MRVIEWER_API
virtual bool onCharPressed_(
unsigned key,
int modifiers )
override;
373 MRVIEWER_API
virtual bool onKeyDown_(
int key,
int modifiers )
override;
374 MRVIEWER_API
virtual bool onKeyUp_(
int key,
int modifiers )
override;
375 MRVIEWER_API
virtual bool onKeyRepeat_(
int key,
int modifiers )
override;
380 MRVIEWER_API
virtual bool spaceMouseMove_(
const Vector3f& translate,
const Vector3f& rotate )
override;
393 MRVIEWER_API
virtual void postFocus_(
bool focused )
override;
#define MR_MAKE_FLAG_OPERATORS(T)
Generates operators for a enum (at namespace scope).
Definition MRFlagOperators.h:6
Definition MRVisualObject.h:54
A base class for a data-model object that is a feature/measurement that can be compared between two m...
Definition MRObjectComparableWithReference.h:17
Definition MRObjectPointsHolder.h:24
named object in the data model
Definition MRObject.h:62
Definition MRViewerPlugin.h:30
GLFW-based mesh viewer.
Definition MRViewer.h:69
Definition MRViewportId.h:16
stores mask of viewport unique identifiers
Definition MRViewportId.h:42
Definition MRViewport.h:49
Visual Object.
Definition MRVisualObject.h:116
auto width(const Box< V > &box)
returns size along x axis
Definition MRBox.h:354
auto height(const Box< V > &box)
returns size along y axis
Definition MRBox.h:361
std::string storedModalMessage_
Definition ImGuiMenu.h:97
MRVIEWER_API void draw_helpers()
SelectedTypesMask
Definition ImGuiMenu.h:40
void make_slider(std::vector< std::shared_ptr< ObjectType > > selectedVisualObjs, const char *label, std::function< T(const ObjectType *)> getter, std::function< void(ObjectType *, T)> setter, T min, T max)
Color labelColor
property label color
Definition ImGuiMenu.h:350
MRVIEWER_API const std::shared_ptr< SceneObjectsListDrawer > & getSceneObjectsList()
Definition ImGuiMenu.h:309
virtual void draw_custom_window()
Can be overwritten by callback_draw_custom_window
Definition ImGuiMenu.h:199
MRVIEWER_API void drawTagInformation_(const std::vector< std::shared_ptr< Object > > &selected)
void draw_labels_window()
virtual MRVIEWER_API void draw_menu()
Draw menu.
void make_color_selector(std::vector< std::shared_ptr< ObjectT > > selectedVisualObjs, const char *label, std::function< Vector4f(const ObjectT *)> getter, std::function< void(ObjectT *, const Vector4f &)> setter)
virtual MRVIEWER_API bool onKeyDown_(int key, int modifiers) override
virtual MRVIEWER_API bool touchpadZoomGestureBegin_() override
boost::signals2::signal< bool(Object &object, NameTagSelectionMode mode), StopOnTrueCombiner > NameTagClickSignal
Definition ImGuiMenu.h:318
virtual MRVIEWER_API UiRenderManager & getUiRenderManager()
This class helps the viewer to renderUi() from IRenderObjects.
virtual MRVIEWER_API void setupShortcuts_()
MouseButton
Definition MRMouse.h:12
Color textColor
value text color
Definition ImGuiMenu.h:348
virtual MRVIEWER_API void postResize_(int width, int height) override
Scene events.
virtual MRVIEWER_API bool touchpadSwipeGestureBegin_() override
ImVec2 sceneWindowSize_
Definition ImGuiMenu.h:102
MRVIEWER_API void draw_scene_list_content(const std::vector< std::shared_ptr< Object > > &selected, const std::vector< std::shared_ptr< Object > > &all)
Draw scene list content only.
virtual MRVIEWER_API void drawShortcutsWindow_()
A virtual function for drawing of the dialog with shortcuts. It can be overriden in the inherited cla...
MRVIEWER_API BasicUiRenderTask::BackwardPassParams beginBackwardPass(ViewportId viewport, UiRenderParams::UiTaskList &tasks) override
float getUserScaling() const
returns UI scaling modifier specified by user
Definition ImGuiMenu.h:223
MRVIEWER_API bool drawAdvancedOptions(const std::vector< std::shared_ptr< VisualObject > > &selectedObjs, SelectedTypesMask selectedMask)
virtual MRVIEWER_API bool onMouseScroll_(float delta_y) override
virtual MRVIEWER_API void showModalMessage(const std::string &msg, NotificationType msgType)
opens Error / Warning / Info modal window with message text
CoordType
Definition ImGuiMenu.h:114
void make_width(std::vector< std::shared_ptr< VisualObject > > selectedVisualObjs, const char *label, std::function< ValueT(const ObjType *)> getter, std::function< void(ObjType *, const ValueT &)> setter)
bool make_visualize_checkbox(std::vector< std::shared_ptr< VisualObject > > selectedVisualObjs, const char *label, AnyVisualizeMaskEnum type, MR::ViewportMask viewportid, bool invert=false)
ViewportConfigurations
Definition ImGuiMenu.h:139
MRVIEWER_API float drawTransform_()
virtual MRVIEWER_API void initBackend()
inits glfw and glsl backend
void make_points_discretization(std::vector< std::shared_ptr< VisualObject > > selectedVisualObjs, const char *label, std::function< int(const ObjectPointsHolder *)> getter, std::function< void(ObjectPointsHolder *, const int &)> setter)
virtual MRVIEWER_API bool touchpadSwipeGestureUpdate_(float deltaX, float deltaY, bool kinetic) override
ImVec2 mainWindowSize_
Definition ImGuiMenu.h:104
bool isSavedDialogPositionsEnabled() const
returns true if enabled using of saved positions of plugin windows in the config file,...
Definition ImGuiMenu.h:304
virtual MRVIEWER_API bool onKeyRepeat_(int key, int modifiers) override
NotificationType
Definition MRNotificationType.h:10
virtual MRVIEWER_API bool spaceMouseDown_(int key) override
MRVIEWER_API void postRenderViewport(ViewportId viewport) override
This is called after doing IRenderObject::renderUi() on even object in a viewport....
virtual MRVIEWER_API void load_font(int font_size=13)
std::optional< std::pair< std::string, Vector4f > > storedColor_
Definition ImGuiMenu.h:131
MRVIEWER_API void allowSceneReorder(bool allow)
std::string popUpRenameBuffer_
Definition ImGuiMenu.h:94
virtual MRVIEWER_API bool onMouseUp_(MouseButton button, int modifier) override
void make_light_strength(std::vector< std::shared_ptr< VisualObject > > selectedVisualObjs, const char *label, std::function< float(const VisualObject *)> getter, std::function< void(VisualObject *, const float &)> setter)
std::function< void(void)> callback_draw_viewer_window
Easy-to-customize callbacks.
Definition ImGuiMenu.h:202
std::string searchPluginsString_
Definition ImGuiMenu.h:134
virtual MRVIEWER_API bool drawCollapsingHeaderTransform_()
override this to customize appearance of collapsing headers for transform block
ImVec2 sceneWindowPos_
Definition ImGuiMenu.h:101
MRVIEWER_API bool canConsumeEvent(BasicUiRenderTask::InteractionMask event) const
MRVIEWER_API void draw_scene_list()
Draw scene list window with content.
Box3f selectionLocalBox_
Definition ImGuiMenu.h:111
MRVIEWER_API bool drawGeneralOptions(const std::vector< std::shared_ptr< Object > > &selectedObjs)
virtual MRVIEWER_API void postFocus_(bool focused) override
Other events.
float hidpi_scaling_
Hidpi scaling to be used for text rendering.
Definition ImGuiMenu.h:72
std::function< void(void)> callback_draw_viewer_menu
Definition ImGuiMenu.h:203
virtual MRVIEWER_API bool onMouseDown_(MouseButton button, int modifier) override
Mouse IO.
ImVec4 selectedColor
Definition ImGuiMenu.h:163
virtual MRVIEWER_API void drawCustomSelectionInformation_(const std::vector< std::shared_ptr< Object > > &selected, const SelectionInformationStyle &style)
draw additional selection information (e.g. for custom objects)
MRVIEWER_API void add_modifier(std::shared_ptr< MR::MeshModifier > modifier)
std::shared_ptr< ShortcutManager > getShortcutManager()
Definition ImGuiMenu.h:280
std::string tagNewName_
buffer string for the tag name input widget
Definition ImGuiMenu.h:170
MRVIEWER_API void drawFeaturePropertiesEditor_(const std::shared_ptr< Object > &object)
MRVIEWER_API void tryRenameSelectedObject()
virtual MRVIEWER_API void cursorEntrance_(bool entered) override
MRVIEWER_API float pixel_ratio()
MRVIEWER_API float getSceneInfoItemWidth_(int itemCount=1)
returns width of items in Scene Info window
virtual MRVIEWER_API void drawModalMessage_()
AffineXf3f editedFeatureObjectOldXf_
When editing feature properties, this is the original xf of the target object, for history purposes.
Definition ImGuiMenu.h:154
MRVIEWER_API float menu_scaling() const
virtual MRVIEWER_API bool touchpadZoomGestureUpdate_(float scale, bool kinetic) override
MRVIEWER_API void setDrawTimeMillisecThreshold(long long maxGoodTimeMillisec)
setup maximum good time for frame rendering (if rendering is slower it will become red in statistics ...
MRVIEWER_API void finishBackwardPass(ViewportId viewport, const BasicUiRenderTask::BackwardPassParams ¶ms) override
After the backward pass is performed, the parameters should be passed back into this function.
virtual MRVIEWER_API bool onMouseMove_(int mouse_x, int mouse_y) override
MRVIEWER_API bool getShowShortcuts() const
return show shortcuts state (enable / disable)
MRVIEWER_API void preRenderViewport(ViewportId viewport) override
This is called before doing IRenderObject::renderUi() on even object in a viewport....
virtual MRVIEWER_API bool onKeyUp_(int key, int modifiers) override
Color selectedTextColor
selected value text color
Definition ImGuiMenu.h:352
MRVIEWER_API void setObjectTreeState(const Object *obj, bool open)
virtual MRVIEWER_API void rescaleStyle_()
virtual MRVIEWER_API bool touchpadZoomGestureEnd_() override
virtual MRVIEWER_API bool onCharPressed_(unsigned key, int modifiers) override
Keyboard IO.
MRVIEWER_API void allowObjectsRemoval(bool allow)
std::shared_ptr< SceneObjectsListDrawer > sceneObjectsList_
Definition ImGuiMenu.h:437
virtual MRVIEWER_API void draw_custom_selection_properties(const std::vector< std::shared_ptr< Object > > &selected)
std::vector< std::shared_ptr< BasicUiRenderTask > > UiTaskList
Definition MRIRenderObject.h:111
MRVIEWER_API bool drawRemoveButton(const std::vector< std::shared_ptr< Object > > &selectedObjs)
float pixel_ratio_
Definition ImGuiMenu.h:76
MRVIEWER_API void setShowShortcuts(bool val)
set show shortcuts state (enable / disable)
std::vector< std::shared_ptr< MR::MeshModifier > > modifiers_
Definition ImGuiMenu.h:136
MRVIEWER_API void draw_text(const Viewport &viewport, const Vector3f &pos, const Vector3f &normal, const std::string &text, const Color &color, bool clipByViewport)
bool checkPossibilityObjectRemoval()
Definition ImGuiMenu.h:285
MRVIEWER_API void expandObjectTreeAndScroll(const Object *obj)
expands all objs parents in tree and scroll scene tree window so selection becomes visible
virtual MRVIEWER_API void startFrame()
call this to validate imgui context in the begining of the frame
static MRVIEWER_API const std::shared_ptr< ImGuiMenu > & instance()
boost::signals2::signal< void(ViewportId viewportId, UiRenderParams::UiTaskList &tasks)> DrawSceneUiSignal
Definition ImGuiMenu.h:326
Vector4f getStoredColor_(const std::string &str, const Color &defaultColor) const
MRVIEWER_API bool simulateNameTagClick(Object &object, NameTagSelectionMode mode)
Behaves as if the user clicked the object name tag, by invoking nameTagClickSignal.
std::weak_ptr< Object > editedFeatureObject_
When editing feature properties, this is the target object.
Definition ImGuiMenu.h:152
virtual MRVIEWER_API void reload_font(int font_size=13)
MRVIEWER_API float drawSelectionInformation_()
MRVIEWER_API bool drawDrawOptionsCheckboxes(const std::vector< std::shared_ptr< VisualObject > > &selectedObjs, SelectedTypesMask selectedMask)
std::string labelBuffer
Definition ImGuiMenu.h:122
MRVIEWER_API void reserveKeyEvent(ImGuiKey key)
call if you want ImGui to take event if this key is pressed (to prevent scene reaction on key press)
MRVIEWER_API SelectedTypesMask calcSelectedTypesMask(const std::vector< std::shared_ptr< Object > > &selectedObjs)
void enableSavedDialogPositions(bool on)
enables using of saved positions of plugin windows in the config file
Definition ImGuiMenu.h:302
MRVIEWER_API bool simulateNameTagClickWithKeyboardModifiers(Object &object)
This version uses the currently held keyboard modifiers instead of a custom mode.
ImGuiWindow * getLastFocusedPlugin() const
Definition ImGuiMenu.h:229
virtual MRVIEWER_API bool touchpadRotateGestureEnd_() override
InteractionMask
Definition MRIRenderObject.h:77
MRVIEWER_API bool anyImGuiWindowIsHovered() const
Scene pick should be disabled because an ImGui window is in the way.
std::string initName
Definition ImGuiMenu.h:159
MRVIEWER_API float hidpi_scaling()
virtual MRVIEWER_API bool drawTransformContextMenu_(const std::shared_ptr< Object > &)
Definition ImGuiMenu.h:413
std::unique_ptr< UiRenderManagerImpl > uiRenderManager_
This class helps the viewer to renderUi() from IRenderObjects.
Definition ImGuiMenu.h:436
std::string name
Definition ImGuiMenu.h:160
Box3f selectionWorldBox_
updated in drawSelectionInformation_
Definition ImGuiMenu.h:112
virtual MRVIEWER_API std::filesystem::path getMenuFontPath() const
virtual MRVIEWER_API void finishFrame()
call this to draw valid imgui context at the end of the frame
NameTagSelectionMode
Definition ImGuiMenu.h:312
virtual MRVIEWER_API void init(MR::Viewer *_viewer) override
This function is called when the viewer is initialized (no mesh will be loaded at this stage)
ImVec2 mainWindowPos_
Definition ImGuiMenu.h:103
virtual MRVIEWER_API bool spaceMouseMove_(const Vector3f &translate, const Vector3f &rotate) override
Spacemouse events.
MRVIEWER_API bool anyUiObjectIsHovered() const
Scene pick should be disabled because a renderUi() UI of some object is in the way.
virtual MRVIEWER_API bool touchpadRotateGestureUpdate_(float angle) override
NameTagClickSignal nameTagClickSignal
This is triggered whenever a name tag of an object is clicked.
Definition ImGuiMenu.h:320
virtual MRVIEWER_API bool drawCollapsingHeader_(const char *label, ImGuiTreeNodeFlags flags=0)
override this to have custom UI in "Selection Properties" window (under "Draw Options")
virtual MRVIEWER_API void draw_selection_properties(const std::vector< std::shared_ptr< Object > > &selected)
std::string lastLabel
Definition ImGuiMenu.h:121
virtual MRVIEWER_API bool touchpadRotateGestureBegin_() override
Touchpad gesture events.
MRVIEWER_API void setUserScaling(float scaling)
sets UI scaling modifier specified by user
MRVIEWER_API bool drawDrawOptionsColors(const std::vector< std::shared_ptr< VisualObject > > &selectedObjs)
MRVIEWER_API ImGuiContext * getCurrentContext() const
DrawSceneUiSignal drawSceneUiSignal
This is called every frame for every viewport. Use this to draw UI bits on top of the scene.
Definition ImGuiMenu.h:328
std::weak_ptr< Object > lastRenameObj_
Definition ImGuiMenu.h:110
virtual MRVIEWER_API void shutdown() override
This function is called before shutdown.
std::string renameBuffer_
Definition ImGuiMenu.h:93
std::shared_ptr< ShortcutManager > shortcutManager_
Definition ImGuiMenu.h:99
virtual MRVIEWER_API void draw_selection_properties_content(const std::vector< std::shared_ptr< Object > > &selected)
std::function< void(void)> callback_draw_custom_window
Definition ImGuiMenu.h:204
MRVIEWER_API void drawComparablePropertiesEditor_(ObjectComparableWithReference &object)
ImVec4 unselectedColor
Definition ImGuiMenu.h:164
TagEditorState tagEditorState_
Definition ImGuiMenu.h:166
virtual MRVIEWER_API void draw_viewer_window()
Can be overwritten by callback_draw_viewer_window
virtual MRVIEWER_API bool touchpadSwipeGestureEnd_() override
virtual MRVIEWER_API void postRescale_(float x, float y) override
@ angle
Direction, normally Vector3f.
@ Single
Definition ImGuiMenu.h:140
@ Vertical
left viewport, right viewport
Definition ImGuiMenu.h:142
@ Horizontal
Definition ImGuiMenu.h:141
only for bindings generation
Definition MRCameraOrientationPlugin.h:8
Definition MRIRenderObject.h:84
Definition MRViewerEventsListener.h:126
class to subscribe on CursorEntranceSingal
Definition MRViewerEventsListener.h:410
Definition MRViewerEventsListener.h:144
Definition MRViewerEventsListener.h:153
Definition MRViewerEventsListener.h:135
Definition MRViewerEventsListener.h:54
Definition MRViewerEventsListener.h:72
Definition MRViewerEventsListener.h:63
Definition MRViewerEventsListener.h:32
class to subscribe on PostFocusSingal
Definition MRViewerEventsListener.h:400
Definition MRViewerEventsListener.h:243
Definition MRViewerEventsListener.h:225
class to subscribe on SpaceMouseDownSgnal
Definition MRViewerEventsListener.h:290
class to subscribe on SpaceMouseMoveSignal
Definition MRViewerEventsListener.h:280
Pass this as a second template argument to boost::signals2::signal<...> to stop the execution of hand...
Definition MRSignalCombiners.h:11
class to subscribe on TouchpadRotateGestureBeginEvent
Definition MRViewerEventsListener.h:310
class to subscribe on TouchpadRotateGestureEndEvent
Definition MRViewerEventsListener.h:330
class to subscribe on TouchpadRotateGestureUpdateEvent
Definition MRViewerEventsListener.h:320
class to subscribe on TouchpadSwipeGestureBeginEvent
Definition MRViewerEventsListener.h:340
class to subscribe on TouchpadSwipeGestureEndEvent
Definition MRViewerEventsListener.h:360
class to subscribe on TouchpadSwipeGestureUpdateEvent
Definition MRViewerEventsListener.h:350
class to subscribe on TouchpadZoomGestureBeginEvent
Definition MRViewerEventsListener.h:370
class to subscribe on TouchpadZoomGestureEndEvent
Definition MRViewerEventsListener.h:390
class to subscribe on TouchpadZoomGestureUpdateEvent
Definition MRViewerEventsListener.h:380
Definition MRIRenderObject.h:118