45 const std::vector<GNEJunction*>& junctionParents,
46 const std::vector<GNEEdge*>& edgeParents,
47 const std::vector<GNELane*>& laneParents,
48 const std::vector<GNEAdditional*>& additionalParents,
49 const std::vector<GNEDemandElement*>& demandElementParents,
50 const std::vector<GNEGenericData*>& genericDataParents) :
52 GNEHierarchicalElement(net, tag, junctionParents, edgeParents, laneParents, additionalParents, demandElementParents, genericDataParents),
54 myStackedLabelNumber(0) {
61 const std::vector<GNEJunction*>& junctionParents,
62 const std::vector<GNEEdge*>& edgeParents,
63 const std::vector<GNELane*>& laneParents,
64 const std::vector<GNEAdditional*>& additionalParents,
65 const std::vector<GNEDemandElement*>& demandElementParents,
66 const std::vector<GNEGenericData*>& genericDataParents) :
68 GNEHierarchicalElement(net, tag, junctionParents, edgeParents, laneParents, additionalParents, demandElementParents, genericDataParents),
70 myStackedLabelNumber(0) {
178 if (inspectedAC->getTagProperty().vehicleRouteEmbedded()) {
180 if (demandElement && (demandElement->getChildDemandElements().size() > 0) &&
181 (demandElement->getChildDemandElements().at(0) ==
this)) {
207 if (vehicleFrame->shown()) {
211 if (vehicleTemplate && vehicleTemplate->getTagProperty().vehicleRoute()) {
214 }
else if (modes.isCurrentSupermodeDemand()) {
260 editModes.isCurrentSupermodeDemand() &&
301 new FXMenuSeparator(ret);
308 new FXMenuSeparator(ret);
412 if (value ==
getID()) {
434 childDemandElement->setDemandElementID(
getID());
443 throw InvalidArgument(
"This demand element doesn't have a type parent");
453 std::map<std::string, GNEDemandElement*> sortedTypes;
456 sortedTypes[type.second->getID()] = type.second;
460 if (sortedTypes.size() > 0) {
461 return sortedTypes.begin()->second;
476 throw InvalidArgument(
"This demand element doesn't have a route parent");
483std::vector<GNEDemandElement*>
487 std::vector<GNEDemandElement*> invalidStops;
491 for (
const auto& edgeStop : edgeStopIndex) {
492 if (edgeStop.stopIndex == -1) {
493 for (
const auto& stop : edgeStop.stops) {
494 invalidStops.push_back(stop);
510 const double rot = ((double)atan2((posB.
x() - posA.
x()), (posA.
y() - posB.
y())) * (double) 180.0 / (
double)
M_PI);
527 const double width,
const double length,
const double exaggeration)
const {
529 const double contourWidth = (0.05 * exaggeration);
534 glRotated(rotation, 0, 0, -1);
535 glTranslated((width * exaggeration * 0.5) + (0.35 * exaggeration) + 0.05, 0, 0);
540 glTranslated(0, 0, 0.1);
627 std::vector<GNEDemandElement*> parents;
628 if (value.size() > 0) {
642std::vector<GNEDemandElement::EdgeStopIndex>
644 std::vector<GNEDemandElement::EdgeStopIndex> edgeStopIndex;
648 std::vector<GNEEdge*> pathEdges;
653 pathEdges = parent->getParentEdges();
654 }
else if (parent->getTagProperty().vehicleRoute()) {
656 if (parent->getParentDemandElements().size() > 1) {
657 pathEdges = parent->getParentDemandElements().at(1)->getParentEdges();
659 }
else if (parent->getTagProperty().vehicleRouteEmbedded()) {
661 pathEdges = parent->getChildDemandElements().front()->getParentEdges();
664 const auto lastEdge = parent->getParentEdges().back();
668 for (
auto it = pathElementSegments.begin(); (it != pathElementSegments.end()) && !stop; it++) {
669 if ((*it)->getLane()) {
670 pathEdges.push_back((*it)->getLane()->getParentEdge());
672 if (pathEdges.back() == lastEdge) {
679 for (
const auto& demandElement : parent->getChildDemandElements()) {
680 if (demandElement->getTagProperty().isVehicleStop()) {
683 if (demandElement->getParentAdditionals().size() > 0) {
684 edge = demandElement->
getParentAdditionals().front()->getParentLanes().front()->getParentEdge();
689 if ((edgeStopIndex.size() > 0) && (edgeStopIndex.back().edge == edge)) {
690 edgeStopIndex.back().stops.push_back(demandElement);
697 int currentEdgeStopIndex = 0;
698 for (
int i = 0; (i < (int)pathEdges.size()) && (currentEdgeStopIndex < (
int)edgeStopIndex.size()); i++) {
700 if (edgeStopIndex[currentEdgeStopIndex].edge == pathEdges.at(i)) {
701 edgeStopIndex[currentEdgeStopIndex].stopIndex = i;
702 currentEdgeStopIndex++;
706 for (
int j = (i + 1); j < (int)pathEdges.size(); j++) {
707 if (edgeStopIndex[currentEdgeStopIndex].edge == pathEdges.at(j)) {
713 currentEdgeStopIndex++;
719 for (
auto& edgeStop : edgeStopIndex) {
720 if (edgeStop.stops.size() > 1) {
722 std::map<double, std::vector<GNEDemandElement*> > sortedStops;
723 for (
const auto& stop : edgeStop.stops) {
731 edgeStop.stops.clear();
732 for (
const auto& sortedStop : sortedStops) {
733 edgeStop.stops.insert(edgeStop.stops.end(), sortedStop.second.begin(), sortedStop.second.end());
737 return edgeStopIndex;
763 return parameters->
color;
771 return parameters->
color;
795 double hue = 180. + atan2(center.
x() - p.
x(), center.
y() - p.
y()) * 180. /
M_PI;
803 double hue = 180. + atan2(center.
x() - p.
x(), center.
y() - p.
y()) * 180. /
M_PI;
811 double hue = 180. + atan2(pb.
x() - pe.
x(), pb.
y() - pe.
y()) * 180. /
M_PI;
818 std::hash<const GNEDemandElement*> ptr_hash;
819 const double hue = (double)(ptr_hash(
this) % 360);
820 const double sat = (double)((ptr_hash(
this) / 360) % 67) / 100. + 0.33;
841 std::vector<std::string> distributionParents;
843 if (distribution.second->keyExists(
this)) {
844 distributionParents.push_back(distribution.second->getID());
847 return toString(distributionParents);
853 std::vector<GNEEdge*> edges;
866 if (path.size() > 0) {
868 for (
const auto& edge : path) {
869 length += edge->getNBEdge()->getFinalLength();
871 for (
int i = 0; i < ((int)path.size() - 1); i++) {
872 length += path.at(i)->getLanes().front()->getLane2laneConnections().getLane2laneGeometry(path.at(i + 1)->getLanes().front()).getShape().length();
882 FXMenuPane* transformOperation =
new FXMenuPane(ret);
884 auto reverseMenuCascade =
new FXMenuCascade(ret,
TL(
"reverse"),
nullptr, transformOperation);
890 reverseMenuCascade->enable();
892 reverseMenuCascade->disable();
@ DEMAND_PERSONPLAN
Mode for editing person plan.
@ DEMAND_CONTAINER
Mode for editing container.
@ DEMAND_DELETE
mode for deleting demand elements
@ DEMAND_PERSON
Mode for editing person.
@ DEMAND_SELECT
mode for selecting demand elements
@ DEMAND_MOVE
mode for moving demand elements
@ DEMAND_CONTAINERPLAN
Mode for editing container plan.
@ MID_GNE_ADDREVERSE
add reverse element
@ MID_COPY_TYPED_NAME
Copy typed object name - popup entry.
@ MID_GNE_REVERSE
reverse current element
@ MID_OPEN_ADDITIONAL_DIALOG
open additional dialog (used in netedit)
@ MID_COPY_NAME
Copy object name - popup entry.
@ GLO_VEHICLELABELS
stack and flow labels (used in netedit)
const long long int VEHPARS_COLOR_SET
SumoXMLTag
Numbers representing SUMO-XML - element names.
@ SUMO_TAG_VTYPE
description of a vehicle/person/container type
@ SUMO_TAG_NOTHING
invalid tag, must be the last one
@ SUMO_TAG_ROUTE_DISTRIBUTION
distribution of a route
@ SUMO_TAG_ROUTE
begin/end of the description of a route
@ SUMO_TAG_VTYPE_DISTRIBUTION
distribution of a vehicle type
@ GNE_TAG_ROUTE_EMBEDDED
embedded route
@ GNE_ATTR_VTYPE_DISTRIBUTION
vehicle type distribution
@ SUMO_ATTR_EDGES
the edges of a route
@ SUMO_ATTR_COLOR
A color information.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
A class that stores a 2D geometrical boundary.
Position getCenter() const
Returns the center of the boundary.
double ymin() const
Returns minimum y-coordinate.
double xmin() const
Returns minimum x-coordinate.
double ymax() const
Returns maximum y-coordinate.
double xmax() const
Returns maximum x-coordinate.
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
static void popMatrix()
pop matrix
static void drawBoxLine(const Position &beg, double rot, double visLength, double width, double offset=0)
Draws a thick line.
static void pushMatrix()
push matrix
static void drawText(const std::string &text, const Position &pos, const double layer, const double size, const RGBColor &col=RGBColor::BLACK, const double angle=0, const int align=0, double width=-1)
const std::string getID() const
get ID (all Attribute Carriers have one)
bool isAttributeCarrierSelected() const
check if attribute carrier is selected
void markForDrawingFront()
mark for drawing front
void selectAttributeCarrier()
select attribute carrier using GUIGlobalSelection
FXIcon * getACIcon() const
get FXIcon associated to this AC
bool mySelected
boolean to check if this AC is selected (more quickly as checking GUIGlObjectStorage)
bool myIsTemplate
whether the current object is a template object (not drawn in the view)
static T parse(const std::string &string)
parses a value of type T from string (used for basic types: int, double, bool, etc....
void unselectAttributeCarrier()
unselect attribute carrier using GUIGlobalSelection
virtual bool isAttributeEnabled(SumoXMLAttr key) const
const std::string & getTagStr() const
get tag assigned to this object in string format
const GNETagProperties & getTagProperty() const
get tagProperty associated with this Attribute Carrier
bool isTemplate() const
check if this AC is template
void drawInLayer(const double typeOrLayer, const double extraOffset=0) const
draw element in the given layer, or in front if corresponding flag is enabled
GNENet * myNet
pointer to net
GNENet * getNet() const
get pointer to net
const GNETagProperties & myTagProperty
reference to tagProperty associated with this attribute carrier
GNEPlanSelector * getPlanSelector() const
get containerPlan selector
GNEPlanSelector * getPlanSelector() const
get containerPlan selector
void buildMenuCommandRouteLength(GUIGLObjectPopupMenu *ret) const
build menu command route length
void replaceDemandParentEdges(const std::string &value)
replace demand parent edges
virtual void updateGeometry()=0
update pre-computed geometry information
std::vector< GNEDemandElement * > getInvalidStops() const
get invalid stops
virtual SUMOVehicleClass getVClass() const =0
obtain VClass related with this demand element
void updateDemandElementGeometry(const GNELane *lane, const double posOverLane)
update element stacked geometry (stacked)
void replaceDemandElementParent(SumoXMLTag tag, const std::string &value, const int parentIndex)
replace demand element parent
void drawStackLabel(const int number, const std::string &element, const Position &position, const double rotation, const double width, const double length, const double exaggeration) const
draw stack label
bool checkDrawOverContour() const
check if draw over contour (orange)
std::string getDistributionParents() const
get distribution in which the given element is part
GUIGeometry myDemandElementGeometry
demand element geometry (also called "stacked geometry")
bool isValidDemandElementID(const std::string &value) const
check if a new demand element ID is valid
GNEDemandElement * getNextChildDemandElement(const GNEDemandElement *demandElement) const
get next child demand element to the given demand element
void updateDemandElementStackLabel(const int stack)
update stack label
void replaceLastParentEdge(const std::string &value)
replace the last parent edge
void drawJunctionLine(const GNEDemandElement *element) const
draw line between junctions
virtual std::string getAttribute(SumoXMLAttr key) const =0
virtual const RGBColor & getColor() const =0
get color
GUIGlObject * getGUIGlObject()
get GUIGlObject associated with this AttributeCarrier
bool isPathElementSelected() const
check if path element is selected
bool checkDrawToContour() const
check if draw from contour (magenta)
void replaceFirstParentAdditional(SumoXMLTag tag, const std::string &value)
replace the first parent additional
GNEDemandElement * getRouteParent() const
get route parent (always the second parent demand element)
void selectGLObject()
select element
bool checkDrawMoveContour() const
check if draw move contour (red)
bool checkDrawDeleteContour() const
check if draw delete contour (pink/white)
void setDemandElementID(const std::string &newID)
set demand element id
GUIGeometry mySpreadGeometry
demand element spread geometry (Only used by vehicles and pedestrians)
void buildMenuAddReverse(GUIGLObjectPopupMenu *ret) const
build menu command route length
void replaceFirstParentJunction(const std::string &value)
replace the first parent junction
std::vector< EdgeStopIndex > getEdgeStopIndex() const
get edgeStopIndex
bool checkDrawRelatedContour() const
check if draw related contour (cyan)
void setVTypeDistributionParent(const std::string &value)
set VTypeDistribution parent
void updateGLObject()
update GLObject (geometry, ID, etc.)
GNEDemandElement * getTypeParent() const
get type parent (needed because first parent can be either type or typeDistribution)
bool checkDrawSelectContour() const
check if draw select contour (blue)
void replaceDemandParentLanes(const std::string &value)
replace demand parent lanes
void replaceFirstParentEdge(const std::string &value)
replace the first parent edge
int myStackedLabelNumber
stacked label number
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
void updateDemandElementSpreadGeometry(const GNELane *lane, const double posOverLane)
update element spread geometry
virtual Position getPositionInView() const =0
Returns position of demand element in view.
RGBColor getColorByScheme(const GUIColorer &c, const SUMOVehicleParameter *parameters) const
get color by scheme (used by vehicles, persons and containers)
const GUIGeometry & getDemandElementGeometry()
get demand element geometry (stacked)
virtual GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
virtual bool checkChildDemandElementRestriction() const
check restriction with the number of children
void removeGeometryPoint(const Position clickedPosition, GNEUndoList *undoList)
remove geometry point in the clicked position (Currently unused in shapes)
GNEDemandElement * getPreviousChildDemandElement(const GNEDemandElement *demandElement) const
get previous child demand element to the given demand element
bool isGLObjectLocked() const
check if element is locked
void markAsFrontElement()
mark element as front element
void replaceLastParentAdditional(SumoXMLTag tag, const std::string &value)
replace the last parent additional
virtual ~GNEDemandElement()
Destructor.
virtual void openDemandElementDialog()
open DemandElement Dialog
void deleteGLObject()
delete element
void replaceLastParentJunction(const std::string &value)
replace the last parent junction
bool checkDrawFromContour() const
check if draw from contour (green)
A road/street connecting two junctions (netedit-version)
const std::vector< GNEJunction * > & getParentJunctions() const
get parent junctions
const std::vector< GNEDemandElement * > & getChildDemandElements() const
return child demand elements
const std::vector< GNEDemandElement * > & getParentDemandElements() const
get parent demand elements
friend class GNEDemandElement
const std::vector< GNEAdditional * > & getParentAdditionals() const
get parent additionals
const std::vector< GNEEdge * > & getParentEdges() const
get parent edges
const std::vector< GNELane * > & getParentLanes() const
get parent lanes
void replaceParentElements(T *elementChild, const U &newParents)
replace parent elements
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
const PositionVector & getLaneShape() const
get elements shape
double myMoveElementLateralOffset
move element lateral offset (used by elements placed over lanes
const std::unordered_map< SumoXMLTag, std::unordered_map< const GUIGlObject *, GNEDemandElement * > > & getDemandElements() const
get demand elements
GNEAdditional * retrieveAdditional(SumoXMLTag type, const std::string &id, bool hardFail=true) const
Returns the named additional.
GNEJunction * retrieveJunction(const std::string &id, bool hardFail=true) const
get junction by id
GNEDemandElement * retrieveDemandElements(const std::vector< SumoXMLTag > types, const std::string &id, bool hardFail=true) const
Returns the named demand element.
void updateDemandElementID(GNEDemandElement *demandElement, const std::string &newID)
update demand element ID in container
GNEEdge * retrieveEdge(const std::string &id, bool hardFail=true) const
get edge by id
GNEDemandElement * retrieveDemandElement(SumoXMLTag type, const std::string &id, bool hardFail=true) const
Returns the named demand element.
A NBNetBuilder extended by visualisation and editing capabilities.
void deleteDemandElement(GNEDemandElement *demandElement, GNEUndoList *undoList)
remove demand element
const Boundary & getBoundary() const
returns the bounder of the network
GNEPathManager * getDemandPathManager()
get demand path manager
GNENetHelper::AttributeCarriers * getAttributeCarriers() const
get all attribute carriers used in this net
GNEViewNet * getViewNet() const
get view net
std::vector< GNEEdge * > calculateDijkstraPath(const SUMOVehicleClass vClass, const std::vector< GNEEdge * > &edges) const
calculate Dijkstra path between a list of edges (for example, from-via-to edges)
PathCalculator * getPathCalculator()
obtain instance of PathCalculator
const std::vector< GNESegment * > & getPathElementSegments(GNEPathElement *pathElement) const
get path segments
GNEPlanSelector * getPlanSelector() const
get personPlan selector
GNEPlanSelector * getPlanSelector() const
get personPlan selector
static bool canReverse(const GNEDemandElement *element)
reverse functions
SelectionInformation * getSelectionInformation() const
get modul for selection information
bool isContainer() const
return true if tag correspond to a container element
const std::string & getTagStr() const
get Tag vinculated with this attribute Property in String Format (used to avoid multiple calls to toS...
bool isRoute() const
return true if tag correspond to a route element
bool isVehicle() const
return true if tag correspond to a vehicle element
SumoXMLTag getTag() const
get Tag vinculated with this attribute Property
bool vehicleRouteEmbedded() const
return true if tag correspond to a vehicle placed over an embedded route
bool hasDialog() const
return true if tag correspond to an element that can be edited using a dialog
bool vehicleEdges() const
return true if tag correspond to a vehicle placed over from-to edges
bool hasAttribute(SumoXMLAttr attr) const
check if current TagProperties owns the attribute "attr"
bool isVehicleStop() const
return true if tag correspond to a vehicle stop element
bool isPerson() const
return true if tag correspond to a person element
bool vehicleRoute() const
plan parents
GNEAttributeCarrier * getCurrentTemplateAC() const
get current templateAC
GNETagSelector * getVehicleTagSelector() const
get vehicle tag selector (needed for transform vehicles)
const std::unordered_set< GNEAttributeCarrier * > & getACs() const
get hash table with all inspected ACs
bool isObjectLocked(GUIGlObjectType objectType, const bool selected) const
check if given GLObject is locked for inspect, select, delete and move
const GUIGlObject * getGUIGlObjectFront() const
get front GUIGLObject or a pointer to nullptr
bool isCurrentlyMovingElements() const
check if an element is being moved
const GNEViewNetHelper::EditModes & getEditModes() const
get edit modes
GNEViewNetHelper::InspectedElements & getInspectedElements()
get inspected elements
GNEViewParent * getViewParent() const
get the net object
bool checkOverLockedElement(const GUIGlObject *GLObject, const bool isSelected) const
check if given element is locked (used for drawing select and delete contour)
GNEUndoList * getUndoList() const
get the undoList object
const GNEViewNetHelper::ViewObjectsSelector & getViewObjectsSelector() const
get objects under cursor
GNEViewNetHelper::LockManager & getLockManager()
get lock manager
void buildSelectionACPopupEntry(GUIGLObjectPopupMenu *ret, GNEAttributeCarrier *AC)
Builds an entry which allows to (de)select the object.
GNEPersonPlanFrame * getPersonPlanFrame() const
get frame for DEMAND_PERSONFRAME
GNESelectorFrame * getSelectorFrame() const
get frame for select elements
GNEContainerPlanFrame * getContainerPlanFrame() const
get frame for DEMAND_CONTAINERFRAME
GNEVehicleFrame * getVehicleFrame() const
get frame for DEMAND_VEHICLE
GNEContainerFrame * getContainerFrame() const
get frame for DEMAND_CONTAINER
GNEPersonFrame * getPersonFrame() const
get frame for DEMAND_PERSON
static FXMenuCommand * buildFXMenuCommand(FXComposite *p, const std::string &text, FXIcon *icon, FXObject *tgt, FXSelector sel, const bool disable=false)
build menu command
void updateGeometry(const PositionVector &shape)
update entire geometry
void buildShowParamsPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to open the parameter window.
virtual void setMicrosimID(const std::string &newID)
Changes the microsimID of the object.
void buildCenterPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to center to the object.
void buildPopupHeader(GUIGLObjectPopupMenu *ret, GUIMainWindow &app, bool addSeparator=true)
Builds the header.
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
void buildPositionCopyEntry(GUIGLObjectPopupMenu *ret, const GUIMainWindow &app) const
Builds an entry which allows to copy the cursor position if geo projection is used,...
A window containing a gl-object's parameter.
void mkItem(const char *name, bool dynamic, ValueSource< T > *src)
Adds a row which obtains its value from a ValueSource.
void closeBuilding(const Parameterised *p=0)
Closes the building of the table.
T getColor(const double value) const
A point in 2D or 3D with translation and scaling methods.
double distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
double distanceTo(const Position &p2) const
returns the euclidean distance in 3 dimensions
double x() const
Returns the x-position.
double y() const
Returns the y-position.
static const RGBColor WHITE
static const RGBColor BLUE
static const RGBColor GREY
static RGBColor fromHSV(double h, double s, double v)
Converts the given hsv-triplet to rgb, inspired by http://alvyray.com/Papers/CG/hsv2rgb....
static const RGBColor DEFAULT_COLOR
The default color (for vehicle types and vehicles)
static const RGBColor RED
named colors
Structure representing possible vehicle parameter.
bool wasSet(long long int what) const
Returns whether the given parameter was set.
RGBColor color
The vehicle's color, TraCI may change this.
static bool isValidVehicleID(const std::string &value)
whether the given string is a valid id for a vehicle or flow
static const std::string format(const std::string &format, T value, Targs... Fargs)
adds a new formatted message
auxiliar struct used for calculate pathStopIndex
bool isCurrentSupermodeDemand() const
@check if current supermode is Demand