mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-14 13:30:48 +03:00
Integration of OCCT 6.5.0 from SVN
This commit is contained in:
461
samples/mfc/standard/10_Convert/src/Convert_Presentation.cpp
Executable file
461
samples/mfc/standard/10_Convert/src/Convert_Presentation.cpp
Executable file
@@ -0,0 +1,461 @@
|
||||
// Convert_Presentation.cpp: implementation of the Convert_Presentation class.
|
||||
// Conversion of elementary geometry to BSpline curves and surfaces
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "Convert_Presentation.h"
|
||||
|
||||
#include <Quantity_Color.hxx>
|
||||
|
||||
#include <gp_Dir.hxx>
|
||||
#include <gp_Ax2.hxx>
|
||||
|
||||
#include <TColgp_Array1OfPnt.hxx>
|
||||
#include <TColStd_Array1OfReal.hxx>
|
||||
#include <TColgp_Array2OfPnt.hxx>
|
||||
#include <TColStd_Array2OfReal.hxx>
|
||||
|
||||
#include <GeomConvert.hxx>
|
||||
|
||||
#include <Geom_BezierSurface.hxx>
|
||||
#include <Geom_Circle.hxx>
|
||||
#include <Geom_Ellipse.hxx>
|
||||
#include <Geom_BezierCurve.hxx>
|
||||
#include <Geom_BSplineCurve.hxx>
|
||||
#include <Geom_SphericalSurface.hxx>
|
||||
#include <Geom_CylindricalSurface.hxx>
|
||||
#include <Geom_RectangularTrimmedSurface.hxx>
|
||||
#include <Geom_SurfaceOfRevolution.hxx>
|
||||
#include <Geom_ToroidalSurface.hxx>
|
||||
#include <Geom_ConicalSurface.hxx>
|
||||
|
||||
|
||||
// Initialization of global variable with an instance of this class
|
||||
OCCDemo_Presentation* OCCDemo_Presentation::Current = new Convert_Presentation;
|
||||
|
||||
// Initialization of array of samples
|
||||
const Convert_Presentation::PSampleFuncType Convert_Presentation::SampleFuncs[] =
|
||||
{
|
||||
&Convert_Presentation::sampleCircle,
|
||||
&Convert_Presentation::sampleEllipse,
|
||||
&Convert_Presentation::sampleBezier,
|
||||
&Convert_Presentation::sampleBezierSurface,
|
||||
&Convert_Presentation::sampleCylindricalSurface,
|
||||
&Convert_Presentation::sampleRevolSurface,
|
||||
&Convert_Presentation::sampleToroidalSurface,
|
||||
&Convert_Presentation::sampleConicalSurface,
|
||||
&Convert_Presentation::sampleSphericalSurface
|
||||
};
|
||||
|
||||
// Colors of objects
|
||||
static const Quantity_Color CurveColor (1,1,0, Quantity_TOC_RGB); // yellow
|
||||
static const Quantity_Color SurfaceColor (1,1,0, Quantity_TOC_RGB); // yellow
|
||||
static const Quantity_Color BSplineColor (1,0.647,0, Quantity_TOC_RGB); // orange
|
||||
static const Quantity_Color BSplineSurfaceColor (0,0,1, Quantity_TOC_RGB); // blue
|
||||
|
||||
#ifdef WNT
|
||||
#define EOL "\r\n"
|
||||
#else
|
||||
#define EOL "\n"
|
||||
#endif
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
Convert_Presentation::Convert_Presentation()
|
||||
{
|
||||
setName ("Conversion to BSpline curves and surfaces");
|
||||
myIndex = 0;
|
||||
myNbFuncs = sizeof(SampleFuncs)/sizeof(PSampleFuncType);
|
||||
myNbSamples = myNbFuncs;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Sample execution
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
void Convert_Presentation::DoSample()
|
||||
{
|
||||
((COCCDemoApp*) AfxGetApp())->SetSampleName("Convert");
|
||||
getAISContext()->EraseAll();
|
||||
if (myIndex >=0 && myIndex < myNbFuncs)
|
||||
(this->*SampleFuncs[myIndex])();
|
||||
}
|
||||
|
||||
|
||||
//================================================================
|
||||
// Function : Convert_Presentation::drawSurfaceAndItsBSpline
|
||||
// Purpose :
|
||||
//================================================================
|
||||
void Convert_Presentation::drawSurfaceAndItsBSpline(Handle_Geom_Surface theSurface,
|
||||
const Standard_CString theName,
|
||||
TCollection_AsciiString& theText)
|
||||
{
|
||||
TCollection_AsciiString aTitle ("Converting ");
|
||||
aTitle += theName;
|
||||
aTitle += " to BSpline surface";
|
||||
|
||||
theText += EOL
|
||||
" Handle_Geom_BSplineSurface aBSplineSurface = " EOL
|
||||
" GeomConvert::SurfaceToBSplineSurface(aSurface);" EOL;
|
||||
|
||||
setResultTitle (aTitle.ToCString());
|
||||
setResultText (theText.ToCString());
|
||||
|
||||
drawSurface (theSurface, SurfaceColor);
|
||||
|
||||
if (WAIT_A_LITTLE) return;
|
||||
|
||||
Handle_Geom_BSplineSurface aBSplineSurface = GeomConvert::SurfaceToBSplineSurface(theSurface);
|
||||
|
||||
_ASSERTE(!aBSplineSurface.IsNull());
|
||||
|
||||
drawSurface (aBSplineSurface, BSplineSurfaceColor);
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : Convert_Presentation::drawCurveAndItsBSpline
|
||||
// Purpose :
|
||||
//================================================================
|
||||
void Convert_Presentation::drawCurveAndItsBSpline(Handle_Geom_Curve theCurve,
|
||||
const Standard_CString theName,
|
||||
TCollection_AsciiString& theText)
|
||||
{
|
||||
TCollection_AsciiString aTitle ("Converting ");
|
||||
aTitle += theName;
|
||||
aTitle += " to BSpline curve";
|
||||
|
||||
theText += EOL
|
||||
" Handle_Geom_BSplineCurve aBSpline = " EOL
|
||||
" GeomConvert::CurveToBSplineCurve(aCurve);" EOL;
|
||||
|
||||
setResultTitle (aTitle.ToCString());
|
||||
setResultText (theText.ToCString());
|
||||
|
||||
drawCurve (theCurve, CurveColor);
|
||||
|
||||
if (WAIT_A_LITTLE) return;
|
||||
|
||||
Handle_Geom_BSplineCurve aBSpline = GeomConvert::CurveToBSplineCurve(theCurve);
|
||||
|
||||
drawCurve (aBSpline, BSplineColor);
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Sample functions
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
//================================================================
|
||||
// Function : Convert_Presentation::sampleCircle
|
||||
// Purpose :
|
||||
//================================================================
|
||||
void Convert_Presentation::sampleCircle()
|
||||
{
|
||||
gp_Pnt aOrigin (0,0,0);
|
||||
gp_Dir aDir (1,0,0);
|
||||
gp_Ax2 aAxis (aOrigin, aDir);
|
||||
Standard_Real aRadius = 300;
|
||||
Handle_Geom_Circle aCurve = new Geom_Circle (aAxis, aRadius);
|
||||
|
||||
TCollection_AsciiString aText (
|
||||
" gp_Pnt aOrigin (0,0,0);" EOL
|
||||
" gp_Dir aDir (1,0,0);" EOL
|
||||
" gp_Ax2 aAxis (aOrigin, aDir);" EOL
|
||||
" Standard_Real aRadius = 300;" EOL
|
||||
" Handle(Geom_Circle) aCurve = new Geom_Circle (aAxis, aRadius);" EOL
|
||||
);
|
||||
drawCurveAndItsBSpline (aCurve, "Circle", aText);
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : Convert_Presentation::sampleEllipse
|
||||
// Purpose :
|
||||
//================================================================
|
||||
void Convert_Presentation::sampleEllipse()
|
||||
{
|
||||
gp_Pnt aOrigin (0,0,0);
|
||||
gp_Dir aDir (1,0,0);
|
||||
gp_Ax2 aMajorAxis (aOrigin, aDir);
|
||||
Standard_Real aMajorRadius = 300;
|
||||
Standard_Real aMinorRadius = 150;
|
||||
Handle(Geom_Ellipse) aCurve =
|
||||
new Geom_Ellipse (aMajorAxis, aMajorRadius, aMinorRadius);
|
||||
|
||||
TCollection_AsciiString aText (
|
||||
" gp_Pnt aOrigin (0,0,0);" EOL
|
||||
" gp_Dir aDir (1,0,0);" EOL
|
||||
" gp_Ax2 aAxis (aOrigin, aDir);" EOL
|
||||
" Standard_Real aMajorRadius = 300;" EOL
|
||||
" Standard_Real aMinorRadius = 150;" EOL
|
||||
" Handle(Geom_Ellipse) aCurve = " EOL
|
||||
" new Geom_Ellipse (aAxis, aMajorRadius, aMinorRadius);" EOL
|
||||
);
|
||||
drawCurveAndItsBSpline (aCurve, "Ellipse", aText);
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : Convert_Presentation::sampleBezier
|
||||
// Purpose :
|
||||
//================================================================
|
||||
void Convert_Presentation::sampleBezier()
|
||||
{
|
||||
TCollection_AsciiString aText (
|
||||
" Standard_Real aPolesCoords[][3] = {" EOL
|
||||
" {0,0,0},{0,1,0},{1,1,0},{1,2,0},{2,2,0},{2,1,0},{3,1,0},{3,0,0},{2,0,0},{2,-1,0}," EOL
|
||||
" {3,-1,0},{3,-2,0},{4,-2,0},{4,-1,0},{5,-1,0},{5,0,0},{6,0,0},{6,-1,0},{7,-1,0}," EOL
|
||||
" {7,0,0},{8,0,0},{8,1,0}" EOL
|
||||
" };" EOL
|
||||
" TColgp_Array1OfPnt aPoles (1, sizeof(aPolesCoords)/(sizeof(Standard_Real)*2));" EOL
|
||||
" " EOL
|
||||
" for (Standard_Integer i=1; i <= aPoles.Upper(); i++)" EOL
|
||||
" aPoles(i) = gp_Pnt (aPolesCoords[i-1][0]*100, " EOL
|
||||
" aPolesCoords[i-1][1]*100, " EOL
|
||||
" aPolesCoords[i-1][2]*100);" EOL
|
||||
" " EOL
|
||||
" Handle(Geom_BezierCurve) aCurve = new Geom_BezierCurve (aPoles);" EOL
|
||||
);
|
||||
|
||||
Standard_Real aPolesCoords[][3] = {
|
||||
{0,0,0},{0,1,0},{1,1,0},{1,2,0},{2,2,0},{2,1,0},{3,1,0},{3,0,0},{2,0,0},{2,-1,0},
|
||||
{3,-1,0},{3,-2,0},{4,-2,0},{4,-1,0},{5,-1,0},{5,0,0},{6,0,0},{6,-1,0},{7,-1,0},
|
||||
{7,0,0},{8,0,0},{8,1,0}
|
||||
};
|
||||
TColgp_Array1OfPnt aPoles (1, sizeof(aPolesCoords)/(sizeof(Standard_Real)*3));
|
||||
|
||||
for (Standard_Integer i=1; i <= aPoles.Upper(); i++)
|
||||
aPoles(i) = gp_Pnt (aPolesCoords[i-1][0]*150-500,
|
||||
aPolesCoords[i-1][1]*150,
|
||||
aPolesCoords[i-1][2]*150);
|
||||
|
||||
Handle(Geom_BezierCurve) aCurve = new Geom_BezierCurve (aPoles);
|
||||
|
||||
drawCurveAndItsBSpline (aCurve, "BezierCurve", aText);
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : Convert_Presentation::sampleBezierSurface
|
||||
// Purpose :
|
||||
//================================================================
|
||||
void Convert_Presentation::sampleBezierSurface()
|
||||
{
|
||||
getAISContext()->EraseAll();
|
||||
|
||||
Standard_CString aName = "BezierSurface";
|
||||
// Create a BezierSurface
|
||||
TColgp_Array2OfPnt aPoles(1,2,1,4); // 8 points
|
||||
TColStd_Array2OfReal aWeights(1,2,1,4);
|
||||
// initializing array of points
|
||||
aPoles.SetValue(1,1,gp_Pnt(0,10,0)); aPoles.SetValue(1,2,gp_Pnt(3.3,6.6,3));
|
||||
aPoles.SetValue(1,3,gp_Pnt(6.6,6.6,-3)); aPoles.SetValue(1,4,gp_Pnt(10,10,0));
|
||||
aPoles.SetValue(2,1,gp_Pnt(0,0,0)); aPoles.SetValue(2,2,gp_Pnt(3.3,3.3,-3));
|
||||
aPoles.SetValue(2,3,gp_Pnt(6.6,3.3,3)); aPoles.SetValue(2,4,gp_Pnt(10,0,0));
|
||||
// scaling poles
|
||||
for (Standard_Integer i=1; i <= aPoles.ColLength(); i++)
|
||||
for (Standard_Integer j=1; j <= aPoles.RowLength(); j++)
|
||||
aPoles(i,j).ChangeCoord() = aPoles(i,j).Coord() * 100 + gp_XYZ(-500,-500,0);
|
||||
//initializing array of weights
|
||||
aWeights.SetValue(1,1,1); aWeights.SetValue(1,2,3);
|
||||
aWeights.SetValue(1,3,9); aWeights.SetValue(1,4,1);
|
||||
aWeights.SetValue(2,1,1); aWeights.SetValue(2,2,2);
|
||||
aWeights.SetValue(2,3,5); aWeights.SetValue(2,4,1);
|
||||
Handle(Geom_BezierSurface) aSurface =
|
||||
new Geom_BezierSurface(aPoles, aWeights);
|
||||
|
||||
TCollection_AsciiString aText (
|
||||
" // Create a BezierSurface" EOL
|
||||
" TColgp_Array2OfPnt aPoles(1,2,1,4); // 8 points" EOL
|
||||
" TColStd_Array2OfReal aWeights(1,2,1,4);" EOL
|
||||
" // initializing array of points" EOL
|
||||
" aPoles.SetValue(1,1,gp_Pnt(0,10,0)); aPoles.SetValue(1,2,gp_Pnt(3.3,6.6,3));" EOL
|
||||
" aPoles.SetValue(1,3,gp_Pnt(6.6,6.6,-3)); aPoles.SetValue(1,4,gp_Pnt(10,10,0));" EOL
|
||||
" aPoles.SetValue(2,1,gp_Pnt(0,0,0)); aPoles.SetValue(2,2,gp_Pnt(3.3,3.3,-3));" EOL
|
||||
" aPoles.SetValue(2,3,gp_Pnt(6.6,3.3,3)); aPoles.SetValue(2,4,gp_Pnt(10,0,0)); " EOL
|
||||
" // scaling poles" EOL
|
||||
" for (Standard_Integer i=1; i <= aPoles.ColLength(); i++)" EOL
|
||||
" for (Standard_Integer j=1; j <= aPoles.RowLength(); j++)" EOL
|
||||
" aPoles(i,j).ChangeCoord() = aPoles(i,j).Coord() * 100 + gp_XYZ(-500,-500,0);" EOL
|
||||
" //initializing array of weights" EOL
|
||||
" aWeights.SetValue(1,1,1); aWeights.SetValue(1,2,3);" EOL
|
||||
" aWeights.SetValue(1,3,9); aWeights.SetValue(1,4,1);" EOL
|
||||
" aWeights.SetValue(2,1,1); aWeights.SetValue(2,2,2);" EOL
|
||||
" aWeights.SetValue(2,3,5); aWeights.SetValue(2,4,1);" EOL
|
||||
" Handle(Geom_BezierSurface) aSurface =" EOL
|
||||
" new Geom_BezierSurface(aPoles, aWeights);" EOL
|
||||
);
|
||||
|
||||
drawSurfaceAndItsBSpline (aSurface, aName, aText);
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : OCCDemo_Presentation::sampleCylindricalSurface
|
||||
// Purpose :
|
||||
//================================================================
|
||||
void Convert_Presentation::sampleCylindricalSurface()
|
||||
{
|
||||
getAISContext()->EraseAll();
|
||||
|
||||
Standard_CString aName = "Cylindrical Surface";
|
||||
TCollection_AsciiString aText (
|
||||
" // creating an axis parallel to Y axis" EOL
|
||||
" gp_Ax3 anAx(gp_Pnt(0,0,0), gp_Dir(0,1,0));" EOL EOL
|
||||
|
||||
" // creating a cylindrical surface along anAx with radius = 100" EOL
|
||||
" Handle(Geom_CylindricalSurface) aCylSurface = new Geom_CylindricalSurface(anAx, 100);" EOL EOL
|
||||
|
||||
" // only finit surfaces can be converted to BSpline surfaces, " EOL
|
||||
" // cylindrical surface is infinite, it must be trimmed" EOL
|
||||
" Handle(Geom_RectangularTrimmedSurface) aSurface = " EOL
|
||||
" new Geom_RectangularTrimmedSurface(aCylSurface, 0, 2*PI, -1000, 1000, Standard_True, Standard_True);" EOL);
|
||||
|
||||
// creating an axis parallel to Y axis
|
||||
gp_Ax3 anAx(gp_Pnt(0,0,0), gp_Dir(0,1,0));
|
||||
|
||||
// creating a cylindrical surface along anAx with radius = 4
|
||||
Handle(Geom_CylindricalSurface) aCylSurface = new Geom_CylindricalSurface(anAx, 100);
|
||||
|
||||
// only finit surfaces can be converted to BSpline surfaces,
|
||||
// cylindrical surface is infinite, it must be trimmed
|
||||
Handle(Geom_RectangularTrimmedSurface) aSurface =
|
||||
new Geom_RectangularTrimmedSurface(aCylSurface, 0, 2*PI, -1000, 1000, Standard_True, Standard_True);
|
||||
|
||||
drawSurfaceAndItsBSpline(aSurface, aName, aText);
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : OCCDemo_Presentation::sampleRevolSurface
|
||||
// Purpose :
|
||||
//================================================================
|
||||
void Convert_Presentation::sampleRevolSurface()
|
||||
{
|
||||
FitMode=false;
|
||||
ResetView();
|
||||
SetViewCenter(176.84682,102.12892);
|
||||
SetViewScale(0.69326);
|
||||
|
||||
getAISContext()->EraseAll();
|
||||
|
||||
Standard_CString aName = "Surface of revolution";
|
||||
TCollection_AsciiString aText (
|
||||
" // creating a curve for revolution. Let it be a Bezier curve." EOL
|
||||
" Handle(Geom_BezierCurve) aBezierCurve;" EOL EOL
|
||||
|
||||
" // array of the bezier curve poles" EOL
|
||||
" TColgp_Array1OfPnt aPoles(1,4);" EOL
|
||||
" // array of the poles' weights" EOL
|
||||
" TColStd_Array1OfReal aWeights(1,4);" EOL EOL
|
||||
|
||||
" aPoles(1) = gp_Pnt(0, 0, 0); aWeights(1) = 1;" EOL
|
||||
" aPoles(2) = gp_Pnt(150, 250, 0); aWeights(2) =75;" EOL
|
||||
" aPoles(3) = gp_Pnt(350, 150, 0); aWeights(3) =120;" EOL
|
||||
" aPoles(4) = gp_Pnt(500, 500, 0); aWeights(4) = 1;" EOL EOL
|
||||
|
||||
" // creating a bezier curve" EOL
|
||||
" aBezierCurve = new Geom_BezierCurve(aPoles, aWeights);" EOL EOL
|
||||
|
||||
" // creating a surface of revolution of the bezier curve around Y axis" EOL
|
||||
" gp_Ax1 anAx(gp_Pnt(0, 0, 0), gp_Dir(0,1,0));" EOL
|
||||
" Handle(Geom_SurfaceOfRevolution) aSurface = new Geom_SurfaceOfRevolution(aBezierCurve, anAx);" EOL
|
||||
);
|
||||
|
||||
// array of the bezier curve poles
|
||||
TColgp_Array1OfPnt aPoles(1,4);
|
||||
// array of the poles' weights
|
||||
TColStd_Array1OfReal aWeights(1,4);
|
||||
|
||||
aPoles(1) = gp_Pnt(0, 0, 0); aWeights(1) = 1;
|
||||
aPoles(2) = gp_Pnt(150, 250, 0); aWeights(2) =75;
|
||||
aPoles(3) = gp_Pnt(350, 150, 0); aWeights(3) =120;
|
||||
aPoles(4) = gp_Pnt(500, 500, 0); aWeights(4) = 1;
|
||||
|
||||
Handle(Geom_BezierCurve) aBezierCurve = new Geom_BezierCurve(aPoles, aWeights);
|
||||
drawCurve(aBezierCurve);
|
||||
|
||||
// creating a surface of revolution of the bezier curve around Y axis
|
||||
gp_Ax1 anAx(gp_Pnt(0,0,0), gp_Dir(0,1,0));
|
||||
Handle(Geom_SurfaceOfRevolution) aSurface = new Geom_SurfaceOfRevolution(aBezierCurve, anAx);
|
||||
|
||||
drawSurfaceAndItsBSpline (aSurface, aName, aText);
|
||||
FitMode=true;
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : Convert_Presentation::sampleToroidalSurface
|
||||
// Purpose :
|
||||
//================================================================
|
||||
void Convert_Presentation::sampleToroidalSurface()
|
||||
{
|
||||
getAISContext()->EraseAll();
|
||||
|
||||
Standard_CString aName = "Toroidal surface";
|
||||
TCollection_AsciiString aText (
|
||||
" // creating an axis parallel to Y axis" EOL
|
||||
" gp_Ax3 anAx(gp_Pnt(0,0,0), gp_Dir(0,1,0));" EOL
|
||||
" // creating a toroidal surface with major radius = 240 and minor radius = 120" EOL
|
||||
" Handle(Geom_ToroidalSurface) aSurface = new Geom_ToroidalSurface(anAx, 240, 120);" EOL);
|
||||
|
||||
// creating an axis parallel to Y axis
|
||||
gp_Ax3 anAx(gp_Pnt(0,0,0), gp_Dir(0,1,0));
|
||||
// creating a toroidal surface with major radius = 240 and minor radius = 120
|
||||
Handle(Geom_ToroidalSurface) aSurface = new Geom_ToroidalSurface(anAx, 240, 120);
|
||||
|
||||
drawSurfaceAndItsBSpline(aSurface, aName, aText);
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : Convert_Presentation::sampleConicalSurface
|
||||
// Purpose :
|
||||
//================================================================
|
||||
void Convert_Presentation::sampleConicalSurface()
|
||||
{
|
||||
getAISContext()->EraseAll();
|
||||
|
||||
Standard_CString aName = "Conical surface";
|
||||
TCollection_AsciiString aText (
|
||||
" // creating an axis parallel to Z axis" EOL
|
||||
" gp_Ax3 anAx(gp_Pnt(0,0,0), gp_Dir(0,0,1)); " EOL
|
||||
" // creating a conical surface with base radius = 10 and angle = 20 deg" EOL
|
||||
" Handle(Geom_ConicalSurface) aConicalSurface = new Geom_ConicalSurface(anAx,PI/9., 10);" EOL EOL
|
||||
|
||||
" // only finit surfaces can be converted to BSpline surfaces, " EOL
|
||||
" // conical surface is infinite, it must be trimmed" EOL
|
||||
" Handle(Geom_RectangularTrimmedSurface) aSurface = " EOL
|
||||
" new Geom_RectangularTrimmedSurface(aConicalSurface, 0, 2*PI, -1000, 1000, Standard_True, Standard_True);" EOL);
|
||||
|
||||
// creating an axis parallel to Z axis
|
||||
gp_Ax3 anAx(gp_Pnt(0,0,0), gp_Dir(0,0,1));
|
||||
// creating a conical surface with base radius = 10 and angle = 20 deg
|
||||
Handle(Geom_ConicalSurface) aConicalSurface = new Geom_ConicalSurface(anAx,PI/9., 10);
|
||||
|
||||
// only finit surfaces can be converted to BSpline surfaces,
|
||||
// conical surface is infinite, it must be trimmed
|
||||
Handle(Geom_RectangularTrimmedSurface) aSurface =
|
||||
new Geom_RectangularTrimmedSurface(aConicalSurface, 0, 2*PI, -1000, 1000, Standard_True, Standard_True);
|
||||
|
||||
drawSurfaceAndItsBSpline(aSurface, aName, aText);
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : Convert_Presentation::sampleSphericalSurface
|
||||
// Purpose :
|
||||
//================================================================
|
||||
void Convert_Presentation::sampleSphericalSurface()
|
||||
{
|
||||
getAISContext()->EraseAll();
|
||||
|
||||
Standard_CString aName = "Spherical surface";
|
||||
TCollection_AsciiString aText (
|
||||
"// creating an axis parallel to Z axis" EOL
|
||||
"gp_Ax3 anAx(gp_Pnt(0,0,0), gp_Dir(0,0,1));" EOL
|
||||
"// creating a spherical surface with radius = 300" EOL
|
||||
"Handle(Geom_SphericalSurface) aSurface = new Geom_SphericalSurface(anAx,300);" EOL);
|
||||
|
||||
// creating an axis parallel to Z axis
|
||||
gp_Ax3 anAx(gp_Pnt(0,0,0), gp_Dir(0,0,1));
|
||||
// creating a spherical surface with radius = 300
|
||||
Handle(Geom_SphericalSurface) aSurface = new Geom_SphericalSurface(anAx,300);
|
||||
|
||||
drawSurfaceAndItsBSpline(aSurface, aName, aText);
|
||||
}
|
||||
|
55
samples/mfc/standard/10_Convert/src/Convert_Presentation.h
Executable file
55
samples/mfc/standard/10_Convert/src/Convert_Presentation.h
Executable file
@@ -0,0 +1,55 @@
|
||||
// Convert_Presentation.h: interface for the Convert_Presentation class.
|
||||
// Conversion of elementary geometry to BSpline curves and surfaces
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_Convert_Presentation_H__790EED7F_7BA2_11D5_BA4A_0060B0EE18EA__INCLUDED_)
|
||||
#define AFX_Convert_Presentation_H__790EED7F_7BA2_11D5_BA4A_0060B0EE18EA__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
#include <OCCDemo_Presentation.h>
|
||||
class Handle_Geom_Curve;
|
||||
class Handle_Geom_Surface;
|
||||
|
||||
class Quantity_Color;
|
||||
|
||||
class Convert_Presentation : public OCCDemo_Presentation
|
||||
{
|
||||
public:
|
||||
// Construction
|
||||
Convert_Presentation();
|
||||
|
||||
public:
|
||||
// Iteration on samples
|
||||
virtual void DoSample();
|
||||
// one phase of iterations
|
||||
|
||||
private:
|
||||
// Sample functions
|
||||
void sampleCircle();
|
||||
void sampleEllipse();
|
||||
void sampleBezier();
|
||||
void sampleBezierSurface();
|
||||
void sampleCylindricalSurface();
|
||||
void sampleRevolSurface();
|
||||
void sampleToroidalSurface();
|
||||
void sampleConicalSurface();
|
||||
void sampleSphericalSurface();
|
||||
|
||||
void drawCurveAndItsBSpline (Handle_Geom_Curve theCurve,
|
||||
const Standard_CString theName, TCollection_AsciiString& theText);
|
||||
|
||||
void drawSurfaceAndItsBSpline (Handle_Geom_Surface theSurface,
|
||||
const Standard_CString theName, TCollection_AsciiString& theText);
|
||||
|
||||
private:
|
||||
// Array of pointers to sample functions
|
||||
typedef void (Convert_Presentation::*PSampleFuncType)();
|
||||
static const PSampleFuncType SampleFuncs[];
|
||||
|
||||
int myNbFuncs;
|
||||
};
|
||||
|
||||
#endif // !defined(AFX_Convert_Presentation_H__790EED7F_7BA2_11D5_BA4A_0060B0EE18EA__INCLUDED_)
|
59
samples/mfc/standard/10_Convert/src/ISession/ISession_Curve.cpp
Executable file
59
samples/mfc/standard/10_Convert/src/ISession/ISession_Curve.cpp
Executable file
@@ -0,0 +1,59 @@
|
||||
// ISession_Curve.cpp: implementation of the ISession_Curve class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "ISession_Curve.h"
|
||||
#include <Prs3d_LineAspect.hxx>
|
||||
#include <StdPrs_Curve.hxx>
|
||||
#include <GeomAdaptor_Curve.hxx>
|
||||
#include <AIS_Drawer.hxx>
|
||||
#include <Prs3d_ArrowAspect.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_HANDLE(ISession_Curve,AIS_InteractiveObject)
|
||||
IMPLEMENT_STANDARD_RTTIEXT(ISession_Curve,AIS_InteractiveObject)
|
||||
|
||||
#ifdef _DEBUG
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[]=__FILE__;
|
||||
#endif
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
ISession_Curve::ISession_Curve(const Handle(Geom_Curve)& aCurve)
|
||||
:AIS_InteractiveObject(),myCurve(aCurve)
|
||||
{
|
||||
}
|
||||
|
||||
ISession_Curve::~ISession_Curve()
|
||||
{
|
||||
|
||||
}
|
||||
void ISession_Curve::Compute(const Handle(PrsMgr_PresentationManager3d)& aPresentationManager,
|
||||
const Handle(Prs3d_Presentation)& aPresentation,
|
||||
const Standard_Integer /*aMode*/)
|
||||
{
|
||||
GeomAdaptor_Curve anAdaptorCurve(myCurve);
|
||||
if (hasOwnColor)
|
||||
myDrawer->LineAspect()->SetColor(myOwnColor);
|
||||
myDrawer->Link()->SetDiscretisation(100);
|
||||
myDrawer->Link()->SetMaximalParameterValue(500);
|
||||
|
||||
StdPrs_Curve::Add (aPresentation, anAdaptorCurve, myDrawer);
|
||||
}
|
||||
|
||||
void ISession_Curve::Compute(const Handle(Prs3d_Projector)& aProjector,
|
||||
const Handle(Prs3d_Presentation)& aPresentation)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void ISession_Curve::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
|
||||
const Standard_Integer aMode)
|
||||
{
|
||||
}
|
||||
|
||||
|
33
samples/mfc/standard/10_Convert/src/ISession/ISession_Curve.h
Executable file
33
samples/mfc/standard/10_Convert/src/ISession/ISession_Curve.h
Executable file
@@ -0,0 +1,33 @@
|
||||
// ISession_Curve.h: interface for the ISession_Curve class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_ISESSION_CURVE_H__F981CB93_A3CC_11D1_8DA3_0800369C8A03__INCLUDED_)
|
||||
#define AFX_ISESSION_CURVE_H__F981CB93_A3CC_11D1_8DA3_0800369C8A03__INCLUDED_
|
||||
|
||||
#if _MSC_VER >= 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER >= 1000
|
||||
#include <Standard_Macro.hxx>
|
||||
#include <Standard_DefineHandle.hxx>
|
||||
#include <AIS_InteractiveObject.hxx>
|
||||
#include <Geom_Curve.hxx>
|
||||
|
||||
DEFINE_STANDARD_HANDLE(ISession_Curve,AIS_InteractiveObject)
|
||||
|
||||
class ISession_Curve : public AIS_InteractiveObject
|
||||
{
|
||||
public:
|
||||
ISession_Curve(const Handle(Geom_Curve)& aCurve);
|
||||
virtual ~ISession_Curve();
|
||||
DEFINE_STANDARD_RTTI(ISession_Curve)
|
||||
private:
|
||||
|
||||
Standard_EXPORT virtual void Compute(const Handle(PrsMgr_PresentationManager3d)& aPresentationManager,const Handle(Prs3d_Presentation)& aPresentation,const Standard_Integer aMode = 0) ;
|
||||
Standard_EXPORT virtual void Compute(const Handle(Prs3d_Projector)& aProjector,const Handle(Prs3d_Presentation)& aPresentation) ;
|
||||
void ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,const Standard_Integer aMode) ;
|
||||
|
||||
Handle(Geom_Curve) myCurve;
|
||||
};
|
||||
|
||||
#endif // !defined(AFX_ISESSION_CURVE_H__F981CB93_A3CC_11D1_8DA3_0800369C8A03__INCLUDED_)
|
314
samples/mfc/standard/10_Convert/src/OCCDemo_Presentation.cpp
Executable file
314
samples/mfc/standard/10_Convert/src/OCCDemo_Presentation.cpp
Executable file
@@ -0,0 +1,314 @@
|
||||
// OCCDemo_Presentation.cpp: implementation of the OCCDemo_Presentation class.
|
||||
// This is a base class for all presentations
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "OCCDemo_Presentation.h"
|
||||
#include "OCCDemoView.h"
|
||||
#include "ISession_Curve.h"
|
||||
|
||||
#include <AIS_InteractiveObject.hxx>
|
||||
#include <Geom_Surface.hxx>
|
||||
#include <Geom_Curve.hxx>
|
||||
#include <Geom2d_Curve.hxx>
|
||||
#include <Quantity_Color.hxx>
|
||||
#include <AIS_Shape.hxx>
|
||||
#include <BRepBuilderAPI_MakeFace.hxx>
|
||||
#include <Precision.hxx>
|
||||
#include <Geom_Line.hxx>
|
||||
#include <Geom_TrimmedCurve.hxx>
|
||||
#include <AIS_Drawer.hxx>
|
||||
#include <Prs3d_ArrowAspect.hxx>
|
||||
#include <AIS_Point.hxx>
|
||||
#include <Geom_CartesianPoint.hxx>
|
||||
#include <Geom2d_OffsetCurve.hxx>
|
||||
#include <GeomAPI.hxx>
|
||||
#include <gp_Pln.hxx>
|
||||
#include <Geom_OffsetCurve.hxx>
|
||||
|
||||
#define MAX_PARAM 1000 // if a surface parameter is infinite, it is assingned
|
||||
// this value in order to display the "infinit" object in the viewer.
|
||||
|
||||
|
||||
Standard_Boolean OCCDemo_Presentation::WaitForInput (unsigned long aMilliSeconds)
|
||||
{
|
||||
//::WaitForSingleObject(::CreateEvent (NULL, FALSE, FALSE, NULL), aMilliSeconds);
|
||||
if (::MsgWaitForMultipleObjects(0, NULL, FALSE, aMilliSeconds,
|
||||
QS_KEY | QS_MOUSEBUTTON) != WAIT_TIMEOUT)
|
||||
{
|
||||
MSG msg;
|
||||
if (::PeekMessage (&msg, NULL, 0, 0, PM_NOREMOVE))
|
||||
{
|
||||
if (msg.message == WM_KEYUP)
|
||||
{
|
||||
::PeekMessage (&msg, NULL, 0, 0, PM_REMOVE);
|
||||
return WaitForInput (aMilliSeconds);
|
||||
}
|
||||
else
|
||||
return Standard_True;
|
||||
}
|
||||
}
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : fixParam
|
||||
// Purpose : assings a finite value to theParam if it intinite
|
||||
// (equal to +- Precision::Infinite())
|
||||
//================================================================
|
||||
static Standard_Boolean fixParam(Standard_Real& theParam)
|
||||
{
|
||||
Standard_Boolean aResult = Standard_False;
|
||||
if (Precision::IsNegativeInfinite(theParam))
|
||||
{
|
||||
theParam = -MAX_PARAM;
|
||||
aResult = Standard_True;
|
||||
}
|
||||
if (Precision::IsPositiveInfinite(theParam))
|
||||
{
|
||||
theParam = MAX_PARAM;
|
||||
aResult = Standard_True;
|
||||
}
|
||||
return aResult;
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : DrawSurface
|
||||
// Purpose : displays a given geometric surface in 3d viewer
|
||||
// (creates a finite face and displays it)
|
||||
//================================================================
|
||||
Handle_AIS_InteractiveObject OCCDemo_Presentation::drawSurface
|
||||
(const Handle_Geom_Surface& theSurface,
|
||||
const Quantity_Color& theColor,
|
||||
const Standard_Boolean toDisplay)
|
||||
{
|
||||
Standard_Real u1, u2, v1, v2;
|
||||
theSurface->Bounds(u1,u2,v1,v2);
|
||||
fixParam(u1);
|
||||
fixParam(u2);
|
||||
fixParam(v1);
|
||||
fixParam(v2);
|
||||
|
||||
Handle_AIS_Shape aGraphicSurface =
|
||||
new AIS_Shape(BRepBuilderAPI_MakeFace (theSurface, u1, u2, v1, v2));
|
||||
|
||||
getAISContext()->SetMaterial(aGraphicSurface, Graphic3d_NOM_PLASTIC, toDisplay);
|
||||
getAISContext()->SetColor(aGraphicSurface, theColor, toDisplay);
|
||||
if (toDisplay) {
|
||||
if (FitMode){
|
||||
getAISContext()->Display (aGraphicSurface, Standard_False);
|
||||
COCCDemoDoc::Fit();
|
||||
}
|
||||
else
|
||||
getAISContext()->Display (aGraphicSurface);
|
||||
}
|
||||
|
||||
return aGraphicSurface;
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : DrawCurve
|
||||
// Purpose : displays a given curve 3d
|
||||
//================================================================
|
||||
Handle_AIS_InteractiveObject OCCDemo_Presentation::drawCurve
|
||||
(const Handle_Geom_Curve& theCurve,
|
||||
const Quantity_Color& theColor,
|
||||
const Standard_Boolean toDisplay)
|
||||
{
|
||||
Handle(ISession_Curve) aGraphicCurve = new ISession_Curve (theCurve);
|
||||
|
||||
getAISContext()->SetColor (aGraphicCurve, theColor, toDisplay);
|
||||
aGraphicCurve->Attributes()->Link()->SetLineArrowDraw(Standard_False);
|
||||
if (toDisplay){
|
||||
if (FitMode){
|
||||
getAISContext()->Display (aGraphicCurve, Standard_False);
|
||||
COCCDemoDoc::Fit();
|
||||
}
|
||||
else
|
||||
getAISContext()->Display (aGraphicCurve);
|
||||
}
|
||||
|
||||
return aGraphicCurve;
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : DrawCurve
|
||||
// Purpose : displays a given curve 2d
|
||||
//================================================================
|
||||
Handle_AIS_InteractiveObject OCCDemo_Presentation::drawCurve
|
||||
(const Handle_Geom2d_Curve& theCurve,
|
||||
const Quantity_Color& theColor,
|
||||
const Standard_Boolean toDisplay,
|
||||
const gp_Ax2& aPosition)
|
||||
{
|
||||
// create 3D curve in plane
|
||||
Handle(Geom_Curve) aCurve3d;
|
||||
if (theCurve->IsKind(STANDARD_TYPE(Geom2d_OffsetCurve)))
|
||||
{
|
||||
Handle(Geom2d_OffsetCurve) aOffCurve =
|
||||
Handle(Geom2d_OffsetCurve)::DownCast(theCurve);
|
||||
Handle(Geom_Curve) aBasCurve3d =
|
||||
GeomAPI::To3d (aOffCurve->BasisCurve(), gp_Pln(aPosition));
|
||||
Standard_Real aDist = aOffCurve->Offset();
|
||||
aCurve3d = new Geom_OffsetCurve (aBasCurve3d, aDist, aPosition.Direction());
|
||||
}
|
||||
else
|
||||
{
|
||||
aCurve3d = GeomAPI::To3d (theCurve, gp_Pln(aPosition));
|
||||
}
|
||||
return drawCurve (aCurve3d, theColor, toDisplay);
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : drawPoint
|
||||
// Purpose : displays a given point
|
||||
//================================================================
|
||||
Handle_AIS_Point OCCDemo_Presentation::drawPoint
|
||||
(const gp_Pnt& aPnt,
|
||||
const Quantity_Color& theColor,
|
||||
const Standard_Boolean toDisplay)
|
||||
{
|
||||
Handle(AIS_Point) aGraphicPoint = new AIS_Point (new Geom_CartesianPoint(aPnt));
|
||||
|
||||
getAISContext()->SetColor (aGraphicPoint, theColor, toDisplay);
|
||||
if (toDisplay) {
|
||||
getAISContext()->Display (aGraphicPoint);
|
||||
//COCCDemoDoc::Fit();
|
||||
}
|
||||
|
||||
return aGraphicPoint;
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : drawVector
|
||||
// Purpose : displays a given vector in 3d viewer
|
||||
// (segment of line starting at thePnt with the arrow at the end,
|
||||
// the length of segment is the length of the vector)
|
||||
//================================================================
|
||||
Handle_AIS_InteractiveObject OCCDemo_Presentation::drawVector
|
||||
(const gp_Pnt& thePnt,
|
||||
const gp_Vec& theVec,
|
||||
const Quantity_Color& theColor,
|
||||
const Standard_Boolean toDisplay)
|
||||
{
|
||||
Standard_Real aLength = theVec.Magnitude();
|
||||
if (aLength < Precision::Confusion())
|
||||
return Handle(AIS_InteractiveObject)();
|
||||
|
||||
Handle(Geom_Curve) aCurve = new Geom_Line (thePnt, theVec);
|
||||
aCurve = new Geom_TrimmedCurve (aCurve, 0, aLength);
|
||||
|
||||
Handle(ISession_Curve) aGraphicCurve = new ISession_Curve (aCurve);
|
||||
|
||||
getAISContext()->SetColor (aGraphicCurve, theColor, toDisplay);
|
||||
Handle(Prs3d_Drawer) aDrawer = aGraphicCurve->Attributes()->Link();
|
||||
aDrawer->SetLineArrowDraw(Standard_True);
|
||||
aDrawer->ArrowAspect()->SetLength(aLength/10);
|
||||
if (toDisplay) {
|
||||
if (FitMode){
|
||||
getAISContext()->Display (aGraphicCurve, Standard_False);
|
||||
COCCDemoDoc::Fit();
|
||||
}
|
||||
else
|
||||
getAISContext()->Display (aGraphicCurve);
|
||||
}
|
||||
|
||||
return aGraphicCurve;
|
||||
}
|
||||
|
||||
|
||||
Handle_AIS_Shape OCCDemo_Presentation::drawShape
|
||||
(const TopoDS_Shape& theShape,const Quantity_Color& theColor,
|
||||
const Standard_Boolean toDisplay)
|
||||
{
|
||||
Handle_AIS_Shape aGraphicShape = new AIS_Shape(theShape);
|
||||
|
||||
getAISContext()->SetMaterial(aGraphicShape, Graphic3d_NOM_PLASTIC, toDisplay);
|
||||
getAISContext()->SetColor (aGraphicShape, theColor, toDisplay);
|
||||
if (toDisplay){
|
||||
if (FitMode){
|
||||
getAISContext()->Display (aGraphicShape, Standard_False);
|
||||
COCCDemoDoc::Fit();
|
||||
}
|
||||
else
|
||||
getAISContext()->Display (aGraphicShape);
|
||||
}
|
||||
|
||||
return aGraphicShape;
|
||||
}
|
||||
|
||||
Handle_AIS_Shape OCCDemo_Presentation::drawShape
|
||||
(const TopoDS_Shape& theShape,
|
||||
const Graphic3d_NameOfMaterial theMaterial,
|
||||
const Standard_Boolean toDisplay)
|
||||
{
|
||||
Handle_AIS_Shape aGraphicShape = new AIS_Shape(theShape);
|
||||
|
||||
getAISContext()->SetMaterial(aGraphicShape, theMaterial, toDisplay);
|
||||
if (toDisplay) {
|
||||
if (FitMode){
|
||||
getAISContext()->Display (aGraphicShape, Standard_False);
|
||||
COCCDemoDoc::Fit();
|
||||
}
|
||||
else
|
||||
getAISContext()->Display (aGraphicShape);
|
||||
}
|
||||
|
||||
return aGraphicShape;
|
||||
}
|
||||
|
||||
void OCCDemo_Presentation::GetViewCenter(V3d_Coordinate& Xc, V3d_Coordinate& Yc)
|
||||
{
|
||||
CMDIFrameWnd *pFrame = (CMDIFrameWnd*)AfxGetApp()->m_pMainWnd;
|
||||
CMDIChildWnd *pChild = (CMDIChildWnd *) pFrame->GetActiveFrame();
|
||||
COCCDemoView *pView = (COCCDemoView *) pChild->GetActiveView();
|
||||
pView->GetViewCenter(Xc,Yc);
|
||||
}
|
||||
|
||||
void OCCDemo_Presentation::SetViewCenter(V3d_Coordinate Xc, V3d_Coordinate Yc)
|
||||
{
|
||||
CMDIFrameWnd *pFrame = (CMDIFrameWnd*)AfxGetApp()->m_pMainWnd;
|
||||
CMDIChildWnd *pChild = (CMDIChildWnd *) pFrame->GetActiveFrame();
|
||||
COCCDemoView *pView = (COCCDemoView *) pChild->GetActiveView();
|
||||
pView->SetViewCenter(Xc,Yc);
|
||||
}
|
||||
|
||||
void OCCDemo_Presentation::GetViewEye(V3d_Coordinate& X, V3d_Coordinate& Y, V3d_Coordinate& Z)
|
||||
{
|
||||
CMDIFrameWnd *pFrame = (CMDIFrameWnd*)AfxGetApp()->m_pMainWnd;
|
||||
CMDIChildWnd *pChild = (CMDIChildWnd *) pFrame->GetActiveFrame();
|
||||
COCCDemoView *pView = (COCCDemoView *) pChild->GetActiveView();
|
||||
pView->GetViewEye(X,Y,Z);
|
||||
}
|
||||
|
||||
void OCCDemo_Presentation::SetViewEye(V3d_Coordinate X, V3d_Coordinate Y, V3d_Coordinate Z)
|
||||
{
|
||||
CMDIFrameWnd *pFrame = (CMDIFrameWnd*)AfxGetApp()->m_pMainWnd;
|
||||
CMDIChildWnd *pChild = (CMDIChildWnd *) pFrame->GetActiveFrame();
|
||||
COCCDemoView *pView = (COCCDemoView *) pChild->GetActiveView();
|
||||
pView->SetViewEye(X,Y,Z);
|
||||
}
|
||||
|
||||
Quantity_Factor OCCDemo_Presentation::GetViewScale()
|
||||
{
|
||||
CMDIFrameWnd *pFrame = (CMDIFrameWnd*)AfxGetApp()->m_pMainWnd;
|
||||
CMDIChildWnd *pChild = (CMDIChildWnd *) pFrame->GetActiveFrame();
|
||||
COCCDemoView *pView = (COCCDemoView *) pChild->GetActiveView();
|
||||
return pView->GetViewScale();
|
||||
}
|
||||
|
||||
void OCCDemo_Presentation::SetViewScale(Quantity_Factor Coef)
|
||||
{
|
||||
CMDIFrameWnd *pFrame = (CMDIFrameWnd*)AfxGetApp()->m_pMainWnd;
|
||||
CMDIChildWnd *pChild = (CMDIChildWnd *) pFrame->GetActiveFrame();
|
||||
COCCDemoView *pView = (COCCDemoView *) pChild->GetActiveView();
|
||||
pView->SetViewScale(Coef);
|
||||
}
|
||||
|
||||
void OCCDemo_Presentation::ResetView()
|
||||
{
|
||||
CMDIFrameWnd *pFrame = (CMDIFrameWnd*)AfxGetApp()->m_pMainWnd;
|
||||
CMDIChildWnd *pChild = (CMDIChildWnd *) pFrame->GetActiveFrame();
|
||||
COCCDemoView *pView = (COCCDemoView *) pChild->GetActiveView();
|
||||
pView->Reset();
|
||||
}
|
134
samples/mfc/standard/10_Convert/src/OCCDemo_Presentation.h
Executable file
134
samples/mfc/standard/10_Convert/src/OCCDemo_Presentation.h
Executable file
@@ -0,0 +1,134 @@
|
||||
// OCCDemo_Presentation.h: interface for the OCCDemo_Presentation class.
|
||||
// This is a base class for all presentations
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_OCCDEMO_PRESENTATION_H__790EED7F_7BA2_11D5_BA4A_0060B0EE18EA__INCLUDED_)
|
||||
#define AFX_OCCDEMO_PRESENTATION_H__790EED7F_7BA2_11D5_BA4A_0060B0EE18EA__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
|
||||
#define WAIT_A_LITTLE WaitForInput(500)
|
||||
#define WAIT_A_SECOND WaitForInput(1000)
|
||||
|
||||
#include <OCCDemoDoc.h>
|
||||
#include <OCCDemo.h>
|
||||
class Handle_AIS_InteractiveObject;
|
||||
class Handle_AIS_Point;
|
||||
class Handle_Geom_Surface;
|
||||
class Handle_Geom_Curve;
|
||||
class Handle_Geom2d_Curve;
|
||||
class Quantity_Color;
|
||||
|
||||
class OCCDemo_Presentation
|
||||
{
|
||||
public:
|
||||
// Construction
|
||||
OCCDemo_Presentation() : myIndex(0), myNbSamples(0), FitMode(false){}
|
||||
virtual ~OCCDemo_Presentation() {}
|
||||
|
||||
public:
|
||||
static OCCDemo_Presentation* Current;
|
||||
// this pointer must be initialized when realize a derivable class;
|
||||
// it is used by application to access to a presentation class instance
|
||||
|
||||
void SetDocument (COCCDemoDoc* theDoc) {myDoc = theDoc;}
|
||||
// document must be set by the user of this class before first use of iterations
|
||||
|
||||
public:
|
||||
// Titling
|
||||
const CString& GetName() const {return myName;}
|
||||
|
||||
public:
|
||||
// Iteration on samples
|
||||
void FirstSample() {myIndex=0;}
|
||||
void LastSample() {myIndex=myNbSamples-1;}
|
||||
Standard_Boolean AtFirstSample() const {return myIndex <= 0;}
|
||||
Standard_Boolean AtLastSample() const {return myIndex >= myNbSamples-1;}
|
||||
void NextSample() {myIndex++;}
|
||||
void PrevSample() {myIndex--;}
|
||||
virtual void DoSample() = 0;
|
||||
static void GetViewCenter(V3d_Coordinate& Xc, V3d_Coordinate& Yc);
|
||||
static void SetViewCenter(const V3d_Coordinate Xc, const V3d_Coordinate Yc);
|
||||
static void GetViewEye(V3d_Coordinate& X, V3d_Coordinate& Y, V3d_Coordinate& Z);
|
||||
static void SetViewEye(V3d_Coordinate X, V3d_Coordinate Y, V3d_Coordinate Z);
|
||||
static Quantity_Factor GetViewScale();
|
||||
static void SetViewScale(Quantity_Factor Coef);
|
||||
static void ResetView();
|
||||
|
||||
|
||||
// place one-time initialization code in this function
|
||||
virtual void Init() {}
|
||||
|
||||
protected:
|
||||
// Methods to call from a derivable class
|
||||
void setName (const char* theName) {myName = CString(theName);}
|
||||
Handle_AIS_InteractiveContext getAISContext() const {return myDoc->GetAISContext();}
|
||||
Handle_V3d_Viewer getViewer() const {return myDoc->GetViewer();}
|
||||
void setResultTitle (const char* theTitle) {myDoc->GetResultDialog()->SetTitle(theTitle);}
|
||||
void setResultText (const char* theText) {myDoc->GetResultDialog()->SetText(theText);}
|
||||
Standard_CString GetDataDir() {return myDoc->GetDataDir();}
|
||||
|
||||
Standard_Boolean WaitForInput (unsigned long aMilliSeconds);
|
||||
// Waits for a user input or a period of time has been elapsed
|
||||
|
||||
Handle_AIS_InteractiveObject drawSurface (const Handle_Geom_Surface& theSurface,
|
||||
const Quantity_Color& theColor = Quantity_Color(Quantity_NOC_LEMONCHIFFON3),
|
||||
const Standard_Boolean toDisplay = Standard_True);
|
||||
// creates a finite face based on the given geometric surface
|
||||
// and displays it in the viewer if toDisplay = Standard_True
|
||||
|
||||
Handle_AIS_InteractiveObject drawCurve (const Handle_Geom_Curve& theCurve,
|
||||
const Quantity_Color& theColor = Quantity_Color(Quantity_NOC_RED),
|
||||
const Standard_Boolean toDisplay = Standard_True);
|
||||
// creates an ISession_Curve based on the given geometric curve
|
||||
// and displays it in the viewer if toDisplay = Standard_True
|
||||
|
||||
Handle_AIS_InteractiveObject drawCurve (const Handle_Geom2d_Curve& theCurve,
|
||||
const Quantity_Color& theColor = Quantity_Color(Quantity_NOC_RED),
|
||||
const Standard_Boolean toDisplay = Standard_True,
|
||||
const gp_Ax2& aPosition = gp::XOY());
|
||||
// converts a given curve to 3d using aPosition and calls the previous method
|
||||
|
||||
Handle_AIS_Point drawPoint (const gp_Pnt& thePnt,
|
||||
const Quantity_Color& theColor = Quantity_Color(Quantity_NOC_GREEN),
|
||||
const Standard_Boolean toDisplay = Standard_True);
|
||||
// creates a presentation of the given point
|
||||
// and displays it in the viewer if toDisplay = Standard_True
|
||||
|
||||
Handle_AIS_InteractiveObject drawVector (const gp_Pnt& thePnt,
|
||||
const gp_Vec& theVec,
|
||||
const Quantity_Color& theColor = Quantity_Color(Quantity_NOC_YELLOW),
|
||||
const Standard_Boolean toDisplay = Standard_True);
|
||||
// creates a presentation of the given vector
|
||||
// and displays it in the viewer if toDisplay = Standard_True
|
||||
|
||||
Handle_AIS_Shape drawShape (const TopoDS_Shape& theShape,
|
||||
const Quantity_Color& theColor,
|
||||
const Standard_Boolean toDisplay = Standard_True);
|
||||
// creates a presentation of the given shape
|
||||
// with material PLASTIC and a given color
|
||||
// and displays it in the viewer if toDisplay = Standard_True
|
||||
|
||||
Handle_AIS_Shape drawShape (const TopoDS_Shape& theShape,
|
||||
const Graphic3d_NameOfMaterial theMaterial = Graphic3d_NOM_BRASS,
|
||||
const Standard_Boolean toDisplay = Standard_True);
|
||||
// creates a presentation of the given shape with the given material
|
||||
// (color is default for a given material)
|
||||
// and displays it in the viewer if toDisplay = Standard_True
|
||||
|
||||
protected:
|
||||
// Fields to use in a derivable class
|
||||
BOOL FitMode;
|
||||
int myIndex;
|
||||
int myNbSamples;
|
||||
|
||||
private:
|
||||
COCCDemoDoc* myDoc;
|
||||
CString myName;
|
||||
|
||||
};
|
||||
|
||||
#endif // !defined(AFX_OCCDEMO_PRESENTATION_H__790EED7F_7BA2_11D5_BA4A_0060B0EE18EA__INCLUDED_)
|
113
samples/mfc/standard/10_Convert/src/WNT/MainFrm.cpp
Executable file
113
samples/mfc/standard/10_Convert/src/WNT/MainFrm.cpp
Executable file
@@ -0,0 +1,113 @@
|
||||
// MainFrm.cpp : implementation of the CMainFrame class
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "OCCDemo.h"
|
||||
|
||||
#include "MainFrm.h"
|
||||
#include "OCCDemoDoc.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CMainFrame
|
||||
|
||||
IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)
|
||||
|
||||
BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
|
||||
//{{AFX_MSG_MAP(CMainFrame)
|
||||
// NOTE - the ClassWizard will add and remove mapping macros here.
|
||||
// DO NOT EDIT what you see in these blocks of generated code !
|
||||
ON_WM_CREATE()
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
static UINT indicators[] =
|
||||
{
|
||||
ID_SEPARATOR // status line indicator
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CMainFrame construction/destruction
|
||||
|
||||
CMainFrame::CMainFrame()
|
||||
{
|
||||
// TODO: add member initialization code here
|
||||
|
||||
}
|
||||
|
||||
CMainFrame::~CMainFrame()
|
||||
{
|
||||
}
|
||||
|
||||
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
|
||||
{
|
||||
if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
|
||||
return -1;
|
||||
|
||||
if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
|
||||
/* | CBRS_GRIPPER */| CBRS_TOOLTIPS | CBRS_FLYBY) ||
|
||||
!m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
|
||||
{
|
||||
TRACE0("Failed to create toolbar\n");
|
||||
return -1; // fail to create
|
||||
}
|
||||
|
||||
if (!m_wndToolBar1.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
|
||||
| CBRS_TOOLTIPS | CBRS_FLYBY) ||
|
||||
!m_wndToolBar1.LoadToolBar(IDR_TOOLBAR1))
|
||||
{
|
||||
TRACE0("Failed to create toolbar\n");
|
||||
return -1; // fail to create
|
||||
}
|
||||
|
||||
if (!m_wndStatusBar.Create(this) ||
|
||||
!m_wndStatusBar.SetIndicators(indicators,
|
||||
sizeof(indicators)/sizeof(UINT)))
|
||||
{
|
||||
TRACE0("Failed to create status bar\n");
|
||||
return -1; // fail to create
|
||||
}
|
||||
|
||||
// TODO: Delete these three lines if you don't want the toolbar to
|
||||
// be dockable
|
||||
//m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
|
||||
//EnableDocking(CBRS_ALIGN_ANY);
|
||||
//DockControlBar(&m_wndToolBar);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
|
||||
{
|
||||
if( !CFrameWnd::PreCreateWindow(cs) )
|
||||
return FALSE;
|
||||
// TODO: Modify the Window class or styles here by modifying
|
||||
// the CREATESTRUCT cs
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CMainFrame diagnostics
|
||||
|
||||
#ifdef _DEBUG
|
||||
void CMainFrame::AssertValid() const
|
||||
{
|
||||
CFrameWnd::AssertValid();
|
||||
}
|
||||
|
||||
void CMainFrame::Dump(CDumpContext& dc) const
|
||||
{
|
||||
CFrameWnd::Dump(dc);
|
||||
}
|
||||
|
||||
#endif //_DEBUG
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CMainFrame message handlers
|
||||
|
59
samples/mfc/standard/10_Convert/src/WNT/MainFrm.h
Executable file
59
samples/mfc/standard/10_Convert/src/WNT/MainFrm.h
Executable file
@@ -0,0 +1,59 @@
|
||||
// MainFrm.h : interface of the CMainFrame class
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_MAINFRM_H__57A6A22C_7B4F_11D5_BA4A_0060B0EE18EA__INCLUDED_)
|
||||
#define AFX_MAINFRM_H__57A6A22C_7B4F_11D5_BA4A_0060B0EE18EA__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
class CMainFrame : public CFrameWnd
|
||||
{
|
||||
|
||||
protected: // create from serialization only
|
||||
CMainFrame();
|
||||
DECLARE_DYNCREATE(CMainFrame)
|
||||
|
||||
// Attributes
|
||||
public:
|
||||
|
||||
// Operations
|
||||
public:
|
||||
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CMainFrame)
|
||||
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
public:
|
||||
virtual ~CMainFrame();
|
||||
#ifdef _DEBUG
|
||||
virtual void AssertValid() const;
|
||||
virtual void Dump(CDumpContext& dc) const;
|
||||
#endif
|
||||
|
||||
protected: // control bar embedded members
|
||||
CStatusBar m_wndStatusBar;
|
||||
CToolBar m_wndToolBar;
|
||||
CToolBar m_wndToolBar1;
|
||||
|
||||
// Generated message map functions
|
||||
protected:
|
||||
//{{AFX_MSG(CMainFrame)
|
||||
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
|
||||
// NOTE - the ClassWizard will add and remove member functions here.
|
||||
// DO NOT EDIT what you see in these blocks of generated code!
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//{{AFX_INSERT_LOCATION}}
|
||||
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
|
||||
|
||||
#endif // !defined(AFX_MAINFRM_H__57A6A22C_7B4F_11D5_BA4A_0060B0EE18EA__INCLUDED_)
|
BIN
samples/mfc/standard/10_Convert/src/WNT/OCCDemo.aps
Executable file
BIN
samples/mfc/standard/10_Convert/src/WNT/OCCDemo.aps
Executable file
Binary file not shown.
179
samples/mfc/standard/10_Convert/src/WNT/OCCDemo.cpp
Executable file
179
samples/mfc/standard/10_Convert/src/WNT/OCCDemo.cpp
Executable file
@@ -0,0 +1,179 @@
|
||||
// OCCDemo.cpp : Defines the class behaviors for the application.
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "OCCDemo.h"
|
||||
|
||||
#include "MainFrm.h"
|
||||
#include "OCCDemoDoc.h"
|
||||
#include "OCCDemoView.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// COCCDemoApp
|
||||
|
||||
BEGIN_MESSAGE_MAP(COCCDemoApp, CWinApp)
|
||||
//{{AFX_MSG_MAP(COCCDemoApp)
|
||||
ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
|
||||
//}}AFX_MSG_MAP
|
||||
// Standard file based document commands
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// COCCDemoApp construction
|
||||
|
||||
COCCDemoApp::COCCDemoApp()
|
||||
{
|
||||
// TODO: add construction code here,
|
||||
// Place all significant initialization in InitInstance
|
||||
SampleName = "";
|
||||
try
|
||||
{
|
||||
myGraphicDevice = new Graphic3d_WNTGraphicDevice;
|
||||
}
|
||||
catch(Standard_Failure)
|
||||
{
|
||||
AfxMessageBox("Fatal Error During Graphic Initialisation");
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// The one and only COCCDemoApp object
|
||||
|
||||
COCCDemoApp theApp;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// COCCDemoApp initialization
|
||||
|
||||
BOOL COCCDemoApp::InitInstance()
|
||||
{
|
||||
// Standard initialization
|
||||
// If you are not using these features and wish to reduce the size
|
||||
// of your final executable, you should remove from the following
|
||||
// the specific initialization routines you do not need.
|
||||
|
||||
// Change the registry key under which our settings are stored.
|
||||
// TODO: You should modify this string to be something appropriate
|
||||
// such as the name of your company or organization.
|
||||
SetRegistryKey(_T("Local AppWizard-Generated Applications"));
|
||||
|
||||
LoadStdProfileSettings(); // Load standard INI file options (including MRU)
|
||||
|
||||
// Register the application's document templates. Document templates
|
||||
// serve as the connection between documents, frame windows and views.
|
||||
|
||||
CSingleDocTemplate* pDocTemplate;
|
||||
pDocTemplate = new CSingleDocTemplate(
|
||||
IDR_MAINFRAME,
|
||||
RUNTIME_CLASS(COCCDemoDoc),
|
||||
RUNTIME_CLASS(CMainFrame), // main SDI frame window
|
||||
RUNTIME_CLASS(COCCDemoView));
|
||||
AddDocTemplate(pDocTemplate);
|
||||
|
||||
|
||||
// Parse command line for standard shell commands, DDE, file open
|
||||
CCommandLineInfo cmdInfo;
|
||||
ParseCommandLine(cmdInfo);
|
||||
|
||||
// Dispatch commands specified on the command line
|
||||
if (!ProcessShellCommand(cmdInfo))
|
||||
return FALSE;
|
||||
|
||||
|
||||
// Create result dialog
|
||||
AfxInitRichEdit();
|
||||
CMainFrame* cFrame = (CMainFrame*) GetMainWnd();
|
||||
COCCDemoDoc* aDoc = (COCCDemoDoc*) cFrame->GetActiveDocument();
|
||||
|
||||
// pass cFrame->GetDesktopWindow() as parent to have an independent dialog
|
||||
// pass cFrame as parent to have the result dialog always above the main window
|
||||
if (!aDoc->GetResultDialog()->Create(CResultDialog::IDD, cFrame->GetDesktopWindow()))
|
||||
TRACE0("Failed to create result dialog\n");
|
||||
|
||||
aDoc->GetResultDialog()->SetIcon(AfxGetApp()->LoadIcon(IDR_MAINFRAME), FALSE);
|
||||
aDoc->GetResultDialog()->ShowWindow(SW_HIDE);
|
||||
aDoc->GetResultDialog()->Initialize();
|
||||
|
||||
// resize the result dialog, so no clipping occures when user
|
||||
// resizes the dialog manually
|
||||
// position the result dialog to the left bottom corner of the view
|
||||
CRect aDlgRect, aViewRect;
|
||||
aDoc->GetResultDialog()->GetWindowRect(&aDlgRect);
|
||||
cFrame->GetActiveView()->GetWindowRect(&aViewRect);
|
||||
|
||||
int x = aViewRect.left;
|
||||
int y = aViewRect.bottom - aDlgRect.Size().cy;
|
||||
int cx = aDlgRect.Size().cx+1;
|
||||
int cy = aDlgRect.Size().cy+1;
|
||||
aDoc->GetResultDialog()->SetWindowPos(NULL, x, y, cx, cy, SWP_NOREDRAW | SWP_NOZORDER);
|
||||
|
||||
m_pMainWnd->ShowWindow(SW_SHOW);
|
||||
m_pMainWnd->UpdateWindow();
|
||||
m_pMainWnd->SetFocus();
|
||||
aDoc->Start();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CAboutDlg dialog used for App About
|
||||
|
||||
class CAboutDlg : public CDialog
|
||||
{
|
||||
public:
|
||||
CAboutDlg();
|
||||
|
||||
// Dialog Data
|
||||
//{{AFX_DATA(CAboutDlg)
|
||||
enum { IDD = IDD_ABOUTBOX };
|
||||
//}}AFX_DATA
|
||||
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CAboutDlg)
|
||||
protected:
|
||||
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
protected:
|
||||
//{{AFX_MSG(CAboutDlg)
|
||||
// No message handlers
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
||||
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
|
||||
{
|
||||
//{{AFX_DATA_INIT(CAboutDlg)
|
||||
//}}AFX_DATA_INIT
|
||||
}
|
||||
|
||||
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialog::DoDataExchange(pDX);
|
||||
//{{AFX_DATA_MAP(CAboutDlg)
|
||||
//}}AFX_DATA_MAP
|
||||
}
|
||||
|
||||
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
|
||||
//{{AFX_MSG_MAP(CAboutDlg)
|
||||
// No message handlers
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
// App command to run the dialog
|
||||
void COCCDemoApp::OnAppAbout()
|
||||
{
|
||||
CAboutDlg aboutDlg;
|
||||
aboutDlg.DoModal();
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// COCCDemoApp message handlers
|
||||
|
||||
*/
|
57
samples/mfc/standard/10_Convert/src/WNT/OCCDemo.h
Executable file
57
samples/mfc/standard/10_Convert/src/WNT/OCCDemo.h
Executable file
@@ -0,0 +1,57 @@
|
||||
// OCCDemo.h : main header file for the OCCDEMO application
|
||||
//
|
||||
|
||||
#if !defined(AFX_OCCDEMO_H__57A6A228_7B4F_11D5_BA4A_0060B0EE18EA__INCLUDED_)
|
||||
#define AFX_OCCDEMO_H__57A6A228_7B4F_11D5_BA4A_0060B0EE18EA__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
#ifndef __AFXWIN_H__
|
||||
#error include 'stdafx.h' before including this file for PCH
|
||||
#endif
|
||||
|
||||
#include "resource.h" // main symbols
|
||||
|
||||
#include <OCC_BaseApp.h>
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// COCCDemoApp:
|
||||
// See OCCDemo.cpp for the implementation of this class
|
||||
//
|
||||
|
||||
class COCCDemoApp : public OCC_BaseApp
|
||||
{
|
||||
public:
|
||||
COCCDemoApp();
|
||||
Handle(Graphic3d_WNTGraphicDevice) GetGraphicDevice() const
|
||||
{ return myGraphicDevice; } ;
|
||||
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(COCCDemoApp)
|
||||
public:
|
||||
virtual BOOL InitInstance();
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
//{{AFX_MSG(COCCDemoApp)
|
||||
//afx_msg void OnAppAbout();
|
||||
// NOTE - the ClassWizard will add and remove member functions here.
|
||||
// DO NOT EDIT what you see in these blocks of generated code !
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
|
||||
private:
|
||||
Handle(Graphic3d_WNTGraphicDevice) myGraphicDevice;
|
||||
|
||||
};
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//{{AFX_INSERT_LOCATION}}
|
||||
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
|
||||
|
||||
#endif // !defined(AFX_OCCDEMO_H__57A6A228_7B4F_11D5_BA4A_0060B0EE18EA__INCLUDED_)
|
388
samples/mfc/standard/10_Convert/src/WNT/OCCDemo.rc
Executable file
388
samples/mfc/standard/10_Convert/src/WNT/OCCDemo.rc
Executable file
@@ -0,0 +1,388 @@
|
||||
//Microsoft Developer Studio generated resource script.
|
||||
//
|
||||
#include "resource.h"
|
||||
|
||||
#define APSTUDIO_READONLY_SYMBOLS
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 2 resource.
|
||||
//
|
||||
#include "afxres.h"
|
||||
#include "..\..\..\Common\res\OCC_Resource.h"
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#undef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// English (U.S.) resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
|
||||
#ifdef _WIN32
|
||||
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||
#pragma code_page(1252)
|
||||
#endif //_WIN32
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TEXTINCLUDE
|
||||
//
|
||||
|
||||
1 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"resource.h\0"
|
||||
END
|
||||
|
||||
2 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"#include ""afxres.h""\r\n"
|
||||
"#include ""..\\..\\..\\Common\\res\\OCC_Resource.h""\0"
|
||||
|
||||
END
|
||||
|
||||
3 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"#define _AFX_NO_SPLITTER_RESOURCES\r\n"
|
||||
"#define _AFX_NO_OLE_RESOURCES\r\n"
|
||||
"#define _AFX_NO_TRACKER_RESOURCES\r\n"
|
||||
"#define _AFX_NO_PROPERTY_RESOURCES\r\n"
|
||||
"\r\n"
|
||||
"#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n"
|
||||
"#ifdef _WIN32\r\n"
|
||||
"LANGUAGE 9, 1\r\n"
|
||||
"#pragma code_page(1252)\r\n"
|
||||
"#endif //_WIN32\r\n"
|
||||
"#include ""res\\OCCDemo.rc2"" // non-Microsoft Visual C++ edited resources\r\n"
|
||||
"#include ""afxres.rc"" // Standard components\r\n"
|
||||
"#endif\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Icon
|
||||
//
|
||||
|
||||
// Icon with lowest ID value placed first to ensure application icon
|
||||
// remains consistent on all systems.
|
||||
IDR_MAINFRAME ICON DISCARDABLE "res\\OCCDemo.ico"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Bitmap
|
||||
//
|
||||
|
||||
IDR_MAINFRAME BITMAP MOVEABLE PURE "res\\Toolbar.bmp"
|
||||
IDR_TOOLBAR1 BITMAP DISCARDABLE "res\\Toolbar1.bmp"
|
||||
IDB_OCCLOGO BITMAP DISCARDABLE "res\\occlogo.bmp"
|
||||
IDB_OPENLOGO BITMAP DISCARDABLE "res\\logopen.bmp"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Toolbar
|
||||
//
|
||||
|
||||
IDR_MAINFRAME TOOLBAR DISCARDABLE 20, 20
|
||||
BEGIN
|
||||
BUTTON ID_BUTTONStart
|
||||
BUTTON ID_BUTTONPrev
|
||||
BUTTON ID_BUTTONRepeat
|
||||
BUTTON ID_BUTTONNext
|
||||
BUTTON ID_BUTTONEnd
|
||||
SEPARATOR
|
||||
BUTTON ID_BUTTONShowResult
|
||||
BUTTON ID_DUMP_VIEW
|
||||
END
|
||||
|
||||
IDR_TOOLBAR1 TOOLBAR DISCARDABLE 20, 20
|
||||
BEGIN
|
||||
BUTTON ID_BUTTONZoomAll
|
||||
BUTTON ID_BUTTONZoomWin
|
||||
BUTTON ID_BUTTONZoomProg
|
||||
SEPARATOR
|
||||
BUTTON ID_BUTTONPan
|
||||
BUTTON ID_BUTTONPanGlo
|
||||
SEPARATOR
|
||||
BUTTON ID_BUTTONFront
|
||||
BUTTON ID_BUTTONTop
|
||||
BUTTON ID_BUTTONLeft
|
||||
BUTTON ID_BUTTONBack
|
||||
BUTTON ID_BUTTONRight
|
||||
BUTTON ID_BUTTONBottom
|
||||
BUTTON ID_BUTTONAxo
|
||||
SEPARATOR
|
||||
BUTTON ID_BUTTONRot
|
||||
BUTTON ID_BUTTONReset
|
||||
SEPARATOR
|
||||
BUTTON ID_BUTTONWire
|
||||
BUTTON ID_BUTTONShade
|
||||
BUTTON ID_BUTTONHlrOn
|
||||
END
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Menu
|
||||
//
|
||||
|
||||
IDR_MAINFRAME MENU PRELOAD DISCARDABLE
|
||||
BEGIN
|
||||
POPUP "&File"
|
||||
BEGIN
|
||||
MENUITEM "Reset", ID_FILE_NEW
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "E&xit", ID_APP_EXIT
|
||||
END
|
||||
POPUP "&Help"
|
||||
BEGIN
|
||||
MENUITEM "&About OCCDemo...", ID_APP_ABOUT
|
||||
END
|
||||
END
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Accelerator
|
||||
//
|
||||
|
||||
IDR_MAINFRAME ACCELERATORS PRELOAD MOVEABLE PURE
|
||||
BEGIN
|
||||
"A", ID_BUTTONAxo, VIRTKEY, CONTROL, NOINVERT
|
||||
"B", ID_BUTTONBack, VIRTKEY, CONTROL, NOINVERT
|
||||
"F", ID_BUTTONZoomAll, VIRTKEY, NOINVERT
|
||||
"F", ID_BUTTONFront, VIRTKEY, CONTROL, NOINVERT
|
||||
"H", ID_BUTTONHlrOn, VIRTKEY, SHIFT, NOINVERT
|
||||
"L", ID_BUTTONLeft, VIRTKEY, CONTROL, NOINVERT
|
||||
"M", ID_BUTTONBottom, VIRTKEY, CONTROL, NOINVERT
|
||||
"R", ID_BUTTONReset, VIRTKEY, NOINVERT
|
||||
"R", ID_BUTTONRight, VIRTKEY, CONTROL, NOINVERT
|
||||
"S", ID_BUTTONShade, VIRTKEY, SHIFT, NOINVERT
|
||||
"T", ID_BUTTONTop, VIRTKEY, CONTROL, NOINVERT
|
||||
VK_END, ID_BUTTONEnd, VIRTKEY, NOINVERT
|
||||
VK_F11, ID_BUTTONShowResult, VIRTKEY, NOINVERT
|
||||
VK_F12, ID_DUMP_VIEW, VIRTKEY, NOINVERT
|
||||
VK_HOME, ID_BUTTONStart, VIRTKEY, NOINVERT
|
||||
VK_NEXT, ID_BUTTONNext, VIRTKEY, NOINVERT
|
||||
VK_PRIOR, ID_BUTTONPrev, VIRTKEY, NOINVERT
|
||||
VK_SPACE, ID_BUTTONRepeat, VIRTKEY, NOINVERT
|
||||
"W", ID_BUTTONWire, VIRTKEY, SHIFT, NOINVERT
|
||||
"X", ID_APP_EXIT, VIRTKEY, CONTROL, NOINVERT
|
||||
END
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Dialog
|
||||
//
|
||||
|
||||
IDD_ABOUTBOX DIALOG DISCARDABLE 0, 0, 229, 170
|
||||
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "About OCCDemo"
|
||||
FONT 8, "MS Sans Serif"
|
||||
BEGIN
|
||||
CTEXT "Copyright (C) 2003, OpenCASCADE Company",IDC_STATIC,42,
|
||||
106,145,8,SS_NOPREFIX
|
||||
DEFPUSHBUTTON "OK",IDOK,90,132,50,14,WS_GROUP
|
||||
CONTROL 142,IDC_STATIC,"Static",SS_BITMAP,50,35,129,62
|
||||
LTEXT "OCCDemo, OpenCASCADE 5.0",IDC_STATIC,64,20,101,8
|
||||
END
|
||||
|
||||
IDD_ResultDialog DIALOG DISCARDABLE 0, 0, 244, 231
|
||||
STYLE WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU |
|
||||
WS_THICKFRAME
|
||||
CAPTION "Result Dialog"
|
||||
FONT 8, "MS Sans Serif"
|
||||
BEGIN
|
||||
CONTROL "",IDC_RICHEDIT_ResultDialog,"RICHEDIT",ES_MULTILINE |
|
||||
ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_NOHIDESEL |
|
||||
ES_READONLY | WS_BORDER | WS_VSCROLL | WS_HSCROLL |
|
||||
WS_TABSTOP,0,7,243,192
|
||||
PUSHBUTTON "Copy selection",IDC_CopySelectionToClipboard,0,206,60,
|
||||
18
|
||||
PUSHBUTTON "Copy all",IDC_CopyAllToClipboard,65,206,60,18
|
||||
PUSHBUTTON "Close",IDCANCEL,183,206,60,18
|
||||
END
|
||||
|
||||
|
||||
#ifndef _MAC
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Version
|
||||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 1,0,0,1
|
||||
PRODUCTVERSION 1,0,0,1
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
#else
|
||||
FILEFLAGS 0x0L
|
||||
#endif
|
||||
FILEOS 0x4L
|
||||
FILETYPE 0x1L
|
||||
FILESUBTYPE 0x0L
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "040904b0"
|
||||
BEGIN
|
||||
VALUE "Comments", "Open CASCADE Technology Demonstration Application\0"
|
||||
VALUE "CompanyName", "Open CASCADE, France\0"
|
||||
VALUE "FileDescription", "OCCDemo MFC Application\0"
|
||||
VALUE "FileVersion", "1, 0, 0, 1\0"
|
||||
VALUE "InternalName", "OCCDemo\0"
|
||||
VALUE "LegalCopyright", "Copyright (C) 2001, Open CASCADE Company\0"
|
||||
VALUE "LegalTrademarks", "Open CASCADE\0"
|
||||
VALUE "OriginalFilename", "OCCDemo.EXE\0"
|
||||
VALUE "PrivateBuild", "\0"
|
||||
VALUE "ProductName", "OCCDemo Application\0"
|
||||
VALUE "ProductVersion", "1, 0, 0, 1\0"
|
||||
VALUE "SpecialBuild", "\0"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x409, 1200
|
||||
END
|
||||
END
|
||||
|
||||
#endif // !_MAC
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// DESIGNINFO
|
||||
//
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
GUIDELINES DESIGNINFO DISCARDABLE
|
||||
BEGIN
|
||||
IDD_ABOUTBOX, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 222
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 162
|
||||
END
|
||||
|
||||
IDD_ResultDialog, DIALOG
|
||||
BEGIN
|
||||
RIGHTMARGIN, 243
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 224
|
||||
END
|
||||
END
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// String Table
|
||||
//
|
||||
|
||||
STRINGTABLE PRELOAD DISCARDABLE
|
||||
BEGIN
|
||||
IDR_MAINFRAME "OCCDemo\n\nOCCDem\n\n\nOCCDemo.Document\nOCCDem Document"
|
||||
END
|
||||
|
||||
STRINGTABLE PRELOAD DISCARDABLE
|
||||
BEGIN
|
||||
AFX_IDS_APP_TITLE "OCCDemo"
|
||||
AFX_IDS_IDLEMESSAGE "Ready"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
ID_FILE_NEW "Start demo a new\nReset"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
ID_APP_ABOUT "Display program information, version number and copyright\nAbout"
|
||||
ID_APP_EXIT "Quit the application\nExit"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
AFX_IDS_SCSIZE "Change the window size"
|
||||
AFX_IDS_SCMOVE "Change the window position"
|
||||
AFX_IDS_SCMINIMIZE "Reduce the window to an icon"
|
||||
AFX_IDS_SCMAXIMIZE "Enlarge the window to full size"
|
||||
AFX_IDS_SCNEXTWINDOW "Switch to the next document window"
|
||||
AFX_IDS_SCPREVWINDOW "Switch to the previous document window"
|
||||
AFX_IDS_SCCLOSE "Close the active window"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
AFX_IDS_SCRESTORE "Restore the window to normal size"
|
||||
AFX_IDS_SCTASKLIST "Activate Task List"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
ID_BUTTONZoomAll "Press to zoom the application objects in the view\nFitAll (F)"
|
||||
ID_BUTTONZoomWin "Press and drag MB1 to select a zoom window\nZoom Window"
|
||||
ID_BUTTONZoomProg "Press and drag MB1 to zoom\nDynamic Zooming"
|
||||
ID_BUTTONPan "Press and drag MB1 to pan\nDynamic Panning"
|
||||
ID_BUTTONPanGlo "Press and select a new view center t\nGlobal Panning"
|
||||
ID_BUTTONFront "Press to select a front View\nFront (Ctrl+F)"
|
||||
ID_BUTTONLeft "Press to select a left View\nLeft (Ctrl+L)"
|
||||
ID_BUTTONTop "Press to select a top View\nTop (Ctrl+T)"
|
||||
ID_BUTTONBack "Press to select a back View\nBack (Ctrl+B)"
|
||||
ID_BUTTONRight "Press to select a right View\nRight (Ctrl+R)"
|
||||
ID_BUTTONBottom "Press to select a bottom View\nBottom (Ctrl+M)"
|
||||
ID_BUTTONAxo "Press to select axonometric View\nAxo (Ctrl+A)"
|
||||
ID_BUTTONRot "Press and drag MB1 to rotate\nDynamic Rotation"
|
||||
ID_BUTTONReset "Press to reset view\nReset (R)"
|
||||
ID_BUTTONWire "Press to switch to wireframe mode\nWireframe mode (Shift+W)"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
ID_BUTTONShade "Press to switch to shading mode\nShading mode (Shift+S)"
|
||||
ID_BUTTONHlrOn "Press to switch to HLR mode\nHLR mode (Shift+H)"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
ID_BUTTONStart "Press to go to the first sample\nFirst sample (Home)"
|
||||
ID_BUTTONNext "Press to go to the next sample\nNext sample (PgDn)"
|
||||
ID_BUTTONShowResult "Press to toggle show of source code on/off\nSource code (F11)"
|
||||
ID_DUMP_VIEW "Save current frame into a GIF file\nExport view to GIF (F12)"
|
||||
ID_BUTTONEnd "Press to go to the last sample\nLast sample (End)"
|
||||
ID_BUTTONPrev "Press to go to the previous sample\nPrevious sample (PgUp)"
|
||||
ID_BUTTONRepeat "Press to repeat the current sample\nRepeat sample (Space)"
|
||||
END
|
||||
|
||||
#endif // English (U.S.) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
#ifndef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 3 resource.
|
||||
//
|
||||
#define _AFX_NO_SPLITTER_RESOURCES
|
||||
#define _AFX_NO_OLE_RESOURCES
|
||||
#define _AFX_NO_TRACKER_RESOURCES
|
||||
#define _AFX_NO_PROPERTY_RESOURCES
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
|
||||
#ifdef _WIN32
|
||||
LANGUAGE 9, 1
|
||||
#pragma code_page(1252)
|
||||
#endif //_WIN32
|
||||
#include "res\OCCDemo.rc2" // non-Microsoft Visual C++ edited resources
|
||||
#include "afxres.rc" // Standard components
|
||||
#include "..\\..\\..\\Common\\res\\OCC_Resource.h"
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#endif // not APSTUDIO_INVOKED
|
||||
|
269
samples/mfc/standard/10_Convert/src/WNT/OCCDemoDoc.cpp
Executable file
269
samples/mfc/standard/10_Convert/src/WNT/OCCDemoDoc.cpp
Executable file
@@ -0,0 +1,269 @@
|
||||
// OCCDemoDoc.cpp : implementation of the COCCDemoDoc class
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "OCCDemo.h"
|
||||
|
||||
#include "OCCDemoDoc.h"
|
||||
#include "OCCDemo_Presentation.h"
|
||||
#include "OCCDemoView.h"
|
||||
|
||||
#include <Standard_ErrorHandler.hxx>
|
||||
#include <Standard_SStream.hxx>
|
||||
|
||||
#ifdef _DEBUG
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// COCCDemoDoc
|
||||
|
||||
IMPLEMENT_DYNCREATE(COCCDemoDoc, CDocument)
|
||||
|
||||
BEGIN_MESSAGE_MAP(COCCDemoDoc, CDocument)
|
||||
//{{AFX_MSG_MAP(COCCDemoDoc)
|
||||
ON_COMMAND(ID_BUTTONNext, OnBUTTONNext)
|
||||
ON_COMMAND(ID_BUTTONStart, OnBUTTONStart)
|
||||
ON_COMMAND(ID_BUTTONRepeat, OnBUTTONRepeat)
|
||||
ON_COMMAND(ID_BUTTONPrev, OnBUTTONPrev)
|
||||
ON_COMMAND(ID_BUTTONEnd, OnBUTTONEnd)
|
||||
ON_UPDATE_COMMAND_UI(ID_BUTTONNext, OnUpdateBUTTONNext)
|
||||
ON_UPDATE_COMMAND_UI(ID_BUTTONPrev, OnUpdateBUTTONPrev)
|
||||
ON_COMMAND(ID_FILE_NEW, OnFileNew)
|
||||
ON_COMMAND(ID_BUTTONShowResult, OnBUTTONShowResult)
|
||||
ON_UPDATE_COMMAND_UI(ID_BUTTONShowResult, OnUpdateBUTTONShowResult)
|
||||
ON_COMMAND(ID_DUMP_VIEW, OnDumpView)
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// COCCDemoDoc construction/destruction
|
||||
|
||||
COCCDemoDoc::COCCDemoDoc()
|
||||
{
|
||||
// TODO: add one-time construction code here
|
||||
Handle(Graphic3d_WNTGraphicDevice) theGraphicDevice =
|
||||
((COCCDemoApp*)AfxGetApp())->GetGraphicDevice();
|
||||
|
||||
myViewer = new V3d_Viewer(theGraphicDevice,(short *) "Visu3D");
|
||||
myViewer->SetDefaultLights();
|
||||
myViewer->SetLightOn();
|
||||
myViewer->SetDefaultBackgroundColor(Quantity_TOC_RGB, 0.,0.,0.);
|
||||
|
||||
myAISContext = new AIS_InteractiveContext(myViewer);
|
||||
myShowResult = FALSE;
|
||||
myPresentation = OCCDemo_Presentation::Current;
|
||||
myPresentation->SetDocument(this);
|
||||
|
||||
strcpy_s(myDataDir, "Data");
|
||||
strcpy_s(myLastPath, ".");
|
||||
}
|
||||
|
||||
COCCDemoDoc::~COCCDemoDoc()
|
||||
{
|
||||
}
|
||||
|
||||
BOOL COCCDemoDoc::OnNewDocument()
|
||||
{
|
||||
if (!CDocument::OnNewDocument())
|
||||
return FALSE;
|
||||
|
||||
// TODO: add reinitialization code here
|
||||
// (SDI documents will reuse this document)
|
||||
SetTitle(myPresentation->GetName());
|
||||
|
||||
myAISContext->EraseAll(Standard_False);
|
||||
myAISContext->SetDisplayMode(AIS_Shaded);
|
||||
|
||||
POSITION pos = GetFirstViewPosition();
|
||||
while (pos != NULL)
|
||||
{
|
||||
COCCDemoView* pView = (COCCDemoView*) GetNextView(pos);
|
||||
pView->Reset();
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void COCCDemoDoc::Start()
|
||||
{
|
||||
myPresentation->Init();
|
||||
OnBUTTONStart();
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// COCCDemoDoc serialization
|
||||
|
||||
void COCCDemoDoc::Serialize(CArchive& ar)
|
||||
{
|
||||
if (ar.IsStoring())
|
||||
{}// TODO: add storing code here
|
||||
else
|
||||
{}// TODO: add loading code here
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// COCCDemoDoc diagnostics
|
||||
|
||||
#ifdef _DEBUG
|
||||
void COCCDemoDoc::AssertValid() const
|
||||
{
|
||||
CDocument::AssertValid();
|
||||
}
|
||||
|
||||
void COCCDemoDoc::Dump(CDumpContext& dc) const
|
||||
{
|
||||
CDocument::Dump(dc);
|
||||
}
|
||||
#endif //_DEBUG
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// COCCDemoDoc commands
|
||||
|
||||
void COCCDemoDoc::OnFileNew()
|
||||
{
|
||||
OnNewDocument();
|
||||
Start();
|
||||
}
|
||||
|
||||
void COCCDemoDoc::InitViewButtons()
|
||||
{
|
||||
POSITION pos = GetFirstViewPosition();
|
||||
while (pos != NULL)
|
||||
{
|
||||
COCCDemoView* pView = (COCCDemoView*) GetNextView(pos);
|
||||
pView->InitButtons();
|
||||
}
|
||||
}
|
||||
|
||||
void COCCDemoDoc::DoSample()
|
||||
{
|
||||
InitViewButtons();
|
||||
|
||||
HCURSOR hOldCursor = ::GetCursor();
|
||||
HCURSOR hNewCursor = AfxGetApp()->LoadStandardCursor(IDC_APPSTARTING);
|
||||
|
||||
SetCursor(hNewCursor);
|
||||
{
|
||||
try
|
||||
{
|
||||
myPresentation->DoSample();
|
||||
}
|
||||
catch (Standard_Failure)
|
||||
{
|
||||
Standard_SStream aSStream;
|
||||
aSStream << "An exception was caught: " << Standard_Failure::Caught() << ends;
|
||||
Standard_CString aMsg = aSStream.str().c_str();
|
||||
// aSStream.rdbuf()->freeze(0); // allow deletion of dynamic array
|
||||
AfxMessageBox (aMsg);
|
||||
}
|
||||
}
|
||||
SetCursor(hOldCursor);
|
||||
}
|
||||
|
||||
void COCCDemoDoc::OnBUTTONStart()
|
||||
{
|
||||
myAISContext->EraseAll(Standard_False);
|
||||
myPresentation->FirstSample();
|
||||
DoSample();
|
||||
}
|
||||
|
||||
void COCCDemoDoc::OnBUTTONEnd()
|
||||
{
|
||||
myAISContext->EraseAll(Standard_False);
|
||||
myPresentation->LastSample();
|
||||
DoSample();
|
||||
}
|
||||
|
||||
void COCCDemoDoc::OnBUTTONRepeat()
|
||||
{
|
||||
DoSample();
|
||||
}
|
||||
|
||||
void COCCDemoDoc::OnBUTTONNext()
|
||||
{
|
||||
if (!myPresentation->AtLastSample())
|
||||
{
|
||||
myPresentation->NextSample();
|
||||
DoSample();
|
||||
}
|
||||
}
|
||||
|
||||
void COCCDemoDoc::OnBUTTONPrev()
|
||||
{
|
||||
if (!myPresentation->AtFirstSample())
|
||||
{
|
||||
myPresentation->PrevSample();
|
||||
DoSample();
|
||||
}
|
||||
}
|
||||
|
||||
void COCCDemoDoc::OnUpdateBUTTONNext(CCmdUI* pCmdUI)
|
||||
{
|
||||
pCmdUI->Enable (!myPresentation->AtLastSample());
|
||||
}
|
||||
|
||||
void COCCDemoDoc::OnUpdateBUTTONPrev(CCmdUI* pCmdUI)
|
||||
{
|
||||
pCmdUI->Enable (!myPresentation->AtFirstSample());
|
||||
}
|
||||
|
||||
void COCCDemoDoc::OnBUTTONShowResult()
|
||||
{
|
||||
myShowResult = !myShowResult;
|
||||
if (myShowResult)
|
||||
myCResultDialog.ShowWindow(SW_SHOWNORMAL);
|
||||
else
|
||||
myCResultDialog.ShowWindow(SW_HIDE);
|
||||
}
|
||||
|
||||
void COCCDemoDoc::OnUpdateBUTTONShowResult(CCmdUI* pCmdUI)
|
||||
{
|
||||
pCmdUI->SetCheck (myShowResult);
|
||||
}
|
||||
|
||||
void COCCDemoDoc::OnDumpView()
|
||||
{
|
||||
// save current directory and restore it on exit
|
||||
char aCurPath[MAX_PATH];
|
||||
::GetCurrentDirectory(MAX_PATH, aCurPath);
|
||||
|
||||
::SetCurrentDirectory(myLastPath);
|
||||
|
||||
CFileDialog *aDlg = new CFileDialog(false, "gif", "OCCView.gif",
|
||||
OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, "GIF Files (*.gif)|*.gif||", NULL);
|
||||
|
||||
int result = aDlg->DoModal();
|
||||
if ( result == IDOK)
|
||||
{
|
||||
CString aFileName = aDlg->GetFileName();
|
||||
delete aDlg;
|
||||
|
||||
POSITION pos = GetFirstViewPosition();
|
||||
while (pos != NULL)
|
||||
{
|
||||
COCCDemoView* pView = (COCCDemoView*) GetNextView(pos);
|
||||
pView->UpdateWindow();
|
||||
}
|
||||
|
||||
myViewer->InitActiveViews();
|
||||
Handle(V3d_View) aView = myViewer->ActiveView();
|
||||
char aStrFileName[MAX_PATH];
|
||||
strcpy_s(aStrFileName, aFileName);
|
||||
aView->Dump(aStrFileName);
|
||||
}
|
||||
else
|
||||
delete aDlg;
|
||||
|
||||
::GetCurrentDirectory(MAX_PATH, myLastPath);
|
||||
::SetCurrentDirectory(aCurPath);
|
||||
}
|
||||
|
||||
void COCCDemoDoc::Fit()
|
||||
{
|
||||
CMDIFrameWnd *pFrame = (CMDIFrameWnd*)AfxGetApp()->m_pMainWnd;
|
||||
CMDIChildWnd *pChild = (CMDIChildWnd *) pFrame->GetActiveFrame();
|
||||
COCCDemoView *pView = (COCCDemoView *) pChild->GetActiveView();
|
||||
pView->FitAll();
|
||||
}
|
89
samples/mfc/standard/10_Convert/src/WNT/OCCDemoDoc.h
Executable file
89
samples/mfc/standard/10_Convert/src/WNT/OCCDemoDoc.h
Executable file
@@ -0,0 +1,89 @@
|
||||
// OCCDemoDoc.h : interface of the COCCDemoDoc class
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_OCCDEMODOC_H__57A6A22E_7B4F_11D5_BA4A_0060B0EE18EA__INCLUDED_)
|
||||
#define AFX_OCCDEMODOC_H__57A6A22E_7B4F_11D5_BA4A_0060B0EE18EA__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
#include "ResultDialog.h"
|
||||
class OCCDemo_Presentation;
|
||||
|
||||
class COCCDemoDoc : public CDocument
|
||||
{
|
||||
public:
|
||||
Handle_V3d_Viewer GetViewer() const { return myViewer; };
|
||||
Handle_AIS_InteractiveContext GetAISContext() const { return myAISContext; };
|
||||
CResultDialog* GetResultDialog () {return &myCResultDialog;}
|
||||
Standard_CString GetDataDir() {return myDataDir;}
|
||||
|
||||
protected: // create from serialization only
|
||||
COCCDemoDoc();
|
||||
DECLARE_DYNCREATE(COCCDemoDoc)
|
||||
|
||||
// Attributes
|
||||
public:
|
||||
BOOL& IsShowResult() {return myShowResult;}
|
||||
|
||||
// Operations
|
||||
public:
|
||||
void Start();
|
||||
static void Fit();
|
||||
|
||||
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(COCCDemoDoc)
|
||||
public:
|
||||
virtual BOOL OnNewDocument();
|
||||
virtual void Serialize(CArchive& ar);
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
public:
|
||||
virtual ~COCCDemoDoc();
|
||||
#ifdef _DEBUG
|
||||
virtual void AssertValid() const;
|
||||
virtual void Dump(CDumpContext& dc) const;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
void InitViewButtons();
|
||||
void DoSample();
|
||||
|
||||
// Generated message map functions
|
||||
protected:
|
||||
//{{AFX_MSG(COCCDemoDoc)
|
||||
afx_msg void OnBUTTONNext();
|
||||
afx_msg void OnBUTTONStart();
|
||||
afx_msg void OnBUTTONRepeat();
|
||||
afx_msg void OnBUTTONPrev();
|
||||
afx_msg void OnBUTTONEnd();
|
||||
afx_msg void OnUpdateBUTTONNext(CCmdUI* pCmdUI);
|
||||
afx_msg void OnUpdateBUTTONPrev(CCmdUI* pCmdUI);
|
||||
afx_msg void OnFileNew();
|
||||
afx_msg void OnBUTTONShowResult();
|
||||
afx_msg void OnUpdateBUTTONShowResult(CCmdUI* pCmdUI);
|
||||
afx_msg void OnDumpView();
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
|
||||
private:
|
||||
Handle_V3d_Viewer myViewer;
|
||||
Handle_AIS_InteractiveContext myAISContext;
|
||||
OCCDemo_Presentation *myPresentation;
|
||||
CResultDialog myCResultDialog;
|
||||
BOOL myShowResult;
|
||||
char myDataDir[5]; // for "Data\0"
|
||||
char myLastPath[MAX_PATH]; // directory of lastly saved file in DumpView()
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//{{AFX_INSERT_LOCATION}}
|
||||
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
|
||||
|
||||
#endif // !defined(AFX_OCCDEMODOC_H__57A6A22E_7B4F_11D5_BA4A_0060B0EE18EA__INCLUDED_)
|
578
samples/mfc/standard/10_Convert/src/WNT/OCCDemoView.cpp
Executable file
578
samples/mfc/standard/10_Convert/src/WNT/OCCDemoView.cpp
Executable file
@@ -0,0 +1,578 @@
|
||||
// OCCDemoView.cpp : implementation of the COCCDemoView class
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "MainFrm.h"
|
||||
#include "OCCDemo.h"
|
||||
#include "OCCDemoDoc.h"
|
||||
#include "OCCDemoView.h"
|
||||
|
||||
#include <Graphic3d_GraphicDriver.hxx>
|
||||
|
||||
#define ValZWMin 1
|
||||
|
||||
#ifdef _DEBUG
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// COCCDemoView
|
||||
|
||||
IMPLEMENT_DYNCREATE(COCCDemoView, CView)
|
||||
|
||||
BEGIN_MESSAGE_MAP(COCCDemoView, CView)
|
||||
//{{AFX_MSG_MAP(COCCDemoView)
|
||||
ON_COMMAND(ID_BUTTONAxo, OnBUTTONAxo)
|
||||
ON_COMMAND(ID_BUTTONBack, OnBUTTONBack)
|
||||
ON_COMMAND(ID_BUTTONBottom, OnBUTTONBottom)
|
||||
ON_COMMAND(ID_BUTTONFront, OnBUTTONFront)
|
||||
ON_COMMAND(ID_BUTTONHlrOn, OnBUTTONHlrOn)
|
||||
ON_COMMAND(ID_BUTTONLeft, OnBUTTONLeft)
|
||||
ON_COMMAND(ID_BUTTONPan, OnBUTTONPan)
|
||||
ON_COMMAND(ID_BUTTONPanGlo, OnBUTTONPanGlo)
|
||||
ON_COMMAND(ID_BUTTONReset, OnBUTTONReset)
|
||||
ON_COMMAND(ID_BUTTONRight, OnBUTTONRight)
|
||||
ON_COMMAND(ID_BUTTONRot, OnBUTTONRot)
|
||||
ON_COMMAND(ID_BUTTONTop, OnBUTTONTop)
|
||||
ON_COMMAND(ID_BUTTONZoomAll, OnBUTTONZoomAll)
|
||||
ON_WM_SIZE()
|
||||
ON_COMMAND(ID_BUTTONZoomProg, OnBUTTONZoomProg)
|
||||
ON_COMMAND(ID_BUTTONZoomWin, OnBUTTONZoomWin)
|
||||
ON_WM_LBUTTONDOWN()
|
||||
ON_WM_LBUTTONUP()
|
||||
ON_WM_MOUSEMOVE()
|
||||
ON_WM_RBUTTONDOWN()
|
||||
ON_WM_RBUTTONUP()
|
||||
ON_UPDATE_COMMAND_UI(ID_BUTTONPanGlo, OnUpdateBUTTONPanGlo)
|
||||
ON_UPDATE_COMMAND_UI(ID_BUTTONPan, OnUpdateBUTTONPan)
|
||||
ON_UPDATE_COMMAND_UI(ID_BUTTONZoomProg, OnUpdateBUTTONZoomProg)
|
||||
ON_UPDATE_COMMAND_UI(ID_BUTTONZoomWin, OnUpdateBUTTONZoomWin)
|
||||
ON_UPDATE_COMMAND_UI(ID_BUTTONRot, OnUpdateBUTTONRot)
|
||||
ON_COMMAND(ID_BUTTONWire, OnBUTTONWire)
|
||||
ON_COMMAND(ID_BUTTONShade, OnBUTTONShade)
|
||||
ON_UPDATE_COMMAND_UI(ID_BUTTONHlrOn, OnUpdateBUTTONHlrOn)
|
||||
ON_UPDATE_COMMAND_UI(ID_BUTTONShade, OnUpdateBUTTONShade)
|
||||
ON_UPDATE_COMMAND_UI(ID_BUTTONWire, OnUpdateBUTTONWire)
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// COCCDemoView construction/destruction
|
||||
|
||||
COCCDemoView::COCCDemoView()
|
||||
{
|
||||
myXmin=0;
|
||||
myYmin=0;
|
||||
myXmax=0;
|
||||
myYmax=0;
|
||||
myCurZoom=0;
|
||||
myCurrentMode = CurAction3d_Nothing;
|
||||
myVisMode = VIS_SHADE;
|
||||
m_Pen = NULL;
|
||||
myGraphicDriver = Handle(Graphic3d_GraphicDriver)::DownCast(
|
||||
((COCCDemoApp*)AfxGetApp())->GetGraphicDevice()->GraphicDriver() );
|
||||
}
|
||||
|
||||
COCCDemoView::~COCCDemoView()
|
||||
{
|
||||
if (!myView.IsNull())
|
||||
myView->Remove();
|
||||
if (m_Pen)
|
||||
delete m_Pen;
|
||||
}
|
||||
|
||||
BOOL COCCDemoView::PreCreateWindow(CREATESTRUCT& cs)
|
||||
{
|
||||
// TODO: Modify the Window class or styles here by modifying
|
||||
// the CREATESTRUCT cs
|
||||
|
||||
return CView::PreCreateWindow(cs);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// COCCDemoView drawing
|
||||
|
||||
void COCCDemoView::OnInitialUpdate()
|
||||
{
|
||||
CView::OnInitialUpdate();
|
||||
|
||||
myView = GetDocument()->GetViewer()->CreateView();
|
||||
|
||||
Handle(Graphic3d_WNTGraphicDevice) theGraphicDevice =
|
||||
((COCCDemoApp*)AfxGetApp())->GetGraphicDevice();
|
||||
|
||||
Handle(WNT_Window) aWNTWindow = new WNT_Window(theGraphicDevice,GetSafeHwnd ());
|
||||
myView->SetWindow(aWNTWindow);
|
||||
if (!aWNTWindow->IsMapped()) aWNTWindow->Map();
|
||||
|
||||
myCurrentMode = CurAction3d_Nothing;
|
||||
myVisMode = VIS_SHADE;
|
||||
RedrawVisMode();
|
||||
}
|
||||
|
||||
void COCCDemoView::OnDraw(CDC* pDC)
|
||||
{
|
||||
COCCDemoDoc* pDoc = GetDocument();
|
||||
ASSERT_VALID(pDoc);
|
||||
// TODO: add draw code for native data here
|
||||
myView->Redraw();
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// COCCDemoView diagnostics
|
||||
|
||||
#ifdef _DEBUG
|
||||
void COCCDemoView::AssertValid() const
|
||||
{
|
||||
CView::AssertValid();
|
||||
}
|
||||
|
||||
void COCCDemoView::Dump(CDumpContext& dc) const
|
||||
{
|
||||
CView::Dump(dc);
|
||||
}
|
||||
|
||||
COCCDemoDoc* COCCDemoView::GetDocument() // non-debug version is inline
|
||||
{
|
||||
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(COCCDemoDoc)));
|
||||
return (COCCDemoDoc*)m_pDocument;
|
||||
}
|
||||
#endif //_DEBUG
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// COCCDemoView message handlers
|
||||
|
||||
void COCCDemoView::OnSize(UINT nType, int cx, int cy)
|
||||
{
|
||||
if (!myView.IsNull())
|
||||
myView->MustBeResized();
|
||||
}
|
||||
|
||||
void COCCDemoView::OnBUTTONBack()
|
||||
{
|
||||
myView->SetProj(V3d_Ypos);
|
||||
}
|
||||
|
||||
void COCCDemoView::OnBUTTONFront()
|
||||
{
|
||||
myView->SetProj(V3d_Yneg);
|
||||
}
|
||||
|
||||
void COCCDemoView::OnBUTTONBottom()
|
||||
{
|
||||
myView->SetProj(V3d_Zneg);
|
||||
}
|
||||
|
||||
void COCCDemoView::OnBUTTONTop()
|
||||
{
|
||||
myView->SetProj(V3d_Zpos);
|
||||
}
|
||||
|
||||
void COCCDemoView::OnBUTTONLeft()
|
||||
{
|
||||
myView->SetProj(V3d_Xneg);
|
||||
}
|
||||
|
||||
void COCCDemoView::OnBUTTONRight()
|
||||
{
|
||||
myView->SetProj(V3d_Xpos);
|
||||
}
|
||||
|
||||
void COCCDemoView::OnBUTTONAxo()
|
||||
{
|
||||
myView->SetProj(V3d_XposYnegZpos);
|
||||
}
|
||||
|
||||
void COCCDemoView::OnBUTTONPan()
|
||||
{
|
||||
myCurrentMode = CurAction3d_DynamicPanning;
|
||||
}
|
||||
|
||||
void COCCDemoView::OnBUTTONPanGlo()
|
||||
{
|
||||
// save the current zoom value
|
||||
myCurZoom = myView->Scale();
|
||||
// Do a Global Zoom
|
||||
myView->FitAll();
|
||||
// Set the mode
|
||||
myCurrentMode = CurAction3d_GlobalPanning;
|
||||
}
|
||||
|
||||
void COCCDemoView::OnBUTTONReset()
|
||||
{
|
||||
myView->Reset();
|
||||
}
|
||||
|
||||
void COCCDemoView::OnBUTTONRot()
|
||||
{
|
||||
myCurrentMode = CurAction3d_DynamicRotation;
|
||||
}
|
||||
|
||||
void COCCDemoView::OnBUTTONZoomAll()
|
||||
{
|
||||
myView->FitAll();
|
||||
myView->ZFitAll();
|
||||
}
|
||||
|
||||
void COCCDemoView::OnBUTTONZoomProg()
|
||||
{
|
||||
myCurrentMode = CurAction3d_DynamicZooming;
|
||||
}
|
||||
|
||||
void COCCDemoView::OnBUTTONZoomWin()
|
||||
{
|
||||
myCurrentMode = CurAction3d_WindowZooming;
|
||||
}
|
||||
|
||||
void COCCDemoView::OnLButtonDown(UINT nFlags, CPoint point)
|
||||
{
|
||||
// save the current mouse coordinate in min
|
||||
myXmin=point.x; myYmin=point.y;
|
||||
myXmax=point.x; myYmax=point.y;
|
||||
|
||||
if ( ! (nFlags & MK_CONTROL) )
|
||||
{
|
||||
if (myCurrentMode == CurAction3d_DynamicRotation)
|
||||
{
|
||||
myView->SetComputedMode(Standard_False);
|
||||
myView->StartRotation(point.x,point.y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void COCCDemoView::OnLButtonUp(UINT nFlags, CPoint point)
|
||||
{
|
||||
if ( !(nFlags & MK_CONTROL) )
|
||||
{
|
||||
switch (myCurrentMode)
|
||||
{
|
||||
case CurAction3d_Nothing :
|
||||
myXmax=point.x;
|
||||
myYmax=point.y;
|
||||
break;
|
||||
case CurAction3d_DynamicZooming :
|
||||
myCurrentMode = CurAction3d_Nothing;
|
||||
break;
|
||||
case CurAction3d_WindowZooming :
|
||||
DrawRectangle(myXmin,myYmin,myXmax,myYmax,Standard_False);
|
||||
myXmax=point.x;
|
||||
myYmax=point.y;
|
||||
if ((abs(myXmin-myXmax)>ValZWMin) || (abs(myYmin-myYmax)>ValZWMin))
|
||||
// Test if the zoom window is greater than a minimale window.
|
||||
{
|
||||
// Do the zoom window between Pmin and Pmax
|
||||
myView->WindowFitAll(myXmin,myYmin,myXmax,myYmax);
|
||||
}
|
||||
myCurrentMode = CurAction3d_Nothing;
|
||||
break;
|
||||
case CurAction3d_DynamicPanning :
|
||||
myCurrentMode = CurAction3d_Nothing;
|
||||
break;
|
||||
case CurAction3d_GlobalPanning :
|
||||
myView->Place(point.x,point.y,myCurZoom);
|
||||
myCurrentMode = CurAction3d_Nothing;
|
||||
break;
|
||||
case CurAction3d_DynamicRotation :
|
||||
if (myVisMode == VIS_HLR)
|
||||
{
|
||||
SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT));
|
||||
myView->SetComputedMode(Standard_True);
|
||||
SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW));
|
||||
}
|
||||
myCurrentMode = CurAction3d_Nothing;
|
||||
break;
|
||||
} //switch (myCurrentMode)
|
||||
}
|
||||
}
|
||||
|
||||
void COCCDemoView::OnRButtonDown(UINT nFlags, CPoint point)
|
||||
{
|
||||
if ( nFlags & MK_CONTROL )
|
||||
{
|
||||
myView->SetComputedMode(Standard_False);
|
||||
myView->StartRotation(point.x,point.y);
|
||||
}
|
||||
}
|
||||
|
||||
void COCCDemoView::OnRButtonUp(UINT nFlags, CPoint point)
|
||||
{
|
||||
if (myVisMode == VIS_HLR)
|
||||
{
|
||||
SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT));
|
||||
myView->SetComputedMode(Standard_True);
|
||||
SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW));
|
||||
}
|
||||
}
|
||||
|
||||
void COCCDemoView::OnMouseMove(UINT nFlags, CPoint point)
|
||||
{
|
||||
// ============================ LEFT BUTTON =======================
|
||||
if ( nFlags & MK_LBUTTON)
|
||||
{
|
||||
if ( nFlags & MK_CONTROL )
|
||||
{
|
||||
// move with MB1 and Control : on the dynamic zooming
|
||||
// Do the zoom in function of mouse's coordinates
|
||||
myView->Zoom(myXmax,myYmax,point.x,point.y);
|
||||
// save the current mouse coordinate in max
|
||||
myXmax = point.x;
|
||||
myYmax = point.y;
|
||||
}
|
||||
else // if ( Ctrl )
|
||||
{
|
||||
switch (myCurrentMode)
|
||||
{
|
||||
case CurAction3d_Nothing :
|
||||
myXmax = point.x;
|
||||
myYmax = point.y;
|
||||
break;
|
||||
case CurAction3d_DynamicZooming :
|
||||
myView->Zoom(myXmax,myYmax,point.x,point.y);
|
||||
// save the current mouse coordinate in max;
|
||||
myXmax=point.x;
|
||||
myYmax=point.y;
|
||||
break;
|
||||
case CurAction3d_WindowZooming :
|
||||
myXmax = point.x; myYmax = point.y;
|
||||
DrawRectangle(myXmin,myYmin,myXmax,myYmax,Standard_False,LongDash);
|
||||
DrawRectangle(myXmin,myYmin,myXmax,myYmax,Standard_True,LongDash);
|
||||
break;
|
||||
case CurAction3d_DynamicPanning :
|
||||
myView->Pan(point.x-myXmax,myYmax-point.y); // Realize the panning
|
||||
myXmax = point.x; myYmax = point.y;
|
||||
break;
|
||||
case CurAction3d_GlobalPanning : // nothing
|
||||
break;
|
||||
case CurAction3d_DynamicRotation :
|
||||
myView->Rotation(point.x,point.y);
|
||||
myView->Redraw();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// ============================ MIDDLE BUTTON =======================
|
||||
else if ( nFlags & MK_MBUTTON)
|
||||
{
|
||||
if ( nFlags & MK_CONTROL )
|
||||
{
|
||||
myView->Pan(point.x-myXmax,myYmax-point.y); // Realize the panning
|
||||
myXmax = point.x; myYmax = point.y;
|
||||
}
|
||||
}
|
||||
// ============================ RIGHT BUTTON =======================
|
||||
else if ( nFlags & MK_RBUTTON)
|
||||
{
|
||||
if ( nFlags & MK_CONTROL )
|
||||
{
|
||||
myView->Rotation(point.x,point.y);
|
||||
}
|
||||
}
|
||||
// ============================ NO BUTTON =======================
|
||||
else
|
||||
{
|
||||
myXmax = point.x;
|
||||
myYmax = point.y;
|
||||
}
|
||||
}
|
||||
|
||||
void COCCDemoView::OnUpdateBUTTONPanGlo(CCmdUI* pCmdUI)
|
||||
{
|
||||
pCmdUI->SetCheck (myCurrentMode == CurAction3d_GlobalPanning);
|
||||
pCmdUI->Enable (myCurrentMode != CurAction3d_GlobalPanning);
|
||||
}
|
||||
|
||||
void COCCDemoView::OnUpdateBUTTONPan(CCmdUI* pCmdUI)
|
||||
{
|
||||
pCmdUI->SetCheck (myCurrentMode == CurAction3d_DynamicPanning);
|
||||
pCmdUI->Enable (myCurrentMode != CurAction3d_DynamicPanning );
|
||||
}
|
||||
|
||||
void COCCDemoView::OnUpdateBUTTONZoomProg(CCmdUI* pCmdUI)
|
||||
{
|
||||
pCmdUI->SetCheck (myCurrentMode == CurAction3d_DynamicZooming );
|
||||
pCmdUI->Enable (myCurrentMode != CurAction3d_DynamicZooming);
|
||||
}
|
||||
|
||||
void COCCDemoView::OnUpdateBUTTONZoomWin(CCmdUI* pCmdUI)
|
||||
{
|
||||
pCmdUI->SetCheck (myCurrentMode == CurAction3d_WindowZooming);
|
||||
pCmdUI->Enable (myCurrentMode != CurAction3d_WindowZooming);
|
||||
}
|
||||
|
||||
void COCCDemoView::OnUpdateBUTTONRot(CCmdUI* pCmdUI)
|
||||
{
|
||||
pCmdUI->SetCheck (myCurrentMode == CurAction3d_DynamicRotation);
|
||||
pCmdUI->Enable (myCurrentMode != CurAction3d_DynamicRotation);
|
||||
}
|
||||
|
||||
void COCCDemoView::DrawRectangle(const Standard_Integer MinX,
|
||||
const Standard_Integer MinY,
|
||||
const Standard_Integer MaxX,
|
||||
const Standard_Integer MaxY,
|
||||
const Standard_Boolean Draw,
|
||||
const LineStyle aLineStyle)
|
||||
{
|
||||
static int m_DrawMode;
|
||||
if (!m_Pen && aLineStyle ==Solid )
|
||||
{
|
||||
m_Pen = new CPen(PS_SOLID, 1, RGB(0,0,0)); m_DrawMode = R2_MERGEPENNOT;
|
||||
}
|
||||
else if (!m_Pen && aLineStyle ==Dot )
|
||||
{
|
||||
m_Pen = new CPen(PS_DOT, 1, RGB(0,0,0)); m_DrawMode = R2_XORPEN;
|
||||
}
|
||||
else if (!m_Pen && aLineStyle == ShortDash)
|
||||
{
|
||||
m_Pen = new CPen(PS_DASH, 1, RGB(255,0,0)); m_DrawMode = R2_XORPEN;
|
||||
}
|
||||
else if (!m_Pen && aLineStyle == LongDash)
|
||||
{
|
||||
m_Pen = new CPen(PS_DASH, 1, RGB(0,0,0)); m_DrawMode = R2_NOTXORPEN;
|
||||
}
|
||||
else if (aLineStyle == Default)
|
||||
{
|
||||
m_Pen = NULL; m_DrawMode = R2_MERGEPENNOT;
|
||||
}
|
||||
|
||||
CPen* aOldPen;
|
||||
CClientDC clientDC(this);
|
||||
if (m_Pen)
|
||||
aOldPen = clientDC.SelectObject(m_Pen);
|
||||
clientDC.SetROP2(m_DrawMode);
|
||||
|
||||
static Standard_Integer StoredMinX, StoredMaxX, StoredMinY, StoredMaxY;
|
||||
static Standard_Boolean m_IsVisible = Standard_False;
|
||||
|
||||
if ( m_IsVisible && !Draw) // move or up : erase at the old position
|
||||
{
|
||||
clientDC.MoveTo(StoredMinX,StoredMinY); clientDC.LineTo(StoredMinX,StoredMaxY);
|
||||
clientDC.LineTo(StoredMaxX,StoredMaxY);
|
||||
clientDC.LineTo(StoredMaxX,StoredMinY); clientDC.LineTo(StoredMinX,StoredMinY);
|
||||
m_IsVisible = false;
|
||||
}
|
||||
|
||||
StoredMinX = min ( MinX, MaxX );
|
||||
StoredMinY = min ( MinY, MaxY );
|
||||
StoredMaxX = max ( MinX, MaxX );
|
||||
StoredMaxY = max ( MinY, MaxY);
|
||||
|
||||
if (Draw) // move : draw
|
||||
{
|
||||
clientDC.MoveTo(StoredMinX,StoredMinY); clientDC.LineTo(StoredMinX,StoredMaxY);
|
||||
clientDC.LineTo(StoredMaxX,StoredMaxY);
|
||||
clientDC.LineTo(StoredMaxX,StoredMinY); clientDC.LineTo(StoredMinX,StoredMinY);
|
||||
m_IsVisible = true;
|
||||
}
|
||||
|
||||
if (m_Pen)
|
||||
clientDC.SelectObject(aOldPen);
|
||||
}
|
||||
|
||||
void COCCDemoView::InitButtons()
|
||||
{
|
||||
myXmin=0;
|
||||
myYmin=0;
|
||||
myXmax=0;
|
||||
myYmax=0;
|
||||
myCurZoom=0;
|
||||
myCurrentMode = CurAction3d_Nothing;
|
||||
}
|
||||
|
||||
void COCCDemoView::Reset()
|
||||
{
|
||||
InitButtons();
|
||||
myVisMode = VIS_SHADE;
|
||||
if (!myView.IsNull())
|
||||
{
|
||||
RedrawVisMode();
|
||||
myView->Reset();
|
||||
}
|
||||
}
|
||||
|
||||
void COCCDemoView::RedrawVisMode()
|
||||
{
|
||||
switch (myVisMode)
|
||||
{
|
||||
case VIS_WIREFRAME:
|
||||
GetDocument()->GetAISContext()->SetDisplayMode(AIS_WireFrame);
|
||||
myView->SetComputedMode (Standard_False);
|
||||
break;
|
||||
case VIS_SHADE:
|
||||
GetDocument()->GetAISContext()->SetDisplayMode(AIS_Shaded);
|
||||
myView->SetComputedMode (Standard_False);
|
||||
break;
|
||||
case VIS_HLR:
|
||||
SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT));
|
||||
myView->SetComputedMode (Standard_True);
|
||||
SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW));
|
||||
GetDocument()->GetAISContext()->SetDisplayMode(AIS_WireFrame);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void COCCDemoView::OnBUTTONWire()
|
||||
{
|
||||
myVisMode = VIS_WIREFRAME;
|
||||
RedrawVisMode();
|
||||
}
|
||||
|
||||
void COCCDemoView::OnBUTTONShade()
|
||||
{
|
||||
myVisMode = VIS_SHADE;
|
||||
RedrawVisMode();
|
||||
}
|
||||
|
||||
void COCCDemoView::OnBUTTONHlrOn()
|
||||
{
|
||||
myVisMode = VIS_HLR;
|
||||
RedrawVisMode();
|
||||
}
|
||||
|
||||
void COCCDemoView::OnUpdateBUTTONWire(CCmdUI* pCmdUI)
|
||||
{
|
||||
pCmdUI->SetCheck (myVisMode == VIS_WIREFRAME);
|
||||
pCmdUI->Enable (myVisMode != VIS_WIREFRAME);
|
||||
}
|
||||
|
||||
void COCCDemoView::OnUpdateBUTTONShade(CCmdUI* pCmdUI)
|
||||
{
|
||||
pCmdUI->SetCheck (myVisMode == VIS_SHADE);
|
||||
pCmdUI->Enable (myVisMode != VIS_SHADE);
|
||||
}
|
||||
|
||||
void COCCDemoView::OnUpdateBUTTONHlrOn(CCmdUI* pCmdUI)
|
||||
{
|
||||
pCmdUI->SetCheck (myVisMode == VIS_HLR);
|
||||
pCmdUI->Enable (myVisMode != VIS_HLR);
|
||||
}
|
||||
|
||||
void COCCDemoView::GetViewCenter(V3d_Coordinate& Xc, V3d_Coordinate& Yc)
|
||||
{
|
||||
myView->Center(Xc,Yc);
|
||||
}
|
||||
|
||||
void COCCDemoView::SetViewCenter(V3d_Coordinate Xc, V3d_Coordinate Yc)
|
||||
{
|
||||
myView->SetCenter(Xc,Yc);
|
||||
}
|
||||
|
||||
void COCCDemoView::GetViewEye(V3d_Coordinate& X, V3d_Coordinate& Y, V3d_Coordinate& Z)
|
||||
{
|
||||
myView->Eye(X,Y,Z);
|
||||
}
|
||||
|
||||
void COCCDemoView::SetViewEye(V3d_Coordinate X, V3d_Coordinate Y, V3d_Coordinate Z)
|
||||
{
|
||||
myView->SetEye(X,Y,Z);
|
||||
}
|
||||
|
||||
Quantity_Factor COCCDemoView::GetViewScale()
|
||||
{
|
||||
return myView->Scale();
|
||||
}
|
||||
|
||||
void COCCDemoView::SetViewScale(Quantity_Factor Coef)
|
||||
{
|
||||
myView->SetScale(Coef);
|
||||
}
|
138
samples/mfc/standard/10_Convert/src/WNT/OCCDemoView.h
Executable file
138
samples/mfc/standard/10_Convert/src/WNT/OCCDemoView.h
Executable file
@@ -0,0 +1,138 @@
|
||||
// OCCDemoView.h : interface of the COCCDemoView class
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_OCCDEMOVIEW_H__57A6A230_7B4F_11D5_BA4A_0060B0EE18EA__INCLUDED_)
|
||||
#define AFX_OCCDEMOVIEW_H__57A6A230_7B4F_11D5_BA4A_0060B0EE18EA__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
enum View3D_CurrentAction {
|
||||
CurAction3d_Nothing,
|
||||
CurAction3d_DynamicZooming,
|
||||
CurAction3d_WindowZooming,
|
||||
CurAction3d_DynamicPanning,
|
||||
CurAction3d_GlobalPanning,
|
||||
CurAction3d_DynamicRotation
|
||||
};
|
||||
|
||||
class COCCDemoView : public CView
|
||||
{
|
||||
protected: // create from serialization only
|
||||
COCCDemoView();
|
||||
DECLARE_DYNCREATE(COCCDemoView)
|
||||
|
||||
// Attributes
|
||||
public:
|
||||
COCCDemoDoc* GetDocument();
|
||||
void FitAll() { myView->FitAll(); myView->ZFitAll(); };
|
||||
void GetViewCenter(V3d_Coordinate& Xc, V3d_Coordinate& Yc);
|
||||
void SetViewCenter(const V3d_Coordinate Xc, const V3d_Coordinate Yc);
|
||||
void GetViewEye(V3d_Coordinate& X, V3d_Coordinate& Y, V3d_Coordinate& Z);
|
||||
void SetViewEye(const V3d_Coordinate X,const V3d_Coordinate Y,const V3d_Coordinate Z);
|
||||
Quantity_Factor GetViewScale();
|
||||
void SetViewScale(const Quantity_Factor Coef);
|
||||
|
||||
|
||||
// Operations
|
||||
public:
|
||||
void InitButtons();
|
||||
void Reset();
|
||||
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(COCCDemoView)
|
||||
public:
|
||||
virtual void OnDraw(CDC* pDC); // overridden to draw this view
|
||||
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
|
||||
virtual void OnInitialUpdate();
|
||||
protected:
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
public:
|
||||
virtual ~COCCDemoView();
|
||||
#ifdef _DEBUG
|
||||
virtual void AssertValid() const;
|
||||
virtual void Dump(CDumpContext& dc) const;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
|
||||
// Generated message map functions
|
||||
protected:
|
||||
//{{AFX_MSG(COCCDemoView)
|
||||
afx_msg void OnBUTTONAxo();
|
||||
afx_msg void OnBUTTONBack();
|
||||
afx_msg void OnBUTTONBottom();
|
||||
afx_msg void OnBUTTONFront();
|
||||
afx_msg void OnBUTTONHlrOn();
|
||||
afx_msg void OnBUTTONLeft();
|
||||
afx_msg void OnBUTTONPan();
|
||||
afx_msg void OnBUTTONPanGlo();
|
||||
afx_msg void OnBUTTONReset();
|
||||
afx_msg void OnBUTTONRight();
|
||||
afx_msg void OnBUTTONRot();
|
||||
afx_msg void OnBUTTONTop();
|
||||
afx_msg void OnBUTTONZoomAll();
|
||||
afx_msg void OnSize(UINT nType, int cx, int cy);
|
||||
afx_msg void OnBUTTONZoomProg();
|
||||
afx_msg void OnBUTTONZoomWin();
|
||||
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
|
||||
afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
|
||||
afx_msg void OnMouseMove(UINT nFlags, CPoint point);
|
||||
afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
|
||||
afx_msg void OnRButtonUp(UINT nFlags, CPoint point);
|
||||
afx_msg void OnUpdateBUTTONPanGlo(CCmdUI* pCmdUI);
|
||||
afx_msg void OnUpdateBUTTONPan(CCmdUI* pCmdUI);
|
||||
afx_msg void OnUpdateBUTTONZoomProg(CCmdUI* pCmdUI);
|
||||
afx_msg void OnUpdateBUTTONZoomWin(CCmdUI* pCmdUI);
|
||||
afx_msg void OnUpdateBUTTONRot(CCmdUI* pCmdUI);
|
||||
afx_msg void OnBUTTONWire();
|
||||
afx_msg void OnBUTTONShade();
|
||||
afx_msg void OnUpdateBUTTONHlrOn(CCmdUI* pCmdUI);
|
||||
afx_msg void OnUpdateBUTTONShade(CCmdUI* pCmdUI);
|
||||
afx_msg void OnUpdateBUTTONWire(CCmdUI* pCmdUI);
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
|
||||
private:
|
||||
void RedrawVisMode();
|
||||
|
||||
private:
|
||||
enum VisMode { VIS_WIREFRAME, VIS_SHADE, VIS_HLR };
|
||||
Handle_V3d_View myView;
|
||||
Handle_Graphic3d_GraphicDriver myGraphicDriver;
|
||||
View3D_CurrentAction myCurrentMode;
|
||||
VisMode myVisMode;
|
||||
Standard_Integer myXmin;
|
||||
Standard_Integer myYmin;
|
||||
Standard_Integer myXmax;
|
||||
Standard_Integer myYmax;
|
||||
Quantity_Factor myCurZoom;
|
||||
|
||||
private:
|
||||
enum LineStyle { Solid, Dot, ShortDash, LongDash, Default };
|
||||
CPen* m_Pen;
|
||||
virtual void DrawRectangle (const Standard_Integer MinX ,
|
||||
const Standard_Integer MinY ,
|
||||
const Standard_Integer MaxX ,
|
||||
const Standard_Integer MaxY ,
|
||||
const Standard_Boolean Draw ,
|
||||
const LineStyle aLineStyle = Default );
|
||||
|
||||
};
|
||||
|
||||
#ifndef _DEBUG // debug version in OCCDemoView.cpp
|
||||
inline COCCDemoDoc* COCCDemoView::GetDocument()
|
||||
{ return (COCCDemoDoc*)m_pDocument; }
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//{{AFX_INSERT_LOCATION}}
|
||||
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
|
||||
|
||||
#endif // !defined(AFX_OCCDEMOVIEW_H__57A6A230_7B4F_11D5_BA4A_0060B0EE18EA__INCLUDED_)
|
206
samples/mfc/standard/10_Convert/src/WNT/ResultDialog.cpp
Executable file
206
samples/mfc/standard/10_Convert/src/WNT/ResultDialog.cpp
Executable file
@@ -0,0 +1,206 @@
|
||||
// ResultDialog.cpp : implementation file
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "OCCDemo.h"
|
||||
#include "ResultDialog.h"
|
||||
#include "MainFrm.h"
|
||||
#include "OCCDemoDoc.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
|
||||
// minimum distance between buttons, button and dialog border
|
||||
#define d 5
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CResultDialog dialog
|
||||
|
||||
|
||||
CResultDialog::CResultDialog(CWnd* pParent /*=NULL*/)
|
||||
: CDialog(CResultDialog::IDD, pParent)
|
||||
{
|
||||
//{{AFX_DATA_INIT(CResultDialog)
|
||||
// NOTE: the ClassWizard will add member initialization here
|
||||
//}}AFX_DATA_INIT
|
||||
}
|
||||
|
||||
void CResultDialog::Empty()
|
||||
{
|
||||
CRichEditCtrl *pEd = (CRichEditCtrl *) GetDlgItem (IDC_RICHEDIT_ResultDialog);
|
||||
pEd->Clear();
|
||||
}
|
||||
|
||||
void CResultDialog::SetText(LPCSTR aText)
|
||||
{
|
||||
CRichEditCtrl *pEd = (CRichEditCtrl *) GetDlgItem (IDC_RICHEDIT_ResultDialog);
|
||||
CString aCStr(aText);
|
||||
pEd->SetWindowText(aCStr);
|
||||
}
|
||||
|
||||
void CResultDialog::SetTitle(LPCSTR aTitle)
|
||||
{
|
||||
CString aCStr(aTitle);
|
||||
SetWindowText(aCStr);
|
||||
}
|
||||
|
||||
void CResultDialog::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialog::DoDataExchange(pDX);
|
||||
//{{AFX_DATA_MAP(CResultDialog)
|
||||
// NOTE: the ClassWizard will add DDX and DDV calls here
|
||||
//}}AFX_DATA_MAP
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(CResultDialog, CDialog)
|
||||
//{{AFX_MSG_MAP(CResultDialog)
|
||||
ON_BN_CLICKED(IDC_CopySelectionToClipboard, OnCopySelectionToClipboard)
|
||||
ON_BN_CLICKED(IDC_CopyAllToClipboard, OnCopyAllToClipboard)
|
||||
ON_WM_SIZE()
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CResultDialog message handlers
|
||||
|
||||
void CResultDialog::OnCopySelectionToClipboard()
|
||||
{
|
||||
CRichEditCtrl *pEd = (CRichEditCtrl *) GetDlgItem (IDC_RICHEDIT_ResultDialog);
|
||||
pEd->Copy( );
|
||||
}
|
||||
|
||||
void CResultDialog::OnCopyAllToClipboard()
|
||||
{
|
||||
CRichEditCtrl *pEd = (CRichEditCtrl *) GetDlgItem (IDC_RICHEDIT_ResultDialog);
|
||||
long nStartChar, nEndChar;
|
||||
pEd->GetSel (nStartChar, nEndChar);
|
||||
pEd->SetSel (0, -1);
|
||||
pEd->Copy();
|
||||
pEd->SetSel (nStartChar, nEndChar);
|
||||
}
|
||||
|
||||
void CResultDialog::OnCancel()
|
||||
{
|
||||
CMainFrame* cFrame = (CMainFrame*) AfxGetApp()->GetMainWnd();
|
||||
COCCDemoDoc* aDoc = (COCCDemoDoc*) cFrame->GetActiveDocument();
|
||||
aDoc->IsShowResult() = FALSE;
|
||||
|
||||
CDialog::OnCancel();
|
||||
}
|
||||
|
||||
void CResultDialog::Initialize()
|
||||
{
|
||||
// Set Fixed Width Font for rich edit control
|
||||
CRichEditCtrl *pEd = (CRichEditCtrl *) GetDlgItem (IDC_RICHEDIT_ResultDialog);
|
||||
CFont aFixedWidthFont;
|
||||
VERIFY(aFixedWidthFont.CreateFont(
|
||||
15, // nHeight
|
||||
5, // nWidth
|
||||
0, // nEscapement
|
||||
0, // nOrientation
|
||||
FW_NORMAL, // nWeight
|
||||
FALSE, // bItalic
|
||||
FALSE, // bUnderline
|
||||
0, // cStrikeOut
|
||||
ANSI_CHARSET, // nCharSet
|
||||
OUT_DEFAULT_PRECIS, // nOutPrecision
|
||||
CLIP_DEFAULT_PRECIS, // nClipPrecision
|
||||
DEFAULT_QUALITY, // nQuality
|
||||
FF_MODERN, // Fix width fonts are FF_MODERN
|
||||
"Courier New")); // lpszFacename
|
||||
pEd->SetFont(&aFixedWidthFont, false);
|
||||
|
||||
// save button's width and height, so they are calculated only once
|
||||
RECT rect;
|
||||
CWnd *pBCopy = (CWnd *) GetDlgItem (IDC_CopySelectionToClipboard);
|
||||
pBCopy->GetWindowRect(&rect);
|
||||
bw = rect.right - rect.left; // a button's width (they are all equal)
|
||||
bh = rect.bottom - rect.top; // a button's height
|
||||
}
|
||||
|
||||
|
||||
// OnSize is a message handler of WM_SIZE messge,
|
||||
// it is reimplemented in order to reposition the buttons
|
||||
// (keep them always in the bottom part of the dialog)
|
||||
// and resize the rich edit controls as user resized THIS dialog.
|
||||
void CResultDialog::OnSize(UINT nType, int cx, int cy)
|
||||
{
|
||||
// call the base class handler
|
||||
CDialog::OnSize(nType, cx, cy);
|
||||
|
||||
//resizes internal GUI controls (rich edit control and 3 buttons)
|
||||
//according to given values of this dialog width (cx) and height (cy).
|
||||
//the method is called from OnSize message handler and
|
||||
//from InitInstance of OCCDemo to do initial resize
|
||||
CWnd *pEd = (CWnd *) GetDlgItem (IDC_RICHEDIT_ResultDialog);
|
||||
CWnd *pBCopy = (CWnd *) GetDlgItem (IDC_CopySelectionToClipboard);
|
||||
CWnd *pBCopyAll = (CWnd *) GetDlgItem (IDC_CopyAllToClipboard);
|
||||
CWnd *pBClose = (CWnd *) GetDlgItem (IDCANCEL);
|
||||
|
||||
if (pEd != NULL) // it is NULL when dialog is being created and OnSize is called
|
||||
{
|
||||
int butY = cy-bh-d; // y coordinate of buttons' top left corner
|
||||
|
||||
pEd->SetWindowPos(&wndTop, 0, 0, cx, butY-4*d, SWP_NOMOVE);
|
||||
pBCopy->SetWindowPos(&wndTop, d, butY, 0, 0, SWP_NOSIZE);
|
||||
pBCopyAll->SetWindowPos(&wndTop, d+bw+d, butY, 0, 0, SWP_NOSIZE);
|
||||
pBClose->SetWindowPos(&wndTop, cx-bw-d, butY, 0, 0, SWP_NOSIZE);
|
||||
}
|
||||
|
||||
RedrawWindow();
|
||||
}
|
||||
|
||||
LRESULT CResultDialog::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
if (message != WM_SIZING)
|
||||
return CDialog::WindowProc(message, wParam, lParam);
|
||||
|
||||
LPRECT pRect = (LPRECT) lParam;
|
||||
int cx = pRect->right - pRect->left;
|
||||
int cy = pRect->bottom - pRect->top;
|
||||
|
||||
int minCx = 3*bw+5*d;
|
||||
int minCy = 2*d+bh+200;
|
||||
|
||||
if (cx < minCx || cy < minCy)
|
||||
{
|
||||
switch (wParam)
|
||||
{
|
||||
case WMSZ_BOTTOM:
|
||||
pRect->bottom = pRect->top + minCy;
|
||||
break;
|
||||
case WMSZ_TOP:
|
||||
pRect->top = pRect->bottom - minCy;
|
||||
break;
|
||||
case WMSZ_LEFT:
|
||||
pRect->left = pRect->right - minCx;
|
||||
break;
|
||||
case WMSZ_RIGHT:
|
||||
pRect->right = pRect->left + minCx;
|
||||
break;
|
||||
case WMSZ_TOPLEFT:
|
||||
if (cx < minCx) pRect->left = pRect->right - minCx;
|
||||
if (cy < minCy) pRect->top = pRect->bottom - minCy;
|
||||
break;
|
||||
case WMSZ_BOTTOMRIGHT:
|
||||
if (cx < minCx) pRect->right = pRect->left + minCx;
|
||||
if (cy < minCy) pRect->bottom = pRect->top + minCy;
|
||||
break;
|
||||
case WMSZ_TOPRIGHT:
|
||||
if (cx < minCx) pRect->right = pRect->left + minCx;
|
||||
if (cy < minCy) pRect->top = pRect->bottom - minCy;
|
||||
break;
|
||||
case WMSZ_BOTTOMLEFT:
|
||||
if (cx < minCx) pRect->left = pRect->right - minCx;
|
||||
if (cy < minCy) pRect->bottom = pRect->top + minCy;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return CDialog::WindowProc(message, wParam, lParam);
|
||||
}
|
||||
|
67
samples/mfc/standard/10_Convert/src/WNT/ResultDialog.h
Executable file
67
samples/mfc/standard/10_Convert/src/WNT/ResultDialog.h
Executable file
@@ -0,0 +1,67 @@
|
||||
#if !defined(AFX_RESULTDIALOG_H__6597303D_7F5B_11D5_BA4D_0060B0EE18EA__INCLUDED_)
|
||||
#define AFX_RESULTDIALOG_H__6597303D_7F5B_11D5_BA4D_0060B0EE18EA__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
// ResultDialog.h : header file
|
||||
//
|
||||
|
||||
#include "resource.h"
|
||||
#include <res\\OCC_Resource.h>
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CResultDialog dialog
|
||||
|
||||
class CResultDialog : public CDialog
|
||||
{
|
||||
// Construction
|
||||
public:
|
||||
void Initialize();
|
||||
CResultDialog(CWnd* pParent = NULL); // standard constructor
|
||||
void SetTitle(LPCSTR aTitle);
|
||||
void SetText(LPCSTR aText);
|
||||
void Empty();
|
||||
|
||||
// Dialog Data
|
||||
//{{AFX_DATA(CResultDialog)
|
||||
enum { IDD = IDD_ResultDialog };
|
||||
// NOTE: the ClassWizard will add data members here
|
||||
//}}AFX_DATA
|
||||
|
||||
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CResultDialog)
|
||||
protected:
|
||||
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
||||
virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
protected:
|
||||
|
||||
// Generated message map functions
|
||||
//{{AFX_MSG(CResultDialog)
|
||||
afx_msg void OnCopySelectionToClipboard();
|
||||
afx_msg void OnCopyAllToClipboard();
|
||||
virtual void OnCancel();
|
||||
|
||||
// OnSize is a message handler of WM_SIZE messge,
|
||||
// it is reimplemented in order to reposition the buttons
|
||||
// (keep them always in the bottom part of the dialog)
|
||||
// and resize the rich edit controls as user resized THIS dialog.
|
||||
afx_msg void OnSize(UINT nType, int cx, int cy);
|
||||
//}}AFX_MSG
|
||||
|
||||
DECLARE_MESSAGE_MAP()
|
||||
|
||||
private:
|
||||
int bw, bh; // button width and height
|
||||
|
||||
};
|
||||
|
||||
//{{AFX_INSERT_LOCATION}}
|
||||
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
|
||||
|
||||
#endif // !defined(AFX_RESULTDIALOG_H__6597303D_7F5B_11D5_BA4D_0060B0EE18EA__INCLUDED_)
|
6
samples/mfc/standard/10_Convert/src/WNT/StdAfx.cpp
Executable file
6
samples/mfc/standard/10_Convert/src/WNT/StdAfx.cpp
Executable file
@@ -0,0 +1,6 @@
|
||||
// stdafx.cpp : source file that includes just the standard includes
|
||||
// OCCDemo.pch will be the pre-compiled header
|
||||
// stdafx.obj will contain the pre-compiled type information
|
||||
|
||||
#include "stdafx.h"
|
||||
|
44
samples/mfc/standard/10_Convert/src/WNT/StdAfx.h
Executable file
44
samples/mfc/standard/10_Convert/src/WNT/StdAfx.h
Executable file
@@ -0,0 +1,44 @@
|
||||
// stdafx.h : include file for standard system include files,
|
||||
// or project specific include files that are used frequently, but
|
||||
// are changed infrequently
|
||||
//
|
||||
|
||||
#if !defined(AFX_STDAFX_H__57A6A22A_7B4F_11D5_BA4A_0060B0EE18EA__INCLUDED_)
|
||||
#define AFX_STDAFX_H__57A6A22A_7B4F_11D5_BA4A_0060B0EE18EA__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
|
||||
|
||||
#include <afxwin.h> // MFC core and standard components
|
||||
#include <afxext.h> // MFC extensions
|
||||
//#include <afxdtctl.h> // MFC support for Internet Explorer 4 Common Controls
|
||||
#ifndef _AFX_NO_AFXCMN_SUPPORT
|
||||
#include <afxcmn.h> // MFC support for Windows Common Controls
|
||||
#endif // _AFX_NO_AFXCMN_SUPPORT
|
||||
|
||||
#if !defined(WNT)
|
||||
#error WNT precompiler directive is mandatory for CasCade
|
||||
#endif
|
||||
|
||||
#pragma warning( disable : 4244 ) // Issue warning 4244
|
||||
#include "Standard_ShortReal.hxx"
|
||||
#pragma warning( default : 4244 ) // Issue warning 4244
|
||||
|
||||
#include <Standard.hxx>
|
||||
|
||||
#include <AIS_InteractiveContext.hxx>
|
||||
#include <AIS_Shape.hxx>
|
||||
#include <AIS_Point.hxx>
|
||||
#include <Graphic3d_WNTGraphicDevice.hxx>
|
||||
#include <V3d_Viewer.hxx>
|
||||
#include <V3d_View.hxx>
|
||||
#include <WNT_Window.hxx>
|
||||
#include <Standard_ErrorHandler.hxx>
|
||||
|
||||
//{{AFX_INSERT_LOCATION}}
|
||||
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
|
||||
|
||||
#endif // !defined(AFX_STDAFX_H__57A6A22A_7B4F_11D5_BA4A_0060B0EE18EA__INCLUDED_)
|
BIN
samples/mfc/standard/10_Convert/src/WNT/res/OCCDemo.ico
Executable file
BIN
samples/mfc/standard/10_Convert/src/WNT/res/OCCDemo.ico
Executable file
Binary file not shown.
After Width: | Height: | Size: 3.7 KiB |
1
samples/mfc/standard/10_Convert/src/WNT/res/OCCDemo.rc2
Executable file
1
samples/mfc/standard/10_Convert/src/WNT/res/OCCDemo.rc2
Executable file
@@ -0,0 +1 @@
|
||||
// This file is to be included in the main resource file
|
BIN
samples/mfc/standard/10_Convert/src/WNT/res/logopen.bmp
Executable file
BIN
samples/mfc/standard/10_Convert/src/WNT/res/logopen.bmp
Executable file
Binary file not shown.
After Width: | Height: | Size: 57 KiB |
BIN
samples/mfc/standard/10_Convert/src/WNT/res/occlogo.bmp
Executable file
BIN
samples/mfc/standard/10_Convert/src/WNT/res/occlogo.bmp
Executable file
Binary file not shown.
After Width: | Height: | Size: 9.0 KiB |
BIN
samples/mfc/standard/10_Convert/src/WNT/res/toolbar.bmp
Executable file
BIN
samples/mfc/standard/10_Convert/src/WNT/res/toolbar.bmp
Executable file
Binary file not shown.
After Width: | Height: | Size: 1.5 KiB |
BIN
samples/mfc/standard/10_Convert/src/WNT/res/toolbar1.bmp
Executable file
BIN
samples/mfc/standard/10_Convert/src/WNT/res/toolbar1.bmp
Executable file
Binary file not shown.
After Width: | Height: | Size: 3.5 KiB |
30
samples/mfc/standard/10_Convert/src/WNT/resource.h
Executable file
30
samples/mfc/standard/10_Convert/src/WNT/resource.h
Executable file
@@ -0,0 +1,30 @@
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Developer Studio generated include file.
|
||||
// Used by OCCDemo.rc
|
||||
//
|
||||
#define IDD_ABOUTBOX 100
|
||||
#define IDR_MAINFRAME 128
|
||||
#define IDR_TOOLBAR1 130
|
||||
#define IDB_OCCLOGO 138
|
||||
#define IDB_OPENLOGO 142
|
||||
#define ID_BUTTONWire 50015
|
||||
#define ID_BUTTONShade 50016
|
||||
#define ID_BUTTONStart 50103
|
||||
#define ID_BUTTONNext 50104
|
||||
#define ID_BUTTONShowResult 50105
|
||||
#define ID_DUMP_VIEW 50106
|
||||
#define ID_BUTTONEnd 50107
|
||||
#define ID_BUTTONPrev 50109
|
||||
#define ID_BUTTONRepeat 50110
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_3D_CONTROLS 1
|
||||
#define _APS_NEXT_RESOURCE_VALUE 143
|
||||
#define _APS_NEXT_COMMAND_VALUE 40111
|
||||
#define _APS_NEXT_CONTROL_VALUE 1007
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
#endif
|
Reference in New Issue
Block a user