qCC_glWindow version 2.13.alpha (Qt) - 31 May 2022
CloudCompare 3D view
Classes | Public Types | Signals | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Types | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
ccGLWindow Class Reference

OpenGL 3D view. More...

#include <ccGLWindow.h>

Inheritance diagram for ccGLWindow:
Inheritance graph
[legend]
Collaboration diagram for ccGLWindow:
Collaboration graph
[legend]

Classes

struct  CaptureModeOptions
 Display capturing mode options. More...
 
struct  ClickableItem
 Clickable item. More...
 
struct  LODState
 LOD state. More...
 
struct  MessageToDisplay
 Temporary Message to display in the lower-left corner. More...
 
struct  PBOPicking
 Fast pixel reading mechanism with PBO. More...
 
struct  StereoParams
 Seterovision parameters. More...
 

Public Types

enum  PICKING_MODE {
  NO_PICKING , ENTITY_PICKING , ENTITY_RECT_PICKING , FAST_PICKING ,
  POINT_PICKING , TRIANGLE_PICKING , POINT_OR_TRIANGLE_PICKING , POINT_OR_TRIANGLE_OR_LABEL_PICKING ,
  LABEL_PICKING , DEFAULT_PICKING
}
 Picking mode.
 
enum  INTERACTION_FLAG {
  INTERACT_NONE = 0 , INTERACT_ROTATE = 1 , INTERACT_PAN = 2 , INTERACT_CTRL_PAN = 4 ,
  INTERACT_ZOOM_CAMERA = 8 , INTERACT_2D_ITEMS = 16 , INTERACT_CLICKABLE_ITEMS = 32 , INTERACT_TRANSFORM_ENTITIES = 64 ,
  INTERACT_SIG_RB_CLICKED = 128 , INTERACT_SIG_LB_CLICKED = 256 , INTERACT_SIG_MOUSE_MOVED = 512 , INTERACT_SIG_BUTTON_RELEASED = 1024 ,
  INTERACT_SIG_MB_CLICKED = 2048 , INTERACT_SEND_ALL_SIGNALS = INTERACT_SIG_RB_CLICKED | INTERACT_SIG_LB_CLICKED | INTERACT_SIG_MB_CLICKED | INTERACT_SIG_MOUSE_MOVED | INTERACT_SIG_BUTTON_RELEASED , MODE_PAN_ONLY = INTERACT_PAN | INTERACT_ZOOM_CAMERA | INTERACT_2D_ITEMS | INTERACT_CLICKABLE_ITEMS , MODE_TRANSFORM_CAMERA = INTERACT_ROTATE | MODE_PAN_ONLY ,
  MODE_TRANSFORM_ENTITIES = INTERACT_ROTATE | INTERACT_PAN | INTERACT_ZOOM_CAMERA | INTERACT_TRANSFORM_ENTITIES | INTERACT_CLICKABLE_ITEMS
}
 Interaction flags (mostly with the mouse)
 
enum  MessagePosition { LOWER_LEFT_MESSAGE , UPPER_CENTER_MESSAGE , SCREEN_CENTER_MESSAGE }
 Default message positions on screen.
 
enum  MessageType {
  CUSTOM_MESSAGE = 0 , SCREEN_SIZE_MESSAGE , PERSPECTIVE_STATE_MESSAGE , SUN_LIGHT_STATE_MESSAGE ,
  CUSTOM_LIGHT_STATE_MESSAGE , MANUAL_TRANSFORMATION_MESSAGE , MANUAL_SEGMENTATION_MESSAGE , ROTAION_LOCK_MESSAGE ,
  FULL_SCREEN_MESSAGE
}
 Message type.
 
enum  PivotVisibility { PIVOT_HIDE , PIVOT_SHOW_ON_MOVE , PIVOT_ALWAYS_SHOW }
 Pivot symbol visibility.
 

Signals

void entitySelectionChanged (ccHObject *entity)
 Signal emitted when an entity is selected in the 3D view.
 
void entitiesSelectionChanged (std::unordered_set< int > entIDs)
 Signal emitted when multiple entities are selected in the 3D view.
 
void itemPicked (ccHObject *entity, unsigned subEntityID, int x, int y, const CCVector3 &P, const CCVector3d &uvw)
 Signal emitted when a point (or a triangle) is picked. More...
 
void itemPickedFast (ccHObject *entity, int subEntityID, int x, int y)
 Signal emitted when an item is picked (FAST_PICKING mode only) More...
 
void fastPickingFinished ()
 Signal emitted when fast picking is finished (FAST_PICKING mode only)
 
void viewMatRotated (const ccGLMatrixd &rotMat)
 Signal emitted when the window 'model view' matrix is interactively changed.
 
void mouseWheelRotated (float wheelDelta_deg)
 Signal emitted when the mouse wheel is rotated.
 
void perspectiveStateChanged ()
 Signal emitted when the perspective state changes (see setPerspectiveState)
 
void baseViewMatChanged (const ccGLMatrixd &newViewMat)
 Signal emitted when the window 'base view' matrix is changed.
 
void fovChanged (float fov)
 Signal emitted when the f.o.v. changes.
 
void zNearCoefChanged (float coef)
 Signal emitted when the zNear coef changes.
 
void pivotPointChanged (const CCVector3d &)
 Signal emitted when the pivot point is changed.
 
void cameraPosChanged (const CCVector3d &)
 Signal emitted when the camera position is changed.
 
void translation (const CCVector3d &t)
 Signal emitted when the selected object is translated by the user.
 
void rotation (const ccGLMatrixd &rotMat)
 Signal emitted when the selected object is rotated by the user. More...
 
void leftButtonClicked (int x, int y)
 Signal emitted when the left mouse button is clicked on the window. More...
 
void rightButtonClicked (int x, int y)
 Signal emitted when the right mouse button is clicked on the window. More...
 
