Salome HOME
Merge from V5_1_main 10/06/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 class QDialog;
43
44 class SUIT_Desktop;
45 class SUIT_Study;
46 class SUIT_ViewWindow;
47 class SUIT_ResourceMgr;
48 class SUIT_ViewManager;
49
50 class LightApp_Operation;
51 class SalomeApp_Study;
52 class LightApp_Selection;
53 class LightApp_SelectionMgr;
54
55 class SMESHGUI_FilterLibraryDlg;
56
57 typedef std::map<int, VTK::MarkerMap> SMESHGUI_StudyId2MarkerMap;
58
59 //=================================================================================
60 // class    : SMESHGUI
61 // purpose  :
62 //=================================================================================
63 class SMESHGUI_EXPORT SMESHGUI : public SalomeApp_Module
64 {
65   Q_OBJECT;
66
67 public :
68   SMESHGUI();
69   ~SMESHGUI();
70
71   static SMESH::SMESH_Gen_var     GetSMESHGen();
72   static SMESHGUI*                GetSMESHGUI();
73   static LightApp_SelectionMgr*   selectionMgr();
74   static SUIT_ResourceMgr*        resourceMgr();
75   static SUIT_Desktop*            desktop();
76   static SalomeApp_Study*         activeStudy();
77   
78   bool                            isActiveStudyLocked();
79
80   static bool                     automaticUpdate();
81
82   static void                     Modified( bool = true );
83
84   virtual LightApp_Displayer*     displayer();
85   virtual QString                 engineIOR() const;
86   virtual void                    initialize( CAM_Application* );
87   virtual void                    windows( QMap<int, int>& ) const;
88   virtual void                    viewManagers( QStringList& ) const;
89
90   QDialog*                        GetActiveDialogBox();
91   void                            SetActiveDialogBox( QDialog* );
92
93   void                            ResetState();
94   void                            SetState( int );
95   bool                            DefineDlgPosition( QWidget*, int&, int& );
96   void                            switchToOperation( int );
97
98   virtual bool                    OnGUIEvent( int );
99   virtual bool                    OnMousePress( QMouseEvent*, SUIT_ViewWindow* );
100   virtual bool                    OnMouseMove( QMouseEvent*, SUIT_ViewWindow* );
101   virtual bool                    OnKeyPress( QKeyEvent*, SUIT_ViewWindow* );
102
103   virtual LightApp_Selection*     createSelection() const;
104
105   virtual void                    BuildPresentation ( const Handle(SALOME_InteractiveObject)&,
106                                                       SUIT_ViewWindow* = 0 );
107
108   /* Non modal dialog boxes management */
109   void                            EmitSignalDeactivateDialog();
110   void                            EmitSignalStudyFrameChanged();
111   void                            EmitSignalCloseAllDialogs();
112   void                            EmitSignalVisibilityChanged();
113
114   virtual void                    contextMenuPopup( const QString&, QMenu*, QString& );
115   virtual void                    createPreferences();
116   virtual void                    preferencesChanged( const QString&, const QString& );
117
118   virtual void                    update( const int );
119
120   static SALOMEDS::Color          getUniqueColor( const QList<SALOMEDS::Color>& );
121
122   virtual void                    storeVisualParameters  (int savePoint);
123   virtual void                    restoreVisualParameters(int savePoint);
124
125 public slots:
126   virtual bool                    deactivateModule( SUIT_Study* );
127   virtual bool                    activateModule( SUIT_Study* );
128   virtual void                    studyClosed( SUIT_Study* );
129
130 private slots:
131   void                            OnGUIEvent();
132   void                            onViewManagerActivated( SUIT_ViewManager* );
133   void                            onOperationCommited( SUIT_Operation* );
134   void                            onOperationAborted( SUIT_Operation* );
135   void                            onHypothesisEdit( int result );
136
137 signals:
138   void                            SignalDeactivateActiveDialog();
139   void                            SignalStudyFrameChanged();
140   void                            SignalCloseAllDialogs();
141   void                            SignalVisibilityChanged();
142
143 protected:
144   void                            createSMESHAction( const int,
145                                                      const QString&,
146                                                      const QString& = QString(),
147                                                      const int = 0,
148                                                      const bool = false );
149   void                            createPopupItem( const int,
150                                                    const QString&,
151                                                    const QString&,
152                                                    const QString& = QString(),
153                                                    const int = -1 );
154
155   virtual LightApp_Operation*     createOperation( const int ) const;
156
157   virtual bool                    isSelectionCompatible();
158
159   virtual bool                    reusableOperation( const int id ); 
160
161 private:
162   void                            OnEditDelete();
163   int                             addVtkFontPref( const QString& label, 
164                                                   const int pId, 
165                                                   const QString& param );
166
167 private :
168   static SMESH::SMESH_Gen_var     myComponentSMESH;
169   QDialog*                        myActiveDialogBox;
170   int                             myState;
171   QMap<int, QString>              myRules;
172   LightApp_Displayer*             myDisplayer;
173
174   SMESHGUI_FilterLibraryDlg*      myFilterLibraryDlg;
175
176   SMESHGUI_StudyId2MarkerMap      myMarkerMap;
177 };
178
179 #endif // SMESHGUI_H