Radium Engine  1.5.20
Loading...
Searching...
No Matches
Ra::Gui::BaseApplication Class Reference

This class contains the main application logic. It owns the engine and the GUI. More...

#include <Gui/BaseApplication.hpp>

+ Collaboration diagram for Ra::Gui::BaseApplication:

Public Slots

virtual void engineOpenGLInitialize ()
 slot called when the OpenGL need to be initialized
 
virtual void initializeGl ()
 
void updateRadiumFrameIfNeeded ()
 
bool loadFile (QString path)
 
void framesCountForStatsChanged (uint count)
 
void appNeedsToQuit ()
 
void setRealFrameRate (bool on)
 
void setRecordFrames (bool on)
 
void setRecordTimings (bool on)
 
void setRecordGraph (bool on)
 
void recordFrame ()
 
void onSelectedItem (const Ra::Engine::Scene::ItemEntry &entry)
 
void setContinuousUpdate (bool b)
 
void askForUpdate ()
 

Signals

void starting ()
 Fired when the engine has just started, before the frame timer is set.
 
void stopping ()
 Fired when the engine is about to stop.
 
void sceneChanged (const Core::Aabb &)
 Fired when the scene has changed.
 
void updateFrameStats (const std::vector< FrameTimerData > &)
 
void loadComplete ()
 
void selectedItem (const Ra::Engine::Scene::ItemEntry &entry)
 

Public Member Functions

 BaseApplication (int &argc, char **argv, QString applicationName="RadiumEngine", QString organizationName="STORM-IRIT")
 
void initialize (const WindowFactory &factory, const glbinding::Version &glVersion={ 4, 1 })
 
virtual void engineBaseInitialization ()
 
virtual void addApplicationExtension ()
 
void radiumFrame ()
 Advance the engine for one frame.
 
bool isRunning () const
 
const Engine::RadiumEnginegetEngine () const
 
ViewergetViewer ()
 
uint getFrameCount () const
 
const std::stringgetExportFolderName () const
 
void addPluginDirectory (const std::string &pluginDir)
 Allow the user to register a specific plugin directory for the application.
 
void clearPluginDirectories ()
 Remove all registered plugin directories (except the default Radium Bundle one)
 
void editSettings ()
 
virtual std::string getHelpText () const
 Get the html formatted help text.
 
void addRadiumMenu ()
 

Public Attributes

std::unique_ptr< Gui::MainWindowInterfacem_mainWindow
 Application main window and GUI root class.
 
Engine::RadiumEnginem_engine
 Instance of the radium engine.
 
std::unique_ptr< Core::TaskQueuem_taskQueue
 Task queue for processing tasks.
 
uint m_targetFPS
 Number of frames per second to generate.
 

Protected Member Functions

void createConnections ()
 Create signal / slots connections.
 
bool loadPlugins (const std::string &pluginsPath, const QStringList &loadList, const QStringList &ignoreList)
 
void setupScene ()
 
bool isUpdateNeeded ()
 check wheter someone ask for update
 
void setIsUpdateNeeded (bool b)
 if b is true, then update anyway. If b is false, update on request only
 

Protected Attributes

std::vector< Ra::Plugins::RadiumPluginInterface * > m_openGLPlugins
 Plugins that need to be initialized once OpenGL is ready.
 
Gui::Viewerm_viewer
 Pointer to OpenGL Viewer for render call (belongs to MainWindow).
 
QTimer * m_frameTimer
 Timer to wake us up at every frame start.
 
Core::Utils::TimePoint m_lastFrameStart
 Time since the last frame start.
 
uint m_frameCounter
 
uint m_frameCountBeforeUpdate
 
uint m_numFrames
 
uint m_maxThreads
 
std::vector< FrameTimerDatam_timerData
 
std::string m_pluginPath
 
bool m_realFrameRate
 If true, use the wall clock to advance the engine. If false, use a fixed time step.
 
std::string m_exportFoldername
 Name of the folder where exported data goes.
 
bool m_recordFrames
 If true, dump each frame to a PNG file.
 
bool m_recordTimings
 If true, print the detailed timings of each frame.
 
bool m_recordGraph
 If true, print the task graph;.
 
bool m_isAboutToQuit
 True if the applicatioon is about to quit. prevent to use resources that are being released.
 
