Salome HOME
bos #29467 SALOME GUI logger
[modules/gui.git] / src / SALOME_PYQT / SalomePyQt / SalomePyQt.sip
1 // Copyright (C) 2007-2023  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_Shortcut,
108   PT_ShortcutTree,
109   PT_BiColor,
110   PT_Background,
111   PT_UserDefined
112 };
113
114 enum Orientation {
115   Horizontal = 0, 
116   Vertical   = 1  
117 };
118
119 enum Action {
120   MoveWidget   = 0, 
121   LeaveWidget  = 1, 
122   SplitAt      = 2  
123 };
124
125 class QtxAction : QWidgetAction
126 {
127 %TypeHeaderCode
128 #include <QtxAction.h>
129 %End
130
131 %ConvertToSubClassCode
132     if ( qobject_cast<QtxAction*>( sipCpp ) )
133       sipType = sipType_QtxAction;
134     else
135       sipType = NULL;
136 %End
137
138 public:
139   explicit QtxAction( QObject* /TransferThis/ = 0, bool = false );
140   QtxAction( const QString&, const QString&, int, QObject* /TransferThis/, bool = false );
141   QtxAction( const QString&, const QIcon&, const QString&, int, QObject* /TransferThis/, bool = false );
142   virtual ~QtxAction();
143
144 private:
145   QtxAction( const QtxAction& );
146 };
147
148 class QtxActionSet : QtxAction
149 {
150 %TypeHeaderCode
151 #include <QtxActionSet.h>
152 %End
153
154 %ConvertToSubClassCode
155     if ( qobject_cast<QtxActionSet*>( sipCpp ) )
156       sipType = sipType_QtxActionSet;
157     else
158       sipType = NULL;
159 %End
160
161 public:
162   explicit QtxActionSet( QObject* /TransferThis/ = 0 );
163   virtual ~QtxActionSet();
164
165   QList<QAction*> actions() const;
166   void            setActions( const QList<QAction*>& );
167
168   void            insertActions( const QList<QAction*>&, const int = -1 );
169
170   int             insertAction( QAction*, const int id = -1, const int = -1 );
171   int             insertAction( const QString&, const int id = -1, const int = -1 );
172   int             insertAction( const QString&, const QIcon&, const int id = -1, const int = -1 );
173
174   void            removeAction( QAction* );
175   void            removeAction( const int );
176
177   void            clear();
178
179 signals:
180   void            triggered( int );
181   void            triggered( QAction* );
182
183 private:
184   QtxActionSet( const QtxActionSet& );
185 };
186
187 class QtxActionGroup : QtxActionSet
188 {
189 %TypeHeaderCode
190 #include <QtxActionGroup.h>
191 %End
192
193 %ConvertToSubClassCode
194     if ( qobject_cast<QtxActionGroup*>( sipCpp ) )
195       sipType = sipType_QtxActionGroup;
196     else
197       sipType = NULL;
198 %End
199
200 public:
201   explicit QtxActionGroup( QObject* /TransferThis/ = 0 );
202   QtxActionGroup( QObject* /TransferThis/, const bool );
203   virtual ~QtxActionGroup();
204
205   bool isExclusive() const;
206   bool usesDropDown() const;
207
208   void add( QAction* );
209
210 public slots:
211   void setExclusive( const bool );
212   void setUsesDropDown( const bool );
213
214 signals:
215   void selected( QAction* );
216
217 private:
218   QtxActionGroup( const QtxActionGroup& );
219 };
220
221 class QtxTreeView : public QTreeView
222 {
223 %TypeHeaderCode
224 #include <QtxTreeView.h>
225 %End
226
227 %ConvertToSubClassCode
228     if ( qobject_cast<QtxTreeView*>( sipCpp ) )
229       sipType = sipType_QtxTreeView;
230     else
231       sipType = NULL;
232 %End
233
234 public:
235   explicit QtxTreeView( QWidget* /TransferThis/ = 0 );
236   QtxTreeView( const bool, QWidget* /TransferThis/ = 0  );
237   virtual ~QtxTreeView();
238
239 signals:
240   void     sortingEnabled( bool );
241   void     selectionChanged();
242
243 private:
244   QtxTreeView( const QtxTreeView& );
245 };
246
247 class UserDefinedContent : public QWidget
248 {
249 %TypeHeaderCode
250 #include <SalomePyQt.h>
251 %End
252
253 %ConvertToSubClassCode
254     if ( qobject_cast<UserDefinedContent*>( sipCpp ) )
255       sipType = sipType_UserDefinedContent;
256     else
257       sipType = NULL;
258 %End
259
260 public:
261   explicit UserDefinedContent();
262
263   virtual void store();
264   virtual void retrieve();
265 };
266
267 enum VisibilityState 
268 {
269   ShownState,
270   HiddenState,
271   UnpresentableState 
272 };
273
274 class SalomePyQt
275 {
276 %TypeHeaderCode
277 #include <SalomePyQt.h>
278 %End
279
280 public:
281   static QString           getAppName() /ReleaseGIL/ ;
282   static bool              isLightApp() /ReleaseGIL/ ;
283
284 /* KeepReference is necessary on method getDesktop with SIP >= 4.15.5 to avoid garbage collection of
285    the Python objects added to the desktop. This causes a small memory leak (the wrapper around desktop
286    object is never garbage collected) but since this object contains only references this is not
287    considered a big problem. With versions < 4.15, it seems that this reference was kept implicitly.
288    No proper solution was found for versions between 4.15 and 4.15.4 (included), so those versions
289    should not be used to compile GUI module.
290 */
291 %If (SIP_4_15_5 - )
292   static QWidget*          getDesktop() /ReleaseGIL,KeepReference/ ;
293 %End
294 %If ( - SIP_4_15_5)
295   static QWidget*          getDesktop() /ReleaseGIL/ ;
296 %End
297
298   static QWidget*          getMainFrame() /ReleaseGIL/ ;
299   static QMenuBar*         getMainMenuBar() /ReleaseGIL/ ;
300   static QMenu*            getPopupMenu( const MenuName ) /ReleaseGIL/ ;
301   static QMenu*            getPopupMenu( const QString& ) /ReleaseGIL/ ;
302   static QTreeView*        getObjectBrowser() /ReleaseGIL/ ;
303   static void              enableSelector() /ReleaseGIL/ ;
304   static void              disableSelector() /ReleaseGIL/ ;
305   static SALOME_Selection* getSelection() /Factory,ReleaseGIL/ ;
306   static void              setSelection( const QStringList& ) /ReleaseGIL/ ;
307   static QStringList       getComponents() /ReleaseGIL/ ;
308   static const QString     getActiveComponent() /ReleaseGIL/ ;
309   static SIP_PYOBJECT      getActivePythonModule() /ReleaseGIL/ ;
310   static bool              activateModule( const QString& ) /ReleaseGIL/ ;
311   static void              registerModule( const QString& ) /ReleaseGIL/ ;
312   static void              updateObjBrowser() /ReleaseGIL/ ;
313
314   static void              infoSetTitle( const QString& ) /ReleaseGIL/ ;
315   static int               infoAddLabel( const QString&, const int = -1 ) /ReleaseGIL/ ;
316   static int               infoAddLabel( const QString&, Qt::Alignment, const int = -1 ) /ReleaseGIL/ ;
317   static int               infoAddAction( QAction*, const int = -1 ) /ReleaseGIL/ ;
318   static int               infoAddGroup( const QString&, const int = -1 ) /ReleaseGIL/ ;
319
320   static void              infoRemove( const int ) /ReleaseGIL/ ;
321   static void              infoClear( const int = -1 ) /ReleaseGIL/ ;
322
323   static void              infoSetVisible( const int, bool ) /ReleaseGIL/ ;
324   static void              infoSetEnabled( const int, bool ) /ReleaseGIL/ ;
325
326   static void              putInfo( const QString&, const int = 0 ) /ReleaseGIL/ ;
327   static int               showNotification( const QString&, const QString&, const int = -1 ) /ReleaseGIL/ ;
328   static void              hideNotification( const QString& ) /ReleaseGIL/ ;
329   static void              hideNotification( const int ) /ReleaseGIL/ ;
330
331   static bool              isModified() /ReleaseGIL/ ;
332   static void              setModified( bool ) /ReleaseGIL/ ;
333
334   static QString           getFileName         ( QWidget*, const QString&, const QStringList&, const QString&, bool ) /ReleaseGIL/ ;
335   static QStringList       getOpenFileNames    ( QWidget*, const QString&, const QStringList&, const QString& ) /ReleaseGIL/ ;
336   static QString           getExistingDirectory( QWidget*, const QString&, const QString& ) /ReleaseGIL/ ;
337                          
338   static void              createRoot() /ReleaseGIL/ ;
339   static QString           createObject( const QString& = QString("") )  /ReleaseGIL/ ;
340   static QString           createObject( const QString&,
341                                          const QString&,
342                                          const QString&,
343                                          const QString& = QString("") )  /ReleaseGIL/ ;
344
345   static void              setName(const QString& ,const QString& ) /ReleaseGIL/ ;
346   static void              setIcon(const QString& ,const QString& ) /ReleaseGIL/ ;
347   static void              setToolTip(const QString& ,const QString& ) /ReleaseGIL/ ;
348   static QString           getName(const QString& ) /ReleaseGIL/ ;
349   static QString           getToolTip(const QString& ) /ReleaseGIL/ ;
350
351   static void              setVisibilityState( const QString&, VisibilityState );
352   static VisibilityState   getVisibilityState( const QString& );
353
354   static void              setObjectPosition( const QString&, int );
355   static int               getObjectPosition( const QString& );
356
357   static void              setColor( const QString&, const QColor& ) /ReleaseGIL/ ;
358   static QColor            getColor( const QString& ) /ReleaseGIL/ ;
359
360   static void              setReference( const QString& ,const QString& ) /ReleaseGIL/ ; 
361   static QString           getReference( const QString& ) /ReleaseGIL/ ;
362
363   static void              removeObject(const QString&  )    /ReleaseGIL/ ;
364   static void              removeChildren(const QString& = QString("")  ) /ReleaseGIL/ ;
365   static void              removeChild(const QString& = QString("")  ) /ReleaseGIL/ ;
366   static QStringList       getChildren(const QString&=QString("") , const bool = false) /ReleaseGIL/ ;
367
368   static QIcon             loadIcon( const QString&, const QString& ) /ReleaseGIL/ ;
369   static void              helpContext( const QString&, const QString& ) /ReleaseGIL/ ;
370
371   static bool              dumpView( const QString&, const int = 0 ) /ReleaseGIL/ ;
372
373   static int               defaultMenuGroup() /ReleaseGIL/ ;
374
375   static int               createTool( const QString&, const QString& = QString() ) /ReleaseGIL/ ;
376   static int               createTool( const int,  const int,      const int = -1 ) /ReleaseGIL/ ;
377   static int               createTool( const int,  const QString&, const int = -1 ) /ReleaseGIL/ ;
378   static int               createTool( QAction*,   const int,      const int = -1, const int = -1 ) /ReleaseGIL/ ;
379   static int               createTool( QAction*,   const QString&, const int = -1, const int = -1 ) /ReleaseGIL/ ;
380   static void              clearTool( const QString& ) /ReleaseGIL/ ;
381
382   static int               createMenu( const QString&, const int,
383                                        const int = -1, const int = -1, const int = -1 ) /ReleaseGIL/ ;
384   static int               createMenu( const QString&, const QString&, 
385                                        const int = -1, const int = -1, const int = -1 ) /ReleaseGIL/ ;
386   static int               createMenu( const int,      const int,
387                                        const int = -1, const int = -1 ) /ReleaseGIL/ ;
388   static int               createMenu( const int,      const QString&, 
389                                        const int = -1, const int = -1 ) /ReleaseGIL/ ;
390   static int               createMenu( QAction*,       const int,      const int = -1, 
391                                        const int = -1, const int = -1 ) /ReleaseGIL/ ;
392   static int               createMenu( QAction*,       const QString&, const int = -1, 
393                                        const int = -1, const int = -1 ) /ReleaseGIL/ ;
394   static QAction*          createSeparator() /ReleaseGIL/ ;
395
396   static QAction*          createAction( const int, const QString&, 
397                                          const QString& = QString(), const QString& = QString(), 
398                                          const QString& = QString(), const int = 0, const bool = false ) /ReleaseGIL/ ;
399
400   static QtxActionGroup*   createActionGroup( const int, const bool = true ) /ReleaseGIL/ ;
401
402   static QAction*          action( const int ) /ReleaseGIL/ ;
403   static int               actionId( const QAction* ) /ReleaseGIL/ ;
404
405   static QString           constant      ( const QString& ) /ReleaseGIL/ ;
406   static void              setConstant   ( const QString&, const QString& ) /ReleaseGIL/ ;
407   static void              addSetting    ( const QString&, const QString&, const double ) /ReleaseGIL/ ;
408   static void              addSetting    ( const QString&, const QString&, const int /Constrained/ ) /ReleaseGIL/ ;
409   static void              addSetting    ( const QString&, const QString&, const bool, const int ) /ReleaseGIL/ ;
410   static void              addSetting    ( const QString&, const QString&, const QString& ) /ReleaseGIL/ ;
411   static void              addSetting    ( const QString&, const QString&, const QColor& ) /ReleaseGIL/ ;
412   static void              addSetting    ( const QString&, const QString&, const QByteArray& ) /ReleaseGIL/ ;
413   static void              addSetting    ( const QString&, const QString&, const QFont& ) /ReleaseGIL/ ;
414   static int               integerSetting( const QString&, const QString&, const int = 0 ) /ReleaseGIL/ ;
415   static double            doubleSetting ( const QString&, const QString&, const double = 0 ) /ReleaseGIL/ ;
416   static bool              boolSetting   ( const QString&, const QString&, const bool = false ) /ReleaseGIL/ ;
417   static QString           stringSetting ( const QString&, const QString&, const QString& = QString(""), const bool = true ) /ReleaseGIL/ ;
418   static QColor            colorSetting  ( const QString&, const QString&, const QColor& = QColor() ) /ReleaseGIL/ ;
419   static QByteArray        byteArraySetting( const QString&, const QString&, const QByteArray& = QByteArray() ) /ReleaseGIL/ ;
420   static QFont             fontSetting( const QString&, const QString&, const QFont& = QFont() ) /ReleaseGIL/ ;
421   static void              removeSetting ( const QString&, const QString& ) /ReleaseGIL/ ;
422   static bool              hasSetting    ( const QString&, const QString& ) /ReleaseGIL/ ;
423   static QStringList       parameters    ( const QString& ) /ReleaseGIL/ ;
424   static QStringList       parameters    ( const QStringList& ) /ReleaseGIL/ ;
425
426 // obsolete
427   static void              addStringSetting( const QString&, const QString&, bool = true ) /ReleaseGIL/ ;
428   static void              addIntSetting   ( const QString&, const int,      bool = true ) /ReleaseGIL/ ;
429   static void              addDoubleSetting( const QString&, const double,   bool = true ) /ReleaseGIL/ ;
430   static void              addBoolSetting  ( const QString&, const bool,     bool = true ) /ReleaseGIL/ ;
431   static void              removeSettings  ( const QString& ) /ReleaseGIL/ ;
432   static QString           getSetting      ( const QString& ) /ReleaseGIL/ ;
433
434   static int               addGlobalPreference( const QString& ) /ReleaseGIL/ ;
435   static int               addPreference( const QString& ) /ReleaseGIL/ ;
436   static int               addPreference( const QString&,
437                                           const int, const int = PT_Auto,
438                                           const QString& = QString(),
439                                           const QString& = QString() ) /ReleaseGIL/ ;
440   static QVariant          preferenceProperty( const int, const QString& ) /ReleaseGIL/ ;
441   static void              setPreferenceProperty( const int, 
442                                                   const QString&,
443                                                   const QVariant& ) /ReleaseGIL/ ;
444   static void              setPreferencePropertyWg( const int, 
445                                                     const QString&,     
446                                                     UserDefinedContent* ) /ReleaseGIL/ ;
447   static void              addPreferenceProperty( const int, 
448                                                   const QString&, 
449                                                   const int, 
450                                                   const QVariant& ) /ReleaseGIL/ ;
451
452   static void              message( const QString&, bool = true ) /ReleaseGIL/ ;
453   static void              clearMessages() /ReleaseGIL/ ;
454   
455   static QList<int>        getViews() /ReleaseGIL/ ;
456   static int               getActiveView() /ReleaseGIL/ ;
457   static QString           getViewType( const int ) /ReleaseGIL/ ;
458   static bool              setViewTitle( const int, const QString& ) /ReleaseGIL/ ;
459   static QString           getViewTitle( const int ) /ReleaseGIL/ ;
460   static bool              setViewSize( const int, const int, const int = 0 ) /ReleaseGIL/ ;
461   static bool              setViewRotationPoint( const double, const double, const double, const int = 0 ) /ReleaseGIL/ ;
462   static QList<int>        findViews( const QString& ) /ReleaseGIL/ ;
463   static bool              activateView( const int ) /ReleaseGIL/ ;
464   static bool              activateViewManagerAndView( const int ) /ReleaseGIL/ ;
465   static QWidget*          getViewWidget( const int ) /ReleaseGIL/ ;
466   static int               createView( const QString&, bool visible = true, const int width = 0, const int height = 0, bool detached = false ) /ReleaseGIL/ ;
467   static int               createView( const QString&, QWidget* ) /ReleaseGIL/ ;
468   static bool              closeView( const int ) /ReleaseGIL/ ;
469   static int               cloneView( const int ) /ReleaseGIL/ ;
470   static void              setViewVisible( const int id, bool visible = true ) /ReleaseGIL/ ;
471   static bool              isViewVisible( const int id ) /ReleaseGIL/ ;
472   static void              setViewClosable( const int id, const bool ) /ReleaseGIL/ ;
473   static bool              isViewClosable( const int id ) /ReleaseGIL/ ;
474   
475   static bool              groupAllViews() /ReleaseGIL/ ;
476   static bool              splitView( const int, Orientation, Action ) /ReleaseGIL/ ;
477   static bool              moveView( const int, const int, const bool ) /ReleaseGIL/ ;
478   static QList<int>        neighbourViews( const int ) /ReleaseGIL/ ;
479   
480 %If (ENABLE_PLOT2D)
481 // start Plot2d-related functionality
482   static void              displayCurve(const int, Plot2d_Curve*) /ReleaseGIL/ ;
483   static void              eraseCurve(const int, Plot2d_Curve*) /ReleaseGIL/ ;
484   static void              eraseCurve(Plot2d_Curve*) /ReleaseGIL/ ;
485   static void              updateCurves( const int ) /ReleaseGIL/ ;
486   static QString           getPlot2dTitle(const int, ObjectType = MainTitle) /ReleaseGIL/ ;
487   static void              setPlot2dTitle(const int, const QString&, ObjectType = MainTitle, bool = true) /ReleaseGIL/ ;
488   static QList<double>     getPlot2dFitRangeByCurves(const int) /ReleaseGIL/ ;
489   static QList<double>     getPlot2dFitRangeCurrent(const int) /ReleaseGIL/ ;
490   static void              setPlot2dFitRange(const int, const double XMin, const double XMax, const double YMin, const double YMax ) /ReleaseGIL/ ;
491 // end of Plot2d-related functionality
492 %End
493
494   static void              processEvents();
495
496   static void              startPyLog(const QString&) /ReleaseGIL/ ;
497   static void              stopPyLog() /ReleaseGIL/ ;
498
499   static void              logUserEvent( const QString& ) /ReleaseGIL/ ;
500   static void              logAction( QAction*, const QString& = QString() ) /ReleaseGIL/ ;
501 };