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 MakeEllipseAndDisplay( const gp_Pnt CenterPoint, const gp_Dir dir, const Standard_Real Major_Radius, const Standard_Real Minor_Radius) ;
170 void MakeArcAndDisplay( gp_Pnt InitPoint, gp_Pnt CirclePoint, gp_Pnt EndPoint ) ;
171 void MakeLineAndDisplay( const gp_Pnt InitPoint, const gp_Pnt LastPoint) ;
172 void MakeCylinderAndDisplay( const gp_Pnt BasePoint, const gp_Dir aDir,
173 const double Radius, const double aHeight ) ;
174 void MakeConeAndDisplay( const gp_Pnt BasePoint, const gp_Dir aDir,
175 const double Radius1, const double Radius2, const double aHeight ) ;
176 void MakeTorusAndDisplay( const gp_Pnt BasePoint, const gp_Dir aDir,
177 const double Radius1, const double Radius2 ) ;
178 void MakeBooleanAndDisplay( GEOM::GEOM_Shape_ptr Shape1, GEOM::GEOM_Shape_ptr Shape2,
179 const short operation ) ;
180 void MakeRevolutionAndDisplay( GEOM::GEOM_Shape_ptr Shape, const gp_Pnt loc,
181 const gp_Dir dir, Standard_Real revolAngle ) ;
182 void MakePrismAndDisplay( GEOM::GEOM_Shape_ptr BaseShape, const gp_Pnt P1, const gp_Pnt P2 ) ;
183 void MakePipeAndDisplay( GEOM::GEOM_Shape_ptr aPath, GEOM::GEOM_Shape_ptr aBase ) ;
184 void MakeFillingAndDisplay( GEOM::GEOM_Shape_ptr SectionShape, const short mindeg, const short maxdeg,
185 const double tol3d, const double tol2d, const short nbiter ) ;
186 void MakeRotationAndDisplay( GEOM::GEOM_Shape_ptr Shape, const gp_Pnt loc, const gp_Dir dir,
187 const Standard_Real angle ) ;
188 void MakeTranslationAndDisplay( GEOM::GEOM_Shape_ptr Shape, const gp_Vec V) ;
190 void MakeMultiTranslation1DAndDisplay( GEOM::GEOM_Shape_ptr Shape, const gp_Dir Dir, const double Step, const short NbTimes ) ;
191 void MakeMultiTranslation2DAndDisplay( GEOM::GEOM_Shape_ptr Shape, const gp_Dir Dir1, const double Step1, const short NbTimes1,
192 const gp_Dir Dir2, const double Step2, const short NbTimes2 ) ;
193 void MakeMultiRotation1DAndDisplay( GEOM::GEOM_Shape_ptr Shape, const gp_Dir Dir, const gp_Pnt Loc, const short NbTimes ) ;
194 void MakeMultiRotation2DAndDisplay( GEOM::GEOM_Shape_ptr Shape, const gp_Dir Dir, const gp_Pnt Loc, const double Ang,
195 const short NbTimes1, const double Step, const short NbTimes2 ) ;
196 void MakeCDGAndDisplay( GEOM::GEOM_Shape_ptr Shape );
197 void MakeScaleAndDisplay( GEOM::GEOM_Shape_ptr Shape, const gp_Pnt centralPoint,
198 const Standard_Real factor) ;
199 void MakeMirrorAndDisplay( GEOM::GEOM_Shape_ptr Shape1, GEOM::GEOM_Shape_ptr Shape2 ) ;
200 void MakeSewingAndDisplay( GEOM::GEOM_Gen::ListOfIOR& listShapesIOR,
201 const Standard_Real precision ) ;
202 void MakeCompoundAndDisplay( GEOM::GEOM_Gen::ListOfIOR& listShapesIOR ) ;
203 void MakeShellAndDisplay( GEOM::GEOM_Gen::ListOfIOR& listShapesIOR ) ;
204 void MakeSolidAndDisplay( GEOM::GEOM_Gen::ListOfIOR& listShapesIOR ) ;
205 void MakeLinearEdgeAndDisplay( const gp_Pnt P1, const gp_Pnt P2 ) ;
206 void MakeOrientationChangeAndDisplay( GEOM::GEOM_Shape_ptr Shape ) ;
208 void MakePartitionAndDisplay (const GEOM::GEOM_Gen::ListOfIOR& listShapesIOR,
209 const GEOM::GEOM_Gen::ListOfIOR& listToolsIOR,
210 const GEOM::GEOM_Gen::ListOfIOR& listKeepInsIOR,
211 const GEOM::GEOM_Gen::ListOfIOR& listRemoveInsIOR,
212 const GEOM::shape_type limit ) ;
214 void MakeWireAndDisplay( GEOM::GEOM_Gen::ListOfIOR& listShapesIOR ) ;
215 void MakeWorkingPlane( const gp_Pnt P, const gp_Dir D) ;
216 void MakeFaceAndDisplay( GEOM::GEOM_Shape_ptr aWire, const Standard_Boolean wantPlanar ) ;
218 /* Simulation management */
219 bool CreateArrowForLinearEdge( const TopoDS_Shape& tds, TopoDS_Shape& ArrowCone ) ;
220 void DisplaySimulationShape(const TopoDS_Shape& S) ;
221 void EraseSimulationShape() ;
223 /* Selection and objects management */
225 TopoDS_Shape GetShapeFromIOR( QString IOR );
226 bool GetTopoFromSelection(SALOME_Selection *Sel, TopoDS_Shape& tds) ;
227 int GetNameOfSelectedIObjects( SALOME_Selection* Sel, QString& aName ) ;
228 GEOM::GEOM_Shape_ptr ConvertIOinGEOMShape( const Handle(SALOME_InteractiveObject)& IO,
229 Standard_Boolean& testResult ) ;
231 Handle(GEOM_AISShape) ConvertIOinGEOMAISShape( const Handle(SALOME_InteractiveObject)& IO,
232 Standard_Boolean& testResult,
233 bool onlyInActiveView = false ) ;
234 Handle(GEOM_AISShape) ConvertIORinGEOMAISShape( const char * IOR,
235 Standard_Boolean& testResult,
236 bool onlyInActiveView = false ) ;
238 GEOM_Actor* ConvertIORinGEOMActor( const char * IOR,
239 Standard_Boolean& testResult,
240 bool onlyInActiveView = false ) ;
242 void ConvertListOfIOInListOfIOR( const SALOME_ListIO& aList,
243 GEOM::GEOM_Gen::ListOfIOR& listIOR ) ;
245 /* Method used by dialog boxes called when used has entered a name of object in a LineEdit */
246 bool SelectionByNameInDialogs( QWidget* aWidget, const QString& userObjectName, SALOME_Selection *Sel ) ;
248 /* Method opening context for any sub shape selection */
249 bool PrepareSubShapeSelection( const int SubShapeType,
250 Standard_Integer& returnLocalContextId ) ;
252 /* Method opening context for sub shape selection on an argument shape */
253 bool PrepareSubShapeSelectionArgumentShape( const TopoDS_Shape& aShape,
254 const int SubShapeType,
255 Standard_Integer& returnLocalContextId ) ;
258 /* Define a list of indices of sub shapes selected in a local context */
259 bool GetIndexSubShapeSelected( const TopoDS_Shape& ShapeTopo,
260 const int SubShapeType,
261 GEOM::GEOM_Shape::ListOfSubShapeID& ListOfID,
262 Standard_Integer& aLocalContextId,
263 bool& myUseLocalContext ) ;
265 /* Methods for sub shapes explode */
266 bool OnSubShapeGetAll( const TopoDS_Shape& ShapeTopo, const char* ShapeTopoIOR, const int SubShapeType) ;
267 bool OnSubShapeGetSelected( const TopoDS_Shape& ShapeTopo,
268 const char* ShapeTopoIOR,
269 const int SubShapeType,
270 Standard_Integer& aLocalContextId,
271 bool& myUseLocalContext ) ;
273 /* Remove faces in a shape */
274 bool OnSuppressFaces( const TopoDS_Shape& ShapeTopo,
275 const char* ShapeTopoIOR,
276 const Standard_Integer& aLocalContextId,
277 bool& myUseLocalContext ) ;
279 /* Remove an hole in a topology (ListOfIdEndFace may be an empty list ) */
280 bool OnSuppressHole( const char* ShapeTopoIOR,
281 const GEOM::GEOM_Shape::ListOfSubShapeID& ListOfIdFace,
282 const GEOM::GEOM_Shape::ListOfSubShapeID& ListOfIdWire,
283 const GEOM::GEOM_Shape::ListOfSubShapeID& ListOfIdEndFace ) ;
285 /* Remove one or more holes in a face or a shell */
286 bool OnSuppressHolesInFaceOrShell( const char* ShapeTopoIOR,
287 const GEOM::GEOM_Shape::ListOfSubShapeID& ListOfIdWires ) ;
289 /* Create a face corresponding to a hole on a shape */
290 bool OnFillingHole( const TopoDS_Shape& MainShape,
291 const char* ShapeTopoIOR,
292 const Standard_Integer& aLocalContextId,
293 bool& myUseLocalContext ) ;
295 /* Method for Fillet */
296 bool OnFilletGetAll(const TopoDS_Shape& ShapeTopo, const double Radius, const int SubShapeType, const char* ShapeTopoIOR) ;
297 bool OnFilletGetSelected(const TopoDS_Shape& ShapeTopo,
298 const char* ShapeTopoIOR,
300 const int SubShapeType,
301 Standard_Integer& aLocalContextId,
302 bool& myUseLocalContext );
304 /* Methods for Chamfer */
305 bool OnChamferGetAll(const TopoDS_Shape& ShapeTopo, const double D1, const double D2, const int SubShapeType, const char* ShapeTopoIOR) ;
306 bool OnChamferGetSelected(const TopoDS_Shape& ShapeTopo,
307 const char* ShapeTopoIOR,
308 const double D1, const double D2, const int SubShapeType,
309 Standard_Integer& aLocalContextId,
310 bool& myUseLocalContext ) ;
312 /* Non modal dialog boxes magement */
313 void EmitSignalDeactivateDialog() ;
314 void EmitSignalCloseAllDialogs() ;
316 /* Sketcher management */
317 void OnSketchSegment();
319 void OnSketchSetAngle();
323 void OnSketchDelete();
324 void OnSketchClose();
327 void OnSketchOptionsOnoffangledimension();
328 void OnSketchOptionsOnofflengthdimension();
329 void OnSketchOptionsOnoffradiusdimension();
330 void OnSketchOptionsOnoffxdimension();
331 void OnSketchOptionsOnoffydimension();
333 void OnSettingsNoconstraint();
334 void OnSettingsPerpendicular();
335 void OnSettingsTangent();
338 void SignalDeactivateActiveDialog() ;
339 void SignalCloseAllDialogs() ;
340 void SignalDefaultStepValueChanged( double newVal ) ;