+/*!
+ \fn int SalomePyQt::addPreference( const QString& label, const int pId, const int type,
+ const QString& section, const QString& param );
+ \brief Add module-related preferences.
+ \param label preferences group name
+ \param pId parent preferences group id
+ \param type preferences type
+ \param section resources file section name
+ \param param resources file setting name
+ \return preferences identifier
+*/
+
+class TAddPrefParamEvent: public SALOME_Event
+{
+public:
+ typedef int TResult;
+ TResult myResult;
+ QString myLabel;
+ int myPId;
+ int myType;
+ QString mySection;
+ QString myParam;
+ TAddPrefParamEvent( const QString& label,
+ const int pId, const int type,
+ const QString& section,
+ const QString& param )
+ : myResult( -1 ),
+ myLabel( label ), myPId( pId ), myType( type ),
+ mySection( section ), myParam ( param ) {}
+ virtual void Execute()
+ {
+ LightApp_Module* module = getActiveModule();
+ if ( module ) {
+ LightApp_Preferences* pref = module->getApp()->preferences();
+ if ( pref )
+ myResult = pref->addPreference( module->moduleName(), myLabel, myPId, myType, mySection, myParam );
+ }
+ }
+};
+int SalomePyQt::addPreference( const QString& label, const int pId, const int type,
+ const QString& section, const QString& param )
+{
+ return ProcessEvent( new TAddPrefParamEvent( label, pId, type, section, param ) );
+}
+
+/*!
+ \fn QVariant SalomePyQt::preferenceProperty( const int id, const QString& prop );
+ \brief Get the preferences property.
+ \param id preferences identifier
+ \param prop preferences property name
+ \return preferences property value or null QVariant if property is not set
+*/
+
+class TPrefPropEvent: public SALOME_Event
+{
+public:
+ typedef QVariant TResult;
+ TResult myResult;
+ int myId;
+ QString myProp;
+ TPrefPropEvent( const int id, const QString& prop )
+ : myId( id ), myProp( prop ) {}
+ virtual void Execute()
+ {
+ LightApp_Module* module = getActiveModule();
+ if ( module ) {
+ LightApp_Preferences* pref = module->getApp()->preferences();
+ if ( pref )
+ myResult = pref->itemProperty( myProp, myId );
+ }
+ }
+};
+QVariant SalomePyQt::preferenceProperty( const int id, const QString& prop )
+{
+ return ProcessEvent( new TPrefPropEvent( id, prop ) );
+}
+
+/*!
+ \brief Set the preferences property.
+ \param id preferences identifier
+ \param prop preferences property name
+ \param var preferences property value
+*/
+void SalomePyQt::setPreferenceProperty( const int id,
+ const QString& prop,
+ const QVariant& var )
+{
+ class TEvent: public SALOME_Event
+ {
+ int myId;
+ QString myProp;
+ QVariant myVar;
+ public:
+ TEvent( const int id, const QString& prop, const QVariant& var )
+ : myId( id ), myProp( prop ), myVar( var ) {}
+ virtual void Execute()
+ {
+ LightApp_Module* module = getActiveModule();
+ if ( module ) {
+ LightApp_Preferences* pref = module->getApp()->preferences();
+ if ( pref )
+ pref->setItemProperty( myProp, myVar, myId );
+ }
+ }
+ };
+ ProcessVoidEvent( new TEvent( id, prop, var) );
+}
+
+/*!
+ \brief Add the property value to the list of values.
+
+ This method allows creating properties which are QList<QVariant>
+ - there is no way to pass such values directly to QVariant parameter with PyQt.
+
+ \param id preferences identifier
+ \param prop preferences property name
+ \param idx preferences property index
+ \param var preferences property value for the index \a idx
+*/
+void SalomePyQt::addPreferenceProperty( const int id,
+ const QString& prop,
+ const int idx,
+ const QVariant& var )
+{
+ class TEvent: public SALOME_Event
+ {
+ int myId;
+ QString myProp;
+ int myIdx;
+ QVariant myVar;
+ public:
+ TEvent( const int id, const QString& prop, const int idx, const QVariant& var )
+ : myId( id ), myProp( prop ), myIdx( idx), myVar( var ) {}
+ virtual void Execute()
+ {
+ LightApp_Module* module = getActiveModule();
+ if ( module ) {
+ LightApp_Preferences* pref = module->getApp()->preferences();
+ if ( pref ) {
+ QVariant var = pref->itemProperty( myProp, myId );
+ if ( var.isValid() ) {
+ if ( var.type() == QVariant::StringList ) {
+ QStringList sl = var.toStringList();
+ if ( myIdx >= 0 && myIdx < sl.count() )
+ sl[myIdx] = myVar.toString();
+ else
+ sl.append( myVar.toString() );
+ pref->setItemProperty( myProp, sl, myId );
+ }
+ else if ( var.type() == QVariant::List ) {
+ QList<QVariant> vl = var.toList();
+ if ( myIdx >= 0 && myIdx < vl.count() )
+ vl[myIdx] = myVar;
+ else
+ vl.append( myVar );
+ pref->setItemProperty( myProp, vl, myId );
+ }
+ }
+ else {
+ QList<QVariant> vl;
+ vl.append( myVar );
+ pref->setItemProperty( myProp, vl, myId );
+ }
+ }
+ }
+ }
+ };
+ ProcessVoidEvent( new TEvent( id, prop, idx, var) );
+}
+
+/*!
+ \brief Put the message to the Log messages output window
+ \param msg message text (it can be of simple rich text format)
+ \param addSeparator boolean flag which specifies if it is necessary
+ to separate the message with predefined separator
+*/
+void SalomePyQt::message( const QString& msg, bool addSeparator )
+{
+ class TEvent: public SALOME_Event
+ {
+ QString myMsg;
+ bool myAddSep;
+ public:
+ TEvent( const QString& msg, bool addSeparator )
+ : myMsg( msg ), myAddSep( addSeparator ) {}
+ virtual void Execute()
+ {
+ if ( LightApp_Application* anApp = getApplication() ) {
+ LogWindow* lw = anApp->logWindow();
+ if ( lw )
+ lw->putMessage( myMsg, myAddSep );
+ }
+ }
+ };
+ ProcessVoidEvent( new TEvent( msg, addSeparator ) );
+}
+
+/*!
+ \brief Remove all the messages from the Log messages output window.
+*/
+void SalomePyQt::clearMessages()
+{
+ class TEvent: public SALOME_Event
+ {
+ public:
+ TEvent() {}
+ virtual void Execute()
+ {
+ if ( LightApp_Application* anApp = getApplication() ) {
+ LogWindow* lw = anApp->logWindow();
+ if ( lw )
+ lw->clear();
+ }
+ }
+ };
+ ProcessVoidEvent( new TEvent() );
+}
+
+/*!
+ \brief Gets window with specified identifier
+ \internal
+ \param id window identifier
+ \return pointer on the window
+*/
+static SUIT_ViewWindow* getWnd( const int id )
+{
+ SUIT_ViewWindow* resWnd = 0;
+
+ LightApp_Application* app = getApplication();
+ if ( app )
+ {
+ ViewManagerList vmlist = app->viewManagers();
+ foreach( SUIT_ViewManager* vm, vmlist )
+ {
+ QVector<SUIT_ViewWindow*> vwlist = vm->getViews();
+ foreach ( SUIT_ViewWindow* vw, vwlist )
+ {
+ if ( id == vw->getId() )
+ {
+ resWnd = vw;
+ break;
+ }
+ }
+ }
+ }
+
+ return resWnd;
+}
+
+/*!
+ \fn bool SalomePyQt::dumpView( const QString& filename, const int id = 0 );
+ \brief Dump the contents of the id view window. If id is 0 then current active view is processed.
+ to the image file in the specified format.
+
+ For the current moment JPEG, PNG and BMP images formats are supported.
+ The image format is defined automatically by the file name extension.
+ By default, BMP format is used.
+
+ \param filename image file name
+ \return operation status (\c true on success)
+*/
+
+class TDumpViewEvent: public SALOME_Event
+{
+public:
+ typedef bool TResult;
+ TResult myResult;
+ QString myFileName;
+ int myWndId;
+ TDumpViewEvent( const QString& filename, const int id )
+ : myResult ( false ), myFileName( filename ), myWndId(id) {}
+ virtual void Execute()
+ {
+ SUIT_ViewWindow* wnd = NULL;
+ if(myWndId == 0)
+ {
+ if ( LightApp_Application* anApp = getApplication() ) {
+ SUIT_ViewManager* vm = anApp->activeViewManager();
+ if ( vm )
+ wnd = vm->getActiveView();
+ }
+ myWndId = wnd->getId();
+ }
+ else
+ {
+ wnd = dynamic_cast<SUIT_ViewWindow*>(getWnd( myWndId ));
+ }
+ if ( wnd ) {
+ QString fmt = SUIT_Tools::extension( myFileName ).toUpper();
+ Plot2d_ViewWindow* wnd2D = dynamic_cast<Plot2d_ViewWindow*>(wnd);
+ if(fmt == "PS" || fmt == "EPS" || fmt == "PDF") {
+ if(wnd2D) {
+ myResult = wnd2D->getViewFrame()->print(myFileName, fmt);
+ } else {
+ myResult = false;
+ }
+ } else {
+ if(wnd2D) {
+ qApp->postEvent( wnd2D->getViewFrame(), new QPaintEvent( QRect( 0, 0, wnd2D->getViewFrame()->width(), wnd2D->getViewFrame()->height() ) ) );
+ qApp->postEvent( wnd2D, new QPaintEvent( QRect( 0, 0, wnd2D->width(), wnd2D->height() ) ) );
+ qApp->processEvents();
+ }
+ QImage im = wnd->dumpView();
+ if ( !im.isNull() && !myFileName.isEmpty() ) {
+ if ( fmt.isEmpty() ) fmt = QString( "BMP" ); // default format
+ if ( fmt == "JPG" ) fmt = "JPEG";
+ myResult = im.save( myFileName, fmt.toLatin1() );
+ }
+ }
+ }
+ }
+};
+bool SalomePyQt::dumpView( const QString& filename, const int id )
+{
+ return ProcessEvent( new TDumpViewEvent( filename, id ) );
+}
+
+
+/*!
+ \fn QList<int> SalomePyQt::getViews();
+ \brief Get list of integer identifiers of all the currently opened views
+ \return list of integer identifiers of all the currently opened views
+*/
+
+class TGetViews: public SALOME_Event
+{
+public:
+ typedef QList<int> TResult;
+ TResult myResult;
+ TGetViews() {}
+ virtual void Execute()
+ {
+ myResult.clear();
+ LightApp_Application* app = getApplication();
+ if ( app )
+ {
+ STD_TabDesktop* tabDesk = dynamic_cast<STD_TabDesktop*>( app->desktop() );
+ if ( tabDesk )
+ {
+ QList<SUIT_ViewWindow*> wndlist = tabDesk->windows();
+ SUIT_ViewWindow* wnd;
+ foreach ( wnd, wndlist )
+ myResult.append( wnd->getId() );
+ }
+ }
+ }
+};
+QList<int> SalomePyQt::getViews()
+{
+ return ProcessEvent( new TGetViews() );
+}
+
+/*!
+ \fn int SalomePyQt::getActiveView();
+ \brief Get integer identifier of the currently active view
+ \return integer identifier of the currently active view
+*/
+
+class TGetActiveView: public SALOME_Event
+{
+public:
+ typedef int TResult;
+ TResult myResult;
+ TGetActiveView()
+ : myResult( -1 ) {}
+ virtual void Execute()
+ {
+ LightApp_Application* app = getApplication();
+ if ( app )
+ {
+ SUIT_ViewManager* viewMgr = app->activeViewManager();
+ if ( viewMgr )
+ {
+ SUIT_ViewWindow* wnd = viewMgr->getActiveView();
+ if ( wnd )
+ myResult = wnd->getId();
+ }
+ }
+ }
+};
+int SalomePyQt::getActiveView()
+{
+ return ProcessEvent( new TGetActiveView() );
+}
+
+/*!
+ \fn QString SalomePyQt::getViewType( const int id );
+ \brief Get type of the specified view, e.g. "OCCViewer"
+ \param id window identifier
+ \return view type
+*/
+
+class TGetViewType: public SALOME_Event
+{
+public:
+ typedef QString TResult;
+ TResult myResult;
+ int myWndId;
+ TGetViewType( const int id )
+ : myWndId( id ) {}
+ virtual void Execute()
+ {
+ SUIT_ViewWindow* wnd = getWnd( myWndId );
+ if ( wnd )
+ {
+ SUIT_ViewManager* viewMgr = wnd->getViewManager();
+ if ( viewMgr )
+ myResult = viewMgr->getType();
+ }
+ }
+};
+QString SalomePyQt::getViewType( const int id )
+{
+ return ProcessEvent( new TGetViewType( id ) );
+}
+
+/*!
+ \fn bool SalomePyQt::setViewTitle( const int id, const QString& title );
+ \brief Change view caption
+ \param id window identifier
+ \param title new window title
+ \return \c true if operation is completed successfully and \c false otherwise
+*/
+
+class TSetViewTitle: public SALOME_Event
+{
+public:
+ typedef bool TResult;
+ TResult myResult;
+ int myWndId;
+ QString myTitle;
+ TSetViewTitle( const int id, const QString& title )
+ : myResult( false ),
+ myWndId( id ),
+ myTitle( title ) {}
+ virtual void Execute()
+ {
+ SUIT_ViewWindow* wnd = getWnd( myWndId );
+ if ( wnd )
+ {
+ wnd->setWindowTitle( myTitle );
+ myResult = true;
+ }
+ }
+};
+bool SalomePyQt::setViewTitle( const int id, const QString& title )
+{
+ return ProcessEvent( new TSetViewTitle( id, title ) );
+}
+
+
+/*!
+ \fn QString SalomePyQt::getViewTitle( const int id );
+ \brief Get view caption
+ \param id window identifier
+ \return view caption
+*/
+
+class TGetViewTitle: public SALOME_Event
+{
+public:
+ typedef QString TResult;
+ TResult myResult;
+ int myWndId;
+ TGetViewTitle( const int id )
+ : myWndId( id ) {}
+ virtual void Execute()
+ {
+ SUIT_ViewWindow* wnd = getWnd( myWndId );
+ if ( wnd )
+ myResult = wnd->windowTitle();
+ }
+};
+QString SalomePyQt::getViewTitle( const int id )
+{
+ return ProcessEvent( new TGetViewTitle( id ) );
+}
+
+/*!
+ \fn QList<int> SalomePyQt::findViews( const QString& type );
+ \brief Get list of integer identifiers of all the
+ currently opened views of the specified type
+ \param type viewer type
+ \return list of integer identifiers
+*/
+
+class TFindViews: public SALOME_Event
+{
+public:
+ typedef QList<int> TResult;
+ TResult myResult;
+ QString myType;
+ TFindViews( const QString& type )
+ : myType( type ) {}
+ virtual void Execute()
+ {
+ myResult.clear();
+ LightApp_Application* app = getApplication();
+ if ( app )
+ {
+ ViewManagerList vmList;
+ app->viewManagers( myType, vmList );
+ SUIT_ViewManager* viewMgr;
+ foreach ( viewMgr, vmList )
+ {
+ QVector<SUIT_ViewWindow*> vec = viewMgr->getViews();
+ for ( int i = 0, n = vec.size(); i < n; i++ )
+ {
+ SUIT_ViewWindow* wnd = vec[ i ];
+ if ( wnd )
+ myResult.append( wnd->getId() );
+ }
+ }
+ }
+ }
+};
+QList<int> SalomePyQt::findViews( const QString& type )
+{
+ return ProcessEvent( new TFindViews( type ) );
+}
+
+/*!
+ \fn bool SalomePyQt::activateView( const int id );
+ \brief Activate view
+ \param id window identifier
+ \return \c true if operation is completed successfully and \c false otherwise
+*/
+
+class TActivateView: public SALOME_Event
+{
+public:
+ typedef bool TResult;
+ TResult myResult;
+ int myWndId;
+ TActivateView( const int id )
+ : myResult( false ),
+ myWndId( id ) {}
+ virtual void Execute()
+ {
+ SUIT_ViewWindow* wnd = getWnd( myWndId );
+ if ( wnd )
+ {
+ wnd->setFocus();
+ myResult = true;
+ }
+ }
+};
+bool SalomePyQt::activateView( const int id )
+{
+ return ProcessEvent( new TActivateView( id ) );
+}
+
+/*!
+ \fn int SalomePyQt::createView( const QString& type, bool visible = true, const int width = 0, const int height = 0 );
+ \brief Create new view and activate it
+ \param type viewer type
+ \param visible
+ \param width
+ \param height
+ \return integer identifier of created view (or -1 if view could not be created)
+*/
+
+class TCreateView: public SALOME_Event
+{
+public:
+ typedef int TResult;
+ TResult myResult;
+ QString myType;
+ bool myVisible;
+ int myWidth;
+ int myHeight;
+ TCreateView( const QString& theType, bool visible, const int width, const int height )
+ : myResult( -1 ),
+ myType( theType ),
+ myVisible(visible),
+ myWidth(width),
+ myHeight(height) {}
+ virtual void Execute()
+ {
+ LightApp_Application* app = getApplication();
+ if ( app )
+ {
+ SUIT_ViewManager* viewMgr = app->createViewManager( myType );
+ if ( viewMgr )
+ {
+ SUIT_ViewWindow* wnd = viewMgr->getActiveView();
+ if ( wnd ) {
+ wnd->setShown(myVisible);
+ if(!myVisible && myWidth == 0 && myHeight == 0) {
+ myWidth = 1024;
+ myHeight = 768;
+ }
+ if(myWidth > 0 && myHeight > 0) {
+ Plot2d_ViewWindow* wnd2D = dynamic_cast<Plot2d_ViewWindow*>(wnd);
+ if(wnd2D) {
+ wnd2D->getViewFrame()->setGeometry(0,0,myWidth,myHeight);
+ } else {
+ wnd->setGeometry(0,0,myWidth,myHeight);
+ }
+ }
+ myResult = wnd->getId();
+ }
+ }
+ }
+ }
+};
+int SalomePyQt::createView( const QString& type, bool visible, const int width, const int height )
+{
+ return ProcessEvent( new TCreateView( type, visible, width, height ) );
+}
+
+/*!
+ \fn int SalomePyQt::createView( const QString& type, QWidget* w );
+ \brief Create new view with custom widget embedded and activate it
+ \param type viewer type
+ \param w custom widget
+ \return integer identifier of created view (or -1 if view could not be created)
+*/
+
+class TCreateViewWg: public SALOME_Event
+{
+public:
+ typedef int TResult;
+ TResult myResult;
+ QString myType;
+ QWidget* myWidget;
+ TCreateViewWg( const QString& theType, QWidget* w )
+ : myResult( -1 ),
+ myType( theType ),
+ myWidget( w ) {}
+ virtual void Execute()
+ {
+ LightApp_Application* app = getApplication();
+ if ( app )
+ {
+ SUIT_ViewManager* viewMgr = app->createViewManager( myType, myWidget );
+ if ( viewMgr )
+ {
+ SUIT_ViewWindow* wnd = viewMgr->getActiveView();
+ if ( wnd )
+ myResult = wnd->getId();
+ }
+ }
+ }
+};
+int SalomePyQt::createView( const QString& type, QWidget* w )
+{
+ return ProcessEvent( new TCreateViewWg( type, w ) );
+}
+
+/*!
+ \fn bool SalomePyQt::closeView( const int id );
+ \brief Close view
+ \param id window identifier
+ \return \c true if operation is completed successfully and \c false otherwise
+*/
+
+class TCloseView: public SALOME_Event
+{
+public:
+ typedef bool TResult;
+ TResult myResult;
+ int myWndId;
+ TCloseView( const int id )
+ : myResult( false ),
+ myWndId( id ) {}
+ virtual void Execute()
+ {
+ SUIT_ViewWindow* wnd = getWnd( myWndId );
+ if ( wnd )
+ {
+ SUIT_ViewManager* viewMgr = wnd->getViewManager();
+ if ( viewMgr )
+ {
+ wnd->close();
+ myResult = true;
+ }
+ }
+ }
+};
+bool SalomePyQt::closeView( const int id )
+{
+ return ProcessEvent( new TCloseView( id ) );
+}
+
+/*!
+ \fn int SalomePyQt::cloneView( const int id );
+ \brief Clone view (if this operation is supported for specified view type)
+ \param id window identifier
+ \return integer identifier of the cloned view or -1 or operation could not be performed
+*/
+
+class TCloneView: public SALOME_Event
+{
+public:
+ typedef int TResult;
+ TResult myResult;
+ int myWndId;
+ TCloneView( const int id )
+ : myResult( -1 ),
+ myWndId( id ) {}
+ virtual void Execute()
+ {
+ SUIT_ViewWindow* wnd = getWnd( myWndId );
+ if ( wnd )
+ {
+ SUIT_ViewManager* viewMgr = wnd->getViewManager();
+ if ( viewMgr )
+ {
+ if ( wnd->inherits( "OCCViewer_ViewWindow" ) )
+ {
+ OCCViewer_ViewWindow* occView = (OCCViewer_ViewWindow*)( wnd );
+ occView->onCloneView();
+
+ wnd = viewMgr->getActiveView();
+ if ( wnd )
+ myResult = wnd->getId();
+ }
+ else if ( wnd->inherits( "Plot2d_ViewWindow" ) )
+ {
+ Plot2d_ViewManager* viewMgr2d = dynamic_cast<Plot2d_ViewManager*>( viewMgr );
+ Plot2d_ViewWindow* srcWnd2d = dynamic_cast<Plot2d_ViewWindow*>( wnd );
+ if ( viewMgr2d && srcWnd2d )
+ {
+ Plot2d_ViewWindow* resWnd = viewMgr2d->cloneView( srcWnd2d );
+ myResult = resWnd->getId();
+ }
+ }
+ }
+ }
+ }
+};
+int SalomePyQt::cloneView( const int id )
+{
+ return ProcessEvent( new TCloneView( id ) );
+}
+
+/*!
+ \fn bool SalomePyQt::setViewVisible( const int id, const bool visible )
+ \brief Set view visibility.
+ \param id window identifier
+ \param visible new visiblity
+*/
+
+void SalomePyQt::setViewVisible( const int id, const bool visible )
+{
+ class TEvent: public SALOME_Event
+ {
+ int myWndId;
+ bool myVisible;
+ public:
+ TEvent( const int id, const bool visible )
+ : myWndId( id ), myVisible( visible ) {}
+ virtual void Execute()
+ {
+ SUIT_ViewWindow* wnd = getWnd( myWndId );
+ if ( wnd ) wnd->setVisible( myVisible );
+ }
+ };
+ ProcessVoidEvent( new TEvent( id, visible ) );
+}
+
+/*!
+ \fn bool SalomePyQt::isViewVisible( const int id );
+ \brief Check whether view is visible ( i.e. it is on the top of the views stack)
+ \param id window identifier
+ \return \c true if view is visible and \c false otherwise
+*/
+
+class TIsViewVisible: public SALOME_Event
+{
+public:
+ typedef bool TResult;
+ TResult myResult;
+ int myWndId;
+ TIsViewVisible( const int id )
+ : myResult( false ),
+ myWndId( id ) {}
+ virtual void Execute()
+ {
+ SUIT_ViewWindow* wnd = getWnd( myWndId );
+ if ( wnd )
+ {
+ QWidget* p = wnd->parentWidget();
+ myResult = ( p && p->isVisibleTo( p->parentWidget() ) );
+ }
+ }
+};
+bool SalomePyQt::isViewVisible( const int id )
+{
+ return ProcessEvent( new TIsViewVisible( id ) );
+}
+
+/*!
+ \fn bool SalomePyQt::setViewClosable( const int id, const bool on );
+ \brief Set / clear view's "closable" option. By default any view is closable
+ (i.e. can be closed by the user).
+ \param id window identifier
+ \param on new "closable" option's value
+*/
+
+void SalomePyQt::setViewClosable( const int id, const bool on )
+{
+ class TEvent: public SALOME_Event
+ {
+ int myWndId;
+ bool myOn;
+ public:
+ TEvent( const int id, const bool on )
+ : myWndId( id ), myOn( on ) {}
+ virtual void Execute()
+ {
+ SUIT_ViewWindow* wnd = getWnd( myWndId );
+ if ( wnd ) wnd->setClosable( myOn );
+ }
+ };
+ ProcessVoidEvent( new TEvent( id, on ) );
+}
+
+/*!
+ \fn bool SalomePyQt::isViewClosable( const int id );
+ \brief Check whether view is closable (i.e. can be closed by the user)
+ \param id window identifier
+ \return \c true if view is closable or \c false otherwise
+*/
+
+class TIsViewClosable: public SALOME_Event
+{
+public:
+ typedef bool TResult;
+ TResult myResult;
+ int myWndId;
+ TIsViewClosable( const int id )
+ : myResult( true ),
+ myWndId( id ) {}
+ virtual void Execute()
+ {
+ SUIT_ViewWindow* wnd = getWnd( myWndId );
+ if ( wnd )
+ myResult = wnd->closable();
+ }
+};
+
+bool SalomePyQt::isViewClosable( const int id )
+{
+ return ProcessEvent( new TIsViewClosable( id ) );
+}
+
+/*!
+ \fn bool SalomePyQt::groupAllViews();
+ \brief Group all views to the single tab area
+ \return \c true if operation is completed successfully and \c false otherwise
+*/
+
+class TGroupAllViews: public SALOME_Event
+{
+public:
+ typedef bool TResult;
+ TResult myResult;
+ TGroupAllViews()
+ : myResult( false ) {}
+ virtual void Execute()
+ {
+ LightApp_Application* app = getApplication();
+ if ( app )
+ {
+ STD_TabDesktop* tabDesk = dynamic_cast<STD_TabDesktop*>( app->desktop() );
+ if ( tabDesk )
+ {
+ QtxWorkstack* wStack = tabDesk->workstack();
+ if ( wStack )
+ {
+ wStack->stack();
+ myResult = true;
+ }
+ }
+ }
+ }
+};
+bool SalomePyQt::groupAllViews()
+{
+ return ProcessEvent( new TGroupAllViews() );
+}
+
+/*!
+ \fn bool SalomePyQt::splitView( const int id, const Orientation ori, const Action action );
+ \brief Split tab area to which view with identifier belongs to
+ \param id window identifier
+ \param ori orientation of split operation
+ \param action action to be performed
+ \return \c true if operation is completed successfully \c false otherwise
+*/
+
+class TSplitView: public SALOME_Event
+{
+public:
+ typedef bool TResult;
+ TResult myResult;
+ int myWndId;
+ Orientation myOri;
+ Action myAction;
+ TSplitView( const int id,
+ const Orientation ori,
+ const Action action )
+ : myResult( false ),
+ myWndId( id ),
+ myOri( ori ),
+ myAction( action ) {}
+ virtual void Execute()
+ {
+ SUIT_ViewWindow* wnd = getWnd( myWndId );
+ if ( wnd )
+ {
+ // activate view
+ // wnd->setFocus(); ???
+
+ // split workstack
+ if ( getApplication() )
+ {
+ STD_TabDesktop* desk =
+ dynamic_cast<STD_TabDesktop*>( getApplication()->desktop() );
+ if ( desk )
+ {
+ QtxWorkstack* wStack = desk->workstack();
+ if ( wStack )
+ {
+ Qt::Orientation qtOri =
+ ( myOri == Horizontal ) ? Qt::Horizontal : Qt::Vertical;
+
+ QtxWorkstack::SplitType sType;
+ if ( myAction == MoveWidget )
+ sType = QtxWorkstack::SplitMove;
+ else if ( myAction == LeaveWidget )
+ sType = QtxWorkstack::SplitStay;
+ else
+ sType = QtxWorkstack::SplitAt;
+
+ wStack->Split( wnd, qtOri, sType );
+ myResult = true;
+ }
+ }
+ }
+ }
+ }
+};
+bool SalomePyQt::splitView( const int id, const Orientation ori, const Action action )
+{
+ return ProcessEvent( new TSplitView( id, ori, action ) );
+}
+
+/*!
+ \fn bool SalomePyQt::moveView( const int id, const int id_to, const bool before );
+ \brief Move view with the first identifier to the same area which
+ another view with the second identifier belongs to
+ \param id source window identifier
+ \param id_to destination window identifier
+ param before specifies whether the first viewt has to be moved before or after
+ the second view
+ \return \c true if operation is completed successfully and \c false otherwise
+*/
+
+class TMoveView: public SALOME_Event
+{
+public:
+ typedef bool TResult;
+ TResult myResult;
+ int myWndId;
+ int myWndToId;
+ bool myIsBefore;
+ TMoveView( const int id, const int id_to, const bool before )
+ : myResult( false ),
+ myWndId( id ),
+ myWndToId( id_to ),
+ myIsBefore( before ) {}
+ virtual void Execute()
+ {
+ SUIT_ViewWindow* wnd = getWnd( myWndId );
+ SUIT_ViewWindow* wnd_to = getWnd( myWndToId );
+ if ( wnd && wnd_to )
+ {
+ QtxWorkstack* wStack = dynamic_cast<STD_TabDesktop*>(
+ getApplication()->desktop() )->workstack();
+ if ( wStack )
+ myResult = wStack->move( wnd, wnd_to, myIsBefore );
+ }
+ }
+};
+bool SalomePyQt::moveView( const int id, const int id_to, const bool before )
+{
+ return ProcessEvent( new TMoveView( id, id_to, before ) );
+}
+
+/*!
+ \fn QList<int> SalomePyQt::neighbourViews( const int id );
+ \brief Get list of views identifiers that belongs to the same area as
+ specified view (excluding it)
+ \param id window identifier
+ \return list of views identifiers
+*/
+
+class TNeighbourViews: public SALOME_Event
+{
+public:
+ typedef QList<int> TResult;
+ TResult myResult;
+ int myWndId;
+ TNeighbourViews( const int id )
+ : myWndId( id ) {}
+ virtual void Execute()
+ {
+ myResult.clear();
+ SUIT_ViewWindow* wnd = getWnd( myWndId );
+ if ( wnd )
+ {
+ QtxWorkstack* wStack = dynamic_cast<STD_TabDesktop*>(
+ getApplication()->desktop() )->workstack();
+ if ( wStack )
+ {
+ QWidgetList wgList = wStack->windowList( wnd );
+ QWidget* wg;
+ foreach ( wg, wgList )
+ {
+ SUIT_ViewWindow* tmpWnd = dynamic_cast<SUIT_ViewWindow*>( wg );
+ if ( tmpWnd && tmpWnd != wnd )
+ myResult.append( tmpWnd->getId() );
+ }
+ }
+ }
+ }
+};
+QList<int> SalomePyQt::neighbourViews( const int id )
+{
+ return ProcessEvent( new TNeighbourViews( id ) );
+}
+
+
+/*!
+ \fn QString SalomePyQt::createObject( const QString& parent );
+ \brief Create empty data object
+ \param parent entry of parent data object
+ \return entry of created data object
+*/
+
+class TCreateEmptyObjectEvent: public SALOME_Event
+{
+public:
+ typedef QString TResult;
+ TResult myResult;
+ QString myParent;
+ TCreateEmptyObjectEvent( const QString& parent )
+ : myParent( parent ) {}
+ virtual void Execute()
+ {
+ SALOME_PYQT_ModuleLight* module = dynamic_cast<SALOME_PYQT_ModuleLight*>( getActiveModule() );
+ if ( module ) {
+ myResult = module->createObject( myParent );
+ }
+ else {
+ if ( verbose() ) printf( "SalomePyQt.createObject() function is not supported for the current module.\n" );
+ }
+ }
+};
+QString SalomePyQt::createObject( const QString& parent )
+{
+ return ProcessEvent( new TCreateEmptyObjectEvent( parent ) );
+}
+
+/*!
+ \fn QString SalomePyQt::createObject( const QString& name, const QString& icon,
+ const QString& tooltip,const QString& parent );
+ \brief Create new data object with specified name, icon and tooltip
+ \param name data object name
+ \param icon data object icon
+ \param toolTip data object tooltip
+ \param parent entry of parent data object
+ \return entry of created data object
+*/
+
+class TCreateObjectEvent: public SALOME_Event
+{
+public:
+ typedef QString TResult;
+ TResult myResult;
+ QString myParent;
+ QString myName;
+ QString myIcon;
+ QString myToolTip;
+ TCreateObjectEvent( const QString& name,
+ const QString& icon,
+ const QString& tooltip,
+ const QString& parent )
+ : myName( name ),
+ myIcon( icon ),
+ myToolTip( tooltip ),
+ myParent( parent ) {}
+ virtual void Execute()
+ {
+ SALOME_PYQT_ModuleLight* module = dynamic_cast<SALOME_PYQT_ModuleLight*>( getActiveModule() );
+ if ( module ) {
+ myResult = module->createObject( myName, myIcon, myToolTip, myParent );
+ }
+ else {
+ if ( verbose() ) printf( "SalomePyQt.createObject() function is not supported for the current module.\n" );
+ }
+ }
+};
+QString SalomePyQt::createObject( const QString& name,
+ const QString& icon,
+ const QString& toolTip,
+ const QString& parent )
+{
+ return ProcessEvent( new TCreateObjectEvent( name, icon, toolTip, parent ) );
+}
+
+
+/*!
+ \fn void SalomePyQt::setName( const QString& entry, const QString& name );
+ \brief Set data object name
+ \param entry data object entry
+ \param name data object name
+*/
+class TSetNameEvent: public SALOME_Event
+{
+public:
+ QString myEntry;
+ QString myName;
+ TSetNameEvent( const QString& entry,
+ const QString& name )
+ : myEntry( entry ),
+ myName( name ) {}
+ virtual void Execute()
+ {
+ SALOME_PYQT_ModuleLight* module = dynamic_cast<SALOME_PYQT_ModuleLight*>( getActiveModule() );
+ if ( module ) {
+ module->setName( myEntry, myName );
+ }
+ else {
+ if ( verbose() ) printf( "SalomePyQt.setName() function is not supported for the current module.\n" );
+ }
+ }
+};
+void SalomePyQt::setName( const QString& entry, const QString& name )
+{
+ ProcessVoidEvent( new TSetNameEvent( entry, name ) );
+}
+
+/*!
+ \fn void SalomePyQt::setIcon( const QString& entry, const QString& icon );
+ \brief Set data object icon
+ \param entry data object entry
+ \param icon data object icon file name (icon is loaded from module resources)
+*/
+
+class TSetIconEvent: public SALOME_Event
+{
+public:
+ QString myEntry;
+ QString myIcon;
+ TSetIconEvent( const QString& entry,
+ const QString& icon )
+ : myEntry( entry ),
+ myIcon( icon ) {}
+ virtual void Execute()
+ {
+ SALOME_PYQT_ModuleLight* module = dynamic_cast<SALOME_PYQT_ModuleLight*>( getActiveModule() );
+ if ( module ) {
+ module->setIcon( myEntry, myIcon );
+ }
+ else {
+ if ( verbose() ) printf( "SalomePyQt.setIcon() function is not supported for the current module.\n" );
+ }
+ }
+};
+
+void SalomePyQt::setIcon( const QString& entry, const QString& icon )
+{
+ ProcessVoidEvent( new TSetIconEvent( entry, icon ) );
+}
+
+/*!
+ \fn void SalomePyQt::setToolTip( const QString& entry, const QString& toolTip );
+ \brief Set data object tooltip
+ \param entry data object entry
+ \param toolTip data object tooltip
+*/
+
+class TSetToolTipEvent: public SALOME_Event
+{
+public:
+ QString myEntry;
+ QString myToolTip;
+ TSetToolTipEvent( const QString& entry,
+ const QString& toolTip )
+ : myEntry( entry ),
+ myToolTip( toolTip ) {}
+ virtual void Execute()
+ {
+ SALOME_PYQT_ModuleLight* module = dynamic_cast<SALOME_PYQT_ModuleLight*>( getActiveModule() );
+ if ( module ) {
+ module->setToolTip( myEntry, myToolTip );
+ }
+ else {
+ if ( verbose() ) printf( "SalomePyQt.setToolTip() function is not supported for the current module.\n" );
+ }
+ }
+};
+void SalomePyQt::setToolTip( const QString& entry, const QString& toolTip )
+{
+ ProcessVoidEvent( new TSetToolTipEvent( entry, toolTip ) );
+}
+
+/*!
+ \fn void SalomePyQt::setReference( const QString& entry, const QString& refEntry );
+ \brief Set reference to another data object
+ \param entry data object entry
+ \param refEntry referenced data object entry
+*/
+
+class TSetRefEvent: public SALOME_Event
+{
+public:
+ QString myEntry;
+ QString myRefEntry;
+ TSetRefEvent( const QString& entry,
+ const QString& refEntry )
+ : myEntry( entry ),
+ myRefEntry( refEntry ) {}
+ virtual void Execute()
+ {
+ SALOME_PYQT_ModuleLight* module = dynamic_cast<SALOME_PYQT_ModuleLight*>( getActiveModule() );
+ if ( module ) {
+ module->setReference( myEntry, myRefEntry );
+ }
+ else {
+ if ( verbose() ) printf( "SalomePyQt.setReference() function is not supported for the current module.\n" );
+ }
+ }
+};
+void SalomePyQt::setReference( const QString& entry, const QString& refEntry )
+{
+ ProcessVoidEvent( new TSetRefEvent( entry, refEntry ) );
+}
+
+/*!
+ \fn void SalomePyQt::setColor( const QString& entry, const QColor& color );
+ \brief Set data object color
+ \param entry data object entry
+ \param color data object color
+ */
+
+class TSetColorEvent: public SALOME_Event
+{
+public:
+ QString myEntry;
+ QColor myColor;
+ TSetColorEvent( const QString& entry,
+ const QColor& color )
+ : myEntry( entry ),
+ myColor( color ) {}
+ virtual void Execute()
+ {
+ SALOME_PYQT_ModuleLight* module = dynamic_cast<SALOME_PYQT_ModuleLight*>( getActiveModule() );
+ if ( module ) {
+ module->setColor( myEntry, myColor );
+ }
+ else {
+ if ( verbose() ) printf( "SalomePyQt.setColor() function is not supported for the current module.\n" );
+ }
+ }
+};
+void SalomePyQt::setColor( const QString& entry, const QColor& color )
+{
+ ProcessVoidEvent( new TSetColorEvent( entry, color ) );
+}
+
+/*!
+ \fn QString SalomePyQt::getName( const QString& entry );
+ \brief Get data object name
+ \param entry data object entry
+ \return data object name
+*/
+
+class TGetNameEvent: public SALOME_Event
+{
+public:
+ typedef QString TResult;
+ TResult myResult;
+ QString myEntry;
+ TGetNameEvent( const QString& entry )
+ : myEntry( entry ) {}
+ virtual void Execute()
+ {
+ SALOME_PYQT_ModuleLight* module = dynamic_cast<SALOME_PYQT_ModuleLight*>( getActiveModule() );
+ if ( module ) {
+ myResult = module->getName( myEntry );
+ }
+ else {
+ if ( verbose() ) printf( "SalomePyQt.getName() function is not supported for the current module.\n" );
+ }
+ }
+};
+QString SalomePyQt::getName( const QString& entry )
+{
+ return ProcessEvent( new TGetNameEvent( entry ) );
+}
+
+/*!
+ \fn QString SalomePyQt::getToolTip( const QString& entry );
+ \brief Get data object tooltip
+ \param entry data object entry
+ \return data object tooltip
+*/
+
+class TGetToolTipEvent: public SALOME_Event
+{
+public:
+ typedef QString TResult;
+ TResult myResult;
+ QString myEntry;
+ TGetToolTipEvent( const QString& entry )
+ : myEntry( entry ) {}
+ virtual void Execute()
+ {
+ SALOME_PYQT_ModuleLight* module = dynamic_cast<SALOME_PYQT_ModuleLight*>( getActiveModule() );
+ if ( module ) {
+ myResult = module->getToolTip( myEntry );
+ }
+ else {
+ if ( verbose() ) printf( "SalomePyQt.getToolTip() function is not supported for the current module.\n" );
+ }
+ }
+};
+QString SalomePyQt::getToolTip( const QString& entry )
+{
+ return ProcessEvent( new TGetToolTipEvent( entry ) );
+}
+
+/*
+ \fn QString SalomePyQt::getReference( const QString& entry );
+ \brief Get entry of the referenced object (if there's any)
+ \param entry data object entry
+ \return referenced data object entry
+*/
+
+class TGetRefEvent: public SALOME_Event
+{
+public:
+ typedef QString TResult;
+ TResult myResult;
+ QString myEntry;
+ TGetRefEvent( const QString& entry )
+ : myEntry( entry ) {}
+ virtual void Execute()
+ {
+ SALOME_PYQT_ModuleLight* module = dynamic_cast<SALOME_PYQT_ModuleLight*>( getActiveModule() );
+ if ( module ) {
+ myResult = module->getReference( myEntry );
+ }
+ else {
+ if ( verbose() ) printf( "SalomePyQt.getReference() function is not supported for the current module.\n" );
+ }
+ }
+};
+QString SalomePyQt::getReference( const QString& entry )
+{
+ return ProcessEvent( new TGetRefEvent( entry ) );
+}
+
+/*!
+ \fn QColor SalomePyQt::getColor( const QString& entry );
+ \brief Get data object color
+ \param entry data object entry
+ \return data object color
+*/
+
+class TGetColorEvent: public SALOME_Event
+{
+public:
+ typedef QColor TResult;
+ TResult myResult;
+ QString myEntry;
+ TGetColorEvent( const QString& entry )
+ : myEntry( entry ) {}
+ virtual void Execute()
+ {
+ SALOME_PYQT_ModuleLight* module = dynamic_cast<SALOME_PYQT_ModuleLight*>( getActiveModule() );
+ if ( module ) {
+ myResult = module->getColor( myEntry );
+ }
+ else {
+ if ( verbose() ) printf( "SalomePyQt.getColor() function is not supported for the current module.\n" );
+ }
+ }
+};
+QColor SalomePyQt::getColor( const QString& entry )
+{
+ return ProcessEvent( new TGetColorEvent( entry ) );
+}
+
+/*!
+ \fn void SalomePyQt::removeChildren( const QString& entry );
+ \brief Remove all child data objects from specified data object
+ \param entry data object entry
+*/
+
+class TRemoveChildEvent: public SALOME_Event
+{
+public:
+ QString myEntry;
+ TRemoveChildEvent( const QString& entry )
+ : myEntry( entry ) {}
+ virtual void Execute()
+ {
+ SALOME_PYQT_ModuleLight* module = dynamic_cast<SALOME_PYQT_ModuleLight*>( getActiveModule() );
+ if ( module ) {
+ module->removeChildren( myEntry );
+ }
+ else {
+ if ( verbose() ) printf( "SalomePyQt.removeChildren() function is not supported for the current module.\n" );
+ }
+ }
+};
+void SalomePyQt::removeChildren( const QString& entry )
+{
+ ProcessVoidEvent( new TRemoveChildEvent( entry ) );
+}
+void SalomePyQt::removeChild( const QString& entry )
+{
+ if ( verbose() ) printf( "SalomePyQt.removeChild() function is obsolete. Use SalomePyQt.removeChildren() instead." );
+ removeChildren( entry );
+}
+
+/*!
+ \fn void SalomePyQt::removeObject( const QString& entry );
+ \brief Remove object by entry
+ \param entry data object entry
+*/
+
+class TRemoveObjectEvent: public SALOME_Event
+{
+public:
+ QString myEntry;
+
+ TRemoveObjectEvent( const QString& entry )
+ : myEntry( entry ) {}
+ virtual void Execute()
+ {
+ SALOME_PYQT_ModuleLight* module = dynamic_cast<SALOME_PYQT_ModuleLight*>( getActiveModule() );
+ if ( module ) {
+ module->removeObject( myEntry );
+ }
+ else {
+ if ( verbose() ) printf( "SalomePyQt.removeObject() function is not supported for the current module.\n" );
+ }
+ }
+};
+void SalomePyQt::removeObject( const QString& entry )
+{
+ ProcessVoidEvent( new TRemoveObjectEvent( entry ) );
+}
+
+/*!
+ \fn QStringList SalomePyQt::getChildren( const QString& entry, const bool recursive );
+ \brief Get entries of all child data objects of specified data object
+ \param entry data object entry
+ \param recursive \c true for recursive processing
+*/
+
+class TGetChildrenEvent: public SALOME_Event
+{
+public:
+ typedef QStringList TResult;
+ TResult myResult;
+ QString myEntry;
+ bool myRecursive;
+ TGetChildrenEvent( const QString& entry, const bool recursive )
+ : myEntry( entry ),
+ myRecursive( recursive ) {}
+ virtual void Execute()
+ {
+ SALOME_PYQT_ModuleLight* module = dynamic_cast<SALOME_PYQT_ModuleLight*>( getActiveModule() );
+ if ( module ) {
+ myResult = module->getChildren( myEntry, myRecursive );
+ }
+ else {
+ if ( verbose() ) printf( "SalomePyQt.getChildren() function is not supported for the current module.\n" );
+ }
+ }
+};
+QStringList SalomePyQt::getChildren( const QString& entry, const bool recursive )
+{
+ return ProcessEvent( new TGetChildrenEvent( entry, recursive ) );
+}
+
+
+/*!
+ \fn void SalomePyQt::displayCurve( const int id, Plot2d_Curve* theCurve )
+ \brief Display theCurve in view
+ \param id window identifier
+ \param theCurve curve to display
+*/
+
+class TDisplayCurve: public SALOME_Event
+{
+public:
+ int myWndId;
+ Plot2d_Curve* myCurve;
+ TDisplayCurve(const int id, Plot2d_Curve* theCurve) : myWndId(id), myCurve(theCurve) {}
+ virtual void Execute() {
+ Plot2d_ViewWindow* wnd = dynamic_cast<Plot2d_ViewWindow*>(getWnd( myWndId ));
+ if ( wnd )
+ {
+ wnd->getViewFrame()->displayCurve(myCurve);
+ }
+ }
+};
+void SalomePyQt::displayCurve(const int id, Plot2d_Curve* theCurve)
+{
+ ProcessVoidEvent( new TDisplayCurve(id, theCurve) );
+}
+
+/*!
+ \fn void SalomePyQt::eraseCurve( const int id, Plot2d_Curve* theCurve )
+ \brief Erase theCurve in view
+ \param id window identifier
+ \param theCurve curve to erase
+*/
+
+class TEraseCurve: public SALOME_Event
+{
+public:
+ int myWndId;
+ Plot2d_Curve* myCurve;
+ TEraseCurve(const int id, Plot2d_Curve* theCurve) : myWndId(id), myCurve(theCurve) {}
+ virtual void Execute() {
+ Plot2d_ViewWindow* wnd = dynamic_cast<Plot2d_ViewWindow*>(getWnd( myWndId ));
+ if ( wnd )
+ {
+ wnd->getViewFrame()->eraseCurve(myCurve);
+ }
+ }
+};
+void SalomePyQt::eraseCurve(const int id, Plot2d_Curve* theCurve)
+{
+ ProcessVoidEvent( new TEraseCurve(id, theCurve) );
+}
+
+/*!
+ \fn void SalomePyQt::deleteCurve( Plot2d_Curve* theCurve )
+ \brief Delete theCurve from all views
+ \param theCurve curve to delete
+*/
+
+class TDeleteCurve: public SALOME_Event
+{
+public:
+ Plot2d_Curve* myCurve;
+ TDeleteCurve(Plot2d_Curve* theCurve) : myCurve(theCurve) {}
+ virtual void Execute() {
+ LightApp_Application* app = getApplication();
+ if ( app )
+ {
+ STD_TabDesktop* tabDesk = dynamic_cast<STD_TabDesktop*>( app->desktop() );
+ if ( tabDesk )
+ {
+ QList<SUIT_ViewWindow*> wndlist = tabDesk->windows();
+ SUIT_ViewWindow* wnd;
+ foreach ( wnd, wndlist )
+ {
+ Plot2d_ViewWindow* aP2d = dynamic_cast<Plot2d_ViewWindow*>(wnd);
+ if(aP2d)
+ {
+ aP2d->getViewFrame()->eraseObject(myCurve);
+ }
+ }
+ }
+ }
+ }
+};
+void SalomePyQt::eraseCurve(Plot2d_Curve * theCurve)
+{
+ ProcessVoidEvent( new TDeleteCurve(theCurve) );
+}
+
+/*!
+ \brief updateCurves (repaint) curves in view window.
+*/
+void SalomePyQt::updateCurves(const int id)
+{
+ class TEvent: public SALOME_Event
+ {
+ public:
+ int myWndId;
+ TEvent( const int id ) : myWndId( id ) {}
+ virtual void Execute()
+ {
+ Plot2d_ViewWindow* wnd = dynamic_cast<Plot2d_ViewWindow*>(getWnd( myWndId ));
+ if ( wnd )
+ {
+ wnd->getViewFrame()->DisplayAll();
+ }
+ }
+ };
+ ProcessVoidEvent( new TEvent(id) );
+}
+
+/*!
+ \fn QString SalomePyQt::getPlot2dTitle( const int id, ObjectType type = MainTitle )
+ \brief Get title of corresponding type
+ \param id window identifier
+ \param type is type of title
+ \return title of corresponding type
+*/
+
+class TGetPlot2dTitle: public SALOME_Event
+{
+public:
+ typedef QString TResult;
+ TResult myResult;
+ int myWndId;
+ ObjectType myType;
+ TGetPlot2dTitle(const int id, ObjectType type) :
+ myWndId(id),
+ myType(type) {}
+ virtual void Execute() {
+ Plot2d_ViewWindow* wnd = dynamic_cast<Plot2d_ViewWindow*>(getWnd( myWndId ));
+ if ( wnd )
+ {
+ myResult = wnd->getViewFrame()->getTitle((Plot2d_ViewFrame::ObjectType)myType);
+ }
+ }
+};
+QString SalomePyQt::getPlot2dTitle(const int id, ObjectType type)
+{
+ return ProcessEvent( new TGetPlot2dTitle(id, type) );
+}
+
+
+/*!
+ \fn void SalomePyQt::setPlot2dTitle( const int id, const QString& title, ObjectType type = MainTitle, bool show = true )
+ \brief Set title of corresponding type
+ \param id window identifier
+ \param title
+ \param type is type of title
+ \param show
+*/
+
+class TSetPlot2dTitle: public SALOME_Event
+{
+public:
+ int myWndId;
+ Plot2d_Curve* myCurve;
+ QString myTitle;
+ ObjectType myType;
+ bool myShow;
+ TSetPlot2dTitle(const int id, const QString& title, ObjectType type, bool show) :
+ myWndId(id),
+ myTitle(title),
+ myType(type),
+ myShow(show) {}
+ virtual void Execute() {
+ Plot2d_ViewWindow* wnd = dynamic_cast<Plot2d_ViewWindow*>(getWnd( myWndId ));
+ if ( wnd )
+ {
+ wnd->getViewFrame()->setTitle(myShow, myTitle, (Plot2d_ViewFrame::ObjectType)myType, false);
+ }
+ }
+};
+void SalomePyQt::setPlot2dTitle(const int id, const QString& title, ObjectType type, bool show)
+{
+ ProcessVoidEvent( new TSetPlot2dTitle(id, title, type, show) );
+}
+
+/*!
+ \fn QList<int> SalomePyQt::getPlot2dFitRangeByCurves( const int id )
+ \brief Get list of Plot2d view ranges
+ \param id window identifier
+ \return list of view ranges (XMin, XMax, YMin, YMax)
+*/
+
+class TFitRangeByCurves: public SALOME_Event
+{
+public:
+ typedef QList<double> TResult;
+ TResult myResult;
+ int myWndId;
+ TFitRangeByCurves( const int id )
+ : myWndId( id ) {}
+ virtual void Execute()
+ {
+ myResult.clear();
+ Plot2d_ViewWindow* wnd = dynamic_cast<Plot2d_ViewWindow*>(getWnd( myWndId ));
+ if ( wnd )
+ {
+ double XMin, XMax, YMin, YMax, Y2Min, Y2Max;
+ wnd->getViewFrame()->getFitRangeByCurves(XMin, XMax, YMin, YMax, Y2Min, Y2Max);
+ myResult.append(XMin);
+ myResult.append(XMax);
+ myResult.append(YMin);
+ myResult.append(YMax);
+ }
+ }
+};
+QList<double> SalomePyQt::getPlot2dFitRangeByCurves( const int id )
+{
+ return ProcessEvent( new TFitRangeByCurves( id ) );
+}
+
+/*!
+ \fn QList<int> SalomePyQt::getPlot2dFitRangeCurrent( const int id )
+ \brief Get list of current Plot2d view ranges
+ \param id window identifier
+ \return list of view ranges (XMin, XMax, YMin, YMax)
+*/
+
+class TFitRangeCurrent: public SALOME_Event
+{
+public:
+ typedef QList<double> TResult;
+ TResult myResult;
+ int myWndId;
+ TFitRangeCurrent( const int id )
+ : myWndId( id ) {}
+ virtual void Execute()
+ {
+ myResult.clear();
+ Plot2d_ViewWindow* wnd = dynamic_cast<Plot2d_ViewWindow*>(getWnd( myWndId ));
+ if ( wnd )
+ {
+ double XMin, XMax, YMin, YMax, Y2Min, Y2Max;
+ wnd->getViewFrame()->getFitRanges(XMin, XMax, YMin, YMax, Y2Min, Y2Max);
+ myResult.append(XMin);
+ myResult.append(XMax);
+ myResult.append(YMin);
+ myResult.append(YMax);
+ }
+ }
+};
+QList<double> SalomePyQt::getPlot2dFitRangeCurrent( const int id )
+{
+ return ProcessEvent( new TFitRangeCurrent( id ) );
+}
+
+/*!
+ \fn void SalomePyQt::setPlot2dFitRange( const int id, const double XMin, const double XMax, const double YMin, const double YMax )
+ \brief Set range of Plot2d view
+ \param id window identifier
+ \param XMin
+ \param XMax
+ \param YMin
+ \param YMax
+*/
+
+class TPlot2dFitRange: public SALOME_Event
+{
+public:
+ int myWndId;
+ double myXMin;
+ double myXMax;
+ double myYMin;
+ double myYMax;
+ TPlot2dFitRange(const int id, const double XMin, const double XMax, const double YMin, const double YMax) :
+ myWndId(id),
+ myXMin(XMin),
+ myXMax(XMax),
+ myYMin(YMin),
+ myYMax(YMax) {}
+ virtual void Execute() {
+ Plot2d_ViewWindow* wnd = dynamic_cast<Plot2d_ViewWindow*>(getWnd( myWndId ));
+ if ( wnd )
+ {
+ wnd->getViewFrame()->fitData(0, myXMin, myXMax, myYMin, myYMax);
+ }
+ }
+};
+void SalomePyQt::setPlot2dFitRange(const int id, const double XMin, const double XMax, const double YMin, const double YMax)
+{
+ ProcessVoidEvent( new TPlot2dFitRange(id, XMin, XMax, YMin, YMax) );
+}
+
+//class TInitParaview: public SALOME_Event
+//{
+//public:
+// TInitParaview() {}
+// virtual void Execute() {
+// LightApp_Application* anApp = getApplication();
+// // Create PVViewer_ViewManager, which will initialize ParaView stuff
+// PVViewer_ViewManager* viewMgr =
+// dynamic_cast<PVViewer_ViewManager*>( anApp->getViewManager( PVViewer_Viewer::Type(), true ) );
+// }
+//};
+//void SalomePyQt::initializeParaViewGUI()
+//{
+// ProcessVoidEvent( new TInitParaview() );
+//}
+
+void SalomePyQt::processEvents()
+{
+ QCoreApplication::processEvents();
+}
+
+void SalomePyQt::setVisibilityState( const QString& theEntry, VisibilityState theState)
+{
+ class TEvent: public SALOME_Event
+ {
+ QString myEntry;
+ int myState;
+ public:
+ TEvent( const QString& theEntry, int theState):
+ myEntry(theEntry), myState(theState) {}
+ virtual void Execute()
+ {
+ LightApp_Study* aStudy = getActiveStudy();
+ if ( !aStudy )
+ return;
+ aStudy->setVisibilityState(myEntry, (Qtx::VisibilityState)myState);
+ }
+ };
+ ProcessVoidEvent( new TEvent(theEntry, theState ) );
+}
+
+class TGetVisibilityStateEvent: public SALOME_Event
+{
+public:
+ typedef int TResult;
+ TResult myResult;
+ QString myEntry;
+ TGetVisibilityStateEvent(const QString& theEntry) : myResult( 0 ), myEntry(theEntry) {}
+ virtual void Execute()
+ {
+ LightApp_Study* aStudy = getActiveStudy();
+ if ( aStudy )
+ myResult = aStudy->visibilityState(myEntry);
+ }
+};
+
+VisibilityState SalomePyQt::getVisibilityState( const QString& theEntry )
+{
+ return (VisibilityState) ProcessEvent( new TGetVisibilityStateEvent(theEntry) );
+}
+
+
+void SalomePyQt::setObjectPosition( const QString& theEntry, int thePos )
+{
+ class TEvent: public SALOME_Event
+ {
+ QString myEntry;
+ int myPos;
+ public:
+ TEvent( const QString& theEntry, int thePos):
+ myEntry(theEntry), myPos(thePos) {}
+ virtual void Execute()
+ {
+ SALOME_PYQT_ModuleLight* module = dynamic_cast<SALOME_PYQT_ModuleLight*>( getActiveModule() );
+ if ( module )
+ module->setObjectPosition(myEntry, myPos );
+ }
+ };
+ ProcessVoidEvent( new TEvent(theEntry, thePos ) );
+}
+
+
+
+class TGetObjectPositionEvent: public SALOME_Event
+{
+public:
+ typedef int TResult;
+ TResult myResult;
+ QString myEntry;
+ TGetObjectPositionEvent(const QString& theEntry) : myResult( 0 ), myEntry(theEntry) {}
+ virtual void Execute()
+ {
+ SALOME_PYQT_ModuleLight* module = dynamic_cast<SALOME_PYQT_ModuleLight*>( getActiveModule() );
+ if ( module )
+ myResult = module->getObjectPosition(myEntry);
+ }
+};
+
+int SalomePyQt::getObjectPosition( const QString& theEntry )
+{
+ return ProcessEvent( new TGetObjectPositionEvent(theEntry) );
+}
+
+void SalomePyQt::startPyLog(const QString& theFileName)
+{
+ class TEvent: public SALOME_Event
+ {
+ QString myFileName;
+ public:
+ TEvent( const QString& theFileName ):
+ myFileName( theFileName ) {}
+ virtual void Execute()
+ {
+ if ( getApplication() ) {
+ PyConsole_Console* pyConsole = getApplication()->pythonConsole( false );
+ if ( pyConsole ) pyConsole->startLog( myFileName );
+ }
+ }
+ };
+ ProcessVoidEvent( new TEvent( theFileName ) );
+}
+
+void SalomePyQt::stopPyLog()
+{
+ class TEvent: public SALOME_Event
+ {
+ public:
+ TEvent() {}
+ virtual void Execute()
+ {
+ if ( getApplication() ) {
+ PyConsole_Console* pyConsole = getApplication()->pythonConsole( false );
+ if ( pyConsole ) pyConsole->stopLog();
+ }
+ }
+ };
+ ProcessVoidEvent( new TEvent() );
+}