1 // Copyright (C) 2003 CEA/DEN, EDF R&D
5 // File : SalomePyQt.cxx
8 #include "SalomePyQt.hxx"
10 #include <qapplication.h>
13 #include "QAD_Application.h"
14 #include "QAD_Desktop.h"
15 #include "QAD_Study.h"
16 #include "QAD_FileDlg.h"
17 #include "QAD_ViewFrame.h"
18 #include "QAD_RightFrame.h"
19 #include "QAD_Tools.h"
21 #include "QAD_Config.h"
22 #include "QAD_Settings.h"
26 QWidget* SalomePyQt::getDesktop()
28 return (QWidget*)(QAD_Application::getDesktop());
31 QWorkspace* SalomePyQt::getMainFrame()
33 return (QWorkspace*)(QAD_Application::getDesktop()->getMainFrame());
36 QMenuBar* SalomePyQt::getMainMenuBar()
38 return (QMenuBar*)(QAD_Application::getDesktop()->getMainMenuBar());
41 int SalomePyQt::getStudyId()
43 return QAD_Application::getDesktop()->getActiveApp()->getActiveStudy()->getStudyId();
46 SALOME_Selection* SalomePyQt::getSelection()
48 return SALOME_Selection::Selection(QAD_Application::getDesktop()->getActiveApp()->getActiveStudy()->getSelection());
51 void SalomePyQt::putInfo( const QString& msg )
53 QAD_Application::getDesktop()->putInfo(msg);
56 void SalomePyQt::putInfo( const QString& msg, int ms )
58 QAD_Application::getDesktop()->putInfo(msg, ms);
61 void SalomePyQt::updateObjBrowser( int studyId, bool updateSelection)
63 QList<QAD_Study>& studies = QAD_Application::getDesktop()->getActiveApp()->getStudies();
64 for ( QAD_Study* study = studies.first(); study; study = studies.next() ) {
65 if ( study->getStudyId() == studyId ) {
66 study->updateObjBrowser( updateSelection );
72 const QString& SalomePyQt::getActiveComponent()
74 return QAD_Application::getDesktop()->getActiveComponent();
77 void SalomePyQt::addStringSetting(QString _name, QString _value, bool _autoValue)
79 QAD_CONFIG->addSetting(_name, _value, _autoValue);
82 void SalomePyQt::addIntSetting(QString _name, int _value, bool _autoValue)
84 QAD_CONFIG->addSetting(_name, _value, _autoValue);
87 void SalomePyQt::addDoubleSetting(QString _name, double _value, bool _autoValue)
89 QAD_CONFIG->addSetting(_name, _value, _autoValue);
92 bool SalomePyQt::removeSettings(QString name)
94 return QAD_CONFIG->removeSettings( name );
97 QString SalomePyQt::getSetting(QString name)
99 return QAD_CONFIG->getSetting(name);
102 QString SalomePyQt::getFileName(QWidget* parent,
103 const QString& initial,
104 const QStringList& filters,
105 const QString& caption,
108 return QAD_FileDlg::getFileName(parent, initial, filters, caption, open);
111 QStringList SalomePyQt::getOpenFileNames(QWidget* parent,
112 const QString& initial,
113 const QStringList& filters,
114 const QString& caption)
116 return QAD_FileDlg::getOpenFileNames(parent, initial, filters, caption);
119 QString SalomePyQt::getExistingDirectory(QWidget* parent,
120 const QString& initial,
121 const QString& caption)
123 return QAD_FileDlg::getExistingDirectory(parent, initial, caption);
126 void SalomePyQt::helpContext(const QString& source, const QString& context) {
127 //QAD_Application::getDesktop()->helpContext(source, context);
130 bool SalomePyQt::dumpView(const QString& filename)
132 QAD_Study* activeStudy = QAD_Application::getDesktop()->getActiveApp()->getActiveStudy();
135 QAD_ViewFrame* activeViewFrame = activeStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame();
136 if ( !activeViewFrame )
138 if ( !activeViewFrame->getViewWidget() )
141 qApp->processEvents();
142 QPixmap px = QPixmap::grabWindow( activeViewFrame->getViewWidget()->winId() );
143 if ( !filename.isNull() ) {
144 QString fmt = QAD_Tools::getFileExtensionFromPath( filename ).upper();
146 fmt = QString( "PNG" ); // default format
149 bool bOk = px.save( filename, fmt.latin1() );
155 QPopupMenu* SalomePyQt::getPopupMenu( const MenuName menu )
157 QMenuBar* mainMenu = QAD_Application::getDesktop()->getMainMenuBar();
158 if ( mainMenu->findItem( menu ) ) {
159 return mainMenu->findItem( menu )->popup();