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 <MRMesh/MRVector2.h>
8#include <cstdint>
9#include <filesystem>
10
11struct GLFWwindow;
12
14#define ENQUEUE_VIEWER_METHOD( NAME, METHOD ) MR::getViewerInstance().emplaceEvent( NAME, [] { \
15 MR::getViewerInstance() . METHOD (); \
16} )
17#define ENQUEUE_VIEWER_METHOD_ARGS( NAME, METHOD, ... ) MR::getViewerInstance().emplaceEvent( NAME, [__VA_ARGS__] { \
18 MR::getViewerInstance() . METHOD ( __VA_ARGS__ ); \
19} )
20#define ENQUEUE_VIEWER_METHOD_ARGS_SKIPABLE( NAME, METHOD, ... ) MR::getViewerInstance().emplaceEvent( NAME, [__VA_ARGS__] { \
21 MR::getViewerInstance() . METHOD ( __VA_ARGS__ ); \
22}, true )
23
24namespace MR
25{
28
29
30class FramebufferData;
31
34{
35 bool fullscreen{ false };
36 int width{ 0 };
37 int height{ 0 };
47 bool preferOpenGL3{ false };
49 bool developerFeatures{ false };
50 bool multiViewport{ true };
51 std::string name{ "MRViewer" };
52 bool resetConfig{ false };
53 bool startEventLoop{ true };
54 bool close{ true };
55 bool console{ false };
56 int argc{ 0 };
57 char** argv{ nullptr };
58
59 bool showMRVersionInTitle{ false };
60 bool isAnimating{ false };
61 int animationMaxFps{ 30 };
62 bool unloadPluginsAtEnd{ false };
63
64 std::shared_ptr<SplashWindow> splashWindow;
65};
66
68class MRVIEWER_CLASS Viewer
69{
70public:
73
75
77 MRVIEWER_API static void parseLaunchParams( LaunchParams& params );
78
80 MRVIEWER_API int launch( const LaunchParams& params );
82 MRVIEWER_API void launchEventLoop();
84 MRVIEWER_API void launchShut();
85
86 bool isLaunched() const { return isLaunched_; }
87
89 const LaunchParams& getLaunchParams() const { return launchParams_; }
90
92 static Viewer* instance() { return &getViewerInstance(); }
93 static Viewer& instanceRef() { return getViewerInstance(); }
95 static const Viewer* constInstance() { return &getViewerInstance(); }
96 static const Viewer& constInstanceRef() { return getViewerInstance(); }
97
98 template<typename PluginType>
99 PluginType* getPluginInstance()
100 {
101 for ( auto& plugin : plugins )
102 {
103 auto p = dynamic_cast< PluginType* >( plugin );
104 if ( p )
105 {
106 return p;
107 }
108 }
109 return nullptr;
110 }
111
114 MRVIEWER_API bool isSupportedFormat( const std::filesystem::path& file_name );
115
118 MRVIEWER_API bool loadFiles( const std::vector< std::filesystem::path>& filesList, const FileLoadOptions & options );
119 MRVIEWER_API bool loadFiles( const std::vector< std::filesystem::path>& filesList );
120
122 MRVIEWER_API bool saveToFile( const std::filesystem::path & mesh_file_name );
123
125 MRVIEWER_API bool keyPressed( unsigned int unicode_key, int modifier );
126 MRVIEWER_API bool keyDown( int key, int modifier );
127 MRVIEWER_API bool keyUp( int key, int modifier );
128 MRVIEWER_API bool keyRepeat( int key, int modifier );
129 MRVIEWER_API bool mouseDown( MouseButton button, int modifier );
130 MRVIEWER_API bool mouseUp( MouseButton button, int modifier );
131 MRVIEWER_API bool mouseMove( int mouse_x, int mouse_y );
132 MRVIEWER_API bool mouseScroll( float delta_y );
133 MRVIEWER_API bool mouseClick( MouseButton button, int modifier );
134 MRVIEWER_API bool dragStart( MouseButton button, int modifier );
135 MRVIEWER_API bool dragEnd( MouseButton button, int modifier );
136 MRVIEWER_API bool drag( int mouse_x, int mouse_y );
137 MRVIEWER_API bool spaceMouseMove( const Vector3f& translate, const Vector3f& rotate );
138 MRVIEWER_API bool spaceMouseDown( int key );
139 MRVIEWER_API bool spaceMouseUp( int key );
140 MRVIEWER_API bool spaceMouseRepeat( int key );
141 MRVIEWER_API bool dragDrop( const std::vector<std::filesystem::path>& paths );
143 MRVIEWER_API bool touchStart( int id, int x, int y );
144 MRVIEWER_API bool touchMove( int id, int x, int y );
145 MRVIEWER_API bool touchEnd( int id, int x, int y );
147 MRVIEWER_API bool touchpadRotateGestureBegin();
148 MRVIEWER_API bool touchpadRotateGestureUpdate( float angle );
149 MRVIEWER_API bool touchpadRotateGestureEnd();
150 MRVIEWER_API bool touchpadSwipeGestureBegin();
151 MRVIEWER_API bool touchpadSwipeGestureUpdate( float dx, float dy, bool kinetic );
152 MRVIEWER_API bool touchpadSwipeGestureEnd();
153 MRVIEWER_API bool touchpadZoomGestureBegin();
154 MRVIEWER_API bool touchpadZoomGestureUpdate( float scale, bool kinetic );
155 MRVIEWER_API bool touchpadZoomGestureEnd();
157 MRVIEWER_API bool interruptWindowClose();
158
160 MRVIEWER_API void draw( bool force = false );
162 MRVIEWER_API void drawFull( bool dirtyScene );
165 MRVIEWER_API void drawScene( FramebufferData* framebuffer );
167 void setSceneDirty() { dirtyScene_ = true; }
169 MRVIEWER_API void setupScene();
171 MRVIEWER_API void clearFramebuffers();
173 MRVIEWER_API void resize( int w, int h );
174 MRVIEWER_API void postResize( int w, int h );
175 MRVIEWER_API void postSetPosition( int xPos, int yPos );
176 MRVIEWER_API void postSetMaximized( bool maximized );
177 MRVIEWER_API void postSetIconified( bool iconified );
178 MRVIEWER_API void postFocus( bool focused );
179 MRVIEWER_API void postRescale( float x, float y );
180 MRVIEWER_API void postClose();
181
185
187 MRVIEWER_API void set_root( SceneRootObject& newRoot );
188
190 MRVIEWER_API void clearScene();
191
195
200 MRVIEWER_API Viewport& viewport( ViewportId viewportId = {} );
201 MRVIEWER_API const Viewport& viewport( ViewportId viewportId = {} ) const;
202
213 MRVIEWER_API ViewportId append_viewport( const ViewportRectangle & viewportRect, bool append_empty = false );
214
217 MRVIEWER_API Box2f getViewportsBounds() const;
218
223 MRVIEWER_API bool erase_viewport( const size_t index );
224 MRVIEWER_API bool erase_viewport( ViewportId viewport_id );
225
228 MRVIEWER_API int viewport_index( ViewportId viewport_id ) const;
229
232 MRVIEWER_API ViewportId getHoveredViewportId() const;
233
236
238 MRVIEWER_API void select_hovered_viewport();
239
243 MRVIEWER_API void fitDataViewport( MR::ViewportMask vpList = MR::ViewportMask::all(), float fill = 0.6f, bool snapView = true );
244
248 MRVIEWER_API void fitBoxViewport( const Box3f& box, MR::ViewportMask vpList = MR::ViewportMask::all(), float fill = 0.6f, bool snapView = true );
249
253 MRVIEWER_API void preciseFitDataViewport( MR::ViewportMask vpList, const FitDataParams& param );
254
255 MRVIEWER_API size_t getTotalFrames() const;
256 MRVIEWER_API size_t getSwappedFrames() const;
257 MRVIEWER_API size_t getFPS() const;
258 MRVIEWER_API double getPrevFrameDrawTimeMillisec() const;
259
261 MRVIEWER_API size_t getStaticGLBufferSize() const;
262
264 bool swapOnLastPostEventsRedraw{ true };
266 int forceRedrawMinimumIncrementAfterEvents{ 4 };
267
270 MRVIEWER_API void incrementForceRedrawFrames( int i = 1, bool swapOnLastOnly = false );
271
273 MRVIEWER_API void forceSwapOnFrame( int i = 0 );
274
276 MRVIEWER_API bool isCurrentFrameSwapping() const;
277
279 enum class EventType
280 {
281 MouseDown,
282 MouseUp,
283 MouseMove,
284 MouseScroll,
285 KeyDown,
286 KeyUp,
287 KeyRepeat,
288 CharPressed,
289 Count
290 };
292 MRVIEWER_API size_t getEventsCount( EventType type )const;
293
296 {
298 PointArraySize,
299 LineArraySize,
300 TriangleArraySize,
301 PointElementsNum,
302 LineElementsNum,
303 TriangleElementsNum,
304 Count
305 };
307 MRVIEWER_API size_t getLastFrameGLPrimitivesCount( GLPrimitivesType type ) const;
309 MRVIEWER_API void incrementThisFrameGLPrimitivesCount( GLPrimitivesType type, size_t num );
310
311
313 ViewportMask getPresentViewports() const { return presentViewportsMask_; }
314
316 MRVIEWER_API void resetAllCounters();
317
323 MRVIEWER_API Image captureSceneScreenShot( const Vector2i& resolution = Vector2i(), bool transparentBg = false );
324
331 MRVIEWER_API void captureUIScreenShot( std::function<void( const Image& )> callback,
332 const Vector2i& pos = Vector2i(), const Vector2i& size = Vector2i() );
333
335 MRVIEWER_API bool isAlphaSortAvailable() const;
338 MRVIEWER_API bool enableAlphaSort( bool on );
340 bool isAlphaSortEnabled() const { return alphaSortEnabled_; }
341
343 MRVIEWER_API int getDepthPeelNumPasses() const;
345 MRVIEWER_API void setDepthPeelNumPasses( int numPasses );
347 MRVIEWER_API bool isDepthPeelingEnabled() const;
348
350 MRVIEWER_API bool isSceneTextureBound() const;
353 MRVIEWER_API void bindSceneTexture( bool bind );
355 MRVIEWER_API bool isSceneTextureEnabled() const;
356
359 MRVIEWER_API int getMSAA() const;
363 MRVIEWER_API void requestChangeMSAA( int newMSAA );
365 MRVIEWER_API int getRequestedMSAA() const;
366
369 MRVIEWER_API void setViewportSettingsManager( std::unique_ptr<IViewerSettingsManager> mng );
370 MRVIEWER_API const std::unique_ptr<IViewerSettingsManager>& getViewerSettingsManager() const { return settingsMng_; }
371
374 MRVIEWER_API PointInAllSpaces getPixelPointInfo( const Vector3f& screenPoint ) const;
377
383 MRVIEWER_API Vector3f screenToViewport( const Vector3f& screenPoint, ViewportId id ) const;
389 MRVIEWER_API Vector3f viewportToScreen( const Vector3f& viewportPoint, ViewportId id ) const;
390
392 MRVIEWER_API std::vector<std::reference_wrapper<Viewport>> getViewports( ViewportMask mask = ViewportMask::any() );
393
395 MRVIEWER_API void enableGlobalHistory( bool on );
397 bool isGlobalHistoryEnabled() const { return bool( globalHistoryStore_ ); };
400 MRVIEWER_API void appendHistoryAction( const std::shared_ptr<HistoryAction>& action );
403 MRVIEWER_API bool globalHistoryUndo();
406 MRVIEWER_API bool globalHistoryRedo();
407
410 MRVIEWER_API HistoryStore* getGlobalHistoryStore() const { return globalHistoryStore_.get(); }
411
413 const std::shared_ptr<SpaceMouse::Handler>& getSpaceMouseHandler() const { return spaceMouseHandler_; }
414
416 MRVIEWER_API void onSceneSaved( const std::filesystem::path& savePath, bool storeInRecent = true );
417
419 MRVIEWER_API const std::shared_ptr<ImGuiMenu>& getMenuPlugin() const;
420 MRVIEWER_API void setMenuPlugin( std::shared_ptr<ImGuiMenu> menu );
421
423 MRVIEWER_API std::shared_ptr<RibbonMenu> getRibbonMenu() const;
424
426 template <typename T>
427 std::shared_ptr<T> getMenuPluginAs() const { return std::dynamic_pointer_cast<T>( getMenuPlugin() ); }
428
430 MRVIEWER_API void stopEventLoop();
432 bool getStopEventLoopFlag() const { return stopEventLoop_; }
433
437
441 bool isGLInitialized() const { return glInitialized_; }
442
444 MRVIEWER_API void makeTitleFromSceneRootPath();
445
447 bool hasScaledFramebuffer() const { return hasScaledFramebuffer_; }
448
449public:
453 GLFWwindow* window;
454
457 std::function<void( Viewer* viewer )> resetSettingsFunction;
458
460 std::vector<Viewport> viewport_list;
462
464 std::vector<ViewerPlugin*> plugins;
465
466 float pixelRatio{ 1.0f };
468 Vector2i windowSavePos;
469 Vector2i windowSaveSize;
470 Vector2i windowOldPos;
471 bool windowMaximized{ false };
472
474 bool isAnimating{ false };
476 int animationMaxFps{ 30 };
479 float scrollForce{ };
481 uint16_t glPickRadius{ };
483 bool experimentalFeatures{ };
485 std::vector<std::string> commandArgs;
486
487 std::shared_ptr<ObjectMesh> basisAxes;
488 std::unique_ptr<CornerControllerObject> basisViewController;
489 std::unique_ptr<ViewportGlobalBasis> globalBasis;
490 std::shared_ptr<ObjectMesh> rotationSphere;
492 std::shared_ptr<ObjectMesh> clippingPlaneObject;
493
495 std::shared_ptr<ViewerTitle> windowTitle;
496
498 ViewerSignals & signals() { return *signals_; }
499
502 MRVIEWER_API void emplaceEvent( std::string name, ViewerEventCallback cb, bool skipable = false );
504 MRVIEWER_API void popEventByName( const std::string& name );
505
506 MRVIEWER_API void postEmptyEvent();
507
508 [[nodiscard]] const TouchpadController &touchpadController() const { return *touchpadController_; }
509 [[nodiscard]] TouchpadController& touchpadController() { return *touchpadController_; }
510
511 [[nodiscard]] const SpaceMouse::Controller &spaceMouseController() const { return *spaceMouseController_; }
512 [[nodiscard]] SpaceMouse::Controller& spaceMouseController() { return *spaceMouseController_; }
513
514 [[nodiscard]] const MouseController &mouseController() const { return *mouseController_; }
515 [[nodiscard]] MouseController &mouseController() { return *mouseController_; }
516
518 [[nodiscard]] const RecentFilesStore &recentFilesStore() const { return *recentFilesStore_; }
519 [[nodiscard]] RecentFilesStore &recentFilesStore() { return *recentFilesStore_; }
520
522 [[nodiscard]] bool getSortDroppedFiles() const { return sortDroppedFiles_; }
523
525 void setSortDroppedFiles( bool value ) { sortDroppedFiles_ = value; }
526
528 MRVIEWER_API void drawUiRenderObjects();
529
532 MRVIEWER_API bool isMultiViewportAvailable();
533private:
534 Viewer();
535 ~Viewer();
536
538 int launchInit_( const LaunchParams& params );
539
541 bool setupWindow_( const LaunchParams& params );
542
544 bool checkOpenGL_(const LaunchParams& params );
545
547 void init_();
548
550 void initPlugins_();
551
553 void shutdownPlugins_();
554
555#ifdef __EMSCRIPTEN__
556 void mainLoopFunc_();
557 static void emsMainInfiniteLoop();
558#endif
560 bool draw_( bool force );
561
563 int forceRedrawFrames_{ 0 };
565 int forceRedrawFramesWithoutSwap_{ 0 };
566
567 std::unique_ptr<ViewerEventQueue> eventQueue_;
568
570 std::shared_ptr<ImGuiMenu> menuPlugin_;
571
572 std::unique_ptr<TouchpadController> touchpadController_;
573 std::unique_ptr<SpaceMouse::Controller> spaceMouseController_;
574 std::unique_ptr<TouchesController> touchesController_;
575 std::unique_ptr<MouseController> mouseController_;
576 std::unique_ptr<IDragDropHandler> dragDropAdvancedHandler_;
577
578 std::unique_ptr<RecentFilesStore> recentFilesStore_;
579 std::unique_ptr<FrameCounter> frameCounter_;
580
581 mutable struct EventsCounter
582 {
583 std::array<size_t, size_t( EventType::Count )> counter{};
584 void reset();
585 } eventsCounter_;
586
587 mutable struct GLPrimitivesCounter
588 {
589 std::array<size_t, size_t( GLPrimitivesType::Count )> counter{};
590 void reset();
591 } glPrimitivesCounter_;
592
593
595 bool tryCreateWindow_( bool fullscreen, int& width, int& height, const std::string& name, int major, int minor );
596
597 bool needRedraw_() const;
598 void resetRedraw_();
599
600 void initGlobalBasisAxesObject_();
601 void initBasisAxesObject_();
602 void initBasisViewControllerObject_();
603 void initClippingPlaneObject_();
604 void initRotationCenterObject_();
605
607 void initSpaceMouseHandler_();
608
610 void updatePixelRatio_();
611
615 int getRequiredMSAA_( bool sceneTextureOn, bool forSceneTexture ) const;
616
617 bool stopEventLoop_{ false };
618
619 bool isLaunched_{ false };
621 bool focusRedrawReady_{ false };
622
623 std::unique_ptr<SceneTextureGL> sceneTexture_;
624 std::unique_ptr<AlphaSortGL> alphaSorter_;
625 std::unique_ptr<DepthPeelingGL> depthPeeler_;
626
627 bool alphaSortEnabled_{ false };
628
629 bool glInitialized_{ false };
630
631 bool isInDraw_{ false };
632 bool dirtyScene_{ false };
633
634 bool hasScaledFramebuffer_{ false };
635
636 bool sortDroppedFiles_{ true };
637
638 LaunchParams launchParams_;
639
640 ViewportId getFirstAvailableViewportId_() const;
641 ViewportMask presentViewportsMask_;
642
643 std::unique_ptr<IViewerSettingsManager> settingsMng_;
644
645 std::unique_ptr<HistoryStore> globalHistoryStore_;
646
647 std::shared_ptr<SpaceMouse::Handler> spaceMouseHandler_;
648
649 struct Connections;
650 std::unique_ptr<Connections> connections_;
651 std::unique_ptr<ViewerSignals> signals_;
652
653 friend MRVIEWER_API Viewer& getViewerInstance();
654};
655
657MRVIEWER_API int launchDefaultViewer( const Viewer::LaunchParams& params, const ViewerSetup& setup );
658
659}
class for easier rendering in framebuffer texture
Definition MRRenderGLHelpers.h:217
This class stores history stack for undo/redo.
Definition MRHistoryStore.h:16
Definition MRMouseController.h:24
Definition MRRecentFilesStore.h:20
Object that is parent of all scene.
Definition MRSceneRoot.h:14
this class stores maps spacemouse event - program action
Definition MRSpaceMouseController.h:11
Definition MRTouchpadController.h:35
Definition MRSetupViewer.h:16
GLFW-based mesh viewer.
Definition MRViewer.h:69
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:49
MRVIEWER_API bool isDepthPeelingEnabled() const
Returns true if depth peeling is enabled, false otherwise.
bool hasScaledFramebuffer() const
returns true if the system framebuffer is scaled (valid for macOS and Wayland)
Definition MRViewer.h:447
MRVIEWER_API bool saveToFile(const std::filesystem::path &mesh_file_name)
Save first selected objects to file.
MRVIEWER_API bool keyUp(int key, int modifier)
WindowMode
Definition MRViewer.h:39
bool render3dSceneInTexture
Definition MRViewer.h:48
MouseMode
Standard mouse functions for camera control.
Definition MRMouse.h:22
bool console
If !startEventLoop close immediately after start, otherwise close on window close,...
Definition MRViewer.h:55
bool developerFeatures
If not set renders scene each frame.
Definition MRViewer.h:49
bool windowShouldClose()
MRVIEWER_API void fitDataViewport(MR::ViewportMask vpList=MR::ViewportMask::all(), float fill=0.6f, bool snapView=true)
MRVIEWER_API bool isAlphaSortAvailable() const
Returns true if can enable alpha sort.
MRVIEWER_API ViewportId getHoveredViewportId() const
char ** argv
Pass argc.
Definition MRViewer.h:57
MRVIEWER_API void setViewportSettingsManager(std::unique_ptr< IViewerSettingsManager > mng)
MouseButton
Definition MRMouse.h:12
MRVIEWER_API void forceSwapOnFrame(int i=0)
Forces redraw no later than the specified number of frames.
bool startEventLoop
if true - resets config file on start of the application
Definition MRViewer.h:53
bool fullscreen
Definition MRViewer.h:35
MRVIEWER_API bool keyRepeat(int key, int modifier)
MRVIEWER_API std::vector< std::reference_wrapper< Viewport > > getViewports(ViewportMask mask=ViewportMask::any())
Returns viewports satisfying given mask.
const MouseController & mouseController() const
Definition MRViewer.h:514
MRVIEWER_API void appendHistoryAction(const std::shared_ptr< HistoryAction > &action)
std::shared_ptr< ViewerTitle > windowTitle
class that updates viewer title
Definition MRViewer.h:495
MRVIEWER_API PointInAllSpaces getMousePointInfo() const
Finds point under mouse in all spaces and under mouse viewport id.
MRVIEWER_API const std::shared_ptr< ImGuiMenu > & getMenuPlugin() const
Get/Set menu plugin (which is separated from other plugins to be inited first before splash window st...
MRVIEWER_API HistoryStore * getGlobalHistoryStore() const
Definition MRViewer.h:410
int animationMaxFps
if true - calls render without system events
Definition MRViewer.h:61
MRVIEWER_API void resize(int w, int h)
OpenGL context resize.
MRVIEWER_API bool mouseClick(MouseButton button, int modifier)
int argc
If true - shows developers console.
Definition MRViewer.h:56
std::vector< ViewerPlugin * > plugins
List of registered plugins.
Definition MRViewer.h:464
static MRVIEWER_API void parseLaunchParams(LaunchParams &params)
Accumulate launch params from cmd args.
MRVIEWER_API Box2f getViewportsBounds() const
Vector2i windowSaveSize
pos to save
Definition MRViewer.h:469
EventType
types of counted events
Definition MRViewer.h:280
const SpaceMouse::Controller & spaceMouseController() const
Definition MRViewer.h:511
ViewportMask getPresentViewports() const
Returns mask of present viewports.
Definition MRViewer.h:313
MRVIEWER_API bool touchpadSwipeGestureEnd()
MRVIEWER_API bool erase_viewport(ViewportId viewport_id)
MRVIEWER_API void fitBoxViewport(const Box3f &box, MR::ViewportMask vpList=MR::ViewportMask::all(), float fill=0.6f, bool snapView=true)
const TouchpadController & touchpadController() const
Definition MRViewer.h:508
MRVIEWER_API size_t getEventsCount(EventType type) const
Returns number of events of given type.
MRVIEWER_API Viewer & getViewerInstance()
returns global instance of Viewer class
std::shared_ptr< SplashWindow > splashWindow
unload all extended libraries right before program exit
Definition MRViewer.h:64
std::shared_ptr< T > getMenuPluginAs() const
Get the menu plugin casted in given type.
Definition MRViewer.h:427
bool isGLInitialized() const
Definition MRViewer.h:441
angle
Definition MRObjectDimensionsEnum.h:16
MRVIEWER_API void onSceneSaved(const std::filesystem::path &savePath, bool storeInRecent=true)
This method is called after successful scene saving to update scene root, window title and undo.
MRVIEWER_API bool touchStart(int id, int x, int y)
Touch callbacks (now used in EMSCRIPTEN build only)
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:490
MRVIEWER_API void clearFramebuffers()
Cleans framebuffers for all viewports (sets its background)
Vector2i windowOldPos
size to save
Definition MRViewer.h:470
std::vector< std::string > commandArgs
command arguments, each parsed arg should be erased from here not to affect other parsers
Definition MRViewer.h:485
MRVIEWER_API Vector3f viewportToScreen(const Vector3f &viewportPoint, ViewportId id) const
MRVIEWER_API Image captureSceneScreenShot(const Vector2i &resolution=Vector2i(), bool transparentBg=false)
MRVIEWER_API bool isCurrentFrameSwapping() const
Returns true if current frame will be shown on display.
MRVIEWER_API double getPrevFrameDrawTimeMillisec() const
MRVIEWER_API void enableGlobalHistory(bool on)
Enables or disables global history (clears it on disable)
MRVIEWER_API int launch(const LaunchParams &params)
Launch viewer with given params.
MRVIEWER_API size_t getSwappedFrames() const
MRVIEWER_API void popEventByName(const std::string &name)
pop all events from the queue while they have this name
const LaunchParams & getLaunchParams() const
get full parameters with witch viewer was launched
Definition MRViewer.h:89
std::function< void(Viewer *viewer)> resetSettingsFunction
Definition MRViewer.h:457
MRVIEWER_API bool touchMove(int id, int x, int y)
MRVIEWER_API bool erase_viewport(const size_t index)
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
bool unloadPluginsAtEnd
max fps if animating
Definition MRViewer.h:62
MRVIEWER_API PointInAllSpaces getPixelPointInfo(const Vector3f &screenPoint) const
Finds point in all spaces from screen space pixel point.
bool isAlphaSortEnabled() const
Returns true if alpha sort is enabled, false otherwise.
Definition MRViewer.h:340
MRVIEWER_API void emplaceEvent(std::string name, ViewerEventCallback cb, bool skipable=false)
MRVIEWER_API int getMSAA() const
MRVIEWER_API bool spaceMouseUp(int key)
MRVIEWER_API void incrementForceRedrawFrames(int i=1, bool swapOnLastOnly=false)
bool close
If false - does not start event loop.
Definition MRViewer.h:54
size_t selected_viewport_index
Definition MRViewer.h:461
bool multiViewport
If set shows some developer features useful for debugging.
Definition MRViewer.h:50
MRVIEWER_API void postSetMaximized(bool maximized)
external set position due to user interaction
MRVIEWER_API int getRequestedMSAA() const
Returns MSAA level that have been requested (might be different from actual MSAA using,...
static Viewer * instance()
provides non const access to viewer
Definition MRViewer.h:92
MRVIEWER_API bool mouseUp(MouseButton button, int modifier)
MRVIEWER_API bool enableAlphaSort(bool on)
PluginType * getPluginInstance()
Definition MRViewer.h:99
MRVIEWER_API bool mouseScroll(float delta_y)
bool isLaunched() const
Definition MRViewer.h:86
bool showMRVersionInTitle
Pass argv.
Definition MRViewer.h:59
MRVIEWER_API void postEmptyEvent()
static const Viewer * constInstance()
provide const access to viewer
Definition MRViewer.h:95
std::unique_ptr< ViewportGlobalBasis > globalBasis
Definition MRViewer.h:489
MRVIEWER_API size_t getFPS() const
MRVIEWER_API Vector3f screenToViewport(const Vector3f &screenPoint, ViewportId id) const
MRVIEWER_API bool dragEnd(MouseButton button, int modifier)
std::shared_ptr< ObjectMesh > clippingPlaneObject
Stores clipping plane mesh.
Definition MRViewer.h:492
MRVIEWER_API const Viewport & viewport(ViewportId viewportId={}) const
static const Viewer & constInstanceRef()
Definition MRViewer.h:96
MRVIEWER_API bool touchpadZoomGestureEnd()
void setSortDroppedFiles(bool value)
sets whether to sort the filenames received from Drag&Drop in lexicographical order before adding the...
Definition MRViewer.h:525
MRVIEWER_API bool touchpadRotateGestureBegin()
Touchpad gesture callbacks.
SpaceMouse::Controller & spaceMouseController()
Definition MRViewer.h:512
MRVIEWER_API bool mouseDown(MouseButton button, int modifier)
RecentFilesStore & recentFilesStore()
Definition MRViewer.h:519
bool enableTransparentBackground
Definition MRViewer.h:46
MRVIEWER_API void select_hovered_viewport()
Change selected_core_index to the viewport containing the mouse.
MRVIEWER_API ViewportId append_viewport(const ViewportRectangle &viewportRect, bool append_empty=false)
int height
Definition MRViewer.h:37
MRVIEWER_API bool touchpadRotateGestureUpdate(float angle)
MRVIEWER_API bool spaceMouseRepeat(int key)
MRVIEWER_API void incrementThisFrameGLPrimitivesCount(GLPrimitivesType type, size_t num)
Increment number of gl primitives drawed in this frame.
MRVIEWER_API void postRescale(float x, float y)
external focus handler due to user interaction
static Viewer & instanceRef()
Definition MRViewer.h:93
std::shared_ptr< ObjectMesh > basisAxes
Definition MRViewer.h:487
bool resetConfig
Window name.
Definition MRViewer.h:52
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)
called when close signal received
MRVIEWER_API void stopEventLoop()
sets stop event loop flag (this flag is glfwShouldWindowClose equivalent)
MRVIEWER_API void launchEventLoop()
Starts event loop.
MRVIEWER_API void drawScene(FramebufferData *framebuffer)
MRVIEWER_API bool isMultiViewportAvailable()
MRVIEWER_API void captureUIScreenShot(std::function< void(const Image &)> callback, const Vector2i &pos=Vector2i(), const Vector2i &size=Vector2i())
MRVIEWER_API void launchShut()
Terminate window.
MRVIEWER_API bool globalHistoryUndo()
MRVIEWER_API std::shared_ptr< RibbonMenu > getRibbonMenu() const
get menu plugin casted in RibbonMenu
MRVIEWER_API const std::unique_ptr< IViewerSettingsManager > & getViewerSettingsManager() const
Definition MRViewer.h:370
MRVIEWER_API void preciseFitDataViewport(MR::ViewportMask vpList=MR::ViewportMask::all())
Vector2i framebufferSize
Definition MRViewer.h:467
ViewerSignals & signals()
return the structure with all viewer's signals
Definition MRViewer.h:498
MRVIEWER_API int launchDefaultViewer(const Viewer::LaunchParams &params, const ViewerSetup &setup)
starts default viewer with given params and setup
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:522
MRVIEWER_API void setupScene()
Setup viewports views.
MRVIEWER_API void setMenuPlugin(std::shared_ptr< ImGuiMenu > menu)
MRVIEWER_API Viewport & viewport(ViewportId viewportId={})
Multi-viewport methods ///.
MRVIEWER_API size_t getStaticGLBufferSize() const
Returns memory amount used by shared GL memory buffer.
GLPrimitivesType
types of gl primitives counters
Definition MRViewer.h:296
Vector2i windowSavePos
Definition MRViewer.h:468
MRVIEWER_API size_t getLastFrameGLPrimitivesCount(GLPrimitivesType type) const
Returns number of events of given type.
MRVIEWER_API bool dragStart(MouseButton button, int modifier)
bool preferOpenGL3
Definition MRViewer.h:47
MRVIEWER_API ViewportId getHoveredViewportIdOrInvalid() const
Same, but returns an invalid ID if no viewport is hovered, instead of returning the last selected vie...
MRVIEWER_API void drawFull(bool dirtyScene)
Draw 3d scene with UI.
std::unique_ptr< CornerControllerObject > basisViewController
Definition MRViewer.h:488
MRVIEWER_API bool loadFiles(const std::vector< std::filesystem::path > &filesList)
int width
if true starts fullscreen
Definition MRViewer.h:36
MRVIEWER_API bool loadFiles(const std::vector< std::filesystem::path > &filesList, const FileLoadOptions &options)
MRVIEWER_API void requestChangeMSAA(int newMSAA)
GLFWwindow * window
Member variables ///.
Definition MRViewer.h:453
enum MR::LaunchParams::WindowMode HideInit
MRVIEWER_API bool drag(int mouse_x, int mouse_y)
std::string name
If set allows to move the imgui (tool) windows outside the main () window. (unavailable for Apple,...
Definition MRViewer.h:51
MRVIEWER_API void postSetIconified(bool iconified)
external set maximized due to user interaction
MRVIEWER_API bool globalHistoryRedo()
MRVIEWER_API void makeTitleFromSceneRootPath()
update the title of the main window and, if any scene was opened, show its filename
MRVIEWER_API size_t getTotalFrames() const
MRVIEWER_API void postFocus(bool focused)
external set iconified due to user interaction
void setSceneDirty()
Call this function to force redraw scene into scene texture.
Definition MRViewer.h:167
MRVIEWER_API void resetAllCounters()
Restes frames counter and events counter.
MRVIEWER_API bool isSupportedFormat(const std::filesystem::path &file_name)
MRVIEWER_API void draw(bool force=false)
Draw everything.
MRVIEWER_API int getDepthPeelNumPasses() const
Returns number of passes performed by depth peeler.
MRVIEWER_API int viewport_index(ViewportId viewport_id) const
MRVIEWER_API bool touchpadRotateGestureEnd()
MouseController & mouseController()
Definition MRViewer.h:515
MRVIEWER_API bool isSceneTextureBound() const
Returns if scene texture is now bound.
MRVIEWER_API bool touchEnd(int id, int x, int y)
const RecentFilesStore & recentFilesStore() const
Store of recently opened files.
Definition MRViewer.h:518
TouchpadController & touchpadController()
Definition MRViewer.h:509
MRVIEWER_API bool interruptWindowClose()
This function is called when window should close, if return value is true, window will stay open.
MRVIEWER_API bool spaceMouseMove(const Vector3f &translate, const Vector3f &rotate)
MRVIEWER_API void preciseFitDataViewport(MR::ViewportMask vpList, const FitDataParams &param)
MRVIEWER_API void setDepthPeelNumPasses(int numPasses)
Sets desired number of passes to depth peeler.
bool isGlobalHistoryEnabled() const
Return true if global history is enabled, false otherwise.
Definition MRViewer.h:397
MRVIEWER_API void postResize(int w, int h)
explicitly set framebuffer size
MRVIEWER_API bool keyPressed(unsigned int unicode_key, int modifier)
Callbacks.
MRVIEWER_API bool isSceneTextureEnabled() const
Returns true if 3d scene is rendering in scene texture instead of main framebuffer.
MRVIEWER_API void postSetPosition(int xPos, int yPos)
external resize due to user interaction
MRVIEWER_API void clearScene()
removes all objects from scene
std::vector< Viewport > viewport_list
Stores all the viewing options.
Definition MRViewer.h:460
bool isAnimating
if true - print version info in window title
Definition MRViewer.h:60
const std::shared_ptr< SpaceMouse::Handler > & getSpaceMouseHandler() const
Return spacemouse handler.
Definition MRViewer.h:413
MRVIEWER_API void postClose()
external rescale due to user interaction
bool getStopEventLoopFlag() const
get stop event loop flag (this flag is glfwShouldWindowClose equivalent)
Definition MRViewer.h:432
@ HideInit
Show window immediately.
Definition MRViewer.h:41
@ NoWindow
Launches in "Hide" mode if OpenGL is present and "NoWindow" if it is not.
Definition MRViewer.h:44
@ TryHidden
Don't show window.
Definition MRViewer.h:43
@ Hide
Show window after init.
Definition MRViewer.h:42
@ Show
Definition MRViewer.h:40
only for bindings generation
Definition MRCameraOrientationPlugin.h:8
Definition MRFileLoadOptions.h:14
Definition MRFitData.h:32
Definition MRImage.h:19
This struct contains rules for viewer launch.
Definition MRViewer.h:34
Definition MRPointInAllSpaces.h:16
Definition MRViewerSignals.h:13