1 //=============================================================================
2 // File : SalomePyQt.cxx
4 // Author : Vadim SANDLER
6 // Copyright : 2003-2005 CEA/DEN, EDF R&D
8 //=============================================================================
10 #include "SalomePyQt.h"
12 #include <qapplication.h>
14 #include <qstringlist.h>
16 #include "SALOME_Event.hxx"
18 #include "SUIT_Session.h"
19 #include "SUIT_Desktop.h"
20 #include "SUIT_ResourceMgr.h"
21 #include "STD_MDIDesktop.h"
22 #include "SalomeApp_Application.h"
23 #include "SalomeApp_Study.h"
24 #include "SalomeApp_SelectionMgr.h"
25 #include "OB_Browser.h"
29 //====================================================================================
31 //====================================================================================
34 Returns active application object [ static ]
36 static SalomeApp_Application* getApplication() {
37 if ( SUIT_Session::session() )
38 return dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
44 Gets active study or 0 if there is no study opened [ static ]
46 static SalomeApp_Study* getActiveStudy()
48 if ( getApplication() )
49 return dynamic_cast<SalomeApp_Study*>( getApplication()->activeStudy() );
53 //====================================================================================
54 // SALOME_Selection class.
55 //====================================================================================
57 SALOME_Selection::SALOME_Selection
58 Selection constructor. Gets an instance of selection manager.
60 SALOME_Selection::SALOME_Selection() : mySelMgr( 0 )
62 if ( SalomeApp_Application* anApp = getApplication() ) {
63 mySelMgr = anApp->selectionMgr();
64 connect( mySelMgr, SIGNAL( selectionChanged() ), this, SIGNAL( currentSelectionChanged() ) );
65 connect( mySelMgr, SIGNAL( destroyed() ), this, SLOT ( onSelMgrDestroyed() ) );
70 SALOME_Selection::onSelMgrDestroyed
71 Watches for the selection manager destroying when study is closed.
73 void SALOME_Selection::onSelMgrDestroyed()
79 SALOME_Selection::Clear
82 void SALOME_Selection::Clear()
84 class TEvent: public SALOME_Event {
85 SalomeApp_SelectionMgr* mySelMgr;
87 TEvent( SalomeApp_SelectionMgr* selMgr )
88 : mySelMgr( selMgr ) {}
89 virtual void Execute() {
91 mySelMgr->clearSelected();
94 ProcessVoidEvent( new TEvent( mySelMgr ) );
98 SALOME_Selection::ClearIObjects
101 void SALOME_Selection::ClearIObjects()
107 SALOME_Selection::ClearFilters
108 Removes all selection filters.
110 void SALOME_Selection::ClearFilters()
112 class TEvent: public SALOME_Event {
113 SalomeApp_SelectionMgr* mySelMgr;
115 TEvent( SalomeApp_SelectionMgr* selMgr )
116 : mySelMgr( selMgr ) {}
117 virtual void Execute() {
119 mySelMgr->clearFilters();
124 //====================================================================================
126 //====================================================================================
129 SalomePyQt::getDesktop
130 Gets desktop. Returns 0 in error.
132 class TGetDesktopEvent: public SALOME_Event {
134 typedef QWidget* TResult;
136 TGetDesktopEvent() : myResult( 0 ) {}
137 virtual void Execute() {
138 if ( getApplication() )
139 myResult = (QWidget*)( getApplication()->desktop() );
142 QWidget* SalomePyQt::getDesktop()
144 return ProcessEvent( new TGetDesktopEvent() );
148 SalomePyQt::getMainFrame
149 Gets workspace widget. Returns 0 in error.
151 class TGetMainFrameEvent: public SALOME_Event {
153 typedef QWidget* TResult;
155 TGetMainFrameEvent() : myResult( 0 ) {}
156 virtual void Execute() {
157 if ( getApplication() ) {
158 SUIT_Desktop* aDesktop = getApplication()->desktop();
159 myResult = (QWidget*)( aDesktop->centralWidget() );
163 QWidget* SalomePyQt::getMainFrame()
165 return ProcessEvent( new TGetMainFrameEvent() );
169 SalomePyQt::getMainMenuBar
170 Gets main menu. Returns 0 in error.
172 class TGetMainMenuBarEvent: public SALOME_Event {
174 typedef QMenuBar* TResult;
176 TGetMainMenuBarEvent() : myResult( 0 ) {}
177 virtual void Execute() {
178 if ( SalomeApp_Application* anApp = getApplication() ) {
179 myResult = anApp->desktop()->menuBar();
183 QMenuBar* SalomePyQt::getMainMenuBar()
185 return ProcessEvent( new TGetMainMenuBarEvent() );
189 SalomePyQt::getPopupMenu
190 Gets an main menu's child popup menu by its id
192 class TGetPopupMenuEvent: public SALOME_Event {
194 typedef QPopupMenu* TResult;
197 TGetPopupMenuEvent( const MenuName menu ) : myResult( 0 ), myMenuName( menu ) {}
198 virtual void Execute() {
199 if ( SalomeApp_Application* anApp = getApplication() ) {
200 QMenuBar* menuBar = anApp->desktop()->menuBar();
203 switch( myMenuName) {
205 menu = QObject::tr( "MEN_DESK_FILE" ); break;
207 menu = QObject::tr( "MEN_DESK_VIEW" ); break;
209 menu = QObject::tr( "MEN_DESK_EDIT" ); break;
211 menu = QObject::tr( "MEN_DESK_PREFERENCES" ); break;
213 menu = QObject::tr( "MEN_DESK_TOOLS" ); break;
215 menu = QObject::tr( "MEN_DESK_WINDOW" ); break;
217 menu = QObject::tr( "MEN_DESK_HELP" ); break;
219 for ( int i = 0; i < menuBar->count() && !myResult; i++ ) {
220 QMenuItem* item = menuBar->findItem( menuBar->idAt( i ) );
221 if ( item && item->text() == menu && item->popup() )
222 myResult = item->popup();
228 QPopupMenu* SalomePyQt::getPopupMenu( const MenuName menu )
230 return ProcessEvent( new TGetPopupMenuEvent( menu ) );
234 SalomePyQt::getStudyId
235 Returns active study's ID or 0 if there is no active study.
237 class TGetStudyIdEvent: public SALOME_Event {
241 TGetStudyIdEvent() : myResult( 0 ) {}
242 virtual void Execute() {
243 if ( SalomeApp_Study* aStudy = getActiveStudy() ) {
244 myResult = aStudy->studyDS()->StudyId();
248 int SalomePyQt::getStudyId()
250 return ProcessEvent( new TGetStudyIdEvent() );
254 SalomePyQt::getSelection
255 Creates a Selection object (to provide a compatibility with previous SALOME GUI).
257 class TGetSelectionEvent: public SALOME_Event {
259 typedef SALOME_Selection* TResult;
261 TGetSelectionEvent() : myResult( 0 ) {}
262 virtual void Execute() {
263 myResult = new SALOME_Selection();
266 SALOME_Selection* SalomePyQt::getSelection()
268 return ProcessEvent( new TGetSelectionEvent() );
273 Puts an information message to the desktop's status bar
274 (with optional delay parameter given in seconds)
276 class TPutInfoEvent: public SALOME_Event {
280 TPutInfoEvent( const QString& msg, const int sec = 0 ) : myMsg( msg ), mySecs( sec ) {}
281 virtual void Execute() {
282 if ( SalomeApp_Application* anApp = getApplication() ) {
283 anApp->putInfo( myMsg, mySecs * 1000 );
287 void SalomePyQt::putInfo( const QString& msg, const int sec )
289 ProcessVoidEvent( new TPutInfoEvent( msg, sec ) );
293 SalomePyQt::getActiveComponent
294 Returns an active component name or empty string if there is no active component
296 class TGetActiveComponentEvent: public SALOME_Event {
298 typedef QString TResult;
300 TGetActiveComponentEvent() {}
301 virtual void Execute() {
302 if ( SalomeApp_Application* anApp = getApplication() ) {
303 if ( CAM_Module* mod = anApp->activeModule() ) {
304 myResult = mod->name("");
309 const QString SalomePyQt::getActiveComponent()
311 return ProcessEvent( new TGetActiveComponentEvent() );
315 SalomePyQt::updateObjBrowser
316 Updates an Object Browser of a given study.
317 If <studyId> <= 0 the active study's object browser is updated.
318 <updateSelection> parameter is obsolete parameter and currently not used. To be removed lately.
320 void SalomePyQt::updateObjBrowser( const int studyId, bool updateSelection )
322 class TEvent: public SALOME_Event {
324 bool myUpdateSelection;
326 TEvent( const int studyId, bool updateSelection )
327 : myStudyId( studyId ), myUpdateSelection( updateSelection ) {}
328 virtual void Execute() {
329 if ( SUIT_Session::session() ) {
330 if ( getActiveStudy() && myStudyId <= 0 )
331 myStudyId = getActiveStudy()->id();
332 if ( myStudyId > 0 ) {
333 QPtrList<SUIT_Application> apps = SUIT_Session::session()->applications();
334 QPtrListIterator<SUIT_Application> it( apps );
335 for( ; it.current(); ++it ) {
336 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( it.current() );
337 if ( anApp && anApp->activeStudy() && anApp->activeStudy()->id() == myStudyId && anApp->objectBrowser() )
338 anApp->objectBrowser()->updateTree();
344 ProcessVoidEvent( new TEvent( studyId, updateSelection ) );
347 const char* DEFAULT_SECTION = "SalomePyQt";
350 SalomePyQt::addStringSetting
351 Adds a string setting to the application preferences
352 <autoValue> parameter is obsolete parameter and currently not used. To be removed lately.
353 This function is obsolete. Use addSetting() instead.
355 void SalomePyQt::addStringSetting( const QString& name, const QString& value, bool autoValue )
357 class TEvent: public SALOME_Event {
362 TEvent( const QString& name, const QString& value, bool autoValue )
363 : myName( name ), myValue( value ), myAutoValue( autoValue ) {}
364 virtual void Execute() {
365 if ( SUIT_Session::session() ) {
366 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
367 QStringList sl = QStringList::split( ":", myName );
368 QString _sec = sl.count() > 1 ? sl[ 0 ].stripWhiteSpace() : QString( DEFAULT_SECTION );
369 QString _nam = sl.count() > 1 ? sl[ 1 ].stripWhiteSpace() : sl.count() > 0 ? sl[ 0 ].stripWhiteSpace() : QString( "" );
370 if ( !_sec.isEmpty() && !_nam.isEmpty() )
371 resMgr->setValue( _sec, _nam, myValue );
375 ProcessVoidEvent( new TEvent( name, value, autoValue ) );
379 SalomePyQt::addIntSetting
380 Adds an integer setting to the application preferences
381 <autoValue> parameter is obsolete parameter and currently not used. To be removed lately.
382 This function is obsolete. Use addSetting() instead.
384 void SalomePyQt::addIntSetting( const QString& name, const int value, bool autoValue)
386 class TEvent: public SALOME_Event {
391 TEvent( const QString& name, const int value, bool autoValue )
392 : myName( name ), myValue( value ), myAutoValue( autoValue ) {}
393 virtual void Execute() {
394 if ( SUIT_Session::session() ) {
395 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
396 QStringList sl = QStringList::split( ":", myName );
397 QString _sec = sl.count() > 1 ? sl[ 0 ].stripWhiteSpace() : QString( DEFAULT_SECTION );
398 QString _nam = sl.count() > 1 ? sl[ 1 ].stripWhiteSpace() : sl.count() > 0 ? sl[ 0 ].stripWhiteSpace() : QString( "" );
399 if ( !_sec.isEmpty() && !_nam.isEmpty() )
400 resMgr->setValue( _sec, _nam, myValue );
404 ProcessVoidEvent( new TEvent( name, value, autoValue ) );
408 SalomePyQt::addDoubleSetting
409 Adds an double setting to the application preferences
410 <autoValue> parameter is obsolete parameter and currently not used. To be removed lately.
411 This function is obsolete. Use addSetting() instead.
413 void SalomePyQt::addDoubleSetting( const QString& name, const double value, bool autoValue )
415 class TEvent: public SALOME_Event {
420 TEvent( const QString& name, const double value, bool autoValue )
421 : myName( name ), myValue( value ), myAutoValue( autoValue ) {}
422 virtual void Execute() {
423 if ( SUIT_Session::session() ) {
424 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
425 QStringList sl = QStringList::split( ":", myName );
426 QString _sec = sl.count() > 1 ? sl[ 0 ].stripWhiteSpace() : QString( DEFAULT_SECTION );
427 QString _nam = sl.count() > 1 ? sl[ 1 ].stripWhiteSpace() : sl.count() > 0 ? sl[ 0 ].stripWhiteSpace() : QString( "" );
428 if ( !_sec.isEmpty() && !_nam.isEmpty() )
429 resMgr->setValue( _sec, _nam, myValue );
433 ProcessVoidEvent( new TEvent( name, value, autoValue ) );
437 SalomePyQt::removeSettings
438 Removes a setting from the application preferences
439 This function is obsolete. Use removeSetting() instead.
441 void SalomePyQt::removeSettings( const QString& name )
443 class TEvent: public SALOME_Event {
446 TEvent( const QString& name ) : myName( name ) {}
447 virtual void Execute() {
448 if ( SUIT_Session::session() ) {
449 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
450 QStringList sl = QStringList::split( ":", myName );
451 QString _sec = sl.count() > 1 ? sl[ 0 ].stripWhiteSpace() : QString( DEFAULT_SECTION );
452 QString _nam = sl.count() > 1 ? sl[ 1 ].stripWhiteSpace() : sl.count() > 0 ? sl[ 0 ].stripWhiteSpace() : QString( "" );
453 if ( !_sec.isEmpty() && !_nam.isEmpty() )
454 resMgr->remove( _sec, _nam );
458 ProcessVoidEvent( new TEvent( name ) );
462 SalomePyQt::getSetting
463 Gets a setting value (as string)
464 This function is obsolete. Use stringSetting(), integerSetting(),
465 boolSetting(), stringSetting() or colorSetting() instead.
467 class TGetSettingEvent: public SALOME_Event {
469 typedef QString TResult;
472 TGetSettingEvent( const QString& name ) : myName( name ) {}
473 virtual void Execute() {
474 if ( SUIT_Session::session() ) {
475 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
476 QStringList sl = QStringList::split( ":", myName );
477 QString _sec = sl.count() > 1 ? sl[ 0 ].stripWhiteSpace() : QString( DEFAULT_SECTION );
478 QString _nam = sl.count() > 1 ? sl[ 1 ].stripWhiteSpace() : sl.count() > 0 ? sl[ 0 ].stripWhiteSpace() : QString( "" );
479 myResult = ( !_sec.isEmpty() && !_nam.isEmpty() ) ? resMgr->stringValue( _sec, _nam, "" ) : QString( "" );
483 QString SalomePyQt::getSetting( const QString& name )
485 return ProcessEvent( new TGetSettingEvent( name ) );
489 SalomePyQt::addSetting
490 Adds a double setting to the application preferences
492 void SalomePyQt::addSetting( const QString& section, const QString& name, const double value )
494 class TEvent: public SALOME_Event {
499 TEvent( const QString& section, const QString& name, double value )
500 : mySection( section ), myName( name ), myValue( value ) {}
501 virtual void Execute() {
502 if ( SUIT_Session::session() ) {
503 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
504 if ( !mySection.isEmpty() && !myName.isEmpty() )
505 resMgr->setValue( mySection, myName, myValue );
509 ProcessVoidEvent( new TEvent( section, name, value ) );
513 SalomePyQt::addSetting
514 Adds an integer setting to the application preferences
516 void SalomePyQt::addSetting( const QString& section, const QString& name, const int value )
518 class TEvent: public SALOME_Event {
523 TEvent( const QString& section, const QString& name, int value )
524 : mySection( section ), myName( name ), myValue( value ) {}
525 virtual void Execute() {
526 if ( SUIT_Session::session() ) {
527 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
528 if ( !mySection.isEmpty() && !myName.isEmpty() )
529 resMgr->setValue( mySection, myName, myValue );
533 ProcessVoidEvent( new TEvent( section, name, value ) );
537 SalomePyQt::addSetting
538 Adds a string setting to the application preferences
540 void SalomePyQt::addSetting( const QString& section, const QString& name, const QString& value )
542 class TEvent: public SALOME_Event {
547 TEvent( const QString& section, const QString& name, const QString& value )
548 : mySection( section ), myName( name ), myValue( value ) {}
549 virtual void Execute() {
550 if ( SUIT_Session::session() ) {
551 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
552 if ( !mySection.isEmpty() && !myName.isEmpty() )
553 resMgr->setValue( mySection, myName, myValue );
557 ProcessVoidEvent( new TEvent( section, name, value ) );
561 SalomePyQt::addSetting
562 Adds a color setting to the application preferences
564 void SalomePyQt::addSetting( const QString& section, const QString& name, const QColor& value )
566 class TEvent: public SALOME_Event {
571 TEvent( const QString& section, const QString& name, const QColor& value )
572 : mySection( section ), myName( name ), myValue( value ) {}
573 virtual void Execute() {
574 if ( SUIT_Session::session() ) {
575 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
576 if ( !mySection.isEmpty() && !myName.isEmpty() )
577 resMgr->setValue( mySection, myName, myValue );
581 ProcessVoidEvent( new TEvent( section, name, value ) );
585 SalomePyQt::integerSetting
586 Gets an integer setting from the application preferences
588 class TGetIntSettingEvent: public SALOME_Event {
595 TGetIntSettingEvent( const QString& section, const QString& name, const int def )
596 : mySection( section ), myName( name ), myDefault( def ) {}
597 virtual void Execute() {
598 if ( SUIT_Session::session() ) {
599 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
600 myResult = ( !mySection.isEmpty() && !myName.isEmpty() ) ? resMgr->integerValue( mySection, myName, myDefault ) : myDefault;
604 int SalomePyQt::integerSetting( const QString& section, const QString& name, const int def )
606 return ProcessEvent( new TGetIntSettingEvent( section, name, def ) );
610 SalomePyQt::doubleSetting
611 Gets a double setting from the application preferences
613 class TGetDblSettingEvent: public SALOME_Event {
615 typedef double TResult;
620 TGetDblSettingEvent( const QString& section, const QString& name, const double def )
621 : mySection( section ), myName( name ), myDefault( def ) {}
622 virtual void Execute() {
623 if ( SUIT_Session::session() ) {
624 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
625 myResult = ( !mySection.isEmpty() && !myName.isEmpty() ) ? resMgr->doubleValue( mySection, myName, myDefault ) : myDefault;
629 double SalomePyQt::doubleSetting( const QString& section, const QString& name, const int def )
631 return ProcessEvent( new TGetDblSettingEvent( section, name, def ) );
635 SalomePyQt::boolSetting
636 Gets a boolean setting from the application preferences
638 class TGetBoolSettingEvent: public SALOME_Event {
640 typedef bool TResult;
645 TGetBoolSettingEvent( const QString& section, const QString& name, const bool def )
646 : mySection( section ), myName( name ), myDefault( def ) {}
647 virtual void Execute() {
648 if ( SUIT_Session::session() ) {
649 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
650 myResult = ( !mySection.isEmpty() && !myName.isEmpty() ) ? resMgr->booleanValue( mySection, myName, myDefault ) : myDefault;
654 bool SalomePyQt::boolSetting( const QString& section, const QString& name, const bool def )
656 return ProcessEvent( new TGetBoolSettingEvent( section, name, def ) );
660 SalomePyQt::stringSetting
661 Gets a string setting from the application preferences
663 class TGetStrSettingEvent: public SALOME_Event {
665 typedef QString TResult;
670 TGetStrSettingEvent( const QString& section, const QString& name, const QString& def )
671 : mySection( section ), myName( name ), myDefault( def ) {}
672 virtual void Execute() {
673 if ( SUIT_Session::session() ) {
674 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
675 myResult = ( !mySection.isEmpty() && !myName.isEmpty() ) ? resMgr->stringValue( mySection, myName, myDefault ) : myDefault;
679 QString SalomePyQt::stringSetting( const QString& section, const QString& name, const QString& def )
681 return ProcessEvent( new TGetStrSettingEvent( section, name, def ) );
685 SalomePyQt::colorSetting
686 Gets a color setting from the application preferences
688 class TGetColorSettingEvent: public SALOME_Event {
690 typedef QColor TResult;
695 TGetColorSettingEvent( const QString& section, const QString& name, const QColor& def )
696 : mySection( section ), myName( name ), myDefault( def ) {}
697 virtual void Execute() {
698 if ( SUIT_Session::session() ) {
699 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
700 myResult = ( !mySection.isEmpty() && !myName.isEmpty() ) ? resMgr->colorValue( mySection, myName, myDefault ) : myDefault;
704 QColor SalomePyQt::colorSetting ( const QString& section, const QString& name, const QColor& def )
706 return ProcessEvent( new TGetColorSettingEvent( section, name, def ) );
710 SalomePyQt::removeSetting
711 Removes a setting from the application preferences
713 void SalomePyQt::removeSetting( const QString& section, const QString& name )
715 class TEvent: public SALOME_Event {
719 TEvent( const QString& section, const QString& name ) : mySection( section ), myName( name ) {}
720 virtual void Execute() {
721 if ( SUIT_Session::session() ) {
722 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
723 if ( !mySection.isEmpty() && !myName.isEmpty() )
724 resMgr->remove( mySection, myName );
728 ProcessVoidEvent( new TEvent( section, name ) );
732 SalomePyQt::getFileName
733 Displays 'Open/Save file' dialog box and returns a user's choice (file name)
735 class TGetFileNameEvent: public SALOME_Event {
737 typedef QString TResult;
741 QStringList myFilters;
744 TGetFileNameEvent( QWidget* parent,
745 const QString& initial,
746 const QStringList& filters,
747 const QString& caption,
749 : myParent ( parent ),
750 myInitial( initial ),
751 myFilters( filters ),
752 myCaption( caption ),
754 virtual void Execute() {
755 if ( /*SalomeApp_Study* aStudy = */getActiveStudy() ) {
757 // myResult = QAD_FileDlg::getFileName(parent, initial, filters, caption, open);
761 QString SalomePyQt::getFileName( QWidget* parent,
762 const QString& initial,
763 const QStringList& filters,
764 const QString& caption,
767 return ProcessEvent( new TGetFileNameEvent( parent, initial, filters, caption, open ) );
771 SalomePyQt::getOpenFileNames
772 Displays 'Open files' dialog box and returns a user's choice (a list of file names)
774 class TGetOpenFileNamesEvent: public SALOME_Event {
776 typedef QStringList TResult;
780 QStringList myFilters;
782 TGetOpenFileNamesEvent( QWidget* parent,
783 const QString& initial,
784 const QStringList& filters,
785 const QString& caption )
786 : myParent ( parent ),
787 myInitial( initial ),
788 myFilters( filters ),
789 myCaption( caption ) {}
790 virtual void Execute() {
791 if ( /*SalomeApp_Study* aStudy = */getActiveStudy() ) {
793 // myResult = QAD_FileDlg::getOpenFileNames(parent, initial, filters, caption);
797 QStringList SalomePyQt::getOpenFileNames( QWidget* parent,
798 const QString& initial,
799 const QStringList& filters,
800 const QString& caption )
802 return ProcessEvent( new TGetOpenFileNamesEvent( parent, initial, filters, caption ) );
806 SalomePyQt::getExistingDirectory
807 Displays 'Get Directory' dialog box and returns a user's choice (a directory name)
809 class TGetExistingDirectoryEvent: public SALOME_Event {
811 typedef QString TResult;
816 TGetExistingDirectoryEvent( QWidget* parent,
817 const QString& initial,
818 const QString& caption )
819 : myParent ( parent ),
820 myInitial( initial ),
821 myCaption( caption ) {}
822 virtual void Execute() {
823 if ( /*SalomeApp_Study* aStudy = */getActiveStudy() ) {
825 // myResult = QAD_FileDlg::getExistingDirectory(parent, initial, caption);
829 QString SalomePyQt::getExistingDirectory( QWidget* parent,
830 const QString& initial,
831 const QString& caption )
833 return ProcessEvent( new TGetExistingDirectoryEvent( parent, initial, caption ) );
837 SalomePyQt::helpContext
838 Opens external browser to display 'context help' information
839 current implementation does nothing.
841 void SalomePyQt::helpContext( const QString& source, const QString& context ) {
842 class TEvent: public SALOME_Event {
846 TEvent( const QString& source, const QString& context )
847 : mySource( source ), myContext( context ) {}
848 virtual void Execute() {
849 if ( /*SalomeApp_Application* anApp =*/ getApplication() ) {
851 ////QAD_Application::getDesktop()->helpContext(source, context);
855 ProcessVoidEvent( new TEvent( source, context ) );
860 Dumps the contents of the currently active view to the image file
861 in the given format (JPEG, PNG, BMP are supported)
863 class TDumpViewEvent: public SALOME_Event {
865 typedef bool TResult;
868 TDumpViewEvent( const QString& filename )
869 : myResult ( false ), myFileName( filename ) {}
870 virtual void Execute() {
871 if ( /*SalomeApp_Study* aStudy = */getActiveStudy() ) {
873 // QAD_Study* activeStudy = QAD_Application::getDesktop()->getActiveApp()->getActiveStudy();
874 // if ( !activeStudy )
876 // QAD_ViewFrame* activeViewFrame = activeStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame();
877 // if ( !activeViewFrame )
879 // if ( !activeViewFrame->getViewWidget() )
882 // qApp->processEvents();
883 // QPixmap px = QPixmap::grabWindow( activeViewFrame->getViewWidget()->winId() );
884 // if ( !filename.isNull() ) {
885 // QString fmt = QAD_Tools::getFileExtensionFromPath( filename ).upper();
886 // if ( fmt.isEmpty() )
887 // fmt = QString( "PNG" ); // default format
888 // if ( fmt == "JPG" )
890 // bool bOk = px.save( filename, fmt.latin1() );
897 bool SalomePyQt::dumpView( const QString& filename )
899 return ProcessEvent( new TDumpViewEvent( filename ) );