void mouseMoved (int x, int y, Qt::MouseButtons buttons)
 Signal emitted when the mouse is moved. More...
 
void buttonReleased ()
 Signal emitted when a mouse button is released (cursor on the window) More...
 
void drawing3D ()
 Signal emitted during 3D pass of OpenGL display process. More...
 
void filesDropped (const QStringList &filenames)
 Signal emitted when files are dropped on the window.
 
void newLabel (ccHObject *obj)
 Signal emitted when a new label is created.
 
void exclusiveFullScreenToggled (bool exclusive)
 Signal emitted when the exclusive fullscreen is toggled.
 
void middleButtonClicked (int x, int y)
 Signal emitted when the middle mouse button is clicked on the window. More...
 

Public Member Functions

 ccGLWindow (QSurfaceFormat *format=nullptr, ccGLWindowParent *parent=nullptr, bool silentInitialization=false)
 Default constructor.
 
 ~ccGLWindow () override
 Destructor.
 
void setSceneDB (ccHObject *root)
 Sets 'scene graph' root.
 
ccHObject * getSceneDB ()
 Returns current 'scene graph' root.
 
void renderText (int x, int y, const QString &str, uint16_t uniqueID=0, const QFont &font=QFont())
 
void renderText (double x, double y, double z, const QString &str, const QFont &font=QFont())
 
void toBeRefreshed () override
 
void refresh (bool only2D=false) override
 
void invalidateViewport () override
 
void deprecate3DLayer () override
 
void display3DLabel (const QString &str, const CCVector3 &pos3D, const ccColor::Rgba *color=nullptr, const QFont &font=QFont()) override
 
void displayText (QString text, int x, int y, unsigned char align=ALIGN_DEFAULT, float bkgAlpha=0.0f, const ccColor::Rgba *color=nullptr, const QFont *font=nullptr) override
 
QFont getTextDisplayFont () const override
 
QFont getLabelDisplayFont () const override
 
const ccViewportParameters & getViewportParameters () const override
 
QPointF toCenteredGLCoordinates (int x, int y) const override
 
QPointF toCornerGLCoordinates (int x, int y) const override
 
void setupProjectiveViewport (const ccGLMatrixd &cameraMatrix, float fov_deg=0.0f, float ar=1.0f, bool viewerBasedPerspective=true, bool bubbleViewMode=false) override
 
QWidget * asWidget () override
 
QSize getScreenSize () const override
 
void getGLCameraParameters (ccGLCameraParameters &params) override
 
virtual void displayNewMessage (const QString &message, MessagePosition pos, bool append=false, int displayMaxDelay_sec=2, MessageType type=CUSTOM_MESSAGE)
 Displays a status message in the bottom-left corner. More...
 
virtual void setSunLight (bool state)
 Activates sun light.
 
virtual void toggleSunLight ()
 Toggles sun light.
 
virtual bool sunLightEnabled () const
 Returns whether sun light is enabled or not.
 
virtual void setCustomLight (bool state)
 Activates custom light.
 
virtual void toggleCustomLight ()
 Toggles custom light.
 
virtual bool customLightEnabled () const
 Returns whether custom light is enabled or not.
 
virtual void setPivotVisibility (PivotVisibility vis)
 Sets pivot visibility.
 
virtual PivotVisibility getPivotVisibility () const
 Returns pivot visibility.
 
virtual void showPivotSymbol (bool state)
 Shows or hide the pivot symbol. More...
 
virtual void setPivotPoint (const CCVector3d &P, bool autoUpdateCameraPos=false, bool verbose=false)
 Sets pivot point. More...
 
virtual void setCameraPos (const CCVector3d &P)
 Sets camera position. More...
 
virtual void moveCamera (CCVector3d &v)
 Displaces camera. More...
 
void setCameraFocalToFitWidth (double width)
 Sets the OpenGL camera 'focal' distance to achieve a given width (in 'metric' units) More...
 
void setFocalDistance (double focalDistance)
 Sets the focal distance.
 
virtual void setPerspectiveState (bool state, bool objectCenteredView)
 Set perspective state/mode. More...
 
virtual void togglePerspective (bool objectCentered)
 Toggles perspective mode. More...
 
virtual bool getPerspectiveState (bool &objectCentered) const
 Returns perspective mode.
 
virtual bool objectPerspectiveEnabled () const
 Shortcut: returns whether object-based perspective mode is enabled.
 
virtual bool viewerPerspectiveEnabled () const
 Shortcut: returns whether viewer-based perspective mode is enabled.
 
void setBubbleViewMode (bool state)
 Sets bubble-view mode state. More...
 
bool bubbleViewModeEnabled () const
 Returns whether bubble-view mode is enabled or no.
 
void setBubbleViewFov (float fov_deg)
 Set bubble-view f.o.v. (in degrees)
 
virtual void updateConstellationCenterAndZoom (const ccBBox *boundingBox=nullptr)
 Center and zoom on a given bounding box. More...
 
void getVisibleObjectsBB (ccBBox &box) const
 Returns the visible objects bounding-box.
 
virtual void rotateBaseViewMat (const ccGLMatrixd &rotMat)
 Rotates the base view matrix. More...
 
virtual const ccGLMatrixd & getBaseViewMat ()
 Returns the base view matrix. More...
 
virtual void setBaseViewMat (ccGLMatrixd &mat)
 Sets the base view matrix. More...
 
virtual void setView (CC_VIEW_ORIENTATION orientation, bool redraw=true)
 Sets camera to a predefined view (top, bottom, etc.)
 
virtual void setCustomView (const CCVector3d &forward, const CCVector3d &up, bool forceRedraw=true)
 Sets camera to a custom view (forward and up directions must be specified)
 
virtual void setInteractionMode (INTERACTION_FLAGS flags)
 Sets current interaction flags.
 
