1 // GEOM SKETCHER : basic sketcher
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 : GEOM_Sketcher.h
25 // Author : Nicolas REJNERI
29 #include "GEOM_SketcherStatus.h"
31 #include <V3d_Viewer.hxx>
32 #include <V3d_View.hxx>
33 #include <BRepBuilderAPI_MakeWire.hxx>
34 #include <Geom_Plane.hxx>
35 #include <AIS_InteractiveContext.hxx>
36 #include <AIS_Shape.hxx>
37 #include <AIS_Axis.hxx>
38 #include <TopoDS_Edge.hxx>
39 #include <AIS_LengthDimension.hxx>
40 #include <AIS_RadiusDimension.hxx>
41 #include <AIS_AngleDimension.hxx>
42 #include <Geom2d_Line.hxx>
43 #include <TColStd_SequenceOfInteger.hxx>
44 #include <TColgp_SequenceOfPnt2d.hxx>
45 #include <gp_Vec2d.hxx>
52 Sketch(const Handle(V3d_Viewer)& aViewer);
53 Sketch(const Handle(V3d_Viewer)& aViewer,
54 const Quantity_Color& anAxisColor,
55 const Quantity_Color& aCurrentColor,
56 const Quantity_Color& aWireColor);
58 static void fitInResol(Standard_Real &toFit,
59 Standard_Boolean minIsResol = Standard_False);
61 void MakeCurrentEdge(const Standard_Integer Xp ,
62 const Standard_Integer Yp ,
63 const Handle(V3d_View)& aView );
65 void MakeCurrentEdge(const Standard_Real X, const Standard_Real Y);
67 Standard_Boolean SetDimension(Standard_Real& aValue);
68 void SetDimension(Standard_Real& deltaX,Standard_Real& deltaY);
70 void SetXDimension(Standard_Real& deltaX);
71 void SetYDimension(Standard_Real& deltaY);
73 void SetSegmentAngle(Standard_Real& aValue);
74 Standard_Real GetSegmentAngle();
83 Standard_Boolean Delete();
85 void SetPlane(const Handle(Geom_Plane)& aPlane);
87 void SetWireColor(const Quantity_Color& aColor);
88 void SetCurrentColor(const Quantity_Color& aColor);
89 void SetAxisColor(const Quantity_Color& aColor);
91 void SetParameterVisibility(const TypeOfParameter atype,
92 const Standard_Boolean OnOff);
94 void HiligthWithColor(const TypeOfParameter atype,
95 const Quantity_NameOfColor acolor);
96 void Unhiligth(const TypeOfParameter atype);
98 Standard_Boolean IsValidCurrentParameter(const TypeOfParameter atype);
100 void SetParameterValue(const TypeOfParameter atype, Standard_Real aValue);
102 void ChangeMode(const SketchStatus aMode);
104 void SetTransitionStatus(const TransitionStatus aStatus);
106 SketchStatus GetCurrentStatus();
107 Standard_Integer GetmyEdgesNumber();
113 void MakeCurrentSegment(Standard_Real X, Standard_Real Y);
115 void MakeCurrentArc(Standard_Real X, Standard_Real Y);
117 void DisplayCurrentEdge();
119 void DisplayLengthDimension(const TopoDS_Vertex& V1,const TopoDS_Vertex& V2);
120 void DisplayXDimension(const TopoDS_Vertex& V1,const TopoDS_Vertex& V2);
121 void DisplayYDimension(const TopoDS_Vertex& V1,const TopoDS_Vertex& V2);
122 void DisplayAngleDimension();
123 void DisplayRadiusDimension();
125 void AddEdgeToWire();
127 void RemoveLastEdge();
129 void CreateConstraints();
132 // Current status of construction
133 SketchStatus myCurrentStatus;
134 // Transition status between arcs and segments
135 TransitionStatus myTransitionStatus;
137 BRepBuilderAPI_MakeWire myCurrentWire;
138 // Current presentable wire
139 Handle_AIS_Shape myPresentableWire;
140 // Number of edges into the current wire
141 Standard_Integer myEdgesNumber;
142 // Store for each edge how it has been built i.d the value of myCurrentStatus
143 TColStd_SequenceOfInteger myConstructionMode;
144 // Store for each edge how it has been built i.d the value of myTransitionStatus
145 TColStd_SequenceOfInteger myConstraintMode;
147 TopoDS_Shape myCurrentEdge;
149 TopoDS_Edge myPreviousEdge;
150 // List of points to interpolate when computing a curve by interpolation
151 TColgp_SequenceOfPnt2d myPointsToInterpolate;
152 // Tangent vector at beginning of curve
153 gp_Vec2d myTangentVector;
154 // Tangent flag at beginning og curve
155 Standard_Boolean myTangentFlag;
158 TopoDS_Vertex myFirstPointSketch;
159 // Last x coordinate of end point of previous edge or picked point
160 Standard_Real myLastX;
161 // Last y coordinate of end point of previous edge or picked point
162 Standard_Real myLastY;
163 // angle between 2 segments when an ANGLE TransitionStatus is set.
164 Standard_Real mySegmentAngle;
165 // Length of segment when the length of the segment is fixed before the angle
166 Standard_Real mySegmentLength;
167 // Value of X fixed coordinate
168 Standard_Real mySegmentX;
169 // Value of Y fixed Coordinate
170 Standard_Real mySegmentY;
171 Handle_AIS_Shape myPresentableEdge; // Current presentable edge
172 Handle_AIS_LengthDimension myLengthDimension;// For display of current length segment dimension
173 Handle_AIS_LengthDimension myXDimension; // For display of current X segment dimension
174 Handle_AIS_LengthDimension myYDimension; // For display of current Y segment dimension
175 Handle_AIS_LengthDimension myRadiusDimension;// For display of current radius dimension
176 Handle_AIS_AngleDimension myAngleDimension; // For display of current angle dimension
177 Standard_Boolean myIsLengthDimensionVisible; // Visibility flag for LengthDimension
178 Standard_Boolean myIsXDimensionVisible; // Visibility flag for X Dimension
179 Standard_Boolean myIsYDimensionVisible; // Visibility flag for Y Dimension
180 Standard_Boolean myIsRadiusDimensionVisible; // Visibility flag for RadiusDimension
181 Standard_Boolean myIsAngleDimensionVisible; // Visibility flag for AngleDimension
182 Handle_AIS_Axis myPresentableMediatrice; // Chord mediatrice of current circle as a presentable object
183 Handle_Geom2d_Line myMediatrice; // Chord mediatrice of current circle as a 2d line
184 Handle_AIS_Shape myCenterCircle; // to visualise center of current arc
186 Handle_AIS_Axis myHAxis; // Horizontal axis
187 Handle_AIS_Axis myVAxis; // Vertical axis
188 Handle_AIS_Axis myAngularAxis; // Axis making a predefined angle with the previous edge
190 Quantity_Color myWireColor; // Color of wire and of build edges
191 Quantity_Color myCurrentColor; // Color of edge under construction
192 Quantity_Color myAxisColor; // Color for axis
193 Handle_AIS_InteractiveContext myInteractiveContext; // Interactive context for display management
195 Handle_Geom_Plane myPlane; // Plane of sketch
197 BRepBuilderAPI_MakeWire myPasteWire;
198 Standard_Integer myPasteEdgesNumber;
199 TColStd_SequenceOfInteger myPasteConstructionMode;
200 TColStd_SequenceOfInteger myPasteConstraintMode;