8545b3ae7e10792425139efc19550fa078a0af8c
[occt.git] / samples / mfc / standard / Common / OCC_BaseDoc.cpp
1 // OCC_BaseDoc.cpp: implementation of the OCC_BaseDoc class.
2 //
3 //////////////////////////////////////////////////////////////////////
4
5 #include <stdafx.h>
6 #include "OCC_BaseDoc.h"
7
8 const CString OCC_BaseDoc::SupportedImageFormats() const
9 {
10   return ("BMP Files (*.BMP)|*.bmp|GIF Files (*.GIF)|*.gif|TIFF Files (*.TIFF)|*.tiff|"
11           "PPM Files (*.PPM)|*.ppm|JPEG Files(*.JPEG)|*.jpeg|PNG Files (*.PNG)|*.png|"
12           "EXR Files (*.EXR)|*.exr|TGA Files (*.TGA)|*.tga");
13 }
14
15 void OCC_BaseDoc::ExportView (const Handle(V3d_View)& theView) const
16 {
17    CFileDialog anExportDlg (FALSE,_T("*.BMP"),NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
18                             SupportedImageFormats() + "||", NULL );
19
20   if (anExportDlg.DoModal() == IDOK)
21   {
22     // Set waiting cursor
23     SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT));
24
25     CString aFileExt = anExportDlg.GetFileExt();
26     TCollection_AsciiString aFileName ((const wchar_t* )anExportDlg.GetPathName());
27
28     // For pixel formats use V3d_View:Dump() method
29     theView->Dump (aFileName.ToCString());
30
31     // Restore cursor
32     SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW));
33   }
34 }
35
36 //////////////////////////////////////////////////////////////////////
37 // Construction/Destruction
38 //////////////////////////////////////////////////////////////////////
39
40 OCC_BaseDoc::OCC_BaseDoc()
41 {
42
43 }
44
45 OCC_BaseDoc::~OCC_BaseDoc()
46 {
47
48 }
49
50 //=============================================================================
51 // function: ResetDocumentViews
52 // purpose:
53 //=============================================================================
54 void OCC_BaseDoc::ResetDocumentViews (CDocTemplate* theTemplate)
55 {
56   // do not delete document if no views
57   BOOL isAutoDelete = m_bAutoDelete;
58   m_bAutoDelete = FALSE;
59
60   // close all opened views
61   POSITION aViewIt = GetFirstViewPosition();
62   while (aViewIt)
63   {
64     CView* aView = GetNextView (aViewIt);
65     if (aView == NULL)
66     {
67       continue;
68     }
69
70     RemoveView (aView);
71
72     aView->GetParentFrame()->SendMessage (WM_CLOSE);
73   }
74
75   // create new view frame
76   CFrameWnd* aNewFrame = theTemplate->CreateNewFrame (this, NULL);
77   m_bAutoDelete = isAutoDelete;
78
79   // init frame
80   theTemplate->InitialUpdateFrame(aNewFrame, this);
81 }