std::atomic_bool m_isUpdateNeeded { true }
 If true update the viewer frame next time.
 
std::atomic< int > m_continuousUpdateRequest { 1 }
 If counter is >= 0, continuously update viewer frame.
 
Plugins::Context m_pluginContext
 
QCommandLineParser * m_parser
 
std::map< std::string, std::stringm_loadedPlugins
 maps name and paths of already loaded plugins
 

Detailed Description

This class contains the main application logic. It owns the engine and the GUI.

Definition at line 31 of file BaseApplication.hpp.

Constructor & Destructor Documentation

◆ BaseApplication()

Ra::Gui::BaseApplication::BaseApplication ( int & argc,
char ** argv,
QString applicationName = "RadiumEngine",
QString organizationName = "STORM-IRIT" )

Setup the application, create main window and main connections.

Parameters
argcfrom main()
argvfrom main()
applicationNameName of the application (used to store settings)
organizationNameName of the organization (used to store settings)

The arguments managed from the command line are the following :

QCommandLineOption fpsOpt(
QStringList { "r", "framerate", "fps" },
"Control the application framerate, 0 to disable it (and run as fast as possible).",
"number",
"60" );
QCommandLineOption maxThreadsOpt(
QStringList { "m", "maxthreads", "max-threads" },
"Control the maximum number of threads. 0 will set to the number of cores available",
"number",
"0" );
QCommandLineOption numFramesOpt(
QStringList { "n", "numframes" }, "Run for a fixed number of frames.", "number", "0" );
QCommandLineOption pluginOpt( QStringList { "p", "plugins", "pluginsPath" },
"Set the path to the plugin dlls.",
"folder",
"Plugins" );
QCommandLineOption pluginLoadOpt(
QStringList { "l", "load", "loadPlugin" },
"Only load plugin with the given name (filename without the extension). If this option is "
"not used, all plugins in the plugins folder will be loaded. ",
"name" );
QCommandLineOption pluginIgnoreOpt( QStringList { "i", "ignore", "ignorePlugin" },
"Ignore plugins with the given name. If the name appears "
"within both load and ignore options, it will be ignored.",
"name" );
QCommandLineOption fileOpt( QStringList { "f", "file", "scene" },
"Open a scene file at startup.",
"file name",
"foo.bar" );
QCommandLineOption camOpt( QStringList { "c", "camera", "cam" },
"Open a camera file at startup",
"file name",
"foo.bar" );
QCommandLineOption recordOpt( QStringList { "s", "recordFrames" },
"Enable snapshot recording." );
QCommandLineOption datapathOpt( QStringList { "d", "data", "export" },
"Set the default data path and store it in the settings.",
"folder",
"./" );
Todo
check optional

[Command line arguments]

[Command line arguments]

Definition at line 62 of file BaseApplication.cpp.

+ Here is the call graph for this function:

◆ ~BaseApplication()

Ra::Gui::BaseApplication::~BaseApplication ( )
override

Definition at line 578 of file BaseApplication.cpp.

Member Function Documentation

◆ addApplicationExtension()

virtual void Ra::Gui::BaseApplication::addApplicationExtension ( )
inlinevirtual

Allow derived applications to add specific extensions to the engine and the base application. Such extensions are expected to be :

  • specific file loaders
  • specific plugins
  • specific global resources needed by the application (Textures, shaders, ...) This method could also be used to populate the engine with systems or with OpenGL related services if this was not already done in the appropriate methods (engineBaseInitialization, engineOpenGLInitialize, initializeGl)
  • specific renderers (could be added instead when configuring OpenGL)

Definition at line 123 of file BaseApplication.hpp.

◆ addPluginDirectory()

void Ra::Gui::BaseApplication::addPluginDirectory ( const std::string & pluginDir)

Allow the user to register a specific plugin directory for the application.

Definition at line 755 of file BaseApplication.cpp.

+ Here is the call graph for this function:

◆ addRadiumMenu()

void Ra::Gui::BaseApplication::addRadiumMenu ( )

Definition at line 389 of file BaseApplication.cpp.

◆ appNeedsToQuit

void Ra::Gui::BaseApplication::appNeedsToQuit ( )
slot

Definition at line 546 of file BaseApplication.cpp.

◆ askForUpdate

void Ra::Gui::BaseApplication::askForUpdate ( )
inlineslot

