newntui/discovermdi/src/disgraphnode.cpp
//-----------------------------------------------------------------------------------
// This method will call node draw and edge draw callbacks when we need
// to draw all graph. Use "DrawGraphRect" method to draw the nodes
// and edges contained in the rectangle.
//-----------------------------------------------------------------------------------
This method will call node draw and edge draw callbacks when we need
to draw all graph. Use "DrawGraphRect" method to draw the nodes
and edges contained in the rectangle.
This method will call node draw and edge draw callbacks when we need to draw all graph . Use " DrawGraphRect " method to draw the nodes and edges contained in the rectangle .
void CDisGraph::DrawGraph(void) {
TSDListIterator nodeIterator(pNodeDList());
TSDListIterator edgeIterator(pEdgeDList());
CDisGraphNode* pNode;
CDisGraphEdge* pEdge;
CItemsList* nodeItems;
CRect nodeRect;
CPoint path[1024];
TSPathDigraph* edgePath;
TSEdge* pPathEdge;
	if(m_EdgeDrawCallback!=NULL) {
        while(edgeIterator)  {
		    pEdge = CDisGraphEdge::castDown(edgeIterator.pObject());
		    int pathVertex=0;
		    edgePath=pEdge->pChildPathDigraph();
			if(edgePath!=NULL) {
               TSDListIterator pathIterator(edgePath->pEdgeDList());
		       while(pathIterator) {
		           pPathEdge = (TSEdge *) pathIterator.pObject();
			       path[pathVertex].x=pPathEdge->fromX();
			       path[pathVertex].y=pPathEdge->fromY();
			       path[pathVertex+1].x=pPathEdge->toX();
			       path[pathVertex+1].y=pPathEdge->toY();
			       pathIterator++;
			       pathVertex++;
			   }
               (m_EdgeDrawCallback)(m_ClientID,path,pathVertex+1,pEdge->GetActiveEdgeProperties());
			} else {
	               TSPad * pFromPad = pEdge->pFromPad();
	               TSPad * pToPad   = pEdge->pToPad();
				   pathVertex=0;
			       path[pathVertex].x=pFromPad->x();
			       path[pathVertex].y=pFromPad->y();
			       path[pathVertex+1].x=pToPad->x();
			       path[pathVertex+1].y=pToPad->y();
                   pathVertex=2;
                   (m_EdgeDrawCallback)(m_ClientID,path,pathVertex,pEdge->GetActiveEdgeProperties());
			}
		    edgeIterator++;
		}
	}
    if(m_NodeDrawCallback!=NULL) {
        while(nodeIterator)  {
            int connectorSide=NONE;
            BOOL status;
		    pNode = CDisGraphNode::castDown(nodeIterator.pObject());
	        nodeItems=pNode->GetItemsList();
			if(pNode->m_ChildNode && pNode->HasChildren()==TRUE) {
				if(pNode->AreChildrenCreated()==TRUE)  {
					if(pNode->IsCollapsed()==TRUE) status=TRUE;
					else                           status=FALSE;
				} else status=TRUE;
				switch(pHDigraph()->pHTailor()->hlevelOrientation()) {
				    case TS_LEFT_TO_RIGHT : connectorSide = RIGHT;  break;
				    case TS_RIGHT_TO_LEFT : connectorSide = LEFT;   break;
				    case TS_TOP_TO_BOTTOM : connectorSide = BOTTOM; break;
				    case TS_BOTTOM_TO_TOP : connectorSide = TOP;    break;
				}
			} 
            int parentsConnectorSide=NONE;
            BOOL parentsStatus;
			if(pNode->m_ParentNode && pNode->HasParents()==TRUE) {
				if(pNode->AreParentsCreated()==TRUE)  {
					if(pNode->IsParentsCollapsed()==TRUE) parentsStatus=TRUE;
					else                                  parentsStatus=FALSE;
				} else parentsStatus=TRUE;
				switch(pHDigraph()->pHTailor()->hlevelOrientation()) {
				    case TS_LEFT_TO_RIGHT : parentsConnectorSide = LEFT;  break;
				    case TS_RIGHT_TO_LEFT : parentsConnectorSide = RIGHT; break;
				    case TS_TOP_TO_BOTTOM : parentsConnectorSide = TOP;   break;
				    case TS_BOTTOM_TO_TOP : parentsConnectorSide = BOTTOM;break;
				}
			} 
		    CRect nodeRect;
            nodeRect.top    = pNode->top();
		    nodeRect.bottom = pNode->bottom();
		    nodeRect.left   = pNode->left();
		    nodeRect.right  = pNode->right();
            (*m_NodeDrawCallback)(m_ClientID,nodeRect,pNode->GetReadableName(),pNode->GetNodeKind(), nodeItems,pNode->GetActiveNodeProperties(),connectorSide,status,parentsConnectorSide,parentsStatus) ;
		    nodeIterator++;
		}
	}
}
void CDisGraph :: DrawGraph ( void ) { TSDListIterator nodeIterator ( pNodeDList ( ) ) ; TSDListIterator edgeIterator ( pEdgeDList ( ) ) ; CDisGraphNode * pNode ; CDisGraphEdge * pEdge ; CItemsList * nodeItems ; CRect nodeRect ; CPoint path [ 1024 ] ; TSPathDigraph * edgePath ; TSEdge * pPathEdge ; if ( m_EdgeDrawCallback != NULL ) { while ( edgeIterator ) { pEdge = CDisGraphEdge :: castDown ( edgeIterator . pObject ( ) ) ; int pathVertex = 0 ; edgePath = pEdge -> pChildPathDigraph ( ) ; if ( edgePath != NULL ) { TSDListIterator pathIterator ( edgePath -> pEdgeDList ( ) ) ; while ( pathIterator ) { pPathEdge = ( TSEdge * ) pathIterator . pObject ( ) ; path [ pathVertex ] . x = pPathEdge -> fromX ( ) ; path [ pathVertex ] . y = pPathEdge -> fromY ( ) ; path [ pathVertex + 1 ] . x = pPathEdge -> toX ( ) ; path [ pathVertex + 1 ] . y = pPathEdge -> toY ( ) ; pathIterator ++ ; pathVertex ++ ; } ( m_EdgeDrawCallback ) ( m_ClientID , path , pathVertex + 1 , pEdge -> GetActiveEdgeProperties ( ) ) ; } else { TSPad * pFromPad = pEdge -> pFromPad ( ) ; TSPad * pToPad = pEdge -> pToPad ( ) ; pathVertex = 0 ; path [ pathVertex ] . x = pFromPad -> x ( ) ; path [ pathVertex ] . y = pFromPad -> y ( ) ; path [ pathVertex + 1 ] . x = pToPad -> x ( ) ; path [ pathVertex + 1 ] . y = pToPad -> y ( ) ; pathVertex = 2 ; ( m_EdgeDrawCallback ) ( m_ClientID , path , pathVertex , pEdge -> GetActiveEdgeProperties ( ) ) ; } edgeIterator ++ ; } } if ( m_NodeDrawCallback != NULL ) { while ( nodeIterator ) { int connectorSide = NONE ; BOOL status ; pNode = CDisGraphNode :: castDown ( nodeIterator . pObject ( ) ) ; nodeItems = pNode -> GetItemsList ( ) ; if ( pNode -> m_ChildNode && pNode -> HasChildren ( ) == TRUE ) { if ( pNode -> AreChildrenCreated ( ) == TRUE ) { if ( pNode -> IsCollapsed ( ) == TRUE ) status = TRUE ; else status = FALSE ; } else status = TRUE ; switch ( pHDigraph ( ) -> pHTailor ( ) -> hlevelOrientation ( ) ) { case TS_LEFT_TO_RIGHT : connectorSide = RIGHT ; break ; case TS_RIGHT_TO_LEFT : connectorSide = LEFT ; break ; case TS_TOP_TO_BOTTOM : connectorSide = BOTTOM ; break ; case TS_BOTTOM_TO_TOP : connectorSide = TOP ; break ; } } int parentsConnectorSide = NONE ; BOOL parentsStatus ; if ( pNode -> m_ParentNode && pNode -> HasParents ( ) == TRUE ) { if ( pNode -> AreParentsCreated ( ) == TRUE ) { if ( pNode -> IsParentsCollapsed ( ) == TRUE ) parentsStatus = TRUE ; else parentsStatus = FALSE ; } else parentsStatus = TRUE ; switch ( pHDigraph ( ) -> pHTailor ( ) -> hlevelOrientation ( ) ) { case TS_LEFT_TO_RIGHT : parentsConnectorSide = LEFT ; break ; case TS_RIGHT_TO_LEFT : parentsConnectorSide = RIGHT ; break ; case TS_TOP_TO_BOTTOM : parentsConnectorSide = TOP ; break ; case TS_BOTTOM_TO_TOP : parentsConnectorSide = BOTTOM ; break ; } } CRect nodeRect ; nodeRect . top = pNode -> top ( ) ; nodeRect . bottom = pNode -> bottom ( ) ; nodeRect . left = pNode -> left ( ) ; nodeRect . right = pNode -> right ( ) ; ( * m_NodeDrawCallback ) ( m_ClientID , nodeRect , pNode -> GetReadableName ( ) , pNode -> GetNodeKind ( ) , nodeItems , pNode -> GetActiveNodeProperties ( ) , connectorSide , status , parentsConnectorSide , parentsStatus ) ; nodeIterator ++ ; } } }
This method will call node draw and edge draw callbacks when we need
to draw all graph.
This method will call node draw and edge draw callbacks when we need to draw all graph .
// Drawing all edges // Drawing all nodes // Determine wether to display expand/collapse buttons and where // Determine wether to display expand/collapse buttons for parents // Extracting new node rectangle from the graph - layout changed // this rectangle position. // Drawinfg the node using node drawing callback