Salome HOME
136881846bcb1ee534134276ba01734537645ae1
[modules/gui.git] / src / SALOME_PYQT / SalomePyQt / SalomePyQt.sip
1 // Copyright (C) 2007-2013  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.
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 class QtxAction : QWidgetAction
105 {
106 %TypeHeaderCode
107 #include <QtxAction.h>
108 %End
109
110 %ConvertToSubClassCode
111     if ( qobject_cast<QtxAction*>( sipCpp ) )
112       sipClass = sipClass_QtxAction;
113     else
114       sipClass = NULL;
115 %End
116
117 public:
118   explicit QtxAction( QObject* /TransferThis/ = 0, bool = false );
119   QtxAction( const QString&, const QString&, int, QObject* /TransferThis/, bool = false );
120   QtxAction( const QString&, const QIcon&, const QString&, int, QObject* /TransferThis/, bool = false );
121   virtual ~QtxAction();
122
123 private:
124   QtxAction( const QtxAction& );
125 };
126
127 class QtxActionSet : QtxAction
128 {
129 %TypeHeaderCode
130 #include <QtxActionSet.h>
131 %End
132
133 %ConvertToSubClassCode
134     if ( qobject_cast<QtxActionSet*>( sipCpp ) )
135       sipClass = sipClass_QtxActionSet;
136     else
137       sipClass = NULL;
138 %End
139
140 public:
141   explicit QtxActionSet( QObject* /TransferThis/ = 0 );
142   virtual ~QtxActionSet();
143
144   QList<QAction*> actions() const;
145   void            setActions( const QList<QAction*>& );
146
147   void            insertActions( const QList<QAction*>&, const int = -1 );
148
149   int             insertAction( QAction*, const int id = -1, const int = -1 );
150   int             insertAction( const QString&, const int id = -1, const int = -1 );
151   int             insertAction( const QString&, const QIcon&, const int id = -1, const int = -1 );
152
153   void            removeAction( QAction* );
154   void            removeAction( const int );
155
156   void            clear();
157
158 signals:
159   void            triggered( int );
160   void            triggered( QAction* );
161
162 private:
163   QtxActionSet( const QtxActionSet& );
164 };
165
166 class QtxActionGroup : QtxActionSet
167 {
168 %TypeHeaderCode
169 #include <QtxActionGroup.h>
170 %End
171
172 %ConvertToSubClassCode
173     if ( qobject_cast<QtxActionGroup*>( sipCpp ) )
174       sipClass = sipClass_QtxActionGroup;
175     else
176       sipClass = NULL;
177 %End
178
179 public:
180   explicit QtxActionGroup( QObject* /TransferThis/ = 0 );
181   QtxActionGroup( QObject* /TransferThis/, const bool );
182   virtual ~QtxActionGroup();
183
184   bool isExclusive() const;
185   bool usesDropDown() const;
186
187   void add( QAction* );
188
189 public slots:
190   void setExclusive( const bool );
191   void setUsesDropDown( const bool );
192
193 signals:
194   void selected( QAction* );
195
196 private:
197   QtxActionGroup( const QtxActionGroup& );
198 };
199
200 enum ObjectType
201 {
202   MainTitle,
203   XTitle,
204   YTitle,
205   Y2Title,
206   XAxis,
207   YAxis,
208   Y2Axis
209 };
210
211 class Plot2d_Curve
212 {
213 %TypeHeaderCode
214 #include <Plot2d_Curve.h>
215 %End
216
217 %ConvertToSubClassCode
218     if ( dynamic_cast<Plot2d_Curve*>( sipCpp ) )
219       sipClass = sipClass_Plot2d_Curve;
220     else
221       sipClass = NULL;
222 %End
223
224 public:
225   Plot2d_Curve();
226   virtual ~Plot2d_Curve();
227   void setName( const QString& );
228   void addPoint( double, double );
229   void addPoints(SIP_PYLIST X, SIP_PYLIST Y);
230 %MethodCode
231   int nx = PyList_Size(a0);
232   int ny = PyList_Size(a1);
233   
234   if( nx != ny ) { 
235     PyErr_Format(PyExc_TypeError,"The dimention of x and y should be the same. It is %d and %d currently.", nx, ny);
236   }
237   
238   int i;
239   PyObject *pX, *pY;
240
241   for (i=0; i<nx; i++) {
242     pX = PyList_GET_ITEM(a0,i);
243     pY = PyList_GET_ITEM(a1,i);
244     double aX = PyFloat_AsDouble(pX);
245     double aY = PyFloat_AsDouble(pY);
246     sipCpp->addPoint(aX, aY);
247   }
248 %End
249   void insertPoint( int, double, double );
250   void deletePoint( int );
251   void clearAllPoints();
252 };
253
254 enum VisibilityState 
255 {
256   ShownState,
257   HiddenState,
258   UnpresentableState 
259 };
260
261
262 class SalomePyQt
263 {
264 %TypeHeaderCode
265 #include <SalomePyQt.h>
266 %End
267
268 public:
269   static QWidget*          getDesktop() /ReleaseGIL/ ;
270   static QWidget*          getMainFrame() /ReleaseGIL/ ;
271   static QMenuBar*         getMainMenuBar() /ReleaseGIL/ ;
272   static QMenu*            getPopupMenu( const MenuName ) /ReleaseGIL/ ;
273   static QMenu*            getPopupMenu( const QString& ) /ReleaseGIL/ ;
274   static QTreeView*        getObjectBrowser() /ReleaseGIL/ ;
275   static SALOME_Selection* getSelection() /Factory,ReleaseGIL/ ;
276   static int               getStudyId() /ReleaseGIL/ ;
277   static void              putInfo( const QString&, const int = 0 ) /ReleaseGIL/ ;
278   static const QString     getActiveComponent() /ReleaseGIL/ ;
279   static SIP_PYOBJECT      getActivePythonModule() /ReleaseGIL/ ;
280   static bool              activateModule( const QString& ) /ReleaseGIL/ ;
281   static void              updateObjBrowser( const int = 0, bool =  true ) /ReleaseGIL/ ;
282   
283   static bool              isModified() /ReleaseGIL/ ;
284   static void              setModified( bool ) /ReleaseGIL/ ;
285
286   static QString           getFileName         ( QWidget*, const QString&, const QStringList&, const QString&, bool ) /ReleaseGIL/ ;
287   static QStringList       getOpenFileNames    ( QWidget*, const QString&, const QStringList&, const QString& ) /ReleaseGIL/ ;
288   static QString           getExistingDirectory( QWidget*, const QString&, const QString& ) /ReleaseGIL/ ;
289                          
290   static QString           createObject( const QString& = QString("") )  /ReleaseGIL/ ;
291   static QString           createObject( const QString&,
292                                          const QString&,
293                                          const QString&,
294                                          const QString& = QString("") )  /ReleaseGIL/ ;
295
296   static void              setName(const QString& ,const QString& ) /ReleaseGIL/ ;
297   static void              setIcon(const QString& ,const QString& ) /ReleaseGIL/ ;
298   static void              setToolTip(const QString& ,const QString& ) /ReleaseGIL/ ;
299   static QString           getName(const QString& ) /ReleaseGIL/ ;
300   static QString           getToolTip(const QString& ) /ReleaseGIL/ ;
301
302   static void              setVisibilityState( const QString&, VisibilityState );
303   static VisibilityState   getVisibilityState( const QString& );
304
305   static void              setObjectPosition( const QString&, int );
306   static int               getObjectPosition( const QString& );
307
308   static void              setColor( const QString&, const QColor& ) /ReleaseGIL/ ;
309   static QColor            getColor( const QString& ) /ReleaseGIL/ ;
310
311   static void              setReference( const QString& ,const QString& ) /ReleaseGIL/ ; 
312   static QString           getReference( const QString& ) /ReleaseGIL/ ;
313
314   static void              removeObject(const QString&  )    /ReleaseGIL/ ;
315   static void              removeChildren(const QString& = QString("")  ) /ReleaseGIL/ ;
316   static void              removeChild(const QString& = QString("")  ) /ReleaseGIL/ ;
317   static QStringList       getChildren(const QString&=QString("") , const bool = false) /ReleaseGIL/ ;
318
319   static QIcon             loadIcon( const QString&, const QString& ) /ReleaseGIL/ ;
320   static void              helpContext( const QString&, const QString& ) /ReleaseGIL/ ;
321
322   static bool              dumpView( const QString&, const int = 0 ) /ReleaseGIL/ ;
323
324   static int               defaultMenuGroup() /ReleaseGIL/ ;
325
326   static int               createTool( const QString& ) /ReleaseGIL/ ;
327   static int               createTool( const int,  const int,      const int = -1 ) /ReleaseGIL/ ;
328   static int               createTool( const int,  const QString&, const int = -1 ) /ReleaseGIL/ ;
329   static int               createTool( QAction*,   const int,      const int = -1, const int = -1 ) /ReleaseGIL/ ;
330   static int               createTool( QAction*,   const QString&, const int = -1, const int = -1 ) /ReleaseGIL/ ;
331
332   static int               createMenu( const QString&, const int,
333                                        const int = -1, const int = -1, const int = -1 ) /ReleaseGIL/ ;
334   static int               createMenu( const QString&, const QString&, 
335                                        const int = -1, const int = -1, const int = -1 ) /ReleaseGIL/ ;
336   static int               createMenu( const int,      const int,
337                                        const int = -1, const int = -1 ) /ReleaseGIL/ ;
338   static int               createMenu( const int,      const QString&, 
339                                        const int = -1, const int = -1 ) /ReleaseGIL/ ;
340   static int               createMenu( QAction*,       const int,      const int = -1, 
341                                        const int = -1, const int = -1 ) /ReleaseGIL/ ;
342   static int               createMenu( QAction*,       const QString&, const int = -1, 
343                                        const int = -1, const int = -1 ) /ReleaseGIL/ ;
344   static QAction*          createSeparator() /ReleaseGIL/ ;
345
346   static QAction*          createAction( const int, const QString&, 
347                                          const QString& = QString(), const QString& = QString(), 
348                                          const QString& = QString(), const int = 0, const bool = false ) /ReleaseGIL/ ;
349
350   static QtxActionGroup*   createActionGroup( const int, const bool = true ) /ReleaseGIL/ ;
351
352   static QAction*          action( const int ) /ReleaseGIL/ ;
353   static int               actionId( const QAction* ) /ReleaseGIL/ ;
354
355   static void              addSetting    ( const QString&, const QString&, const double ) /ReleaseGIL/ ;
356   static void              addSetting    ( const QString&, const QString&, const int /Constrained/ ) /ReleaseGIL/ ;
357   static void              addSetting    ( const QString&, const QString&, const bool, const int ) /ReleaseGIL/ ;
358   static void              addSetting    ( const QString&, const QString&, const QString& ) /ReleaseGIL/ ;
359   static void              addSetting    ( const QString&, const QString&, const QColor& ) /ReleaseGIL/ ;
360   static int               integerSetting( const QString&, const QString&, const int = 0 ) /ReleaseGIL/ ;
361   static double            doubleSetting ( const QString&, const QString&, const double = 0 ) /ReleaseGIL/ ;
362   static bool              boolSetting   ( const QString&, const QString&, const bool = false ) /ReleaseGIL/ ;
363   static QString           stringSetting ( const QString&, const QString&, const QString& = QString("") ) /ReleaseGIL/ ;
364   static QColor            colorSetting  ( const QString&, const QString&, const QColor& = QColor() ) /ReleaseGIL/ ;
365   static void              removeSetting ( const QString&, const QString& ) /ReleaseGIL/ ;
366   static bool              hasSetting    ( const QString&, const QString& ) /ReleaseGIL/ ;
367
368 // obsolete
369   static void              addStringSetting( const QString&, const QString&, bool = true ) /ReleaseGIL/ ;
370   static void              addIntSetting   ( const QString&, const int,      bool = true ) /ReleaseGIL/ ;
371   static void              addDoubleSetting( const QString&, const double,   bool = true ) /ReleaseGIL/ ;
372   static void              addBoolSetting  ( const QString&, const bool,     bool = true ) /ReleaseGIL/ ;
373   static void              removeSettings  ( const QString& ) /ReleaseGIL/ ;
374   static QString           getSetting      ( const QString& ) /ReleaseGIL/ ;
375
376   static int               addGlobalPreference( const QString& ) /ReleaseGIL/ ;
377   static int               addPreference( const QString& ) /ReleaseGIL/ ;
378   static int               addPreference( const QString&,
379                                           const int, const int = PT_Auto,
380                                           const QString& = QString(),
381                                           const QString& = QString() ) /ReleaseGIL/ ;
382   static QVariant          preferenceProperty( const int, const QString& ) /ReleaseGIL/ ;
383   static void              setPreferenceProperty( const int, 
384                                                   const QString&,
385                                                   const QVariant& ) /ReleaseGIL/ ;
386   static void              addPreferenceProperty( const int, 
387                                                   const QString&, 
388                                                   const int, 
389                                                   const QVariant& ) /ReleaseGIL/ ;
390
391   static void              message( const QString&, bool = true ) /ReleaseGIL/ ;
392   static void              clearMessages() /ReleaseGIL/ ;
393   
394   static QList<int>        getViews() /ReleaseGIL/ ;
395   static int               getActiveView() /ReleaseGIL/ ;
396   static QString           getViewType( const int ) /ReleaseGIL/ ;
397   static bool              setViewTitle( const int, const QString& ) /ReleaseGIL/ ;
398   static QString           getViewTitle( const int ) /ReleaseGIL/ ;
399   static QList<int>        findViews( const QString& ) /ReleaseGIL/ ;
400   static bool              activateView( const int ) /ReleaseGIL/ ;
401   static int               createView( const QString&, bool visible = true, const int width = 0, const int height = 0 ) /ReleaseGIL/ ;
402   static int               createView( const QString&, QWidget* ) /ReleaseGIL/ ;
403   static bool              closeView( const int ) /ReleaseGIL/ ;
404   static int               cloneView( const int ) /ReleaseGIL/ ;
405   static void              setViewVisible( const int id, bool visible = true ) /ReleaseGIL/ ;
406   static bool              isViewVisible( const int id ) /ReleaseGIL/ ;
407   static void              setViewClosable( const int id, const bool ) /ReleaseGIL/ ;
408   static bool              isViewClosable( const int id ) /ReleaseGIL/ ;
409   
410   static bool              groupAllViews() /ReleaseGIL/ ;
411   static bool              splitView( const int, Orientation, Action ) /ReleaseGIL/ ;
412   static bool              moveView( const int, const int, const bool ) /ReleaseGIL/ ;
413   static QList<int>        neighbourViews( const int ) /ReleaseGIL/ ;
414   
415   static void              displayCurve(const int, Plot2d_Curve*) /ReleaseGIL/ ;
416   static void              eraseCurve(const int, Plot2d_Curve*) /ReleaseGIL/ ;
417   static void              eraseCurve(Plot2d_Curve*) /ReleaseGIL/ ;
418   static void              updateCurves( const int ) /ReleaseGIL/ ;
419   static QString           getPlot2dTitle(const int, ObjectType = MainTitle) /ReleaseGIL/ ;
420   static void              setPlot2dTitle(const int, const QString&, ObjectType = MainTitle, bool = true) /ReleaseGIL/ ;
421   static QList<double>     getPlot2dFitRangeByCurves(const int) /ReleaseGIL/ ;
422   static QList<double>     getPlot2dFitRangeCurrent(const int) /ReleaseGIL/ ;
423   static void              setPlot2dFitRange(const int, const double XMin, const double XMax, const double YMin, const double YMax ) /ReleaseGIL/ ;
424 };