Salome HOME
New generic 2D View based on Qt
[modules/gui.git] / src / SALOME_PYQT / SalomePyQt / SalomePyQt.sip
1 // Copyright (C) 2007-2024  CEA, EDF, 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   WT_InfoPanel,
83 %If (ENABLE_CORBA)
84   WT_NoteBook,
85 %End
86   WT_User
87 };
88
89 enum PrefType {
90   PT_Auto,
91   PT_Space,
92   PT_Bool,
93   PT_Color,
94   PT_String,
95   PT_Selector,
96   PT_DblSpin,
97   PT_IntSpin,
98   PT_Double,
99   PT_Integer,
100   PT_GroupBox,
101   PT_Tab,
102   PT_Frame,
103   PT_Font,
104   PT_DirList,
105   PT_File,
106   PT_Slider,
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       sipType = sipType_QtxAction;
133     else
134       sipType = 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       sipType = sipType_QtxActionSet;
156     else
157       sipType = 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       sipType = sipType_QtxActionGroup;
195     else
196       sipType = 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       sipType = sipType_QtxTreeView;
229     else
230       sipType = 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       sipType = sipType_UserDefinedContent;
255     else
256       sipType = 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   static QString           getAppName() /ReleaseGIL/ ;
281   static bool              isLightApp() /ReleaseGIL/ ;
282
283 /* KeepReference is necessary on method getDesktop with SIP >= 4.15.5 to avoid garbage collection of
284    the Python objects added to the desktop. This causes a small memory leak (the wrapper around desktop
285    object is never garbage collected) but since this object contains only references this is not
286    considered a big problem. With versions < 4.15, it seems that this reference was kept implicitly.
287    No proper solution was found for versions between 4.15 and 4.15.4 (included), so those versions
288    should not be used to compile GUI module.
289 */
290 %If (SIP_4_15_5 - )
291   static QWidget*          getDesktop() /ReleaseGIL,KeepReference/ ;
292 %End
293 %If ( - SIP_4_15_5)
294   static QWidget*          getDesktop() /ReleaseGIL/ ;
295 %End
296
297   static QWidget*          getMainFrame() /ReleaseGIL/ ;
298   static QMenuBar*         getMainMenuBar() /ReleaseGIL/ ;
299   static QMenu*            getPopupMenu( const MenuName ) /ReleaseGIL/ ;
300   static QMenu*            getPopupMenu( const QString& ) /ReleaseGIL/ ;
301   static QTreeView*        getObjectBrowser() /ReleaseGIL/ ;
302   static void              enableSelector() /ReleaseGIL/ ;
303   static void              disableSelector() /ReleaseGIL/ ;
304   static SALOME_Selection* getSelection() /Factory,ReleaseGIL/ ;
305   static void              setSelection( const QStringList& ) /ReleaseGIL/ ;
306   static QStringList       getComponents() /ReleaseGIL/ ;
307   static const QString     getActiveComponent() /ReleaseGIL/ ;
308   static SIP_PYOBJECT      getActivePythonModule() /ReleaseGIL/ ;
309   static bool              activateModule( const QString& ) /ReleaseGIL/ ;
310   static void              registerModule( const QString& ) /ReleaseGIL/ ;
311   static void              updateObjBrowser() /ReleaseGIL/ ;
312
313   static void              infoSetTitle( const QString& ) /ReleaseGIL/ ;
314   static int               infoAddLabel( const QString&, const int = -1 ) /ReleaseGIL/ ;
315   static int               infoAddLabel( const QString&, Qt::Alignment, const int = -1 ) /ReleaseGIL/ ;
316   static int               infoAddAction( QAction*, const int = -1 ) /ReleaseGIL/ ;
317   static int               infoAddGroup( const QString&, const int = -1 ) /ReleaseGIL/ ;
318
319   static void              infoRemove( const int ) /ReleaseGIL/ ;
320   static void              infoClear( const int = -1 ) /ReleaseGIL/ ;
321
322   static void              infoSetVisible( const int, bool ) /ReleaseGIL/ ;
323   static void              infoSetEnabled( const int, bool ) /ReleaseGIL/ ;
324
325   static void              putInfo( const QString&, const int = 0 ) /ReleaseGIL/ ;
326   static int               showNotification( const QString&, const QString&, const int = -1 ) /ReleaseGIL/ ;
327   static void              hideNotification( const QString& ) /ReleaseGIL/ ;
328   static void              hideNotification( const int ) /ReleaseGIL/ ;
329
330   static bool              isModified() /ReleaseGIL/ ;
331   static void              setModified( bool ) /ReleaseGIL/ ;
332
333   static QString           getFileName         ( QWidget*, const QString&, const QStringList&, const QString&, bool ) /ReleaseGIL/ ;
334   static QStringList       getOpenFileNames    ( QWidget*, const QString&, const QStringList&, const QString& ) /ReleaseGIL/ ;
335   static QString           getExistingDirectory( QWidget*, const QString&, const QString& ) /ReleaseGIL/ ;
336
337   static void              createRoot() /ReleaseGIL/ ;
338   static QString           createObject( const QString& = QString("") )  /ReleaseGIL/ ;
339   static QString           createObject( const QString&,
340                                          const QString&,
341                                          const QString&,
342                                          const QString& = QString("") )  /ReleaseGIL/ ;
343
344   static void              setName(const QString& ,const QString& ) /ReleaseGIL/ ;
345   static void              setIcon(const QString& ,const QString& ) /ReleaseGIL/ ;
346   static void              setToolTip(const QString& ,const QString& ) /ReleaseGIL/ ;
347   static QString           getName(const QString& ) /ReleaseGIL/ ;
348   static QString           getToolTip(const QString& ) /ReleaseGIL/ ;
349
350   static void              setVisibilityState( const QString&, VisibilityState );
351   static VisibilityState   getVisibilityState( const QString& );
352
353   static void              setObjectPosition( const QString&, int );
354   static int               getObjectPosition( const QString& );
355
356   static void              setColor( const QString&, const QColor& ) /ReleaseGIL/ ;
357   static QColor            getColor( const QString& ) /ReleaseGIL/ ;
358
359   static void              setReference( const QString& ,const QString& ) /ReleaseGIL/ ;
360   static QString           getReference( const QString& ) /ReleaseGIL/ ;
361
362   static void              removeObject(const QString&  )    /ReleaseGIL/ ;
363   static void              removeChildren(const QString& = QString("")  ) /ReleaseGIL/ ;
364   static void              removeChild(const QString& = QString("")  ) /ReleaseGIL/ ;
365   static QStringList       getChildren(const QString&=QString("") , const bool = false) /ReleaseGIL/ ;
366
367   static QIcon             loadIcon( const QString&, const QString& ) /ReleaseGIL/ ;
368   static void              helpContext( const QString&, const QString& ) /ReleaseGIL/ ;
369
370   static bool              dumpView( const QString&, const int = 0 ) /ReleaseGIL/ ;
371
372   static int               defaultMenuGroup() /ReleaseGIL/ ;
373
374   static int               createTool( const QString&, const QString& = QString() ) /ReleaseGIL/ ;
375   static int               createTool( const int,  const int,      const int = -1 ) /ReleaseGIL/ ;
376   static int               createTool( const int,  const QString&, const int = -1 ) /ReleaseGIL/ ;
377   static int               createTool( QAction*,   const int,      const int = -1, const int = -1 ) /ReleaseGIL/ ;
378   static int               createTool( QAction*,   const QString&, const int = -1, const int = -1 ) /ReleaseGIL/ ;
379   static void              clearTool( const QString& ) /ReleaseGIL/ ;
380
381   static int               createMenu( const QString&, const int,
382                                        const int = -1, const int = -1, const int = -1 ) /ReleaseGIL/ ;
383   static int               createMenu( const QString&, const QString&,
384                                        const int = -1, const int = -1, const int = -1 ) /ReleaseGIL/ ;
385   static int               createMenu( const int,      const int,
386                                        const int = -1, const int = -1 ) /ReleaseGIL/ ;
387   static int               createMenu( const int,      const QString&,
388                                        const int = -1, const int = -1 ) /ReleaseGIL/ ;
389   static int               createMenu( QAction*,       const int,      const int = -1,
390                                        const int = -1, const int = -1 ) /ReleaseGIL/ ;
391   static int               createMenu( QAction*,       const QString&, const int = -1,
392                                        const int = -1, const int = -1 ) /ReleaseGIL/ ;
393   static QAction*          createSeparator() /ReleaseGIL/ ;
394
395   static QAction*          createAction( const int, const QString&,
396                                          const QString& = QString(), const QString& = QString(),
397                                          const QString& = QString(), const int = 0, const bool = false ) /ReleaseGIL/ ;
398
399   static QtxActionGroup*   createActionGroup( const int, const bool = true ) /ReleaseGIL/ ;
400
401   static QAction*          action( const int ) /ReleaseGIL/ ;
402   static int               actionId( const QAction* ) /ReleaseGIL/ ;
403
404   static QString           constant      ( const QString& ) /ReleaseGIL/ ;
405   static void              setConstant   ( const QString&, const QString& ) /ReleaseGIL/ ;
406   static void              addSetting    ( const QString&, const QString&, const double ) /ReleaseGIL/ ;
407   static void              addSetting    ( const QString&, const QString&, const int /Constrained/ ) /ReleaseGIL/ ;
408   static void              addSetting    ( const QString&, const QString&, const bool, const int ) /ReleaseGIL/ ;
409   static void              addSetting    ( const QString&, const QString&, const QString& ) /ReleaseGIL/ ;
410   static void              addSetting    ( const QString&, const QString&, const QColor& ) /ReleaseGIL/ ;
411   static void              addSetting    ( const QString&, const QString&, const QByteArray& ) /ReleaseGIL/ ;
412   static void              addSetting    ( const QString&, const QString&, const QFont& ) /ReleaseGIL/ ;
413   static int               integerSetting( const QString&, const QString&, const int = 0 ) /ReleaseGIL/ ;
414   static double            doubleSetting ( const QString&, const QString&, const double = 0 ) /ReleaseGIL/ ;
415   static bool              boolSetting   ( const QString&, const QString&, const bool = false ) /ReleaseGIL/ ;
416   static QString           stringSetting ( const QString&, const QString&, const QString& = QString(""), const bool = true ) /ReleaseGIL/ ;
417   static QColor            colorSetting  ( const QString&, const QString&, const QColor& = QColor() ) /ReleaseGIL/ ;
418   static QByteArray        byteArraySetting( const QString&, const QString&, const QByteArray& = QByteArray() ) /ReleaseGIL/ ;
419   static QFont             fontSetting( const QString&, const QString&, const QFont& = QFont() ) /ReleaseGIL/ ;
420   static void              removeSetting ( const QString&, const QString& ) /ReleaseGIL/ ;
421   static bool              hasSetting    ( const QString&, const QString& ) /ReleaseGIL/ ;
422   static QStringList       parameters    ( const QString& ) /ReleaseGIL/ ;
423   static QStringList       parameters    ( const QStringList& ) /ReleaseGIL/ ;
424
425 // obsolete
426   static void              addStringSetting( const QString&, const QString&, bool = true ) /ReleaseGIL/ ;
427   static void              addIntSetting   ( const QString&, const int,      bool = true ) /ReleaseGIL/ ;
428   static void              addDoubleSetting( const QString&, const double,   bool = true ) /ReleaseGIL/ ;
429   static void              addBoolSetting  ( const QString&, const bool,     bool = true ) /ReleaseGIL/ ;
430   static void              removeSettings  ( const QString& ) /ReleaseGIL/ ;
431   static QString           getSetting      ( const QString& ) /ReleaseGIL/ ;
432
433   static int               addGlobalPreference( const QString& ) /ReleaseGIL/ ;
434   static int               addPreference( const QString& ) /ReleaseGIL/ ;
435   static int               addPreference( const QString&,
436                                           const int, const int = PT_Auto,
437                                           const QString& = QString(),
438                                           const QString& = QString() ) /ReleaseGIL/ ;
439   static QVariant          preferenceProperty( const int, const QString& ) /ReleaseGIL/ ;
440   static void              setPreferenceProperty( const int,
441                                                   const QString&,
442                                                   const QVariant& ) /ReleaseGIL/ ;
443   static void              setPreferencePropertyWg( const int,
444                                                     const QString&,
445                                                     UserDefinedContent* ) /ReleaseGIL/ ;
446   static void              addPreferenceProperty( const int,
447                                                   const QString&,
448                                                   const int,
449                                                   const QVariant& ) /ReleaseGIL/ ;
450
451   static void              message( const QString&, bool = true ) /ReleaseGIL/ ;
452   static void              clearMessages() /ReleaseGIL/ ;
453
454   static QList<int>        getViews() /ReleaseGIL/ ;
455   static int               getActiveView() /ReleaseGIL/ ;
456   static QString           getViewType( const int ) /ReleaseGIL/ ;
457   static bool              setViewTitle( const int, const QString& ) /ReleaseGIL/ ;
458   static QString           getViewTitle( const int ) /ReleaseGIL/ ;
459   static bool              setViewSize( const int, const int, const int = 0 ) /ReleaseGIL/ ;
460   static bool              setViewRotationPoint( const double, const double, const double, const int = 0 ) /ReleaseGIL/ ;
461   static QList<int>        findViews( const QString& ) /ReleaseGIL/ ;
462   static bool              activateView( const int ) /ReleaseGIL/ ;
463   static bool              activateViewManagerAndView( const int ) /ReleaseGIL/ ;
464   static QWidget*          getViewWidget( const int ) /ReleaseGIL/ ;
465   static int               createView( const QString&, bool visible = true, const int width = 0, const int height = 0, bool detached = false ) /ReleaseGIL/ ;
466   static int               createView( const QString&, QWidget* ) /ReleaseGIL/ ;
467   static bool              closeView( const int ) /ReleaseGIL/ ;
468   static int               cloneView( const int ) /ReleaseGIL/ ;
469   static void              setViewVisible( const int id, bool visible = true ) /ReleaseGIL/ ;
470   static bool              isViewVisible( const int id ) /ReleaseGIL/ ;
471   static void              setViewClosable( const int id, const bool ) /ReleaseGIL/ ;
472   static bool              isViewClosable( const int id ) /ReleaseGIL/ ;
473
474   static bool              groupAllViews() /ReleaseGIL/ ;
475   static bool              splitView( const int, Orientation, Action ) /ReleaseGIL/ ;
476   static bool              moveView( const int, const int, const bool ) /ReleaseGIL/ ;
477   static QList<int>        neighbourViews( const int ) /ReleaseGIL/ ;
478
479 %If (ENABLE_PLOT2D)
480 // start Plot2d-related functionality
481   static void              displayCurve(const int, Plot2d_Curve*) /ReleaseGIL/ ;
482   static void              eraseCurve(const int, Plot2d_Curve*) /ReleaseGIL/ ;
483   static void              eraseCurve(Plot2d_Curve*) /ReleaseGIL/ ;
484   static void              updateCurves( const int ) /ReleaseGIL/ ;
485   static QString           getPlot2dTitle(const int, ObjectType = MainTitle) /ReleaseGIL/ ;
486   static void              setPlot2dTitle(const int, const QString&, ObjectType = MainTitle, bool = true) /ReleaseGIL/ ;
487   static QList<double>     getPlot2dFitRangeByCurves(const int) /ReleaseGIL/ ;
488   static QList<double>     getPlot2dFitRangeCurrent(const int) /ReleaseGIL/ ;
489   static void              setPlot2dFitRange(const int, const double XMin, const double XMax, const double YMin, const double YMax ) /ReleaseGIL/ ;
490 // end of Plot2d-related functionality
491 %End
492
493   static void              processEvents();
494
495   static void              startPyLog(const QString&) /ReleaseGIL/ ;
496   static void              stopPyLog() /ReleaseGIL/ ;
497
498   static void              logUserEvent( const QString& ) /ReleaseGIL/ ;
499   static void              logAction( QAction*, const QString& = QString() ) /ReleaseGIL/ ;
500   static void              setActionLoggingEnabled( bool ) /ReleaseGIL/ ;
501 };