Definition at line 205 of file BaseApplication.hpp.

◆ clearPluginDirectories()

void Ra::Gui::BaseApplication::clearPluginDirectories ( )

Remove all registered plugin directories (except the default Radium Bundle one)

Definition at line 767 of file BaseApplication.cpp.

◆ createConnections()

void Ra::Gui::BaseApplication::createConnections ( )
protected

Create signal / slots connections.

Definition at line 412 of file BaseApplication.cpp.

+ Here is the call graph for this function:

◆ editSettings()

void Ra::Gui::BaseApplication::editSettings ( )

Open the QSetting editor for the current application

Todo
implement the editor

Definition at line 772 of file BaseApplication.cpp.

◆ engineBaseInitialization()

void Ra::Gui::BaseApplication::engineBaseInitialization ( )
virtual

This method configure the base, non opengl dependant, scene services.

It is expected that this method add the Engine's systems required by the application. and configure the engine time management properties. The default implementation add the following systems :

  • Ra::Engine::GeometrySystem

The default implementation also configure the time system according to the user requested frame rate (app command line argument -framerate) or to the default 60fps.

Definition at line 374 of file BaseApplication.cpp.

+ Here is the call graph for this function:

◆ engineOpenGLInitialize

void Ra::Gui::BaseApplication::engineOpenGLInitialize ( )
virtualslot

slot called when the OpenGL need to be initialized

Definition at line 407 of file BaseApplication.cpp.

+ Here is the call graph for this function:

◆ framesCountForStatsChanged

void Ra::Gui::BaseApplication::framesCountForStatsChanged ( uint count)
slot

Definition at line 465 of file BaseApplication.cpp.

◆ getEngine()

const Engine::RadiumEngine * Ra::Gui::BaseApplication::getEngine ( ) const
inline

Definition at line 130 of file BaseApplication.hpp.

◆ getExportFolderName()

const std::string & Ra::Gui::BaseApplication::getExportFolderName ( ) const
inline

Definition at line 135 of file BaseApplication.hpp.

◆ getFrameCount()

uint Ra::Gui::BaseApplication::getFrameCount ( ) const
inline

Definition at line 133 of file BaseApplication.hpp.

◆ getHelpText()

std::string Ra::Gui::BaseApplication::getHelpText ( ) const
virtual

Get the html formatted help text.

Definition at line 778 of file BaseApplication.cpp.

◆ getViewer()

Viewer * Ra::Gui::BaseApplication::getViewer ( )
inline

Definition at line 131 of file BaseApplication.hpp.

◆ initialize()

void Ra::Gui::BaseApplication::initialize ( const WindowFactory & factory,
const glbinding::Version & glVersion = { 4, 1 } )

Initialize the application, create the Gui and OpenGL environment. The initialization of an application is made in several steps

  1. Create and initialize the engine and its non-OpenGL services
    • Once the engine singleton is instanciated, call the BaseApplication's virtual method engineBaseInitialization to populate the engine with the base systems (eg. GeometrySystem) and configure the non-openGL engine services.
  2. Create and initialize the openGL environment
    • When the openGL context is ready and bound, call the BaseApplication's virtual method engineOpenGLInitialize (this method is a virtual slot connected to the event Gui::Viewer::requestEngineOpenGLInitialization).
    • When the application and its opengl window are ready, call the BaseApplication's virtual method initializeGl (this method is a virtual slot connected to the event Gui::Viewer::glInitialized).
  3. Create Plugin context, load plugins, configure base Radium::IO services
    • The plugins located int the registered plugin paths (into the Radium Engine or bundled with the installed application, into paths found in the app configuration file) are loaded automatically.
    • The Radium::IO services compiled into the Radium bundle are configured (file loaders)
    • After plugins and default services are configured, call the BaseApplication's virtual method addApplicationExtension.
  4. Manage scene related command-line argument
    • loads the given scene, ...
Parameters
factory: a functor that instanciate the mainWindow
glVersion: glbinding::Version of the requested OpenGL Version. If no version is given, the default recommended version for Radium (4.1) will be requested.
Note
The initialize method call virtual methods on the object being initialized to configure the engine and application services. When redefining those methods, it is recommended to call the inherited one to have consistent initialization wrt the BaseApplication ancestor. The initialize method could be also overloaded by derived classes. In this case, it is recommended that the overload explicetely call the ancestor method..
Todo
allow the user to ask for some "standard" systems to be added to the initialized Engine.
Todo
Code updated wrt camera manager, TEST IT !

