Version: 8.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CAM_Application Class Reference

Introduces an application class which provides modular architecture. More...

#include <CAM_Application.h>

Inheritance diagram for CAM_Application:
Inheritance graph

Classes

struct  ModuleInfo
 
struct  ModuleShortInfo
 

Public Types

typedef QList< CAM_Module * > ModuleList
 
typedef QList< ModuleShortInfoModuleShortInfoList
 
- 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_ModuleactiveModule () const
 Get active module. More...
 
CAM_Modulemodule (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_ModuleloadModule (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_ViewManageractiveViewManager () const
 
SUIT_ViewManagerviewManager (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_Desktopdesktop ()
 Returns main widget (Desktop) of the application (if it exists) More...
 
virtual SUIT_StudyactiveStudy () 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_ResourceMgrresourceMgr () const
 
SUIT_ShortcutMgrshortcutMgr () const
 Get access to shortcut manager. More...
 
void putInfo (const QString &, const int=0)
 Puts the message to the status bar. More...
 
QActionaction (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_StudycreateNewStudy ()
 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_ApplicationstartApplication (int, char **) const
 
SUIT_ApplicationstartApplication (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 *)
 
QActioncreateAction (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())
 
QActioncreateAction (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< ModuleInfoModuleInfoList
 

Private Member Functions

void readModuleList ()
 Read modules information list. More...
 

Private Attributes

CAM_ModulemyModule
 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 ()
 

Detailed Description

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

  • loading of modules
  • modules activation/deactivation
  • etc

Member Typedef Documentation

Constructor & Destructor Documentation

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()).

Parameters
autoLoadauto loading flag

References readModuleList().

CAM_Application::~CAM_Application ( )
virtual

Does nothing currently.

References myModules.

Member Function Documentation

bool CAM_Application::abortAllOperations ( )
protectedvirtual

Iterates through all modules and asks each of them if there are pending operations that cannot be aborted.

Returns
false if some operation cannot be aborted

Reimplemented from STD_Application.

References myModules.

bool CAM_Application::activateModule ( const QString &  modName)
virtual
Parameters
modNamemodule name
Returns
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.

bool CAM_Application::activateModule ( CAM_Module mod = 0)
protectedvirtual

Shows error message if module could not be activated in the current study.

Parameters
modmodule object pointer
Returns
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 
)
Parameters
modNamemodule name
actionIdis a numerical unique operation identifier
Returns
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 
)
Parameters
modNamemodule name
actionIdis a string unique operation identifier
Returns
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 
)
Parameters
modNamemodule name
actionIdis a string unique operation identifier
pluginNameis a name of a plugin where the operation is implemented
Returns
true in case of success and false otherwise

References CAM_Module::activateOperation(), addModule(), isModuleAccessible(), and loadModule().

CAM_Module * CAM_Application::activeModule ( ) const
Returns
active module or 0 if there are no any

References myModule.

void CAM_Application::addModule ( CAM_Module mod)
virtual

Performes module initialization. Does nothing if the module is already added.

Parameters
modmodule being added
See Also
CAM_Module::initialize()

References CAM_Module::initialize(), module(), moduleAdded(), CAM_Module::moduleName(), myInfoList, and myModules.

void CAM_Application::afterCloseDoc ( )
protectedvirtual

Virtual function. Not implemented here.

Reimplemented from STD_Application.

Reimplemented in LightApp_Application, and SalomeApp_Application.

void CAM_Application::beforeCloseDoc ( SUIT_Study theDoc)
protectedvirtual

Closes all modules in study theDoc.

Parameters
theDocstudy

Reimplemented from STD_Application.

Reimplemented in LightApp_Application.

References myModules.

void CAM_Application::contextMenuPopup ( const QString &  type,
QMenu menu,
QString &  title 
)
virtual

Menu items list is defined by the active module.

Parameters
typepopup menu context
menupopup menu
titlepopup 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().

void CAM_Application::createEmptyStudy ( )
virtual
SUIT_Study * CAM_Application::createNewStudy ( )
protectedvirtual
Returns
study object pointer

Reimplemented from SUIT_Application.

Reimplemented in LightApp_Application, and SalomeApp_Application.

bool CAM_Application::isModuleAccessible ( const QString &  title)
static
Parameters
titlemodule title (user name)
Returns
true if module is accessible (can be loaded) or false otherwise

References app, SUIT_Session::applications(), modules(), myInfoList, and SUIT_Session::session().

CAM_Module * CAM_Application::loadModule ( const QString &  modName,
const bool  showMsg = true 
)
virtual

The function prints warning message if:

  • modules information list is empty
  • modules information list does not include specified module info
  • module library can not be loaded by some reason
Parameters
modNamemodule name
Returns
module object pointer or 0 if module could not be loaded

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().

void CAM_Application::loadModules ( )
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
Returns
module or 0 if not found

References myModules.

void CAM_Application::moduleAdded ( CAM_Module )
protectedvirtual

This virtual method can be re-implemented in the successors. Base implementation does nothing.

Parameters
modmodule being added

Reimplemented in LightApp_Application.

QString CAM_Application::moduleIcon ( const QString &  name)
static
Parameters
namemodule name
Returns
module icon or null QString if module is not found

References myInfoList.

QString CAM_Application::moduleLibrary ( const QString &  title,
const bool  full = true 
)
staticprotected
Parameters
titlemodule title (user name)
fullif true, return full library name, otherwise return its internal name
Returns
module library name or null QString if module is not found

References Qtx::library(), and myInfoList.

QString CAM_Application::moduleName ( const QString &  title)
static
Parameters
titlemodule title (user name)
Returns
module name or null QString if module is not found

References myInfoList.

CAM_Application::ModuleList CAM_Application::modules ( ) const
Returns
list of modules

References myModules.

void CAM_Application::modules ( CAM_Application::ModuleList out) const
Parameters
returninglist 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.

Parameters
lstoutput list of modules names
loadedboolean flag, defines what modules names to return

References myInfoList, and myModules.

QString CAM_Application::moduleTitle ( const QString &  name)
static
Parameters
namemodule name
Returns
module title (user name) or null QString if module is not found

References myInfoList.

void CAM_Application::readModuleList ( )
private

This function first tries to get the modules names list by parsing the application command line arguments, looking for the "&ndash;modules ( <mod_name>[:<mod_name>...] )" option. List of modules is separated by colon symbol (":").

If "&ndash;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.

See Also
SUIT_ResourceMgr

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().

void CAM_Application::setActiveStudy ( SUIT_Study study)
protectedvirtual
Parameters
studystudy to be made active

Reimplemented from SUIT_Application.

Reimplemented in LightApp_Application.

References SUIT_Application::setActiveStudy().

void CAM_Application::start ( )
virtual

Load all modules, if "auto loading" flag has been set to true.

See Also
CAM_Application()

Reimplemented from STD_Application.

Reimplemented in LightApp_Application, and SalomeApp_Application.

References loadModules(), myAutoLoad, and STD_Application::start().

void CAM_Application::updateCommandsStatus ( )
protectedvirtual

Member Data Documentation

bool CAM_Application::myAutoLoad
private
bool CAM_Application::myBlocked
private
CAM_Application::ModuleInfoList CAM_Application::myInfoList
staticprivate
CAM_Module* CAM_Application::myModule
private
ModuleList CAM_Application::myModules
private

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