\sa PyModuleHelper::deactivate()
*/
bool SALOME_PYQT_ModuleLight::deactivateModule( SUIT_Study* study )
-{
+{
// call helper
bool res = myHelper->deactivate( study );
return LightApp_Module::deactivateModule( study ) && res;
}
+/*!
+ \brief 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.
+*/
+void SALOME_PYQT_ModuleLight::onModelClosed()
+{
+ // call helper
+ myHelper->modelClosed(application()->activeStudy());
+ LightApp_Module::onModelClosed();
+}
+
+
/*!
\brief Get the dockable windows associated with the module.
\param winMap output map of dockable windows in form { <window_type> : <dock_area> }
return true;
}
+/*!
+ \brief 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.
+*/
+void PyModuleHelper::modelClosed( SUIT_Study* study )
+{
+ FuncMsg fmsg( "PyModuleHelper::modelClosed()" );
+
+ class StudyClosedReq : public PyInterp_LockRequest
+ {
+ public:
+ StudyClosedReq( PyInterp_Interp* _py_interp,
+ PyModuleHelper* _helper,
+ SUIT_Study* _study )
+ : PyInterp_LockRequest( _py_interp, 0, true ), // this request should be processed synchronously (sync == true)
+ myHelper( _helper ),
+ myStudy ( _study )
+ {}
+ protected:
+ virtual void execute()
+ {
+ myHelper->internalClosedStudy( myStudy );
+ }
+ private:
+ PyModuleHelper* myHelper;
+ SUIT_Study* myStudy;
+ };
+
+ // post request
+ PyInterp_Dispatcher::Get()->Exec( new StudyClosedReq( myInterp, this, study ) );
+
+ // disconnect preferences changing signal
+ disconnect( myModule->getApp(), SIGNAL( preferenceChanged( const QString&, const QString&, const QString& ) ),
+ this, SLOT( preferenceChanged( const QString&, const QString&, const QString& ) ) );
+
+ // disconnect the SUIT_Desktop signal windowActivated()
+ SUIT_Desktop* d = study->application()->desktop();
+ disconnect( d, SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
+ this, SLOT( activeViewChanged( SUIT_ViewWindow* ) ) );
+
+ // deactivate menus, toolbars, etc
+ if ( myXmlHandler ) myXmlHandler->activateMenus( false );
+
+ // hide menus / toolbars
+ myModule->setMenuShown( false );
+ myModule->setToolShown( false );
+}
+
+
/*!
\brief Process module's preferences changing.
}
}
+/*!
+ \brief Internal closure:
+
+ Performs the following actions:
+ - call Python module's closeStudy() method
+
+ \param theStudy parent study object
+*/
+void PyModuleHelper::internalClosedStudy( SUIT_Study* theStudy )
+{
+ FuncMsg fmsg( "--- PyModuleHelper::internalClosedStudy()" );
+
+ // Get study Id
+ // get study Id
+ LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>( theStudy );
+ int aStudyId = aStudy ? aStudy->id() : 0;
+
+ // check that Python subinterpreter is initialized and Python module is imported
+ if ( !myInterp || !myPyModule ) {
+ // Error! Python subinterpreter should be initialized and module should be imported first!
+ return;
+ }
+ // then call Python module's deactivate() method
+ if ( PyObject_HasAttrString( myPyModule , (char*)"closeStudy" ) ) {
+ PyObjWrapper res( PyObject_CallMethod( myPyModule, (char*)"closeStudy", (char*)"i", aStudyId ) );
+ if( !res ) {
+ PyErr_Print();
+ }
+ }
+}
+
+
+
/*!
\brief Preference changing callback function.
\internal
void initialize( CAM_Application* );
bool activate( SUIT_Study* study );
bool deactivate( SUIT_Study* study );
+ void modelClosed( SUIT_Study* study );
void preferencesChanged( const QString&, const QString& setting );
void preferenceChanged( const QString&, const QString&, const QString& setting );
void studyActivated( SUIT_Study* );
void internalActivate( SUIT_Study* );
void internalCustomize( SUIT_Study* );
void internalDeactivate( SUIT_Study* );
+ void internalClosedStudy( SUIT_Study* );
void internalPreferencesChanged( const QString&, const QString& );
void internalStudyChanged( SUIT_Study* );
void internalActionActivated( int );