1 // GEOM GEOMGUI : GUI for Geometry component
3 // Copyright (C) 2003 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : GeometryGUI.h
25 // Author : Lucien PIGNOLONI
29 #ifndef GeometryGUI_HeaderFile
30 #define GeometryGUI_HeaderFile
33 #include "QAD_Desktop.h"
34 #include "SALOME_Selection.h"
35 #include "SALOME_InteractiveObject.hxx"
36 #include "GEOM_InteractiveObject.hxx"
37 #include "GEOM_AISShape.hxx"
38 #include "GEOM_Actor.h"
39 #include "GEOM_Sketcher.h"
41 // Open CASCADE Includes
42 #include <AIS_InteractiveContext.hxx>
43 #include <Standard.hxx>
45 #include <V3d_View.hxx>
46 #include <Quantity_Color.hxx>
49 #include <SALOMEconfig.h>
50 #include CORBA_SERVER_HEADER(GEOM_Gen)
51 #include CORBA_SERVER_HEADER(SALOMEDS)
52 #include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
54 //=================================================================================
56 //=================================================================================
63 //=================================================================================
64 // class : GeometryGUI
66 //=================================================================================
67 class GeometryGUI : public QObject
69 Q_OBJECT /* for QT compatibility */
73 QAD_Desktop* myDesktop;
74 QAD_Study* myActiveStudy;
75 GEOM::GEOM_Gen_var myComponentGeom;
76 QDialog* myActiveDialogBox; /* Unique active dialog box */
77 Handle(AIS_Shape) mySimulationShape; /* AIS shape used only during topo/geom simulations */
78 vtkActorCollection* mySimulationActor; /* GEOM Actor used only during topo/geom simulations */
79 int myNbGeom ; /* Unique name for a geom entity */
80 int myState ; /* Identify a method */
83 Quantity_Color myShadingColor;
90 static GeometryGUI* GetOrCreateGeometryGUI( QAD_Desktop* desktop );
91 static GeometryGUI* GetGeometryGUI() ;
93 QAD_Study* GetActiveStudy() ;
94 QAD_Desktop* GetDesktop() ;
96 QDialog* GetActiveDialogBox() ; /* Returns the active DialogBox */
97 void SetActiveDialogBox(QDialog* aDlg) ; /* Sets 'myActiveDialogBox' a pointer to the active Dialog Box */
99 void SetState(int aState) ;
100 void ResetState() ; /* Sets myState = -1 a private field to indicate wich method is active */
101 bool DefineDlgPosition(QWidget* aDlg, int& x, int& y) ;
103 bool SObjectExist(SALOMEDS::SObject_ptr theFatherObject, const char* IOR);
106 void OnEditDelete ();
107 void OnVTKDisplayOnly ();
109 void OnDisplayOnly ();
110 void OnDisplayAll ( bool onlyPreviousDisplayedObject = false );
111 void SetDisplayedObjectList();
113 bool AddInStudy( bool selection = false, const Handle(SALOME_InteractiveObject)& anIO = 0 );
114 bool Display( GEOM::GEOM_Shape_ptr aShape, Standard_CString name = "");
116 /* Import and export topology methods */
121 static int GetIndex(const TopoDS_Shape& subshape, const TopoDS_Shape& shape, int ShapeType) ;
122 static bool VertexToPoint(const TopoDS_Shape& S, gp_Pnt& P) ;
123 static void GetBipointDxDyDz( gp_Pnt P1, gp_Pnt P2, double& dx, double& dy, double& dz) ;
125 static bool GetShapeTypeString( const TopoDS_Shape& aShape, Standard_CString& aTypeString ) ;
126 static bool LinearEdgeExtremities( const TopoDS_Shape& S, gp_Pnt& P1, gp_Pnt& P2) ;
128 static gp_Pnt ConvertClickToPoint( Standard_Real x, Standard_Real y, Handle(V3d_View) aView ) ;
130 /* User dialog 1 parameter returned */
131 static double Parameter( Standard_Boolean& res,
132 const char* aValue1 = 0,
133 const char* aTitle1 = 0,
134 const char* aTitle = 0,
135 const double bottom = -1E6,
136 const double top = +1E6,
137 const int decimals = 6 ) ;
139 /* Managed by IAPP */
140 Standard_EXPORT static bool OnGUIEvent ( int theCommandID, QAD_Desktop* parent) ;
141 Standard_EXPORT static bool OnMousePress ( QMouseEvent* pe, QAD_Desktop* parent,
142 QAD_StudyFrame* studyFrame );
143 Standard_EXPORT static bool OnMouseMove ( QMouseEvent* pe, QAD_Desktop* parent,
144 QAD_StudyFrame* studyFrame );
145 Standard_EXPORT static bool OnKeyPress ( QKeyEvent* pe, QAD_Desktop* parent,
146 QAD_StudyFrame* studyFrame );
147 Standard_EXPORT static void activeStudyChanged ( QAD_Desktop* parent );
148 Standard_EXPORT static bool SetSettings ( QAD_Desktop* parent );
149 Standard_EXPORT static void DefinePopup( QString & theContext,
151 QString & theObject );
152 Standard_EXPORT static bool CustomPopup ( QAD_Desktop* parent,
154 const QString& theContext,
155 const QString& theParent,
156 const QString& theObject );
157 Standard_EXPORT static void BuildPresentation(const Handle(SALOME_InteractiveObject)&);
159 void Archimede( const Handle(SALOME_InteractiveObject)& IO, const double aWeight,
160 const double aWaterDensity, const double aMeshingDeflection );
162 void MakePointAndDisplay( const double x, const double y, const double z ) ;
163 void MakeVectorAndDisplay( const gp_Pnt P1, const gp_Pnt P2 );
164 void MakeBoxAndDisplay( const gp_Pnt P1, const gp_Pnt P2 ) ;
165 void MakePlaneAndDisplay( const gp_Pnt P1, const Standard_Real dx,
166 const Standard_Real dy, const Standard_Real dz, const Standard_Real TrimSize ) ;
167 void MakeSphereAndDisplay( const gp_Pnt aCenterPoint, const double aRadius) ;
168 void MakeCircleAndDisplay( const gp_Pnt CenterPoint, const gp_Dir dir, const Standard_Real Radius) ;
169 void MakeArcAndDisplay( gp_Pnt InitPoint, gp_Pnt CirclePoint, gp_Pnt EndPoint ) ;
170 void MakeLineAndDisplay( const gp_Pnt InitPoint, const gp_Pnt LastPoint) ;
171 void MakeCylinderAndDisplay( const gp_Pnt BasePoint, const gp_Dir aDir,
172 const double Radius, const double aHeight ) ;
173 void MakeConeAndDisplay( const gp_Pnt BasePoint, const gp_Dir aDir,
174 const double Radius1, const double Radius2, const double aHeight ) ;
175 void MakeTorusAndDisplay( const gp_Pnt BasePoint, const gp_Dir aDir,
176 const double Radius1, const double Radius2 ) ;
177 void MakeBooleanAndDisplay( GEOM::GEOM_Shape_ptr Shape1, GEOM::GEOM_Shape_ptr Shape2,
178 const short operation ) ;
179 void MakeRevolutionAndDisplay( GEOM::GEOM_Shape_ptr Shape, const gp_Pnt loc,
180 const gp_Dir dir, Standard_Real revolAngle ) ;
181 void MakePrismAndDisplay( GEOM::GEOM_Shape_ptr BaseShape, const gp_Pnt P1, const gp_Pnt P2 ) ;
182 void MakePipeAndDisplay( GEOM::GEOM_Shape_ptr aPath, GEOM::GEOM_Shape_ptr aBase ) ;
183 void MakeFillingAndDisplay( GEOM::GEOM_Shape_ptr SectionShape, const short mindeg, const short maxdeg,
184 const double tol3d, const double tol2d, const short nbiter ) ;
185 void MakeRotationAndDisplay( GEOM::GEOM_Shape_ptr Shape, const gp_Pnt loc, const gp_Dir dir,
186 const Standard_Real angle ) ;
187 void MakeTranslationAndDisplay( GEOM::GEOM_Shape_ptr Shape, const gp_Vec V) ;
189 void MakeMultiTranslation1DAndDisplay( GEOM::GEOM_Shape_ptr Shape, const gp_Dir Dir, const double Step, const short NbTimes ) ;
190 void MakeMultiTranslation2DAndDisplay( GEOM::GEOM_Shape_ptr Shape, const gp_Dir Dir1, const double Step1, const short NbTimes1,
191 const gp_Dir Dir2, const double Step2, const short NbTimes2 ) ;
192 void MakeMultiRotation1DAndDisplay( GEOM::GEOM_Shape_ptr Shape, const gp_Dir Dir, const gp_Pnt Loc, const short NbTimes ) ;
193 void MakeMultiRotation2DAndDisplay( GEOM::GEOM_Shape_ptr Shape, const gp_Dir Dir, const gp_Pnt Loc, const double Ang,
194 const short NbTimes1, const double Step, const short NbTimes2 ) ;
195 void MakeCDGAndDisplay( GEOM::GEOM_Shape_ptr Shape );
196 void MakeScaleAndDisplay( GEOM::GEOM_Shape_ptr Shape, const gp_Pnt centralPoint,
197 const Standard_Real factor) ;
198 void MakeMirrorAndDisplay( GEOM::GEOM_Shape_ptr Shape1, GEOM::GEOM_Shape_ptr Shape2 ) ;
199 void MakeSewingAndDisplay( GEOM::GEOM_Gen::ListOfIOR& listShapesIOR,
200 const Standard_Real precision ) ;
201 void MakeCompoundAndDisplay( GEOM::GEOM_Gen::ListOfIOR& listShapesIOR ) ;
202 void MakeLinearEdgeAndDisplay( const gp_Pnt P1, const gp_Pnt P2 ) ;
203 void MakeOrientationChangeAndDisplay( GEOM::GEOM_Shape_ptr Shape ) ;
205 void MakePartitionAndDisplay (const GEOM::GEOM_Gen::ListOfIOR& listShapesIOR,
206 const GEOM::GEOM_Gen::ListOfIOR& listToolsIOR,
207 const GEOM::GEOM_Gen::ListOfIOR& listKeepInsIOR,
208 const GEOM::GEOM_Gen::ListOfIOR& listRemoveInsIOR,
209 const GEOM::shape_type limit ) ;
211 void MakeWireAndDisplay( GEOM::GEOM_Gen::ListOfIOR& listShapesIOR ) ;
212 void MakeWorkingPlane( const gp_Pnt P, const gp_Dir D) ;
213 void MakeFaceAndDisplay( GEOM::GEOM_Shape_ptr aWire, const Standard_Boolean wantPlanar ) ;
215 /* Simulation management */
216 bool CreateArrowForLinearEdge( const TopoDS_Shape& tds, TopoDS_Shape& ArrowCone ) ;
217 void DisplaySimulationShape(const TopoDS_Shape& S) ;
218 void EraseSimulationShape() ;
220 /* Selection and objects management */
222 TopoDS_Shape GetShapeFromIOR( QString IOR );
223 bool GetTopoFromSelection(SALOME_Selection *Sel, TopoDS_Shape& tds) ;
224 int GetNameOfSelectedIObjects( SALOME_Selection* Sel, QString& aName ) ;
225 GEOM::GEOM_Shape_ptr ConvertIOinGEOMShape( const Handle(SALOME_InteractiveObject)& IO,
226 Standard_Boolean& testResult ) ;
228 Handle(GEOM_AISShape) ConvertIOinGEOMAISShape( const Handle(SALOME_InteractiveObject)& IO,
229 Standard_Boolean& testResult,
230 bool onlyInActiveView = false ) ;
231 Handle(GEOM_AISShape) ConvertIORinGEOMAISShape( const char * IOR,
232 Standard_Boolean& testResult,
233 bool onlyInActiveView = false ) ;
235 GEOM_Actor* ConvertIORinGEOMActor( const char * IOR,
236 Standard_Boolean& testResult,
237 bool onlyInActiveView = false ) ;
239 void ConvertListOfIOInListOfIOR( const SALOME_ListIO& aList,
240 GEOM::GEOM_Gen::ListOfIOR& listIOR ) ;
242 /* Method used by dialog boxes called when used has entered a name of object in a LineEdit */
243 bool SelectionByNameInDialogs( QWidget* aWidget, const QString& userObjectName, SALOME_Selection *Sel ) ;
245 /* Method opening context for any sub shape selection */
246 bool PrepareSubShapeSelection( const int SubShapeType,
247 Standard_Integer& returnLocalContextId ) ;
249 /* Method opening context for sub shape selection on an argument shape */
250 bool PrepareSubShapeSelectionArgumentShape( const TopoDS_Shape& aShape,
251 const int SubShapeType,
252 Standard_Integer& returnLocalContextId ) ;
255 /* Define a list of indices of sub shapes selected in a local context */
256 bool GetIndexSubShapeSelected( const TopoDS_Shape& ShapeTopo,
257 const int SubShapeType,
258 GEOM::GEOM_Shape::ListOfSubShapeID& ListOfID,
259 Standard_Integer& aLocalContextId,
260 bool& myUseLocalContext ) ;
262 /* Methods for sub shapes explode */
263 bool OnSubShapeGetAll( const TopoDS_Shape& ShapeTopo, const char* ShapeTopoIOR, const int SubShapeType) ;
264 bool OnSubShapeGetSelected( const TopoDS_Shape& ShapeTopo,
265 const char* ShapeTopoIOR,
266 const int SubShapeType,
267 Standard_Integer& aLocalContextId,
268 bool& myUseLocalContext ) ;
270 /* Remove faces in a shape */
271 bool OnSuppressFaces( const TopoDS_Shape& ShapeTopo,
272 const char* ShapeTopoIOR,
273 const Standard_Integer& aLocalContextId,
274 bool& myUseLocalContext ) ;
276 /* Remove an hole in a topology (ListOfIdEndFace may be an empty list ) */
277 bool OnSuppressHole( const char* ShapeTopoIOR,
278 const GEOM::GEOM_Shape::ListOfSubShapeID& ListOfIdFace,
279 const GEOM::GEOM_Shape::ListOfSubShapeID& ListOfIdWire,
280 const GEOM::GEOM_Shape::ListOfSubShapeID& ListOfIdEndFace ) ;
282 /* Remove one or more holes in a face or a shell */
283 bool OnSuppressHolesInFaceOrShell( const char* ShapeTopoIOR,
284 const GEOM::GEOM_Shape::ListOfSubShapeID& ListOfIdWires ) ;
286 /* Create a face corresponding to a hole on a shape */
287 bool OnFillingHole( const TopoDS_Shape& MainShape,
288 const char* ShapeTopoIOR,
289 const Standard_Integer& aLocalContextId,
290 bool& myUseLocalContext ) ;
292 /* Method for Fillet */
293 bool OnFilletGetAll(const TopoDS_Shape& ShapeTopo, const double Radius, const int SubShapeType, const char* ShapeTopoIOR) ;
294 bool OnFilletGetSelected(const TopoDS_Shape& ShapeTopo,
295 const char* ShapeTopoIOR,
297 const int SubShapeType,
298 Standard_Integer& aLocalContextId,
299 bool& myUseLocalContext );
301 /* Methods for Chamfer */
302 bool OnChamferGetAll(const TopoDS_Shape& ShapeTopo, const double D1, const double D2, const int SubShapeType, const char* ShapeTopoIOR) ;
303 bool OnChamferGetSelected(const TopoDS_Shape& ShapeTopo,
304 const char* ShapeTopoIOR,
305 const double D1, const double D2, const int SubShapeType,
306 Standard_Integer& aLocalContextId,
307 bool& myUseLocalContext ) ;
309 /* Non modal dialog boxes magement */
310 void EmitSignalDeactivateDialog() ;
311 void EmitSignalCloseAllDialogs() ;
313 /* Sketcher management */
314 void OnSketchSegment();
316 void OnSketchSetAngle();
320 void OnSketchDelete();
321 void OnSketchClose();
324 void OnSketchOptionsOnoffangledimension();
325 void OnSketchOptionsOnofflengthdimension();
326 void OnSketchOptionsOnoffradiusdimension();
327 void OnSketchOptionsOnoffxdimension();
328 void OnSketchOptionsOnoffydimension();
330 void OnSettingsNoconstraint();
331 void OnSettingsPerpendicular();
332 void OnSettingsTangent();
335 void SignalDeactivateActiveDialog() ;
336 void SignalCloseAllDialogs() ;
337 void SignalDefaultStepValueChanged( double newVal ) ;