Eclipse SUMO - Simulation of Urban MObility
GNENetElement.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-2020 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 // A abstract class for netElements
19 /****************************************************************************/
20 #include <config.h>
21 
22 #include <netedit/GNENet.h>
23 #include <netedit/GNEViewNet.h>
24 #include <netedit/GNEViewParent.h>
28 #include <utils/geom/GeomHelper.h>
29 
30 #include "GNENetElement.h"
31 
32 
33 // ===========================================================================
34 // method definitions
35 // ===========================================================================
36 
37 GNENetElement::GNENetElement(GNENet* net, const std::string& id, GUIGlObjectType type, SumoXMLTag tag) :
38  GUIGlObject(type, id),
40  GNEHierarchicalParentElements(this, {}, {}, {}, {}, {}),
41  GNEHierarchicalChildElements(this, {}, {}, {}, {}, {}),
42  myNet(net),
44 }
45 
46 
48 
49 
50 void
53 }
54 
55 
56 std::string
58  return "";
59 }
60 
61 
62 GNENet*
64  return myNet;
65 }
66 
67 
70  // Create table
71  GUIParameterTableWindow* ret = new GUIParameterTableWindow(app, *this);
72  // Iterate over attributes
73  for (const auto& i : myTagProperty) {
74  // Add attribute and set it dynamic if aren't unique
75  if (i.isUnique()) {
76  ret->mkItem(i.getAttrStr().c_str(), false, getAttribute(i.getAttr()));
77  } else {
78  ret->mkItem(i.getAttrStr().c_str(), true, getAttribute(i.getAttr()));
79  }
80  }
81  // close building
82  ret->closeBuilding();
83  return ret;
84 }
85 
86 
87 void
89  if (!myNet) {
90  throw ProcessError("Net cannot be nullptr");
91  } else {
93  // add object into list of selected objects
95  if (changeFlag) {
96  mySelected = true;
97 
98  }
99  }
100 }
101 
102 
103 void
105  if (!myNet) {
106  throw ProcessError("Net cannot be nullptr");
107  } else {
109  // remove object of list of selected objects
111  if (changeFlag) {
112  mySelected = false;
113  }
114  }
115 }
116 
117 
118 bool
120  return mySelected;
121 }
122 
123 
124 bool
127  return true;
128  } else {
129  return false;
130  }
131 }
132 
133 
134 void
136  //
137 }
138 
139 
140 void
142  //
143 }
144 
145 
146 std::string
150  } else {
151  return getTagStr() + ": " + getID();
152  }
153 }
154 
155 
156 std::string
160  } else if (myTagProperty.getTag() == SUMO_TAG_CONNECTION) {
163  return getPopUpID();
164  } else {
165  return getTagStr();
166  }
167 }
168 
169 
170 void
171 GNENetElement::setEnabledAttribute(const int /*enabledAttributes*/) {
172  //
173 }
174 
175 
176 /****************************************************************************/
bool mySelected
boolean to check if this AC is selected (instead of GUIGlObjectStorage)
const TagProperties & myTagProperty
the xml tag to which this attribute carrier corresponds
SumoXMLTag
Numbers representing SUMO-XML - element names.
GNEGeometry::DottedGeometry myDottedGeometry
dotted geometry
void closeBuilding(const Parameterised *p=0)
Closes the building of the table.
void addedLockedObject(const GUIGlObjectType type)
set object selected
GNENet * myNet
the net to inform about updates
GUIGlObjectType
begin/end of the description of a single lane
GNENet * getNet() const
get Net in which this element is placed
bool drawUsingSelectColor() const
check if attribute carrier must be drawn using selecting color.
virtual std::string generateChildID(SumoXMLTag childTag)=0
gererate a new ID for an element child
connectio between two lanes
An special type of Attribute carrier that owns hierarchical elements.
GUIVisualizationSettings & getVisualisationSettings() const
get visualization settings
void select(GUIGlID id, bool update=true)
Adds the object with the given id.
GNEViewParent * getViewParent() const
get the net object
void setEnabledAttribute(const int enabledAttributes)
method for enabling the attribute and nothing else (used in GNEChange_EnableAttribute) ...
void mkItem(const char *name, bool dynamic, ValueSource< T > *src)
Adds a row which obtains its value from a ValueSource.
A NBNetBuilder extended by visualisation and editing capabilities.
Definition: GNENet.h:75
void updateDottedGeometry(const GUIVisualizationSettings &s, const PositionVector &contourShape)
update DottedGeometry (using an existent shape)
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
void updateDottedGeometry(const PositionVector &shape)
updated dotted geometry
Boundary myMovingGeometryBoundary
boundary used during moving of elements
~GNENetElement()
Destructor.
std::string getPopUpID() const
get PopPup ID (Used in AC Hierarchy)
GNENetElement(GNENet *net, const std::string &id, GUIGlObjectType type, SumoXMLTag tag)
Constructor.
LockGLObjectTypes * getLockGLObjectTypes() const
get selected items Modul
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:44
SumoXMLTag getTag() const
get Tag vinculated with this attribute Property
std::string getHierarchyName() const
get Hierarchy Name (Used in AC Hierarchy)
A list of positions.
Supermode currentSupermode
the current supermode
void removeLockedObject(const GUIGlObjectType type)
set object unselected
GNESelectorFrame * getSelectorFrame() const
get frame for GNE_NMODE_SELECT
const std::string getID() const
function to support debugging
void selectAttributeCarrier(bool changeFlag=true)
select attribute carrier using GUIGlobalSelection
begin/end of the description of an edge
void unselectAttributeCarrier(bool changeFlag=true)
unselect attribute carrier using GUIGlobalSelection
void deselect(GUIGlID id)
Deselects the object with the given id.
void disableAttribute(SumoXMLAttr key, GNEUndoList *undoList)
const std::string & getTagStr() const
get tag assigned to this object in string format
crossing between edges for pedestrians
virtual std::string getAttribute(SumoXMLAttr key) const =0
GUIGlID getGlID() const
Returns the numerical id of the object.
GNEHierarchicalChildElements(GNEAttributeCarrier *AC, const std::vector< GNEEdge *> &childEdges, const std::vector< GNELane *> &childLanes, const std::vector< GNEShape *> &childShapes, const std::vector< GNEAdditional *> &childAdditionals, const std::vector< GNEDemandElement *> &childDemandElements)
Parameter Constructor.
void enableAttribute(SumoXMLAttr key, GNEUndoList *undoList)
const GNEViewNetHelper::EditModes & getEditModes() const
get edit modes
Definition: GNEViewNet.cpp:431
Network mode (Edges, junctions, etc..)
GUISelectedStorage gSelected
A global holder of selected objects.
A window containing a gl-object&#39;s parameter.
bool isAttributeCarrierSelected() const
check if attribute carrier is selected
GNEViewNet * getViewNet() const
get view net
Definition: GNENet.cpp:2117