void CUiModels::OnRoutesCurrentChanged(const QModelIndex& current, const QModelIndex& previous) { QStandardItemModel* model = (QStandardItemModel*)current.model(); QModelIndex sibling = current.sibling(current.row(), 0); QStandardItem* item = model->itemFromIndex(sibling); if(item == NULL) { return; } MAPOPP.graph_.UnSelectAll(); int data = item->data().toInt(); //node selected if(data >= 0) { MAPOPP.graph_.GetNode(data)->Select(true); ((OAppMapEdit*)APPMNGR.GetState())->ReDraw(); return; } //total selected if(data == -3) { for(int i = 0; i < 5; i++) { QStandardItem* item_day = model->item(i); for(int j = 0; j < item_day->rowCount(); j++) { QStandardItem* item_veh = item_day->child(j); MarkRoute(item_veh); } } ((OAppMapEdit*)APPMNGR.GetState())->ReDraw(); return; } //day selected if(data == -2) { for(int i = 0; i < item->rowCount(); i++) { QStandardItem* item_veh = item->child(i); MarkRoute(item_veh); } ((OAppMapEdit*)APPMNGR.GetState())->ReDraw(); return; } //route (veh type) selected if(data == -1) { MarkRoute(item); ((OAppMapEdit*)APPMNGR.GetState())->ReDraw(); return; } }
int SetArrivalTime(oneHop * desiredPath, int trainNum) { /* Take in the path desired by a task and determine if this path is feasible. * If the path is feasible, mark the arrival times in the trafficMap and return * speed train should go at. If there is a colision return COLISION. * If route is not clear, route is not marked in the path, but collision point is * marked broken. */ int WillCollide; /* Is this train going to collide with anything */ int Tspeed; /* speed to set the train to */ int CollisionPoint; /* If there is a collision where it will take place */ Tspeed = 6; WillCollide = CheckSpeed(desiredPath, trainNum, speedLookup(trainNum, Tspeed)); if (!WillCollide) { MarkRoute(desiredPath, trainNum, speedLookup(trainNum, Tspeed)); return Tspeed; } Tspeed = 2; WillCollide = CheckSpeed(desiredPath, trainNum, speedLookup(trainNum, Tspeed)); if (!WillCollide) { MarkRoute(desiredPath, trainNum, speedLookup(trainNum, Tspeed)); return Tspeed; } Tspeed = 10; WillCollide = CheckSpeed(desiredPath, trainNum, speedLookup(trainNum, Tspeed)); if (!WillCollide) { MarkRoute(desiredPath, trainNum, speedLookup(trainNum, Tspeed)); return Tspeed; } /* Picking different speeds is not doing much good, lets find the point * of collision and try to avoid it. */ CollisionPoint = CheckSpeed(desiredPath, trainNum, speedLookup(trainNum, 6)); breakSeg(desiredPath[CollisionPoint].thisNode); return COLISION; }