1 // Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // File : SalomePyQt.cxx
24 // Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
27 // E.A. : On windows with python 2.6, there is a conflict
28 // E.A. : between pymath.h and Standard_math.h which define
29 // E.A. : some same symbols : acosh, asinh, ...
30 #include <Standard_math.hxx>
34 #include "SALOME_PYQT_ModuleLight.h" // this include must be first!!!
35 #include "SALOME_PYQT_DataModelLight.h"
36 #include "SALOME_PYQT_PyModule.h"
37 #include "SalomePyQt.h"
39 #include "LightApp_SelectionMgr.h"
40 #include "LogWindow.h"
41 #ifndef DISABLE_OCCVIEWER
42 #include "OCCViewer_ViewWindow.h"
43 #include "OCCViewer_ViewFrame.h"
44 #endif // DISABLE_OCCVIEWER
45 #ifndef DISABLE_VTKVIEWER
46 #include "SVTK_ViewWindow.h"
47 #endif // DISABLE_VTKVIEWER
48 #ifndef DISABLE_PLOT2DVIEWER
49 #include "Plot2d_ViewManager.h"
50 #include "Plot2d_ViewWindow.h"
51 #endif // DISABLE_PLOT2DVIEWER
52 #ifndef DISABLE_PVVIEWER
53 #include "PVViewer_ViewManager.h"
54 #include "PVViewer_ViewModel.h"
55 #endif // DISABLE_PVVIEWER
56 #include "QtxActionMenuMgr.h"
57 #include "QtxWorkstack.h"
58 #include "QtxTreeView.h"
59 #include "SALOME_Event.h"
60 #include "STD_TabDesktop.h"
61 #include "SUIT_DataBrowser.h"
62 #include "SUIT_ResourceMgr.h"
63 #include "SUIT_Session.h"
64 #include "SUIT_Tools.h"
65 #include "SUIT_ViewManager.h"
66 #include "SUIT_ViewWindow.h"
67 #include "PyConsole_Console.h"
70 #include <QApplication>
71 #include <QPaintEvent>
72 #include <QCoreApplication>
73 #include <QVBoxLayout>
75 #include <utilities.h>
80 \brief Get the currently active application.
82 \return active application object or 0 if there is no any
84 LightApp_Application* getApplication()
86 if ( SUIT_Session::session() )
87 return dynamic_cast<LightApp_Application*>( SUIT_Session::session()->activeApplication() );
92 \brief Get the currently active study.
94 \return active study or 0 if there is no study opened
96 LightApp_Study* getActiveStudy()
98 if ( getApplication() )
99 return dynamic_cast<LightApp_Study*>( getApplication()->activeStudy() );
104 \brief Get the currently active module.
106 This function returns correct result only if Python-based
107 module is currently active. Otherwize, 0 is returned.
109 LightApp_Module* getActiveModule()
111 LightApp_Module* module = 0;
112 if ( LightApp_Application* anApp = getApplication() ) {
113 module = PyModuleHelper::getInitModule();
115 module = dynamic_cast<LightApp_Module*>( anApp->activeModule() );
121 \brief Get the currently active Python module's helper.
123 This function returns correct result only if Python-based
124 module is currently active. Otherwize, 0 is returned.
126 PyModuleHelper* getPythonHelper()
128 LightApp_Module* module = getActiveModule();
129 PyModuleHelper* helper = module ? module->findChild<PyModuleHelper*>( "python_module_helper" ) : 0;
134 \brief Get SALOME verbose level
136 \return \c true if SALOME debug output is allowed or \c false otherwise
140 bool isVerbose = false;
141 if ( getenv( "SALOME_VERBOSE" ) ) {
142 QString envVar = getenv( "SALOME_VERBOSE" );
144 int value = envVar.toInt( &ok );
145 isVerbose = ok && value != 0;
151 \brief Get menu item title
153 \param menuId menu identifier
154 \return menu title (localized)
156 QString getMenuName( const QString& menuId )
158 QStringList contexts;
159 contexts << "SalomeApp_Application" << "LightApp_Application" << "STD_TabDesktop" <<
160 "STD_MDIDesktop" << "STD_Application" << "SUIT_Application" << "";
161 QString menuName = menuId;
162 for ( int i = 0; i < contexts.count() && menuName == menuId; i++ )
163 menuName = QApplication::translate( contexts[i].toLatin1().data(), menuId.toLatin1().data() );
168 \brief Load module icon
170 \param module module name
171 \param fileName path to the icon file
174 QIcon loadIconInternal( const QString& module, const QString& fileName )
178 LightApp_Application* app = getApplication();
180 if ( app && !fileName.isEmpty() ) {
181 QPixmap pixmap = app->resourceMgr()->loadPixmap( module,
182 QApplication::translate( module.toLatin1().data(),
183 fileName.toLatin1().data() ) );
184 if ( !pixmap.isNull() )
185 icon = QIcon( pixmap );
191 \brief Gets window with specified identifier
193 \param id window identifier
194 \return pointer on the window
196 SUIT_ViewWindow* getWnd( const int id )
198 SUIT_ViewWindow* resWnd = 0;
200 LightApp_Application* app = getApplication();
202 ViewManagerList vmlist = app->viewManagers();
203 foreach( SUIT_ViewManager* vm, vmlist ) {
204 QVector<SUIT_ViewWindow*> vwlist = vm->getViews();
205 foreach ( SUIT_ViewWindow* vw, vwlist ) {
206 if ( id == vw->getId() ) {
217 \brief Map of created selection objects.
220 QMap<LightApp_Application*, SALOME_Selection*> SelMap;
223 \brief Default resource file section name.
226 const char* DEFAULT_SECTION = "SalomePyQt";
230 \class SALOME_Selection
231 \brief The class represents selection which can be used in Python.
235 \brief Get the selection object for the specified application.
237 Finds or creates the selection object (one per study).
239 \param app application object
240 \return selection object or 0 if \a app is invalid
242 SALOME_Selection* SALOME_Selection::GetSelection( LightApp_Application* app )
244 SALOME_Selection* sel = 0;
245 if ( app && SelMap.find( app ) != SelMap.end() )
248 sel = SelMap[ app ] = new SALOME_Selection( app );
255 \param p parent object
257 SALOME_Selection::SALOME_Selection( QObject* p ) : QObject( 0 ), mySelMgr( 0 )
259 LightApp_Application* app = dynamic_cast<LightApp_Application*>( p );
261 mySelMgr = app->selectionMgr();
262 connect( mySelMgr, SIGNAL( selectionChanged() ), this, SIGNAL( currentSelectionChanged() ) );
263 connect( mySelMgr, SIGNAL( destroyed() ), this, SLOT ( onSelMgrDestroyed() ) );
270 SALOME_Selection::~SALOME_Selection()
272 LightApp_Application* app = 0;
273 QMap<LightApp_Application*, SALOME_Selection*>::Iterator it;
274 for ( it = SelMap.begin(); it != SelMap.end() && !app; ++it ) {
275 if ( it.value() == this ) app = it.key();
277 if ( app ) SelMap.remove( app );
281 \brief Called when selection manager is destroyed (usually
282 when the study is closed).
284 void SALOME_Selection::onSelMgrDestroyed()
290 \brief Clear the selection.
292 void SALOME_Selection::Clear()
294 class TEvent: public SALOME_Event
296 LightApp_SelectionMgr* mySelMgr;
298 TEvent( LightApp_SelectionMgr* selMgr )
299 : mySelMgr( selMgr ) {}
300 virtual void Execute()
303 mySelMgr->clearSelected();
306 ProcessVoidEvent( new TEvent( mySelMgr ) );
310 \brief Clear the selection.
312 void SALOME_Selection::ClearIObjects()
318 Removes all selection filters.
320 void SALOME_Selection::ClearFilters()
322 class TEvent: public SALOME_Event
324 LightApp_SelectionMgr* mySelMgr;
326 TEvent( LightApp_SelectionMgr* selMgr )
327 : mySelMgr( selMgr ) {}
328 virtual void Execute()
331 mySelMgr->clearFilters();
334 ProcessVoidEvent( new TEvent( mySelMgr ) );
338 \class UserDefinedContent
339 \brief The class represents base class for user defined widget that
340 can be inserted to the Preferences dialog.
346 UserDefinedContent::UserDefinedContent()
352 \brief Called from Preferences dialog to store settings to the resource file.
354 void UserDefinedContent::store()
359 \brief Called from Preferences dialog to restore settings from the resource file.
361 void UserDefinedContent::retrieve()
366 \class SgPyQtUserDefinedContent
367 \brief A Wrapper for UserDefinedContent class.
370 class SgPyQtUserDefinedContent: public QtxUserDefinedContent
373 SgPyQtUserDefinedContent(UserDefinedContent*);
374 virtual ~SgPyQtUserDefinedContent();
376 void store( QtxResourceMgr*, QtxPreferenceMgr* );
377 void retrieve( QtxResourceMgr*, QtxPreferenceMgr* );
380 UserDefinedContent* myContent;
384 \brief Create custom item for Preferences dialog wrapping widget passed from Python.
387 SgPyQtUserDefinedContent::SgPyQtUserDefinedContent(UserDefinedContent* content)
388 : QtxUserDefinedContent( 0 ), myContent( content )
390 QVBoxLayout* l = new QVBoxLayout( this );
391 l->setContentsMargins( 0, 0, 0, 0 );
392 l->addWidget( myContent );
399 SgPyQtUserDefinedContent::~SgPyQtUserDefinedContent()
404 \brief Called from Preferences dialog to store settings to the resource file.
407 void SgPyQtUserDefinedContent::store( QtxResourceMgr*, QtxPreferenceMgr* )
413 \brief Called from Preferences dialog to restore settings from the resource file.
416 void SgPyQtUserDefinedContent::retrieve( QtxResourceMgr*, QtxPreferenceMgr* )
418 myContent->retrieve();
423 \brief The class provides utility functions which can be used in the Python
424 to operate with the SALOME GUI.
426 All the functionality of this class is implemented as static methods, so they
427 can be called with the class name prefixed or via creation of the class instance.
428 For example, next both ways of SalomePyQt class usage are legal:
430 from SalomePyQt import *
432 # using SalomePyQt class instance
433 desktop = sg.getDesktop()
434 # using SalomePyQt class directly
435 menubar = SalomePyQt.getMainMenuBar()
440 \fn QWidget* SalomePyQt::getDesktop();
441 \brief Get the active application's desktop window.
442 \return desktop window or 0 if there is no any
445 class TGetDesktopEvent: public SALOME_Event
448 typedef QWidget* TResult;
450 TGetDesktopEvent() : myResult( 0 ) {}
451 virtual void Execute()
453 if ( getApplication() )
454 myResult = (QWidget*)( getApplication()->desktop() );
457 QWidget* SalomePyQt::getDesktop()
459 return ProcessEvent( new TGetDesktopEvent() );
463 \fn QWidget* SalomePyQt::getMainFrame();
464 \brief Get current application's main frame widget [obsolete].
466 Main frame widget is an internal widget of the application
467 desktop window (workspace).
469 \return workspace widget (0 on any error)
472 class TGetMainFrameEvent: public SALOME_Event
475 typedef QWidget* TResult;
477 TGetMainFrameEvent() : myResult( 0 ) {}
478 virtual void Execute()
480 if ( getApplication() ) {
481 SUIT_Desktop* aDesktop = getApplication()->desktop();
482 myResult = (QWidget*)( aDesktop->centralWidget() );
486 QWidget* SalomePyQt::getMainFrame()
488 return ProcessEvent( new TGetMainFrameEvent() );
492 \fn QMenuBar* SalomePyQt::getMainMenuBar();
493 \brief Get current application desktop's main menu.
494 \return main menu object (0 on any error)
497 class TGetMainMenuBarEvent: public SALOME_Event
500 typedef QMenuBar* TResult;
502 TGetMainMenuBarEvent() : myResult( 0 ) {}
503 virtual void Execute()
505 if ( LightApp_Application* anApp = getApplication() ) {
506 myResult = anApp->desktop()->menuBar();
510 QMenuBar* SalomePyQt::getMainMenuBar()
512 return ProcessEvent( new TGetMainMenuBarEvent() );
516 \fn QMenu* SalomePyQt::getPopupMenu( const MenuName menu );
517 \brief Get main menu's child popup submenu by its identifier.
519 This function is obsolete.
520 Use QMenu* SalomePyQt::getPopupMenu( const QString& menu ) instead.
522 \param menu menu identifier
523 \return popup submenu object or 0 if it does not exist
527 \fn QMenu* SalomePyQt::getPopupMenu( const QString& menu );
528 \brief Get main menu's child popup submenu by its name.
530 The function creates menu if it does not exist.
532 \param menu menu name
533 \return popup submenu object (0 on any error)
536 class TGetPopupMenuEvent: public SALOME_Event
539 typedef QMenu* TResult;
542 TGetPopupMenuEvent( const QString& menu ) : myResult( 0 ), myMenuName( menu ) {}
543 virtual void Execute()
545 LightApp_Application* anApp = getApplication();
546 if ( anApp && !myMenuName.isEmpty() ) {
547 QtxActionMenuMgr* mgr = anApp->desktop()->menuMgr();
548 myResult = mgr->findMenu( myMenuName, -1, false ); // search only top menu
553 QMenu* SalomePyQt::getPopupMenu( const MenuName menu )
558 menuName = getMenuName( "MEN_DESK_FILE" ); break;
560 menuName = getMenuName( "MEN_DESK_VIEW" ); break;
562 menuName = getMenuName( "MEN_DESK_EDIT" ); break;
564 menuName = getMenuName( "MEN_DESK_PREFERENCES" ); break;
566 menuName = getMenuName( "MEN_DESK_TOOLS" ); break;
568 menuName = getMenuName( "MEN_DESK_WINDOW" ); break;
570 menuName = getMenuName( "MEN_DESK_HELP" ); break;
572 return ProcessEvent( new TGetPopupMenuEvent( menuName ) );
574 QMenu* SalomePyQt::getPopupMenu( const QString& menu )
576 return ProcessEvent( new TGetPopupMenuEvent( menu ) );
580 \fn QTreeView* SalomePyQt::getObjectBrowser();
581 \brief Get object browser
582 \return object browser for the active study or 0 in case of error
585 class TGetObjectBrowserEvent: public SALOME_Event
588 typedef QTreeView* TResult;
590 TGetObjectBrowserEvent() : myResult( 0 ) {}
591 virtual void Execute()
593 LightApp_Application* anApp = getApplication();
594 if ( anApp && anApp->objectBrowser() ) {
595 myResult = anApp->objectBrowser()->treeView();
599 QTreeView* SalomePyQt::getObjectBrowser()
601 return ProcessEvent( new TGetObjectBrowserEvent() );
605 \fn int SalomePyQt::getStudyId();
606 \brief Get active study's identifier.
607 \return active study ID or 0 if there is no active study
610 class TGetStudyIdEvent: public SALOME_Event
615 TGetStudyIdEvent() : myResult( 0 ) {}
616 virtual void Execute()
618 if ( LightApp_Study* aStudy = getActiveStudy() ) {
619 myResult = aStudy->id();
623 int SalomePyQt::getStudyId()
625 return ProcessEvent( new TGetStudyIdEvent() );
629 \fn SALOME_Selection* SalomePyQt::getSelection();
630 \brief Get the selection object for the current study.
632 Creates a Selection object if it has not been created yet.
634 \return selection object (0 on error)
637 class TGetSelectionEvent: public SALOME_Event
640 typedef SALOME_Selection* TResult;
642 TGetSelectionEvent() : myResult( 0 ) {}
643 virtual void Execute()
645 myResult = SALOME_Selection::GetSelection( getApplication() );
648 SALOME_Selection* SalomePyQt::getSelection()
650 return ProcessEvent( new TGetSelectionEvent() );
654 \fn QStringList* SalomePyQt::setSelection(const QStringList& );
655 \brief Send local selection for notification.
657 The list of locally selected objects (study entries) is sent for notification of
658 other listening entities (modules, viewers...).
661 class TSetSelectionEvent: public SALOME_Event
663 QStringList myEntryList;
665 TSetSelectionEvent(const QStringList& entryList) : myEntryList(entryList) {}
666 virtual void Execute()
668 SALOME_PYQT_ModuleLight* module = dynamic_cast<SALOME_PYQT_ModuleLight*>( getActiveModule() );
669 if ( !module ) return;
670 module->setLocalSelected(myEntryList);
673 void SalomePyQt::setSelection( const QStringList& entryList)
675 return ProcessVoidEvent( new TSetSelectionEvent(entryList) );
679 \fn void SalomePyQt::enableSelector();
680 \brief enable PyQt_Selector (on module activation, for instance)
683 class TEnableSelectorEvent: public SALOME_Event
686 TEnableSelectorEvent() {}
687 virtual void Execute()
689 SALOME_PYQT_ModuleLight* module = dynamic_cast<SALOME_PYQT_ModuleLight*>( getActiveModule() );
690 if ( !module ) return;
691 module->enableSelector();
694 void SalomePyQt::enableSelector()
696 return ProcessVoidEvent( new TEnableSelectorEvent() );
701 \fn void SalomePyQt::disableSelector();
702 \brief disable PyQt_Selector (on module activation, for instance)
705 class TdisableSelectorEvent: public SALOME_Event
708 TdisableSelectorEvent() {}
709 virtual void Execute()
711 SALOME_PYQT_ModuleLight* module = dynamic_cast<SALOME_PYQT_ModuleLight*>( getActiveModule() );
712 if ( !module ) return;
713 module->disableSelector();
716 void SalomePyQt::disableSelector()
718 return ProcessVoidEvent( new TdisableSelectorEvent() );
723 \fn void SalomePyQt::putInfo( const QString& msg, const int sec );
724 \brief Put an information message to the current application's
727 Optional second delay parameter (\a sec) can be used to specify
728 time of the message diplaying in seconds. If this parameter is less
729 or equal to zero, the constant message will be put.
731 \param msg message text
732 \param sec message displaying time in seconds
735 class TPutInfoEvent: public SALOME_Event
740 TPutInfoEvent( const QString& msg, const int sec = 0 ) : myMsg( msg ), mySecs( sec ) {}
741 virtual void Execute()
743 if ( LightApp_Application* anApp = getApplication() ) {
744 anApp->putInfo( myMsg, mySecs * 1000 );
748 void SalomePyQt::putInfo( const QString& msg, const int sec )
750 ProcessVoidEvent( new TPutInfoEvent( msg, sec ) );
754 \fn int SalomePyQt::showNotification( const QString& msg, const QString& title, const int sec );
755 \brief Show notification in the application's desktop window.
757 Optional third delay parameter (\a sec) can be used to specify
758 time of the notification diplaying in seconds. If this parameter is less
759 or equal to zero, the permanent notification will be put.
761 Notification can be forcibly hidden via hideNotification() method.
763 \param msg message text
764 \param title title text
765 \param sec notification displaying time in seconds
766 \return unique ID of the notification (can be used to hide notification)
767 \sa hideNotification()
770 class TShowNotifyEvent: public SALOME_Event
781 TShowNotifyEvent( const QString& msg, const QString& title, const int sec = -1 ) : myMsg( msg ), myTitle( title), mySecs( sec ), myResult( -1 ) {}
782 virtual void Execute()
784 if ( LightApp_Application* anApp = getApplication() ) {
785 myResult = anApp->showNotification( myMsg, myTitle, mySecs * 1000 );
790 int SalomePyQt::showNotification( const QString& msg, const QString& title, const int sec )
792 return ProcessEvent( new TShowNotifyEvent( msg, title, sec ) );
796 \fn void SalomePyQt::hideNotification( const QString& msg );
797 \brief Remove notification with given message text from the application's desktop.
799 \param msg message text
800 \sa showNotification()
804 \fn void SalomePyQt::hideNotification( const int id );
805 \brief Remove notification with given \a id from the application's desktop.
807 \param id notification id
808 \sa showNotification()
811 class THideNotifyEvent: public SALOME_Event
817 THideNotifyEvent( const QString& msg ) : myId( -1 ), myMsg( msg ) {}
818 THideNotifyEvent( const int id ) : myId( id ) {}
819 virtual void Execute()
821 if ( LightApp_Application* anApp = getApplication() ) {
823 anApp->hideNotification( myId );
825 anApp->hideNotification( myMsg );
830 void SalomePyQt::hideNotification( const QString& msg )
832 ProcessVoidEvent( new THideNotifyEvent( msg ) );
835 void SalomePyQt::hideNotification( const int id )
837 ProcessVoidEvent( new THideNotifyEvent( id ) );
841 \fn const QString SalomePyQt::getActiveComponent();
842 \brief Get the currently active module name (for the current study).
843 \return active module name or empty string if there is no active module
846 class TGetActiveComponentEvent: public SALOME_Event
849 typedef QString TResult;
851 TGetActiveComponentEvent() {}
852 virtual void Execute()
854 if ( LightApp_Application* anApp = getApplication() ) {
855 if ( CAM_Module* mod = anApp->activeModule() ) {
856 myResult = mod->name();
861 const QString SalomePyQt::getActiveComponent()
863 return ProcessEvent( new TGetActiveComponentEvent() );
867 \fn PyObject* SalomePyQt::getActivePythonModule();
868 \brief Access to Python module object currently loaded into SALOME_PYQT_ModuleLight container.
869 \return Python module object currently loaded into SALOME_PYQT_ModuleLight container
872 class TGetActivePyModuleEvent: public SALOME_Event
875 typedef PyObject* TResult;
877 TGetActivePyModuleEvent() : myResult( Py_None ) {}
878 virtual void Execute()
880 PyModuleHelper* helper = getPythonHelper();
882 myResult = (PyObject*)helper->pythonModule();
885 PyObject* SalomePyQt::getActivePythonModule()
887 return ProcessEvent( new TGetActivePyModuleEvent() );
891 \fn bool SalomePyQt::activateModule( const QString& modName );
892 \brief Activates SALOME module with the given name
893 \return True if the module has been activated and False otherwise.
896 class TActivateModuleEvent: public SALOME_Event
899 typedef bool TResult;
901 QString myModuleName;
902 TActivateModuleEvent( const QString& modName )
903 : myResult( false ), myModuleName( modName ) {}
904 virtual void Execute()
906 if ( LightApp_Application* anApp = getApplication() ) {
907 myResult = anApp->activateModule( myModuleName );
911 bool SalomePyQt::activateModule( const QString& modName )
913 return ProcessEvent( new TActivateModuleEvent( modName ) );
917 \brief Update an Object Browser of the specified (by identifier) study.
919 If \a studyId <= 0 the active study's object browser is updated.
920 The \a updateSelection parameter is obsolete and currently is not used.
921 This parameter will be removed in future, so try to avoid its usage in
924 \brief studyId study identifier
925 \brief updateSelection update selection flag (not used)
928 void SalomePyQt::updateObjBrowser( const int studyId, bool updateSelection )
930 class TEvent: public SALOME_Event
933 bool myUpdateSelection;
935 TEvent( const int studyId, bool updateSelection )
936 : myStudyId( studyId ), myUpdateSelection( updateSelection ) {}
937 virtual void Execute()
939 if ( SUIT_Session::session() ) {
940 if ( getActiveStudy() && myStudyId <= 0 )
941 myStudyId = getActiveStudy()->id();
942 if ( myStudyId > 0 ) {
943 QList<SUIT_Application*> apps = SUIT_Session::session()->applications();
944 QList<SUIT_Application*>::Iterator it;
945 for( it = apps.begin(); it != apps.end(); ++it ) {
946 LightApp_Application* anApp = dynamic_cast<LightApp_Application*>( *it );
947 if ( anApp && anApp->activeStudy() && anApp->activeStudy()->id() == myStudyId ) {
948 anApp->updateObjectBrowser();
956 ProcessVoidEvent( new TEvent( studyId, updateSelection ) );
961 SalomePyQt::isModified()
962 \return The modification status of the data model
963 for the currently active Python module
964 \note This function is supported for "light" Python-based SALOME modules only.
967 class TIsModifiedEvent: public SALOME_Event
970 typedef bool TResult;
972 TIsModifiedEvent() : myResult( false ) {}
973 virtual void Execute()
975 LightApp_Module* module = getActiveModule();
979 SALOME_PYQT_DataModelLight* aModel =
980 dynamic_cast<SALOME_PYQT_DataModelLight*>( module->dataModel() );
982 myResult = aModel->isModified();
985 if ( verbose() ) printf( "SalomePyQt.isModified() function is not supported for the current module.\n" );
989 bool SalomePyQt::isModified()
991 return ProcessEvent(new TIsModifiedEvent());
995 SalomePyQt::setModified()
997 Sets the modification status of the data model for
998 the currently active Python module. This method should be used
999 by the Python code in order to enable/disable "Save" operation
1000 depending on the module's data state.
1002 \note This function is supported for "light" Python-based SALOME modules only.
1004 \param New modification status of the data model
1008 void SalomePyQt::setModified( bool flag )
1010 class TEvent: public SALOME_Event
1016 virtual void Execute()
1018 LightApp_Module* module = getActiveModule();
1022 SALOME_PYQT_DataModelLight* model =
1023 dynamic_cast<SALOME_PYQT_DataModelLight*>( module->dataModel() );
1025 LightApp_Application* app = module->getApp();
1027 if ( model && app ) {
1028 model->setModified( myFlag );
1029 app->updateActions();
1032 if ( verbose() ) printf( "SalomePyQt.setModified() function is not supported for the current module.\n" );
1036 ProcessVoidEvent( new TEvent( flag ) );
1040 \brief Add string setting to the application preferences.
1042 The parameter \a autoValue is obsolete parameter and currently is not used.
1043 This parameter will be removed in future, so try to avoid its usage in
1046 This function is obsolete. Use one of addSetting() instead.
1048 \param name setting name (it should be of kind <section:setting> where
1049 \c section is resources section name and \c setting is setting name)
1050 \param value new setting value
1051 \param autoValue (not used)
1053 void SalomePyQt::addStringSetting( const QString& name, const QString& value, bool autoValue )
1055 class TEvent: public SALOME_Event
1061 TEvent( const QString& name, const QString& value, bool autoValue )
1062 : myName( name ), myValue( value ), myAutoValue( autoValue ) {}
1063 virtual void Execute()
1065 if ( SUIT_Session::session() ) {
1066 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1067 QStringList sl = myName.split( ":", QString::SkipEmptyParts );
1068 QString _sec = sl.count() > 1 ? sl[ 0 ].trimmed() : QString( DEFAULT_SECTION );
1069 QString _nam = sl.count() > 1 ? sl[ 1 ].trimmed() : sl.count() > 0 ? sl[ 0 ].trimmed() : QString( "" );
1070 if ( !_sec.isEmpty() && !_nam.isEmpty() )
1071 resMgr->setValue( _sec, _nam, myValue );
1075 ProcessVoidEvent( new TEvent( name, value, autoValue ) );
1079 \brief Add integer setting to the application preferences.
1081 The parameter \a autoValue is obsolete parameter and currently is not used.
1082 This parameter will be removed in future, so try to avoid its usage in
1085 This function is obsolete. Use one of addSetting() instead.
1087 \param name setting name (it should be of kind <section:setting> where
1088 \c section is resources section name and \c setting is setting name)
1089 \param value new setting value
1090 \param autoValue (not used)
1092 void SalomePyQt::addIntSetting( const QString& name, const int value, bool autoValue)
1094 class TEvent: public SALOME_Event
1100 TEvent( const QString& name, const int value, bool autoValue )
1101 : myName( name ), myValue( value ), myAutoValue( autoValue ) {}
1102 virtual void Execute()
1104 if ( SUIT_Session::session() ) {
1105 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1106 QStringList sl = myName.split( ":", QString::SkipEmptyParts );
1107 QString _sec = sl.count() > 1 ? sl[ 0 ].trimmed() : QString( DEFAULT_SECTION );
1108 QString _nam = sl.count() > 1 ? sl[ 1 ].trimmed() : sl.count() > 0 ? sl[ 0 ].trimmed() : QString( "" );
1109 if ( !_sec.isEmpty() && !_nam.isEmpty() )
1110 resMgr->setValue( _sec, _nam, myValue );
1114 ProcessVoidEvent( new TEvent( name, value, autoValue ) );
1118 \brief Add double setting to the application preferences.
1120 The parameter \a autoValue is obsolete parameter and currently is not used.
1121 This parameter will be removed in future, so try to avoid its usage in
1124 This function is obsolete. Use one of addSetting() instead.
1126 \param name setting name (it should be of kind <section:setting> where
1127 \c section is resources section name and \c setting is setting name)
1128 \param value new setting value
1129 \param autoValue (not used)
1131 void SalomePyQt::addDoubleSetting( const QString& name, const double value, bool autoValue )
1133 class TEvent: public SALOME_Event
1139 TEvent( const QString& name, const double value, bool autoValue )
1140 : myName( name ), myValue( value ), myAutoValue( autoValue ) {}
1141 virtual void Execute()
1143 if ( SUIT_Session::session() ) {
1144 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1145 QStringList sl = myName.split( ":", QString::SkipEmptyParts );
1146 QString _sec = sl.count() > 1 ? sl[ 0 ].trimmed() : QString( DEFAULT_SECTION );
1147 QString _nam = sl.count() > 1 ? sl[ 1 ].trimmed() : sl.count() > 0 ? sl[ 0 ].trimmed() : QString( "" );
1148 if ( !_sec.isEmpty() && !_nam.isEmpty() )
1149 resMgr->setValue( _sec, _nam, myValue );
1153 ProcessVoidEvent( new TEvent( name, value, autoValue ) );
1157 \brief Add boolean setting to the application preferences.
1159 The parameter \a autoValue is obsolete parameter and currently is not used.
1160 This parameter will be removed in future, so try to avoid its usage in
1163 This function is obsolete. Use one of addSetting() instead.
1165 \param name setting name (it should be of kind <section:setting> where
1166 \c section is resources section name and \c setting is setting name)
1167 \param value new setting value
1168 \param autoValue (not used)
1170 void SalomePyQt::addBoolSetting( const QString& name, const bool value, bool autoValue )
1172 class TEvent: public SALOME_Event
1178 TEvent( const QString& name, const bool value, bool autoValue )
1179 : myName( name ), myValue( value ), myAutoValue( autoValue ) {}
1180 virtual void Execute()
1182 if ( SUIT_Session::session() ) {
1183 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1184 QStringList sl = myName.split( ":", QString::SkipEmptyParts );
1185 QString _sec = sl.count() > 1 ? sl[ 0 ].trimmed() : QString( DEFAULT_SECTION );
1186 QString _nam = sl.count() > 1 ? sl[ 1 ].trimmed() : sl.count() > 0 ? sl[ 0 ].trimmed() : QString( "" );
1187 if ( !_sec.isEmpty() && !_nam.isEmpty() )
1188 resMgr->setValue( _sec, _nam, myValue );
1192 ProcessVoidEvent( new TEvent( name, value, autoValue ) );
1196 \brief Remove setting from the application preferences.
1198 This function is obsolete. Use removeSetting() instead.
1200 \param name setting name (it should be of kind <section:setting> where
1201 \c section is resources section name and \c setting is setting name)
1203 void SalomePyQt::removeSettings( const QString& name )
1205 class TEvent: public SALOME_Event
1209 TEvent( const QString& name ) : myName( name ) {}
1210 virtual void Execute()
1212 if ( SUIT_Session::session() ) {
1213 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1214 QStringList sl = myName.split( ":", QString::SkipEmptyParts );
1215 QString _sec = sl.count() > 1 ? sl[ 0 ].trimmed() : QString( DEFAULT_SECTION );
1216 QString _nam = sl.count() > 1 ? sl[ 1 ].trimmed() : sl.count() > 0 ? sl[ 0 ].trimmed() : QString( "" );
1217 if ( !_sec.isEmpty() && !_nam.isEmpty() )
1218 resMgr->remove( _sec, _nam );
1222 ProcessVoidEvent( new TEvent( name ) );
1226 \fn QString SalomePyQt::getSetting( const QString& name );
1227 \brief Get application setting value (as string represenation).
1229 This function is obsolete. Use stringSetting(), integerSetting(),
1230 boolSetting(), stringSetting() or colorSetting() instead.
1232 \param name setting name (it should be of kind <section:setting> where
1233 \c section is resources section name and \c setting is setting name)
1234 \return setting name (empty string if setting name is invalid)
1237 class TGetSettingEvent: public SALOME_Event
1240 typedef QString TResult;
1243 TGetSettingEvent( const QString& name ) : myName( name ) {}
1244 virtual void Execute()
1246 if ( SUIT_Session::session() ) {
1247 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1248 QStringList sl = myName.split( ":", QString::SkipEmptyParts );
1249 QString _sec = sl.count() > 1 ? sl[ 0 ].trimmed() : QString( DEFAULT_SECTION );
1250 QString _nam = sl.count() > 1 ? sl[ 1 ].trimmed() : sl.count() > 0 ? sl[ 0 ].trimmed() : QString( "" );
1251 myResult = ( !_sec.isEmpty() && !_nam.isEmpty() ) ? resMgr->stringValue( _sec, _nam, "" ) : QString( "" );
1255 QString SalomePyQt::getSetting( const QString& name )
1257 return ProcessEvent( new TGetSettingEvent( name ) );
1261 \fn QString SalomePyQt::constant( const QString& name );
1262 \brief Get constant's value from application's resource manager.
1264 \param name name of the constant
1265 \return value of the constant
1270 class TGetConstantEvent: public SALOME_Event
1273 typedef QString TResult;
1276 TGetConstantEvent( const QString& name ) : myName( name ) {}
1277 virtual void Execute()
1279 if ( SUIT_Session::session() )
1280 myResult = SUIT_Session::session()->resourceMgr()->constant( myName );
1283 QString SalomePyQt::constant( const QString& name )
1285 return ProcessEvent( new TGetConstantEvent( name ) );
1289 \brief Add constant to the application's resource manager.
1291 This function is useful to specify programmatically specific
1292 variables that are referenced in the resource setting.
1294 For example, some resource value can be set as "$(myroot)/data/files".
1295 Then, "mypath" constant can be set programmatically by the application
1296 depending on run-time requirements.
1298 \param section resources file section name
1299 \param name name of the constant
1300 \param value value of the constant
1304 void SalomePyQt::setConstant( const QString& name, const QString& value )
1306 class TEvent: public SALOME_Event
1308 QString myName, myValue;
1310 TEvent( const QString& name, const QString& value )
1311 : myName( name ), myValue( value ) {}
1312 virtual void Execute()
1314 if ( SUIT_Session::session() )
1315 SUIT_Session::session()->resourceMgr()->setConstant( myName, myValue );
1318 ProcessVoidEvent( new TEvent( name, value ) );
1322 \brief Add double setting to the application preferences.
1323 \param section resources file section name
1324 \param name setting name
1325 \param value new setting value
1327 void SalomePyQt::addSetting( const QString& section, const QString& name, const double value )
1329 class TEvent: public SALOME_Event
1335 TEvent( const QString& section, const QString& name, double value )
1336 : mySection( section ), myName( name ), myValue( value ) {}
1337 virtual void Execute()
1339 if ( SUIT_Session::session() ) {
1340 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1341 if ( !mySection.isEmpty() && !myName.isEmpty() )
1342 resMgr->setValue( mySection, myName, myValue );
1346 ProcessVoidEvent( new TEvent( section, name, value ) );
1350 \brief Add integer setting to the application preferences.
1351 \param section resources file section name
1352 \param name setting name
1353 \param value new setting value
1355 void SalomePyQt::addSetting( const QString& section, const QString& name, const int value )
1357 class TEvent: public SALOME_Event
1363 TEvent( const QString& section, const QString& name, int value )
1364 : mySection( section ), myName( name ), myValue( value ) {}
1365 virtual void Execute()
1367 if ( SUIT_Session::session() ) {
1368 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1369 if ( !mySection.isEmpty() && !myName.isEmpty() )
1370 resMgr->setValue( mySection, myName, myValue );
1374 ProcessVoidEvent( new TEvent( section, name, value ) );
1378 \brief Add boolean setting to the application preferences.
1379 \param section resources file section name
1380 \param name setting name
1381 \param value new setting value
1382 \param dumb this parameter is used in order to avoid sip compilation error
1383 because of conflicting int and bool types
1385 void SalomePyQt::addSetting( const QString& section, const QString& name, const bool value, const int /*dumb*/ )
1387 class TEvent: public SALOME_Event
1393 TEvent( const QString& section, const QString& name, bool value )
1394 : mySection( section ), myName( name ), myValue( value ) {}
1395 virtual void Execute()
1397 if ( SUIT_Session::session() ) {
1398 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1399 if ( !mySection.isEmpty() && !myName.isEmpty() )
1400 resMgr->setValue( mySection, myName, myValue );
1404 ProcessVoidEvent( new TEvent( section, name, value ) );
1408 \brief Add string setting to the application preferences.
1409 \param section resources file section name
1410 \param name setting name
1411 \param value new setting value
1413 void SalomePyQt::addSetting( const QString& section, const QString& name, const QString& value )
1415 class TEvent: public SALOME_Event
1421 TEvent( const QString& section, const QString& name, const QString& value )
1422 : mySection( section ), myName( name ), myValue( value ) {}
1423 virtual void Execute()
1425 if ( SUIT_Session::session() ) {
1426 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1427 if ( !mySection.isEmpty() && !myName.isEmpty() )
1428 resMgr->setValue( mySection, myName, myValue );
1432 ProcessVoidEvent( new TEvent( section, name, value ) );
1436 \brief Add color setting to the application preferences.
1437 \param section resources file section name
1438 \param name setting name
1439 \param value new setting value
1441 void SalomePyQt::addSetting( const QString& section, const QString& name, const QColor& value )
1443 class TEvent: public SALOME_Event
1449 TEvent( const QString& section, const QString& name, const QColor& value )
1450 : mySection( section ), myName( name ), myValue( value ) {}
1451 virtual void Execute()
1453 if ( SUIT_Session::session() ) {
1454 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1455 if ( !mySection.isEmpty() && !myName.isEmpty() )
1456 resMgr->setValue( mySection, myName, myValue );
1460 ProcessVoidEvent( new TEvent( section, name, value ) );
1464 \brief Add byte array setting to the application preferences.
1465 \param section resources file section name
1466 \param name setting name
1467 \param value new setting value
1469 void SalomePyQt::addSetting( const QString& section, const QString& name, const QByteArray& value )
1471 class TEvent: public SALOME_Event
1477 TEvent( const QString& section, const QString& name, const QByteArray& value )
1478 : mySection( section ), myName( name ), myValue( value ) {}
1479 virtual void Execute()
1481 if ( SUIT_Session::session() ) {
1482 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1483 if ( !mySection.isEmpty() && !myName.isEmpty() )
1484 resMgr->setValue( mySection, myName, myValue );
1488 ProcessVoidEvent( new TEvent( section, name, value ) );
1492 \brief Add font setting to the application preferences.
1493 \param section resources file section name
1494 \param name setting name
1495 \param value new setting value
1497 void SalomePyQt::addSetting( const QString& section, const QString& name, const QFont& value )
1499 class TEvent: public SALOME_Event
1505 TEvent( const QString& section, const QString& name, const QFont& value )
1506 : mySection( section ), myName( name ), myValue( value ) {}
1507 virtual void Execute()
1509 if ( SUIT_Session::session() ) {
1510 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1511 if ( !mySection.isEmpty() && !myName.isEmpty() )
1512 resMgr->setValue( mySection, myName, myValue );
1516 ProcessVoidEvent( new TEvent( section, name, value ) );
1520 \fn int SalomePyQt::integerSetting( const QString& section,
1521 const QString& name,
1523 \brief Get integer setting from the application preferences.
1524 \param section resources file section name
1525 \param name setting name
1526 \param def default value which is returned if the setting is not found
1527 \return setting value
1530 class TGetIntSettingEvent: public SALOME_Event
1533 typedef int TResult;
1538 TGetIntSettingEvent( const QString& section, const QString& name, const int def )
1539 : mySection( section ), myName( name ), myDefault( def ) {}
1540 virtual void Execute()
1542 if ( SUIT_Session::session() ) {
1543 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1544 myResult = ( !mySection.isEmpty() && !myName.isEmpty() ) ? resMgr->integerValue( mySection, myName, myDefault ) : myDefault;
1548 int SalomePyQt::integerSetting( const QString& section, const QString& name, const int def )
1550 return ProcessEvent( new TGetIntSettingEvent( section, name, def ) );
1554 \fn double SalomePyQt::doubleSetting( const QString& section,
1555 const QString& name,
1557 \brief Get double setting from the application preferences.
1558 \param section resources file section name
1559 \param name setting name
1560 \param def default value which is returned if the setting is not found
1561 \return setting value
1564 class TGetDblSettingEvent: public SALOME_Event
1567 typedef double TResult;
1572 TGetDblSettingEvent( const QString& section, const QString& name, const double def )
1573 : mySection( section ), myName( name ), myDefault( def ) {}
1574 virtual void Execute()
1576 if ( SUIT_Session::session() ) {
1577 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1578 myResult = ( !mySection.isEmpty() && !myName.isEmpty() ) ? resMgr->doubleValue( mySection, myName, myDefault ) : myDefault;
1582 double SalomePyQt::doubleSetting( const QString& section, const QString& name, const double def )
1584 return ProcessEvent( new TGetDblSettingEvent( section, name, def ) );
1588 \fn bool SalomePyQt::boolSetting( const QString& section,
1589 const QString& name,
1591 \brief Get boolean setting from the application preferences.
1592 \param section resources file section name
1593 \param name setting name
1594 \param def default value which is returned if the setting is not found
1595 \return setting value
1598 class TGetBoolSettingEvent: public SALOME_Event
1601 typedef bool TResult;
1606 TGetBoolSettingEvent( const QString& section, const QString& name, const bool def )
1607 : mySection( section ), myName( name ), myDefault( def ) {}
1608 virtual void Execute()
1610 if ( SUIT_Session::session() ) {
1611 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1612 myResult = ( !mySection.isEmpty() && !myName.isEmpty() ) ? resMgr->booleanValue( mySection, myName, myDefault ) : myDefault;
1616 bool SalomePyQt::boolSetting( const QString& section, const QString& name, const bool def )
1618 return ProcessEvent( new TGetBoolSettingEvent( section, name, def ) );
1622 \fn QString SalomePyQt::stringSetting( const QString& section,
1623 const QString& name,
1626 \brief Get string setting from the application preferences.
1627 \param section resources file section name
1628 \param name setting name
1629 \param def default value which is returned if the setting is not found
1630 \param subst \c true to make substitution, \c false to get "raw" value
1631 \return setting value
1634 class TGetStrSettingEvent: public SALOME_Event
1637 typedef QString TResult;
1643 TGetStrSettingEvent( const QString& section, const QString& name, const QString& def, const bool subst )
1644 : mySection( section ), myName( name ), myDefault( def ), mySubst( subst ) {}
1645 virtual void Execute()
1647 if ( SUIT_Session::session() ) {
1648 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1649 myResult = ( !mySection.isEmpty() && !myName.isEmpty() ) ? resMgr->stringValue( mySection, myName, myDefault, mySubst ) : myDefault;
1653 QString SalomePyQt::stringSetting( const QString& section, const QString& name, const QString& def, const bool subst )
1655 return ProcessEvent( new TGetStrSettingEvent( section, name, def, subst ) );
1659 \fn QColor SalomePyQt::colorSetting( const QString& section,
1660 const QString& name,
1662 \brief Get color setting from the application preferences.
1663 \param section resources file section name
1664 \param name setting name
1665 \param def default value which is returned if the setting is not found
1666 \return setting value
1669 class TGetColorSettingEvent: public SALOME_Event
1672 typedef QColor TResult;
1677 TGetColorSettingEvent( const QString& section, const QString& name, const QColor& def )
1678 : mySection( section ), myName( name ), myDefault( def ) {}
1679 virtual void Execute()
1681 if ( SUIT_Session::session() ) {
1682 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1683 myResult = ( !mySection.isEmpty() && !myName.isEmpty() ) ? resMgr->colorValue( mySection, myName, myDefault ) : myDefault;
1687 QColor SalomePyQt::colorSetting ( const QString& section, const QString& name, const QColor& def )
1689 return ProcessEvent( new TGetColorSettingEvent( section, name, def ) );
1693 \fn QByteArray SalomePyQt::byteArraySetting( const QString& section,
1694 const QString& name,
1695 const QByteArray& def );
1696 \brief Get byte array setting from the application preferences.
1697 \param section resources file section name
1698 \param name setting name
1699 \param def default value which is returned if the setting is not found
1700 \return setting value
1703 class TGetByteArraySettingEvent: public SALOME_Event
1706 typedef QByteArray TResult;
1711 TGetByteArraySettingEvent( const QString& section, const QString& name, const QByteArray& def )
1712 : mySection( section ), myName( name ), myDefault( def ) {}
1713 virtual void Execute()
1715 if ( SUIT_Session::session() ) {
1716 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1717 myResult = ( !mySection.isEmpty() && !myName.isEmpty() ) ? resMgr->byteArrayValue( mySection, myName, myDefault ) : myDefault;
1721 QByteArray SalomePyQt::byteArraySetting ( const QString& section, const QString& name, const QByteArray& def )
1723 return ProcessEvent( new TGetByteArraySettingEvent( section, name, def ) );
1727 \fn QByteArray SalomePyQt::fontSetting( const QString& section,
1728 const QString& name,
1730 \brief Get font setting from the application preferences.
1731 \param section resources file section name
1732 \param name setting name
1733 \param def default value which is returned if the setting is not found
1734 \return setting value
1737 class TGetFontSettingEvent: public SALOME_Event
1740 typedef QFont TResult;
1745 TGetFontSettingEvent( const QString& section, const QString& name, const QFont& def )
1746 : mySection( section ), myName( name ), myDefault( def ) {}
1747 virtual void Execute()
1749 if ( SUIT_Session::session() ) {
1750 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1751 myResult = ( !mySection.isEmpty() && !myName.isEmpty() ) ? resMgr->fontValue( mySection, myName, myDefault ) : myDefault;
1755 QFont SalomePyQt::fontSetting ( const QString& section, const QString& name, const QFont& def )
1757 return ProcessEvent( new TGetFontSettingEvent( section, name, def ) );
1761 \brief Remove setting from the application preferences.
1762 \param section resources file section name
1763 \param name setting name
1765 void SalomePyQt::removeSetting( const QString& section, const QString& name )
1767 class TEvent: public SALOME_Event
1772 TEvent( const QString& section, const QString& name ) : mySection( section ), myName( name ) {}
1773 virtual void Execute()
1775 if ( SUIT_Session::session() ) {
1776 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1777 if ( !mySection.isEmpty() && !myName.isEmpty() )
1778 resMgr->remove( mySection, myName );
1782 ProcessVoidEvent( new TEvent( section, name ) );
1786 \fn bool SalomePyQt::hasSetting( const QString& section, const QString& name );
1787 \brief Check setting existence in the application preferences.
1788 \param section resources file section name
1789 \param name setting name
1790 \return \c true if setting exists
1793 class THasSettingEvent: public SALOME_Event
1796 typedef bool TResult;
1800 THasSettingEvent( const QString& section, const QString& name )
1801 : mySection( section ), myName( name ) {}
1802 virtual void Execute()
1804 if ( SUIT_Session::session() ) {
1805 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1806 myResult = resMgr->hasValue( mySection, myName );
1810 bool SalomePyQt::hasSetting( const QString& section, const QString& name )
1812 return ProcessEvent( new THasSettingEvent( section, name ) );
1816 \fn QStringList SalomePyQt::parameters( const QString& section );
1817 \brief Get names of preference items stored within the given section.
1818 \param section resources file section's name
1819 \return \c list of preferences items
1823 \fn QStringList SalomePyQt::parameters( const QStringList& section );
1824 \brief Get names of preference items stored within the given section.
1825 \param section resources file section's name
1826 \return \c list of preferences items
1829 class TParametersEvent: public SALOME_Event
1832 typedef QStringList TResult;
1834 QStringList mySection;
1835 TParametersEvent( const QString& section )
1837 mySection << section;
1839 TParametersEvent( const QStringList& section )
1840 : mySection( section )
1842 virtual void Execute()
1844 if ( SUIT_Session::session() ) {
1845 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1846 myResult = resMgr->parameters( mySection );
1850 QStringList SalomePyQt::parameters( const QString& section )
1852 return ProcessEvent( new TParametersEvent( section ) );
1854 QStringList SalomePyQt::parameters( const QStringList& section )
1856 return ProcessEvent( new TParametersEvent( section ) );
1860 \fn QString SalomePyQt::getFileName( QWidget* parent,
1861 const QString& initial,
1862 const QStringList& filters,
1863 const QString& caption,
1865 \brief Show 'Open/Save file' dialog box for file selection
1866 and return a user's choice (selected file name).
1867 \param parent parent widget
1868 \param initial initial directory the dialog box to be opened in
1869 \param filters list of files filters (wildcards)
1870 \param caption dialog box title
1871 \param open if \c true, "Open File" dialog box is shown;
1872 otherwise "Save File" dialog box is shown
1873 \return selected file name (null string if user cancels operation)
1876 class TGetFileNameEvent: public SALOME_Event
1879 typedef QString TResult;
1883 QStringList myFilters;
1886 TGetFileNameEvent( QWidget* parent,
1887 const QString& initial,
1888 const QStringList& filters,
1889 const QString& caption,
1891 : myParent ( parent ),
1892 myInitial( initial ),
1893 myFilters( filters ),
1894 myCaption( caption ),
1896 virtual void Execute()
1898 if ( LightApp_Application* anApp = getApplication() ) {
1899 myResult = anApp->getFileName( myOpen, myInitial, myFilters.join(";;"),
1900 myCaption, myParent );
1904 QString SalomePyQt::getFileName( QWidget* parent,
1905 const QString& initial,
1906 const QStringList& filters,
1907 const QString& caption,
1910 return ProcessEvent( new TGetFileNameEvent( parent, initial, filters, caption, open ) );
1914 \fn QStringList SalomePyQt::getOpenFileNames( QWidget* parent,
1915 const QString& initial,
1916 const QStringList& filters,
1917 const QString& caption );
1918 \brief Show 'Open files' dialog box for multiple files selection
1919 and return a user's choice (selected file names list).
1920 \param parent parent widget
1921 \param initial initial directory the dialog box to be opened in
1922 \param filters list of files filters (wildcards)
1923 \param caption dialog box title
1924 \return selected file names list (empty list if user cancels operation)
1927 class TGetOpenFileNamesEvent: public SALOME_Event
1930 typedef QStringList TResult;
1934 QStringList myFilters;
1936 TGetOpenFileNamesEvent( QWidget* parent,
1937 const QString& initial,
1938 const QStringList& filters,
1939 const QString& caption )
1940 : myParent ( parent ),
1941 myInitial( initial ),
1942 myFilters( filters ),
1943 myCaption( caption ) {}
1944 virtual void Execute()
1946 if ( LightApp_Application* anApp = getApplication() ) {
1947 myResult = anApp->getOpenFileNames( myInitial, myFilters.join(";;"), myCaption, myParent );
1951 QStringList SalomePyQt::getOpenFileNames( QWidget* parent,
1952 const QString& initial,
1953 const QStringList& filters,
1954 const QString& caption )
1956 return ProcessEvent( new TGetOpenFileNamesEvent( parent, initial, filters, caption ) );
1960 \fn QString SalomePyQt::getExistingDirectory( QWidget* parent,
1961 const QString& initial,
1962 const QString& caption );
1963 \brief Show 'Get Directory' dialog box for the directory selection
1964 and return a user's choice (selected directory name).
1965 \param parent parent widget
1966 \param initial initial directory the dialog box to be opened in
1967 \param caption dialog box title
1968 \return selected directory name (null string if user cancels operation)
1971 class TGetExistingDirectoryEvent: public SALOME_Event
1974 typedef QString TResult;
1979 TGetExistingDirectoryEvent( QWidget* parent,
1980 const QString& initial,
1981 const QString& caption )
1982 : myParent ( parent ),
1983 myInitial( initial ),
1984 myCaption( caption ) {}
1985 virtual void Execute()
1987 if ( LightApp_Application* anApp = getApplication() ) {
1988 myResult = anApp->getDirectory( myInitial, myCaption, myParent );
1992 QString SalomePyQt::getExistingDirectory( QWidget* parent,
1993 const QString& initial,
1994 const QString& caption )
1996 return ProcessEvent( new TGetExistingDirectoryEvent( parent, initial, caption ) );
2000 \fn QString SalomePyQt::loadIcon( const QString& filename );
2001 \brief Load an icon from the module resources by the specified file name.
2002 \param fileName icon file name
2006 class TLoadIconEvent: public SALOME_Event
2009 typedef QIcon TResult;
2013 TLoadIconEvent( const QString& module, const QString& filename )
2014 : myModule( module ),
2015 myFileName ( filename ) {}
2016 virtual void Execute()
2018 myResult = loadIconInternal( myModule, myFileName );
2021 QIcon SalomePyQt::loadIcon( const QString& module, const QString& filename )
2023 return ProcessEvent( new TLoadIconEvent( module, filename ) );
2027 \brief Open external browser to display context help information.
2030 Current implementation does nothing.
2032 \param source documentation (HTML) file name
2033 \param context context (for example, HTML ancor name)
2035 void SalomePyQt::helpContext( const QString& source, const QString& context )
2037 class TEvent: public SALOME_Event
2042 TEvent( const QString& source, const QString& context )
2043 : mySource( source ), myContext( context ) {}
2044 virtual void Execute()
2046 if ( LightApp_Application* anApp = getApplication() ) {
2047 anApp->onHelpContextModule( "", mySource, myContext );
2051 ProcessVoidEvent( new TEvent( source, context ) );
2055 \fn int SalomePyQt::defaultMenuGroup();
2056 \brief Get detault menu group identifier which can be used when
2057 creating menus (insert custom menu commands).
2058 \return default menu group ID
2061 class TDefMenuGroupEvent: public SALOME_Event
2064 typedef int TResult;
2066 TDefMenuGroupEvent() : myResult( -1 ) {}
2067 virtual void Execute()
2069 myResult = PyModuleHelper::defaultMenuGroup();
2072 int SalomePyQt::defaultMenuGroup()
2074 return ProcessEvent( new TDefMenuGroupEvent() );
2080 CrTool( const QString& tBar, const QString& nBar )
2081 : myCase( 0 ), myTbTitle( tBar ), myTbName( nBar) {}
2082 CrTool( const int id, const int tBar, const int idx )
2083 : myCase( 1 ), myId( id ), myTbId( tBar ), myIndex( idx ) {}
2084 CrTool( const int id, const QString& tBar, const int idx )
2085 : myCase( 2 ), myId( id ), myTbTitle( tBar ), myIndex( idx ) {}
2086 CrTool( QAction* action, const int tbId, const int id, const int idx )
2087 : myCase( 3 ), myAction( action ), myTbId( tbId ), myId( id ), myIndex( idx ) {}
2088 CrTool( QAction* action, const QString& tBar, const int id, const int idx )
2089 : myCase( 4 ), myAction( action ), myTbTitle( tBar ), myId( id ), myIndex( idx ) {}
2091 int execute( LightApp_Module* module ) const
2096 return module->createTool( myTbTitle, myTbName );
2098 return module->createTool( myId, myTbId, myIndex );
2100 return module->createTool( myId, myTbTitle, myIndex );
2102 return module->createTool( myAction, myTbId, myId, myIndex );
2104 return module->createTool( myAction, myTbTitle, myId, myIndex );
2119 class TCreateToolEvent: public SALOME_Event
2122 typedef int TResult;
2124 const CrTool& myCrTool;
2125 TCreateToolEvent( const CrTool& crTool )
2126 : myResult( -1 ), myCrTool( crTool ) {}
2127 virtual void Execute()
2129 LightApp_Module* module = getActiveModule();
2131 myResult = myCrTool.execute( module );
2136 \brief Create toolbar with specified name.
2137 \param tBar toolbar title (language-dependent)
2138 \param nBar toolbar name (language-independent) [optional]
2139 \return toolbar ID or -1 if toolbar creation is failed
2141 int SalomePyQt::createTool( const QString& tBar, const QString& nBar )
2143 return ProcessEvent( new TCreateToolEvent( CrTool( tBar, nBar ) ) );
2147 \brief Insert action with specified \a id to the toolbar.
2149 \param tBar toolbar ID
2150 \param idx required index in the toolbar
2151 \return action ID or -1 if action could not be added
2153 int SalomePyQt::createTool( const int id, const int tBar, const int idx )
2155 return ProcessEvent( new TCreateToolEvent( CrTool( id, tBar, idx ) ) );
2159 \brief Insert action with specified \a id to the toolbar.
2161 \param tBar toolbar name
2162 \param idx required index in the toolbar
2163 \return action ID or -1 if action could not be added
2165 int SalomePyQt::createTool( const int id, const QString& tBar, const int idx )
2167 return ProcessEvent( new TCreateToolEvent( CrTool( id, tBar, idx ) ) );
2171 \brief Insert action to the toolbar.
2173 \param tBar toolbar ID
2174 \param id required action ID
2175 \param idx required index in the toolbar
2176 \return action ID or -1 if action could not be added
2178 int SalomePyQt::createTool( QAction* a, const int tBar, const int id, const int idx )
2180 return ProcessEvent( new TCreateToolEvent( CrTool( a, tBar, id, idx ) ) );
2184 \brief Insert action to the toolbar.
2186 \param tBar toolbar name
2187 \param id required action ID
2188 \param idx required index in the toolbar
2189 \return action ID or -1 if action could not be added
2191 int SalomePyQt::createTool( QAction* a, const QString& tBar, const int id, const int idx )
2193 return ProcessEvent( new TCreateToolEvent( CrTool( a, tBar, id, idx ) ) );
2199 CrMenu( const QString& subMenu, const int menu, const int id, const int group, const int idx )
2200 : myCase( 0 ), mySubMenuName( subMenu ), myMenuId( menu ), myId( id ), myGroup( group ), myIndex( idx ) {}
2201 CrMenu( const QString& subMenu, const QString& menu, const int id, const int group, const int idx )
2202 : myCase( 1 ), mySubMenuName( subMenu ), myMenuName( menu ), myId( id ), myGroup( group ), myIndex( idx ) {}
2203 CrMenu( const int id, const int menu, const int group, const int idx )
2204 : myCase( 2 ), myId( id ), myMenuId( menu ), myGroup( group ), myIndex( idx ) {}
2205 CrMenu( const int id, const QString& menu, const int group, const int idx )
2206 : myCase( 3 ), myId( id ), myMenuName( menu ), myGroup( group ), myIndex( idx ) {}
2207 CrMenu( QAction* action, const int menu, const int id, const int group, const int idx )
2208 : myCase( 4 ), myAction( action ), myMenuId( menu ), myId( id ), myGroup( group ), myIndex( idx ) {}
2209 CrMenu( QAction* action, const QString& menu, const int id, const int group, const int idx )
2210 : myCase( 5 ), myAction( action ), myMenuName( menu ), myId( id ), myGroup( group ), myIndex( idx ) {}
2212 int execute( LightApp_Module* module ) const
2217 return module->createMenu( mySubMenuName, myMenuId, myId, myGroup, myIndex );
2219 return module->createMenu( mySubMenuName, myMenuName, myId, myGroup, myIndex );
2221 return module->createMenu( myId, myMenuId, myGroup, myIndex );
2223 return module->createMenu( myId, myMenuName, myGroup, myIndex );
2225 return module->createMenu( myAction, myMenuId, myId, myGroup, myIndex );
2227 return module->createMenu( myAction, myMenuName, myId, myGroup, myIndex );
2236 QString mySubMenuName;
2243 class TCreateMenuEvent: public SALOME_Event
2246 typedef int TResult;
2248 const CrMenu& myCrMenu;
2249 TCreateMenuEvent( const CrMenu& crMenu )
2250 : myResult( -1 ), myCrMenu( crMenu ) {}
2251 virtual void Execute()
2253 LightApp_Module* module = getActiveModule();
2255 myResult = myCrMenu.execute( module );
2260 \brief Create main menu.
2261 \param subMenu menu name
2262 \param menu parent menu ID
2263 \param id required menu ID
2264 \param group menu group ID
2265 \param idx required index in the menu
2266 \return menu ID or -1 if menu could not be added
2268 int SalomePyQt::createMenu( const QString& subMenu, const int menu, const int id, const int group, const int idx )
2270 return ProcessEvent( new TCreateMenuEvent( CrMenu( subMenu, menu, id, group, idx ) ) );
2274 \brief Create main menu.
2275 \param subMenu menu name
2276 \param menu parent menu name (list of menu names separated by "|")
2277 \param id required menu ID
2278 \param group menu group ID
2279 \param idx required index in the menu
2280 \return menu ID or -1 if menu could not be added
2282 int SalomePyQt::createMenu( const QString& subMenu, const QString& menu, const int id, const int group, const int idx )
2284 return ProcessEvent( new TCreateMenuEvent( CrMenu( subMenu, menu, id, group, idx ) ) );
2288 \brief Insert action to the main menu.
2290 \param menu parent menu ID
2291 \param group menu group ID
2292 \param idx required index in the menu
2293 \return action ID or -1 if action could not be added
2295 int SalomePyQt::createMenu( const int id, const int menu, const int group, const int idx )
2297 return ProcessEvent( new TCreateMenuEvent( CrMenu( id, menu, group, idx ) ) );
2301 \brief Insert action to the main menu.
2303 \param menu parent menu name (list of menu names separated by "|")
2304 \param group menu group ID
2305 \param idx required index in the menu
2306 \return action ID or -1 if action could not be added
2308 int SalomePyQt::createMenu( const int id, const QString& menu, const int group, const int idx )
2310 return ProcessEvent( new TCreateMenuEvent( CrMenu( id, menu, group, idx ) ) );
2314 \brief Insert action to the main menu.
2316 \param menu parent menu ID
2317 \param group menu group ID
2318 \param idx required index in the menu
2319 \return action ID or -1 if action could not be added
2321 int SalomePyQt::createMenu( QAction* a, const int menu, const int id, const int group, const int idx )
2323 return ProcessEvent( new TCreateMenuEvent( CrMenu( a, menu, id, group, idx ) ) );
2327 \brief Insert action to the main menu.
2329 \param menu parent menu name (list of menu names separated by "|")
2330 \param group menu group ID
2331 \param idx required index in the menu
2332 \return action ID or -1 if action could not be added
2334 int SalomePyQt::createMenu( QAction* a, const QString& menu, const int id, const int group, const int idx )
2336 return ProcessEvent( new TCreateMenuEvent( CrMenu( a, menu, id, group, idx ) ) );
2340 \fn QAction* SalomePyQt::createSeparator();
2341 \brief Create separator action which can be used in the menu or toolbar.
2342 \return new separator action
2345 class TCreateSepEvent: public SALOME_Event
2348 typedef QAction* TResult;
2352 virtual void Execute()
2354 LightApp_Module* module = getActiveModule();
2356 myResult = (QAction*)module->separator();
2359 QAction* SalomePyQt::createSeparator()
2361 return ProcessEvent( new TCreateSepEvent() );
2365 \fn QAction* SalomePyQt::createAction( const int id,
2366 const QString& menuText,
2367 const QString& tipText,
2368 const QString& statusText,
2369 const QString& icon,
2371 const bool toggle );
2372 \brief Create an action which can be then used in the menu or toolbar.
2373 \param id the unique id action to be registered to
2374 \param menuText action text which should appear in menu
2375 \param tipText text which should appear in the tooltip
2376 \param statusText text which should appear in the status bar when action is activated
2377 \param icon the name of the icon file (the actual icon file name can be coded in the translation files)
2378 \param key the key accelrator for the action
2379 \param toggle if \c true the action is checkable
2382 class TCreateActionEvent: public SALOME_Event
2385 typedef QAction* TResult;
2390 QString myStatusText;
2394 TCreateActionEvent( const int id, const QString& menuText, const QString& tipText,
2395 const QString& statusText, const QString& icon, const int key, const bool toggle )
2396 : myResult( 0 ), myId( id ), myMenuText( menuText ), myTipText( tipText ),
2397 myStatusText( statusText ), myIcon( icon ), myKey( key ), myToggle( toggle ) {}
2398 virtual void Execute()
2400 LightApp_Module* module = getActiveModule();
2402 QIcon icon = loadIconInternal( module->name(), myIcon );
2403 myResult = (QAction*)module->action( myId );
2405 if ( myResult->toolTip().isEmpty() && !myTipText.isEmpty() )
2406 myResult->setToolTip( myTipText );
2407 if ( myResult->text().isEmpty() && !myMenuText.isEmpty() )
2408 myResult->setText( myMenuText );
2409 if ( myResult->icon().isNull() && !icon.isNull() )
2410 myResult->setIcon( icon );
2411 if ( myResult->statusTip().isEmpty() && !myStatusText.isEmpty() )
2412 myResult->setStatusTip( myStatusText );
2413 if ( myResult->shortcut().isEmpty() && myKey )
2414 myResult->setShortcut( myKey );
2415 if ( myResult->isCheckable() != myToggle )
2416 myResult->setCheckable( myToggle );
2419 myResult = (QAction*)module->createAction( myId, myTipText, icon, myMenuText, myStatusText, myKey, module, myToggle );
2421 // for Python module, automatically connect action to callback slot
2422 PyModuleHelper* helper = module->findChild<PyModuleHelper*>( "python_module_helper" );
2423 if ( helper ) helper->connectAction( myResult );
2427 QAction* SalomePyQt::createAction( const int id, const QString& menuText,
2428 const QString& tipText, const QString& statusText,
2429 const QString& icon, const int key, const bool toggle )
2431 return ProcessEvent( new TCreateActionEvent( id, menuText, tipText, statusText, icon, key, toggle ) );
2435 \fn QtxActionGroup* SalomePyQt::createActionGroup( const int id, const bool exclusive );
2436 \brief Create an action group which can be then used in the menu or toolbar
2437 \param id : the unique id action group to be registered to
2438 \param exclusive : if \c true the action group does exclusive toggling
2441 struct TCreateActionGroupEvent: public SALOME_Event
2443 typedef QtxActionGroup* TResult;
2447 TCreateActionGroupEvent( const int id, const bool exclusive )
2448 : myId( id ), myExclusive( exclusive ) {}
2449 virtual void Execute()
2451 LightApp_Module* module = getActiveModule();
2453 myResult = module->createActionGroup( myId, myExclusive );
2456 QtxActionGroup* SalomePyQt::createActionGroup( const int id, const bool exclusive )
2458 return ProcessEvent( new TCreateActionGroupEvent( id, exclusive ) );
2462 \fn QAction* SalomePyQt::action( const int id );
2463 \brief Get action by specified identifier.
2464 \return action or 0 if action is not registered
2467 class TActionEvent: public SALOME_Event
2470 typedef QAction* TResult;
2473 TActionEvent( const int id )
2474 : myResult( 0 ), myId( id ) {}
2475 virtual void Execute()
2477 LightApp_Module* module = getActiveModule();
2479 myResult = (QAction*)module->action( myId );
2482 QAction* SalomePyQt::action( const int id )
2484 return ProcessEvent( new TActionEvent( id ) );
2488 \fn int SalomePyQt::actionId( const QAction* a );
2489 \brief Get an action identifier.
2490 \return action ID or -1 if action is not registered
2493 class TActionIdEvent: public SALOME_Event
2496 typedef int TResult;
2498 const QAction* myAction;
2499 TActionIdEvent( const QAction* action )
2500 : myResult( -1 ), myAction( action ) {}
2501 virtual void Execute()
2503 LightApp_Module* module = getActiveModule();
2505 myResult = module->actionId( myAction );
2508 int SalomePyQt::actionId( const QAction* a )
2510 return ProcessEvent( new TActionIdEvent( a ) );
2514 \fn int SalomePyQt::addGlobalPreference( const QString& label );
2515 \brief Add global (not module-related) preferences group.
2516 \param label global preferences group name
2517 \return preferences group identifier
2520 class TAddGlobalPrefEvent: public SALOME_Event
2523 typedef int TResult;
2526 TAddGlobalPrefEvent( const QString& label )
2527 : myResult( -1 ), myLabel( label ) {}
2528 virtual void Execute()
2530 LightApp_Module* module = getActiveModule();
2532 LightApp_Preferences* pref = module->getApp()->preferences();
2534 myResult = pref->addPreference( myLabel, -1 );
2538 int SalomePyQt::addGlobalPreference( const QString& label )
2540 return ProcessEvent( new TAddGlobalPrefEvent( label ) );
2544 \fn int SalomePyQt::addPreference( const QString& label );
2545 \brief Add module-related preferences group.
2546 \param label preferences group name
2547 \return preferences group identifier
2550 class TAddPrefEvent: public SALOME_Event
2553 typedef int TResult;
2556 TAddPrefEvent( const QString& label )
2557 : myResult( -1 ), myLabel( label ) {}
2558 virtual void Execute()
2560 LightApp_Module* module = getActiveModule();
2562 LightApp_Preferences* pref = module->getApp()->preferences();
2564 int cId = pref->addPreference( module->moduleName(), -1 );
2566 myResult = pref->addPreference( myLabel, cId );
2571 int SalomePyQt::addPreference( const QString& label )
2573 return ProcessEvent( new TAddPrefEvent( label ) );
2577 \fn int SalomePyQt::addPreference( const QString& label, const int pId, const int type,
2578 const QString& section, const QString& param );
2579 \brief Add module-related preferences.
2580 \param label preferences group name
2581 \param pId parent preferences group id
2582 \param type preferences type
2583 \param section resources file section name
2584 \param param resources file setting name
2585 \return preferences identifier
2588 class TAddPrefParamEvent: public SALOME_Event
2591 typedef int TResult;
2598 TAddPrefParamEvent( const QString& label,
2599 const int pId, const int type,
2600 const QString& section,
2601 const QString& param )
2603 myLabel( label ), myPId( pId ), myType( type ),
2604 mySection( section ), myParam ( param ) {}
2605 virtual void Execute()
2607 LightApp_Module* module = getActiveModule();
2609 LightApp_Preferences* pref = module->getApp()->preferences();
2611 myResult = pref->addPreference( module->moduleName(), myLabel, myPId, myType, mySection, myParam );
2615 int SalomePyQt::addPreference( const QString& label, const int pId, const int type,
2616 const QString& section, const QString& param )
2618 return ProcessEvent( new TAddPrefParamEvent( label, pId, type, section, param ) );
2622 \fn QVariant SalomePyQt::preferenceProperty( const int id, const QString& prop );
2623 \brief Get the preferences property.
2624 \param id preferences identifier
2625 \param prop preferences property name
2626 \return preferences property value or null QVariant if property is not set
2629 class TPrefPropEvent: public SALOME_Event
2632 typedef QVariant TResult;
2636 TPrefPropEvent( const int id, const QString& prop )
2637 : myId( id ), myProp( prop ) {}
2638 virtual void Execute()
2640 LightApp_Module* module = getActiveModule();
2642 LightApp_Preferences* pref = module->getApp()->preferences();
2644 myResult = pref->itemProperty( myProp, myId );
2648 QVariant SalomePyQt::preferenceProperty( const int id, const QString& prop )
2650 return ProcessEvent( new TPrefPropEvent( id, prop ) );
2654 \brief Set the preferences property.
2655 \param id preferences identifier
2656 \param prop preferences property name
2657 \param var preferences property value
2659 void SalomePyQt::setPreferenceProperty( const int id,
2660 const QString& prop,
2661 const QVariant& var )
2663 class TEvent: public SALOME_Event
2669 TEvent( const int id, const QString& prop, const QVariant& var )
2670 : myId( id ), myProp( prop ), myVar( var ) {}
2671 virtual void Execute()
2673 LightApp_Module* module = getActiveModule();
2675 LightApp_Preferences* pref = module->getApp()->preferences();
2677 pref->setItemProperty( myProp, myVar, myId );
2681 ProcessVoidEvent( new TEvent( id, prop, var ) );
2685 \brief Set specific widget as a custom preferences item.
2686 \param id preferences identifier
2687 \param prop preferences property name
2688 \param widget custom widget
2690 void SalomePyQt::setPreferencePropertyWg( const int id,
2691 const QString& prop,
2692 UserDefinedContent* widget )
2694 class TEvent: public SALOME_Event
2698 UserDefinedContent* myWidget;
2700 TEvent( const int id, const QString& prop, UserDefinedContent* widget )
2701 : myId( id ), myProp( prop ), myWidget( widget ) {}
2702 virtual void Execute()
2704 LightApp_Module* module = getActiveModule();
2706 LightApp_Preferences* pref = module->getApp()->preferences();
2708 pref->setItemProperty( myProp, (qint64) new SgPyQtUserDefinedContent( myWidget ), myId );
2713 ProcessVoidEvent( new TEvent( id, prop, widget ) );
2717 \brief Add the property value to the list of values.
2719 This method allows creating properties which are QList<QVariant>
2720 - there is no way to pass such values directly to QVariant parameter with PyQt.
2722 \param id preferences identifier
2723 \param prop preferences property name
2724 \param idx preferences property index
2725 \param var preferences property value for the index \a idx
2727 void SalomePyQt::addPreferenceProperty( const int id,
2728 const QString& prop,
2730 const QVariant& var )
2732 class TEvent: public SALOME_Event
2739 TEvent( const int id, const QString& prop, const int idx, const QVariant& var )
2740 : myId( id ), myProp( prop ), myIdx( idx), myVar( var ) {}
2741 virtual void Execute()
2743 LightApp_Module* module = getActiveModule();
2745 LightApp_Preferences* pref = module->getApp()->preferences();
2747 QVariant var = pref->itemProperty( myProp, myId );
2748 if ( var.isValid() ) {
2749 if ( var.type() == QVariant::StringList ) {
2750 QStringList sl = var.toStringList();
2751 if ( myIdx >= 0 && myIdx < sl.count() )
2752 sl[myIdx] = myVar.toString();
2754 sl.append( myVar.toString() );
2755 pref->setItemProperty( myProp, sl, myId );
2757 else if ( var.type() == QVariant::List ) {
2758 QList<QVariant> vl = var.toList();
2759 if ( myIdx >= 0 && myIdx < vl.count() )
2763 pref->setItemProperty( myProp, vl, myId );
2769 pref->setItemProperty( myProp, vl, myId );
2775 ProcessVoidEvent( new TEvent( id, prop, idx, var) );
2779 \brief Put the message to the Log messages output window
2780 \param msg message text (it can be of simple rich text format)
2781 \param addSeparator boolean flag which specifies if it is necessary
2782 to separate the message with predefined separator
2784 void SalomePyQt::message( const QString& msg, bool addSeparator )
2786 class TEvent: public SALOME_Event
2791 TEvent( const QString& msg, bool addSeparator )
2792 : myMsg( msg ), myAddSep( addSeparator ) {}
2793 virtual void Execute()
2795 if ( LightApp_Application* anApp = getApplication() ) {
2796 LogWindow* lw = anApp->logWindow();
2798 lw->putMessage( myMsg, myAddSep );
2802 ProcessVoidEvent( new TEvent( msg, addSeparator ) );
2806 \brief Remove all the messages from the Log messages output window.
2808 void SalomePyQt::clearMessages()
2810 class TEvent: public SALOME_Event
2814 virtual void Execute()
2816 if ( LightApp_Application* anApp = getApplication() ) {
2817 LogWindow* lw = anApp->logWindow();
2823 ProcessVoidEvent( new TEvent() );
2827 \fn bool SalomePyQt::dumpView( const QString& filename, const int id = 0 );
2828 \brief Dump the contents of the id view window. If id is 0 then current active view is processed.
2829 to the image file in the specified format.
2831 For the current moment JPEG, PNG and BMP images formats are supported.
2832 The image format is defined automatically by the file name extension.
2833 By default, BMP format is used.
2835 \param filename image file name
2836 \return operation status (\c true on success)
2839 class TDumpViewEvent: public SALOME_Event
2842 typedef bool TResult;
2846 TDumpViewEvent( const QString& filename, const int id )
2847 : myResult ( false ), myFileName( filename ), myWndId( id ) {}
2848 virtual void Execute()
2850 SUIT_ViewWindow* wnd = 0;
2852 if ( LightApp_Application* anApp = getApplication() ) {
2853 SUIT_ViewManager* vm = anApp->activeViewManager();
2855 wnd = vm->getActiveView();
2857 myWndId = wnd->getId();
2860 wnd = dynamic_cast<SUIT_ViewWindow*>( getWnd( myWndId ) );
2863 QString fmt = SUIT_Tools::extension( myFileName ).toUpper();
2864 #ifndef DISABLE_PLOT2DVIEWER
2865 Plot2d_ViewWindow* wnd2D = dynamic_cast<Plot2d_ViewWindow*>( wnd );
2867 qApp->postEvent( wnd2D->getViewFrame(), new QPaintEvent( QRect( 0, 0, wnd2D->getViewFrame()->width(), wnd2D->getViewFrame()->height() ) ) );
2868 qApp->postEvent( wnd2D, new QPaintEvent( QRect( 0, 0, wnd2D->width(), wnd2D->height() ) ) );
2869 qApp->processEvents();
2870 if ( fmt == "PS" || fmt == "EPS" || fmt == "PDF" ) {
2871 myResult = wnd2D->getViewFrame()->print( myFileName, fmt );
2875 #endif // DISABLE_PLOT2DVIEWER
2876 QImage im = wnd->dumpView();
2877 if ( !im.isNull() && !myFileName.isEmpty() ) {
2878 if ( fmt.isEmpty() ) fmt = QString( "BMP" ); // default format
2879 if ( fmt == "JPG" ) fmt = "JPEG";
2880 myResult = im.save( myFileName, fmt.toLatin1() );
2885 bool SalomePyQt::dumpView( const QString& filename, const int id )
2887 return ProcessEvent( new TDumpViewEvent( filename, id ) );
2891 \fn QList<int> SalomePyQt::getViews();
2892 \brief Get list of integer identifiers of all the currently opened views
2893 \return list of integer identifiers of all the currently opened views
2896 class TGetViews: public SALOME_Event
2899 typedef QList<int> TResult;
2902 virtual void Execute()
2905 LightApp_Application* app = getApplication();
2907 STD_TabDesktop* tabDesk = dynamic_cast<STD_TabDesktop*>( app->desktop() );
2909 QList<SUIT_ViewWindow*> wndlist = tabDesk->windows();
2910 SUIT_ViewWindow* wnd;
2911 foreach ( wnd, wndlist )
2912 myResult.append( wnd->getId() );
2917 QList<int> SalomePyQt::getViews()
2919 return ProcessEvent( new TGetViews() );
2923 \fn int SalomePyQt::getActiveView();
2924 \brief Get integer identifier of the currently active view
2925 \return integer identifier of the currently active view
2928 class TGetActiveView: public SALOME_Event
2931 typedef int TResult;
2935 virtual void Execute()
2937 LightApp_Application* app = getApplication();
2939 SUIT_ViewManager* viewMgr = app->activeViewManager();
2941 SUIT_ViewWindow* wnd = viewMgr->getActiveView();
2943 myResult = wnd->getId();
2948 int SalomePyQt::getActiveView()
2950 return ProcessEvent( new TGetActiveView() );
2954 \fn QString SalomePyQt::getViewType( const int id );
2955 \brief Get type of the specified view, e.g. "OCCViewer"
2956 \param id window identifier
2960 class TGetViewType: public SALOME_Event
2963 typedef QString TResult;
2966 TGetViewType( const int id )
2968 virtual void Execute()
2970 SUIT_ViewWindow* wnd = getWnd( myWndId );
2972 SUIT_ViewManager* viewMgr = wnd->getViewManager();
2974 myResult = viewMgr->getType();
2978 QString SalomePyQt::getViewType( const int id )
2980 return ProcessEvent( new TGetViewType( id ) );
2984 \fn bool SalomePyQt::setViewTitle( const int id, const QString& title );
2985 \brief Change view caption
2986 \param id window identifier
2987 \param title new window title
2988 \return \c true if operation is completed successfully and \c false otherwise
2991 class TSetViewTitle: public SALOME_Event
2994 typedef bool TResult;
2998 TSetViewTitle( const int id, const QString& title )
2999 : myResult( false ),
3002 virtual void Execute()
3004 SUIT_ViewWindow* wnd = getWnd( myWndId );
3006 wnd->setWindowTitle( myTitle );
3011 bool SalomePyQt::setViewTitle( const int id, const QString& title )
3013 return ProcessEvent( new TSetViewTitle( id, title ) );
3017 \fn bool SalomePyQt::setViewSize( const int w, const int h, const int id );
3018 \brief Set view size
3019 \param w window width
3020 \param h window height
3021 \param id window identifier
3022 \return \c true if operation is completed successfully and \c false otherwise
3025 class TSetViewSize: public SALOME_Event
3028 typedef bool TResult;
3033 TSetViewSize( const int w, const int h, const int id )
3034 : myResult( false ),
3038 virtual void Execute()
3040 SUIT_ViewWindow* wnd = 0;
3042 if ( LightApp_Application* anApp = getApplication() ) {
3043 SUIT_ViewManager* vm = anApp->activeViewManager();
3045 wnd = vm->getActiveView();
3049 wnd = dynamic_cast<SUIT_ViewWindow*>( getWnd( myWndId ) );
3052 SUIT_ViewManager* viewMgr = wnd->getViewManager();
3054 QString type = viewMgr->getType();
3055 if ( type == "OCCViewer") {
3056 #ifndef DISABLE_OCCVIEWER
3057 // specific processing for OCC viewer:
3058 // OCC view can embed up to 4 sub-views, split according to the specified layout;
3059 // - if there is only one sub-view active; it will be resized;
3060 // - if there are several sub-views, each of them will be resized.
3061 OCCViewer_ViewWindow* occView = qobject_cast<OCCViewer_ViewWindow*>( wnd );
3062 for ( int i = OCCViewer_ViewFrame::BOTTOM_RIGHT; i <= OCCViewer_ViewFrame::TOP_RIGHT; i++ ) {
3063 if ( occView && occView->getView( i ) ) {
3064 occView->getView( i )->centralWidget()->resize( myWndWidth, myWndHeight );
3068 #endif // DISABLE_OCCVIEWER
3070 else if ( type == "ParaView") {
3071 #ifndef DISABLE_PVVIEWER
3072 // specific processing for ParaView viewer:
3073 // hierarchy of ParaView viewer is much complex than for usual view;
3074 // we look for sub-widget named "Viewport"
3075 QList<QWidget*> lst = wnd->findChildren<QWidget*>( "Viewport" );
3076 if ( !lst.isEmpty() ) {
3077 lst[0]->resize( myWndWidth, myWndHeight );
3080 #endif // DISABLE_PVVIEWER
3083 if ( wnd->centralWidget() ) {
3084 wnd->centralWidget()->resize( myWndWidth, myWndHeight );
3092 bool SalomePyQt::setViewSize( const int w, const int h, const int id )
3094 return ProcessEvent( new TSetViewSize( w, h, id ) );
3098 \fn bool SalomePyQt::setViewRotationPoint( const double x, const double y, const double z, const int id );
3099 \brief Set view rotation point
3100 \param x coordinate X view rotation point
3101 \param y coordinate Y view rotation point
3102 \param z coordinate Z view rotation point
3103 \param id window identifier
3104 \return \c true if operation is completed successfully and \c false otherwise
3107 class TSetViewRotationPoint: public SALOME_Event
3110 typedef bool TResult;
3116 TSetViewRotationPoint( const double x, const double y, const double z, const int id )
3117 : myResult( false ),
3122 virtual void Execute()
3124 SUIT_ViewWindow* wnd = 0;
3126 if ( LightApp_Application* anApp = getApplication() ) {
3127 SUIT_ViewManager* vm = anApp->activeViewManager();
3129 wnd = vm->getActiveView();
3133 wnd = dynamic_cast<SUIT_ViewWindow*>( getWnd( myWndId ) );
3136 SUIT_ViewManager* viewMgr = wnd->getViewManager();
3138 QString type = viewMgr->getType();
3139 if ( type == "OCCViewer") {
3140 #ifndef DISABLE_OCCVIEWER
3141 // specific processing for OCC viewer:
3142 // OCC view can embed up to 4 sub-views, split according to the specified layout;
3143 // - if there is only one sub-view active; its rotation point will be changed;
3144 // - if there are several sub-views, rotaion points of each of them will be changed.
3145 OCCViewer_ViewWindow* occView = qobject_cast<OCCViewer_ViewWindow*>( wnd );
3147 for ( int i = OCCViewer_ViewFrame::BOTTOM_RIGHT; i <= OCCViewer_ViewFrame::TOP_RIGHT; i++ ) {
3148 if ( occView && occView->getView( i ) ) {
3149 occView->getView( i )->activateSetRotationSelected( myX, myY, myZ );
3154 #endif // DISABLE_OCCVIEWER
3156 else if ( type == "VTKViewer") {
3157 #ifndef DISABLE_VTKVIEWER
3158 SVTK_ViewWindow* vtkView = qobject_cast<SVTK_ViewWindow*>( wnd );
3161 double aCenter[3] = { myX, myY, myZ };
3162 vtkView->activateSetRotationSelected( (void*)aCenter );
3165 #endif // DISABLE_VTKVIEWER
3171 bool SalomePyQt::setViewRotationPoint( const double x, const double y, const double z, const int id )
3173 return ProcessEvent( new TSetViewRotationPoint( x, y, z, id ) );
3177 \fn QString SalomePyQt::getViewTitle( const int id );
3178 \brief Get view caption
3179 \param id window identifier
3180 \return view caption
3183 class TGetViewTitle: public SALOME_Event
3186 typedef QString TResult;
3189 TGetViewTitle( const int id )
3191 virtual void Execute()
3193 SUIT_ViewWindow* wnd = getWnd( myWndId );
3195 myResult = wnd->windowTitle();
3198 QString SalomePyQt::getViewTitle( const int id )
3200 return ProcessEvent( new TGetViewTitle( id ) );
3204 \fn QList<int> SalomePyQt::findViews( const QString& type );
3205 \brief Get list of integer identifiers of all the
3206 currently opened views of the specified type
3207 \param type viewer type
3208 \return list of integer identifiers
3211 class TFindViews: public SALOME_Event
3214 typedef QList<int> TResult;
3217 TFindViews( const QString& type )
3219 virtual void Execute()
3222 LightApp_Application* app = getApplication();
3224 ViewManagerList vmList;
3225 app->viewManagers( myType, vmList );
3226 SUIT_ViewManager* viewMgr;
3227 foreach ( viewMgr, vmList ) {
3228 QVector<SUIT_ViewWindow*> vec = viewMgr->getViews();
3229 for ( int i = 0, n = vec.size(); i < n; i++ ) {
3230 SUIT_ViewWindow* wnd = vec[ i ];
3233 MESSAGE("SUIT_ViewWindow*: "<< wnd << " id: " << wnd->getId());
3234 myResult.append( wnd->getId() );
3241 QList<int> SalomePyQt::findViews( const QString& type )
3243 return ProcessEvent( new TFindViews( type ) );
3247 \fn bool SalomePyQt::activateView( const int id );
3248 \brief Activate view
3249 \param id window identifier
3250 \return \c true if operation is completed successfully and \c false otherwise
3253 class TActivateView: public SALOME_Event
3256 typedef bool TResult;
3259 TActivateView( const int id )
3260 : myResult( false ),
3262 virtual void Execute()
3264 SUIT_ViewWindow* wnd = getWnd( myWndId );
3265 MESSAGE("window id:" << myWndId << " SUIT_ViewWindow*: " << wnd);
3272 bool SalomePyQt::activateView( const int id )
3274 return ProcessEvent( new TActivateView( id ) );
3278 \fn bool SalomePyQt::activateManagerAndView( const int id );
3279 \brief Activate view manager and view: useful for a view embedded in a module main Window
3280 \param id window identifier
3281 \return \c true if operation is completed successfully and \c false otherwise
3284 class TActivateViewManagerAndView: public SALOME_Event
3287 typedef bool TResult;
3290 TActivateViewManagerAndView( const int id )
3291 : myResult( false ),
3293 virtual void Execute()
3295 SUIT_ViewWindow* wnd = getWnd( myWndId );
3296 MESSAGE("window id:" << myWndId << " SUIT_ViewWindow*: " << wnd);
3299 LightApp_Application* app = getApplication();
3300 app->desktop()->windowActivated(wnd); // equivalent to app->setActiveViewManager(wnd->getViewManager())
3306 bool SalomePyQt::activateViewManagerAndView( const int id )
3308 return ProcessEvent( new TActivateViewManagerAndView( id ) );
3315 class TGetViewWidget: public SALOME_Event
3318 typedef QWidget* TResult;
3321 TGetViewWidget( const int id )
3324 virtual void Execute()
3326 SUIT_ViewWindow* wnd = getWnd( myWndId );
3328 myResult = (QWidget*)wnd;
3332 QWidget* SalomePyQt::getViewWidget( const int id)
3334 return ProcessEvent( new TGetViewWidget( id ) );
3339 \fn int SalomePyQt::createView( const QString& type, bool visible = true, const int width = 0, const int height = 0 );
3340 \brief Create new view and activate it
3341 \param type viewer type
3345 \return integer identifier of created view (or -1 if view could not be created)
3348 class TCreateView: public SALOME_Event
3351 typedef int TResult;
3358 TCreateView( const QString& theType, bool visible, const int width, const int height, bool detached )
3364 myDetached(detached) {}
3365 virtual void Execute()
3367 LightApp_Application* app = getApplication();
3369 SUIT_ViewManager* viewMgr = app->createViewManager( myType, myDetached );
3371 QWidget* wnd = viewMgr->getActiveView();
3372 myResult = viewMgr->getActiveView()->getId();
3375 wnd->setVisible(false);
3376 if ( !myVisible && myWidth == 0 && myHeight == 0 ) {
3380 if (myWidth > 0 && myHeight > 0) {
3381 #ifndef DISABLE_PLOT2DVIEWER
3382 Plot2d_ViewWindow* wnd2D = dynamic_cast<Plot2d_ViewWindow*>( wnd );
3383 if ( wnd2D ) wnd = wnd2D->getViewFrame();
3384 #endif // DISABLE_PLOT2DVIEWER
3385 wnd->setGeometry( 0, 0, myWidth, myHeight );
3392 int SalomePyQt::createView( const QString& type, bool visible, const int width, const int height, bool detached )
3394 int ret = ProcessEvent( new TCreateView( type, visible, width, height, detached ) );
3395 QCoreApplication::processEvents();
3400 \fn int SalomePyQt::createView( const QString& type, QWidget* w );
3401 \brief Create new view with custom widget embedded and activate it
3402 \param type viewer type
3403 \param w custom widget
3404 \return integer identifier of created view (or -1 if view could not be created)
3407 class TCreateViewWg: public SALOME_Event
3410 typedef int TResult;
3414 TCreateViewWg( const QString& theType, QWidget* w )
3418 virtual void Execute()
3420 LightApp_Application* app = getApplication();
3422 SUIT_ViewManager* viewMgr = app->createViewManager( myType, myWidget );
3424 SUIT_ViewWindow* wnd = viewMgr->getActiveView();
3426 myResult = wnd->getId();
3431 int SalomePyQt::createView( const QString& type, QWidget* w )
3433 int ret = ProcessEvent( new TCreateViewWg( type, w ) );
3434 QCoreApplication::processEvents();
3439 \fn bool SalomePyQt::closeView( const int id );
3441 \param id window identifier
3442 \return \c true if operation is completed successfully and \c false otherwise
3445 class TCloseView: public SALOME_Event
3448 typedef bool TResult;
3451 TCloseView( const int id )
3452 : myResult( false ),
3454 virtual void Execute()
3456 SUIT_ViewWindow* wnd = getWnd( myWndId );
3458 SUIT_ViewManager* viewMgr = wnd->getViewManager();
3466 bool SalomePyQt::closeView( const int id )
3468 return ProcessEvent( new TCloseView( id ) );
3472 \fn int SalomePyQt::cloneView( const int id );
3473 \brief Clone view (if this operation is supported for specified view type)
3474 \param id window identifier
3475 \return integer identifier of the cloned view or -1 or operation could not be performed
3478 class TCloneView: public SALOME_Event
3481 typedef int TResult;
3484 TCloneView( const int id )
3487 virtual void Execute()
3489 SUIT_ViewWindow* wnd = getWnd( myWndId );
3491 SUIT_ViewManager* viewMgr = wnd->getViewManager();
3493 #ifndef DISABLE_OCCVIEWER
3494 if ( wnd->inherits( "OCCViewer_ViewWindow" ) ) {
3495 OCCViewer_ViewWindow* occView = (OCCViewer_ViewWindow*)( wnd );
3496 occView->onCloneView();
3497 wnd = viewMgr->getActiveView();
3499 myResult = wnd->getId();
3501 #endif // DISABLE_OCCVIEWER
3502 #ifndef DISABLE_PLOT2DVIEWER
3503 if ( wnd->inherits( "Plot2d_ViewWindow" ) ) {
3504 Plot2d_ViewManager* viewMgr2d = dynamic_cast<Plot2d_ViewManager*>( viewMgr );
3505 Plot2d_ViewWindow* srcWnd2d = dynamic_cast<Plot2d_ViewWindow*>( wnd );
3506 if ( viewMgr2d && srcWnd2d ) {
3507 Plot2d_ViewWindow* resWnd = viewMgr2d->cloneView( srcWnd2d );
3508 myResult = resWnd->getId();
3511 #endif // DISABLE_OCCVIEWER
3516 int SalomePyQt::cloneView( const int id )
3518 return ProcessEvent( new TCloneView( id ) );
3522 \fn bool SalomePyQt::setViewVisible( const int id, const bool visible )
3523 \brief Set view visibility.
3524 \param id window identifier
3525 \param visible new visiblity
3528 void SalomePyQt::setViewVisible( const int id, const bool visible )
3530 class TEvent: public SALOME_Event
3535 TEvent( const int id, const bool visible )
3536 : myWndId( id ), myVisible( visible ) {}
3537 virtual void Execute()
3539 SUIT_ViewWindow* wnd = getWnd( myWndId );
3540 if ( wnd ) wnd->setVisible( myVisible );
3543 ProcessVoidEvent( new TEvent( id, visible ) );
3547 \fn bool SalomePyQt::isViewVisible( const int id );
3548 \brief Check whether view is visible ( i.e. it is on the top of the views stack)
3549 \param id window identifier
3550 \return \c true if view is visible and \c false otherwise
3553 class TIsViewVisible: public SALOME_Event
3556 typedef bool TResult;
3559 TIsViewVisible( const int id )
3560 : myResult( false ),
3562 virtual void Execute()
3564 SUIT_ViewWindow* wnd = getWnd( myWndId );
3567 QWidget* p = wnd->parentWidget();
3568 myResult = ( p && p->isVisibleTo( p->parentWidget() ) );
3572 bool SalomePyQt::isViewVisible( const int id )
3574 return ProcessEvent( new TIsViewVisible( id ) );
3578 \fn bool SalomePyQt::setViewClosable( const int id, const bool on );
3579 \brief Set / clear view's "closable" option. By default any view is closable
3580 (i.e. can be closed by the user).
3581 \param id window identifier
3582 \param on new "closable" option's value
3585 void SalomePyQt::setViewClosable( const int id, const bool on )
3587 class TEvent: public SALOME_Event
3592 TEvent( const int id, const bool on )
3593 : myWndId( id ), myOn( on ) {}
3594 virtual void Execute()
3596 SUIT_ViewWindow* wnd = getWnd( myWndId );
3597 if ( wnd ) wnd->setClosable( myOn );
3600 ProcessVoidEvent( new TEvent( id, on ) );
3604 \fn bool SalomePyQt::isViewClosable( const int id );
3605 \brief Check whether view is closable (i.e. can be closed by the user)
3606 \param id window identifier
3607 \return \c true if view is closable or \c false otherwise
3610 class TIsViewClosable: public SALOME_Event
3613 typedef bool TResult;
3616 TIsViewClosable( const int id )
3619 virtual void Execute()
3621 SUIT_ViewWindow* wnd = getWnd( myWndId );
3623 myResult = wnd->closable();
3627 bool SalomePyQt::isViewClosable( const int id )
3629 return ProcessEvent( new TIsViewClosable( id ) );
3633 \fn bool SalomePyQt::groupAllViews();
3634 \brief Group all views to the single tab area
3635 \return \c true if operation is completed successfully and \c false otherwise
3638 class TGroupAllViews: public SALOME_Event
3641 typedef bool TResult;
3644 : myResult( false ) {}
3645 virtual void Execute()
3647 LightApp_Application* app = getApplication();
3649 STD_TabDesktop* tabDesk = dynamic_cast<STD_TabDesktop*>( app->desktop() );
3651 QtxWorkstack* wStack = tabDesk->workstack();
3660 bool SalomePyQt::groupAllViews()
3662 return ProcessEvent( new TGroupAllViews() );
3666 \fn bool SalomePyQt::splitView( const int id, const Orientation ori, const Action action );
3667 \brief Split tab area to which view with identifier belongs to
3668 \param id window identifier
3669 \param ori orientation of split operation
3670 \param action action to be performed
3671 \return \c true if operation is completed successfully \c false otherwise
3674 class TSplitView: public SALOME_Event
3677 typedef bool TResult;
3682 TSplitView( const int id,
3683 const Orientation ori,
3684 const Action action )
3685 : myResult( false ),
3688 myAction( action ) {}
3689 virtual void Execute()
3691 SUIT_ViewWindow* wnd = getWnd( myWndId );
3694 // wnd->setFocus(); ???
3697 if ( getApplication() ) {
3698 STD_TabDesktop* desk =
3699 dynamic_cast<STD_TabDesktop*>( getApplication()->desktop() );
3701 QtxWorkstack* wStack = desk->workstack();
3703 Qt::Orientation qtOri =
3704 ( myOri == Horizontal ) ? Qt::Horizontal : Qt::Vertical;
3706 QtxWorkstack::SplitType sType;
3707 if ( myAction == MoveWidget )
3708 sType = QtxWorkstack::SplitMove;
3709 else if ( myAction == LeaveWidget )
3710 sType = QtxWorkstack::SplitStay;
3712 sType = QtxWorkstack::SplitAt;
3714 wStack->Split( wnd, qtOri, sType );
3722 bool SalomePyQt::splitView( const int id, const Orientation ori, const Action action )
3724 return ProcessEvent( new TSplitView( id, ori, action ) );
3728 \fn bool SalomePyQt::moveView( const int id, const int id_to, const bool before );
3729 \brief Move view with the first identifier to the same area which
3730 another view with the second identifier belongs to
3731 \param id source window identifier
3732 \param id_to destination window identifier
3733 param before specifies whether the first viewt has to be moved before or after
3735 \return \c true if operation is completed successfully and \c false otherwise
3738 class TMoveView: public SALOME_Event
3741 typedef bool TResult;
3746 TMoveView( const int id, const int id_to, const bool before )
3747 : myResult( false ),
3750 myIsBefore( before ) {}
3751 virtual void Execute()
3753 SUIT_ViewWindow* wnd = getWnd( myWndId );
3754 SUIT_ViewWindow* wnd_to = getWnd( myWndToId );
3755 if ( wnd && wnd_to ) {
3756 QtxWorkstack* wStack = dynamic_cast<STD_TabDesktop*>(
3757 getApplication()->desktop() )->workstack();
3759 myResult = wStack->move( wnd, wnd_to, myIsBefore );
3763 bool SalomePyQt::moveView( const int id, const int id_to, const bool before )
3765 return ProcessEvent( new TMoveView( id, id_to, before ) );
3769 \fn QList<int> SalomePyQt::neighbourViews( const int id );
3770 \brief Get list of views identifiers that belongs to the same area as
3771 specified view (excluding it)
3772 \param id window identifier
3773 \return list of views identifiers
3776 class TNeighbourViews: public SALOME_Event
3779 typedef QList<int> TResult;
3782 TNeighbourViews( const int id )
3784 virtual void Execute()
3787 SUIT_ViewWindow* wnd = getWnd( myWndId );
3789 QtxWorkstack* wStack = dynamic_cast<STD_TabDesktop*>(
3790 getApplication()->desktop() )->workstack();
3792 QWidgetList wgList = wStack->windowList( wnd );
3794 foreach ( wg, wgList ) {
3795 SUIT_ViewWindow* tmpWnd = dynamic_cast<SUIT_ViewWindow*>( wg );
3796 if ( tmpWnd && tmpWnd != wnd )
3797 myResult.append( tmpWnd->getId() );
3803 QList<int> SalomePyQt::neighbourViews( const int id )
3805 return ProcessEvent( new TNeighbourViews( id ) );
3810 \fn void SalomePyQt::createRoot();
3811 \brief Initialize root data object.
3813 Does nothing if root is already initialized.
3816 void SalomePyQt::createRoot()
3818 class TEvent: public SALOME_Event
3822 virtual void Execute()
3824 SALOME_PYQT_ModuleLight* module = dynamic_cast<SALOME_PYQT_ModuleLight*>( getActiveModule() );
3826 SALOME_PYQT_DataModelLight* dm =
3827 dynamic_cast<SALOME_PYQT_DataModelLight*>( module->dataModel() );
3832 if ( verbose() ) printf( "SalomePyQt.createRoot() function is not supported for the current module.\n" );
3836 ProcessVoidEvent( new TEvent() );
3840 \fn QString SalomePyQt::createObject( const QString& parent );
3841 \brief Create empty data object
3842 \param parent entry of parent data object
3843 \return entry of created data object
3846 class TCreateEmptyObjectEvent: public SALOME_Event
3849 typedef QString TResult;
3852 TCreateEmptyObjectEvent( const QString& parent )
3853 : myParent( parent ) {}
3854 virtual void Execute()
3856 SALOME_PYQT_ModuleLight* module = dynamic_cast<SALOME_PYQT_ModuleLight*>( getActiveModule() );
3858 myResult = module->createObject( myParent );
3861 if ( verbose() ) printf( "SalomePyQt.createObject() function is not supported for the current module.\n" );
3865 QString SalomePyQt::createObject( const QString& parent )
3867 return ProcessEvent( new TCreateEmptyObjectEvent( parent ) );
3871 \fn QString SalomePyQt::createObject( const QString& name, const QString& icon,
3872 const QString& tooltip,const QString& parent );
3873 \brief Create new data object with specified name, icon and tooltip
3874 \param name data object name
3875 \param icon data object icon
3876 \param toolTip data object tooltip
3877 \param parent entry of parent data object
3878 \return entry of created data object
3881 class TCreateObjectEvent: public SALOME_Event
3884 typedef QString TResult;
3890 TCreateObjectEvent( const QString& name,
3891 const QString& icon,
3892 const QString& tooltip,
3893 const QString& parent )
3896 myToolTip( tooltip ),
3897 myParent( parent ) {}
3898 virtual void Execute()
3900 SALOME_PYQT_ModuleLight* module = dynamic_cast<SALOME_PYQT_ModuleLight*>( getActiveModule() );
3902 myResult = module->createObject( myName, myIcon, myToolTip, myParent );
3905 if ( verbose() ) printf( "SalomePyQt.createObject() function is not supported for the current module.\n" );
3909 QString SalomePyQt::createObject( const QString& name,
3910 const QString& icon,
3911 const QString& toolTip,
3912 const QString& parent )
3914 return ProcessEvent( new TCreateObjectEvent( name, icon, toolTip, parent ) );
3919 \fn void SalomePyQt::setName( const QString& entry, const QString& name );
3920 \brief Set data object name
3921 \param entry data object entry
3922 \param name data object name
3924 class TSetNameEvent: public SALOME_Event
3929 TSetNameEvent( const QString& entry,
3930 const QString& name )
3933 virtual void Execute()
3935 SALOME_PYQT_ModuleLight* module = dynamic_cast<SALOME_PYQT_ModuleLight*>( getActiveModule() );
3937 module->setName( myEntry, myName );
3940 if ( verbose() ) printf( "SalomePyQt.setName() function is not supported for the current module.\n" );
3944 void SalomePyQt::setName( const QString& entry, const QString& name )
3946 ProcessVoidEvent( new TSetNameEvent( entry, name ) );
3950 \fn void SalomePyQt::setIcon( const QString& entry, const QString& icon );
3951 \brief Set data object icon
3952 \param entry data object entry
3953 \param icon data object icon file name (icon is loaded from module resources)
3956 class TSetIconEvent: public SALOME_Event
3961 TSetIconEvent( const QString& entry,
3962 const QString& icon )
3965 virtual void Execute()
3967 SALOME_PYQT_ModuleLight* module = dynamic_cast<SALOME_PYQT_ModuleLight*>( getActiveModule() );
3969 module->setIcon( myEntry, myIcon );
3972 if ( verbose() ) printf( "SalomePyQt.setIcon() function is not supported for the current module.\n" );
3977 void SalomePyQt::setIcon( const QString& entry, const QString& icon )
3979 ProcessVoidEvent( new TSetIconEvent( entry, icon ) );
3983 \fn void SalomePyQt::setToolTip( const QString& entry, const QString& toolTip );
3984 \brief Set data object tooltip
3985 \param entry data object entry
3986 \param toolTip data object tooltip
3989 class TSetToolTipEvent: public SALOME_Event
3994 TSetToolTipEvent( const QString& entry,
3995 const QString& toolTip )
3997 myToolTip( toolTip ) {}
3998 virtual void Execute()
4000 SALOME_PYQT_ModuleLight* module = dynamic_cast<SALOME_PYQT_ModuleLight*>( getActiveModule() );
4002 module->setToolTip( myEntry, myToolTip );
4005 if ( verbose() ) printf( "SalomePyQt.setToolTip() function is not supported for the current module.\n" );
4009 void SalomePyQt::setToolTip( const QString& entry, const QString& toolTip )
4011 ProcessVoidEvent( new TSetToolTipEvent( entry, toolTip ) );
4015 \fn void SalomePyQt::setReference( const QString& entry, const QString& refEntry );
4016 \brief Set reference to another data object
4017 \param entry data object entry
4018 \param refEntry referenced data object entry
4021 class TSetRefEvent: public SALOME_Event
4026 TSetRefEvent( const QString& entry,
4027 const QString& refEntry )
4029 myRefEntry( refEntry ) {}
4030 virtual void Execute()
4032 SALOME_PYQT_ModuleLight* module = dynamic_cast<SALOME_PYQT_ModuleLight*>( getActiveModule() );
4034 module->setReference( myEntry, myRefEntry );
4037 if ( verbose() ) printf( "SalomePyQt.setReference() function is not supported for the current module.\n" );
4041 void SalomePyQt::setReference( const QString& entry, const QString& refEntry )
4043 ProcessVoidEvent( new TSetRefEvent( entry, refEntry ) );
4047 \fn void SalomePyQt::setColor( const QString& entry, const QColor& color );
4048 \brief Set data object color
4049 \param entry data object entry
4050 \param color data object color
4053 class TSetColorEvent: public SALOME_Event
4058 TSetColorEvent( const QString& entry,
4059 const QColor& color )
4062 virtual void Execute()
4064 SALOME_PYQT_ModuleLight* module = dynamic_cast<SALOME_PYQT_ModuleLight*>( getActiveModule() );
4066 module->setColor( myEntry, myColor );
4069 if ( verbose() ) printf( "SalomePyQt.setColor() function is not supported for the current module.\n" );
4073 void SalomePyQt::setColor( const QString& entry, const QColor& color )
4075 ProcessVoidEvent( new TSetColorEvent( entry, color ) );
4079 \fn QString SalomePyQt::getName( const QString& entry );
4080 \brief Get data object name
4081 \param entry data object entry
4082 \return data object name
4085 class TGetNameEvent: public SALOME_Event
4088 typedef QString TResult;
4091 TGetNameEvent( const QString& entry )
4092 : myEntry( entry ) {}
4093 virtual void Execute()
4095 SALOME_PYQT_ModuleLight* module = dynamic_cast<SALOME_PYQT_ModuleLight*>( getActiveModule() );
4097 myResult = module->getName( myEntry );
4100 if ( verbose() ) printf( "SalomePyQt.getName() function is not supported for the current module.\n" );
4104 QString SalomePyQt::getName( const QString& entry )
4106 return ProcessEvent( new TGetNameEvent( entry ) );
4110 \fn QString SalomePyQt::getToolTip( const QString& entry );
4111 \brief Get data object tooltip
4112 \param entry data object entry
4113 \return data object tooltip
4116 class TGetToolTipEvent: public SALOME_Event
4119 typedef QString TResult;
4122 TGetToolTipEvent( const QString& entry )
4123 : myEntry( entry ) {}
4124 virtual void Execute()
4126 SALOME_PYQT_ModuleLight* module = dynamic_cast<SALOME_PYQT_ModuleLight*>( getActiveModule() );
4128 myResult = module->getToolTip( myEntry );
4131 if ( verbose() ) printf( "SalomePyQt.getToolTip() function is not supported for the current module.\n" );
4135 QString SalomePyQt::getToolTip( const QString& entry )
4137 return ProcessEvent( new TGetToolTipEvent( entry ) );
4141 \fn QString SalomePyQt::getReference( const QString& entry );
4142 \brief Get entry of the referenced object (if there's any)
4143 \param entry data object entry
4144 \return referenced data object entry
4147 class TGetRefEvent: public SALOME_Event
4150 typedef QString TResult;
4153 TGetRefEvent( const QString& entry )
4154 : myEntry( entry ) {}
4155 virtual void Execute()
4157 SALOME_PYQT_ModuleLight* module = dynamic_cast<SALOME_PYQT_ModuleLight*>( getActiveModule() );
4159 myResult = module->getReference( myEntry );
4162 if ( verbose() ) printf( "SalomePyQt.getReference() function is not supported for the current module.\n" );
4166 QString SalomePyQt::getReference( const QString& entry )
4168 return ProcessEvent( new TGetRefEvent( entry ) );
4172 \fn QColor SalomePyQt::getColor( const QString& entry );
4173 \brief Get data object color
4174 \param entry data object entry
4175 \return data object color
4178 class TGetColorEvent: public SALOME_Event
4181 typedef QColor TResult;
4184 TGetColorEvent( const QString& entry )
4185 : myEntry( entry ) {}
4186 virtual void Execute()
4188 SALOME_PYQT_ModuleLight* module = dynamic_cast<SALOME_PYQT_ModuleLight*>( getActiveModule() );
4190 myResult = module->getColor( myEntry );
4193 if ( verbose() ) printf( "SalomePyQt.getColor() function is not supported for the current module.\n" );
4197 QColor SalomePyQt::getColor( const QString& entry )
4199 return ProcessEvent( new TGetColorEvent( entry ) );
4203 \fn void SalomePyQt::removeChildren( const QString& entry );
4204 \brief Remove all child data objects from specified data object
4205 \param entry data object entry
4208 class TRemoveChildEvent: public SALOME_Event
4212 TRemoveChildEvent( const QString& entry )
4213 : myEntry( entry ) {}
4214 virtual void Execute()
4216 SALOME_PYQT_ModuleLight* module = dynamic_cast<SALOME_PYQT_ModuleLight*>( getActiveModule() );
4218 module->removeChildren( myEntry );
4221 if ( verbose() ) printf( "SalomePyQt.removeChildren() function is not supported for the current module.\n" );
4225 void SalomePyQt::removeChildren( const QString& entry )
4227 ProcessVoidEvent( new TRemoveChildEvent( entry ) );
4229 void SalomePyQt::removeChild( const QString& entry )
4231 if ( verbose() ) printf( "SalomePyQt.removeChild() function is obsolete. Use SalomePyQt.removeChildren() instead." );
4232 removeChildren( entry );
4236 \fn void SalomePyQt::removeObject( const QString& entry );
4237 \brief Remove object by entry
4238 \param entry data object entry
4241 class TRemoveObjectEvent: public SALOME_Event
4246 TRemoveObjectEvent( const QString& entry )
4247 : myEntry( entry ) {}
4248 virtual void Execute()
4250 SALOME_PYQT_ModuleLight* module = dynamic_cast<SALOME_PYQT_ModuleLight*>( getActiveModule() );
4252 module->removeObject( myEntry );
4255 if ( verbose() ) printf( "SalomePyQt.removeObject() function is not supported for the current module.\n" );
4259 void SalomePyQt::removeObject( const QString& entry )
4261 ProcessVoidEvent( new TRemoveObjectEvent( entry ) );
4265 \fn QStringList SalomePyQt::getChildren( const QString& entry, const bool recursive );
4266 \brief Get entries of all child data objects of specified data object
4267 \param entry data object entry
4268 \param recursive \c true for recursive processing
4271 class TGetChildrenEvent: public SALOME_Event
4274 typedef QStringList TResult;
4278 TGetChildrenEvent( const QString& entry, const bool recursive )
4280 myRecursive( recursive ) {}
4281 virtual void Execute()
4283 SALOME_PYQT_ModuleLight* module = dynamic_cast<SALOME_PYQT_ModuleLight*>( getActiveModule() );
4285 myResult = module->getChildren( myEntry, myRecursive );
4288 if ( verbose() ) printf( "SalomePyQt.getChildren() function is not supported for the current module.\n" );
4292 QStringList SalomePyQt::getChildren( const QString& entry, const bool recursive )
4294 return ProcessEvent( new TGetChildrenEvent( entry, recursive ) );
4297 #ifndef DISABLE_PLOT2DVIEWER
4298 // Next set of methods relates to the Plot2d viewer functionality
4301 \fn void SalomePyQt::displayCurve( const int id, Plot2d_Curve* theCurve )
4302 \brief Display theCurve in view
4303 \param id window identifier
4304 \param theCurve curve to display
4307 class TDisplayCurve: public SALOME_Event
4311 Plot2d_Curve* myCurve;
4312 TDisplayCurve( const int id, Plot2d_Curve* theCurve ) : myWndId( id ), myCurve( theCurve ) {}
4313 virtual void Execute() {
4314 Plot2d_ViewWindow* wnd = dynamic_cast<Plot2d_ViewWindow*>( getWnd( myWndId ) );
4316 wnd->getViewFrame()->displayCurve( myCurve );
4319 void SalomePyQt::displayCurve( const int id, Plot2d_Curve* theCurve )
4321 ProcessVoidEvent( new TDisplayCurve( id, theCurve ) );
4325 \fn void SalomePyQt::eraseCurve( const int id, Plot2d_Curve* theCurve )
4326 \brief Erase theCurve in view
4327 \param id window identifier
4328 \param theCurve curve to erase
4331 class TEraseCurve: public SALOME_Event
4335 Plot2d_Curve* myCurve;
4336 TEraseCurve( const int id, Plot2d_Curve* theCurve ) : myWndId( id ), myCurve( theCurve ) {}
4337 virtual void Execute() {
4338 Plot2d_ViewWindow* wnd = dynamic_cast<Plot2d_ViewWindow*>( getWnd( myWndId ) );
4339 wnd->getViewFrame()->eraseCurve( myCurve );
4342 void SalomePyQt::eraseCurve( const int id, Plot2d_Curve* theCurve )
4344 ProcessVoidEvent( new TEraseCurve( id, theCurve ) );
4348 \fn void SalomePyQt::deleteCurve( Plot2d_Curve* theCurve )
4349 \brief Delete theCurve from all views
4350 \param theCurve curve to delete
4353 class TDeleteCurve: public SALOME_Event
4356 Plot2d_Curve* myCurve;
4357 TDeleteCurve( Plot2d_Curve* theCurve ) : myCurve( theCurve ) {}
4358 virtual void Execute() {
4359 LightApp_Application* app = getApplication();
4361 STD_TabDesktop* tabDesk = dynamic_cast<STD_TabDesktop*>( app->desktop() );
4363 QList<SUIT_ViewWindow*> wndlist = tabDesk->windows();
4364 SUIT_ViewWindow* wnd;
4365 foreach ( wnd, wndlist ) {
4366 Plot2d_ViewWindow* aP2d = dynamic_cast<Plot2d_ViewWindow*>( wnd );
4368 aP2d->getViewFrame()->eraseObject( myCurve );
4374 void SalomePyQt::eraseCurve( Plot2d_Curve* theCurve )
4376 ProcessVoidEvent( new TDeleteCurve( theCurve ) );
4380 \brief updateCurves (repaint) curves in view window.
4382 void SalomePyQt::updateCurves( const int id )
4384 class TEvent: public SALOME_Event
4388 TEvent( const int id ) : myWndId( id ) {}
4389 virtual void Execute()
4391 Plot2d_ViewWindow* wnd = dynamic_cast<Plot2d_ViewWindow*>( getWnd( myWndId ) );
4393 wnd->getViewFrame()->DisplayAll();
4396 ProcessVoidEvent( new TEvent( id ) );
4400 \fn QString SalomePyQt::getPlot2dTitle( const int id, ObjectType type = MainTitle )
4401 \brief Get title of corresponding type
4402 \param id window identifier
4403 \param type is type of title
4404 \return title of corresponding type
4407 class TGetPlot2dTitle: public SALOME_Event
4410 typedef QString TResult;
4414 TGetPlot2dTitle(const int id, ObjectType type) :
4417 virtual void Execute() {
4418 Plot2d_ViewWindow* wnd = dynamic_cast<Plot2d_ViewWindow*>( getWnd( myWndId ) );
4420 myResult = wnd->getViewFrame()->getTitle( (Plot2d_ViewFrame::ObjectType)myType );
4423 QString SalomePyQt::getPlot2dTitle( const int id, ObjectType type )
4425 return ProcessEvent( new TGetPlot2dTitle( id, type ) );
4430 \fn void SalomePyQt::setPlot2dTitle( const int id, const QString& title, ObjectType type = MainTitle, bool show = true )
4431 \brief Set title of corresponding type
4432 \param id window identifier
4434 \param type is type of title
4438 class TSetPlot2dTitle: public SALOME_Event
4442 Plot2d_Curve* myCurve;
4446 TSetPlot2dTitle( const int id, const QString& title, ObjectType type, bool show ) :
4451 virtual void Execute() {
4452 Plot2d_ViewWindow* wnd = dynamic_cast<Plot2d_ViewWindow*>( getWnd( myWndId ) );
4453 wnd->getViewFrame()->setTitle( myShow, myTitle, (Plot2d_ViewFrame::ObjectType)myType, false );
4456 void SalomePyQt::setPlot2dTitle( const int id, const QString& title, ObjectType type, bool show )
4458 ProcessVoidEvent( new TSetPlot2dTitle( id, title, type, show ) );
4462 \fn QList<int> SalomePyQt::getPlot2dFitRangeByCurves( const int id )
4463 \brief Get list of Plot2d view ranges
4464 \param id window identifier
4465 \return list of view ranges (XMin, XMax, YMin, YMax)
4468 class TFitRangeByCurves: public SALOME_Event
4471 typedef QList<double> TResult;
4474 TFitRangeByCurves( const int id )
4476 virtual void Execute()
4479 Plot2d_ViewWindow* wnd = dynamic_cast<Plot2d_ViewWindow*>( getWnd( myWndId ) );
4481 double XMin, XMax, YMin, YMax, Y2Min, Y2Max;
4482 wnd->getViewFrame()->getFitRangeByCurves( XMin, XMax, YMin, YMax, Y2Min, Y2Max );
4483 myResult.append( XMin );
4484 myResult.append( XMax );
4485 myResult.append( YMin );
4486 myResult.append( YMax );
4490 QList<double> SalomePyQt::getPlot2dFitRangeByCurves( const int id )
4492 return ProcessEvent( new TFitRangeByCurves( id ) );
4496 \fn QList<int> SalomePyQt::getPlot2dFitRangeCurrent( const int id )
4497 \brief Get list of current Plot2d view ranges
4498 \param id window identifier
4499 \return list of view ranges (XMin, XMax, YMin, YMax)
4502 class TFitRangeCurrent: public SALOME_Event
4505 typedef QList<double> TResult;
4508 TFitRangeCurrent( const int id )
4510 virtual void Execute()
4513 Plot2d_ViewWindow* wnd = dynamic_cast<Plot2d_ViewWindow*>( getWnd( myWndId ) );
4515 double XMin, XMax, YMin, YMax, Y2Min, Y2Max;
4516 wnd->getViewFrame()->getFitRanges( XMin, XMax, YMin, YMax, Y2Min, Y2Max );
4517 myResult.append( XMin );
4518 myResult.append( XMax );
4519 myResult.append( YMin );
4520 myResult.append( YMax );
4524 QList<double> SalomePyQt::getPlot2dFitRangeCurrent( const int id )
4526 return ProcessEvent( new TFitRangeCurrent( id ) );
4530 \fn void SalomePyQt::setPlot2dFitRange( const int id, const double XMin, const double XMax, const double YMin, const double YMax )
4531 \brief Set range of Plot2d view
4532 \param id window identifier
4539 class TPlot2dFitRange: public SALOME_Event
4547 TPlot2dFitRange( const int id, const double XMin, const double XMax, const double YMin, const double YMax ) :
4553 virtual void Execute() {
4554 Plot2d_ViewWindow* wnd = dynamic_cast<Plot2d_ViewWindow*>( getWnd( myWndId ) );
4556 wnd->getViewFrame()->fitData( 0, myXMin, myXMax, myYMin, myYMax );
4559 void SalomePyQt::setPlot2dFitRange( const int id, const double XMin, const double XMax, const double YMin, const double YMax )
4561 ProcessVoidEvent( new TPlot2dFitRange( id, XMin, XMax, YMin, YMax ) );
4564 // End of methods related to the Plot2d viewer functionality
4565 #endif // DISABLE_PLOT2DVIEWER
4568 \brief Process Qt event loop
4570 void SalomePyQt::processEvents()
4572 QCoreApplication::processEvents();
4576 \brief Set visibility state for given object
4577 \param theEntry study ID of the object
4578 \param theState visibility state
4580 void SalomePyQt::setVisibilityState( const QString& theEntry, VisibilityState theState )
4582 class TEvent: public SALOME_Event
4587 TEvent( const QString& theEntry, int theState ):
4588 myEntry( theEntry ), myState( theState ) {}
4589 virtual void Execute()
4591 LightApp_Study* aStudy = getActiveStudy();
4594 aStudy->setVisibilityState( myEntry, (Qtx::VisibilityState)myState );
4597 ProcessVoidEvent( new TEvent( theEntry, theState ) );
4601 \fn VisibilityState SalomePyQt::getVisibilityState( const QString& theEntry )
4602 \brief Get visibility state for given object
4603 \param theEntry study ID of the object
4604 \return visibility state
4607 class TGetVisibilityStateEvent: public SALOME_Event
4610 typedef int TResult;
4613 TGetVisibilityStateEvent( const QString& theEntry ) : myResult( 0 ), myEntry( theEntry ) {}
4614 virtual void Execute()
4616 LightApp_Study* aStudy = getActiveStudy();
4618 myResult = aStudy->visibilityState( myEntry );
4621 VisibilityState SalomePyQt::getVisibilityState( const QString& theEntry )
4623 return (VisibilityState) ProcessEvent( new TGetVisibilityStateEvent( theEntry ) );
4627 \brief Set position of given object in the tree
4628 \param theEntry study ID of the object
4629 \param thePos position
4631 void SalomePyQt::setObjectPosition( const QString& theEntry, int thePos )
4633 class TEvent: public SALOME_Event
4638 TEvent( const QString& theEntry, int thePos ):
4639 myEntry( theEntry ), myPos( thePos ) {}
4640 virtual void Execute()
4642 SALOME_PYQT_ModuleLight* module = dynamic_cast<SALOME_PYQT_ModuleLight*>( getActiveModule() );
4644 module->setObjectPosition( myEntry, myPos );
4647 ProcessVoidEvent( new TEvent( theEntry, thePos ) );
4651 \fn int SalomePyQt::getObjectPosition( const QString& theEntry )
4652 \brief Get position of given object in the tree
4653 \param theEntry study ID of the object
4657 class TGetObjectPositionEvent: public SALOME_Event
4660 typedef int TResult;
4663 TGetObjectPositionEvent( const QString& theEntry ) : myResult( 0 ), myEntry( theEntry ) {}
4664 virtual void Execute()
4666 SALOME_PYQT_ModuleLight* module = dynamic_cast<SALOME_PYQT_ModuleLight*>( getActiveModule() );
4668 myResult = module->getObjectPosition( myEntry );
4671 int SalomePyQt::getObjectPosition( const QString& theEntry )
4673 return ProcessEvent( new TGetObjectPositionEvent( theEntry ) );
4677 \brief Start recordind a log of Python commands from embedded console
4678 \param theFileName output lof file name
4680 void SalomePyQt::startPyLog( const QString& theFileName )
4682 class TEvent: public SALOME_Event
4686 TEvent( const QString& theFileName ):
4687 myFileName( theFileName ) {}
4688 virtual void Execute()
4690 if ( getApplication() ) {
4691 PyConsole_Console* pyConsole = getApplication()->pythonConsole( false );
4692 if ( pyConsole ) pyConsole->startLog( myFileName );
4696 ProcessVoidEvent( new TEvent( theFileName ) );
4700 \brief Stop recordind a log of Python commands from embedded console
4702 void SalomePyQt::stopPyLog()
4704 class TEvent: public SALOME_Event
4708 virtual void Execute()
4710 if ( getApplication() ) {
4711 PyConsole_Console* pyConsole = getApplication()->pythonConsole( false );
4712 if ( pyConsole ) pyConsole->stopLog();
4716 ProcessVoidEvent( new TEvent() );