Salome HOME
Merge branch 'V9_2_BR'
[modules/gui.git] / src / SALOME_PYQT / SalomePyQt / SalomePyQt.sip
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 // File   : SalomePyQt.sip
23 // Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
24 //
25
26 %Module SalomePyQt
27
28 %Feature ENABLE_CORBA
29 %Feature ENABLE_PLOT2D
30
31 %Import QtCore/QtCoremod.sip
32 %Import QtGui/QtGuimod.sip
33 %If (Qt_5_0_0 -)
34 %Import QtWidgets/QtWidgetsmod.sip
35 %End
36 %Import QtXml/QtXmlmod.sip
37
38 %If (ENABLE_PLOT2D)
39 %Include SalomePyQt_Plot2d.sip
40 %End
41
42 %ExportedHeaderCode
43 #include <QtxAction.h>
44 #include <QtxActionSet.h>
45 #include <QtxActionGroup.h>
46 #include <QtxTreeView.h>
47 #include <SalomePyQt.h>
48 %End
49
50 class SALOME_Selection : QObject
51 {
52 %TypeHeaderCode
53 #include <SalomePyQt.h>
54 %End
55
56 public:
57   void Clear() /ReleaseGIL/ ;
58   void ClearIObjects() /ReleaseGIL/ ;
59   void ClearFilters() /ReleaseGIL/ ;
60
61 private:
62   SALOME_Selection( QObject* /TransferThis/ );
63
64 signals:
65   void currentSelectionChanged();
66 };
67
68 enum MenuName {
69   File        = 1,
70   View        = 2,
71   Edit        = 3,
72   Preferences = 4,
73   Tools       = 5,
74   Window      = 6,
75   Help        = 7  
76 };
77
78 enum WindowType {
79   WT_ObjectBrowser,
80   WT_PyConsole,
81   WT_LogWindow,
82 %If (ENABLE_CORBA)
83   WT_NoteBook,
84 %End
85   WT_User
86 };
87
88 enum PrefType { 
89   PT_Auto,
90   PT_Space,
91   PT_Bool, 
92   PT_Color,
93   PT_String, 
94   PT_Selector, 
95   PT_DblSpin, 
96   PT_IntSpin, 
97   PT_Double, 
98   PT_Integer, 
99   PT_GroupBox, 
100   PT_Tab, 
101   PT_Frame, 
102   PT_Font, 
103   PT_DirList, 
104   PT_File, 
105   PT_Slider,
106   PT_Shortcut,
107   PT_ShortcutTree,
108   PT_BiColor,
109   PT_Background,
110   PT_UserDefined
111 };
112
113 enum Orientation {
114   Horizontal = 0, 
115   Vertical   = 1  
116 };
117
118 enum Action {
119   MoveWidget   = 0, 
120   LeaveWidget  = 1, 
121   SplitAt      = 2  
122 };
123
124 class QtxAction : QWidgetAction
125 {
126 %TypeHeaderCode
127 #include <QtxAction.h>
128 %End
129
130 %ConvertToSubClassCode
131     if ( qobject_cast<QtxAction*>( sipCpp ) )
132       sipClass = sipClass_QtxAction;
133     else
134       sipClass = NULL;
135 %End
136
137 public:
138   explicit QtxAction( QObject* /TransferThis/ = 0, bool = false );
139   QtxAction( const QString&, const QString&, int, QObject* /TransferThis/, bool = false );
140   QtxAction( const QString&, const QIcon&, const QString&, int, QObject* /TransferThis/, bool = false );
141   virtual ~QtxAction();
142
143 private:
144   QtxAction( const QtxAction& );
145 };
146
147 class QtxActionSet : QtxAction
148 {
149 %TypeHeaderCode
150 #include <QtxActionSet.h>
151 %End
152
153 %ConvertToSubClassCode
154     if ( qobject_cast<QtxActionSet*>( sipCpp ) )
155       sipClass = sipClass_QtxActionSet;
156     else
157       sipClass = NULL;
158 %End
159
160 public:
161   explicit QtxActionSet( QObject* /TransferThis/ = 0 );
162   virtual ~QtxActionSet();
163
164   QList<QAction*> actions() const;
165   void            setActions( const QList<QAction*>& );
166
167   void            insertActions( const QList<QAction*>&, const int = -1 );
168
169   int             insertAction( QAction*, const int id = -1, const int = -1 );
170   int             insertAction( const QString&, const int id = -1, const int = -1 );
171   int             insertAction( const QString&, const QIcon&, const int id = -1, const int = -1 );
172
173   void            removeAction( QAction* );
174   void            removeAction( const int );
175
176   void            clear();
177
178 signals:
179   void            triggered( int );
180   void            triggered( QAction* );
181
182 private:
183   QtxActionSet( const QtxActionSet& );
184 };
185
186 class QtxActionGroup : QtxActionSet
187 {
188 %TypeHeaderCode
189 #include <QtxActionGroup.h>
190 %End
191
192 %ConvertToSubClassCode
193     if ( qobject_cast<QtxActionGroup*>( sipCpp ) )
194       sipClass = sipClass_QtxActionGroup;
195     else
196       sipClass = NULL;
197 %End
198
199 public:
200   explicit QtxActionGroup( QObject* /TransferThis/ = 0 );
201   QtxActionGroup( QObject* /TransferThis/, const bool );
202   virtual ~QtxActionGroup();
203
204   bool isExclusive() const;
205   bool usesDropDown() const;
206
207   void add( QAction* );
208
209 public slots:
210   void setExclusive( const bool );
211   void setUsesDropDown( const bool );
212
213 signals:
214   void selected( QAction* );
215
216 private:
217   QtxActionGroup( const QtxActionGroup& );
218 };
219
220 class QtxTreeView : public QTreeView
221 {
222 %TypeHeaderCode
223 #include <QtxTreeView.h>
224 %End
225
226 %ConvertToSubClassCode
227     if ( qobject_cast<QtxTreeView*>( sipCpp ) )
228       sipClass = sipClass_QtxTreeView;
229     else
230       sipClass = NULL;
231 %End
232
233 public:
234   explicit QtxTreeView( QWidget* /TransferThis/ = 0 );
235   QtxTreeView( const bool, QWidget* /TransferThis/ = 0  );
236   virtual ~QtxTreeView();
237
238 signals:
239   void     sortingEnabled( bool );
240   void     selectionChanged();
241
242 private:
243   QtxTreeView( const QtxTreeView& );
244 };
245
246 class UserDefinedContent : public QWidget
247 {
248 %TypeHeaderCode
249 #include <SalomePyQt.h>
250 %End
251
252 %ConvertToSubClassCode
253     if ( qobject_cast<UserDefinedContent*>( sipCpp ) )
254       sipClass = sipClass_UserDefinedContent;
255     else
256       sipClass = NULL;
257 %End
258
259 public:
260   explicit UserDefinedContent();
261
262   virtual void store();
263   virtual void retrieve();
264 };
265
266 enum VisibilityState 
267 {
268   ShownState,
269   HiddenState,
270   UnpresentableState 
271 };
272
273 class SalomePyQt
274 {
275 %TypeHeaderCode
276 #include <SalomePyQt.h>
277 %End
278
279 public:
280 /* KeepReference is necessary on method getDesktop with SIP >= 4.15.5 to avoid garbage collection of
281    the Python objects added to the desktop. This causes a small memory leak (the wrapper around desktop
282    object is never garbage collected) but since this object contains only references this is not
283    considered a big problem. With versions < 4.15, it seems that this reference was kept implicitly.
284    No proper solution was found for versions between 4.15 and 4.15.4 (included), so those versions
285    should not be used to compile GUI module.
286 */
287 %If (SIP_4_15_5 - )
288   static QWidget*          getDesktop() /ReleaseGIL,KeepReference/ ;
289 %End
290 %If ( - SIP_4_15_5)
291   static QWidget*          getDesktop() /ReleaseGIL/ ;
292 %End
293
294   static QWidget*          getMainFrame() /ReleaseGIL/ ;
295   static QMenuBar*         getMainMenuBar() /ReleaseGIL/ ;
296   static QMenu*            getPopupMenu( const MenuName ) /ReleaseGIL/ ;
297   static QMenu*            getPopupMenu( const QString& ) /ReleaseGIL/ ;
298   static QTreeView*        getObjectBrowser() /ReleaseGIL/ ;
299   static void              enableSelector() /ReleaseGIL/ ;
300   static void              disableSelector() /ReleaseGIL/ ;
301   static SALOME_Selection* getSelection() /Factory,ReleaseGIL/ ;
302   static void              setSelection( const QStringList& ) /ReleaseGIL/ ;
303   static QStringList       getComponents() /ReleaseGIL/ ;
304   static const QString     getActiveComponent() /ReleaseGIL/ ;
305   static SIP_PYOBJECT      getActivePythonModule() /ReleaseGIL/ ;
306   static bool              activateModule( const QString& ) /ReleaseGIL/ ;
307   static void              updateObjBrowser() /ReleaseGIL/ ;
308
309   static void              putInfo( const QString&, const int = 0 ) /ReleaseGIL/ ;
310   static int               showNotification( const QString&, const QString&, const int = -1 ) /ReleaseGIL/ ;
311   static void              hideNotification( const QString& ) /ReleaseGIL/ ;
312   static void              hideNotification( const int ) /ReleaseGIL/ ;
313
314   static bool              isModified() /ReleaseGIL/ ;
315   static void              setModified( bool ) /ReleaseGIL/ ;
316
317   static QString           getFileName         ( QWidget*, const QString&, const QStringList&, const QString&, bool ) /ReleaseGIL/ ;
318   static QStringList       getOpenFileNames    ( QWidget*, const QString&, const QStringList&, const QString& ) /ReleaseGIL/ ;
319   static QString           getExistingDirectory( QWidget*, const QString&, const QString& ) /ReleaseGIL/ ;
320                          
321   static void              createRoot() /ReleaseGIL/ ;
322   static QString           createObject( const QString& = QString("") )  /ReleaseGIL/ ;
323   static QString           createObject( const QString&,
324                                          const QString&,
325                                          const QString&,
326                                          const QString& = QString("") )  /ReleaseGIL/ ;
327
328   static void              setName(const QString& ,const QString& ) /ReleaseGIL/ ;
329   static void              setIcon(const QString& ,const QString& ) /ReleaseGIL/ ;
330   static void              setToolTip(const QString& ,const QString& ) /ReleaseGIL/ ;
331   static QString           getName(const QString& ) /ReleaseGIL/ ;
332   static QString           getToolTip(const QString& ) /ReleaseGIL/ ;
333
334   static void              setVisibilityState( const QString&, VisibilityState );
335   static VisibilityState   getVisibilityState( const QString& );
336
337   static void              setObjectPosition( const QString&, int );
338   static int               getObjectPosition( const QString& );
339
340   static void              setColor( const QString&, const QColor& ) /ReleaseGIL/ ;
341   static QColor            getColor( const QString& ) /ReleaseGIL/ ;
342
343   static void              setReference( const QString& ,const QString& ) /ReleaseGIL/ ; 
344   static QString           getReference( const QString& ) /ReleaseGIL/ ;
345
346   static void              removeObject(const QString&  )    /ReleaseGIL/ ;
347   static void              removeChildren(const QString& = QString("")  ) /ReleaseGIL/ ;
348   static void              removeChild(const QString& = QString("")  ) /ReleaseGIL/ ;
349   static QStringList       getChildren(const QString&=QString("") , const bool = false) /ReleaseGIL/ ;
350
351   static QIcon             loadIcon( const QString&, const QString& ) /ReleaseGIL/ ;
352   static void              helpContext( const QString&, const QString& ) /ReleaseGIL/ ;
353
354   static bool              dumpView( const QString&, const int = 0 ) /ReleaseGIL/ ;
355
356   static int               defaultMenuGroup() /ReleaseGIL/ ;
357
358   static int               createTool( const QString&, const QString& = QString() ) /ReleaseGIL/ ;
359   static int               createTool( const int,  const int,      const int = -1 ) /ReleaseGIL/ ;
360   static int               createTool( const int,  const QString&, const int = -1 ) /ReleaseGIL/ ;
361   static int               createTool( QAction*,   const int,      const int = -1, const int = -1 ) /ReleaseGIL/ ;
362   static int               createTool( QAction*,   const QString&, const int = -1, const int = -1 ) /ReleaseGIL/ ;
363   static void              clearTool( const QString& ) /ReleaseGIL/ ;
364
365   static int               createMenu( const QString&, const int,
366                                        const int = -1, const int = -1, const int = -1 ) /ReleaseGIL/ ;
367   static int               createMenu( const QString&, const QString&, 
368                                        const int = -1, const int = -1, const int = -1 ) /ReleaseGIL/ ;
369   static int               createMenu( const int,      const int,
370                                        const int = -1, const int = -1 ) /ReleaseGIL/ ;
371   static int               createMenu( const int,      const QString&, 
372                                        const int = -1, const int = -1 ) /ReleaseGIL/ ;
373   static int               createMenu( QAction*,       const int,      const int = -1, 
374                                        const int = -1, const int = -1 ) /ReleaseGIL/ ;
375   static int               createMenu( QAction*,       const QString&, const int = -1, 
376                                        const int = -1, const int = -1 ) /ReleaseGIL/ ;
377   static QAction*          createSeparator() /ReleaseGIL/ ;
378
379   static QAction*          createAction( const int, const QString&, 
380                                          const QString& = QString(), const QString& = QString(), 
381                                          const QString& = QString(), const int = 0, const bool = false ) /ReleaseGIL/ ;
382
383   static QtxActionGroup*   createActionGroup( const int, const bool = true ) /ReleaseGIL/ ;
384
385   static QAction*          action( const int ) /ReleaseGIL/ ;
386   static int               actionId( const QAction* ) /ReleaseGIL/ ;
387
388   static QString           constant      ( const QString& ) /ReleaseGIL/ ;
389   static void              setConstant   ( const QString&, const QString& ) /ReleaseGIL/ ;
390   static void              addSetting    ( const QString&, const QString&, const double ) /ReleaseGIL/ ;
391   static void              addSetting    ( const QString&, const QString&, const int /Constrained/ ) /ReleaseGIL/ ;
392   static void              addSetting    ( const QString&, const QString&, const bool, const int ) /ReleaseGIL/ ;
393   static void              addSetting    ( const QString&, const QString&, const QString& ) /ReleaseGIL/ ;
394   static void              addSetting    ( const QString&, const QString&, const QColor& ) /ReleaseGIL/ ;
395   static void              addSetting    ( const QString&, const QString&, const QByteArray& ) /ReleaseGIL/ ;
396   static void              addSetting    ( const QString&, const QString&, const QFont& ) /ReleaseGIL/ ;
397   static int               integerSetting( const QString&, const QString&, const int = 0 ) /ReleaseGIL/ ;
398   static double            doubleSetting ( const QString&, const QString&, const double = 0 ) /ReleaseGIL/ ;
399   static bool              boolSetting   ( const QString&, const QString&, const bool = false ) /ReleaseGIL/ ;
400   static QString           stringSetting ( const QString&, const QString&, const QString& = QString(""), const bool = true ) /ReleaseGIL/ ;
401   static QColor            colorSetting  ( const QString&, const QString&, const QColor& = QColor() ) /ReleaseGIL/ ;
402   static QByteArray        byteArraySetting( const QString&, const QString&, const QByteArray& = QByteArray() ) /ReleaseGIL/ ;
403   static QFont             fontSetting( const QString&, const QString&, const QFont& = QFont() ) /ReleaseGIL/ ;
404   static void              removeSetting ( const QString&, const QString& ) /ReleaseGIL/ ;
405   static bool              hasSetting    ( const QString&, const QString& ) /ReleaseGIL/ ;
406   static QStringList       parameters    ( const QString& ) /ReleaseGIL/ ;
407   static QStringList       parameters    ( const QStringList& ) /ReleaseGIL/ ;
408
409 // obsolete
410   static void              addStringSetting( const QString&, const QString&, bool = true ) /ReleaseGIL/ ;
411   static void              addIntSetting   ( const QString&, const int,      bool = true ) /ReleaseGIL/ ;
412   static void              addDoubleSetting( const QString&, const double,   bool = true ) /ReleaseGIL/ ;
413   static void              addBoolSetting  ( const QString&, const bool,     bool = true ) /ReleaseGIL/ ;
414   static void              removeSettings  ( const QString& ) /ReleaseGIL/ ;
415   static QString           getSetting      ( const QString& ) /ReleaseGIL/ ;
416
417   static int               addGlobalPreference( const QString& ) /ReleaseGIL/ ;
418   static int               addPreference( const QString& ) /ReleaseGIL/ ;
419   static int               addPreference( const QString&,
420                                           const int, const int = PT_Auto,
421                                           const QString& = QString(),
422                                           const QString& = QString() ) /ReleaseGIL/ ;
423   static QVariant          preferenceProperty( const int, const QString& ) /ReleaseGIL/ ;
424   static void              setPreferenceProperty( const int, 
425                                                   const QString&,
426                                                   const QVariant& ) /ReleaseGIL/ ;
427   static void              setPreferencePropertyWg( const int, 
428                                                     const QString&,     
429                                                     UserDefinedContent* ) /ReleaseGIL/ ;
430   static void              addPreferenceProperty( const int, 
431                                                   const QString&, 
432                                                   const int, 
433                                                   const QVariant& ) /ReleaseGIL/ ;
434
435   static void              message( const QString&, bool = true ) /ReleaseGIL/ ;
436   static void              clearMessages() /ReleaseGIL/ ;
437   
438   static QList<int>        getViews() /ReleaseGIL/ ;
439   static int               getActiveView() /ReleaseGIL/ ;
440   static QString           getViewType( const int ) /ReleaseGIL/ ;
441   static bool              setViewTitle( const int, const QString& ) /ReleaseGIL/ ;
442   static QString           getViewTitle( const int ) /ReleaseGIL/ ;
443   static bool              setViewSize( const int, const int, const int = 0 ) /ReleaseGIL/ ;
444   static bool              setViewRotationPoint( const double, const double, const double, const int = 0 ) /ReleaseGIL/ ;
445   static QList<int>        findViews( const QString& ) /ReleaseGIL/ ;
446   static bool              activateView( const int ) /ReleaseGIL/ ;
447   static bool              activateViewManagerAndView( const int ) /ReleaseGIL/ ;
448   static QWidget*          getViewWidget( const int ) /ReleaseGIL/ ;
449   static int               createView( const QString&, bool visible = true, const int width = 0, const int height = 0, bool detached = false ) /ReleaseGIL/ ;
450   static int               createView( const QString&, QWidget* ) /ReleaseGIL/ ;
451   static bool              closeView( const int ) /ReleaseGIL/ ;
452   static int               cloneView( const int ) /ReleaseGIL/ ;
453   static void              setViewVisible( const int id, bool visible = true ) /ReleaseGIL/ ;
454   static bool              isViewVisible( const int id ) /ReleaseGIL/ ;
455   static void              setViewClosable( const int id, const bool ) /ReleaseGIL/ ;
456   static bool              isViewClosable( const int id ) /ReleaseGIL/ ;
457   
458   static bool              groupAllViews() /ReleaseGIL/ ;
459   static bool              splitView( const int, Orientation, Action ) /ReleaseGIL/ ;
460   static bool              moveView( const int, const int, const bool ) /ReleaseGIL/ ;
461   static QList<int>        neighbourViews( const int ) /ReleaseGIL/ ;
462   
463 %If (ENABLE_PLOT2D)
464 // start Plot2d-related functionality
465   static void              displayCurve(const int, Plot2d_Curve*) /ReleaseGIL/ ;
466   static void              eraseCurve(const int, Plot2d_Curve*) /ReleaseGIL/ ;
467   static void              eraseCurve(Plot2d_Curve*) /ReleaseGIL/ ;
468   static void              updateCurves( const int ) /ReleaseGIL/ ;
469   static QString           getPlot2dTitle(const int, ObjectType = MainTitle) /ReleaseGIL/ ;
470   static void              setPlot2dTitle(const int, const QString&, ObjectType = MainTitle, bool = true) /ReleaseGIL/ ;
471   static QList<double>     getPlot2dFitRangeByCurves(const int) /ReleaseGIL/ ;
472   static QList<double>     getPlot2dFitRangeCurrent(const int) /ReleaseGIL/ ;
473   static void              setPlot2dFitRange(const int, const double XMin, const double XMax, const double YMin, const double YMax ) /ReleaseGIL/ ;
474 // end of Plot2d-related functionality
475 %End
476
477   static void              processEvents();
478
479   static void              startPyLog(const QString&) /ReleaseGIL/ ;
480   static void              stopPyLog() /ReleaseGIL/ ;
481 };