virtual INTERACTION_FLAGS getInteractionMode () const
 Returns the current interaction flags.
 
virtual void setPickingMode (PICKING_MODE mode=DEFAULT_PICKING)
 Sets current picking mode. More...
 
virtual PICKING_MODE getPickingMode () const
 Returns current picking mode.
 
virtual void lockPickingMode (bool state)
 Locks picking mode. More...
 
virtual bool isPickingModeLocked () const
 Returns whether picking mode is locked or not.
 
virtual void setUnclosable (bool state)
 Specify whether this 3D window can be closed by the user or not.
 
virtual void getContext (CC_DRAW_CONTEXT &context)
 Returns context information.
 
virtual void setPointSize (float size, bool silent=false)
 Sets point size. More...
 
virtual void setLineWidth (float width, bool silent=false)
 Sets line width. More...
 
virtual int getFontPointSize () const
 Returns current font size.
 
virtual int getLabelFontPointSize () const
 Returns current font size for labels.
 
virtual ccHObject * getOwnDB ()
 Returns window own DB.
 
virtual void addToOwnDB (ccHObject *obj, bool noDependency=true)
 Adds an entity to window own DB. More...
 
virtual void removeFromOwnDB (ccHObject *obj)
 Removes an entity from window own DB.
 
virtual void setViewportParameters (const ccViewportParameters &params)
 Sets viewport parameters (all at once)
 
virtual void setFov (float fov)
 Sets current camera f.o.v. (field of view) in degrees. More...
 
virtual float getFov () const
 Returns the current f.o.v. (field of view) in degrees.
 
virtual void setGLCameraAspectRatio (float ar)
 Sets current OpenGL camera aspect ratio (width/height)
 
virtual void setZNearCoef (double coef)
 Sets current camera 'zNear' coefficient. More...
 
virtual void invalidateVisualization ()
 Invalidate current visualization state. More...
 
virtual QImage renderToImage (float zoomFactor=1.0f, bool dontScaleFeatures=false, bool renderOverlayItems=false, bool silent=false)
 Renders screen to an image.
 
virtual bool renderToFile (QString filename, float zoomFactor=1.0f, bool dontScaleFeatures=false, bool renderOverlayItems=false)
 Renders screen to a file.
 
virtual void setShader (ccShader *shader)
 
virtual void setGlFilter (ccGlFilter *filter)
 
ccGlFilter * getGlFilter ()
 
const ccGlFilter * getGlFilter () const
 
virtual bool areShadersEnabled () const
 
virtual bool areGLFiltersEnabled () const
 
virtual double computeActualPixelSize () const
 Returns the actual pixel size on screen (taking zoom or perspective parameters into account) More...
 
bool hasColorRampShader () const
 Returns whether the ColorRamp shader is supported or not.
 
bool isRectangularPickingAllowed () const
 Returns whether rectangular picking is allowed or not.
 
void setRectangularPickingAllowed (bool state)
 Sets whether rectangular picking is allowed or not.
 
const ccGui::ParamStructgetDisplayParameters () const
 Returns current parameters for this display (const version) More...
 
void setDisplayParameters (const ccGui::ParamStruct &params, bool thisWindowOnly=false)
 Sets current parameters for this display.
 
bool hasOverriddenDisplayParameters () const
 Whether display parameters are overidden for this window.
 
void setPickingRadius (int radius)
 Sets picking radius.
 
int getPickingRadius () const
 Returns the current picking radius.
 
void displayOverlayEntities (bool showScale, bool showTrihedron)
 Sets whether overlay entities (scale and trihedron) should be displayed or not.
 
bool scaleIsDisplayed () const
 Returns whether the scale bar is displayed or not.
 
bool trihedronIsDisplayed () const
 Returns whether the trihedron is displayed or not.
 
float computeTrihedronLength () const
 Computes the trihedron size (in pixels)
 
int getGlFilterBannerHeight () const
 Returns the height of the 'GL filter' banner.
 
void computeColorRampAreaLimits (int &yStart, int &yStop) const
 Returns the extents of the vertical area available for displaying the color ramp.
 
CCVector3 backprojectPointOnTriangle (const CCVector2i &P2D, const CCVector3 &A3D, const CCVector3 &B3D, const CCVector3 &C3D)
 Backprojects a 2D points on a 3D triangle. More...
 
int getUniqueID () const
 Returns unique ID.
 
int qtWidth () const
 Returns the widget width (in pixels)
 
int qtHeight () const
 Returns the widget height (in pixels)
 
QSize qtSize () const
 Returns the widget size (in pixels)
 
int glWidth () const
 Returns the OpenGL context width.
 
int glHeight () const
 Returns the OpenGL context height.
 
QSize glSize () const
 Returns the OpenGL context size.
 
bool isLODEnabled () const
 Returns whether LOD is enabled on this display or not.
 
bool setLODEnabled (bool state, bool autoDisable=false)
 Enables or disables LOD on this display. More...
 
void toggleExclusiveFullScreen (bool state)
 Toggles (exclusive) full-screen mode.
 
bool exclusiveFullScreen () const
 Returns whether the window is in exclusive full screen mode or not.
 
void enableDebugTrace (bool state)
 Shows debug info on screen.
 
void toggleDebugTrace ()
 Toggles debug info on screen.
 
bool enableStereoMode (const StereoParams &params)
 Enables stereo display mode.
 
void disableStereoMode ()
 Disables stereo display mode.
 
bool stereoModeIsEnabled () const
 Returns whether the stereo display mode is enabled or not.
 
const StereoParamsgetStereoParams () const
 Returns the current stereo mode parameters.
 
void showCursorCoordinates (bool state)
 Sets whether to display the coordinates of the point below the cursor position.
 
bool cursorCoordinatesShown () const
 Whether the coordinates of the point below the cursor position are displayed or not.
 
