Introduces an application class which provides modular architecture. More...
#include <CAM_Application.h>
Classes | |
struct | ModuleInfo |
struct | ModuleShortInfo |
Public Types | |
typedef QList< CAM_Module * > | ModuleList |
typedef QList< ModuleShortInfo > | ModuleShortInfoList |
Public Types inherited from STD_Application | |
enum | { MenuFileId, FileNewId, FileOpenId, FileReopenId, FileCloseId, FileSaveId, FileSaveAsId, FileExitId, MenuViewId, ViewWindowsId, ViewToolBarsId, ViewStatusBarId, NewWindowId, MenuEditId, EditCutId, EditCopyId, EditPasteId, MenuHelpId, HelpAboutId, UserID } |
Public Member Functions | |
CAM_Application (const bool=true) | |
Constructor. More... | |
virtual | ~CAM_Application () |
Destructor. More... | |
virtual void | start () |
Start an application. More... | |
CAM_Module * | activeModule () const |
Get active module. More... | |
CAM_Module * | module (const QString &) const |
Get the module with specified name. More... | |
ModuleList | modules () const |
Get all loaded modules. More... | |
void | modules (ModuleList &) const |
Get all loaded modules. More... | |
void | modules (QStringList &, const bool loaded=true) const |
Get names of all modules. More... | |
virtual void | addModule (CAM_Module *) |
Add module mod to the modules list. More... | |
virtual void | loadModules () |
Load modules from the modules information list. More... | |
virtual CAM_Module * | loadModule (const QString &, const bool=true) |
Load module modName. More... | |
virtual bool | activateModule (const QString &) |
Activate module modName. More... | |
bool | activateOperation (const QString &modName, int actionId) |
Load module modName and activate its operation, corresponding to actionId. This method is dedicated to run operations of some module from any other module. More... | |
bool | activateOperation (const QString &modName, const QString &actionId) |
Load module modName and activate its operation, corresponding to actionId. This method is dedicated to run operations of some module from any other module. More... | |
bool | activateOperation (const QString &modName, const QString &actionId, const QString &pluginName) |
Load module modName and activate its operation, corresponding to actionId and pluginName. This method is dedicated to run operations of some module from any other module. More... | |
virtual void | contextMenuPopup (const QString &, QMenu *, QString &) |
Add common menu items to the popup menu. More... | |
virtual void | createEmptyStudy () |
Create new empty study. More... | |
Public Member Functions inherited from STD_Application | |
STD_Application () | |
virtual | ~STD_Application () |
virtual QString | applicationName () const |
virtual bool | isPossibleToClose (bool &) |
virtual bool | useFile (const QString &) |
void | setEditEnabled (const bool) |
bool | isEditEnabled () const |
void | clearViewManagers () |
virtual void | addViewManager (SUIT_ViewManager *) |
virtual void | removeViewManager (SUIT_ViewManager *) |
SUIT_ViewManager * | activeViewManager () const |
SUIT_ViewManager * | viewManager (const QString &) const |
bool | containsViewManager (SUIT_ViewManager *) const |
ViewManagerList | viewManagers () const |
void | viewManagers (ViewManagerList &) const |
void | viewManagers (const QString &, ViewManagerList &) const |
virtual int | viewManagerId (const SUIT_ViewManager *) const |
virtual QString | getFileFilter (bool open) const |
virtual QString | getFileName (bool open, const QString &initial, const QString &filters, const QString &caption, QWidget *parent) |
QString | getDirectory (const QString &initial, const QString &caption, QWidget *parent) |
virtual void | closeApplication () |
bool | exitConfirmation () const |
void | setExitConfirmation (const bool) |
virtual void | updateDesktopTitle () |
Public Member Functions inherited from SUIT_Application | |
SUIT_Application () | |
virtual | ~SUIT_Application () |
virtual SUIT_Desktop * | desktop () |
Returns main widget (Desktop) of the application (if it exists) More... | |
virtual SUIT_Study * | activeStudy () const |
Returns active Study. If Application supports wirking with several studies this method should be redefined. More... | |
virtual QString | applicationVersion () const |
virtual int | getNbStudies () const |
SUIT_ResourceMgr * | resourceMgr () const |
SUIT_ShortcutMgr * | shortcutMgr () const |
Get access to shortcut manager. More... | |
void | putInfo (const QString &, const int=0) |
Puts the message to the status bar. More... | |
QAction * | action (const int) const |
void | addPostRoutine (void(*theRoutine)()) |
Static Public Member Functions | |
static QString | moduleName (const QString &) |
Get module name by its title (user name). More... | |
static QString | moduleTitle (const QString &) |
Get module title (user name) by its name. More... | |
static QString | moduleIcon (const QString &) |
Get module icon name. More... | |
static bool | isModuleAccessible (const QString &) |
Returns true if module is accessible for the current application. Singleton module can be loaded only in one application object. In other application objects this module will be unavailable. More... | |
static ModuleShortInfoList | getVersionInfo () |
Return information about version of the each module. More... | |
Protected Member Functions | |
virtual SUIT_Study * | createNewStudy () |
Create new study. More... | |
virtual void | updateCommandsStatus () |
Update menu commands status. More... | |
virtual void | moduleAdded (CAM_Module *) |
Callback function, called when the module is added to the application. More... | |
virtual void | beforeCloseDoc (SUIT_Study *) |
Prepare application to study closing. More... | |
virtual void | afterCloseDoc () |
virtual bool | activateModule (CAM_Module *=0) |
Activate module mod. More... | |
virtual void | setActiveStudy (SUIT_Study *) |
Set active study. More... | |
virtual bool | abortAllOperations () |
Abort active operations if there are any. More... | |
Protected Member Functions inherited from STD_Application | |
virtual void | createActions () |
virtual void | setDesktop (SUIT_Desktop *) |
virtual void | loadPreferences () |
virtual void | savePreferences () |
virtual void | studySaved (SUIT_Study *) |
virtual void | studyOpened (SUIT_Study *) |
virtual void | studyCreated (SUIT_Study *) |
virtual void | setActiveViewManager (SUIT_ViewManager *) |
virtual int | openChoice (const QString &) |
virtual bool | openAction (const int, const QString &) |
virtual int | closeChoice (const QString &) |
virtual bool | closeAction (const int, bool &) |
virtual bool | closeDoc (bool ask=true) |
virtual bool | closeActiveDoc (bool permanently=true) |
Protected Member Functions inherited from SUIT_Application | |
SUIT_Application * | startApplication (int, char **) const |
SUIT_Application * | startApplication (const QString &, int, char **) const |
void | setActionShown (QAction *, const bool) |
void | setActionShown (const int, const bool) |
int | actionId (const QAction *) const |
QList< QAction * > | actions () const |
QList< int > | actionIds () const |
int | registerAction (const int, QAction *) |
QAction * | createAction (const int, const QString &, const QIcon &, const QString &, const QString &, const int, QObject *=0, const bool=false, QObject *=0, const char *=0, const QString &=QString()) |
QAction * | createAction (const int, const QString &, const QIcon &, const QString &, const QString &, const QKeySequence &, QObject *=0, const bool=false, QObject *=0, const char *=0, const QString &=QString()) |
int | createTool (const QString &, const QString &=QString()) |
int | createTool (const int, const int, const int=-1) |
int | createTool (const int, const QString &, const int=-1) |
int | createTool (QAction *, const int, const int=-1, const int=-1) |
int | createTool (QAction *, const QString &, const int=-1, const int=-1) |
int | createMenu (const QString &, const int, const int=-1, const int=-1, const int=-1) |
int | createMenu (const QString &, const QString &, const int=-1, const int=-1, const int=-1) |
int | createMenu (const int, const int, const int=-1, const int=-1) |
int | createMenu (const int, const QString &, const int=-1, const int=-1) |
int | createMenu (QAction *, const int, const int=-1, const int=-1, const int=-1) |
int | createMenu (QAction *, const QString &, const int=-1, const int=-1, const int=-1) |
void | setMenuShown (QAction *, const bool) |
void | setMenuShown (const int, const bool) |
void | setToolShown (QAction *, const bool) |
void | setToolShown (const int, const bool) |
Static Protected Member Functions | |
static QString | moduleLibrary (const QString &, const bool=true) |
Get module library name by its title (user name). More... | |
Private Types | |
typedef QList< ModuleInfo > | ModuleInfoList |
Private Member Functions | |
void | readModuleList () |
Read modules information list. More... | |
Private Attributes | |
CAM_Module * | myModule |
active module More... | |
ModuleList | myModules |
loaded modules list More... | |
bool | myAutoLoad |
auto loading flag More... | |
bool | myBlocked |
"blocked" flag, internal usage More... | |
Static Private Attributes | |
static ModuleInfoList | myInfoList |
modules info list More... | |
Additional Inherited Members | |
Public Slots inherited from STD_Application | |
virtual void | onNewDoc () |
virtual bool | onNewDoc (const QString &) |
virtual void | onCloseDoc (bool ask=true) |
virtual void | onSaveDoc () |
virtual bool | onSaveAsDoc () |
virtual void | onOpenDoc () |
virtual bool | onOpenDoc (const QString &) |
virtual bool | onReopenDoc () |
virtual void | onExit () |
virtual void | onCopy () |
virtual void | onPaste () |
virtual void | onViewStatusBar (bool) |
virtual void | onHelpAbout () |
virtual void | onDesktopClosing (SUIT_Desktop *, QCloseEvent *) |
virtual void | onConnectPopupRequest (SUIT_PopupClient *, QContextMenuEvent *) |
Signals inherited from STD_Application | |
void | viewManagerAdded (SUIT_ViewManager *) |
void | viewManagerRemoved (SUIT_ViewManager *) |
void | viewManagerActivated (SUIT_ViewManager *) |
void | appClosed () |
Protected Types inherited from STD_Application | |
enum | { OpenCancel, OpenNew, OpenExist } |
enum | { CloseCancel, CloseSave, CloseDiscard } |
Protected Slots inherited from SUIT_Application | |
virtual void | onDesktopActivated () |
This class defines multi-modular application configuration and behaviour. Each module (CAM_Module) can have own data model, document windows and viewers, etc.
An application provides all necessary functionality for modules management, like
|
private |
typedef QList<CAM_Module*> CAM_Application::ModuleList |
CAM_Application::CAM_Application | ( | const bool | autoLoad = true | ) |
Read modules list (from command line or from resource file). If autoLoad parameter is true
all the modules will be loaded immediately after application starting, otherwise each module will be loaded by demand (with activateModule()).
autoLoad | auto loading flag |
References readModuleList().
|
virtual |
Does nothing currently.
References myModules.
|
protectedvirtual |
Iterates through all modules and asks each of them if there are pending operations that cannot be aborted.
false
if some operation cannot be aborted Reimplemented from STD_Application.
References myModules.
|
virtual |
modName | module name |
true
, if module is loaded and activated successfully and false
otherwise Reimplemented in LightApp_Application.
References SUIT_Application::activeStudy(), addModule(), loadModule(), module(), moduleLibrary(), and myBlocked.
|
protectedvirtual |
Shows error message if module could not be activated in the current study.
mod | module object pointer |
true
, if module is loaded and activated successfully and false
otherwise Reimplemented in LightApp_Application.
References CAM_Module::activateModule(), SUIT_Application::activeStudy(), CAM_Module::connectToStudy(), SUIT_MessageBox::critical(), CAM_Module::deactivateModule(), SUIT_Application::desktop(), CAM_Module::moduleName(), myModule, CAM_Module::setMenuShown(), CAM_Module::setToolShown(), and updateCommandsStatus().
bool CAM_Application::activateOperation | ( | const QString & | modName, |
int | actionId | ||
) |
modName | module name |
actionId | is a numerical unique operation identifier |
true
in case of success and false
otherwise References CAM_Module::activateOperation(), addModule(), isModuleAccessible(), and loadModule().
modName | module name |
actionId | is a string unique operation identifier |
true
in case of success and false
otherwise References CAM_Module::activateOperation(), addModule(), isModuleAccessible(), and loadModule().
bool CAM_Application::activateOperation | ( | const QString & | modName, |
const QString & | actionId, | ||
const QString & | pluginName | ||
) |
modName | module name |
actionId | is a string unique operation identifier |
pluginName | is a name of a plugin where the operation is implemented |
true
in case of success and false
otherwise References CAM_Module::activateOperation(), addModule(), isModuleAccessible(), and loadModule().
CAM_Module * CAM_Application::activeModule | ( | ) | const |
References myModule.
|
virtual |
Performes module initialization. Does nothing if the module is already added.
mod | module being added |
References CAM_Module::initialize(), module(), moduleAdded(), CAM_Module::moduleName(), myInfoList, and myModules.
|
protectedvirtual |
Virtual function. Not implemented here.
Reimplemented from STD_Application.
Reimplemented in LightApp_Application, and SalomeApp_Application.
|
protectedvirtual |
Closes all modules in study theDoc.
theDoc | study |
Reimplemented from STD_Application.
Reimplemented in LightApp_Application.
References myModules.
|
virtual |
Menu items list is defined by the active module.
type | popup menu context |
menu | popup menu |
title | popup menu title, which can be set by the module if required |
Reimplemented from STD_Application.
Reimplemented in LightApp_Application, and SalomeApp_Application.
References activeModule(), and CAM_Module::contextMenuPopup().
|
virtual |
Reimplemented from STD_Application.
Reimplemented in LightApp_Application.
References SUIT_Application::activeStudy(), and STD_Application::createEmptyStudy().
|
protectedvirtual |
Reimplemented from SUIT_Application.
Reimplemented in LightApp_Application, and SalomeApp_Application.
|
static |
|
static |
title | module title (user name) |
true
if module is accessible (can be loaded) or false
otherwise References app, SUIT_Session::applications(), modules(), myInfoList, and SUIT_Session::session().
|
virtual |
The function prints warning message if:
modName | module name |
Reimplemented in LightApp_Application.
References SUIT_Application::desktop(), GET_MODULE_NAME, GET_VERSION_NAME, isModuleAccessible(), module(), moduleLibrary(), moduleName(), myInfoList, CAM_Module::setModuleName(), CAM_Module::setName(), and SUIT_MessageBox::warning().
|
virtual |
If some module can not be loaded, an error message is shown.
References addModule(), SUIT_MessageBox::critical(), SUIT_Application::desktop(), isModuleAccessible(), loadModule(), and myInfoList.
CAM_Module * CAM_Application::module | ( | const QString & | modName | ) | const |
References myModules.
|
protectedvirtual |
This virtual method can be re-implemented in the successors. Base implementation does nothing.
mod | module being added |
Reimplemented in LightApp_Application.
|
static |
name | module name |
References myInfoList.
|
staticprotected |
title | module title (user name) |
full | if true , return full library name, otherwise return its internal name |
References Qtx::library(), and myInfoList.
|
static |
title | module title (user name) |
References myInfoList.
CAM_Application::ModuleList CAM_Application::modules | ( | ) | const |
References myModules.
void CAM_Application::modules | ( | CAM_Application::ModuleList & | out | ) | const |
returning | list of modules |
References myModules.
void CAM_Application::modules | ( | QStringList & | lst, |
const bool | loaded = true |
||
) | const |
Get loaded modules names if loaded is true
, otherwise get all avaiable modules names.
lst | output list of modules names |
loaded | boolean flag, defines what modules names to return |
References myInfoList, and myModules.
|
static |
name | module name |
References myInfoList.
|
private |
This function first tries to get the modules names list by parsing the application command line arguments, looking for the "–modules ( <mod_name>[:<mod_name>...] )" option. List of modules is separated by colon symbol (":").
If "–modules" command line option is not used, the list of modules is retrieved from the application resource file: parameter "modules" of the section "launch".
Then the information about each module (module title (user name), library name) is retrieved from the corresponding section of resource file with help of resources manager.
Shows the warning message, if module information list is empty.
References QtxResourceMgr::booleanValue(), SUIT_Application::desktop(), Qtx::extension(), Qtx::file(), CAM_Application::ModuleInfo::icon, CAM_Application::ModuleInfo::internal, CAM_Application::ModuleInfo::isSingleton, modules(), moduleTitle(), myInfoList, CAM_Application::ModuleInfo::name, SUIT_Session::resourceMgr(), SUIT_Session::session(), QtxResourceMgr::stringValue(), CAM_Application::ModuleInfo::title, CAM_Application::ModuleInfo::version, and SUIT_MessageBox::warning().
|
protectedvirtual |
study | study to be made active |
Reimplemented from SUIT_Application.
Reimplemented in LightApp_Application.
References SUIT_Application::setActiveStudy().
|
virtual |
Load all modules, if "auto loading" flag has been set to true
.
Reimplemented from STD_Application.
Reimplemented in LightApp_Application, and SalomeApp_Application.
References loadModules(), myAutoLoad, and STD_Application::start().
|
protectedvirtual |
Reimplemented from STD_Application.
Reimplemented in LightApp_Application, and SalomeApp_Application.
References activeModule(), CAM_Module::updateCommandsStatus(), and STD_Application::updateCommandsStatus().
|
private |
|
private |
|
staticprivate |
|
private |
|
private |