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