0020716: Eliminate usage of "config.h" header file
[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 #include <DrawTrSurf_Point.ixx>
18 #include <Standard_Stream.hxx>
19
20 //=======================================================================
21 //function : DrawTrSurf_Point
22 //purpose  : 
23 //=======================================================================
24
25 DrawTrSurf_Point::DrawTrSurf_Point(const gp_Pnt& P, 
26                                    const Draw_MarkerShape Shape,
27                                    const Draw_Color& Col) :
28        myPoint(P),
29        is3D(Standard_True),
30        myShape(Shape),
31        myColor(Col)
32 {
33 }
34
35 //=======================================================================
36 //function : DrawTrSurf_Point
37 //purpose  : 
38 //=======================================================================
39
40 DrawTrSurf_Point::DrawTrSurf_Point(const gp_Pnt2d& P, 
41                                    const Draw_MarkerShape Shape,
42                                    const Draw_Color& Col) :
43        myPoint(P.X(),P.Y(),0.),
44        is3D(Standard_False),
45        myShape(Shape),
46        myColor(Col)
47 {
48 }
49
50 //=======================================================================
51 //function : Is3D
52 //purpose  : 
53 //=======================================================================
54
55 Standard_Boolean DrawTrSurf_Point::Is3D() const
56 {
57   return is3D;
58 }
59
60 //=======================================================================
61 //function : DrawOn
62 //purpose  : 
63 //=======================================================================
64
65 void DrawTrSurf_Point::DrawOn(Draw_Display& dis) const 
66 {
67   dis.SetColor(myColor);
68   if (is3D)
69     dis.DrawMarker(myPoint,myShape);
70   else
71     dis.DrawMarker(Point2d(),myShape);
72 }
73
74 //=======================================================================
75 //function : Point
76 //purpose  : 
77 //=======================================================================
78
79 gp_Pnt DrawTrSurf_Point::Point() const 
80 {
81   return myPoint;
82 }
83
84 //=======================================================================
85 //function : Point
86 //purpose  : 
87 //=======================================================================
88
89 void DrawTrSurf_Point::Point(const gp_Pnt& P)
90 {
91   myPoint = P;
92   is3D = Standard_True;
93 }
94
95 //=======================================================================
96 //function : Point2d
97 //purpose  : 
98 //=======================================================================
99
100 gp_Pnt2d DrawTrSurf_Point::Point2d() const 
101 {
102   return gp_Pnt2d(myPoint.X(),myPoint.Y());
103 }
104
105 //=======================================================================
106 //function : Point2d
107 //purpose  : 
108 //=======================================================================
109
110 void DrawTrSurf_Point::Point2d(const gp_Pnt2d& P)
111 {
112   myPoint.SetCoord(P.X(),P.Y(),0);
113   is3D = Standard_False;
114 }
115
116 //=======================================================================
117 //function : Color
118 //purpose  : 
119 //=======================================================================
120
121 void DrawTrSurf_Point::Color(const Draw_Color& aColor)
122 {
123   myColor = aColor;
124 }
125
126 //=======================================================================
127 //function : Color
128 //purpose  : 
129 //=======================================================================
130
131 Draw_Color DrawTrSurf_Point::Color() const 
132 {
133   return myColor;
134 }
135
136 //=======================================================================
137 //function : Shape
138 //purpose  : 
139 //=======================================================================
140
141 void DrawTrSurf_Point::Shape(const Draw_MarkerShape S)
142 {
143   myShape = S;
144 }
145
146 //=======================================================================
147 //function : Shape
148 //purpose  : 
149 //=======================================================================
150
151 Draw_MarkerShape DrawTrSurf_Point::Shape() const 
152 {
153   return myShape;
154 }
155
156 //=======================================================================
157 //function : Copy
158 //purpose  : 
159 //=======================================================================
160
161 Handle(Draw_Drawable3D) DrawTrSurf_Point::Copy() const 
162 {
163   Handle(DrawTrSurf_Point) P;
164   if (is3D)
165     P = new DrawTrSurf_Point(myPoint,myShape,myColor);
166   else
167     P = new DrawTrSurf_Point(Point2d(),myShape,myColor);
168     
169   return P;
170 }
171
172 //=======================================================================
173 //function : Dump
174 //purpose  : 
175 //=======================================================================
176
177 void DrawTrSurf_Point::Dump(Standard_OStream& S) const 
178 {
179 #if !defined(_WIN32) && !defined(__sgi) && !defined(IRIX)
180   ios::fmtflags F = S.flags();
181   S.setf(ios::scientific,ios::floatfield);
182   S.precision(15);
183 #else
184   long form = S.setf(ios::scientific);
185   std::streamsize prec = S.precision(15);
186 #endif
187   if (is3D)
188     S << "Point : " << myPoint.X() << ", " << myPoint.Y() << ", " << myPoint.Z() <<endl;
189   else
190     S << "Point 2d : " << myPoint.X() << ", " << myPoint.Y() <<endl;
191 #if !defined(_WIN32) && !defined(__sgi) && !defined(IRIX)
192   S.setf(F);
193 #else
194   S.setf(form);
195   S.precision(prec);
196 #endif
197 }
198
199 //=======================================================================
200 //function : Whatis
201 //purpose  : 
202 //=======================================================================
203
204 void DrawTrSurf_Point::Whatis(Draw_Interpretor& S) const 
205 {
206     S << "point";
207 }