1 // HLRApp.cpp : Defines the class behaviors for the application.
8 #include <OCC_MainFrame.h>
9 #include <OCC_3dChildFrame.h>
11 #include <OCC_2dChildFrame.h>
12 #include "HLRView2D.h"
13 #include <OCC_3dView.h>
18 //#define new DEBUG_NEW
22 static char THIS_FILE[] = __FILE__;
25 /////////////////////////////////////////////////////////////////////////////
26 // CHLRApp construction
28 CHLRApp::CHLRApp() : OCC_App()
30 SampleName = "HLR"; //for about dialog
31 SetSamplePath (L"..\\..\\08_HLR");
36 delete pDocTemplateForView2d;
39 /////////////////////////////////////////////////////////////////////////////
40 // The one and only CHLRApp object
44 /////////////////////////////////////////////////////////////////////////////
45 // CHLRApp initialization
47 BOOL CHLRApp::InitInstance()
49 AfxEnableControlContainer();
51 // Standard initialization
52 // If you are not using these features and wish to reduce the size
53 // of your final executable, you should remove from the following
54 // the specific initialization routines you do not need.
56 // Change the registry key under which our settings are stored.
57 // You should modify this string to be something appropriate
58 // such as the name of your company or organization.
59 // Modified by CasCade :
60 SetRegistryKey(_T("Local CasCade Applications"));
62 LoadStdProfileSettings(); // Load standard INI file options (including MRU)
64 // Register the application's document templates. Document templates
65 // serve as the connection between documents, frame windows and views.
70 pDocTemplateForView2d = new CMultiDocTemplate(
72 RUNTIME_CLASS(CHLRDoc),
73 RUNTIME_CLASS(OCC_2dChildFrame), // custom MDI child frame
74 RUNTIME_CLASS(CHLRView2D));
76 // AddDocTemplate(pDocTemplateForView2d);
79 pDocTemplateForView3d = new CMultiDocTemplate(
81 RUNTIME_CLASS(CHLRDoc),
82 RUNTIME_CLASS(OCC_3dChildFrame), // custom MDI child frame
83 RUNTIME_CLASS(OCC_3dView));
85 AddDocTemplate(pDocTemplateForView3d);
88 // create main MDI Frame window
89 OCC_MainFrame* pMainFrame = new OCC_MainFrame(with_AIS_TB);
90 if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
92 m_pMainWnd = pMainFrame;
94 // Parse command line for standard shell commands, DDE, file open
95 CCommandLineInfo cmdInfo;
96 ParseCommandLine(cmdInfo);
98 // Dispatch commands specified on the command line
99 if (!ProcessShellCommand(cmdInfo))
102 // The main window has been initialized, so show and update it.
103 pMainFrame->MDITile(MDITILE_VERTICAL);
104 pMainFrame->ShowWindow(m_nCmdShow);
105 pMainFrame->UpdateWindow();
110 /////////////////////////////////////////////////////////////////////////////
113 //===================================================
115 CFrameWnd* CHLRApp::CreateView2D(CHLRDoc* pDoc )
118 ASSERT_VALID(pDocTemplateForView2d);
119 CRuntimeClass * pViewClass = RUNTIME_CLASS(OCC_2dView);
120 ASSERT(pViewClass != (CRuntimeClass *)NULL );
121 // Create a new frame window
122 CFrameWnd* pNewFrame = pDocTemplateForView2d->CreateNewFrame(pDoc, NULL);
124 pDocTemplateForView2d->InitialUpdateFrame(pNewFrame, pDoc);
129 //===================================================
130 CFrameWnd* CHLRApp::CreateView3D(CHLRDoc* pDoc )
133 ASSERT_VALID(pDocTemplateForView3d);
134 CRuntimeClass * pViewClass = RUNTIME_CLASS(OCC_3dView);
135 ASSERT(pViewClass != (CRuntimeClass *)NULL );
136 // Create a new frame window
137 CFrameWnd* pNewFrame = pDocTemplateForView3d->CreateNewFrame(pDoc, NULL);
138 pDocTemplateForView3d->InitialUpdateFrame(pNewFrame, pDoc);
144 BOOL CHLRApp::IsViewExisting(CDocument * pDoc, CRuntimeClass * pViewClass, CView * & pView)
147 ASSERT(pViewClass != (CRuntimeClass *)NULL );
149 POSITION position = pDoc->GetFirstViewPosition();
150 while (position != (POSITION)NULL)
152 CView* pCurrentView = pDoc->GetNextView(position);
153 ASSERT_VALID(pCurrentView);
154 if (pCurrentView->IsKindOf(pViewClass))
156 pView = pCurrentView;