0023654: Problem with displaying vertices in OCC view after closing all OCC views...
[occt.git] / samples / mfc / standard / 04_Viewer3d / src / Viewer3dDoc.cpp
1 // Viewer3dDoc.cpp : implementation of the CViewer3dDoc class
2 //
3
4 #include "stdafx.h"
5 #include "Viewer3dApp.h"
6 #include "BoxRadius.h"
7 #include "DlgIsos.h"
8
9 #include "Viewer3dDoc.h"
10 #include "Viewer3dView.h"
11 #include "OffsetDlg.h"
12 #include "ResultDialog.h"
13 #include "User_Cylinder.hxx"
14
15 #include "AIS_Trihedron.hxx"
16 #include "Geom_Axis2Placement.hxx"
17
18 /////////////////////////////////////////////////////////////////////////////
19 // CViewer3dDoc
20
21 IMPLEMENT_DYNCREATE(CViewer3dDoc, CDocument)
22
23 BEGIN_MESSAGE_MAP(CViewer3dDoc, OCC_3dBaseDoc)
24         //{{AFX_MSG_MAP(CViewer3dDoc)
25         ON_COMMAND(ID_BOX, OnBox)
26         ON_COMMAND(ID_Cylinder, OnCylinder)
27         ON_COMMAND(ID_SPHERE, OnSphere)
28         ON_COMMAND(ID_ERASEALL, OnRemoveAll)
29         ON_COMMAND(ID_NBISOS, OnNbisos)
30         ON_COMMAND(ID_FACES, OnFaces)
31         ON_COMMAND(ID_EDGES, OnEdges)
32         ON_COMMAND(ID_VERTICES, OnVertices)
33         ON_COMMAND(ID_NEUTRAL, OnNeutral)
34         ON_COMMAND(ID_USERCYLINDER_CHANGEFACECOLOR, OnUsercylinderChangefacecolor)
35         ON_COMMAND(ID_FILLET3D, OnFillet3d)
36         ON_COMMAND(ID_CIRCLE, OnCircle)
37         ON_COMMAND(ID_LINE, OnLine)
38         ON_COMMAND(ID_OVERLAPPED_BOX, OnOverlappedBox)
39         ON_COMMAND(ID_OVERLAPPED_CYLINDER, OnOverlappedCylinder)
40         ON_COMMAND(ID_OVERLAPPED_SPHERE, OnOverlappedSphere)
41         ON_COMMAND(ID_POLYGON_OFFSETS, OnPolygonOffsets)
42         ON_UPDATE_COMMAND_UI(ID_POLYGON_OFFSETS, OnUpdatePolygonOffsets)
43         ON_UPDATE_COMMAND_UI(ID_Cylinder, OnUpdateCylinder)
44         ON_UPDATE_COMMAND_UI(ID_SPHERE, OnUpdateSphere)
45         ON_UPDATE_COMMAND_UI(ID_BOX, OnUpdateBox)
46         ON_UPDATE_COMMAND_UI(ID_OVERLAPPED_CYLINDER, OnUpdateOverlappedCylinder)
47         ON_UPDATE_COMMAND_UI(ID_OVERLAPPED_SPHERE, OnUpdateOverlappedSphere)
48         ON_UPDATE_COMMAND_UI(ID_OVERLAPPED_BOX, OnUpdateOverlappedBox)
49         ON_COMMAND(ID_OBJECT_REMOVE, OnObjectRemove)
50         ON_COMMAND(ID_OBJECT_ERASE, OnObjectErase)
51         ON_COMMAND(ID_OBJECT_DISPLAYALL, OnObjectDisplayall)
52         ON_COMMAND(ID_OBJECT_COLORED_MESH, OnObjectColoredMesh)
53         ON_UPDATE_COMMAND_UI(ID_OBJECT_COLORED_MESH, OnUpdateObjectColoredMesh)
54         ON_UPDATE_COMMAND_UI(ID_OBJECT_SHADING, OnUpdateObjectShading)
55         ON_UPDATE_COMMAND_UI(ID_OBJECT_WIREFRAME, OnUpdateObjectWireframe)
56         ON_COMMAND(ID_OPTIONS_TRIHEDRON_DYNAMIC_TRIHEDRON, OnOptionsTrihedronDynamicTrihedron)
57         ON_UPDATE_COMMAND_UI(ID_OPTIONS_TRIHEDRON_DYNAMIC_TRIHEDRON, OnUpdateOptionsTrihedronDynamicTrihedron)
58         ON_UPDATE_COMMAND_UI(ID_OPTIONS_TRIHEDRON_STATIC_TRIHEDRON, OnUpdateOptionsTrihedronStaticTrihedron)
59         ON_COMMAND(ID_OBJECT_MATERIAL, OnObjectMaterial)
60         ON_COMMAND(ID_TEXTURE_ON, OnTextureOn)
61         ON_COMMAND(ID_BUTTONNext, OnBUTTONNext)
62         ON_COMMAND(ID_BUTTONStart, OnBUTTONStart)
63         ON_COMMAND(ID_BUTTONRepeat, OnBUTTONRepeat)
64         ON_COMMAND(ID_BUTTONPrev, OnBUTTONPrev)
65         ON_COMMAND(ID_BUTTONEnd, OnBUTTONEnd)
66         ON_UPDATE_COMMAND_UI(ID_BUTTONNext, OnUpdateBUTTONNext)
67         ON_UPDATE_COMMAND_UI(ID_BUTTONPrev, OnUpdateBUTTONPrev)
68         ON_UPDATE_COMMAND_UI(ID_BUTTONStart, OnUpdateBUTTONStart)
69         ON_UPDATE_COMMAND_UI(ID_BUTTONRepeat, OnUpdateBUTTONRepeat)
70         ON_UPDATE_COMMAND_UI(ID_BUTTONEnd, OnUpdateBUTTONEnd)
71         ON_COMMAND(ID_FILE_NEW, OnFileNew)
72         ON_COMMAND(ID_DUMP_VIEW, OnDumpView)
73         //}}AFX_MSG_MAP
74 END_MESSAGE_MAP()
75
76 /////////////////////////////////////////////////////////////////////////////
77 // CViewer3dDoc construction/destruction
78
79 CViewer3dDoc::CViewer3dDoc()
80 {
81         myCylinder.Nullify();
82         mySphere.Nullify();
83         myBox.Nullify();
84         myOverlappedCylinder.Nullify();
85         myOverlappedSphere.Nullify();
86         myOverlappedBox.Nullify();
87         myOffsetDlg = NULL;
88         myStaticTrihedronAxisIsDisplayed = FALSE;
89
90         myState = -1;
91
92         isTextureSampleStarted = FALSE;
93 /*
94         // TODO: add one-time construction code here
95         Handle(Graphic3d_WNTGraphicDevice) theGraphicDevice = 
96                 ((CViewer3dApp*)AfxGetApp())->GetGraphicDevice();
97
98         myViewer = new V3d_Viewer(theGraphicDevice,(short *) "Visu3D");
99         myViewer->SetDefaultLights();
100         myViewer->SetLightOn();
101 */
102
103 //      myViewer->SetDefaultBackgroundColor(Quantity_TOC_RGB, 0.,0.,0.);
104
105         myPresentation = OCCDemo_Presentation::Current;
106         myPresentation->SetDocument(this);
107
108
109         myAISContext->DefaultDrawer()->ShadingAspect()->SetColor(Quantity_NOC_CHARTREUSE1); 
110         myAISContext->DefaultDrawer()->ShadingAspect()->SetMaterial(Graphic3d_NOM_SILVER);
111
112         strcpy_s(myDataDir, "Data");
113         strcpy_s(myLastPath, ".");
114
115         /*
116         Handle(AIS_Trihedron) myTrihedron;
117         Handle(Geom_Axis2Placement) myTrihedronAxis=new Geom_Axis2Placement(gp::XOY());
118         myTrihedron=new AIS_Trihedron(myTrihedronAxis);
119         myAISContext->Display(myTrihedron);
120         */
121 }
122
123 CViewer3dDoc::~CViewer3dDoc()
124 {
125 }
126
127 /////////////////////////////////////////////////////////////////////////////
128 // CViewer3dDoc diagnostics
129
130 #ifdef _DEBUG
131 void CViewer3dDoc::AssertValid() const
132 {
133         CDocument::AssertValid();
134 }
135
136 void CViewer3dDoc::Dump(CDumpContext& dc) const
137 {
138         CDocument::Dump(dc);
139 }
140 #endif //_DEBUG
141
142 /////////////////////////////////////////////////////////////////////////////
143 // CViewer3dDoc commands
144
145 void CViewer3dDoc::UpdateResultMessageDlg(CString Title, TCollection_AsciiString aMessage)
146 {
147     CString text(aMessage.ToCString());
148     myCResultDialog.SetText(text);
149
150     myCResultDialog.SetTitle(Title);
151 }
152
153 void CViewer3dDoc::OnBox() 
154 {
155         if(myBox.IsNull()){
156                 BRepPrimAPI_MakeBox B(gp_Pnt(0,-400,-100), 200.,150.,100.);
157
158
159                 myBox = new AIS_Shape(B.Shape());
160
161                 myAISContext->SetMaterial(myBox,Graphic3d_NOM_PEWTER);    
162                 myAISContext->SetDisplayMode(myBox,1);
163
164                 myAISContext->Display(myBox);   
165                 TCollection_AsciiString Message("\
166 BRepPrimAPI_MakeBox Box1(gp_Pnt(0,-400,-100), 200.,150.,100.);\n\
167                 ");
168                 
169                 UpdateResultMessageDlg("Create Box",Message);
170
171         }
172 }
173
174 void CViewer3dDoc::OnCylinder() 
175 {
176         if(myCylinder.IsNull()) {
177                 gp_Ax2 CylAx2(gp_Pnt(0,0,-100), gp_Dir(gp_Vec(gp_Pnt(0,0,-100),gp_Pnt(0,0,100))));
178
179                 //BRepPrimAPI_MakeCylinder C(CylAx2, 80.,200.);
180                 
181                 myCylinder = new User_Cylinder(CylAx2, 80.,200.);
182                 
183 //              myCylinder = new AIS_Shape(C.Shape());
184 /*
185                 myCylinder->SetTransparency(0.5);               
186
187                 myAISContext->SetColor(myCylinder,Quantity_NOC_WHITE); 
188                 myAISContext->SetMaterial(myCylinder,Graphic3d_NOM_SHINY_PLASTIC);    
189 */
190                 myAISContext->SetDisplayMode(myCylinder,1);
191
192                 myAISContext->Display(myCylinder);
193
194                 TCollection_AsciiString Message("\
195 gp_Ax2 CylAx2(gp_Pnt(0,0,-100), gp_Dir(gp_Vec(gp_Pnt(0,0,-100),gp_Pnt(0,0,100))));\n\
196 C = new User_Cylinder(CylAx2, 80.,200.);;\n\
197                 ");
198                 
199                 UpdateResultMessageDlg("Create Cylinder",Message);
200
201         }
202 }
203
204 void CViewer3dDoc::OnSphere() 
205 {
206         if(mySphere.IsNull()){
207                 BRepPrimAPI_MakeSphere S(gp_Pnt(0,300,0), 100.);
208
209                 mySphere = new AIS_Shape(S.Shape());
210                 
211                 myAISContext->SetMaterial(mySphere,Graphic3d_NOM_BRONZE);    
212                 myAISContext->SetDisplayMode(mySphere,1);
213
214                 myAISContext->Display(mySphere);
215                 TCollection_AsciiString Message("\
216 BRepPrimAPI_MakeSphere S(gp_Pnt(0,300,0), 100.);\n\
217                 ");
218                 UpdateResultMessageDlg("Create Sphere",Message);
219         }
220 }
221
222 void CViewer3dDoc::OnRemoveAll() 
223
224 {
225         AIS_ListOfInteractive aListOfObjects;
226         myAISContext->ObjectsInside(aListOfObjects,AIS_KOI_Shape);
227
228         AIS_ListIteratorOfListOfInteractive aListIterator;
229         for(aListIterator.Initialize(aListOfObjects);aListIterator.More();aListIterator.Next()){
230                 myAISContext->Remove(aListIterator.Value());
231         }
232
233         myAISContext->Remove(myCylinder);
234
235
236         myCylinder.Nullify();
237         mySphere.Nullify();
238         myBox.Nullify();
239         myOverlappedCylinder.Nullify();
240         myOverlappedSphere.Nullify();
241         myOverlappedBox.Nullify();
242         if(myOffsetDlg && myOffsetDlg->IsWindowVisible())
243                 myOffsetDlg->UpdateValues();
244 }
245
246 void CViewer3dDoc::OnOverlappedBox() 
247 {
248         OnBox();
249         if(myOverlappedBox.IsNull()){
250                 BRepPrimAPI_MakeBox B(gp_Pnt(0,-400,-100), 200.,150.,100.);
251
252                 BRepBuilderAPI_NurbsConvert aNurbsConvert(B.Shape());
253                 TopoDS_Shape aBoxShape2 = aNurbsConvert.Shape();
254
255
256                 myOverlappedBox = new AIS_Shape(aBoxShape2);
257
258                 myAISContext->SetMaterial(myOverlappedBox,Graphic3d_NOM_GOLD);    
259                 myAISContext->SetDisplayMode(myOverlappedBox,1);
260
261                 myAISContext->Display(myOverlappedBox); 
262                 TCollection_AsciiString Message("\
263 BRepPrimAPI_MakeBox Box1(gp_Pnt(0,-400,-100), 200.,150.,100.);\n\
264 \n\
265 BRepPrimAPI_MakeBox Box2(gp_Pnt(0,-400,-100), 200.,150.,100.);\n\
266 BRepBuilderAPI_NurbsConvert aNurbsConvert(Box2.Shape());\n\
267                 ");
268                 UpdateResultMessageDlg("Create overlapped boxes",Message);
269                 if(myOffsetDlg && myOffsetDlg->IsWindowVisible())
270                         myOffsetDlg->UpdateValues();
271
272
273         }
274 }
275
276 void CViewer3dDoc::OnOverlappedCylinder() 
277 {
278         OnCylinder();
279
280         if(myOverlappedCylinder.IsNull()){
281                 gp_Ax2 CylAx2(gp_Pnt(0,0,-100), gp_Dir(gp_Vec(gp_Pnt(0,0,-100),gp_Pnt(0,0,100))));
282                 BRepPrimAPI_MakeCylinder C(CylAx2, 80.,200.);
283
284                 BRepBuilderAPI_NurbsConvert aNurbsConvert(C.Shape());
285                 TopoDS_Shape aCylShape2 = aNurbsConvert.Shape();
286
287                 myOverlappedCylinder = new AIS_Shape(aCylShape2);
288
289         
290                 myAISContext->SetMaterial(myOverlappedCylinder,Graphic3d_NOM_GOLD);    
291                 myAISContext->SetDisplayMode(myOverlappedCylinder,1);
292
293                 myAISContext->Display(myOverlappedCylinder);
294
295                 TCollection_AsciiString Message("\
296 gp_Ax2 CylAx2(gp_Pnt(0,0,-100), gp_Dir(gp_Vec(gp_Pnt(0,0,-100),gp_Pnt(0,0,100))));\n\
297 Cylinder1 = new User_Cylinder(CylAx2, 80.,200.);\n\
298 \n\
299 BRepPrimAPI_MakeCylinder Cylinder2(CylAx2, 80.,200.);\n\
300 BRepBuilderAPI_NurbsConvert aNurbsConvert(Cylinder2.Shape());\n\
301                 ");
302                 UpdateResultMessageDlg("Create overlapped cylinders",Message);
303                 if(myOffsetDlg && myOffsetDlg->IsWindowVisible())
304                         myOffsetDlg->UpdateValues();
305
306         }
307 }
308
309 void CViewer3dDoc::OnOverlappedSphere() 
310 {
311         OnSphere();
312         if(myOverlappedSphere.IsNull()){
313                 BRepPrimAPI_MakeSphere S(gp_Pnt(0,300,0), 100.);
314
315                 BRepBuilderAPI_NurbsConvert aNurbsConvert(S.Shape());
316                 TopoDS_Shape aSphereShape2 = aNurbsConvert.Shape();
317
318                 myOverlappedSphere = new AIS_Shape(aSphereShape2);
319
320                 myAISContext->SetMaterial(myOverlappedSphere,Graphic3d_NOM_GOLD);    
321
322                 myAISContext->SetDisplayMode(myOverlappedSphere,1);
323
324                 myAISContext->Display(myOverlappedSphere);
325
326                 TCollection_AsciiString Message("\
327 BRepPrimAPI_MakeSphere Sphere1(gp_Pnt(0,300,0), 100.);\n\
328 \n\
329 BRepPrimAPI_MakeSphere Sphere2(gp_Pnt(0,300,0), 100.);\n\
330 BRepBuilderAPI_NurbsConvert aNurbsConvert(Sphere2.Shape());\n\
331                 ");
332                 UpdateResultMessageDlg("Create overlapped spheres",Message);
333                 if(myOffsetDlg && myOffsetDlg->IsWindowVisible())
334                         myOffsetDlg->UpdateValues();
335
336         }
337 }
338
339 void CViewer3dDoc::OnPolygonOffsets() 
340 {
341
342         myOffsetDlg = new COffsetDlg(this);
343         myOffsetDlg->Create(COffsetDlg::IDD,NULL);
344         myAISContext->UpdateCurrentViewer();
345
346 }
347
348 void CViewer3dDoc::OnUpdatePolygonOffsets(CCmdUI* pCmdUI) 
349 {
350         Standard_Integer aOffsetMode;
351         Standard_ShortReal aFactor;
352         Standard_ShortReal aCylUnits = 0;
353         Standard_ShortReal aSphereUnits = 0;
354         Standard_ShortReal aBoxUnits = 0;
355
356         BOOL IsOverlappedCylinderDisplayed = myAISContext->IsDisplayed(myOverlappedCylinder);
357         BOOL IsOverlappedSphereDisplayed = myAISContext->IsDisplayed(myOverlappedSphere);
358         BOOL IsOverlappedBoxDisplayed = myAISContext->IsDisplayed(myOverlappedBox);
359         BOOL IsAnyOverlappedObjectDisplayed = 
360                 IsOverlappedCylinderDisplayed || IsOverlappedSphereDisplayed || IsOverlappedBoxDisplayed;
361         
362         if(!myOverlappedCylinder.IsNull() && IsOverlappedCylinderDisplayed){
363                 myOverlappedCylinder->PolygonOffsets(aOffsetMode,aFactor,aCylUnits);
364         }
365         
366         if(!myOverlappedSphere.IsNull() && IsOverlappedSphereDisplayed){
367                 myOverlappedSphere->PolygonOffsets(aOffsetMode,aFactor,aSphereUnits);
368         }
369
370         if(!myOverlappedBox.IsNull() && IsOverlappedBoxDisplayed){
371                 myOverlappedBox->PolygonOffsets(aOffsetMode,aFactor,aBoxUnits);
372         }
373
374         if(myOffsetDlg && myOffsetDlg->IsWindowVisible())
375                 pCmdUI->SetCheck(TRUE);
376         else
377                 pCmdUI->SetCheck(FALSE);
378         if (IsAnyOverlappedObjectDisplayed)
379                 if(myOffsetDlg)
380                         pCmdUI->Enable(!myOffsetDlg->IsWindowVisible());  
381                 else
382                         pCmdUI->Enable(TRUE);
383         else 
384                         pCmdUI->Enable(FALSE);
385         
386         
387 }
388
389 void CViewer3dDoc::OnUpdateCylinder(CCmdUI* pCmdUI) 
390 {
391         pCmdUI->Enable(myCylinder.IsNull()); 
392                 
393 }
394
395 void CViewer3dDoc::OnUpdateSphere(CCmdUI* pCmdUI) 
396 {
397         pCmdUI->Enable(mySphere.IsNull()); 
398                 
399 }
400
401 void CViewer3dDoc::OnUpdateBox(CCmdUI* pCmdUI) 
402 {
403         pCmdUI->Enable(myBox.IsNull()); 
404                 
405 }
406
407 void CViewer3dDoc::OnUpdateOverlappedCylinder(CCmdUI* pCmdUI) 
408 {
409         pCmdUI->Enable   (myOverlappedCylinder.IsNull()
410                                                 || myCylinder.IsNull());
411                 
412 }
413
414 void CViewer3dDoc::OnUpdateOverlappedSphere(CCmdUI* pCmdUI) 
415 {
416         pCmdUI->Enable   (myOverlappedSphere.IsNull()
417                                                 || mySphere.IsNull());
418 }
419
420 void CViewer3dDoc::OnUpdateOverlappedBox(CCmdUI* pCmdUI) 
421 {
422         pCmdUI->Enable   (myOverlappedBox.IsNull()
423                                                 || myBox.IsNull());
424 }
425
426 void CViewer3dDoc::OnObjectRemove() 
427
428 {
429
430         if(myAISContext->IsCurrent(myBox))
431                 myBox.Nullify();
432
433         if(myAISContext->IsCurrent(myCylinder))
434                 myCylinder.Nullify();
435
436         if(myAISContext->IsCurrent(mySphere))
437                 mySphere.Nullify();
438
439         if(myAISContext->IsCurrent(myOverlappedBox))
440                 myOverlappedBox.Nullify();
441
442         if(myAISContext->IsCurrent(myOverlappedCylinder))
443                 myOverlappedCylinder.Nullify();
444
445         if(myAISContext->IsCurrent(myOverlappedSphere))
446                 myOverlappedSphere.Nullify();
447
448         
449         for(myAISContext->InitCurrent();myAISContext->MoreCurrent();myAISContext->InitCurrent())
450                 myAISContext->Remove(myAISContext->Current(),Standard_True);
451
452         if(myOffsetDlg && myOffsetDlg->IsWindowVisible())
453                 myOffsetDlg->UpdateValues();
454
455 }
456
457 void CViewer3dDoc::OnObjectErase() 
458
459 {
460         OCC_3dBaseDoc::OnObjectErase(); 
461         if(myOffsetDlg && myOffsetDlg->IsWindowVisible())
462                 myOffsetDlg->UpdateValues();
463 }
464
465 void CViewer3dDoc::OnObjectDisplayall() 
466
467 {
468         OCC_3dBaseDoc::OnObjectDisplayall(); 
469         if(myOffsetDlg && myOffsetDlg->IsWindowVisible())
470                 myOffsetDlg->UpdateValues();
471 }
472
473 Handle_User_Cylinder CViewer3dDoc::GetCylinder()
474 {
475         return myCylinder;
476 }
477
478
479 Handle_AIS_Shape CViewer3dDoc::GetSphere()
480 {
481         return mySphere;
482 }
483
484 Handle_AIS_Shape CViewer3dDoc::GetBox()
485 {
486         return myBox;
487 }
488
489 Handle_AIS_Shape CViewer3dDoc::GetOverlappedCylinder()
490 {
491         return myOverlappedCylinder;
492 }
493
494
495 Handle_AIS_Shape CViewer3dDoc::GetOverlappedSphere()
496 {
497         return myOverlappedSphere;
498 }
499
500 Handle_AIS_Shape CViewer3dDoc::GetOverlappedBox()
501 {
502         return myOverlappedBox;
503 }
504
505 void CViewer3dDoc::DragEvent(const Standard_Integer  x        ,
506                                                   const Standard_Integer  y        ,
507                                                   const Standard_Integer  TheState ,
508                                   const Handle(V3d_View)& aView    )
509 {
510         OCC_3dBaseDoc::DragEvent(x,y, TheState,aView);
511         if(myOffsetDlg && myOffsetDlg->IsWindowVisible())
512                 myOffsetDlg->UpdateValues();
513 }
514
515 //-----------------------------------------------------------------------------------------
516 //
517 //-----------------------------------------------------------------------------------------
518 void CViewer3dDoc::InputEvent(const Standard_Integer  x     ,
519                                                    const Standard_Integer  y     ,
520                                    const Handle(V3d_View)& aView ) 
521 {
522   if (myOffsetDlg && myOffsetDlg->IsWindowVisible())
523     myOffsetDlg->UpdateValues();
524
525   Quantity_Color CSFColor;
526   COLORREF MSColor;
527   myAISContext->Select(); 
528
529   // Change the color of a selected face in a user cylinder
530   if (myState == FACE_COLOR)
531   {
532     myAISContext->InitSelected();
533     if (myAISContext->MoreSelected())
534     {
535       Handle_AIS_InteractiveObject Current = myAISContext->SelectedInteractive();
536       if (Current->HasColor())
537       {
538         CSFColor = myAISContext->Color (Current);
539         MSColor = RGB (CSFColor.Red()*255.0, CSFColor.Green()*255.0, CSFColor.Blue()*255.0);
540       }
541       else 
542       {
543         MSColor = RGB (255, 255, 255);
544       }
545
546       CColorDialog dlgColor(MSColor);
547       if (dlgColor.DoModal() == IDOK)
548       {
549         MSColor = dlgColor.GetColor();
550         CSFColor = Quantity_Color (GetRValue (MSColor)/255.0,
551                                    GetGValue (MSColor)/255.0,
552                                    GetBValue (MSColor)/255.0,
553                                    Quantity_TOC_RGB);
554
555         TopoDS_Shape S = myAISContext->SelectedShape();
556         Handle(Geom_Surface) Surface = BRep_Tool::Surface (TopoDS::Face(S));
557         if (Surface->IsKind (STANDARD_TYPE (Geom_Plane)))
558         {
559           Handle(User_Cylinder)::DownCast (myAISContext->SelectedInteractive())
560             ->SetPlanarFaceColor (CSFColor.Name());
561         }
562         else
563         {
564           Handle(User_Cylinder)::DownCast (myAISContext->SelectedInteractive())
565             ->SetCylindricalFaceColor (CSFColor.Name());
566         }
567
568         myAISContext->Redisplay (myAISContext->SelectedInteractive());
569         myState = -1;
570         myAISContext->CloseLocalContext();
571       }
572     }
573
574     TCollection_AsciiString aMessage ("  TopoDS_Shape S = myAISContext->SelectedShape(); \n"
575                                       "  \n"
576                                       "  Handle(Geom_Surface) Surface = BRep_Tool::Surface(TopoDS::Face(S));"
577                                       "  if (Surface->IsKind(STANDARD_TYPE(Geom_Plane))) \n"
578                                       "    Handle(User_Cylinder)::DownCast(myAISContext->Current())->SetPlanarFaceColor(CSFColor.Name()); \n"
579                                       "  else \n"
580                                       "    Handle(User_Cylinder)::DownCast(myAISContext->Current())->SetCylindricalFaceColor(CSFColor.Name()); \n"
581                                       "  \n"
582                                       "  myAISContext->Redisplay(myAISContext->Current()); \n"
583                                       "  \n"
584                                       "  myAISContext->CloseLocalContext(); \n"
585                                       "  \n"
586                                       "  \n"
587                                       "  NOTE: a User_Cylinder is an object defined by the user. \n"
588                                       "  The User_Cylinder class inherit from the AIS_InteractiveObject \n"
589                                       "  Cascade class, it's use is the same as an AIS_InteractiveObject. \n"
590                                       "  Methods SetPlanarFaceColor and SetCylindricalFaceColor are also \n"
591                                       "  defined in the User_Cylinder class. \n"
592                                       "  \n");
593
594     CString aMsgStr (aMessage.ToCString());
595     myCResultDialog.SetTitle (CString ("Change face color"));
596     myCResultDialog.SetText (aMsgStr);
597     SetTitle (CString ("Change face color"));
598   }
599 }
600
601 //-----------------------------------------------------------------------------------------
602 //
603 //-----------------------------------------------------------------------------------------
604 void CViewer3dDoc::ShiftDragEvent(const Standard_Integer  x        ,
605                                                                            const Standard_Integer  y        ,
606                                                                            const Standard_Integer  TheState ,
607                                        const Handle(V3d_View)& aView    ) 
608 {
609   OCC_3dBaseDoc::ShiftDragEvent(x,y,TheState,aView);
610   if(myOffsetDlg && myOffsetDlg->IsWindowVisible())
611     myOffsetDlg->UpdateValues();
612 }
613
614
615 //-----------------------------------------------------------------------------------------
616 //
617 //-----------------------------------------------------------------------------------------
618
619 void CViewer3dDoc::ShiftInputEvent(const Standard_Integer  x       ,
620                                                                             const Standard_Integer  y       ,
621                                         const Handle(V3d_View)& aView   ) 
622 {
623   OCC_3dBaseDoc::ShiftInputEvent(x,y,aView);
624   if(myOffsetDlg && myOffsetDlg->IsWindowVisible())
625     myOffsetDlg->UpdateValues();
626 }
627
628 void CViewer3dDoc::OnObjectColoredMesh() 
629 {
630   for(myAISContext->InitCurrent();myAISContext->MoreCurrent();myAISContext->NextCurrent())
631     if (myAISContext->Current()->IsKind(STANDARD_TYPE(User_Cylinder)))
632     {
633       myAISContext->ClearPrs(myAISContext->Current(),6,Standard_False);
634       myAISContext->RecomputePrsOnly(myAISContext->Current(),Standard_False);
635       myAISContext->SetDisplayMode(myAISContext->Current(),6);
636     }
637 }
638
639 void CViewer3dDoc::OnUpdateObjectColoredMesh(CCmdUI* pCmdUI) 
640 {
641   bool CylinderIsCurrentAndDisplayed = false;
642   for (myAISContext->InitCurrent();myAISContext->MoreCurrent ();myAISContext->NextCurrent ())
643         if(myAISContext->Current()->IsKind(STANDARD_TYPE(User_Cylinder)))
644                 CylinderIsCurrentAndDisplayed=true;
645   pCmdUI->Enable (CylinderIsCurrentAndDisplayed);       
646 }
647
648 void CViewer3dDoc::OnUpdateObjectWireframe(CCmdUI* pCmdUI) 
649 {
650   bool OneOrMoreInShadingOrColoredMesh = false;
651   for (myAISContext->InitCurrent();myAISContext->MoreCurrent ();myAISContext->NextCurrent ())
652     if (myAISContext->IsDisplayed(myAISContext->Current(),1) || myAISContext->IsDisplayed(myAISContext->Current(),6)) 
653                 OneOrMoreInShadingOrColoredMesh=true;
654         pCmdUI->Enable (OneOrMoreInShadingOrColoredMesh);       
655 }
656
657
658 void CViewer3dDoc::OnUpdateObjectShading(CCmdUI* pCmdUI) 
659 {
660   bool OneOrMoreInWireframeOrColoredMesh = false;
661   for (myAISContext->InitCurrent();myAISContext->MoreCurrent ();myAISContext->NextCurrent ())
662     if (myAISContext->IsDisplayed(myAISContext->Current(),0) || myAISContext->IsDisplayed(myAISContext->Current(),6))
663                 OneOrMoreInWireframeOrColoredMesh=true;
664         pCmdUI->Enable (OneOrMoreInWireframeOrColoredMesh);     
665 }
666
667
668 void CViewer3dDoc::OnOptionsTrihedronDynamicTrihedron() 
669 {
670         if (myAISContext -> IsDisplayed(myTrihedron))
671         {
672                 myAISContext->Remove(myTrihedron);
673         }               
674         else
675         {
676                 Handle(Geom_Axis2Placement) myTrihedronAxis=new Geom_Axis2Placement(gp::XOY());
677                 myTrihedron=new AIS_Trihedron(myTrihedronAxis);
678                 myAISContext->SetTrihedronSize(200, Standard_True);
679                 myAISContext->Display(myTrihedron);     
680         }               
681 }
682
683 void CViewer3dDoc::OnUpdateOptionsTrihedronDynamicTrihedron(CCmdUI* pCmdUI) 
684 {
685         if (myAISContext->IsDisplayed(myTrihedron))
686                 pCmdUI->SetCheck(1);
687         else
688                 pCmdUI->SetCheck(0);
689 }
690
691 void CViewer3dDoc::SetMyStaticTrihedronAxisIsDisplayed(BOOL IsDisplayed)
692 {
693         myStaticTrihedronAxisIsDisplayed = IsDisplayed;
694 }
695
696 void CViewer3dDoc::OnUpdateOptionsTrihedronStaticTrihedron(CCmdUI* pCmdUI) 
697 {
698         if (myStaticTrihedronAxisIsDisplayed)
699                 pCmdUI->SetCheck(1);
700         else
701                 pCmdUI->SetCheck(0);
702         
703 }
704
705 void  CViewer3dDoc::Popup( const Standard_Integer  x,
706                                                    const Standard_Integer  y ,
707                            const Handle(V3d_View)& aView   ) 
708 {
709   Standard_Integer PopupMenuNumber=0;
710  myAISContext->InitCurrent();
711   if (myAISContext->MoreCurrent()) {
712                 if (myAISContext->Current()->IsKind(STANDARD_TYPE(User_Cylinder)))
713                         return;
714                 else 
715                         PopupMenuNumber = 1;
716         }
717
718   CMenu menu;
719   VERIFY(menu.LoadMenu(IDR_Popup3D));
720   CMenu* pPopup = menu.GetSubMenu(PopupMenuNumber);
721
722   ASSERT(pPopup != NULL);
723    if (PopupMenuNumber == 1) // more than 1 object.
724   {
725     bool OneOrMoreInShading = false;
726         for (myAISContext->InitCurrent();myAISContext->MoreCurrent ();myAISContext->NextCurrent ())
727     if (myAISContext->IsDisplayed(myAISContext->Current(),1)) OneOrMoreInShading=true;
728         if(!OneOrMoreInShading)
729         pPopup->EnableMenuItem(5, MF_BYPOSITION | MF_DISABLED | MF_GRAYED);
730    }
731
732   POINT winCoord = { x , y };
733   Handle(WNT_Window) aWNTWindow=
734   Handle(WNT_Window)::DownCast(aView->Window());
735   ClientToScreen ( (HWND)(aWNTWindow->HWindow()),&winCoord);
736   pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON , winCoord.x, winCoord.y , 
737                          AfxGetMainWnd());
738 }
739
740 //Set faces selection mode
741 void CViewer3dDoc::OnFaces() 
742 {
743   myAISContext->CloseAllContexts();
744   myAISContext->OpenLocalContext();
745   myAISContext->ActivateStandardMode (TopAbs_FACE);
746
747   TCollection_AsciiString aMessage ("  myAISContext->OpenLocalContext(); \n"
748                                     "  \n"
749                                     "  myAISContext->ActivateStandardMode(TopAbs_FACE); \n"
750                                     "  \n");
751
752   CString aMsgStr (aMessage.ToCString());
753   myCResultDialog.SetTitle (CString("Standard mode: TopAbs_FACE"));
754   myCResultDialog.SetText (aMsgStr);
755   SetTitle (CString ("Standard mode: TopAbs_FACE"));
756 }
757
758 //Set edges selection mode
759 void CViewer3dDoc::OnEdges() 
760 {
761   myAISContext->CloseAllContexts();
762   myAISContext->OpenLocalContext();
763   myAISContext->ActivateStandardMode(TopAbs_EDGE);
764
765   TCollection_AsciiString aMessage ("  myAISContext->OpenLocalContext(); \n"
766                                     "  \n"
767                                     "  myAISContext->ActivateStandardMode(TopAbs_EDGE); \n"
768                                     "  \n");
769
770   CString aMsgStr (aMessage.ToCString());
771   myCResultDialog.SetTitle (CString ("Standard mode: TopAbs_EDGE"));
772   myCResultDialog.SetText (aMsgStr);
773   SetTitle (CString ("Standard mode: TopAbs_EDGE"));
774 }
775
776 // Set vertices selection mode
777 void CViewer3dDoc::OnVertices() 
778 {
779   myAISContext->CloseAllContexts();
780   myAISContext->OpenLocalContext();
781   myAISContext->ActivateStandardMode (TopAbs_VERTEX);
782
783   TCollection_AsciiString aMessage ("  myAISContext->OpenLocalContext(); \n"
784                                     "  \n"
785                                     "  myAISContext->ActivateStandardMode(TopAbs_VERTEX); \n"
786                                     "  \n");
787
788   CString aMsgStr (aMessage.ToCString());
789   myCResultDialog.SetTitle (CString ("Standard mode: TopAbs_VERTEX"));
790   myCResultDialog.SetText (aMsgStr);
791   SetTitle (CString ("Standard mode: TopAbs_VERTEX"));
792 }
793
794 //Neutral selection mode
795 void CViewer3dDoc::OnNeutral() 
796 {
797   myAISContext->CloseAllContexts();
798
799   TCollection_AsciiString aMessage ("  myAISContext->CloseAllContexts(); \n"
800                                     "  \n");
801
802   CString aMsgStr (aMessage.ToCString());
803   myCResultDialog.SetTitle (CString ("Standard mode: Neutral"));
804   myCResultDialog.SetText (aMsgStr);
805   SetTitle (CString ("Standard mode: Neutral"));
806 }
807
808 // Change the color of faces on a user cylinder
809 void CViewer3dDoc::OnUsercylinderChangefacecolor() 
810 {
811   myAISContext->OpenLocalContext();
812   myAISContext->Activate(myAISContext->Current(),4);
813   myState = FACE_COLOR;
814   // see the following of treatment in inputevent
815 }
816
817 // Make 3d fillets on solids
818 // It is necessary to activate the edges selection mode and select edges on an object
819 // before running this function
820 void CViewer3dDoc::OnFillet3d() 
821 {
822   if (!myAISContext->HasOpenedContext())
823   {
824     AfxMessageBox("It is necessary to activate the edges selection mode\n"
825                   "and select edges on an object before \nrunning this function");
826     return;
827   }
828
829   myAISContext->InitSelected();
830   if (myAISContext->MoreSelected()) 
831   {
832     Handle(AIS_Shape) S = Handle(AIS_Shape)::DownCast (myAISContext->SelectedInteractive());
833
834     if (S.IsNull())
835     {
836       AfxMessageBox("It is necessary to activate the edges selection mode\n"
837                     "and select edges on an object before \nrunning this function");
838       return;
839     }
840
841     TopoDS_Shape Sh=S->Shape();
842
843     BRepFilletAPI_MakeFillet aFillet(Sh);
844
845     for (myAISContext->InitSelected(); myAISContext->MoreSelected(); myAISContext->NextSelected())
846     {
847       TopoDS_Shape aSelShape = myAISContext->SelectedShape();
848       if (aSelShape.ShapeType() != TopAbs_EDGE)
849       {
850         AfxMessageBox("It is necessary to activate the edges selection mode\n\
851                       and select edges on an object before \nrunning this function");
852         return;
853       }
854     }
855
856     BoxRadius dlg(NULL,10.);
857     if (dlg.DoModal() == IDOK)
858     {
859       for (myAISContext->InitSelected(); myAISContext->MoreSelected(); myAISContext->NextSelected())
860       {
861         TopoDS_Edge anEdge = TopoDS::Edge(myAISContext->SelectedShape());
862         aFillet.Add(dlg.m_radius,anEdge);
863       }
864     }
865     else
866     {
867       return;
868     }
869
870     TopoDS_Shape aNewShape;
871     try
872     {
873       aNewShape = aFillet.Shape();
874     }
875     catch (Standard_Failure)
876     {
877       AfxMessageBox("Error During Fillet computation");
878       return;
879     }
880
881     S ->Set (aNewShape);
882     myAISContext->Redisplay (S);
883   }
884
885   TCollection_AsciiString aMessage ("  Handle(AIS_Shape) S = Handle(AIS_Shape)::DownCast(myAISContext->Interactive()); \n"
886                                     "  \n"
887                                     "  BRepAPI_MakeFillet aFillet(S->Shape()); \n"
888                                     "  \n"
889                                     "  TopoDS_Edge anEdge=TopoDS::Edge(myAISContext->SelectedShape()); \n"
890                                     "  \n"
891                                     "  aFillet.Add(dlg.m_radius,anEdge); \n"
892                                     "  \n"
893                                     "  TopoDS_Shape aNewShape = aFillet.Shape(); \n"
894                                     "  \n"
895                                     "  S->Set(aNewShape); \n"
896                                     "  \n"
897                                     "  myAISContext->Redisplay(S); \n"
898                                     "  \n");
899
900   CString aMsgStr (aMessage.ToCString());
901   myCResultDialog.SetTitle (CString ("Make a fillet"));
902   myCResultDialog.SetText (aMsgStr);
903   SetTitle (CString ("Make a fillet"));
904 }
905
906 // Create and display a circle with standard tools
907 void CViewer3dDoc::OnCircle() 
908 {
909   gp_Ax2 anAx2 (gp_Pnt (0., 0., 0.), gp_Dir(0., 0., -1.));
910   Handle(Geom_Circle) aGeomCircle = new Geom_Circle (anAx2, 300);
911
912   // the lines above substitute
913   // GC_MakeCircle C(gp_Pnt(-100.,-300.,0.),gp_Pnt(-50.,-200.,0.),gp_Pnt(-10.,-250.,0.));
914   // Handle(AIS_Circle) anAISCirc = new AIS_Circle(C.Value());
915
916   Handle(AIS_Circle) anAISCirc = new AIS_Circle(aGeomCircle);
917   myAISContext->Display (anAISCirc);
918
919   TCollection_AsciiString aMessage ("  GC_MakeCircle C(gp_Pnt(-100.,-300.,0.),gp_Pnt(-50.,-200.,0.),gp_Pnt(-10.,-250.,0.)); \n"
920                                     "  \n"
921                                     "  Handle(AIS_Circle) anAISCirc = new AIS_Circle(C.Value()); \n"
922                                     "  \n"
923                                     "  myAISContext->Display(anAISCirc); \n"
924                                     "  \n");
925
926   CString aMsgStr (aMessage.ToCString());
927   myCResultDialog.SetTitle (CString ("Create a circle"));
928   myCResultDialog.SetText (aMsgStr);
929   SetTitle (CString ("Create a circle"));
930 }
931
932 void CViewer3dDoc::OnLine() 
933 {
934   // TODO: Add your command handler code here
935   gp_Lin aGpLin (gp_Pnt (0., 0., 0.), gp_Dir(1., 0., 0.));
936   Handle(Geom_Line) aGeomLin = new Geom_Line (aGpLin);
937   Handle(AIS_Line) anAISLine = new AIS_Line (aGeomLin);
938   myAISContext->Display (anAISLine);
939
940   TCollection_AsciiString aMessage ("  gp_Lin L(gp_Pnt(0.,0.,0.),gp_Dir(1.,0.,0.)); \n"
941                                     "  \n"
942                                     "  Handle(Geom_Line) aLine = new Geom_Line(L); \n"
943                                     "  \n"
944                                     "  Handle(AIS_Line) anAISLine = new AIS_Line(aLine); \n"
945                                     "  \n"
946                                     "  myAISContext->Display(anAISLine); \n"
947                                     "  \n");
948
949   CString aMsgStr (aMessage.ToCString());
950   myCResultDialog.SetTitle (CString("Create a line"));
951   myCResultDialog.SetText (aMsgStr);
952   SetTitle (CString ("Create a line"));
953 }
954
955 void CViewer3dDoc::OnNbisos() 
956 {
957   int aNumU = myAISContext->DefaultDrawer()->UIsoAspect()->Number();
958   int aNumV = myAISContext->DefaultDrawer()->VIsoAspect()->Number();
959
960   DlgIsos aDlg (NULL, aNumU, aNumV);
961
962   if (aDlg.DoModal() == IDOK)
963   {
964     myAISContext->DefaultDrawer()->UIsoAspect()->SetNumber (aDlg.m_isou);
965     myAISContext->DefaultDrawer()->VIsoAspect()->SetNumber (aDlg.m_isov);
966
967     TCollection_AsciiString aMessage ("  myAISContext->DefaultDrawer()->UIsoAspect()->SetNumber(dlg.m_isou); \n"
968                                       "  \n"
969                                       "  myAISContext->DefaultDrawer()->VIsoAspect()->SetNumber(dlg.m_isov); \n"
970                                       "  \n");
971
972     CString aMsgStr (aMessage.ToCString());
973     myCResultDialog.SetTitle (CString("Iso Aspect"));
974     myCResultDialog.SetText (aMsgStr);
975     SetTitle (CString ("Iso Aspect"));
976   }
977 }
978
979 BOOL CViewer3dDoc::OnNewDocument()
980 {
981   if (!CDocument::OnNewDocument())
982     return FALSE;
983
984   // TODO: add reinitialization code here
985   // (SDI documents will reuse this document)
986   SetTitle(myPresentation->GetName());
987
988   myAISContext->EraseAll();
989   myAISContext->SetDisplayMode(AIS_Shaded);
990
991   POSITION pos = GetFirstViewPosition();
992   while (pos != NULL)
993   {
994     CViewer3dView* pView = (CViewer3dView*) GetNextView(pos);
995     pView->Reset();
996   }  
997
998   return TRUE;
999 }
1000
1001 void CViewer3dDoc::OnFileNew()
1002 {
1003   OnNewDocument();
1004 }
1005
1006 void CViewer3dDoc::InitViewButtons()
1007 {
1008   POSITION pos = GetFirstViewPosition();
1009   while (pos != NULL)
1010   {
1011     CViewer3dView* pView = (CViewer3dView*) GetNextView(pos);
1012     pView->InitButtons();
1013   }
1014 }
1015
1016 void CViewer3dDoc::OnTextureOn()
1017 {
1018         isTextureSampleStarted = TRUE;
1019         Start();
1020 }
1021
1022 void CViewer3dDoc::DoSample()
1023 {
1024   InitViewButtons();
1025
1026   HCURSOR hOldCursor = ::GetCursor();
1027   HCURSOR hNewCursor = AfxGetApp()->LoadStandardCursor(IDC_APPSTARTING);
1028
1029   SetCursor(hNewCursor);
1030   {
1031     try
1032     {
1033       myPresentation->DoSample();
1034     }
1035     catch (Standard_Failure)
1036     {
1037       Standard_SStream aSStream;
1038       aSStream << "An exception was caught: " << Standard_Failure::Caught() << ends;
1039       Standard_CString aMsg = aSStream.str().c_str();
1040       //      aSStream.rdbuf()->freeze(0);   // allow deletion of dynamic array
1041       AfxMessageBox (aMsg);
1042     }
1043   }
1044   SetCursor(hOldCursor);
1045 }
1046
1047 void CViewer3dDoc::OnBUTTONStart() 
1048 {
1049   myAISContext->EraseAll();
1050   myPresentation->FirstSample();
1051   DoSample();
1052 }
1053
1054 void CViewer3dDoc::OnBUTTONEnd()
1055 {
1056   myAISContext->EraseAll();
1057   myPresentation->LastSample();
1058   DoSample();
1059 }
1060
1061 void CViewer3dDoc::OnBUTTONRepeat() 
1062 {
1063   DoSample();
1064 }
1065
1066 void CViewer3dDoc::OnBUTTONNext() 
1067 {
1068   if (!myPresentation->AtLastSample())
1069   {
1070     myPresentation->NextSample();
1071     DoSample();
1072   }
1073 }
1074
1075 void CViewer3dDoc::OnBUTTONPrev() 
1076 {
1077   if (!myPresentation->AtFirstSample())
1078   {
1079     myPresentation->PrevSample();
1080     DoSample();
1081   }
1082 }
1083
1084 void CViewer3dDoc::OnUpdateBUTTONNext(CCmdUI* pCmdUI) 
1085 {
1086         if ( isTextureSampleStarted )
1087                 pCmdUI->Enable (!myPresentation->AtLastSample());
1088         else
1089                 pCmdUI->Enable (FALSE);
1090 }
1091
1092 void CViewer3dDoc::OnUpdateBUTTONPrev(CCmdUI* pCmdUI) 
1093 {
1094         if ( isTextureSampleStarted )
1095                 pCmdUI->Enable (!myPresentation->AtFirstSample());
1096         else
1097                 pCmdUI->Enable (FALSE);
1098 }
1099
1100 void CViewer3dDoc::OnUpdateBUTTONStart(CCmdUI* pCmdUI) 
1101 {
1102         pCmdUI->Enable (isTextureSampleStarted);
1103 }
1104
1105 void CViewer3dDoc::OnUpdateBUTTONRepeat(CCmdUI* pCmdUI) 
1106 {
1107         pCmdUI->Enable (isTextureSampleStarted);
1108 }
1109
1110 void CViewer3dDoc::OnUpdateBUTTONEnd(CCmdUI* pCmdUI) 
1111 {
1112         pCmdUI->Enable (isTextureSampleStarted);
1113 }
1114
1115 void CViewer3dDoc::OnDumpView() 
1116 {
1117   CFileDialog aDlg (false, "gif", "OCCView.gif", OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
1118     "GIF  Files (*.GIF)|*.gif|"
1119     "BMP  Files (*.BMP)|*.bmp|"
1120     "PNG  Files (*.PNG)|*.png|"
1121     "JPEG Files (*.JPG)|*.jpg|"
1122     "PPM  Files (*.PPM)|*.ppm|"
1123     "TIFF Files (*.TIFF)|*.tiff|"
1124     "TGA  Files (*.TGA)|*.tga|"
1125     "EXR  Files (*.EXR)|*.exr||", NULL);
1126   if (aDlg.DoModal() != IDOK)
1127   {
1128     return;
1129   }
1130
1131   for (POSITION aPos = GetFirstViewPosition(); aPos != NULL;)
1132   {
1133     CViewer3dView* pView = (CViewer3dView* )GetNextView (aPos);
1134     pView->UpdateWindow();
1135   }
1136   myViewer->InitActiveViews();
1137   Handle(V3d_View) aView = myViewer->ActiveView();
1138   aView->Dump (aDlg.GetPathName());
1139 }
1140
1141 void CViewer3dDoc::Start()
1142 {
1143   myPresentation->Init();
1144   OnBUTTONStart();
1145 }
1146
1147 void CViewer3dDoc::Fit()
1148 {
1149         CMDIFrameWnd *pFrame =  (CMDIFrameWnd*)AfxGetApp()->m_pMainWnd;
1150         CMDIChildWnd *pChild =  (CMDIChildWnd *) pFrame->GetActiveFrame();
1151         CViewer3dView *pView = (CViewer3dView *) pChild->GetActiveView();
1152         pView->FitAll();
1153 }