MeshLib C++ Docs
Loading...
Searching...
No Matches
MRViewer.h
Go to the documentation of this file.
1#pragma once
2
3#include "MRViewerInstance.h"
4#include "MRMouse.h"
5#include "MRSignalCombiners.h"
6#include "MRMakeSlot.h"
7#include <MRMesh/MRVector2.h>
9#include "MRMesh/MRSignal.h"
11#include <cstdint>
12#include <filesystem>
13
14struct GLFWwindow;
15
17#define ENQUEUE_VIEWER_METHOD( NAME, METHOD ) MR::getViewerInstance().emplaceEvent( NAME, [] { \
18 MR::getViewerInstance() . METHOD (); \
19} )
20#define ENQUEUE_VIEWER_METHOD_ARGS( NAME, METHOD, ... ) MR::getViewerInstance().emplaceEvent( NAME, [__VA_ARGS__] { \
21 MR::getViewerInstance() . METHOD ( __VA_ARGS__ ); \
22} )
23#define ENQUEUE_VIEWER_METHOD_ARGS_SKIPABLE( NAME, METHOD, ... ) MR::getViewerInstance().emplaceEvent( NAME, [__VA_ARGS__] { \
24 MR::getViewerInstance() . METHOD ( __VA_ARGS__ ); \
25}, true )
26
27namespace MR
28{
29
30class ViewerTitle;
31
32class SpaceMouseHandler;
33
34class IDragDropHandler;
35
36class CornerControllerObject;
37// This struct contains rules for viewer launch
39{
40 bool fullscreen{ false }; // if true starts fullscreen
41 int width{ 0 };
42 int height{ 0 };
44 {
45 Show, // Show window immediately
46 HideInit, // Show window after init
47 Hide, // Don't show window
48 TryHidden, // Launches in "Hide" mode if OpenGL is present and "NoWindow" if it is not
49 NoWindow // Don't initialize GL window (don't call GL functions)(force `isAnimating`)
50 } windowMode{ HideInit };
52 bool preferOpenGL3{ false };
53 bool render3dSceneInTexture{ true }; // If not set renders scene each frame
54 bool developerFeatures{ false }; // If set shows some developer features useful for debugging
55 std::string name{ "MRViewer" }; // Window name
56 bool startEventLoop{ true }; // If false - does not start event loop
57 bool close{ true }; // If !startEventLoop close immediately after start, otherwise close on window close, make sure you call `launchShut` manually if this flag is false
58 bool console{ false }; // If true - shows developers console
59 int argc{ 0 }; // Pass argc
60 char** argv{ nullptr }; // Pass argv
61
62 bool showMRVersionInTitle{ false }; // if true - print version info in window title
63 bool isAnimating{ false }; // if true - calls render without system events
64 int animationMaxFps{ 30 }; // max fps if animating
65 bool unloadPluginsAtEnd{ false }; // unload all extended libraries right before program exit
66
67 std::shared_ptr<SplashWindow> splashWindow; // if present will show this window while initializing plugins (after menu initialization)
68};
69
70using FilesLoadedCallback = std::function<void(const std::vector<std::shared_ptr<Object>>& objs,const std::string& errors, const std::string& warnings)>;
71
73{
75 const char * undoPrefix = "Open ";
76
78 bool forceReplaceScene = false;
79
83};
84
85// GLFW-based mesh viewer
86class MRVIEWER_CLASS Viewer
87{
88public:
91
93
94 // Accumulate launch params from cmd args
95 MRVIEWER_API static void parseLaunchParams( LaunchParams& params );
96
97 // Launch viewer with given params
98 MRVIEWER_API int launch( const LaunchParams& params );
99 // Starts event loop
100 MRVIEWER_API void launchEventLoop();
101 // Terminate window
102 MRVIEWER_API void launchShut();
103
104 bool isLaunched() const { return isLaunched_; }
105
106 // get full parameters with witch viewer was launched
107 const LaunchParams& getLaunchParams() const { return launchParams_; }
108
109 // provides non const access to viewer
110 static Viewer* instance() { return &getViewerInstance(); }
111 static Viewer& instanceRef() { return getViewerInstance(); }
112 // provide const access to viewer
113 static const Viewer* constInstance() { return &getViewerInstance(); }
114 static const Viewer& constInstanceRef() { return getViewerInstance(); }
115
116 template<typename PluginType>
117 PluginType* getPluginInstance()
118 {
119 for ( auto& plugin : plugins )
120 {
121 auto p = dynamic_cast< PluginType* >( plugin );
122 if ( p )
123 {
124 return p;
125 }
126 }
127 return nullptr;
128 }
129
130 // Mesh IO
131 // Check the supported file format
132 MRVIEWER_API bool isSupportedFormat( const std::filesystem::path& file_name );
133
134 // Load objects / scenes from files
135 // Note! load files with progress bar in next frame if it possible, otherwise load directly inside this function
136 MRVIEWER_API bool loadFiles( const std::vector< std::filesystem::path>& filesList, const FileLoadOptions & options = {} );
137
138 // Save first selected objects to file
139 MRVIEWER_API bool saveToFile( const std::filesystem::path & mesh_file_name );
140
141 // Callbacks
142 MRVIEWER_API bool keyPressed( unsigned int unicode_key, int modifier );
143 MRVIEWER_API bool keyDown( int key, int modifier );
144 MRVIEWER_API bool keyUp( int key, int modifier );
145 MRVIEWER_API bool keyRepeat( int key, int modifier );
146 MRVIEWER_API bool mouseDown( MouseButton button, int modifier );
147 MRVIEWER_API bool mouseUp( MouseButton button, int modifier );
148 MRVIEWER_API bool mouseMove( int mouse_x, int mouse_y );
149 MRVIEWER_API bool mouseScroll( float delta_y );
150 MRVIEWER_API bool mouseClick( MouseButton button, int modifier );
151 MRVIEWER_API bool dragStart( MouseButton button, int modifier );
152 MRVIEWER_API bool dragEnd( MouseButton button, int modifier );
153 MRVIEWER_API bool drag( int mouse_x, int mouse_y );
154 MRVIEWER_API bool spaceMouseMove( const Vector3f& translate, const Vector3f& rotate );
155 MRVIEWER_API bool spaceMouseDown( int key );
156 MRVIEWER_API bool spaceMouseUp( int key );
157 MRVIEWER_API bool spaceMouseRepeat( int key );
158 MRVIEWER_API bool dragDrop( const std::vector<std::filesystem::path>& paths );
159 // Touch callbacks (now used in EMSCRIPTEN build only)
160 MRVIEWER_API bool touchStart( int id, int x, int y );
161 MRVIEWER_API bool touchMove( int id, int x, int y );
162 MRVIEWER_API bool touchEnd( int id, int x, int y );
163 // Touchpad gesture callbacks
164 MRVIEWER_API bool touchpadRotateGestureBegin();
165 MRVIEWER_API bool touchpadRotateGestureUpdate( float angle );
166 MRVIEWER_API bool touchpadRotateGestureEnd();
167 MRVIEWER_API bool touchpadSwipeGestureBegin();
168 MRVIEWER_API bool touchpadSwipeGestureUpdate( float dx, float dy, bool kinetic );
169 MRVIEWER_API bool touchpadSwipeGestureEnd();
170 MRVIEWER_API bool touchpadZoomGestureBegin();
171 MRVIEWER_API bool touchpadZoomGestureUpdate( float scale, bool kinetic );
172 MRVIEWER_API bool touchpadZoomGestureEnd();
173 // This function is called when window should close, if return value is true, window will stay open
174 MRVIEWER_API bool interruptWindowClose();
175
176 // Draw everything
177 MRVIEWER_API void draw( bool force = false );
178 // Draw 3d scene with UI
179 MRVIEWER_API void drawFull( bool dirtyScene );
180 // Draw 3d scene without UI
181 MRVIEWER_API void drawScene();
182 // Call this function to force redraw scene into scene texture
183 void setSceneDirty() { dirtyScene_ = true; }
184 // Setup viewports views
185 MRVIEWER_API void setupScene();
186 // Cleans framebuffers for all viewports (sets its background)
187 MRVIEWER_API void clearFramebuffers();
188 // OpenGL context resize
189 MRVIEWER_API void resize( int w, int h ); // explicitly set framebuffer size
190 MRVIEWER_API void postResize( int w, int h ); // external resize due to user interaction
191 MRVIEWER_API void postSetPosition( int xPos, int yPos ); // external set position due to user interaction
192 MRVIEWER_API void postSetMaximized( bool maximized ); // external set maximized due to user interaction
193 MRVIEWER_API void postSetIconified( bool iconified ); // external set iconified due to user interaction
194 MRVIEWER_API void postFocus( bool focused ); // external focus handler due to user interaction
195 MRVIEWER_API void postRescale( float x, float y ); // external rescale due to user interaction
196 MRVIEWER_API void postClose(); // called when close signal received
197
199 // Multi-mesh methods //
201
202 // reset objectRoot with newRoot, append all RenderObjects and basis objects
203 MRVIEWER_API void set_root( SceneRootObject& newRoot );
204
205 // removes all objects from scene
206 MRVIEWER_API void clearScene();
207
209 // Multi-viewport methods //
211
212 // Return the current viewport, or the viewport corresponding to a given unique identifier
213 //
214 // Inputs:
215 // viewportId unique identifier corresponding to the desired viewport (current viewport if 0)
216 MRVIEWER_API Viewport& viewport( ViewportId viewportId = {} );
217 MRVIEWER_API const Viewport& viewport( ViewportId viewportId = {} ) const;
218
219 // Append a new "slot" for a viewport (i.e., copy properties of the current viewport, only
220 // changing the viewport size/position)
221 //
222 // Inputs:
223 // viewport Vector specifying the viewport origin and size in screen coordinates.
224 // append_empty If true, existing meshes are hidden on the new viewport.
225 //
226 // Returns the unique id of the newly inserted viewport. There can be a maximum of 31
227 // viewports created in the same viewport. Erasing a viewport does not change the id of
228 // other existing viewports
229 MRVIEWER_API ViewportId append_viewport( const ViewportRectangle & viewportRect, bool append_empty = false );
230
231 // Calculates and returns viewports bounds in gl space:
232 // (0,0) - lower left angle
233 MRVIEWER_API Box2f getViewportsBounds() const;
234
235 // Erase a viewport
236 //
237 // Inputs:
238 // index index of the viewport to erase
239 MRVIEWER_API bool erase_viewport( const size_t index );
240 MRVIEWER_API bool erase_viewport( ViewportId viewport_id );
241
242 // Retrieve viewport index from its unique identifier
243 // Returns -1 if not found
244 MRVIEWER_API int viewport_index( ViewportId viewport_id ) const;
245
246 // Get unique id of the vieport containing the mouse
247 // if mouse is out of any viewport returns index of last selected viewport
248 // (current_mouse_x, current_mouse_y)
249 MRVIEWER_API ViewportId getHoveredViewportId() const;
250
251 // Change selected_core_index to the viewport containing the mouse
252 // (current_mouse_x, current_mouse_y)
253 MRVIEWER_API void select_hovered_viewport();
254
255 // Calls fitData for single/each viewport in viewer
256 // fill = 0.6 parameter means that scene will 0.6 of screen,
257 // snapView - to snap camera angle to closest canonical quaternion
258 MRVIEWER_API void fitDataViewport( MR::ViewportMask vpList = MR::ViewportMask::all(), float fill = 0.6f, bool snapView = true );
259
260 // Calls fitBox for single/each viewport in viewer
261 // fill = 0.6 parameter means that scene will 0.6 of screen,
262 // snapView - to snap camera angle to closest canonical quaternion
263 MRVIEWER_API void fitBoxViewport( const Box3f& box, MR::ViewportMask vpList = MR::ViewportMask::all(), float fill = 0.6f, bool snapView = true );
264
265 // Calls fitData and change FOV to match the screen size then
266 // params - params fit data
268 MRVIEWER_API void preciseFitDataViewport( MR::ViewportMask vpList, const FitDataParams& param );
269
270 MRVIEWER_API size_t getTotalFrames() const;
271 MRVIEWER_API size_t getSwappedFrames() const;
272 MRVIEWER_API size_t getFPS() const;
273 MRVIEWER_API double getPrevFrameDrawTimeMillisec() const;
274
275 // Returns memory amount used by shared GL memory buffer
276 MRVIEWER_API size_t getStaticGLBufferSize() const;
277
278 // if true only last frame of force redraw after events will be swapped, otherwise each will be swapped
279 bool swapOnLastPostEventsRedraw{ true };
280 // minimum auto increment force redraw frames after events
281 int forceRedrawMinimumIncrementAfterEvents{ 4 };
282
283 // Increment number of forced frames to redraw in event loop
284 // if `swapOnLastOnly` only last forced frame will be present on screen and all previous will not
285 MRVIEWER_API void incrementForceRedrawFrames( int i = 1, bool swapOnLastOnly = false );
286
287 // Returns true if current frame will be shown on display
288 MRVIEWER_API bool isCurrentFrameSwapping() const;
289
290 // types of counted events
291 enum class EventType
292 {
293 MouseDown,
294 MouseUp,
295 MouseMove,
296 MouseScroll,
297 KeyDown,
298 KeyUp,
299 KeyRepeat,
300 CharPressed,
301 Count
302 };
303 // Returns number of events of given type
304 MRVIEWER_API size_t getEventsCount( EventType type )const;
305
306 // types of gl primitives counters
308 {
309 // arrays and elements are different gl calls
310 PointArraySize,
311 LineArraySize,
312 TriangleArraySize,
313 PointElementsNum,
314 LineElementsNum,
315 TriangleElementsNum,
316 Count
317 };
318 // Returns number of events of given type
319 MRVIEWER_API size_t getLastFrameGLPrimitivesCount( GLPrimitivesType type ) const;
320 // Increment number of gl primitives drawed in this frame
321 MRVIEWER_API void incrementThisFrameGLPrimitivesCount( GLPrimitivesType type, size_t num );
322
323
324 // Returns mask of present viewports
325 ViewportMask getPresentViewports() const { return presentViewportsMask_; }
326
327 // Restes frames counter and events counter
328 MRVIEWER_API void resetAllCounters();
329
334 MRVIEWER_API Image captureSceneScreenShot( const Vector2i& resolution = Vector2i() );
335
342 MRVIEWER_API void captureUIScreenShot( std::function<void( const Image& )> callback,
343 const Vector2i& pos = Vector2i(), const Vector2i& size = Vector2i() );
344
345 // Returns true if can enable alpha sort
346 MRVIEWER_API bool isAlphaSortAvailable() const;
347 // Tries to enable alpha sort,
348 // returns true if value was changed, return false otherwise
349 MRVIEWER_API bool enableAlphaSort( bool on );
350 // Returns true if alpha sort is enabled, false otherwise
351 bool isAlphaSortEnabled() const { return alphaSortEnabled_; }
352
353 // Returns if scene texture is now bound
354 MRVIEWER_API bool isSceneTextureBound() const;
355 // Binds or unbinds scene texture (should be called only with valid window)
356 // note that it does not clear framebuffer
357 MRVIEWER_API void bindSceneTexture( bool bind );
358 // Returns true if 3d scene is rendering in scene texture instead of main framebuffer
359 MRVIEWER_API bool isSceneTextureEnabled() const;
360
361 // Returns actual msaa level of:
362 // scene texture if it is present, or main framebuffer
363 MRVIEWER_API int getMSAA() const;
364 // Requests changing MSAA level
365 // if scene texture is using, request should be executed in the beginig of next frame
366 // otherwise restart of the app is required to apply change to main framebuffer
367 MRVIEWER_API void requestChangeMSAA( int newMSAA );
368 // Returns MSAA level that have been requested (might be different from actual MSAA using, because of GPU limitations or need to restart app)
369 MRVIEWER_API int getRequestedMSAA() const;
370
371 // Sets manager of viewer settings which loads user personal settings on beginning of app
372 // and saves it in app's ending
373 MRVIEWER_API void setViewportSettingsManager( std::unique_ptr<IViewerSettingsManager> mng );
374 MRVIEWER_API const std::unique_ptr<IViewerSettingsManager>& getViewerSettingsManager() const { return settingsMng_; }
375
377 // Finds point in all spaces from screen space pixel point
378 MRVIEWER_API PointInAllSpaces getPixelPointInfo( const Vector3f& screenPoint ) const;
379 // Finds point under mouse in all spaces and under mouse viewport id
381
382 // Converts screen space coordinate to viewport space coordinate
383 // (0,0) if viewport does not exist
384 // screen space: X [0,framebufferSize.x], Y [0,framebufferSize.y] - (0,0) is upper left of window
385 // viewport space: X [0,viewport_width], Y [0,viewport_height] - (0,0) is upper left of viewport
386 // Z [0,1] - 0 is Dnear, 1 is Dfar
387 MRVIEWER_API Vector3f screenToViewport( const Vector3f& screenPoint, ViewportId id ) const;
388 // Converts viewport space coordinate to screen space coordinate
389 // (0,0) if viewport does not exist
390 // screen space: X [0,framebufferSize.x], Y [0,framebufferSize.y] - (0,0) is upper left of window
391 // viewport space: X [0,viewport_width], Y [0,viewport_height] - (0,0) is upper left of viewport
392 // Z [0,1] - 0 is Dnear, 1 is Dfar
393 MRVIEWER_API Vector3f viewportToScreen( const Vector3f& viewportPoint, ViewportId id ) const;
394
395 // Returns viewports satisfying given mask
396 MRVIEWER_API std::vector<std::reference_wrapper<Viewport>> getViewports( ViewportMask mask = ViewportMask::any() );
397
398 // Enables or disables global history (clears it on disable)
399 MRVIEWER_API void enableGlobalHistory( bool on );
400 // Return true if global history is enabled, false otherwise
401 bool isGlobalHistoryEnabled() const { return bool( globalHistoryStore_ ); };
402 // Appends history action to current stack position (clearing redo)
403 // if global history is disabled do nothing
404 MRVIEWER_API void appendHistoryAction( const std::shared_ptr<HistoryAction>& action );
405 // Applies undo if global history is enabled
406 // return true if undo was applied
407 MRVIEWER_API bool globalHistoryUndo();
408 // Applies redo if global history is enabled
409 // return true if redo was applied
410 MRVIEWER_API bool globalHistoryRedo();
411 // Returns global history store
412 const std::shared_ptr<HistoryStore>& getGlobalHistoryStore() const { return globalHistoryStore_; }
413 // Return spacemouse handler
414 const std::shared_ptr<SpaceMouseHandler>& getSpaceMouseHandler() const { return spaceMouseHandler_; }
415
416 // This method is called after successful scene saving to update scene root, window title and undo
417 MRVIEWER_API void onSceneSaved( const std::filesystem::path& savePath, bool storeInRecent = true );
418
419 // Get/Set menu plugin (which is separated from other plugins to be inited first before splash window starts)
420 MRVIEWER_API const std::shared_ptr<ImGuiMenu>& getMenuPlugin() const;
421 MRVIEWER_API void setMenuPlugin( std::shared_ptr<ImGuiMenu> menu );
422
423 // get menu plugin casted in RibbonMenu
424 MRVIEWER_API std::shared_ptr<RibbonMenu> getRibbonMenu() const;
425
426 // Get the menu plugin casted in given type
427 template <typename T>
428 std::shared_ptr<T> getMenuPluginAs() const { return std::dynamic_pointer_cast<T>( getMenuPlugin() ); }
429
430 // sets stop event loop flag (this flag is glfwShouldWindowClose equivalent)
431 MRVIEWER_API void stopEventLoop();
432 // get stop event loop flag (this flag is glfwShouldWindowClose equivalent)
433 bool getStopEventLoopFlag() const { return stopEventLoop_; }
434
435 // return true if window should close
436 // calls interrupt signal and if no slot interrupts return true, otherwise return false
438
439 // returns true if viewer has valid GL context
440 // note that sometimes it is not enough, for example to free GL memory in destructor,
441 // glInitialized_ can be already reset and it requires `loadGL()` check too
442 bool isGLInitialized() const { return glInitialized_; }
443
444 // update the title of the main window and, if any scene was opened, show its filename
445 MRVIEWER_API void makeTitleFromSceneRootPath();
446
447 // returns true if the system framebuffer is scaled (valid for macOS and Wayland)
448 bool hasScaledFramebuffer() const { return hasScaledFramebuffer_; }
449
450public:
452 // Member variables //
454 GLFWwindow* window;
455
456 // A function to reset setting to initial state
457 // Overrides should call previous function
458 std::function<void( Viewer* viewer )> resetSettingsFunction;
459
460 // Stores all the viewing options
461 std::vector<Viewport> viewport_list;
463
464 // List of registered plugins
465 std::vector<ViewerPlugin*> plugins;
466
467 float pixelRatio{ 1.0f };
469 Vector2i windowSavePos; // pos to save
470 Vector2i windowSaveSize; // size to save
471 Vector2i windowOldPos;
472 bool windowMaximized{ false };
473
474 // if true - calls render without system events
475 bool isAnimating{ false };
476 // max fps if animating
477 int animationMaxFps{ 30 };
478 // this parameter can force up/down mouse scroll
479 // useful for WebAssembler version because it has too powerful scroll
480 float scrollForce{ }; // init in resetSettingsFunction()
481 // opengl-based pick window radius in pixels
482 uint16_t glPickRadius{ }; // init in resetSettingsFunction()
483 // Experimental/developer features enabled
484 bool experimentalFeatures{ };
485 // command arguments, each parsed arg should be erased from here not to affect other parsers
486 std::vector<std::string> commandArgs;
487
488 std::shared_ptr<ObjectMesh> basisAxes;
489 std::unique_ptr<CornerControllerObject> basisViewController;
490 std::shared_ptr<ObjectMesh> globalBasisAxes;
491 std::shared_ptr<ObjectMesh> rotationSphere;
492 // Stores clipping plane mesh
493 std::shared_ptr<ObjectMesh> clippingPlaneObject;
494
495 // class that updates viewer title
496 std::shared_ptr<ViewerTitle> windowTitle;
497
498 //*********
499 // SIGNALS
500 //*********
502 // Mouse events
503 using MouseUpDownSignal = boost::signals2::signal<bool( MouseButton btn, int modifier ), SignalStopHandler>;
504 using MouseMoveSignal = boost::signals2::signal<bool( int x, int y ), SignalStopHandler>;
505 using MouseScrollSignal = boost::signals2::signal<bool( float delta ), SignalStopHandler>;
506 MouseUpDownSignal mouseDownSignal; // signal is called on mouse down
507 MouseUpDownSignal mouseUpSignal; // signal is called on mouse up
508 MouseMoveSignal mouseMoveSignal; // signal is called on mouse move, note that input x and y are in screen space
509 MouseScrollSignal mouseScrollSignal; // signal is called on mouse is scrolled
510 // High-level mouse events for clicks and dragging, emitted by MouseController
511 // When mouseClickSignal has connections, a small delay for click detection is introduced into camera operations and dragging
512 // Dragging starts if dragStartSignal is handled (returns true), and ends on button release
513 // When dragging is active, dragSignal and dragEndSignal are emitted instead of mouseMove and mouseUp
514 // mouseDown handler have priority over dragStart
515 MouseUpDownSignal mouseClickSignal; // signal is called when mouse button is pressed and immediately released
516 MouseUpDownSignal dragStartSignal; // signal is called when mouse button is pressed (deterred if click behavior is on)
517 MouseUpDownSignal dragEndSignal; // signal is called when mouse button used to start drag is released
518 MouseMoveSignal dragSignal; // signal is called when mouse is being dragged with button down
519 // Cursor enters/leaves
520 using CursorEntranceSignal = boost::signals2::signal<void(bool)>;
522 // Keyboard event
523 using CharPressedSignal = boost::signals2::signal<bool( unsigned unicodeKey, int modifier ), SignalStopHandler>;
524 using KeySignal = boost::signals2::signal<bool( int key, int modifier ), SignalStopHandler>;
525 CharPressedSignal charPressedSignal; // signal is called when unicode char on/is down/pressed for some time
526 KeySignal keyUpSignal; // signal is called on key up
527 KeySignal keyDownSignal; // signal is called on key down
528 KeySignal keyRepeatSignal; // signal is called when key is pressed for some time
529 // SpaceMouseEvents
530 using SpaceMouseMoveSignal = boost::signals2::signal<bool( const Vector3f& translate, const Vector3f& rotate ), SignalStopHandler>;
531 using SpaceMouseKeySignal = boost::signals2::signal<bool( int ), SignalStopHandler>;
532 SpaceMouseMoveSignal spaceMouseMoveSignal; // signal is called on spacemouse 3d controller (joystick) move
533 SpaceMouseKeySignal spaceMouseDownSignal; // signal is called on spacemouse key down
534 SpaceMouseKeySignal spaceMouseUpSignal; // signal is called on spacemouse key up
535 SpaceMouseKeySignal spaceMouseRepeatSignal; // signal is called when spacemouse key is pressed for some time
536 // Render events
537 using RenderSignal = boost::signals2::signal<void()>;
538 RenderSignal preDrawSignal; // signal is called before scene draw (but after scene setup)
539 RenderSignal preDrawPostViewportSignal; // signal is called before scene draw but after viewport.preDraw()
540 RenderSignal drawSignal; // signal is called on scene draw (after objects tree but before viewport.postDraw())
541 RenderSignal postDrawPreViewportSignal; // signal is called after scene draw but after before viewport.postDraw()
542 RenderSignal postDrawSignal; // signal is called after scene draw
543 // Scene events
544 using ObjectsLoadedSignal = boost::signals2::signal<void( const std::vector<std::shared_ptr<Object>>& objs, const std::string& errors, const std::string& warnings )>;
545 using DragDropSignal = boost::signals2::signal<bool( const std::vector<std::filesystem::path>& paths ), SignalStopHandler>;
546 using PostResizeSignal = boost::signals2::signal<void( int x, int y )>;
547 using PostRescaleSignal = boost::signals2::signal<void( float xscale, float yscale )>;
548 using InterruptCloseSignal = boost::signals2::signal<bool(), SignalStopHandler>;
549 ObjectsLoadedSignal objectsLoadedSignal; // signal is called when objects are loaded by Viewer::loadFiles function
550 CursorEntranceSignal dragEntranceSignal; // signal is called on drag enter/leave the window
551 MouseMoveSignal dragOverSignal; // signal is called on drag coordinate changed
552 DragDropSignal dragDropSignal; // signal is called on drag and drop file
553 PostResizeSignal postResizeSignal; // signal is called after window resize
554 PostRescaleSignal postRescaleSignal; // signal is called after window rescale
555 InterruptCloseSignal interruptCloseSignal; // signal is called before close window (return true will prevent closing)
556 // Touch signals
557 using TouchSignal = boost::signals2::signal<bool(int,int,int), SignalStopHandler>;
558 TouchSignal touchStartSignal; // signal is called when any touch starts
559 TouchSignal touchMoveSignal; // signal is called when touch moves
560 TouchSignal touchEndSignal; // signal is called when touch stops
561 // Touchpad gesture events
562 using TouchpadGestureBeginSignal = boost::signals2::signal<bool(), SignalStopHandler>;
563 using TouchpadGestureEndSignal = boost::signals2::signal<bool(), SignalStopHandler>;
564 using TouchpadRotateGestureUpdateSignal = boost::signals2::signal<bool( float angle ), SignalStopHandler>;
565 using TouchpadSwipeGestureUpdateSignal = boost::signals2::signal<bool( float deltaX, float deltaY, bool kinetic ), SignalStopHandler>;
566 using TouchpadZoomGestureUpdateSignal = boost::signals2::signal<bool( float scale, bool kinetic ), SignalStopHandler>;
567 TouchpadGestureBeginSignal touchpadRotateGestureBeginSignal; // signal is called on touchpad rotate gesture beginning
568 TouchpadRotateGestureUpdateSignal touchpadRotateGestureUpdateSignal; // signal is called on touchpad rotate gesture update
569 TouchpadGestureEndSignal touchpadRotateGestureEndSignal; // signal is called on touchpad rotate gesture end
570 TouchpadGestureBeginSignal touchpadSwipeGestureBeginSignal; // signal is called on touchpad swipe gesture beginning
571 TouchpadSwipeGestureUpdateSignal touchpadSwipeGestureUpdateSignal; // signal is called on touchpad swipe gesture update
572 TouchpadGestureEndSignal touchpadSwipeGestureEndSignal; // signal is called on touchpad swipe gesture end
573 TouchpadGestureBeginSignal touchpadZoomGestureBeginSignal; // signal is called on touchpad zoom gesture beginning
574 TouchpadZoomGestureUpdateSignal touchpadZoomGestureUpdateSignal; // signal is called on touchpad zoom gesture update
575 TouchpadGestureEndSignal touchpadZoomGestureEndSignal; // signal is called on touchpad zoom gesture end
576 // Window focus signal
577 using PostFocusSignal = boost::signals2::signal<void( bool )>;
579
582 MRVIEWER_API void emplaceEvent( std::string name, ViewerEventCallback cb, bool skipable = false );
583 // pop all events from the queue while they have this name
584 MRVIEWER_API void popEventByName( const std::string& name );
585
586 MRVIEWER_API void postEmptyEvent();
587
588 [[nodiscard]] MRVIEWER_API const TouchpadParameters & getTouchpadParameters() const;
589 MRVIEWER_API void setTouchpadParameters( const TouchpadParameters & );
590
591 [[nodiscard]] MRVIEWER_API SpaceMouseParameters getSpaceMouseParameters() const;
592 MRVIEWER_API void setSpaceMouseParameters( const SpaceMouseParameters & );
593
594 [[nodiscard]] const MouseController &mouseController() const { return *mouseController_; }
595 [[nodiscard]] MouseController &mouseController() { return *mouseController_; }
596
597 // Store of recently opened files
598 [[nodiscard]] const RecentFilesStore &recentFilesStore() const { return *recentFilesStore_; }
599 [[nodiscard]] RecentFilesStore &recentFilesStore() { return *recentFilesStore_; }
600
602 [[nodiscard]] bool getSortDroppedFiles() const { return sortDroppedFiles_; }
603
605 void setSortDroppedFiles( bool value ) { sortDroppedFiles_ = value; }
606
609 MRVIEWER_API void initSpaceMouseHandler( std::function<void(const std::string&)> deviceSignal = {} );
610
611private:
612 Viewer();
613 ~Viewer();
614
615 // Init window
616 int launchInit_( const LaunchParams& params );
617
618 // Called from launchInit_ after window creating to configure it properly
619 bool setupWindow_( const LaunchParams& params );
620
621 // Return true if OpenGL loaded successfully
622 bool checkOpenGL_(const LaunchParams& params );
623
624 // Init base objects
625 void init_();
626
627 // Init all plugins on start
628 void initPlugins_();
629
630 // Shut all plugins at the end
631 void shutdownPlugins_();
632
633#ifdef __EMSCRIPTEN__
634 void mainLoopFunc_();
635 static void emsMainInfiniteLoop();
636#endif
637 // returns true if was swapped
638 bool draw_( bool force );
639
640 void drawUiRenderObjects_();
641
642 // the minimum number of frames to be rendered even if the scene is unchanged
643 int forceRedrawFrames_{ 0 };
644 // Should be `<= forceRedrawFrames_`. The next N frames will not be shown on screen.
645 int forceRedrawFramesWithoutSwap_{ 0 };
646
647 // if this flag is set shows some developer features useful for debugging
648 bool enableDeveloperFeatures_{ false };
649
650 std::unique_ptr<ViewerEventQueue> eventQueue_;
651
652 // special plugin for menu (initialized before splash window starts)
653 std::shared_ptr<ImGuiMenu> menuPlugin_;
654
655 std::unique_ptr<TouchpadController> touchpadController_;
656 std::unique_ptr<SpaceMouseController> spaceMouseController_;
657 std::unique_ptr<TouchesController> touchesController_;
658 std::unique_ptr<MouseController> mouseController_;
659 std::unique_ptr<IDragDropHandler> dragDropAdvancedHandler_;
660
661 std::unique_ptr<RecentFilesStore> recentFilesStore_;
662 std::unique_ptr<FrameCounter> frameCounter_;
663
664 mutable struct EventsCounter
665 {
666 std::array<size_t, size_t( EventType::Count )> counter{};
667 void reset();
668 } eventsCounter_;
669
670 mutable struct GLPrimitivesCounter
671 {
672 std::array<size_t, size_t( GLPrimitivesType::Count )> counter{};
673 void reset();
674 } glPrimitivesCounter_;
675
676
677 // creates glfw window with gl version major.minor, false if failed;
678 bool tryCreateWindow_( bool fullscreen, int& width, int& height, const std::string& name, int major, int minor );
679
680 bool needRedraw_() const;
681 void resetRedraw_();
682
683 void recursiveDraw_( const Viewport& vp, const Object& obj, const AffineXf3f& parentXf, RenderModelPassMask renderType, int* numDraws = nullptr ) const;
684
685 void initGlobalBasisAxesObject_();
686 void initBasisAxesObject_();
687 void initBasisViewControllerObject_();
688 void initClippingPlaneObject_();
689 void initRotationCenterObject_();
690
691 // recalculate pixel ratio
692 void updatePixelRatio_();
693
694 // return MSAA that is required for framebuffer
695 // sceneTextureOn - true means that app is using scene texture for rendering (false means that scene is rendered directly in main framebuffer)
696 // forSceneTexture - true request MSAA required for scene texture (calling with !sceneTextureOn is invalid), false - request MSAA for main framebuffer
697 int getRequiredMSAA_( bool sceneTextureOn, bool forSceneTexture ) const;
698
699 bool stopEventLoop_{ false };
700
701 bool isLaunched_{ false };
702 // this flag is needed to know if all viewer setup was already done, and we can call draw
703 bool focusRedrawReady_{ false };
704
705 std::unique_ptr<SceneTextureGL> sceneTexture_;
706 std::unique_ptr<AlphaSortGL> alphaSorter_;
707
708 bool alphaSortEnabled_{false};
709
710 bool glInitialized_{ false };
711
712 bool isInDraw_{ false };
713 bool dirtyScene_{ false };
714
715 bool hasScaledFramebuffer_{ false };
716
717 bool sortDroppedFiles_{ true };
718
719 LaunchParams launchParams_;
720
721 ViewportId getFirstAvailableViewportId_() const;
722 ViewportMask presentViewportsMask_;
723
724 std::unique_ptr<IViewerSettingsManager> settingsMng_;
725
726 std::shared_ptr<HistoryStore> globalHistoryStore_;
727
728 std::shared_ptr<SpaceMouseHandler> spaceMouseHandler_;
729
730 std::vector<boost::signals2::scoped_connection> colorUpdateConnections_;
731
732 friend MRVIEWER_API Viewer& getViewerInstance();
733};
734
735// starts default viewer with given params and setup
736MRVIEWER_API int launchDefaultViewer( const Viewer::LaunchParams& params, const ViewerSetup& setup );
737
738// call this function to load MRViewer.dll
739MRVIEWER_API void loadMRViewerDll();
740
741} // end namespace
angle
Definition MRObjectDimensionsEnum.h:13
Definition MRMouseController.h:21
Definition MRRecentFilesStore.h:17
Object that is parent of all scene.
Definition MRSceneRoot.h:11
Definition MRSetupViewer.h:13
Definition MRViewer.h:87
boost::signals2::signal< bool(const Vector3f &translate, const Vector3f &rotate), SignalStopHandler > SpaceMouseMoveSignal
Definition MRViewer.h:530
bool hasScaledFramebuffer() const
Definition MRViewer.h:448
MRVIEWER_API bool saveToFile(const std::filesystem::path &mesh_file_name)
MRVIEWER_API bool keyUp(int key, int modifier)
PostResizeSignal postResizeSignal
Definition MRViewer.h:553
bool windowShouldClose()
TouchpadGestureBeginSignal touchpadRotateGestureBeginSignal
Definition MRViewer.h:567
MRVIEWER_API void fitDataViewport(MR::ViewportMask vpList=MR::ViewportMask::all(), float fill=0.6f, bool snapView=true)
MRVIEWER_API bool isAlphaSortAvailable() const
boost::signals2::signal< bool(), SignalStopHandler > InterruptCloseSignal
Definition MRViewer.h:548
MRVIEWER_API ViewportId getHoveredViewportId() const
boost::signals2::signal< void()> RenderSignal
Definition MRViewer.h:537
boost::signals2::signal< bool(int x, int y), SignalStopHandler > MouseMoveSignal
Definition MRViewer.h:504
MRVIEWER_API void setViewportSettingsManager(std::unique_ptr< IViewerSettingsManager > mng)
PostFocusSignal postFocusSignal
Definition MRViewer.h:578
TouchpadGestureBeginSignal touchpadSwipeGestureBeginSignal
Definition MRViewer.h:570
TouchpadRotateGestureUpdateSignal touchpadRotateGestureUpdateSignal
Definition MRViewer.h:568
RenderSignal preDrawPostViewportSignal
Definition MRViewer.h:539
MRVIEWER_API bool keyRepeat(int key, int modifier)
MRVIEWER_API std::vector< std::reference_wrapper< Viewport > > getViewports(ViewportMask mask=ViewportMask::any())
const MouseController & mouseController() const
Definition MRViewer.h:594
MRVIEWER_API void appendHistoryAction(const std::shared_ptr< HistoryAction > &action)
std::shared_ptr< ViewerTitle > windowTitle
Definition MRViewer.h:496
boost::signals2::signal< bool(MouseButton btn, int modifier), SignalStopHandler > MouseUpDownSignal
Definition MRViewer.h:503
MRVIEWER_API PointInAllSpaces getMousePointInfo() const
MouseUpDownSignal dragStartSignal
Definition MRViewer.h:516
boost::signals2::signal< bool(int key, int modifier), SignalStopHandler > KeySignal
Definition MRViewer.h:524
MRVIEWER_API const std::shared_ptr< ImGuiMenu > & getMenuPlugin() const
MRVIEWER_API void resize(int w, int h)
MRVIEWER_API bool mouseClick(MouseButton button, int modifier)
std::vector< ViewerPlugin * > plugins
Definition MRViewer.h:465
static MRVIEWER_API void parseLaunchParams(LaunchParams &params)
RenderSignal drawSignal
Definition MRViewer.h:540
MRVIEWER_API Box2f getViewportsBounds() const
boost::signals2::signal< void(bool)> CursorEntranceSignal
Definition MRViewer.h:520
TouchpadGestureBeginSignal touchpadZoomGestureBeginSignal
Definition MRViewer.h:573
Vector2i windowSaveSize
Definition MRViewer.h:470
EventType
Definition MRViewer.h:292
RenderSignal postDrawPreViewportSignal
Definition MRViewer.h:541
ViewportMask getPresentViewports() const
Definition MRViewer.h:325
MRVIEWER_API bool touchpadSwipeGestureEnd()
MRVIEWER_API bool erase_viewport(ViewportId viewport_id)
MRVIEWER_API SpaceMouseParameters getSpaceMouseParameters() const
InterruptCloseSignal interruptCloseSignal
Definition MRViewer.h:555
MRVIEWER_API void fitBoxViewport(const Box3f &box, MR::ViewportMask vpList=MR::ViewportMask::all(), float fill=0.6f, bool snapView=true)
RenderSignal postDrawSignal
Definition MRViewer.h:542
MRVIEWER_API void setSpaceMouseParameters(const SpaceMouseParameters &)
MRVIEWER_API size_t getEventsCount(EventType type) const
KeySignal keyUpSignal
Definition MRViewer.h:526
std::shared_ptr< T > getMenuPluginAs() const
Definition MRViewer.h:428
const std::shared_ptr< HistoryStore > & getGlobalHistoryStore() const
Definition MRViewer.h:412
boost::signals2::signal< void(float xscale, float yscale)> PostRescaleSignal
Definition MRViewer.h:547
bool isGLInitialized() const
Definition MRViewer.h:442
MRVIEWER_API void onSceneSaved(const std::filesystem::path &savePath, bool storeInRecent=true)
boost::signals2::signal< bool(), SignalStopHandler > TouchpadGestureBeginSignal
Definition MRViewer.h:562
MRVIEWER_API bool touchStart(int id, int x, int y)
MRVIEWER_API bool mouseMove(int mouse_x, int mouse_y)
std::shared_ptr< ObjectMesh > rotationSphere
Definition MRViewer.h:491
MRVIEWER_API void clearFramebuffers()
Vector2i windowOldPos
Definition MRViewer.h:471
boost::signals2::signal< bool(int), SignalStopHandler > SpaceMouseKeySignal
Definition MRViewer.h:531
std::vector< std::string > commandArgs
Definition MRViewer.h:486
TouchpadGestureEndSignal touchpadZoomGestureEndSignal
Definition MRViewer.h:575
MRVIEWER_API Vector3f viewportToScreen(const Vector3f &viewportPoint, ViewportId id) const
boost::signals2::signal< bool(unsigned unicodeKey, int modifier), SignalStopHandler > CharPressedSignal
Definition MRViewer.h:523
MouseUpDownSignal dragEndSignal
Definition MRViewer.h:517
boost::signals2::signal< void(bool)> PostFocusSignal
Definition MRViewer.h:577
MouseUpDownSignal mouseClickSignal
Definition MRViewer.h:515
KeySignal keyDownSignal
Definition MRViewer.h:527
MRVIEWER_API bool isCurrentFrameSwapping() const
MRVIEWER_API double getPrevFrameDrawTimeMillisec() const
MRVIEWER_API void enableGlobalHistory(bool on)
MRVIEWER_API int launch(const LaunchParams &params)
MouseScrollSignal mouseScrollSignal
Definition MRViewer.h:509
MRVIEWER_API size_t getSwappedFrames() const
MRVIEWER_API void popEventByName(const std::string &name)
const LaunchParams & getLaunchParams() const
Definition MRViewer.h:107
std::function< void(Viewer *viewer)> resetSettingsFunction
Definition MRViewer.h:458
TouchSignal touchEndSignal
Definition MRViewer.h:560
MRVIEWER_API bool touchMove(int id, int x, int y)
MouseMoveSignal mouseMoveSignal
Definition MRViewer.h:508
MRVIEWER_API bool erase_viewport(const size_t index)
SpaceMouseMoveSignal spaceMouseMoveSignal
Definition MRViewer.h:532
MRVIEWER_API bool touchpadSwipeGestureBegin()
MRVIEWER_API bool dragDrop(const std::vector< std::filesystem::path > &paths)
MRVIEWER_API bool spaceMouseDown(int key)
MRVIEWER_API bool touchpadSwipeGestureUpdate(float dx, float dy, bool kinetic)
friend MRVIEWER_API Viewer & getViewerInstance()
returns global instance of Viewer class
TouchpadZoomGestureUpdateSignal touchpadZoomGestureUpdateSignal
Definition MRViewer.h:574
MRVIEWER_API PointInAllSpaces getPixelPointInfo(const Vector3f &screenPoint) const
bool isAlphaSortEnabled() const
Definition MRViewer.h:351
MRVIEWER_API void emplaceEvent(std::string name, ViewerEventCallback cb, bool skipable=false)
MRVIEWER_API int getMSAA() const
MRVIEWER_API bool spaceMouseUp(int key)
CharPressedSignal charPressedSignal
Definition MRViewer.h:525
MRVIEWER_API void incrementForceRedrawFrames(int i=1, bool swapOnLastOnly=false)
boost::signals2::signal< void(const std::vector< std::shared_ptr< Object > > &objs, const std::string &errors, const std::string &warnings)> ObjectsLoadedSignal
Definition MRViewer.h:544
size_t selected_viewport_index
Definition MRViewer.h:462
MRVIEWER_API const TouchpadParameters & getTouchpadParameters() const
MRVIEWER_API void postSetMaximized(bool maximized)
const std::shared_ptr< SpaceMouseHandler > & getSpaceMouseHandler() const
Definition MRViewer.h:414
MRVIEWER_API int getRequestedMSAA() const
static Viewer * instance()
Definition MRViewer.h:110
MRVIEWER_API bool mouseUp(MouseButton button, int modifier)
MRVIEWER_API bool enableAlphaSort(bool on)
PluginType * getPluginInstance()
Definition MRViewer.h:117
ObjectsLoadedSignal objectsLoadedSignal
Definition MRViewer.h:549
MRVIEWER_API bool mouseScroll(float delta_y)
bool isLaunched() const
Definition MRViewer.h:104
MRVIEWER_API void postEmptyEvent()
static const Viewer * constInstance()
Definition MRViewer.h:113
TouchpadGestureEndSignal touchpadRotateGestureEndSignal
Definition MRViewer.h:569
RenderSignal preDrawSignal
Definition MRViewer.h:538
MRVIEWER_API size_t getFPS() const
TouchpadGestureEndSignal touchpadSwipeGestureEndSignal
Definition MRViewer.h:572
MRVIEWER_API Vector3f screenToViewport(const Vector3f &screenPoint, ViewportId id) const
MRVIEWER_API bool dragEnd(MouseButton button, int modifier)
boost::signals2::signal< bool(int, int, int), SignalStopHandler > TouchSignal
Definition MRViewer.h:557
std::shared_ptr< ObjectMesh > clippingPlaneObject
Definition MRViewer.h:493
TouchpadSwipeGestureUpdateSignal touchpadSwipeGestureUpdateSignal
Definition MRViewer.h:571
MRVIEWER_API const Viewport & viewport(ViewportId viewportId={}) const
static const Viewer & constInstanceRef()
Definition MRViewer.h:114
MRVIEWER_API bool touchpadZoomGestureEnd()
MRVIEWER_API Image captureSceneScreenShot(const Vector2i &resolution=Vector2i())
void setSortDroppedFiles(bool value)
sets whether to sort the filenames received from Drag&Drop in lexicographical order before adding the...
Definition MRViewer.h:605
MouseUpDownSignal mouseDownSignal
Definition MRViewer.h:506
boost::signals2::signal< bool(float scale, bool kinetic), SignalStopHandler > TouchpadZoomGestureUpdateSignal
Definition MRViewer.h:566
MRVIEWER_API bool touchpadRotateGestureBegin()
MRVIEWER_API bool mouseDown(MouseButton button, int modifier)
std::shared_ptr< ObjectMesh > globalBasisAxes
Definition MRViewer.h:490
RecentFilesStore & recentFilesStore()
Definition MRViewer.h:599
MRVIEWER_API void select_hovered_viewport()
MRVIEWER_API ViewportId append_viewport(const ViewportRectangle &viewportRect, bool append_empty=false)
MRVIEWER_API bool touchpadRotateGestureUpdate(float angle)
MRVIEWER_API bool spaceMouseRepeat(int key)
MRVIEWER_API void incrementThisFrameGLPrimitivesCount(GLPrimitivesType type, size_t num)
CursorEntranceSignal dragEntranceSignal
Definition MRViewer.h:550
MRVIEWER_API void postRescale(float x, float y)
static Viewer & instanceRef()
Definition MRViewer.h:111
std::shared_ptr< ObjectMesh > basisAxes
Definition MRViewer.h:488
MRVIEWER_API bool touchpadZoomGestureBegin()
MRVIEWER_API void bindSceneTexture(bool bind)
MRVIEWER_API bool touchpadZoomGestureUpdate(float scale, bool kinetic)
MRVIEWER_API void set_root(SceneRootObject &newRoot)
MRVIEWER_API void stopEventLoop()
MRVIEWER_API void launchEventLoop()
PostRescaleSignal postRescaleSignal
Definition MRViewer.h:554
DragDropSignal dragDropSignal
Definition MRViewer.h:552
MRVIEWER_API void captureUIScreenShot(std::function< void(const Image &)> callback, const Vector2i &pos=Vector2i(), const Vector2i &size=Vector2i())
boost::signals2::signal< void(int x, int y)> PostResizeSignal
Definition MRViewer.h:546
MRVIEWER_API void launchShut()
MRVIEWER_API bool globalHistoryUndo()
MRVIEWER_API std::shared_ptr< RibbonMenu > getRibbonMenu() const
MRVIEWER_API const std::unique_ptr< IViewerSettingsManager > & getViewerSettingsManager() const
Definition MRViewer.h:374
boost::signals2::signal< bool(), SignalStopHandler > TouchpadGestureEndSignal
Definition MRViewer.h:563
MRVIEWER_API void preciseFitDataViewport(MR::ViewportMask vpList=MR::ViewportMask::all())
Vector2i framebufferSize
Definition MRViewer.h:468
CursorEntranceSignal cursorEntranceSignal
Definition MRViewer.h:521
MRVIEWER_API bool keyDown(int key, int modifier)
bool getSortDroppedFiles() const
returns whether to sort the filenames received from Drag&Drop in lexicographical order before adding ...
Definition MRViewer.h:602
MRVIEWER_API void setupScene()
MouseMoveSignal dragOverSignal
Definition MRViewer.h:551
MRVIEWER_API void setMenuPlugin(std::shared_ptr< ImGuiMenu > menu)
MRVIEWER_API Viewport & viewport(ViewportId viewportId={})
MouseUpDownSignal mouseUpSignal
Definition MRViewer.h:507
MRVIEWER_API size_t getStaticGLBufferSize() const
GLPrimitivesType
Definition MRViewer.h:308
boost::signals2::signal< bool(float deltaX, float deltaY, bool kinetic), SignalStopHandler > TouchpadSwipeGestureUpdateSignal
Definition MRViewer.h:565
Vector2i windowSavePos
Definition MRViewer.h:469
MRVIEWER_API size_t getLastFrameGLPrimitivesCount(GLPrimitivesType type) const
MRVIEWER_API bool dragStart(MouseButton button, int modifier)
MRVIEWER_API void drawFull(bool dirtyScene)
std::unique_ptr< CornerControllerObject > basisViewController
Definition MRViewer.h:489
SpaceMouseKeySignal spaceMouseUpSignal
Definition MRViewer.h:534
TouchSignal touchStartSignal
Definition MRViewer.h:558
MRVIEWER_API void drawScene()
MRVIEWER_API void requestChangeMSAA(int newMSAA)
GLFWwindow * window
Definition MRViewer.h:454
MRVIEWER_API bool drag(int mouse_x, int mouse_y)
SpaceMouseKeySignal spaceMouseDownSignal
Definition MRViewer.h:533
MRVIEWER_API void postSetIconified(bool iconified)
MRVIEWER_API bool globalHistoryRedo()
MRVIEWER_API void makeTitleFromSceneRootPath()
MRVIEWER_API size_t getTotalFrames() const
MRVIEWER_API void postFocus(bool focused)
void setSceneDirty()
Definition MRViewer.h:183
MRVIEWER_API void resetAllCounters()
MRVIEWER_API bool isSupportedFormat(const std::filesystem::path &file_name)
MouseMoveSignal dragSignal
Definition MRViewer.h:518
boost::signals2::signal< bool(const std::vector< std::filesystem::path > &paths), SignalStopHandler > DragDropSignal
Definition MRViewer.h:545
MRVIEWER_API void draw(bool force=false)
MRVIEWER_API int viewport_index(ViewportId viewport_id) const
MRVIEWER_API bool touchpadRotateGestureEnd()
boost::signals2::signal< bool(float angle), SignalStopHandler > TouchpadRotateGestureUpdateSignal
Definition MRViewer.h:564
MouseController & mouseController()
Definition MRViewer.h:595
MRVIEWER_API bool isSceneTextureBound() const
MRVIEWER_API void initSpaceMouseHandler(std::function< void(const std::string &)> deviceSignal={})
MRVIEWER_API bool touchEnd(int id, int x, int y)
boost::signals2::signal< bool(float delta), SignalStopHandler > MouseScrollSignal
Definition MRViewer.h:505
SpaceMouseKeySignal spaceMouseRepeatSignal
Definition MRViewer.h:535
MRVIEWER_API bool loadFiles(const std::vector< std::filesystem::path > &filesList, const FileLoadOptions &options={})
const RecentFilesStore & recentFilesStore() const
Definition MRViewer.h:598
MRVIEWER_API bool interruptWindowClose()
MRVIEWER_API bool spaceMouseMove(const Vector3f &translate, const Vector3f &rotate)
MRVIEWER_API void setTouchpadParameters(const TouchpadParameters &)
MRVIEWER_API void preciseFitDataViewport(MR::ViewportMask vpList, const FitDataParams &param)
bool isGlobalHistoryEnabled() const
Definition MRViewer.h:401
KeySignal keyRepeatSignal
Definition MRViewer.h:528
MRVIEWER_API void postResize(int w, int h)
TouchSignal touchMoveSignal
Definition MRViewer.h:559
MRVIEWER_API bool keyPressed(unsigned int unicode_key, int modifier)
MRVIEWER_API bool isSceneTextureEnabled() const
MRVIEWER_API void postSetPosition(int xPos, int yPos)
MRVIEWER_API void clearScene()
std::vector< Viewport > viewport_list
Definition MRViewer.h:461
MRVIEWER_API void postClose()
bool getStopEventLoopFlag() const
Definition MRViewer.h:433
Definition MRViewportId.h:16
stores mask of viewport unique identifiers
Definition MRViewportId.h:42
static ViewportMask all()
mask meaning all or any viewports
Definition MRViewportId.h:49
Definition MRViewport.h:46
Definition MRCameraOrientationPlugin.h:8
MRVIEWER_API void loadMRViewerDll()
MouseMode
Definition MRMouse.h:19
MouseButton
Definition MRMouse.h:9
std::function< void(const std::vector< std::shared_ptr< Object > > &objs, const std::string &errors, const std::string &warnings)> FilesLoadedCallback
Definition MRViewer.h:70
MRVIEWER_API Viewer & getViewerInstance()
returns global instance of Viewer class
MRVIEWER_API int launchDefaultViewer(const Viewer::LaunchParams &params, const ViewerSetup &setup)
Box2f ViewportRectangle
Viewport size.
Definition MRViewerFwd.h:12
std::function< void()> ViewerEventCallback
Definition MRViewerFwd.h:69
Definition MRViewer.h:73
FilesLoadedCallback loadedCallback
Definition MRViewer.h:82
const char * undoPrefix
first part of undo name
Definition MRViewer.h:75
bool forceReplaceScene
true here will replace existing scene even if more than one file is open
Definition MRViewer.h:78
Definition MRFitData.h:29
Definition MRImage.h:15
Definition MRViewer.h:39
WindowMode
Definition MRViewer.h:44
@ HideInit
Definition MRViewer.h:46
@ NoWindow
Definition MRViewer.h:49
@ TryHidden
Definition MRViewer.h:48
@ Hide
Definition MRViewer.h:47
@ Show
Definition MRViewer.h:45
bool render3dSceneInTexture
Definition MRViewer.h:53
bool console
Definition MRViewer.h:58
bool developerFeatures
Definition MRViewer.h:54
char ** argv
Definition MRViewer.h:60
bool startEventLoop
Definition MRViewer.h:56
bool fullscreen
Definition MRViewer.h:40
int animationMaxFps
Definition MRViewer.h:64
int argc
Definition MRViewer.h:59
std::shared_ptr< SplashWindow > splashWindow
Definition MRViewer.h:67
bool unloadPluginsAtEnd
Definition MRViewer.h:65
bool close
Definition MRViewer.h:57
bool showMRVersionInTitle
Definition MRViewer.h:62
bool enableTransparentBackground
Definition MRViewer.h:51
int height
Definition MRViewer.h:42
bool preferOpenGL3
Definition MRViewer.h:52
int width
Definition MRViewer.h:41
enum MR::LaunchParams::WindowMode HideInit
std::string name
Definition MRViewer.h:55
bool isAnimating
Definition MRViewer.h:63
Definition MRPointInAllSpaces.h:13
Definition MRSpaceMouseParameters.h:10
Definition MRSignalCombiners.h:8
Definition MRTouchpadParameters.h:9