EdgeItem::EdgeItem(NodeItem* start /* = nullptr */, NodeItem* end /* = nullptr */) : QGraphicsObject() , m_startNode(nullptr) , m_endNode(nullptr) , m_weight(0) , m_arrowhead(false) , m_emphasised(false) { resetFont(); resetEmphasisPen(); setStartNode(start); setEndNode(end); setZValue(100.0f); setCacheMode(QGraphicsItem::NoCache); setAcceptedMouseButtons(Qt::NoButton); adjust(); }
void UbLink::setNodes( UbNodeRef start, UbNodeRef end ) { setStartNode( start ); setEndNode( end ); updatePath(); }
void DesignExtractor::buildCFG(TNode currNode, vector<std::pair<int,int>> * graph){ int nodeType = currNode.getNodeType(); vector<int> children = currNode.getChildren(); vector<std::pair<int,int>>::iterator it = graph->begin(); int currStmtNum = currNode.getStmtNumber(); switch(nodeType){ case PROCEDURE: { //go into statement list buildCFG(ast->getChild(currNode, 0), graph); //set end nodes setEndNode(graph); break; } case STMT_LST: { //for each node of stmtLst visit it for(int i = 0; i < children.size(); ++i){ buildCFG(ast->getChild(currNode, i), graph); } break; } case CALL: case ASSIGN: { //first we check if we can find follows, otherwise find a parent's follows. STMT followStmtNum = follows->getFollows(1,currStmtNum); if(followStmtNum == -1) { graph->at(currStmtNum).first = findLoopback(currStmtNum); if(graph->at(currStmtNum).first == 0) graph->at(currStmtNum).first = findFollows(currStmtNum); } else{ graph->at(currStmtNum).first = followStmtNum; } return; break; } case WHILE: { //connect to first stmt of my stmtLst STMT firstStmtNum = ast->getChild(ast->getChild(currNode, 1), 0).getStmtNumber(); graph->at(currStmtNum).first = firstStmtNum; //first we check if we can find follows, otherwise find a parent's follows. STMT followStmtNum = follows->getFollows(1,currStmtNum); if(followStmtNum == -1) { graph->at(currStmtNum).second = findLoopback(currStmtNum); if(graph->at(currStmtNum).second == 0) graph->at(currStmtNum).second = findFollows(currStmtNum); } else{ graph->at(currStmtNum).second = followStmtNum; } // call buildCFG again on the stmtLst buildCFG(ast->getChild(currNode, 1), graph); break; } case IF: { //connect to first stmt of then stmtLst TNode thenNode = ast->getChild(currNode, 1); STMT thenStmtNum = ast->getChild(thenNode, 0).getStmtNumber(); graph->at(currStmtNum).first = thenStmtNum; //connect to first stmt of else stmtLst TNode elseNode = ast->getChild(currNode, 2); STMT elseStmtNum = ast->getChild(elseNode, 0).getStmtNumber(); graph->at(currStmtNum).second = elseStmtNum; //call buildCFG of then buildCFG(thenNode, graph); //call buildCFG of else buildCFG(elseNode, graph); break; } default: break; } }