1 // Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // SMESH SMESHGUI : GUI for SMESH component
25 // Author : Nicolas REJNERI, Open CASCADE S.A.S.
31 #include "SMESH_SMESHGUI.hxx"
33 // SALOME GUI includes
34 #include <SalomeApp_Module.h>
35 #include <VTKViewer_MarkerDef.h>
36 #include <SALOME_InteractiveObject.hxx>
39 #include <SALOMEconfig.h>
40 #include CORBA_SERVER_HEADER(SMESH_Gen)
43 #include <vtkSmartPointer.h>
47 class vtkCallbackCommand;
54 class SUIT_ViewWindow;
55 class SUIT_ResourceMgr;
56 class SUIT_ViewManager;
58 class LightApp_Operation;
59 class SalomeApp_Study;
60 class LightApp_Selection;
61 class LightApp_SelectionMgr;
64 class SMESHGUI_FilterLibraryDlg;
66 typedef std::map<int, VTK::MarkerMap> SMESHGUI_StudyId2MarkerMap;
71 struct ClippingPlaneInfo
74 std::list<vtkActor*> ActorList;
78 typedef std::list<SMESH::ClippingPlaneInfo> SMESHGUI_ClippingPlaneInfoList;
79 typedef std::map<SUIT_ViewManager*, SMESHGUI_ClippingPlaneInfoList> SMESHGUI_ClippingPlaneInfoMap;
81 //=================================================================================
84 //=================================================================================
85 class SMESHGUI_EXPORT SMESHGUI : public SalomeApp_Module
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();
100 bool isActiveStudyLocked();
102 static bool automaticUpdate(unsigned int requestedSize = 0, bool* limitExceeded = 0);
103 static bool automaticUpdate( SMESH::SMESH_Mesh_ptr, int*, bool*, int* );
105 static void Modified( bool = true );
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;
113 QDialog* GetActiveDialogBox();
114 void SetActiveDialogBox( QDialog* );
117 void SetState( int );
118 bool DefineDlgPosition( QWidget*, int&, int& );
119 void switchToOperation( int );
121 virtual bool OnGUIEvent( int );
122 virtual bool OnMousePress( QMouseEvent*, SUIT_ViewWindow* );
123 virtual bool OnMouseMove( QMouseEvent*, SUIT_ViewWindow* );
124 virtual bool OnKeyPress( QKeyEvent*, SUIT_ViewWindow* );
126 virtual LightApp_Selection* createSelection() const;
128 virtual void BuildPresentation ( const Handle(SALOME_InteractiveObject)&,
129 SUIT_ViewWindow* = 0 );
131 /* Non modal dialog boxes management */
132 void EmitSignalDeactivateDialog();
133 void EmitSignalStudyFrameChanged();
134 void EmitSignalCloseAllDialogs();
135 void EmitSignalVisibilityChanged();
137 virtual void contextMenuPopup( const QString&, QMenu*, QString& );
138 virtual void createPreferences();
139 virtual void preferencesChanged( const QString&, const QString& );
141 virtual void message( const QString& );
143 virtual void update( const int );
145 static SALOMEDS::Color getUniqueColor( const QList<SALOMEDS::Color>& );
146 static SALOMEDS::Color getPredefinedUniqueColor();
148 virtual void storeVisualParameters (int savePoint);
149 virtual void restoreVisualParameters(int savePoint);
151 virtual void addActorAsObserver( SMESH_Actor* theActor );
153 virtual bool renameAllowed( const QString& ) const;
154 virtual bool renameObject( const QString&, const QString& );
157 SMESHGUI_ClippingPlaneInfoMap& getClippingPlaneInfoMap() { return myClippingPlaneInfoMap; }
160 virtual bool deactivateModule( SUIT_Study* );
161 virtual bool activateModule( SUIT_Study* );
162 virtual void studyClosed( SUIT_Study* );
163 void onViewClosed( SUIT_ViewWindow* );
167 void onViewManagerActivated( SUIT_ViewManager* );
168 void onViewManagerRemoved( SUIT_ViewManager* );
169 void onOperationCommited( SUIT_Operation* );
170 void onOperationAborted( SUIT_Operation* );
171 void onHypothesisEdit( int result );
174 void SignalDeactivateActiveDialog();
175 void SignalStudyFrameChanged();
176 void SignalCloseAllDialogs();
177 void SignalVisibilityChanged();
180 void createSMESHAction( const int,
182 const QString& = QString(),
185 const QString& = QString() );
186 void createPopupItem( const int,
189 const QString& = QString(),
192 virtual LightApp_Operation* createOperation( const int ) const;
194 virtual bool isSelectionCompatible();
196 virtual bool reusableOperation( const int id );
198 static void ProcessEvents( vtkObject* theObject,
199 unsigned long theEvent,
205 int addVtkFontPref( const QString&,
210 void connectView( const SUIT_ViewWindow* );
214 static SMESH::SMESH_Gen_var myComponentSMESH;
215 QDialog* myActiveDialogBox;
217 QMap<int, QString> myRules;
218 LightApp_Displayer* myDisplayer;
220 SMESHGUI_FilterLibraryDlg* myFilterLibraryDlg;
222 SMESHGUI_StudyId2MarkerMap myMarkerMap;
223 SMESHGUI_ClippingPlaneInfoMap myClippingPlaneInfoMap;
225 vtkSmartPointer<vtkCallbackCommand> myEventCallbackCommand;