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 SALOME_Selection* SalomePyQt::getSelection();
606 \brief Get the selection object for the current study.
608 Creates a Selection object if it has not been created yet.
610 \return selection object (0 on error)
613 class TGetSelectionEvent: public SALOME_Event
616 typedef SALOME_Selection* TResult;
618 TGetSelectionEvent() : myResult( 0 ) {}
619 virtual void Execute()
621 myResult = SALOME_Selection::GetSelection( getApplication() );
624 SALOME_Selection* SalomePyQt::getSelection()
626 return ProcessEvent( new TGetSelectionEvent() );
630 \fn QStringList* SalomePyQt::setSelection(const QStringList& );
631 \brief Send local selection for notification.
633 The list of locally selected objects (study entries) is sent for notification of
634 other listening entities (modules, viewers...).
637 class TSetSelectionEvent: public SALOME_Event
639 QStringList myEntryList;
641 TSetSelectionEvent(const QStringList& entryList) : myEntryList(entryList) {}
642 virtual void Execute()
644 SALOME_PYQT_ModuleLight* module = dynamic_cast<SALOME_PYQT_ModuleLight*>( getActiveModule() );
645 if ( !module ) return;
646 module->setLocalSelected(myEntryList);
649 void SalomePyQt::setSelection( const QStringList& entryList)
651 return ProcessVoidEvent( new TSetSelectionEvent(entryList) );
655 \fn void SalomePyQt::enableSelector();
656 \brief enable PyQt_Selector (on module activation, for instance)
659 class TEnableSelectorEvent: public SALOME_Event
662 TEnableSelectorEvent() {}
663 virtual void Execute()
665 SALOME_PYQT_ModuleLight* module = dynamic_cast<SALOME_PYQT_ModuleLight*>( getActiveModule() );
666 if ( !module ) return;
667 module->enableSelector();
670 void SalomePyQt::enableSelector()
672 return ProcessVoidEvent( new TEnableSelectorEvent() );
677 \fn void SalomePyQt::disableSelector();
678 \brief disable PyQt_Selector (on module activation, for instance)
681 class TdisableSelectorEvent: public SALOME_Event
684 TdisableSelectorEvent() {}
685 virtual void Execute()
687 SALOME_PYQT_ModuleLight* module = dynamic_cast<SALOME_PYQT_ModuleLight*>( getActiveModule() );
688 if ( !module ) return;
689 module->disableSelector();
692 void SalomePyQt::disableSelector()
694 return ProcessVoidEvent( new TdisableSelectorEvent() );
699 \fn void SalomePyQt::putInfo( const QString& msg, const int sec );
700 \brief Put an information message to the current application's
703 Optional second delay parameter (\a sec) can be used to specify
704 time of the message diplaying in seconds. If this parameter is less
705 or equal to zero, the constant message will be put.
707 \param msg message text
708 \param sec message displaying time in seconds
711 class TPutInfoEvent: public SALOME_Event
716 TPutInfoEvent( const QString& msg, const int sec = 0 ) : myMsg( msg ), mySecs( sec ) {}
717 virtual void Execute()
719 if ( LightApp_Application* anApp = getApplication() ) {
720 anApp->putInfo( myMsg, mySecs * 1000 );
724 void SalomePyQt::putInfo( const QString& msg, const int sec )
726 ProcessVoidEvent( new TPutInfoEvent( msg, sec ) );
730 \fn int SalomePyQt::showNotification( const QString& msg, const QString& title, const int sec );
731 \brief Show notification in the application's desktop window.
733 Optional third delay parameter (\a sec) can be used to specify
734 time of the notification diplaying in seconds. If this parameter is less
735 or equal to zero, the permanent notification will be put.
737 Notification can be forcibly hidden via hideNotification() method.
739 \param msg message text
740 \param title title text
741 \param sec notification displaying time in seconds
742 \return unique ID of the notification (can be used to hide notification)
743 \sa hideNotification()
746 class TShowNotifyEvent: public SALOME_Event
757 TShowNotifyEvent( const QString& msg, const QString& title, const int sec = -1 ) : myMsg( msg ), myTitle( title), mySecs( sec ), myResult( -1 ) {}
758 virtual void Execute()
760 if ( LightApp_Application* anApp = getApplication() ) {
761 myResult = anApp->showNotification( myMsg, myTitle, mySecs * 1000 );
766 int SalomePyQt::showNotification( const QString& msg, const QString& title, const int sec )
768 return ProcessEvent( new TShowNotifyEvent( msg, title, sec ) );
772 \fn void SalomePyQt::hideNotification( const QString& msg );
773 \brief Remove notification with given message text from the application's desktop.
775 \param msg message text
776 \sa showNotification()
780 \fn void SalomePyQt::hideNotification( const int id );
781 \brief Remove notification with given \a id from the application's desktop.
783 \param id notification id
784 \sa showNotification()
787 class THideNotifyEvent: public SALOME_Event
793 THideNotifyEvent( const QString& msg ) : myId( -1 ), myMsg( msg ) {}
794 THideNotifyEvent( const int id ) : myId( id ) {}
795 virtual void Execute()
797 if ( LightApp_Application* anApp = getApplication() ) {
799 anApp->hideNotification( myId );
801 anApp->hideNotification( myMsg );
806 void SalomePyQt::hideNotification( const QString& msg )
808 ProcessVoidEvent( new THideNotifyEvent( msg ) );
811 void SalomePyQt::hideNotification( const int id )
813 ProcessVoidEvent( new THideNotifyEvent( id ) );
817 \fn const QString SalomePyQt::getActiveComponent();
818 \brief Get the currently active module name (for the current study).
819 \return active module name or empty string if there is no active module
822 class TGetActiveComponentEvent: public SALOME_Event
825 typedef QString TResult;
827 TGetActiveComponentEvent() {}
828 virtual void Execute()
830 if ( LightApp_Application* anApp = getApplication() ) {
831 if ( CAM_Module* mod = anApp->activeModule() ) {
832 myResult = mod->name();
837 const QString SalomePyQt::getActiveComponent()
839 return ProcessEvent( new TGetActiveComponentEvent() );
843 \fn PyObject* SalomePyQt::getActivePythonModule();
844 \brief Access to Python module object currently loaded into SALOME_PYQT_ModuleLight container.
845 \return Python module object currently loaded into SALOME_PYQT_ModuleLight container
848 class TGetActivePyModuleEvent: public SALOME_Event
851 typedef PyObject* TResult;
853 TGetActivePyModuleEvent() : myResult( Py_None ) {}
854 virtual void Execute()
856 PyModuleHelper* helper = getPythonHelper();
858 myResult = (PyObject*)helper->pythonModule();
861 PyObject* SalomePyQt::getActivePythonModule()
863 return ProcessEvent( new TGetActivePyModuleEvent() );
867 \fn bool SalomePyQt::activateModule( const QString& modName );
868 \brief Activates SALOME module with the given name
869 \return True if the module has been activated and False otherwise.
872 class TActivateModuleEvent: public SALOME_Event
875 typedef bool TResult;
877 QString myModuleName;
878 TActivateModuleEvent( const QString& modName )
879 : myResult( false ), myModuleName( modName ) {}
880 virtual void Execute()
882 if ( LightApp_Application* anApp = getApplication() ) {
883 myResult = anApp->activateModule( myModuleName );
887 bool SalomePyQt::activateModule( const QString& modName )
889 return ProcessEvent( new TActivateModuleEvent( modName ) );
893 \brief Update an Object Browser of the study.
895 void SalomePyQt::updateObjBrowser()
897 class TEvent: public SALOME_Event
901 virtual void Execute()
903 if ( SUIT_Session::session() ) {
904 if ( getActiveStudy() ) {
905 QList<SUIT_Application*> apps = SUIT_Session::session()->applications();
906 QList<SUIT_Application*>::Iterator it;
907 for( it = apps.begin(); it != apps.end(); ++it ) {
908 LightApp_Application* anApp = dynamic_cast<LightApp_Application*>( *it );
909 if ( anApp && anApp->activeStudy() ) {
910 anApp->updateObjectBrowser();
918 ProcessVoidEvent( new TEvent() );
923 SalomePyQt::isModified()
924 \return The modification status of the data model
925 for the currently active Python module
926 \note This function is supported for "light" Python-based SALOME modules only.
929 class TIsModifiedEvent: public SALOME_Event
932 typedef bool TResult;
934 TIsModifiedEvent() : myResult( false ) {}
935 virtual void Execute()
937 LightApp_Module* module = getActiveModule();
941 SALOME_PYQT_DataModelLight* aModel =
942 dynamic_cast<SALOME_PYQT_DataModelLight*>( module->dataModel() );
944 myResult = aModel->isModified();
947 if ( verbose() ) printf( "SalomePyQt.isModified() function is not supported for the current module.\n" );
951 bool SalomePyQt::isModified()
953 return ProcessEvent(new TIsModifiedEvent());
957 SalomePyQt::setModified()
959 Sets the modification status of the data model for
960 the currently active Python module. This method should be used
961 by the Python code in order to enable/disable "Save" operation
962 depending on the module's data state.
964 \note This function is supported for "light" Python-based SALOME modules only.
966 \param New modification status of the data model
970 void SalomePyQt::setModified( bool flag )
972 class TEvent: public SALOME_Event
978 virtual void Execute()
980 LightApp_Module* module = getActiveModule();
984 SALOME_PYQT_DataModelLight* model =
985 dynamic_cast<SALOME_PYQT_DataModelLight*>( module->dataModel() );
987 LightApp_Application* app = module->getApp();
989 if ( model && app ) {
990 model->setModified( myFlag );
991 app->updateActions();
994 if ( verbose() ) printf( "SalomePyQt.setModified() function is not supported for the current module.\n" );
998 ProcessVoidEvent( new TEvent( flag ) );
1002 \brief Add string setting to the application preferences.
1004 The parameter \a autoValue is obsolete parameter and currently is not used.
1005 This parameter will be removed in future, so try to avoid its usage in
1008 This function is obsolete. Use one of addSetting() instead.
1010 \param name setting name (it should be of kind <section:setting> where
1011 \c section is resources section name and \c setting is setting name)
1012 \param value new setting value
1013 \param autoValue (not used)
1015 void SalomePyQt::addStringSetting( const QString& name, const QString& value, bool autoValue )
1017 class TEvent: public SALOME_Event
1023 TEvent( const QString& name, const QString& value, bool autoValue )
1024 : myName( name ), myValue( value ), myAutoValue( autoValue ) {}
1025 virtual void Execute()
1027 if ( SUIT_Session::session() ) {
1028 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1029 QStringList sl = myName.split( ":", QString::SkipEmptyParts );
1030 QString _sec = sl.count() > 1 ? sl[ 0 ].trimmed() : QString( DEFAULT_SECTION );
1031 QString _nam = sl.count() > 1 ? sl[ 1 ].trimmed() : sl.count() > 0 ? sl[ 0 ].trimmed() : QString( "" );
1032 if ( !_sec.isEmpty() && !_nam.isEmpty() )
1033 resMgr->setValue( _sec, _nam, myValue );
1037 ProcessVoidEvent( new TEvent( name, value, autoValue ) );
1041 \brief Add integer setting to the application preferences.
1043 The parameter \a autoValue is obsolete parameter and currently is not used.
1044 This parameter will be removed in future, so try to avoid its usage in
1047 This function is obsolete. Use one of addSetting() instead.
1049 \param name setting name (it should be of kind <section:setting> where
1050 \c section is resources section name and \c setting is setting name)
1051 \param value new setting value
1052 \param autoValue (not used)
1054 void SalomePyQt::addIntSetting( const QString& name, const int value, bool autoValue)
1056 class TEvent: public SALOME_Event
1062 TEvent( const QString& name, const int value, bool autoValue )
1063 : myName( name ), myValue( value ), myAutoValue( autoValue ) {}
1064 virtual void Execute()
1066 if ( SUIT_Session::session() ) {
1067 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1068 QStringList sl = myName.split( ":", QString::SkipEmptyParts );
1069 QString _sec = sl.count() > 1 ? sl[ 0 ].trimmed() : QString( DEFAULT_SECTION );
1070 QString _nam = sl.count() > 1 ? sl[ 1 ].trimmed() : sl.count() > 0 ? sl[ 0 ].trimmed() : QString( "" );
1071 if ( !_sec.isEmpty() && !_nam.isEmpty() )
1072 resMgr->setValue( _sec, _nam, myValue );
1076 ProcessVoidEvent( new TEvent( name, value, autoValue ) );
1080 \brief Add double setting to the application preferences.
1082 The parameter \a autoValue is obsolete parameter and currently is not used.
1083 This parameter will be removed in future, so try to avoid its usage in
1086 This function is obsolete. Use one of addSetting() instead.
1088 \param name setting name (it should be of kind <section:setting> where
1089 \c section is resources section name and \c setting is setting name)
1090 \param value new setting value
1091 \param autoValue (not used)
1093 void SalomePyQt::addDoubleSetting( const QString& name, const double value, bool autoValue )
1095 class TEvent: public SALOME_Event
1101 TEvent( const QString& name, const double value, bool autoValue )
1102 : myName( name ), myValue( value ), myAutoValue( autoValue ) {}
1103 virtual void Execute()
1105 if ( SUIT_Session::session() ) {
1106 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1107 QStringList sl = myName.split( ":", QString::SkipEmptyParts );
1108 QString _sec = sl.count() > 1 ? sl[ 0 ].trimmed() : QString( DEFAULT_SECTION );
1109 QString _nam = sl.count() > 1 ? sl[ 1 ].trimmed() : sl.count() > 0 ? sl[ 0 ].trimmed() : QString( "" );
1110 if ( !_sec.isEmpty() && !_nam.isEmpty() )
1111 resMgr->setValue( _sec, _nam, myValue );
1115 ProcessVoidEvent( new TEvent( name, value, autoValue ) );
1119 \brief Add boolean setting to the application preferences.
1121 The parameter \a autoValue is obsolete parameter and currently is not used.
1122 This parameter will be removed in future, so try to avoid its usage in
1125 This function is obsolete. Use one of addSetting() instead.
1127 \param name setting name (it should be of kind <section:setting> where
1128 \c section is resources section name and \c setting is setting name)
1129 \param value new setting value
1130 \param autoValue (not used)
1132 void SalomePyQt::addBoolSetting( const QString& name, const bool value, bool autoValue )
1134 class TEvent: public SALOME_Event
1140 TEvent( const QString& name, const bool value, bool autoValue )
1141 : myName( name ), myValue( value ), myAutoValue( autoValue ) {}
1142 virtual void Execute()
1144 if ( SUIT_Session::session() ) {
1145 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1146 QStringList sl = myName.split( ":", QString::SkipEmptyParts );
1147 QString _sec = sl.count() > 1 ? sl[ 0 ].trimmed() : QString( DEFAULT_SECTION );
1148 QString _nam = sl.count() > 1 ? sl[ 1 ].trimmed() : sl.count() > 0 ? sl[ 0 ].trimmed() : QString( "" );
1149 if ( !_sec.isEmpty() && !_nam.isEmpty() )
1150 resMgr->setValue( _sec, _nam, myValue );
1154 ProcessVoidEvent( new TEvent( name, value, autoValue ) );
1158 \brief Remove setting from the application preferences.
1160 This function is obsolete. Use removeSetting() instead.
1162 \param name setting name (it should be of kind <section:setting> where
1163 \c section is resources section name and \c setting is setting name)
1165 void SalomePyQt::removeSettings( const QString& name )
1167 class TEvent: public SALOME_Event
1171 TEvent( const QString& name ) : myName( name ) {}
1172 virtual void Execute()
1174 if ( SUIT_Session::session() ) {
1175 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1176 QStringList sl = myName.split( ":", QString::SkipEmptyParts );
1177 QString _sec = sl.count() > 1 ? sl[ 0 ].trimmed() : QString( DEFAULT_SECTION );
1178 QString _nam = sl.count() > 1 ? sl[ 1 ].trimmed() : sl.count() > 0 ? sl[ 0 ].trimmed() : QString( "" );
1179 if ( !_sec.isEmpty() && !_nam.isEmpty() )
1180 resMgr->remove( _sec, _nam );
1184 ProcessVoidEvent( new TEvent( name ) );
1188 \fn QString SalomePyQt::getSetting( const QString& name );
1189 \brief Get application setting value (as string represenation).
1191 This function is obsolete. Use stringSetting(), integerSetting(),
1192 boolSetting(), stringSetting() or colorSetting() instead.
1194 \param name setting name (it should be of kind <section:setting> where
1195 \c section is resources section name and \c setting is setting name)
1196 \return setting name (empty string if setting name is invalid)
1199 class TGetSettingEvent: public SALOME_Event
1202 typedef QString TResult;
1205 TGetSettingEvent( const QString& name ) : myName( name ) {}
1206 virtual void Execute()
1208 if ( SUIT_Session::session() ) {
1209 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1210 QStringList sl = myName.split( ":", QString::SkipEmptyParts );
1211 QString _sec = sl.count() > 1 ? sl[ 0 ].trimmed() : QString( DEFAULT_SECTION );
1212 QString _nam = sl.count() > 1 ? sl[ 1 ].trimmed() : sl.count() > 0 ? sl[ 0 ].trimmed() : QString( "" );
1213 myResult = ( !_sec.isEmpty() && !_nam.isEmpty() ) ? resMgr->stringValue( _sec, _nam, "" ) : QString( "" );
1217 QString SalomePyQt::getSetting( const QString& name )
1219 return ProcessEvent( new TGetSettingEvent( name ) );
1223 \fn QString SalomePyQt::constant( const QString& name );
1224 \brief Get constant's value from application's resource manager.
1226 \param name name of the constant
1227 \return value of the constant
1232 class TGetConstantEvent: public SALOME_Event
1235 typedef QString TResult;
1238 TGetConstantEvent( const QString& name ) : myName( name ) {}
1239 virtual void Execute()
1241 if ( SUIT_Session::session() )
1242 myResult = SUIT_Session::session()->resourceMgr()->constant( myName );
1245 QString SalomePyQt::constant( const QString& name )
1247 return ProcessEvent( new TGetConstantEvent( name ) );
1251 \brief Add constant to the application's resource manager.
1253 This function is useful to specify programmatically specific
1254 variables that are referenced in the resource setting.
1256 For example, some resource value can be set as "$(myroot)/data/files".
1257 Then, "mypath" constant can be set programmatically by the application
1258 depending on run-time requirements.
1260 \param section resources file section name
1261 \param name name of the constant
1262 \param value value of the constant
1266 void SalomePyQt::setConstant( const QString& name, const QString& value )
1268 class TEvent: public SALOME_Event
1270 QString myName, myValue;
1272 TEvent( const QString& name, const QString& value )
1273 : myName( name ), myValue( value ) {}
1274 virtual void Execute()
1276 if ( SUIT_Session::session() )
1277 SUIT_Session::session()->resourceMgr()->setConstant( myName, myValue );
1280 ProcessVoidEvent( new TEvent( name, value ) );
1284 \brief Add double setting to the application preferences.
1285 \param section resources file section name
1286 \param name setting name
1287 \param value new setting value
1289 void SalomePyQt::addSetting( const QString& section, const QString& name, const double value )
1291 class TEvent: public SALOME_Event
1297 TEvent( const QString& section, const QString& name, double value )
1298 : mySection( section ), myName( name ), myValue( value ) {}
1299 virtual void Execute()
1301 if ( SUIT_Session::session() ) {
1302 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1303 if ( !mySection.isEmpty() && !myName.isEmpty() )
1304 resMgr->setValue( mySection, myName, myValue );
1308 ProcessVoidEvent( new TEvent( section, name, value ) );
1312 \brief Add integer setting to the application preferences.
1313 \param section resources file section name
1314 \param name setting name
1315 \param value new setting value
1317 void SalomePyQt::addSetting( const QString& section, const QString& name, const int value )
1319 class TEvent: public SALOME_Event
1325 TEvent( const QString& section, const QString& name, int value )
1326 : mySection( section ), myName( name ), myValue( value ) {}
1327 virtual void Execute()
1329 if ( SUIT_Session::session() ) {
1330 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1331 if ( !mySection.isEmpty() && !myName.isEmpty() )
1332 resMgr->setValue( mySection, myName, myValue );
1336 ProcessVoidEvent( new TEvent( section, name, value ) );
1340 \brief Add boolean setting to the application preferences.
1341 \param section resources file section name
1342 \param name setting name
1343 \param value new setting value
1344 \param dumb this parameter is used in order to avoid sip compilation error
1345 because of conflicting int and bool types
1347 void SalomePyQt::addSetting( const QString& section, const QString& name, const bool value, const int /*dumb*/ )
1349 class TEvent: public SALOME_Event
1355 TEvent( const QString& section, const QString& name, bool value )
1356 : mySection( section ), myName( name ), myValue( value ) {}
1357 virtual void Execute()
1359 if ( SUIT_Session::session() ) {
1360 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1361 if ( !mySection.isEmpty() && !myName.isEmpty() )
1362 resMgr->setValue( mySection, myName, myValue );
1366 ProcessVoidEvent( new TEvent( section, name, value ) );
1370 \brief Add string setting to the application preferences.
1371 \param section resources file section name
1372 \param name setting name
1373 \param value new setting value
1375 void SalomePyQt::addSetting( const QString& section, const QString& name, const QString& value )
1377 class TEvent: public SALOME_Event
1383 TEvent( const QString& section, const QString& name, const QString& value )
1384 : mySection( section ), myName( name ), myValue( value ) {}
1385 virtual void Execute()
1387 if ( SUIT_Session::session() ) {
1388 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1389 if ( !mySection.isEmpty() && !myName.isEmpty() )
1390 resMgr->setValue( mySection, myName, myValue );
1394 ProcessVoidEvent( new TEvent( section, name, value ) );
1398 \brief Add color setting to the application preferences.
1399 \param section resources file section name
1400 \param name setting name
1401 \param value new setting value
1403 void SalomePyQt::addSetting( const QString& section, const QString& name, const QColor& value )
1405 class TEvent: public SALOME_Event
1411 TEvent( const QString& section, const QString& name, const QColor& value )
1412 : mySection( section ), myName( name ), myValue( value ) {}
1413 virtual void Execute()
1415 if ( SUIT_Session::session() ) {
1416 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1417 if ( !mySection.isEmpty() && !myName.isEmpty() )
1418 resMgr->setValue( mySection, myName, myValue );
1422 ProcessVoidEvent( new TEvent( section, name, value ) );
1426 \brief Add byte array setting to the application preferences.
1427 \param section resources file section name
1428 \param name setting name
1429 \param value new setting value
1431 void SalomePyQt::addSetting( const QString& section, const QString& name, const QByteArray& value )
1433 class TEvent: public SALOME_Event
1439 TEvent( const QString& section, const QString& name, const QByteArray& value )
1440 : mySection( section ), myName( name ), myValue( value ) {}
1441 virtual void Execute()
1443 if ( SUIT_Session::session() ) {
1444 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1445 if ( !mySection.isEmpty() && !myName.isEmpty() )
1446 resMgr->setValue( mySection, myName, myValue );
1450 ProcessVoidEvent( new TEvent( section, name, value ) );
1454 \brief Add font setting to the application preferences.
1455 \param section resources file section name
1456 \param name setting name
1457 \param value new setting value
1459 void SalomePyQt::addSetting( const QString& section, const QString& name, const QFont& value )
1461 class TEvent: public SALOME_Event
1467 TEvent( const QString& section, const QString& name, const QFont& value )
1468 : mySection( section ), myName( name ), myValue( value ) {}
1469 virtual void Execute()
1471 if ( SUIT_Session::session() ) {
1472 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1473 if ( !mySection.isEmpty() && !myName.isEmpty() )
1474 resMgr->setValue( mySection, myName, myValue );
1478 ProcessVoidEvent( new TEvent( section, name, value ) );
1482 \fn int SalomePyQt::integerSetting( const QString& section,
1483 const QString& name,
1485 \brief Get integer setting from the application preferences.
1486 \param section resources file section name
1487 \param name setting name
1488 \param def default value which is returned if the setting is not found
1489 \return setting value
1492 class TGetIntSettingEvent: public SALOME_Event
1495 typedef int TResult;
1500 TGetIntSettingEvent( const QString& section, const QString& name, const int def )
1501 : mySection( section ), myName( name ), myDefault( def ) {}
1502 virtual void Execute()
1504 if ( SUIT_Session::session() ) {
1505 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1506 myResult = ( !mySection.isEmpty() && !myName.isEmpty() ) ? resMgr->integerValue( mySection, myName, myDefault ) : myDefault;
1510 int SalomePyQt::integerSetting( const QString& section, const QString& name, const int def )
1512 return ProcessEvent( new TGetIntSettingEvent( section, name, def ) );
1516 \fn double SalomePyQt::doubleSetting( const QString& section,
1517 const QString& name,
1519 \brief Get double setting from the application preferences.
1520 \param section resources file section name
1521 \param name setting name
1522 \param def default value which is returned if the setting is not found
1523 \return setting value
1526 class TGetDblSettingEvent: public SALOME_Event
1529 typedef double TResult;
1534 TGetDblSettingEvent( const QString& section, const QString& name, const double def )
1535 : mySection( section ), myName( name ), myDefault( def ) {}
1536 virtual void Execute()
1538 if ( SUIT_Session::session() ) {
1539 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1540 myResult = ( !mySection.isEmpty() && !myName.isEmpty() ) ? resMgr->doubleValue( mySection, myName, myDefault ) : myDefault;
1544 double SalomePyQt::doubleSetting( const QString& section, const QString& name, const double def )
1546 return ProcessEvent( new TGetDblSettingEvent( section, name, def ) );
1550 \fn bool SalomePyQt::boolSetting( const QString& section,
1551 const QString& name,
1553 \brief Get boolean setting from the application preferences.
1554 \param section resources file section name
1555 \param name setting name
1556 \param def default value which is returned if the setting is not found
1557 \return setting value
1560 class TGetBoolSettingEvent: public SALOME_Event
1563 typedef bool TResult;
1568 TGetBoolSettingEvent( const QString& section, const QString& name, const bool def )
1569 : mySection( section ), myName( name ), myDefault( def ) {}
1570 virtual void Execute()
1572 if ( SUIT_Session::session() ) {
1573 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1574 myResult = ( !mySection.isEmpty() && !myName.isEmpty() ) ? resMgr->booleanValue( mySection, myName, myDefault ) : myDefault;
1578 bool SalomePyQt::boolSetting( const QString& section, const QString& name, const bool def )
1580 return ProcessEvent( new TGetBoolSettingEvent( section, name, def ) );
1584 \fn QString SalomePyQt::stringSetting( const QString& section,
1585 const QString& name,
1588 \brief Get string setting from the application preferences.
1589 \param section resources file section name
1590 \param name setting name
1591 \param def default value which is returned if the setting is not found
1592 \param subst \c true to make substitution, \c false to get "raw" value
1593 \return setting value
1596 class TGetStrSettingEvent: public SALOME_Event
1599 typedef QString TResult;
1605 TGetStrSettingEvent( const QString& section, const QString& name, const QString& def, const bool subst )
1606 : mySection( section ), myName( name ), myDefault( def ), mySubst( subst ) {}
1607 virtual void Execute()
1609 if ( SUIT_Session::session() ) {
1610 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1611 myResult = ( !mySection.isEmpty() && !myName.isEmpty() ) ? resMgr->stringValue( mySection, myName, myDefault, mySubst ) : myDefault;
1615 QString SalomePyQt::stringSetting( const QString& section, const QString& name, const QString& def, const bool subst )
1617 return ProcessEvent( new TGetStrSettingEvent( section, name, def, subst ) );
1621 \fn QColor SalomePyQt::colorSetting( const QString& section,
1622 const QString& name,
1624 \brief Get color setting from the application preferences.
1625 \param section resources file section name
1626 \param name setting name
1627 \param def default value which is returned if the setting is not found
1628 \return setting value
1631 class TGetColorSettingEvent: public SALOME_Event
1634 typedef QColor TResult;
1639 TGetColorSettingEvent( const QString& section, const QString& name, const QColor& def )
1640 : mySection( section ), myName( name ), myDefault( def ) {}
1641 virtual void Execute()
1643 if ( SUIT_Session::session() ) {
1644 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1645 myResult = ( !mySection.isEmpty() && !myName.isEmpty() ) ? resMgr->colorValue( mySection, myName, myDefault ) : myDefault;
1649 QColor SalomePyQt::colorSetting ( const QString& section, const QString& name, const QColor& def )
1651 return ProcessEvent( new TGetColorSettingEvent( section, name, def ) );
1655 \fn QByteArray SalomePyQt::byteArraySetting( const QString& section,
1656 const QString& name,
1657 const QByteArray& def );
1658 \brief Get byte array setting from the application preferences.
1659 \param section resources file section name
1660 \param name setting name
1661 \param def default value which is returned if the setting is not found
1662 \return setting value
1665 class TGetByteArraySettingEvent: public SALOME_Event
1668 typedef QByteArray TResult;
1673 TGetByteArraySettingEvent( const QString& section, const QString& name, const QByteArray& def )
1674 : mySection( section ), myName( name ), myDefault( def ) {}
1675 virtual void Execute()
1677 if ( SUIT_Session::session() ) {
1678 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1679 myResult = ( !mySection.isEmpty() && !myName.isEmpty() ) ? resMgr->byteArrayValue( mySection, myName, myDefault ) : myDefault;
1683 QByteArray SalomePyQt::byteArraySetting ( const QString& section, const QString& name, const QByteArray& def )
1685 return ProcessEvent( new TGetByteArraySettingEvent( section, name, def ) );
1689 \fn QByteArray SalomePyQt::fontSetting( const QString& section,
1690 const QString& name,
1692 \brief Get font setting from the application preferences.
1693 \param section resources file section name
1694 \param name setting name
1695 \param def default value which is returned if the setting is not found
1696 \return setting value
1699 class TGetFontSettingEvent: public SALOME_Event
1702 typedef QFont TResult;
1707 TGetFontSettingEvent( const QString& section, const QString& name, const QFont& def )
1708 : mySection( section ), myName( name ), myDefault( def ) {}
1709 virtual void Execute()
1711 if ( SUIT_Session::session() ) {
1712 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1713 myResult = ( !mySection.isEmpty() && !myName.isEmpty() ) ? resMgr->fontValue( mySection, myName, myDefault ) : myDefault;
1717 QFont SalomePyQt::fontSetting ( const QString& section, const QString& name, const QFont& def )
1719 return ProcessEvent( new TGetFontSettingEvent( section, name, def ) );
1723 \brief Remove setting from the application preferences.
1724 \param section resources file section name
1725 \param name setting name
1727 void SalomePyQt::removeSetting( const QString& section, const QString& name )
1729 class TEvent: public SALOME_Event
1734 TEvent( const QString& section, const QString& name ) : mySection( section ), myName( name ) {}
1735 virtual void Execute()
1737 if ( SUIT_Session::session() ) {
1738 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1739 if ( !mySection.isEmpty() && !myName.isEmpty() )
1740 resMgr->remove( mySection, myName );
1744 ProcessVoidEvent( new TEvent( section, name ) );
1748 \fn bool SalomePyQt::hasSetting( const QString& section, const QString& name );
1749 \brief Check setting existence in the application preferences.
1750 \param section resources file section name
1751 \param name setting name
1752 \return \c true if setting exists
1755 class THasSettingEvent: public SALOME_Event
1758 typedef bool TResult;
1762 THasSettingEvent( const QString& section, const QString& name )
1763 : mySection( section ), myName( name ) {}
1764 virtual void Execute()
1766 if ( SUIT_Session::session() ) {
1767 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1768 myResult = resMgr->hasValue( mySection, myName );
1772 bool SalomePyQt::hasSetting( const QString& section, const QString& name )
1774 return ProcessEvent( new THasSettingEvent( section, name ) );
1778 \fn QStringList SalomePyQt::parameters( const QString& section );
1779 \brief Get names of preference items stored within the given section.
1780 \param section resources file section's name
1781 \return \c list of preferences items
1785 \fn QStringList SalomePyQt::parameters( const QStringList& section );
1786 \brief Get names of preference items stored within the given section.
1787 \param section resources file section's name
1788 \return \c list of preferences items
1791 class TParametersEvent: public SALOME_Event
1794 typedef QStringList TResult;
1796 QStringList mySection;
1797 TParametersEvent( const QString& section )
1799 mySection << section;
1801 TParametersEvent( const QStringList& section )
1802 : mySection( section )
1804 virtual void Execute()
1806 if ( SUIT_Session::session() ) {
1807 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1808 myResult = resMgr->parameters( mySection );
1812 QStringList SalomePyQt::parameters( const QString& section )
1814 return ProcessEvent( new TParametersEvent( section ) );
1816 QStringList SalomePyQt::parameters( const QStringList& section )
1818 return ProcessEvent( new TParametersEvent( section ) );
1822 \fn QString SalomePyQt::getFileName( QWidget* parent,
1823 const QString& initial,
1824 const QStringList& filters,
1825 const QString& caption,
1827 \brief Show 'Open/Save file' dialog box for file selection
1828 and return a user's choice (selected file name).
1829 \param parent parent widget
1830 \param initial initial directory the dialog box to be opened in
1831 \param filters list of files filters (wildcards)
1832 \param caption dialog box title
1833 \param open if \c true, "Open File" dialog box is shown;
1834 otherwise "Save File" dialog box is shown
1835 \return selected file name (null string if user cancels operation)
1838 class TGetFileNameEvent: public SALOME_Event
1841 typedef QString TResult;
1845 QStringList myFilters;
1848 TGetFileNameEvent( QWidget* parent,
1849 const QString& initial,
1850 const QStringList& filters,
1851 const QString& caption,
1853 : myParent ( parent ),
1854 myInitial( initial ),
1855 myFilters( filters ),
1856 myCaption( caption ),
1858 virtual void Execute()
1860 if ( LightApp_Application* anApp = getApplication() ) {
1861 myResult = anApp->getFileName( myOpen, myInitial, myFilters.join(";;"),
1862 myCaption, myParent );
1866 QString SalomePyQt::getFileName( QWidget* parent,
1867 const QString& initial,
1868 const QStringList& filters,
1869 const QString& caption,
1872 return ProcessEvent( new TGetFileNameEvent( parent, initial, filters, caption, open ) );
1876 \fn QStringList SalomePyQt::getOpenFileNames( QWidget* parent,
1877 const QString& initial,
1878 const QStringList& filters,
1879 const QString& caption );
1880 \brief Show 'Open files' dialog box for multiple files selection
1881 and return a user's choice (selected file names list).
1882 \param parent parent widget
1883 \param initial initial directory the dialog box to be opened in
1884 \param filters list of files filters (wildcards)
1885 \param caption dialog box title
1886 \return selected file names list (empty list if user cancels operation)
1889 class TGetOpenFileNamesEvent: public SALOME_Event
1892 typedef QStringList TResult;
1896 QStringList myFilters;
1898 TGetOpenFileNamesEvent( QWidget* parent,
1899 const QString& initial,
1900 const QStringList& filters,
1901 const QString& caption )
1902 : myParent ( parent ),
1903 myInitial( initial ),
1904 myFilters( filters ),
1905 myCaption( caption ) {}
1906 virtual void Execute()
1908 if ( LightApp_Application* anApp = getApplication() ) {
1909 myResult = anApp->getOpenFileNames( myInitial, myFilters.join(";;"), myCaption, myParent );
1913 QStringList SalomePyQt::getOpenFileNames( QWidget* parent,
1914 const QString& initial,
1915 const QStringList& filters,
1916 const QString& caption )
1918 return ProcessEvent( new TGetOpenFileNamesEvent( parent, initial, filters, caption ) );
1922 \fn QString SalomePyQt::getExistingDirectory( QWidget* parent,
1923 const QString& initial,
1924 const QString& caption );
1925 \brief Show 'Get Directory' dialog box for the directory selection
1926 and return a user's choice (selected directory name).
1927 \param parent parent widget
1928 \param initial initial directory the dialog box to be opened in
1929 \param caption dialog box title
1930 \return selected directory name (null string if user cancels operation)
1933 class TGetExistingDirectoryEvent: public SALOME_Event
1936 typedef QString TResult;
1941 TGetExistingDirectoryEvent( QWidget* parent,
1942 const QString& initial,
1943 const QString& caption )
1944 : myParent ( parent ),
1945 myInitial( initial ),
1946 myCaption( caption ) {}
1947 virtual void Execute()
1949 if ( LightApp_Application* anApp = getApplication() ) {
1950 myResult = anApp->getDirectory( myInitial, myCaption, myParent );
1954 QString SalomePyQt::getExistingDirectory( QWidget* parent,
1955 const QString& initial,
1956 const QString& caption )
1958 return ProcessEvent( new TGetExistingDirectoryEvent( parent, initial, caption ) );
1962 \fn QString SalomePyQt::loadIcon( const QString& filename );
1963 \brief Load an icon from the module resources by the specified file name.
1964 \param fileName icon file name
1968 class TLoadIconEvent: public SALOME_Event
1971 typedef QIcon TResult;
1975 TLoadIconEvent( const QString& module, const QString& filename )
1976 : myModule( module ),
1977 myFileName ( filename ) {}
1978 virtual void Execute()
1980 myResult = loadIconInternal( myModule, myFileName );
1983 QIcon SalomePyQt::loadIcon( const QString& module, const QString& filename )
1985 return ProcessEvent( new TLoadIconEvent( module, filename ) );
1989 \brief Open external browser to display context help information.
1992 Current implementation does nothing.
1994 \param source documentation (HTML) file name
1995 \param context context (for example, HTML ancor name)
1997 void SalomePyQt::helpContext( const QString& source, const QString& context )
1999 class TEvent: public SALOME_Event
2004 TEvent( const QString& source, const QString& context )
2005 : mySource( source ), myContext( context ) {}
2006 virtual void Execute()
2008 if ( LightApp_Application* anApp = getApplication() ) {
2009 anApp->onHelpContextModule( "", mySource, myContext );
2013 ProcessVoidEvent( new TEvent( source, context ) );
2017 \fn int SalomePyQt::defaultMenuGroup();
2018 \brief Get detault menu group identifier which can be used when
2019 creating menus (insert custom menu commands).
2020 \return default menu group ID
2023 class TDefMenuGroupEvent: public SALOME_Event
2026 typedef int TResult;
2028 TDefMenuGroupEvent() : myResult( -1 ) {}
2029 virtual void Execute()
2031 myResult = PyModuleHelper::defaultMenuGroup();
2034 int SalomePyQt::defaultMenuGroup()
2036 return ProcessEvent( new TDefMenuGroupEvent() );
2042 CrTool( const QString& tBar, const QString& nBar )
2043 : myCase( 0 ), myTbTitle( tBar ), myTbName( nBar) {}
2044 CrTool( const int id, const int tBar, const int idx )
2045 : myCase( 1 ), myId( id ), myTbId( tBar ), myIndex( idx ) {}
2046 CrTool( const int id, const QString& tBar, const int idx )
2047 : myCase( 2 ), myId( id ), myTbTitle( tBar ), myIndex( idx ) {}
2048 CrTool( QAction* action, const int tbId, const int id, const int idx )
2049 : myCase( 3 ), myAction( action ), myTbId( tbId ), myId( id ), myIndex( idx ) {}
2050 CrTool( QAction* action, const QString& tBar, const int id, const int idx )
2051 : myCase( 4 ), myAction( action ), myTbTitle( tBar ), myId( id ), myIndex( idx ) {}
2053 int execute( LightApp_Module* module ) const
2058 return module->createTool( myTbTitle, myTbName );
2060 return module->createTool( myId, myTbId, myIndex );
2062 return module->createTool( myId, myTbTitle, myIndex );
2064 return module->createTool( myAction, myTbId, myId, myIndex );
2066 return module->createTool( myAction, myTbTitle, myId, myIndex );
2081 class TCreateToolEvent: public SALOME_Event
2084 typedef int TResult;
2086 const CrTool& myCrTool;
2087 TCreateToolEvent( const CrTool& crTool )
2088 : myResult( -1 ), myCrTool( crTool ) {}
2089 virtual void Execute()
2091 LightApp_Module* module = getActiveModule();
2093 myResult = myCrTool.execute( module );
2098 \brief Create toolbar with specified name.
2099 \param tBar toolbar title (language-dependent)
2100 \param nBar toolbar name (language-independent) [optional]
2101 \return toolbar ID or -1 if toolbar creation is failed
2103 int SalomePyQt::createTool( const QString& tBar, const QString& nBar )
2105 return ProcessEvent( new TCreateToolEvent( CrTool( tBar, nBar ) ) );
2109 \brief Insert action with specified \a id to the toolbar.
2111 \param tBar toolbar ID
2112 \param idx required index in the toolbar
2113 \return action ID or -1 if action could not be added
2115 int SalomePyQt::createTool( const int id, const int tBar, const int idx )
2117 return ProcessEvent( new TCreateToolEvent( CrTool( id, tBar, idx ) ) );
2121 \brief Insert action with specified \a id to the toolbar.
2123 \param tBar toolbar name
2124 \param idx required index in the toolbar
2125 \return action ID or -1 if action could not be added
2127 int SalomePyQt::createTool( const int id, const QString& tBar, const int idx )
2129 return ProcessEvent( new TCreateToolEvent( CrTool( id, tBar, idx ) ) );
2133 \brief Insert action to the toolbar.
2135 \param tBar toolbar ID
2136 \param id required action ID
2137 \param idx required index in the toolbar
2138 \return action ID or -1 if action could not be added
2140 int SalomePyQt::createTool( QAction* a, const int tBar, const int id, const int idx )
2142 return ProcessEvent( new TCreateToolEvent( CrTool( a, tBar, id, idx ) ) );
2146 \brief Insert action to the toolbar.
2148 \param tBar toolbar name
2149 \param id required action ID
2150 \param idx required index in the toolbar
2151 \return action ID or -1 if action could not be added
2153 int SalomePyQt::createTool( QAction* a, const QString& tBar, const int id, const int idx )
2155 return ProcessEvent( new TCreateToolEvent( CrTool( a, tBar, id, idx ) ) );
2161 CrMenu( const QString& subMenu, const int menu, const int id, const int group, const int idx )
2162 : myCase( 0 ), mySubMenuName( subMenu ), myMenuId( menu ), myId( id ), myGroup( group ), myIndex( idx ) {}
2163 CrMenu( const QString& subMenu, const QString& menu, const int id, const int group, const int idx )
2164 : myCase( 1 ), mySubMenuName( subMenu ), myMenuName( menu ), myId( id ), myGroup( group ), myIndex( idx ) {}
2165 CrMenu( const int id, const int menu, const int group, const int idx )
2166 : myCase( 2 ), myId( id ), myMenuId( menu ), myGroup( group ), myIndex( idx ) {}
2167 CrMenu( const int id, const QString& menu, const int group, const int idx )
2168 : myCase( 3 ), myId( id ), myMenuName( menu ), myGroup( group ), myIndex( idx ) {}
2169 CrMenu( QAction* action, const int menu, const int id, const int group, const int idx )
2170 : myCase( 4 ), myAction( action ), myMenuId( menu ), myId( id ), myGroup( group ), myIndex( idx ) {}
2171 CrMenu( QAction* action, const QString& menu, const int id, const int group, const int idx )
2172 : myCase( 5 ), myAction( action ), myMenuName( menu ), myId( id ), myGroup( group ), myIndex( idx ) {}
2174 int execute( LightApp_Module* module ) const
2179 return module->createMenu( mySubMenuName, myMenuId, myId, myGroup, myIndex );
2181 return module->createMenu( mySubMenuName, myMenuName, myId, myGroup, myIndex );
2183 return module->createMenu( myId, myMenuId, myGroup, myIndex );
2185 return module->createMenu( myId, myMenuName, myGroup, myIndex );
2187 return module->createMenu( myAction, myMenuId, myId, myGroup, myIndex );
2189 return module->createMenu( myAction, myMenuName, myId, myGroup, myIndex );
2198 QString mySubMenuName;
2205 class TCreateMenuEvent: public SALOME_Event
2208 typedef int TResult;
2210 const CrMenu& myCrMenu;
2211 TCreateMenuEvent( const CrMenu& crMenu )
2212 : myResult( -1 ), myCrMenu( crMenu ) {}
2213 virtual void Execute()
2215 LightApp_Module* module = getActiveModule();
2217 myResult = myCrMenu.execute( module );
2222 \brief Create main menu.
2223 \param subMenu menu name
2224 \param menu parent menu ID
2225 \param id required menu ID
2226 \param group menu group ID
2227 \param idx required index in the menu
2228 \return menu ID or -1 if menu could not be added
2230 int SalomePyQt::createMenu( const QString& subMenu, const int menu, const int id, const int group, const int idx )
2232 return ProcessEvent( new TCreateMenuEvent( CrMenu( subMenu, menu, id, group, idx ) ) );
2236 \brief Create main menu.
2237 \param subMenu menu name
2238 \param menu parent menu name (list of menu names separated by "|")
2239 \param id required menu ID
2240 \param group menu group ID
2241 \param idx required index in the menu
2242 \return menu ID or -1 if menu could not be added
2244 int SalomePyQt::createMenu( const QString& subMenu, const QString& menu, const int id, const int group, const int idx )
2246 return ProcessEvent( new TCreateMenuEvent( CrMenu( subMenu, menu, id, group, idx ) ) );
2250 \brief Insert action to the main menu.
2252 \param menu parent menu ID
2253 \param group menu group ID
2254 \param idx required index in the menu
2255 \return action ID or -1 if action could not be added
2257 int SalomePyQt::createMenu( const int id, const int menu, const int group, const int idx )
2259 return ProcessEvent( new TCreateMenuEvent( CrMenu( id, menu, group, idx ) ) );
2263 \brief Insert action to the main menu.
2265 \param menu parent menu name (list of menu names separated by "|")
2266 \param group menu group ID
2267 \param idx required index in the menu
2268 \return action ID or -1 if action could not be added
2270 int SalomePyQt::createMenu( const int id, const QString& menu, const int group, const int idx )
2272 return ProcessEvent( new TCreateMenuEvent( CrMenu( id, menu, group, idx ) ) );
2276 \brief Insert action to the main menu.
2278 \param menu parent menu ID
2279 \param group menu group ID
2280 \param idx required index in the menu
2281 \return action ID or -1 if action could not be added
2283 int SalomePyQt::createMenu( QAction* a, const int menu, const int id, const int group, const int idx )
2285 return ProcessEvent( new TCreateMenuEvent( CrMenu( a, menu, id, group, idx ) ) );
2289 \brief Insert action to the main menu.
2291 \param menu parent menu name (list of menu names separated by "|")
2292 \param group menu group ID
2293 \param idx required index in the menu
2294 \return action ID or -1 if action could not be added
2296 int SalomePyQt::createMenu( QAction* a, const QString& menu, const int id, const int group, const int idx )
2298 return ProcessEvent( new TCreateMenuEvent( CrMenu( a, menu, id, group, idx ) ) );
2302 \fn QAction* SalomePyQt::createSeparator();
2303 \brief Create separator action which can be used in the menu or toolbar.
2304 \return new separator action
2307 class TCreateSepEvent: public SALOME_Event
2310 typedef QAction* TResult;
2314 virtual void Execute()
2316 LightApp_Module* module = getActiveModule();
2318 myResult = (QAction*)module->separator();
2321 QAction* SalomePyQt::createSeparator()
2323 return ProcessEvent( new TCreateSepEvent() );
2327 \fn QAction* SalomePyQt::createAction( const int id,
2328 const QString& menuText,
2329 const QString& tipText,
2330 const QString& statusText,
2331 const QString& icon,
2333 const bool toggle );
2334 \brief Create an action which can be then used in the menu or toolbar.
2335 \param id the unique id action to be registered to
2336 \param menuText action text which should appear in menu
2337 \param tipText text which should appear in the tooltip
2338 \param statusText text which should appear in the status bar when action is activated
2339 \param icon the name of the icon file (the actual icon file name can be coded in the translation files)
2340 \param key the key accelrator for the action
2341 \param toggle if \c true the action is checkable
2344 class TCreateActionEvent: public SALOME_Event
2347 typedef QAction* TResult;
2352 QString myStatusText;
2356 TCreateActionEvent( const int id, const QString& menuText, const QString& tipText,
2357 const QString& statusText, const QString& icon, const int key, const bool toggle )
2358 : myResult( 0 ), myId( id ), myMenuText( menuText ), myTipText( tipText ),
2359 myStatusText( statusText ), myIcon( icon ), myKey( key ), myToggle( toggle ) {}
2360 virtual void Execute()
2362 LightApp_Module* module = getActiveModule();
2364 QIcon icon = loadIconInternal( module->name(), myIcon );
2365 myResult = (QAction*)module->action( myId );
2367 if ( myResult->toolTip().isEmpty() && !myTipText.isEmpty() )
2368 myResult->setToolTip( myTipText );
2369 if ( myResult->text().isEmpty() && !myMenuText.isEmpty() )
2370 myResult->setText( myMenuText );
2371 if ( myResult->icon().isNull() && !icon.isNull() )
2372 myResult->setIcon( icon );
2373 if ( myResult->statusTip().isEmpty() && !myStatusText.isEmpty() )
2374 myResult->setStatusTip( myStatusText );
2375 if ( myResult->shortcut().isEmpty() && myKey )
2376 myResult->setShortcut( myKey );
2377 if ( myResult->isCheckable() != myToggle )
2378 myResult->setCheckable( myToggle );
2381 myResult = (QAction*)module->createAction( myId, myTipText, icon, myMenuText, myStatusText, myKey, module, myToggle );
2383 // for Python module, automatically connect action to callback slot
2384 PyModuleHelper* helper = module->findChild<PyModuleHelper*>( "python_module_helper" );
2385 if ( helper ) helper->connectAction( myResult );
2389 QAction* SalomePyQt::createAction( const int id, const QString& menuText,
2390 const QString& tipText, const QString& statusText,
2391 const QString& icon, const int key, const bool toggle )
2393 return ProcessEvent( new TCreateActionEvent( id, menuText, tipText, statusText, icon, key, toggle ) );
2397 \fn QtxActionGroup* SalomePyQt::createActionGroup( const int id, const bool exclusive );
2398 \brief Create an action group which can be then used in the menu or toolbar
2399 \param id : the unique id action group to be registered to
2400 \param exclusive : if \c true the action group does exclusive toggling
2403 struct TCreateActionGroupEvent: public SALOME_Event
2405 typedef QtxActionGroup* TResult;
2409 TCreateActionGroupEvent( const int id, const bool exclusive )
2410 : myId( id ), myExclusive( exclusive ) {}
2411 virtual void Execute()
2413 LightApp_Module* module = getActiveModule();
2415 myResult = module->createActionGroup( myId, myExclusive );
2418 QtxActionGroup* SalomePyQt::createActionGroup( const int id, const bool exclusive )
2420 return ProcessEvent( new TCreateActionGroupEvent( id, exclusive ) );
2424 \fn QAction* SalomePyQt::action( const int id );
2425 \brief Get action by specified identifier.
2426 \return action or 0 if action is not registered
2429 class TActionEvent: public SALOME_Event
2432 typedef QAction* TResult;
2435 TActionEvent( const int id )
2436 : myResult( 0 ), myId( id ) {}
2437 virtual void Execute()
2439 LightApp_Module* module = getActiveModule();
2441 myResult = (QAction*)module->action( myId );
2444 QAction* SalomePyQt::action( const int id )
2446 return ProcessEvent( new TActionEvent( id ) );
2450 \fn int SalomePyQt::actionId( const QAction* a );
2451 \brief Get an action identifier.
2452 \return action ID or -1 if action is not registered
2455 class TActionIdEvent: public SALOME_Event
2458 typedef int TResult;
2460 const QAction* myAction;
2461 TActionIdEvent( const QAction* action )
2462 : myResult( -1 ), myAction( action ) {}
2463 virtual void Execute()
2465 LightApp_Module* module = getActiveModule();
2467 myResult = module->actionId( myAction );
2470 int SalomePyQt::actionId( const QAction* a )
2472 return ProcessEvent( new TActionIdEvent( a ) );
2476 \fn int SalomePyQt::addGlobalPreference( const QString& label );
2477 \brief Add global (not module-related) preferences group.
2478 \param label global preferences group name
2479 \return preferences group identifier
2482 class TAddGlobalPrefEvent: public SALOME_Event
2485 typedef int TResult;
2488 TAddGlobalPrefEvent( const QString& label )
2489 : myResult( -1 ), myLabel( label ) {}
2490 virtual void Execute()
2492 LightApp_Module* module = getActiveModule();
2494 LightApp_Preferences* pref = module->getApp()->preferences();
2496 myResult = pref->addPreference( myLabel, -1 );
2500 int SalomePyQt::addGlobalPreference( const QString& label )
2502 return ProcessEvent( new TAddGlobalPrefEvent( label ) );
2506 \fn int SalomePyQt::addPreference( const QString& label );
2507 \brief Add module-related preferences group.
2508 \param label preferences group name
2509 \return preferences group identifier
2512 class TAddPrefEvent: public SALOME_Event
2515 typedef int TResult;
2518 TAddPrefEvent( const QString& label )
2519 : myResult( -1 ), myLabel( label ) {}
2520 virtual void Execute()
2522 LightApp_Module* module = getActiveModule();
2524 LightApp_Preferences* pref = module->getApp()->preferences();
2526 int cId = pref->addPreference( module->moduleName(), -1 );
2528 myResult = pref->addPreference( myLabel, cId );
2533 int SalomePyQt::addPreference( const QString& label )
2535 return ProcessEvent( new TAddPrefEvent( label ) );
2539 \fn int SalomePyQt::addPreference( const QString& label, const int pId, const int type,
2540 const QString& section, const QString& param );
2541 \brief Add module-related preferences.
2542 \param label preferences group name
2543 \param pId parent preferences group id
2544 \param type preferences type
2545 \param section resources file section name
2546 \param param resources file setting name
2547 \return preferences identifier
2550 class TAddPrefParamEvent: public SALOME_Event
2553 typedef int TResult;
2560 TAddPrefParamEvent( const QString& label,
2561 const int pId, const int type,
2562 const QString& section,
2563 const QString& param )
2565 myLabel( label ), myPId( pId ), myType( type ),
2566 mySection( section ), myParam ( param ) {}
2567 virtual void Execute()
2569 LightApp_Module* module = getActiveModule();
2571 LightApp_Preferences* pref = module->getApp()->preferences();
2573 myResult = pref->addPreference( module->moduleName(), myLabel, myPId, myType, mySection, myParam );
2577 int SalomePyQt::addPreference( const QString& label, const int pId, const int type,
2578 const QString& section, const QString& param )
2580 return ProcessEvent( new TAddPrefParamEvent( label, pId, type, section, param ) );
2584 \fn QVariant SalomePyQt::preferenceProperty( const int id, const QString& prop );
2585 \brief Get the preferences property.
2586 \param id preferences identifier
2587 \param prop preferences property name
2588 \return preferences property value or null QVariant if property is not set
2591 class TPrefPropEvent: public SALOME_Event
2594 typedef QVariant TResult;
2598 TPrefPropEvent( const int id, const QString& prop )
2599 : myId( id ), myProp( prop ) {}
2600 virtual void Execute()
2602 LightApp_Module* module = getActiveModule();
2604 LightApp_Preferences* pref = module->getApp()->preferences();
2606 myResult = pref->itemProperty( myProp, myId );
2610 QVariant SalomePyQt::preferenceProperty( const int id, const QString& prop )
2612 return ProcessEvent( new TPrefPropEvent( id, prop ) );
2616 \brief Set the preferences property.
2617 \param id preferences identifier
2618 \param prop preferences property name
2619 \param var preferences property value
2621 void SalomePyQt::setPreferenceProperty( const int id,
2622 const QString& prop,
2623 const QVariant& var )
2625 class TEvent: public SALOME_Event
2631 TEvent( const int id, const QString& prop, const QVariant& var )
2632 : myId( id ), myProp( prop ), myVar( var ) {}
2633 virtual void Execute()
2635 LightApp_Module* module = getActiveModule();
2637 LightApp_Preferences* pref = module->getApp()->preferences();
2639 pref->setItemProperty( myProp, myVar, myId );
2643 ProcessVoidEvent( new TEvent( id, prop, var ) );
2647 \brief Set specific widget as a custom preferences item.
2648 \param id preferences identifier
2649 \param prop preferences property name
2650 \param widget custom widget
2652 void SalomePyQt::setPreferencePropertyWg( const int id,
2653 const QString& prop,
2654 UserDefinedContent* widget )
2656 class TEvent: public SALOME_Event
2660 UserDefinedContent* myWidget;
2662 TEvent( const int id, const QString& prop, UserDefinedContent* widget )
2663 : myId( id ), myProp( prop ), myWidget( widget ) {}
2664 virtual void Execute()
2666 LightApp_Module* module = getActiveModule();
2668 LightApp_Preferences* pref = module->getApp()->preferences();
2670 pref->setItemProperty( myProp, (qint64) new SgPyQtUserDefinedContent( myWidget ), myId );
2675 ProcessVoidEvent( new TEvent( id, prop, widget ) );
2679 \brief Add the property value to the list of values.
2681 This method allows creating properties which are QList<QVariant>
2682 - there is no way to pass such values directly to QVariant parameter with PyQt.
2684 \param id preferences identifier
2685 \param prop preferences property name
2686 \param idx preferences property index
2687 \param var preferences property value for the index \a idx
2689 void SalomePyQt::addPreferenceProperty( const int id,
2690 const QString& prop,
2692 const QVariant& var )
2694 class TEvent: public SALOME_Event
2701 TEvent( const int id, const QString& prop, const int idx, const QVariant& var )
2702 : myId( id ), myProp( prop ), myIdx( idx), myVar( var ) {}
2703 virtual void Execute()
2705 LightApp_Module* module = getActiveModule();
2707 LightApp_Preferences* pref = module->getApp()->preferences();
2709 QVariant var = pref->itemProperty( myProp, myId );
2710 if ( var.isValid() ) {
2711 if ( var.type() == QVariant::StringList ) {
2712 QStringList sl = var.toStringList();
2713 if ( myIdx >= 0 && myIdx < sl.count() )
2714 sl[myIdx] = myVar.toString();
2716 sl.append( myVar.toString() );
2717 pref->setItemProperty( myProp, sl, myId );
2719 else if ( var.type() == QVariant::List ) {
2720 QList<QVariant> vl = var.toList();
2721 if ( myIdx >= 0 && myIdx < vl.count() )
2725 pref->setItemProperty( myProp, vl, myId );
2731 pref->setItemProperty( myProp, vl, myId );
2737 ProcessVoidEvent( new TEvent( id, prop, idx, var) );
2741 \brief Put the message to the Log messages output window
2742 \param msg message text (it can be of simple rich text format)
2743 \param addSeparator boolean flag which specifies if it is necessary
2744 to separate the message with predefined separator
2746 void SalomePyQt::message( const QString& msg, bool addSeparator )
2748 class TEvent: public SALOME_Event
2753 TEvent( const QString& msg, bool addSeparator )
2754 : myMsg( msg ), myAddSep( addSeparator ) {}
2755 virtual void Execute()
2757 if ( LightApp_Application* anApp = getApplication() ) {
2758 LogWindow* lw = anApp->logWindow();
2760 lw->putMessage( myMsg, myAddSep );
2764 ProcessVoidEvent( new TEvent( msg, addSeparator ) );
2768 \brief Remove all the messages from the Log messages output window.
2770 void SalomePyQt::clearMessages()
2772 class TEvent: public SALOME_Event
2776 virtual void Execute()
2778 if ( LightApp_Application* anApp = getApplication() ) {
2779 LogWindow* lw = anApp->logWindow();
2785 ProcessVoidEvent( new TEvent() );
2789 \fn bool SalomePyQt::dumpView( const QString& filename, const int id = 0 );
2790 \brief Dump the contents of the id view window. If id is 0 then current active view is processed.
2791 to the image file in the specified format.
2793 For the current moment JPEG, PNG and BMP images formats are supported.
2794 The image format is defined automatically by the file name extension.
2795 By default, BMP format is used.
2797 \param filename image file name
2798 \return operation status (\c true on success)
2801 class TDumpViewEvent: public SALOME_Event
2804 typedef bool TResult;
2808 TDumpViewEvent( const QString& filename, const int id )
2809 : myResult ( false ), myFileName( filename ), myWndId( id ) {}
2810 virtual void Execute()
2812 SUIT_ViewWindow* wnd = 0;
2814 if ( LightApp_Application* anApp = getApplication() ) {
2815 SUIT_ViewManager* vm = anApp->activeViewManager();
2817 wnd = vm->getActiveView();
2819 myWndId = wnd->getId();
2822 wnd = dynamic_cast<SUIT_ViewWindow*>( getWnd( myWndId ) );
2825 QString fmt = SUIT_Tools::extension( myFileName ).toUpper();
2826 #ifndef DISABLE_PLOT2DVIEWER
2827 Plot2d_ViewWindow* wnd2D = dynamic_cast<Plot2d_ViewWindow*>( wnd );
2829 qApp->postEvent( wnd2D->getViewFrame(), new QPaintEvent( QRect( 0, 0, wnd2D->getViewFrame()->width(), wnd2D->getViewFrame()->height() ) ) );
2830 qApp->postEvent( wnd2D, new QPaintEvent( QRect( 0, 0, wnd2D->width(), wnd2D->height() ) ) );
2831 qApp->processEvents();
2832 if ( fmt == "PS" || fmt == "EPS" || fmt == "PDF" ) {
2833 myResult = wnd2D->getViewFrame()->print( myFileName, fmt );
2837 #endif // DISABLE_PLOT2DVIEWER
2838 QImage im = wnd->dumpView();
2839 if ( !im.isNull() && !myFileName.isEmpty() ) {
2840 if ( fmt.isEmpty() ) fmt = QString( "BMP" ); // default format
2841 if ( fmt == "JPG" ) fmt = "JPEG";
2842 myResult = im.save( myFileName, fmt.toLatin1() );
2847 bool SalomePyQt::dumpView( const QString& filename, const int id )
2849 return ProcessEvent( new TDumpViewEvent( filename, id ) );
2853 \fn QList<int> SalomePyQt::getViews();
2854 \brief Get list of integer identifiers of all the currently opened views
2855 \return list of integer identifiers of all the currently opened views
2858 class TGetViews: public SALOME_Event
2861 typedef QList<int> TResult;
2864 virtual void Execute()
2867 LightApp_Application* app = getApplication();
2869 STD_TabDesktop* tabDesk = dynamic_cast<STD_TabDesktop*>( app->desktop() );
2871 QList<SUIT_ViewWindow*> wndlist = tabDesk->windows();
2872 SUIT_ViewWindow* wnd;
2873 foreach ( wnd, wndlist )
2874 myResult.append( wnd->getId() );
2879 QList<int> SalomePyQt::getViews()
2881 return ProcessEvent( new TGetViews() );
2885 \fn int SalomePyQt::getActiveView();
2886 \brief Get integer identifier of the currently active view
2887 \return integer identifier of the currently active view
2890 class TGetActiveView: public SALOME_Event
2893 typedef int TResult;
2897 virtual void Execute()
2899 LightApp_Application* app = getApplication();
2901 SUIT_ViewManager* viewMgr = app->activeViewManager();
2903 SUIT_ViewWindow* wnd = viewMgr->getActiveView();
2905 myResult = wnd->getId();
2910 int SalomePyQt::getActiveView()
2912 return ProcessEvent( new TGetActiveView() );
2916 \fn QString SalomePyQt::getViewType( const int id );
2917 \brief Get type of the specified view, e.g. "OCCViewer"
2918 \param id window identifier
2922 class TGetViewType: public SALOME_Event
2925 typedef QString TResult;
2928 TGetViewType( const int id )
2930 virtual void Execute()
2932 SUIT_ViewWindow* wnd = getWnd( myWndId );
2934 SUIT_ViewManager* viewMgr = wnd->getViewManager();
2936 myResult = viewMgr->getType();
2940 QString SalomePyQt::getViewType( const int id )
2942 return ProcessEvent( new TGetViewType( id ) );
2946 \fn bool SalomePyQt::setViewTitle( const int id, const QString& title );
2947 \brief Change view caption
2948 \param id window identifier
2949 \param title new window title
2950 \return \c true if operation is completed successfully and \c false otherwise
2953 class TSetViewTitle: public SALOME_Event
2956 typedef bool TResult;
2960 TSetViewTitle( const int id, const QString& title )
2961 : myResult( false ),
2964 virtual void Execute()
2966 SUIT_ViewWindow* wnd = getWnd( myWndId );
2968 wnd->setWindowTitle( myTitle );
2973 bool SalomePyQt::setViewTitle( const int id, const QString& title )
2975 return ProcessEvent( new TSetViewTitle( id, title ) );
2979 \fn bool SalomePyQt::setViewSize( const int w, const int h, const int id );
2980 \brief Set view size
2981 \param w window width
2982 \param h window height
2983 \param id window identifier
2984 \return \c true if operation is completed successfully and \c false otherwise
2987 class TSetViewSize: public SALOME_Event
2990 typedef bool TResult;
2995 TSetViewSize( const int w, const int h, const int id )
2996 : myResult( false ),
3000 virtual void Execute()
3002 SUIT_ViewWindow* wnd = 0;
3004 if ( LightApp_Application* anApp = getApplication() ) {
3005 SUIT_ViewManager* vm = anApp->activeViewManager();
3007 wnd = vm->getActiveView();
3011 wnd = dynamic_cast<SUIT_ViewWindow*>( getWnd( myWndId ) );
3014 SUIT_ViewManager* viewMgr = wnd->getViewManager();
3016 QString type = viewMgr->getType();
3017 if ( type == "OCCViewer") {
3018 #ifndef DISABLE_OCCVIEWER
3019 // specific processing for OCC viewer:
3020 // OCC view can embed up to 4 sub-views, split according to the specified layout;
3021 // - if there is only one sub-view active; it will be resized;
3022 // - if there are several sub-views, each of them will be resized.
3023 OCCViewer_ViewWindow* occView = qobject_cast<OCCViewer_ViewWindow*>( wnd );
3024 for ( int i = OCCViewer_ViewFrame::BOTTOM_RIGHT; i <= OCCViewer_ViewFrame::TOP_RIGHT; i++ ) {
3025 if ( occView && occView->getView( i ) ) {
3026 occView->getView( i )->centralWidget()->resize( myWndWidth, myWndHeight );
3030 #endif // DISABLE_OCCVIEWER
3032 else if ( type == "ParaView") {
3033 #ifndef DISABLE_PVVIEWER
3034 // specific processing for ParaView viewer:
3035 // hierarchy of ParaView viewer is much complex than for usual view;
3036 // we look for sub-widget named "Viewport"
3037 QList<QWidget*> lst = wnd->findChildren<QWidget*>( "Viewport" );
3038 if ( !lst.isEmpty() ) {
3039 lst[0]->resize( myWndWidth, myWndHeight );
3042 #endif // DISABLE_PVVIEWER
3045 if ( wnd->centralWidget() ) {
3046 wnd->centralWidget()->resize( myWndWidth, myWndHeight );
3054 bool SalomePyQt::setViewSize( const int w, const int h, const int id )
3056 return ProcessEvent( new TSetViewSize( w, h, id ) );
3060 \fn bool SalomePyQt::setViewRotationPoint( const double x, const double y, const double z, const int id );
3061 \brief Set view rotation point
3062 \param x coordinate X view rotation point
3063 \param y coordinate Y view rotation point
3064 \param z coordinate Z view rotation point
3065 \param id window identifier
3066 \return \c true if operation is completed successfully and \c false otherwise
3069 class TSetViewRotationPoint: public SALOME_Event
3072 typedef bool TResult;
3078 TSetViewRotationPoint( const double x, const double y, const double z, const int id )
3079 : myResult( false ),
3084 virtual void Execute()
3086 SUIT_ViewWindow* wnd = 0;
3088 if ( LightApp_Application* anApp = getApplication() ) {
3089 SUIT_ViewManager* vm = anApp->activeViewManager();
3091 wnd = vm->getActiveView();
3095 wnd = dynamic_cast<SUIT_ViewWindow*>( getWnd( myWndId ) );
3098 SUIT_ViewManager* viewMgr = wnd->getViewManager();
3100 QString type = viewMgr->getType();
3101 if ( type == "OCCViewer") {
3102 #ifndef DISABLE_OCCVIEWER
3103 // specific processing for OCC viewer:
3104 // OCC view can embed up to 4 sub-views, split according to the specified layout;
3105 // - if there is only one sub-view active; its rotation point will be changed;
3106 // - if there are several sub-views, rotaion points of each of them will be changed.
3107 OCCViewer_ViewWindow* occView = qobject_cast<OCCViewer_ViewWindow*>( wnd );
3109 for ( int i = OCCViewer_ViewFrame::BOTTOM_RIGHT; i <= OCCViewer_ViewFrame::TOP_RIGHT; i++ ) {
3110 if ( occView && occView->getView( i ) ) {
3111 occView->getView( i )->activateSetRotationSelected( myX, myY, myZ );
3116 #endif // DISABLE_OCCVIEWER
3118 else if ( type == "VTKViewer") {
3119 #ifndef DISABLE_VTKVIEWER
3120 SVTK_ViewWindow* vtkView = qobject_cast<SVTK_ViewWindow*>( wnd );
3123 double aCenter[3] = { myX, myY, myZ };
3124 vtkView->activateSetRotationSelected( (void*)aCenter );
3127 #endif // DISABLE_VTKVIEWER
3133 bool SalomePyQt::setViewRotationPoint( const double x, const double y, const double z, const int id )
3135 return ProcessEvent( new TSetViewRotationPoint( x, y, z, id ) );
3139 \fn QString SalomePyQt::getViewTitle( const int id );
3140 \brief Get view caption
3141 \param id window identifier
3142 \return view caption
3145 class TGetViewTitle: public SALOME_Event
3148 typedef QString TResult;
3151 TGetViewTitle( const int id )
3153 virtual void Execute()
3155 SUIT_ViewWindow* wnd = getWnd( myWndId );
3157 myResult = wnd->windowTitle();
3160 QString SalomePyQt::getViewTitle( const int id )
3162 return ProcessEvent( new TGetViewTitle( id ) );
3166 \fn QList<int> SalomePyQt::findViews( const QString& type );
3167 \brief Get list of integer identifiers of all the
3168 currently opened views of the specified type
3169 \param type viewer type
3170 \return list of integer identifiers
3173 class TFindViews: public SALOME_Event
3176 typedef QList<int> TResult;
3179 TFindViews( const QString& type )
3181 virtual void Execute()
3184 LightApp_Application* app = getApplication();
3186 ViewManagerList vmList;
3187 app->viewManagers( myType, vmList );
3188 SUIT_ViewManager* viewMgr;
3189 foreach ( viewMgr, vmList ) {
3190 QVector<SUIT_ViewWindow*> vec = viewMgr->getViews();
3191 for ( int i = 0, n = vec.size(); i < n; i++ ) {
3192 SUIT_ViewWindow* wnd = vec[ i ];
3195 MESSAGE("SUIT_ViewWindow*: "<< wnd << " id: " << wnd->getId());
3196 myResult.append( wnd->getId() );
3203 QList<int> SalomePyQt::findViews( const QString& type )
3205 return ProcessEvent( new TFindViews( type ) );
3209 \fn bool SalomePyQt::activateView( const int id );
3210 \brief Activate view
3211 \param id window identifier
3212 \return \c true if operation is completed successfully and \c false otherwise
3215 class TActivateView: public SALOME_Event
3218 typedef bool TResult;
3221 TActivateView( const int id )
3222 : myResult( false ),
3224 virtual void Execute()
3226 SUIT_ViewWindow* wnd = getWnd( myWndId );
3227 MESSAGE("window id:" << myWndId << " SUIT_ViewWindow*: " << wnd);
3234 bool SalomePyQt::activateView( const int id )
3236 return ProcessEvent( new TActivateView( id ) );
3240 \fn bool SalomePyQt::activateManagerAndView( const int id );
3241 \brief Activate view manager and view: useful for a view embedded in a module main Window
3242 \param id window identifier
3243 \return \c true if operation is completed successfully and \c false otherwise
3246 class TActivateViewManagerAndView: public SALOME_Event
3249 typedef bool TResult;
3252 TActivateViewManagerAndView( const int id )
3253 : myResult( false ),
3255 virtual void Execute()
3257 SUIT_ViewWindow* wnd = getWnd( myWndId );
3258 MESSAGE("window id:" << myWndId << " SUIT_ViewWindow*: " << wnd);
3261 LightApp_Application* app = getApplication();
3262 app->desktop()->windowActivated(wnd); // equivalent to app->setActiveViewManager(wnd->getViewManager())
3268 bool SalomePyQt::activateViewManagerAndView( const int id )
3270 return ProcessEvent( new TActivateViewManagerAndView( id ) );
3277 class TGetViewWidget: public SALOME_Event
3280 typedef QWidget* TResult;
3283 TGetViewWidget( const int id )
3286 virtual void Execute()
3288 SUIT_ViewWindow* wnd = getWnd( myWndId );
3290 myResult = (QWidget*)wnd;
3294 QWidget* SalomePyQt::getViewWidget( const int id)
3296 return ProcessEvent( new TGetViewWidget( id ) );
3301 \fn int SalomePyQt::createView( const QString& type, bool visible = true, const int width = 0, const int height = 0 );
3302 \brief Create new view and activate it
3303 \param type viewer type
3307 \return integer identifier of created view (or -1 if view could not be created)
3310 class TCreateView: public SALOME_Event
3313 typedef int TResult;
3320 TCreateView( const QString& theType, bool visible, const int width, const int height, bool detached )
3326 myDetached(detached) {}
3327 virtual void Execute()
3329 LightApp_Application* app = getApplication();
3331 SUIT_ViewManager* viewMgr = app->createViewManager( myType, myDetached );
3333 QWidget* wnd = viewMgr->getActiveView();
3334 myResult = viewMgr->getActiveView()->getId();
3337 wnd->setVisible(false);
3338 if ( !myVisible && myWidth == 0 && myHeight == 0 ) {
3342 if (myWidth > 0 && myHeight > 0) {
3343 #ifndef DISABLE_PLOT2DVIEWER
3344 Plot2d_ViewWindow* wnd2D = dynamic_cast<Plot2d_ViewWindow*>( wnd );
3345 if ( wnd2D ) wnd = wnd2D->getViewFrame();
3346 #endif // DISABLE_PLOT2DVIEWER
3347 wnd->setGeometry( 0, 0, myWidth, myHeight );
3354 int SalomePyQt::createView( const QString& type, bool visible, const int width, const int height, bool detached )
3356 int ret = ProcessEvent( new TCreateView( type, visible, width, height, detached ) );
3357 QCoreApplication::processEvents();
3362 \fn int SalomePyQt::createView( const QString& type, QWidget* w );
3363 \brief Create new view with custom widget embedded and activate it
3364 \param type viewer type
3365 \param w custom widget
3366 \return integer identifier of created view (or -1 if view could not be created)
3369 class TCreateViewWg: public SALOME_Event
3372 typedef int TResult;
3376 TCreateViewWg( const QString& theType, QWidget* w )
3380 virtual void Execute()
3382 LightApp_Application* app = getApplication();
3384 SUIT_ViewManager* viewMgr = app->createViewManager( myType, myWidget );
3386 SUIT_ViewWindow* wnd = viewMgr->getActiveView();
3388 myResult = wnd->getId();
3393 int SalomePyQt::createView( const QString& type, QWidget* w )
3395 int ret = ProcessEvent( new TCreateViewWg( type, w ) );
3396 QCoreApplication::processEvents();
3401 \fn bool SalomePyQt::closeView( const int id );
3403 \param id window identifier
3404 \return \c true if operation is completed successfully and \c false otherwise
3407 class TCloseView: public SALOME_Event
3410 typedef bool TResult;
3413 TCloseView( const int id )
3414 : myResult( false ),
3416 virtual void Execute()
3418 SUIT_ViewWindow* wnd = getWnd( myWndId );
3420 SUIT_ViewManager* viewMgr = wnd->getViewManager();
3428 bool SalomePyQt::closeView( const int id )
3430 return ProcessEvent( new TCloseView( id ) );
3434 \fn int SalomePyQt::cloneView( const int id );
3435 \brief Clone view (if this operation is supported for specified view type)
3436 \param id window identifier
3437 \return integer identifier of the cloned view or -1 or operation could not be performed
3440 class TCloneView: public SALOME_Event
3443 typedef int TResult;
3446 TCloneView( const int id )
3449 virtual void Execute()
3451 SUIT_ViewWindow* wnd = getWnd( myWndId );
3453 SUIT_ViewManager* viewMgr = wnd->getViewManager();
3455 #ifndef DISABLE_OCCVIEWER
3456 if ( wnd->inherits( "OCCViewer_ViewWindow" ) ) {
3457 OCCViewer_ViewWindow* occView = (OCCViewer_ViewWindow*)( wnd );
3458 occView->onCloneView();
3459 wnd = viewMgr->getActiveView();
3461 myResult = wnd->getId();
3463 #endif // DISABLE_OCCVIEWER
3464 #ifndef DISABLE_PLOT2DVIEWER
3465 if ( wnd->inherits( "Plot2d_ViewWindow" ) ) {
3466 Plot2d_ViewManager* viewMgr2d = dynamic_cast<Plot2d_ViewManager*>( viewMgr );
3467 Plot2d_ViewWindow* srcWnd2d = dynamic_cast<Plot2d_ViewWindow*>( wnd );
3468 if ( viewMgr2d && srcWnd2d ) {
3469 Plot2d_ViewWindow* resWnd = viewMgr2d->cloneView( srcWnd2d );
3470 myResult = resWnd->getId();
3473 #endif // DISABLE_OCCVIEWER
3478 int SalomePyQt::cloneView( const int id )
3480 return ProcessEvent( new TCloneView( id ) );
3484 \fn bool SalomePyQt::setViewVisible( const int id, const bool visible )
3485 \brief Set view visibility.
3486 \param id window identifier
3487 \param visible new visiblity
3490 void SalomePyQt::setViewVisible( const int id, const bool visible )
3492 class TEvent: public SALOME_Event
3497 TEvent( const int id, const bool visible )
3498 : myWndId( id ), myVisible( visible ) {}
3499 virtual void Execute()
3501 SUIT_ViewWindow* wnd = getWnd( myWndId );
3502 if ( wnd ) wnd->setVisible( myVisible );
3505 ProcessVoidEvent( new TEvent( id, visible ) );
3509 \fn bool SalomePyQt::isViewVisible( const int id );
3510 \brief Check whether view is visible ( i.e. it is on the top of the views stack)
3511 \param id window identifier
3512 \return \c true if view is visible and \c false otherwise
3515 class TIsViewVisible: public SALOME_Event
3518 typedef bool TResult;
3521 TIsViewVisible( const int id )
3522 : myResult( false ),
3524 virtual void Execute()
3526 SUIT_ViewWindow* wnd = getWnd( myWndId );
3529 QWidget* p = wnd->parentWidget();
3530 myResult = ( p && p->isVisibleTo( p->parentWidget() ) );
3534 bool SalomePyQt::isViewVisible( const int id )
3536 return ProcessEvent( new TIsViewVisible( id ) );
3540 \fn bool SalomePyQt::setViewClosable( const int id, const bool on );
3541 \brief Set / clear view's "closable" option. By default any view is closable
3542 (i.e. can be closed by the user).
3543 \param id window identifier
3544 \param on new "closable" option's value
3547 void SalomePyQt::setViewClosable( const int id, const bool on )
3549 class TEvent: public SALOME_Event
3554 TEvent( const int id, const bool on )
3555 : myWndId( id ), myOn( on ) {}
3556 virtual void Execute()
3558 SUIT_ViewWindow* wnd = getWnd( myWndId );
3559 if ( wnd ) wnd->setClosable( myOn );
3562 ProcessVoidEvent( new TEvent( id, on ) );
3566 \fn bool SalomePyQt::isViewClosable( const int id );
3567 \brief Check whether view is closable (i.e. can be closed by the user)
3568 \param id window identifier
3569 \return \c true if view is closable or \c false otherwise
3572 class TIsViewClosable: public SALOME_Event
3575 typedef bool TResult;
3578 TIsViewClosable( const int id )
3581 virtual void Execute()
3583 SUIT_ViewWindow* wnd = getWnd( myWndId );
3585 myResult = wnd->closable();
3589 bool SalomePyQt::isViewClosable( const int id )
3591 return ProcessEvent( new TIsViewClosable( id ) );
3595 \fn bool SalomePyQt::groupAllViews();
3596 \brief Group all views to the single tab area
3597 \return \c true if operation is completed successfully and \c false otherwise
3600 class TGroupAllViews: public SALOME_Event
3603 typedef bool TResult;
3606 : myResult( false ) {}
3607 virtual void Execute()
3609 LightApp_Application* app = getApplication();
3611 STD_TabDesktop* tabDesk = dynamic_cast<STD_TabDesktop*>( app->desktop() );
3613 QtxWorkstack* wStack = tabDesk->workstack();
3622 bool SalomePyQt::groupAllViews()
3624 return ProcessEvent( new TGroupAllViews() );
3628 \fn bool SalomePyQt::splitView( const int id, const Orientation ori, const Action action );
3629 \brief Split tab area to which view with identifier belongs to
3630 \param id window identifier
3631 \param ori orientation of split operation
3632 \param action action to be performed
3633 \return \c true if operation is completed successfully \c false otherwise
3636 class TSplitView: public SALOME_Event
3639 typedef bool TResult;
3644 TSplitView( const int id,
3645 const Orientation ori,
3646 const Action action )
3647 : myResult( false ),
3650 myAction( action ) {}
3651 virtual void Execute()
3653 SUIT_ViewWindow* wnd = getWnd( myWndId );
3656 // wnd->setFocus(); ???
3659 if ( getApplication() ) {
3660 STD_TabDesktop* desk =
3661 dynamic_cast<STD_TabDesktop*>( getApplication()->desktop() );
3663 QtxWorkstack* wStack = desk->workstack();
3665 Qt::Orientation qtOri =
3666 ( myOri == Horizontal ) ? Qt::Horizontal : Qt::Vertical;
3668 QtxWorkstack::SplitType sType;
3669 if ( myAction == MoveWidget )
3670 sType = QtxWorkstack::SplitMove;
3671 else if ( myAction == LeaveWidget )
3672 sType = QtxWorkstack::SplitStay;
3674 sType = QtxWorkstack::SplitAt;
3676 wStack->Split( wnd, qtOri, sType );
3684 bool SalomePyQt::splitView( const int id, const Orientation ori, const Action action )
3686 return ProcessEvent( new TSplitView( id, ori, action ) );
3690 \fn bool SalomePyQt::moveView( const int id, const int id_to, const bool before );
3691 \brief Move view with the first identifier to the same area which
3692 another view with the second identifier belongs to
3693 \param id source window identifier
3694 \param id_to destination window identifier
3695 param before specifies whether the first viewt has to be moved before or after
3697 \return \c true if operation is completed successfully and \c false otherwise
3700 class TMoveView: public SALOME_Event
3703 typedef bool TResult;
3708 TMoveView( const int id, const int id_to, const bool before )
3709 : myResult( false ),
3712 myIsBefore( before ) {}
3713 virtual void Execute()
3715 SUIT_ViewWindow* wnd = getWnd( myWndId );
3716 SUIT_ViewWindow* wnd_to = getWnd( myWndToId );
3717 if ( wnd && wnd_to ) {
3718 QtxWorkstack* wStack = dynamic_cast<STD_TabDesktop*>(
3719 getApplication()->desktop() )->workstack();
3721 myResult = wStack->move( wnd, wnd_to, myIsBefore );
3725 bool SalomePyQt::moveView( const int id, const int id_to, const bool before )
3727 return ProcessEvent( new TMoveView( id, id_to, before ) );
3731 \fn QList<int> SalomePyQt::neighbourViews( const int id );
3732 \brief Get list of views identifiers that belongs to the same area as
3733 specified view (excluding it)
3734 \param id window identifier
3735 \return list of views identifiers
3738 class TNeighbourViews: public SALOME_Event
3741 typedef QList<int> TResult;
3744 TNeighbourViews( const int id )
3746 virtual void Execute()
3749 SUIT_ViewWindow* wnd = getWnd( myWndId );
3751 QtxWorkstack* wStack = dynamic_cast<STD_TabDesktop*>(
3752 getApplication()->desktop() )->workstack();
3754 QWidgetList wgList = wStack->windowList( wnd );
3756 foreach ( wg, wgList ) {
3757 SUIT_ViewWindow* tmpWnd = dynamic_cast<SUIT_ViewWindow*>( wg );
3758 if ( tmpWnd && tmpWnd != wnd )
3759 myResult.append( tmpWnd->getId() );
3765 QList<int> SalomePyQt::neighbourViews( const int id )
3767 return ProcessEvent( new TNeighbourViews( id ) );
3772 \fn void SalomePyQt::createRoot();
3773 \brief Initialize root data object.
3775 Does nothing if root is already initialized.
3778 void SalomePyQt::createRoot()
3780 class TEvent: public SALOME_Event
3784 virtual void Execute()
3786 SALOME_PYQT_ModuleLight* module = dynamic_cast<SALOME_PYQT_ModuleLight*>( getActiveModule() );
3788 SALOME_PYQT_DataModelLight* dm =
3789 dynamic_cast<SALOME_PYQT_DataModelLight*>( module->dataModel() );
3794 if ( verbose() ) printf( "SalomePyQt.createRoot() function is not supported for the current module.\n" );
3798 ProcessVoidEvent( new TEvent() );
3802 \fn QString SalomePyQt::createObject( const QString& parent );
3803 \brief Create empty data object
3804 \param parent entry of parent data object
3805 \return entry of created data object
3808 class TCreateEmptyObjectEvent: public SALOME_Event
3811 typedef QString TResult;
3814 TCreateEmptyObjectEvent( const QString& parent )
3815 : myParent( parent ) {}
3816 virtual void Execute()
3818 SALOME_PYQT_ModuleLight* module = dynamic_cast<SALOME_PYQT_ModuleLight*>( getActiveModule() );
3820 myResult = module->createObject( myParent );
3823 if ( verbose() ) printf( "SalomePyQt.createObject() function is not supported for the current module.\n" );
3827 QString SalomePyQt::createObject( const QString& parent )
3829 return ProcessEvent( new TCreateEmptyObjectEvent( parent ) );
3833 \fn QString SalomePyQt::createObject( const QString& name, const QString& icon,
3834 const QString& tooltip,const QString& parent );
3835 \brief Create new data object with specified name, icon and tooltip
3836 \param name data object name
3837 \param icon data object icon
3838 \param toolTip data object tooltip
3839 \param parent entry of parent data object
3840 \return entry of created data object
3843 class TCreateObjectEvent: public SALOME_Event
3846 typedef QString TResult;
3852 TCreateObjectEvent( const QString& name,
3853 const QString& icon,
3854 const QString& tooltip,
3855 const QString& parent )
3858 myToolTip( tooltip ),
3859 myParent( parent ) {}
3860 virtual void Execute()
3862 SALOME_PYQT_ModuleLight* module = dynamic_cast<SALOME_PYQT_ModuleLight*>( getActiveModule() );
3864 myResult = module->createObject( myName, myIcon, myToolTip, myParent );
3867 if ( verbose() ) printf( "SalomePyQt.createObject() function is not supported for the current module.\n" );
3871 QString SalomePyQt::createObject( const QString& name,
3872 const QString& icon,
3873 const QString& toolTip,
3874 const QString& parent )
3876 return ProcessEvent( new TCreateObjectEvent( name, icon, toolTip, parent ) );
3881 \fn void SalomePyQt::setName( const QString& entry, const QString& name );
3882 \brief Set data object name
3883 \param entry data object entry
3884 \param name data object name
3886 class TSetNameEvent: public SALOME_Event
3891 TSetNameEvent( const QString& entry,
3892 const QString& name )
3895 virtual void Execute()
3897 SALOME_PYQT_ModuleLight* module = dynamic_cast<SALOME_PYQT_ModuleLight*>( getActiveModule() );
3899 module->setName( myEntry, myName );
3902 if ( verbose() ) printf( "SalomePyQt.setName() function is not supported for the current module.\n" );
3906 void SalomePyQt::setName( const QString& entry, const QString& name )
3908 ProcessVoidEvent( new TSetNameEvent( entry, name ) );
3912 \fn void SalomePyQt::setIcon( const QString& entry, const QString& icon );
3913 \brief Set data object icon
3914 \param entry data object entry
3915 \param icon data object icon file name (icon is loaded from module resources)
3918 class TSetIconEvent: public SALOME_Event
3923 TSetIconEvent( const QString& entry,
3924 const QString& icon )
3927 virtual void Execute()
3929 SALOME_PYQT_ModuleLight* module = dynamic_cast<SALOME_PYQT_ModuleLight*>( getActiveModule() );
3931 module->setIcon( myEntry, myIcon );
3934 if ( verbose() ) printf( "SalomePyQt.setIcon() function is not supported for the current module.\n" );
3939 void SalomePyQt::setIcon( const QString& entry, const QString& icon )
3941 ProcessVoidEvent( new TSetIconEvent( entry, icon ) );
3945 \fn void SalomePyQt::setToolTip( const QString& entry, const QString& toolTip );
3946 \brief Set data object tooltip
3947 \param entry data object entry
3948 \param toolTip data object tooltip
3951 class TSetToolTipEvent: public SALOME_Event
3956 TSetToolTipEvent( const QString& entry,
3957 const QString& toolTip )
3959 myToolTip( toolTip ) {}
3960 virtual void Execute()
3962 SALOME_PYQT_ModuleLight* module = dynamic_cast<SALOME_PYQT_ModuleLight*>( getActiveModule() );
3964 module->setToolTip( myEntry, myToolTip );
3967 if ( verbose() ) printf( "SalomePyQt.setToolTip() function is not supported for the current module.\n" );
3971 void SalomePyQt::setToolTip( const QString& entry, const QString& toolTip )
3973 ProcessVoidEvent( new TSetToolTipEvent( entry, toolTip ) );
3977 \fn void SalomePyQt::setReference( const QString& entry, const QString& refEntry );
3978 \brief Set reference to another data object
3979 \param entry data object entry
3980 \param refEntry referenced data object entry
3983 class TSetRefEvent: public SALOME_Event
3988 TSetRefEvent( const QString& entry,
3989 const QString& refEntry )
3991 myRefEntry( refEntry ) {}
3992 virtual void Execute()
3994 SALOME_PYQT_ModuleLight* module = dynamic_cast<SALOME_PYQT_ModuleLight*>( getActiveModule() );
3996 module->setReference( myEntry, myRefEntry );
3999 if ( verbose() ) printf( "SalomePyQt.setReference() function is not supported for the current module.\n" );
4003 void SalomePyQt::setReference( const QString& entry, const QString& refEntry )
4005 ProcessVoidEvent( new TSetRefEvent( entry, refEntry ) );
4009 \fn void SalomePyQt::setColor( const QString& entry, const QColor& color );
4010 \brief Set data object color
4011 \param entry data object entry
4012 \param color data object color
4015 class TSetColorEvent: public SALOME_Event
4020 TSetColorEvent( const QString& entry,
4021 const QColor& color )
4024 virtual void Execute()
4026 SALOME_PYQT_ModuleLight* module = dynamic_cast<SALOME_PYQT_ModuleLight*>( getActiveModule() );
4028 module->setColor( myEntry, myColor );
4031 if ( verbose() ) printf( "SalomePyQt.setColor() function is not supported for the current module.\n" );
4035 void SalomePyQt::setColor( const QString& entry, const QColor& color )
4037 ProcessVoidEvent( new TSetColorEvent( entry, color ) );
4041 \fn QString SalomePyQt::getName( const QString& entry );
4042 \brief Get data object name
4043 \param entry data object entry
4044 \return data object name
4047 class TGetNameEvent: public SALOME_Event
4050 typedef QString TResult;
4053 TGetNameEvent( const QString& entry )
4054 : myEntry( entry ) {}
4055 virtual void Execute()
4057 SALOME_PYQT_ModuleLight* module = dynamic_cast<SALOME_PYQT_ModuleLight*>( getActiveModule() );
4059 myResult = module->getName( myEntry );
4062 if ( verbose() ) printf( "SalomePyQt.getName() function is not supported for the current module.\n" );
4066 QString SalomePyQt::getName( const QString& entry )
4068 return ProcessEvent( new TGetNameEvent( entry ) );
4072 \fn QString SalomePyQt::getToolTip( const QString& entry );
4073 \brief Get data object tooltip
4074 \param entry data object entry
4075 \return data object tooltip
4078 class TGetToolTipEvent: public SALOME_Event
4081 typedef QString TResult;
4084 TGetToolTipEvent( const QString& entry )
4085 : myEntry( entry ) {}
4086 virtual void Execute()
4088 SALOME_PYQT_ModuleLight* module = dynamic_cast<SALOME_PYQT_ModuleLight*>( getActiveModule() );
4090 myResult = module->getToolTip( myEntry );
4093 if ( verbose() ) printf( "SalomePyQt.getToolTip() function is not supported for the current module.\n" );
4097 QString SalomePyQt::getToolTip( const QString& entry )
4099 return ProcessEvent( new TGetToolTipEvent( entry ) );
4103 \fn QString SalomePyQt::getReference( const QString& entry );
4104 \brief Get entry of the referenced object (if there's any)
4105 \param entry data object entry
4106 \return referenced data object entry
4109 class TGetRefEvent: public SALOME_Event
4112 typedef QString TResult;
4115 TGetRefEvent( const QString& entry )
4116 : myEntry( entry ) {}
4117 virtual void Execute()
4119 SALOME_PYQT_ModuleLight* module = dynamic_cast<SALOME_PYQT_ModuleLight*>( getActiveModule() );
4121 myResult = module->getReference( myEntry );
4124 if ( verbose() ) printf( "SalomePyQt.getReference() function is not supported for the current module.\n" );
4128 QString SalomePyQt::getReference( const QString& entry )
4130 return ProcessEvent( new TGetRefEvent( entry ) );
4134 \fn QColor SalomePyQt::getColor( const QString& entry );
4135 \brief Get data object color
4136 \param entry data object entry
4137 \return data object color
4140 class TGetColorEvent: public SALOME_Event
4143 typedef QColor TResult;
4146 TGetColorEvent( const QString& entry )
4147 : myEntry( entry ) {}
4148 virtual void Execute()
4150 SALOME_PYQT_ModuleLight* module = dynamic_cast<SALOME_PYQT_ModuleLight*>( getActiveModule() );
4152 myResult = module->getColor( myEntry );
4155 if ( verbose() ) printf( "SalomePyQt.getColor() function is not supported for the current module.\n" );
4159 QColor SalomePyQt::getColor( const QString& entry )
4161 return ProcessEvent( new TGetColorEvent( entry ) );
4165 \fn void SalomePyQt::removeChildren( const QString& entry );
4166 \brief Remove all child data objects from specified data object
4167 \param entry data object entry
4170 class TRemoveChildEvent: public SALOME_Event
4174 TRemoveChildEvent( const QString& entry )
4175 : myEntry( entry ) {}
4176 virtual void Execute()
4178 SALOME_PYQT_ModuleLight* module = dynamic_cast<SALOME_PYQT_ModuleLight*>( getActiveModule() );
4180 module->removeChildren( myEntry );
4183 if ( verbose() ) printf( "SalomePyQt.removeChildren() function is not supported for the current module.\n" );
4187 void SalomePyQt::removeChildren( const QString& entry )
4189 ProcessVoidEvent( new TRemoveChildEvent( entry ) );
4191 void SalomePyQt::removeChild( const QString& entry )
4193 if ( verbose() ) printf( "SalomePyQt.removeChild() function is obsolete. Use SalomePyQt.removeChildren() instead." );
4194 removeChildren( entry );
4198 \fn void SalomePyQt::removeObject( const QString& entry );
4199 \brief Remove object by entry
4200 \param entry data object entry
4203 class TRemoveObjectEvent: public SALOME_Event
4208 TRemoveObjectEvent( const QString& entry )
4209 : myEntry( entry ) {}
4210 virtual void Execute()
4212 SALOME_PYQT_ModuleLight* module = dynamic_cast<SALOME_PYQT_ModuleLight*>( getActiveModule() );
4214 module->removeObject( myEntry );
4217 if ( verbose() ) printf( "SalomePyQt.removeObject() function is not supported for the current module.\n" );
4221 void SalomePyQt::removeObject( const QString& entry )
4223 ProcessVoidEvent( new TRemoveObjectEvent( entry ) );
4227 \fn QStringList SalomePyQt::getChildren( const QString& entry, const bool recursive );
4228 \brief Get entries of all child data objects of specified data object
4229 \param entry data object entry
4230 \param recursive \c true for recursive processing
4233 class TGetChildrenEvent: public SALOME_Event
4236 typedef QStringList TResult;
4240 TGetChildrenEvent( const QString& entry, const bool recursive )
4242 myRecursive( recursive ) {}
4243 virtual void Execute()
4245 SALOME_PYQT_ModuleLight* module = dynamic_cast<SALOME_PYQT_ModuleLight*>( getActiveModule() );
4247 myResult = module->getChildren( myEntry, myRecursive );
4250 if ( verbose() ) printf( "SalomePyQt.getChildren() function is not supported for the current module.\n" );
4254 QStringList SalomePyQt::getChildren( const QString& entry, const bool recursive )
4256 return ProcessEvent( new TGetChildrenEvent( entry, recursive ) );
4259 #ifndef DISABLE_PLOT2DVIEWER
4260 // Next set of methods relates to the Plot2d viewer functionality
4263 \fn void SalomePyQt::displayCurve( const int id, Plot2d_Curve* theCurve )
4264 \brief Display theCurve in view
4265 \param id window identifier
4266 \param theCurve curve to display
4269 class TDisplayCurve: public SALOME_Event
4273 Plot2d_Curve* myCurve;
4274 TDisplayCurve( const int id, Plot2d_Curve* theCurve ) : myWndId( id ), myCurve( theCurve ) {}
4275 virtual void Execute() {
4276 Plot2d_ViewWindow* wnd = dynamic_cast<Plot2d_ViewWindow*>( getWnd( myWndId ) );
4278 wnd->getViewFrame()->displayCurve( myCurve );
4281 void SalomePyQt::displayCurve( const int id, Plot2d_Curve* theCurve )
4283 ProcessVoidEvent( new TDisplayCurve( id, theCurve ) );
4287 \fn void SalomePyQt::eraseCurve( const int id, Plot2d_Curve* theCurve )
4288 \brief Erase theCurve in view
4289 \param id window identifier
4290 \param theCurve curve to erase
4293 class TEraseCurve: public SALOME_Event
4297 Plot2d_Curve* myCurve;
4298 TEraseCurve( const int id, Plot2d_Curve* theCurve ) : myWndId( id ), myCurve( theCurve ) {}
4299 virtual void Execute() {
4300 Plot2d_ViewWindow* wnd = dynamic_cast<Plot2d_ViewWindow*>( getWnd( myWndId ) );
4301 wnd->getViewFrame()->eraseCurve( myCurve );
4304 void SalomePyQt::eraseCurve( const int id, Plot2d_Curve* theCurve )
4306 ProcessVoidEvent( new TEraseCurve( id, theCurve ) );
4310 \fn void SalomePyQt::deleteCurve( Plot2d_Curve* theCurve )
4311 \brief Delete theCurve from all views
4312 \param theCurve curve to delete
4315 class TDeleteCurve: public SALOME_Event
4318 Plot2d_Curve* myCurve;
4319 TDeleteCurve( Plot2d_Curve* theCurve ) : myCurve( theCurve ) {}
4320 virtual void Execute() {
4321 LightApp_Application* app = getApplication();
4323 STD_TabDesktop* tabDesk = dynamic_cast<STD_TabDesktop*>( app->desktop() );
4325 QList<SUIT_ViewWindow*> wndlist = tabDesk->windows();
4326 SUIT_ViewWindow* wnd;
4327 foreach ( wnd, wndlist ) {
4328 Plot2d_ViewWindow* aP2d = dynamic_cast<Plot2d_ViewWindow*>( wnd );
4330 aP2d->getViewFrame()->eraseObject( myCurve );
4336 void SalomePyQt::eraseCurve( Plot2d_Curve* theCurve )
4338 ProcessVoidEvent( new TDeleteCurve( theCurve ) );
4342 \brief updateCurves (repaint) curves in view window.
4344 void SalomePyQt::updateCurves( const int id )
4346 class TEvent: public SALOME_Event
4350 TEvent( const int id ) : myWndId( id ) {}
4351 virtual void Execute()
4353 Plot2d_ViewWindow* wnd = dynamic_cast<Plot2d_ViewWindow*>( getWnd( myWndId ) );
4355 wnd->getViewFrame()->DisplayAll();
4358 ProcessVoidEvent( new TEvent( id ) );
4362 \fn QString SalomePyQt::getPlot2dTitle( const int id, ObjectType type = MainTitle )
4363 \brief Get title of corresponding type
4364 \param id window identifier
4365 \param type is type of title
4366 \return title of corresponding type
4369 class TGetPlot2dTitle: public SALOME_Event
4372 typedef QString TResult;
4376 TGetPlot2dTitle(const int id, ObjectType type) :
4379 virtual void Execute() {
4380 Plot2d_ViewWindow* wnd = dynamic_cast<Plot2d_ViewWindow*>( getWnd( myWndId ) );
4382 myResult = wnd->getViewFrame()->getTitle( (Plot2d_ViewFrame::ObjectType)myType );
4385 QString SalomePyQt::getPlot2dTitle( const int id, ObjectType type )
4387 return ProcessEvent( new TGetPlot2dTitle( id, type ) );
4392 \fn void SalomePyQt::setPlot2dTitle( const int id, const QString& title, ObjectType type = MainTitle, bool show = true )
4393 \brief Set title of corresponding type
4394 \param id window identifier
4396 \param type is type of title
4400 class TSetPlot2dTitle: public SALOME_Event
4404 Plot2d_Curve* myCurve;
4408 TSetPlot2dTitle( const int id, const QString& title, ObjectType type, bool show ) :
4413 virtual void Execute() {
4414 Plot2d_ViewWindow* wnd = dynamic_cast<Plot2d_ViewWindow*>( getWnd( myWndId ) );
4415 wnd->getViewFrame()->setTitle( myShow, myTitle, (Plot2d_ViewFrame::ObjectType)myType, false );
4418 void SalomePyQt::setPlot2dTitle( const int id, const QString& title, ObjectType type, bool show )
4420 ProcessVoidEvent( new TSetPlot2dTitle( id, title, type, show ) );
4424 \fn QList<int> SalomePyQt::getPlot2dFitRangeByCurves( const int id )
4425 \brief Get list of Plot2d view ranges
4426 \param id window identifier
4427 \return list of view ranges (XMin, XMax, YMin, YMax)
4430 class TFitRangeByCurves: public SALOME_Event
4433 typedef QList<double> TResult;
4436 TFitRangeByCurves( const int id )
4438 virtual void Execute()
4441 Plot2d_ViewWindow* wnd = dynamic_cast<Plot2d_ViewWindow*>( getWnd( myWndId ) );
4443 double XMin, XMax, YMin, YMax, Y2Min, Y2Max;
4444 wnd->getViewFrame()->getFitRangeByCurves( XMin, XMax, YMin, YMax, Y2Min, Y2Max );
4445 myResult.append( XMin );
4446 myResult.append( XMax );
4447 myResult.append( YMin );
4448 myResult.append( YMax );
4452 QList<double> SalomePyQt::getPlot2dFitRangeByCurves( const int id )
4454 return ProcessEvent( new TFitRangeByCurves( id ) );
4458 \fn QList<int> SalomePyQt::getPlot2dFitRangeCurrent( const int id )
4459 \brief Get list of current Plot2d view ranges
4460 \param id window identifier
4461 \return list of view ranges (XMin, XMax, YMin, YMax)
4464 class TFitRangeCurrent: public SALOME_Event
4467 typedef QList<double> TResult;
4470 TFitRangeCurrent( const int id )
4472 virtual void Execute()
4475 Plot2d_ViewWindow* wnd = dynamic_cast<Plot2d_ViewWindow*>( getWnd( myWndId ) );
4477 double XMin, XMax, YMin, YMax, Y2Min, Y2Max;
4478 wnd->getViewFrame()->getFitRanges( XMin, XMax, YMin, YMax, Y2Min, Y2Max );
4479 myResult.append( XMin );
4480 myResult.append( XMax );
4481 myResult.append( YMin );
4482 myResult.append( YMax );
4486 QList<double> SalomePyQt::getPlot2dFitRangeCurrent( const int id )
4488 return ProcessEvent( new TFitRangeCurrent( id ) );
4492 \fn void SalomePyQt::setPlot2dFitRange( const int id, const double XMin, const double XMax, const double YMin, const double YMax )
4493 \brief Set range of Plot2d view
4494 \param id window identifier
4501 class TPlot2dFitRange: public SALOME_Event
4509 TPlot2dFitRange( const int id, const double XMin, const double XMax, const double YMin, const double YMax ) :
4515 virtual void Execute() {
4516 Plot2d_ViewWindow* wnd = dynamic_cast<Plot2d_ViewWindow*>( getWnd( myWndId ) );
4518 wnd->getViewFrame()->fitData( 0, myXMin, myXMax, myYMin, myYMax );
4521 void SalomePyQt::setPlot2dFitRange( const int id, const double XMin, const double XMax, const double YMin, const double YMax )
4523 ProcessVoidEvent( new TPlot2dFitRange( id, XMin, XMax, YMin, YMax ) );
4526 // End of methods related to the Plot2d viewer functionality
4527 #endif // DISABLE_PLOT2DVIEWER
4530 \brief Process Qt event loop
4532 void SalomePyQt::processEvents()
4534 QCoreApplication::processEvents();
4538 \brief Set visibility state for given object
4539 \param theEntry study ID of the object
4540 \param theState visibility state
4542 void SalomePyQt::setVisibilityState( const QString& theEntry, VisibilityState theState )
4544 class TEvent: public SALOME_Event
4549 TEvent( const QString& theEntry, int theState ):
4550 myEntry( theEntry ), myState( theState ) {}
4551 virtual void Execute()
4553 LightApp_Study* aStudy = getActiveStudy();
4556 aStudy->setVisibilityState( myEntry, (Qtx::VisibilityState)myState );
4559 ProcessVoidEvent( new TEvent( theEntry, theState ) );
4563 \fn VisibilityState SalomePyQt::getVisibilityState( const QString& theEntry )
4564 \brief Get visibility state for given object
4565 \param theEntry study ID of the object
4566 \return visibility state
4569 class TGetVisibilityStateEvent: public SALOME_Event
4572 typedef int TResult;
4575 TGetVisibilityStateEvent( const QString& theEntry ) : myResult( 0 ), myEntry( theEntry ) {}
4576 virtual void Execute()
4578 LightApp_Study* aStudy = getActiveStudy();
4580 myResult = aStudy->visibilityState( myEntry );
4583 VisibilityState SalomePyQt::getVisibilityState( const QString& theEntry )
4585 return (VisibilityState) ProcessEvent( new TGetVisibilityStateEvent( theEntry ) );
4589 \brief Set position of given object in the tree
4590 \param theEntry study ID of the object
4591 \param thePos position
4593 void SalomePyQt::setObjectPosition( const QString& theEntry, int thePos )
4595 class TEvent: public SALOME_Event
4600 TEvent( const QString& theEntry, int thePos ):
4601 myEntry( theEntry ), myPos( thePos ) {}
4602 virtual void Execute()
4604 SALOME_PYQT_ModuleLight* module = dynamic_cast<SALOME_PYQT_ModuleLight*>( getActiveModule() );
4606 module->setObjectPosition( myEntry, myPos );
4609 ProcessVoidEvent( new TEvent( theEntry, thePos ) );
4613 \fn int SalomePyQt::getObjectPosition( const QString& theEntry )
4614 \brief Get position of given object in the tree
4615 \param theEntry study ID of the object
4619 class TGetObjectPositionEvent: public SALOME_Event
4622 typedef int TResult;
4625 TGetObjectPositionEvent( const QString& theEntry ) : myResult( 0 ), myEntry( theEntry ) {}
4626 virtual void Execute()
4628 SALOME_PYQT_ModuleLight* module = dynamic_cast<SALOME_PYQT_ModuleLight*>( getActiveModule() );
4630 myResult = module->getObjectPosition( myEntry );
4633 int SalomePyQt::getObjectPosition( const QString& theEntry )
4635 return ProcessEvent( new TGetObjectPositionEvent( theEntry ) );
4639 \brief Start recordind a log of Python commands from embedded console
4640 \param theFileName output lof file name
4642 void SalomePyQt::startPyLog( const QString& theFileName )
4644 class TEvent: public SALOME_Event
4648 TEvent( const QString& theFileName ):
4649 myFileName( theFileName ) {}
4650 virtual void Execute()
4652 if ( getApplication() ) {
4653 PyConsole_Console* pyConsole = getApplication()->pythonConsole( false );
4654 if ( pyConsole ) pyConsole->startLog( myFileName );
4658 ProcessVoidEvent( new TEvent( theFileName ) );
4662 \brief Stop recordind a log of Python commands from embedded console
4664 void SalomePyQt::stopPyLog()
4666 class TEvent: public SALOME_Event
4670 virtual void Execute()
4672 if ( getApplication() ) {
4673 PyConsole_Console* pyConsole = getApplication()->pythonConsole( false );
4674 if ( pyConsole ) pyConsole->stopLog();
4678 ProcessVoidEvent( new TEvent() );