void GUINet::initGUIStructures() { // initialise detector storage for gui initDetectors(); // initialise the tl-map initTLMap(); // initialise edge storage for gui GUIEdge::fill(myEdgeWrapper); // initialise junction storage for gui size_t size = myJunctions->size(); myJunctionWrapper.reserve(size); const std::map<std::string, MSJunction*> &junctions = myJunctions->getMyMap(); for (std::map<std::string, MSJunction*>::const_iterator i=junctions.begin(); i!=junctions.end(); ++i) { myJunctionWrapper.push_back(new GUIJunctionWrapper(GUIGlObjectStorage::gIDStorage, *(*i).second)); } // build the visualization tree float *cmin = new float[2]; float *cmax = new float[2]; for (std::vector<GUIEdge*>::iterator i=myEdgeWrapper.begin(); i!=myEdgeWrapper.end(); ++i) { GUIEdge *edge = *i; Boundary b; const std::vector<MSLane*> &lanes = edge->getLanes(); for (std::vector<MSLane*>::const_iterator j=lanes.begin(); j!=lanes.end(); ++j) { b.add((*j)->getShape().getBoxBoundary()); } b.grow(2.); cmin[0] = b.xmin(); cmin[1] = b.ymin(); cmax[0] = b.xmax(); cmax[1] = b.ymax(); myGrid->Insert(cmin, cmax, edge); myBoundary.add(b); } for (std::vector<GUIJunctionWrapper*>::iterator i=myJunctionWrapper.begin(); i!=myJunctionWrapper.end(); ++i) { GUIJunctionWrapper *junction = *i; Boundary b = junction->getBoundary(); b.grow(2.); cmin[0] = b.xmin(); cmin[1] = b.ymin(); cmax[0] = b.xmax(); cmax[1] = b.ymax(); myGrid->Insert(cmin, cmax, junction); myBoundary.add(b); } const std::vector<GUIGlObject_AbstractAdd*> &a = GUIGlObject_AbstractAdd::getObjectList(); for (std::vector<GUIGlObject_AbstractAdd*>::const_iterator i=a.begin(); i!=a.end(); ++i) { GUIGlObject_AbstractAdd *o = *i; Boundary b = o->getCenteringBoundary(); cmin[0] = b.xmin(); cmin[1] = b.ymin(); cmax[0] = b.xmax(); cmax[1] = b.ymax(); myGrid->Insert(cmin, cmax, o); } delete[] cmin; delete[] cmax; myGrid->add(myBoundary); }
std::vector<GUIGlID> GUIEdge::getIDs(bool includeInternal) { std::vector<GUIGlID> ret; ret.reserve(MSEdge::myDict.size()); for (MSEdge::DictType::iterator i = MSEdge::myDict.begin(); i != MSEdge::myDict.end(); ++i) { GUIEdge* edge = dynamic_cast<GUIEdge*>(i->second); assert(edge); if (edge->getPurpose() != EDGEFUNCTION_INTERNAL || includeInternal) { ret.push_back(edge->getGlID()); } } return ret; }
bool GUISUMOViewParent::isSelected(GUIGlObject* o) const { GUIGlObjectType type = o->getType(); if (gSelected.isSelected(type, o->getGlID())) { return true; } else if (type == GLO_EDGE) { GUIEdge* edge = dynamic_cast<GUIEdge*>(o); if (edge == 0) { // hmph, just some security stuff return false; } size_t noLanes = edge->getLanes().size(); for (size_t j = 0; j < noLanes; ++j) { const GUILaneWrapper& l = edge->getLaneGeometry(j); if (gSelected.isSelected(GLO_LANE, l.getGlID())) { return true; } } return false; } else { return false; } }
bool GUISUMOViewParent::isSelected(GUIGlObject* o) const { GUIGlObjectType type = o->getType(); if (gSelected.isSelected(type, o->getGlID())) { return true; } else if (type == GLO_EDGE) { GUIEdge* edge = dynamic_cast<GUIEdge*>(o); if (edge == 0) { // hmph, just some security stuff return false; } const std::vector<MSLane*>& lanes = edge->getLanes(); for (std::vector<MSLane*>::const_iterator j = lanes.begin(); j != lanes.end(); ++j) { GUILane* l = dynamic_cast<GUILane*>(*j); if (l != 0 && gSelected.isSelected(GLO_LANE, l->getGlID())) { return true; } } return false; } else { return false; } }
void GUINet::initGUIStructures() { // initialise detector storage for gui const std::vector<SumoXMLTag> types = myDetectorControl->getAvailableTypes(); for (std::vector<SumoXMLTag>::const_iterator i = types.begin(); i != types.end(); ++i) { const std::map<std::string, MSDetectorFileOutput*>& dets = myDetectorControl->getTypedDetectors(*i).getMyMap(); for (std::map<std::string, MSDetectorFileOutput*>::const_iterator j = dets.begin(); j != dets.end(); ++j) { GUIDetectorWrapper* wrapper = (*j).second->buildDetectorGUIRepresentation(); if (wrapper != 0) { myDetectorDict.push_back(wrapper); myGrid.addAdditionalGLObject(wrapper); } } } // initialise the tl-map initTLMap(); // initialise edge storage for gui GUIEdge::fill(myEdgeWrapper); // initialise junction storage for gui size_t size = myJunctions->size(); myJunctionWrapper.reserve(size); const std::map<std::string, MSJunction*>& junctions = myJunctions->getMyMap(); for (std::map<std::string, MSJunction*>::const_iterator i = junctions.begin(); i != junctions.end(); ++i) { myJunctionWrapper.push_back(new GUIJunctionWrapper(*(*i).second)); } // build the visualization tree float* cmin = new float[2]; float* cmax = new float[2]; for (std::vector<GUIEdge*>::iterator i = myEdgeWrapper.begin(); i != myEdgeWrapper.end(); ++i) { GUIEdge* edge = *i; Boundary b; const std::vector<MSLane*>& lanes = edge->getLanes(); for (std::vector<MSLane*>::const_iterator j = lanes.begin(); j != lanes.end(); ++j) { b.add((*j)->getShape().getBoxBoundary()); } // make sure persons are always drawn and selectable since they depend on their edge being drawn b.grow(MSPModel::SIDEWALK_OFFSET + 1); cmin[0] = b.xmin(); cmin[1] = b.ymin(); cmax[0] = b.xmax(); cmax[1] = b.ymax(); myGrid.Insert(cmin, cmax, edge); myBoundary.add(b); if (myBoundary.getWidth() > 10e16 || myBoundary.getHeight() > 10e16) { throw ProcessError("Network size exceeds 1 Lightyear. Please reconsider your inputs.\n"); } } for (std::vector<GUIJunctionWrapper*>::iterator i = myJunctionWrapper.begin(); i != myJunctionWrapper.end(); ++i) { GUIJunctionWrapper* junction = *i; Boundary b = junction->getBoundary(); b.grow(2.); cmin[0] = b.xmin(); cmin[1] = b.ymin(); cmax[0] = b.xmax(); cmax[1] = b.ymax(); myGrid.Insert(cmin, cmax, junction); myBoundary.add(b); } delete[] cmin; delete[] cmax; myGrid.add(myBoundary); }
Boundary GUINet::getEdgeBoundary(const std::string &name) const { GUIEdge *edge = static_cast<GUIEdge*>(MSEdge::dictionary(name)); return edge->getBoundary(); }