MeshLib C++ Docs
Loading...
Searching...
No Matches

GLFW-based mesh viewer. More...

#include <MRViewer/MRViewer.h>

Public Types

enum class  EventType {
  EventType::MouseDown , EventType::MouseUp , EventType::MouseMove , EventType::MouseScroll ,
  EventType::KeyDown , EventType::KeyUp , EventType::KeyRepeat , EventType::CharPressed ,
  EventType::Count
}
 types of counted events More...
enum class  GLPrimitivesType {
  GLPrimitivesType::PointArraySize , GLPrimitivesType::LineArraySize , GLPrimitivesType::TriangleArraySize , GLPrimitivesType::PointElementsNum ,
  GLPrimitivesType::LineElementsNum , GLPrimitivesType::TriangleElementsNum , GLPrimitivesType::Count
}
 types of gl primitives counters More...
using MouseButton = MR::MouseButton
using MouseMode = MR::MouseMode
using LaunchParams = MR::LaunchParams
using PointInAllSpaces = MR::PointInAllSpaces

Public Member Functions

int launch (const LaunchParams &params)
 Launch viewer with given params.
void launchEventLoop ()
 Starts event loop.
void launchShut ()
 Terminate window.
bool isLaunched () const
const LaunchParamsgetLaunchParams () const
 get full parameters with witch viewer was launched
template<typename PluginType>
PluginType * getPluginInstance ()
bool isSupportedFormat (const std::filesystem::path &file_name)
bool loadFiles (const std::vector< std::filesystem::path > &filesList, const FileLoadOptions &options)
bool loadFiles (const std::vector< std::filesystem::path > &filesList)
bool saveToFile (const std::filesystem::path &mesh_file_name)
 Save first selected objects to file.
bool keyPressed (unsigned int unicode_key, int modifier)
 Callbacks.
bool keyDown (int key, int modifier)
bool keyUp (int key, int modifier)
bool keyRepeat (int key, int modifier)
bool mouseDown (MouseButton button, int modifier)
bool mouseUp (MouseButton button, int modifier)
bool mouseMove (int mouse_x, int mouse_y)
bool mouseScroll (float delta_y)
bool mouseClick (MouseButton button, int modifier)
bool dragStart (MouseButton button, int modifier)
bool dragEnd (MouseButton button, int modifier)
bool drag (int mouse_x, int mouse_y)
bool spaceMouseMove (const Vector3f &translate, const Vector3f &rotate)
bool spaceMouseDown (int key)
bool spaceMouseUp (int key)
bool spaceMouseRepeat (int key)
bool dragDrop (const std::vector< std::filesystem::path > &paths)
bool touchStart (int id, int x, int y)
 Touch callbacks (now used in EMSCRIPTEN build only)
bool touchMove (int id, int x, int y)
bool touchEnd (int id, int x, int y)
bool touchpadRotateGestureBegin ()
 Touchpad gesture callbacks.
bool touchpadRotateGestureUpdate (float angle)
bool touchpadRotateGestureEnd ()
bool touchpadSwipeGestureBegin ()
bool touchpadSwipeGestureUpdate (float dx, float dy, bool kinetic)
bool touchpadSwipeGestureEnd ()
bool touchpadZoomGestureBegin ()
bool touchpadZoomGestureUpdate (float scale, bool kinetic)
bool touchpadZoomGestureEnd ()
bool interruptWindowClose ()
 This function is called when window should close, if return value is true, window will stay open.
void draw (bool force=false)
 Draw everything.
void drawFull (bool dirtyScene)
 Draw 3d scene with UI.
void drawScene (FramebufferData *framebuffer)
void setSceneDirty ()
 Call this function to force redraw scene into scene texture.
void setupScene ()
 Setup viewports views.
void clearFramebuffers ()
 Cleans framebuffers for all viewports (sets its background)
void resize (int w, int h)
 OpenGL context resize.
void postResize (int w, int h)
 explicitly set framebuffer size
void postSetPosition (int xPos, int yPos)
 external resize due to user interaction
void postSetMaximized (bool maximized)
 external set position due to user interaction
void postSetIconified (bool iconified)
 external set maximized due to user interaction
void postFocus (bool focused)
 external set iconified due to user interaction
void postRescale (float x, float y)
 external focus handler due to user interaction
void postClose ()
 external rescale due to user interaction
void set_root (SceneRootObject &newRoot)
 called when close signal received
