Salome HOME
NRI : First integration.
[modules/geom.git] / src / SKETCHER / GEOM_Sketcher.h
1 //  File      : GEOM_Sketcher.h
2 //  Created   : Wed Jul 5 10:12:09 2000
3 //  Author    : Martine LANGLOIS
4
5 //  Modified  : Tue Dec 11 21:23:41 2001
6 //  Author    : Nicolas REJNERI
7 //  Project   : SALOME
8 //  Module    : SALOMEGUI
9 //  Copyright : Open CASCADE
10 //  $Header$
11
12 #include "GEOM_SketcherStatus.h"
13
14 #include <V3d_Viewer.hxx>
15 #include <V3d_View.hxx>
16 #include <BRepBuilderAPI_MakeWire.hxx>
17 #include <Geom_Plane.hxx>
18 #include <AIS_InteractiveContext.hxx>
19 #include <AIS_Shape.hxx>
20 #include <AIS_Axis.hxx>
21 #include <TopoDS_Edge.hxx>
22 #include <AIS_LengthDimension.hxx>
23 #include <AIS_RadiusDimension.hxx>
24 #include <AIS_AngleDimension.hxx>
25 #include <Geom2d_Line.hxx>
26 #include <TColStd_SequenceOfInteger.hxx>
27 #include <TColgp_SequenceOfPnt2d.hxx>
28 #include <gp_Vec2d.hxx>
29
30 class Sketch  
31 {
32 public:
33         Sketch();
34         ~Sketch();
35         Sketch(const Handle(V3d_Viewer)& aViewer);
36         Sketch(const Handle(V3d_Viewer)& aViewer, 
37                        const Quantity_Color& anAxisColor,
38                        const Quantity_Color& aCurrentColor,
39                        const Quantity_Color& aWireColor);
40
41         static void fitInResol(Standard_Real &toFit, 
42                                Standard_Boolean minIsResol = Standard_False);
43
44         void MakeCurrentEdge(const Standard_Integer  Xp   ,
45                                      const Standard_Integer  Yp   ,
46                                      const Handle(V3d_View)& aView );
47         
48         void MakeCurrentEdge(const Standard_Real  X, const Standard_Real Y);
49
50         Standard_Boolean SetDimension(Standard_Real& aValue); 
51         void SetDimension(Standard_Real& deltaX,Standard_Real& deltaY);
52
53         void SetXDimension(Standard_Real& deltaX);
54         void SetYDimension(Standard_Real& deltaY);
55
56         void SetSegmentAngle(Standard_Real& aValue); 
57         Standard_Real GetSegmentAngle();
58
59         void ValidateEdge();
60
61         TopoDS_Wire Close();
62         TopoDS_Wire End();
63
64         void Clear();
65
66         Standard_Boolean Delete();
67
68         void SetPlane(const Handle(Geom_Plane)& aPlane);
69
70         void SetWireColor(const Quantity_Color& aColor);
71         void SetCurrentColor(const Quantity_Color& aColor);
72         void SetAxisColor(const Quantity_Color& aColor);
73
74         void SetParameterVisibility(const TypeOfParameter atype, 
75                                             const Standard_Boolean OnOff);
76
77         void HiligthWithColor(const TypeOfParameter atype, 
78                                       const Quantity_NameOfColor acolor);
79         void Unhiligth(const TypeOfParameter atype);
80
81         Standard_Boolean IsValidCurrentParameter(const TypeOfParameter atype);
82
83         void SetParameterValue(const TypeOfParameter atype, Standard_Real aValue);
84
85         void ChangeMode(const SketchStatus aMode);
86
87         void SetTransitionStatus(const TransitionStatus aStatus);
88
89         SketchStatus GetCurrentStatus(); 
90         Standard_Integer GetmyEdgesNumber();
91
92 private :
93         
94         void Init();
95
96         void MakeCurrentSegment(Standard_Real X, Standard_Real Y);
97
98         void MakeCurrentArc(Standard_Real X, Standard_Real Y);
99
100         void DisplayCurrentEdge();
101
102         void DisplayLengthDimension(const TopoDS_Vertex& V1,const TopoDS_Vertex& V2);
103         void DisplayXDimension(const TopoDS_Vertex& V1,const TopoDS_Vertex& V2);
104         void DisplayYDimension(const TopoDS_Vertex& V1,const TopoDS_Vertex& V2);
105         void DisplayAngleDimension();
106         void DisplayRadiusDimension();
107
108         void AddEdgeToWire();
109
110         void RemoveLastEdge();
111
112         void CreateConstraints();
113
114 private:
115         // Current status of construction
116         SketchStatus myCurrentStatus; 
117         // Transition status between arcs and segments
118         TransitionStatus myTransitionStatus;  
119         // Current wire
120         BRepBuilderAPI_MakeWire myCurrentWire;
121         // Current presentable wire
122         Handle_AIS_Shape myPresentableWire;   
123         // Number of edges into the current wire
124         Standard_Integer myEdgesNumber;       
125         // Store for each edge how it has been built i.d the value of myCurrentStatus
126         TColStd_SequenceOfInteger myConstructionMode; 
127         // Store for each edge how it has been built i.d the value of myTransitionStatus
128         TColStd_SequenceOfInteger myConstraintMode;  
129         // Current edge 
130         TopoDS_Shape myCurrentEdge; 
131         // Previous edge
132         TopoDS_Edge myPreviousEdge; 
133         // List of points to interpolate when computing a curve by interpolation
134         TColgp_SequenceOfPnt2d myPointsToInterpolate; 
135         // Tangent vector at beginning of curve
136         gp_Vec2d myTangentVector;         
137         // Tangent flag at beginning og curve
138         Standard_Boolean myTangentFlag;   
139         
140         // Origin of sketch
141         TopoDS_Vertex myFirstPointSketch; 
142         // Last x coordinate of end point of previous edge or picked point
143         Standard_Real myLastX; 
144         // Last y coordinate of end point of previous edge or picked point
145         Standard_Real myLastY; 
146         // angle between 2 segments when an ANGLE TransitionStatus is set.
147         Standard_Real mySegmentAngle;  
148         // Length of segment when the length of the segment is fixed before the angle
149         Standard_Real mySegmentLength; 
150         // Value of X fixed coordinate 
151         Standard_Real mySegmentX;                    
152         // Value of Y fixed Coordinate
153         Standard_Real mySegmentY;                    
154         Handle_AIS_Shape myPresentableEdge;          // Current presentable edge
155         Handle_AIS_LengthDimension myLengthDimension;// For display of current length segment dimension
156         Handle_AIS_LengthDimension myXDimension;     // For display of current X segment dimension
157         Handle_AIS_LengthDimension myYDimension;     // For display of current Y segment dimension
158         Handle_AIS_LengthDimension myRadiusDimension;// For display of current radius dimension
159         Handle_AIS_AngleDimension myAngleDimension;  // For display of current angle dimension
160         Standard_Boolean myIsLengthDimensionVisible; // Visibility flag for LengthDimension
161         Standard_Boolean myIsXDimensionVisible;      // Visibility flag for X Dimension
162         Standard_Boolean myIsYDimensionVisible;      // Visibility flag for Y Dimension
163         Standard_Boolean myIsRadiusDimensionVisible; // Visibility flag for RadiusDimension
164         Standard_Boolean myIsAngleDimensionVisible;  // Visibility flag for AngleDimension
165         Handle_AIS_Axis myPresentableMediatrice;     // Chord mediatrice of current circle as a presentable object
166         Handle_Geom2d_Line myMediatrice; // Chord mediatrice of current circle as a 2d line
167         Handle_AIS_Shape myCenterCircle; // to visualise center of current arc
168
169         Handle_AIS_Axis myHAxis;         // Horizontal axis
170         Handle_AIS_Axis myVAxis;         // Vertical axis
171         Handle_AIS_Axis myAngularAxis;   // Axis making a predefined angle with the previous edge
172
173         Quantity_Color myWireColor;      // Color of wire and of build edges
174         Quantity_Color myCurrentColor;   // Color of edge under construction
175         Quantity_Color myAxisColor;      // Color for axis
176         Handle_AIS_InteractiveContext myInteractiveContext; // Interactive context for display management
177         
178         Handle_Geom_Plane myPlane;       // Plane of sketch
179
180         BRepBuilderAPI_MakeWire myPasteWire;                                            
181         Standard_Integer myPasteEdgesNumber;
182         TColStd_SequenceOfInteger myPasteConstructionMode;
183         TColStd_SequenceOfInteger myPasteConstraintMode;        
184 };