Beispiel #1
0
//---------------------------------------------------------------
// Purpose: 
//---------------------------------------------------------------
CeditorDoc * GetActiveDocument( void )
{
	CChildFrame *chldFrm = (CChildFrame*)(((CMainFrame*)AfxGetMainWnd())->MDIGetActive());
	if( !chldFrm )
		return NULL;

	return (CeditorDoc*)chldFrm->GetActiveView()->GetDocument();
}
Beispiel #2
0
CView* CStaticDoc::GetActiveView( )
{
	CMainFrame * pMainFrame = AfxGetMainFrame();
	if( pMainFrame )
	{
		CChildFrame * pChildFrame = DYNAMIC_DOWNCAST( CChildFrame, pMainFrame->MDIGetActive() );
		if( pChildFrame )
		{
			CView * pView = pChildFrame->GetActiveView();
			if( pView && this == pView->GetDocument() )
				return pView;
		}
	}
	return NULL;
}
Beispiel #3
0
// generates the string list of view names to be used for the tabs
void CBonfireDoc::UpdateTabs(LPCTSTR lpszPathName /*= NULL*/)
{
	CStringList pTabList;
	CString ext = (lpszPathName == NULL) 
				? GetFileExtension(GetPathName()) 
				: GetFileExtension(lpszPathName);
	
	// generate tabs based on the file extension
	CString strViews	= theApp.m_opOptions.views.vAssociations[0].strViews; // init to default views
	CString strExtList	= "";
	size_t nExt			= theApp.m_opOptions.views.vAssociations.size();
	
	// see if the current file's extension is in the list
	while (nExt-- > 0) // 0 is the default file extension
	{
		strExtList = (CString)theApp.m_opOptions.views.vAssociations[nExt].strExtensions;
		strExtList.Remove(' ');

		if (IsStringPresent(strExtList, ext))
		{
			strViews = theApp.m_opOptions.views.vAssociations[nExt].strViews;
			break;
		}
	}

	POSITION pos		= GetFirstViewPosition();
	CChildFrame* pChild = ((CChildFrame*)GetNextView(pos)->GetParentFrame());
	CView* pView		= pChild->GetActiveView();
	BOOL bIsCurViewAvail = FALSE;

	// also make sure the current view is available, if not, close it
	// add the tabs to the tablist
	for (int i = 0; i < theApp.m_arAllViews.GetSize(); i++)
	{
		if (strViews[i] != '-')
		{
			pTabList.AddHead( ((CBonfireView*)theApp.m_arAllViews[i])->m_strCaption );
			if (pView && pView->IsKindOf(theApp.m_arAllViews[i]->m_pClass))
				bIsCurViewAvail = TRUE;
		}
	}

	// draw the tabs
	pChild->DrawTabs(&pTabList);

	if (!pView || !bIsCurViewAvail)
		SwitchToFirstView();
}
//##ModelId=4095FA7D002E
void look::OnSelchanged(NMHDR* pNMHDR, LRESULT* pResult) 
{
	NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;
	// TODO: Add your control notification handler code here
	HTREEITEM s=m_TreeCtrl->GetSelectedItem ();
	HTREEITEM s1=m_TreeCtrl->GetSelectedItem ();
	fm *p=(fm*)((CMainFrame *)AfxGetMainWnd())->m_wndWorkspace.GetView (RUNTIME_CLASS(fm));
	CString str;
	CString str0;
	CString sql;




	//we willl save something before we lost it
////////////////////////////////////////////////////////////////////////////////
		BOOL bMaximized = FALSE;
		CChildFrame* pActiveWnd = (CChildFrame*)((CMainFrame *)AfxGetMainWnd())->MDIGetActive(&bMaximized);
		CDbView *pActiveView = NULL;
		if (!pActiveWnd) 
		{
			return;
		}
		pActiveView = (CDbView *)pActiveWnd->GetActiveView();

		//pActiveView ->SendMessage(WM_USER+100);

////////////////////////////////////////////////////////////////



	int i=0;

	str=m_TreeCtrl->GetItemText(s);
	CStatusBar *m=(CStatusBar *)((CMainFrame *)AfxGetMainWnd())->GetDescendantWindow (AFX_IDW_STATUS_BAR);
	while ((s=m_TreeCtrl->GetParentItem (s))!=NULL)
	{
		str0=m_TreeCtrl->GetItemText(s);
		
		i=i+1;
		//TRACE1("%d",i);


	}
	//TRACE1("%d",i);

	if(i)
	{
		sql=sql="select content from help where type=\'"+str0+"\'  and "+"title=\'"+str+"\'";
		if(con.mysql_exec(my,sql)!=0) 
		{
			//MessageBox("服务器可能已经关闭,请重试,如果问题仍然存在,请联系[email protected]");
			//AfxGetMainWnd()->PostMessage (WM_CLOSE);
			return;
		}
		rs_dad=con.store_result (my);
	//clear the list
		
		 
		if (row=mysql_fetch_row(rs_dad))
			pActiveView->GetEditCtrl().SetWindowText(row[0]);
		con.free_result (rs_dad);
	

		CString title_all;
		title_all="db - ["+str0+">>"+str+"]";
		SETTITLE(title_all.GetBuffer(title_all.GetLength ()));
		//(CMainFrame *)AfxGetMainWnd())->GetActiveWindow
		pActiveView->GetDocument()->SetTitle(str0+">>"+str);
		p->title=str;
		p->type=str0;



		
		
	
	
	}
	m->SetPaneText (0,str);

	*pResult = 0;
}
Beispiel #5
0
/////////////////////////////////////////////////////////////////////////////
// switch to the new selected view tab
/////////////////////////////////////////////////////////////////////////////
BOOL CBonfireDoc::SwitchToView(CString strTab)
{
	if (strTab == "")
		return FALSE;

	CChildFrame*	pChild		= (CChildFrame*)g_pMainFrame->MDIGetActive();
	if (!pChild || pChild->GetActiveDocument() != this)
	{
		POSITION pos = GetFirstViewPosition();
		pChild	= (CChildFrame*)GetNextView(pos)->GetParentFrame();
	}

	if (!pChild)
		return FALSE;

	CView*			pViewAdd	= NULL;
	CBonfireView*	pGlobalView	= NULL;
	CBonfireView*	pBNewView	= NULL;
	
	// get the view to "hide"
	CView*			pViewDel	= pChild->GetActiveView();
	
	// if we're already displaying this kind of view, no need to go further.
	for (int i = 0; i < theApp.m_arAllViews.GetSize(); i++)
	{
		if ( ((CBonfireView*)theApp.m_arAllViews[i])->m_strCaption.Compare(strTab) == 0 )
		{
			pGlobalView = (CBonfireView*)theApp.m_arAllViews[i];
			break;
		}
	}

	if ( pViewDel && pViewDel->IsKindOf(pGlobalView->m_pClass) )
		return TRUE;

	// check if a view of this type already exists
 	if ( !m_pViews->Lookup(pGlobalView->m_strCaption, (void*&)pBNewView) )
	{
		// doesn't exist so create a new view
		pViewAdd = (CView*)pGlobalView->m_pClass->CreateObject();
		if (pViewAdd == NULL)
		{
			TRACE1("Warning: Dynamic create of view type %Fs failed\n", pGlobalView->m_pClass->m_lpszClassName);
			return FALSE;
		}

		// draw new view
		CCreateContext context;
		context.m_pNewViewClass		= pGlobalView->m_pClass;
		context.m_pCurrentDoc		= NULL;
		context.m_pNewDocTemplate	= this->GetDocTemplate();
		context.m_pLastView			= NULL;
		context.m_pCurrentFrame		= pChild;

		// draw new view
		if (!pViewAdd->Create(NULL, NULL, AFX_WS_DEFAULT_VIEW, CRect(0, 0, 0, 0),
			pChild, AFX_IDW_PANE_FIRST, &context))
		{
			TRACE0("Warning: couldn't create view for frame\n");
			delete pViewAdd;
			return FALSE;
		}

		// add the view to the map
		pBNewView			= new CBonfireView(pGlobalView);
		pBNewView->m_pView	= pViewAdd;
		pBNewView->m_pClass	= pViewAdd->GetRuntimeClass();

		// add this view to the document's map
		AddViewToMap(pBNewView);

		// WM_INITIALUPDATE is defined in afxpriv.h
		pViewAdd->SendMessage(WM_INITIALUPDATE,0,0);

		// connect the view to the document
		AddView(pViewAdd);
	}
	else
	{
		pViewAdd = pBNewView->m_pView;
	}

	// save file on switching views
	if (theApp.m_opOptions.general.dwSaveOnSwitch && !m_xTextBuffer.GetReadOnly() && pViewDel)
		DoFileSave();
	
	CSplitterWnd*	pSplitter	= NULL;
	POSITION pos				= GetFirstViewPosition();
	BOOL firstOne				= true;
	while (pos)
	{
		CView* pv	= GetNextView(pos);
		if (pv == pViewAdd)	
		{
			pv->SetDlgCtrlID(AFX_IDW_PANE_FIRST);

			// show the view
			if (pBNewView->m_bAllowsSplitter)
			{
				pSplitter	= (CSplitterWnd*)pViewAdd->GetParent();
				
				// show the splitter (show the children view(s) as well)
				pSplitter->ShowWindow(SW_SHOW);
			}
			else
				// show the view
				pViewAdd->ShowWindow(SW_SHOW);
		}
		else 
		{
			// check if the view is inside a splitter
			if (pv->GetParent()->GetRuntimeClass() == (CRuntimeClass*)RUNTIME_CLASS(CSplitterWnd))
			{
				pSplitter	= (CSplitterWnd*)pv->GetParent();
				
				// hide the splitter (hide all views with the splitter)
				pSplitter->ShowWindow(SW_HIDE);
			}
			else
			{
				// hide the view
				pv->ShowWindow(SW_HIDE);
				pv->SetDlgCtrlID(AFX_IDW_PANE_FIRST + 255);
			}
		}

		TRACE("%s (%d) ", pv->GetRuntimeClass()->m_lpszClassName, (unsigned)(pv->GetDlgCtrlID() - AFX_IDW_PANE_FIRST));
		if (pv == pViewDel)		TRACE("= D ");
		if (pv == pViewAdd)		TRACE("= A ");
		if (pv->GetRuntimeClass() == pGlobalView->m_pClass)
		{
			if (firstOne)
				firstOne = false;
			else
				TRACE("removing ");
		}
	}
	TRACE("\n");

	// get rid of extra views created by the splitter
	if (pSplitter)
	{
		for (int cols = 1; cols < pSplitter->GetColumnCount(); cols++)
			pSplitter->DeleteColumn(cols);
		for (int rows = 1; rows < pSplitter->GetRowCount(); rows++)
			pSplitter->DeleteRow(rows);

		pSplitter->RecalcLayout();
	}

	pViewAdd->UpdateWindow();
	pChild->SetActiveView(pViewAdd);
	pChild->RecalcLayout();

	if (pBNewView->m_bModifiedSinceRefresh)
	{
		pBNewView->m_bModifiedSinceRefresh = FALSE;
		if (pGlobalView->m_pClass == RUNTIME_CLASS(CXMLTreeView))
		{
			((CXMLTreeView*)pViewAdd)->RefreshView();
		}
		else if (pGlobalView->m_pClass == RUNTIME_CLASS(CBrowserView))
		{
			((CBrowserView*)pViewAdd)->RefreshView();
		}
		else
		{
			pBNewView->m_bModifiedSinceRefresh = TRUE;
		}
	}

	return TRUE;
}
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 );

	// 输出结果
}