Version: 8.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SalomePyQt.h
Go to the documentation of this file.
1 // Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
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.
10 //
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.
15 //
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
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 
23 // File : SalomePyQt.h
24 // Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
25 //
26 #ifndef SALOME_PYQT_H
27 #define SALOME_PYQT_H
28 
29 #include <Python.h>
30 
31 #include <QObject>
32 #include <QString>
33 #include <QColor>
34 
35 #include <LightApp_Application.h>
36 #ifndef GUI_DISABLE_CORBA
37 #include <SalomeApp_Application.h>
38 #endif
39 #include <LightApp_Preferences.h>
40 #ifndef DISABLE_PLOT2DVIEWER
41 #include <Plot2d_ViewFrame.h>
42 #endif
43 
45 class QMenuBar;
46 class QMenu;
47 class QWidget;
48 class QAction;
49 class QTreeView;
50 class QtxActionGroup;
51 #ifndef DISABLE_PLOT2DVIEWER
52 class Plot2d_Curve;
53 #endif
54 
55 class SALOME_Selection : public QObject
56 {
57  Q_OBJECT
58 
59 public:
62 
63  void Clear();
64  void ClearIObjects();
65  void ClearFilters();
66 
67 signals:
69 
70 private slots:
71  void onSelMgrDestroyed();
72 
73 private:
76 };
77 
78 enum MenuName {
79  File = 1,
80  View = 2,
81  Edit = 3,
83  Tools = 5,
84  Window = 6,
85  Help = 7
86 };
87 
88 enum {
92 #ifndef GUI_DISABLE_CORBA
95 #else
97 #endif
98 };
99 
100 enum {
117 };
118 
122  Vertical = 1
123 };
124 
126 enum Action {
129  SplitAt = 2
130 };
131 
132 #ifndef DISABLE_PLOT2DVIEWER
133 
135 {
143 };
144 #endif
145 
147 {
151 };
152 
153 #ifndef DISABLE_PLOT2DVIEWER
154 enum Axis {
159 };
160 #endif
161 
163 {
164 public:
165  static QWidget* getDesktop();
166  static QWidget* getMainFrame();
167  static QMenuBar* getMainMenuBar();
168  static QMenu* getPopupMenu( const MenuName );
169  static QMenu* getPopupMenu( const QString& );
170  static QTreeView* getObjectBrowser();
171  static void enableSelector();
172  static void disableSelector();
173  static SALOME_Selection* getSelection();
174  static void setSelection( const QStringList& );
175  static int getStudyId();
176  static void putInfo( const QString&, const int = 0 );
177  static const QString getActiveComponent();
178  static PyObject* getActivePythonModule();
179  static bool activateModule( const QString& );
180  static void updateObjBrowser( const int = 0, bool = true );
181 
182  static bool isModified();
183  static void setModified( bool );
184 
185  static QString getFileName ( QWidget*, const QString&, const QStringList&, const QString&, bool );
186  static QStringList getOpenFileNames ( QWidget*, const QString&, const QStringList&, const QString& );
187  static QString getExistingDirectory( QWidget*, const QString&, const QString& );
188 
189  static void createRoot();
190  static QString createObject( const QString& parent = QString() );
191  static QString createObject( const QString&, const QString&, const QString&, const QString& = QString() );
192 
193  static void removeObject( const QString&);
194  static void removeChildren( const QString& = QString() );
195  static QStringList getChildren( const QString& = QString(), const bool = false );
196  static void setName( const QString&, const QString& );
197  static void setIcon( const QString&, const QString& );
198  static void setToolTip( const QString&, const QString& );
199  static QString getName( const QString& );
200  static QString getToolTip( const QString& );
201 
202  static void setVisibilityState( const QString&, VisibilityState );
203  static VisibilityState getVisibilityState( const QString& );
204 
205  static void setObjectPosition( const QString&, int );
206  static int getObjectPosition( const QString& );
207 
208 
209  static void setColor( const QString&, const QColor& );
210  static QColor getColor( const QString& );
211 
212  static void setReference( const QString&, const QString& );
213  static QString getReference( const QString& );
214 
215  static QIcon loadIcon( const QString&, const QString& );
216 
217  static void helpContext( const QString&, const QString& );
218 
219  static bool dumpView( const QString&, const int = 0 );
220 
221  static int defaultMenuGroup();
222 
223  static int createTool( const QString&, const QString& = QString() );
224  static int createTool( const int, const int, const int = -1 );
225  static int createTool( const int, const QString&, const int = -1 );
226  static int createTool( QAction*, const int, const int = -1, const int = -1 );
227  static int createTool( QAction*, const QString&, const int = -1, const int = -1 );
228 
229  static int createMenu( const QString&, const int = -1,
230  const int = -1, const int = -1, const int = -1 );
231  static int createMenu( const QString&, const QString& = QString(),
232  const int = -1, const int = -1, const int = -1 );
233  static int createMenu( const int, const int = -1,
234  const int = -1, const int = -1 );
235  static int createMenu( const int, const QString& = QString(),
236  const int = -1, const int = -1 );
237  static int createMenu( QAction*, const int, const int = -1,
238  const int = -1, const int = -1 );
239  static int createMenu( QAction*, const QString&, const int = -1,
240  const int = -1, const int = -1 );
241 
242  static QAction* createSeparator();
243 
244  static QAction* createAction( const int, const QString&,
245  const QString& = QString(), const QString& = QString(),
246  const QString& = QString(), const int = 0, const bool = false );
247 
248  static QtxActionGroup* createActionGroup( const int, const bool = true );
249 
250  static QAction* action( const int );
251  static int actionId( const QAction* );
252 
253  static QString constant ( const QString& );
254  static void setConstant ( const QString&, const QString& );
255  static void addSetting ( const QString&, const QString&, const double );
256  static void addSetting ( const QString&, const QString&, const int );
257  static void addSetting ( const QString&, const QString&, const bool, const int );
258  static void addSetting ( const QString&, const QString&, const QString& );
259  static void addSetting ( const QString&, const QString&, const QColor& );
260  static void addSetting ( const QString&, const QString&, const QByteArray& );
261  static int integerSetting( const QString&, const QString&, const int = 0 );
262  static double doubleSetting ( const QString&, const QString&, const double = 0 );
263  static bool boolSetting ( const QString&, const QString&, const bool = 0 );
264  static QString stringSetting ( const QString&, const QString&, const QString& = QString(""), const bool = true );
265  static QColor colorSetting ( const QString&, const QString&, const QColor& = QColor() );
266  static QByteArray byteArraySetting( const QString&, const QString&, const QByteArray& = QByteArray() );
267  static void removeSetting ( const QString&, const QString& );
268  static bool hasSetting ( const QString&, const QString& );
269  static QStringList parameters ( const QString& );
270  static QStringList parameters ( const QStringList& );
271 
272  static int addGlobalPreference( const QString& );
273  static int addPreference( const QString& );
274  static int addPreference( const QString&,
275  const int, const int = PT_Auto,
276  const QString& = QString(),
277  const QString& = QString() );
278  static QVariant preferenceProperty( const int, const QString& );
279  static void setPreferenceProperty( const int, const QString&, const QVariant& );
280  static void addPreferenceProperty( const int, const QString&, const int, const QVariant& );
281 
282  static void message( const QString&, bool = true );
283  static void clearMessages();
284 
285  static QList<int> getViews();
286  static int getActiveView();
287  static QString getViewType( const int );
288  static bool setViewTitle( const int, const QString& );
289  static QString getViewTitle( const int );
290  static bool setViewSize( const int, const int, const int = 0 );
291  static QList<int> findViews( const QString& );
292  static bool activateView( const int );
293  static bool activateViewManagerAndView( const int );
294  static QWidget* getViewWidget( const int );
295  static int createView( const QString&, bool visible = true, const int width = 0, const int height = 0, bool detached = false );
296  static int createView( const QString&, QWidget* );
297  static bool closeView( const int );
298  static int cloneView( const int );
299  static void setViewVisible( const int id, bool visible = true );
300  static bool isViewVisible( const int );
301  static void setViewClosable( const int, const bool );
302  static bool isViewClosable( const int );
303 
304  static bool groupAllViews();
305  static bool splitView( const int, const Orientation, const Action );
306  static bool moveView( const int, const int, const bool );
307  static QList<int> neighbourViews( const int );
308 
309 #ifndef DISABLE_PLOT2DVIEWER
310  static void displayCurve(const int, Plot2d_Curve*);
311  static void eraseCurve(const int, Plot2d_Curve*);
312  static void eraseCurve(Plot2d_Curve*);
313  static void updateCurves( const int );
314  static QString getPlot2dTitle(const int, ObjectType = MainTitle);
315  static void setPlot2dTitle(const int, const QString&, ObjectType = MainTitle, bool = true);
316  static QList<double> getPlot2dFitRangeByCurves(const int);
317  static QList<double> getPlot2dFitRangeCurrent(const int);
318  static void setPlot2dFitRange(const int, const double XMin, const double XMax, const double YMin, const double YMax);
319 #endif
320 
321 // static void initializeParaViewGUI();
322  static void processEvents();
323 
324  // the following methods are obsolete
325  static void addStringSetting( const QString&, const QString&, bool = true );
326  static void addIntSetting ( const QString&, const int, bool = true );
327  static void addBoolSetting ( const QString&, const bool, bool = true );
328  static void addDoubleSetting( const QString&, const double, bool = true );
329  static void removeSettings ( const QString& );
330  static QString getSetting ( const QString& );
331 
332  static void removeChild( const QString& = QString() );
333 
334  static void startPyLog(const QString&);
335  static void stopPyLog();
336 
337 };
338 
339 #endif // SALOME_PYQT_H