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 CornerControllerObject;
35// This struct contains rules for viewer launch
37{
38 bool fullscreen{ false }; // if true starts fullscreen
39 int width{ 0 };
40 int height{ 0 };
42 {
43 Show, // Show window immediately
44 HideInit, // Show window after init
45 Hide, // Don't show window
46 TryHidden, // Launches in "Hide" mode if OpenGL is present and "NoWindow" if it is not
47 NoWindow // Don't initialize GL window (don't call GL functions)(force `isAnimating`)
48 } windowMode{ HideInit };
50 bool preferOpenGL3{ false };
51 bool render3dSceneInTexture{ true }; // If not set renders scene each frame
52 bool developerFeatures{ false }; // If set shows some developer features useful for debugging
53 std::string name{ "MRViewer" }; // Window name
54 bool startEventLoop{ true }; // If false - does not start event loop
55 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
56 bool console{ false }; // If true - shows developers console
57 int argc{ 0 }; // Pass argc
58 char** argv{ nullptr }; // Pass argv
59
60 bool showMRVersionInTitle{ false }; // if true - print version info in window title
61 bool isAnimating{ false }; // if true - calls render without system events
62 int animationMaxFps{ 30 }; // max fps if animating
63 bool unloadPluginsAtEnd{ false }; // unload all extended libraries right before program exit
64
65 std::shared_ptr<SplashWindow> splashWindow; // if present will show this window while initializing plugins (after menu initialization)
66};
67
68using FilesLoadedCallback = std::function<void(const std::vector<std::shared_ptr<Object>>& objs,const std::string& errors, const std::string& warnings)>;
69
71{
73 const char * undoPrefix = "Open ";
74
76 bool forceReplaceScene = false;
77
81};
82
83// GLFW-based mesh viewer
84class MRVIEWER_CLASS Viewer
85{
86public:
89
91
92 // Accumulate launch params from cmd args
93 MRVIEWER_API static void parseLaunchParams( LaunchParams& params );
94
95 // Launch viewer with given params
96 MRVIEWER_API int launch( const LaunchParams& params );
97 // Starts event loop
98 MRVIEWER_API void launchEventLoop();
99 // Terminate window
100 MRVIEWER_API void launchShut();
101
102 bool isLaunched() const { return isLaunched_; }
103
104 // get full parameters with witch viewer was launched
105 const LaunchParams& getLaunchParams() const { return launchParams_; }
106
107 // provides non const access to viewer
108 static Viewer* instance() { return &getViewerInstance(); }
109 static Viewer& instanceRef() { return getViewerInstance(); }
110 // provide const access to viewer
111 static const Viewer* constInstance() { return &getViewerInstance(); }
112 static const Viewer& constInstanceRef() { return getViewerInstance(); }
113
114 template<typename PluginType>
115 PluginType* getPluginInstance()
116 {
117 for ( auto& plugin : plugins )
118 {
119 auto p = dynamic_cast< PluginType* >( plugin );
120 if ( p )
121 {
122 return p;
123 }
124 }
125 return nullptr;
126 }
127
128 // Mesh IO
129 // Check the supported file format
130 MRVIEWER_API bool isSupportedFormat( const std::filesystem::path& file_name );
131
132 // Load objects / scenes from files
133 // Note! load files with progress bar in next frame if it possible, otherwise load directly inside this function
134 MRVIEWER_API bool loadFiles( const std::vector< std::filesystem::path>& filesList, const FileLoadOptions & options = {} );
135
136 // Save first selected objects to file
137 MRVIEWER_API bool saveToFile( const std::filesystem::path & mesh_file_name );
138
139 // Callbacks
140 MRVIEWER_API bool keyPressed( unsigned int unicode_key, int modifier );
141 MRVIEWER_API bool keyDown( int key, int modifier );
142 MRVIEWER_API bool keyUp( int key, int modifier );
143 MRVIEWER_API bool keyRepeat( int key, int modifier );
144 MRVIEWER_API bool mouseDown( MouseButton button, int modifier );
145 MRVIEWER_API bool mouseUp( MouseButton button, int modifier );
146 MRVIEWER_API bool mouseMove( int mouse_x, int mouse_y );
147 MRVIEWER_API bool mouseScroll( float delta_y );
148 MRVIEWER_API bool mouseClick( MouseButton button, int modifier );
149 MRVIEWER_API bool dragStart( MouseButton button, int modifier );
150 MRVIEWER_API bool dragEnd( MouseButton button, int modifier );
151 MRVIEWER_API bool drag( int mouse_x, int mouse_y );
152 MRVIEWER_API bool spaceMouseMove( const Vector3f& translate, const Vector3f& rotate );
153 MRVIEWER_API bool spaceMouseDown( int key );
154 MRVIEWER_API bool spaceMouseUp( int key );
155 MRVIEWER_API bool spaceMouseRepeat( int key );
156 MRVIEWER_API bool dragDrop( const std::vector<std::filesystem::path>& paths );
157 // Touch callbacks (now used in EMSCRIPTEN build only)
158 MRVIEWER_API bool touchStart( int id, int x, int y );
159 MRVIEWER_API bool touchMove( int id, int x, int y );
160 MRVIEWER_API bool touchEnd( int id, int x, int y );
161 // Touchpad gesture callbacks
162 MRVIEWER_API bool touchpadRotateGestureBegin();
163 MRVIEWER_API bool touchpadRotateGestureUpdate( float angle );
164 MRVIEWER_API bool touchpadRotateGestureEnd();
165 MRVIEWER_API bool touchpadSwipeGestureBegin();
166 MRVIEWER_API bool touchpadSwipeGestureUpdate( float dx, float dy, bool kinetic );
167 MRVIEWER_API bool touchpadSwipeGestureEnd();
168 MRVIEWER_API bool touchpadZoomGestureBegin();
169 MRVIEWER_API bool touchpadZoomGestureUpdate( float scale, bool kinetic );
170 MRVIEWER_API bool touchpadZoomGestureEnd();
171 // This function is called when window should close, if return value is true, window will stay open
172 MRVIEWER_API bool interruptWindowClose();
173 // callback to update connected / disconnected joystick
174 MRVIEWER_API void joystickUpdateConnected( int jid, int event );
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 DragDropSignal dragDropSignal; // signal is called on drag and drop file
551 PostResizeSignal postResizeSignal; // signal is called after window resize
552 PostRescaleSignal postRescaleSignal; // signal is called after window rescale
553 InterruptCloseSignal interruptCloseSignal; // signal is called before close window (return true will prevent closing)
554 // Touch signals
555 using TouchSignal = boost::signals2::signal<bool(int,int,int), SignalStopHandler>;
556 TouchSignal touchStartSignal; // signal is called when any touch starts
557 TouchSignal touchMoveSignal; // signal is called when touch moves
558 TouchSignal touchEndSignal; // signal is called when touch stops
559 // Touchpad gesture events
560 using TouchpadGestureBeginSignal = boost::signals2::signal<bool(), SignalStopHandler>;
561 using TouchpadGestureEndSignal = boost::signals2::signal<bool(), SignalStopHandler>;
562 using TouchpadRotateGestureUpdateSignal = boost::signals2::signal<bool( float angle ), SignalStopHandler>;
563 using TouchpadSwipeGestureUpdateSignal = boost::signals2::signal<bool( float deltaX, float deltaY, bool kinetic ), SignalStopHandler>;
564 using TouchpadZoomGestureUpdateSignal = boost::signals2::signal<bool( float scale, bool kinetic ), SignalStopHandler>;
565 TouchpadGestureBeginSignal touchpadRotateGestureBeginSignal; // signal is called on touchpad rotate gesture beginning
566 TouchpadRotateGestureUpdateSignal touchpadRotateGestureUpdateSignal; // signal is called on touchpad rotate gesture update
567 TouchpadGestureEndSignal touchpadRotateGestureEndSignal; // signal is called on touchpad rotate gesture end
568 TouchpadGestureBeginSignal touchpadSwipeGestureBeginSignal; // signal is called on touchpad swipe gesture beginning
569 TouchpadSwipeGestureUpdateSignal touchpadSwipeGestureUpdateSignal; // signal is called on touchpad swipe gesture update
570 TouchpadGestureEndSignal touchpadSwipeGestureEndSignal; // signal is called on touchpad swipe gesture end
571 TouchpadGestureBeginSignal touchpadZoomGestureBeginSignal; // signal is called on touchpad zoom gesture beginning
572 TouchpadZoomGestureUpdateSignal touchpadZoomGestureUpdateSignal; // signal is called on touchpad zoom gesture update
573 TouchpadGestureEndSignal touchpadZoomGestureEndSignal; // signal is called on touchpad zoom gesture end
574 // Window focus signal
575 using PostFocusSignal = boost::signals2::signal<void( bool )>;
577
580 MRVIEWER_API void emplaceEvent( std::string name, ViewerEventCallback cb, bool skipable = false );
581 // pop all events from the queue while they have this name
582 MRVIEWER_API void popEventByName( const std::string& name );
583
584 MRVIEWER_API void postEmptyEvent();
585
586 [[nodiscard]] MRVIEWER_API const TouchpadParameters & getTouchpadParameters() const;
587 MRVIEWER_API void setTouchpadParameters( const TouchpadParameters & );
588
589 [[nodiscard]] MRVIEWER_API SpaceMouseParameters getSpaceMouseParameters() const;
590 MRVIEWER_API void setSpaceMouseParameters( const SpaceMouseParameters & );
591
592 [[nodiscard]] const MouseController &mouseController() const { return *mouseController_; }
593 [[nodiscard]] MouseController &mouseController() { return *mouseController_; }
594
595 // Store of recently opened files
596 [[nodiscard]] const RecentFilesStore &recentFilesStore() const { return *recentFilesStore_; }
597 [[nodiscard]] RecentFilesStore &recentFilesStore() { return *recentFilesStore_; }
598
599private:
600 Viewer();
601 ~Viewer();
602
603 // Init window
604 int launchInit_( const LaunchParams& params );
605 // Return true if OpenGL loaded successfully
606 bool checkOpenGL_(const LaunchParams& params );
607 // Init base objects
608 void init_();
609 // Init all plugins on start
610 void initPlugins_();
611 // Shut all plugins at the end
612 void shutdownPlugins_();
613#ifdef __EMSCRIPTEN__
614 void mainLoopFunc_();
615 static void emsMainInfiniteLoop();
616#endif
617 // returns true if was swapped
618 bool draw_( bool force );
619
620 void drawUiRenderObjects_();
621
622 // the minimum number of frames to be rendered even if the scene is unchanged
623 int forceRedrawFrames_{ 0 };
624 // Should be `<= forceRedrawFrames_`. The next N frames will not be shown on screen.
625 int forceRedrawFramesWithoutSwap_{ 0 };
626
627 // if this flag is set shows some developer features useful for debugging
628 bool enableDeveloperFeatures_{ false };
629
630 std::unique_ptr<ViewerEventQueue> eventQueue_;
631
632 // special plugin for menu (initialized before splash window starts)
633 std::shared_ptr<ImGuiMenu> menuPlugin_;
634
635 std::unique_ptr<TouchpadController> touchpadController_;
636 std::unique_ptr<SpaceMouseController> spaceMouseController_;
637 std::unique_ptr<TouchesController> touchesController_;
638 std::unique_ptr<MouseController> mouseController_;
639
640 std::unique_ptr<RecentFilesStore> recentFilesStore_;
641 std::unique_ptr<FrameCounter> frameCounter_;
642
643 mutable struct EventsCounter
644 {
645 std::array<size_t, size_t( EventType::Count )> counter{};
646 void reset();
647 } eventsCounter_;
648
649 mutable struct GLPrimitivesCounter
650 {
651 std::array<size_t, size_t( GLPrimitivesType::Count )> counter{};
652 void reset();
653 } glPrimitivesCounter_;
654
655
656 // creates glfw window with gl version major.minor, false if failed;
657 bool tryCreateWindow_( bool fullscreen, int& width, int& height, const std::string& name, int major, int minor );
658
659 bool needRedraw_() const;
660 void resetRedraw_();
661
662 void recursiveDraw_( const Viewport& vp, const Object& obj, const AffineXf3f& parentXf, RenderModelPassMask renderType, int* numDraws = nullptr ) const;
663
664 void initGlobalBasisAxesObject_();
665 void initBasisAxesObject_();
666 void initBasisViewControllerObject_();
667 void initClippingPlaneObject_();
668 void initRotationCenterObject_();
669 void initSpaceMouseHandler_();
670
671 // recalculate pixel ratio
672 void updatePixelRatio_();
673
674 // return MSAA that is required for framebuffer
675 // sceneTextureOn - true means that app is using scene texture for rendering (false means that scene is rendered directly in main framebuffer)
676 // forSceneTexture - true request MSAA required for scene texture (calling with !sceneTextureOn is invalid), false - request MSAA for main framebuffer
677 int getRequiredMSAA_( bool sceneTextureOn, bool forSceneTexture ) const;
678
679 bool stopEventLoop_{ false };
680
681 bool isLaunched_{ false };
682 // this flag is needed to know if all viewer setup was already done, and we can call draw
683 bool focusRedrawReady_{ false };
684
685 std::unique_ptr<SceneTextureGL> sceneTexture_;
686 std::unique_ptr<AlphaSortGL> alphaSorter_;
687
688 bool alphaSortEnabled_{false};
689
690 bool glInitialized_{ false };
691
692 bool isInDraw_{ false };
693 bool dirtyScene_{ false };
694
695 bool hasScaledFramebuffer_{ false };
696
697 LaunchParams launchParams_;
698
699 ViewportId getFirstAvailableViewportId_() const;
700 ViewportMask presentViewportsMask_;
701
702 std::unique_ptr<IViewerSettingsManager> settingsMng_;
703
704 std::shared_ptr<HistoryStore> globalHistoryStore_;
705
706 std::shared_ptr<SpaceMouseHandler> spaceMouseHandler_;
707
708 std::vector<boost::signals2::scoped_connection> colorUpdateConnections_;
709
710 friend MRVIEWER_API Viewer& getViewerInstance();
711};
712
713// starts default viewer with given params and setup
714MRVIEWER_API int launchDefaultViewer( const Viewer::LaunchParams& params, const ViewerSetup& setup );
715
716// call this function to load MRViewer.dll
717MRVIEWER_API void loadMRViewerDll();
718
719} // 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:85
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:551
bool windowShouldClose()
TouchpadGestureBeginSignal touchpadRotateGestureBeginSignal
Definition MRViewer.h:565
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:576
TouchpadGestureBeginSignal touchpadSwipeGestureBeginSignal
Definition MRViewer.h:568
TouchpadRotateGestureUpdateSignal touchpadRotateGestureUpdateSignal
Definition MRViewer.h:566
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:592
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:571
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:553
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:560
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:573
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:575
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:105
std::function< void(Viewer *viewer)> resetSettingsFunction
Definition MRViewer.h:458
TouchSignal touchEndSignal
Definition MRViewer.h:558
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:572
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 void joystickUpdateConnected(int jid, int event)
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:108
MRVIEWER_API bool mouseUp(MouseButton button, int modifier)
MRVIEWER_API bool enableAlphaSort(bool on)
PluginType * getPluginInstance()
Definition MRViewer.h:115
ObjectsLoadedSignal objectsLoadedSignal
Definition MRViewer.h:549
MRVIEWER_API bool mouseScroll(float delta_y)
bool isLaunched() const
Definition MRViewer.h:102
MRVIEWER_API void postEmptyEvent()
static const Viewer * constInstance()
Definition MRViewer.h:111
TouchpadGestureEndSignal touchpadRotateGestureEndSignal
Definition MRViewer.h:567
RenderSignal preDrawSignal
Definition MRViewer.h:538
MRVIEWER_API size_t getFPS() const
TouchpadGestureEndSignal touchpadSwipeGestureEndSignal
Definition MRViewer.h:570
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:555
std::shared_ptr< ObjectMesh > clippingPlaneObject
Definition MRViewer.h:493
TouchpadSwipeGestureUpdateSignal touchpadSwipeGestureUpdateSignal
Definition MRViewer.h:569
MRVIEWER_API const Viewport & viewport(ViewportId viewportId={}) const
static const Viewer & constInstanceRef()
Definition MRViewer.h:112
MRVIEWER_API bool touchpadZoomGestureEnd()
MRVIEWER_API Image captureSceneScreenShot(const Vector2i &resolution=Vector2i())
MouseUpDownSignal mouseDownSignal
Definition MRViewer.h:506
boost::signals2::signal< bool(float scale, bool kinetic), SignalStopHandler > TouchpadZoomGestureUpdateSignal
Definition MRViewer.h:564
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:597
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)
MRVIEWER_API void postRescale(float x, float y)
static Viewer & instanceRef()
Definition MRViewer.h:109
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:552
DragDropSignal dragDropSignal
Definition MRViewer.h:550
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:561
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)
MRVIEWER_API void setupScene()
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:563
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:556
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:562
MouseController & mouseController()
Definition MRViewer.h:593
MRVIEWER_API bool isSceneTextureBound() const
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:596
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:557
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:38
static ViewportMask all()
mask meaning all or any viewports
Definition MRViewportId.h:45
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:68
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:71
FilesLoadedCallback loadedCallback
Definition MRViewer.h:80
const char * undoPrefix
first part of undo name
Definition MRViewer.h:73
bool forceReplaceScene
true here will replace existing scene even if more than one file is open
Definition MRViewer.h:76
Definition MRFitData.h:28
Definition MRImage.h:15
Definition MRViewer.h:37
WindowMode
Definition MRViewer.h:42
@ HideInit
Definition MRViewer.h:44
@ NoWindow
Definition MRViewer.h:47
@ TryHidden
Definition MRViewer.h:46
@ Hide
Definition MRViewer.h:45
@ Show
Definition MRViewer.h:43
bool render3dSceneInTexture
Definition MRViewer.h:51
bool console
Definition MRViewer.h:56
bool developerFeatures
Definition MRViewer.h:52
char ** argv
Definition MRViewer.h:58
bool startEventLoop
Definition MRViewer.h:54
bool fullscreen
Definition MRViewer.h:38
int animationMaxFps
Definition MRViewer.h:62
int argc
Definition MRViewer.h:57
std::shared_ptr< SplashWindow > splashWindow
Definition MRViewer.h:65
bool unloadPluginsAtEnd
Definition MRViewer.h:63
bool close
Definition MRViewer.h:55
bool showMRVersionInTitle
Definition MRViewer.h:60
bool enableTransparentBackground
Definition MRViewer.h:49
int height
Definition MRViewer.h:40
bool preferOpenGL3
Definition MRViewer.h:50
int width
Definition MRViewer.h:39
enum MR::LaunchParams::WindowMode HideInit
std::string name
Definition MRViewer.h:53
bool isAnimating
Definition MRViewer.h:61
Definition MRPointInAllSpaces.h:13
Definition MRSpaceMouseParameters.h:10
Definition MRSignalCombiners.h:8
Definition MRTouchpadParameters.h:9