void clearScene ()
 removes all objects from scene
Viewportviewport (ViewportId viewportId={})
 Multi-viewport methods ///.
const Viewportviewport (ViewportId viewportId={}) const
ViewportId append_viewport (const ViewportRectangle &viewportRect, bool append_empty=false)
Box2f getViewportsBounds () const
bool erase_viewport (const size_t index)
bool erase_viewport (ViewportId viewport_id)
int viewport_index (ViewportId viewport_id) const
ViewportId getHoveredViewportId () const
ViewportId getHoveredViewportIdOrInvalid () const
 Same, but returns an invalid ID if no viewport is hovered, instead of returning the last selected viewport.
void select_hovered_viewport ()
 Change selected_core_index to the viewport containing the mouse.
void fitDataViewport (MR::ViewportMask vpList=MR::ViewportMask::all(), float fill=0.6f, bool snapView=true)
void fitBoxViewport (const Box3f &box, MR::ViewportMask vpList=MR::ViewportMask::all(), float fill=0.6f, bool snapView=true)
void preciseFitDataViewport (MR::ViewportMask vpList=MR::ViewportMask::all())
void preciseFitDataViewport (MR::ViewportMask vpList, const FitDataParams &param)
size_t getTotalFrames () const
size_t getSwappedFrames () const
size_t getFPS () const
double getPrevFrameDrawTimeMillisec () const
size_t getStaticGLBufferSize () const
 Returns memory amount used by shared GL memory buffer.
void incrementForceRedrawFrames (int i=1, bool swapOnLastOnly=false)
void forceSwapOnFrame (int i=0)
 Forces redraw no later than the specified number of frames.
bool isCurrentFrameSwapping () const
 Returns true if current frame will be shown on display.
size_t getEventsCount (EventType type) const
 Returns number of events of given type.
size_t getLastFrameGLPrimitivesCount (GLPrimitivesType type) const
 Returns number of events of given type.
void incrementThisFrameGLPrimitivesCount (GLPrimitivesType type, size_t num)
 Increment number of gl primitives drawed in this frame.
ViewportMask getPresentViewports () const
 Returns mask of present viewports.
void resetAllCounters ()
 Restes frames counter and events counter.
Image captureSceneScreenShot (const Vector2i &resolution=Vector2i(), bool transparentBg=false)
void captureUIScreenShot (std::function< void(const Image &)> callback, const Vector2i &pos=Vector2i(), const Vector2i &size=Vector2i())
bool isAlphaSortAvailable () const
 Returns true if can enable alpha sort.
bool enableAlphaSort (bool on)
bool isAlphaSortEnabled () const
 Returns true if alpha sort is enabled, false otherwise.
int getDepthPeelNumPasses () const
 Returns number of passes performed by depth peeler.
void setDepthPeelNumPasses (int numPasses)
 Sets desired number of passes to depth peeler.
bool isDepthPeelingEnabled () const
 Returns true if depth peeling is enabled, false otherwise.
bool isSceneTextureBound () const
 Returns if scene texture is now bound.
void bindSceneTexture (bool bind)
bool isSceneTextureEnabled () const
 Returns true if 3d scene is rendering in scene texture instead of main framebuffer.
int getMSAA () const
void requestChangeMSAA (int newMSAA)
int getRequestedMSAA () const
 Returns MSAA level that have been requested (might be different from actual MSAA using, because of GPU limitations or need to restart app)
void setViewportSettingsManager (std::unique_ptr< IViewerSettingsManager > mng)
const std::unique_ptr< IViewerSettingsManager > & getViewerSettingsManager () const
PointInAllSpaces getPixelPointInfo (const Vector3f &screenPoint) const
 Finds point in all spaces from screen space pixel point.
PointInAllSpaces getMousePointInfo () const
 Finds point under mouse in all spaces and under mouse viewport id.
Vector3f screenToViewport (const Vector3f &screenPoint, ViewportId id) const
Vector3f viewportToScreen (const Vector3f &viewportPoint, ViewportId id) const
std::vector< std::reference_wrapper< Viewport > > getViewports (ViewportMask mask=ViewportMask::any())
 Returns viewports satisfying given mask.
void enableGlobalHistory (bool on)
 Enables or disables global history (clears it on disable)
bool isGlobalHistoryEnabled () const
 Return true if global history is enabled, false otherwise.
