1 // Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // File : SalomePyQt.cxx
24 // Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
27 // E.A. : On windows with python 2.6, there is a conflict
28 // E.A. : between pymath.h and Standard_math.h which define
29 // E.A. : some same symbols : acosh, asinh, ...
30 #include <Standard_math.hxx>
34 #include "SALOME_PYQT_ModuleLight.h" // this include must be first!!!
35 #include "SALOME_PYQT_DataModelLight.h"
36 #include "SALOME_PYQT_PyModule.h"
37 #include "SalomePyQt.h"
39 #include "LightApp_SelectionMgr.h"
40 #include "LogWindow.h"
41 #ifndef DISABLE_OCCVIEWER
42 #include "OCCViewer_ViewWindow.h"
43 #include "OCCViewer_ViewFrame.h"
44 #endif // DISABLE_OCCVIEWER
45 #ifndef DISABLE_VTKVIEWER
46 #include "SVTK_ViewWindow.h"
47 #endif // DISABLE_VTKVIEWER
48 #ifndef DISABLE_PLOT2DVIEWER
49 #include "Plot2d_ViewManager.h"
50 #include "Plot2d_ViewWindow.h"
51 #endif // DISABLE_PLOT2DVIEWER
52 #ifndef DISABLE_PVVIEWER
53 #include "PVViewer_ViewManager.h"
54 #include "PVViewer_ViewModel.h"
55 #endif // DISABLE_PVVIEWER
56 #include "QtxActionMenuMgr.h"
57 #include "QtxWorkstack.h"
58 #include "QtxTreeView.h"
59 #include "SALOME_Event.h"
60 #include "STD_TabDesktop.h"
61 #include "SUIT_DataBrowser.h"
62 #include "SUIT_ResourceMgr.h"
63 #include "SUIT_Session.h"
64 #include "SUIT_Tools.h"
65 #include "SUIT_ViewManager.h"
66 #include "SUIT_ViewWindow.h"
67 #include "PyConsole_Console.h"
70 #include <QApplication>
71 #include <QPaintEvent>
72 #include <QCoreApplication>
73 #include <QVBoxLayout>
75 #include <utilities.h>
80 \brief Get the currently active application.
82 \return active application object or 0 if there is no any
84 LightApp_Application* getApplication()
86 if ( SUIT_Session::session() )
87 return dynamic_cast<LightApp_Application*>( SUIT_Session::session()->activeApplication() );
92 \brief Get the currently active study.
94 \return active study or 0 if there is no study opened
96 LightApp_Study* getActiveStudy()
98 if ( getApplication() )
99 return dynamic_cast<LightApp_Study*>( getApplication()->activeStudy() );
104 \brief Get the currently active module.
106 This function returns correct result only if Python-based
107 module is currently active. Otherwize, 0 is returned.
109 LightApp_Module* getActiveModule()
111 LightApp_Module* module = 0;
112 if ( LightApp_Application* anApp = getApplication() ) {
113 module = PyModuleHelper::getInitModule();
115 module = dynamic_cast<LightApp_Module*>( anApp->activeModule() );
121 \brief Get the currently active Python module's helper.
123 This function returns correct result only if Python-based
124 module is currently active. Otherwize, 0 is returned.
126 PyModuleHelper* getPythonHelper()
128 LightApp_Module* module = getActiveModule();
129 PyModuleHelper* helper = module ? module->findChild<PyModuleHelper*>( "python_module_helper" ) : 0;
134 \brief Get SALOME verbose level
136 \return \c true if SALOME debug output is allowed or \c false otherwise
140 bool isVerbose = false;
141 if ( getenv( "SALOME_VERBOSE" ) ) {
142 QString envVar = getenv( "SALOME_VERBOSE" );
144 int value = envVar.toInt( &ok );
145 isVerbose = ok && value != 0;
151 \brief Get menu item title
153 \param menuId menu identifier
154 \return menu title (localized)
156 QString getMenuName( const QString& menuId )
158 QStringList contexts;
159 contexts << "SalomeApp_Application" << "LightApp_Application" << "STD_TabDesktop" <<
160 "STD_MDIDesktop" << "STD_Application" << "SUIT_Application" << "";
161 QString menuName = menuId;
162 for ( int i = 0; i < contexts.count() && menuName == menuId; i++ )
163 menuName = QApplication::translate( contexts[i].toLatin1().data(), menuId.toLatin1().data() );
168 \brief Load module icon
170 \param module module name
171 \param fileName path to the icon file
174 QIcon loadIconInternal( const QString& module, const QString& fileName )
178 LightApp_Application* app = getApplication();
180 if ( app && !fileName.isEmpty() ) {
181 QPixmap pixmap = app->resourceMgr()->loadPixmap( module,
182 QApplication::translate( module.toLatin1().data(),
183 fileName.toLatin1().data() ) );
184 if ( !pixmap.isNull() )
185 icon = QIcon( pixmap );
191 \brief Gets window with specified identifier
193 \param id window identifier
194 \return pointer on the window
196 SUIT_ViewWindow* getWnd( const int id )
198 SUIT_ViewWindow* resWnd = 0;
200 LightApp_Application* app = getApplication();
202 ViewManagerList vmlist = app->viewManagers();
203 foreach( SUIT_ViewManager* vm, vmlist ) {
204 QVector<SUIT_ViewWindow*> vwlist = vm->getViews();
205 foreach ( SUIT_ViewWindow* vw, vwlist ) {
206 if ( id == vw->getId() ) {
217 \brief Map of created selection objects.
220 QMap<LightApp_Application*, SALOME_Selection*> SelMap;
223 \brief Default resource file section name.
226 const char* DEFAULT_SECTION = "SalomePyQt";
230 \class SALOME_Selection
231 \brief The class represents selection which can be used in Python.
235 \brief Get the selection object for the specified application.
237 Finds or creates the selection object (one per study).
239 \param app application object
240 \return selection object or 0 if \a app is invalid
242 SALOME_Selection* SALOME_Selection::GetSelection( LightApp_Application* app )
244 SALOME_Selection* sel = 0;
245 if ( app && SelMap.find( app ) != SelMap.end() )
248 sel = SelMap[ app ] = new SALOME_Selection( app );
255 \param p parent object
257 SALOME_Selection::SALOME_Selection( QObject* p ) : QObject( 0 ), mySelMgr( 0 )
259 LightApp_Application* app = dynamic_cast<LightApp_Application*>( p );
261 mySelMgr = app->selectionMgr();
262 connect( mySelMgr, SIGNAL( selectionChanged() ), this, SIGNAL( currentSelectionChanged() ) );
263 connect( mySelMgr, SIGNAL( destroyed() ), this, SLOT ( onSelMgrDestroyed() ) );
270 SALOME_Selection::~SALOME_Selection()
272 LightApp_Application* app = 0;
273 QMap<LightApp_Application*, SALOME_Selection*>::Iterator it;
274 for ( it = SelMap.begin(); it != SelMap.end() && !app; ++it ) {
275 if ( it.value() == this ) app = it.key();
277 if ( app ) SelMap.remove( app );
281 \brief Called when selection manager is destroyed (usually
282 when the study is closed).
284 void SALOME_Selection::onSelMgrDestroyed()
290 \brief Clear the selection.
292 void SALOME_Selection::Clear()
294 class TEvent: public SALOME_Event
296 LightApp_SelectionMgr* mySelMgr;
298 TEvent( LightApp_SelectionMgr* selMgr )
299 : mySelMgr( selMgr ) {}
300 virtual void Execute()
303 mySelMgr->clearSelected();
306 ProcessVoidEvent( new TEvent( mySelMgr ) );
310 \brief Clear the selection.
312 void SALOME_Selection::ClearIObjects()
318 Removes all selection filters.
320 void SALOME_Selection::ClearFilters()
322 class TEvent: public SALOME_Event
324 LightApp_SelectionMgr* mySelMgr;
326 TEvent( LightApp_SelectionMgr* selMgr )
327 : mySelMgr( selMgr ) {}
328 virtual void Execute()
331 mySelMgr->clearFilters();
334 ProcessVoidEvent( new TEvent( mySelMgr ) );
338 \class UserDefinedContent
339 \brief The class represents base class for user defined widget that
340 can be inserted to the Preferences dialog.
346 UserDefinedContent::UserDefinedContent()
352 \brief Called from Preferences dialog to store settings to the resource file.
354 void UserDefinedContent::store()
359 \brief Called from Preferences dialog to restore settings from the resource file.
361 void UserDefinedContent::retrieve()
366 \class SgPyQtUserDefinedContent
367 \brief A Wrapper for UserDefinedContent class.
370 class SgPyQtUserDefinedContent: public QtxUserDefinedContent
373 SgPyQtUserDefinedContent(UserDefinedContent*);
374 virtual ~SgPyQtUserDefinedContent();
376 void store( QtxResourceMgr*, QtxPreferenceMgr* );
377 void retrieve( QtxResourceMgr*, QtxPreferenceMgr* );
380 UserDefinedContent* myContent;
384 \brief Create custom item for Preferences dialog wrapping widget passed from Python.
387 SgPyQtUserDefinedContent::SgPyQtUserDefinedContent(UserDefinedContent* content)
388 : QtxUserDefinedContent( 0 ), myContent( content )
390 QVBoxLayout* l = new QVBoxLayout( this );
391 l->setContentsMargins( 0, 0, 0, 0 );
392 l->addWidget( myContent );
399 SgPyQtUserDefinedContent::~SgPyQtUserDefinedContent()
404 \brief Called from Preferences dialog to store settings to the resource file.
407 void SgPyQtUserDefinedContent::store( QtxResourceMgr*, QtxPreferenceMgr* )
413 \brief Called from Preferences dialog to restore settings from the resource file.
416 void SgPyQtUserDefinedContent::retrieve( QtxResourceMgr*, QtxPreferenceMgr* )
418 myContent->retrieve();
423 \brief The class provides utility functions which can be used in the Python
424 to operate with the SALOME GUI.
426 All the functionality of this class is implemented as static methods, so they
427 can be called with the class name prefixed or via creation of the class instance.
428 For example, next both ways of SalomePyQt class usage are legal:
430 from SalomePyQt import *
432 # using SalomePyQt class instance
433 desktop = sg.getDesktop()
434 # using SalomePyQt class directly
435 menubar = SalomePyQt.getMainMenuBar()
440 \fn QWidget* SalomePyQt::getDesktop();
441 \brief Get the active application's desktop window.
442 \return desktop window or 0 if there is no any
445 class TGetDesktopEvent: public SALOME_Event
448 typedef QWidget* TResult;
450 TGetDesktopEvent() : myResult( 0 ) {}
451 virtual void Execute()
453 if ( getApplication() )
454 myResult = (QWidget*)( getApplication()->desktop() );
457 QWidget* SalomePyQt::getDesktop()
459 return ProcessEvent( new TGetDesktopEvent() );
463 \fn QWidget* SalomePyQt::getMainFrame();
464 \brief Get current application's main frame widget [obsolete].
466 Main frame widget is an internal widget of the application
467 desktop window (workspace).
469 \return workspace widget (0 on any error)
472 class TGetMainFrameEvent: public SALOME_Event
475 typedef QWidget* TResult;
477 TGetMainFrameEvent() : myResult( 0 ) {}
478 virtual void Execute()
480 if ( getApplication() ) {
481 SUIT_Desktop* aDesktop = getApplication()->desktop();
482 myResult = (QWidget*)( aDesktop->centralWidget() );
486 QWidget* SalomePyQt::getMainFrame()
488 return ProcessEvent( new TGetMainFrameEvent() );
492 \fn QMenuBar* SalomePyQt::getMainMenuBar();
493 \brief Get current application desktop's main menu.
494 \return main menu object (0 on any error)
497 class TGetMainMenuBarEvent: public SALOME_Event
500 typedef QMenuBar* TResult;
502 TGetMainMenuBarEvent() : myResult( 0 ) {}
503 virtual void Execute()
505 if ( LightApp_Application* anApp = getApplication() ) {
506 myResult = anApp->desktop()->menuBar();
510 QMenuBar* SalomePyQt::getMainMenuBar()
512 return ProcessEvent( new TGetMainMenuBarEvent() );
516 \fn QMenu* SalomePyQt::getPopupMenu( const MenuName menu );
517 \brief Get main menu's child popup submenu by its identifier.
519 This function is obsolete.
520 Use QMenu* SalomePyQt::getPopupMenu( const QString& menu ) instead.
522 \param menu menu identifier
523 \return popup submenu object or 0 if it does not exist
527 \fn QMenu* SalomePyQt::getPopupMenu( const QString& menu );
528 \brief Get main menu's child popup submenu by its name.
530 The function creates menu if it does not exist.
532 \param menu menu name
533 \return popup submenu object (0 on any error)
536 class TGetPopupMenuEvent: public SALOME_Event
539 typedef QMenu* TResult;
542 TGetPopupMenuEvent( const QString& menu ) : myResult( 0 ), myMenuName( menu ) {}
543 virtual void Execute()
545 LightApp_Application* anApp = getApplication();
546 if ( anApp && !myMenuName.isEmpty() ) {
547 QtxActionMenuMgr* mgr = anApp->desktop()->menuMgr();
548 myResult = mgr->findMenu( myMenuName, -1, false ); // search only top menu
553 QMenu* SalomePyQt::getPopupMenu( const MenuName menu )
558 menuName = getMenuName( "MEN_DESK_FILE" ); break;
560 menuName = getMenuName( "MEN_DESK_VIEW" ); break;
562 menuName = getMenuName( "MEN_DESK_EDIT" ); break;
564 menuName = getMenuName( "MEN_DESK_PREFERENCES" ); break;
566 menuName = getMenuName( "MEN_DESK_TOOLS" ); break;
568 menuName = getMenuName( "MEN_DESK_WINDOW" ); break;
570 menuName = getMenuName( "MEN_DESK_HELP" ); break;
572 return ProcessEvent( new TGetPopupMenuEvent( menuName ) );
574 QMenu* SalomePyQt::getPopupMenu( const QString& menu )
576 return ProcessEvent( new TGetPopupMenuEvent( menu ) );
580 \fn QTreeView* SalomePyQt::getObjectBrowser();
581 \brief Get object browser
582 \return object browser for the active study or 0 in case of error
585 class TGetObjectBrowserEvent: public SALOME_Event
588 typedef QTreeView* TResult;
590 TGetObjectBrowserEvent() : myResult( 0 ) {}
591 virtual void Execute()
593 LightApp_Application* anApp = getApplication();
594 if ( anApp && anApp->objectBrowser() ) {
595 myResult = anApp->objectBrowser()->treeView();
599 QTreeView* SalomePyQt::getObjectBrowser()
601 return ProcessEvent( new TGetObjectBrowserEvent() );
605 \fn int SalomePyQt::getStudyId();
606 \brief Get active study's identifier.
607 \return active study ID or 0 if there is no active study
610 class TGetStudyIdEvent: public SALOME_Event
615 TGetStudyIdEvent() : myResult( 0 ) {}
616 virtual void Execute()
618 if ( LightApp_Study* aStudy = getActiveStudy() ) {
619 myResult = aStudy->id();
623 int SalomePyQt::getStudyId()
625 return ProcessEvent( new TGetStudyIdEvent() );
629 \fn SALOME_Selection* SalomePyQt::getSelection();
630 \brief Get the selection object for the current study.
632 Creates a Selection object if it has not been created yet.
634 \return selection object (0 on error)
637 class TGetSelectionEvent: public SALOME_Event
640 typedef SALOME_Selection* TResult;
642 TGetSelectionEvent() : myResult( 0 ) {}
643 virtual void Execute()
645 myResult = SALOME_Selection::GetSelection( getApplication() );
648 SALOME_Selection* SalomePyQt::getSelection()
650 return ProcessEvent( new TGetSelectionEvent() );
654 \fn QStringList* SalomePyQt::setSelection(const QStringList& );
655 \brief Send local selection for notification.
657 The list of locally selected objects (study entries) is sent for notification of
658 other listening entities (modules, viewers...).
661 class TSetSelectionEvent: public SALOME_Event
663 QStringList myEntryList;
665 TSetSelectionEvent(const QStringList& entryList) : myEntryList(entryList) {}
666 virtual void Execute()
668 SALOME_PYQT_ModuleLight* module = dynamic_cast<SALOME_PYQT_ModuleLight*>( getActiveModule() );
669 if ( !module ) return;
670 module->setLocalSelected(myEntryList);
673 void SalomePyQt::setSelection( const QStringList& entryList)
675 return ProcessVoidEvent( new TSetSelectionEvent(entryList) );
679 \fn void SalomePyQt::enableSelector();
680 \brief enable PyQt_Selector (on module activation, for instance)
683 class TEnableSelectorEvent: public SALOME_Event
686 TEnableSelectorEvent() {}
687 virtual void Execute()
689 SALOME_PYQT_ModuleLight* module = dynamic_cast<SALOME_PYQT_ModuleLight*>( getActiveModule() );
690 if ( !module ) return;
691 module->enableSelector();
694 void SalomePyQt::enableSelector()
696 return ProcessVoidEvent( new TEnableSelectorEvent() );
701 \fn void SalomePyQt::disableSelector();
702 \brief disable PyQt_Selector (on module activation, for instance)
705 class TdisableSelectorEvent: public SALOME_Event
708 TdisableSelectorEvent() {}
709 virtual void Execute()
711 SALOME_PYQT_ModuleLight* module = dynamic_cast<SALOME_PYQT_ModuleLight*>( getActiveModule() );
712 if ( !module ) return;
713 module->disableSelector();
716 void SalomePyQt::disableSelector()
718 return ProcessVoidEvent( new TdisableSelectorEvent() );
723 \fn void SalomePyQt::putInfo( const QString& msg, const int sec );
724 \brief Put an information message to the current application's
727 Optional second delay parameter (\a sec) can be used to specify
728 time of the message diplaying in seconds. If this parameter is less
729 or equal to zero, the constant message will be put.
731 \param msg message text
732 \param sec message displaying time in seconds
735 class TPutInfoEvent: public SALOME_Event
740 TPutInfoEvent( const QString& msg, const int sec = 0 ) : myMsg( msg ), mySecs( sec ) {}
741 virtual void Execute()
743 if ( LightApp_Application* anApp = getApplication() ) {
744 anApp->putInfo( myMsg, mySecs * 1000 );
748 void SalomePyQt::putInfo( const QString& msg, const int sec )
750 ProcessVoidEvent( new TPutInfoEvent( msg, sec ) );
754 \fn const QString SalomePyQt::getActiveComponent();
755 \brief Get the currently active module name (for the current study).
756 \return active module name or empty string if there is no active module
759 class TGetActiveComponentEvent: public SALOME_Event
762 typedef QString TResult;
764 TGetActiveComponentEvent() {}
765 virtual void Execute()
767 if ( LightApp_Application* anApp = getApplication() ) {
768 if ( CAM_Module* mod = anApp->activeModule() ) {
769 myResult = mod->name();
774 const QString SalomePyQt::getActiveComponent()
776 return ProcessEvent( new TGetActiveComponentEvent() );
780 \fn PyObject* SalomePyQt::getActivePythonModule();
781 \brief Access to Python module object currently loaded into SALOME_PYQT_ModuleLight container.
782 \return Python module object currently loaded into SALOME_PYQT_ModuleLight container
785 class TGetActivePyModuleEvent: public SALOME_Event
788 typedef PyObject* TResult;
790 TGetActivePyModuleEvent() : myResult( Py_None ) {}
791 virtual void Execute()
793 PyModuleHelper* helper = getPythonHelper();
795 myResult = (PyObject*)helper->pythonModule();
798 PyObject* SalomePyQt::getActivePythonModule()
800 return ProcessEvent( new TGetActivePyModuleEvent() );
804 \fn bool SalomePyQt::activateModule( const QString& modName );
805 \brief Activates SALOME module with the given name
806 \return True if the module has been activated and False otherwise.
809 class TActivateModuleEvent: public SALOME_Event
812 typedef bool TResult;
814 QString myModuleName;
815 TActivateModuleEvent( const QString& modName )
816 : myResult( false ), myModuleName( modName ) {}
817 virtual void Execute()
819 if ( LightApp_Application* anApp = getApplication() ) {
820 myResult = anApp->activateModule( myModuleName );
824 bool SalomePyQt::activateModule( const QString& modName )
826 return ProcessEvent( new TActivateModuleEvent( modName ) );
830 \brief Update an Object Browser of the specified (by identifier) study.
832 If \a studyId <= 0 the active study's object browser is updated.
833 The \a updateSelection parameter is obsolete and currently is not used.
834 This parameter will be removed in future, so try to avoid its usage in
837 \brief studyId study identifier
838 \brief updateSelection update selection flag (not used)
841 void SalomePyQt::updateObjBrowser( const int studyId, bool updateSelection )
843 class TEvent: public SALOME_Event
846 bool myUpdateSelection;
848 TEvent( const int studyId, bool updateSelection )
849 : myStudyId( studyId ), myUpdateSelection( updateSelection ) {}
850 virtual void Execute()
852 if ( SUIT_Session::session() ) {
853 if ( getActiveStudy() && myStudyId <= 0 )
854 myStudyId = getActiveStudy()->id();
855 if ( myStudyId > 0 ) {
856 QList<SUIT_Application*> apps = SUIT_Session::session()->applications();
857 QList<SUIT_Application*>::Iterator it;
858 for( it = apps.begin(); it != apps.end(); ++it ) {
859 LightApp_Application* anApp = dynamic_cast<LightApp_Application*>( *it );
860 if ( anApp && anApp->activeStudy() && anApp->activeStudy()->id() == myStudyId ) {
861 anApp->updateObjectBrowser();
869 ProcessVoidEvent( new TEvent( studyId, updateSelection ) );
874 SalomePyQt::isModified()
875 \return The modification status of the data model
876 for the currently active Python module
877 \note This function is supported for "light" Python-based SALOME modules only.
880 class TIsModifiedEvent: public SALOME_Event
883 typedef bool TResult;
885 TIsModifiedEvent() : myResult( false ) {}
886 virtual void Execute()
888 LightApp_Module* module = getActiveModule();
892 SALOME_PYQT_DataModelLight* aModel =
893 dynamic_cast<SALOME_PYQT_DataModelLight*>( module->dataModel() );
895 myResult = aModel->isModified();
898 if ( verbose() ) printf( "SalomePyQt.isModified() function is not supported for the current module.\n" );
902 bool SalomePyQt::isModified()
904 return ProcessEvent(new TIsModifiedEvent());
908 SalomePyQt::setModified()
910 Sets the modification status of the data model for
911 the currently active Python module. This method should be used
912 by the Python code in order to enable/disable "Save" operation
913 depending on the module's data state.
915 \note This function is supported for "light" Python-based SALOME modules only.
917 \param New modification status of the data model
921 void SalomePyQt::setModified( bool flag )
923 class TEvent: public SALOME_Event
929 virtual void Execute()
931 LightApp_Module* module = getActiveModule();
935 SALOME_PYQT_DataModelLight* model =
936 dynamic_cast<SALOME_PYQT_DataModelLight*>( module->dataModel() );
938 LightApp_Application* app = module->getApp();
940 if ( model && app ) {
941 model->setModified( myFlag );
942 app->updateActions();
945 if ( verbose() ) printf( "SalomePyQt.setModified() function is not supported for the current module.\n" );
949 ProcessVoidEvent( new TEvent( flag ) );
953 \brief Add string setting to the application preferences.
955 The parameter \a autoValue is obsolete parameter and currently is not used.
956 This parameter will be removed in future, so try to avoid its usage in
959 This function is obsolete. Use one of addSetting() instead.
961 \param name setting name (it should be of kind <section:setting> where
962 \c section is resources section name and \c setting is setting name)
963 \param value new setting value
964 \param autoValue (not used)
966 void SalomePyQt::addStringSetting( const QString& name, const QString& value, bool autoValue )
968 class TEvent: public SALOME_Event
974 TEvent( const QString& name, const QString& value, bool autoValue )
975 : myName( name ), myValue( value ), myAutoValue( autoValue ) {}
976 virtual void Execute()
978 if ( SUIT_Session::session() ) {
979 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
980 QStringList sl = myName.split( ":", QString::SkipEmptyParts );
981 QString _sec = sl.count() > 1 ? sl[ 0 ].trimmed() : QString( DEFAULT_SECTION );
982 QString _nam = sl.count() > 1 ? sl[ 1 ].trimmed() : sl.count() > 0 ? sl[ 0 ].trimmed() : QString( "" );
983 if ( !_sec.isEmpty() && !_nam.isEmpty() )
984 resMgr->setValue( _sec, _nam, myValue );
988 ProcessVoidEvent( new TEvent( name, value, autoValue ) );
992 \brief Add integer setting to the application preferences.
994 The parameter \a autoValue is obsolete parameter and currently is not used.
995 This parameter will be removed in future, so try to avoid its usage in
998 This function is obsolete. Use one of addSetting() instead.
1000 \param name setting name (it should be of kind <section:setting> where
1001 \c section is resources section name and \c setting is setting name)
1002 \param value new setting value
1003 \param autoValue (not used)
1005 void SalomePyQt::addIntSetting( const QString& name, const int value, bool autoValue)
1007 class TEvent: public SALOME_Event
1013 TEvent( const QString& name, const int value, bool autoValue )
1014 : myName( name ), myValue( value ), myAutoValue( autoValue ) {}
1015 virtual void Execute()
1017 if ( SUIT_Session::session() ) {
1018 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1019 QStringList sl = myName.split( ":", QString::SkipEmptyParts );
1020 QString _sec = sl.count() > 1 ? sl[ 0 ].trimmed() : QString( DEFAULT_SECTION );
1021 QString _nam = sl.count() > 1 ? sl[ 1 ].trimmed() : sl.count() > 0 ? sl[ 0 ].trimmed() : QString( "" );
1022 if ( !_sec.isEmpty() && !_nam.isEmpty() )
1023 resMgr->setValue( _sec, _nam, myValue );
1027 ProcessVoidEvent( new TEvent( name, value, autoValue ) );
1031 \brief Add double setting to the application preferences.
1033 The parameter \a autoValue is obsolete parameter and currently is not used.
1034 This parameter will be removed in future, so try to avoid its usage in
1037 This function is obsolete. Use one of addSetting() instead.
1039 \param name setting name (it should be of kind <section:setting> where
1040 \c section is resources section name and \c setting is setting name)
1041 \param value new setting value
1042 \param autoValue (not used)
1044 void SalomePyQt::addDoubleSetting( const QString& name, const double value, bool autoValue )
1046 class TEvent: public SALOME_Event
1052 TEvent( const QString& name, const double value, bool autoValue )
1053 : myName( name ), myValue( value ), myAutoValue( autoValue ) {}
1054 virtual void Execute()
1056 if ( SUIT_Session::session() ) {
1057 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1058 QStringList sl = myName.split( ":", QString::SkipEmptyParts );
1059 QString _sec = sl.count() > 1 ? sl[ 0 ].trimmed() : QString( DEFAULT_SECTION );
1060 QString _nam = sl.count() > 1 ? sl[ 1 ].trimmed() : sl.count() > 0 ? sl[ 0 ].trimmed() : QString( "" );
1061 if ( !_sec.isEmpty() && !_nam.isEmpty() )
1062 resMgr->setValue( _sec, _nam, myValue );
1066 ProcessVoidEvent( new TEvent( name, value, autoValue ) );
1070 \brief Add boolean setting to the application preferences.
1072 The parameter \a autoValue is obsolete parameter and currently is not used.
1073 This parameter will be removed in future, so try to avoid its usage in
1076 This function is obsolete. Use one of addSetting() instead.
1078 \param name setting name (it should be of kind <section:setting> where
1079 \c section is resources section name and \c setting is setting name)
1080 \param value new setting value
1081 \param autoValue (not used)
1083 void SalomePyQt::addBoolSetting( const QString& name, const bool value, bool autoValue )
1085 class TEvent: public SALOME_Event
1091 TEvent( const QString& name, const bool value, bool autoValue )
1092 : myName( name ), myValue( value ), myAutoValue( autoValue ) {}
1093 virtual void Execute()
1095 if ( SUIT_Session::session() ) {
1096 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1097 QStringList sl = myName.split( ":", QString::SkipEmptyParts );
1098 QString _sec = sl.count() > 1 ? sl[ 0 ].trimmed() : QString( DEFAULT_SECTION );
1099 QString _nam = sl.count() > 1 ? sl[ 1 ].trimmed() : sl.count() > 0 ? sl[ 0 ].trimmed() : QString( "" );
1100 if ( !_sec.isEmpty() && !_nam.isEmpty() )
1101 resMgr->setValue( _sec, _nam, myValue );
1105 ProcessVoidEvent( new TEvent( name, value, autoValue ) );
1109 \brief Remove setting from the application preferences.
1111 This function is obsolete. Use removeSetting() instead.
1113 \param name setting name (it should be of kind <section:setting> where
1114 \c section is resources section name and \c setting is setting name)
1116 void SalomePyQt::removeSettings( const QString& name )
1118 class TEvent: public SALOME_Event
1122 TEvent( const QString& name ) : myName( name ) {}
1123 virtual void Execute()
1125 if ( SUIT_Session::session() ) {
1126 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1127 QStringList sl = myName.split( ":", QString::SkipEmptyParts );
1128 QString _sec = sl.count() > 1 ? sl[ 0 ].trimmed() : QString( DEFAULT_SECTION );
1129 QString _nam = sl.count() > 1 ? sl[ 1 ].trimmed() : sl.count() > 0 ? sl[ 0 ].trimmed() : QString( "" );
1130 if ( !_sec.isEmpty() && !_nam.isEmpty() )
1131 resMgr->remove( _sec, _nam );
1135 ProcessVoidEvent( new TEvent( name ) );
1139 \fn QString SalomePyQt::getSetting( const QString& name );
1140 \brief Get application setting value (as string represenation).
1142 This function is obsolete. Use stringSetting(), integerSetting(),
1143 boolSetting(), stringSetting() or colorSetting() instead.
1145 \param name setting name (it should be of kind <section:setting> where
1146 \c section is resources section name and \c setting is setting name)
1147 \return setting name (empty string if setting name is invalid)
1150 class TGetSettingEvent: public SALOME_Event
1153 typedef QString TResult;
1156 TGetSettingEvent( const QString& name ) : myName( name ) {}
1157 virtual void Execute()
1159 if ( SUIT_Session::session() ) {
1160 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1161 QStringList sl = myName.split( ":", QString::SkipEmptyParts );
1162 QString _sec = sl.count() > 1 ? sl[ 0 ].trimmed() : QString( DEFAULT_SECTION );
1163 QString _nam = sl.count() > 1 ? sl[ 1 ].trimmed() : sl.count() > 0 ? sl[ 0 ].trimmed() : QString( "" );
1164 myResult = ( !_sec.isEmpty() && !_nam.isEmpty() ) ? resMgr->stringValue( _sec, _nam, "" ) : QString( "" );
1168 QString SalomePyQt::getSetting( const QString& name )
1170 return ProcessEvent( new TGetSettingEvent( name ) );
1174 \fn QString SalomePyQt::constant( const QString& name );
1175 \brief Get constant's value from application's resource manager.
1177 \param name name of the constant
1178 \return value of the constant
1183 class TGetConstantEvent: public SALOME_Event
1186 typedef QString TResult;
1189 TGetConstantEvent( const QString& name ) : myName( name ) {}
1190 virtual void Execute()
1192 if ( SUIT_Session::session() )
1193 myResult = SUIT_Session::session()->resourceMgr()->constant( myName );
1196 QString SalomePyQt::constant( const QString& name )
1198 return ProcessEvent( new TGetConstantEvent( name ) );
1202 \brief Add constant to the application's resource manager.
1204 This function is useful to specify programmatically specific
1205 variables that are referenced in the resource setting.
1207 For example, some resource value can be set as "$(myroot)/data/files".
1208 Then, "mypath" constant can be set programmatically by the application
1209 depending on run-time requirements.
1211 \param section resources file section name
1212 \param name name of the constant
1213 \param value value of the constant
1217 void SalomePyQt::setConstant( const QString& name, const QString& value )
1219 class TEvent: public SALOME_Event
1221 QString myName, myValue;
1223 TEvent( const QString& name, const QString& value )
1224 : myName( name ), myValue( value ) {}
1225 virtual void Execute()
1227 if ( SUIT_Session::session() )
1228 SUIT_Session::session()->resourceMgr()->setConstant( myName, myValue );
1231 ProcessVoidEvent( new TEvent( name, value ) );
1235 \brief Add double setting to the application preferences.
1236 \param section resources file section name
1237 \param name setting name
1238 \param value new setting value
1240 void SalomePyQt::addSetting( const QString& section, const QString& name, const double value )
1242 class TEvent: public SALOME_Event
1248 TEvent( const QString& section, const QString& name, double value )
1249 : mySection( section ), myName( name ), myValue( value ) {}
1250 virtual void Execute()
1252 if ( SUIT_Session::session() ) {
1253 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1254 if ( !mySection.isEmpty() && !myName.isEmpty() )
1255 resMgr->setValue( mySection, myName, myValue );
1259 ProcessVoidEvent( new TEvent( section, name, value ) );
1263 \brief Add integer setting to the application preferences.
1264 \param section resources file section name
1265 \param name setting name
1266 \param value new setting value
1268 void SalomePyQt::addSetting( const QString& section, const QString& name, const int value )
1270 class TEvent: public SALOME_Event
1276 TEvent( const QString& section, const QString& name, int value )
1277 : mySection( section ), myName( name ), myValue( value ) {}
1278 virtual void Execute()
1280 if ( SUIT_Session::session() ) {
1281 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1282 if ( !mySection.isEmpty() && !myName.isEmpty() )
1283 resMgr->setValue( mySection, myName, myValue );
1287 ProcessVoidEvent( new TEvent( section, name, value ) );
1291 \brief Add boolean setting to the application preferences.
1292 \param section resources file section name
1293 \param name setting name
1294 \param value new setting value
1295 \param dumb this parameter is used in order to avoid sip compilation error
1296 because of conflicting int and bool types
1298 void SalomePyQt::addSetting( const QString& section, const QString& name, const bool value, const int /*dumb*/ )
1300 class TEvent: public SALOME_Event
1306 TEvent( const QString& section, const QString& name, bool value )
1307 : mySection( section ), myName( name ), myValue( value ) {}
1308 virtual void Execute()
1310 if ( SUIT_Session::session() ) {
1311 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1312 if ( !mySection.isEmpty() && !myName.isEmpty() )
1313 resMgr->setValue( mySection, myName, myValue );
1317 ProcessVoidEvent( new TEvent( section, name, value ) );
1321 \brief Add string setting to the application preferences.
1322 \param section resources file section name
1323 \param name setting name
1324 \param value new setting value
1326 void SalomePyQt::addSetting( const QString& section, const QString& name, const QString& value )
1328 class TEvent: public SALOME_Event
1334 TEvent( const QString& section, const QString& name, const QString& value )
1335 : mySection( section ), myName( name ), myValue( value ) {}
1336 virtual void Execute()
1338 if ( SUIT_Session::session() ) {
1339 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1340 if ( !mySection.isEmpty() && !myName.isEmpty() )
1341 resMgr->setValue( mySection, myName, myValue );
1345 ProcessVoidEvent( new TEvent( section, name, value ) );
1349 \brief Add color setting to the application preferences.
1350 \param section resources file section name
1351 \param name setting name
1352 \param value new setting value
1354 void SalomePyQt::addSetting( const QString& section, const QString& name, const QColor& value )
1356 class TEvent: public SALOME_Event
1362 TEvent( const QString& section, const QString& name, const QColor& value )
1363 : mySection( section ), myName( name ), myValue( value ) {}
1364 virtual void Execute()
1366 if ( SUIT_Session::session() ) {
1367 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1368 if ( !mySection.isEmpty() && !myName.isEmpty() )
1369 resMgr->setValue( mySection, myName, myValue );
1373 ProcessVoidEvent( new TEvent( section, name, value ) );
1377 \brief Add byte array setting to the application preferences.
1378 \param section resources file section name
1379 \param name setting name
1380 \param value new setting value
1382 void SalomePyQt::addSetting( const QString& section, const QString& name, const QByteArray& value )
1384 class TEvent: public SALOME_Event
1390 TEvent( const QString& section, const QString& name, const QByteArray& value )
1391 : mySection( section ), myName( name ), myValue( value ) {}
1392 virtual void Execute()
1394 if ( SUIT_Session::session() ) {
1395 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1396 if ( !mySection.isEmpty() && !myName.isEmpty() )
1397 resMgr->setValue( mySection, myName, myValue );
1401 ProcessVoidEvent( new TEvent( section, name, value ) );
1405 \brief Add font setting to the application preferences.
1406 \param section resources file section name
1407 \param name setting name
1408 \param value new setting value
1410 void SalomePyQt::addSetting( const QString& section, const QString& name, const QFont& value )
1412 class TEvent: public SALOME_Event
1418 TEvent( const QString& section, const QString& name, const QFont& value )
1419 : mySection( section ), myName( name ), myValue( value ) {}
1420 virtual void Execute()
1422 if ( SUIT_Session::session() ) {
1423 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1424 if ( !mySection.isEmpty() && !myName.isEmpty() )
1425 resMgr->setValue( mySection, myName, myValue );
1429 ProcessVoidEvent( new TEvent( section, name, value ) );
1433 \fn int SalomePyQt::integerSetting( const QString& section,
1434 const QString& name,
1436 \brief Get integer setting from the application preferences.
1437 \param section resources file section name
1438 \param name setting name
1439 \param def default value which is returned if the setting is not found
1440 \return setting value
1443 class TGetIntSettingEvent: public SALOME_Event
1446 typedef int TResult;
1451 TGetIntSettingEvent( const QString& section, const QString& name, const int def )
1452 : mySection( section ), myName( name ), myDefault( def ) {}
1453 virtual void Execute()
1455 if ( SUIT_Session::session() ) {
1456 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1457 myResult = ( !mySection.isEmpty() && !myName.isEmpty() ) ? resMgr->integerValue( mySection, myName, myDefault ) : myDefault;
1461 int SalomePyQt::integerSetting( const QString& section, const QString& name, const int def )
1463 return ProcessEvent( new TGetIntSettingEvent( section, name, def ) );
1467 \fn double SalomePyQt::doubleSetting( const QString& section,
1468 const QString& name,
1470 \brief Get double setting from the application preferences.
1471 \param section resources file section name
1472 \param name setting name
1473 \param def default value which is returned if the setting is not found
1474 \return setting value
1477 class TGetDblSettingEvent: public SALOME_Event
1480 typedef double TResult;
1485 TGetDblSettingEvent( const QString& section, const QString& name, const double def )
1486 : mySection( section ), myName( name ), myDefault( def ) {}
1487 virtual void Execute()
1489 if ( SUIT_Session::session() ) {
1490 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1491 myResult = ( !mySection.isEmpty() && !myName.isEmpty() ) ? resMgr->doubleValue( mySection, myName, myDefault ) : myDefault;
1495 double SalomePyQt::doubleSetting( const QString& section, const QString& name, const double def )
1497 return ProcessEvent( new TGetDblSettingEvent( section, name, def ) );
1501 \fn bool SalomePyQt::boolSetting( const QString& section,
1502 const QString& name,
1504 \brief Get boolean setting from the application preferences.
1505 \param section resources file section name
1506 \param name setting name
1507 \param def default value which is returned if the setting is not found
1508 \return setting value
1511 class TGetBoolSettingEvent: public SALOME_Event
1514 typedef bool TResult;
1519 TGetBoolSettingEvent( const QString& section, const QString& name, const bool def )
1520 : mySection( section ), myName( name ), myDefault( def ) {}
1521 virtual void Execute()
1523 if ( SUIT_Session::session() ) {
1524 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1525 myResult = ( !mySection.isEmpty() && !myName.isEmpty() ) ? resMgr->booleanValue( mySection, myName, myDefault ) : myDefault;
1529 bool SalomePyQt::boolSetting( const QString& section, const QString& name, const bool def )
1531 return ProcessEvent( new TGetBoolSettingEvent( section, name, def ) );
1535 \fn QString SalomePyQt::stringSetting( const QString& section,
1536 const QString& name,
1539 \brief Get string setting from the application preferences.
1540 \param section resources file section name
1541 \param name setting name
1542 \param def default value which is returned if the setting is not found
1543 \param subst \c true to make substitution, \c false to get "raw" value
1544 \return setting value
1547 class TGetStrSettingEvent: public SALOME_Event
1550 typedef QString TResult;
1556 TGetStrSettingEvent( const QString& section, const QString& name, const QString& def, const bool subst )
1557 : mySection( section ), myName( name ), myDefault( def ), mySubst( subst ) {}
1558 virtual void Execute()
1560 if ( SUIT_Session::session() ) {
1561 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1562 myResult = ( !mySection.isEmpty() && !myName.isEmpty() ) ? resMgr->stringValue( mySection, myName, myDefault, mySubst ) : myDefault;
1566 QString SalomePyQt::stringSetting( const QString& section, const QString& name, const QString& def, const bool subst )
1568 return ProcessEvent( new TGetStrSettingEvent( section, name, def, subst ) );
1572 \fn QColor SalomePyQt::colorSetting( const QString& section,
1573 const QString& name,
1575 \brief Get color setting from the application preferences.
1576 \param section resources file section name
1577 \param name setting name
1578 \param def default value which is returned if the setting is not found
1579 \return setting value
1582 class TGetColorSettingEvent: public SALOME_Event
1585 typedef QColor TResult;
1590 TGetColorSettingEvent( const QString& section, const QString& name, const QColor& def )
1591 : mySection( section ), myName( name ), myDefault( def ) {}
1592 virtual void Execute()
1594 if ( SUIT_Session::session() ) {
1595 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1596 myResult = ( !mySection.isEmpty() && !myName.isEmpty() ) ? resMgr->colorValue( mySection, myName, myDefault ) : myDefault;
1600 QColor SalomePyQt::colorSetting ( const QString& section, const QString& name, const QColor& def )
1602 return ProcessEvent( new TGetColorSettingEvent( section, name, def ) );
1606 \fn QByteArray SalomePyQt::byteArraySetting( const QString& section,
1607 const QString& name,
1608 const QByteArray& def );
1609 \brief Get byte array setting from the application preferences.
1610 \param section resources file section name
1611 \param name setting name
1612 \param def default value which is returned if the setting is not found
1613 \return setting value
1616 class TGetByteArraySettingEvent: public SALOME_Event
1619 typedef QByteArray TResult;
1624 TGetByteArraySettingEvent( const QString& section, const QString& name, const QByteArray& def )
1625 : mySection( section ), myName( name ), myDefault( def ) {}
1626 virtual void Execute()
1628 if ( SUIT_Session::session() ) {
1629 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1630 myResult = ( !mySection.isEmpty() && !myName.isEmpty() ) ? resMgr->byteArrayValue( mySection, myName, myDefault ) : myDefault;
1634 QByteArray SalomePyQt::byteArraySetting ( const QString& section, const QString& name, const QByteArray& def )
1636 return ProcessEvent( new TGetByteArraySettingEvent( section, name, def ) );
1640 \fn QByteArray SalomePyQt::fontSetting( const QString& section,
1641 const QString& name,
1643 \brief Get font setting from the application preferences.
1644 \param section resources file section name
1645 \param name setting name
1646 \param def default value which is returned if the setting is not found
1647 \return setting value
1650 class TGetFontSettingEvent: public SALOME_Event
1653 typedef QFont TResult;
1658 TGetFontSettingEvent( const QString& section, const QString& name, const QFont& def )
1659 : mySection( section ), myName( name ), myDefault( def ) {}
1660 virtual void Execute()
1662 if ( SUIT_Session::session() ) {
1663 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1664 myResult = ( !mySection.isEmpty() && !myName.isEmpty() ) ? resMgr->fontValue( mySection, myName, myDefault ) : myDefault;
1668 QFont SalomePyQt::fontSetting ( const QString& section, const QString& name, const QFont& def )
1670 return ProcessEvent( new TGetFontSettingEvent( section, name, def ) );
1674 \brief Remove setting from the application preferences.
1675 \param section resources file section name
1676 \param name setting name
1678 void SalomePyQt::removeSetting( const QString& section, const QString& name )
1680 class TEvent: public SALOME_Event
1685 TEvent( const QString& section, const QString& name ) : mySection( section ), myName( name ) {}
1686 virtual void Execute()
1688 if ( SUIT_Session::session() ) {
1689 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1690 if ( !mySection.isEmpty() && !myName.isEmpty() )
1691 resMgr->remove( mySection, myName );
1695 ProcessVoidEvent( new TEvent( section, name ) );
1699 \fn bool SalomePyQt::hasSetting( const QString& section, const QString& name );
1700 \brief Check setting existence in the application preferences.
1701 \param section resources file section name
1702 \param name setting name
1703 \return \c true if setting exists
1706 class THasSettingEvent: public SALOME_Event
1709 typedef bool TResult;
1713 THasSettingEvent( const QString& section, const QString& name )
1714 : mySection( section ), myName( name ) {}
1715 virtual void Execute()
1717 if ( SUIT_Session::session() ) {
1718 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1719 myResult = resMgr->hasValue( mySection, myName );
1723 bool SalomePyQt::hasSetting( const QString& section, const QString& name )
1725 return ProcessEvent( new THasSettingEvent( section, name ) );
1729 \fn QStringList SalomePyQt::parameters( const QString& section );
1730 \brief Get names of preference items stored within the given section.
1731 \param section resources file section's name
1732 \return \c list of preferences items
1736 \fn QStringList SalomePyQt::parameters( const QStringList& section );
1737 \brief Get names of preference items stored within the given section.
1738 \param section resources file section's name
1739 \return \c list of preferences items
1742 class TParametersEvent: public SALOME_Event
1745 typedef QStringList TResult;
1747 QStringList mySection;
1748 TParametersEvent( const QString& section )
1750 mySection << section;
1752 TParametersEvent( const QStringList& section )
1753 : mySection( section )
1755 virtual void Execute()
1757 if ( SUIT_Session::session() ) {
1758 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1759 myResult = resMgr->parameters( mySection );
1763 QStringList SalomePyQt::parameters( const QString& section )
1765 return ProcessEvent( new TParametersEvent( section ) );
1767 QStringList SalomePyQt::parameters( const QStringList& section )
1769 return ProcessEvent( new TParametersEvent( section ) );
1773 \fn QString SalomePyQt::getFileName( QWidget* parent,
1774 const QString& initial,
1775 const QStringList& filters,
1776 const QString& caption,
1778 \brief Show 'Open/Save file' dialog box for file selection
1779 and return a user's choice (selected file name).
1780 \param parent parent widget
1781 \param initial initial directory the dialog box to be opened in
1782 \param filters list of files filters (wildcards)
1783 \param caption dialog box title
1784 \param open if \c true, "Open File" dialog box is shown;
1785 otherwise "Save File" dialog box is shown
1786 \return selected file name (null string if user cancels operation)
1789 class TGetFileNameEvent: public SALOME_Event
1792 typedef QString TResult;
1796 QStringList myFilters;
1799 TGetFileNameEvent( QWidget* parent,
1800 const QString& initial,
1801 const QStringList& filters,
1802 const QString& caption,
1804 : myParent ( parent ),
1805 myInitial( initial ),
1806 myFilters( filters ),
1807 myCaption( caption ),
1809 virtual void Execute()
1811 if ( LightApp_Application* anApp = getApplication() ) {
1812 myResult = anApp->getFileName( myOpen, myInitial, myFilters.join(";;"),
1813 myCaption, myParent );
1817 QString SalomePyQt::getFileName( QWidget* parent,
1818 const QString& initial,
1819 const QStringList& filters,
1820 const QString& caption,
1823 return ProcessEvent( new TGetFileNameEvent( parent, initial, filters, caption, open ) );
1827 \fn QStringList SalomePyQt::getOpenFileNames( QWidget* parent,
1828 const QString& initial,
1829 const QStringList& filters,
1830 const QString& caption );
1831 \brief Show 'Open files' dialog box for multiple files selection
1832 and return a user's choice (selected file names list).
1833 \param parent parent widget
1834 \param initial initial directory the dialog box to be opened in
1835 \param filters list of files filters (wildcards)
1836 \param caption dialog box title
1837 \return selected file names list (empty list if user cancels operation)
1840 class TGetOpenFileNamesEvent: public SALOME_Event
1843 typedef QStringList TResult;
1847 QStringList myFilters;
1849 TGetOpenFileNamesEvent( QWidget* parent,
1850 const QString& initial,
1851 const QStringList& filters,
1852 const QString& caption )
1853 : myParent ( parent ),
1854 myInitial( initial ),
1855 myFilters( filters ),
1856 myCaption( caption ) {}
1857 virtual void Execute()
1859 if ( LightApp_Application* anApp = getApplication() ) {
1860 myResult = anApp->getOpenFileNames( myInitial, myFilters.join(";;"), myCaption, myParent );
1864 QStringList SalomePyQt::getOpenFileNames( QWidget* parent,
1865 const QString& initial,
1866 const QStringList& filters,
1867 const QString& caption )
1869 return ProcessEvent( new TGetOpenFileNamesEvent( parent, initial, filters, caption ) );
1873 \fn QString SalomePyQt::getExistingDirectory( QWidget* parent,
1874 const QString& initial,
1875 const QString& caption );
1876 \brief Show 'Get Directory' dialog box for the directory selection
1877 and return a user's choice (selected directory name).
1878 \param parent parent widget
1879 \param initial initial directory the dialog box to be opened in
1880 \param caption dialog box title
1881 \return selected directory name (null string if user cancels operation)
1884 class TGetExistingDirectoryEvent: public SALOME_Event
1887 typedef QString TResult;
1892 TGetExistingDirectoryEvent( QWidget* parent,
1893 const QString& initial,
1894 const QString& caption )
1895 : myParent ( parent ),
1896 myInitial( initial ),
1897 myCaption( caption ) {}
1898 virtual void Execute()
1900 if ( LightApp_Application* anApp = getApplication() ) {
1901 myResult = anApp->getDirectory( myInitial, myCaption, myParent );
1905 QString SalomePyQt::getExistingDirectory( QWidget* parent,
1906 const QString& initial,
1907 const QString& caption )
1909 return ProcessEvent( new TGetExistingDirectoryEvent( parent, initial, caption ) );
1913 \fn QString SalomePyQt::loadIcon( const QString& filename );
1914 \brief Load an icon from the module resources by the specified file name.
1915 \param fileName icon file name
1919 class TLoadIconEvent: public SALOME_Event
1922 typedef QIcon TResult;
1926 TLoadIconEvent( const QString& module, const QString& filename )
1927 : myModule( module ),
1928 myFileName ( filename ) {}
1929 virtual void Execute()
1931 myResult = loadIconInternal( myModule, myFileName );
1934 QIcon SalomePyQt::loadIcon( const QString& module, const QString& filename )
1936 return ProcessEvent( new TLoadIconEvent( module, filename ) );
1940 \brief Open external browser to display context help information.
1943 Current implementation does nothing.
1945 \param source documentation (HTML) file name
1946 \param context context (for example, HTML ancor name)
1948 void SalomePyQt::helpContext( const QString& source, const QString& context )
1950 class TEvent: public SALOME_Event
1955 TEvent( const QString& source, const QString& context )
1956 : mySource( source ), myContext( context ) {}
1957 virtual void Execute()
1959 if ( LightApp_Application* anApp = getApplication() ) {
1960 anApp->onHelpContextModule( "", mySource, myContext );
1964 ProcessVoidEvent( new TEvent( source, context ) );
1968 \fn int SalomePyQt::defaultMenuGroup();
1969 \brief Get detault menu group identifier which can be used when
1970 creating menus (insert custom menu commands).
1971 \return default menu group ID
1974 class TDefMenuGroupEvent: public SALOME_Event
1977 typedef int TResult;
1979 TDefMenuGroupEvent() : myResult( -1 ) {}
1980 virtual void Execute()
1982 myResult = PyModuleHelper::defaultMenuGroup();
1985 int SalomePyQt::defaultMenuGroup()
1987 return ProcessEvent( new TDefMenuGroupEvent() );
1993 CrTool( const QString& tBar, const QString& nBar )
1994 : myCase( 0 ), myTbTitle( tBar ), myTbName( nBar) {}
1995 CrTool( const int id, const int tBar, const int idx )
1996 : myCase( 1 ), myId( id ), myTbId( tBar ), myIndex( idx ) {}
1997 CrTool( const int id, const QString& tBar, const int idx )
1998 : myCase( 2 ), myId( id ), myTbTitle( tBar ), myIndex( idx ) {}
1999 CrTool( QAction* action, const int tbId, const int id, const int idx )
2000 : myCase( 3 ), myAction( action ), myTbId( tbId ), myId( id ), myIndex( idx ) {}
2001 CrTool( QAction* action, const QString& tBar, const int id, const int idx )
2002 : myCase( 4 ), myAction( action ), myTbTitle( tBar ), myId( id ), myIndex( idx ) {}
2004 int execute( LightApp_Module* module ) const
2009 return module->createTool( myTbTitle, myTbName );
2011 return module->createTool( myId, myTbId, myIndex );
2013 return module->createTool( myId, myTbTitle, myIndex );
2015 return module->createTool( myAction, myTbId, myId, myIndex );
2017 return module->createTool( myAction, myTbTitle, myId, myIndex );
2032 class TCreateToolEvent: public SALOME_Event
2035 typedef int TResult;
2037 const CrTool& myCrTool;
2038 TCreateToolEvent( const CrTool& crTool )
2039 : myResult( -1 ), myCrTool( crTool ) {}
2040 virtual void Execute()
2042 LightApp_Module* module = getActiveModule();
2044 myResult = myCrTool.execute( module );
2049 \brief Create toolbar with specified name.
2050 \param tBar toolbar title (language-dependent)
2051 \param nBar toolbar name (language-independent) [optional]
2052 \return toolbar ID or -1 if toolbar creation is failed
2054 int SalomePyQt::createTool( const QString& tBar, const QString& nBar )
2056 return ProcessEvent( new TCreateToolEvent( CrTool( tBar, nBar ) ) );
2060 \brief Insert action with specified \a id to the toolbar.
2062 \param tBar toolbar ID
2063 \param idx required index in the toolbar
2064 \return action ID or -1 if action could not be added
2066 int SalomePyQt::createTool( const int id, const int tBar, const int idx )
2068 return ProcessEvent( new TCreateToolEvent( CrTool( id, tBar, idx ) ) );
2072 \brief Insert action with specified \a id to the toolbar.
2074 \param tBar toolbar name
2075 \param idx required index in the toolbar
2076 \return action ID or -1 if action could not be added
2078 int SalomePyQt::createTool( const int id, const QString& tBar, const int idx )
2080 return ProcessEvent( new TCreateToolEvent( CrTool( id, tBar, idx ) ) );
2084 \brief Insert action to the toolbar.
2086 \param tBar toolbar ID
2087 \param id required action ID
2088 \param idx required index in the toolbar
2089 \return action ID or -1 if action could not be added
2091 int SalomePyQt::createTool( QAction* a, const int tBar, const int id, const int idx )
2093 return ProcessEvent( new TCreateToolEvent( CrTool( a, tBar, id, idx ) ) );
2097 \brief Insert action to the toolbar.
2099 \param tBar toolbar name
2100 \param id required action ID
2101 \param idx required index in the toolbar
2102 \return action ID or -1 if action could not be added
2104 int SalomePyQt::createTool( QAction* a, const QString& tBar, const int id, const int idx )
2106 return ProcessEvent( new TCreateToolEvent( CrTool( a, tBar, id, idx ) ) );
2112 CrMenu( const QString& subMenu, const int menu, const int id, const int group, const int idx )
2113 : myCase( 0 ), mySubMenuName( subMenu ), myMenuId( menu ), myId( id ), myGroup( group ), myIndex( idx ) {}
2114 CrMenu( const QString& subMenu, const QString& menu, const int id, const int group, const int idx )
2115 : myCase( 1 ), mySubMenuName( subMenu ), myMenuName( menu ), myId( id ), myGroup( group ), myIndex( idx ) {}
2116 CrMenu( const int id, const int menu, const int group, const int idx )
2117 : myCase( 2 ), myId( id ), myMenuId( menu ), myGroup( group ), myIndex( idx ) {}
2118 CrMenu( const int id, const QString& menu, const int group, const int idx )
2119 : myCase( 3 ), myId( id ), myMenuName( menu ), myGroup( group ), myIndex( idx ) {}
2120 CrMenu( QAction* action, const int menu, const int id, const int group, const int idx )
2121 : myCase( 4 ), myAction( action ), myMenuId( menu ), myId( id ), myGroup( group ), myIndex( idx ) {}
2122 CrMenu( QAction* action, const QString& menu, const int id, const int group, const int idx )
2123 : myCase( 5 ), myAction( action ), myMenuName( menu ), myId( id ), myGroup( group ), myIndex( idx ) {}
2125 int execute( LightApp_Module* module ) const
2130 return module->createMenu( mySubMenuName, myMenuId, myId, myGroup, myIndex );
2132 return module->createMenu( mySubMenuName, myMenuName, myId, myGroup, myIndex );
2134 return module->createMenu( myId, myMenuId, myGroup, myIndex );
2136 return module->createMenu( myId, myMenuName, myGroup, myIndex );
2138 return module->createMenu( myAction, myMenuId, myId, myGroup, myIndex );
2140 return module->createMenu( myAction, myMenuName, myId, myGroup, myIndex );
2149 QString mySubMenuName;
2156 class TCreateMenuEvent: public SALOME_Event
2159 typedef int TResult;
2161 const CrMenu& myCrMenu;
2162 TCreateMenuEvent( const CrMenu& crMenu )
2163 : myResult( -1 ), myCrMenu( crMenu ) {}
2164 virtual void Execute()
2166 LightApp_Module* module = getActiveModule();
2168 myResult = myCrMenu.execute( module );
2173 \brief Create main menu.
2174 \param subMenu menu name
2175 \param menu parent menu ID
2176 \param id required menu ID
2177 \param group menu group ID
2178 \param idx required index in the menu
2179 \return menu ID or -1 if menu could not be added
2181 int SalomePyQt::createMenu( const QString& subMenu, const int menu, const int id, const int group, const int idx )
2183 return ProcessEvent( new TCreateMenuEvent( CrMenu( subMenu, menu, id, group, idx ) ) );
2187 \brief Create main menu.
2188 \param subMenu menu name
2189 \param menu parent menu name (list of menu names separated by "|")
2190 \param id required menu ID
2191 \param group menu group ID
2192 \param idx required index in the menu
2193 \return menu ID or -1 if menu could not be added
2195 int SalomePyQt::createMenu( const QString& subMenu, const QString& menu, const int id, const int group, const int idx )
2197 return ProcessEvent( new TCreateMenuEvent( CrMenu( subMenu, menu, id, group, idx ) ) );
2201 \brief Insert action to the main menu.
2203 \param menu parent menu ID
2204 \param group menu group ID
2205 \param idx required index in the menu
2206 \return action ID or -1 if action could not be added
2208 int SalomePyQt::createMenu( const int id, const int menu, const int group, const int idx )
2210 return ProcessEvent( new TCreateMenuEvent( CrMenu( id, menu, group, idx ) ) );
2214 \brief Insert action to the main menu.
2216 \param menu parent menu name (list of menu names separated by "|")
2217 \param group menu group ID
2218 \param idx required index in the menu
2219 \return action ID or -1 if action could not be added
2221 int SalomePyQt::createMenu( const int id, const QString& menu, const int group, const int idx )
2223 return ProcessEvent( new TCreateMenuEvent( CrMenu( id, menu, group, idx ) ) );
2227 \brief Insert action to the main menu.
2229 \param menu parent menu ID
2230 \param group menu group ID
2231 \param idx required index in the menu
2232 \return action ID or -1 if action could not be added
2234 int SalomePyQt::createMenu( QAction* a, const int menu, const int id, const int group, const int idx )
2236 return ProcessEvent( new TCreateMenuEvent( CrMenu( a, menu, id, group, idx ) ) );
2240 \brief Insert action to the main menu.
2242 \param menu parent menu name (list of menu names separated by "|")
2243 \param group menu group ID
2244 \param idx required index in the menu
2245 \return action ID or -1 if action could not be added
2247 int SalomePyQt::createMenu( QAction* a, const QString& menu, const int id, const int group, const int idx )
2249 return ProcessEvent( new TCreateMenuEvent( CrMenu( a, menu, id, group, idx ) ) );
2253 \fn QAction* SalomePyQt::createSeparator();
2254 \brief Create separator action which can be used in the menu or toolbar.
2255 \return new separator action
2258 class TCreateSepEvent: public SALOME_Event
2261 typedef QAction* TResult;
2265 virtual void Execute()
2267 LightApp_Module* module = getActiveModule();
2269 myResult = (QAction*)module->separator();
2272 QAction* SalomePyQt::createSeparator()
2274 return ProcessEvent( new TCreateSepEvent() );
2278 \fn QAction* SalomePyQt::createAction( const int id,
2279 const QString& menuText,
2280 const QString& tipText,
2281 const QString& statusText,
2282 const QString& icon,
2284 const bool toggle );
2285 \brief Create an action which can be then used in the menu or toolbar.
2286 \param id the unique id action to be registered to
2287 \param menuText action text which should appear in menu
2288 \param tipText text which should appear in the tooltip
2289 \param statusText text which should appear in the status bar when action is activated
2290 \param icon the name of the icon file (the actual icon file name can be coded in the translation files)
2291 \param key the key accelrator for the action
2292 \param toggle if \c true the action is checkable
2295 class TCreateActionEvent: public SALOME_Event
2298 typedef QAction* TResult;
2303 QString myStatusText;
2307 TCreateActionEvent( const int id, const QString& menuText, const QString& tipText,
2308 const QString& statusText, const QString& icon, const int key, const bool toggle )
2309 : myResult( 0 ), myId( id ), myMenuText( menuText ), myTipText( tipText ),
2310 myStatusText( statusText ), myIcon( icon ), myKey( key ), myToggle( toggle ) {}
2311 virtual void Execute()
2313 LightApp_Module* module = getActiveModule();
2315 QIcon icon = loadIconInternal( module->name(), myIcon );
2316 myResult = (QAction*)module->action( myId );
2318 if ( myResult->toolTip().isEmpty() && !myTipText.isEmpty() )
2319 myResult->setToolTip( myTipText );
2320 if ( myResult->text().isEmpty() && !myMenuText.isEmpty() )
2321 myResult->setText( myMenuText );
2322 if ( myResult->icon().isNull() && !icon.isNull() )
2323 myResult->setIcon( icon );
2324 if ( myResult->statusTip().isEmpty() && !myStatusText.isEmpty() )
2325 myResult->setStatusTip( myStatusText );
2326 if ( myResult->shortcut().isEmpty() && myKey )
2327 myResult->setShortcut( myKey );
2328 if ( myResult->isCheckable() != myToggle )
2329 myResult->setCheckable( myToggle );
2332 myResult = (QAction*)module->createAction( myId, myTipText, icon, myMenuText, myStatusText, myKey, module, myToggle );
2334 // for Python module, automatically connect action to callback slot
2335 PyModuleHelper* helper = module->findChild<PyModuleHelper*>( "python_module_helper" );
2336 if ( helper ) helper->connectAction( myResult );
2340 QAction* SalomePyQt::createAction( const int id, const QString& menuText,
2341 const QString& tipText, const QString& statusText,
2342 const QString& icon, const int key, const bool toggle )
2344 return ProcessEvent( new TCreateActionEvent( id, menuText, tipText, statusText, icon, key, toggle ) );
2348 \fn QtxActionGroup* SalomePyQt::createActionGroup( const int id, const bool exclusive );
2349 \brief Create an action group which can be then used in the menu or toolbar
2350 \param id : the unique id action group to be registered to
2351 \param exclusive : if \c true the action group does exclusive toggling
2354 struct TCreateActionGroupEvent: public SALOME_Event
2356 typedef QtxActionGroup* TResult;
2360 TCreateActionGroupEvent( const int id, const bool exclusive )
2361 : myId( id ), myExclusive( exclusive ) {}
2362 virtual void Execute()
2364 LightApp_Module* module = getActiveModule();
2366 myResult = module->createActionGroup( myId, myExclusive );
2369 QtxActionGroup* SalomePyQt::createActionGroup( const int id, const bool exclusive )
2371 return ProcessEvent( new TCreateActionGroupEvent( id, exclusive ) );
2375 \fn QAction* SalomePyQt::action( const int id );
2376 \brief Get action by specified identifier.
2377 \return action or 0 if action is not registered
2380 class TActionEvent: public SALOME_Event
2383 typedef QAction* TResult;
2386 TActionEvent( const int id )
2387 : myResult( 0 ), myId( id ) {}
2388 virtual void Execute()
2390 LightApp_Module* module = getActiveModule();
2392 myResult = (QAction*)module->action( myId );
2395 QAction* SalomePyQt::action( const int id )
2397 return ProcessEvent( new TActionEvent( id ) );
2401 \fn int SalomePyQt::actionId( const QAction* a );
2402 \brief Get an action identifier.
2403 \return action ID or -1 if action is not registered
2406 class TActionIdEvent: public SALOME_Event
2409 typedef int TResult;
2411 const QAction* myAction;
2412 TActionIdEvent( const QAction* action )
2413 : myResult( -1 ), myAction( action ) {}
2414 virtual void Execute()
2416 LightApp_Module* module = getActiveModule();
2418 myResult = module->actionId( myAction );
2421 int SalomePyQt::actionId( const QAction* a )
2423 return ProcessEvent( new TActionIdEvent( a ) );
2427 \fn int SalomePyQt::addGlobalPreference( const QString& label );
2428 \brief Add global (not module-related) preferences group.
2429 \param label global preferences group name
2430 \return preferences group identifier
2433 class TAddGlobalPrefEvent: public SALOME_Event
2436 typedef int TResult;
2439 TAddGlobalPrefEvent( const QString& label )
2440 : myResult( -1 ), myLabel( label ) {}
2441 virtual void Execute()
2443 LightApp_Module* module = getActiveModule();
2445 LightApp_Preferences* pref = module->getApp()->preferences();
2447 myResult = pref->addPreference( myLabel, -1 );
2451 int SalomePyQt::addGlobalPreference( const QString& label )
2453 return ProcessEvent( new TAddGlobalPrefEvent( label ) );
2457 \fn int SalomePyQt::addPreference( const QString& label );
2458 \brief Add module-related preferences group.
2459 \param label preferences group name
2460 \return preferences group identifier
2463 class TAddPrefEvent: public SALOME_Event
2466 typedef int TResult;
2469 TAddPrefEvent( const QString& label )
2470 : myResult( -1 ), myLabel( label ) {}
2471 virtual void Execute()
2473 LightApp_Module* module = getActiveModule();
2475 LightApp_Preferences* pref = module->getApp()->preferences();
2477 int cId = pref->addPreference( module->moduleName(), -1 );
2479 myResult = pref->addPreference( myLabel, cId );
2484 int SalomePyQt::addPreference( const QString& label )
2486 return ProcessEvent( new TAddPrefEvent( label ) );
2490 \fn int SalomePyQt::addPreference( const QString& label, const int pId, const int type,
2491 const QString& section, const QString& param );
2492 \brief Add module-related preferences.
2493 \param label preferences group name
2494 \param pId parent preferences group id
2495 \param type preferences type
2496 \param section resources file section name
2497 \param param resources file setting name
2498 \return preferences identifier
2501 class TAddPrefParamEvent: public SALOME_Event
2504 typedef int TResult;
2511 TAddPrefParamEvent( const QString& label,
2512 const int pId, const int type,
2513 const QString& section,
2514 const QString& param )
2516 myLabel( label ), myPId( pId ), myType( type ),
2517 mySection( section ), myParam ( param ) {}
2518 virtual void Execute()
2520 LightApp_Module* module = getActiveModule();
2522 LightApp_Preferences* pref = module->getApp()->preferences();
2524 myResult = pref->addPreference( module->moduleName(), myLabel, myPId, myType, mySection, myParam );
2528 int SalomePyQt::addPreference( const QString& label, const int pId, const int type,
2529 const QString& section, const QString& param )
2531 return ProcessEvent( new TAddPrefParamEvent( label, pId, type, section, param ) );
2535 \fn QVariant SalomePyQt::preferenceProperty( const int id, const QString& prop );
2536 \brief Get the preferences property.
2537 \param id preferences identifier
2538 \param prop preferences property name
2539 \return preferences property value or null QVariant if property is not set
2542 class TPrefPropEvent: public SALOME_Event
2545 typedef QVariant TResult;
2549 TPrefPropEvent( const int id, const QString& prop )
2550 : myId( id ), myProp( prop ) {}
2551 virtual void Execute()
2553 LightApp_Module* module = getActiveModule();
2555 LightApp_Preferences* pref = module->getApp()->preferences();
2557 myResult = pref->itemProperty( myProp, myId );
2561 QVariant SalomePyQt::preferenceProperty( const int id, const QString& prop )
2563 return ProcessEvent( new TPrefPropEvent( id, prop ) );
2567 \brief Set the preferences property.
2568 \param id preferences identifier
2569 \param prop preferences property name
2570 \param var preferences property value
2572 void SalomePyQt::setPreferenceProperty( const int id,
2573 const QString& prop,
2574 const QVariant& var )
2576 class TEvent: public SALOME_Event
2582 TEvent( const int id, const QString& prop, const QVariant& var )
2583 : myId( id ), myProp( prop ), myVar( var ) {}
2584 virtual void Execute()
2586 LightApp_Module* module = getActiveModule();
2588 LightApp_Preferences* pref = module->getApp()->preferences();
2590 pref->setItemProperty( myProp, myVar, myId );
2594 ProcessVoidEvent( new TEvent( id, prop, var ) );
2598 \brief Set specific widget as a custom preferences item.
2599 \param id preferences identifier
2600 \param prop preferences property name
2601 \param widget custom widget
2603 void SalomePyQt::setPreferencePropertyWg( const int id,
2604 const QString& prop,
2605 UserDefinedContent* widget )
2607 class TEvent: public SALOME_Event
2611 UserDefinedContent* myWidget;
2613 TEvent( const int id, const QString& prop, UserDefinedContent* widget )
2614 : myId( id ), myProp( prop ), myWidget( widget ) {}
2615 virtual void Execute()
2617 LightApp_Module* module = getActiveModule();
2619 LightApp_Preferences* pref = module->getApp()->preferences();
2621 pref->setItemProperty( myProp, (qint64) new SgPyQtUserDefinedContent( myWidget ), myId );
2626 ProcessVoidEvent( new TEvent( id, prop, widget ) );
2630 \brief Add the property value to the list of values.
2632 This method allows creating properties which are QList<QVariant>
2633 - there is no way to pass such values directly to QVariant parameter with PyQt.
2635 \param id preferences identifier
2636 \param prop preferences property name
2637 \param idx preferences property index
2638 \param var preferences property value for the index \a idx
2640 void SalomePyQt::addPreferenceProperty( const int id,
2641 const QString& prop,
2643 const QVariant& var )
2645 class TEvent: public SALOME_Event
2652 TEvent( const int id, const QString& prop, const int idx, const QVariant& var )
2653 : myId( id ), myProp( prop ), myIdx( idx), myVar( var ) {}
2654 virtual void Execute()
2656 LightApp_Module* module = getActiveModule();
2658 LightApp_Preferences* pref = module->getApp()->preferences();
2660 QVariant var = pref->itemProperty( myProp, myId );
2661 if ( var.isValid() ) {
2662 if ( var.type() == QVariant::StringList ) {
2663 QStringList sl = var.toStringList();
2664 if ( myIdx >= 0 && myIdx < sl.count() )
2665 sl[myIdx] = myVar.toString();
2667 sl.append( myVar.toString() );
2668 pref->setItemProperty( myProp, sl, myId );
2670 else if ( var.type() == QVariant::List ) {
2671 QList<QVariant> vl = var.toList();
2672 if ( myIdx >= 0 && myIdx < vl.count() )
2676 pref->setItemProperty( myProp, vl, myId );
2682 pref->setItemProperty( myProp, vl, myId );
2688 ProcessVoidEvent( new TEvent( id, prop, idx, var) );
2692 \brief Put the message to the Log messages output window
2693 \param msg message text (it can be of simple rich text format)
2694 \param addSeparator boolean flag which specifies if it is necessary
2695 to separate the message with predefined separator
2697 void SalomePyQt::message( const QString& msg, bool addSeparator )
2699 class TEvent: public SALOME_Event
2704 TEvent( const QString& msg, bool addSeparator )
2705 : myMsg( msg ), myAddSep( addSeparator ) {}
2706 virtual void Execute()
2708 if ( LightApp_Application* anApp = getApplication() ) {
2709 LogWindow* lw = anApp->logWindow();
2711 lw->putMessage( myMsg, myAddSep );
2715 ProcessVoidEvent( new TEvent( msg, addSeparator ) );
2719 \brief Remove all the messages from the Log messages output window.
2721 void SalomePyQt::clearMessages()
2723 class TEvent: public SALOME_Event
2727 virtual void Execute()
2729 if ( LightApp_Application* anApp = getApplication() ) {
2730 LogWindow* lw = anApp->logWindow();
2736 ProcessVoidEvent( new TEvent() );
2740 \fn bool SalomePyQt::dumpView( const QString& filename, const int id = 0 );
2741 \brief Dump the contents of the id view window. If id is 0 then current active view is processed.
2742 to the image file in the specified format.
2744 For the current moment JPEG, PNG and BMP images formats are supported.
2745 The image format is defined automatically by the file name extension.
2746 By default, BMP format is used.
2748 \param filename image file name
2749 \return operation status (\c true on success)
2752 class TDumpViewEvent: public SALOME_Event
2755 typedef bool TResult;
2759 TDumpViewEvent( const QString& filename, const int id )
2760 : myResult ( false ), myFileName( filename ), myWndId( id ) {}
2761 virtual void Execute()
2763 SUIT_ViewWindow* wnd = 0;
2765 if ( LightApp_Application* anApp = getApplication() ) {
2766 SUIT_ViewManager* vm = anApp->activeViewManager();
2768 wnd = vm->getActiveView();
2770 myWndId = wnd->getId();
2773 wnd = dynamic_cast<SUIT_ViewWindow*>( getWnd( myWndId ) );
2776 QString fmt = SUIT_Tools::extension( myFileName ).toUpper();
2777 #ifndef DISABLE_PLOT2DVIEWER
2778 Plot2d_ViewWindow* wnd2D = dynamic_cast<Plot2d_ViewWindow*>( wnd );
2780 qApp->postEvent( wnd2D->getViewFrame(), new QPaintEvent( QRect( 0, 0, wnd2D->getViewFrame()->width(), wnd2D->getViewFrame()->height() ) ) );
2781 qApp->postEvent( wnd2D, new QPaintEvent( QRect( 0, 0, wnd2D->width(), wnd2D->height() ) ) );
2782 qApp->processEvents();
2783 if ( fmt == "PS" || fmt == "EPS" || fmt == "PDF" ) {
2784 myResult = wnd2D->getViewFrame()->print( myFileName, fmt );
2788 #endif // DISABLE_PLOT2DVIEWER
2789 QImage im = wnd->dumpView();
2790 if ( !im.isNull() && !myFileName.isEmpty() ) {
2791 if ( fmt.isEmpty() ) fmt = QString( "BMP" ); // default format
2792 if ( fmt == "JPG" ) fmt = "JPEG";
2793 myResult = im.save( myFileName, fmt.toLatin1() );
2798 bool SalomePyQt::dumpView( const QString& filename, const int id )
2800 return ProcessEvent( new TDumpViewEvent( filename, id ) );
2804 \fn QList<int> SalomePyQt::getViews();
2805 \brief Get list of integer identifiers of all the currently opened views
2806 \return list of integer identifiers of all the currently opened views
2809 class TGetViews: public SALOME_Event
2812 typedef QList<int> TResult;
2815 virtual void Execute()
2818 LightApp_Application* app = getApplication();
2820 STD_TabDesktop* tabDesk = dynamic_cast<STD_TabDesktop*>( app->desktop() );
2822 QList<SUIT_ViewWindow*> wndlist = tabDesk->windows();
2823 SUIT_ViewWindow* wnd;
2824 foreach ( wnd, wndlist )
2825 myResult.append( wnd->getId() );
2830 QList<int> SalomePyQt::getViews()
2832 return ProcessEvent( new TGetViews() );
2836 \fn int SalomePyQt::getActiveView();
2837 \brief Get integer identifier of the currently active view
2838 \return integer identifier of the currently active view
2841 class TGetActiveView: public SALOME_Event
2844 typedef int TResult;
2848 virtual void Execute()
2850 LightApp_Application* app = getApplication();
2852 SUIT_ViewManager* viewMgr = app->activeViewManager();
2854 SUIT_ViewWindow* wnd = viewMgr->getActiveView();
2856 myResult = wnd->getId();
2861 int SalomePyQt::getActiveView()
2863 return ProcessEvent( new TGetActiveView() );
2867 \fn QString SalomePyQt::getViewType( const int id );
2868 \brief Get type of the specified view, e.g. "OCCViewer"
2869 \param id window identifier
2873 class TGetViewType: public SALOME_Event
2876 typedef QString TResult;
2879 TGetViewType( const int id )
2881 virtual void Execute()
2883 SUIT_ViewWindow* wnd = getWnd( myWndId );
2885 SUIT_ViewManager* viewMgr = wnd->getViewManager();
2887 myResult = viewMgr->getType();
2891 QString SalomePyQt::getViewType( const int id )
2893 return ProcessEvent( new TGetViewType( id ) );
2897 \fn bool SalomePyQt::setViewTitle( const int id, const QString& title );
2898 \brief Change view caption
2899 \param id window identifier
2900 \param title new window title
2901 \return \c true if operation is completed successfully and \c false otherwise
2904 class TSetViewTitle: public SALOME_Event
2907 typedef bool TResult;
2911 TSetViewTitle( const int id, const QString& title )
2912 : myResult( false ),
2915 virtual void Execute()
2917 SUIT_ViewWindow* wnd = getWnd( myWndId );
2919 wnd->setWindowTitle( myTitle );
2924 bool SalomePyQt::setViewTitle( const int id, const QString& title )
2926 return ProcessEvent( new TSetViewTitle( id, title ) );
2930 \fn bool SalomePyQt::setViewSize( const int w, const int h, const int id );
2931 \brief Set view size
2932 \param w window width
2933 \param h window height
2934 \param id window identifier
2935 \return \c true if operation is completed successfully and \c false otherwise
2938 class TSetViewSize: public SALOME_Event
2941 typedef bool TResult;
2946 TSetViewSize( const int w, const int h, const int id )
2947 : myResult( false ),
2951 virtual void Execute()
2953 SUIT_ViewWindow* wnd = 0;
2955 if ( LightApp_Application* anApp = getApplication() ) {
2956 SUIT_ViewManager* vm = anApp->activeViewManager();
2958 wnd = vm->getActiveView();
2962 wnd = dynamic_cast<SUIT_ViewWindow*>( getWnd( myWndId ) );
2965 SUIT_ViewManager* viewMgr = wnd->getViewManager();
2967 QString type = viewMgr->getType();
2968 if ( type == "OCCViewer") {
2969 #ifndef DISABLE_OCCVIEWER
2970 // specific processing for OCC viewer:
2971 // OCC view can embed up to 4 sub-views, split according to the specified layout;
2972 // - if there is only one sub-view active; it will be resized;
2973 // - if there are several sub-views, each of them will be resized.
2974 OCCViewer_ViewWindow* occView = qobject_cast<OCCViewer_ViewWindow*>( wnd );
2975 for ( int i = OCCViewer_ViewFrame::BOTTOM_RIGHT; i <= OCCViewer_ViewFrame::TOP_RIGHT; i++ ) {
2976 if ( occView && occView->getView( i ) ) {
2977 occView->getView( i )->centralWidget()->resize( myWndWidth, myWndHeight );
2981 #endif // DISABLE_OCCVIEWER
2983 else if ( type == "ParaView") {
2984 #ifndef DISABLE_PVVIEWER
2985 // specific processing for ParaView viewer:
2986 // hierarchy of ParaView viewer is much complex than for usual view;
2987 // we look for sub-widget named "Viewport"
2988 QList<QWidget*> lst = wnd->findChildren<QWidget*>( "Viewport" );
2989 if ( !lst.isEmpty() ) {
2990 lst[0]->resize( myWndWidth, myWndHeight );
2993 #endif // DISABLE_PVVIEWER
2996 if ( wnd->centralWidget() ) {
2997 wnd->centralWidget()->resize( myWndWidth, myWndHeight );
3005 bool SalomePyQt::setViewSize( const int w, const int h, const int id )
3007 return ProcessEvent( new TSetViewSize( w, h, id ) );
3011 \fn bool SalomePyQt::setViewRotationPoint( const double x, const double y, const double z, const int id );
3012 \brief Set view rotation point
3013 \param x coordinate X view rotation point
3014 \param y coordinate Y view rotation point
3015 \param z coordinate Z view rotation point
3016 \param id window identifier
3017 \return \c true if operation is completed successfully and \c false otherwise
3020 class TSetViewRotationPoint: public SALOME_Event
3023 typedef bool TResult;
3029 TSetViewRotationPoint( const double x, const double y, const double z, const int id )
3030 : myResult( false ),
3035 virtual void Execute()
3037 SUIT_ViewWindow* wnd = 0;
3039 if ( LightApp_Application* anApp = getApplication() ) {
3040 SUIT_ViewManager* vm = anApp->activeViewManager();
3042 wnd = vm->getActiveView();
3046 wnd = dynamic_cast<SUIT_ViewWindow*>( getWnd( myWndId ) );
3049 SUIT_ViewManager* viewMgr = wnd->getViewManager();
3051 QString type = viewMgr->getType();
3052 if ( type == "OCCViewer") {
3053 #ifndef DISABLE_OCCVIEWER
3054 // specific processing for OCC viewer:
3055 // OCC view can embed up to 4 sub-views, split according to the specified layout;
3056 // - if there is only one sub-view active; its rotation point will be changed;
3057 // - if there are several sub-views, rotaion points of each of them will be changed.
3058 OCCViewer_ViewWindow* occView = qobject_cast<OCCViewer_ViewWindow*>( wnd );
3060 for ( int i = OCCViewer_ViewFrame::BOTTOM_RIGHT; i <= OCCViewer_ViewFrame::TOP_RIGHT; i++ ) {
3061 if ( occView && occView->getView( i ) ) {
3062 occView->getView( i )->activateSetRotationSelected( myX, myY, myZ );
3067 #endif // DISABLE_OCCVIEWER
3069 else if ( type == "VTKViewer") {
3070 #ifndef DISABLE_VTKVIEWER
3071 SVTK_ViewWindow* vtkView = qobject_cast<SVTK_ViewWindow*>( wnd );
3074 double aCenter[3] = { myX, myY, myZ };
3075 vtkView->activateSetRotationSelected( (void*)aCenter );
3078 #endif // DISABLE_VTKVIEWER
3084 bool SalomePyQt::setViewRotationPoint( const double x, const double y, const double z, const int id )
3086 return ProcessEvent( new TSetViewRotationPoint( x, y, z, id ) );
3090 \fn QString SalomePyQt::getViewTitle( const int id );
3091 \brief Get view caption
3092 \param id window identifier
3093 \return view caption
3096 class TGetViewTitle: public SALOME_Event
3099 typedef QString TResult;
3102 TGetViewTitle( const int id )
3104 virtual void Execute()
3106 SUIT_ViewWindow* wnd = getWnd( myWndId );
3108 myResult = wnd->windowTitle();
3111 QString SalomePyQt::getViewTitle( const int id )
3113 return ProcessEvent( new TGetViewTitle( id ) );
3117 \fn QList<int> SalomePyQt::findViews( const QString& type );
3118 \brief Get list of integer identifiers of all the
3119 currently opened views of the specified type
3120 \param type viewer type
3121 \return list of integer identifiers
3124 class TFindViews: public SALOME_Event
3127 typedef QList<int> TResult;
3130 TFindViews( const QString& type )
3132 virtual void Execute()
3135 LightApp_Application* app = getApplication();
3137 ViewManagerList vmList;
3138 app->viewManagers( myType, vmList );
3139 SUIT_ViewManager* viewMgr;
3140 foreach ( viewMgr, vmList ) {
3141 QVector<SUIT_ViewWindow*> vec = viewMgr->getViews();
3142 for ( int i = 0, n = vec.size(); i < n; i++ ) {
3143 SUIT_ViewWindow* wnd = vec[ i ];
3146 MESSAGE("SUIT_ViewWindow*: "<< wnd << " id: " << wnd->getId());
3147 myResult.append( wnd->getId() );
3154 QList<int> SalomePyQt::findViews( const QString& type )
3156 return ProcessEvent( new TFindViews( type ) );
3160 \fn bool SalomePyQt::activateView( const int id );
3161 \brief Activate view
3162 \param id window identifier
3163 \return \c true if operation is completed successfully and \c false otherwise
3166 class TActivateView: public SALOME_Event
3169 typedef bool TResult;
3172 TActivateView( const int id )
3173 : myResult( false ),
3175 virtual void Execute()
3177 SUIT_ViewWindow* wnd = getWnd( myWndId );
3178 MESSAGE("window id:" << myWndId << " SUIT_ViewWindow*: " << wnd);
3185 bool SalomePyQt::activateView( const int id )
3187 return ProcessEvent( new TActivateView( id ) );
3191 \fn bool SalomePyQt::activateManagerAndView( const int id );
3192 \brief Activate view manager and view: useful for a view embedded in a module main Window
3193 \param id window identifier
3194 \return \c true if operation is completed successfully and \c false otherwise
3197 class TActivateViewManagerAndView: public SALOME_Event
3200 typedef bool TResult;
3203 TActivateViewManagerAndView( const int id )
3204 : myResult( false ),
3206 virtual void Execute()
3208 SUIT_ViewWindow* wnd = getWnd( myWndId );
3209 MESSAGE("window id:" << myWndId << " SUIT_ViewWindow*: " << wnd);
3212 LightApp_Application* app = getApplication();
3213 app->desktop()->windowActivated(wnd); // equivalent to app->setActiveViewManager(wnd->getViewManager())
3219 bool SalomePyQt::activateViewManagerAndView( const int id )
3221 return ProcessEvent( new TActivateViewManagerAndView( id ) );
3228 class TGetViewWidget: public SALOME_Event
3231 typedef QWidget* TResult;
3234 TGetViewWidget( const int id )
3237 virtual void Execute()
3239 SUIT_ViewWindow* wnd = getWnd( myWndId );
3241 myResult = (QWidget*)wnd;
3245 QWidget* SalomePyQt::getViewWidget( const int id)
3247 return ProcessEvent( new TGetViewWidget( id ) );
3252 \fn int SalomePyQt::createView( const QString& type, bool visible = true, const int width = 0, const int height = 0 );
3253 \brief Create new view and activate it
3254 \param type viewer type
3258 \return integer identifier of created view (or -1 if view could not be created)
3261 class TCreateView: public SALOME_Event
3264 typedef int TResult;
3271 TCreateView( const QString& theType, bool visible, const int width, const int height, bool detached )
3277 myDetached(detached) {}
3278 virtual void Execute()
3280 LightApp_Application* app = getApplication();
3282 SUIT_ViewManager* viewMgr = app->createViewManager( myType, myDetached );
3284 QWidget* wnd = viewMgr->getActiveView();
3285 myResult = viewMgr->getActiveView()->getId();
3288 wnd->setVisible(false);
3289 if ( !myVisible && myWidth == 0 && myHeight == 0 ) {
3293 if (myWidth > 0 && myHeight > 0) {
3294 #ifndef DISABLE_PLOT2DVIEWER
3295 Plot2d_ViewWindow* wnd2D = dynamic_cast<Plot2d_ViewWindow*>( wnd );
3296 if ( wnd2D ) wnd = wnd2D->getViewFrame();
3297 #endif // DISABLE_PLOT2DVIEWER
3298 wnd->setGeometry( 0, 0, myWidth, myHeight );
3305 int SalomePyQt::createView( const QString& type, bool visible, const int width, const int height, bool detached )
3307 int ret = ProcessEvent( new TCreateView( type, visible, width, height, detached ) );
3308 QCoreApplication::processEvents();
3313 \fn int SalomePyQt::createView( const QString& type, QWidget* w );
3314 \brief Create new view with custom widget embedded and activate it
3315 \param type viewer type
3316 \param w custom widget
3317 \return integer identifier of created view (or -1 if view could not be created)
3320 class TCreateViewWg: public SALOME_Event
3323 typedef int TResult;
3327 TCreateViewWg( const QString& theType, QWidget* w )
3331 virtual void Execute()
3333 LightApp_Application* app = getApplication();
3335 SUIT_ViewManager* viewMgr = app->createViewManager( myType, myWidget );
3337 SUIT_ViewWindow* wnd = viewMgr->getActiveView();
3339 myResult = wnd->getId();
3344 int SalomePyQt::createView( const QString& type, QWidget* w )
3346 int ret = ProcessEvent( new TCreateViewWg( type, w ) );
3347 QCoreApplication::processEvents();
3352 \fn bool SalomePyQt::closeView( const int id );
3354 \param id window identifier
3355 \return \c true if operation is completed successfully and \c false otherwise
3358 class TCloseView: public SALOME_Event
3361 typedef bool TResult;
3364 TCloseView( const int id )
3365 : myResult( false ),
3367 virtual void Execute()
3369 SUIT_ViewWindow* wnd = getWnd( myWndId );
3371 SUIT_ViewManager* viewMgr = wnd->getViewManager();
3379 bool SalomePyQt::closeView( const int id )
3381 return ProcessEvent( new TCloseView( id ) );
3385 \fn int SalomePyQt::cloneView( const int id );
3386 \brief Clone view (if this operation is supported for specified view type)
3387 \param id window identifier
3388 \return integer identifier of the cloned view or -1 or operation could not be performed
3391 class TCloneView: public SALOME_Event
3394 typedef int TResult;
3397 TCloneView( const int id )
3400 virtual void Execute()
3402 SUIT_ViewWindow* wnd = getWnd( myWndId );
3404 SUIT_ViewManager* viewMgr = wnd->getViewManager();
3406 #ifndef DISABLE_OCCVIEWER
3407 if ( wnd->inherits( "OCCViewer_ViewWindow" ) ) {
3408 OCCViewer_ViewWindow* occView = (OCCViewer_ViewWindow*)( wnd );
3409 occView->onCloneView();
3410 wnd = viewMgr->getActiveView();
3412 myResult = wnd->getId();
3414 #endif // DISABLE_OCCVIEWER
3415 #ifndef DISABLE_PLOT2DVIEWER
3416 if ( wnd->inherits( "Plot2d_ViewWindow" ) ) {
3417 Plot2d_ViewManager* viewMgr2d = dynamic_cast<Plot2d_ViewManager*>( viewMgr );
3418 Plot2d_ViewWindow* srcWnd2d = dynamic_cast<Plot2d_ViewWindow*>( wnd );
3419 if ( viewMgr2d && srcWnd2d ) {
3420 Plot2d_ViewWindow* resWnd = viewMgr2d->cloneView( srcWnd2d );
3421 myResult = resWnd->getId();
3424 #endif // DISABLE_OCCVIEWER
3429 int SalomePyQt::cloneView( const int id )
3431 return ProcessEvent( new TCloneView( id ) );
3435 \fn bool SalomePyQt::setViewVisible( const int id, const bool visible )
3436 \brief Set view visibility.
3437 \param id window identifier
3438 \param visible new visiblity
3441 void SalomePyQt::setViewVisible( const int id, const bool visible )
3443 class TEvent: public SALOME_Event
3448 TEvent( const int id, const bool visible )
3449 : myWndId( id ), myVisible( visible ) {}
3450 virtual void Execute()
3452 SUIT_ViewWindow* wnd = getWnd( myWndId );
3453 if ( wnd ) wnd->setVisible( myVisible );
3456 ProcessVoidEvent( new TEvent( id, visible ) );
3460 \fn bool SalomePyQt::isViewVisible( const int id );
3461 \brief Check whether view is visible ( i.e. it is on the top of the views stack)
3462 \param id window identifier
3463 \return \c true if view is visible and \c false otherwise
3466 class TIsViewVisible: public SALOME_Event
3469 typedef bool TResult;
3472 TIsViewVisible( const int id )
3473 : myResult( false ),
3475 virtual void Execute()
3477 SUIT_ViewWindow* wnd = getWnd( myWndId );
3480 QWidget* p = wnd->parentWidget();
3481 myResult = ( p && p->isVisibleTo( p->parentWidget() ) );
3485 bool SalomePyQt::isViewVisible( const int id )
3487 return ProcessEvent( new TIsViewVisible( id ) );
3491 \fn bool SalomePyQt::setViewClosable( const int id, const bool on );
3492 \brief Set / clear view's "closable" option. By default any view is closable
3493 (i.e. can be closed by the user).
3494 \param id window identifier
3495 \param on new "closable" option's value
3498 void SalomePyQt::setViewClosable( const int id, const bool on )
3500 class TEvent: public SALOME_Event
3505 TEvent( const int id, const bool on )
3506 : myWndId( id ), myOn( on ) {}
3507 virtual void Execute()
3509 SUIT_ViewWindow* wnd = getWnd( myWndId );
3510 if ( wnd ) wnd->setClosable( myOn );
3513 ProcessVoidEvent( new TEvent( id, on ) );
3517 \fn bool SalomePyQt::isViewClosable( const int id );
3518 \brief Check whether view is closable (i.e. can be closed by the user)
3519 \param id window identifier
3520 \return \c true if view is closable or \c false otherwise
3523 class TIsViewClosable: public SALOME_Event
3526 typedef bool TResult;
3529 TIsViewClosable( const int id )
3532 virtual void Execute()
3534 SUIT_ViewWindow* wnd = getWnd( myWndId );
3536 myResult = wnd->closable();
3540 bool SalomePyQt::isViewClosable( const int id )
3542 return ProcessEvent( new TIsViewClosable( id ) );
3546 \fn bool SalomePyQt::groupAllViews();
3547 \brief Group all views to the single tab area
3548 \return \c true if operation is completed successfully and \c false otherwise
3551 class TGroupAllViews: public SALOME_Event
3554 typedef bool TResult;
3557 : myResult( false ) {}
3558 virtual void Execute()
3560 LightApp_Application* app = getApplication();
3562 STD_TabDesktop* tabDesk = dynamic_cast<STD_TabDesktop*>( app->desktop() );
3564 QtxWorkstack* wStack = tabDesk->workstack();
3573 bool SalomePyQt::groupAllViews()
3575 return ProcessEvent( new TGroupAllViews() );
3579 \fn bool SalomePyQt::splitView( const int id, const Orientation ori, const Action action );
3580 \brief Split tab area to which view with identifier belongs to
3581 \param id window identifier
3582 \param ori orientation of split operation
3583 \param action action to be performed
3584 \return \c true if operation is completed successfully \c false otherwise
3587 class TSplitView: public SALOME_Event
3590 typedef bool TResult;
3595 TSplitView( const int id,
3596 const Orientation ori,
3597 const Action action )
3598 : myResult( false ),
3601 myAction( action ) {}
3602 virtual void Execute()
3604 SUIT_ViewWindow* wnd = getWnd( myWndId );
3607 // wnd->setFocus(); ???
3610 if ( getApplication() ) {
3611 STD_TabDesktop* desk =
3612 dynamic_cast<STD_TabDesktop*>( getApplication()->desktop() );
3614 QtxWorkstack* wStack = desk->workstack();
3616 Qt::Orientation qtOri =
3617 ( myOri == Horizontal ) ? Qt::Horizontal : Qt::Vertical;
3619 QtxWorkstack::SplitType sType;
3620 if ( myAction == MoveWidget )
3621 sType = QtxWorkstack::SplitMove;
3622 else if ( myAction == LeaveWidget )
3623 sType = QtxWorkstack::SplitStay;
3625 sType = QtxWorkstack::SplitAt;
3627 wStack->Split( wnd, qtOri, sType );
3635 bool SalomePyQt::splitView( const int id, const Orientation ori, const Action action )
3637 return ProcessEvent( new TSplitView( id, ori, action ) );
3641 \fn bool SalomePyQt::moveView( const int id, const int id_to, const bool before );
3642 \brief Move view with the first identifier to the same area which
3643 another view with the second identifier belongs to
3644 \param id source window identifier
3645 \param id_to destination window identifier
3646 param before specifies whether the first viewt has to be moved before or after
3648 \return \c true if operation is completed successfully and \c false otherwise
3651 class TMoveView: public SALOME_Event
3654 typedef bool TResult;
3659 TMoveView( const int id, const int id_to, const bool before )
3660 : myResult( false ),
3663 myIsBefore( before ) {}
3664 virtual void Execute()
3666 SUIT_ViewWindow* wnd = getWnd( myWndId );
3667 SUIT_ViewWindow* wnd_to = getWnd( myWndToId );
3668 if ( wnd && wnd_to ) {
3669 QtxWorkstack* wStack = dynamic_cast<STD_TabDesktop*>(
3670 getApplication()->desktop() )->workstack();
3672 myResult = wStack->move( wnd, wnd_to, myIsBefore );
3676 bool SalomePyQt::moveView( const int id, const int id_to, const bool before )
3678 return ProcessEvent( new TMoveView( id, id_to, before ) );
3682 \fn QList<int> SalomePyQt::neighbourViews( const int id );
3683 \brief Get list of views identifiers that belongs to the same area as
3684 specified view (excluding it)
3685 \param id window identifier
3686 \return list of views identifiers
3689 class TNeighbourViews: public SALOME_Event
3692 typedef QList<int> TResult;
3695 TNeighbourViews( const int id )
3697 virtual void Execute()
3700 SUIT_ViewWindow* wnd = getWnd( myWndId );
3702 QtxWorkstack* wStack = dynamic_cast<STD_TabDesktop*>(
3703 getApplication()->desktop() )->workstack();
3705 QWidgetList wgList = wStack->windowList( wnd );
3707 foreach ( wg, wgList ) {
3708 SUIT_ViewWindow* tmpWnd = dynamic_cast<SUIT_ViewWindow*>( wg );
3709 if ( tmpWnd && tmpWnd != wnd )
3710 myResult.append( tmpWnd->getId() );
3716 QList<int> SalomePyQt::neighbourViews( const int id )
3718 return ProcessEvent( new TNeighbourViews( id ) );
3723 \fn void SalomePyQt::createRoot();
3724 \brief Initialize root data object.
3726 Does nothing if root is already initialized.
3729 void SalomePyQt::createRoot()
3731 class TEvent: public SALOME_Event
3735 virtual void Execute()
3737 SALOME_PYQT_ModuleLight* module = dynamic_cast<SALOME_PYQT_ModuleLight*>( getActiveModule() );
3739 SALOME_PYQT_DataModelLight* dm =
3740 dynamic_cast<SALOME_PYQT_DataModelLight*>( module->dataModel() );
3745 if ( verbose() ) printf( "SalomePyQt.createRoot() function is not supported for the current module.\n" );
3749 ProcessVoidEvent( new TEvent() );
3753 \fn QString SalomePyQt::createObject( const QString& parent );
3754 \brief Create empty data object
3755 \param parent entry of parent data object
3756 \return entry of created data object
3759 class TCreateEmptyObjectEvent: public SALOME_Event
3762 typedef QString TResult;
3765 TCreateEmptyObjectEvent( const QString& parent )
3766 : myParent( parent ) {}
3767 virtual void Execute()
3769 SALOME_PYQT_ModuleLight* module = dynamic_cast<SALOME_PYQT_ModuleLight*>( getActiveModule() );
3771 myResult = module->createObject( myParent );
3774 if ( verbose() ) printf( "SalomePyQt.createObject() function is not supported for the current module.\n" );
3778 QString SalomePyQt::createObject( const QString& parent )
3780 return ProcessEvent( new TCreateEmptyObjectEvent( parent ) );
3784 \fn QString SalomePyQt::createObject( const QString& name, const QString& icon,
3785 const QString& tooltip,const QString& parent );
3786 \brief Create new data object with specified name, icon and tooltip
3787 \param name data object name
3788 \param icon data object icon
3789 \param toolTip data object tooltip
3790 \param parent entry of parent data object
3791 \return entry of created data object
3794 class TCreateObjectEvent: public SALOME_Event
3797 typedef QString TResult;
3803 TCreateObjectEvent( const QString& name,
3804 const QString& icon,
3805 const QString& tooltip,
3806 const QString& parent )
3809 myToolTip( tooltip ),
3810 myParent( parent ) {}
3811 virtual void Execute()
3813 SALOME_PYQT_ModuleLight* module = dynamic_cast<SALOME_PYQT_ModuleLight*>( getActiveModule() );
3815 myResult = module->createObject( myName, myIcon, myToolTip, myParent );
3818 if ( verbose() ) printf( "SalomePyQt.createObject() function is not supported for the current module.\n" );
3822 QString SalomePyQt::createObject( const QString& name,
3823 const QString& icon,
3824 const QString& toolTip,
3825 const QString& parent )
3827 return ProcessEvent( new TCreateObjectEvent( name, icon, toolTip, parent ) );
3832 \fn void SalomePyQt::setName( const QString& entry, const QString& name );
3833 \brief Set data object name
3834 \param entry data object entry
3835 \param name data object name
3837 class TSetNameEvent: public SALOME_Event
3842 TSetNameEvent( const QString& entry,
3843 const QString& name )
3846 virtual void Execute()
3848 SALOME_PYQT_ModuleLight* module = dynamic_cast<SALOME_PYQT_ModuleLight*>( getActiveModule() );
3850 module->setName( myEntry, myName );
3853 if ( verbose() ) printf( "SalomePyQt.setName() function is not supported for the current module.\n" );
3857 void SalomePyQt::setName( const QString& entry, const QString& name )
3859 ProcessVoidEvent( new TSetNameEvent( entry, name ) );
3863 \fn void SalomePyQt::setIcon( const QString& entry, const QString& icon );
3864 \brief Set data object icon
3865 \param entry data object entry
3866 \param icon data object icon file name (icon is loaded from module resources)
3869 class TSetIconEvent: public SALOME_Event
3874 TSetIconEvent( const QString& entry,
3875 const QString& icon )
3878 virtual void Execute()
3880 SALOME_PYQT_ModuleLight* module = dynamic_cast<SALOME_PYQT_ModuleLight*>( getActiveModule() );
3882 module->setIcon( myEntry, myIcon );
3885 if ( verbose() ) printf( "SalomePyQt.setIcon() function is not supported for the current module.\n" );
3890 void SalomePyQt::setIcon( const QString& entry, const QString& icon )
3892 ProcessVoidEvent( new TSetIconEvent( entry, icon ) );
3896 \fn void SalomePyQt::setToolTip( const QString& entry, const QString& toolTip );
3897 \brief Set data object tooltip
3898 \param entry data object entry
3899 \param toolTip data object tooltip
3902 class TSetToolTipEvent: public SALOME_Event
3907 TSetToolTipEvent( const QString& entry,
3908 const QString& toolTip )
3910 myToolTip( toolTip ) {}
3911 virtual void Execute()
3913 SALOME_PYQT_ModuleLight* module = dynamic_cast<SALOME_PYQT_ModuleLight*>( getActiveModule() );
3915 module->setToolTip( myEntry, myToolTip );
3918 if ( verbose() ) printf( "SalomePyQt.setToolTip() function is not supported for the current module.\n" );
3922 void SalomePyQt::setToolTip( const QString& entry, const QString& toolTip )
3924 ProcessVoidEvent( new TSetToolTipEvent( entry, toolTip ) );
3928 \fn void SalomePyQt::setReference( const QString& entry, const QString& refEntry );
3929 \brief Set reference to another data object
3930 \param entry data object entry
3931 \param refEntry referenced data object entry
3934 class TSetRefEvent: public SALOME_Event
3939 TSetRefEvent( const QString& entry,
3940 const QString& refEntry )
3942 myRefEntry( refEntry ) {}
3943 virtual void Execute()
3945 SALOME_PYQT_ModuleLight* module = dynamic_cast<SALOME_PYQT_ModuleLight*>( getActiveModule() );
3947 module->setReference( myEntry, myRefEntry );
3950 if ( verbose() ) printf( "SalomePyQt.setReference() function is not supported for the current module.\n" );
3954 void SalomePyQt::setReference( const QString& entry, const QString& refEntry )
3956 ProcessVoidEvent( new TSetRefEvent( entry, refEntry ) );
3960 \fn void SalomePyQt::setColor( const QString& entry, const QColor& color );
3961 \brief Set data object color
3962 \param entry data object entry
3963 \param color data object color
3966 class TSetColorEvent: public SALOME_Event
3971 TSetColorEvent( const QString& entry,
3972 const QColor& color )
3975 virtual void Execute()
3977 SALOME_PYQT_ModuleLight* module = dynamic_cast<SALOME_PYQT_ModuleLight*>( getActiveModule() );
3979 module->setColor( myEntry, myColor );
3982 if ( verbose() ) printf( "SalomePyQt.setColor() function is not supported for the current module.\n" );
3986 void SalomePyQt::setColor( const QString& entry, const QColor& color )
3988 ProcessVoidEvent( new TSetColorEvent( entry, color ) );
3992 \fn QString SalomePyQt::getName( const QString& entry );
3993 \brief Get data object name
3994 \param entry data object entry
3995 \return data object name
3998 class TGetNameEvent: public SALOME_Event
4001 typedef QString TResult;
4004 TGetNameEvent( const QString& entry )
4005 : myEntry( entry ) {}
4006 virtual void Execute()
4008 SALOME_PYQT_ModuleLight* module = dynamic_cast<SALOME_PYQT_ModuleLight*>( getActiveModule() );
4010 myResult = module->getName( myEntry );
4013 if ( verbose() ) printf( "SalomePyQt.getName() function is not supported for the current module.\n" );
4017 QString SalomePyQt::getName( const QString& entry )
4019 return ProcessEvent( new TGetNameEvent( entry ) );
4023 \fn QString SalomePyQt::getToolTip( const QString& entry );
4024 \brief Get data object tooltip
4025 \param entry data object entry
4026 \return data object tooltip
4029 class TGetToolTipEvent: public SALOME_Event
4032 typedef QString TResult;
4035 TGetToolTipEvent( const QString& entry )
4036 : myEntry( entry ) {}
4037 virtual void Execute()
4039 SALOME_PYQT_ModuleLight* module = dynamic_cast<SALOME_PYQT_ModuleLight*>( getActiveModule() );
4041 myResult = module->getToolTip( myEntry );
4044 if ( verbose() ) printf( "SalomePyQt.getToolTip() function is not supported for the current module.\n" );
4048 QString SalomePyQt::getToolTip( const QString& entry )
4050 return ProcessEvent( new TGetToolTipEvent( entry ) );
4054 \fn QString SalomePyQt::getReference( const QString& entry );
4055 \brief Get entry of the referenced object (if there's any)
4056 \param entry data object entry
4057 \return referenced data object entry
4060 class TGetRefEvent: public SALOME_Event
4063 typedef QString TResult;
4066 TGetRefEvent( const QString& entry )
4067 : myEntry( entry ) {}
4068 virtual void Execute()
4070 SALOME_PYQT_ModuleLight* module = dynamic_cast<SALOME_PYQT_ModuleLight*>( getActiveModule() );
4072 myResult = module->getReference( myEntry );
4075 if ( verbose() ) printf( "SalomePyQt.getReference() function is not supported for the current module.\n" );
4079 QString SalomePyQt::getReference( const QString& entry )
4081 return ProcessEvent( new TGetRefEvent( entry ) );
4085 \fn QColor SalomePyQt::getColor( const QString& entry );
4086 \brief Get data object color
4087 \param entry data object entry
4088 \return data object color
4091 class TGetColorEvent: public SALOME_Event
4094 typedef QColor TResult;
4097 TGetColorEvent( const QString& entry )
4098 : myEntry( entry ) {}
4099 virtual void Execute()
4101 SALOME_PYQT_ModuleLight* module = dynamic_cast<SALOME_PYQT_ModuleLight*>( getActiveModule() );
4103 myResult = module->getColor( myEntry );
4106 if ( verbose() ) printf( "SalomePyQt.getColor() function is not supported for the current module.\n" );
4110 QColor SalomePyQt::getColor( const QString& entry )
4112 return ProcessEvent( new TGetColorEvent( entry ) );
4116 \fn void SalomePyQt::removeChildren( const QString& entry );
4117 \brief Remove all child data objects from specified data object
4118 \param entry data object entry
4121 class TRemoveChildEvent: public SALOME_Event
4125 TRemoveChildEvent( const QString& entry )
4126 : myEntry( entry ) {}
4127 virtual void Execute()
4129 SALOME_PYQT_ModuleLight* module = dynamic_cast<SALOME_PYQT_ModuleLight*>( getActiveModule() );
4131 module->removeChildren( myEntry );
4134 if ( verbose() ) printf( "SalomePyQt.removeChildren() function is not supported for the current module.\n" );
4138 void SalomePyQt::removeChildren( const QString& entry )
4140 ProcessVoidEvent( new TRemoveChildEvent( entry ) );
4142 void SalomePyQt::removeChild( const QString& entry )
4144 if ( verbose() ) printf( "SalomePyQt.removeChild() function is obsolete. Use SalomePyQt.removeChildren() instead." );
4145 removeChildren( entry );
4149 \fn void SalomePyQt::removeObject( const QString& entry );
4150 \brief Remove object by entry
4151 \param entry data object entry
4154 class TRemoveObjectEvent: public SALOME_Event
4159 TRemoveObjectEvent( const QString& entry )
4160 : myEntry( entry ) {}
4161 virtual void Execute()
4163 SALOME_PYQT_ModuleLight* module = dynamic_cast<SALOME_PYQT_ModuleLight*>( getActiveModule() );
4165 module->removeObject( myEntry );
4168 if ( verbose() ) printf( "SalomePyQt.removeObject() function is not supported for the current module.\n" );
4172 void SalomePyQt::removeObject( const QString& entry )
4174 ProcessVoidEvent( new TRemoveObjectEvent( entry ) );
4178 \fn QStringList SalomePyQt::getChildren( const QString& entry, const bool recursive );
4179 \brief Get entries of all child data objects of specified data object
4180 \param entry data object entry
4181 \param recursive \c true for recursive processing
4184 class TGetChildrenEvent: public SALOME_Event
4187 typedef QStringList TResult;
4191 TGetChildrenEvent( const QString& entry, const bool recursive )
4193 myRecursive( recursive ) {}
4194 virtual void Execute()
4196 SALOME_PYQT_ModuleLight* module = dynamic_cast<SALOME_PYQT_ModuleLight*>( getActiveModule() );
4198 myResult = module->getChildren( myEntry, myRecursive );
4201 if ( verbose() ) printf( "SalomePyQt.getChildren() function is not supported for the current module.\n" );
4205 QStringList SalomePyQt::getChildren( const QString& entry, const bool recursive )
4207 return ProcessEvent( new TGetChildrenEvent( entry, recursive ) );
4210 #ifndef DISABLE_PLOT2DVIEWER
4211 // Next set of methods relates to the Plot2d viewer functionality
4214 \fn void SalomePyQt::displayCurve( const int id, Plot2d_Curve* theCurve )
4215 \brief Display theCurve in view
4216 \param id window identifier
4217 \param theCurve curve to display
4220 class TDisplayCurve: public SALOME_Event
4224 Plot2d_Curve* myCurve;
4225 TDisplayCurve( const int id, Plot2d_Curve* theCurve ) : myWndId( id ), myCurve( theCurve ) {}
4226 virtual void Execute() {
4227 Plot2d_ViewWindow* wnd = dynamic_cast<Plot2d_ViewWindow*>( getWnd( myWndId ) );
4229 wnd->getViewFrame()->displayCurve( myCurve );
4232 void SalomePyQt::displayCurve( const int id, Plot2d_Curve* theCurve )
4234 ProcessVoidEvent( new TDisplayCurve( id, theCurve ) );
4238 \fn void SalomePyQt::eraseCurve( const int id, Plot2d_Curve* theCurve )
4239 \brief Erase theCurve in view
4240 \param id window identifier
4241 \param theCurve curve to erase
4244 class TEraseCurve: public SALOME_Event
4248 Plot2d_Curve* myCurve;
4249 TEraseCurve( const int id, Plot2d_Curve* theCurve ) : myWndId( id ), myCurve( theCurve ) {}
4250 virtual void Execute() {
4251 Plot2d_ViewWindow* wnd = dynamic_cast<Plot2d_ViewWindow*>( getWnd( myWndId ) );
4252 wnd->getViewFrame()->eraseCurve( myCurve );
4255 void SalomePyQt::eraseCurve( const int id, Plot2d_Curve* theCurve )
4257 ProcessVoidEvent( new TEraseCurve( id, theCurve ) );
4261 \fn void SalomePyQt::deleteCurve( Plot2d_Curve* theCurve )
4262 \brief Delete theCurve from all views
4263 \param theCurve curve to delete
4266 class TDeleteCurve: public SALOME_Event
4269 Plot2d_Curve* myCurve;
4270 TDeleteCurve( Plot2d_Curve* theCurve ) : myCurve( theCurve ) {}
4271 virtual void Execute() {
4272 LightApp_Application* app = getApplication();
4274 STD_TabDesktop* tabDesk = dynamic_cast<STD_TabDesktop*>( app->desktop() );
4276 QList<SUIT_ViewWindow*> wndlist = tabDesk->windows();
4277 SUIT_ViewWindow* wnd;
4278 foreach ( wnd, wndlist ) {
4279 Plot2d_ViewWindow* aP2d = dynamic_cast<Plot2d_ViewWindow*>( wnd );
4281 aP2d->getViewFrame()->eraseObject( myCurve );
4287 void SalomePyQt::eraseCurve( Plot2d_Curve* theCurve )
4289 ProcessVoidEvent( new TDeleteCurve( theCurve ) );
4293 \brief updateCurves (repaint) curves in view window.
4295 void SalomePyQt::updateCurves( const int id )
4297 class TEvent: public SALOME_Event
4301 TEvent( const int id ) : myWndId( id ) {}
4302 virtual void Execute()
4304 Plot2d_ViewWindow* wnd = dynamic_cast<Plot2d_ViewWindow*>( getWnd( myWndId ) );
4306 wnd->getViewFrame()->DisplayAll();
4309 ProcessVoidEvent( new TEvent( id ) );
4313 \fn QString SalomePyQt::getPlot2dTitle( const int id, ObjectType type = MainTitle )
4314 \brief Get title of corresponding type
4315 \param id window identifier
4316 \param type is type of title
4317 \return title of corresponding type
4320 class TGetPlot2dTitle: public SALOME_Event
4323 typedef QString TResult;
4327 TGetPlot2dTitle(const int id, ObjectType type) :
4330 virtual void Execute() {
4331 Plot2d_ViewWindow* wnd = dynamic_cast<Plot2d_ViewWindow*>( getWnd( myWndId ) );
4333 myResult = wnd->getViewFrame()->getTitle( (Plot2d_ViewFrame::ObjectType)myType );
4336 QString SalomePyQt::getPlot2dTitle( const int id, ObjectType type )
4338 return ProcessEvent( new TGetPlot2dTitle( id, type ) );
4343 \fn void SalomePyQt::setPlot2dTitle( const int id, const QString& title, ObjectType type = MainTitle, bool show = true )
4344 \brief Set title of corresponding type
4345 \param id window identifier
4347 \param type is type of title
4351 class TSetPlot2dTitle: public SALOME_Event
4355 Plot2d_Curve* myCurve;
4359 TSetPlot2dTitle( const int id, const QString& title, ObjectType type, bool show ) :
4364 virtual void Execute() {
4365 Plot2d_ViewWindow* wnd = dynamic_cast<Plot2d_ViewWindow*>( getWnd( myWndId ) );
4366 wnd->getViewFrame()->setTitle( myShow, myTitle, (Plot2d_ViewFrame::ObjectType)myType, false );
4369 void SalomePyQt::setPlot2dTitle( const int id, const QString& title, ObjectType type, bool show )
4371 ProcessVoidEvent( new TSetPlot2dTitle( id, title, type, show ) );
4375 \fn QList<int> SalomePyQt::getPlot2dFitRangeByCurves( const int id )
4376 \brief Get list of Plot2d view ranges
4377 \param id window identifier
4378 \return list of view ranges (XMin, XMax, YMin, YMax)
4381 class TFitRangeByCurves: public SALOME_Event
4384 typedef QList<double> TResult;
4387 TFitRangeByCurves( const int id )
4389 virtual void Execute()
4392 Plot2d_ViewWindow* wnd = dynamic_cast<Plot2d_ViewWindow*>( getWnd( myWndId ) );
4394 double XMin, XMax, YMin, YMax, Y2Min, Y2Max;
4395 wnd->getViewFrame()->getFitRangeByCurves( XMin, XMax, YMin, YMax, Y2Min, Y2Max );
4396 myResult.append( XMin );
4397 myResult.append( XMax );
4398 myResult.append( YMin );
4399 myResult.append( YMax );
4403 QList<double> SalomePyQt::getPlot2dFitRangeByCurves( const int id )
4405 return ProcessEvent( new TFitRangeByCurves( id ) );
4409 \fn QList<int> SalomePyQt::getPlot2dFitRangeCurrent( const int id )
4410 \brief Get list of current Plot2d view ranges
4411 \param id window identifier
4412 \return list of view ranges (XMin, XMax, YMin, YMax)
4415 class TFitRangeCurrent: public SALOME_Event
4418 typedef QList<double> TResult;
4421 TFitRangeCurrent( const int id )
4423 virtual void Execute()
4426 Plot2d_ViewWindow* wnd = dynamic_cast<Plot2d_ViewWindow*>( getWnd( myWndId ) );
4428 double XMin, XMax, YMin, YMax, Y2Min, Y2Max;
4429 wnd->getViewFrame()->getFitRanges( XMin, XMax, YMin, YMax, Y2Min, Y2Max );
4430 myResult.append( XMin );
4431 myResult.append( XMax );
4432 myResult.append( YMin );
4433 myResult.append( YMax );
4437 QList<double> SalomePyQt::getPlot2dFitRangeCurrent( const int id )
4439 return ProcessEvent( new TFitRangeCurrent( id ) );
4443 \fn void SalomePyQt::setPlot2dFitRange( const int id, const double XMin, const double XMax, const double YMin, const double YMax )
4444 \brief Set range of Plot2d view
4445 \param id window identifier
4452 class TPlot2dFitRange: public SALOME_Event
4460 TPlot2dFitRange( const int id, const double XMin, const double XMax, const double YMin, const double YMax ) :
4466 virtual void Execute() {
4467 Plot2d_ViewWindow* wnd = dynamic_cast<Plot2d_ViewWindow*>( getWnd( myWndId ) );
4469 wnd->getViewFrame()->fitData( 0, myXMin, myXMax, myYMin, myYMax );
4472 void SalomePyQt::setPlot2dFitRange( const int id, const double XMin, const double XMax, const double YMin, const double YMax )
4474 ProcessVoidEvent( new TPlot2dFitRange( id, XMin, XMax, YMin, YMax ) );
4477 // End of methods related to the Plot2d viewer functionality
4478 #endif // DISABLE_PLOT2DVIEWER
4481 \brief Process Qt event loop
4483 void SalomePyQt::processEvents()
4485 QCoreApplication::processEvents();
4489 \brief Set visibility state for given object
4490 \param theEntry study ID of the object
4491 \param theState visibility state
4493 void SalomePyQt::setVisibilityState( const QString& theEntry, VisibilityState theState )
4495 class TEvent: public SALOME_Event
4500 TEvent( const QString& theEntry, int theState ):
4501 myEntry( theEntry ), myState( theState ) {}
4502 virtual void Execute()
4504 LightApp_Study* aStudy = getActiveStudy();
4507 aStudy->setVisibilityState( myEntry, (Qtx::VisibilityState)myState );
4510 ProcessVoidEvent( new TEvent( theEntry, theState ) );
4514 \fn VisibilityState SalomePyQt::getVisibilityState( const QString& theEntry )
4515 \brief Get visibility state for given object
4516 \param theEntry study ID of the object
4517 \return visibility state
4520 class TGetVisibilityStateEvent: public SALOME_Event
4523 typedef int TResult;
4526 TGetVisibilityStateEvent( const QString& theEntry ) : myResult( 0 ), myEntry( theEntry ) {}
4527 virtual void Execute()
4529 LightApp_Study* aStudy = getActiveStudy();
4531 myResult = aStudy->visibilityState( myEntry );
4534 VisibilityState SalomePyQt::getVisibilityState( const QString& theEntry )
4536 return (VisibilityState) ProcessEvent( new TGetVisibilityStateEvent( theEntry ) );
4540 \brief Set position of given object in the tree
4541 \param theEntry study ID of the object
4542 \param thePos position
4544 void SalomePyQt::setObjectPosition( const QString& theEntry, int thePos )
4546 class TEvent: public SALOME_Event
4551 TEvent( const QString& theEntry, int thePos ):
4552 myEntry( theEntry ), myPos( thePos ) {}
4553 virtual void Execute()
4555 SALOME_PYQT_ModuleLight* module = dynamic_cast<SALOME_PYQT_ModuleLight*>( getActiveModule() );
4557 module->setObjectPosition( myEntry, myPos );
4560 ProcessVoidEvent( new TEvent( theEntry, thePos ) );
4564 \fn int SalomePyQt::getObjectPosition( const QString& theEntry )
4565 \brief Get position of given object in the tree
4566 \param theEntry study ID of the object
4570 class TGetObjectPositionEvent: public SALOME_Event
4573 typedef int TResult;
4576 TGetObjectPositionEvent( const QString& theEntry ) : myResult( 0 ), myEntry( theEntry ) {}
4577 virtual void Execute()
4579 SALOME_PYQT_ModuleLight* module = dynamic_cast<SALOME_PYQT_ModuleLight*>( getActiveModule() );
4581 myResult = module->getObjectPosition( myEntry );
4584 int SalomePyQt::getObjectPosition( const QString& theEntry )
4586 return ProcessEvent( new TGetObjectPositionEvent( theEntry ) );
4590 \brief Start recordind a log of Python commands from embedded console
4591 \param theFileName output lof file name
4593 void SalomePyQt::startPyLog( const QString& theFileName )
4595 class TEvent: public SALOME_Event
4599 TEvent( const QString& theFileName ):
4600 myFileName( theFileName ) {}
4601 virtual void Execute()
4603 if ( getApplication() ) {
4604 PyConsole_Console* pyConsole = getApplication()->pythonConsole( false );
4605 if ( pyConsole ) pyConsole->startLog( myFileName );
4609 ProcessVoidEvent( new TEvent( theFileName ) );
4613 \brief Stop recordind a log of Python commands from embedded console
4615 void SalomePyQt::stopPyLog()
4617 class TEvent: public SALOME_Event
4621 virtual void Execute()
4623 if ( getApplication() ) {
4624 PyConsole_Console* pyConsole = getApplication()->pythonConsole( false );
4625 if ( pyConsole ) pyConsole->stopLog();
4629 ProcessVoidEvent( new TEvent() );