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.toUtf8().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 QStringList SalomePyQt::getComponents();
818 \brief Get all modules used in current GUI session.
819 \return List of modules
822 class TGetComponentsEvent: public SALOME_Event
825 typedef QStringList TResult;
827 TGetComponentsEvent() {}
828 virtual void Execute()
830 if ( LightApp_Application* anApp = getApplication() )
833 anApp->modules( titles, false );
834 foreach ( QString title, titles )
836 myResult << anApp->moduleName( title );
841 QStringList SalomePyQt::getComponents()
843 return ProcessEvent( new TGetComponentsEvent() );
847 \fn const QString SalomePyQt::getActiveComponent();
848 \brief Get the currently active module name (for the current study).
849 \return active module name or empty string if there is no active module
852 class TGetActiveComponentEvent: public SALOME_Event
855 typedef QString TResult;
857 TGetActiveComponentEvent() {}
858 virtual void Execute()
860 if ( LightApp_Application* anApp = getApplication() ) {
861 if ( CAM_Module* mod = anApp->activeModule() ) {
862 myResult = mod->name();
867 const QString SalomePyQt::getActiveComponent()
869 return ProcessEvent( new TGetActiveComponentEvent() );
873 \fn PyObject* SalomePyQt::getActivePythonModule();
874 \brief Access to Python module object currently loaded into SALOME_PYQT_ModuleLight container.
875 \return Python module object currently loaded into SALOME_PYQT_ModuleLight container
878 class TGetActivePyModuleEvent: public SALOME_Event
881 typedef PyObject* TResult;
883 TGetActivePyModuleEvent() : myResult( Py_None ) {}
884 virtual void Execute()
886 PyModuleHelper* helper = getPythonHelper();
888 myResult = (PyObject*)helper->pythonModule();
891 PyObject* SalomePyQt::getActivePythonModule()
893 return ProcessEvent( new TGetActivePyModuleEvent() );
897 \fn bool SalomePyQt::activateModule( const QString& modName );
898 \brief Activates SALOME module with the given name
899 \return True if the module has been activated and False otherwise.
902 class TActivateModuleEvent: public SALOME_Event
905 typedef bool TResult;
907 QString myModuleName;
908 TActivateModuleEvent( const QString& modName )
909 : myResult( false ), myModuleName( modName ) {}
910 virtual void Execute()
912 if ( LightApp_Application* anApp = getApplication() ) {
913 myResult = anApp->activateModule( myModuleName );
917 bool SalomePyQt::activateModule( const QString& modName )
919 return ProcessEvent( new TActivateModuleEvent( modName ) );
923 \brief Update an Object Browser of the study.
925 void SalomePyQt::updateObjBrowser()
927 class TEvent: public SALOME_Event
931 virtual void Execute()
933 if ( SUIT_Session::session() ) {
934 if ( getActiveStudy() ) {
935 QList<SUIT_Application*> apps = SUIT_Session::session()->applications();
936 QList<SUIT_Application*>::Iterator it;
937 for( it = apps.begin(); it != apps.end(); ++it ) {
938 LightApp_Application* anApp = dynamic_cast<LightApp_Application*>( *it );
939 if ( anApp && anApp->activeStudy() ) {
940 anApp->updateObjectBrowser();
948 ProcessVoidEvent( new TEvent() );
953 SalomePyQt::isModified()
954 \return The modification status of the data model
955 for the currently active Python module
956 \note This function is supported for "light" Python-based SALOME modules only.
959 class TIsModifiedEvent: public SALOME_Event
962 typedef bool TResult;
964 TIsModifiedEvent() : myResult( false ) {}
965 virtual void Execute()
967 LightApp_Module* module = getActiveModule();
971 SALOME_PYQT_DataModelLight* aModel =
972 dynamic_cast<SALOME_PYQT_DataModelLight*>( module->dataModel() );
974 myResult = aModel->isModified();
977 if ( verbose() ) printf( "SalomePyQt.isModified() function is not supported for the current module.\n" );
981 bool SalomePyQt::isModified()
983 return ProcessEvent(new TIsModifiedEvent());
987 SalomePyQt::setModified()
989 Sets the modification status of the data model for
990 the currently active Python module. This method should be used
991 by the Python code in order to enable/disable "Save" operation
992 depending on the module's data state.
994 \note This function is supported for "light" Python-based SALOME modules only.
996 \param New modification status of the data model
1000 void SalomePyQt::setModified( bool flag )
1002 class TEvent: public SALOME_Event
1008 virtual void Execute()
1010 LightApp_Module* module = getActiveModule();
1014 SALOME_PYQT_DataModelLight* model =
1015 dynamic_cast<SALOME_PYQT_DataModelLight*>( module->dataModel() );
1017 LightApp_Application* app = module->getApp();
1019 if ( model && app ) {
1020 model->setModified( myFlag );
1021 app->updateActions();
1024 if ( verbose() ) printf( "SalomePyQt.setModified() function is not supported for the current module.\n" );
1028 ProcessVoidEvent( new TEvent( flag ) );
1032 \brief Add string setting to the application preferences.
1034 The parameter \a autoValue is obsolete parameter and currently is not used.
1035 This parameter will be removed in future, so try to avoid its usage in
1038 This function is obsolete. Use one of addSetting() instead.
1040 \param name setting name (it should be of kind <section:setting> where
1041 \c section is resources section name and \c setting is setting name)
1042 \param value new setting value
1043 \param autoValue (not used)
1045 void SalomePyQt::addStringSetting( const QString& name, const QString& value, bool autoValue )
1047 class TEvent: public SALOME_Event
1053 TEvent( const QString& name, const QString& value, bool autoValue )
1054 : myName( name ), myValue( value ), myAutoValue( autoValue ) {}
1055 virtual void Execute()
1057 if ( SUIT_Session::session() ) {
1058 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1059 QStringList sl = myName.split( ":", QString::SkipEmptyParts );
1060 QString _sec = sl.count() > 1 ? sl[ 0 ].trimmed() : QString( DEFAULT_SECTION );
1061 QString _nam = sl.count() > 1 ? sl[ 1 ].trimmed() : sl.count() > 0 ? sl[ 0 ].trimmed() : QString( "" );
1062 if ( !_sec.isEmpty() && !_nam.isEmpty() )
1063 resMgr->setValue( _sec, _nam, myValue );
1067 ProcessVoidEvent( new TEvent( name, value, autoValue ) );
1071 \brief Add integer setting to the application preferences.
1073 The parameter \a autoValue is obsolete parameter and currently is not used.
1074 This parameter will be removed in future, so try to avoid its usage in
1077 This function is obsolete. Use one of addSetting() instead.
1079 \param name setting name (it should be of kind <section:setting> where
1080 \c section is resources section name and \c setting is setting name)
1081 \param value new setting value
1082 \param autoValue (not used)
1084 void SalomePyQt::addIntSetting( const QString& name, const int value, bool autoValue)
1086 class TEvent: public SALOME_Event
1092 TEvent( const QString& name, const int value, bool autoValue )
1093 : myName( name ), myValue( value ), myAutoValue( autoValue ) {}
1094 virtual void Execute()
1096 if ( SUIT_Session::session() ) {
1097 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1098 QStringList sl = myName.split( ":", QString::SkipEmptyParts );
1099 QString _sec = sl.count() > 1 ? sl[ 0 ].trimmed() : QString( DEFAULT_SECTION );
1100 QString _nam = sl.count() > 1 ? sl[ 1 ].trimmed() : sl.count() > 0 ? sl[ 0 ].trimmed() : QString( "" );
1101 if ( !_sec.isEmpty() && !_nam.isEmpty() )
1102 resMgr->setValue( _sec, _nam, myValue );
1106 ProcessVoidEvent( new TEvent( name, value, autoValue ) );
1110 \brief Add double setting to the application preferences.
1112 The parameter \a autoValue is obsolete parameter and currently is not used.
1113 This parameter will be removed in future, so try to avoid its usage in
1116 This function is obsolete. Use one of addSetting() instead.
1118 \param name setting name (it should be of kind <section:setting> where
1119 \c section is resources section name and \c setting is setting name)
1120 \param value new setting value
1121 \param autoValue (not used)
1123 void SalomePyQt::addDoubleSetting( const QString& name, const double value, bool autoValue )
1125 class TEvent: public SALOME_Event
1131 TEvent( const QString& name, const double value, bool autoValue )
1132 : myName( name ), myValue( value ), myAutoValue( autoValue ) {}
1133 virtual void Execute()
1135 if ( SUIT_Session::session() ) {
1136 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1137 QStringList sl = myName.split( ":", QString::SkipEmptyParts );
1138 QString _sec = sl.count() > 1 ? sl[ 0 ].trimmed() : QString( DEFAULT_SECTION );
1139 QString _nam = sl.count() > 1 ? sl[ 1 ].trimmed() : sl.count() > 0 ? sl[ 0 ].trimmed() : QString( "" );
1140 if ( !_sec.isEmpty() && !_nam.isEmpty() )
1141 resMgr->setValue( _sec, _nam, myValue );
1145 ProcessVoidEvent( new TEvent( name, value, autoValue ) );
1149 \brief Add boolean setting to the application preferences.
1151 The parameter \a autoValue is obsolete parameter and currently is not used.
1152 This parameter will be removed in future, so try to avoid its usage in
1155 This function is obsolete. Use one of addSetting() instead.
1157 \param name setting name (it should be of kind <section:setting> where
1158 \c section is resources section name and \c setting is setting name)
1159 \param value new setting value
1160 \param autoValue (not used)
1162 void SalomePyQt::addBoolSetting( const QString& name, const bool value, bool autoValue )
1164 class TEvent: public SALOME_Event
1170 TEvent( const QString& name, const bool value, bool autoValue )
1171 : myName( name ), myValue( value ), myAutoValue( autoValue ) {}
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->setValue( _sec, _nam, myValue );
1184 ProcessVoidEvent( new TEvent( name, value, autoValue ) );
1188 \brief Remove setting from the application preferences.
1190 This function is obsolete. Use removeSetting() instead.
1192 \param name setting name (it should be of kind <section:setting> where
1193 \c section is resources section name and \c setting is setting name)
1195 void SalomePyQt::removeSettings( const QString& name )
1197 class TEvent: public SALOME_Event
1201 TEvent( const QString& name ) : myName( name ) {}
1202 virtual void Execute()
1204 if ( SUIT_Session::session() ) {
1205 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1206 QStringList sl = myName.split( ":", QString::SkipEmptyParts );
1207 QString _sec = sl.count() > 1 ? sl[ 0 ].trimmed() : QString( DEFAULT_SECTION );
1208 QString _nam = sl.count() > 1 ? sl[ 1 ].trimmed() : sl.count() > 0 ? sl[ 0 ].trimmed() : QString( "" );
1209 if ( !_sec.isEmpty() && !_nam.isEmpty() )
1210 resMgr->remove( _sec, _nam );
1214 ProcessVoidEvent( new TEvent( name ) );
1218 \fn QString SalomePyQt::getSetting( const QString& name );
1219 \brief Get application setting value (as string represenation).
1221 This function is obsolete. Use stringSetting(), integerSetting(),
1222 boolSetting(), stringSetting() or colorSetting() instead.
1224 \param name setting name (it should be of kind <section:setting> where
1225 \c section is resources section name and \c setting is setting name)
1226 \return setting name (empty string if setting name is invalid)
1229 class TGetSettingEvent: public SALOME_Event
1232 typedef QString TResult;
1235 TGetSettingEvent( const QString& name ) : myName( name ) {}
1236 virtual void Execute()
1238 if ( SUIT_Session::session() ) {
1239 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1240 QStringList sl = myName.split( ":", QString::SkipEmptyParts );
1241 QString _sec = sl.count() > 1 ? sl[ 0 ].trimmed() : QString( DEFAULT_SECTION );
1242 QString _nam = sl.count() > 1 ? sl[ 1 ].trimmed() : sl.count() > 0 ? sl[ 0 ].trimmed() : QString( "" );
1243 myResult = ( !_sec.isEmpty() && !_nam.isEmpty() ) ? resMgr->stringValue( _sec, _nam, "" ) : QString( "" );
1247 QString SalomePyQt::getSetting( const QString& name )
1249 return ProcessEvent( new TGetSettingEvent( name ) );
1253 \fn QString SalomePyQt::constant( const QString& name );
1254 \brief Get constant's value from application's resource manager.
1256 \param name name of the constant
1257 \return value of the constant
1262 class TGetConstantEvent: public SALOME_Event
1265 typedef QString TResult;
1268 TGetConstantEvent( const QString& name ) : myName( name ) {}
1269 virtual void Execute()
1271 if ( SUIT_Session::session() )
1272 myResult = SUIT_Session::session()->resourceMgr()->constant( myName );
1275 QString SalomePyQt::constant( const QString& name )
1277 return ProcessEvent( new TGetConstantEvent( name ) );
1281 \brief Add constant to the application's resource manager.
1283 This function is useful to specify programmatically specific
1284 variables that are referenced in the resource setting.
1286 For example, some resource value can be set as "$(myroot)/data/files".
1287 Then, "mypath" constant can be set programmatically by the application
1288 depending on run-time requirements.
1290 \param section resources file section name
1291 \param name name of the constant
1292 \param value value of the constant
1296 void SalomePyQt::setConstant( const QString& name, const QString& value )
1298 class TEvent: public SALOME_Event
1300 QString myName, myValue;
1302 TEvent( const QString& name, const QString& value )
1303 : myName( name ), myValue( value ) {}
1304 virtual void Execute()
1306 if ( SUIT_Session::session() )
1307 SUIT_Session::session()->resourceMgr()->setConstant( myName, myValue );
1310 ProcessVoidEvent( new TEvent( name, value ) );
1314 \brief Add double setting to the application preferences.
1315 \param section resources file section name
1316 \param name setting name
1317 \param value new setting value
1319 void SalomePyQt::addSetting( const QString& section, const QString& name, const double value )
1321 class TEvent: public SALOME_Event
1327 TEvent( const QString& section, const QString& name, double value )
1328 : mySection( section ), myName( name ), myValue( value ) {}
1329 virtual void Execute()
1331 if ( SUIT_Session::session() ) {
1332 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1333 if ( !mySection.isEmpty() && !myName.isEmpty() )
1334 resMgr->setValue( mySection, myName, myValue );
1338 ProcessVoidEvent( new TEvent( section, name, value ) );
1342 \brief Add integer setting to the application preferences.
1343 \param section resources file section name
1344 \param name setting name
1345 \param value new setting value
1347 void SalomePyQt::addSetting( const QString& section, const QString& name, const int value )
1349 class TEvent: public SALOME_Event
1355 TEvent( const QString& section, const QString& name, int 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 boolean setting to the application preferences.
1371 \param section resources file section name
1372 \param name setting name
1373 \param value new setting value
1374 \param dumb this parameter is used in order to avoid sip compilation error
1375 because of conflicting int and bool types
1377 void SalomePyQt::addSetting( const QString& section, const QString& name, const bool value, const int /*dumb*/ )
1379 class TEvent: public SALOME_Event
1385 TEvent( const QString& section, const QString& name, bool value )
1386 : mySection( section ), myName( name ), myValue( value ) {}
1387 virtual void Execute()
1389 if ( SUIT_Session::session() ) {
1390 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1391 if ( !mySection.isEmpty() && !myName.isEmpty() )
1392 resMgr->setValue( mySection, myName, myValue );
1396 ProcessVoidEvent( new TEvent( section, name, value ) );
1400 \brief Add string setting to the application preferences.
1401 \param section resources file section name
1402 \param name setting name
1403 \param value new setting value
1405 void SalomePyQt::addSetting( const QString& section, const QString& name, const QString& value )
1407 class TEvent: public SALOME_Event
1413 TEvent( const QString& section, const QString& name, const QString& value )
1414 : mySection( section ), myName( name ), myValue( value ) {}
1415 virtual void Execute()
1417 if ( SUIT_Session::session() ) {
1418 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1419 if ( !mySection.isEmpty() && !myName.isEmpty() )
1420 resMgr->setValue( mySection, myName, myValue );
1424 ProcessVoidEvent( new TEvent( section, name, value ) );
1428 \brief Add color setting to the application preferences.
1429 \param section resources file section name
1430 \param name setting name
1431 \param value new setting value
1433 void SalomePyQt::addSetting( const QString& section, const QString& name, const QColor& value )
1435 class TEvent: public SALOME_Event
1441 TEvent( const QString& section, const QString& name, const QColor& value )
1442 : mySection( section ), myName( name ), myValue( value ) {}
1443 virtual void Execute()
1445 if ( SUIT_Session::session() ) {
1446 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1447 if ( !mySection.isEmpty() && !myName.isEmpty() )
1448 resMgr->setValue( mySection, myName, myValue );
1452 ProcessVoidEvent( new TEvent( section, name, value ) );
1456 \brief Add byte array setting to the application preferences.
1457 \param section resources file section name
1458 \param name setting name
1459 \param value new setting value
1461 void SalomePyQt::addSetting( const QString& section, const QString& name, const QByteArray& value )
1463 class TEvent: public SALOME_Event
1469 TEvent( const QString& section, const QString& name, const QByteArray& value )
1470 : mySection( section ), myName( name ), myValue( value ) {}
1471 virtual void Execute()
1473 if ( SUIT_Session::session() ) {
1474 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1475 if ( !mySection.isEmpty() && !myName.isEmpty() )
1476 resMgr->setValue( mySection, myName, myValue );
1480 ProcessVoidEvent( new TEvent( section, name, value ) );
1484 \brief Add font setting to the application preferences.
1485 \param section resources file section name
1486 \param name setting name
1487 \param value new setting value
1489 void SalomePyQt::addSetting( const QString& section, const QString& name, const QFont& value )
1491 class TEvent: public SALOME_Event
1497 TEvent( const QString& section, const QString& name, const QFont& value )
1498 : mySection( section ), myName( name ), myValue( value ) {}
1499 virtual void Execute()
1501 if ( SUIT_Session::session() ) {
1502 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1503 if ( !mySection.isEmpty() && !myName.isEmpty() )
1504 resMgr->setValue( mySection, myName, myValue );
1508 ProcessVoidEvent( new TEvent( section, name, value ) );
1512 \fn int SalomePyQt::integerSetting( const QString& section,
1513 const QString& name,
1515 \brief Get integer setting from the application preferences.
1516 \param section resources file section name
1517 \param name setting name
1518 \param def default value which is returned if the setting is not found
1519 \return setting value
1522 class TGetIntSettingEvent: public SALOME_Event
1525 typedef int TResult;
1530 TGetIntSettingEvent( const QString& section, const QString& name, const int def )
1531 : mySection( section ), myName( name ), myDefault( def ) {}
1532 virtual void Execute()
1534 if ( SUIT_Session::session() ) {
1535 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1536 myResult = ( !mySection.isEmpty() && !myName.isEmpty() ) ? resMgr->integerValue( mySection, myName, myDefault ) : myDefault;
1540 int SalomePyQt::integerSetting( const QString& section, const QString& name, const int def )
1542 return ProcessEvent( new TGetIntSettingEvent( section, name, def ) );
1546 \fn double SalomePyQt::doubleSetting( const QString& section,
1547 const QString& name,
1549 \brief Get double setting from the application preferences.
1550 \param section resources file section name
1551 \param name setting name
1552 \param def default value which is returned if the setting is not found
1553 \return setting value
1556 class TGetDblSettingEvent: public SALOME_Event
1559 typedef double TResult;
1564 TGetDblSettingEvent( const QString& section, const QString& name, const double def )
1565 : mySection( section ), myName( name ), myDefault( def ) {}
1566 virtual void Execute()
1568 if ( SUIT_Session::session() ) {
1569 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1570 myResult = ( !mySection.isEmpty() && !myName.isEmpty() ) ? resMgr->doubleValue( mySection, myName, myDefault ) : myDefault;
1574 double SalomePyQt::doubleSetting( const QString& section, const QString& name, const double def )
1576 return ProcessEvent( new TGetDblSettingEvent( section, name, def ) );
1580 \fn bool SalomePyQt::boolSetting( const QString& section,
1581 const QString& name,
1583 \brief Get boolean setting from the application preferences.
1584 \param section resources file section name
1585 \param name setting name
1586 \param def default value which is returned if the setting is not found
1587 \return setting value
1590 class TGetBoolSettingEvent: public SALOME_Event
1593 typedef bool TResult;
1598 TGetBoolSettingEvent( const QString& section, const QString& name, const bool def )
1599 : mySection( section ), myName( name ), myDefault( def ) {}
1600 virtual void Execute()
1602 if ( SUIT_Session::session() ) {
1603 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1604 myResult = ( !mySection.isEmpty() && !myName.isEmpty() ) ? resMgr->booleanValue( mySection, myName, myDefault ) : myDefault;
1608 bool SalomePyQt::boolSetting( const QString& section, const QString& name, const bool def )
1610 return ProcessEvent( new TGetBoolSettingEvent( section, name, def ) );
1614 \fn QString SalomePyQt::stringSetting( const QString& section,
1615 const QString& name,
1618 \brief Get string setting from the application preferences.
1619 \param section resources file section name
1620 \param name setting name
1621 \param def default value which is returned if the setting is not found
1622 \param subst \c true to make substitution, \c false to get "raw" value
1623 \return setting value
1626 class TGetStrSettingEvent: public SALOME_Event
1629 typedef QString TResult;
1635 TGetStrSettingEvent( const QString& section, const QString& name, const QString& def, const bool subst )
1636 : mySection( section ), myName( name ), myDefault( def ), mySubst( subst ) {}
1637 virtual void Execute()
1639 if ( SUIT_Session::session() ) {
1640 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1641 myResult = ( !mySection.isEmpty() && !myName.isEmpty() ) ? resMgr->stringValue( mySection, myName, myDefault, mySubst ) : myDefault;
1645 QString SalomePyQt::stringSetting( const QString& section, const QString& name, const QString& def, const bool subst )
1647 return ProcessEvent( new TGetStrSettingEvent( section, name, def, subst ) );
1651 \fn QColor SalomePyQt::colorSetting( const QString& section,
1652 const QString& name,
1654 \brief Get color setting from the application preferences.
1655 \param section resources file section name
1656 \param name setting name
1657 \param def default value which is returned if the setting is not found
1658 \return setting value
1661 class TGetColorSettingEvent: public SALOME_Event
1664 typedef QColor TResult;
1669 TGetColorSettingEvent( const QString& section, const QString& name, const QColor& def )
1670 : mySection( section ), myName( name ), myDefault( def ) {}
1671 virtual void Execute()
1673 if ( SUIT_Session::session() ) {
1674 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1675 myResult = ( !mySection.isEmpty() && !myName.isEmpty() ) ? resMgr->colorValue( mySection, myName, myDefault ) : myDefault;
1679 QColor SalomePyQt::colorSetting ( const QString& section, const QString& name, const QColor& def )
1681 return ProcessEvent( new TGetColorSettingEvent( section, name, def ) );
1685 \fn QByteArray SalomePyQt::byteArraySetting( const QString& section,
1686 const QString& name,
1687 const QByteArray& def );
1688 \brief Get byte array setting from the application preferences.
1689 \param section resources file section name
1690 \param name setting name
1691 \param def default value which is returned if the setting is not found
1692 \return setting value
1695 class TGetByteArraySettingEvent: public SALOME_Event
1698 typedef QByteArray TResult;
1703 TGetByteArraySettingEvent( const QString& section, const QString& name, const QByteArray& def )
1704 : mySection( section ), myName( name ), myDefault( def ) {}
1705 virtual void Execute()
1707 if ( SUIT_Session::session() ) {
1708 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1709 myResult = ( !mySection.isEmpty() && !myName.isEmpty() ) ? resMgr->byteArrayValue( mySection, myName, myDefault ) : myDefault;
1713 QByteArray SalomePyQt::byteArraySetting ( const QString& section, const QString& name, const QByteArray& def )
1715 return ProcessEvent( new TGetByteArraySettingEvent( section, name, def ) );
1719 \fn QByteArray SalomePyQt::fontSetting( const QString& section,
1720 const QString& name,
1722 \brief Get font setting from the application preferences.
1723 \param section resources file section name
1724 \param name setting name
1725 \param def default value which is returned if the setting is not found
1726 \return setting value
1729 class TGetFontSettingEvent: public SALOME_Event
1732 typedef QFont TResult;
1737 TGetFontSettingEvent( const QString& section, const QString& name, const QFont& def )
1738 : mySection( section ), myName( name ), myDefault( def ) {}
1739 virtual void Execute()
1741 if ( SUIT_Session::session() ) {
1742 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1743 myResult = ( !mySection.isEmpty() && !myName.isEmpty() ) ? resMgr->fontValue( mySection, myName, myDefault ) : myDefault;
1747 QFont SalomePyQt::fontSetting ( const QString& section, const QString& name, const QFont& def )
1749 return ProcessEvent( new TGetFontSettingEvent( section, name, def ) );
1753 \brief Remove setting from the application preferences.
1754 \param section resources file section name
1755 \param name setting name
1757 void SalomePyQt::removeSetting( const QString& section, const QString& name )
1759 class TEvent: public SALOME_Event
1764 TEvent( const QString& section, const QString& name ) : mySection( section ), myName( name ) {}
1765 virtual void Execute()
1767 if ( SUIT_Session::session() ) {
1768 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1769 if ( !mySection.isEmpty() && !myName.isEmpty() )
1770 resMgr->remove( mySection, myName );
1774 ProcessVoidEvent( new TEvent( section, name ) );
1778 \fn bool SalomePyQt::hasSetting( const QString& section, const QString& name );
1779 \brief Check setting existence in the application preferences.
1780 \param section resources file section name
1781 \param name setting name
1782 \return \c true if setting exists
1785 class THasSettingEvent: public SALOME_Event
1788 typedef bool TResult;
1792 THasSettingEvent( const QString& section, const QString& name )
1793 : mySection( section ), myName( name ) {}
1794 virtual void Execute()
1796 if ( SUIT_Session::session() ) {
1797 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1798 myResult = resMgr->hasValue( mySection, myName );
1802 bool SalomePyQt::hasSetting( const QString& section, const QString& name )
1804 return ProcessEvent( new THasSettingEvent( section, name ) );
1808 \fn QStringList SalomePyQt::parameters( const QString& section );
1809 \brief Get names of preference items stored within the given section.
1810 \param section resources file section's name
1811 \return \c list of preferences items
1815 \fn QStringList SalomePyQt::parameters( const QStringList& section );
1816 \brief Get names of preference items stored within the given section.
1817 \param section resources file section's name
1818 \return \c list of preferences items
1821 class TParametersEvent: public SALOME_Event
1824 typedef QStringList TResult;
1826 QStringList mySection;
1827 TParametersEvent( const QString& section )
1829 mySection << section;
1831 TParametersEvent( const QStringList& section )
1832 : mySection( section )
1834 virtual void Execute()
1836 if ( SUIT_Session::session() ) {
1837 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1838 myResult = resMgr->parameters( mySection );
1842 QStringList SalomePyQt::parameters( const QString& section )
1844 return ProcessEvent( new TParametersEvent( section ) );
1846 QStringList SalomePyQt::parameters( const QStringList& section )
1848 return ProcessEvent( new TParametersEvent( section ) );
1852 \fn QString SalomePyQt::getFileName( QWidget* parent,
1853 const QString& initial,
1854 const QStringList& filters,
1855 const QString& caption,
1857 \brief Show 'Open/Save file' dialog box for file selection
1858 and return a user's choice (selected file name).
1859 \param parent parent widget
1860 \param initial initial directory the dialog box to be opened in
1861 \param filters list of files filters (wildcards)
1862 \param caption dialog box title
1863 \param open if \c true, "Open File" dialog box is shown;
1864 otherwise "Save File" dialog box is shown
1865 \return selected file name (null string if user cancels operation)
1868 class TGetFileNameEvent: public SALOME_Event
1871 typedef QString TResult;
1875 QStringList myFilters;
1878 TGetFileNameEvent( QWidget* parent,
1879 const QString& initial,
1880 const QStringList& filters,
1881 const QString& caption,
1883 : myParent ( parent ),
1884 myInitial( initial ),
1885 myFilters( filters ),
1886 myCaption( caption ),
1888 virtual void Execute()
1890 if ( LightApp_Application* anApp = getApplication() ) {
1891 myResult = anApp->getFileName( myOpen, myInitial, myFilters.join(";;"),
1892 myCaption, myParent );
1896 QString SalomePyQt::getFileName( QWidget* parent,
1897 const QString& initial,
1898 const QStringList& filters,
1899 const QString& caption,
1902 return ProcessEvent( new TGetFileNameEvent( parent, initial, filters, caption, open ) );
1906 \fn QStringList SalomePyQt::getOpenFileNames( QWidget* parent,
1907 const QString& initial,
1908 const QStringList& filters,
1909 const QString& caption );
1910 \brief Show 'Open files' dialog box for multiple files selection
1911 and return a user's choice (selected file names list).
1912 \param parent parent widget
1913 \param initial initial directory the dialog box to be opened in
1914 \param filters list of files filters (wildcards)
1915 \param caption dialog box title
1916 \return selected file names list (empty list if user cancels operation)
1919 class TGetOpenFileNamesEvent: public SALOME_Event
1922 typedef QStringList TResult;
1926 QStringList myFilters;
1928 TGetOpenFileNamesEvent( QWidget* parent,
1929 const QString& initial,
1930 const QStringList& filters,
1931 const QString& caption )
1932 : myParent ( parent ),
1933 myInitial( initial ),
1934 myFilters( filters ),
1935 myCaption( caption ) {}
1936 virtual void Execute()
1938 if ( LightApp_Application* anApp = getApplication() ) {
1939 myResult = anApp->getOpenFileNames( myInitial, myFilters.join(";;"), myCaption, myParent );
1943 QStringList SalomePyQt::getOpenFileNames( QWidget* parent,
1944 const QString& initial,
1945 const QStringList& filters,
1946 const QString& caption )
1948 return ProcessEvent( new TGetOpenFileNamesEvent( parent, initial, filters, caption ) );
1952 \fn QString SalomePyQt::getExistingDirectory( QWidget* parent,
1953 const QString& initial,
1954 const QString& caption );
1955 \brief Show 'Get Directory' dialog box for the directory selection
1956 and return a user's choice (selected directory name).
1957 \param parent parent widget
1958 \param initial initial directory the dialog box to be opened in
1959 \param caption dialog box title
1960 \return selected directory name (null string if user cancels operation)
1963 class TGetExistingDirectoryEvent: public SALOME_Event
1966 typedef QString TResult;
1971 TGetExistingDirectoryEvent( QWidget* parent,
1972 const QString& initial,
1973 const QString& caption )
1974 : myParent ( parent ),
1975 myInitial( initial ),
1976 myCaption( caption ) {}
1977 virtual void Execute()
1979 if ( LightApp_Application* anApp = getApplication() ) {
1980 myResult = anApp->getDirectory( myInitial, myCaption, myParent );
1984 QString SalomePyQt::getExistingDirectory( QWidget* parent,
1985 const QString& initial,
1986 const QString& caption )
1988 return ProcessEvent( new TGetExistingDirectoryEvent( parent, initial, caption ) );
1992 \fn QString SalomePyQt::loadIcon( const QString& filename );
1993 \brief Load an icon from the module resources by the specified file name.
1994 \param fileName icon file name
1998 class TLoadIconEvent: public SALOME_Event
2001 typedef QIcon TResult;
2005 TLoadIconEvent( const QString& module, const QString& filename )
2006 : myModule( module ),
2007 myFileName ( filename ) {}
2008 virtual void Execute()
2010 myResult = loadIconInternal( myModule, myFileName );
2013 QIcon SalomePyQt::loadIcon( const QString& module, const QString& filename )
2015 return ProcessEvent( new TLoadIconEvent( module, filename ) );
2019 \brief Open external browser to display context help information.
2022 Current implementation does nothing.
2024 \param source documentation (HTML) file name
2025 \param context context (for example, HTML ancor name)
2027 void SalomePyQt::helpContext( const QString& source, const QString& context )
2029 class TEvent: public SALOME_Event
2034 TEvent( const QString& source, const QString& context )
2035 : mySource( source ), myContext( context ) {}
2036 virtual void Execute()
2038 if ( LightApp_Application* anApp = getApplication() ) {
2039 anApp->onHelpContextModule( "", mySource, myContext );
2043 ProcessVoidEvent( new TEvent( source, context ) );
2047 \fn int SalomePyQt::defaultMenuGroup();
2048 \brief Get detault menu group identifier which can be used when
2049 creating menus (insert custom menu commands).
2050 \return default menu group ID
2053 class TDefMenuGroupEvent: public SALOME_Event
2056 typedef int TResult;
2058 TDefMenuGroupEvent() : myResult( -1 ) {}
2059 virtual void Execute()
2061 myResult = PyModuleHelper::defaultMenuGroup();
2064 int SalomePyQt::defaultMenuGroup()
2066 return ProcessEvent( new TDefMenuGroupEvent() );
2072 CrTool( const QString& tBar, const QString& nBar )
2073 : myCase( 0 ), myTbTitle( tBar ), myTbName( nBar) {}
2074 CrTool( const int id, const int tBar, const int idx )
2075 : myCase( 1 ), myId( id ), myTbId( tBar ), myIndex( idx ) {}
2076 CrTool( const int id, const QString& tBar, const int idx )
2077 : myCase( 2 ), myId( id ), myTbTitle( tBar ), myIndex( idx ) {}
2078 CrTool( QAction* action, const int tbId, const int id, const int idx )
2079 : myCase( 3 ), myAction( action ), myTbId( tbId ), myId( id ), myIndex( idx ) {}
2080 CrTool( QAction* action, const QString& tBar, const int id, const int idx )
2081 : myCase( 4 ), myAction( action ), myTbTitle( tBar ), myId( id ), myIndex( idx ) {}
2083 int execute( LightApp_Module* module ) const
2088 return module->createTool( myTbTitle, myTbName );
2090 return module->createTool( myId, myTbId, myIndex );
2092 return module->createTool( myId, myTbTitle, myIndex );
2094 return module->createTool( myAction, myTbId, myId, myIndex );
2096 return module->createTool( myAction, myTbTitle, myId, myIndex );
2111 class TCreateToolEvent: public SALOME_Event
2114 typedef int TResult;
2116 const CrTool& myCrTool;
2117 TCreateToolEvent( const CrTool& crTool )
2118 : myResult( -1 ), myCrTool( crTool ) {}
2119 virtual void Execute()
2121 LightApp_Module* module = getActiveModule();
2123 myResult = myCrTool.execute( module );
2128 \brief Create toolbar with specified name.
2129 \param tBar toolbar title (language-dependent)
2130 \param nBar toolbar name (language-independent) [optional]
2131 \return toolbar ID or -1 if toolbar creation is failed
2133 int SalomePyQt::createTool( const QString& tBar, const QString& nBar )
2135 return ProcessEvent( new TCreateToolEvent( CrTool( tBar, nBar ) ) );
2139 \brief Insert action with specified \a id to the toolbar.
2141 \param tBar toolbar ID
2142 \param idx required index in the toolbar
2143 \return action ID or -1 if action could not be added
2145 int SalomePyQt::createTool( const int id, const int tBar, const int idx )
2147 return ProcessEvent( new TCreateToolEvent( CrTool( id, tBar, idx ) ) );
2151 \brief Insert action with specified \a id to the toolbar.
2153 \param tBar toolbar name
2154 \param idx required index in the toolbar
2155 \return action ID or -1 if action could not be added
2157 int SalomePyQt::createTool( const int id, const QString& tBar, const int idx )
2159 return ProcessEvent( new TCreateToolEvent( CrTool( id, tBar, idx ) ) );
2163 \brief Insert action to the toolbar.
2165 \param tBar toolbar ID
2166 \param id required action ID
2167 \param idx required index in the toolbar
2168 \return action ID or -1 if action could not be added
2170 int SalomePyQt::createTool( QAction* a, const int tBar, const int id, const int idx )
2172 return ProcessEvent( new TCreateToolEvent( CrTool( a, tBar, id, idx ) ) );
2176 \brief Insert action to the toolbar.
2178 \param tBar toolbar name
2179 \param id required action ID
2180 \param idx required index in the toolbar
2181 \return action ID or -1 if action could not be added
2183 int SalomePyQt::createTool( QAction* a, const QString& tBar, const int id, const int idx )
2185 return ProcessEvent( new TCreateToolEvent( CrTool( a, tBar, id, idx ) ) );
2191 CrMenu( const QString& subMenu, const int menu, const int id, const int group, const int idx )
2192 : myCase( 0 ), mySubMenuName( subMenu ), myMenuId( menu ), myId( id ), myGroup( group ), myIndex( idx ) {}
2193 CrMenu( const QString& subMenu, const QString& menu, const int id, const int group, const int idx )
2194 : myCase( 1 ), mySubMenuName( subMenu ), myMenuName( menu ), myId( id ), myGroup( group ), myIndex( idx ) {}
2195 CrMenu( const int id, const int menu, const int group, const int idx )
2196 : myCase( 2 ), myId( id ), myMenuId( menu ), myGroup( group ), myIndex( idx ) {}
2197 CrMenu( const int id, const QString& menu, const int group, const int idx )
2198 : myCase( 3 ), myId( id ), myMenuName( menu ), myGroup( group ), myIndex( idx ) {}
2199 CrMenu( QAction* action, const int menu, const int id, const int group, const int idx )
2200 : myCase( 4 ), myAction( action ), myMenuId( menu ), myId( id ), myGroup( group ), myIndex( idx ) {}
2201 CrMenu( QAction* action, const QString& menu, const int id, const int group, const int idx )
2202 : myCase( 5 ), myAction( action ), myMenuName( menu ), myId( id ), myGroup( group ), myIndex( idx ) {}
2204 int execute( LightApp_Module* module ) const
2209 return module->createMenu( mySubMenuName, myMenuId, myId, myGroup, myIndex );
2211 return module->createMenu( mySubMenuName, myMenuName, myId, myGroup, myIndex );
2213 return module->createMenu( myId, myMenuId, myGroup, myIndex );
2215 return module->createMenu( myId, myMenuName, myGroup, myIndex );
2217 return module->createMenu( myAction, myMenuId, myId, myGroup, myIndex );
2219 return module->createMenu( myAction, myMenuName, myId, myGroup, myIndex );
2228 QString mySubMenuName;
2235 class TCreateMenuEvent: public SALOME_Event
2238 typedef int TResult;
2240 const CrMenu& myCrMenu;
2241 TCreateMenuEvent( const CrMenu& crMenu )
2242 : myResult( -1 ), myCrMenu( crMenu ) {}
2243 virtual void Execute()
2245 LightApp_Module* module = getActiveModule();
2247 myResult = myCrMenu.execute( module );
2252 \brief Create main menu.
2253 \param subMenu menu name
2254 \param menu parent menu ID
2255 \param id required menu ID
2256 \param group menu group ID
2257 \param idx required index in the menu
2258 \return menu ID or -1 if menu could not be added
2260 int SalomePyQt::createMenu( const QString& subMenu, const int menu, const int id, const int group, const int idx )
2262 return ProcessEvent( new TCreateMenuEvent( CrMenu( subMenu, menu, id, group, idx ) ) );
2266 \brief Create main menu.
2267 \param subMenu menu name
2268 \param menu parent menu name (list of menu names separated by "|")
2269 \param id required menu ID
2270 \param group menu group ID
2271 \param idx required index in the menu
2272 \return menu ID or -1 if menu could not be added
2274 int SalomePyQt::createMenu( const QString& subMenu, const QString& menu, const int id, const int group, const int idx )
2276 return ProcessEvent( new TCreateMenuEvent( CrMenu( subMenu, menu, id, group, idx ) ) );
2280 \brief Insert action to the main menu.
2282 \param menu parent menu ID
2283 \param group menu group ID
2284 \param idx required index in the menu
2285 \return action ID or -1 if action could not be added
2287 int SalomePyQt::createMenu( const int id, const int menu, const int group, const int idx )
2289 return ProcessEvent( new TCreateMenuEvent( CrMenu( id, menu, group, idx ) ) );
2293 \brief Insert action to the main menu.
2295 \param menu parent menu name (list of menu names separated by "|")
2296 \param group menu group ID
2297 \param idx required index in the menu
2298 \return action ID or -1 if action could not be added
2300 int SalomePyQt::createMenu( const int id, const QString& menu, const int group, const int idx )
2302 return ProcessEvent( new TCreateMenuEvent( CrMenu( id, menu, group, idx ) ) );
2306 \brief Insert action to the main menu.
2308 \param menu parent menu ID
2309 \param group menu group ID
2310 \param idx required index in the menu
2311 \return action ID or -1 if action could not be added
2313 int SalomePyQt::createMenu( QAction* a, const int menu, const int id, const int group, const int idx )
2315 return ProcessEvent( new TCreateMenuEvent( CrMenu( a, menu, id, group, idx ) ) );
2319 \brief Insert action to the main menu.
2321 \param menu parent menu name (list of menu names separated by "|")
2322 \param group menu group ID
2323 \param idx required index in the menu
2324 \return action ID or -1 if action could not be added
2326 int SalomePyQt::createMenu( QAction* a, const QString& menu, const int id, const int group, const int idx )
2328 return ProcessEvent( new TCreateMenuEvent( CrMenu( a, menu, id, group, idx ) ) );
2332 \fn QAction* SalomePyQt::createSeparator();
2333 \brief Create separator action which can be used in the menu or toolbar.
2334 \return new separator action
2337 class TCreateSepEvent: public SALOME_Event
2340 typedef QAction* TResult;
2344 virtual void Execute()
2346 LightApp_Module* module = getActiveModule();
2348 myResult = (QAction*)module->separator();
2351 QAction* SalomePyQt::createSeparator()
2353 return ProcessEvent( new TCreateSepEvent() );
2357 \fn QAction* SalomePyQt::createAction( const int id,
2358 const QString& menuText,
2359 const QString& tipText,
2360 const QString& statusText,
2361 const QString& icon,
2363 const bool toggle );
2364 \brief Create an action which can be then used in the menu or toolbar.
2365 \param id the unique id action to be registered to
2366 \param menuText action text which should appear in menu
2367 \param tipText text which should appear in the tooltip
2368 \param statusText text which should appear in the status bar when action is activated
2369 \param icon the name of the icon file (the actual icon file name can be coded in the translation files)
2370 \param key the key accelrator for the action
2371 \param toggle if \c true the action is checkable
2374 class TCreateActionEvent: public SALOME_Event
2377 typedef QAction* TResult;
2382 QString myStatusText;
2386 TCreateActionEvent( const int id, const QString& menuText, const QString& tipText,
2387 const QString& statusText, const QString& icon, const int key, const bool toggle )
2388 : myResult( 0 ), myId( id ), myMenuText( menuText ), myTipText( tipText ),
2389 myStatusText( statusText ), myIcon( icon ), myKey( key ), myToggle( toggle ) {}
2390 virtual void Execute()
2392 LightApp_Module* module = getActiveModule();
2394 QIcon icon = loadIconInternal( module->name(), myIcon );
2395 myResult = (QAction*)module->action( myId );
2397 if ( myResult->toolTip().isEmpty() && !myTipText.isEmpty() )
2398 myResult->setToolTip( myTipText );
2399 if ( myResult->text().isEmpty() && !myMenuText.isEmpty() )
2400 myResult->setText( myMenuText );
2401 if ( myResult->icon().isNull() && !icon.isNull() )
2402 myResult->setIcon( icon );
2403 if ( myResult->statusTip().isEmpty() && !myStatusText.isEmpty() )
2404 myResult->setStatusTip( myStatusText );
2405 if ( myResult->shortcut().isEmpty() && myKey )
2406 myResult->setShortcut( myKey );
2407 if ( myResult->isCheckable() != myToggle )
2408 myResult->setCheckable( myToggle );
2411 myResult = (QAction*)module->createAction( myId, myTipText, icon, myMenuText, myStatusText, myKey, module, myToggle );
2413 // for Python module, automatically connect action to callback slot
2414 PyModuleHelper* helper = module->findChild<PyModuleHelper*>( "python_module_helper" );
2415 if ( helper ) helper->connectAction( myResult );
2419 QAction* SalomePyQt::createAction( const int id, const QString& menuText,
2420 const QString& tipText, const QString& statusText,
2421 const QString& icon, const int key, const bool toggle )
2423 return ProcessEvent( new TCreateActionEvent( id, menuText, tipText, statusText, icon, key, toggle ) );
2427 \fn QtxActionGroup* SalomePyQt::createActionGroup( const int id, const bool exclusive );
2428 \brief Create an action group which can be then used in the menu or toolbar
2429 \param id : the unique id action group to be registered to
2430 \param exclusive : if \c true the action group does exclusive toggling
2433 struct TCreateActionGroupEvent: public SALOME_Event
2435 typedef QtxActionGroup* TResult;
2439 TCreateActionGroupEvent( const int id, const bool exclusive )
2440 : myId( id ), myExclusive( exclusive ) {}
2441 virtual void Execute()
2443 LightApp_Module* module = getActiveModule();
2445 myResult = module->createActionGroup( myId, myExclusive );
2448 QtxActionGroup* SalomePyQt::createActionGroup( const int id, const bool exclusive )
2450 return ProcessEvent( new TCreateActionGroupEvent( id, exclusive ) );
2454 \fn QAction* SalomePyQt::action( const int id );
2455 \brief Get action by specified identifier.
2456 \return action or 0 if action is not registered
2459 class TActionEvent: public SALOME_Event
2462 typedef QAction* TResult;
2465 TActionEvent( const int id )
2466 : myResult( 0 ), myId( id ) {}
2467 virtual void Execute()
2469 LightApp_Module* module = getActiveModule();
2471 myResult = (QAction*)module->action( myId );
2474 QAction* SalomePyQt::action( const int id )
2476 return ProcessEvent( new TActionEvent( id ) );
2480 \fn int SalomePyQt::actionId( const QAction* a );
2481 \brief Get an action identifier.
2482 \return action ID or -1 if action is not registered
2485 class TActionIdEvent: public SALOME_Event
2488 typedef int TResult;
2490 const QAction* myAction;
2491 TActionIdEvent( const QAction* action )
2492 : myResult( -1 ), myAction( action ) {}
2493 virtual void Execute()
2495 LightApp_Module* module = getActiveModule();
2497 myResult = module->actionId( myAction );
2500 int SalomePyQt::actionId( const QAction* a )
2502 return ProcessEvent( new TActionIdEvent( a ) );
2506 \fn int SalomePyQt::addGlobalPreference( const QString& label );
2507 \brief Add global (not module-related) preferences group.
2508 \param label global preferences group name
2509 \return preferences group identifier
2512 class TAddGlobalPrefEvent: public SALOME_Event
2515 typedef int TResult;
2518 TAddGlobalPrefEvent( 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 myResult = pref->addPreference( myLabel, -1 );
2530 int SalomePyQt::addGlobalPreference( const QString& label )
2532 return ProcessEvent( new TAddGlobalPrefEvent( label ) );
2536 \fn int SalomePyQt::addPreference( const QString& label );
2537 \brief Add module-related preferences group.
2538 \param label preferences group name
2539 \return preferences group identifier
2542 class TAddPrefEvent: public SALOME_Event
2545 typedef int TResult;
2548 TAddPrefEvent( const QString& label )
2549 : myResult( -1 ), myLabel( label ) {}
2550 virtual void Execute()
2552 LightApp_Module* module = getActiveModule();
2554 LightApp_Preferences* pref = module->getApp()->preferences();
2556 int cId = pref->addPreference( module->moduleName(), -1 );
2558 myResult = pref->addPreference( myLabel, cId );
2563 int SalomePyQt::addPreference( const QString& label )
2565 return ProcessEvent( new TAddPrefEvent( label ) );
2569 \fn int SalomePyQt::addPreference( const QString& label, const int pId, const int type,
2570 const QString& section, const QString& param );
2571 \brief Add module-related preferences.
2572 \param label preferences group name
2573 \param pId parent preferences group id
2574 \param type preferences type
2575 \param section resources file section name
2576 \param param resources file setting name
2577 \return preferences identifier
2580 class TAddPrefParamEvent: public SALOME_Event
2583 typedef int TResult;
2590 TAddPrefParamEvent( const QString& label,
2591 const int pId, const int type,
2592 const QString& section,
2593 const QString& param )
2595 myLabel( label ), myPId( pId ), myType( type ),
2596 mySection( section ), myParam ( param ) {}
2597 virtual void Execute()
2599 LightApp_Module* module = getActiveModule();
2601 LightApp_Preferences* pref = module->getApp()->preferences();
2603 myResult = pref->addPreference( module->moduleName(), myLabel, myPId, myType, mySection, myParam );
2607 int SalomePyQt::addPreference( const QString& label, const int pId, const int type,
2608 const QString& section, const QString& param )
2610 return ProcessEvent( new TAddPrefParamEvent( label, pId, type, section, param ) );
2614 \fn QVariant SalomePyQt::preferenceProperty( const int id, const QString& prop );
2615 \brief Get the preferences property.
2616 \param id preferences identifier
2617 \param prop preferences property name
2618 \return preferences property value or null QVariant if property is not set
2621 class TPrefPropEvent: public SALOME_Event
2624 typedef QVariant TResult;
2628 TPrefPropEvent( const int id, const QString& prop )
2629 : myId( id ), myProp( prop ) {}
2630 virtual void Execute()
2632 LightApp_Module* module = getActiveModule();
2634 LightApp_Preferences* pref = module->getApp()->preferences();
2636 myResult = pref->itemProperty( myProp, myId );
2640 QVariant SalomePyQt::preferenceProperty( const int id, const QString& prop )
2642 return ProcessEvent( new TPrefPropEvent( id, prop ) );
2646 \brief Set the preferences property.
2647 \param id preferences identifier
2648 \param prop preferences property name
2649 \param var preferences property value
2651 void SalomePyQt::setPreferenceProperty( const int id,
2652 const QString& prop,
2653 const QVariant& var )
2655 class TEvent: public SALOME_Event
2661 TEvent( const int id, const QString& prop, const QVariant& var )
2662 : myId( id ), myProp( prop ), myVar( var ) {}
2663 virtual void Execute()
2665 LightApp_Module* module = getActiveModule();
2667 LightApp_Preferences* pref = module->getApp()->preferences();
2669 pref->setItemProperty( myProp, myVar, myId );
2673 ProcessVoidEvent( new TEvent( id, prop, var ) );
2677 \brief Set specific widget as a custom preferences item.
2678 \param id preferences identifier
2679 \param prop preferences property name
2680 \param widget custom widget
2682 void SalomePyQt::setPreferencePropertyWg( const int id,
2683 const QString& prop,
2684 UserDefinedContent* widget )
2686 class TEvent: public SALOME_Event
2690 UserDefinedContent* myWidget;
2692 TEvent( const int id, const QString& prop, UserDefinedContent* widget )
2693 : myId( id ), myProp( prop ), myWidget( widget ) {}
2694 virtual void Execute()
2696 LightApp_Module* module = getActiveModule();
2698 LightApp_Preferences* pref = module->getApp()->preferences();
2700 pref->setItemProperty( myProp, (qint64) new SgPyQtUserDefinedContent( myWidget ), myId );
2705 ProcessVoidEvent( new TEvent( id, prop, widget ) );
2709 \brief Add the property value to the list of values.
2711 This method allows creating properties which are QList<QVariant>
2712 - there is no way to pass such values directly to QVariant parameter with PyQt.
2714 \param id preferences identifier
2715 \param prop preferences property name
2716 \param idx preferences property index
2717 \param var preferences property value for the index \a idx
2719 void SalomePyQt::addPreferenceProperty( const int id,
2720 const QString& prop,
2722 const QVariant& var )
2724 class TEvent: public SALOME_Event
2731 TEvent( const int id, const QString& prop, const int idx, const QVariant& var )
2732 : myId( id ), myProp( prop ), myIdx( idx), myVar( var ) {}
2733 virtual void Execute()
2735 LightApp_Module* module = getActiveModule();
2737 LightApp_Preferences* pref = module->getApp()->preferences();
2739 QVariant var = pref->itemProperty( myProp, myId );
2740 if ( var.isValid() ) {
2741 if ( var.type() == QVariant::StringList ) {
2742 QStringList sl = var.toStringList();
2743 if ( myIdx >= 0 && myIdx < sl.count() )
2744 sl[myIdx] = myVar.toString();
2746 sl.append( myVar.toString() );
2747 pref->setItemProperty( myProp, sl, myId );
2749 else if ( var.type() == QVariant::List ) {
2750 QList<QVariant> vl = var.toList();
2751 if ( myIdx >= 0 && myIdx < vl.count() )
2755 pref->setItemProperty( myProp, vl, myId );
2761 pref->setItemProperty( myProp, vl, myId );
2767 ProcessVoidEvent( new TEvent( id, prop, idx, var) );
2771 \brief Put the message to the Log messages output window
2772 \param msg message text (it can be of simple rich text format)
2773 \param addSeparator boolean flag which specifies if it is necessary
2774 to separate the message with predefined separator
2776 void SalomePyQt::message( const QString& msg, bool addSeparator )
2778 class TEvent: public SALOME_Event
2783 TEvent( const QString& msg, bool addSeparator )
2784 : myMsg( msg ), myAddSep( addSeparator ) {}
2785 virtual void Execute()
2787 if ( LightApp_Application* anApp = getApplication() ) {
2788 LogWindow* lw = anApp->logWindow();
2790 lw->putMessage( myMsg, myAddSep );
2794 ProcessVoidEvent( new TEvent( msg, addSeparator ) );
2798 \brief Remove all the messages from the Log messages output window.
2800 void SalomePyQt::clearMessages()
2802 class TEvent: public SALOME_Event
2806 virtual void Execute()
2808 if ( LightApp_Application* anApp = getApplication() ) {
2809 LogWindow* lw = anApp->logWindow();
2815 ProcessVoidEvent( new TEvent() );
2819 \fn bool SalomePyQt::dumpView( const QString& filename, const int id = 0 );
2820 \brief Dump the contents of the id view window. If id is 0 then current active view is processed.
2821 to the image file in the specified format.
2823 For the current moment JPEG, PNG and BMP images formats are supported.
2824 The image format is defined automatically by the file name extension.
2825 By default, BMP format is used.
2827 \param filename image file name
2828 \return operation status (\c true on success)
2831 class TDumpViewEvent: public SALOME_Event
2834 typedef bool TResult;
2838 TDumpViewEvent( const QString& filename, const int id )
2839 : myResult ( false ), myFileName( filename ), myWndId( id ) {}
2840 virtual void Execute()
2842 SUIT_ViewWindow* wnd = 0;
2844 if ( LightApp_Application* anApp = getApplication() ) {
2845 SUIT_ViewManager* vm = anApp->activeViewManager();
2847 wnd = vm->getActiveView();
2849 myWndId = wnd->getId();
2852 wnd = dynamic_cast<SUIT_ViewWindow*>( getWnd( myWndId ) );
2855 QString fmt = SUIT_Tools::extension( myFileName ).toUpper();
2856 #ifndef DISABLE_PLOT2DVIEWER
2857 Plot2d_ViewWindow* wnd2D = dynamic_cast<Plot2d_ViewWindow*>( wnd );
2859 qApp->postEvent( wnd2D->getViewFrame(), new QPaintEvent( QRect( 0, 0, wnd2D->getViewFrame()->width(), wnd2D->getViewFrame()->height() ) ) );
2860 qApp->postEvent( wnd2D, new QPaintEvent( QRect( 0, 0, wnd2D->width(), wnd2D->height() ) ) );
2861 qApp->processEvents();
2862 if ( fmt == "PS" || fmt == "EPS" || fmt == "PDF" ) {
2863 myResult = wnd2D->getViewFrame()->print( myFileName, fmt );
2867 #endif // DISABLE_PLOT2DVIEWER
2868 QImage im = wnd->dumpView();
2869 if ( !im.isNull() && !myFileName.isEmpty() ) {
2870 if ( fmt.isEmpty() ) fmt = QString( "BMP" ); // default format
2871 if ( fmt == "JPG" ) fmt = "JPEG";
2872 myResult = im.save( myFileName, fmt.toLatin1() );
2877 bool SalomePyQt::dumpView( const QString& filename, const int id )
2879 return ProcessEvent( new TDumpViewEvent( filename, id ) );
2883 \fn QList<int> SalomePyQt::getViews();
2884 \brief Get list of integer identifiers of all the currently opened views
2885 \return list of integer identifiers of all the currently opened views
2888 class TGetViews: public SALOME_Event
2891 typedef QList<int> TResult;
2894 virtual void Execute()
2897 LightApp_Application* app = getApplication();
2899 STD_TabDesktop* tabDesk = dynamic_cast<STD_TabDesktop*>( app->desktop() );
2901 QList<SUIT_ViewWindow*> wndlist = tabDesk->windows();
2902 SUIT_ViewWindow* wnd;
2903 foreach ( wnd, wndlist )
2904 myResult.append( wnd->getId() );
2909 QList<int> SalomePyQt::getViews()
2911 return ProcessEvent( new TGetViews() );
2915 \fn int SalomePyQt::getActiveView();
2916 \brief Get integer identifier of the currently active view
2917 \return integer identifier of the currently active view
2920 class TGetActiveView: public SALOME_Event
2923 typedef int TResult;
2927 virtual void Execute()
2929 LightApp_Application* app = getApplication();
2931 SUIT_ViewManager* viewMgr = app->activeViewManager();
2933 SUIT_ViewWindow* wnd = viewMgr->getActiveView();
2935 myResult = wnd->getId();
2940 int SalomePyQt::getActiveView()
2942 return ProcessEvent( new TGetActiveView() );
2946 \fn QString SalomePyQt::getViewType( const int id );
2947 \brief Get type of the specified view, e.g. "OCCViewer"
2948 \param id window identifier
2952 class TGetViewType: public SALOME_Event
2955 typedef QString TResult;
2958 TGetViewType( const int id )
2960 virtual void Execute()
2962 SUIT_ViewWindow* wnd = getWnd( myWndId );
2964 SUIT_ViewManager* viewMgr = wnd->getViewManager();
2966 myResult = viewMgr->getType();
2970 QString SalomePyQt::getViewType( const int id )
2972 return ProcessEvent( new TGetViewType( id ) );
2976 \fn bool SalomePyQt::setViewTitle( const int id, const QString& title );
2977 \brief Change view caption
2978 \param id window identifier
2979 \param title new window title
2980 \return \c true if operation is completed successfully and \c false otherwise
2983 class TSetViewTitle: public SALOME_Event
2986 typedef bool TResult;
2990 TSetViewTitle( const int id, const QString& title )
2991 : myResult( false ),
2994 virtual void Execute()
2996 SUIT_ViewWindow* wnd = getWnd( myWndId );
2998 wnd->setWindowTitle( myTitle );
3003 bool SalomePyQt::setViewTitle( const int id, const QString& title )
3005 return ProcessEvent( new TSetViewTitle( id, title ) );
3009 \fn bool SalomePyQt::setViewSize( const int w, const int h, const int id );
3010 \brief Set view size
3011 \param w window width
3012 \param h window height
3013 \param id window identifier
3014 \return \c true if operation is completed successfully and \c false otherwise
3017 class TSetViewSize: public SALOME_Event
3020 typedef bool TResult;
3025 TSetViewSize( const int w, const int h, const int id )
3026 : myResult( false ),
3030 virtual void Execute()
3032 SUIT_ViewWindow* wnd = 0;
3034 if ( LightApp_Application* anApp = getApplication() ) {
3035 SUIT_ViewManager* vm = anApp->activeViewManager();
3037 wnd = vm->getActiveView();
3041 wnd = dynamic_cast<SUIT_ViewWindow*>( getWnd( myWndId ) );
3044 SUIT_ViewManager* viewMgr = wnd->getViewManager();
3046 QString type = viewMgr->getType();
3047 if ( type == "OCCViewer") {
3048 #ifndef DISABLE_OCCVIEWER
3049 // specific processing for OCC viewer:
3050 // OCC view can embed up to 4 sub-views, split according to the specified layout;
3051 // - if there is only one sub-view active; it will be resized;
3052 // - if there are several sub-views, each of them will be resized.
3053 OCCViewer_ViewWindow* occView = qobject_cast<OCCViewer_ViewWindow*>( wnd );
3054 for ( int i = OCCViewer_ViewFrame::BOTTOM_RIGHT; i <= OCCViewer_ViewFrame::TOP_RIGHT; i++ ) {
3055 if ( occView && occView->getView( i ) ) {
3056 occView->getView( i )->centralWidget()->resize( myWndWidth, myWndHeight );
3060 #endif // DISABLE_OCCVIEWER
3062 else if ( type == "ParaView") {
3063 #ifndef DISABLE_PVVIEWER
3064 // specific processing for ParaView viewer:
3065 // hierarchy of ParaView viewer is much complex than for usual view;
3066 // we look for sub-widget named "Viewport"
3067 QList<QWidget*> lst = wnd->findChildren<QWidget*>( "Viewport" );
3068 if ( !lst.isEmpty() ) {
3069 lst[0]->resize( myWndWidth, myWndHeight );
3072 #endif // DISABLE_PVVIEWER
3075 if ( wnd->centralWidget() ) {
3076 wnd->centralWidget()->resize( myWndWidth, myWndHeight );
3084 bool SalomePyQt::setViewSize( const int w, const int h, const int id )
3086 return ProcessEvent( new TSetViewSize( w, h, id ) );
3090 \fn bool SalomePyQt::setViewRotationPoint( const double x, const double y, const double z, const int id );
3091 \brief Set view rotation point
3092 \param x coordinate X view rotation point
3093 \param y coordinate Y view rotation point
3094 \param z coordinate Z view rotation point
3095 \param id window identifier
3096 \return \c true if operation is completed successfully and \c false otherwise
3099 class TSetViewRotationPoint: public SALOME_Event
3102 typedef bool TResult;
3108 TSetViewRotationPoint( const double x, const double y, const double z, const int id )
3109 : myResult( false ),
3114 virtual void Execute()
3116 SUIT_ViewWindow* wnd = 0;
3118 if ( LightApp_Application* anApp = getApplication() ) {
3119 SUIT_ViewManager* vm = anApp->activeViewManager();
3121 wnd = vm->getActiveView();
3125 wnd = dynamic_cast<SUIT_ViewWindow*>( getWnd( myWndId ) );
3128 SUIT_ViewManager* viewMgr = wnd->getViewManager();
3130 QString type = viewMgr->getType();
3131 if ( type == "OCCViewer") {
3132 #ifndef DISABLE_OCCVIEWER
3133 // specific processing for OCC viewer:
3134 // OCC view can embed up to 4 sub-views, split according to the specified layout;
3135 // - if there is only one sub-view active; its rotation point will be changed;
3136 // - if there are several sub-views, rotaion points of each of them will be changed.
3137 OCCViewer_ViewWindow* occView = qobject_cast<OCCViewer_ViewWindow*>( wnd );
3139 for ( int i = OCCViewer_ViewFrame::BOTTOM_RIGHT; i <= OCCViewer_ViewFrame::TOP_RIGHT; i++ ) {
3140 if ( occView && occView->getView( i ) ) {
3141 occView->getView( i )->activateSetRotationSelected( myX, myY, myZ );
3146 #endif // DISABLE_OCCVIEWER
3148 else if ( type == "VTKViewer") {
3149 #ifndef DISABLE_VTKVIEWER
3150 SVTK_ViewWindow* vtkView = qobject_cast<SVTK_ViewWindow*>( wnd );
3153 double aCenter[3] = { myX, myY, myZ };
3154 vtkView->activateSetRotationSelected( (void*)aCenter );
3157 #endif // DISABLE_VTKVIEWER
3163 bool SalomePyQt::setViewRotationPoint( const double x, const double y, const double z, const int id )
3165 return ProcessEvent( new TSetViewRotationPoint( x, y, z, id ) );
3169 \fn QString SalomePyQt::getViewTitle( const int id );
3170 \brief Get view caption
3171 \param id window identifier
3172 \return view caption
3175 class TGetViewTitle: public SALOME_Event
3178 typedef QString TResult;
3181 TGetViewTitle( const int id )
3183 virtual void Execute()
3185 SUIT_ViewWindow* wnd = getWnd( myWndId );
3187 myResult = wnd->windowTitle();
3190 QString SalomePyQt::getViewTitle( const int id )
3192 return ProcessEvent( new TGetViewTitle( id ) );
3196 \fn QList<int> SalomePyQt::findViews( const QString& type );
3197 \brief Get list of integer identifiers of all the
3198 currently opened views of the specified type
3199 \param type viewer type
3200 \return list of integer identifiers
3203 class TFindViews: public SALOME_Event
3206 typedef QList<int> TResult;
3209 TFindViews( const QString& type )
3211 virtual void Execute()
3214 LightApp_Application* app = getApplication();
3216 ViewManagerList vmList;
3217 app->viewManagers( myType, vmList );
3218 SUIT_ViewManager* viewMgr;
3219 foreach ( viewMgr, vmList ) {
3220 QVector<SUIT_ViewWindow*> vec = viewMgr->getViews();
3221 for ( int i = 0, n = vec.size(); i < n; i++ ) {
3222 SUIT_ViewWindow* wnd = vec[ i ];
3225 MESSAGE("SUIT_ViewWindow*: "<< wnd << " id: " << wnd->getId());
3226 myResult.append( wnd->getId() );
3233 QList<int> SalomePyQt::findViews( const QString& type )
3235 return ProcessEvent( new TFindViews( type ) );
3239 \fn bool SalomePyQt::activateView( const int id );
3240 \brief Activate view
3241 \param id window identifier
3242 \return \c true if operation is completed successfully and \c false otherwise
3245 class TActivateView: public SALOME_Event
3248 typedef bool TResult;
3251 TActivateView( const int id )
3252 : myResult( false ),
3254 virtual void Execute()
3256 SUIT_ViewWindow* wnd = getWnd( myWndId );
3257 MESSAGE("window id:" << myWndId << " SUIT_ViewWindow*: " << wnd);
3264 bool SalomePyQt::activateView( const int id )
3266 return ProcessEvent( new TActivateView( id ) );
3270 \fn bool SalomePyQt::activateManagerAndView( const int id );
3271 \brief Activate view manager and view: useful for a view embedded in a module main Window
3272 \param id window identifier
3273 \return \c true if operation is completed successfully and \c false otherwise
3276 class TActivateViewManagerAndView: public SALOME_Event
3279 typedef bool TResult;
3282 TActivateViewManagerAndView( const int id )
3283 : myResult( false ),
3285 virtual void Execute()
3287 SUIT_ViewWindow* wnd = getWnd( myWndId );
3288 MESSAGE("window id:" << myWndId << " SUIT_ViewWindow*: " << wnd);
3291 LightApp_Application* app = getApplication();
3292 app->desktop()->windowActivated(wnd); // equivalent to app->setActiveViewManager(wnd->getViewManager())
3298 bool SalomePyQt::activateViewManagerAndView( const int id )
3300 return ProcessEvent( new TActivateViewManagerAndView( id ) );
3307 class TGetViewWidget: public SALOME_Event
3310 typedef QWidget* TResult;
3313 TGetViewWidget( const int id )
3316 virtual void Execute()
3318 SUIT_ViewWindow* wnd = getWnd( myWndId );
3320 myResult = (QWidget*)wnd;
3324 QWidget* SalomePyQt::getViewWidget( const int id)
3326 return ProcessEvent( new TGetViewWidget( id ) );
3331 \fn int SalomePyQt::createView( const QString& type, bool visible = true, const int width = 0, const int height = 0 );
3332 \brief Create new view and activate it
3333 \param type viewer type
3337 \return integer identifier of created view (or -1 if view could not be created)
3340 class TCreateView: public SALOME_Event
3343 typedef int TResult;
3350 TCreateView( const QString& theType, bool visible, const int width, const int height, bool detached )
3356 myDetached(detached) {}
3357 virtual void Execute()
3359 LightApp_Application* app = getApplication();
3361 SUIT_ViewManager* viewMgr = app->createViewManager( myType, myDetached );
3363 QWidget* wnd = viewMgr->getActiveView();
3364 myResult = viewMgr->getActiveView()->getId();
3367 wnd->setVisible(false);
3368 if ( !myVisible && myWidth == 0 && myHeight == 0 ) {
3372 if (myWidth > 0 && myHeight > 0) {
3373 #ifndef DISABLE_PLOT2DVIEWER
3374 Plot2d_ViewWindow* wnd2D = dynamic_cast<Plot2d_ViewWindow*>( wnd );
3375 if ( wnd2D ) wnd = wnd2D->getViewFrame();
3376 #endif // DISABLE_PLOT2DVIEWER
3377 wnd->setGeometry( 0, 0, myWidth, myHeight );
3384 int SalomePyQt::createView( const QString& type, bool visible, const int width, const int height, bool detached )
3386 int ret = ProcessEvent( new TCreateView( type, visible, width, height, detached ) );
3387 QCoreApplication::processEvents();
3392 \fn int SalomePyQt::createView( const QString& type, QWidget* w );
3393 \brief Create new view with custom widget embedded and activate it
3394 \param type viewer type
3395 \param w custom widget
3396 \return integer identifier of created view (or -1 if view could not be created)
3399 class TCreateViewWg: public SALOME_Event
3402 typedef int TResult;
3406 TCreateViewWg( const QString& theType, QWidget* w )
3410 virtual void Execute()
3412 LightApp_Application* app = getApplication();
3414 SUIT_ViewManager* viewMgr = app->createViewManager( myType, myWidget );
3416 SUIT_ViewWindow* wnd = viewMgr->getActiveView();
3418 myResult = wnd->getId();
3423 int SalomePyQt::createView( const QString& type, QWidget* w )
3425 int ret = ProcessEvent( new TCreateViewWg( type, w ) );
3426 QCoreApplication::processEvents();
3431 \fn bool SalomePyQt::closeView( const int id );
3433 \param id window identifier
3434 \return \c true if operation is completed successfully and \c false otherwise
3437 class TCloseView: public SALOME_Event
3440 typedef bool TResult;
3443 TCloseView( const int id )
3444 : myResult( false ),
3446 virtual void Execute()
3448 SUIT_ViewWindow* wnd = getWnd( myWndId );
3450 SUIT_ViewManager* viewMgr = wnd->getViewManager();
3458 bool SalomePyQt::closeView( const int id )
3460 return ProcessEvent( new TCloseView( id ) );
3464 \fn int SalomePyQt::cloneView( const int id );
3465 \brief Clone view (if this operation is supported for specified view type)
3466 \param id window identifier
3467 \return integer identifier of the cloned view or -1 or operation could not be performed
3470 class TCloneView: public SALOME_Event
3473 typedef int TResult;
3476 TCloneView( const int id )
3479 virtual void Execute()
3481 SUIT_ViewWindow* wnd = getWnd( myWndId );
3483 SUIT_ViewManager* viewMgr = wnd->getViewManager();
3485 #ifndef DISABLE_OCCVIEWER
3486 if ( wnd->inherits( "OCCViewer_ViewWindow" ) ) {
3487 OCCViewer_ViewWindow* occView = (OCCViewer_ViewWindow*)( wnd );
3488 occView->onCloneView();
3489 wnd = viewMgr->getActiveView();
3491 myResult = wnd->getId();
3493 #endif // DISABLE_OCCVIEWER
3494 #ifndef DISABLE_PLOT2DVIEWER
3495 if ( wnd->inherits( "Plot2d_ViewWindow" ) ) {
3496 Plot2d_ViewManager* viewMgr2d = dynamic_cast<Plot2d_ViewManager*>( viewMgr );
3497 Plot2d_ViewWindow* srcWnd2d = dynamic_cast<Plot2d_ViewWindow*>( wnd );
3498 if ( viewMgr2d && srcWnd2d ) {
3499 Plot2d_ViewWindow* resWnd = viewMgr2d->cloneView( srcWnd2d );
3500 myResult = resWnd->getId();
3503 #endif // DISABLE_OCCVIEWER
3508 int SalomePyQt::cloneView( const int id )
3510 return ProcessEvent( new TCloneView( id ) );
3514 \fn bool SalomePyQt::setViewVisible( const int id, const bool visible )
3515 \brief Set view visibility.
3516 \param id window identifier
3517 \param visible new visiblity
3520 void SalomePyQt::setViewVisible( const int id, const bool visible )
3522 class TEvent: public SALOME_Event
3527 TEvent( const int id, const bool visible )
3528 : myWndId( id ), myVisible( visible ) {}
3529 virtual void Execute()
3531 SUIT_ViewWindow* wnd = getWnd( myWndId );
3532 if ( wnd ) wnd->setVisible( myVisible );
3535 ProcessVoidEvent( new TEvent( id, visible ) );
3539 \fn bool SalomePyQt::isViewVisible( const int id );
3540 \brief Check whether view is visible ( i.e. it is on the top of the views stack)
3541 \param id window identifier
3542 \return \c true if view is visible and \c false otherwise
3545 class TIsViewVisible: public SALOME_Event
3548 typedef bool TResult;
3551 TIsViewVisible( const int id )
3552 : myResult( false ),
3554 virtual void Execute()
3556 SUIT_ViewWindow* wnd = getWnd( myWndId );
3559 QWidget* p = wnd->parentWidget();
3560 myResult = ( p && p->isVisibleTo( p->parentWidget() ) );
3564 bool SalomePyQt::isViewVisible( const int id )
3566 return ProcessEvent( new TIsViewVisible( id ) );
3570 \fn bool SalomePyQt::setViewClosable( const int id, const bool on );
3571 \brief Set / clear view's "closable" option. By default any view is closable
3572 (i.e. can be closed by the user).
3573 \param id window identifier
3574 \param on new "closable" option's value
3577 void SalomePyQt::setViewClosable( const int id, const bool on )
3579 class TEvent: public SALOME_Event
3584 TEvent( const int id, const bool on )
3585 : myWndId( id ), myOn( on ) {}
3586 virtual void Execute()
3588 SUIT_ViewWindow* wnd = getWnd( myWndId );
3589 if ( wnd ) wnd->setClosable( myOn );
3592 ProcessVoidEvent( new TEvent( id, on ) );
3596 \fn bool SalomePyQt::isViewClosable( const int id );
3597 \brief Check whether view is closable (i.e. can be closed by the user)
3598 \param id window identifier
3599 \return \c true if view is closable or \c false otherwise
3602 class TIsViewClosable: public SALOME_Event
3605 typedef bool TResult;
3608 TIsViewClosable( const int id )
3611 virtual void Execute()
3613 SUIT_ViewWindow* wnd = getWnd( myWndId );
3615 myResult = wnd->closable();
3619 bool SalomePyQt::isViewClosable( const int id )
3621 return ProcessEvent( new TIsViewClosable( id ) );
3625 \fn bool SalomePyQt::groupAllViews();
3626 \brief Group all views to the single tab area
3627 \return \c true if operation is completed successfully and \c false otherwise
3630 class TGroupAllViews: public SALOME_Event
3633 typedef bool TResult;
3636 : myResult( false ) {}
3637 virtual void Execute()
3639 LightApp_Application* app = getApplication();
3641 STD_TabDesktop* tabDesk = dynamic_cast<STD_TabDesktop*>( app->desktop() );
3643 QtxWorkstack* wStack = tabDesk->workstack();
3652 bool SalomePyQt::groupAllViews()
3654 return ProcessEvent( new TGroupAllViews() );
3658 \fn bool SalomePyQt::splitView( const int id, const Orientation ori, const Action action );
3659 \brief Split tab area to which view with identifier belongs to
3660 \param id window identifier
3661 \param ori orientation of split operation
3662 \param action action to be performed
3663 \return \c true if operation is completed successfully \c false otherwise
3666 class TSplitView: public SALOME_Event
3669 typedef bool TResult;
3674 TSplitView( const int id,
3675 const Orientation ori,
3676 const Action action )
3677 : myResult( false ),
3680 myAction( action ) {}
3681 virtual void Execute()
3683 SUIT_ViewWindow* wnd = getWnd( myWndId );
3686 // wnd->setFocus(); ???
3689 if ( getApplication() ) {
3690 STD_TabDesktop* desk =
3691 dynamic_cast<STD_TabDesktop*>( getApplication()->desktop() );
3693 QtxWorkstack* wStack = desk->workstack();
3695 Qt::Orientation qtOri =
3696 ( myOri == Horizontal ) ? Qt::Horizontal : Qt::Vertical;
3698 QtxWorkstack::SplitType sType;
3699 if ( myAction == MoveWidget )
3700 sType = QtxWorkstack::SplitMove;
3701 else if ( myAction == LeaveWidget )
3702 sType = QtxWorkstack::SplitStay;
3704 sType = QtxWorkstack::SplitAt;
3706 wStack->Split( wnd, qtOri, sType );
3714 bool SalomePyQt::splitView( const int id, const Orientation ori, const Action action )
3716 return ProcessEvent( new TSplitView( id, ori, action ) );
3720 \fn bool SalomePyQt::moveView( const int id, const int id_to, const bool before );
3721 \brief Move view with the first identifier to the same area which
3722 another view with the second identifier belongs to
3723 \param id source window identifier
3724 \param id_to destination window identifier
3725 param before specifies whether the first viewt has to be moved before or after
3727 \return \c true if operation is completed successfully and \c false otherwise
3730 class TMoveView: public SALOME_Event
3733 typedef bool TResult;
3738 TMoveView( const int id, const int id_to, const bool before )
3739 : myResult( false ),
3742 myIsBefore( before ) {}
3743 virtual void Execute()
3745 SUIT_ViewWindow* wnd = getWnd( myWndId );
3746 SUIT_ViewWindow* wnd_to = getWnd( myWndToId );
3747 if ( wnd && wnd_to ) {
3748 QtxWorkstack* wStack = dynamic_cast<STD_TabDesktop*>(
3749 getApplication()->desktop() )->workstack();
3751 myResult = wStack->move( wnd, wnd_to, myIsBefore );
3755 bool SalomePyQt::moveView( const int id, const int id_to, const bool before )
3757 return ProcessEvent( new TMoveView( id, id_to, before ) );
3761 \fn QList<int> SalomePyQt::neighbourViews( const int id );
3762 \brief Get list of views identifiers that belongs to the same area as
3763 specified view (excluding it)
3764 \param id window identifier
3765 \return list of views identifiers
3768 class TNeighbourViews: public SALOME_Event
3771 typedef QList<int> TResult;
3774 TNeighbourViews( const int id )
3776 virtual void Execute()
3779 SUIT_ViewWindow* wnd = getWnd( myWndId );
3781 QtxWorkstack* wStack = dynamic_cast<STD_TabDesktop*>(
3782 getApplication()->desktop() )->workstack();
3784 QWidgetList wgList = wStack->windowList( wnd );
3786 foreach ( wg, wgList ) {
3787 SUIT_ViewWindow* tmpWnd = dynamic_cast<SUIT_ViewWindow*>( wg );
3788 if ( tmpWnd && tmpWnd != wnd )
3789 myResult.append( tmpWnd->getId() );
3795 QList<int> SalomePyQt::neighbourViews( const int id )
3797 return ProcessEvent( new TNeighbourViews( id ) );
3802 \fn void SalomePyQt::createRoot();
3803 \brief Initialize root data object.
3805 Does nothing if root is already initialized.
3808 void SalomePyQt::createRoot()
3810 class TEvent: public SALOME_Event
3814 virtual void Execute()
3816 SALOME_PYQT_ModuleLight* module = dynamic_cast<SALOME_PYQT_ModuleLight*>( getActiveModule() );
3818 SALOME_PYQT_DataModelLight* dm =
3819 dynamic_cast<SALOME_PYQT_DataModelLight*>( module->dataModel() );
3824 if ( verbose() ) printf( "SalomePyQt.createRoot() function is not supported for the current module.\n" );
3828 ProcessVoidEvent( new TEvent() );
3832 \fn QString SalomePyQt::createObject( const QString& parent );
3833 \brief Create empty data object
3834 \param parent entry of parent data object
3835 \return entry of created data object
3838 class TCreateEmptyObjectEvent: public SALOME_Event
3841 typedef QString TResult;
3844 TCreateEmptyObjectEvent( const QString& parent )
3845 : myParent( parent ) {}
3846 virtual void Execute()
3848 SALOME_PYQT_ModuleLight* module = dynamic_cast<SALOME_PYQT_ModuleLight*>( getActiveModule() );
3850 myResult = module->createObject( myParent );
3853 if ( verbose() ) printf( "SalomePyQt.createObject() function is not supported for the current module.\n" );
3857 QString SalomePyQt::createObject( const QString& parent )
3859 return ProcessEvent( new TCreateEmptyObjectEvent( parent ) );
3863 \fn QString SalomePyQt::createObject( const QString& name, const QString& icon,
3864 const QString& tooltip,const QString& parent );
3865 \brief Create new data object with specified name, icon and tooltip
3866 \param name data object name
3867 \param icon data object icon
3868 \param toolTip data object tooltip
3869 \param parent entry of parent data object
3870 \return entry of created data object
3873 class TCreateObjectEvent: public SALOME_Event
3876 typedef QString TResult;
3882 TCreateObjectEvent( const QString& name,
3883 const QString& icon,
3884 const QString& tooltip,
3885 const QString& parent )
3888 myToolTip( tooltip ),
3889 myParent( parent ) {}
3890 virtual void Execute()
3892 SALOME_PYQT_ModuleLight* module = dynamic_cast<SALOME_PYQT_ModuleLight*>( getActiveModule() );
3894 myResult = module->createObject( myName, myIcon, myToolTip, myParent );
3897 if ( verbose() ) printf( "SalomePyQt.createObject() function is not supported for the current module.\n" );
3901 QString SalomePyQt::createObject( const QString& name,
3902 const QString& icon,
3903 const QString& toolTip,
3904 const QString& parent )
3906 return ProcessEvent( new TCreateObjectEvent( name, icon, toolTip, parent ) );
3911 \fn void SalomePyQt::setName( const QString& entry, const QString& name );
3912 \brief Set data object name
3913 \param entry data object entry
3914 \param name data object name
3916 class TSetNameEvent: public SALOME_Event
3921 TSetNameEvent( const QString& entry,
3922 const QString& name )
3925 virtual void Execute()
3927 SALOME_PYQT_ModuleLight* module = dynamic_cast<SALOME_PYQT_ModuleLight*>( getActiveModule() );
3929 module->setName( myEntry, myName );
3932 if ( verbose() ) printf( "SalomePyQt.setName() function is not supported for the current module.\n" );
3936 void SalomePyQt::setName( const QString& entry, const QString& name )
3938 ProcessVoidEvent( new TSetNameEvent( entry, name ) );
3942 \fn void SalomePyQt::setIcon( const QString& entry, const QString& icon );
3943 \brief Set data object icon
3944 \param entry data object entry
3945 \param icon data object icon file name (icon is loaded from module resources)
3948 class TSetIconEvent: public SALOME_Event
3953 TSetIconEvent( const QString& entry,
3954 const QString& icon )
3957 virtual void Execute()
3959 SALOME_PYQT_ModuleLight* module = dynamic_cast<SALOME_PYQT_ModuleLight*>( getActiveModule() );
3961 module->setIcon( myEntry, myIcon );
3964 if ( verbose() ) printf( "SalomePyQt.setIcon() function is not supported for the current module.\n" );
3969 void SalomePyQt::setIcon( const QString& entry, const QString& icon )
3971 ProcessVoidEvent( new TSetIconEvent( entry, icon ) );
3975 \fn void SalomePyQt::setToolTip( const QString& entry, const QString& toolTip );
3976 \brief Set data object tooltip
3977 \param entry data object entry
3978 \param toolTip data object tooltip
3981 class TSetToolTipEvent: public SALOME_Event
3986 TSetToolTipEvent( const QString& entry,
3987 const QString& toolTip )
3989 myToolTip( toolTip ) {}
3990 virtual void Execute()
3992 SALOME_PYQT_ModuleLight* module = dynamic_cast<SALOME_PYQT_ModuleLight*>( getActiveModule() );
3994 module->setToolTip( myEntry, myToolTip );
3997 if ( verbose() ) printf( "SalomePyQt.setToolTip() function is not supported for the current module.\n" );
4001 void SalomePyQt::setToolTip( const QString& entry, const QString& toolTip )
4003 ProcessVoidEvent( new TSetToolTipEvent( entry, toolTip ) );
4007 \fn void SalomePyQt::setReference( const QString& entry, const QString& refEntry );
4008 \brief Set reference to another data object
4009 \param entry data object entry
4010 \param refEntry referenced data object entry
4013 class TSetRefEvent: public SALOME_Event
4018 TSetRefEvent( const QString& entry,
4019 const QString& refEntry )
4021 myRefEntry( refEntry ) {}
4022 virtual void Execute()
4024 SALOME_PYQT_ModuleLight* module = dynamic_cast<SALOME_PYQT_ModuleLight*>( getActiveModule() );
4026 module->setReference( myEntry, myRefEntry );
4029 if ( verbose() ) printf( "SalomePyQt.setReference() function is not supported for the current module.\n" );
4033 void SalomePyQt::setReference( const QString& entry, const QString& refEntry )
4035 ProcessVoidEvent( new TSetRefEvent( entry, refEntry ) );
4039 \fn void SalomePyQt::setColor( const QString& entry, const QColor& color );
4040 \brief Set data object color
4041 \param entry data object entry
4042 \param color data object color
4045 class TSetColorEvent: public SALOME_Event
4050 TSetColorEvent( const QString& entry,
4051 const QColor& color )
4054 virtual void Execute()
4056 SALOME_PYQT_ModuleLight* module = dynamic_cast<SALOME_PYQT_ModuleLight*>( getActiveModule() );
4058 module->setColor( myEntry, myColor );
4061 if ( verbose() ) printf( "SalomePyQt.setColor() function is not supported for the current module.\n" );
4065 void SalomePyQt::setColor( const QString& entry, const QColor& color )
4067 ProcessVoidEvent( new TSetColorEvent( entry, color ) );
4071 \fn QString SalomePyQt::getName( const QString& entry );
4072 \brief Get data object name
4073 \param entry data object entry
4074 \return data object name
4077 class TGetNameEvent: public SALOME_Event
4080 typedef QString TResult;
4083 TGetNameEvent( const QString& entry )
4084 : myEntry( entry ) {}
4085 virtual void Execute()
4087 SALOME_PYQT_ModuleLight* module = dynamic_cast<SALOME_PYQT_ModuleLight*>( getActiveModule() );
4089 myResult = module->getName( myEntry );
4092 if ( verbose() ) printf( "SalomePyQt.getName() function is not supported for the current module.\n" );
4096 QString SalomePyQt::getName( const QString& entry )
4098 return ProcessEvent( new TGetNameEvent( entry ) );
4102 \fn QString SalomePyQt::getToolTip( const QString& entry );
4103 \brief Get data object tooltip
4104 \param entry data object entry
4105 \return data object tooltip
4108 class TGetToolTipEvent: public SALOME_Event
4111 typedef QString TResult;
4114 TGetToolTipEvent( const QString& entry )
4115 : myEntry( entry ) {}
4116 virtual void Execute()
4118 SALOME_PYQT_ModuleLight* module = dynamic_cast<SALOME_PYQT_ModuleLight*>( getActiveModule() );
4120 myResult = module->getToolTip( myEntry );
4123 if ( verbose() ) printf( "SalomePyQt.getToolTip() function is not supported for the current module.\n" );
4127 QString SalomePyQt::getToolTip( const QString& entry )
4129 return ProcessEvent( new TGetToolTipEvent( entry ) );
4133 \fn QString SalomePyQt::getReference( const QString& entry );
4134 \brief Get entry of the referenced object (if there's any)
4135 \param entry data object entry
4136 \return referenced data object entry
4139 class TGetRefEvent: public SALOME_Event
4142 typedef QString TResult;
4145 TGetRefEvent( const QString& entry )
4146 : myEntry( entry ) {}
4147 virtual void Execute()
4149 SALOME_PYQT_ModuleLight* module = dynamic_cast<SALOME_PYQT_ModuleLight*>( getActiveModule() );
4151 myResult = module->getReference( myEntry );
4154 if ( verbose() ) printf( "SalomePyQt.getReference() function is not supported for the current module.\n" );
4158 QString SalomePyQt::getReference( const QString& entry )
4160 return ProcessEvent( new TGetRefEvent( entry ) );
4164 \fn QColor SalomePyQt::getColor( const QString& entry );
4165 \brief Get data object color
4166 \param entry data object entry
4167 \return data object color
4170 class TGetColorEvent: public SALOME_Event
4173 typedef QColor TResult;
4176 TGetColorEvent( const QString& entry )
4177 : myEntry( entry ) {}
4178 virtual void Execute()
4180 SALOME_PYQT_ModuleLight* module = dynamic_cast<SALOME_PYQT_ModuleLight*>( getActiveModule() );
4182 myResult = module->getColor( myEntry );
4185 if ( verbose() ) printf( "SalomePyQt.getColor() function is not supported for the current module.\n" );
4189 QColor SalomePyQt::getColor( const QString& entry )
4191 return ProcessEvent( new TGetColorEvent( entry ) );
4195 \fn void SalomePyQt::removeChildren( const QString& entry );
4196 \brief Remove all child data objects from specified data object
4197 \param entry data object entry
4200 class TRemoveChildEvent: public SALOME_Event
4204 TRemoveChildEvent( const QString& entry )
4205 : myEntry( entry ) {}
4206 virtual void Execute()
4208 SALOME_PYQT_ModuleLight* module = dynamic_cast<SALOME_PYQT_ModuleLight*>( getActiveModule() );
4210 module->removeChildren( myEntry );
4213 if ( verbose() ) printf( "SalomePyQt.removeChildren() function is not supported for the current module.\n" );
4217 void SalomePyQt::removeChildren( const QString& entry )
4219 ProcessVoidEvent( new TRemoveChildEvent( entry ) );
4221 void SalomePyQt::removeChild( const QString& entry )
4223 if ( verbose() ) printf( "SalomePyQt.removeChild() function is obsolete. Use SalomePyQt.removeChildren() instead." );
4224 removeChildren( entry );
4228 \fn void SalomePyQt::removeObject( const QString& entry );
4229 \brief Remove object by entry
4230 \param entry data object entry
4233 class TRemoveObjectEvent: public SALOME_Event
4238 TRemoveObjectEvent( const QString& entry )
4239 : myEntry( entry ) {}
4240 virtual void Execute()
4242 SALOME_PYQT_ModuleLight* module = dynamic_cast<SALOME_PYQT_ModuleLight*>( getActiveModule() );
4244 module->removeObject( myEntry );
4247 if ( verbose() ) printf( "SalomePyQt.removeObject() function is not supported for the current module.\n" );
4251 void SalomePyQt::removeObject( const QString& entry )
4253 ProcessVoidEvent( new TRemoveObjectEvent( entry ) );
4257 \fn QStringList SalomePyQt::getChildren( const QString& entry, const bool recursive );
4258 \brief Get entries of all child data objects of specified data object
4259 \param entry data object entry
4260 \param recursive \c true for recursive processing
4263 class TGetChildrenEvent: public SALOME_Event
4266 typedef QStringList TResult;
4270 TGetChildrenEvent( const QString& entry, const bool recursive )
4272 myRecursive( recursive ) {}
4273 virtual void Execute()
4275 SALOME_PYQT_ModuleLight* module = dynamic_cast<SALOME_PYQT_ModuleLight*>( getActiveModule() );
4277 myResult = module->getChildren( myEntry, myRecursive );
4280 if ( verbose() ) printf( "SalomePyQt.getChildren() function is not supported for the current module.\n" );
4284 QStringList SalomePyQt::getChildren( const QString& entry, const bool recursive )
4286 return ProcessEvent( new TGetChildrenEvent( entry, recursive ) );
4289 #ifndef DISABLE_PLOT2DVIEWER
4290 // Next set of methods relates to the Plot2d viewer functionality
4293 \fn void SalomePyQt::displayCurve( const int id, Plot2d_Curve* theCurve )
4294 \brief Display theCurve in view
4295 \param id window identifier
4296 \param theCurve curve to display
4299 class TDisplayCurve: public SALOME_Event
4303 Plot2d_Curve* myCurve;
4304 TDisplayCurve( const int id, Plot2d_Curve* theCurve ) : myWndId( id ), myCurve( theCurve ) {}
4305 virtual void Execute() {
4306 Plot2d_ViewWindow* wnd = dynamic_cast<Plot2d_ViewWindow*>( getWnd( myWndId ) );
4308 wnd->getViewFrame()->displayCurve( myCurve );
4311 void SalomePyQt::displayCurve( const int id, Plot2d_Curve* theCurve )
4313 ProcessVoidEvent( new TDisplayCurve( id, theCurve ) );
4317 \fn void SalomePyQt::eraseCurve( const int id, Plot2d_Curve* theCurve )
4318 \brief Erase theCurve in view
4319 \param id window identifier
4320 \param theCurve curve to erase
4323 class TEraseCurve: public SALOME_Event
4327 Plot2d_Curve* myCurve;
4328 TEraseCurve( const int id, Plot2d_Curve* theCurve ) : myWndId( id ), myCurve( theCurve ) {}
4329 virtual void Execute() {
4330 Plot2d_ViewWindow* wnd = dynamic_cast<Plot2d_ViewWindow*>( getWnd( myWndId ) );
4331 wnd->getViewFrame()->eraseCurve( myCurve );
4334 void SalomePyQt::eraseCurve( const int id, Plot2d_Curve* theCurve )
4336 ProcessVoidEvent( new TEraseCurve( id, theCurve ) );
4340 \fn void SalomePyQt::deleteCurve( Plot2d_Curve* theCurve )
4341 \brief Delete theCurve from all views
4342 \param theCurve curve to delete
4345 class TDeleteCurve: public SALOME_Event
4348 Plot2d_Curve* myCurve;
4349 TDeleteCurve( Plot2d_Curve* theCurve ) : myCurve( theCurve ) {}
4350 virtual void Execute() {
4351 LightApp_Application* app = getApplication();
4353 STD_TabDesktop* tabDesk = dynamic_cast<STD_TabDesktop*>( app->desktop() );
4355 QList<SUIT_ViewWindow*> wndlist = tabDesk->windows();
4356 SUIT_ViewWindow* wnd;
4357 foreach ( wnd, wndlist ) {
4358 Plot2d_ViewWindow* aP2d = dynamic_cast<Plot2d_ViewWindow*>( wnd );
4360 aP2d->getViewFrame()->eraseObject( myCurve );
4366 void SalomePyQt::eraseCurve( Plot2d_Curve* theCurve )
4368 ProcessVoidEvent( new TDeleteCurve( theCurve ) );
4372 \brief updateCurves (repaint) curves in view window.
4374 void SalomePyQt::updateCurves( const int id )
4376 class TEvent: public SALOME_Event
4380 TEvent( const int id ) : myWndId( id ) {}
4381 virtual void Execute()
4383 Plot2d_ViewWindow* wnd = dynamic_cast<Plot2d_ViewWindow*>( getWnd( myWndId ) );
4385 wnd->getViewFrame()->DisplayAll();
4388 ProcessVoidEvent( new TEvent( id ) );
4392 \fn QString SalomePyQt::getPlot2dTitle( const int id, ObjectType type = MainTitle )
4393 \brief Get title of corresponding type
4394 \param id window identifier
4395 \param type is type of title
4396 \return title of corresponding type
4399 class TGetPlot2dTitle: public SALOME_Event
4402 typedef QString TResult;
4406 TGetPlot2dTitle(const int id, ObjectType type) :
4409 virtual void Execute() {
4410 Plot2d_ViewWindow* wnd = dynamic_cast<Plot2d_ViewWindow*>( getWnd( myWndId ) );
4412 myResult = wnd->getViewFrame()->getTitle( (Plot2d_ViewFrame::ObjectType)myType );
4415 QString SalomePyQt::getPlot2dTitle( const int id, ObjectType type )
4417 return ProcessEvent( new TGetPlot2dTitle( id, type ) );
4422 \fn void SalomePyQt::setPlot2dTitle( const int id, const QString& title, ObjectType type = MainTitle, bool show = true )
4423 \brief Set title of corresponding type
4424 \param id window identifier
4426 \param type is type of title
4430 class TSetPlot2dTitle: public SALOME_Event
4434 Plot2d_Curve* myCurve;
4438 TSetPlot2dTitle( const int id, const QString& title, ObjectType type, bool show ) :
4443 virtual void Execute() {
4444 Plot2d_ViewWindow* wnd = dynamic_cast<Plot2d_ViewWindow*>( getWnd( myWndId ) );
4445 wnd->getViewFrame()->setTitle( myShow, myTitle, (Plot2d_ViewFrame::ObjectType)myType, false );
4448 void SalomePyQt::setPlot2dTitle( const int id, const QString& title, ObjectType type, bool show )
4450 ProcessVoidEvent( new TSetPlot2dTitle( id, title, type, show ) );
4454 \fn QList<int> SalomePyQt::getPlot2dFitRangeByCurves( const int id )
4455 \brief Get list of Plot2d view ranges
4456 \param id window identifier
4457 \return list of view ranges (XMin, XMax, YMin, YMax)
4460 class TFitRangeByCurves: public SALOME_Event
4463 typedef QList<double> TResult;
4466 TFitRangeByCurves( const int id )
4468 virtual void Execute()
4471 Plot2d_ViewWindow* wnd = dynamic_cast<Plot2d_ViewWindow*>( getWnd( myWndId ) );
4473 double XMin, XMax, YMin, YMax, Y2Min, Y2Max;
4474 wnd->getViewFrame()->getFitRangeByCurves( XMin, XMax, YMin, YMax, Y2Min, Y2Max );
4475 myResult.append( XMin );
4476 myResult.append( XMax );
4477 myResult.append( YMin );
4478 myResult.append( YMax );
4482 QList<double> SalomePyQt::getPlot2dFitRangeByCurves( const int id )
4484 return ProcessEvent( new TFitRangeByCurves( id ) );
4488 \fn QList<int> SalomePyQt::getPlot2dFitRangeCurrent( const int id )
4489 \brief Get list of current Plot2d view ranges
4490 \param id window identifier
4491 \return list of view ranges (XMin, XMax, YMin, YMax)
4494 class TFitRangeCurrent: public SALOME_Event
4497 typedef QList<double> TResult;
4500 TFitRangeCurrent( const int id )
4502 virtual void Execute()
4505 Plot2d_ViewWindow* wnd = dynamic_cast<Plot2d_ViewWindow*>( getWnd( myWndId ) );
4507 double XMin, XMax, YMin, YMax, Y2Min, Y2Max;
4508 wnd->getViewFrame()->getFitRanges( XMin, XMax, YMin, YMax, Y2Min, Y2Max );
4509 myResult.append( XMin );
4510 myResult.append( XMax );
4511 myResult.append( YMin );
4512 myResult.append( YMax );
4516 QList<double> SalomePyQt::getPlot2dFitRangeCurrent( const int id )
4518 return ProcessEvent( new TFitRangeCurrent( id ) );
4522 \fn void SalomePyQt::setPlot2dFitRange( const int id, const double XMin, const double XMax, const double YMin, const double YMax )
4523 \brief Set range of Plot2d view
4524 \param id window identifier
4531 class TPlot2dFitRange: public SALOME_Event
4539 TPlot2dFitRange( const int id, const double XMin, const double XMax, const double YMin, const double YMax ) :
4545 virtual void Execute() {
4546 Plot2d_ViewWindow* wnd = dynamic_cast<Plot2d_ViewWindow*>( getWnd( myWndId ) );
4548 wnd->getViewFrame()->fitData( 0, myXMin, myXMax, myYMin, myYMax );
4551 void SalomePyQt::setPlot2dFitRange( const int id, const double XMin, const double XMax, const double YMin, const double YMax )
4553 ProcessVoidEvent( new TPlot2dFitRange( id, XMin, XMax, YMin, YMax ) );
4556 // End of methods related to the Plot2d viewer functionality
4557 #endif // DISABLE_PLOT2DVIEWER
4560 \brief Process Qt event loop
4562 void SalomePyQt::processEvents()
4564 QCoreApplication::processEvents();
4568 \brief Set visibility state for given object
4569 \param theEntry study ID of the object
4570 \param theState visibility state
4572 void SalomePyQt::setVisibilityState( const QString& theEntry, VisibilityState theState )
4574 class TEvent: public SALOME_Event
4579 TEvent( const QString& theEntry, int theState ):
4580 myEntry( theEntry ), myState( theState ) {}
4581 virtual void Execute()
4583 LightApp_Study* aStudy = getActiveStudy();
4586 aStudy->setVisibilityState( myEntry, (Qtx::VisibilityState)myState );
4589 ProcessVoidEvent( new TEvent( theEntry, theState ) );
4593 \fn VisibilityState SalomePyQt::getVisibilityState( const QString& theEntry )
4594 \brief Get visibility state for given object
4595 \param theEntry study ID of the object
4596 \return visibility state
4599 class TGetVisibilityStateEvent: public SALOME_Event
4602 typedef int TResult;
4605 TGetVisibilityStateEvent( const QString& theEntry ) : myResult( 0 ), myEntry( theEntry ) {}
4606 virtual void Execute()
4608 LightApp_Study* aStudy = getActiveStudy();
4610 myResult = aStudy->visibilityState( myEntry );
4613 VisibilityState SalomePyQt::getVisibilityState( const QString& theEntry )
4615 return (VisibilityState) ProcessEvent( new TGetVisibilityStateEvent( theEntry ) );
4619 \brief Set position of given object in the tree
4620 \param theEntry study ID of the object
4621 \param thePos position
4623 void SalomePyQt::setObjectPosition( const QString& theEntry, int thePos )
4625 class TEvent: public SALOME_Event
4630 TEvent( const QString& theEntry, int thePos ):
4631 myEntry( theEntry ), myPos( thePos ) {}
4632 virtual void Execute()
4634 SALOME_PYQT_ModuleLight* module = dynamic_cast<SALOME_PYQT_ModuleLight*>( getActiveModule() );
4636 module->setObjectPosition( myEntry, myPos );
4639 ProcessVoidEvent( new TEvent( theEntry, thePos ) );
4643 \fn int SalomePyQt::getObjectPosition( const QString& theEntry )
4644 \brief Get position of given object in the tree
4645 \param theEntry study ID of the object
4649 class TGetObjectPositionEvent: public SALOME_Event
4652 typedef int TResult;
4655 TGetObjectPositionEvent( const QString& theEntry ) : myResult( 0 ), myEntry( theEntry ) {}
4656 virtual void Execute()
4658 SALOME_PYQT_ModuleLight* module = dynamic_cast<SALOME_PYQT_ModuleLight*>( getActiveModule() );
4660 myResult = module->getObjectPosition( myEntry );
4663 int SalomePyQt::getObjectPosition( const QString& theEntry )
4665 return ProcessEvent( new TGetObjectPositionEvent( theEntry ) );
4669 \brief Start recordind a log of Python commands from embedded console
4670 \param theFileName output lof file name
4672 void SalomePyQt::startPyLog( const QString& theFileName )
4674 class TEvent: public SALOME_Event
4678 TEvent( const QString& theFileName ):
4679 myFileName( theFileName ) {}
4680 virtual void Execute()
4682 if ( getApplication() ) {
4683 PyConsole_Console* pyConsole = getApplication()->pythonConsole( false );
4684 if ( pyConsole ) pyConsole->startLog( myFileName );
4688 ProcessVoidEvent( new TEvent( theFileName ) );
4692 \brief Stop recordind a log of Python commands from embedded console
4694 void SalomePyQt::stopPyLog()
4696 class TEvent: public SALOME_Event
4700 virtual void Execute()
4702 if ( getApplication() ) {
4703 PyConsole_Console* pyConsole = getApplication()->pythonConsole( false );
4704 if ( pyConsole ) pyConsole->stopLog();
4708 ProcessVoidEvent( new TEvent() );