Radium Engine  1.5.0
Ra::Gui::BaseApplication Class Reference

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

#include <Gui/BaseApplication.hpp>

Inherits QApplication.

+ 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. More...
 
bool isRunning () const
 
const Engine::RadiumEnginegetEngine () const
 
uint getFrameCount () const
 
const std::string & getExportFolderName () 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::string > m_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:

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.

◆ 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:

◆ 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.

◆ 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:

◆ 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:

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