b311480e |
1 | // Created on: 1994-03-28 |
2 | // Created by: Remi LEQUETTE |
3 | // Copyright (c) 1994-1999 Matra Datavision |
973c2be1 |
4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
5 | // |
973c2be1 |
6 | // This file is part of Open CASCADE Technology software library. |
b311480e |
7 | // |
d5f74e42 |
8 | // This library is free software; you can redistribute it and/or modify it under |
9 | // the terms of the GNU Lesser General Public License version 2.1 as published |
973c2be1 |
10 | // by the Free Software Foundation, with special exception defined in the file |
11 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
12 | // distribution for complete text of the license and disclaimer of any warranty. |
b311480e |
13 | // |
973c2be1 |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
7fd59977 |
16 | |
42cf5bc1 |
17 | |
18 | #include <Draw_Color.hxx> |
19 | #include <Draw_Display.hxx> |
20 | #include <Draw_Drawable3D.hxx> |
21 | #include <DrawTrSurf_Point.hxx> |
22 | #include <gp_Pnt.hxx> |
23 | #include <gp_Pnt2d.hxx> |
7fd59977 |
24 | #include <Standard_Stream.hxx> |
42cf5bc1 |
25 | #include <Standard_Type.hxx> |
7fd59977 |
26 | |
92efcf78 |
27 | IMPLEMENT_STANDARD_RTTIEXT(DrawTrSurf_Point,Draw_Drawable3D) |
28 | |
7fd59977 |
29 | //======================================================================= |
30 | //function : DrawTrSurf_Point |
31 | //purpose : |
32 | //======================================================================= |
7fd59977 |
33 | DrawTrSurf_Point::DrawTrSurf_Point(const gp_Pnt& P, |
34 | const Draw_MarkerShape Shape, |
35 | const Draw_Color& Col) : |
36 | myPoint(P), |
37 | is3D(Standard_True), |
38 | myShape(Shape), |
39 | myColor(Col) |
40 | { |
41 | } |
42 | |
43 | //======================================================================= |
44 | //function : DrawTrSurf_Point |
45 | //purpose : |
46 | //======================================================================= |
47 | |
48 | DrawTrSurf_Point::DrawTrSurf_Point(const gp_Pnt2d& P, |
49 | const Draw_MarkerShape Shape, |
50 | const Draw_Color& Col) : |
51 | myPoint(P.X(),P.Y(),0.), |
52 | is3D(Standard_False), |
53 | myShape(Shape), |
54 | myColor(Col) |
55 | { |
56 | } |
57 | |
58 | //======================================================================= |
59 | //function : Is3D |
60 | //purpose : |
61 | //======================================================================= |
62 | |
63 | Standard_Boolean DrawTrSurf_Point::Is3D() const |
64 | { |
65 | return is3D; |
66 | } |
67 | |
68 | //======================================================================= |
69 | //function : DrawOn |
70 | //purpose : |
71 | //======================================================================= |
72 | |
73 | void DrawTrSurf_Point::DrawOn(Draw_Display& dis) const |
74 | { |
75 | dis.SetColor(myColor); |
76 | if (is3D) |
77 | dis.DrawMarker(myPoint,myShape); |
78 | else |
79 | dis.DrawMarker(Point2d(),myShape); |
80 | } |
81 | |
82 | //======================================================================= |
83 | //function : Point |
84 | //purpose : |
85 | //======================================================================= |
86 | |
87 | gp_Pnt DrawTrSurf_Point::Point() const |
88 | { |
89 | return myPoint; |
90 | } |
91 | |
92 | //======================================================================= |
93 | //function : Point |
94 | //purpose : |
95 | //======================================================================= |
96 | |
97 | void DrawTrSurf_Point::Point(const gp_Pnt& P) |
98 | { |
99 | myPoint = P; |
100 | is3D = Standard_True; |
101 | } |
102 | |
103 | //======================================================================= |
104 | //function : Point2d |
105 | //purpose : |
106 | //======================================================================= |
107 | |
108 | gp_Pnt2d DrawTrSurf_Point::Point2d() const |
109 | { |
110 | return gp_Pnt2d(myPoint.X(),myPoint.Y()); |
111 | } |
112 | |
113 | //======================================================================= |
114 | //function : Point2d |
115 | //purpose : |
116 | //======================================================================= |
117 | |
118 | void DrawTrSurf_Point::Point2d(const gp_Pnt2d& P) |
119 | { |
120 | myPoint.SetCoord(P.X(),P.Y(),0); |
121 | is3D = Standard_False; |
122 | } |
123 | |
124 | //======================================================================= |
125 | //function : Color |
126 | //purpose : |
127 | //======================================================================= |
128 | |
129 | void DrawTrSurf_Point::Color(const Draw_Color& aColor) |
130 | { |
131 | myColor = aColor; |
132 | } |
133 | |
134 | //======================================================================= |
135 | //function : Color |
136 | //purpose : |
137 | //======================================================================= |
138 | |
139 | Draw_Color DrawTrSurf_Point::Color() const |
140 | { |
141 | return myColor; |
142 | } |
143 | |
144 | //======================================================================= |
145 | //function : Shape |
146 | //purpose : |
147 | //======================================================================= |
148 | |
149 | void DrawTrSurf_Point::Shape(const Draw_MarkerShape S) |
150 | { |
151 | myShape = S; |
152 | } |
153 | |
154 | //======================================================================= |
155 | //function : Shape |
156 | //purpose : |
157 | //======================================================================= |
158 | |
159 | Draw_MarkerShape DrawTrSurf_Point::Shape() const |
160 | { |
161 | return myShape; |
162 | } |
163 | |
164 | //======================================================================= |
165 | //function : Copy |
166 | //purpose : |
167 | //======================================================================= |
168 | |
169 | Handle(Draw_Drawable3D) DrawTrSurf_Point::Copy() const |
170 | { |
171 | Handle(DrawTrSurf_Point) P; |
172 | if (is3D) |
173 | P = new DrawTrSurf_Point(myPoint,myShape,myColor); |
174 | else |
175 | P = new DrawTrSurf_Point(Point2d(),myShape,myColor); |
176 | |
177 | return P; |
178 | } |
179 | |
180 | //======================================================================= |
181 | //function : Dump |
182 | //purpose : |
183 | //======================================================================= |
184 | |
185 | void DrawTrSurf_Point::Dump(Standard_OStream& S) const |
186 | { |
7c65581d |
187 | #if !defined(_MSC_VER) && !defined(__sgi) && !defined(IRIX) |
7fd59977 |
188 | ios::fmtflags F = S.flags(); |
189 | S.setf(ios::scientific,ios::floatfield); |
190 | S.precision(15); |
191 | #else |
192 | long form = S.setf(ios::scientific); |
60be1f9b |
193 | std::streamsize prec = S.precision(15); |
7fd59977 |
194 | #endif |
195 | if (is3D) |
196 | S << "Point : " << myPoint.X() << ", " << myPoint.Y() << ", " << myPoint.Z() <<endl; |
197 | else |
198 | S << "Point 2d : " << myPoint.X() << ", " << myPoint.Y() <<endl; |
7c65581d |
199 | #if !defined(_MSC_VER) && !defined(__sgi) && !defined(IRIX) |
7fd59977 |
200 | S.setf(F); |
201 | #else |
202 | S.setf(form); |
203 | S.precision(prec); |
204 | #endif |
205 | } |
206 | |
207 | //======================================================================= |
208 | //function : Whatis |
209 | //purpose : |
210 | //======================================================================= |
211 | |
212 | void DrawTrSurf_Point::Whatis(Draw_Interpretor& S) const |
213 | { |
214 | S << "point"; |
215 | } |