0028726: Quantity_NameOfColor should be replaced by Quantity_Color in function input...
[occt.git] / samples / mfc / standard / 04_Viewer3d / src / Viewer3dDoc.cpp
CommitLineData
7fd59977 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
21IMPLEMENT_DYNCREATE(CViewer3dDoc, CDocument)
22
47162471 23BEGIN_MESSAGE_MAP(CViewer3dDoc, OCC_3dDoc)
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
7fd59977 74END_MESSAGE_MAP()
75
76/////////////////////////////////////////////////////////////////////////////
77// CViewer3dDoc construction/destruction
78
79CViewer3dDoc::CViewer3dDoc()
a6eb515f 80:OCC_3dDoc()
7fd59977 81{
47162471 82 myCylinder.Nullify();
83 mySphere.Nullify();
84 myBox.Nullify();
85 myOverlappedCylinder.Nullify();
86 myOverlappedSphere.Nullify();
87 myOverlappedBox.Nullify();
88 myOffsetDlg = NULL;
89 myStaticTrihedronAxisIsDisplayed = FALSE;
90 myState = -1;
7fd59977 91
47162471 92 isTextureSampleStarted = FALSE;
7fd59977 93
47162471 94 myPresentation = OCCDemo_Presentation::Current;
95 myPresentation->SetDocument(this);
7fd59977 96
97
47162471 98 myAISContext->DefaultDrawer()->ShadingAspect()->SetColor(Quantity_NOC_CHARTREUSE1);
99 myAISContext->DefaultDrawer()->ShadingAspect()->SetMaterial(Graphic3d_NOM_SILVER);
7fd59977 100
47162471 101 strcpy_s(myDataDir, "Data");
102 strcpy_s(myLastPath, ".");
7fd59977 103
47162471 104 /*
105 Handle(AIS_Trihedron) myTrihedron;
106 Handle(Geom_Axis2Placement) myTrihedronAxis=new Geom_Axis2Placement(gp::XOY());
107 myTrihedron=new AIS_Trihedron(myTrihedronAxis);
108 myAISContext->Display(myTrihedron);
109 */
7fd59977 110}
111
112CViewer3dDoc::~CViewer3dDoc()
113{
114}
115
116/////////////////////////////////////////////////////////////////////////////
117// CViewer3dDoc diagnostics
118
119#ifdef _DEBUG
120void CViewer3dDoc::AssertValid() const
121{
47162471 122 CDocument::AssertValid();
7fd59977 123}
124
125void CViewer3dDoc::Dump(CDumpContext& dc) const
126{
47162471 127 CDocument::Dump(dc);
7fd59977 128}
129#endif //_DEBUG
130
131/////////////////////////////////////////////////////////////////////////////
132// CViewer3dDoc commands
133
576f8b11 134void CViewer3dDoc::UpdateResultMessageDlg (CString theTitle, const TCollection_AsciiString& theMessage)
7fd59977 135{
47162471 136 CString aText (theMessage.ToCString());
137 myCResultDialog.SetText (aText);
138 myCResultDialog.SetTitle(theTitle);
576f8b11 139}
7fd59977 140
576f8b11 141void CViewer3dDoc::UpdateResultMessageDlg(CString theTitle, CString theMessage)
142{
143 myCResultDialog.SetText (theMessage);
144 myCResultDialog.SetTitle(theTitle);
7fd59977 145}
146
47162471 147void CViewer3dDoc::OnBox()
7fd59977 148{
47162471 149 if(myBox.IsNull())
150 {
151 BRepPrimAPI_MakeBox B(gp_Pnt(0,-400,-100), 200.,150.,100.);
7fd59977 152
153
47162471 154 myBox = new AIS_Shape(B.Shape());
7fd59977 155
0577ae8c 156 myAISContext->SetMaterial (myBox, Graphic3d_NOM_PEWTER, Standard_False);
157 myAISContext->SetDisplayMode (myBox, 1, Standard_False);
7fd59977 158
0577ae8c 159 myAISContext->Display (myBox, Standard_True);
47162471 160 TCollection_AsciiString Message("\
7fd59977 161BRepPrimAPI_MakeBox Box1(gp_Pnt(0,-400,-100), 200.,150.,100.);\n\
47162471 162 ");
7fd59977 163
47162471 164 UpdateResultMessageDlg("Create Box",Message);
165 }
7fd59977 166}
167
47162471 168void CViewer3dDoc::OnCylinder()
7fd59977 169{
47162471 170 if(myCylinder.IsNull())
171 {
172 gp_Ax2 CylAx2(gp_Pnt(0,0,-100), gp_Dir(gp_Vec(gp_Pnt(0,0,-100),gp_Pnt(0,0,100))));
173 myCylinder = new User_Cylinder(CylAx2, 80.,200.);
7fd59977 174
0577ae8c 175 myAISContext->SetDisplayMode (myCylinder, 1, Standard_False);
7fd59977 176
0577ae8c 177 myAISContext->Display (myCylinder, Standard_True);
7fd59977 178
47162471 179 TCollection_AsciiString Message("\
7fd59977 180gp_Ax2 CylAx2(gp_Pnt(0,0,-100), gp_Dir(gp_Vec(gp_Pnt(0,0,-100),gp_Pnt(0,0,100))));\n\
181C = new User_Cylinder(CylAx2, 80.,200.);;\n\
47162471 182 ");
7fd59977 183
47162471 184 UpdateResultMessageDlg("Create Cylinder",Message);
185 }
7fd59977 186}
187
47162471 188void CViewer3dDoc::OnSphere()
7fd59977 189{
47162471 190 if(mySphere.IsNull())
191 {
192 BRepPrimAPI_MakeSphere S(gp_Pnt(0,300,0), 100.);
7fd59977 193
47162471 194 mySphere = new AIS_Shape(S.Shape());
7fd59977 195
0577ae8c 196 myAISContext->SetMaterial (mySphere, Graphic3d_NOM_BRONZE, Standard_False);
197 myAISContext->SetDisplayMode (mySphere, 1, Standard_False);
47162471 198
0577ae8c 199 myAISContext->Display (mySphere, Standard_False);
47162471 200 TCollection_AsciiString Message("\
7fd59977 201BRepPrimAPI_MakeSphere S(gp_Pnt(0,300,0), 100.);\n\
47162471 202 ");
203 UpdateResultMessageDlg("Create Sphere",Message);
204 }
7fd59977 205}
206
47162471 207void CViewer3dDoc::OnRemoveAll()
7fd59977 208
209{
47162471 210 AIS_ListOfInteractive aListOfObjects;
211 myAISContext->ObjectsInside(aListOfObjects,AIS_KOI_Shape);
7fd59977 212
47162471 213 AIS_ListIteratorOfListOfInteractive aListIterator;
214 for(aListIterator.Initialize(aListOfObjects);aListIterator.More();aListIterator.Next()){
0577ae8c 215 myAISContext->Remove (aListIterator.Value(), Standard_False);
47162471 216 }
7fd59977 217
0577ae8c 218 myAISContext->Remove (myCylinder, Standard_True);
7fd59977 219
220
47162471 221 myCylinder.Nullify();
222 mySphere.Nullify();
223 myBox.Nullify();
224 myOverlappedCylinder.Nullify();
225 myOverlappedSphere.Nullify();
226 myOverlappedBox.Nullify();
227 if(myOffsetDlg && myOffsetDlg->IsWindowVisible())
228 myOffsetDlg->UpdateValues();
7fd59977 229}
230
231void CViewer3dDoc::OnOverlappedBox()
232{
47162471 233 OnBox();
234 if(myOverlappedBox.IsNull()){
235 BRepPrimAPI_MakeBox B(gp_Pnt(0,-400,-100), 200.,150.,100.);
7fd59977 236
47162471 237 BRepBuilderAPI_NurbsConvert aNurbsConvert(B.Shape());
238 TopoDS_Shape aBoxShape2 = aNurbsConvert.Shape();
7fd59977 239
240
47162471 241 myOverlappedBox = new AIS_Shape(aBoxShape2);
7fd59977 242
0577ae8c 243 myAISContext->SetMaterial (myOverlappedBox, Graphic3d_NOM_GOLD, Standard_False);
244 myAISContext->SetDisplayMode (myOverlappedBox, 1, Standard_False);
7fd59977 245
0577ae8c 246 myAISContext->Display (myOverlappedBox, Standard_True);
47162471 247 TCollection_AsciiString Message("\
7fd59977 248BRepPrimAPI_MakeBox Box1(gp_Pnt(0,-400,-100), 200.,150.,100.);\n\
249\n\
250BRepPrimAPI_MakeBox Box2(gp_Pnt(0,-400,-100), 200.,150.,100.);\n\
251BRepBuilderAPI_NurbsConvert aNurbsConvert(Box2.Shape());\n\
47162471 252 ");
253 UpdateResultMessageDlg("Create overlapped boxes",Message);
254 if(myOffsetDlg && myOffsetDlg->IsWindowVisible())
255 myOffsetDlg->UpdateValues();
256 }
7fd59977 257}
258
47162471 259void CViewer3dDoc::OnOverlappedCylinder()
7fd59977 260{
47162471 261 OnCylinder();
262
263 if(myOverlappedCylinder.IsNull()){
264 gp_Ax2 CylAx2(gp_Pnt(0,0,-100), gp_Dir(gp_Vec(gp_Pnt(0,0,-100),gp_Pnt(0,0,100))));
265 BRepPrimAPI_MakeCylinder C(CylAx2, 80.,200.);
7fd59977 266
47162471 267 BRepBuilderAPI_NurbsConvert aNurbsConvert(C.Shape());
268 TopoDS_Shape aCylShape2 = aNurbsConvert.Shape();
7fd59977 269
47162471 270 myOverlappedCylinder = new AIS_Shape(aCylShape2);
7fd59977 271
7fd59977 272
0577ae8c 273 myAISContext->SetMaterial (myOverlappedCylinder, Graphic3d_NOM_GOLD, Standard_False);
274 myAISContext->SetDisplayMode (myOverlappedCylinder, 1, Standard_False);
7fd59977 275
0577ae8c 276 myAISContext->Display (myOverlappedCylinder, Standard_True);
7fd59977 277
47162471 278 TCollection_AsciiString Message("\
7fd59977 279gp_Ax2 CylAx2(gp_Pnt(0,0,-100), gp_Dir(gp_Vec(gp_Pnt(0,0,-100),gp_Pnt(0,0,100))));\n\
280Cylinder1 = new User_Cylinder(CylAx2, 80.,200.);\n\
281\n\
282BRepPrimAPI_MakeCylinder Cylinder2(CylAx2, 80.,200.);\n\
283BRepBuilderAPI_NurbsConvert aNurbsConvert(Cylinder2.Shape());\n\
47162471 284 ");
285 UpdateResultMessageDlg("Create overlapped cylinders",Message);
286 if (myOffsetDlg && myOffsetDlg->IsWindowVisible())
287 {
288 myOffsetDlg->UpdateValues();
289 }
290 }
7fd59977 291}
292
47162471 293void CViewer3dDoc::OnOverlappedSphere()
7fd59977 294{
47162471 295 OnSphere();
296 if(myOverlappedSphere.IsNull()){
297 BRepPrimAPI_MakeSphere S(gp_Pnt(0,300,0), 100.);
7fd59977 298
47162471 299 BRepBuilderAPI_NurbsConvert aNurbsConvert(S.Shape());
300 TopoDS_Shape aSphereShape2 = aNurbsConvert.Shape();
7fd59977 301
47162471 302 myOverlappedSphere = new AIS_Shape(aSphereShape2);
7fd59977 303
0577ae8c 304 myAISContext->SetMaterial (myOverlappedSphere, Graphic3d_NOM_GOLD, Standard_False);
7fd59977 305
0577ae8c 306 myAISContext->SetDisplayMode (myOverlappedSphere, 1, Standard_False);
7fd59977 307
0577ae8c 308 myAISContext->Display (myOverlappedSphere, Standard_True);
7fd59977 309
47162471 310 TCollection_AsciiString Message("\
7fd59977 311BRepPrimAPI_MakeSphere Sphere1(gp_Pnt(0,300,0), 100.);\n\
312\n\
313BRepPrimAPI_MakeSphere Sphere2(gp_Pnt(0,300,0), 100.);\n\
314BRepBuilderAPI_NurbsConvert aNurbsConvert(Sphere2.Shape());\n\
47162471 315 ");
316 UpdateResultMessageDlg("Create overlapped spheres",Message);
317 if (myOffsetDlg && myOffsetDlg->IsWindowVisible())
318 {
319 myOffsetDlg->UpdateValues();
320 }
321 }
7fd59977 322}
323
47162471 324void CViewer3dDoc::OnPolygonOffsets()
7fd59977 325{
47162471 326 myOffsetDlg = new COffsetDlg(this);
327 myOffsetDlg->Create(COffsetDlg::IDD,NULL);
328 myAISContext->UpdateCurrentViewer();
7fd59977 329}
330
331void CViewer3dDoc::OnUpdatePolygonOffsets(CCmdUI* pCmdUI)
332{
47162471 333 Standard_Integer aOffsetMode;
334 Standard_ShortReal aFactor;
335 Standard_ShortReal aCylUnits = 0;
336 Standard_ShortReal aSphereUnits = 0;
337 Standard_ShortReal aBoxUnits = 0;
7fd59977 338
47162471 339 BOOL IsOverlappedCylinderDisplayed = myAISContext->IsDisplayed(myOverlappedCylinder);
340 BOOL IsOverlappedSphereDisplayed = myAISContext->IsDisplayed(myOverlappedSphere);
341 BOOL IsOverlappedBoxDisplayed = myAISContext->IsDisplayed(myOverlappedBox);
342 BOOL IsAnyOverlappedObjectDisplayed =
343 IsOverlappedCylinderDisplayed || IsOverlappedSphereDisplayed || IsOverlappedBoxDisplayed;
7fd59977 344
47162471 345 if(!myOverlappedCylinder.IsNull() && IsOverlappedCylinderDisplayed){
346 myOverlappedCylinder->PolygonOffsets(aOffsetMode,aFactor,aCylUnits);
347 }
7fd59977 348
47162471 349 if(!myOverlappedSphere.IsNull() && IsOverlappedSphereDisplayed){
350 myOverlappedSphere->PolygonOffsets(aOffsetMode,aFactor,aSphereUnits);
351 }
352
353 if(!myOverlappedBox.IsNull() && IsOverlappedBoxDisplayed){
354 myOverlappedBox->PolygonOffsets(aOffsetMode,aFactor,aBoxUnits);
355 }
356
357 if(myOffsetDlg && myOffsetDlg->IsWindowVisible())
358 pCmdUI->SetCheck(TRUE);
359 else
360 pCmdUI->SetCheck(FALSE);
361 if (IsAnyOverlappedObjectDisplayed)
362 if(myOffsetDlg)
363 pCmdUI->Enable(!myOffsetDlg->IsWindowVisible());
364 else
365 pCmdUI->Enable(TRUE);
366 else
367 pCmdUI->Enable(FALSE);
7fd59977 368}
369
47162471 370void CViewer3dDoc::OnUpdateCylinder(CCmdUI* pCmdUI)
7fd59977 371{
47162471 372 pCmdUI->Enable(myCylinder.IsNull());
7fd59977 373}
374
47162471 375void CViewer3dDoc::OnUpdateSphere(CCmdUI* pCmdUI)
7fd59977 376{
47162471 377 pCmdUI->Enable(mySphere.IsNull());
7fd59977 378}
379
47162471 380void CViewer3dDoc::OnUpdateBox(CCmdUI* pCmdUI)
7fd59977 381{
47162471 382 pCmdUI->Enable(myBox.IsNull());
7fd59977 383}
384
47162471 385void CViewer3dDoc::OnUpdateOverlappedCylinder(CCmdUI* pCmdUI)
7fd59977 386{
47162471 387 pCmdUI->Enable (myOverlappedCylinder.IsNull()
388 || myCylinder.IsNull());
389
7fd59977 390}
391
47162471 392void CViewer3dDoc::OnUpdateOverlappedSphere(CCmdUI* pCmdUI)
7fd59977 393{
47162471 394 pCmdUI->Enable (myOverlappedSphere.IsNull()
395 || mySphere.IsNull());
7fd59977 396}
397
47162471 398void CViewer3dDoc::OnUpdateOverlappedBox(CCmdUI* pCmdUI)
7fd59977 399{
47162471 400 pCmdUI->Enable (myOverlappedBox.IsNull()
401 || myBox.IsNull());
7fd59977 402}
403
47162471 404void CViewer3dDoc::OnObjectRemove()
7fd59977 405{
404c8936 406 // A small trick to avoid complier error (C2668).
407 const Handle(AIS_InteractiveObject)& aBox = myBox;
408 if(myAISContext->IsSelected (aBox))
47162471 409 myBox.Nullify();
7fd59977 410
404c8936 411 const Handle(AIS_InteractiveObject)& aCylinder = myCylinder;
412 if(myAISContext->IsSelected (aCylinder))
47162471 413 myCylinder.Nullify();
7fd59977 414
404c8936 415 const Handle(AIS_InteractiveObject)& aSphere = mySphere;
416 if(myAISContext->IsSelected (aSphere))
47162471 417 mySphere.Nullify();
7fd59977 418
404c8936 419 const Handle(AIS_InteractiveObject)& anOverlappedBox = myOverlappedBox;
420 if(myAISContext->IsSelected (anOverlappedBox))
47162471 421 myOverlappedBox.Nullify();
7fd59977 422
404c8936 423 const Handle(AIS_InteractiveObject)& anOverlappedCylinder = myOverlappedCylinder;
424 if(myAISContext->IsSelected (anOverlappedCylinder))
47162471 425 myOverlappedCylinder.Nullify();
7fd59977 426
404c8936 427 const Handle(AIS_InteractiveObject)& anOverlappedSphere = myOverlappedSphere;
428 if(myAISContext->IsSelected (anOverlappedSphere))
47162471 429 myOverlappedSphere.Nullify();
7fd59977 430
7fd59977 431
404c8936 432 for(myAISContext->InitSelected();myAISContext->MoreSelected();myAISContext->InitSelected())
433 myAISContext->Remove(myAISContext->SelectedInteractive(),Standard_True);
7fd59977 434
47162471 435 if(myOffsetDlg && myOffsetDlg->IsWindowVisible())
436 myOffsetDlg->UpdateValues();
7fd59977 437}
438
47162471 439void CViewer3dDoc::OnObjectErase()
7fd59977 440
441{
47162471 442 OCC_3dBaseDoc::OnObjectErase();
443 if(myOffsetDlg && myOffsetDlg->IsWindowVisible())
444 myOffsetDlg->UpdateValues();
7fd59977 445}
446
47162471 447void CViewer3dDoc::OnObjectDisplayall()
7fd59977 448
449{
47162471 450 OCC_3dBaseDoc::OnObjectDisplayall();
451 if(myOffsetDlg && myOffsetDlg->IsWindowVisible())
452 myOffsetDlg->UpdateValues();
7fd59977 453}
454
92efcf78 455Handle(User_Cylinder) CViewer3dDoc::GetCylinder()
7fd59977 456{
47162471 457 return myCylinder;
7fd59977 458}
459
460
92efcf78 461Handle(AIS_Shape) CViewer3dDoc::GetSphere()
7fd59977 462{
47162471 463 return mySphere;
7fd59977 464}
465
92efcf78 466Handle(AIS_Shape) CViewer3dDoc::GetBox()
7fd59977 467{
47162471 468 return myBox;
7fd59977 469}
470
92efcf78 471Handle(AIS_Shape) CViewer3dDoc::GetOverlappedCylinder()
7fd59977 472{
47162471 473 return myOverlappedCylinder;
7fd59977 474}
475
476
92efcf78 477Handle(AIS_Shape) CViewer3dDoc::GetOverlappedSphere()
7fd59977 478{
47162471 479 return myOverlappedSphere;
7fd59977 480}
481
92efcf78 482Handle(AIS_Shape) CViewer3dDoc::GetOverlappedBox()
7fd59977 483{
47162471 484 return myOverlappedBox;
7fd59977 485}
486
47162471 487void CViewer3dDoc::DragEvent (const Standard_Integer theX,
488 const Standard_Integer theY,
489 const Standard_Integer theState,
490 const Handle(V3d_View)& theView)
7fd59977 491{
47162471 492 OCC_3dBaseDoc::DragEvent (theX, theY, theState, theView);
493 if(myOffsetDlg && myOffsetDlg->IsWindowVisible())
494 myOffsetDlg->UpdateValues();
7fd59977 495}
496
497//-----------------------------------------------------------------------------------------
498//
499//-----------------------------------------------------------------------------------------
5c573e69 500void CViewer3dDoc::InputEvent(const Standard_Integer /*x*/,
501 const Standard_Integer /*y*/,
502 const Handle(V3d_View)& /*aView*/ )
7fd59977 503{
5c1f974e 504 if (myOffsetDlg && myOffsetDlg->IsWindowVisible())
505 myOffsetDlg->UpdateValues();
7fd59977 506
5c1f974e 507 Quantity_Color CSFColor;
508 COLORREF MSColor;
0577ae8c 509 myAISContext->Select (Standard_True);
7fd59977 510
5c1f974e 511 // Change the color of a selected face in a user cylinder
512 if (myState == FACE_COLOR)
513 {
514 myAISContext->InitSelected();
515 if (myAISContext->MoreSelected())
516 {
92efcf78 517 Handle(AIS_InteractiveObject) Current = myAISContext->SelectedInteractive();
5c1f974e 518 if (Current->HasColor())
519 {
87432b82 520 myAISContext->Color (Current, CSFColor);
5c1f974e 521 MSColor = RGB (CSFColor.Red()*255.0, CSFColor.Green()*255.0, CSFColor.Blue()*255.0);
522 }
523 else
524 {
525 MSColor = RGB (255, 255, 255);
526 }
527
528 CColorDialog dlgColor(MSColor);
529 if (dlgColor.DoModal() == IDOK)
530 {
531 MSColor = dlgColor.GetColor();
532 CSFColor = Quantity_Color (GetRValue (MSColor)/255.0,
533 GetGValue (MSColor)/255.0,
534 GetBValue (MSColor)/255.0,
535 Quantity_TOC_RGB);
536
4208cf18 537 Handle(AIS_InteractiveObject) aSelectedObject = myAISContext->SelectedInteractive();
87432b82 538 Handle(User_Cylinder)::DownCast (aSelectedObject)->SetColor (CSFColor);
4208cf18 539
0577ae8c 540 myAISContext->Redisplay (aSelectedObject, Standard_True);
5c1f974e 541 myState = -1;
5c1f974e 542 }
543 }
544
5c573e69 545 myCResultDialog.SetTitle("Change face color");
87432b82 546 myCResultDialog.SetText( " Handle(AIS_InteractiveObject) aSelectedObject = myAISContext->SelectedInteractive(); \n"
547 " Handle(User_Cylinder)::DownCast(aSelectedObject)->SetColor (CSFColor); \n"
548 " myAISContext->Redisplay (myAISContext->Current(), Standard_True); \n"
5c1f974e 549 " \n"
550 " \n"
551 " NOTE: a User_Cylinder is an object defined by the user. \n"
552 " The User_Cylinder class inherit from the AIS_InteractiveObject \n"
553 " Cascade class, it's use is the same as an AIS_InteractiveObject. \n"
5c1f974e 554 " \n");
576f8b11 555 SetTitle (L"Change face color");
5c1f974e 556 }
557}
7fd59977 558
559//-----------------------------------------------------------------------------------------
560//
561//-----------------------------------------------------------------------------------------
47162471 562void CViewer3dDoc::ShiftDragEvent (const Standard_Integer theX,
563 const Standard_Integer theY,
564 const Standard_Integer theState,
565 const Handle(V3d_View)& theView)
7fd59977 566{
47162471 567 OCC_3dBaseDoc::ShiftDragEvent(theX, theY, theState, theView);
5c1f974e 568 if(myOffsetDlg && myOffsetDlg->IsWindowVisible())
569 myOffsetDlg->UpdateValues();
7fd59977 570}
571
572
573//-----------------------------------------------------------------------------------------
574//
575//-----------------------------------------------------------------------------------------
47162471 576void CViewer3dDoc::ShiftInputEvent (const Standard_Integer theX,
577 const Standard_Integer theY,
578 const Handle(V3d_View)& theView)
7fd59977 579{
47162471 580 OCC_3dBaseDoc::ShiftInputEvent (theX, theY, theView);
5c1f974e 581 if(myOffsetDlg && myOffsetDlg->IsWindowVisible())
582 myOffsetDlg->UpdateValues();
7fd59977 583}
584
47162471 585void CViewer3dDoc::OnObjectColoredMesh()
7fd59977 586{
404c8936 587 for(myAISContext->InitSelected();myAISContext->MoreSelected();myAISContext->NextSelected())
588 if (myAISContext->SelectedInteractive()->IsKind(STANDARD_TYPE(User_Cylinder)))
5c1f974e 589 {
404c8936 590 myAISContext->ClearPrs(myAISContext->SelectedInteractive(),6,Standard_False);
591 myAISContext->RecomputePrsOnly(myAISContext->SelectedInteractive(), Standard_False);
0577ae8c 592 myAISContext->SetDisplayMode(myAISContext->SelectedInteractive(), 6, Standard_False);
5c1f974e 593 }
0577ae8c 594
595 myAISContext->UpdateCurrentViewer();
7fd59977 596}
597
47162471 598void CViewer3dDoc::OnUpdateObjectColoredMesh(CCmdUI* pCmdUI)
7fd59977 599{
600 bool CylinderIsCurrentAndDisplayed = false;
404c8936 601 for (myAISContext->InitSelected();myAISContext->MoreSelected ();myAISContext->NextSelected ())
602 if(myAISContext->SelectedInteractive()->IsKind(STANDARD_TYPE(User_Cylinder)))
47162471 603 CylinderIsCurrentAndDisplayed=true;
604 pCmdUI->Enable (CylinderIsCurrentAndDisplayed);
7fd59977 605}
606
47162471 607void CViewer3dDoc::OnUpdateObjectWireframe(CCmdUI* pCmdUI)
7fd59977 608{
609 bool OneOrMoreInShadingOrColoredMesh = false;
404c8936 610 for (myAISContext->InitSelected();myAISContext->MoreSelected ();myAISContext->NextSelected ())
611 if (myAISContext->IsDisplayed(myAISContext->SelectedInteractive(), 1) || myAISContext->IsDisplayed(myAISContext->SelectedInteractive(), 6))
47162471 612 OneOrMoreInShadingOrColoredMesh=true;
613 pCmdUI->Enable (OneOrMoreInShadingOrColoredMesh);
7fd59977 614}
615
616
47162471 617void CViewer3dDoc::OnUpdateObjectShading(CCmdUI* pCmdUI)
7fd59977 618{
619 bool OneOrMoreInWireframeOrColoredMesh = false;
404c8936 620 for (myAISContext->InitSelected();myAISContext->MoreSelected ();myAISContext->NextSelected ())
621 if (myAISContext->IsDisplayed(myAISContext->SelectedInteractive(),0) || myAISContext->IsDisplayed(myAISContext->SelectedInteractive(),6))
47162471 622 OneOrMoreInWireframeOrColoredMesh=true;
623 pCmdUI->Enable (OneOrMoreInWireframeOrColoredMesh);
7fd59977 624}
625
47162471 626void CViewer3dDoc::OnOptionsTrihedronDynamicTrihedron()
7fd59977 627{
47162471 628 if (myAISContext -> IsDisplayed(myTrihedron))
629 {
0577ae8c 630 myAISContext->Remove(myTrihedron, Standard_True);
47162471 631 }
632 else
633 {
634 Handle(Geom_Axis2Placement) myTrihedronAxis=new Geom_Axis2Placement(gp::XOY());
635 myTrihedron=new AIS_Trihedron(myTrihedronAxis);
0577ae8c 636 myAISContext->SetTrihedronSize(200, Standard_False);
637 myAISContext->Display(myTrihedron, Standard_True);
47162471 638 }
7fd59977 639}
640
47162471 641void CViewer3dDoc::OnUpdateOptionsTrihedronDynamicTrihedron(CCmdUI* pCmdUI)
7fd59977 642{
47162471 643 if (myAISContext->IsDisplayed(myTrihedron))
644 pCmdUI->SetCheck(1);
645 else
646 pCmdUI->SetCheck(0);
7fd59977 647}
648
649void CViewer3dDoc::SetMyStaticTrihedronAxisIsDisplayed(BOOL IsDisplayed)
650{
47162471 651 myStaticTrihedronAxisIsDisplayed = IsDisplayed;
7fd59977 652}
653
654void CViewer3dDoc::OnUpdateOptionsTrihedronStaticTrihedron(CCmdUI* pCmdUI)
655{
47162471 656 if (myStaticTrihedronAxisIsDisplayed)
657 pCmdUI->SetCheck(1);
658 else
659 pCmdUI->SetCheck(0);
660
7fd59977 661}
662
a6eb515f 663void CViewer3dDoc::Popup (const Standard_Integer x,
664 const Standard_Integer y ,
665 const Handle(V3d_View)& aView)
7fd59977 666{
a6eb515f 667 myPopupMenuNumber=0;
668 // Specified check for context menu number to call
404c8936 669 myAISContext->InitSelected();
670 if (myAISContext->MoreSelected())
7fd59977 671 {
404c8936 672 if (myAISContext->SelectedInteractive()->IsKind(STANDARD_TYPE(User_Cylinder)))
a6eb515f 673 {
674 myPopupMenuNumber = 2;
675 //return;
676 }
677 }
678 OCC_3dBaseDoc::Popup(x,y, aView);
7fd59977 679}
5c1f974e 680
7fd59977 681//Set faces selection mode
682void CViewer3dDoc::OnFaces()
683{
404c8936 684 myAISContext->Activate (AIS_Shape::SelectionMode (TopAbs_FACE));
7fd59977 685
5c573e69 686 myCResultDialog.SetTitle("Standard mode: TopAbs_FACE");
687 myCResultDialog.SetText(" myAISContext->OpenLocalContext(); \n"
5c1f974e 688 " \n"
689 " myAISContext->ActivateStandardMode(TopAbs_FACE); \n"
690 " \n");
576f8b11 691 SetTitle (L"Standard mode: TopAbs_FACE");
7fd59977 692}
693
694//Set edges selection mode
695void CViewer3dDoc::OnEdges()
696{
404c8936 697 myAISContext->Activate (AIS_Shape::SelectionMode (TopAbs_EDGE));
7fd59977 698
5c573e69 699 myCResultDialog.SetTitle("Standard mode: TopAbs_EDGE");
700 myCResultDialog.SetText(" myAISContext->OpenLocalContext(); \n"
5c1f974e 701 " \n"
702 " myAISContext->ActivateStandardMode(TopAbs_EDGE); \n"
703 " \n");
576f8b11 704 SetTitle (L"Standard mode: TopAbs_EDGE");
7fd59977 705}
706
707// Set vertices selection mode
708void CViewer3dDoc::OnVertices()
709{
404c8936 710 myAISContext->Activate (AIS_Shape::SelectionMode (TopAbs_VERTEX));
7fd59977 711
5c573e69 712 myCResultDialog.SetTitle("Standard mode: TopAbs_VERTEX");
713 myCResultDialog.SetText(" myAISContext->OpenLocalContext(); \n"
5c1f974e 714 " \n"
715 " myAISContext->ActivateStandardMode(TopAbs_VERTEX); \n"
716 " \n");
576f8b11 717 SetTitle (L"Standard mode: TopAbs_VERTEX");
7fd59977 718}
719
720//Neutral selection mode
721void CViewer3dDoc::OnNeutral()
722{
5c573e69 723 myCResultDialog.SetTitle("Standard mode: Neutral");
724 myCResultDialog.SetText(" myAISContext->CloseAllContexts(); \n"
5c1f974e 725 " \n");
576f8b11 726 SetTitle (L"Standard mode: Neutral");
7fd59977 727}
728
729// Change the color of faces on a user cylinder
730void CViewer3dDoc::OnUsercylinderChangefacecolor()
731{
404c8936 732 myAISContext->Activate(myAISContext->SelectedInteractive(), 4);
5c1f974e 733 myState = FACE_COLOR;
734 // see the following of treatment in inputevent
7fd59977 735}
736
737// Make 3d fillets on solids
738// It is necessary to activate the edges selection mode and select edges on an object
739// before running this function
740void CViewer3dDoc::OnFillet3d()
741{
5c1f974e 742 myAISContext->InitSelected();
743 if (myAISContext->MoreSelected())
744 {
92efcf78 745 Handle(AIS_Shape) aSelInteractive (Handle(AIS_Shape)::DownCast (myAISContext->SelectedInteractive()));
47162471 746 if (aSelInteractive.IsNull())
5c1f974e 747 {
576f8b11 748 AfxMessageBox (L"It is necessary to activate the edges selection mode\n"
749 L"and select edges on an object before \nrunning this function");
5c1f974e 750 return;
751 }
752
47162471 753 BRepFilletAPI_MakeFillet aFillet (aSelInteractive->Shape());
5c1f974e 754
755 for (myAISContext->InitSelected(); myAISContext->MoreSelected(); myAISContext->NextSelected())
7fd59977 756 {
47162471 757 const TopoDS_Shape& aSelShape = myAISContext->SelectedShape();
5c1f974e 758 if (aSelShape.ShapeType() != TopAbs_EDGE)
759 {
576f8b11 760 AfxMessageBox (L"It is necessary to activate the edges selection mode\n"
761 L"and select edges on an object before \nrunning this function");
7fd59977 762 return;
5c1f974e 763 }
7fd59977 764 }
7fd59977 765
47162471 766 BoxRadius aDialog (NULL,10.);
767 if (aDialog.DoModal() == IDOK)
5c1f974e 768 {
769 for (myAISContext->InitSelected(); myAISContext->MoreSelected(); myAISContext->NextSelected())
770 {
47162471 771 // Selected shape has its own location, and sub-shapes in the solid shape for fillet building
772 // don't have own locations. Fillet builder needs to know that input edge is just the same one as
773 // some sub-shape in our target solid shape, so no location is to be in input edge for fillet builder.
774 TopoDS_Shape aSelShape = myAISContext->SelectedShape().Located (TopLoc_Location());
775 aFillet.Add (aDialog.m_radius, TopoDS::Edge (aSelShape) );
5c1f974e 776 }
777 }
778 else
779 {
780 return;
781 }
782
783 TopoDS_Shape aNewShape;
784 try
785 {
786 aNewShape = aFillet.Shape();
787 }
788 catch (Standard_Failure)
789 {
576f8b11 790 AfxMessageBox (L"Error During Fillet computation");
5c1f974e 791 return;
792 }
793
47162471 794 aSelInteractive ->Set (aNewShape);
0577ae8c 795 myAISContext->Redisplay (aSelInteractive, Standard_True);
5c1f974e 796 }
797
5c573e69 798 myCResultDialog.SetTitle("Make a fillet");
799 myCResultDialog.SetText(" Handle(AIS_Shape) S = Handle(AIS_Shape)::DownCast(myAISContext->Interactive()); \n"
5c1f974e 800 " \n"
801 " BRepAPI_MakeFillet aFillet(S->Shape()); \n"
802 " \n"
803 " TopoDS_Edge anEdge=TopoDS::Edge(myAISContext->SelectedShape()); \n"
804 " \n"
805 " aFillet.Add(dlg.m_radius,anEdge); \n"
806 " \n"
807 " TopoDS_Shape aNewShape = aFillet.Shape(); \n"
808 " \n"
809 " S->Set(aNewShape); \n"
810 " \n"
811 " myAISContext->Redisplay(S); \n"
812 " \n");
576f8b11 813 SetTitle (L"Make a fillet");
7fd59977 814}
5c1f974e 815
7fd59977 816// Create and display a circle with standard tools
817void CViewer3dDoc::OnCircle()
818{
5c1f974e 819 gp_Ax2 anAx2 (gp_Pnt (0., 0., 0.), gp_Dir(0., 0., -1.));
820 Handle(Geom_Circle) aGeomCircle = new Geom_Circle (anAx2, 300);
7fd59977 821
5c1f974e 822 // the lines above substitute
823 // GC_MakeCircle C(gp_Pnt(-100.,-300.,0.),gp_Pnt(-50.,-200.,0.),gp_Pnt(-10.,-250.,0.));
824 // Handle(AIS_Circle) anAISCirc = new AIS_Circle(C.Value());
825
826 Handle(AIS_Circle) anAISCirc = new AIS_Circle(aGeomCircle);
0577ae8c 827 myAISContext->Display (anAISCirc, Standard_True);
7fd59977 828
5c573e69 829 myCResultDialog.SetTitle("Create a circle");
830 myCResultDialog.SetText(" GC_MakeCircle C(gp_Pnt(-100.,-300.,0.),gp_Pnt(-50.,-200.,0.),gp_Pnt(-10.,-250.,0.)); \n"
5c1f974e 831 " \n"
832 " Handle(AIS_Circle) anAISCirc = new AIS_Circle(C.Value()); \n"
833 " \n"
834 " myAISContext->Display(anAISCirc); \n"
835 " \n");
576f8b11 836 SetTitle (L"Create a circle");
7fd59977 837}
838
839void CViewer3dDoc::OnLine()
840{
5c1f974e 841 // TODO: Add your command handler code here
842 gp_Lin aGpLin (gp_Pnt (0., 0., 0.), gp_Dir(1., 0., 0.));
843 Handle(Geom_Line) aGeomLin = new Geom_Line (aGpLin);
844 Handle(AIS_Line) anAISLine = new AIS_Line (aGeomLin);
0577ae8c 845 myAISContext->Display (anAISLine, Standard_True);
7fd59977 846
5c573e69 847 myCResultDialog.SetTitle("Create a line");
848 myCResultDialog.SetText(" gp_Lin L(gp_Pnt(0.,0.,0.),gp_Dir(1.,0.,0.)); \n"
5c1f974e 849 " \n"
850 " Handle(Geom_Line) aLine = new Geom_Line(L); \n"
851 " \n"
852 " Handle(AIS_Line) anAISLine = new AIS_Line(aLine); \n"
853 " \n"
854 " myAISContext->Display(anAISLine); \n"
855 " \n");
576f8b11 856 SetTitle (L"Create a line");
7fd59977 857}
858
859void CViewer3dDoc::OnNbisos()
860{
5c1f974e 861 int aNumU = myAISContext->DefaultDrawer()->UIsoAspect()->Number();
862 int aNumV = myAISContext->DefaultDrawer()->VIsoAspect()->Number();
7fd59977 863
5c1f974e 864 DlgIsos aDlg (NULL, aNumU, aNumV);
7fd59977 865
5c1f974e 866 if (aDlg.DoModal() == IDOK)
867 {
868 myAISContext->DefaultDrawer()->UIsoAspect()->SetNumber (aDlg.m_isou);
869 myAISContext->DefaultDrawer()->VIsoAspect()->SetNumber (aDlg.m_isov);
870
5c573e69 871 myCResultDialog.SetTitle("Iso Aspect");
872 myCResultDialog.SetText(" myAISContext->DefaultDrawer()->UIsoAspect()->SetNumber(dlg.m_isou); \n"
5c1f974e 873 " \n"
874 " myAISContext->DefaultDrawer()->VIsoAspect()->SetNumber(dlg.m_isov); \n"
875 " \n");
576f8b11 876 SetTitle (L"Iso Aspect");
5c1f974e 877 }
7fd59977 878}
879
880BOOL CViewer3dDoc::OnNewDocument()
881{
5c1f974e 882 if (!CDocument::OnNewDocument())
883 return FALSE;
7fd59977 884
5c1f974e 885 // TODO: add reinitialization code here
886 // (SDI documents will reuse this document)
7fd59977 887 SetTitle(myPresentation->GetName());
888
0577ae8c 889 myAISContext->EraseAll (Standard_False);
890 myAISContext->SetDisplayMode(AIS_Shaded, Standard_True);
7fd59977 891
892 POSITION pos = GetFirstViewPosition();
893 while (pos != NULL)
894 {
895 CViewer3dView* pView = (CViewer3dView*) GetNextView(pos);
896 pView->Reset();
897 }
898
5c1f974e 899 return TRUE;
7fd59977 900}
901
902void CViewer3dDoc::OnFileNew()
903{
904 OnNewDocument();
905}
906
907void CViewer3dDoc::InitViewButtons()
908{
909 POSITION pos = GetFirstViewPosition();
910 while (pos != NULL)
911 {
912 CViewer3dView* pView = (CViewer3dView*) GetNextView(pos);
913 pView->InitButtons();
914 }
915}
916
917void CViewer3dDoc::OnTextureOn()
918{
919 isTextureSampleStarted = TRUE;
920 Start();
921}
922
923void CViewer3dDoc::DoSample()
924{
925 InitViewButtons();
926
927 HCURSOR hOldCursor = ::GetCursor();
928 HCURSOR hNewCursor = AfxGetApp()->LoadStandardCursor(IDC_APPSTARTING);
929
930 SetCursor(hNewCursor);
931 {
932 try
933 {
934 myPresentation->DoSample();
935 }
9775fa61 936 catch (Standard_Failure const& anException)
7fd59977 937 {
938 Standard_SStream aSStream;
9775fa61 939 aSStream << "An exception was caught: " << anException << ends;
576f8b11 940 CString aMsg = aSStream.str().c_str();
7fd59977 941 AfxMessageBox (aMsg);
942 }
943 }
944 SetCursor(hOldCursor);
945}
946
947void CViewer3dDoc::OnBUTTONStart()
948{
0577ae8c 949 myAISContext->EraseAll (Standard_True);
7fd59977 950 myPresentation->FirstSample();
951 DoSample();
952}
953
954void CViewer3dDoc::OnBUTTONEnd()
955{
0577ae8c 956 myAISContext->EraseAll (Standard_True);
7fd59977 957 myPresentation->LastSample();
958 DoSample();
959}
960
961void CViewer3dDoc::OnBUTTONRepeat()
962{
963 DoSample();
964}
965
966void CViewer3dDoc::OnBUTTONNext()
967{
968 if (!myPresentation->AtLastSample())
969 {
970 myPresentation->NextSample();
971 DoSample();
972 }
973}
974
975void CViewer3dDoc::OnBUTTONPrev()
976{
977 if (!myPresentation->AtFirstSample())
978 {
979 myPresentation->PrevSample();
980 DoSample();
981 }
982}
983
984void CViewer3dDoc::OnUpdateBUTTONNext(CCmdUI* pCmdUI)
985{
986 if ( isTextureSampleStarted )
987 pCmdUI->Enable (!myPresentation->AtLastSample());
988 else
989 pCmdUI->Enable (FALSE);
990}
991
992void CViewer3dDoc::OnUpdateBUTTONPrev(CCmdUI* pCmdUI)
993{
994 if ( isTextureSampleStarted )
995 pCmdUI->Enable (!myPresentation->AtFirstSample());
996 else
997 pCmdUI->Enable (FALSE);
998}
999
1000void CViewer3dDoc::OnUpdateBUTTONStart(CCmdUI* pCmdUI)
1001{
1002 pCmdUI->Enable (isTextureSampleStarted);
1003}
1004
1005void CViewer3dDoc::OnUpdateBUTTONRepeat(CCmdUI* pCmdUI)
1006{
1007 pCmdUI->Enable (isTextureSampleStarted);
1008}
1009
1010void CViewer3dDoc::OnUpdateBUTTONEnd(CCmdUI* pCmdUI)
1011{
1012 pCmdUI->Enable (isTextureSampleStarted);
1013}
1014
12c76bee 1015void CViewer3dDoc::OnDumpView()
1016{
5c1f974e 1017 for (POSITION aPos = GetFirstViewPosition(); aPos != NULL;)
1018 {
1019 CViewer3dView* pView = (CViewer3dView* )GetNextView (aPos);
1020 pView->UpdateWindow();
7fd59977 1021 }
12c76bee 1022
5c1f974e 1023 myViewer->InitActiveViews();
1024 Handle(V3d_View) aView = myViewer->ActiveView();
12c76bee 1025 ExportView (aView);
7fd59977 1026}
1027
1028void CViewer3dDoc::Start()
1029{
1030 myPresentation->Init();
1031 OnBUTTONStart();
1032}
1033
1034void CViewer3dDoc::Fit()
1035{
1036 CMDIFrameWnd *pFrame = (CMDIFrameWnd*)AfxGetApp()->m_pMainWnd;
1037 CMDIChildWnd *pChild = (CMDIChildWnd *) pFrame->GetActiveFrame();
1038 CViewer3dView *pView = (CViewer3dView *) pChild->GetActiveView();
1039 pView->FitAll();
1040}