]> SALOME platform Git repositories - modules/gui.git/blob - src/SALOME_PYQT/SalomePyQt/SalomePyQt.sip
Salome HOME
40e4b4bd18497a2602b362a954c66ca708ada31c
[modules/gui.git] / src / SALOME_PYQT / SalomePyQt / SalomePyQt.sip
1 // Copyright (C) 2007-2014  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 // File   : SalomePyQt.sip
23 // Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
24 //
25
26 %Module SalomePyQt
27
28 %Import QtGuimod.sip
29 %Import QtXmlmod.sip
30
31 %ExportedHeaderCode
32 #include <QtxAction.h>
33 #include <QtxActionSet.h>
34 #include <QtxActionGroup.h>
35 #include <SalomePyQt.h>
36 #include <Plot2d_Curve.h>
37 %End
38
39 class SALOME_Selection : QObject
40 {
41 %TypeHeaderCode
42 #include <SalomePyQt.h>
43 %End
44
45 public:
46   void Clear() /ReleaseGIL/ ;
47   void ClearIObjects() /ReleaseGIL/ ;
48   void ClearFilters() /ReleaseGIL/ ;
49
50 private:
51   SALOME_Selection( QObject* /TransferThis/ );
52
53 signals:
54   void currentSelectionChanged();
55 };
56
57 enum MenuName {
58   File        = 1,
59   View        = 2,
60   Edit        = 3,
61   Preferences = 4,
62   Tools       = 5,
63   Window      = 6,
64   Help        = 7  
65 };
66
67 enum WindowType {
68   WT_ObjectBrowser,
69   WT_PyConsole,
70   WT_LogWindow,
71   WT_User
72 };
73
74 enum PrefType { 
75   PT_Auto,
76   PT_Space,
77   PT_Bool, 
78   PT_Color,
79   PT_String, 
80   PT_Selector, 
81   PT_DblSpin, 
82   PT_IntSpin, 
83   PT_Double, 
84   PT_Integer, 
85   PT_GroupBox, 
86   PT_Tab, 
87   PT_Frame, 
88   PT_Font, 
89   PT_DirList, 
90   PT_File, 
91 };
92
93 enum Orientation {
94   Horizontal = 0, 
95   Vertical   = 1  
96 };
97
98 enum Action {
99   MoveWidget   = 0, 
100   LeaveWidget  = 1, 
101   SplitAt      = 2  
102 };
103
104 enum Axis {
105   yLeft,
106   yRight,
107   xBottom,
108   xTop,         
109 };      
110
111 class QtxAction : QWidgetAction
112 {
113 %TypeHeaderCode
114 #include <QtxAction.h>
115 %End
116
117 %ConvertToSubClassCode
118     if ( qobject_cast<QtxAction*>( sipCpp ) )
119       sipClass = sipClass_QtxAction;
120     else
121       sipClass = NULL;
122 %End
123
124 public:
125   explicit QtxAction( QObject* /TransferThis/ = 0, bool = false );
126   QtxAction( const QString&, const QString&, int, QObject* /TransferThis/, bool = false );
127   QtxAction( const QString&, const QIcon&, const QString&, int, QObject* /TransferThis/, bool = false );
128   virtual ~QtxAction();
129
130 private:
131   QtxAction( const QtxAction& );
132 };
133
134 class QtxActionSet : QtxAction
135 {
136 %TypeHeaderCode
137 #include <QtxActionSet.h>
138 %End
139
140 %ConvertToSubClassCode
141     if ( qobject_cast<QtxActionSet*>( sipCpp ) )
142       sipClass = sipClass_QtxActionSet;
143     else
144       sipClass = NULL;
145 %End
146
147 public:
148   explicit QtxActionSet( QObject* /TransferThis/ = 0 );
149   virtual ~QtxActionSet();
150
151   QList<QAction*> actions() const;
152   void            setActions( const QList<QAction*>& );
153
154   void            insertActions( const QList<QAction*>&, const int = -1 );
155
156   int             insertAction( QAction*, const int id = -1, const int = -1 );
157   int             insertAction( const QString&, const int id = -1, const int = -1 );
158   int             insertAction( const QString&, const QIcon&, const int id = -1, const int = -1 );
159
160   void            removeAction( QAction* );
161   void            removeAction( const int );
162
163   void            clear();
164
165 signals:
166   void            triggered( int );
167   void            triggered( QAction* );
168
169 private:
170   QtxActionSet( const QtxActionSet& );
171 };
172
173 class QtxActionGroup : QtxActionSet
174 {
175 %TypeHeaderCode
176 #include <QtxActionGroup.h>
177 %End
178
179 %ConvertToSubClassCode
180     if ( qobject_cast<QtxActionGroup*>( sipCpp ) )
181       sipClass = sipClass_QtxActionGroup;
182     else
183       sipClass = NULL;
184 %End
185
186 public:
187   explicit QtxActionGroup( QObject* /TransferThis/ = 0 );
188   QtxActionGroup( QObject* /TransferThis/, const bool );
189   virtual ~QtxActionGroup();
190
191   bool isExclusive() const;
192   bool usesDropDown() const;
193
194   void add( QAction* );
195
196 public slots:
197   void setExclusive( const bool );
198   void setUsesDropDown( const bool );
199
200 signals:
201   void selected( QAction* );
202
203 private:
204   QtxActionGroup( const QtxActionGroup& );
205 };
206
207 enum ObjectType
208 {
209   MainTitle,
210   XTitle,
211   YTitle,
212   Y2Title,
213   XAxis,
214   YAxis,
215   Y2Axis
216 };
217
218 class Plot2d_Curve
219 {
220 %TypeHeaderCode
221 #include <Plot2d_Curve.h>
222 %End
223
224 %ConvertToSubClassCode
225     if ( dynamic_cast<Plot2d_Curve*>( sipCpp ) )
226       sipClass = sipClass_Plot2d_Curve;
227     else
228       sipClass = NULL;
229 %End
230
231 public:
232   Plot2d_Curve();
233   virtual ~Plot2d_Curve();
234   void setName( const QString& );
235   void addPoint( double, double );
236   void addPoints(SIP_PYLIST X, SIP_PYLIST Y);
237 %MethodCode
238   int nx = PyList_Size(a0);
239   int ny = PyList_Size(a1);
240   
241   if( nx != ny ) { 
242     PyErr_Format(PyExc_TypeError,"The dimension of x and y should be the same. It is %d and %d currently.", nx, ny);
243   }
244   
245   int i;
246   PyObject *pX, *pY;
247
248   for (i=0; i<nx; i++) {
249     pX = PyList_GET_ITEM(a0,i);
250     pY = PyList_GET_ITEM(a1,i);
251     double aX = PyFloat_AsDouble(pX);
252     double aY = PyFloat_AsDouble(pY);
253     sipCpp->addPoint(aX, aY);
254   }
255 %End
256   void insertPoint( int, double, double );
257   void deletePoint( int );
258   void clearAllPoints();
259   void setXAxis( Axis );
260 %MethodCode
261   int ax = int(a0);
262   sipCpp->setXAxis(QwtPlot::Axis(ax));
263 %End
264   Axis getXAxis() const;
265 %MethodCode
266   sipRes = Axis(sipCpp->getXAxis());
267 %End
268   void setYAxis( Axis );
269 %MethodCode
270   int ay = int(a0);
271   sipCpp->setYAxis(QwtPlot::Axis(ay));
272 %End
273   Axis getYAxis() const;
274 %MethodCode
275   sipRes = Axis(sipCpp->getYAxis());
276 %End
277 };
278
279 enum VisibilityState 
280 {
281   ShownState,
282   HiddenState,
283   UnpresentableState 
284 };
285
286
287 class SalomePyQt
288 {
289 %TypeHeaderCode
290 #include <SalomePyQt.h>
291 %End
292
293 public:
294   static QWidget*          getDesktop() /ReleaseGIL/ ;
295   static QWidget*          getMainFrame() /ReleaseGIL/ ;
296   static QMenuBar*         getMainMenuBar() /ReleaseGIL/ ;
297   static QMenu*            getPopupMenu( const MenuName ) /ReleaseGIL/ ;
298   static QMenu*            getPopupMenu( const QString& ) /ReleaseGIL/ ;
299   static QTreeView*        getObjectBrowser() /ReleaseGIL/ ;
300   static SALOME_Selection* getSelection() /Factory,ReleaseGIL/ ;
301   static int               getStudyId() /ReleaseGIL/ ;
302   static void              putInfo( const QString&, const int = 0 ) /ReleaseGIL/ ;
303   static const QString     getActiveComponent() /ReleaseGIL/ ;
304   static SIP_PYOBJECT      getActivePythonModule() /ReleaseGIL/ ;
305   static bool              activateModule( const QString& ) /ReleaseGIL/ ;
306   static void              updateObjBrowser( const int = 0, bool =  true ) /ReleaseGIL/ ;
307   
308   static bool              isModified() /ReleaseGIL/ ;
309   static void              setModified( bool ) /ReleaseGIL/ ;
310
311   static QString           getFileName         ( QWidget*, const QString&, const QStringList&, const QString&, bool ) /ReleaseGIL/ ;
312   static QStringList       getOpenFileNames    ( QWidget*, const QString&, const QStringList&, const QString& ) /ReleaseGIL/ ;
313   static QString           getExistingDirectory( QWidget*, const QString&, const QString& ) /ReleaseGIL/ ;
314                          
315   static QString           createObject( const QString& = QString("") )  /ReleaseGIL/ ;
316   static QString           createObject( const QString&,
317                                          const QString&,
318                                          const QString&,
319                                          const QString& = QString("") )  /ReleaseGIL/ ;
320
321   static void              setName(const QString& ,const QString& ) /ReleaseGIL/ ;
322   static void              setIcon(const QString& ,const QString& ) /ReleaseGIL/ ;
323   static void              setToolTip(const QString& ,const QString& ) /ReleaseGIL/ ;
324   static QString           getName(const QString& ) /ReleaseGIL/ ;
325   static QString           getToolTip(const QString& ) /ReleaseGIL/ ;
326
327   static void              setVisibilityState( const QString&, VisibilityState );
328   static VisibilityState   getVisibilityState( const QString& );
329
330   static void              setObjectPosition( const QString&, int );
331   static int               getObjectPosition( const QString& );
332
333   static void              setColor( const QString&, const QColor& ) /ReleaseGIL/ ;
334   static QColor            getColor( const QString& ) /ReleaseGIL/ ;
335
336   static void              setReference( const QString& ,const QString& ) /ReleaseGIL/ ; 
337   static QString           getReference( const QString& ) /ReleaseGIL/ ;
338
339   static void              removeObject(const QString&  )    /ReleaseGIL/ ;
340   static void              removeChildren(const QString& = QString("")  ) /ReleaseGIL/ ;
341   static void              removeChild(const QString& = QString("")  ) /ReleaseGIL/ ;
342   static QStringList       getChildren(const QString&=QString("") , const bool = false) /ReleaseGIL/ ;
343
344   static QIcon             loadIcon( const QString&, const QString& ) /ReleaseGIL/ ;
345   static void              helpContext( const QString&, const QString& ) /ReleaseGIL/ ;
346
347   static bool              dumpView( const QString&, const int = 0 ) /ReleaseGIL/ ;
348
349   static int               defaultMenuGroup() /ReleaseGIL/ ;
350
351   static int               createTool( const QString& ) /ReleaseGIL/ ;
352   static int               createTool( const int,  const int,      const int = -1 ) /ReleaseGIL/ ;
353   static int               createTool( const int,  const QString&, const int = -1 ) /ReleaseGIL/ ;
354   static int               createTool( QAction*,   const int,      const int = -1, const int = -1 ) /ReleaseGIL/ ;
355   static int               createTool( QAction*,   const QString&, const int = -1, const int = -1 ) /ReleaseGIL/ ;
356
357   static int               createMenu( const QString&, const int,
358                                        const int = -1, const int = -1, const int = -1 ) /ReleaseGIL/ ;
359   static int               createMenu( const QString&, const QString&, 
360                                        const int = -1, const int = -1, const int = -1 ) /ReleaseGIL/ ;
361   static int               createMenu( const int,      const int,
362                                        const int = -1, const int = -1 ) /ReleaseGIL/ ;
363   static int               createMenu( const int,      const QString&, 
364                                        const int = -1, const int = -1 ) /ReleaseGIL/ ;
365   static int               createMenu( QAction*,       const int,      const int = -1, 
366                                        const int = -1, const int = -1 ) /ReleaseGIL/ ;
367   static int               createMenu( QAction*,       const QString&, const int = -1, 
368                                        const int = -1, const int = -1 ) /ReleaseGIL/ ;
369   static QAction*          createSeparator() /ReleaseGIL/ ;
370
371   static QAction*          createAction( const int, const QString&, 
372                                          const QString& = QString(), const QString& = QString(), 
373                                          const QString& = QString(), const int = 0, const bool = false ) /ReleaseGIL/ ;
374
375   static QtxActionGroup*   createActionGroup( const int, const bool = true ) /ReleaseGIL/ ;
376
377   static QAction*          action( const int ) /ReleaseGIL/ ;
378   static int               actionId( const QAction* ) /ReleaseGIL/ ;
379
380   static void              addSetting    ( const QString&, const QString&, const double ) /ReleaseGIL/ ;
381   static void              addSetting    ( const QString&, const QString&, const int /Constrained/ ) /ReleaseGIL/ ;
382   static void              addSetting    ( const QString&, const QString&, const bool, const int ) /ReleaseGIL/ ;
383   static void              addSetting    ( const QString&, const QString&, const QString& ) /ReleaseGIL/ ;
384   static void              addSetting    ( const QString&, const QString&, const QColor& ) /ReleaseGIL/ ;
385   static int               integerSetting( const QString&, const QString&, const int = 0 ) /ReleaseGIL/ ;
386   static double            doubleSetting ( const QString&, const QString&, const double = 0 ) /ReleaseGIL/ ;
387   static bool              boolSetting   ( const QString&, const QString&, const bool = false ) /ReleaseGIL/ ;
388   static QString           stringSetting ( const QString&, const QString&, const QString& = QString("") ) /ReleaseGIL/ ;
389   static QColor            colorSetting  ( const QString&, const QString&, const QColor& = QColor() ) /ReleaseGIL/ ;
390   static void              removeSetting ( const QString&, const QString& ) /ReleaseGIL/ ;
391   static bool              hasSetting    ( const QString&, const QString& ) /ReleaseGIL/ ;
392
393 // obsolete
394   static void              addStringSetting( const QString&, const QString&, bool = true ) /ReleaseGIL/ ;
395   static void              addIntSetting   ( const QString&, const int,      bool = true ) /ReleaseGIL/ ;
396   static void              addDoubleSetting( const QString&, const double,   bool = true ) /ReleaseGIL/ ;
397   static void              addBoolSetting  ( const QString&, const bool,     bool = true ) /ReleaseGIL/ ;
398   static void              removeSettings  ( const QString& ) /ReleaseGIL/ ;
399   static QString           getSetting      ( const QString& ) /ReleaseGIL/ ;
400
401   static int               addGlobalPreference( const QString& ) /ReleaseGIL/ ;
402   static int               addPreference( const QString& ) /ReleaseGIL/ ;
403   static int               addPreference( const QString&,
404                                           const int, const int = PT_Auto,
405                                           const QString& = QString(),
406                                           const QString& = QString() ) /ReleaseGIL/ ;
407   static QVariant          preferenceProperty( const int, const QString& ) /ReleaseGIL/ ;
408   static void              setPreferenceProperty( const int, 
409                                                   const QString&,
410                                                   const QVariant& ) /ReleaseGIL/ ;
411   static void              addPreferenceProperty( const int, 
412                                                   const QString&, 
413                                                   const int, 
414                                                   const QVariant& ) /ReleaseGIL/ ;
415
416   static void              message( const QString&, bool = true ) /ReleaseGIL/ ;
417   static void              clearMessages() /ReleaseGIL/ ;
418   
419   static QList<int>        getViews() /ReleaseGIL/ ;
420   static int               getActiveView() /ReleaseGIL/ ;
421   static QString           getViewType( const int ) /ReleaseGIL/ ;
422   static bool              setViewTitle( const int, const QString& ) /ReleaseGIL/ ;
423   static QString           getViewTitle( const int ) /ReleaseGIL/ ;
424   static QList<int>        findViews( const QString& ) /ReleaseGIL/ ;
425   static bool              activateView( const int ) /ReleaseGIL/ ;
426   static int               createView( const QString&, bool visible = true, const int width = 0, const int height = 0 ) /ReleaseGIL/ ;
427   static int               createView( const QString&, QWidget* ) /ReleaseGIL/ ;
428   static bool              closeView( const int ) /ReleaseGIL/ ;
429   static int               cloneView( const int ) /ReleaseGIL/ ;
430   static void              setViewVisible( const int id, bool visible = true ) /ReleaseGIL/ ;
431   static bool              isViewVisible( const int id ) /ReleaseGIL/ ;
432   static void              setViewClosable( const int id, const bool ) /ReleaseGIL/ ;
433   static bool              isViewClosable( const int id ) /ReleaseGIL/ ;
434   
435   static bool              groupAllViews() /ReleaseGIL/ ;
436   static bool              splitView( const int, Orientation, Action ) /ReleaseGIL/ ;
437   static bool              moveView( const int, const int, const bool ) /ReleaseGIL/ ;
438   static QList<int>        neighbourViews( const int ) /ReleaseGIL/ ;
439   
440   static void              displayCurve(const int, Plot2d_Curve*) /ReleaseGIL/ ;
441   static void              eraseCurve(const int, Plot2d_Curve*) /ReleaseGIL/ ;
442   static void              eraseCurve(Plot2d_Curve*) /ReleaseGIL/ ;
443   static void              updateCurves( const int ) /ReleaseGIL/ ;
444   static QString           getPlot2dTitle(const int, ObjectType = MainTitle) /ReleaseGIL/ ;
445   static void              setPlot2dTitle(const int, const QString&, ObjectType = MainTitle, bool = true) /ReleaseGIL/ ;
446   static QList<double>     getPlot2dFitRangeByCurves(const int) /ReleaseGIL/ ;
447   static QList<double>     getPlot2dFitRangeCurrent(const int) /ReleaseGIL/ ;
448   static void              setPlot2dFitRange(const int, const double XMin, const double XMax, const double YMin, const double YMax ) /ReleaseGIL/ ;
449 };