Radium Engine
1.5.20
|
#include <Gui/Viewer/Viewer.hpp>
Public Slots | |
void | reloadShaders () |
Tell the renderer to reload all shaders. | |
void | displayTexture (const QString &tex) |
Set the final display texture. | |
bool | changeRenderer (int index) |
Set the renderer. | |
void | enablePostProcess (int enabled) |
Toggle the post-process effetcs. | |
void | enableDebugDraw (int enabled) |
Toggle the debug drawing. | |
void | setBackgroundColor (const Core::Utils::Color &background) |
void | displayHelpDialog () |
Public Slots inherited from Ra::Gui::WindowQt | |
void | cleanupGL () |
call deinitializeGL if needed, with context activated | |
void | screenChanged () |
Signals | |
void | requestEngineOpenGLInitialization () |
bool | glInitialized () |
void | rendererReady () |
Emitted when GL context is ready. We except call to addRenderer here. | |
void | rightClickPicking (const Ra::Engine::Rendering::Renderer::PickingResult &result) |
Emitted when the rendered is correctly initialized. | |
void | toggleBrushPicking (bool on) |
Emitted when the corresponding key is released (see keyReleaseEvent) | |
void | needUpdate () |
void | onMousePress (QMouseEvent *event) |
Event sent after a mouse press event has been processed, but before emitting needUpdate() | |
void | onMouseRelease (QMouseEvent *event) |
Event sent after a mouse release event has been processed, but before emitting needUpdate() | |
void | onMouseMove (QMouseEvent *event) |
Event sent after a mouse move event has been processed, but before emitting needUpdate() | |
Signals inherited from Ra::Gui::WindowQt | |
void | dpiChanged () |
Emitted when physical device changes. Useful for tracking devicePixelRatio() change. | |
Public Member Functions | |
Viewer (QScreen *screen=nullptr) | |
Constructor. | |
~Viewer () override | |
Destructor. | |
virtual void | setupKeyMappingCallbacks () |
add observers to keyMappingManager for gizmo, camera and viewer. | |
virtual bool | prepareDisplay () |
QOpenGLContext * | getContext () const |
Access to the OpenGL context of the Viewer. | |
void | setCameraManipulator (CameraManipulator *ci) |
Set the current camera interface. | |
CameraManipulator * | getCameraManipulator () |
Access to camera interface. | |
void | resetToDefaultCamera () |
GizmoManager * | getGizmoManager () |
Access to gizmo manager. | |
const Engine::Rendering::Renderer * | getRenderer () const |
Read-only access to renderer. | |
Engine::Rendering::Renderer * | getRenderer () |
Read-write access to renderer. | |
int | addRenderer (const std::shared_ptr< Engine::Rendering::Renderer > &e) |
PickingManager * | getPickingManager () |
Access to the feature picking manager. | |
virtual void | update (const Scalar dt) |
Update the internal viewer state to the (application) time dt. | |
void | startRendering (const Scalar dt) |
Start rendering (potentially asynchronously in a separate thread) | |
void | swapBuffers () |
Blocks until rendering is finished. | |
Scalar | getDepthUnderMouse () const |
Core::Vector2 | toDevice (const Core::Vector2 &logicCoordinates) |
Misc functions | |
void | processPicking () |
Emits signals corresponding to picking requests. | |
void | fitCameraToScene (const Core::Aabb &sceneAabb) |
Moves the camera so that the whole scene is visible. | |
void | fitCamera () |
std::vector< std::string > | getRenderersName () const |
Returns the names of the different registred renderers. | |
void | grabFrame (const std::string &filename) |
Write the current frame as an image. Supports either BMP or PNG file names. | |
void | enableDebug () |
const Core::Utils::Color & | getBackgroundColor () const |
get the currently used background color | |
KeyMappingManager::KeyMappingAction | addCustomAction (const std::string &actionName, const KeyMappingManager::EventBinding &binding, std::function< void(QEvent *)> callback) |
Add a custom event callback. | |
Public Member Functions inherited from Ra::Gui::WindowQt | |
WindowQt (QScreen *screen) | |
void | resizeEvent (QResizeEvent *event) override |
void | showEvent (QShowEvent *event) override |
void | exposeEvent (QExposeEvent *event) override |
virtual void | enterEvent (QEvent *event) |
paintgl is done by main rendering loop | |
virtual void | leaveEvent (QEvent *event) |
void | makeCurrent () |
void | doneCurrent () |
ScopedGLContext | activateScopedContext () |
QOpenGLContext * | context () |
bool | isOpenGlInitialized () const |
Protected Types | |
enum | KeyEventType { KeyPressed = 0 , KeyReleased , KeyEventTypeCount } |
Name of the customisable key actions. More... | |
Protected Member Functions | |
void | createGizmoManager () |
create gizmos | |
void | initializeRenderer (Engine::Rendering::Renderer *renderer) |
Initialize renderer internal state + configure lights. | |
bool | initializeGL () override |
void | resizeGL (QResizeEvent *event) override |
Resize the view port and the camera. Called by the resize event. | |
Engine::Rendering::Renderer::PickingMode | getPickingMode (const Ra::Gui::KeyMappingManager::KeyMappingAction &action) const |
void | showEvent (QShowEvent *ev) override |
void | focusOutEvent (QFocusEvent *event) override |
reset key pressed, in case a key is pressed when focus lost | |
If GL is initialized, do the viewer stuff, and call handle*Event to perform actual event handling, according to keyMapping. If event is not processed by Viewer, it's forwarded to parent() (if any). | |
void | keyPressEvent (QKeyEvent *event) override |
void | keyReleaseEvent (QKeyEvent *event) override |
void | mousePressEvent (QMouseEvent *event) override |
void | mouseReleaseEvent (QMouseEvent *event) override |
void | mouseMoveEvent (QMouseEvent *event) override |
void | wheelEvent (QWheelEvent *event) override |
handle the events, called by *Event, do the actual work, should be overriden in derived classes. | |
virtual bool | handleKeyPressEvent (QKeyEvent *event) |
virtual bool | handleKeyReleaseEvent (QKeyEvent *event) |
virtual void | handleMousePressEvent (QMouseEvent *event, Ra::Engine::Rendering::Renderer::PickingResult &result) |
virtual void | handleMouseReleaseEvent (QMouseEvent *event) |
virtual void | handleMouseMoveEvent (QMouseEvent *event, Ra::Engine::Rendering::Renderer::PickingResult &result) |
virtual void | handleWheelEvent (QWheelEvent *event) |
Protected Member Functions inherited from Ra::Gui::WindowQt | |
void | initialize () |
void | resizeInternal (QResizeEvent *event) |
virtual void | deinitializeGL () |
DeInitialize the OpenGL. | |
Protected Member Functions inherited from Ra::Gui::KeyMappingManageable< Viewer > | |
Viewer & | self () |
Protected Attributes | |
std::vector< std::shared_ptr< Engine::Rendering::Renderer > > | m_renderers |
std::vector< std::shared_ptr< Engine::Rendering::Renderer > > | m_pendingRenderers |
Engine::Rendering::Renderer * | m_currentRenderer |
PickingManager * | m_pickingManager |
Owning Pointer to the feature picking manager. | |
bool | m_isBrushPickingEnabled |
Scalar | m_brushRadius |
std::unique_ptr< CameraManipulator > | m_camera |
Owning pointer to the camera. | |
GizmoManager * | m_gizmoManager |
Owning (QObject child) pointer to gizmo manager. | |
Core::Utils::Color | m_backgroundColor { Core::Utils::Color::Grey( 0.0392_ra, 0_ra ) } |
std::array< std::map< Core::Utils::Index, std::function< void(QKeyEvent *)> >, KeyEventTypeCount > | m_customKeyActions |
KeyMappingCallbackManager | m_keyMappingCallbackManager |
KeyMappingManager::Context | m_activeContext {} |
Protected Attributes inherited from Ra::Gui::WindowQt | |
std::unique_ptr< QOpenGLContext > | m_context |
bool | m_updatePending |
std::atomic_bool | m_glInitialized |
Friends | |
class | KeyMappingManageable< Viewer > |
Additional Inherited Members | |
Static Public Member Functions inherited from Ra::Gui::KeyMappingManageable< Viewer > | |
static KeyMappingManager::Context | getContext () |
static void | configureKeyMapping () |
Static Protected Member Functions inherited from Ra::Gui::WindowQt | |
static glbinding::ProcAddress | getProcAddress (const char *name) |
Static Protected Member Functions inherited from Ra::Gui::KeyMappingManageable< Viewer > | |
static void | setContext (const KeyMappingManager::Context &c) |
The Viewer is the main display class. It could be used as an independant window or can be set as a central widget on a more complex gui by using the adapter from QWindow to QWidget To do that, the following code could be used :
Whatever its usage (QWindow or QWidget) the Viewer has the same funtionalities. Its acts as a bridge between the interface, the engine and the renderer Among its responsibilities are :
Definition at line 53 of file Viewer.hpp.
|
protected |
Name of the customisable key actions.
Definition at line 319 of file Viewer.hpp.
|
explicit |
Constructor.
Definition at line 140 of file Viewer.cpp.
|
override |
KeyMappingManager::KeyMappingAction Ra::Gui::Viewer::addCustomAction | ( | const std::string & | actionName, |
const KeyMappingManager::EventBinding & | binding, | ||
std::function< void(QEvent *)> | callback ) |
Add a custom event callback.
Definition at line 849 of file Viewer.cpp.
int Ra::Gui::Viewer::addRenderer | ( | const std::shared_ptr< Engine::Rendering::Renderer > & | e | ) |
Add a renderer and return its index. Need to be called when catching
e | : your own renderer |
Definition at line 188 of file Viewer.cpp.
|
slot |
Set the renderer.
Definition at line 377 of file Viewer.cpp.
|
protected |
create gizmos
Definition at line 444 of file Viewer.cpp.
|
slot |
Definition at line 841 of file Viewer.cpp.
|
slot |
Set the final display texture.
Definition at line 365 of file Viewer.cpp.
void Ra::Gui::Viewer::enableDebug | ( | ) |
Definition at line 337 of file Viewer.cpp.
|
slot |
Toggle the debug drawing.
Definition at line 409 of file Viewer.cpp.
|
slot |
Toggle the post-process effetcs.
Definition at line 405 of file Viewer.cpp.
void Ra::Gui::Viewer::fitCamera | ( | ) |
Definition at line 302 of file Viewer.cpp.
void Ra::Gui::Viewer::fitCameraToScene | ( | const Core::Aabb & | sceneAabb | ) |
Moves the camera so that the whole scene is visible.
Definition at line 290 of file Viewer.cpp.
|
overrideprotected |
reset key pressed, in case a key is pressed when focus lost
Definition at line 636 of file Viewer.cpp.
|
inline |
get the currently used background color
Definition at line 148 of file Viewer.hpp.
CameraManipulator * Ra::Gui::Viewer::getCameraManipulator | ( | ) |
Access to camera interface.
Definition at line 165 of file Viewer.cpp.
|
inline |
Access to the OpenGL context of the Viewer.
Definition at line 79 of file Viewer.hpp.
|
inline |
Definition at line 157 of file Viewer.hpp.
GizmoManager * Ra::Gui::Viewer::getGizmoManager | ( | ) |
Access to gizmo manager.
Definition at line 176 of file Viewer.cpp.
PickingManager * Ra::Gui::Viewer::getPickingManager | ( | ) |
Access to the feature picking manager.
Definition at line 207 of file Viewer.cpp.
|
protected |
Definition at line 539 of file Viewer.cpp.
Engine::Rendering::Renderer * Ra::Gui::Viewer::getRenderer | ( | ) |
Read-write access to renderer.
Definition at line 184 of file Viewer.cpp.
const Engine::Rendering::Renderer * Ra::Gui::Viewer::getRenderer | ( | ) | const |
Read-only access to renderer.
Definition at line 180 of file Viewer.cpp.
std::vector< std::string > Ra::Gui::Viewer::getRenderersName | ( | ) | const |
Returns the names of the different registred renderers.
Definition at line 308 of file Viewer.cpp.
void Ra::Gui::Viewer::grabFrame | ( | const std::string & | filename | ) |
Write the current frame as an image. Supports either BMP or PNG file names.
Definition at line 318 of file Viewer.cpp.
|
protectedvirtual |
Definition at line 658 of file Viewer.cpp.
|
protectedvirtual |
Definition at line 681 of file Viewer.cpp.
|
protectedvirtual |
Definition at line 766 of file Viewer.cpp.
|
protectedvirtual |
[event dispatch]
[event dispatch]
Definition at line 698 of file Viewer.cpp.
|
protectedvirtual |
Definition at line 756 of file Viewer.cpp.
|
protectedvirtual |
Definition at line 797 of file Viewer.cpp.
|
overrideprotectedvirtual |
Initialize openGL. Called on by the first "show" call to the main window.
Reimplemented from Ra::Gui::WindowQt.
Definition at line 460 of file Viewer.cpp.
|
protected |
Initialize renderer internal state + configure lights.
Definition at line 448 of file Viewer.cpp.
|
overrideprotected |
Definition at line 561 of file Viewer.cpp.
|
overrideprotected |
Definition at line 569 of file Viewer.cpp.
|
overrideprotected |
Definition at line 600 of file Viewer.cpp.
|
overrideprotected |
We intercept the mouse events in this widget to get the coordinates of the mouse in screen space.
Definition at line 577 of file Viewer.cpp.
|
overrideprotected |
Definition at line 594 of file Viewer.cpp.
|
virtual |
Prepare the viewer to display a scene. This will ask the renderer to build its specific OenGL related objects and set the camera to its default state
Definition at line 827 of file Viewer.cpp.
void Ra::Gui::Viewer::processPicking | ( | ) |
Emits signals corresponding to picking requests.
Definition at line 269 of file Viewer.cpp.
|
slot |
Tell the renderer to reload all shaders.
Definition at line 352 of file Viewer.cpp.
|
signal |
Emitted when GL context is ready and the engine OpenGL part must be initialized. Renderers might be added here using addRenderer.
void Ra::Gui::Viewer::resetToDefaultCamera | ( | ) |
Definition at line 169 of file Viewer.cpp.
|
overrideprotectedvirtual |
Resize the view port and the camera. Called by the resize event.
Reimplemented from Ra::Gui::WindowQt.
Definition at line 527 of file Viewer.cpp.
|
signal |
Emitted when the rendered is correctly initialized.
Emitted when the resut of a right click picking is known (for selection)
|
slot |
Definition at line 413 of file Viewer.cpp.
void Ra::Gui::Viewer::setCameraManipulator | ( | CameraManipulator * | ci | ) |
Set the current camera interface.
Definition at line 161 of file Viewer.cpp.
|
virtual |
add observers to keyMappingManager for gizmo, camera and viewer.
Definition at line 74 of file Viewer.cpp.
|
overrideprotected |
Definition at line 628 of file Viewer.cpp.
void Ra::Gui::Viewer::startRendering | ( | const Scalar | dt | ) |
Start rendering (potentially asynchronously in a separate thread)
Definition at line 218 of file Viewer.cpp.
void Ra::Gui::Viewer::swapBuffers | ( | ) |
Blocks until rendering is finished.
Definition at line 264 of file Viewer.cpp.
|
inline |
Computes device dependent (i.e. framebuffer) 2d coordinates from device independent (i.e. qt's main coordinate system) coordinates.
See https://doc.qt.io/qt-6/highdpi.html
Definition at line 165 of file Viewer.hpp.
|
virtual |
Update the internal viewer state to the (application) time dt.
Definition at line 211 of file Viewer.cpp.
|
overrideprotected |
Definition at line 616 of file Viewer.cpp.
|
friend |
Definition at line 53 of file Viewer.hpp.
|
protected |
Definition at line 327 of file Viewer.hpp.
|
protected |
Definition at line 316 of file Viewer.hpp.
|
protected |
Definition at line 308 of file Viewer.hpp.
|
protected |
Owning pointer to the camera.
Definition at line 311 of file Viewer.hpp.
|
protected |
Definition at line 302 of file Viewer.hpp.
|
protected |
Array of custom key event handler Index is KeyEventType
Definition at line 323 of file Viewer.hpp.
|
protected |
Owning (QObject child) pointer to gizmo manager.
Definition at line 314 of file Viewer.hpp.
|
protected |
Definition at line 307 of file Viewer.hpp.
|
protected |
Definition at line 325 of file Viewer.hpp.
|
protected |
Definition at line 301 of file Viewer.hpp.
|
protected |
Owning Pointer to the feature picking manager.
Definition at line 305 of file Viewer.hpp.
|
protected |
Definition at line 300 of file Viewer.hpp.