1 #include <Draw_View.hxx>
2 #include <Draw_Viewer.hxx>
6 //=======================================================================
8 //purpose : Constructor
9 //=======================================================================
10 Draw_View::Draw_View(Standard_Integer theId,
11 Draw_Viewer* theViewer,
12 Standard_Integer theX,
13 Standard_Integer theY,
14 Standard_Integer theWidth,
15 Standard_Integer theHeight)
16 : Draw_Window("Win", theX, theY, theWidth, theHeight),
19 myIsPers (Standard_False),
20 myIs2D (Standard_False),
32 //=======================================================================
33 //function : Draw_View
34 //purpose : Constructor
35 //=======================================================================
36 #if defined(_WIN32) || defined(__WIN32__)
37 Draw_View::Draw_View(Standard_Integer theId,
38 Draw_Viewer* theViewer,
39 Standard_Integer theX,
40 Standard_Integer theY,
41 Standard_Integer theWidth,
42 Standard_Integer theHeight,
44 : Draw_Window("Win", theX, theY, theWidth, theHeight, theWindow),
47 myIsPers (Standard_False),
48 myIs2D (Standard_False),
60 //=======================================================================
61 //function : Draw_View
62 //purpose : Constructor
63 //=======================================================================
64 #elif defined(__APPLE__) && !defined(MACOSX_USE_GLX)
65 Draw_View::Draw_View(Standard_Integer theId,
66 Draw_Viewer* theViewer,
67 Standard_Integer theX,
68 Standard_Integer theY,
69 Standard_Integer theWidth,
70 Standard_Integer theHeight,
72 : Draw_Window(theWindow, "Win", theX, theY, theWidth, theHeight),
75 myIsPers (Standard_False),
76 myIs2D (Standard_False),
90 //=======================================================================
91 //function : Draw_View
92 //purpose : Constructor
93 //=======================================================================
94 #if defined(_WIN32) || defined (__WIN32__) || (defined(__APPLE__) && !defined(MACOSX_USE_GLX))
95 Draw_View::Draw_View(Standard_Integer /*theId*/,
96 Draw_Viewer* /*theViewer*/,
97 const char* /*theTitle*/)
102 Draw_View::Draw_View(Standard_Integer theId,
103 Draw_Viewer* theViewer,
104 const char* theTitle)
105 : Draw_Window (theTitle),
107 myViewer (theViewer),
109 myIsPers (Standard_False),
110 myIs2D (Standard_False),
111 myFocalDistance(0.0),
122 //=======================================================================
123 //function : ~Draw_View
124 //purpose : Destructor
125 //=======================================================================
126 Draw_View::~Draw_View()
128 Draw_Window::Destroy();
131 //=======================================================================
134 //=======================================================================
135 Standard_Boolean Draw_View::Init(const char* theType)
138 myFocalDistance = 500.;
139 myIsPers = Standard_False;
140 myIs2D = strcmp("-2D-", theType) ? Standard_False : Standard_True;
147 gp_Pnt Pvise(0.0, 0.0, 0.0);
149 if (!strcmp("+X+Y", theType) || myIs2D)
151 myMatrix = aRotation;
153 else if (!strcmp("-Y+X", theType))
155 const gp_Dir aD(0., 0., 1.);
156 myMatrix.SetRotation(gp_Ax1(Pvise, aD), 0.5 * M_PI);
158 else if (!strcmp("-X-Y", theType))
160 const gp_Dir aD(0., 0., 1.);
161 myMatrix.SetRotation(gp_Ax1(Pvise, aD), M_PI);
163 else if (!strcmp("+Y-X", theType))
165 const gp_Dir aD(0., 0., 1.);
166 myMatrix.SetRotation(gp_Ax1(Pvise, aD), -0.5 * M_PI);
168 else if (!strcmp("+Y+X", theType))
170 const gp_Dir aD1(0., 0., 1.);
171 const gp_Dir aD2(0., 1., 0.);
173 myMatrix.SetRotation (gp_Ax1(Pvise, aD1), -0.5 * M_PI);
174 aRotation.SetRotation(gp_Ax1(Pvise, aD2), M_PI);
175 myMatrix.Multiply(aRotation);
177 else if (!strcmp("-X+Y", theType))
179 const gp_Dir aD(0., 1., 0.);
180 myMatrix.SetRotation(gp_Ax1(Pvise, aD), M_PI);
182 else if (!strcmp("-Y-X", theType))
184 const gp_Dir aD1(0., 0., 1.);
185 const gp_Dir aD2(1., 0., 0.);
187 myMatrix.SetRotation (gp_Ax1(Pvise, aD1), -0.5 * M_PI);
188 aRotation.SetRotation(gp_Ax1(Pvise, aD2), M_PI);
189 myMatrix.Multiply(aRotation);
191 else if (!strcmp("+X-Y", theType))
193 const gp_Dir aD(1., 0., 0.);
194 myMatrix.SetRotation(gp_Ax1(Pvise, aD), M_PI);
196 else if (!strcmp("+X+Z", theType))
198 const gp_Dir aD(1., 0., 0.);
199 myMatrix.SetRotation(gp_Ax1(Pvise, aD), -0.5 * M_PI);
201 else if (!strcmp("-Z+X", theType))
203 const gp_Dir aD1(1., 0., 0.);
204 const gp_Dir aD2(0., 1., 0.);
206 myMatrix.SetRotation (gp_Ax1(Pvise, aD1), -0.5 * M_PI);
207 aRotation.SetRotation(gp_Ax1(Pvise, aD2), -0.5 * M_PI);
208 myMatrix.Multiply(aRotation);
210 else if (!strcmp("-X-Z", theType))
212 const gp_Dir aD1(1., 0., 0.);
213 const gp_Dir aD2(0., 1., 0.);
215 myMatrix.SetRotation (gp_Ax1(Pvise, aD1), -0.5 * M_PI);
216 aRotation.SetRotation(gp_Ax1(Pvise, aD2), -M_PI);
217 myMatrix.Multiply(aRotation);
219 else if (!strcmp("+Z-X", theType))
221 const gp_Dir aD1(1., 0., 0.);
222 const gp_Dir aD2(0., 1., 0.);
224 myMatrix.SetRotation (gp_Ax1(Pvise, aD1), -0.5 * M_PI);
225 aRotation.SetRotation(gp_Ax1(Pvise, aD2), 0.5 * M_PI);
226 myMatrix.Multiply(aRotation);
228 else if (!strcmp("+Z+X", theType))
230 const gp_Dir aD1(1., 0., 0.);
231 const gp_Dir aD2(0., 1., 0.);
233 myMatrix.SetRotation (gp_Ax1(Pvise, aD1), 0.5 * M_PI);
234 aRotation.SetRotation(gp_Ax1(Pvise, aD2), 0.5 * M_PI);
235 myMatrix.Multiply(aRotation);
237 else if (!strcmp("-X+Z", theType))
239 const gp_Dir aD1(1., 0., 0.);
240 const gp_Dir aD2(0., 1., 0.);
242 myMatrix.SetRotation (gp_Ax1(Pvise, aD1), 0.5 * M_PI);
243 aRotation.SetRotation(gp_Ax1(Pvise, aD2), M_PI);
244 myMatrix.Multiply(aRotation);
246 else if (!strcmp("-Z-X", theType))
248 const gp_Dir aD1(1., 0., 0.);
249 const gp_Dir aD2(0., 1., 0.);
251 myMatrix.SetRotation (gp_Ax1(Pvise, aD1), 0.5 * M_PI);
252 aRotation.SetRotation(gp_Ax1(Pvise, aD2), -0.5 * M_PI);
253 myMatrix.Multiply(aRotation);
255 else if (!strcmp("+X-Z", theType))
257 const gp_Dir aD(1., 0., 0.);
258 myMatrix.SetRotation(gp_Ax1(Pvise, aD), 0.5 * M_PI);
260 else if (!strcmp("+Y+Z", theType))
262 const gp_Dir aD1(0., 1., 0.);
263 const gp_Dir aD2(1., 0., 0.);
265 myMatrix.SetRotation (gp_Ax1(Pvise, aD1), -0.5 * M_PI);
266 aRotation.SetRotation(gp_Ax1(Pvise, aD2), -0.5 * M_PI);
267 myMatrix.Multiply(aRotation);
269 else if (!strcmp("-Z+Y", theType))
271 const gp_Dir aD(0., 1., 0.);
272 myMatrix.SetRotation(gp_Ax1(Pvise, aD), -0.5 * M_PI);
274 else if (!strcmp("-Y-Z", theType))
276 const gp_Dir aD1(0., 1., 0.);
277 const gp_Dir aD2(1., 0., 0.);
279 myMatrix.SetRotation (gp_Ax1(Pvise, aD1), -0.5 * M_PI);
280 aRotation.SetRotation(gp_Ax1(Pvise, aD2), 0.5 * M_PI);
281 myMatrix.Multiply(aRotation);
283 else if (!strcmp("+Z-Y", theType))
285 const gp_Dir aD1(0., 1., 0.);
286 const gp_Dir aD2(1., 0., 0.);
288 myMatrix.SetRotation (gp_Ax1(Pvise, aD1), -0.5 * M_PI);
289 aRotation.SetRotation(gp_Ax1(Pvise, aD2), M_PI);
290 myMatrix.Multiply(aRotation);
292 else if (!strcmp("+Z+Y", theType))
294 const gp_Dir aD(0., 1., 0.);
295 myMatrix.SetRotation(gp_Ax1(Pvise, aD), 0.5 * M_PI);
297 else if (!strcmp("-Y+Z", theType))
299 const gp_Dir aD1(0., 1., 0.);
300 const gp_Dir aD2(1., 0., 0.);
302 myMatrix.SetRotation (gp_Ax1(Pvise, aD1), 0.5 * M_PI);
303 aRotation.SetRotation(gp_Ax1(Pvise, aD2), -0.5 * M_PI);
304 myMatrix.Multiply(aRotation);
306 else if (!strcmp("-Z-Y", theType))
308 const gp_Dir aD1(0., 1., 0.);
309 const gp_Dir aD2(1., 0., 0.);
311 myMatrix.SetRotation (gp_Ax1(Pvise, aD1), 0.5 * M_PI);
312 aRotation.SetRotation(gp_Ax1(Pvise, aD2), M_PI);
313 myMatrix.Multiply(aRotation);
315 else if (!strcmp("+Y-Z", theType))
317 const gp_Dir aD1(0., 1., 0.);
318 const gp_Dir aD2(1., 0., 0.);
320 myMatrix.SetRotation (gp_Ax1(Pvise, aD1), 0.5 * M_PI);
321 aRotation.SetRotation(gp_Ax1(Pvise, aD2), 0.5 * M_PI);
322 myMatrix.Multiply(aRotation);
324 else if (!strcmp("AXON", theType))
326 const gp_Dir aD1(1., 0., 0.);
327 const gp_Dir aD2(0., 0., 1.);
329 myMatrix.SetRotation (gp_Ax1(Pvise, aD1), -0.25 * M_PI);
330 aRotation.SetRotation(gp_Ax1(Pvise, aD2), -0.25 * M_PI);
331 myMatrix.Multiply(aRotation);
333 else if (!strcmp("PERS", theType))
335 const gp_Dir aD1(1., 0., 0.);
336 const gp_Dir aD2(0., 0., 1.);
338 myMatrix.SetRotation (gp_Ax1(Pvise, aD1), -0.25 * M_PI);
339 aRotation.SetRotation(gp_Ax1(Pvise, aD2), -0.25 * M_PI);
340 myMatrix.Multiply(aRotation);
342 myIsPers = Standard_True;
346 return Standard_False;
349 strcpy(myType, theType);
350 return Standard_True;
353 //=======================================================================
354 //function : Transform
356 //=======================================================================
357 void Draw_View::Transform(const gp_Trsf& theTransformation)
359 myMatrix.Multiply(theTransformation);
362 //=======================================================================
363 //function : ResetFrame
365 //=======================================================================
366 void Draw_View::ResetFrame()
374 //=======================================================================
375 //function : GetFrame
377 //=======================================================================
378 void Draw_View::GetFrame(Standard_Integer& theX0,Standard_Integer& theY0,
379 Standard_Integer& theX1,Standard_Integer& theY1)
381 if ( myFrameX0 == myFrameX1 )
383 myViewer->GetFrame(myId, theX0, theY0, theX1, theY1);
398 //=======================================================================
401 //=======================================================================
402 void Draw_View::WExpose()
405 myViewer->RepaintView(myId);