void COCCDemoDoc::Fit() { CMDIFrameWnd *pFrame = (CMDIFrameWnd*)AfxGetApp()->m_pMainWnd; CMDIChildWnd *pChild = (CMDIChildWnd *) pFrame->GetActiveFrame(); COCCDemoView *pView = (COCCDemoView *) pChild->GetActiveView(); pView->FitAll(); }
void OCCDemo_Presentation::ResetView() { CMDIFrameWnd *pFrame = (CMDIFrameWnd*)AfxGetApp()->m_pMainWnd; CMDIChildWnd *pChild = (CMDIChildWnd *) pFrame->GetActiveFrame(); COCCDemoView *pView = (COCCDemoView *) pChild->GetActiveView(); pView->Reset(); }
void OCCDemo_Presentation::SetViewCenter(V3d_Coordinate Xc, V3d_Coordinate Yc) { CMDIFrameWnd *pFrame = (CMDIFrameWnd*)AfxGetApp()->m_pMainWnd; CMDIChildWnd *pChild = (CMDIChildWnd *) pFrame->GetActiveFrame(); COCCDemoView *pView = (COCCDemoView *) pChild->GetActiveView(); pView->SetViewCenter(Xc,Yc); }
void OCCDemo_Presentation::SetViewScale(Quantity_Factor Coef) { CMDIFrameWnd *pFrame = (CMDIFrameWnd*)AfxGetApp()->m_pMainWnd; CMDIChildWnd *pChild = (CMDIChildWnd *) pFrame->GetActiveFrame(); COCCDemoView *pView = (COCCDemoView *) pChild->GetActiveView(); pView->SetViewScale(Coef); }
void OCCDemo_Presentation::SetViewEye(V3d_Coordinate X, V3d_Coordinate Y, V3d_Coordinate Z) { CMDIFrameWnd *pFrame = (CMDIFrameWnd*)AfxGetApp()->m_pMainWnd; CMDIChildWnd *pChild = (CMDIChildWnd *) pFrame->GetActiveFrame(); COCCDemoView *pView = (COCCDemoView *) pChild->GetActiveView(); pView->SetViewEye(X,Y,Z); }
void CFileView::OnProperties() { CMDIFrameWnd *pMain = (CMDIFrameWnd*)AfxGetApp()->m_pMainWnd; CMDIChildWnd *pChild = (CMDIChildWnd *)pMain->GetActiveFrame(); CDocument* pDoc = NULL; pDoc = pChild->GetActiveDocument(); //9-8添加判断,如果不判断,都关闭后再点击项目管理项,程序会崩溃 if( pDoc!= NULL) { CString filePath=pDoc->GetPathName(); filePath.Trim(); filePath.MakeLower(); CString fileEx=filePath.Right(2); if(fileEx==_T(".t")) { int iLength = lstrlen(filePath) ; int iIndex = filePath.ReverseFind(L'\\') ; CString fileName = filePath.Right(iLength - iIndex - 1); ((CMainFrame*)AfxGetApp()->m_pMainWnd)->SetProjProperty(fileName,filePath); } else { ((CMainFrame*)AfxGetApp()->m_pMainWnd)->SetProjProperty(_T(""),_T("")); } } }
void CSideBar::OnPopupSidebarAttrUpdate() { // NB! This needs some work! CTreeCtrl& tree = GetTreeCtrl(); // since this may happen at any time, should really check for anything going badly wrong, // e.g., no current graph document: CMDIFrameWnd *pFrame = (CMDIFrameWnd*) AfxGetApp()->m_pMainWnd; CMDIChildWnd *pChild = (CMDIChildWnd *) pFrame->GetActiveFrame(); CDocument *pDoc = pChild->GetActiveDocument(); if (pDoc != m_treeDoc) { return; } if (m_popup_attribute == -1) { AfxMessageBox(_T("Cannot replace values for the reference number column")); return; } MetaGraph *graph = m_treeDoc->m_meta_graph; PointMap *pointmap = NULL; ShapeMap *shapemap = NULL; // Need to check what this does GetItemMap(graph,pointmap,shapemap); if (m_treeDoc->ReplaceColumnContents(pointmap, shapemap, m_popup_attribute)) { graph->setDisplayedAttribute(m_popup_attribute); m_treeDoc->SetUpdateFlag(CGraphDoc::NEW_DATA); m_treeDoc->SetRedrawFlag(CGraphDoc::VIEW_ALL, CGraphDoc::REDRAW_GRAPH, CGraphDoc::NEW_DATA ); } SwitchFocusBack(); }
Quantity_Factor OCCDemo_Presentation::GetViewScale() { CMDIFrameWnd *pFrame = (CMDIFrameWnd*)AfxGetApp()->m_pMainWnd; CMDIChildWnd *pChild = (CMDIChildWnd *) pFrame->GetActiveFrame(); COCCDemoView *pView = (COCCDemoView *) pChild->GetActiveView(); return pView->GetViewScale(); }
//颜色选择完成 LRESULT CMainFrame::OnSelEndOKColor(WPARAM wParam, LPARAM lParam) { UINT uiCmd = ( UINT )lParam; CMDIFrameWnd *pFrame = (CMDIFrameWnd*)AfxGetApp()->m_pMainWnd; CMDIChildWnd *pChild = (CMDIChildWnd *) pFrame->GetActiveFrame(); CDrawView *pView = (CDrawView*)pChild->GetActiveView(); if(pView == NULL) return 0; if ( uiCmd == ID_FORMATTING_COLOR ) { m_crCurrent = ( COLORREF )wParam; if(pView->m_selection.GetCount() >= 1) { POSITION pos = pView->m_selection.GetHeadPosition(); while(pos != NULL) { CDrawObj * pObj = pView->m_selection.GetNext(pos); if(pObj->IsKindOf(RUNTIME_CLASS(CDrawButton))) { CDrawButton *pButton = (CDrawButton *)pObj; pButton->m_color = m_crCurrent; pButton->Invalidate(); } } } pView->GetDocument()->SetModifiedFlag(); } if( uiCmd == ID_FORMATTING_BACK_COLOR) { m_crFillColor = ( COLORREF )wParam; if(pView->m_selection.GetCount() >= 1) { POSITION pos = pView->m_selection.GetHeadPosition(); while(pos != NULL) { CDrawObj * pObj = pView->m_selection.GetNext(pos); if(!pObj->IsKindOf(RUNTIME_CLASS(CDrawButton))) { pObj->m_clrFillColor = m_crFillColor; pObj->Invalidate(); } } } pView->GetDocument()->SetModifiedFlag(); } return 0; }
void CSideBar::SwitchFocusBack() { CMDIFrameWnd *pFrame = (CMDIFrameWnd*)AfxGetApp()->m_pMainWnd; // Get the active MDI child window. CMDIChildWnd *pChild = (CMDIChildWnd *) pFrame->GetActiveFrame(); // Get the active view attached to the active MDI child // window. CView *pView = pChild->GetActiveView(); pView->SetFocus(); }
CLuaView* CMainFrame::GetActiveView() { CMDIFrameWnd *pFrame = (CMDIFrameWnd*)AfxGetApp()->m_pMainWnd; CMDIChildWnd *pChild = (CMDIChildWnd *)pFrame->GetActiveFrame(); if ( !pChild ) return NULL; CView *pView = pChild->GetActiveView(); if ( pView && pView->IsKindOf(RUNTIME_CLASS(CLuaView)) ) return (CLuaView*)pView; return NULL; }
//字体或字号选择完成 void CMainFrame::OnSelEndOk() { int iSel = m_wndComboSize.GetCurSel( ); if ( iSel != CB_ERR ) { m_wndComboSize.GetLBText( iSel, m_strFontSize ); } else { m_wndComboSize.GetWindowText( m_strFontSize ); } //m_wndComboFont.GetWindowText(m_strFontName); m_wndComboFont.GetSelFont(m_strFontName); int nFontSize = atoi(m_strFontSize); CMDIFrameWnd *pFrame = (CMDIFrameWnd*)AfxGetApp()->m_pMainWnd; CMDIChildWnd *pChild = (CMDIChildWnd *) pFrame->GetActiveFrame(); CDrawView *pView = (CDrawView*)pChild->GetActiveView(); if(pView == NULL) return; if(pView->m_selection.GetCount() >= 1) { POSITION pos = pView->m_selection.GetHeadPosition(); while(pos != NULL) { CDrawObj * pObj = pView->m_selection.GetNext(pos); if(pObj->IsKindOf(RUNTIME_CLASS(CDrawButton))) { CDrawButton *pButton = (CDrawButton *)pObj; if(m_strFontName.GetLength() > 0) { pButton->m_fontName = m_strFontName; } if( nFontSize > 0) pButton->m_fontSize = nFontSize; pButton->Invalidate(); } } } pView->GetDocument()->SetModifiedFlag(); }
static void on_view(mfc_term_view *view) { if (view && IsWindow(view->m_hWnd)) { CMDIFrameWnd *fw = (CMDIFrameWnd *)(the_boss.m_pMainWnd); if (view->is_visible) { CMDIChildWnd *cw = (CMDIChildWnd *)fw->GetActiveFrame(); if (view == cw->GetActiveView()) fw->MDINext(); view->GetParent()->ShowWindow(SW_HIDE); } else { view->GetParent()->ShowWindow(SW_SHOW); fw->MDIActivate(view->GetParent()); } view->is_visible = !view->is_visible; SendMessage(fw->m_hWndMDIClient, WM_MDIREFRESHMENU, 0, 0); } }
void CSideBar::OnPopupSidebarAttrDelete() { CTreeCtrl& tree = GetTreeCtrl(); // since this may happen at any time, should really check for anything going badly wrong, // e.g., no current graph document: CMDIFrameWnd *pFrame = (CMDIFrameWnd*) AfxGetApp()->m_pMainWnd; CMDIChildWnd *pChild = (CMDIChildWnd *) pFrame->GetActiveFrame(); CDocument *pDoc = pChild->GetActiveDocument(); if (pDoc != m_treeDoc) { return; } MetaGraph *graph = m_treeDoc->m_meta_graph; if (graph->viewingProcessed()) { AttributeTable& table = graph->getAttributeTable(); if (table.isColumnLocked(m_popup_attribute)) { AfxMessageBox(_T("Cannot remove locked column")); } else if (IDYES == AfxMessageBox(CString("Are you sure you want to delete the ") + table.getColumnName(m_popup_attribute).c_str() + CString(" column?"), MB_YESNO)) { bool displayed = graph->getDisplayedAttribute() == m_popup_attribute; // note this -1 simply means shift back one if (displayed) { // note, cannot delete the ref column, so minimum is display -1 graph->setDisplayedAttribute(m_popup_attribute - 1); } int view_class = graph->getViewClass() & (MetaGraph::VIEWVGA | MetaGraph::VIEWAXIAL | MetaGraph::VIEWDATA); switch (view_class) { case MetaGraph::VIEWVGA: case MetaGraph::VIEWBACKVGA: graph->PointMaps::getDisplayedPointMap().removeAttribute(m_popup_attribute); break; case MetaGraph::VIEWAXIAL: case MetaGraph::VIEWBACKAXIAL: graph->getShapeGraphs().getDisplayedMap().removeAttribute(m_popup_attribute); break; case MetaGraph::VIEWDATA: case MetaGraph::VIEWBACKDATA: graph->getDataMaps().getDisplayedMap().removeAttribute(m_popup_attribute); break; } m_treeDoc->SetUpdateFlag(CGraphDoc::NEW_DATA); // some views need to react to this for their column titles: m_treeDoc->SetRedrawFlag(CGraphDoc::VIEW_ALL, CGraphDoc::REDRAW_GRAPH, CGraphDoc::NEW_COLUMN ); } } SwitchFocusBack(); }
void CSideBar::OnPopupSidebarAttrRename() { CTreeCtrl& tree = GetTreeCtrl(); // since this may happen at any time, should really check for anything going badly wrong, // e.g., no current graph document: CMDIFrameWnd *pFrame = (CMDIFrameWnd*) AfxGetApp()->m_pMainWnd; CMDIChildWnd *pChild = (CMDIChildWnd *) pFrame->GetActiveFrame(); CDocument *pDoc = pChild->GetActiveDocument(); if (pDoc != m_treeDoc) { return; } MetaGraph *graph = m_treeDoc->m_meta_graph; bool displayed = (graph->getDisplayedAttribute() == m_popup_attribute); AttributeTable *tab = NULL; int view_class = graph->getViewClass() & (MetaGraph::VIEWVGA | MetaGraph::VIEWAXIAL | MetaGraph::VIEWDATA); switch (view_class) { case MetaGraph::VIEWVGA: case MetaGraph::VIEWBACKVGA: tab = &(graph->PointMaps::getDisplayedPointMap().getAttributeTable()); break; case MetaGraph::VIEWAXIAL: case MetaGraph::VIEWBACKAXIAL: tab = &(graph->getShapeGraphs().getDisplayedMap().getAttributeTable()); break; case MetaGraph::VIEWDATA: case MetaGraph::VIEWBACKDATA: tab = &(graph->getDataMaps().getDisplayedMap().getAttributeTable()); break; } if (tab != NULL) { int newcol = m_treeDoc->RenameColumn(tab, m_popup_attribute); if (newcol != -1) { m_treeDoc->SetUpdateFlag(CGraphDoc::NEW_DATA); graph->setDisplayedAttribute(newcol); m_treeDoc->SetRedrawFlag(CGraphDoc::VIEW_ALL, CGraphDoc::REDRAW_GRAPH, CGraphDoc::NEW_COLUMN ); } } SwitchFocusBack(); }
void CSideBar::OnPopupSidebarAttrProperties() { CTreeCtrl& tree = GetTreeCtrl(); // since this may happen at any time, should really check for anything going badly wrong, // e.g., no current graph document: CMDIFrameWnd *pFrame = (CMDIFrameWnd*) AfxGetApp()->m_pMainWnd; CMDIChildWnd *pChild = (CMDIChildWnd *) pFrame->GetActiveFrame(); CDocument *pDoc = pChild->GetActiveDocument(); if (pDoc != m_treeDoc) { return; } MetaGraph *graph = m_treeDoc->m_meta_graph; if (graph->viewingProcessed()) { AttributeTable& table = graph->getAttributeTable(); CColumnPropertiesDlg dlg(&table, m_popup_attribute); dlg.DoModal(); } SwitchFocusBack(); }
BOOL CStartDoc::OnOpenDocument(LPCTSTR lpszPathName) { CMDIFrameWnd *pFrame = (CMDIFrameWnd*)AfxGetApp()->m_pMainWnd; // Get the active MDI child window. CMDIChildWnd *pChild = (CMDIChildWnd *) pFrame->GetActiveFrame(); CStartView *pView = NULL; POSITION pos = GetFirstViewPosition(); pView = (CStartView *) GetNextView(pos); SetTitle(_T("示例")); /*if (!CDocument::OnOpenDocument(lpszPathName)) return FALSE;*/ // TODO: 在此添加您专用的创建代码 return TRUE; }
// Returns the name of the currently opened file, including extension (if saved). CString CTemplateFormater::GetFile(void) { // Use the generic view class to make this class as portable as possible CView* pView = NULL; CMDIFrameWnd* pFrame = reinterpret_cast<CMDIFrameWnd*>(AfxGetApp()->m_pMainWnd); // Get the active MDI child window. CMDIChildWnd* pChild = reinterpret_cast<CMDIChildWnd*>(pFrame->GetActiveFrame()); // or CMDIChildWnd *pChild = pFrame->MDIGetActive(); // Get the active view attached to the active MDI child window. pView = reinterpret_cast<CView*>(pChild->GetActiveView()); ASSERT(pView != NULL); // If at this point the view could not be obtained, the leave if (pView != NULL) { CDocument* pDoc = pView->GetDocument(); ASSERT(pDoc != NULL); if (pDoc != NULL) { CString strPathName = pDoc->GetPathName(); if (!strPathName.IsEmpty()) { CCFileSpec fs(strPathName); //NOTE: This part is not portable! return fs.GetFileName(); } else { return pDoc->GetTitle(); } } } return _T(""); };
void CChildView::OnPaint() { CRect pos(0, 0, 0, 0); HotSpots.clear(); CPaintDC pdc(this); // device context for painting CMemDC m(pdc, this); CDC& dc = m.GetDC(); CRect client; GetClientRect(&client); dc.FillSolidRect(&client, crBackground); if (!m_pClass) return; dc.SelectObject(&Font); HotSpots.clear(); DWORD classSize = m_pClass->GetMemorySize(); Memory.SetSize(classSize); ReadMemory((LPVOID)m_pClass->offset, Memory.pMemory, classSize); ViewInfo View; View.Address = m_pClass->offset; View.pData = Memory.pMemory; View.Classes = &theApp.Classes; View.client = &client; View.dc = &dc; View.Level = 0; View.HotSpots = &HotSpots; View.bMultiSelected = (Selected.size() > 1) ? true : false; int ypos = m_Scroll.GetScrollPos() * FontHeight; if (m_Scroll.IsWindowVisible()) View.client->right -= SB_WIDTH; int DrawMax = m_pClass->Draw(View, 0, -ypos) + ypos; if (m_pClass->RequestPosition != -1) { if ((m_pClass->RequestPosition >= 0) && ((unsigned int)m_pClass->RequestPosition < theApp.Classes.size())) { int idx = -1; for (UINT i = 0; i < theApp.Classes.size(); i++) { CNodeClass* pClass = View.Classes->at(i); if (m_pClass == theApp.Classes[i]) idx = i; } theApp.Classes.erase(theApp.Classes.begin() + idx); theApp.Classes.insert(theApp.Classes.begin() + m_pClass->RequestPosition, m_pClass); } m_pClass->RequestPosition = -1; } if (client.Height() < DrawMax) { SCROLLINFO si; si.cbSize = sizeof(SCROLLINFO); si.fMask = SIF_PAGE | SIF_RANGE; si.nMin = 0; si.nMax = DrawMax / FontHeight; si.nPage = client.Height() / FontHeight; m_Scroll.SetScrollInfo(&si); m_Scroll.ShowScrollBar(1); } else { m_Scroll.SetScrollPos(0); m_Scroll.ShowScrollBar(0); } // this makes tabs CMDIFrameWnd* pFrame = (CMDIFrameWnd*)AfxGetApp()->m_pMainWnd; CChildFrame* pChild = (CChildFrame*)pFrame->GetActiveFrame(); if (pChild->m_wndView.m_hWnd == this->m_hWnd) { pChild->SetWindowText(m_pClass->Name.GetString()); pChild->SetTitle(m_pClass->Name.GetString()); pFrame->UpdateFrameTitleForDocument(m_pClass->Name.GetString()); //char txt[256]; //sprintf (txt,"Total HotSpots: %i",HotSpots.size()); //dc.SetTextColor(0xFF0000); //dc.SetBkColor(0x000000); //dc.SetBkMode(OPAQUE); //dc.DrawText(txt,-1,&CRect(0,0,0,0), DT_LEFT | DT_NOCLIP | DT_NOPREFIX); } //for (UINT i=0; i < HotSpots.size();i++) //{ // dc.DrawFocusRect(HotSpots[i].Rect); //} }
void CSideBar::OnSelchangingSidebarTree(NMHDR* pNMHDR, LRESULT* pResult) { NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR; switch (pNMTreeView->action) { case TVC_UNKNOWN: case TVC_BYMOUSE: case TVC_BYKEYBOARD: break; default: // shouldn't have received this, ignore completely: *pResult = TRUE; return; } CTreeCtrl& tree = GetTreeCtrl(); HTREEITEM hItem = pNMTreeView->itemNew.hItem; // since this may happen at any time, should really check for anything going badly wrong, // e.g., no current graph document: CMDIFrameWnd *pFrame = (CMDIFrameWnd*) AfxGetApp()->m_pMainWnd; CMDIChildWnd *pChild = (CMDIChildWnd *) pFrame->GetActiveFrame(); CDocument *pDoc = pChild->GetActiveDocument(); if (pDoc != m_treeDoc) { return; } MetaGraph *graph = m_treeDoc->m_meta_graph; // look it up in the table to see what to do: size_t n = m_treegraphmap.searchindex(hItem); if (n != paftl::npos) { CTreeEntry entry = m_treegraphmap.value(n); bool remenu = false; if (entry.m_cat != -1) { if (entry.m_subcat == -1) { switch (entry.m_type) { case 0: if (graph->getViewClass() & MetaGraph::VIEWVGA) { if (graph->getDisplayedPointMapRef() == entry.m_cat) { graph->setViewClass(MetaGraph::SHOWHIDEVGA); } else { graph->setDisplayedPointMapRef(entry.m_cat); } } else { graph->setDisplayedPointMapRef(entry.m_cat); graph->setViewClass(MetaGraph::SHOWVGATOP); } remenu = true; break; case 1: if (graph->getViewClass() & MetaGraph::VIEWAXIAL) { if (graph->getShapeGraphs().getDisplayedMapRef() == entry.m_cat) { graph->setViewClass(MetaGraph::SHOWHIDEAXIAL); } else { graph->getShapeGraphs().setDisplayedMapRef(entry.m_cat); } } else { graph->getShapeGraphs().setDisplayedMapRef(entry.m_cat); graph->setViewClass(MetaGraph::SHOWAXIALTOP); } remenu = true; break; case 2: if (graph->getViewClass() & MetaGraph::VIEWDATA) { if (graph->getDataMaps().getDisplayedMapRef() == entry.m_cat) { graph->setViewClass(MetaGraph::SHOWHIDESHAPE); } else { graph->getDataMaps().setDisplayedMapRef(entry.m_cat); } } else { graph->getDataMaps().setDisplayedMapRef(entry.m_cat); graph->setViewClass(MetaGraph::SHOWSHAPETOP); } remenu = true; break; case 4: // slightly different for this one break; } if (remenu) { SetGraphTreeChecks(); m_treeDoc->SetRemenuFlag(CGraphDoc::VIEW_ALL, true); GetApp()->GetMainWnd()->PostMessage( WM_DMP_FOCUS_GRAPH, (WPARAM) m_treeDoc, CGraphDoc::CONTROLS_CHANGEATTRIBUTE ); } m_treeDoc->SetRedrawFlag(CGraphDoc::VIEW_ALL, CGraphDoc::REDRAW_GRAPH, CGraphDoc::NEW_TABLE ); } else if (entry.m_subcat == -2) { // hit editable box if (SetEditable(entry)) { // update required (but probably not a redraw of the views) SetGraphTreeChecks(); } } else { // They've clicked on the displayed layers bool update = false; if (entry.m_type == 1) { bool show = graph->getShapeGraphs().getMap(entry.m_cat).isLayerVisible(entry.m_subcat); graph->getShapeGraphs().getMap(entry.m_cat).setLayerVisible(entry.m_subcat, !show); update = true; } else if (entry.m_type == 2) { bool show = graph->getDataMaps().getMap(entry.m_cat).isLayerVisible(entry.m_subcat); graph->getDataMaps().getMap(entry.m_cat).setLayerVisible(entry.m_subcat, !show); update = true; } if (update) { // Update required for the check boxes SetGraphTreeChecks(); // Depending on if the map is displayed you may have to redraw -- I'm just going to redraw *anyway* // (it may be worth switching it to topmost when they do click here) m_treeDoc->SetRedrawFlag(CGraphDoc::VIEW_ALL, CGraphDoc::REDRAW_GRAPH, CGraphDoc::NEW_TABLE ); } } } } else { size_t n = m_treedrawingmap.searchindex(hItem); if (n != paftl::npos) { CTreeEntry entry = m_treedrawingmap.value(n); if (entry.m_subcat != -1) { if (graph->getLineLayer(entry.m_cat,entry.m_subcat).isShown()) { graph->getLineLayer(entry.m_cat,entry.m_subcat).setShow(false); graph->PointMaps::redoBlockLines(); graph->resetBSPtree(); tree.SetItemImage(hItem,13,13); } else { graph->getLineLayer(entry.m_cat,entry.m_subcat).setShow(true); graph->PointMaps::redoBlockLines(); graph->resetBSPtree(); tree.SetItemImage(hItem,12,12); } } m_treeDoc->SetRedrawFlag(CGraphDoc::VIEW_ALL, CGraphDoc::REDRAW_GRAPH, CGraphDoc::NEW_LINESET ); } } // this doesn't appear to work (at least not always)... SwitchFocusBack(); // we handled it... don't let it select: *pResult = TRUE; }
void CFontPreviewWnd::OnPaint() { CPaintDC dc(this); // device context for painting // Draw the background CRect rct; GetClientRect(rct); dc.FillSolidRect(&rct, RGB(255, 255, 255)); // Get the active view CMDIFrameWnd *pFrame = (CMDIFrameWnd*)GET_PMWAPP()->m_pMainWnd; CMDIChildWnd *pChild = (CMDIChildWnd *) pFrame->GetActiveFrame(); CPmwView *pView = (CPmwView *)pChild->GetActiveView(); // Find the current document CPmwDoc* pDoc = (CPmwDoc*)(pChild->GetActiveDocument()); ASSERT(pDoc != NULL); // Get the database PMGDatabasePtr database = pDoc->get_database(); // Get the current style CTextStyle Style(database); CTxp* pTxp = pView->GetTxp(); Style = pTxp->Style(); // If text color is white, make it black so we can see it FillFormatV1& Fill = Style.Fill(); if (Fill.m_ForegroundColor == COLOR_WHITE) { Fill.m_ForegroundColor = COLOR_BLACK; } // Get the entry for this face. FaceEntry* entry; int face_to_use = m_nFontID; int font_number = -1; if ((entry = typeface_server.face_list.get_face(face_to_use)) != NULL) { int nVariation = 0; if (Style.Bold()) { nVariation |= FONT_STYLE_Bold; } if (Style.Italic()) { nVariation |= FONT_STYLE_Italic; } VARIATION_TYPE vtype = entry->get_variation_type(nVariation); if (vtype == VARIATION_TYPE_VIRTUAL || vtype == VARIATION_TYPE_REGISTRATION) { // We want to use the preview font for "virtual" (PMW.FFL) fonts. Check if // the font has an entry in the preview font. font_number = entry->get_preview_font_number(nVariation); if (font_number != -1) { // Set the font number back to -1 in case we fail. It will // be reloaded if we can sucessfully use the preview font. font_number = -1; // We want to use the font preview. Try to switch to the preview font. PCSTR pn = typeface_server.preview_face_name(); if (pn != NULL) { int found_face; if ((found_face = typeface_server.find_face(pn, FALSE)) != -1) { face_to_use = found_face; font_number = entry->get_preview_font_number(nVariation); } } } } } // Get a database record for this face. // This will be a 'temporary' reference which we must free. PMGFontServer *pFontServer = (PMGFontServer*)pDoc->get_font_server(); DB_RECORD_NUMBER f_record = pFontServer->font_face_to_record(face_to_use); // Set the face in the style. The style gets its own reference. Style.Font(f_record); // Default to 36 point. Style.BaseSize(MakeFixed(36)); Style.Size(Style.BaseSize()); Style.UpdateFontMetrics(); // Free our temp reference. database->free_font_record(f_record, TRUE); // Build the redisplay context. RedisplayContext rc; rc.destination_hdc = dc.m_hDC; rc.hwnd = m_hWnd; rc.scaled_source_x0 = rc.scaled_source_y0 = 0; rc.destination_rect = rct; rc.destination_x0 = 0; rc.destination_y0 = 0; rc.x_resolution = GetDeviceCaps(dc.m_hDC, LOGPIXELSX); rc.y_resolution = GetDeviceCaps(dc.m_hDC, LOGPIXELSY); //rc.outline_gamma_curve = rc.bitmap_gamma_curve = screen_gamma_curve; //rc.set_check_interrupt(standard_check_interrupt, (void*)&rc); rc.terminate_interrupts = TRUE; rc.clip_rect = rct; // Initialize the redisplay context so we can use it rc.set_info(dc.m_hDC); rc.screen_to_pbox(&rct, &rc.source_pbox); // Create the frame object now. FRAMEOBJ_CREATE_STRUCT fcs; fcs.alignment = ALIGN_center; fcs.vert_alignment = ALIGN_middle; fcs.bound = rc.source_pbox; CFrameObject* pObject; if ((pObject = database->create_frame_object(&fcs)) != NULL) { // This object is not on the page! pObject->OnPage(FALSE); // Nor is it selected! pObject->remove_select_flags(SELECT_FLAG_boundary); // Prepare to add some text. CTxp Txp(database); CHARACTER Text[4]; if (font_number == -1) { Text[0] = 'T'; Text[1] = 'y'; Text[2] = 'p'; Text[3] = 'e'; } else { // We substituted the preview font int ch_base = font_number*4 + '!'; Text[0] = ch_base++; Text[1] = ch_base++; Text[2] = ch_base++; Text[3] = ch_base++; } // Stick in some text Txp.Init(pObject, 0); Txp.SetHorizontalAlignment(ALIGN_center); Txp.Style(Style); Txp.InsertText(Text, 4); // Select our palette in. CPalette* pOldPalette = dc.SelectPalette(pOurPal, FALSE); if (pOldPalette != NULL) { dc.RealizePalette(); } // And draw the object! UpdateStatePtr ustate; if ((ustate = pObject->update(&rc, &fcs.bound, &rct, NULL, REFRESH_ALL)) != NULL) { // See what happened switch (ustate->type) { case UPDATE_TYPE_Interrupted: { // This should not happen delete ustate; // Fall through to... } case UPDATE_TYPE_Terminated: { // Try again later InvalidateRect(&rct, FALSE); break; } default: { break; } } } pObject->destroy(); // Remove from the document. delete pObject; // Select our palette back out. if (pOldPalette != NULL) { dc.SelectPalette(pOldPalette, FALSE); } } // Do not call CBarMRUCombo::OnPaint() for painting messages }
void KSceneModelEditorSFXNewDialog::OnButtonSpeedtree() { HRESULT hrResult = E_FAIL; HRESULT hrRetCode = E_FAIL; IEKG3DModel *pModel = NULL; IEKG3DModelTable *pModelTable = NULL; IEKG3DModelSpeedTree* pModelTree = NULL; IEKG3DModel *pModelTreeModel = NULL; INT nNumBones = 0; //TCHAR strPartFileName[MAX_PATH]; POSITION ViewPos; DWORD dwType; CString strSpdTreeName; LPCSTR strBuffer; KSceneModelEditorFrameWnd *pFrameWnd = NULL; int nReturn = MessageBox("要把现有模型转换成speedtree吗?", "提示", MB_YESNO); KG_PROCESS_SUCCESS(nReturn != IDYES); KG_PROCESS_ERROR(m_lpSceneModelEditor); hrRetCode = m_lpSceneModelDoc->GetCurrentModel(&pModel); KG_COM_PROCESS_ERROR (hrRetCode); pModel->GetType(&dwType); KG_PROCESS_ERROR(dwType == MESHTYPE_DEFAULT); hrRetCode = pModel->GetNumBones(&nNumBones); KG_COM_PROCESS_ERROR(hrRetCode); if (!nNumBones) { MessageBox("转化为SpeedTree失败,确认是带骨胳的模型."); KG_PROCESS_ERROR(nNumBones); } hrRetCode = g_pEngineManager->GetIEKG3DModelTable(&pModelTable); KG_COM_PROCESS_ERROR (hrRetCode); hrRetCode = pModelTable->IEGet1NewResourse(&pModelTreeModel, MESHTYPE_SPEEDTREE); KGLOG_COM_PROCESS_ERROR(hrRetCode); hrRetCode = pModelTreeModel->GetIEKG3DModelSpeedTree(&pModelTree); KGLOG_COM_PROCESS_ERROR(hrRetCode); hrRetCode = pModelTree->Init(pModel); if (FAILED(hrRetCode)) { MessageBox("转化为SpeedTree失败"); } KG_COM_PROCESS_ERROR(hrRetCode); pModel->GetName(&strBuffer); strSpdTreeName = strBuffer; strSpdTreeName.MakeLower(); m_lpSceneModelEditor->OpenModel(pModelTreeModel, FALSE); ViewPos = m_lpSceneModelDoc->GetFirstViewPosition(); if (ViewPos) { KSceneModelEditorView* pView = static_cast<KSceneModelEditorView*>(m_lpSceneModelDoc->GetNextView(ViewPos)); if (pView) { pView->Zoom(); } } int nStartPos = strSpdTreeName.Find(".mesh", 0); strSpdTreeName.Insert(nStartPos, "_ST"); m_lpSceneModelDoc->SetPathName(strSpdTreeName + ".stree"); CMDIFrameWnd *pMainFrame = (CMDIFrameWnd*)AfxGetMainWnd(); KG_PROCESS_ERROR(pMainFrame); pFrameWnd = (KSceneModelEditorFrameWnd*)pMainFrame->GetActiveFrame(); KG_PROCESS_ERROR(pFrameWnd); pFrameWnd->OnModelChange(0, 0); Exit1: hrResult = S_OK; Exit0: /*if (FAILED(hrResult)) { SAFE_RELEASE(pModel); }*/ OnOK(); }