46#pragma warning(disable: 4355)
116 myNet->getGNEApplicationWindow()->getFileBucketHandler()->updateOptions();
118 myNet->getSavingStatus()->requireSaveAdditionals();
119 myNet->getSavingStatus()->requireSaveDemandElements();
205 for (
const auto& inspectedAC :
myNet->getViewNet()->getInspectedElements().getACs()) {
206 if (inspectedAC->getTagProperty()->vehicleRouteEmbedded()) {
208 if (demandElement && (demandElement->getChildDemandElements().size() > 0) &&
209 (demandElement->getChildDemandElements().at(0) ==
this)) {
216 if (
myNet->getViewNet()->getPopup()) {
217 return myNet->getViewNet()->getPopup()->getGLObject() ==
this;
226 const auto& modes =
myNet->getViewNet()->getEditModes();
228 const auto& personFramePlanSelector =
myNet->getViewParent()->getPersonFrame()->getPlanSelector();
229 const auto& personPlanFramePlanSelector =
myNet->getViewParent()->getPersonPlanFrame()->getPlanSelector();
230 const auto& containerFramePlanSelector =
myNet->getViewParent()->getContainerFrame()->getPlanSelector();
231 const auto& containerPlanFramePlanSelector =
myNet->getViewParent()->getContainerPlanFrame()->getPlanSelector();
235 const auto& vehicleFrame =
myNet->getViewParent()->getVehicleFrame();
237 if (vehicleFrame->shown()) {
239 const auto& vehicleTemplate = vehicleFrame->getVehicleTagSelector()->getCurrentTemplateAC();
241 if (vehicleTemplate && vehicleTemplate->getTagProperty()->vehicleRoute()) {
242 return myNet->getViewNet()->getViewObjectsSelector().getGUIGlObjectFront() ==
this;
244 }
else if (modes.isCurrentSupermodeDemand()) {
250 return myNet->getViewNet()->getViewObjectsSelector().getGUIGlObjectFront() ==
this;
261 const auto& editModes =
myNet->getViewNet()->getEditModes();
274 const auto route =
myNet->getViewNet()->getViewObjectsSelector().getDemandElementFront();
275 if (route && (route ==
myNet->getViewNet()->getViewObjectsSelector().getAttributeCarrierFront())) {
279 const auto vehicle =
myNet->getViewNet()->getViewObjectsSelector().getDemandElementFront();
280 if (vehicle && (vehicle ==
myNet->getViewNet()->getViewObjectsSelector().getAttributeCarrierFront())) {
291 const auto& editModes =
myNet->getViewNet()->getEditModes();
304 const auto& editModes =
myNet->getViewNet()->getEditModes();
306 if (!
myNet->getViewNet()->isCurrentlyMovingElements() &&
307 editModes.isCurrentSupermodeDemand() &&
310 myNet->getViewNet()->getViewObjectsSelector().getGUIGlObjectFront() ==
this) {
346 new FXMenuSeparator(ret);
358 for (
const auto& attrProperty :
myTagProperty->getAttributeProperties()) {
360 if (attrProperty->isUnique()) {
361 ret->
mkItem(attrProperty->getAttrStr().c_str(),
false,
getAttribute(attrProperty->getAttr()));
363 ret->
mkItem(attrProperty->getAttrStr().c_str(),
true,
getAttribute(attrProperty->getAttr()));
374 if (
myNet->getViewNet()->getEditModes().isCurrentSupermodeDemand()) {
398 myNet->deleteDemandElement(
this,
myNet->getUndoList());
404 myNet->deleteDemandElement(
this,
myNet->getUndoList());
417 myNet->getViewParent()->getSelectorFrame()->getSelectionInformation()->updateInformationLabel();
453 return (
myNet->getAttributeCarriers()->retrieveDemandElement(
myTagProperty->getTag(),
value,
false) ==
nullptr);
467 return (
myNet->getAttributeCarriers()->retrieveDemandElements(tags,
value,
false) ==
nullptr);
480 myNet->getAttributeCarriers()->updateDemandElementID(
this, newID);
486 childDemandElement->setDemandElementID(
getID());
495 throw InvalidArgument(
"This demand element doesn't have a type parent");
508 throw InvalidArgument(
"This demand element doesn't have a route parent");
518std::vector<GNEDemandElement*>
522 std::vector<GNEDemandElement*> invalidStops;
526 for (
const auto& edgeStop : edgeStopIndex) {
527 if (edgeStop.stopIndex == -1) {
528 for (
const auto& stop : edgeStop.stops) {
529 invalidStops.push_back(stop);
545 const double rot = ((double)atan2((posB.
x() - posA.
x()), (posA.
y() - posB.
y())) * (double) 180.0 / (
double)
M_PI);
562 const double width,
const double length,
const double exaggeration)
const {
564 const double contourWidth = (0.05 * exaggeration);
569 glRotated(rotation, 0, 0, -1);
570 glTranslated((width * exaggeration * 0.5) + (0.35 * exaggeration) + 0.05, 0, 0);
575 glTranslated(0, 0, 0.1);
594 auto newLane =
myNet->getAttributeCarriers()->retrieveLane(
value);
601 auto newJunction =
myNet->getAttributeCarriers()->retrieveJunction(
value);
608 auto newJunction =
myNet->getAttributeCarriers()->retrieveJunction(
value);
615 auto newEdge =
myNet->getAttributeCarriers()->retrieveEdge(
value);
622 auto newEdge =
myNet->getAttributeCarriers()->retrieveEdge(
value);
629 auto newAdditional =
myNet->getAttributeCarriers()->retrieveAdditional(tag,
value);
636 auto newAdditional =
myNet->getAttributeCarriers()->retrieveAdditional(tag,
value);
645 for (
auto it = tags.begin(); (it != tags.end()) && (newDemandElement ==
nullptr); it++) {
646 newDemandElement =
myNet->getAttributeCarriers()->retrieveDemandElement(*it,
value,
false);
648 if (newDemandElement) {
651 throw ProcessError(
"Attempted to replace with non-existant demand element " +
value);
663std::vector<GNEDemandElement::EdgeStopIndex>
665 std::vector<GNEDemandElement::EdgeStopIndex> edgeStopIndex;
669 std::vector<GNEEdge*> pathEdges;
674 pathEdges = parent->getParentEdges();
675 }
else if (parent->getTagProperty()->vehicleRoute()) {
677 if (parent->getParentDemandElements().size() > 1) {
678 pathEdges = parent->getParentDemandElements().at(1)->getParentEdges();
680 }
else if (parent->getTagProperty()->vehicleRouteEmbedded()) {
682 pathEdges = parent->getChildDemandElements().front()->getParentEdges();
685 const auto lastEdge = parent->getParentEdges().back();
687 const auto& pathElementSegments =
myNet->getDemandPathManager()->getPathElementSegments(parent);
689 for (
auto it = pathElementSegments.begin(); (it != pathElementSegments.end()) && !stop; it++) {
690 if ((*it)->getLane()) {
691 pathEdges.push_back((*it)->getLane()->getParentEdge());
693 if (pathEdges.back() == lastEdge) {
700 for (
const auto& demandElement : parent->getChildDemandElements()) {
701 if (demandElement->getTagProperty()->isVehicleStop()) {
704 if (demandElement->getParentAdditionals().size() > 0) {
705 edge = demandElement->
getParentAdditionals().front()->getParentLanes().front()->getParentEdge();
710 if ((edgeStopIndex.size() > 0) && (edgeStopIndex.back().edge == edge)) {
711 edgeStopIndex.back().stops.push_back(demandElement);
718 int currentEdgeStopIndex = 0;
719 for (
int i = 0; (i < (int)pathEdges.size()) && (currentEdgeStopIndex < (
int)edgeStopIndex.size()); i++) {
721 if (edgeStopIndex[currentEdgeStopIndex].edge == pathEdges.at(i)) {
722 edgeStopIndex[currentEdgeStopIndex].stopIndex = i;
723 currentEdgeStopIndex++;
727 for (
int j = (i + 1); j < (int)pathEdges.size(); j++) {
728 if (edgeStopIndex[currentEdgeStopIndex].edge == pathEdges.at(j)) {
734 currentEdgeStopIndex++;
740 for (
auto& edgeStop : edgeStopIndex) {
741 if (edgeStop.stops.size() > 1) {
743 std::map<double, std::vector<GNEDemandElement*> > sortedStops;
744 for (
const auto& stop : edgeStop.stops) {
752 edgeStop.stops.clear();
753 for (
const auto& sortedStop : sortedStops) {
754 edgeStop.stops.insert(edgeStop.stops.end(), sortedStop.second.begin(), sortedStop.second.end());
758 return edgeStopIndex;
784 return parameters->
color;
792 return parameters->
color;
815 double hue = 180. + atan2(center.
x() - p.
x(), center.
y() - p.
y()) * 180. /
M_PI;
823 double hue = 180. + atan2(center.
x() - p.
x(), center.
y() - p.
y()) * 180. /
M_PI;
831 double hue = 180. + atan2(pb.
x() - pe.
x(), pb.
y() - pe.
y()) * 180. /
M_PI;
838 std::hash<const GNEDemandElement*> ptr_hash;
839 const double hue = (double)(ptr_hash(
this) % 360);
840 const double sat = (double)((ptr_hash(
this) / 360) % 67) / 100. + 0.33;
852 std::vector<GNEEdge*> edges;
863 const auto path =
myNet->getDemandPathManager()->getPathCalculator()->calculateDijkstraPath(
getVClass(), edges);
865 if (path.size() > 0) {
867 for (
const auto& edge : path) {
868 length += edge->getNBEdge()->getFinalLength();
870 for (
int i = 0; i < ((int)path.size() - 1); i++) {
871 length += path.at(i)->getChildLanes().front()->getLane2laneConnections().getLane2laneGeometry(path.at(i + 1)->getChildLanes().front()).getShape().length();
881 FXMenuPane* transformOperation =
new FXMenuPane(ret);
883 auto reverseMenuCascade =
new FXMenuCascade(ret,
TL(
"reverse"),
nullptr, transformOperation);
889 reverseMenuCascade->enable();
891 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_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)
GUIPropertySchemeStorage< GUIColorScheme > GUIColorer
const std::string invalid_return< std::string >::value
const long long int VEHPARS_COLOR_SET
SumoXMLTag
Numbers representing SUMO-XML - element names.
@ SUMO_TAG_ROUTE
description of a route
@ GNE_TAG_ROUTE_EMBEDDED
embedded route
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
@ 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.
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)
bool isAttributeCarrierSelected() const
check if attribute carrier is selected
void markForDrawingFront()
mark for drawing front
void selectAttributeCarrier()
GNEAttributeCarrier(const SumoXMLTag tag, GNENet *net)
Constructor for templates.
FXIcon * getACIcon() const
get FXIcon associated to this AC
bool mySelected
boolean to check if this AC is selected (more quickly as checking GUIGlObjectStorage)
FileBucket * myFileBucket
filebucket vinculated whith this AC
const std::string getID() const override
get ID (all Attribute Carriers have one)
static T parse(const std::string &string)
parses a value of type T from string (used for basic types: int, double, bool, etc....
PositionVector getCommonAttributePositionVector(SumoXMLAttr key) const
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
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
Position getCommonAttributePosition(SumoXMLAttr key) const
const GNETagProperties * getTagProperty() const
get tagProperty associated with this Attribute Carrier
GNENet * myNet
pointer to net
GNENet * getNet() const
get pointer to net
virtual void updateGeometry()=0
update pre-computed geometry information
virtual std::string getAttribute(SumoXMLAttr key) const =0
const GNETagProperties * myTagProperty
reference to tagProperty associated with this attribute carrier
void buildMenuCommandRouteLength(GUIGLObjectPopupMenu *ret) const
build menu command route length
bool checkDrawFromContour() const override
check if draw from contour (green)
bool isGLObjectLocked() const override
check if element is locked
Position getAttributePosition(SumoXMLAttr key) const override
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 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
GNEHierarchicalElement * getHierarchicalElement() override
methods to retrieve the elements linked to this GNEDemandElement
GUIGeometry myDemandElementGeometry
demand element geometry (also called "stacked geometry")
void changeFileBucket(FileBucket *fileBucket)
change filebucket manually (used only during calibratorFlows creation)
bool isValidDemandElementID(const std::string &value) const
check if a new demand element ID is valid
void selectGLObject() override
select element
GNEDemandElement * getNextChildDemandElement(const GNEDemandElement *demandElement) const
get next child demand element to the given demand element
void updateDemandElementStackLabel(const int stack)
update stack label
bool checkDrawDeleteContour() const override
check if draw delete contour (pink/white)
void replaceLastParentEdge(const std::string &value)
replace the last parent edge
void drawJunctionLine(const GNEDemandElement *element) const
draw line between junctions
virtual const RGBColor & getColor() const =0
get color
bool isPathElementSelected() const override
check if path element is selected
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent) override
Returns an own parameter window.
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 setDemandElementID(const std::string &newID)
set demand element id
PositionVector getAttributePositionVector(SumoXMLAttr key) const override
bool checkDrawMoveContour() const override
check if draw move contour (red)
GUIGeometry mySpreadGeometry
demand element spread geometry (Only used by vehicles and pedestrians)
void buildMenuAddReverse(GUIGLObjectPopupMenu *ret) const
build menu command route length
void updateGLObject() override
update GLObject (geometry, ID, etc.)
void replaceFirstParentJunction(const std::string &value)
replace the first parent junction
std::vector< EdgeStopIndex > getEdgeStopIndex() const
get edgeStopIndex
bool checkDrawSelectContour() const override
check if draw select contour (blue)
GNEDemandElement * getTypeParent() const
get type parent (needed because first parent can be either type or typeDistribution)
void replaceDemandElementParent(const std::vector< SumoXMLTag > tags, const std::string &value, const int parentIndex)
replace demand element parent
void deleteGLObject() override
delete element
void replaceParentEdges(const std::string &value)
all edges
virtual GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent) override
Returns an own popup-menu.
void replaceFirstParentEdge(const std::string &value)
replace the first parent edge
int myStackedLabelNumber
stacked label number
FileBucket * getFileBucket() const override
get reference to fileBucket in which save this AC
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)
GNEDemandElement(GNENet *net, SumoXMLTag tag)
Constructor for templates.
virtual bool checkChildDemandElementRestriction() const
check restriction with the number of children
GUIGlObject * getGUIGlObject() override
get GUIGlObject associated with this GNEDemandElement
bool checkDrawRelatedContour() const override
check if draw related contour (cyan)
GNEDemandElement * getPreviousChildDemandElement(const GNEDemandElement *demandElement) const
get previous child demand element to the given demand element
void replaceFirstParentLane(const std::string &value)
replace the first parent lane
bool checkDrawDeleteContourSmall() const override
check if draw delete contour small (pink/white)
void replaceLastParentAdditional(SumoXMLTag tag, const std::string &value)
replace the last parent additional
virtual ~GNEDemandElement()
Destructor.
virtual void openDemandElementDialog()
open DemandElement Dialog
void replaceLastParentJunction(const std::string &value)
replace the last parent junction
bool checkDrawToContour() const override
check if draw from contour (magenta)
void markAsFrontElement() override
mark element as front element
bool checkDrawOverContour() const override
check if draw over contour (orange)
const GNEHierarchicalContainerParents< GNEAdditional * > & getParentAdditionals() const
get parent additionals
const GNEHierarchicalContainerParents< GNEDemandElement * > & getParentDemandElements() const
get parent demand elements
const GNEHierarchicalContainerParents< GNEEdge * > & getParentEdges() const
get parent edges
friend class GNEDemandElement
const GNEHierarchicalContainerParents< GNEJunction * > & getParentJunctions() const
get parent junctions
const GNEHierarchicalContainerParents< GNELane * > & getParentLanes() const
get parent lanes
static void updateParent(ElementType element, const int index, ParentType newParent)
update single parent element
const GNEHierarchicalContainerChildren< GNEDemandElement * > & getChildDemandElements() const
return child demand elements
static void updateParents(ElementType element, GNEHierarchicalContainerParents< ParentType > newParents)
update all parent elements
const PositionVector & getLaneShape() const
get elements shape
GNEPathElement(const GNEPathElement::Options options)
constructor
bool isRoute() const
check if pathElement is a route
static bool canReverse(const GNEDemandElement *element)
reverse functions
static FXMenuCommand * buildFXMenuCommand(FXComposite *p, const std::string &text, FXIcon *icon, FXObject *tgt, FXSelector sel, const bool disable=false)
build menu command
virtual void setMicrosimID(const std::string &newID)
Changes the microsimID of the object.
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
void buildPopUpMenuCommonOptions(GUIGLObjectPopupMenu *ret, GUIMainWindow &app, GUISUMOAbstractView *parent, const SumoXMLTag tag, const bool selected, bool addSeparator=true)
GUIGlObject(GUIGlObjectType type, const std::string µsimID, FXIcon *icon)
Constructor.
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