void appendHistoryAction (const std::shared_ptr< HistoryAction > &action)
bool globalHistoryUndo ()
bool globalHistoryRedo ()
HistoryStoregetGlobalHistoryStore () const
const std::shared_ptr< SpaceMouse::Handler > & getSpaceMouseHandler () const
 Return spacemouse handler.
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.
const std::shared_ptr< ImGuiMenu > & getMenuPlugin () const
 Get/Set menu plugin (which is separated from other plugins to be inited first before splash window starts)
void setMenuPlugin (std::shared_ptr< ImGuiMenu > menu)
std::shared_ptr< RibbonMenugetRibbonMenu () const
 get menu plugin casted in RibbonMenu
template<typename T>
std::shared_ptr< T > getMenuPluginAs () const
 Get the menu plugin casted in given type.
void stopEventLoop ()
 sets stop event loop flag (this flag is glfwShouldWindowClose equivalent)
bool getStopEventLoopFlag () const
 get stop event loop flag (this flag is glfwShouldWindowClose equivalent)
bool windowShouldClose ()
bool isGLInitialized () const
void makeTitleFromSceneRootPath ()
 update the title of the main window and, if any scene was opened, show its filename
bool hasScaledFramebuffer () const
 returns true if the system framebuffer is scaled (valid for macOS and Wayland)
ViewerSignalssignals ()
 return the structure with all viewer's signals
void emplaceEvent (std::string name, ViewerEventCallback cb, bool skipable=false)
void popEventByName (const std::string &name)
 pop all events from the queue while they have this name
void postEmptyEvent ()
const TouchpadControllertouchpadController () const
TouchpadControllertouchpadController ()
const SpaceMouse::ControllerspaceMouseController () const
SpaceMouse::ControllerspaceMouseController ()
const MouseControllermouseController () const
MouseControllermouseController ()
const RecentFilesStorerecentFilesStore () const
 Store of recently opened files.
RecentFilesStorerecentFilesStore ()
bool getSortDroppedFiles () const
 returns whether to sort the filenames received from Drag&Drop in lexicographical order before adding them in scene
void setSortDroppedFiles (bool value)
 sets whether to sort the filenames received from Drag&Drop in lexicographical order before adding them in scene
void drawUiRenderObjects ()
 draw 2d (UI) part of objects in scene
bool isMultiViewportAvailable ()

Static Public Member Functions

static void parseLaunchParams (LaunchParams &params)
 Accumulate launch params from cmd args.
static Viewerinstance ()
 provides non const access to viewer
static ViewerinstanceRef ()
static const ViewerconstInstance ()
 provide const access to viewer
static const ViewerconstInstanceRef ()

Public Attributes

bool swapOnLastPostEventsRedraw { true }
 if true only last frame of force redraw after events will be swapped, otherwise each will be swapped
int forceRedrawMinimumIncrementAfterEvents { 4 }
 minimum auto increment force redraw frames after events
GLFWwindow * window
 Member variables ///.
std::function< void(Viewer *viewer)> resetSettingsFunction
std::vector< Viewportviewport_list
 Stores all the viewing options.
size_t selected_viewport_index
std::vector< ViewerPlugin * > plugins
 List of registered plugins.
float pixelRatio { 1.0f }
Vector2i framebufferSize
Vector2i windowSavePos
Vector2i windowSaveSize
 pos to save
Vector2i windowOldPos
 size to save
bool windowMaximized { false }
bool isAnimating { false }
 if true - calls render without system events
int animationMaxFps { 30 }
 max fps if animating
float scrollForce { }
uint16_t glPickRadius { }
 opengl-based pick window radius in pixels
bool experimentalFeatures { }
 Experimental/developer features enabled.
std::vector< std::string > commandArgs
 command arguments, each parsed arg should be erased from here not to affect other parsers
std::shared_ptr< ObjectMeshbasisAxes
std::unique_ptr< CornerControllerObjectbasisViewController
std::unique_ptr< ViewportGlobalBasisglobalBasis
std::shared_ptr< ObjectMeshrotationSphere
std::shared_ptr< ObjectMeshclippingPlaneObject
 Stores clipping plane mesh.
std::shared_ptr< ViewerTitlewindowTitle
 class that updates viewer title

Friends

ViewergetViewerInstance ()
 returns global instance of Viewer class

Detailed Description

GLFW-based mesh viewer.


The documentation for this class was generated from the following file: