b311480e |
1 | // Created on: 1994-03-28 |
2 | // Created by: Remi LEQUETTE |
3 | // Copyright (c) 1994-1999 Matra Datavision |
4 | // Copyright (c) 1999-2012 OPEN CASCADE SAS |
5 | // |
6 | // The content of this file is subject to the Open CASCADE Technology Public |
7 | // License Version 6.5 (the "License"). You may not use the content of this file |
8 | // except in compliance with the License. Please obtain a copy of the License |
9 | // at http://www.opencascade.org and read it completely before using this file. |
10 | // |
11 | // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its |
12 | // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. |
13 | // |
14 | // The Original Code and all software distributed under the License is |
15 | // distributed on an "AS IS" basis, without warranty of any kind, and the |
16 | // Initial Developer hereby disclaims all such warranties, including without |
17 | // limitation, any warranties of merchantability, fitness for a particular |
18 | // purpose or non-infringement. Please see the License for the specific terms |
19 | // and conditions governing the rights and limitations under the License. |
20 | |
7fd59977 |
21 | |
22 | #ifdef HAVE_CONFIG_H |
23 | # include <config.h> |
24 | #endif |
25 | |
26 | #ifdef HAVE_IOS |
27 | # include <ios> |
28 | #elif defined(HAVE_IOS_H) |
29 | # include <ios.h> |
30 | #endif |
31 | |
32 | #include <DrawTrSurf_Point.ixx> |
33 | #include <Standard_Stream.hxx> |
34 | |
35 | //======================================================================= |
36 | //function : DrawTrSurf_Point |
37 | //purpose : |
38 | //======================================================================= |
39 | |
40 | DrawTrSurf_Point::DrawTrSurf_Point(const gp_Pnt& P, |
41 | const Draw_MarkerShape Shape, |
42 | const Draw_Color& Col) : |
43 | myPoint(P), |
44 | is3D(Standard_True), |
45 | myShape(Shape), |
46 | myColor(Col) |
47 | { |
48 | } |
49 | |
50 | //======================================================================= |
51 | //function : DrawTrSurf_Point |
52 | //purpose : |
53 | //======================================================================= |
54 | |
55 | DrawTrSurf_Point::DrawTrSurf_Point(const gp_Pnt2d& P, |
56 | const Draw_MarkerShape Shape, |
57 | const Draw_Color& Col) : |
58 | myPoint(P.X(),P.Y(),0.), |
59 | is3D(Standard_False), |
60 | myShape(Shape), |
61 | myColor(Col) |
62 | { |
63 | } |
64 | |
65 | //======================================================================= |
66 | //function : Is3D |
67 | //purpose : |
68 | //======================================================================= |
69 | |
70 | Standard_Boolean DrawTrSurf_Point::Is3D() const |
71 | { |
72 | return is3D; |
73 | } |
74 | |
75 | //======================================================================= |
76 | //function : DrawOn |
77 | //purpose : |
78 | //======================================================================= |
79 | |
80 | void DrawTrSurf_Point::DrawOn(Draw_Display& dis) const |
81 | { |
82 | dis.SetColor(myColor); |
83 | if (is3D) |
84 | dis.DrawMarker(myPoint,myShape); |
85 | else |
86 | dis.DrawMarker(Point2d(),myShape); |
87 | } |
88 | |
89 | //======================================================================= |
90 | //function : Point |
91 | //purpose : |
92 | //======================================================================= |
93 | |
94 | gp_Pnt DrawTrSurf_Point::Point() const |
95 | { |
96 | return myPoint; |
97 | } |
98 | |
99 | //======================================================================= |
100 | //function : Point |
101 | //purpose : |
102 | //======================================================================= |
103 | |
104 | void DrawTrSurf_Point::Point(const gp_Pnt& P) |
105 | { |
106 | myPoint = P; |
107 | is3D = Standard_True; |
108 | } |
109 | |
110 | //======================================================================= |
111 | //function : Point2d |
112 | //purpose : |
113 | //======================================================================= |
114 | |
115 | gp_Pnt2d DrawTrSurf_Point::Point2d() const |
116 | { |
117 | return gp_Pnt2d(myPoint.X(),myPoint.Y()); |
118 | } |
119 | |
120 | //======================================================================= |
121 | //function : Point2d |
122 | //purpose : |
123 | //======================================================================= |
124 | |
125 | void DrawTrSurf_Point::Point2d(const gp_Pnt2d& P) |
126 | { |
127 | myPoint.SetCoord(P.X(),P.Y(),0); |
128 | is3D = Standard_False; |
129 | } |
130 | |
131 | //======================================================================= |
132 | //function : Color |
133 | //purpose : |
134 | //======================================================================= |
135 | |
136 | void DrawTrSurf_Point::Color(const Draw_Color& aColor) |
137 | { |
138 | myColor = aColor; |
139 | } |
140 | |
141 | //======================================================================= |
142 | //function : Color |
143 | //purpose : |
144 | //======================================================================= |
145 | |
146 | Draw_Color DrawTrSurf_Point::Color() const |
147 | { |
148 | return myColor; |
149 | } |
150 | |
151 | //======================================================================= |
152 | //function : Shape |
153 | //purpose : |
154 | //======================================================================= |
155 | |
156 | void DrawTrSurf_Point::Shape(const Draw_MarkerShape S) |
157 | { |
158 | myShape = S; |
159 | } |
160 | |
161 | //======================================================================= |
162 | //function : Shape |
163 | //purpose : |
164 | //======================================================================= |
165 | |
166 | Draw_MarkerShape DrawTrSurf_Point::Shape() const |
167 | { |
168 | return myShape; |
169 | } |
170 | |
171 | //======================================================================= |
172 | //function : Copy |
173 | //purpose : |
174 | //======================================================================= |
175 | |
176 | Handle(Draw_Drawable3D) DrawTrSurf_Point::Copy() const |
177 | { |
178 | Handle(DrawTrSurf_Point) P; |
179 | if (is3D) |
180 | P = new DrawTrSurf_Point(myPoint,myShape,myColor); |
181 | else |
182 | P = new DrawTrSurf_Point(Point2d(),myShape,myColor); |
183 | |
184 | return P; |
185 | } |
186 | |
187 | //======================================================================= |
188 | //function : Dump |
189 | //purpose : |
190 | //======================================================================= |
191 | |
192 | void DrawTrSurf_Point::Dump(Standard_OStream& S) const |
193 | { |
194 | #if defined(HAVE_IOS) && !defined(__sgi) && !defined(IRIX) |
195 | ios::fmtflags F = S.flags(); |
196 | S.setf(ios::scientific,ios::floatfield); |
197 | S.precision(15); |
198 | #else |
199 | long form = S.setf(ios::scientific); |
60be1f9b |
200 | std::streamsize prec = S.precision(15); |
7fd59977 |
201 | #endif |
202 | if (is3D) |
203 | S << "Point : " << myPoint.X() << ", " << myPoint.Y() << ", " << myPoint.Z() <<endl; |
204 | else |
205 | S << "Point 2d : " << myPoint.X() << ", " << myPoint.Y() <<endl; |
206 | #if defined(HAVE_IOS) && !defined(__sgi) && !defined(IRIX) |
207 | S.setf(F); |
208 | #else |
209 | S.setf(form); |
210 | S.precision(prec); |
211 | #endif |
212 | } |
213 | |
214 | //======================================================================= |
215 | //function : Whatis |
216 | //purpose : |
217 | //======================================================================= |
218 | |
219 | void DrawTrSurf_Point::Whatis(Draw_Interpretor& S) const |
220 | { |
221 | S << "point"; |
222 | } |