7fd59977 |
1 | // OCC_2dDoc.cpp: implementation of the OCC_2dDoc class. |
2 | // |
3 | ////////////////////////////////////////////////////////////////////// |
4 | |
5 | #include <stdafx.h> |
6 | |
7 | #include "OCC_2dDoc.h" |
8 | |
5c1f974e |
9 | #include "OCC_App.h" |
7fd59977 |
10 | #include "OCC_2dView.h" |
11 | |
12 | IMPLEMENT_DYNCREATE(OCC_2dDoc, CDocument) |
13 | |
14 | ////////////////////////////////////////////////////////////////////// |
15 | // Construction/Destruction |
16 | ////////////////////////////////////////////////////////////////////// |
17 | |
5c1f974e |
18 | OCC_2dDoc::OCC_2dDoc() : OCC_BaseDoc() |
7fd59977 |
19 | { |
5c1f974e |
20 | // Get the Graphic Driver from the application |
21 | Handle(Graphic3d_GraphicDriver) aGraphicDriver = |
22 | ((OCC_App*)AfxGetApp())->GetGraphicDriver(); |
7fd59977 |
23 | |
5c1f974e |
24 | // create the Viewer |
6a24c6de |
25 | myViewer = new V3d_Viewer (aGraphicDriver); |
5c1f974e |
26 | myViewer->SetDefaultLights(); |
27 | myViewer->SetLightOn(); |
28 | myViewer->SetDefaultViewProj (V3d_Zpos); |
29 | |
30 | // set default values for grids |
31 | myViewer->SetCircularGridValues (0, 0, 10, 8, 0); |
32 | myViewer->SetRectangularGridValues (0, 0, 10, 10, 0); |
7fd59977 |
33 | |
5c1f974e |
34 | myAISContext = new AIS_InteractiveContext (myViewer); |
35 | |
36 | AfxInitRichEdit(); |
7fd59977 |
37 | } |
38 | |
234e52be |
39 | OCC_2dDoc::~OCC_2dDoc() |
40 | { |
41 | } |
42 | |
5c1f974e |
43 | void OCC_2dDoc::FitAll2DViews(Standard_Boolean theUpdateViewer) |
7fd59977 |
44 | { |
5c1f974e |
45 | if (theUpdateViewer) |
7fd59977 |
46 | { |
5c1f974e |
47 | myViewer->Update(); |
48 | } |
49 | |
50 | POSITION aPosition = GetFirstViewPosition(); |
51 | while (aPosition != (POSITION)NULL) |
52 | { |
53 | OCC_2dView* aCurrentView = (OCC_2dView*)GetNextView (aPosition); |
54 | ASSERT_VALID (aCurrentView); |
55 | aCurrentView->GetV2dView()->FitAll(); |
7fd59977 |
56 | } |
57 | } |
58 | |
5c1f974e |
59 | void OCC_2dDoc::MoveEvent(const Standard_Integer theMouseX, |
60 | const Standard_Integer theMouseY, |
61 | const Handle(V3d_View)& theView) |
7fd59977 |
62 | { |
0577ae8c |
63 | myAISContext->MoveTo (theMouseX, theMouseY, theView, Standard_True); |
7fd59977 |
64 | } |
65 | |
5c1f974e |
66 | void OCC_2dDoc::ShiftMoveEvent(const Standard_Integer theMouseX, |
67 | const Standard_Integer theMouseY, |
68 | const Handle(V3d_View)& theView) |
7fd59977 |
69 | { |
0577ae8c |
70 | myAISContext->MoveTo (theMouseX, theMouseY, theView, Standard_True); |
7fd59977 |
71 | } |