]> SALOME platform Git repositories - modules/gui.git/blob - src/SALOME_PYQT/SalomePyQt/SalomePyQt.h
Salome HOME
2643b2112578b040bc52c8992b3b4c9742bad814
[modules/gui.git] / src / SALOME_PYQT / SalomePyQt / SalomePyQt.h
1 //  Copyright (C) 2007-2008  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.h
23 // Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
24 //
25 #ifndef SALOME_PYQT_H
26 #define SALOME_PYQT_H
27
28 #include <QObject>
29 #include <QString>
30 #include <QColor>
31
32 #include <LightApp_Application.h>
33 #include <LightApp_Preferences.h>
34
35 class LightApp_SelectionMgr;
36 class SalomeApp_Application;
37 class QMenuBar;
38 class QMenu;
39 class QWidget;
40 class QAction;
41 class QtxActionGroup;
42
43 class SALOME_Selection : public QObject
44 {
45   Q_OBJECT
46
47 public:
48   ~SALOME_Selection();
49   static SALOME_Selection* GetSelection( SalomeApp_Application* );
50
51   void Clear();
52   void ClearIObjects();
53   void ClearFilters();
54
55 signals:
56   void currentSelectionChanged();
57
58 private slots:
59   void onSelMgrDestroyed();
60
61 private:
62   LightApp_SelectionMgr* mySelMgr;
63   SALOME_Selection( QObject* );
64 };
65
66 enum MenuName {
67   File        = 1,
68   View        = 2,
69   Edit        = 3,
70   Preferences = 4,
71   Tools       = 5,
72   Window      = 6,
73   Help        = 7  
74 };
75
76 enum {
77   WT_ObjectBrowser = LightApp_Application::WT_ObjectBrowser,
78   WT_PyConsole     = LightApp_Application::WT_PyConsole,
79   WT_LogWindow     = LightApp_Application::WT_LogWindow,
80   WT_User          = LightApp_Application::WT_User
81 };
82
83 enum { 
84   PT_Auto     = LightApp_Preferences::Auto,
85   PT_Space    = LightApp_Preferences::Space,
86   PT_Bool     = LightApp_Preferences::Bool, 
87   PT_Color    = LightApp_Preferences::Color,
88   PT_String   = LightApp_Preferences::String, 
89   PT_Selector = LightApp_Preferences::Selector, 
90   PT_DblSpin  = LightApp_Preferences::DblSpin, 
91   PT_IntSpin  = LightApp_Preferences::IntSpin, 
92   PT_Double   = LightApp_Preferences::Double, 
93   PT_Integer  = LightApp_Preferences::Integer, 
94   PT_GroupBox = LightApp_Preferences::GroupBox, 
95   PT_Tab      = LightApp_Preferences::Tab, 
96   PT_Frame    = LightApp_Preferences::Frame, 
97   PT_Font     = LightApp_Preferences::Font, 
98   PT_DirList  = LightApp_Preferences::DirList, 
99   PT_File     = LightApp_Preferences::File, 
100 };
101
102 //! Orientation
103 enum Orientation {
104   Horizontal = 0, //!< Horizontal orientation 
105   Vertical   = 1  //!< Vertical orientation
106 };
107
108 //! Action of splitting corresponding to QtxWorkstack::SplitType enumeration
109 enum Action {
110   MoveWidget   = 0, //!< move specified widget to the new area, other views stay in the previous area
111   LeaveWidget  = 1, //!< specified widget stays in the old area, all other views are moved to the new area
112   SplitAt      = 2  //!< the view area is splitted in such a way, that specified view and all views which follow it, are moved to the new area
113 };
114
115 class SalomePyQt
116 {
117 public:
118   static QWidget*          getDesktop();
119   static QWidget*          getMainFrame();
120   static QMenuBar*         getMainMenuBar();
121   static QMenu*            getPopupMenu( const MenuName );
122   static QMenu*            getPopupMenu( const QString& );
123   static SALOME_Selection* getSelection();
124   static int               getStudyId();
125   static void              putInfo( const QString&, const int = 0 );
126   static const QString     getActiveComponent();
127   static void              updateObjBrowser( const int = 0, bool = true );
128
129   static QString           getFileName         ( QWidget*, const QString&, const QStringList&, const QString&, bool );
130   static QStringList       getOpenFileNames    ( QWidget*, const QString&, const QStringList&, const QString& );
131   static QString           getExistingDirectory( QWidget*, const QString&, const QString& );
132
133   static void              helpContext( const QString&, const QString& );
134
135   static bool              dumpView( const QString& );
136
137   static int               defaultMenuGroup();
138
139   static int               createTool( const QString& );
140   static int               createTool( const int,  const int,      const int = -1 );
141   static int               createTool( const int,  const QString&, const int = -1 );
142   static int               createTool( QAction*, const int,      const int = -1, const int = -1 );
143   static int               createTool( QAction*, const QString&, const int = -1, const int = -1 );
144
145   static int               createMenu( const QString&, const int = -1,
146                                        const int = -1, const int = -1, const int = -1 );
147   static int               createMenu( const QString&, const QString& = QString(), 
148                                        const int = -1, const int = -1, const int = -1 );
149   static int               createMenu( const int,      const int = -1,
150                                        const int = -1, const int = -1 );
151   static int               createMenu( const int,      const QString& = QString(), 
152                                        const int = -1, const int = -1 );
153   static int               createMenu( QAction*,     const int,      const int = -1, 
154                                        const int = -1, const int = -1 );
155   static int               createMenu( QAction*,     const QString&, const int = -1, 
156                                        const int = -1, const int = -1 );
157
158   static QAction*          createSeparator();
159
160   static QAction*          createAction( const int, const QString&,
161                                          const QString& = QString(), const QString& = QString(), 
162                                          const QString& = QString(), const int = 0, const bool = false );
163   
164   static QtxActionGroup*   createActionGroup( const int, const bool = true );
165
166   static QAction*          action( const int );
167   static int               actionId( const QAction* );
168
169   static void              addSetting    ( const QString&, const QString&, const double );
170   static void              addSetting    ( const QString&, const QString&, const int );
171   static void              addSetting    ( const QString&, const QString&, const bool, const int );
172   static void              addSetting    ( const QString&, const QString&, const QString& );
173   static void              addSetting    ( const QString&, const QString&, const QColor& );
174   static int               integerSetting( const QString&, const QString&, const int = 0 );
175   static double            doubleSetting ( const QString&, const QString&, const double = 0 );
176   static bool              boolSetting   ( const QString&, const QString&, const bool = 0 );
177   static QString           stringSetting ( const QString&, const QString&, const QString& = QString("") );
178   static QColor            colorSetting  ( const QString&, const QString&, const QColor& = QColor() );
179   static void              removeSetting ( const QString&, const QString& );
180   static bool              hasSetting    ( const QString&, const QString& );
181   // obsolete
182   static void              addStringSetting( const QString&, const QString&, bool = true );
183   static void              addIntSetting   ( const QString&, const int,      bool = true );
184   static void              addBoolSetting  ( const QString&, const bool,     bool = true );
185   static void              addDoubleSetting( const QString&, const double,   bool = true );
186   static void              removeSettings  ( const QString& );
187   static QString           getSetting      ( const QString& );
188
189   static int               addGlobalPreference( const QString& );
190   static int               addPreference( const QString& );
191   static int               addPreference( const QString&,
192                                           const int, const int = PT_Auto,
193                                           const QString& = QString(),
194                                           const QString& = QString() );
195   static QVariant          preferenceProperty( const int, const QString& );
196   static void              setPreferenceProperty( const int, 
197                                                   const QString&,
198                                                   const QVariant& );
199   static void              addPreferenceProperty( const int,
200                                                   const QString&,
201                                                   const int,
202                                                   const QVariant& );
203
204   static void              message( const QString&, bool = true );
205   static void              clearMessages();
206   
207   static QList<int>        getViews();
208   static int               getActiveView();
209   static QString           getViewType( const int );
210   static bool              setViewTitle( const int, const QString& );
211   static QString           getViewTitle( const int );
212   static QList<int>        findViews( const QString& );
213   static bool              activateView( const int );
214   static int               createView( const QString& );
215   static bool              closeView( const int );
216   static int               cloneView( const int );
217   static bool              isViewVisible( const int id );
218   
219   static bool              groupAllViews();
220   static bool              splitView( const int, const Orientation, const Action );
221   static bool              moveView( const int, const int, const bool );
222   static QList<int>        neighbourViews( const int );
223 };
224
225 #endif // SALOME_PYQT_H