void setAutoPickPivotAtCenter (bool state)
 Toggles the automatic setting of the pivot point at the center of the screen.
 
bool autoPickPivotAtCenter () const
 Whether the pivot point is automatically set at the center of the screen.
 
void lockRotationAxis (bool state, const CCVector3d &axis)
 Lock the rotation axis.
 
bool isRotationAxisLocked () const
 Returns whether the rotation axis is locaked or not.
 
void zoomGlobal ()
 Applies a 1:1 global zoom.
 
void redraw (bool only2D=false, bool resetLOD=true) override
 
void onWheelEvent (float wheelDelta_deg)
 
void startFrameRateTest ()
 Tests frame rate.
 
void requestUpdate ()
 Request an update of the display. More...
 

Static Public Member Functions

static void setShaderPath (const QString &path)
 

Static Public Attributes

static constexpr float MIN_POINT_SIZE_F = 1.0f
 Minimum point size.
 
static constexpr float MAX_POINT_SIZE_F = 16.0f
 Maximum point size.
 
static constexpr float MIN_LINE_WIDTH_F = 1.0f
 Minimum line width.
 
static constexpr float MAX_LINE_WIDTH_F = 16.0f
 Maximum line width.
 
static const int DefaultPickRadius = 5
 Default picking radius value.
 

Protected Types

using ccQOpenGLFunctions = QOpenGLFunctions_2_1
 
using SharedTexture = QSharedPointer< QOpenGLTexture >
 

Protected Member Functions

void renderNextLODLevel ()
 Renders the next L.O.D. level.
 
void stopFrameRateTest ()
 Stops frame rate test.
 
void onItemPickedFast (ccHObject *pickedEntity, int pickedItemIndex, int x, int y)
 Reacts to the itemPickedFast signal.
 
void checkScheduledRedraw ()
 Checks for scheduled redraw.
 
void handleLoggedMessage (const QOpenGLDebugMessage &)
 OpenGL KHR debug log.
 
void doPicking ()
 Performs standard picking at the last clicked mouse position (see m_lastMousePos)
 
ccQOpenGLFunctions * functions () const
 Returns the set of OpenGL functions.
 
void makeCurrent ()
 
bool bindFBO (ccFrameBufferObject *fbo)
 Binds an FBO or releases the current one (if input is nullptr) More...
 
void fullRenderingPass (CC_DRAW_CONTEXT &context, RenderingParams &params)
 Full rendering pass (drawBackground + draw3D + drawForeground)
 
void drawBackground (CC_DRAW_CONTEXT &context, RenderingParams &params)
 Draws the background layer. More...
 
void draw3D (CC_DRAW_CONTEXT &context, RenderingParams &params)
 Draws the main 3D layer.
 
void drawForeground (CC_DRAW_CONTEXT &context, RenderingParams &params)
 Draws the foreground layer. More...
 
int width () const
 
int height () const
 
QSize size () const
 
virtual const ccGLMatrixd & getModelViewMatrix ()
 Returns the current (OpenGL) view matrix. More...
 
virtual const ccGLMatrixd & getProjectionMatrix ()
 Returns the current (OpenGL) projection matrix. More...
 
bool processClickableItems (int x, int y)
 Processes the clickable items. More...
 
void setFontPointSize (int pixelSize)
 Sets current font size. More...
 
void mousePressEvent (QMouseEvent *event) override
 
void mouseMoveEvent (QMouseEvent *event) override
 
void mouseDoubleClickEvent (QMouseEvent *event) override
 
void mouseReleaseEvent (QMouseEvent *event) override
 
void wheelEvent (QWheelEvent *event) override
 
bool event (QEvent *evt) override
 
bool initialize ()
 
GLuint defaultQtFBO () const
 
void initializeGL () override
 
void resizeGL (int w, int h) override
 
void paintGL () override
 
void dragEnterEvent (QDragEnterEvent *event) override
 
void dropEvent (QDropEvent *event) override
 
void drawCross ()
 
void drawTrihedron ()
 
void drawScale (const ccColor::Rgbub &color)
 
ccGLMatrixd computeModelViewMatrix () const
 Computes the model view matrix.
 
ccGLMatrixd computeProjectionMatrix (bool withGLfeatures, ProjectionMetrics *metrics=nullptr, double *eyeOffset=nullptr) const
 Computes the projection matrix. More...
 
void updateModelViewMatrix ()
 
void updateProjectionMatrix ()
 
void setStandardOrthoCenter ()
 
void setStandardOrthoCorner ()
 
void glEnableSunLight ()
 
void glDisableSunLight ()
 
void glEnableCustomLight ()
 
void glDisableCustomLight ()
 
void drawCustomLight ()
 
void drawPivot ()
 Draws pivot point symbol in 3D.
 
void startPicking (PickingParameters &params)
 Starts picking process. More...
 
void startOpenGLPicking (const PickingParameters &params)
 Performs the picking with OpenGL.
 
void startCPUBasedPointPicking (const PickingParameters &params)
 Starts OpenGL picking process.
 
void processPickingResult (const PickingParameters &params, ccHObject *pickedEntity, int pickedItemIndex, const CCVector3 *nearestPoint=nullptr, const CCVector3d *nearestPointBC=nullptr, const std::unordered_set< int > *selectedIDs=nullptr)
 Processes the picking process result and sends the corresponding signal.
 
void updateActiveItemsList (int x, int y, bool extendToSelectedLabels=false)
 Updates currently active items list (m_activeItems) More...
 
bool initFBO (int w, int h)
 Inits FBO (frame buffer object)
 
bool initFBOSafe (ccFrameBufferObject *&fbo, int w, int h)
 Inits FBO (safe)
 
void removeFBO ()
 Releases any active FBO.
 
void removeFBOSafe (ccFrameBufferObject *&fbo)
 Releases any active FBO (safe)
 
