This class implements API helper for all the Python-based SALOME GUI modules.
#include <SALOME_PYQT_PyModule.h>
Classes | |
class | InitLocker |
Initialization locker. More... | |
class | XmlHandler |
XML resource files parser. More... | |
Public Slots | |
void | initialize (CAM_Application *) |
Initialization of the Python-based SALOME module. More... | |
bool | activate (SUIT_Study *study) |
Activation of the module. More... | |
bool | deactivate (SUIT_Study *study) |
Deactivation of the module. More... | |
void | modelClosed (SUIT_Study *study) |
Close of the module. More... | |
void | preferencesChanged (const QString &, const QString &setting) |
Process module's preferences changing. More... | |
void | preferenceChanged (const QString &, const QString &, const QString &setting) |
Process application preferences changing. More... | |
void | studyActivated (SUIT_Study *) |
Process study activation. More... | |
void | actionActivated () |
Process action activation. More... | |
void | selectionUpdated (const QStringList &) |
update selection from other views or modules. More... | |
void | contextMenu (const QString &, QMenu *) |
Process context popup menu request. More... | |
void | createPreferences () |
Export preferences for the Python module. Called only once when the first instance of the module is created or when common Preferences dialog box is first time invoked. More... | |
void | activeViewChanged (SUIT_ViewWindow *) |
Signal handler windowActivated(SUIT_ViewWindow*) of SUIT_Desktop. More... | |
void | tryCloseView (SUIT_ViewWindow *) |
Signal handler tryClose(SUIT_ViewWindow*) of a view. More... | |
void | closeView (SUIT_ViewWindow *) |
Signal handler closing(SUIT_ViewWindow*) of a view. More... | |
void | cloneView (SUIT_ViewWindow *) |
Signal handler cloneView() of OCCViewer_ViewWindow. More... | |
void | save (QStringList &, const QString &) |
Save module data. Called when user saves study. More... | |
bool | load (const QStringList &, const QString &) |
void | dumpPython (QStringList &files) |
Dump module data to the Python script. Called when user activates dump study operation. More... | |
bool | isDraggable (const SUIT_DataObject *) const |
Test if object what can be dragged by the user. More... | |
bool | isDropAccepted (const SUIT_DataObject *) const |
Test if drop operation can be done on the where object. More... | |
void | dropObjects (const DataObjectList &, SUIT_DataObject *, const int, Qt::DropAction) |
Perform drop operation. More... | |
QString | engineIOR () const |
Get module engine IOR. More... | |
void | onObjectBrowserClicked (SUIT_DataObject *, int) |
Public Member Functions | |
PyModuleHelper (LightApp_Module *) | |
Constructor. More... | |
~PyModuleHelper () | |
Destructor. More... | |
LightApp_Module * | module () const |
Get owner module. More... | |
PyObject * | pythonModule () const |
Get Python GUI module object. More... | |
void | connectAction (QAction *) |
Connect action to the internal actionActivated() slot. More... | |
QMap< int, int > | windows () const |
Get the dockable windows associated with the module. More... | |
QStringList | viewManagers () const |
Define the compatible view windows associated with the module. More... | |
Static Public Member Functions | |
static LightApp_Module * | getInitModule () |
Get the module being initialized. More... | |
static int | defaultMenuGroup () |
Get default menu group identifier. More... | |
Private Types | |
typedef QMap< int, PyInterp_Interp * > | InterpMap |
Private Member Functions | |
void | initInterp (int) |
Initialize python subinterpreter (one per study). More... | |
void | importModule () |
Import Python GUI module and store reference to the module. More... | |
void | setWorkSpace () |
Set study workspace to the Python module. More... | |
void | internalInitialize (CAM_Application *) |
Initialization callback function. More... | |
void | internalActivate (SUIT_Study *) |
Activation callback function. More... | |
void | internalCustomize (SUIT_Study *) |
Additional menu customization callback function. More... | |
void | internalDeactivate (SUIT_Study *) |
Deactivation callback function. More... | |
void | internalClosedStudy (SUIT_Study *) |
Internal closure: More... | |
void | internalPreferencesChanged (const QString &, const QString &) |
Preference changing callback function. More... | |
void | internalStudyChanged (SUIT_Study *) |
Active study change callback function. More... | |
void | internalActionActivated (int) |
GUI event handling callback function. More... | |
void | internalSelectionUpdated (const QStringList &) |
update selection from other views or modules More... | |
void | internalContextMenu (const QString &, QMenu *) |
Context popup menu handling callback function. More... | |
void | internalCreatePreferences () |
Preferences initialization callback function. More... | |
void | internalActiveViewChanged (SUIT_ViewWindow *) |
Active view changing callback function. More... | |
void | internalTryCloseView (SUIT_ViewWindow *) |
View closing callback function. More... | |
void | internalCloseView (SUIT_ViewWindow *) |
View closing callback function. More... | |
void | internalCloneView (SUIT_ViewWindow *) |
View cloning callback function. More... | |
void | internalSave (QStringList &, const QString &) |
Module data saving callback function. More... | |
void | internalLoad (const QStringList &, const QString &, bool &) |
Module data loading callback function. More... | |
void | internalDumpPython (QStringList &) |
Module dump python callback function. More... | |
bool | internalIsDraggable (LightApp_DataObject *) |
Check data object's 'draggable' status callback function. More... | |
bool | internalIsDropAccepted (LightApp_DataObject *) |
Check data object's 'drop allowed' status callback function. More... | |
void | internalDropObjects (const DataObjectList &, SUIT_DataObject *, const int, Qt::DropAction) |
Data dropping callback function. More... | |
QString | internalEngineIOR () const |
Get engine IOR callback function. More... | |
void | internalOBClickedPython (const QString &, int) |
void | connectView (SUIT_ViewWindow *) |
Connects signals about activating and cloning view on internal slots. More... | |
Private Attributes | |
LightApp_Module * | myModule |
GUI module. More... | |
PyObject * | myPyModule |
Python GUI module. More... | |
PyInterp_Interp * | myInterp |
current Python subinterpreter More... | |
XmlHandler * | myXmlHandler |
XML resource file parser. More... | |
QMap< int, int > | myWindowsMap |
windows map More... | |
QStringList | myViewMgrList |
compatible view managers list More... | |
bool | myLastActivateStatus |
latest module activation status More... | |
Static Private Attributes | |
static InterpMap | myInterpMap |
study to Python subinterpreter map More... | |
static LightApp_Module * | myInitModule = 0 |
Python GUI being initialized (not zero only during the initialization) More... | |
|
private |
PyModuleHelper::PyModuleHelper | ( | LightApp_Module * | module | ) |
module | owner module |
PyModuleHelper::~PyModuleHelper | ( | ) |
References myInterp, myPyModule, and myXmlHandler.
|
slot |
Called when action is activated. Used for notifying the Python module about any related action activation.
References CAM_Module::actionId(), myInterp, and myModule.
|
slot |
This function is usually used in order to show the module's specific menus and toolbars, update actions state and perform other such actions required when the module is activated.
false
from this function prevents the module activation.study | parent study |
true
if activation is successful and false
otherwise References PyModuleHelper::XmlHandler::activateMenus(), activeViewChanged(), SUIT_Study::application(), connectView(), SUIT_Application::desktop(), LightApp_Module::getApp(), myLastActivateStatus, myModule, myXmlHandler, preferenceChanged(), CAM_Module::setMenuShown(), and CAM_Module::setToolShown().
|
slot |
Used to notify Python module that active view has been changed by the user.
view | view being activated |
References connectView(), and myInterp.
|
slot |
view | view being cloned |
References myInterp.
|
slot |
view | view being closed |
References myInterp.
void PyModuleHelper::connectAction | ( | QAction * | a | ) |
Actions connected to internal actionActivated(), when activated, will be forwarded to the Python GUI module OnGUIEvent() function.
a | action being connected |
References actionActivated(), and myModule.
|
private |
view | view being connected |
References cloneView(), closeView(), SUIT_ViewWindow::getViewManager(), SUIT_ViewManager::getViewModel(), and tryCloseView().
Called when user activates popup menu in some window (view, object browser, etc).
context | popup menu context (e.g. "ObjectBrowser") |
menu | popup menu |
References myInterp.
|
slot |
This function is usually used in order to hide the module's specific menus and toolbars and perform other such actions required when the module is deactivated.
study | parent study |
true
if deactivation is successful and false
otherwise References PyModuleHelper::XmlHandler::activateMenus(), activeViewChanged(), SUIT_Study::application(), SUIT_Application::desktop(), LightApp_Module::getApp(), myInterp, myModule, myXmlHandler, preferenceChanged(), CAM_Module::setMenuShown(), and CAM_Module::setToolShown().
|
static |
References DEFAULT_GROUP.
|
slot |
what | list of data objects being dropped |
where | target data object for drop operation |
row | line (child item index) where drop operation is performed to |
action | current drop action (copy or move) |
References myInterp.
|
slot |
|
slot |
|
static |
This is a little trick :) needed to provide an access from Python (SalomePyQt) to the module being currently activated. The problem that during the process of module initialization (initialize() function) it is not yet available via application->activeModule() call.
This method returns valid pointer only if called in scope of initialize() function or in several other specific cases.
References myInitModule, and myInitMutex.
|
private |
Warning! initInterp() should be called first!!!
References myInterp, myModule, myPyModule, and CAM_Module::name().
|
slot |
This method can be used for creation of the menus, toolbars and other such stuff.
There are two ways to do this: 1) for obsolete modules, the implementation of this method first tries to read the <module>_<language>.xml resource file which contains a menu, toolbars and popup menus description; 2) new modules can create menus by direct calling of the corresponding methods of SalomePyQt Python API in the Python module's initialize() method which is called from here.
app | parent application object |
References PyModuleHelper::XmlHandler::createActions(), LightApp_Module::getApp(), myModule, myXmlHandler, CAM_Module::name(), QtxResourceMgr::path(), SUIT_Application::resourceMgr(), and QtxResourceMgr::stringValue().
|
private |
studyId | study ID |
References SUIT_PYTHON::initialized, myInitMutex, myInterp, and myInterpMap.
|
private |
Performs the following actions:
id | GUI action ID |
References FuncMsg::message(), myInterp, and myPyModule.
|
private |
Performs the following actions:
study | parent study |
References SUIT_Study::id(), importModule(), initInterp(), myInterp, myLastActivateStatus, and myPyModule.
|
private |
view | view being activated |
References SUIT_ViewWindow::getId(), FuncMsg::message(), myInterp, and myPyModule.
|
private |
view | view being cloned |
References SUIT_ViewWindow::getId(), FuncMsg::message(), myInterp, and myPyModule.
|
private |
Performs the following actions:
theStudy | parent study object |
References SUIT_Study::id(), myInterp, and myPyModule.
|
private |
view | view being closed |
References SUIT_ViewWindow::getId(), FuncMsg::message(), myInterp, and myPyModule.
Performs the following actions:
context | popup menu context |
menu | popup menu |
References PyModuleHelper::XmlHandler::createPopup(), IsCallOldMethods, FuncMsg::message(), myInterp, myPyModule, and myXmlHandler.
|
private |
Performs the following actions:
References myInterp, and myPyModule.
|
private |
Performs the following actions:
study | parent study |
References SUIT_Study::id(), importModule(), initInterp(), IsCallOldMethods, myInterp, myLastActivateStatus, myPyModule, and setWorkSpace().
|
private |
Performs the following actions:
study | parent study |
References myInterp, and myPyModule.
|
private |
what | list of data objects being dropped |
where | target data object for drop operation |
row | line (child item index) where drop operation is performed to |
action | current drop action (copy or move) |
References LightApp_DataObject::entry(), myInterp, and myPyModule.
|
private |
files | output list of files where module stores python script |
References myInterp, and myPyModule.
|
private |
Tries to get engine IOR from the Python module using engineIOR() function. That function can load module engine using appropriate container if required.
References myInterp, myModule, and myPyModule.
|
private |
Performs the following actions:
app | parent application object |
References SUIT_Application::activeStudy(), app, SUIT_Study::id(), importModule(), initInterp(), myInterp, myPyModule, myViewMgrList, myWindowsMap, LightApp_Application::WT_LogWindow, LightApp_Application::WT_ObjectBrowser, and LightApp_Application::WT_PyConsole.
|
private |
what | data object being tested |
true
if object can be dragged or false
otherwise References LightApp_DataObject::entry(), myInterp, and myPyModule.
|
private |
where | data object being tested |
true
if if drop operation is supported by object or false
otherwise References LightApp_DataObject::entry(), myInterp, and myPyModule.
|
private |
files | list of files where module data is stored |
url | study URL |
opened | output success flag |
References myInterp, and myPyModule.
|
private |
References myInterp, and myPyModule.
|
private |
Performs the following actions:
section | resources section name |
setting | resources parameter name |
References myInterp, and myPyModule.
|
private |
files | output list of files where module stores data |
url | study URL |
References myInterp, and myPyModule.
|
private |
Performs the following actions:
list | of entries |
References myInterp, and myPyModule.
|
private |
Called when active the study is actived (user brings its desktop to top):
study | study being activated |
References SUIT_Study::id(), importModule(), initInterp(), FuncMsg::message(), myInterp, myPyModule, and setWorkSpace().
|
private |
view | view user tries to close |
References SUIT_ViewWindow::getId(), FuncMsg::message(), myInterp, and myPyModule.
|
slot |
what | data object being tested |
true
if object can be dragged or false
otherwise References myInterp.
|
slot |
where | data object being tested |
true
if if drop operation is supported by object or false
otherwise References myInterp.
References myInterp.
|
slot |
This function is usually used in order to close the module's specific menus and toolbars and perform other such actions required when the module is closed.
References PyModuleHelper::XmlHandler::activateMenus(), activeViewChanged(), SUIT_Study::application(), SUIT_Application::desktop(), LightApp_Module::getApp(), myInterp, myModule, myXmlHandler, preferenceChanged(), CAM_Module::setMenuShown(), and CAM_Module::setToolShown().
LightApp_Module * PyModuleHelper::module | ( | ) | const |
References myModule.
|
slot |
References LightApp_DataObject::entry(), myEntry, myInterp, and myModule.
|
slot |
Called when any application setting is changed.
module | preference module |
section | preference resources section |
parameter | preference resources parameter name |
References CAM_Module::moduleName(), myModule, and preferencesChanged().
Called when the module's own preferences are changed.
section | preference resources section |
parameter | preference resources parameter name |
References myInterp.
PyObject * PyModuleHelper::pythonModule | ( | ) | const |
References myPyModule.
|
slot |
|
slot |
Called when selection is modified outside.
References myInterp.
|
private |
Calls setWorkSpace() method of the Python module with PyQt QWidget object to use with interpreter.
Attention! initInterp() and importModule() should be called first!!!
References SUIT_Application::desktop(), LightApp_Module::getApp(), IsCallOldMethods, myInterp, myModule, myPyModule, STD_MDIDesktop::workspace(), and STD_TabDesktop::workstack().
|
slot |
Called when study desktop is activated. Used for notifying the Python module about changing of the active study.
study | study being activated |
|
slot |
view | view being closed |
References myInterp.
QStringList PyModuleHelper::viewManagers | ( | ) | const |
The associated view windows are opened automatically when the module is activated.
To fill the list of views the correspondind Python module's views() method is called during the module initialization. By default, the list of view types is empty.
References myViewMgrList.
QMap< int, int > PyModuleHelper::windows | ( | ) | const |
To fill the list of windows the correspondind Python module's windows() method is called during the module initialization.
By default, ObjectBrowser, PythonConsole and LogWindow windows are associated to the module.
Allowed dockable windows:
Dock area is defined by Qt::DockWidgetArea enumeration:
References myWindowsMap.
|
staticprivate |
|
private |
|
staticprivate |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |