Update for OCCT 6.5.1. Changing number of arguments of V3d_Plane.
[occt.git] / samples / mfc / standard / 04_Viewer3d / src / Viewer3dView.cpp
... / ...
CommitLineData
1// Viewer3dView.cpp : implementation of the CViewer3dView class
2//
3
4#include "stdafx.h"
5
6#include "Viewer3dView.h"
7
8#include "OCC_MainFrame.h"
9#include "Viewer3dApp.h"
10#include "Viewer3dDoc.h"
11#include "ZClippingDlg.h"
12#include "ZCueingDlg.h"
13#include "ScaleDlg.h"
14#include "ShadingModelDlg.h"
15#include "ModelClippingDlg.h"
16#include "TrihedronDlg.h"
17
18#include <V3d_AmbientLight.hxx>
19#include <V3d_DirectionalLight.hxx>
20#include <V3d_PositionalLight.hxx>
21#include <V3d_PositionLight.hxx>
22#include <V3d_SpotLight.hxx>
23#include <TopoDS_Solid.hxx>
24#include <Precision.hxx>
25#include <Graphic3d_GraphicDriver.hxx>
26
27#define ValZWMin 1
28#define X_Key 0x58
29#define Y_Key 0x59
30#define Z_Key 0x5A
31
32#define ModelClipping
33
34#ifdef _DEBUG
35#undef THIS_FILE
36static char THIS_FILE[] = __FILE__;
37#endif
38
39//gp_Pnt ConvertClickToPoint(Standard_Real x, Standard_Real y, Handle(V3d_View) aView);
40
41 gp_Pnt p1,p2,p3;
42 Handle(AIS_Shape) spotConeShape=new AIS_Shape(TopoDS_Solid());
43 Handle(AIS_Shape) directionalEdgeShape=new AIS_Shape(TopoDS_Edge());
44
45/////////////////////////////////////////////////////////////////////////////
46// CViewer3dView
47
48IMPLEMENT_DYNCREATE(CViewer3dView, CView)
49
50BEGIN_MESSAGE_MAP(CViewer3dView, CView)
51 //{{AFX_MSG_MAP(CViewer3dView)
52 ON_COMMAND(ID_BUTTONAxo, OnBUTTONAxo)
53 ON_COMMAND(ID_BUTTONBack, OnBUTTONBack)
54 ON_COMMAND(ID_BUTTONBottom, OnBUTTONBottom)
55 ON_COMMAND(ID_BUTTONFront, OnBUTTONFront)
56 ON_COMMAND(ID_BUTTONHlrOff, OnBUTTONHlrOff)
57 ON_COMMAND(ID_BUTTONHlrOn, OnBUTTONHlrOn)
58 ON_COMMAND(ID_BUTTONLeft, OnBUTTONLeft)
59 ON_COMMAND(ID_BUTTONPan, OnBUTTONPan)
60 ON_COMMAND(ID_BUTTONPanGlo, OnBUTTONPanGlo)
61 ON_COMMAND(ID_BUTTONReset, OnBUTTONReset)
62 ON_COMMAND(ID_BUTTONRight, OnBUTTONRight)
63 ON_COMMAND(ID_BUTTONRot, OnBUTTONRot)
64 ON_COMMAND(ID_BUTTONTop, OnBUTTONTop)
65 ON_COMMAND(ID_BUTTONZoomAll, OnBUTTONZoomAll)
66 ON_WM_SIZE()
67 ON_COMMAND(ID_BUTTONZoomProg, OnBUTTONZoomProg)
68 ON_COMMAND(ID_BUTTONZoomWin, OnBUTTONZoomWin)
69 ON_WM_LBUTTONDOWN()
70 ON_WM_KEYDOWN()
71 ON_WM_LBUTTONUP()
72 ON_WM_MBUTTONDOWN()
73 ON_WM_MBUTTONUP()
74 ON_WM_MOUSEMOVE()
75 ON_WM_RBUTTONDOWN()
76 ON_WM_RBUTTONUP()
77 ON_UPDATE_COMMAND_UI(ID_BUTTONHlrOff, OnUpdateBUTTONHlrOff)
78 ON_UPDATE_COMMAND_UI(ID_BUTTONHlrOn, OnUpdateBUTTONHlrOn)
79 ON_UPDATE_COMMAND_UI(ID_BUTTONPanGlo, OnUpdateBUTTONPanGlo)
80 ON_UPDATE_COMMAND_UI(ID_BUTTONPan, OnUpdateBUTTONPan)
81 ON_UPDATE_COMMAND_UI(ID_BUTTONZoomProg, OnUpdateBUTTONZoomProg)
82 ON_UPDATE_COMMAND_UI(ID_BUTTONZoomWin, OnUpdateBUTTONZoomWin)
83 ON_UPDATE_COMMAND_UI(ID_BUTTONRot, OnUpdateBUTTONRot)
84 ON_COMMAND(ID_Modify_ChangeBackground , OnModifyChangeBackground)
85 ON_COMMAND(ID_DIRECTIONAL_LIGHT, OnDirectionalLight)
86 ON_COMMAND(ID_SPOT_LIGHT, OnSpotLight)
87 ON_COMMAND(ID_POSITIONAL_LIGHT, OnPositionalLight)
88 ON_COMMAND(ID_AMBIENT_LIGHT, OnAmbientLight)
89 ON_COMMAND(ID_ZCUEING, OnZcueing)
90 ON_COMMAND(ID_SCALE, OnScale)
91 ON_COMMAND(ID_ZCLIPPING, OnZclipping)
92 ON_COMMAND(ID_SHADINGMODEL, OnShadingmodel)
93 ON_COMMAND(ID_ANTIALIASINGONOFF, OnAntialiasingonoff)
94 ON_COMMAND(ID_CLEAR_LIGHTS, OnClearLights)
95 ON_COMMAND(ID_MODELCLIPPING, OnModelclipping)
96 ON_COMMAND(ID_OPTIONS_TRIHEDRON_STATIC_TRIHEDRON, OnOptionsTrihedronStaticTrihedron)
97 //}}AFX_MSG_MAP
98END_MESSAGE_MAP()
99
100/////////////////////////////////////////////////////////////////////////////
101// CViewer3dView construction/destruction
102
103CViewer3dView::CViewer3dView()
104{
105 // TODO: add construction code here
106 myXmin=0;
107 myYmin=0;
108 myXmax=0;
109 myYmax=0;
110 myCurZoom=0;
111 myWidth=0;
112 myHeight=0;
113
114 scaleX = 1;
115 scaleY = 1;
116 scaleZ = 1;
117
118 myAxisKey = 0;
119 myScaleDirection = 0;
120
121
122 myVisMode = VIS_SHADE;
123
124 // will be set in OnInitial update, but, for more security :
125 myCurrentMode = CurAction3d_Nothing;
126 myDegenerateModeIsOn=Standard_True;
127 m_Pen = NULL;
128 NbActiveLights=2; // There are 2 default active lights
129 myGraphicDriver = Handle(Graphic3d_GraphicDriver)::DownCast(
130 ((CViewer3dApp*)AfxGetApp())->GetGraphicDevice()->GraphicDriver() );
131}
132
133CViewer3dView::~CViewer3dView()
134{
135 myView->Remove();
136 if (m_Pen) delete m_Pen;
137}
138
139BOOL CViewer3dView::PreCreateWindow(CREATESTRUCT& cs)
140{
141 // TODO: Modify the Window class or styles here by modifying
142 // the CREATESTRUCT cs
143
144 return CView::PreCreateWindow(cs);
145}
146
147/////////////////////////////////////////////////////////////////////////////
148// CViewer3dView drawing
149void CViewer3dView::OnInitialUpdate()
150{
151 CView::OnInitialUpdate();
152
153
154 myView = GetDocument()->GetViewer()->CreateView();
155
156 // set the default mode in wireframe ( not hidden line ! )
157 myView->SetDegenerateModeOn();
158 // store for restore state after rotation (witch is in Degenerated mode)
159 myDegenerateModeIsOn = Standard_True;
160
161
162 Handle(Graphic3d_WNTGraphicDevice) theGraphicDevice =
163 ((CViewer3dApp*)AfxGetApp())->GetGraphicDevice();
164
165 Handle(WNT_Window) aWNTWindow = new WNT_Window(theGraphicDevice,GetSafeHwnd ());
166 myView->SetWindow(aWNTWindow);
167 if (!aWNTWindow->IsMapped()) aWNTWindow->Map();
168
169// Standard_Integer w=100 , h=100 ; /* Debug Matrox */
170// aWNTWindow->Size (w,h) ; /* Keeps me unsatisfied (rlb)..... */
171 /* Resize is not supposed to be done on */
172 /* Matrox */
173 /* I suspect another problem elsewhere */
174// ::PostMessage ( GetSafeHwnd () , WM_SIZE , SIZE_RESTORED , w + h*65536 ) ;
175
176 // store the mode ( nothing , dynamic zooming, dynamic ... )
177 myCurrentMode = CurAction3d_Nothing;
178 myVisMode = VIS_SHADE;
179 RedrawVisMode();
180}
181
182void CViewer3dView::OnDraw(CDC* pDC)
183{
184 CViewer3dDoc* pDoc = GetDocument();
185 ASSERT_VALID(pDoc);
186 CRect aRect;
187 GetWindowRect(aRect);
188 if(myWidth != aRect.Width() || myHeight != aRect.Height()) {
189 myWidth = aRect.Width();
190 myHeight = aRect.Height();
191 ::PostMessage ( GetSafeHwnd () , WM_SIZE , SW_SHOW , myWidth + myHeight*65536 );
192 }
193 myView->Redraw();
194
195}
196
197/////////////////////////////////////////////////////////////////////////////
198// CViewer3dView diagnostics
199
200#ifdef _DEBUG
201void CViewer3dView::AssertValid() const
202{
203 CView::AssertValid();
204}
205
206void CViewer3dView::Dump(CDumpContext& dc) const
207{
208 CView::Dump(dc);
209}
210
211CViewer3dDoc* CViewer3dView::GetDocument() // non-debug version is inline
212{
213 ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CViewer3dDoc)));
214 return (CViewer3dDoc*)m_pDocument;
215}
216#endif //_DEBUG
217
218/////////////////////////////////////////////////////////////////////////////
219// CViewer3dView message handlers
220
221gp_Pnt ConvertClickToPoint(Standard_Real x, Standard_Real y, Handle(V3d_View) aView)
222{
223 V3d_Coordinate XEye,YEye,ZEye,XAt,YAt,ZAt;
224 aView->Eye(XEye,YEye,ZEye);
225 aView->At(XAt,YAt,ZAt);
226 gp_Pnt EyePoint(XEye,YEye,ZEye);
227 gp_Pnt AtPoint(XAt,YAt,ZAt);
228
229 gp_Vec EyeVector(EyePoint,AtPoint);
230 gp_Dir EyeDir(EyeVector);
231
232 gp_Pln PlaneOfTheView = gp_Pln(AtPoint,EyeDir);
233 Standard_Real X,Y,Z;
234 aView->Convert(int(x),int(y),X,Y,Z);
235 gp_Pnt ConvertedPoint(X,Y,Z);
236 gp_Pnt2d ConvertedPointOnPlane = ProjLib::Project(PlaneOfTheView,ConvertedPoint);
237
238 gp_Pnt ResultPoint = ElSLib::Value(ConvertedPointOnPlane.X(),
239 ConvertedPointOnPlane.Y(),
240 PlaneOfTheView);
241 return ResultPoint;
242}
243
244void CViewer3dView::OnSize(UINT nType, int cx, int cy)
245{
246 if (!myView.IsNull())
247 myView->MustBeResized();
248}
249
250void CViewer3dView::OnBUTTONBack()
251{
252 myView->SetProj(V3d_Xneg);
253
254TCollection_AsciiString Message("\
255myView->SetProj(V3d_Xneg);\n\
256 ");
257
258 // Update The Result Message Dialog
259GetDocument()->UpdateResultMessageDlg("SetProj",Message);
260} // See the back View
261void CViewer3dView::OnBUTTONFront()
262{
263 myView->SetProj(V3d_Xpos);
264
265TCollection_AsciiString Message("\
266myView->SetProj(V3d_Xpos);\n\
267 ");
268
269 // Update The Result Message Dialog
270GetDocument()->UpdateResultMessageDlg("SetProj",Message);
271} // See the front View
272
273void CViewer3dView::OnBUTTONBottom()
274{
275 myView->SetProj(V3d_Zneg);
276
277TCollection_AsciiString Message("\
278myView->SetProj(V3d_Zneg);\n\
279 ");
280
281 // Update The Result Message Dialog
282GetDocument()->UpdateResultMessageDlg("SetProj",Message);
283} // See the bottom View
284void CViewer3dView::OnBUTTONTop()
285{
286 myView->SetProj(V3d_Zpos);
287
288TCollection_AsciiString Message("\
289myView->SetProj(V3d_Zpos);\n\
290 ");
291
292 // Update The Result Message Dialog
293GetDocument()->UpdateResultMessageDlg("SetProj",Message);
294} // See the top View
295
296void CViewer3dView::OnBUTTONLeft()
297{
298 myView->SetProj(V3d_Ypos);
299
300TCollection_AsciiString Message("\
301myView->SetProj(V3d_Ypos);\n\
302 ");
303
304 // Update The Result Message Dialog
305GetDocument()->UpdateResultMessageDlg("SetProj",Message);
306} // See the left View
307void CViewer3dView::OnBUTTONRight()
308{
309 myView->SetProj(V3d_Yneg);
310
311TCollection_AsciiString Message("\
312myView->SetProj(V3d_Yneg);\n\
313 ");
314
315 // Update The Result Message Dialog
316GetDocument()->UpdateResultMessageDlg("SetProj",Message);
317} // See the right View
318
319void CViewer3dView::OnBUTTONAxo()
320{
321 myView->SetProj(V3d_XposYnegZpos);
322
323TCollection_AsciiString Message("\
324myView->SetProj(V3d_XposYnegZpos);\n\
325 ");
326
327 // Update The Result Message Dialog
328GetDocument()->UpdateResultMessageDlg("SetProj",Message);
329} // See the axonometric View
330
331void CViewer3dView::OnBUTTONHlrOff()
332{
333 myView->SetDegenerateModeOn();
334 myDegenerateModeIsOn = Standard_True;
335
336TCollection_AsciiString Message("\
337myView->SetDegenerateModeOn();\n\
338 ");
339
340 // Update The Result Message Dialog
341GetDocument()->UpdateResultMessageDlg("SetDegenerateModeOn",Message);
342}
343
344void CViewer3dView::OnBUTTONHlrOn()
345{
346 SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT));
347 myView->SetDegenerateModeOff();
348 myDegenerateModeIsOn = Standard_False;
349 SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW));
350
351TCollection_AsciiString Message("\
352myView->SetDegenerateModeOff();\n\
353 ");
354
355 // Update The Result Message Dialog
356GetDocument()->UpdateResultMessageDlg("SetDegenerateModeOff",Message);
357}
358
359void CViewer3dView::OnBUTTONPan()
360{ myCurrentMode = CurAction3d_DynamicPanning; }
361
362void CViewer3dView::OnBUTTONPanGlo()
363{
364 // save the current zoom value
365 myCurZoom = myView->Scale();
366 // Do a Global Zoom
367 myView->FitAll();
368 // Set the mode
369 myCurrentMode = CurAction3d_GlobalPanning;
370}
371
372void CViewer3dView::OnBUTTONReset()
373{ myView->Reset(); }
374
375void CViewer3dView::OnBUTTONRot()
376{ myCurrentMode = CurAction3d_DynamicRotation; }
377
378
379void CViewer3dView::OnBUTTONZoomAll()
380{
381 myView->FitAll();
382 myView->ZFitAll();
383}
384
385void CViewer3dView::OnBUTTONZoomProg()
386{ myCurrentMode = CurAction3d_DynamicZooming; }
387
388void CViewer3dView::OnBUTTONZoomWin()
389{ myCurrentMode = CurAction3d_WindowZooming; }
390
391void CViewer3dView::OnLButtonDown(UINT nFlags, CPoint point)
392{
393 // save the current mouse coordinate in min
394 myXmin=point.x; myYmin=point.y;
395 myXmax=point.x; myYmax=point.y;
396
397 if ( nFlags & MK_CONTROL )
398 {
399 // Button MB1 down Control :start zomming
400 // SetCursor(AfxGetApp()->LoadStandardCursor());
401 }
402 else // if ( Ctrl )
403 {
404 switch (myCurrentMode)
405 {
406 case CurAction3d_Nothing : // start a drag
407 if (nFlags & MK_SHIFT)
408 GetDocument()->ShiftDragEvent(myXmax,myYmax,-1,myView);
409 else
410 GetDocument()->DragEvent(myXmax,myYmax,-1,myView);
411 break;
412 break;
413 case CurAction3d_DynamicZooming : // noting
414 break;
415 case CurAction3d_WindowZooming :
416 break;
417 case CurAction3d_DynamicPanning :// noting
418 break;
419 case CurAction3d_GlobalPanning :// noting
420 break;
421 case CurAction3d_DynamicRotation :
422 if (!myDegenerateModeIsOn)
423 myView->SetDegenerateModeOn();
424 myView->StartRotation(point.x,point.y);
425 break;
426 case CurAction3d_BeginPositionalLight :
427 {
428 p1 = ConvertClickToPoint(point.x,point.y,myView);
429 myCurrent_PositionalLight->SetPosition(p1.X(),p1.Y(),p1.Z()) ;
430 GetDocument()->GetAISContext()->CloseLocalContext();
431 ((OCC_MainFrame*)AfxGetMainWnd())->SetStatusMessage("Ready");
432 myCurrentMode = CurAction3d_Nothing;
433
434TCollection_AsciiString Message("\
435myCurrent_PositionalLight->SetPosition(Xp, Yp, Zp) ;\n\
436");
437// Update The Result Message Dialog
438GetDocument()->UpdateResultMessageDlg("SetPosition",Message);
439 }
440 break;
441 case CurAction3d_BeginSpotLight :
442 {
443 p1 = ConvertClickToPoint(point.x,point.y,myView);
444 myCurrent_SpotLight = new V3d_SpotLight(myView->Viewer(),0.,0.,1., p1.X(),p1.Y(),p1.Z(),Quantity_NOC_RED);
445 myView->SetLightOn(myCurrent_SpotLight);
446 NbActiveLights++;
447 p2 = gp_Pnt(p1.X(),p1.Y(),p1.Z()+1.);
448 Standard_Real coneHeigth=p1.Distance(p2);
449 BRepPrimAPI_MakeCone MakeCone(gp_Ax2(p1, gp_Dir(gp_Vec(p1, p2))),
450 0, (p1.Distance(p2))/tan(1.04), coneHeigth);
451 spotConeShape->Set(MakeCone.Solid());
452 GetDocument()->GetAISContext()->Display(spotConeShape,0,-1);
453 ((OCC_MainFrame*)AfxGetMainWnd())->SetStatusMessage("Pick the target point");
454 myCurrentMode = CurAction3d_TargetSpotLight;
455
456TCollection_AsciiString Message("\
457myCurrent_SpotLight->SetDirection(Xv, Yv, Zv);\n\
458");
459// Update The Result Message Dialog
460GetDocument()->UpdateResultMessageDlg("SetDirection",Message);
461 }
462 break;
463 case CurAction3d_TargetSpotLight :
464 {
465 p2 = ConvertClickToPoint(point.x,point.y,myView);
466 ((OCC_MainFrame*)AfxGetMainWnd())->SetStatusMessage("Pick a third point (to define the angle)");
467 myCurrentMode = CurAction3d_EndSpotLight;
468
469TCollection_AsciiString Message("\
470myCurrent_SpotLight->SetAngle(Angle) ;\n\
471");
472// Update The Result Message Dialog
473GetDocument()->UpdateResultMessageDlg("SetAngle",Message);
474 }
475 break;
476 case CurAction3d_EndSpotLight :
477 GetDocument()->GetAISContext()->Erase(spotConeShape);
478 GetDocument()->GetAISContext()->CloseLocalContext();
479 ((OCC_MainFrame*)AfxGetMainWnd())->SetStatusMessage("Ready");
480 myCurrentMode = CurAction3d_Nothing;
481 break;
482 case CurAction3d_BeginDirectionalLight:
483 {
484 p1 = ConvertClickToPoint(point.x,point.y,myView);
485 p2 = gp_Pnt(p1.X(),p1.Y(),p1.Z()+1.);
486 BRepBuilderAPI_MakeEdge MakeEdge(p1, p2);
487 directionalEdgeShape->Set(MakeEdge.Edge());
488 GetDocument()->GetAISContext()->Display(directionalEdgeShape,0,-1);
489 // Create a directional light
490 myCurrent_DirectionalLight = new V3d_DirectionalLight(myView->Viewer(), p1.X(),p1.Y(),p1.Z(),0.,0.,1.);
491 myView->SetLightOn(myCurrent_DirectionalLight);
492 NbActiveLights++;
493 ((OCC_MainFrame*)AfxGetMainWnd())->SetStatusMessage("Pick the target point");
494 myCurrentMode = CurAction3d_EndDirectionalLight;
495
496
497TCollection_AsciiString Message("\
498myCurrent_DirectionalLight->SetDirection(Xv, Yv, Zv);\n\
499");
500// Update The Result Message Dialog
501GetDocument()->UpdateResultMessageDlg("SetDirection",Message);
502 }
503 break;
504 case CurAction3d_EndDirectionalLight:
505 GetDocument()->GetAISContext()->Erase(directionalEdgeShape);
506 GetDocument()->GetAISContext()->CloseLocalContext();
507 ((OCC_MainFrame*)AfxGetMainWnd())->SetStatusMessage("Ready");
508 myCurrentMode = CurAction3d_Nothing;
509 break;
510 }
511 }
512}
513
514void CViewer3dView::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
515{
516
517 if( nChar == X_Key || nChar == Y_Key || nChar == Z_Key )
518 myAxisKey = nChar;
519 else if( (nChar == VK_ADD || nChar == VK_SUBTRACT) && myAxisKey )
520 {
521 myScaleDirection = nChar;
522 if( myAxisKey && myScaleDirection )
523 {
524 switch( myAxisKey )
525 {
526 case X_Key:
527 if( myScaleDirection == VK_ADD ) scaleX ++;
528 if( myScaleDirection == VK_SUBTRACT ) scaleX --;
529 break;
530 case Y_Key:
531 if( myScaleDirection == VK_ADD ) scaleY ++;
532 if( myScaleDirection == VK_SUBTRACT ) scaleY --;
533 break;
534 case Z_Key:
535 if( myScaleDirection == VK_ADD ) scaleZ ++;
536 if( myScaleDirection == VK_SUBTRACT ) scaleZ --;
537 break;
538 default:
539 break;
540 }
541 if( scaleX < 1 ) scaleX = 1;
542 if( scaleY < 1 ) scaleY = 1;
543 if( scaleZ < 1 ) scaleZ = 1;
544
545 myView->SetAxialScale( scaleX, scaleY, scaleZ );
546 }
547 }
548}
549
550void CViewer3dView::OnLButtonUp(UINT nFlags, CPoint point)
551{
552 if ( nFlags & MK_CONTROL )
553 {
554 return;
555 }
556 else // if ( Ctrl )
557 {
558 switch (myCurrentMode)
559 {
560 case CurAction3d_Nothing :
561 if (point.x == myXmin && point.y == myYmin)
562 { // no offset between down and up --> selectEvent
563 myXmax=point.x;
564 myYmax=point.y;
565 if (nFlags & MK_SHIFT )
566 GetDocument()->ShiftInputEvent(point.x,point.y,myView);
567 else
568 GetDocument()->InputEvent (point.x,point.y,myView);
569 } else
570 {
571 DrawRectangle(myXmin,myYmin,myXmax,myYmax,Standard_False);
572 myXmax=point.x;
573 myYmax=point.y;
574 if (nFlags & MK_SHIFT)
575 GetDocument()->ShiftDragEvent(point.x,point.y,1,myView);
576 else
577 GetDocument()->DragEvent(point.x,point.y,1,myView);
578 }
579 break;
580 case CurAction3d_DynamicZooming :
581 // SetCursor(AfxGetApp()->LoadStandardCursor());
582 myCurrentMode = CurAction3d_Nothing;
583 break;
584 case CurAction3d_WindowZooming :
585 DrawRectangle(myXmin,myYmin,myXmax,myYmax,Standard_False);
586 myXmax=point.x;
587 myYmax=point.y;
588 if ((abs(myXmin-myXmax)>ValZWMin) || (abs(myYmin-myYmax)>ValZWMin))
589 // Test if the zoom window is greater than a minimale window.
590 {
591 // Do the zoom window between Pmin and Pmax
592 myView->WindowFitAll(myXmin,myYmin,myXmax,myYmax);
593 }
594 myCurrentMode = CurAction3d_Nothing;
595 break;
596 case CurAction3d_DynamicPanning :
597 myCurrentMode = CurAction3d_Nothing;
598 break;
599 case CurAction3d_GlobalPanning :
600 myView->Place(point.x,point.y,myCurZoom);
601 myCurrentMode = CurAction3d_Nothing;
602 break;
603 case CurAction3d_DynamicRotation :
604 myCurrentMode = CurAction3d_Nothing;
605 break;
606 } //switch (myCurrentMode)
607 } // else // if ( Ctrl )
608}
609
610void CViewer3dView::OnMButtonDown(UINT nFlags, CPoint point)
611{
612 if ( nFlags & MK_CONTROL )
613 {
614 // Button MB2 down Control : panning init
615 // SetCursor(AfxGetApp()->LoadStandardCursor());
616 }
617}
618
619void CViewer3dView::OnMButtonUp(UINT nFlags, CPoint point)
620{
621 if ( nFlags & MK_CONTROL )
622 {
623 // Button MB2 down Control : panning init
624 // SetCursor(AfxGetApp()->LoadStandardCursor());
625 }
626}
627
628void CViewer3dView::OnRButtonDown(UINT nFlags, CPoint point)
629{
630 if ( nFlags & MK_CONTROL )
631 {
632 // SetCursor(AfxGetApp()->LoadStandardCursor());
633 if (!myDegenerateModeIsOn)
634 myView->SetDegenerateModeOn();
635 myView->StartRotation(point.x,point.y);
636 }
637 else // if ( Ctrl )
638 {
639 GetDocument()->Popup(point.x,point.y,myView);
640 }
641}
642
643void CViewer3dView::OnRButtonUp(UINT nFlags, CPoint point)
644{
645 SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT));
646 if (!myDegenerateModeIsOn)
647 {
648 myView->SetDegenerateModeOff();
649 myDegenerateModeIsOn = Standard_False;
650 } else
651 {
652 myView->SetDegenerateModeOn();
653 myDegenerateModeIsOn = Standard_True;
654 }
655 SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW));
656}
657
658void CViewer3dView::OnMouseMove(UINT nFlags, CPoint point)
659{
660 // ============================ LEFT BUTTON =======================
661 if ( nFlags & MK_LBUTTON)
662 {
663 if ( nFlags & MK_CONTROL )
664 {
665 // move with MB1 and Control : on the dynamic zooming
666 // Do the zoom in function of mouse's coordinates
667 myView->Zoom(myXmax,myYmax,point.x,point.y);
668 // save the current mouse coordinate in min
669 myXmax = point.x;
670 myYmax = point.y;
671 }
672 else // if ( Ctrl )
673 {
674 switch (myCurrentMode)
675 {
676 case CurAction3d_Nothing :
677 myXmax = point.x; myYmax = point.y;
678 DrawRectangle(myXmin,myYmin,myXmax,myYmax,Standard_False);
679 if (nFlags & MK_SHIFT)
680 GetDocument()->ShiftDragEvent(myXmax,myYmax,0,myView);
681 else
682 GetDocument()->DragEvent(myXmax,myYmax,0,myView);
683 DrawRectangle(myXmin,myYmin,myXmax,myYmax,Standard_True);
684 break;
685 case CurAction3d_DynamicZooming :
686 myView->Zoom(myXmax,myYmax,point.x,point.y);
687 // save the current mouse coordinate in min \n";
688 myXmax=point.x; myYmax=point.y;
689 break;
690 case CurAction3d_WindowZooming :
691 myXmax = point.x; myYmax = point.y;
692 DrawRectangle(myXmin,myYmin,myXmax,myYmax,Standard_False,LongDash);
693 DrawRectangle(myXmin,myYmin,myXmax,myYmax,Standard_True,LongDash);
694
695 break;
696 case CurAction3d_DynamicPanning :
697 myView->Pan(point.x-myXmax,myYmax-point.y); // Realize the panning
698 myXmax = point.x; myYmax = point.y;
699 break;
700 case CurAction3d_GlobalPanning : // nothing
701 break;
702 case CurAction3d_DynamicRotation :
703 myView->Rotation(point.x,point.y);
704 myView->Redraw();
705 break;
706 }// switch (myCurrentMode)
707 }// if ( nFlags & MK_CONTROL ) else
708 } else // if ( nFlags & MK_LBUTTON)
709 // ============================ MIDDLE BUTTON =======================
710 if ( nFlags & MK_MBUTTON)
711 {
712 if ( nFlags & MK_CONTROL )
713 {
714 myView->Pan(point.x-myXmax,myYmax-point.y); // Realize the panning
715 myXmax = point.x; myYmax = point.y;
716
717 }
718 } else // if ( nFlags & MK_MBUTTON)
719 // ============================ RIGHT BUTTON =======================
720 if ( nFlags & MK_RBUTTON)
721 {
722 if ( nFlags & MK_CONTROL )
723 {
724 myView->Rotation(point.x,point.y);
725 }
726 }else //if ( nFlags & MK_RBUTTON)
727 // ============================ NO BUTTON =======================
728 { // No buttons
729 myXmax = point.x; myYmax = point.y;
730 if (myCurrentMode == CurAction3d_EndDirectionalLight)
731 {
732 p2 = ConvertClickToPoint(point.x,point.y,myView);
733 //Update the light dynamically
734 if( p1.Distance(p2)>Precision::Confusion())
735 {
736 BRepBuilderAPI_MakeEdge MakeEdge(p1, p2);
737 directionalEdgeShape->Set(MakeEdge.Edge());
738 GetDocument()->GetAISContext()->Redisplay(directionalEdgeShape,0,-1);
739 myCurrent_DirectionalLight->SetDirection(p2.X()-p1.X(),p2.Y()-p1.Y(),p2.Z()-p1.Z());
740 myView->UpdateLights();
741 }
742 }
743 else if (myCurrentMode == CurAction3d_BeginPositionalLight)
744 {
745 p2 = ConvertClickToPoint(point.x,point.y,myView);
746 //Update the light dynamically
747 myCurrent_PositionalLight->SetPosition(p2.X(),p2.Y(),p2.Z());
748 myView->UpdateLights();
749 }
750 else if (myCurrentMode == CurAction3d_TargetSpotLight)
751 {
752 p2 = ConvertClickToPoint(point.x,point.y,myView);
753 //Update the light dynamically
754 Standard_Real coneHeigth=p1.Distance(p2);
755 if( coneHeigth>Precision::Confusion())
756 {
757 BRepPrimAPI_MakeCone MakeCone(gp_Ax2(p1, gp_Dir(gp_Vec(p1, p2))),
758 0, (p1.Distance(p2))/tan(1.04), coneHeigth);
759 spotConeShape->Set(MakeCone.Solid());
760 GetDocument()->GetAISContext()->Redisplay(spotConeShape,0,-1);
761 myCurrent_SpotLight->SetDirection(p2.X()-p1.X(),p2.Y()-p1.Y(),p2.Z()-p1.Z());
762 myView->UpdateLights();
763 }
764 }
765 else if (myCurrentMode == CurAction3d_EndSpotLight)
766 {
767 p3 = ConvertClickToPoint(point.x,point.y,myView);
768 //Update the light dynamically
769 Standard_Real coneHeigth=p1.Distance(p2);
770 if( (p2.Distance(p3))>Precision::Confusion())
771 {
772 BRepPrimAPI_MakeCone MakeCone(gp_Ax2(p1, gp_Dir(gp_Vec(p1, p2))),
773 0, p2.Distance(p3), coneHeigth);
774 spotConeShape->Set(MakeCone.Solid());
775 GetDocument()->GetAISContext()->Redisplay(spotConeShape,0,-1);
776 myCurrent_SpotLight->SetAngle(atan(p2.Distance(p3)/p1.Distance(p2))) ;
777 myView->UpdateLights();
778 }
779 }
780 if (nFlags & MK_SHIFT)
781 GetDocument()->ShiftMoveEvent(point.x,point.y,myView);
782 else
783 GetDocument()->MoveEvent(point.x,point.y,myView);
784 }
785}
786
787void CViewer3dView::OnUpdateBUTTONHlrOff(CCmdUI* pCmdUI)
788{
789 pCmdUI->SetCheck (myDegenerateModeIsOn);
790 pCmdUI->Enable (!myDegenerateModeIsOn);
791}
792
793void CViewer3dView::OnUpdateBUTTONHlrOn(CCmdUI* pCmdUI)
794{
795 pCmdUI->SetCheck (!myDegenerateModeIsOn);
796 pCmdUI->Enable (myDegenerateModeIsOn);
797}
798
799void CViewer3dView::OnUpdateBUTTONPanGlo(CCmdUI* pCmdUI)
800{
801 pCmdUI->SetCheck (myCurrentMode == CurAction3d_GlobalPanning);
802 pCmdUI->Enable (myCurrentMode != CurAction3d_GlobalPanning);
803
804}
805
806void CViewer3dView::OnUpdateBUTTONPan(CCmdUI* pCmdUI)
807{
808 pCmdUI->SetCheck (myCurrentMode == CurAction3d_DynamicPanning);
809 pCmdUI->Enable (myCurrentMode != CurAction3d_DynamicPanning );
810}
811
812void CViewer3dView::OnUpdateBUTTONZoomProg(CCmdUI* pCmdUI)
813{
814 pCmdUI->SetCheck (myCurrentMode == CurAction3d_DynamicZooming );
815 pCmdUI->Enable (myCurrentMode != CurAction3d_DynamicZooming);
816}
817
818void CViewer3dView::OnUpdateBUTTONZoomWin(CCmdUI* pCmdUI)
819{
820 pCmdUI->SetCheck (myCurrentMode == CurAction3d_WindowZooming);
821 pCmdUI->Enable (myCurrentMode != CurAction3d_WindowZooming);
822}
823
824void CViewer3dView::OnUpdateBUTTONRot(CCmdUI* pCmdUI)
825{
826 pCmdUI->SetCheck (myCurrentMode == CurAction3d_DynamicRotation);
827 pCmdUI->Enable (myCurrentMode != CurAction3d_DynamicRotation);
828}
829
830void CViewer3dView::DrawRectangle(const Standard_Integer MinX ,
831 const Standard_Integer MinY ,
832 const Standard_Integer MaxX ,
833 const Standard_Integer MaxY ,
834 const Standard_Boolean Draw ,
835 const LineStyle aLineStyle)
836{
837 static int m_DrawMode;
838 if (!m_Pen && aLineStyle ==Solid )
839 {m_Pen = new CPen(PS_SOLID, 1, RGB(0,0,0)); m_DrawMode = R2_MERGEPENNOT;}
840 else if (!m_Pen && aLineStyle ==Dot )
841 {m_Pen = new CPen(PS_DOT, 1, RGB(0,0,0)); m_DrawMode = R2_XORPEN;}
842 else if (!m_Pen && aLineStyle == ShortDash)
843 {m_Pen = new CPen(PS_DASH, 1, RGB(255,0,0)); m_DrawMode = R2_XORPEN;}
844 else if (!m_Pen && aLineStyle == LongDash)
845 {m_Pen = new CPen(PS_DASH, 1, RGB(0,0,0)); m_DrawMode = R2_NOTXORPEN;}
846 else if (aLineStyle == Default)
847 { m_Pen = NULL; m_DrawMode = R2_MERGEPENNOT;}
848
849 CPen* aOldPen;
850 CClientDC clientDC(this);
851 if (m_Pen) aOldPen = clientDC.SelectObject(m_Pen);
852 clientDC.SetROP2(m_DrawMode);
853
854 static Standard_Integer StoredMinX, StoredMaxX, StoredMinY, StoredMaxY;
855 static Standard_Boolean m_IsVisible;
856
857 if ( m_IsVisible && !Draw) // move or up : erase at the old position
858 {
859 clientDC.MoveTo(StoredMinX,StoredMinY);
860 clientDC.LineTo(StoredMinX,StoredMaxY);
861 clientDC.LineTo(StoredMaxX,StoredMaxY);
862 clientDC.LineTo(StoredMaxX,StoredMinY);
863 clientDC.LineTo(StoredMinX,StoredMinY);
864 m_IsVisible = false;
865 }
866
867 StoredMinX = min ( MinX, MaxX );
868 StoredMinY = min ( MinY, MaxY );
869 StoredMaxX = max ( MinX, MaxX );
870 StoredMaxY = max ( MinY, MaxY);
871
872 if (Draw) // move : draw
873 {
874 clientDC.MoveTo(StoredMinX,StoredMinY);
875 clientDC.LineTo(StoredMinX,StoredMaxY);
876 clientDC.LineTo(StoredMaxX,StoredMaxY);
877 clientDC.LineTo(StoredMaxX,StoredMinY);
878 clientDC.LineTo(StoredMinX,StoredMinY);
879 m_IsVisible = true;
880 }
881
882 if (m_Pen)
883 clientDC.SelectObject(aOldPen);
884}
885
886void CViewer3dView::OnModifyChangeBackground()
887{
888 Standard_Real R1;
889 Standard_Real G1;
890 Standard_Real B1;
891 myView->BackgroundColor(Quantity_TOC_RGB,R1,G1,B1);
892 COLORREF m_clr ;
893 m_clr = RGB(R1*255,G1*255,B1*255);
894
895 CColorDialog dlgColor(m_clr);
896 if (dlgColor.DoModal() == IDOK)
897 {
898 m_clr = dlgColor.GetColor();
899 R1 = GetRValue(m_clr)/255.;
900 G1 = GetGValue(m_clr)/255.;
901 B1 = GetBValue(m_clr)/255.;
902 myView->SetBackgroundColor(Quantity_TOC_RGB,R1,G1,B1);
903 }
904 myView->Redraw();
905}
906
907void CViewer3dView::OnDirectionalLight()
908{
909// Directional light source creation
910
911// Checking if the Active lights limit number is not reached
912 if( NbActiveLights>=myGraphicDriver->InquireLightLimit() )
913 {
914 char tmpStr[128];
915 sprintf_s(tmpStr, "You have reach the limit number of active lights (%d).\n Clear lights to create new ones.",
916 myGraphicDriver->InquireLightLimit());
917 MessageBox(tmpStr,"Light creation", MB_OK);
918 return;
919 }
920
921 UpdateData(TRUE);
922 ((OCC_MainFrame*)AfxGetMainWnd())->SetStatusMessage("Pick a first point");
923 GetDocument()->GetAISContext()->OpenLocalContext();
924 myCurrentMode = CurAction3d_BeginDirectionalLight;
925
926TCollection_AsciiString Message("\
927myCurrent_DirectionalLight = new V3d_DirectionalLight(myView->Viewer(), Xt, Yt, Zt, Xp, Yp, Zp);\n\
928\n\
929myView->SetLightOn(myCurrent_DirectionalLight);\n\
930\n\
931");
932// Update The Result Message Dialog
933 GetDocument()->UpdateResultMessageDlg("V3d_DirectionalLight",Message);
934}
935
936void CViewer3dView::OnSpotLight()
937{
938// Spot light source creation
939
940// Checking if the Active lights limit number is not reached
941 if( NbActiveLights>=myGraphicDriver->InquireLightLimit() )
942 {
943 char tmpStr[128];
944 sprintf_s(tmpStr, "You have reach the limit number of active lights (%d).\n Clear lights to create new ones.",
945 myGraphicDriver->InquireLightLimit());
946 MessageBox(tmpStr,"Light creation", MB_OK);
947 return;
948 }
949
950 GetDocument()->GetAISContext()->OpenLocalContext();
951 ((OCC_MainFrame*)AfxGetMainWnd())->SetStatusMessage("Pick the light position");
952 myCurrentMode = CurAction3d_BeginSpotLight;
953
954TCollection_AsciiString Message("\
955myCurrent_SpotLight = new V3d_SpotLight(myView->Viewer(), Xt, Yt, Zt, Xp, Yp, Zp,Quantity_NOC_RED);\n\
956\n\
957myView->SetLightOn(myCurrent_SpotLight);\n\
958\n\
959");
960// Update The Result Message Dialog
961GetDocument()->UpdateResultMessageDlg("V3d_SpotLight",Message);
962}
963
964void CViewer3dView::OnPositionalLight()
965{
966// Positional light source creation
967
968// Checking if the Active lights limit number is not reached
969 if( NbActiveLights>=myGraphicDriver->InquireLightLimit() )
970 {
971 char tmpStr[128];
972 sprintf_s(tmpStr, "You have reach the limit number of active lights (%d).\n Clear lights to create new ones.",
973 myGraphicDriver->InquireLightLimit());
974 MessageBox(tmpStr,"Light creation", MB_OK);
975 return;
976 }
977
978 GetDocument()->GetAISContext()->OpenLocalContext();
979 myCurrent_PositionalLight=new V3d_PositionalLight(myView->Viewer(),0,0,0,Quantity_NOC_GREEN,1,0);
980 myView->SetLightOn(myCurrent_PositionalLight);
981 NbActiveLights++;
982 ((OCC_MainFrame*)AfxGetMainWnd())->SetStatusMessage("Pick the light position");
983 myCurrentMode = CurAction3d_BeginPositionalLight;
984
985TCollection_AsciiString Message("\
986myCurrent_PositionalLight=new V3d_PositionalLight(myView->Viewer(),Xp, Yp, Zp,Quantity_NOC_GREEN,1,0);\n\
987\n\
988myView->SetLightOn(myCurrent_PositionalLight) ;\n\
989 ");
990
991 // Update The Result Message Dialog
992GetDocument()->UpdateResultMessageDlg("V3d_PositionalLight",Message);
993}
994
995void CViewer3dView::OnAmbientLight()
996{
997// Ambiant light source creation
998
999// Checking if the Active lights limit number is not reached
1000 if( NbActiveLights>=myGraphicDriver->InquireLightLimit() )
1001 {
1002 char tmpStr[128];
1003 sprintf_s(tmpStr, "You have reach the limit number of active lights (%d).\n Clear lights to create new ones.",
1004 myGraphicDriver->InquireLightLimit());
1005 MessageBox(tmpStr,"Light creation", MB_OK);
1006 return;
1007 }
1008
1009 GetDocument()->GetAISContext()->OpenLocalContext();
1010 myCurrent_AmbientLight=new V3d_AmbientLight(myView->Viewer(), Quantity_NOC_GRAY);
1011 myView->SetLightOn(myCurrent_AmbientLight) ;
1012 NbActiveLights++;
1013 GetDocument()->GetAISContext()->CloseLocalContext();
1014
1015 myView->UpdateLights();
1016
1017TCollection_AsciiString Message("\
1018myCurrent_AmbientLight=new V3d_AmbientLight(myView->Viewer(), Quantity_NOC_GRAY);\n\
1019\n\
1020myView->SetLightOn(myCurrent_AmbientLight) ;\n\
1021 ");
1022
1023 // Update The Result Message Dialog
1024GetDocument()->UpdateResultMessageDlg("V3d_AmbientLight",Message);
1025}
1026
1027
1028void CViewer3dView::OnScale()
1029{
1030 ScaleDlg Dlg(myView, this);
1031 Dlg.DoModal();
1032 myView->Redraw();
1033}
1034
1035void CViewer3dView::OnZcueing()
1036{
1037 ZCueingDlg Dlg(myView, GetDocument());
1038 Dlg.DoModal();
1039 myView->Redraw();
1040}
1041
1042void CViewer3dView::OnZclipping()
1043{
1044 ZClippingDlg Dlg(myView, GetDocument());
1045 Dlg.DoModal();
1046 myView->Redraw();
1047}
1048
1049//V3d_View.hxx
1050
1051void CViewer3dView::OnShadingmodel()
1052{
1053TCollection_AsciiString Message("\
1054myView->SetShadingModel(V3d_TypeOfShadingModel myTypeOfShadingModel);\n\
1055\n\
1056myCurrent_V3d_View->Update();\n\
1057 ");
1058
1059 // Update The Result Message Dialog
1060GetDocument()->UpdateResultMessageDlg("SetShadingModel",Message);
1061
1062 CShadingModelDlg Dlg(myView);
1063 Dlg.DoModal();
1064 myView->Redraw();
1065}
1066
1067
1068void CViewer3dView::OnAntialiasingonoff()
1069{
1070 if(!myView->Antialiasing())
1071 myView->SetAntialiasingOn();
1072 else
1073 myView->SetAntialiasingOff();
1074
1075 myView->Update();
1076
1077TCollection_AsciiString Message("\
1078if(!myView->Antialiasing())\n\
1079 myView->SetAntialiasingOn();\n\
1080else\n\
1081 myView->SetAntialiasingOff();\n\
1082 ");
1083
1084 // Update The Result Message Dialog
1085GetDocument()->UpdateResultMessageDlg("SetAntialiasingOn/SetAntialiasingOff",Message);
1086}
1087
1088void CViewer3dView::OnClearLights()
1089{
1090// Setting Off all viewer active lights
1091 for(myView->Viewer()->InitActiveLights(); myView->Viewer()->MoreActiveLights(); myView->Viewer()->NextActiveLights())
1092 myView->Viewer()->SetLightOff(myView->Viewer()->ActiveLight());
1093// Setting Off all view active lights
1094 for(myView->InitActiveLights(); myView->MoreActiveLights(); myView->NextActiveLights())
1095 myView->SetLightOff(myView->ActiveLight());
1096
1097 myView->Viewer()->SetDefaultLights();// Setting the default lights on
1098
1099 NbActiveLights = 2;// There are 2 default active lights
1100
1101 myView->Update();
1102
1103TCollection_AsciiString Message("\
1104for(myView->Viewer()->InitActiveLights(); myView->Viewer()->MoreActiveLights(); myView->Viewer()->NextActiveLights())\n\
1105 myView->Viewer()->SetLightOff(myView->Viewer()->ActiveLight()); //Setting Off all viewer active lights\n\
1106for(myView->InitActiveLights(); myView->MoreActiveLights(); myView->NextActiveLights())\n\
1107 myView->SetLightOff(myView->ActiveLight()); //Setting Off all view active lights\n\
1108\n\
1109myView->Viewer()->SetDefaultLights();// Setting the default lights on\n\
1110 ");
1111
1112 // Update The Result Message Dialog
1113GetDocument()->UpdateResultMessageDlg("SetLightOff",Message);
1114}
1115
1116void CViewer3dView::OnModelclipping()
1117{
1118 if( myPlane.IsNull() )
1119 {
1120//creates a plane defined : center of the box ( 50,50,50) and 1 direction
1121 gp_Pln tmpPln(gp_Pnt(0,0,0),gp_Dir(1,0,0));
1122//getting the coefficients of the gp_Pln ( ax+by+cz+d = 0 )
1123 Standard_Real A,B,C,D;
1124 tmpPln.Coefficients(A,B,C,D);
1125//with these coefficients, creating a V3d_Plane
1126 myPlane = new V3d_Plane(A,B,C,D);
1127// GetDocument()->GetViewer(),A,B,C,D);
1128//creates the Face
1129//NOTE : the face must be behind the clipping plane !!
1130 tmpPln = gp_Pln(gp_Pnt(0.1,0,0),gp_Dir(1,0,0));
1131 BRepBuilderAPI_MakeFace MakeFace(tmpPln, 200, -200, 410, -410);
1132 TopoDS_Face S = MakeFace.Face();
1133//display the face
1134 myShape = new AIS_Shape(S);
1135 }
1136
1137 CModelClippingDlg Dlg(myView, myPlane, myShape, GetDocument());
1138 Dlg.DoModal();
1139}
1140
1141void CViewer3dView::OnOptionsTrihedronStaticTrihedron()
1142{
1143 CTrihedronDlg Dlg(myView, GetDocument());
1144 Dlg.DoModal();
1145}
1146
1147void CViewer3dView::InitButtons()
1148{
1149 myXmin=0;
1150 myYmin=0;
1151 myXmax=0;
1152 myYmax=0;
1153 myCurZoom=0;
1154 myCurrentMode = CurAction3d_Nothing;
1155}
1156
1157void CViewer3dView::Reset()
1158{
1159 InitButtons();
1160 myVisMode = VIS_SHADE;
1161 if (!myView.IsNull())
1162 {
1163 RedrawVisMode();
1164 myView->Reset();
1165 }
1166}
1167
1168void CViewer3dView::GetViewCenter(V3d_Coordinate& Xc, V3d_Coordinate& Yc)
1169{
1170 myView->Center(Xc,Yc);
1171}
1172
1173void CViewer3dView::SetViewCenter(V3d_Coordinate Xc, V3d_Coordinate Yc)
1174{
1175 myView->SetCenter(Xc,Yc);
1176}
1177
1178void CViewer3dView::GetViewEye(V3d_Coordinate& X, V3d_Coordinate& Y, V3d_Coordinate& Z)
1179{
1180 myView->Eye(X,Y,Z);
1181}
1182
1183void CViewer3dView::SetViewEye(V3d_Coordinate X, V3d_Coordinate Y, V3d_Coordinate Z)
1184{
1185 myView->SetEye(X,Y,Z);
1186}
1187
1188Quantity_Factor CViewer3dView::GetViewScale()
1189{
1190 return myView->Scale();
1191}
1192
1193void CViewer3dView::SetViewScale(Quantity_Factor Coef)
1194{
1195 myView->SetScale(Coef);
1196}
1197
1198void CViewer3dView::RedrawVisMode()
1199{
1200 switch (myVisMode)
1201 {
1202 case VIS_WIREFRAME:
1203 GetDocument()->GetAISContext()->SetDisplayMode(AIS_WireFrame);
1204 myView->SetComputedMode (Standard_False);
1205 break;
1206 case VIS_SHADE:
1207 GetDocument()->GetAISContext()->SetDisplayMode(AIS_Shaded);
1208 myView->SetComputedMode (Standard_False);
1209 break;
1210 case VIS_HLR:
1211 SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT));
1212 myView->SetComputedMode (Standard_True);
1213 SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW));
1214 GetDocument()->GetAISContext()->SetDisplayMode(AIS_WireFrame);
1215 break;
1216 }
1217}