bool initGLFilter (int w, int h, bool silent=false)
 Inits active GL filter (advanced shader)
 
void removeGLFilter ()
 Releases active GL filter.
 
CCVector3d convertMousePositionToOrientation (int x, int y)
 Converts a given (mouse) position in pixels to an orientation. More...
 
void drawClickableItems (int xStart, int &yStart)
 Draws the 'hot zone' (+/- icons for point size), 'leave bubble-view' button, etc.
 
void stopLODCycle ()
 Disables current LOD rendering cycle.
 
void uninitializeGL ()
 
void scheduleFullRedraw (unsigned maxDelay_ms)
 Schedules a full redraw. More...
 
void cancelScheduledRedraw ()
 Cancels any scheduled redraw. More...
 
void setGLViewport (int x, int y, int w, int h)
 Sets the OpenGL viewport (shortut)
 
void setGLViewport (const QRect &rect)
 Sets the OpenGL viewport.
 
const QRect & getGLViewport () const
 Returns the current (OpenGL) viewport.
 
void logGLError (const char *context) const
 Logs a GL error (shortcut)
 
void toggleAutoRefresh (bool state, int period_ms=0)
 Toggles auto-refresh mode.
 
GLfloat getGLDepth (int x, int y, bool extendToNeighbors=false, bool usePBO=false)
 Returns the (relative) depth value at a given pixel position. More...
 
bool getClick3DPos (int x, int y, CCVector3d &P3D, bool usePBO)
 Returns the approximate 3D position of the clicked pixel.
 

Static Protected Member Functions

static void LogGLError (GLenum error, const char *context)
 Logs a GL error. More...
 

Protected Attributes

std::list< ccInteractor * > m_activeItems
 Currently active items. More...
 
int m_uniqueID
 Unique ID.
 
bool m_initialized
 Initialization state.
 
GLuint m_trihedronGLList
 Trihedron GL list.
 
GLuint m_pivotGLList
 Pivot center GL list.
 
ccViewportParameters m_viewportParams
 Viewport parameters (zoom, etc.)
 
QPoint m_lastMousePos
 Last mouse position.
 
ccGLMatrixd m_viewMatd
 Complete visualization matrix (GL style - double version)
 
bool m_validModelviewMatrix
 Whether the model veiw matrix is valid (or need to be recomputed)
 
ccGLMatrixd m_projMatd
 Projection matrix (GL style - double version)
 
bool m_validProjectionMatrix
 Whether the projection matrix is valid (or need to be recomputed)
 
double m_cameraToBBCenterDist
 Distance between the camera and the displayed objects bounding-box.
 
double m_bbHalfDiag
 Half size of the displayed objects bounding-box.
 
QRect m_glViewport
 GL viewport.
 
bool m_LODEnabled
 Whether L.O.D. (level of detail) is enabled or not.
 
bool m_LODAutoDisable
 Whether L.O.D. should be automatically disabled at the end of the rendering cycle.
 
bool m_shouldBeRefreshed
 Whether the display should be refreshed on next call to 'refresh'.
 
bool m_mouseMoved
 Whether the mouse (cursor) has moved after being pressed or not.
 
bool m_mouseButtonPressed
 Whether the mouse is currently pressed or not.
 
bool m_unclosable
 Whether this 3D window can be closed by the user or not.
 
INTERACTION_FLAGS m_interactionFlags
 Current intercation flags.
 
PICKING_MODE m_pickingMode
 Current picking mode.
 
bool m_pickingModeLocked
 Whether picking mode is locked or not.
 
CaptureModeOptions m_captureMode
 Display capturing mode options.
 
std::list< MessageToDisplaym_messagesToDisplay
 List of messages to display.
 
qint64 m_lastClickTime_ticks
 Last click time (msec)
 
float m_sunLightPos [4]
 Sun light position. More...
 
bool m_sunLightEnabled
 Whether sun light is enabled or not.
 
float m_customLightPos [4]
 Custom light position. More...
 
bool m_customLightEnabled
 Whether custom light is enabled or not.
 
std::vector< ClickableItemm_clickableItems
 Currently displayed clickable items.
 
bool m_clickableItemsVisible
 Whether clickable items are visible (= mouse over) or not.
 
ccShader * m_activeShader
 Currently active shader.
 
bool m_shadersEnabled
 Whether shaders are enabled or not.
 
ccFrameBufferObject * m_activeFbo
 Currently active FBO (frame buffer object)
 
ccFrameBufferObject * m_fbo
 First default FBO (frame buffer object)
 
ccFrameBufferObject * m_fbo2
 Second default FBO (frame buffer object) - used for stereo rendering.
 
bool m_alwaysUseFBO
 Whether to always use FBO or only for GL filters.
 
bool m_updateFBO
 Whether FBO should be updated (or simply displayed as a texture = faster!)
 
ccColorRampShader * m_colorRampShader
 
ccShader * m_customRenderingShader
 
ccGlFilter * m_activeGLFilter
 Active GL filter.
 
bool m_glFiltersEnabled
 Whether GL filters are enabled or not.
 
ccHObject * m_winDBRoot
 Window own DB.
 
ccHObject * m_globalDBRoot
 CC main DB.
 
QFont m_font
 Default font.
 
PivotVisibility m_pivotVisibility
 Pivot symbol visibility.
 
bool m_pivotSymbolShown
 Whether pivot symbol should be shown or not.
 
bool m_allowRectangularEntityPicking
 Whether rectangular picking is allowed or not.
 
ccPolyline * m_rectPickingPoly
 Rectangular picking polyline.
 
ccGui::ParamStruct m_overriddenDisplayParameters
 Overridden display parameter.
 
bool m_overriddenDisplayParametersEnabled
 Whether display parameters are overidden for this window.
 
bool m_showScale
 Whether to display the scale bar.
 
bool m_showTrihedron
 Whether to display the trihedron.
 
