1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-04 18:06:22 +03:00
occt/samples/mfc/standard/Common/OCC_BaseDoc.cpp
kgv 7ff18fb9cc 0031521: Samples - update MFC ImportExport sample to use AIS_ViewController
The following MFC samples have been updated to use AIS_ViewController:
Geometry, HLR, ImportExport, Modeling, OCAF, Triangulation, Viewer2D.
2020-04-29 20:44:15 +03:00

82 lines
2.2 KiB
C++
Executable File

// OCC_BaseDoc.cpp: implementation of the OCC_BaseDoc class.
//
//////////////////////////////////////////////////////////////////////
#include <stdafx.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");
}
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 aFileExt = anExportDlg.GetFileExt();
TCollection_AsciiString aFileName ((const wchar_t* )anExportDlg.GetPathName());
// For pixel formats use V3d_View:Dump() method
theView->Dump (aFileName.ToCString());
// Restore cursor
SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW));
}
}
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
OCC_BaseDoc::OCC_BaseDoc()
{
}
OCC_BaseDoc::~OCC_BaseDoc()
{
}
//=============================================================================
// function: ResetDocumentViews
// purpose:
//=============================================================================
void OCC_BaseDoc::ResetDocumentViews (CDocTemplate* theTemplate)
{
// do not delete document if no views
BOOL isAutoDelete = m_bAutoDelete;
m_bAutoDelete = FALSE;
// close all opened views
POSITION aViewIt = GetFirstViewPosition();
while (aViewIt)
{
CView* aView = GetNextView (aViewIt);
if (aView == NULL)
{
continue;
}
RemoveView (aView);
aView->GetParentFrame()->SendMessage (WM_CLOSE);
}
// create new view frame
CFrameWnd* aNewFrame = theTemplate->CreateNewFrame (this, NULL);
m_bAutoDelete = isAutoDelete;
// init frame
theTemplate->InitialUpdateFrame(aNewFrame, this);
}