Salome HOME
Merge remote-tracking branch 'origin/master' into V8_5_BR
[modules/smesh.git] / src / SMESHGUI / SMESHGUI.h
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
23 // SMESH SMESHGUI : GUI for SMESH component
24 // File   : SMESHGUI.h
25 // Author : Nicolas REJNERI, Open CASCADE S.A.S.
26 //
27 #ifndef SMESHGUI_H
28 #define SMESHGUI_H
29
30 // SMESH includes
31 #include "SMESH_SMESHGUI.hxx"
32
33 // SALOME GUI includes
34 #include <SalomeApp_Module.h>
35 #include <VTKViewer_MarkerDef.h>
36 #include <SALOME_InteractiveObject.hxx>
37
38 // IDL includes
39 #include <SALOMEconfig.h>
40 #include CORBA_SERVER_HEADER(SMESH_Gen)
41
42 // VTK includes
43 #include <vtkSmartPointer.h>
44 #include <vtkType.h>
45
46 class vtkActor;
47 class vtkCallbackCommand;
48 class vtkObject;
49
50 class QDialog;
51
52 class SUIT_Desktop;
53 class SUIT_Study;
54 class SUIT_ViewWindow;
55 class SUIT_ResourceMgr;
56 class SUIT_ViewManager;
57
58 class LightApp_Operation;
59 class SalomeApp_Study;
60 class LightApp_Selection;
61 class LightApp_SelectionMgr;
62
63 class SMESH_Actor;
64 class SMESHGUI_FilterLibraryDlg;
65
66 typedef std::map<int, VTK::MarkerMap> SMESHGUI_StudyId2MarkerMap;
67
68 namespace SMESH
69 {
70   class OrientedPlane;
71   struct ClippingPlaneInfo
72   {
73     OrientedPlane*       Plane;
74     std::list<vtkActor*> ActorList;
75   };
76 }
77
78 typedef std::list<SMESH::ClippingPlaneInfo>                         SMESHGUI_ClippingPlaneInfoList;
79 typedef std::map<SUIT_ViewManager*, SMESHGUI_ClippingPlaneInfoList> SMESHGUI_ClippingPlaneInfoMap;
80
81 //=================================================================================
82 // class    : SMESHGUI
83 // purpose  :
84 //=================================================================================
85 class SMESHGUI_EXPORT SMESHGUI : public SalomeApp_Module
86 {
87   Q_OBJECT
88
89 public :
90   SMESHGUI();
91   ~SMESHGUI();
92
93   static SMESH::SMESH_Gen_var     GetSMESHGen();
94   static SMESHGUI*                GetSMESHGUI();
95   static LightApp_SelectionMgr*   selectionMgr();
96   static SUIT_ResourceMgr*        resourceMgr();
97   static SUIT_Desktop*            desktop();
98   static SalomeApp_Study*         activeStudy();
99   
100   bool                            isActiveStudyLocked();
101
102   static bool                     automaticUpdate(unsigned int requestedSize = 0, bool* limitExceeded = 0);
103   static bool                     automaticUpdate( SMESH::SMESH_IDSource_ptr, int*, bool*, int*, long* );
104
105   static void                     Modified( bool = true );
106
107   virtual LightApp_Displayer*     displayer();
108   virtual QString                 engineIOR() const;
109   virtual void                    initialize( CAM_Application* );
110   virtual void                    windows( QMap<int, int>& ) const;
111   virtual void                    viewManagers( QStringList& ) const;
112
113   QDialog*                        GetActiveDialogBox();
114   void                            SetActiveDialogBox( QDialog* );
115
116   void                            ResetState();
117   void                            SetState( int );
118   int                             GetState() const { return myState; }
119   bool                            DefineDlgPosition( QWidget*, int&, int& );
120   void                            switchToOperation( int );
121
122   virtual bool                    OnGUIEvent( int );
123   virtual bool                    OnMousePress( QMouseEvent*, SUIT_ViewWindow* );
124   virtual bool                    OnMouseMove( QMouseEvent*, SUIT_ViewWindow* );
125   virtual bool                    OnKeyPress( QKeyEvent*, SUIT_ViewWindow* );
126
127   virtual LightApp_Selection*     createSelection() const;
128
129   virtual void                    BuildPresentation ( const Handle(SALOME_InteractiveObject)&,
130                                                       SUIT_ViewWindow* = 0 );
131
132   /* Non modal dialog boxes management */
133   void                            EmitSignalDeactivateDialog();
134   void                            EmitSignalStudyFrameChanged();
135   void                            EmitSignalCloseAllDialogs();
136   void                            EmitSignalVisibilityChanged();
137   void                            EmitSignalCloseView();
138   void                            EmitSignalActivatedViewManager();
139
140   virtual void                    contextMenuPopup( const QString&, QMenu*, QString& );
141   virtual void                    createPreferences();
142   virtual void                    preferencesChanged( const QString&, const QString& );
143
144   virtual void                    message( const QString& );
145
146   virtual void                    update( const int );
147
148   static SALOMEDS::Color          getUniqueColor( const QList<SALOMEDS::Color>& );
149   static SALOMEDS::Color          getPredefinedUniqueColor();
150
151   virtual void                    storeVisualParameters  (int savePoint);
152   virtual void                    restoreVisualParameters(int savePoint);
153
154   virtual void                    addActorAsObserver( SMESH_Actor* theActor );
155   
156   virtual bool                    renameAllowed( const QString& ) const;
157   virtual bool                    renameObject( const QString&, const QString& );
158
159
160   SMESHGUI_ClippingPlaneInfoMap&  getClippingPlaneInfoMap() { return myClippingPlaneInfoMap; }
161
162 public slots:
163   virtual bool                    deactivateModule( SUIT_Study* );
164   virtual bool                    activateModule( SUIT_Study* );
165   virtual void                    studyClosed( SUIT_Study* );
166   void                            onViewClosed( SUIT_ViewWindow* );
167
168 private slots:
169   void                            OnGUIEvent();
170   void                            onViewManagerActivated( SUIT_ViewManager* );
171   void                            onViewManagerRemoved( SUIT_ViewManager* );
172   void                            onOperationCommited( SUIT_Operation* );
173   void                            onOperationAborted( SUIT_Operation* );
174   void                            onHypothesisEdit( int result );
175   void                            onUpdateControlActions();
176
177 signals:
178   void                            SignalDeactivateActiveDialog();
179   void                            SignalStudyFrameChanged();
180   void                            SignalCloseAllDialogs();
181   void                            SignalVisibilityChanged();
182   void                            SignalCloseView();
183   void                            SignalActivatedViewManager();
184
185 protected:
186   void                            createSMESHAction( const int,
187                                                      const QString&,
188                                                      const QString& = QString(),
189                                                      const int = 0,
190                                                      const bool = false,
191                                                      const QString& = QString() );
192   void                            createPopupItem( const int,
193                                                    const QString&,
194                                                    const QString&,
195                                                    const QString& = QString(),
196                                                    const int = -1 );
197
198   virtual LightApp_Operation*     createOperation( const int ) const;
199
200   virtual bool                    isSelectionCompatible();
201
202   virtual bool                    reusableOperation( const int id ); 
203
204   static void                     ProcessEvents( vtkObject* theObject, 
205                                                  unsigned long theEvent,
206                                                  void* theClientData, 
207                                                  void* theCallData );
208
209 private:
210   void                            OnEditDelete();
211   int                             addVtkFontPref( const QString&, 
212                                                   const int, 
213                                                   const QString&,
214                                                   const bool = false);
215
216   void                            connectView( const SUIT_ViewWindow* );
217  
218
219 private :
220   static SMESH::SMESH_Gen_var     myComponentSMESH;
221   QDialog*                        myActiveDialogBox;
222   int                             myState;
223   QMap<int, QString>              myRules;
224   LightApp_Displayer*             myDisplayer;
225
226   SMESHGUI_FilterLibraryDlg*      myFilterLibraryDlg;
227
228   SMESHGUI_StudyId2MarkerMap      myMarkerMap;
229   SMESHGUI_ClippingPlaneInfoMap   myClippingPlaneInfoMap;
230
231   vtkSmartPointer<vtkCallbackCommand> myEventCallbackCommand;
232   double            myPriority;
233 };
234
235 #endif // SMESHGUI_H