Definition at line 248 of file BaseApplication.cpp.

+ Here is the call graph for this function:

◆ initializeGl

void Ra::Gui::BaseApplication::initializeGl ( )
virtualslot

slot called once the application window and its OpenGL services are ready. TODO : rename this to be more representative of post opengl & gui operations

Definition at line 551 of file BaseApplication.cpp.

+ Here is the call graph for this function:

◆ isRunning()

bool Ra::Gui::BaseApplication::isRunning ( ) const
inline

Definition at line 128 of file BaseApplication.hpp.

◆ isUpdateNeeded()

bool Ra::Gui::BaseApplication::isUpdateNeeded ( )
inlineprotected

check wheter someone ask for update

Definition at line 222 of file BaseApplication.hpp.

◆ loadFile

bool Ra::Gui::BaseApplication::loadFile ( QString path)
slot

Definition at line 446 of file BaseApplication.cpp.

◆ loadPlugins()

bool Ra::Gui::BaseApplication::loadPlugins ( const std::string & pluginsPath,
const QStringList & loadList,
const QStringList & ignoreList )
protected

Load plugins from the specified folder. If loadList is empty, attempts to load all DLLs in the folder (except those on the ignore list) If loadList contains names it will only look for DLLs in that folder with the given name.

Definition at line 588 of file BaseApplication.cpp.

+ Here is the call graph for this function:

◆ onSelectedItem

void Ra::Gui::BaseApplication::onSelectedItem ( const Ra::Engine::Scene::ItemEntry & entry)
inlineslot

Definition at line 197 of file BaseApplication.hpp.

◆ radiumFrame()

void Ra::Gui::BaseApplication::radiumFrame ( )

Advance the engine for one frame.

Todo
make rendering one gpu task.

Definition at line 469 of file BaseApplication.cpp.

+ Here is the call graph for this function:

◆ recordFrame

void Ra::Gui::BaseApplication::recordFrame ( )
slot

Definition at line 571 of file BaseApplication.cpp.

◆ setContinuousUpdate

void Ra::Gui::BaseApplication::setContinuousUpdate ( bool b)
inlineslot

Definition at line 199 of file BaseApplication.hpp.

◆ setIsUpdateNeeded()

void Ra::Gui::BaseApplication::setIsUpdateNeeded ( bool b)
inlineprotected

if b is true, then update anyway. If b is false, update on request only

Definition at line 225 of file BaseApplication.hpp.

◆ setRealFrameRate

void Ra::Gui::BaseApplication::setRealFrameRate ( bool on)
slot

Definition at line 561 of file BaseApplication.cpp.

◆ setRecordFrames

void Ra::Gui::BaseApplication::setRecordFrames ( bool on)
slot

Definition at line 565 of file BaseApplication.cpp.

◆ setRecordGraph

void Ra::Gui::BaseApplication::setRecordGraph ( bool on)
slot

Definition at line 751 of file BaseApplication.cpp.

◆ setRecordTimings

void Ra::Gui::BaseApplication::setRecordTimings ( bool on)
slot

Definition at line 747 of file BaseApplication.cpp.

◆ setupScene()

void Ra::Gui::BaseApplication::setupScene ( )
protected

Definition at line 428 of file BaseApplication.cpp.

◆ updateRadiumFrameIfNeeded

void Ra::Gui::BaseApplication::updateRadiumFrameIfNeeded ( )
inlineslot

Definition at line 176 of file BaseApplication.hpp.

Member Data Documentation

◆ m_continuousUpdateRequest

std::atomic<int> Ra::Gui::BaseApplication::m_continuousUpdateRequest { 1 }
protected

If counter is >= 0, continuously update viewer frame.

Definition at line 282 of file BaseApplication.hpp.

◆ m_engine

Engine::RadiumEngine* Ra::Gui::BaseApplication::m_engine

Instance of the radium engine.

Definition at line 233 of file BaseApplication.hpp.

◆ m_exportFoldername

std::string Ra::Gui::BaseApplication::m_exportFoldername
protected

Name of the folder where exported data goes.

Definition at line 266 of file BaseApplication.hpp.

◆ m_frameCountBeforeUpdate

