This class implements API helper for all the Python-based SALOME GUI modules. More...
#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 Member Functions | |
void | initInterp () |
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 LightApp_Module * | myInitModule = 0 |
Python GUI being initialized (not zero only during the initialization) More... | |
This class implements API helper for all the Python-based SALOME GUI modules.
PyModuleHelper::PyModuleHelper | ( | LightApp_Module * | module | ) |
Constructor.
module | owner module |
PyModuleHelper::~PyModuleHelper | ( | ) |
Destructor.
References myInterp, myPyModule, and myXmlHandler.
|
slot |
Process action activation.
Called when action is activated. Used for notifying the Python module about any related action activation.
References CAM_Module::actionId(), myInterp, and myModule.
|
slot |
Activation of the module.
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_Desktop::activeWindow(), SUIT_Study::application(), connectView(), SUIT_Application::desktop(), LightApp_Module::getApp(), myLastActivateStatus, myModule, myXmlHandler, preferenceChanged(), CAM_Module::setMenuShown(), CAM_Module::setToolShown(), and SUIT_Desktop::windows().
|
slot |
Signal handler windowActivated(SUIT_ViewWindow*) of SUIT_Desktop.
Used to notify Python module that active view has been changed by the user.
view | view being activated |
References connectView(), and myInterp.
|
slot |
Signal handler cloneView() of OCCViewer_ViewWindow.
view | view being cloned |
References myInterp.
|
slot |
Signal handler closing(SUIT_ViewWindow*) of a view.
view | view being closed |
References myInterp.
void PyModuleHelper::connectAction | ( | QAction * | a | ) |
Connect action to the internal actionActivated() slot.
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 |
Connects signals about activating and cloning view on internal slots.
view | view being connected |
References cloneView(), closeView(), SUIT_ViewWindow::getViewManager(), SUIT_ViewManager::getViewModel(), and tryCloseView().
|
slot |
Process context popup menu request.
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 |
|
slot |
Deactivation of the module.
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 |
|
slot |
Perform drop operation.
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 |
Get the module being initialized.
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 |
Import Python GUI module and store reference to the module.
Warning! initInterp() should be called first!!!
References myInterp, myModule, myPyModule, and CAM_Module::name().
|
slot |
Initialization of the Python-based SALOME module.
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 |
Initialize python subinterpreter (one per study).
References SUIT_PYTHON::initialized, myInitMutex, and myInterp.
|
private |
GUI event handling callback function.
Performs the following actions:
id | GUI action ID |
References FuncMsg::message(), myInterp, and myPyModule.
|
private |
Activation callback function.
Performs the following actions:
study | parent study |
References importModule(), initInterp(), myInterp, myLastActivateStatus, and myPyModule.
|
private |
Active view changing callback function.
view | view being activated |
References SUIT_ViewWindow::getId(), FuncMsg::message(), myInterp, and myPyModule.
|
private |
View cloning callback function.
view | view being cloned |
References SUIT_ViewWindow::getId(), FuncMsg::message(), myInterp, and myPyModule.
|
private |
Internal closure:
Performs the following actions:
theStudy | parent study object |
References myInterp, and myPyModule.
|
private |
View closing callback function.
view | view being closed |
References SUIT_ViewWindow::getId(), FuncMsg::message(), myInterp, and myPyModule.
|
private |
Context popup menu handling callback function.
Performs the following actions:
context | popup menu context |
menu | popup menu |
References PyModuleHelper::XmlHandler::createPopup(), IsCallOldMethods, FuncMsg::message(), myInterp, myPyModule, and myXmlHandler.
|
private |
Preferences initialization callback function.
Performs the following actions:
References myInterp, and myPyModule.
|
private |
Additional menu customization callback function.
Performs the following actions:
study | parent study |
References importModule(), initInterp(), IsCallOldMethods, myInterp, myLastActivateStatus, myPyModule, and setWorkSpace().
|
private |
Deactivation callback function.
Performs the following actions:
study | parent study |
References myInterp, and myPyModule.
|
private |
Data dropping callback function.
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 |
Module dump python callback function.
files | output list of files where module stores python script |
References myInterp, and myPyModule.
|
private |
Get engine IOR callback function.
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 |
Initialization callback function.
Performs the following actions:
app | parent application object |
References SUIT_Application::activeStudy(), importModule(), initInterp(), myInterp, myPyModule, myViewMgrList, myWindowsMap, LightApp_Application::WT_LogWindow, LightApp_Application::WT_ObjectBrowser, and LightApp_Application::WT_PyConsole.
|
private |
Check data object's 'draggable' status callback function.
what | data object being tested |
true
if object can be dragged or false
otherwise References LightApp_DataObject::entry(), myInterp, and myPyModule.
|
private |
Check data object's 'drop allowed' status callback function.
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 |
Module data loading callback function.
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 |
Preference changing callback function.
Performs the following actions:
section | resources section name |
setting | resources parameter name |
References myInterp, and myPyModule.
|
private |
Module data saving callback function.
files | output list of files where module stores data |
url | study URL |
References myInterp, and myPyModule.
|
private |
update selection from other views or modules
Performs the following actions:
list | of entries |
References myInterp, and myPyModule.
|
private |
Active study change callback function.
Called when active the study is actived (user brings its desktop to top):
study | study being activated |
References importModule(), initInterp(), myInterp, myPyModule, and setWorkSpace().
|
private |
View closing callback function.
view | view user tries to close |
References SUIT_ViewWindow::getId(), FuncMsg::message(), myInterp, and myPyModule.
|
slot |
Test if object what can be dragged by the user.
what | data object being tested |
true
if object can be dragged or false
otherwise References myInterp.
|
slot |
Test if drop operation can be done on the where object.
where | data object being tested |
true
if if drop operation is supported by object or false
otherwise References myInterp.
|
slot |
References myInterp.
|
slot |
Close of the module.
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 |
|
slot |
References LightApp_DataObject::entry(), myInterp, and myModule.
|
slot |
Process application preferences changing.
Called when any application setting is changed.
module | preference module |
section | preference resources section |
parameter | preference resources parameter name |
References module(), CAM_Module::moduleName(), myModule, and preferencesChanged().
|
slot |
Process module's preferences changing.
Called when the module's own preferences are changed.
section | preference resources section |
parameter | preference resources parameter name |
References myInterp.
PyObject * PyModuleHelper::pythonModule | ( | ) | const |
|
slot |
|
slot |
update selection from other views or modules.
Called when selection is modified outside.
References myInterp.
|
private |
Set study workspace to the Python module.
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 |
Process study activation.
Called when study desktop is activated. Used for notifying the Python module about changing of the active study.
study | study being activated |
|
slot |
Signal handler tryClose(SUIT_ViewWindow*) of a view.
view | view being closed |
References myInterp.
QStringList PyModuleHelper::viewManagers | ( | ) | const |
Define the compatible view windows associated with the module.
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 |
Get the dockable windows associated with the module.
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 |
Python GUI being initialized (not zero only during the initialization)
|
private |
current Python subinterpreter
|
private |
latest module activation status
|
private |
GUI module.
|
private |
Python GUI module.
|
private |
compatible view managers list
|
private |
windows map
|
private |
XML resource file parser.