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