bool m_silentInitialization
 Whether initialization should be silent or not (i.e. no message to console)
 
bool m_bubbleViewModeEnabled
 Bubble-view mode state.
 
float m_bubbleViewFov_deg
 Bubble-view mode f.o.v. (degrees)
 
ccViewportParameters m_preBubbleViewParameters
 Pre-bubble-view camera parameters (backup)
 
LODState m_currentLODState
 Current LOD state.
 
bool m_LODPendingRefresh
 LOD refresh signal sent.
 
bool m_LODPendingIgnore
 LOD refresh signal should be ignored.
 
QElapsedTimer m_timer
 Internal timer.
 
bool m_touchInProgress
 Touch event in progress.
 
qreal m_touchBaseDist
 Touch gesture initial distance.
 
QTimer m_scheduleTimer
 Scheduler timer.
 
qint64 m_scheduledFullRedrawTime
 Scheduled full redraw (no LOD)
 
StereoParams m_stereoParams
 Seterovision mode parameters.
 
bool m_stereoModeEnabled
 Whether seterovision mode is enabled or not.
 
QWidget * m_formerParent
 Former parent object (for exclusive full-screen display)
 
bool m_exclusiveFullscreen
 Wether exclusive full screen is enabled or not.
 
QByteArray m_formerGeometry
 Former geometry (for exclusive full-screen display)
 
bool m_showDebugTraces
 Debug traces visibility.
 
int m_pickRadius
 Picking radius (pixels)
 
QOpenGLExtension_ARB_framebuffer_object m_glExtFunc
 FBO support.
 
bool m_glExtFuncSupported
 Whether FBO support is on.
 
bool m_autoRefresh
 Auto-refresh mode.
 
QTimer m_autoRefreshTimer
 Auto-refresh timer.
 
HotZone * m_hotZone
 Hot zone.
 
bool m_showCursorCoordinates
 Whether to display the coordinates of the point below the cursor position.
 
bool m_autoPickPivotAtCenter
 Whether the pivot point is automatically picked at the center of the screen (when possible)
 
QTimer m_deferredPickingTimer
 Deferred picking.
 
bool m_ignoreMouseReleaseEvent
 Ignore next mouse release event.
 
bool m_rotationAxisLocked
 Wheter the rotation axis is locked or not.
 
CCVector3d m_lockedRotationAxis
 Locked rotation axis.
 
QMap< uint16_t, SharedTexture > m_uniqueTextures
 Reserved textures (for renderText)
 
std::vector< SharedTexture > m_texturePool
 Texture pool (for renderText)
 
size_t m_texturePoolLastIndex
 Last texture pool index.
 
PBOPicking m_pickingPBO
 Fast pixel reading mechanism with PBO.
 

Detailed Description

OpenGL 3D view.

Member Function Documentation

◆ addToOwnDB()

void ccGLWindow::addToOwnDB ( ccHObject *  obj,
bool  noDependency = true 
)
virtual

Adds an entity to window own DB.

By default no dependency link is established between the entity and the window (DB).

◆ backprojectPointOnTriangle()

CCVector3 ccGLWindow::backprojectPointOnTriangle ( const CCVector2i &  P2D,
const CCVector3 &  A3D,
const CCVector3 &  B3D,
const CCVector3 &  C3D 
)

Backprojects a 2D points on a 3D triangle.

Warning
Uses the current display parameters!
Parameters
P2Dpoint on the screen
A3Dfirst vertex of the 3D triangle
B3Dsecond vertex of the 3D triangle
C3Dthird vertex of the 3D triangle
Returns
backprojected point

◆ bindFBO()

bool ccGLWindow::bindFBO ( ccFrameBufferObject *  fbo)
protected

Binds an FBO or releases the current one (if input is nullptr)

This method must be called instead of the FBO's own 'start' and 'stop' methods so as to properly handle the interactions with QOpenGLWidget's own FBO.

◆ buttonReleased

void ccGLWindow::buttonReleased ( )
signal

Signal emitted when a mouse button is released (cursor on the window)

See INTERACT_SIG_BUTTON_RELEASED.

◆ cancelScheduledRedraw()

void ccGLWindow::cancelScheduledRedraw ( )
protected

Cancels any scheduled redraw.

See ccGLWindow::scheduleFullRedraw.

◆ computeActualPixelSize()

double ccGLWindow::computeActualPixelSize ( ) const
virtual

Returns the actual pixel size on screen (taking zoom or perspective parameters into account)

In perspective mode, this value is approximate (especially if we are in 'viewer-based' viewing mode).

◆ computeProjectionMatrix()

ccGLMatrixd ccGLWindow::computeProjectionMatrix ( bool  withGLfeatures,
ProjectionMetrics *  metrics = nullptr,
double *  eyeOffset = nullptr 
) const
protected

Computes the projection matrix.

Parameters
[in]withGLfeatureswhether to take additional elements (pivot symbol, custom light, etc.) into account or not
[out]metrics[optional] output other metrics (Znear and Zfar, etc.)
[out]eyeOffset[optional] eye offset (for stereo display)

◆ convertMousePositionToOrientation()

CCVector3d ccGLWindow::convertMousePositionToOrientation ( int  x,
int  y 
)
protected

Converts a given (mouse) position in pixels to an orientation.

The orientation vector origin is the current pivot point!

◆ displayNewMessage()

void ccGLWindow::displayNewMessage ( const QString &  message,
MessagePosition  pos,
bool  append = false,
int  displayMaxDelay_sec = 2,
MessageType  type = CUSTOM_MESSAGE 
)
virtual

Displays a status message in the bottom-left corner.

WARNING: currently, 'append' is not supported for SCREEN_CENTER_MESSAGE

