mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-10 18:51:21 +03:00
0023931: Incorrect image export code in MFC sample: Added OCC_BaseDoc::ExportView() method to unify image export procedure in all MFC samples.
Compilation errors were corrected.
This commit is contained in:
parent
89c4bca846
commit
12c76beeb0
@ -9,11 +9,12 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#endif // _MSC_VER >= 1000
|
#endif // _MSC_VER >= 1000
|
||||||
|
|
||||||
|
#include "OCC_BaseDoc.h"
|
||||||
#include "ResultDialog.h"
|
#include "ResultDialog.h"
|
||||||
|
|
||||||
class Handle_AIS_Point;
|
class Handle_AIS_Point;
|
||||||
|
|
||||||
class CGeometryDoc : public CDocument
|
class CGeometryDoc : public OCC_BaseDoc
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void Put2DOnTop(bool isMax = true);
|
void Put2DOnTop(bool isMax = true);
|
||||||
@ -210,20 +211,10 @@ protected:
|
|||||||
//}}AFX_MSG
|
//}}AFX_MSG
|
||||||
DECLARE_MESSAGE_MAP()
|
DECLARE_MESSAGE_MAP()
|
||||||
|
|
||||||
|
|
||||||
private:
|
|
||||||
Handle_V3d_Viewer myViewer;
|
|
||||||
Handle_V3d_Viewer myViewerCollector;
|
|
||||||
Handle_AIS_InteractiveContext myAISContext;
|
|
||||||
public :
|
|
||||||
Handle_AIS_InteractiveContext& GetAISContext(){ return myAISContext; };
|
|
||||||
Handle_V3d_Viewer GetViewer() { return myViewer; };
|
|
||||||
Handle_V3d_Viewer GetViewerCollector() { return myViewerCollector; };
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Handle_V3d_Viewer myViewer2D;
|
Handle_V3d_Viewer myViewer2D;
|
||||||
Handle_AIS_InteractiveContext myAISContext2D;
|
Handle_AIS_InteractiveContext myAISContext2D;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
int Current;
|
int Current;
|
||||||
void Minimize3D();
|
void Minimize3D();
|
||||||
|
@ -79,23 +79,7 @@ CGeometryDoc* CGeometryView::GetDocument() // non-debug version is inline
|
|||||||
|
|
||||||
void CGeometryView::OnFileExportImage()
|
void CGeometryView::OnFileExportImage()
|
||||||
{
|
{
|
||||||
CFileDialog aDlg (FALSE, "*.BMP", NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
|
GetDocument()->ExportView (myView);
|
||||||
"BMP Files (*.BMP)|*.bmp|"
|
|
||||||
"GIF Files (*.GIF)|*.gif|"
|
|
||||||
"PNG Files (*.PNG)|*.png|"
|
|
||||||
"JPEG Files (*.JPG)|*.jpg|"
|
|
||||||
"PPM Files (*.PPM)|*.ppm|"
|
|
||||||
"TIFF Files (*.TIFF)|*.tiff|"
|
|
||||||
"TGA Files (*.TGA)|*.tga|"
|
|
||||||
"EXR Files (*.EXR)|*.exr||", NULL);
|
|
||||||
if (aDlg.DoModal() != IDOK)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT));
|
|
||||||
myView->Dump (aDlg.GetPathName());
|
|
||||||
SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGeometryView::OnSize(UINT /*nType*/, int /*cx*/, int /*cy*/)
|
void CGeometryView::OnSize(UINT /*nType*/, int /*cx*/, int /*cy*/)
|
||||||
|
@ -317,24 +317,22 @@ void CViewer2dDoc::OnBUTTONTestCurve()
|
|||||||
|
|
||||||
void CViewer2dDoc::OnBUTTONTestImage()
|
void CViewer2dDoc::OnBUTTONTestImage()
|
||||||
{
|
{
|
||||||
CFileDialog dlg(TRUE,
|
CFileDialog anOpenImageDlg (TRUE,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
|
OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
|
||||||
"image Files (*.bmp , *.gif , *.jpeg, *.bmp, *.ppm, *.exr, *.tga, *.tiff, *.pgf, *.pdf)"
|
SupportedImageFormats() + "| all files (*.*)|*.*;||",
|
||||||
"|*.bmp; *.gif; *.jpeg; *.bmp; *.ppm; *.exr; *.tga; *.tiff; *.pgf; *.pdf;"
|
|
||||||
"| all files (*.*)|*.*;||",
|
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
CString initdir(((OCC_App*) AfxGetApp())->GetInitDataDir());
|
CString anInitDir (((OCC_App*) AfxGetApp())->GetInitDataDir());
|
||||||
initdir += "\\Data";
|
anInitDir += "\\Data";
|
||||||
|
|
||||||
dlg.m_ofn.lpstrInitialDir = initdir;
|
anOpenImageDlg.m_ofn.lpstrInitialDir = anInitDir;
|
||||||
if(dlg.DoModal() == IDOK)
|
if(anOpenImageDlg.DoModal() == IDOK)
|
||||||
{
|
{
|
||||||
SetCursor(AfxGetApp()->LoadStandardCursor (IDC_WAIT));
|
SetCursor(AfxGetApp()->LoadStandardCursor (IDC_WAIT));
|
||||||
CString filename = dlg.GetPathName();
|
CString aFilePath = anOpenImageDlg.GetPathName();
|
||||||
TCollection_AsciiString aFileName(filename);
|
TCollection_AsciiString aFileName (aFilePath);
|
||||||
|
|
||||||
//erase viewer
|
//erase viewer
|
||||||
if(myAISContext->HasOpenedContext())
|
if(myAISContext->HasOpenedContext())
|
||||||
@ -352,30 +350,29 @@ void CViewer2dDoc::OnBUTTONTestImage()
|
|||||||
|
|
||||||
void CViewer2dDoc::OnBUTTONMultipleImage()
|
void CViewer2dDoc::OnBUTTONMultipleImage()
|
||||||
{
|
{
|
||||||
CFileDialog dlg(TRUE,
|
CFileDialog anOpenImageDlg (TRUE,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
|
OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
|
||||||
"image Files (*.bmp , *.gif , *.jpeg, *.bmp, *.ppm, *.exr, *.tga, *.tiff, *.pgf, *.pdf)"
|
SupportedImageFormats() + "| all files (*.*)|*.*;||",
|
||||||
"|*.bmp; *.gif; *.jpeg; *.bmp; *.ppm; *.exr; *.tga; *.tiff; *.pgf; *.pdf;"
|
|
||||||
"| all files (*.*)|*.*;||",
|
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
CString initdir(((OCC_App*) AfxGetApp())->GetInitDataDir());
|
CString anInitDir (((OCC_App*) AfxGetApp())->GetInitDataDir());
|
||||||
initdir += "\\Data";
|
anInitDir += "\\Data";
|
||||||
|
|
||||||
dlg.m_ofn.lpstrInitialDir = initdir;
|
anOpenImageDlg.m_ofn.lpstrInitialDir = anInitDir;
|
||||||
|
|
||||||
|
if (anOpenImageDlg.DoModal() == IDOK)
|
||||||
if (dlg.DoModal() == IDOK)
|
|
||||||
{
|
{
|
||||||
SetCursor(AfxGetApp()->LoadStandardCursor (IDC_WAIT));
|
SetCursor(AfxGetApp()->LoadStandardCursor (IDC_WAIT));
|
||||||
CString filename = dlg.GetPathName();
|
CString aFilePath = anOpenImageDlg.GetPathName();
|
||||||
TCollection_AsciiString aFileName(filename);
|
TCollection_AsciiString aFileName (aFilePath);
|
||||||
|
|
||||||
//erase viewer
|
//erase viewer
|
||||||
if(myAISContext->HasOpenedContext())
|
if(myAISContext->HasOpenedContext())
|
||||||
myAISContext->CloseAllContexts();
|
myAISContext->CloseAllContexts();
|
||||||
myAISContext->EraseAll();
|
myAISContext->EraseAll();
|
||||||
|
|
||||||
//create images
|
//create images
|
||||||
{ // 1
|
{ // 1
|
||||||
Handle(Sample2D_Image) anImage = new Sample2D_Image (aFileName);
|
Handle(Sample2D_Image) anImage = new Sample2D_Image (aFileName);
|
||||||
@ -386,7 +383,6 @@ void CViewer2dDoc::OnBUTTONMultipleImage()
|
|||||||
}
|
}
|
||||||
{ // 2
|
{ // 2
|
||||||
Handle(Sample2D_Image) anImage = new Sample2D_Image (aFileName);
|
Handle(Sample2D_Image) anImage = new Sample2D_Image (aFileName);
|
||||||
|
|
||||||
anImage->SetCoord (100, 50);
|
anImage->SetCoord (100, 50);
|
||||||
anImage->SetScale (0.9);
|
anImage->SetScale (0.9);
|
||||||
myAISContext->Display (anImage, Standard_False);
|
myAISContext->Display (anImage, Standard_False);
|
||||||
|
@ -120,7 +120,18 @@ BOOL CModelClippingDlg::OnInitDialog()
|
|||||||
if (m_ModelClippingONOFF)
|
if (m_ModelClippingONOFF)
|
||||||
{
|
{
|
||||||
// register and activate clipping plane
|
// register and activate clipping plane
|
||||||
if (!myView->GetClipPlanes().Contains (myClippingPlane))
|
Standard_Boolean toAddPlane = Standard_True;
|
||||||
|
Graphic3d_SequenceOfHClipPlane::Iterator aPlaneIt (myView->GetClipPlanes());
|
||||||
|
for (; aPlaneIt.More(); aPlaneIt.Next())
|
||||||
|
{
|
||||||
|
if (aPlaneIt.Value() == myClippingPlane)
|
||||||
|
{
|
||||||
|
toAddPlane = Standard_False;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (toAddPlane)
|
||||||
{
|
{
|
||||||
myView->AddClipPlane (myClippingPlane);
|
myView->AddClipPlane (myClippingPlane);
|
||||||
}
|
}
|
||||||
@ -188,7 +199,18 @@ void CModelClippingDlg::OnCheckModelclippingonoff()
|
|||||||
if (m_ModelClippingONOFF)
|
if (m_ModelClippingONOFF)
|
||||||
{
|
{
|
||||||
// register and activate clipping plane
|
// register and activate clipping plane
|
||||||
if (!myView->GetClipPlanes().Contains (myClippingPlane))
|
Standard_Boolean toAddPlane = Standard_True;
|
||||||
|
Graphic3d_SequenceOfHClipPlane::Iterator aPlaneIt (myView->GetClipPlanes());
|
||||||
|
for (; aPlaneIt.More(); aPlaneIt.Next())
|
||||||
|
{
|
||||||
|
if (aPlaneIt.Value() == myClippingPlane)
|
||||||
|
{
|
||||||
|
toAddPlane = Standard_False;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (toAddPlane)
|
||||||
{
|
{
|
||||||
myView->AddClipPlane (myClippingPlane);
|
myView->AddClipPlane (myClippingPlane);
|
||||||
}
|
}
|
||||||
|
@ -511,7 +511,7 @@ END
|
|||||||
|
|
||||||
STRINGTABLE
|
STRINGTABLE
|
||||||
BEGIN
|
BEGIN
|
||||||
ID_DUMP_VIEW "Save current frame into a GIF file\nExport view to GIF (F12)"
|
ID_DUMP_VIEW "Save current frame into an image file\nExport view (F12)"
|
||||||
ID_TEXTURE_ON "Run texture example\nRun texture example"
|
ID_TEXTURE_ON "Run texture example\nRun texture example"
|
||||||
END
|
END
|
||||||
|
|
||||||
|
@ -1059,28 +1059,15 @@ void CViewer3dDoc::OnUpdateBUTTONEnd(CCmdUI* pCmdUI)
|
|||||||
|
|
||||||
void CViewer3dDoc::OnDumpView()
|
void CViewer3dDoc::OnDumpView()
|
||||||
{
|
{
|
||||||
CFileDialog aDlg (false, "gif", "OCCView.gif", OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
|
|
||||||
"GIF Files (*.GIF)|*.gif|"
|
|
||||||
"BMP Files (*.BMP)|*.bmp|"
|
|
||||||
"PNG Files (*.PNG)|*.png|"
|
|
||||||
"JPEG Files (*.JPG)|*.jpg|"
|
|
||||||
"PPM Files (*.PPM)|*.ppm|"
|
|
||||||
"TIFF Files (*.TIFF)|*.tiff|"
|
|
||||||
"TGA Files (*.TGA)|*.tga|"
|
|
||||||
"EXR Files (*.EXR)|*.exr||", NULL);
|
|
||||||
if (aDlg.DoModal() != IDOK)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (POSITION aPos = GetFirstViewPosition(); aPos != NULL;)
|
for (POSITION aPos = GetFirstViewPosition(); aPos != NULL;)
|
||||||
{
|
{
|
||||||
CViewer3dView* pView = (CViewer3dView* )GetNextView (aPos);
|
CViewer3dView* pView = (CViewer3dView* )GetNextView (aPos);
|
||||||
pView->UpdateWindow();
|
pView->UpdateWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
myViewer->InitActiveViews();
|
myViewer->InitActiveViews();
|
||||||
Handle(V3d_View) aView = myViewer->ActiveView();
|
Handle(V3d_View) aView = myViewer->ActiveView();
|
||||||
aView->Dump (aDlg.GetPathName());
|
ExportView (aView);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CViewer3dDoc::Start()
|
void CViewer3dDoc::Start()
|
||||||
|
@ -202,7 +202,7 @@ BEGIN
|
|||||||
ID_BUTTONStart "Press to go to the first sample\nFirst sample (Home)"
|
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_BUTTONNext "Press to go to the next sample\nNext sample (PgDn)"
|
||||||
ID_BUTTONEnd "Press to go to the last sample\nLast sample (End)"
|
ID_BUTTONEnd "Press to go to the last sample\nLast sample (End)"
|
||||||
ID_DUMP_VIEW "Save current frame into a GIF file\nExport view to GIF (F12)"
|
ID_DUMP_VIEW "Save current frame into an image file\nExport view (F12)"
|
||||||
END
|
END
|
||||||
|
|
||||||
#endif // English (U.S.) resources
|
#endif // English (U.S.) resources
|
||||||
|
@ -407,28 +407,15 @@ void CTriangulationDoc::OnUpdateBUTTONPrev(CCmdUI* pCmdUI)
|
|||||||
|
|
||||||
void CTriangulationDoc::OnDumpView()
|
void CTriangulationDoc::OnDumpView()
|
||||||
{
|
{
|
||||||
CFileDialog aDlg (false, "gif", "OCCView.gif", OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
|
|
||||||
"GIF Files (*.GIF)|*.gif|"
|
|
||||||
"BMP Files (*.BMP)|*.bmp|"
|
|
||||||
"PNG Files (*.PNG)|*.png|"
|
|
||||||
"JPEG Files (*.JPEG)|*.jpeg|"
|
|
||||||
"PPM Files (*.PPM)|*.ppm|"
|
|
||||||
"TIFF Files (*.TIFF)|*.tiff|"
|
|
||||||
"TGA Files (*.TGA)|*.tga|"
|
|
||||||
"EXR Files (*.EXR)|*.exr||", NULL);
|
|
||||||
if (aDlg.DoModal() != IDOK)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (POSITION aPos = GetFirstViewPosition(); aPos != NULL;)
|
for (POSITION aPos = GetFirstViewPosition(); aPos != NULL;)
|
||||||
{
|
{
|
||||||
OCC_3dView* pView = (OCC_3dView* )GetNextView (aPos);
|
OCC_3dView* pView = (OCC_3dView* )GetNextView (aPos);
|
||||||
pView->UpdateWindow();
|
pView->UpdateWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
myViewer->InitActiveViews();
|
myViewer->InitActiveViews();
|
||||||
Handle(V3d_View) aView = myViewer->ActiveView();
|
Handle(V3d_View) aView = myViewer->ActiveView();
|
||||||
aView->Dump (aDlg.GetPathName());
|
ExportView (aView);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTriangulationDoc::Fit()
|
void CTriangulationDoc::Fit()
|
||||||
|
@ -9,12 +9,12 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#endif // _MSC_VER >= 1000
|
#endif // _MSC_VER >= 1000
|
||||||
|
|
||||||
|
#include "OCC_BaseDoc.h"
|
||||||
#include "AIS_ConnectedInteractive.hxx"
|
#include "AIS_ConnectedInteractive.hxx"
|
||||||
#include "Geom_Transformation.hxx"
|
#include "Geom_Transformation.hxx"
|
||||||
|
|
||||||
|
|
||||||
class CAnimationDoc : public CDocument
|
class CAnimationDoc : public OCC_BaseDoc
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -22,22 +22,28 @@ public:
|
|||||||
const Standard_Integer y,
|
const Standard_Integer y,
|
||||||
const Standard_Integer TheState,
|
const Standard_Integer TheState,
|
||||||
const Handle(V3d_View)& aView);
|
const Handle(V3d_View)& aView);
|
||||||
|
|
||||||
void InputEvent (const Standard_Integer x,
|
void InputEvent (const Standard_Integer x,
|
||||||
const Standard_Integer y,
|
const Standard_Integer y,
|
||||||
const Handle(V3d_View)& aView);
|
const Handle(V3d_View)& aView);
|
||||||
|
|
||||||
void MoveEvent (const Standard_Integer x,
|
void MoveEvent (const Standard_Integer x,
|
||||||
const Standard_Integer y,
|
const Standard_Integer y,
|
||||||
const Handle(V3d_View)& aView);
|
const Handle(V3d_View)& aView);
|
||||||
|
|
||||||
void ShiftMoveEvent (const Standard_Integer x,
|
void ShiftMoveEvent (const Standard_Integer x,
|
||||||
const Standard_Integer y,
|
const Standard_Integer y,
|
||||||
const Handle(V3d_View)& aView);
|
const Handle(V3d_View)& aView);
|
||||||
|
|
||||||
void ShiftDragEvent (const Standard_Integer x,
|
void ShiftDragEvent (const Standard_Integer x,
|
||||||
const Standard_Integer y,
|
const Standard_Integer y,
|
||||||
const Standard_Integer TheState,
|
const Standard_Integer TheState,
|
||||||
const Handle(V3d_View)& aView);
|
const Handle(V3d_View)& aView);
|
||||||
|
|
||||||
void ShiftInputEvent (const Standard_Integer x,
|
void ShiftInputEvent (const Standard_Integer x,
|
||||||
const Standard_Integer y,
|
const Standard_Integer y,
|
||||||
const Handle(V3d_View)& aView);
|
const Handle(V3d_View)& aView);
|
||||||
|
|
||||||
void Popup (const Standard_Integer x,
|
void Popup (const Standard_Integer x,
|
||||||
const Standard_Integer y,
|
const Standard_Integer y,
|
||||||
const Handle(V3d_View)& aView);
|
const Handle(V3d_View)& aView);
|
||||||
@ -46,18 +52,6 @@ protected: // create from serialization only
|
|||||||
CAnimationDoc();
|
CAnimationDoc();
|
||||||
DECLARE_DYNCREATE(CAnimationDoc)
|
DECLARE_DYNCREATE(CAnimationDoc)
|
||||||
|
|
||||||
// Attributes
|
|
||||||
public:
|
|
||||||
|
|
||||||
// Operations
|
|
||||||
public:
|
|
||||||
|
|
||||||
// Overrides
|
|
||||||
// ClassWizard generated virtual function overrides
|
|
||||||
//{{AFX_VIRTUAL(CAnimationDoc)
|
|
||||||
public:
|
|
||||||
//}}AFX_VIRTUAL
|
|
||||||
|
|
||||||
// Implementation
|
// Implementation
|
||||||
public:
|
public:
|
||||||
virtual ~CAnimationDoc();
|
virtual ~CAnimationDoc();
|
||||||
@ -66,8 +60,6 @@ public:
|
|||||||
virtual void Dump(CDumpContext& dc) const;
|
virtual void Dump(CDumpContext& dc) const;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
protected:
|
|
||||||
|
|
||||||
// Generated message map functions
|
// Generated message map functions
|
||||||
protected:
|
protected:
|
||||||
//{{AFX_MSG(CAnimationDoc)
|
//{{AFX_MSG(CAnimationDoc)
|
||||||
@ -77,18 +69,6 @@ protected:
|
|||||||
afx_msg void OnUpdateWalkWalkthru(CCmdUI* pCmdUI);
|
afx_msg void OnUpdateWalkWalkthru(CCmdUI* pCmdUI);
|
||||||
//}}AFX_MSG
|
//}}AFX_MSG
|
||||||
DECLARE_MESSAGE_MAP()
|
DECLARE_MESSAGE_MAP()
|
||||||
public :
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
|
||||||
Handle_V3d_Viewer myViewer;
|
|
||||||
Handle_AIS_InteractiveContext myAISContext;
|
|
||||||
public :
|
|
||||||
Handle_AIS_InteractiveContext& GetAISContext(){ return myAISContext; };
|
|
||||||
Handle_V3d_Viewer GetViewer() { return myViewer; };
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Handle_AIS_Shape myAisCrankArm ;
|
Handle_AIS_Shape myAisCrankArm ;
|
||||||
|
@ -225,24 +225,7 @@ CAnimationDoc* CAnimationView3D::GetDocument() // non-debug version is inline
|
|||||||
// CAnimationView3D message handlers
|
// CAnimationView3D message handlers
|
||||||
void CAnimationView3D::OnFileExportImage()
|
void CAnimationView3D::OnFileExportImage()
|
||||||
{
|
{
|
||||||
CFileDialog aDlg (FALSE, "*.BMP", NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
|
GetDocument()->ExportView (myView);
|
||||||
"BMP Files (*.BMP)|*.bmp|"
|
|
||||||
"GIF Files (*.GIF)|*.gif|"
|
|
||||||
"PNG Files (*.PNG)|*.png|"
|
|
||||||
"JPEG Files (*.JPEG)|*.jpeg|"
|
|
||||||
"PPM Files (*.PPM)|*.ppm|"
|
|
||||||
"TIFF Files (*.TIFF)|*.tiff|"
|
|
||||||
"TGA Files (*.TGA)|*.tga|"
|
|
||||||
"EXR Files (*.EXR)|*.exr||",
|
|
||||||
NULL);
|
|
||||||
if (aDlg.DoModal() != IDOK)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT));
|
|
||||||
myView->Dump (aDlg.GetPathName());
|
|
||||||
SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CAnimationView3D::OnSize(UINT /*nType*/, int cx, int cy)
|
void CAnimationView3D::OnSize(UINT /*nType*/, int cx, int cy)
|
||||||
|
@ -352,7 +352,7 @@ BEGIN
|
|||||||
ID_BUTTONStart "Press to go to the first sample\nFirst sample (Home)"
|
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_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_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_DUMP_VIEW "Save current frame into an image file\nExport view (F12)"
|
||||||
ID_BUTTONEnd "Press to go to the last sample\nLast sample (End)"
|
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_BUTTONPrev "Press to go to the previous sample\nPrevious sample (PgUp)"
|
||||||
ID_BUTTONRepeat "Press to repeat the current sample\nRepeat sample (Space)"
|
ID_BUTTONRepeat "Press to repeat the current sample\nRepeat sample (Space)"
|
||||||
|
@ -225,28 +225,15 @@ void COCCDemoDoc::OnUpdateBUTTONShowResult(CCmdUI* pCmdUI)
|
|||||||
|
|
||||||
void COCCDemoDoc::OnDumpView()
|
void COCCDemoDoc::OnDumpView()
|
||||||
{
|
{
|
||||||
CFileDialog aDlg (false, "gif", "OCCView.gif", OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
|
|
||||||
"GIF Files (*.GIF)|*.gif|"
|
|
||||||
"BMP Files (*.BMP)|*.bmp|"
|
|
||||||
"PNG Files (*.PNG)|*.png|"
|
|
||||||
"JPEG Files (*.JPEG)|*.jpeg|"
|
|
||||||
"PPM Files (*.PPM)|*.ppm|"
|
|
||||||
"TIFF Files (*.TIFF)|*.tiff|"
|
|
||||||
"TGA Files (*.TGA)|*.tga|"
|
|
||||||
"EXR Files (*.EXR)|*.exr||", NULL);
|
|
||||||
if (aDlg.DoModal() != IDOK)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (POSITION aPos = GetFirstViewPosition(); aPos != NULL;)
|
for (POSITION aPos = GetFirstViewPosition(); aPos != NULL;)
|
||||||
{
|
{
|
||||||
COCCDemoView* pView = (COCCDemoView* )GetNextView (aPos);
|
COCCDemoView* pView = (COCCDemoView* )GetNextView (aPos);
|
||||||
pView->UpdateWindow();
|
pView->UpdateWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
myViewer->InitActiveViews();
|
myViewer->InitActiveViews();
|
||||||
Handle(V3d_View) aView = myViewer->ActiveView();
|
Handle(V3d_View) aView = myViewer->ActiveView();
|
||||||
aView->Dump (aDlg.GetPathName());
|
ExportView (aView);
|
||||||
}
|
}
|
||||||
|
|
||||||
void COCCDemoDoc::Fit()
|
void COCCDemoDoc::Fit()
|
||||||
|
@ -9,14 +9,13 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#endif // _MSC_VER > 1000
|
#endif // _MSC_VER > 1000
|
||||||
|
|
||||||
|
#include <OCC_BaseDoc.h>
|
||||||
#include "ResultDialog.h"
|
#include "ResultDialog.h"
|
||||||
class OCCDemo_Presentation;
|
class OCCDemo_Presentation;
|
||||||
|
|
||||||
class COCCDemoDoc : public CDocument
|
class COCCDemoDoc : public OCC_BaseDoc
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Handle_V3d_Viewer GetViewer() const { return myViewer; };
|
|
||||||
Handle_AIS_InteractiveContext GetAISContext() const { return myAISContext; };
|
|
||||||
CResultDialog* GetResultDialog () {return &myCResultDialog;}
|
CResultDialog* GetResultDialog () {return &myCResultDialog;}
|
||||||
Standard_CString GetDataDir() {return myDataDir;}
|
Standard_CString GetDataDir() {return myDataDir;}
|
||||||
|
|
||||||
@ -72,8 +71,6 @@ protected:
|
|||||||
DECLARE_MESSAGE_MAP()
|
DECLARE_MESSAGE_MAP()
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Handle_V3d_Viewer myViewer;
|
|
||||||
Handle_AIS_InteractiveContext myAISContext;
|
|
||||||
OCCDemo_Presentation *myPresentation;
|
OCCDemo_Presentation *myPresentation;
|
||||||
CResultDialog myCResultDialog;
|
CResultDialog myCResultDialog;
|
||||||
BOOL myShowResult;
|
BOOL myShowResult;
|
||||||
|
@ -121,36 +121,7 @@ void OCC_2dView::OnInitialUpdate()
|
|||||||
|
|
||||||
void OCC_2dView::OnFileExportImage()
|
void OCC_2dView::OnFileExportImage()
|
||||||
{
|
{
|
||||||
LPCTSTR filter;
|
GetDocument()->ExportView (myV2dView);
|
||||||
filter = _T("EXR Files (*.EXR)|*.exr|TGA Files (*.TGA)|*.tga|TIFF Files (*.TIFF)|*.tiff|"
|
|
||||||
"PPM Files (*.PPM)|*.ppm|JPEG Files(*.JPEG)|*.jpeg|PNG Files (*.PNG)|*.png|"
|
|
||||||
"GIF Files (*.GIF)|*.gif|BMP Files (*.BMP)|*.bmp|PS Files (*.PS)|*.ps|"
|
|
||||||
"EPS Files (*.EPS)|*.eps|TEX Files (*.TEX)|*.tex|PDF Files (*.PDF)|*.pdf"
|
|
||||||
"|SVG Files (*.SVG)|*.svg|PGF Files (*.PGF)|*.pgf|EMF Files (*.EMF)|*.emf||");
|
|
||||||
CFileDialog dlg(FALSE,_T("*.BMP"),NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
|
|
||||||
filter,
|
|
||||||
NULL );
|
|
||||||
|
|
||||||
|
|
||||||
if (dlg.DoModal() == IDOK)
|
|
||||||
{
|
|
||||||
SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT));
|
|
||||||
CString aFileName = dlg.GetPathName();
|
|
||||||
CString ext = dlg.GetFileExt();
|
|
||||||
if (!(ext.CompareNoCase("ps")) || !(ext.CompareNoCase("emf"))
|
|
||||||
|| !(ext.CompareNoCase("pdf")) || !(ext.CompareNoCase("eps"))
|
|
||||||
|| !(ext.CompareNoCase("tex")) || !(ext.CompareNoCase("svg"))
|
|
||||||
|| !(ext.CompareNoCase("pgf")))
|
|
||||||
{
|
|
||||||
Graphic3d_ExportFormat exFormat;
|
|
||||||
if (!(ext.CompareNoCase("ps"))) exFormat = Graphic3d_EF_PostScript;
|
|
||||||
else exFormat = Graphic3d_EF_EnhPostScript;
|
|
||||||
myV2dView->View()->Export( aFileName, exFormat );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
myV2dView->Dump(aFileName);
|
|
||||||
SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -146,33 +146,7 @@ OCC_3dDoc* OCC_3dView::GetDocument() // non-debug version is inline
|
|||||||
// OCC_3dView message handlers
|
// OCC_3dView message handlers
|
||||||
void OCC_3dView::OnFileExportImage()
|
void OCC_3dView::OnFileExportImage()
|
||||||
{
|
{
|
||||||
LPCTSTR filter;
|
GetDocument()->ExportView (myView);
|
||||||
filter = _T("EXR Files (*.EXR)|*.exr|TGA Files (*.TGA)|*.tga|TIFF Files (*.TIFF)|*.tiff|"
|
|
||||||
"PPM Files (*.PPM)|*.ppm|JPEG Files(*.JPEG)|*.jpeg|PNG Files (*.PNG)|*.png|"
|
|
||||||
"GIF Files (*.GIF)|*.gif|BMP Files (*.BMP)|*.bmp|PS Files (*.PS)|*.ps|"
|
|
||||||
"EPS Files (*.EPS)|*.eps|TEX Files (*.TEX)|*.tex|PDF Files (*.PDF)|*.pdf"
|
|
||||||
"|SVG Files (*.SVG)|*.svg|PGF Files (*.PGF)|*.pgf|EMF Files (*.EMF)|*.emf||");
|
|
||||||
CFileDialog dlg(FALSE,_T("*.BMP"),NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
|
|
||||||
filter,
|
|
||||||
NULL );
|
|
||||||
|
|
||||||
if (dlg.DoModal() == IDOK)
|
|
||||||
{
|
|
||||||
CString aFileName = dlg.GetPathName();
|
|
||||||
CString ext = dlg.GetFileExt();
|
|
||||||
if (!(ext.CompareNoCase("ps")) || !(ext.CompareNoCase("emf"))
|
|
||||||
|| !(ext.CompareNoCase("pdf")) || !(ext.CompareNoCase("eps"))
|
|
||||||
|| !(ext.CompareNoCase("tex")) || !(ext.CompareNoCase("svg"))
|
|
||||||
|| !(ext.CompareNoCase("pgf")))
|
|
||||||
{
|
|
||||||
Graphic3d_ExportFormat exFormat;
|
|
||||||
if (!(ext.CompareNoCase("ps"))) exFormat = Graphic3d_EF_PostScript;
|
|
||||||
else exFormat = Graphic3d_EF_EnhPostScript;
|
|
||||||
myView->View()->Export( aFileName, exFormat );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
myView->Dump(aFileName);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void OCC_3dView::OnSize(UINT /*nType*/, int /*cx*/, int /*cy*/)
|
void OCC_3dView::OnSize(UINT /*nType*/, int /*cx*/, int /*cy*/)
|
||||||
|
@ -5,6 +5,55 @@
|
|||||||
#include <stdafx.h>
|
#include <stdafx.h>
|
||||||
#include "OCC_BaseDoc.h"
|
#include "OCC_BaseDoc.h"
|
||||||
|
|
||||||
|
const CString OCC_BaseDoc::SupportedImageFormats() const
|
||||||
|
{
|
||||||
|
return ("BMP Files (*.BMP)|*.bmp|GIF Files (*.GIF)|*.gif|TIFF Files (*.TIFF)|*.tiff|"
|
||||||
|
"PPM Files (*.PPM)|*.ppm|JPEG Files(*.JPEG)|*.jpeg|PNG Files (*.PNG)|*.png|"
|
||||||
|
"EXR Files (*.EXR)|*.exr|TGA Files (*.TGA)|*.tga|PS Files (*.PS)|*.ps|"
|
||||||
|
"EPS Files (*.EPS)|*.eps|TEX Files (*.TEX)|*.tex|PDF Files (*.PDF)|*.pdf"
|
||||||
|
"|SVG Files (*.SVG)|*.svg|PGF Files (*.PGF)|*.pgf");
|
||||||
|
}
|
||||||
|
|
||||||
|
void OCC_BaseDoc::ExportView (const Handle(V3d_View)& theView) const
|
||||||
|
{
|
||||||
|
CFileDialog anExportDlg (FALSE,_T("*.BMP"),NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
|
||||||
|
SupportedImageFormats() + "||", NULL );
|
||||||
|
|
||||||
|
if (anExportDlg.DoModal() == IDOK)
|
||||||
|
{
|
||||||
|
// Set waiting cursor
|
||||||
|
SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT));
|
||||||
|
|
||||||
|
CString aFileName = anExportDlg.GetPathName();
|
||||||
|
CString aFileExt = anExportDlg.GetFileExt();
|
||||||
|
|
||||||
|
// For vector formats use V3d_View::Export() method
|
||||||
|
if (!(aFileExt.CompareNoCase ("ps")) || !(aFileExt.CompareNoCase ("pdf"))
|
||||||
|
|| !(aFileExt.CompareNoCase ("eps")) || !(aFileExt.CompareNoCase ("tex"))
|
||||||
|
|| !(aFileExt.CompareNoCase ("svg")) || !(aFileExt.CompareNoCase ("pgf")))
|
||||||
|
{
|
||||||
|
Graphic3d_ExportFormat anExportFormat;
|
||||||
|
|
||||||
|
if (!(aFileExt.CompareNoCase ("ps"))) anExportFormat = Graphic3d_EF_PostScript;
|
||||||
|
else if (!(aFileExt.CompareNoCase ("eps"))) anExportFormat = Graphic3d_EF_EnhPostScript;
|
||||||
|
else if (!(aFileExt.CompareNoCase ("pdf"))) anExportFormat = Graphic3d_EF_PDF;
|
||||||
|
else if (!(aFileExt.CompareNoCase ("tex"))) anExportFormat = Graphic3d_EF_TEX;
|
||||||
|
else if (!(aFileExt.CompareNoCase ("svg"))) anExportFormat = Graphic3d_EF_SVG;
|
||||||
|
else anExportFormat = Graphic3d_EF_PGF;
|
||||||
|
|
||||||
|
theView->View()->Export (aFileName, anExportFormat);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// For pixel formats use V3d_View:Dump() method
|
||||||
|
theView->Dump (aFileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Restore cursor
|
||||||
|
SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
// Construction/Destruction
|
// Construction/Destruction
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
@ -9,9 +9,18 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#endif // _MSC_VER > 1000
|
#endif // _MSC_VER > 1000
|
||||||
|
|
||||||
#include <stdafx.h>
|
#include <AIS_InteractiveContext.hxx>
|
||||||
|
#include <V3d_Viewer.hxx>
|
||||||
|
|
||||||
class OCC_BaseDoc : public CDocument
|
// Base class for all documents in the sample.
|
||||||
|
// Declares base functionlaity and interface for the sample documents.
|
||||||
|
// Common properties:
|
||||||
|
// - interactive context
|
||||||
|
// - 3d viewer
|
||||||
|
// Common methods:
|
||||||
|
// - base events
|
||||||
|
// - export into one of supported export formats.
|
||||||
|
class AFX_EXT_CLASS OCC_BaseDoc : public CDocument
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -23,6 +32,12 @@ public:
|
|||||||
|
|
||||||
Handle(V3d_Viewer) GetViewer() { return myViewer; }
|
Handle(V3d_Viewer) GetViewer() { return myViewer; }
|
||||||
|
|
||||||
|
// Returns string with supported export pixel and vector images formats.
|
||||||
|
const CString SupportedImageFormats() const;
|
||||||
|
|
||||||
|
// Exports the given view into of the supported formats.
|
||||||
|
void ExportView (const Handle(V3d_View)& theView) const;
|
||||||
|
|
||||||
//Events
|
//Events
|
||||||
virtual void DragEvent (const Standard_Integer /*theMouseX*/,
|
virtual void DragEvent (const Standard_Integer /*theMouseX*/,
|
||||||
const Standard_Integer /*theMouseY*/,
|
const Standard_Integer /*theMouseY*/,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user