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