Eclipse SUMO - Simulation of Urban MObility
GNEShape.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2022 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials are made available under the
5 // terms of the Eclipse Public License 2.0 which is available at
6 // https://www.eclipse.org/legal/epl-2.0/
7 // This Source Code may also be made available under the following Secondary
8 // Licenses when the conditions for such availability set forth in the Eclipse
9 // Public License 2.0 are satisfied: GNU General Public License, version 2
10 // or later which is available at
11 // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 /****************************************************************************/
18 // Abstract class for Shapes uses in netedit
19 /****************************************************************************/
20 #include <config.h>
21 
23 #include <netedit/GNENet.h>
24 #include <netedit/GNEViewNet.h>
26 #include <utils/gui/div/GLHelper.h>
27 
28 #include "GNEShape.h"
29 
30 
31 // ===========================================================================
32 // method definitions
33 // ===========================================================================
34 
35 GNEShape::GNEShape(const std::string& id, GNENet* net, GUIGlObjectType type, SumoXMLTag tag,
36  const std::vector<GNEJunction*>& junctionParents,
37  const std::vector<GNEEdge*>& edgeParents,
38  const std::vector<GNELane*>& laneParents,
39  const std::vector<GNEAdditional*>& additionalParents,
40  const std::vector<GNEShape*>& shapeParents,
41  const std::vector<GNETAZElement*>& TAZElementParents,
42  const std::vector<GNEDemandElement*>& demandElementParents,
43  const std::vector<GNEGenericData*>& genericDataParents) :
44  GUIGlObject(type, id),
45  GNEHierarchicalElement(net, tag, junctionParents, edgeParents, laneParents, additionalParents, shapeParents, TAZElementParents, demandElementParents, genericDataParents) {
46 }
47 
48 
50 
51 
52 const std::string&
53 GNEShape::getID() const {
54  return getMicrosimID();
55 }
56 
57 
60  return this;
61 }
62 
63 
66  return myBoundary;
67 }
68 
69 
70 void
72  //
73 }
74 
75 
76 void
78  //
79 }
80 
81 
82 bool
84  return false;
85 }
86 
87 
88 std::string
90  return getTagStr() + ": " + getID();
91 }
92 
93 
94 std::string
96  return getTagStr();
97 }
98 
99 
100 void
101 GNEShape::replaceShapeParentLanes(const std::string& value) {
102  replaceParentElements(this, parse<std::vector<GNELane*> >(getNet(), value));
103 }
104 
105 
106 void
108  // get new lane parent vector
109  std::vector<GNELane*> newLane = {getParentLanes().front()->getParentEdge()->getLanes().at(getParentLanes().front()->getIndex() + 1)};
110  // replace parent elements
111  replaceParentElements(this, newLane);
112 }
113 
114 
115 void
116 GNEShape::toogleAttribute(SumoXMLAttr /*key*/, const bool /*value*/, const int /*previousParameters*/) {
117  // throw InvalidArgument("Nothing to enable");
118 }
119 
120 /****************************************************************************/
GUIGlObjectType
SumoXMLTag
Numbers representing SUMO-XML - element names.
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:39
static T parse(const std::string &string)
parses a value of type T from string (used for basic types: int, double, bool, etc....
const std::string & getTagStr() const
get tag assigned to this object in string format
GNENet * getNet() const
get pointer to net
const std::vector< GNELane * > & getParentLanes() const
get parent lanes
void replaceParentElements(T *elementChild, const U &newParents)
replace parent elements
A NBNetBuilder extended by visualisation and editing capabilities.
Definition: GNENet.h:42
std::string getHierarchyName() const
get Hierarchy Name (Used in AC Hierarchy)
Definition: GNEShape.cpp:95
void disableAttribute(SumoXMLAttr key, GNEUndoList *undoList)
Definition: GNEShape.cpp:77
void enableAttribute(SumoXMLAttr key, GNEUndoList *undoList)
Definition: GNEShape.cpp:71
Boundary myBoundary
object boundary
Definition: GNEShape.h:207
std::string getPopUpID() const
get PopPup ID (Used in AC Hierarchy)
Definition: GNEShape.cpp:89
void shiftLaneIndex()
shift lane index
Definition: GNEShape.cpp:107
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GNEShape.cpp:65
GNEShape(const std::string &id, GNENet *net, GUIGlObjectType type, SumoXMLTag tag, const std::vector< GNEJunction * > &junctionParents, const std::vector< GNEEdge * > &edgeParents, const std::vector< GNELane * > &laneParents, const std::vector< GNEAdditional * > &additionalParents, const std::vector< GNEShape * > &shapeParents, const std::vector< GNETAZElement * > &TAZElementParents, const std::vector< GNEDemandElement * > &demandElementParents, const std::vector< GNEGenericData * > &genericDataParents)
Constructor.
Definition: GNEShape.cpp:35
void toogleAttribute(SumoXMLAttr key, const bool value, const int previousParameters)
method for enable or disable the attribute and nothing else (used in GNEChange_EnableAttribute)
Definition: GNEShape.cpp:116
GUIGlObject * getGUIGlObject()
get GUIGlObject associated with this AttributeCarrier
Definition: GNEShape.cpp:59
const std::string & getID() const
get ID (all shapes have one)
Definition: GNEShape.cpp:53
~GNEShape()
Destructor.
Definition: GNEShape.cpp:49
bool isAttributeComputed(SumoXMLAttr key) const
Definition: GNEShape.cpp:83
void replaceShapeParentLanes(const std::string &value)
replace shape parent lanes
Definition: GNEShape.cpp:101
virtual const std::string & getMicrosimID() const
Returns the id of the object as known to microsim.