7fd59977 |
1 | // OcafApp.cpp : Defines the class behaviors for the application. |
2 | // |
3 | |
4 | #include "StdAfx.h" |
5 | |
6 | #include "OcafApp.h" |
7 | |
8 | #include "OcafMainFrm.h" |
9 | #include <OCC_3dChildFrame.h> |
10 | #include "OcafDoc.h" |
11 | #include <OCC_3dView.h> |
12 | |
13 | #include "direct.h" |
14 | #include <OSD_Environment.hxx> |
15 | |
16 | ///////////////////////////////////////////////////////////////////////////// |
17 | // COcafApp |
18 | |
19 | BEGIN_MESSAGE_MAP(COcafApp, CWinApp) |
20 | //{{AFX_MSG_MAP(COcafApp) |
21 | ON_COMMAND(ID_APP_ABOUT, OnAppAbout) |
22 | // NOTE - the ClassWizard will add and remove mapping macros here. |
23 | // DO NOT EDIT what you see in these blocks of generated code! |
24 | //}}AFX_MSG_MAP |
25 | // Standard file based document commands |
26 | ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew) |
27 | ON_COMMAND(ID_FILE_OPEN, OnFileOpen) |
28 | // ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen) |
29 | END_MESSAGE_MAP() |
30 | |
31 | ///////////////////////////////////////////////////////////////////////////// |
32 | |
33 | ///////////////////////////////////////////////////////////////////////////// |
34 | // COcafApp construction |
35 | |
5c1f974e |
36 | COcafApp::COcafApp() : OCC_App() |
7fd59977 |
37 | { |
5c1f974e |
38 | SetSamplePath("06_Ocaf"); |
39 | myApp = new TOcaf_Application(); |
40 | SampleName = "OCAF"; //for about dialog |
7fd59977 |
41 | |
5c1f974e |
42 | try |
43 | { |
44 | UnitsAPI::SetLocalSystem(UnitsAPI_MDTV); |
45 | } |
46 | catch (Standard_Failure) |
47 | { |
48 | AfxMessageBox("Fatal Error in units initialisation"); |
49 | } |
7fd59977 |
50 | } |
51 | |
52 | ///////////////////////////////////////////////////////////////////////////// |
53 | // The one and only COcafApp object |
54 | |
55 | COcafApp theApp; |
56 | |
57 | ///////////////////////////////////////////////////////////////////////////// |
58 | // COcafApp initialization |
59 | |
60 | BOOL COcafApp::InitInstance() |
61 | { |
62 | AfxEnableControlContainer(); |
63 | |
64 | // Standard initialization |
65 | // If you are not using these features and wish to reduce the size |
66 | // of your final executable, you should remove from the following |
67 | // the specific initialization routines you do not need. |
68 | |
69 | // Change the registry key under which our settings are stored. |
70 | // You should modify this string to be something appropriate |
71 | // such as the name of your company or organization. |
72 | // Modified by CasCade : |
73 | SetRegistryKey(_T("Local CasCade Applications")); |
74 | |
75 | LoadStdProfileSettings(); // Load standard INI file options (including MRU) |
76 | |
77 | // Register the application's document templates. Document templates |
78 | // serve as the connection between documents, frame windows and views. |
79 | |
80 | pDocTemplateForView3d = new CMultiDocTemplate( |
81 | IDR_3DTYPE, |
82 | RUNTIME_CLASS(COcafDoc), |
83 | RUNTIME_CLASS(OCC_3dChildFrame), |
84 | RUNTIME_CLASS(OCC_3dView)); |
85 | AddDocTemplate(pDocTemplateForView3d); |
86 | |
87 | // create main MDI Frame window |
88 | OcafMainFrame* pMainFrame = new OcafMainFrame; |
89 | if (!pMainFrame->LoadFrame(IDR_MAINFRAME)) |
90 | return FALSE; |
91 | m_pMainWnd = pMainFrame; |
92 | |
93 | // Parse command line for standard shell commands, DDE, file open |
94 | CCommandLineInfo cmdInfo; |
95 | ParseCommandLine(cmdInfo); |
96 | |
97 | // Dispatch commands specified on the command line |
98 | if (!ProcessShellCommand(cmdInfo)) |
99 | return FALSE; |
100 | |
101 | // The main window has been initialized, so show and update it. |
102 | pMainFrame->ShowWindow(m_nCmdShow); |
103 | pMainFrame->UpdateWindow(); |
104 | |
105 | return TRUE; |
106 | } |
107 | |
108 | ///////////////////////////////////////////////////////////////////////////// |
109 | // COcafApp commands |
110 | |
111 | BOOL COcafApp::IsViewExisting(CDocument * pDoc, CRuntimeClass * pViewClass, CView * & pView) |
112 | { |
113 | ASSERT_VALID(pDoc); |
114 | ASSERT(pViewClass != (CRuntimeClass *)NULL ); |
115 | |
116 | POSITION position = pDoc->GetFirstViewPosition(); |
117 | while (position != (POSITION)NULL) |
118 | { |
119 | CView* pCurrentView = pDoc->GetNextView(position); |
120 | ASSERT_VALID(pCurrentView); |
121 | if (pCurrentView->IsKindOf(pViewClass)) |
122 | { |
123 | pView = pCurrentView; |
124 | return TRUE; |
125 | } |
126 | } |
127 | return FALSE; |
128 | } |
129 | |
130 | ///////////////////////////////////////////////////////////////////////////// |
131 | // COCcafApp message handlers |
132 | |
133 | //================================================================ |
134 | // Function : COcafApp::OnFileOpen() |
5c1f974e |
135 | // Purpose : |
7fd59977 |
136 | //================================================================ |
137 | void COcafApp::OnFileOpen() |
138 | { |
139 | CFileDialog aDlg(TRUE, NULL, NULL, OFN_FILEMUSTEXIST|OFN_HIDEREADONLY, |
cc1d74e2 |
140 | "OCAFSample(STD) (*.std)|*.std|OCAFSample(XML) (*.xml)|*.xml|OCAFSample(Binary) (*.cbf)|*.cbf||"); |
7fd59977 |
141 | |
142 | if (aDlg.DoModal() != IDOK) |
143 | return; |
144 | |
41335b96 |
145 | |
146 | int strLength = aDlg.GetPathName().GetLength()+1; |
7fd59977 |
147 | LPTSTR lpszFileName = new TCHAR[strLength]; |
41335b96 |
148 | strcpy_s(lpszFileName, strLength, aDlg.GetPathName() ); |
7fd59977 |
149 | |
150 | OpenDocumentFile(lpszFileName); |
151 | } |