/** Finds which checklines must be visited before driving on this quad * (useful for rescue) */ void QuadGraph::computeChecklineRequirements(GraphNode* node, int latest_checkline) { for (unsigned int n=0; n<node->getNumberOfSuccessors(); n++) { const int succ_id = node->getSuccessor(n); // warp-around if (succ_id == 0) break; GraphNode* succ = m_all_nodes[succ_id]; int new_latest_checkline = CheckManager::get()->getChecklineTriggering(node->getCenter(), succ->getCenter() ); if(new_latest_checkline==-1) new_latest_checkline = latest_checkline; /* printf("Quad %i : checkline %i\n", succ_id, new_latest_checkline); printf("Quad %i :\n", succ_id); for (std::set<int>::iterator it = these_checklines.begin();it != these_checklines.end(); it++) { printf(" Depends on checkline %i\n", *it); } */ if (new_latest_checkline != -1) succ->setChecklineRequirements(new_latest_checkline); computeChecklineRequirements(succ, new_latest_checkline); } } // computeChecklineRequirements
void GraphView::mouseMoveEvent(QMouseEvent *event) { if (currentAction == MOVING && selectedItem && event->button() != Qt::RightButton) { QPointF newPos = mapToScene(event->pos()); GraphNode* node = dynamic_cast<GraphNode*>(selectedItem); if (node) { QRect rect = this->geometry(); if (event->pos().x() - node->getRadius() > rect.left() && event->pos().x() + node->getRadius() < rect.right() && event->pos().y() - node->getRadius() > rect.top() && event->pos().y() + node->getRadius() < rect.bottom()) { QPointF oldPos = node->getCenter(); undoStack->push(new MoveNodeCommand(node, oldPos, newPos)); } } } }