1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-04 18:06:22 +03:00
occt/samples/mfc/standard/Common/OCC_2dDoc.cpp
ibs 234e52be90 0023874: Converting OCCT MFC samples to CMake build system.
CMake meta-projects for samples were added
launch script for samples was added
unrelated changes: CSF_GraphicShr variable were removed
occt building with cmake article was updated
2013-11-14 15:11:59 +04:00

78 lines
2.1 KiB
C++
Executable File

// OCC_2dDoc.cpp: implementation of the OCC_2dDoc class.
//
//////////////////////////////////////////////////////////////////////
#include <stdafx.h>
#include "OCC_2dDoc.h"
#include "OCC_App.h"
#include "OCC_2dView.h"
IMPLEMENT_DYNCREATE(OCC_2dDoc, CDocument)
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
OCC_2dDoc::OCC_2dDoc() : OCC_BaseDoc()
{
// Get the Graphic Driver from the application
Handle(Graphic3d_GraphicDriver) aGraphicDriver =
((OCC_App*)AfxGetApp())->GetGraphicDriver();
// create the Viewer
TCollection_ExtendedString aName ("Viewer 2D");
TCollection_AsciiString aDomain ("My Domain");
myViewer = new V3d_Viewer (aGraphicDriver,
aName.ToExtString(),
aDomain.ToCString());
myViewer->SetDefaultLights();
myViewer->SetLightOn();
myViewer->SetDefaultViewProj (V3d_Zpos);
// set default values for grids
myViewer->SetCircularGridValues (0, 0, 10, 8, 0);
myViewer->SetRectangularGridValues (0, 0, 10, 10, 0);
myAISContext = new AIS_InteractiveContext (myViewer);
AfxInitRichEdit();
}
OCC_2dDoc::~OCC_2dDoc()
{
}
void OCC_2dDoc::FitAll2DViews(Standard_Boolean theUpdateViewer)
{
if (theUpdateViewer)
{
myViewer->Update();
}
POSITION aPosition = GetFirstViewPosition();
while (aPosition != (POSITION)NULL)
{
OCC_2dView* aCurrentView = (OCC_2dView*)GetNextView (aPosition);
ASSERT_VALID (aCurrentView);
aCurrentView->GetV2dView()->FitAll();
}
}
void OCC_2dDoc::MoveEvent(const Standard_Integer theMouseX,
const Standard_Integer theMouseY,
const Handle(V3d_View)& theView)
{
myAISContext->MoveTo (theMouseX, theMouseY, theView);
}
void OCC_2dDoc::ShiftMoveEvent(const Standard_Integer theMouseX,
const Standard_Integer theMouseY,
const Handle(V3d_View)& theView)
{
myAISContext->MoveTo (theMouseX, theMouseY, theView);
}