Home | Products | Download | Purchase | Support 


   

CriticalPath Sample

 

 

The UCanCode E-XD++ Component Enterprise Edition product family enables you to develop graph visualization applications quickly and efficiently. With these products, you can easily enhance your applications with sophisticated graph display, viewing and editing technologies presented in an eye-catching, intuitive graphical user interface. You can customize both the display and the interactive behaviors of your application using industry standard components, such as toolbars, menus and mouse-event handling.

Graph Layout Diagrams are a natural and intuitive way of expressing relationships in your application data.  E-XD++ Components make it easy to add expressive, interactive graph drawing, layout, printing, features to your application. UCanCode's E-XD++ Diagram Component is the most comprehensive set of tools, components and libraries for creating graphical editing, visualization, supervision and monitoring tools for the VC++ / .NET platform. Both diagrams—displays used to show the relationships between objects and graph drawing and layout can be easily created.

Steps:

1. Load data from XML File:


void CCriticalPathView::DoConnectLoadXml(const CString &strXMLFile) 
{
	// TODO: Add your command handler code here
	CExtDataModel *pDataModel = (CExtDataModel *)GetCurrentModel();
	if (NULL == pDataModel)
		return;
	
	AfxGetApp()->BeginWaitCursor();
// TODO: Add your command handler code here
	CFODrawShapeSet	setNodes;

	CArray<FOP_LINK_DATA,FOP_LINK_DATA> m_arLinks;
	CXDXml xml;	
	if (TRUE == xml.Load(strXMLFile))
	{
		BOOL bFirst = TRUE;
		int nOffset = 20;
		CPoint ptStart = CPoint(20,20);
		CFODrawShape *pFirst = NULL;
		CXDXmlNode xmlNode = xml.GetNodeList(_T("Project/Tasks/Task"));
		for (int i = 0; i<xmlNode.GetNodeListSize(); i++)
		{
			CString strName = xmlNode.GetNodeText(_T("Name"));
			CString strStart = xmlNode.GetNodeText(_T("Start"));
			strStart = strStart.Left(10);
			CString strFinish = xmlNode.GetNodeText(_T("Finish"));
			strFinish = strFinish.Left(10);
			CString strUID = xmlNode.GetNodeText(_T("UID"));
			int nstartid = xmlNode.GetNodeInt(_T("UID"));
			CString strCaption = strName + _T("\n") + strStart + _T("\n") + strFinish;

			CFORoundRectShape *pRect = new CFORoundRectShape;
			pRect->AddRef();
			CRect rc(ptStart, CSize(200, 100));
			pRect->Create(rc);
			pRect->SetObjectCaption(strCaption);
			pRect->SetShowLabelAtFirst(TRUE);
			pRect->SetMultiLine(TRUE);
			pRect->AllowTextWrap(TRUE);
			pRect->SetPointSize(10);
			pRect->SetBrushType(1);
			pRect->SetLineColor(RGB(0,123,0));
			pRect->SetLineWidth(2);
			pRect->SetWeight(700);
			pRect->SetFontColor(RGB(0,128,255));
			pRect->PutPropIntValue(P_ID_EXT_VALUE, nstartid);
			GetCurrentModel()->GetShapes()->AddTail(pRect);
			pRect->Release();

			if(bFirst)
			{
				pFirst = pRect;
				bFirst = FALSE;
			}

			CXDXmlNode newChild = xmlNode.GetNodeList(_T("PredecessorLink"));
			int nNewSize = newChild.GetNodeListSize();
			for (int i1=0; i1<nNewSize; i1++)
			{
				CString str2 = newChild.GetNodeText(_T("PredecessorUID"));
				int nendid = newChild.GetNodeInt(_T("PredecessorUID"));
				FOP_LINK_DATA linkdata;
				linkdata.startid = nstartid;
				linkdata.endid = nendid;

				m_arLinks.Add(linkdata);
				newChild.GetNextNode();
			}

			ptStart += CPoint(nOffset, nOffset);
			
			xmlNode.GetNextNode();
		}
		m_wndProgress.UpdateProgress(19);
		for(int x = 0; x < m_arLinks.GetSize(); x++)
		{
			FOP_LINK_DATA linkdata = m_arLinks.GetAt(x);
			int nStartId = linkdata.startid;
			int nEndId = linkdata.endid;
			
			CFODrawPortsShape *pStart = (CFODrawPortsShape *)FindShapeWithValue(nStartId);
			CFODrawPortsShape *pEnd = (CFODrawPortsShape *)FindShapeWithValue(nEndId);

			if(pStart != NULL && pEnd != NULL)
			{
				AddLinkShapeNoUndo(pStart, pEnd, FOP_ROUND_TURNCORNER_LINKSHAPE, 1);
			}
		}
		m_wndProgress.UpdateProgress(10);
		CFOPLayeredLayout layout1;
		layout1.Initialize(GetCurrentModel(), *GetCurrentModel()->GetFormObjects());
		layout1.DoLayoutNew();
		
		m_wndProgress.UpdateProgress(50);
	
		int nCount = GetCurrentModel()->GetShapes()->GetCount();
		for(int x2 = 0; x2 < nCount; x2++)
		{
			CFODrawShape *pShape = (CFODrawShape *)GetCurrentModel()->GetShapes()->GetObject(x2);
			pShape->OffsetAllPoints(1000,500);
		}
		m_wndProgress.UpdateProgress(20);
		ptCenter = pFirst->GetCenterPoint();

		SelectNewShape(pFirst);

		m_wndProgress.Hide();

	}

	AfxGetApp()->EndWaitCursor();
}
2. Create link:
CFOLinkShape *CCriticalPathView::AddLinkShapeNoUndo(CFODrawPortsShape *pFirst,CFODrawPortsShape *pSecond, 
											  const int &nLinkType, const int &nArrowType)
{
	CFOPortShape *pStart = pFirst->GetCenterPort();
	CFOPortShape *pEnd = pSecond->GetCenterPort();

	if(pStart == NULL || pEnd == NULL)
	{
		return NULL;
	}

	CFOLinkShape * pLinkComp = NULL;


	switch(nLinkType)
	{
	case FO_COMP_LINK:	//CFOLinkShape
		{
			pLinkComp = new CFOLinkShape;
		}
		break;

	case FOP_COMP_TURNCORNERLINK:
		{
			pLinkComp = new CFOTurnCornerLinkShape;
		}
		break;

	case FOP_ROUND_TURNCORNER_LINKSHAPE:
		{
			pLinkComp = new CFORoundTurnCornerLinkShape;
		}
		break;

	case FOP_COMP_BREAKCENTERLINK:
		{
			pLinkComp = new CFOPBreakCenterLinkShape;
		}
		break;

	case FO_COMP_UPRIGHTLINK://CFOUpRightLinkShape
		{
			pLinkComp = new CFOUpRightLinkShape;
		}
		break;

	case FOP_ROUND_UPRIGHT_LINKSHAPE://CFOPRoundUpRightLinkShape
		{
			pLinkComp = new CFOPRoundUpRightLinkShape;
		}
		break;

	case FO_COMP_CORNERLINK://CFOCornerLinkShape
		{
			pLinkComp = new CFOCornerLinkShape;
		}
		break;

	case FO_COMP_EXT_CORNERLINK://CFOPExtCornerLinkShape
		{
			pLinkComp = new CFOPExtCornerLinkShape;
		}
		break;

	case FO_COMP_BEZIERLINK://CFOBezierLinkShape
		{
			pLinkComp = new CFOBezierLinkShape;
		}
		break;

	case FOP_NEW_SINGLEARROW_LINKSHAPE://CFOPNewSingleArrowLinkShape
		{
			pLinkComp = new CFOPNewSingleArrowLinkShape;
		}
		break;

	case FOP_NEW_REVERSE_SINGLEARROW_LINKSHAPE://CFOPNewReverseSingleArrowLinkShape
		{
			pLinkComp = new CFOPNewReverseSingleArrowLinkShape;
		}
		break;

	case FOP_NEW_DOUBLEARROW_LINKSHAPE://CFOPNewDoubleArrowLinkShape
		{
			pLinkComp = new CFOPNewDoubleArrowLinkShape;
		}
		break;
		
	case FOP_NEW_SIMPLE_LINKSHAPE:
		{
			pLinkComp = new CFOPNewSimpleLinkShape;
			
		}
		break;
		
	case FOP_NEW_LINEAR_LINKSHAPE://CFOPNewLinearLinkShape
		{
			pLinkComp = new CFOPNewLinearLinkShape;
		}
		break;
		
	case FOP_NEW_CURVE_LINKSHAPE://CFOPNewCurveLinkShape
		{
			pLinkComp = new CFOPNewCurveLinkShape;
		}
		break;
		
	case FOP_NEW_COMM_LINKSHAPE://CFOPCommLinkShape
		{
			pLinkComp = new CFOPCommLinkShape;
		}
		break;
		
	case FOP_COMP_EXTLINKSHAPE:
		{
			pLinkComp = new CFOPExtLinkShape;
		}
		break;

	default:
		{
			pLinkComp = new CFOLinkShape;
		}
		break;
	}
	pLinkComp->AddRef();
	CPoint ptPoints[2];
	ptPoints[0] = pStart->GetLinkPoint();
	ptPoints[1] = pEnd->GetLinkPoint();
	pLinkComp->Create(ptPoints,2);

	pLinkComp->SetFromPort(pStart);
	pLinkComp->SetToPort(pEnd);

	pLinkComp->SetLineWidth(2);
	pLinkComp->SetShadow(FALSE);
	pLinkComp->SetLineColor(RGB(0,0,51));

	pStart->AddLinkShape(pLinkComp);
	pEnd->AddLinkShape(pLinkComp);
	
	// Set arrow type.
	int nType = nArrowType;
	pLinkComp->SetEndArrowType(nType);
	GetCurrentModel()->AddChildAtTail(pLinkComp);
	pLinkComp->UpdateComp();
	pLinkComp->RelayoutPoints();
	pLinkComp->Release();
	
	return pLinkComp;
}

 

 


[ Home | Products | Download Area | Purchase | SupportContact us ]


Copyright ?1998-2007 UCanCode.Net Software, all rights reserved.
Other product and company names herein may be the trademarks of their respective owners.

Please direct your questions or comments to webmaster@ucancode.com