Parameters
messagemessage (if message is empty and append is 'false', all messages will be cleared)
posmessage position on screen
appendwhether to append the message or to replace existing one(s) (only messages of the same type are impacted)
displayMaxDelay_secminimum display duration
typemessage type (if not custom, only one message of this type at a time is accepted)

◆ drawBackground()

void ccGLWindow::drawBackground ( CC_DRAW_CONTEXT &  context,
RenderingParams &  params 
)
protected

Draws the background layer.

Background + 2D background objects

◆ drawForeground()

void ccGLWindow::drawForeground ( CC_DRAW_CONTEXT &  context,
RenderingParams &  params 
)
protected

Draws the foreground layer.

2D foreground objects / text

◆ drawing3D

void ccGLWindow::drawing3D ( )
signal

Signal emitted during 3D pass of OpenGL display process.

Any object connected to this slot can draw additional stuff in 3D. Depth buffering, lights and shaders are enabled by default.

◆ getBaseViewMat()

const ccGLMatrixd & ccGLWindow::getBaseViewMat ( )
virtual

Returns the base view matrix.

Warning: 'base view' marix is either:

  • the rotation around the object in object-centered mode
  • the rotation around the camera center in viewer-centered mode (see setPerspectiveState).

◆ getDisplayParameters()

const ccGui::ParamStruct & ccGLWindow::getDisplayParameters ( ) const

Returns current parameters for this display (const version)

Warning: may return overridden parameters!

◆ getGLDepth()

GLfloat ccGLWindow::getGLDepth ( int  x,
int  y,
bool  extendToNeighbors = false,
bool  usePBO = false 
)
protected

Returns the (relative) depth value at a given pixel position.

Returns
the (relative) depth or 1.0 if none is defined

◆ getModelViewMatrix()

const ccGLMatrixd & ccGLWindow::getModelViewMatrix ( )
protectedvirtual

Returns the current (OpenGL) view matrix.

Warning: may be different from the 'view' matrix returned by getBaseViewMat. Will call automatically updateModelViewMatrix if necessary.

◆ getProjectionMatrix()

const ccGLMatrixd & ccGLWindow::getProjectionMatrix ( )
protectedvirtual

Returns the current (OpenGL) projection matrix.

Will call automatically updateProjectionMatrix if necessary.

◆ invalidateVisualization()

void ccGLWindow::invalidateVisualization ( )
virtual

Invalidate current visualization state.

Forces view matrix update and 3D/FBO display.

◆ itemPicked

void ccGLWindow::itemPicked ( ccHObject *  entity,
unsigned  subEntityID,
int  x,
int  y,
const CCVector3 &  P,
const CCVector3d &  uvw 
)
signal

Signal emitted when a point (or a triangle) is picked.

Parameters
entity'picked' entity
subEntityIDpoint or triangle index in entity
xmouse cursor x position
ymouse cursor y position
Pthe picked point
uvwbarycentric coordinates of the point (if picked on a mesh)

◆ itemPickedFast

void ccGLWindow::itemPickedFast ( ccHObject *  entity,
int  subEntityID,
int  x,
int  y 
)
signal

Signal emitted when an item is picked (FAST_PICKING mode only)

Parameters
entityentity
subEntityIDpoint or triangle index in entity
xmouse cursor x position
ymouse cursor y position

◆ leftButtonClicked

void ccGLWindow::leftButtonClicked ( int  x,
int  y 
)
signal

Signal emitted when the left mouse button is clicked on the window.

See INTERACT_SIG_LB_CLICKED. Arguments correspond to the clicked point coordinates (x,y) in pixels relative to the window corner!

◆ lockPickingMode()

virtual void ccGLWindow::lockPickingMode ( bool  state)
inlinevirtual

Locks picking mode.

Warning
Bes sure to unlock it at some point ;)

◆ LogGLError()

void ccGLWindow::LogGLError ( GLenum  error,
const char *  context 
)
staticprotected

Logs a GL error.

Logs a warning or error message corresponding to the input GL error. If error == GL_NO_ERROR, nothing is logged.

Parameters
errorGL error code
contextname of the method/object that catched the error

◆ middleButtonClicked

void ccGLWindow::middleButtonClicked ( int  x,
int  y 
)
signal

Signal emitted when the middle mouse button is clicked on the window.

See INTERACT_SIG_MB_CLICKED. Arguments correspond to the clicked point coordinates (x,y) in pixels relative to the window corner!

◆ mouseMoved

void ccGLWindow::mouseMoved ( int  x,
int  y,
Qt::MouseButtons  buttons 
)
signal

Signal emitted when the mouse is moved.

See INTERACT_SIG_MOUSE_MOVED. The two first arguments correspond to the current cursor coordinates (x,y) relative to the window corner!

◆ moveCamera()

void ccGLWindow::moveCamera ( CCVector3d &  v)
virtual

Displaces camera.

Values are given in objects world along the current camera viewing directions (we use the right hand rule): X: horizontal axis (right) Y: vertical axis (up) Z: depth axis (pointing out of the screen)

Parameters
vdisplacement vector

◆ processClickableItems()

bool ccGLWindow::processClickableItems ( int  x,
int  y 
)
protected

Processes the clickable items.

Returns
true if an item has been clicked

◆ requestUpdate()

void ccGLWindow::requestUpdate ( )

Request an update of the display.

The request will be executed if not in auto refresh mode already

◆ rightButtonClicked

void ccGLWindow::rightButtonClicked ( int  x,
int  y 
)
signal

Signal emitted when the right mouse button is clicked on the window.

See INTERACT_SIG_RB_CLICKED. Arguments correspond to the clicked point coordinates (x,y) in pixels relative to the window corner!

◆ rotateBaseViewMat()

void ccGLWindow::rotateBaseViewMat ( const ccGLMatrixd &  rotMat)
virtual

Rotates the base view matrix.

