void C图片管理器App::OnMyfile() { // TODO: 在此添加命令处理程序代码 OnFileNew(); CMainFrame* cm = (CMainFrame*)m_pMainWnd; C图片管理器Doc* cd = (C图片管理器Doc*)cm->GetActiveFrame()->GetActiveDocument(); if (!cd->LoadImage()) ((CChildFrame*)cm->GetActiveFrame())->ExitWithoutQuery(); }
CBCGPTabWnd * CxViewMgr::GetViewTab( LPCTSTR lpszViewName ) { VIEW_DATA * pViewData = Find(lpszViewName); if (pViewData == NULL) return NULL; if ( pViewData->m_pView == NULL ) return NULL; if ( !::IsWindow( pViewData->m_pView->GetSafeHwnd() ) ) return NULL; if (theApp.m_pMainWnd == NULL) return NULL; if ( !::IsWindow( theApp.m_pMainWnd->GetSafeHwnd() ) ) return NULL; CMainFrame * pMainFrame = reinterpret_cast< CMainFrame * > ( theApp.m_pMainWnd ); if (pMainFrame == NULL) return NULL; CMDIChildWndEx * pFrame = reinterpret_cast< CMDIChildWndEx * > ( pMainFrame->GetActiveFrame() ); if (pFrame == NULL) return NULL; CBCGPTabWnd * pTab = (CBCGPTabWnd *)pFrame->GetRelatedTabGroup(); if (pTab == NULL) return NULL; int nTabs = pTab->GetTabsNum(); CString strTabLabel; for (int i=0; i<nTabs; i++) { pTab->GetTabLabel(i, strTabLabel); if (strTabLabel == pViewData->m_strTitle) { return pTab; } } return NULL; }
void CxViewMgr::ActiveView( VIEW_DATA * pView ) { if (pView == NULL) return; if ( pView->m_pView == NULL ) return; if ( !::IsWindow( pView->m_pView->GetSafeHwnd() ) ) return; if (theApp.m_pMainWnd == NULL) return; if ( !::IsWindow( theApp.m_pMainWnd->GetSafeHwnd() ) ) return; CMainFrame * pMainFrame = reinterpret_cast< CMainFrame * > ( theApp.m_pMainWnd ); if (pMainFrame == NULL) return; CMDIChildWndEx * pFrame = reinterpret_cast< CMDIChildWndEx * > ( pMainFrame->GetActiveFrame() ); if (pFrame == NULL) return; CBCGPTabWnd * pTabCtrl = (CBCGPTabWnd * )pFrame->GetRelatedTabGroup(); if (pTabCtrl == NULL) return; int nTabs = pTabCtrl->GetTabsNum(); CString strTabLabel; for (int i=0; i<nTabs; i++) { pTabCtrl->GetTabLabel(i, strTabLabel); if (strTabLabel == pView->m_strTitle) { pTabCtrl->SetActiveTab(i); break; } } }
void CMy3DSmartCityView::OnInitialUpdate() { CView::OnInitialUpdate(); mOSG->InitOSG(); mThreadHandle=(HANDLE)_beginthread(&COSGObject::Render,0,mOSG); // TODO: 在此添加专用代码和/或调用基类 CMainFrame* pFrame = (CMainFrame*)AfxGetApp()->m_pMainWnd; SmartCityTreeView* leftView = (SmartCityTreeView*)pFrame->GetActiveFrame(); SmartCityTreeView* leftView001=(SmartCityTreeView*)pFrame->m_wndSplitter.GetPane(0,0); CMy3DSmartCityView* pRightView = (CMy3DSmartCityView*)pFrame->m_wndSplitter.GetPane(0,1); tree.Create(WS_VISIBLE | WS_TABSTOP | WS_CHILD | WS_BORDER | TVS_HASBUTTONS | TVS_LINESATROOT | TVS_HASLINES | TVS_DISABLEDRAGDROP | TVS_NOTOOLTIPS | TVS_EDITLABELS, CRect(0, 30, 250, 1000), leftView001, 1200); tree.ShowWindow(SW_SHOW); tree.ModifyStyle( TVS_CHECKBOXES, 0 ); tree.ModifyStyle( 0, TVS_CHECKBOXES ); HTREEITEM hRoot; CString str="图层名称"; hRoot=tree.InsertItem(str); tree.SetCheck(hRoot); HTREEITEM hChild ; for(vector<string>::iterator it=pRightView->mOSG->layernames.begin();it!=pRightView->mOSG->layernames.end();it++) { layerName = it->c_str(); hChild=tree.InsertItem(layerName,hRoot); tree.SetCheck(hChild); } }
CSeriousSkaStudioView* CSeriousSkaStudioApp::GetActiveView(void) { CSeriousSkaStudioView *res; CMainFrame* pMainFrame = STATIC_DOWNCAST(CMainFrame, AfxGetMainWnd()); res = DYNAMIC_DOWNCAST(CSeriousSkaStudioView, pMainFrame->GetActiveFrame()->GetActiveView()); return res; }
void C图片管理器App::OnFileOpen() { OnFileNew(); CMainFrame* cm = (CMainFrame*)m_pMainWnd; C图片管理器Doc* cd = (C图片管理器Doc*)cm->GetActiveFrame()->GetActiveDocument(); if (!cd) return; cd->OnFileOpen(); return; // TODO: 在此添加命令处理程序代码 }
void AppState::OpenScriptAtLine(ScriptId script, int iLine) { CMainFrame *pMainWnd = static_cast<CMainFrame*>(_pApp->m_pMainWnd); if (script.GetResourceNumber() == InvalidResourceNumber) { WORD wScriptNumber; GetResourceMap().GetScriptNumber(script, wScriptNumber); script.SetResourceNumber(wScriptNumber); } CScriptDocument *pDoc = pMainWnd->Tabs().ActivateScript(script); if (pDoc == nullptr) { // Make an new one. pDoc = static_cast<CScriptDocument*>(_pScriptTemplate->OpenDocumentFile(script.GetFullPath().c_str(), TRUE)); if (pDoc) { pDoc->SetTitle(script.GetFileNameOrig().c_str()); pDoc->SetDependencyTracker(GetResourceMap().GetDependencyTracker()); } } if (pDoc) { // We lost context... pDoc->SetScriptNumber(script.GetResourceNumber()); CFrameWnd *pFrame = pMainWnd->GetActiveFrame(); if (pFrame) { CView *pView = pFrame->GetActiveView(); if (pView->IsKindOf(RUNTIME_CLASS(CScriptView))) { CScriptView *pSV = static_cast<CScriptView*>(pView); int y = iLine - 1; // Off by 1 // Ensure within bounds CCrystalTextBuffer *pBuffer = pSV->LocateTextBuffer(); if (pBuffer) { y = min(y, pBuffer->GetLineCount() - 1); CPoint pt(0, y); pSV->HighlightLine(pt); pSV->EnsureVisible(pt); pSV->SetCursorPos(pt); } } } } }
void CxViewMgr::CloseView( VIEW_DATA * pView ) { if (pView == NULL) return; if ( pView->m_pView == NULL ) return; if ( !::IsWindow( pView->m_pView->GetSafeHwnd() ) ) return; if (theApp.m_pMainWnd == NULL) return; if ( !::IsWindow( theApp.m_pMainWnd->GetSafeHwnd() ) ) return; CMainFrame * pMainFrame = reinterpret_cast< CMainFrame * > ( theApp.m_pMainWnd ); if (pMainFrame == NULL) return; CMDIChildWndEx * pFrame = reinterpret_cast< CMDIChildWndEx * > ( pMainFrame->GetActiveFrame() ); if (pFrame == NULL) return; CBCGPTabWnd * pTabCtrl = (CBCGPTabWnd *)pFrame->GetRelatedTabGroup(); if (pTabCtrl == NULL) return; //pMainFrame->SendMessage(WM_MDIDESTROY, (WPARAM)pView->m_pView->GetSafeHwnd()); pView->m_pView->SendMessage(WM_COMMAND, ID_FILE_CLOSE); }
void Clinenum_testView::OnActivateView(BOOL bActivate, CView* pActivateView, CView* pDeactiveView) { //TODO: 在此添加专用代码和/或调用基类 if(!bActivate && ::IsWindow(this->m_hWnd)) { CMainFrame *pWnd = (CMainFrame*)AfxGetMainWnd(); //pWnd->SetActiveView(this); Clinenum_testView* pview=(Clinenum_testView*)pWnd->GetActiveFrame()->GetActiveView(); TRACE(_T("ad \n")); //Clinenum_testView *pView = (Clinenum_testView*)pWnd->GetActiveView(); } CRichEditView::OnActivateView(bActivate, pActivateView, pDeactiveView); //if(bActivate) //{ // CMainFrame *pWnd = (CMainFrame*)AfxGetMainWnd(); // pWnd->SetActiveView(this); // TRACE(_T("ad \n")); ////Clinenum_testView *pView = (Clinenum_testView*)pWnd->GetActiveView(); //} }
void CConditionsView::OnSelchanged(NMHDR* pNMHDR, LRESULT* pResult) { NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR; // m_pSelectedCondition = NULL; m_pSelectedNode = NULL; // get the selected item and update the good frame (open the condition edition page in the form too) CTreeCtrl &treeCtrl = GetTreeCtrl(); HTREEITEM hItem; hItem = treeCtrl.GetSelectedItem(); // if (hItem == treeCtrl.GetRootItem()) return; // get the node selected (if any) if ( ! m_mapItemToNode.Lookup(hItem, m_pSelectedNode) ) m_pSelectedNode = NULL; // get the condition (if any) while ( treeCtrl.GetParentItem( hItem ) != treeCtrl.GetRootItem() ) hItem = treeCtrl.GetParentItem( hItem ); CString condName = treeCtrl.GetItemText( hItem ); CLogic_editorDoc *pDoc = static_cast<CLogic_editorDoc *> (GetDocument()); // to update the fields of the condition page in the form view CMainFrame *pFrame = (CMainFrame*)AfxGetApp()->m_pMainWnd; // Get the active MDI child window. CChildFrame *pChild = (CChildFrame *) pFrame->GetActiveFrame(); CEditorFormView *pFormView = static_cast<CEditorFormView *> ( pChild->m_wndSplitter.GetPane(0,1) ); CConditionPage *pCondPage = static_cast<CConditionPage*> ( pFormView->m_pPropertySheet->GetPage(2) ); if ( pDoc->m_conditions.Lookup( condName, (void*&) m_pSelectedCondition) ) { pFormView->m_pPropertySheet->SetActivePage( pCondPage ); if ( pCondPage->m_pSelectedConditionNode != m_pSelectedNode || m_pSelectedNode == NULL) { pCondPage->m_pSelectedCondition = this->m_pSelectedCondition; pCondPage->m_pSelectedConditionNode = this->m_pSelectedNode; pCondPage->Update(); } } else { if (pCondPage->m_pSelectedCondition != NULL) { pCondPage->m_pSelectedConditionNode = this->m_pSelectedNode; // = NULL pCondPage->m_pSelectedCondition = this->m_pSelectedCondition; // = NULL pCondPage->Update(); } } this->SetFocus(); // *pResult = 0; }
void CPFAOptimize::Example() { CMainFrame* pMainFrame = NULL; pMainFrame = (CMainFrame*)AfxGetApp()->m_pMainWnd; CChildFrame* pChildFrame = NULL; pChildFrame = (CChildFrame*)pMainFrame->GetActiveFrame(); CAutoPFAView* pAutoView = NULL; pAutoView = (CAutoPFAView*)pChildFrame->GetActiveView(); ComponentManager* pComManager = pAutoView->GetDocument()->m_scenarioManager.GetCurScenario()->GetCompManager(); JunSystemTransformCircleSystem( *pComManager, OptData ); DisplayMatrix( "F://CirPipe.txt", 100, OptData ); InitializePipeCircle( OptData ); DisplayMatrix( "F://Pipe.txt", 102, OptData ); // 从pComManager中初始化OptData的 初始实际流量,管道长度,节点流量,配水源,控制点, // 先手动设置配水源和控制点 int iTemp = 1; OptData.SetProperty( 0, 200, iTemp ); // 节点1为配水源 iTemp = 6; OptData.SetProperty( 0, 201, iTemp ); // 节点10为控制点 CMinimumSquareSum MinSquSum; //MinSquSum.InitializeFactFlux( *pComManager, OptData ); // 初始实际流量 /////////////////////////////////////// int i = 0; int iKeyOfPipe = 0; double Temp = 0.0; Temp = 0.03; OptData.SetProperty( 1, 1, Temp ); OptData.SetProperty( 3, 1, Temp ); OptData.SetProperty( 6, 1, Temp ); OptData.SetProperty( 7, 1, Temp ); Temp = 0.02; OptData.SetProperty( 2, 1, Temp ); OptData.SetProperty( 4, 1, Temp ); OptData.SetProperty( 5, 1, Temp ); //////////////////////////////////////// double dTemp = 0.0; Pipe* pPipe = NULL; Component* pComponent = NULL; map< int, double > BeforeDiameterMap; // 存储了上一次计算的直径 int iIteratorTime = 0; // 迭代次数 IteratorPtr<Component> PipeItPtr( pComManager->CreatPipeIterator() ); for( PipeItPtr->Fist(); !PipeItPtr->IsDone(); PipeItPtr->Next() ) { pComponent = &PipeItPtr->CurrentItem(); pPipe = dynamic_cast<Pipe*>( pComponent ); dTemp = pPipe->Len(); OptData.SetProperty( pPipe->GetKey(), 2, dTemp ); dTemp = pPipe->InDia(); OptData.SetProperty( pPipe->GetKey(), 4, dTemp ); } // 节点流量 QuantityManager& qm = QuantityManager::Instance(); CString strUnit = ""; CString strValue = ""; Jun* pJun = NULL; IteratorPtr<Component> JunItPtr( pComManager->CreatJunIterator() ); for( JunItPtr->Fist(); !JunItPtr->IsDone(); JunItPtr->Next() ) { pComponent = &JunItPtr->CurrentItem(); pJun = dynamic_cast<Jun*>( pComponent ); strUnit = pJun->ms_InitGuess.GetValue( 2 ); // 获得单位 strValue = pJun->ms_InitGuess.GetValue( 1 ); TCHAR* pChar = NULL; qm.TransformToStd( dTemp, strUnit.GetBuffer( 32 ), _tcstod( strValue.GetBuffer( 32 ), &pChar ) ); // 转化成标准单位 if( IDS_STRVOLUMEFLOW != _ttoi( pJun->ms_InitGuess.GetValue( 0 ).GetBuffer( 32 ) ) ) // 质量流量,要转化为体积流量 { double dTempDensity = 0.0; NumFlyWeight *pDensity = &( ( pComManager->SysProperty().GetFuild() )->ms_Density ); dTemp *= pDensity->GetNum(); // GetNum返回标准单位数 } OptData.SetProperty( pJun->GetKey(), 3, dTemp ); } //////////// dTemp = 0.06; OptData.SetProperty( 1, 3, dTemp ); dTemp = -0.06; OptData.SetProperty( 6, 3, dTemp ); //////////// // 初始化经济参数 OptData.SetAModulus( 8.4 ); OptData.SetBModulus( 107 ); OptData.SetAlfaModulus( 1.6 ); OptData.SetDisinvestmentTime( 1.0e3 ); OptData.SetRepairModulus( 3.3 ); OptData.SetEletricityPrice( 0.5 ); OptData.SetAsymmetryModulus( 1.0 ); OptData.SetPumpEfficiency( 0.7 ); OptData.SetKModulus( 1.34e-10 ); OptData.SetMModulus( 5.3 ); OptData.SetNModulus( 2 ); OptData.Initialization(); BeforeDiameterMap.clear(); iIteratorTime = 0; do { // 初始化虚流量 MinSquSum.InitializeDummyFlux( *pComManager, OptData ); // 虚流量平差 CalEconomyDiameterAndWaterHarmer( *pComManager, 0.0001, 5000, OptData ); // 通过经济管径计算标准管径 FindStandardDiameter( OptData ); // 实际流量平差 CalFactFlux( *pComManager, 0.0001, 5000, OptData ); // 迭代次数加一 iIteratorTime++; } while( !DiameterIsEqual( OptData, BeforeDiameterMap ) && ( 5000 > iIteratorTime ) ); // 比较前后管径,不相等则跳到 初始化虚流量 // 计算其他要素 CalOthersVariable( *pComManager, OptData ); // 输出结果 }