uint Ra::Gui::BaseApplication::m_frameCountBeforeUpdate
protected

Definition at line 255 of file BaseApplication.hpp.

◆ m_frameCounter

uint Ra::Gui::BaseApplication::m_frameCounter
protected

Definition at line 254 of file BaseApplication.hpp.

◆ m_frameTimer

QTimer* Ra::Gui::BaseApplication::m_frameTimer
protected

Timer to wake us up at every frame start.

Definition at line 249 of file BaseApplication.hpp.

◆ m_isAboutToQuit

bool Ra::Gui::BaseApplication::m_isAboutToQuit
protected

True if the applicatioon is about to quit. prevent to use resources that are being released.

Definition at line 276 of file BaseApplication.hpp.

◆ m_isUpdateNeeded

std::atomic_bool Ra::Gui::BaseApplication::m_isUpdateNeeded { true }
protected

If true update the viewer frame next time.

Definition at line 279 of file BaseApplication.hpp.

◆ m_lastFrameStart

Core::Utils::TimePoint Ra::Gui::BaseApplication::m_lastFrameStart
protected

Time since the last frame start.

Definition at line 252 of file BaseApplication.hpp.

◆ m_loadedPlugins

std::map<std::string, std::string> Ra::Gui::BaseApplication::m_loadedPlugins
protected

maps name and paths of already loaded plugins

Definition at line 288 of file BaseApplication.hpp.

◆ m_mainWindow

std::unique_ptr<Gui::MainWindowInterface> Ra::Gui::BaseApplication::m_mainWindow

Application main window and GUI root class.

Definition at line 230 of file BaseApplication.hpp.

◆ m_maxThreads

uint Ra::Gui::BaseApplication::m_maxThreads
protected

Definition at line 257 of file BaseApplication.hpp.

◆ m_numFrames

uint Ra::Gui::BaseApplication::m_numFrames
protected

Definition at line 256 of file BaseApplication.hpp.

◆ m_openGLPlugins

std::vector<Ra::Plugins::RadiumPluginInterface*> Ra::Gui::BaseApplication::m_openGLPlugins
protected

Plugins that need to be initialized once OpenGL is ready.

Definition at line 243 of file BaseApplication.hpp.

◆ m_parser

QCommandLineParser* Ra::Gui::BaseApplication::m_parser
protected

Definition at line 285 of file BaseApplication.hpp.

◆ m_pluginContext

Plugins::Context Ra::Gui::BaseApplication::m_pluginContext
protected

Definition at line 284 of file BaseApplication.hpp.

◆ m_pluginPath

std::string Ra::Gui::BaseApplication::m_pluginPath
protected

Definition at line 259 of file BaseApplication.hpp.

◆ m_realFrameRate

bool Ra::Gui::BaseApplication::m_realFrameRate
protected

If true, use the wall clock to advance the engine. If false, use a fixed time step.

Definition at line 262 of file BaseApplication.hpp.

◆ m_recordFrames

bool Ra::Gui::BaseApplication::m_recordFrames
protected

If true, dump each frame to a PNG file.

Definition at line 269 of file BaseApplication.hpp.

◆ m_recordGraph

bool Ra::Gui::BaseApplication::m_recordGraph
protected

If true, print the task graph;.

Definition at line 273 of file BaseApplication.hpp.

◆ m_recordTimings

bool Ra::Gui::BaseApplication::m_recordTimings
protected

If true, print the detailed timings of each frame.

Definition at line 271 of file BaseApplication.hpp.

◆ m_targetFPS

uint Ra::Gui::BaseApplication::m_targetFPS

Number of frames per second to generate.

Definition at line 239 of file BaseApplication.hpp.

◆ m_taskQueue

std::unique_ptr<Core::TaskQueue> Ra::Gui::BaseApplication::m_taskQueue

Task queue for processing tasks.

Definition at line 236 of file BaseApplication.hpp.

◆ m_timerData

std::vector<FrameTimerData> Ra::Gui::BaseApplication::m_timerData
protected

Definition at line 258 of file BaseApplication.hpp.

◆ m_viewer

Gui::Viewer* Ra::Gui::BaseApplication::m_viewer
protected

Pointer to OpenGL Viewer for render call (belongs to MainWindow).

Definition at line 246 of file BaseApplication.hpp.


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