Warning: 'base view' marix is either:

  • the rotation around the object in object-centered mode
  • the rotation around the camera center in viewer-centered mode (see setPerspectiveState).

◆ rotation

void ccGLWindow::rotation ( const ccGLMatrixd &  rotMat)
signal

Signal emitted when the selected object is rotated by the user.

Parameters
rotMatrotation applied to current viewport (4x4 OpenGL matrix)

◆ scheduleFullRedraw()

void ccGLWindow::scheduleFullRedraw ( unsigned  maxDelay_ms)
protected

Schedules a full redraw.

Any previously scheduled redraw will be cancelled.

Warning
The redraw will be cancelled if redraw/update is called before.
Parameters
maxDelay_msthe maximum delay for the call to redraw (in ms)

◆ setBaseViewMat()

void ccGLWindow::setBaseViewMat ( ccGLMatrixd &  mat)
virtual

Sets the base view matrix.

Warning: 'base view' marix is either:

  • the rotation around the object in object-centered mode
  • the rotation around the camera center in viewer-centered mode (see setPerspectiveState).

◆ setBubbleViewMode()

void ccGLWindow::setBubbleViewMode ( bool  state)

Sets bubble-view mode state.

Bubble-view is a kind of viewer-based perspective mode where the user can't displace the camera (apart from up-down or left-right rotations). The f.o.v. is also maximized.

Warning
Any call to a method that changes the perpsective will automatically disable this mode.

◆ setCameraFocalToFitWidth()

void ccGLWindow::setCameraFocalToFitWidth ( double  width)

Sets the OpenGL camera 'focal' distance to achieve a given width (in 'metric' units)

The camera will be positionned relatively to the current pivot point

◆ setCameraPos()

void ccGLWindow::setCameraPos ( const CCVector3d &  P)
virtual

Sets camera position.

Emits the 'cameraPosChanged' signal.

◆ setFontPointSize()

void ccGLWindow::setFontPointSize ( int  pixelSize)
protected

Sets current font size.

Warning: only used internally. Change 'defaultFontSize' with setDisplayParameters instead!

◆ setFov()

void ccGLWindow::setFov ( float  fov)
virtual

Sets current camera f.o.v. (field of view) in degrees.

FOV is only used in perspective mode.

◆ setLineWidth()

void ccGLWindow::setLineWidth ( float  width,
bool  silent = false 
)
virtual

Sets line width.

Parameters
widthlines width (between MIN_LINE_WIDTH_F and MAX_LINE_WIDTH_F)
silentwhether this function can log and/or display messages on the screen

◆ setLODEnabled()

bool ccGLWindow::setLODEnabled ( bool  state,
bool  autoDisable = false 
)

Enables or disables LOD on this display.

Returns
success

◆ setPerspectiveState()

void ccGLWindow::setPerspectiveState ( bool  state,
bool  objectCenteredView 
)
virtual

Set perspective state/mode.

Persepctive mode can be:

  • object-centered (moving the mouse make the object rotate)
  • viewer-centered (moving the mouse make the camera move)
    Warning
    Disables bubble-view mode automatically
    Parameters
    statewhether perspective mode is enabled or not
    objectCenteredViewwhether view is object- or viewer-centered (forced to true in ortho. mode)

◆ setPickingMode()

void ccGLWindow::setPickingMode ( PICKING_MODE  mode = DEFAULT_PICKING)
virtual

Sets current picking mode.

Picking can be applied to entities (default), points, triangles, etc.)

◆ setPivotPoint()

void ccGLWindow::setPivotPoint ( const CCVector3d &  P,
bool  autoUpdateCameraPos = false,
bool  verbose = false 
)
virtual

Sets pivot point.

Emits the 'pivotPointChanged' signal.

◆ setPointSize()

void ccGLWindow::setPointSize ( float  size,
bool  silent = false 
)
virtual

Sets point size.

Parameters
sizepoint size (between MIN_POINT_SIZE_F and MAX_POINT_SIZE_F)
silentwhether this function can log and/or display messages on the screen

◆ setZNearCoef()

void ccGLWindow::setZNearCoef ( double  coef)
virtual

Sets current camera 'zNear' coefficient.

zNear coef. is only used in perspective mode.

◆ showPivotSymbol()

void ccGLWindow::showPivotSymbol ( bool  state)
virtual

Shows or hide the pivot symbol.

Warnings:

  • not to be mistaken with setPivotVisibility
  • only taken into account if pivot visibility is set to PIVOT_SHOW_ON_MOVE

◆ startPicking()

void ccGLWindow::startPicking ( PickingParameters &  params)
protected

Starts picking process.

Parameters
paramspicking parameters

◆ togglePerspective()

void ccGLWindow::togglePerspective ( bool  objectCentered)
virtual

Toggles perspective mode.

If perspective is activated, the user must specify if it should be object or viewer based (see setPerspectiveState)

◆ updateActiveItemsList()

void ccGLWindow::updateActiveItemsList ( int  x,
int  y,
bool  extendToSelectedLabels = false 
)
protected

Updates currently active items list (m_activeItems)

The items must be currently displayed in this context AND at least one of them must be under the mouse cursor.

◆ updateConstellationCenterAndZoom()

void ccGLWindow::updateConstellationCenterAndZoom ( const ccBBox *  boundingBox = nullptr)
virtual

Center and zoom on a given bounding box.

If no bounding box is defined, the current displayed 'scene graph' bounding box is used.

Parameters
boundingBoxbounding box to zoom on

Member Data Documentation

◆ m_activeItems

std::list<ccInteractor*> ccGLWindow::m_activeItems
protected

Currently active items.

Active items can be moved with mouse, etc.

◆ m_customLightPos

float ccGLWindow::m_customLightPos[4]
protected

Custom light position.

Relative to object.

◆ m_sunLightPos

float ccGLWindow::m_sunLightPos[4]
protected

Sun light position.

Relative to screen.


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