Salome HOME
Merge from V5_1_main branch 24/11/2010
[modules/smesh.git] / src / SMESHGUI / SMESHGUI.h
1 //  Copyright (C) 2007-2010  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
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
104   static void                     Modified( bool = true );
105
106   virtual LightApp_Displayer*     displayer();
107   virtual QString                 engineIOR() const;
108   virtual void                    initialize( CAM_Application* );
109   virtual void                    windows( QMap<int, int>& ) const;
110   virtual void                    viewManagers( QStringList& ) const;
111
112   QDialog*                        GetActiveDialogBox();
113   void                            SetActiveDialogBox( QDialog* );
114
115   void                            ResetState();
116   void                            SetState( int );
117   bool                            DefineDlgPosition( QWidget*, int&, int& );
118   void                            switchToOperation( int );
119
120   virtual bool                    OnGUIEvent( int );
121   virtual bool                    OnMousePress( QMouseEvent*, SUIT_ViewWindow* );
122   virtual bool                    OnMouseMove( QMouseEvent*, SUIT_ViewWindow* );
123   virtual bool                    OnKeyPress( QKeyEvent*, SUIT_ViewWindow* );
124
125   virtual LightApp_Selection*     createSelection() const;
126
127   virtual void                    BuildPresentation ( const Handle(SALOME_InteractiveObject)&,
128                                                       SUIT_ViewWindow* = 0 );
129
130   /* Non modal dialog boxes management */
131   void                            EmitSignalDeactivateDialog();
132   void                            EmitSignalStudyFrameChanged();
133   void                            EmitSignalCloseAllDialogs();
134   void                            EmitSignalVisibilityChanged();
135
136   virtual void                    contextMenuPopup( const QString&, QMenu*, QString& );
137   virtual void                    createPreferences();
138   virtual void                    preferencesChanged( const QString&, const QString& );
139
140   virtual void                    update( const int );
141
142   static SALOMEDS::Color          getUniqueColor( const QList<SALOMEDS::Color>& );
143
144   virtual void                    storeVisualParameters  (int savePoint);
145   virtual void                    restoreVisualParameters(int savePoint);
146
147   virtual void                    addActorAsObserver( SMESH_Actor* theActor );
148
149   SMESHGUI_ClippingPlaneInfoMap&  getClippingPlaneInfoMap() { return myClippingPlaneInfoMap; }
150
151 public slots:
152   virtual bool                    deactivateModule( SUIT_Study* );
153   virtual bool                    activateModule( SUIT_Study* );
154   virtual void                    studyClosed( SUIT_Study* );
155
156 private slots:
157   void                            OnGUIEvent();
158   void                            onViewManagerActivated( SUIT_ViewManager* );
159   void                            onViewManagerRemoved( SUIT_ViewManager* );
160   void                            onOperationCommited( SUIT_Operation* );
161   void                            onOperationAborted( SUIT_Operation* );
162   void                            onHypothesisEdit( int result );
163
164 signals:
165   void                            SignalDeactivateActiveDialog();
166   void                            SignalStudyFrameChanged();
167   void                            SignalCloseAllDialogs();
168   void                            SignalVisibilityChanged();
169
170 protected:
171   void                            createSMESHAction( const int,
172                                                      const QString&,
173                                                      const QString& = QString(),
174                                                      const int = 0,
175                                                      const bool = false,
176                                                      const QString& = QString() );
177   void                            createPopupItem( const int,
178                                                    const QString&,
179                                                    const QString&,
180                                                    const QString& = QString(),
181                                                    const int = -1 );
182
183   virtual LightApp_Operation*     createOperation( const int ) const;
184
185   virtual bool                    isSelectionCompatible();
186
187   virtual bool                    reusableOperation( const int id ); 
188
189   static void                     ProcessEvents( vtkObject* theObject, 
190                                                  unsigned long theEvent,
191                                                  void* theClientData, 
192                                                  void* theCallData );
193
194 private:
195   void                            OnEditDelete();
196   int                             addVtkFontPref( const QString& label, 
197                                                   const int pId, 
198                                                   const QString& param );
199
200 private :
201   static SMESH::SMESH_Gen_var     myComponentSMESH;
202   QDialog*                        myActiveDialogBox;
203   int                             myState;
204   QMap<int, QString>              myRules;
205   LightApp_Displayer*             myDisplayer;
206
207   SMESHGUI_FilterLibraryDlg*      myFilterLibraryDlg;
208
209   SMESHGUI_StudyId2MarkerMap      myMarkerMap;
210   SMESHGUI_ClippingPlaneInfoMap   myClippingPlaneInfoMap;
211
212   vtkSmartPointer<vtkCallbackCommand> myEventCallbackCommand;
213   vtkFloatingPointType            myPriority;
214 };
215
216 #endif // SMESHGUI_H