Eclipse SUMO - Simulation of Urban MObility
GNENetworkElement.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3 // Copyright (C) 2001-2024 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 networkElements
19 /****************************************************************************/
20 #include <config.h>
21 
25 #include <netedit/GNENet.h>
26 #include <netedit/GNEViewNet.h>
27 #include <netedit/GNEViewParent.h>
28 
29 #include "GNENetworkElement.h"
30 
31 
32 // ===========================================================================
33 // method definitions
34 // ===========================================================================
35 
36 GNENetworkElement::GNENetworkElement(GNENet* net, const std::string& id, GUIGlObjectType type, SumoXMLTag tag, FXIcon* icon,
37  const std::vector<GNEJunction*>& junctionParents,
38  const std::vector<GNEEdge*>& edgeParents,
39  const std::vector<GNELane*>& laneParents,
40  const std::vector<GNEAdditional*>& additionalParents,
41  const std::vector<GNEDemandElement*>& demandElementParents,
42  const std::vector<GNEGenericData*>& genericDataParents) :
43  GUIGlObject(type, id, icon),
44  GNEHierarchicalElement(net, tag, junctionParents, edgeParents, laneParents, additionalParents, demandElementParents, genericDataParents),
45  myShapeEdited(false) {
46 }
47 
48 
50 
51 
54  return this;
55 }
56 
57 
58 const GUIGlObject*
60  return this;
61 }
62 
63 
64 void
66  myShapeEdited = value;
67 }
68 
69 
70 bool
72  return myShapeEdited;
73 }
74 
75 
76 bool
77 GNENetworkElement::GNENetworkElement::isNetworkElementValid() const {
78  // implement in children
79  return true;
80 }
81 
82 
83 std::string
84 GNENetworkElement::GNENetworkElement::getNetworkElementProblem() const {
85  // implement in children
86  return "";
87 }
88 
89 
92  // Create table
93  GUIParameterTableWindow* ret = new GUIParameterTableWindow(app, *this);
94  // Iterate over attributes
95  for (const auto& i : myTagProperty) {
96  // Add attribute and set it dynamic if aren't unique
97  if (i.isUnique()) {
98  ret->mkItem(i.getAttrStr().c_str(), false, getAttribute(i.getAttr()));
99  } else {
100  ret->mkItem(i.getAttrStr().c_str(), true, getAttribute(i.getAttr()));
101  }
102  }
103  // close building
104  ret->closeBuilding();
105  return ret;
106 }
107 
108 
109 bool
113  } else {
114  return true;
115  }
116 }
117 
118 
119 void
122 }
123 
124 
125 void
129  } else {
131  }
132  // update information label
134 }
135 
136 
137 const std::string
139  try {
141  } catch (InvalidArgument&) {
142  return "";
143  }
144 }
145 
146 
147 std::string
151  } else {
152  return getTagStr() + ": " + getID();
153  }
154 }
155 
156 
157 std::string
161  } else if (myTagProperty.getTag() == SUMO_TAG_CONNECTION) {
164  return getPopUpID();
165  } else {
166  return getTagStr();
167  }
168 }
169 
170 
171 void
172 GNENetworkElement::setNetworkElementID(const std::string& newID) {
173  // set microsim ID
174  setMicrosimID(newID);
175  // enable save add elements if this network element has children
176  if (getChildAdditionals().size() > 0) {
178  }
179  // enable save demand elements if this network element has children
180  if (getChildDemandElements().size() > 0) {
182  }
183  // enable save data elements if this network element has children
184  if (getChildGenericDatas().size() > 0) {
186  }
187 }
188 
189 
190 bool
193  return true;
194  } else if (!gViewObjectsHandler.isElementSelected(this)) {
195  return true;
196  } else {
197  return false;
198  }
199 }
200 
201 /****************************************************************************/
GUIGlObjectType
GUIViewObjectsHandler gViewObjectsHandler
SumoXMLTag
Numbers representing SUMO-XML - element names.
@ SUMO_TAG_CONNECTION
connectioon between two lanes
@ SUMO_TAG_CROSSING
crossing between edges for pedestrians
@ SUMO_TAG_LANE
begin/end of the description of a single lane
@ SUMO_TAG_EDGE
begin/end of the description of an edge
@ SUMO_ATTR_FROM_LANE
@ SUMO_ATTR_INDEX
@ SUMO_ATTR_NAME
@ SUMO_ATTR_TO
@ SUMO_ATTR_FROM
@ SUMO_ATTR_TO_LANE
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:46
bool isInitialised() const
check if Boundary is Initialised
Definition: Boundary.cpp:235
const std::string getID() const
get ID (all Attribute Carriers have one)
bool isAttributeCarrierSelected() const
check if attribute carrier is selected
const std::string & getTagStr() const
get tag assigned to this object in string format
void unselectAttributeCarrier(const bool changeFlag=true)
unselect attribute carrier using GUIGlobalSelection
GNENet * myNet
pointer to net
void selectAttributeCarrier(const bool changeFlag=true)
select attribute carrier using GUIGlobalSelection
const GNETagProperties & myTagProperty
reference to tagProperty associated with this attribute carrier
const std::vector< GNEDemandElement * > & getChildDemandElements() const
return child demand elements
const std::vector< GNEAdditional * > & getChildAdditionals() const
return child additionals
const std::vector< GNEGenericData * > & getChildGenericDatas() const
return child generic data elements
void requireSaveAdditionals()
inform that additionals has to be saved
void requireSaveDataElements()
inform that data elements has to be saved
void requireSaveDemandElements()
inform that demand elements has to be saved
A NBNetBuilder extended by visualisation and editing capabilities.
Definition: GNENet.h:42
GNENetHelper::SavingStatus * getSavingStatus() const
get saving status
Definition: GNENet.cpp:127
GNEViewNet * getViewNet() const
get view net
Definition: GNENet.cpp:2056
bool checkDrawingBoundarySelection() const
std::string getPopUpID() const
get PopPup ID (Used in AC Hierarchy)
virtual std::string getAttribute(SumoXMLAttr key) const =0
void selectGLObject()
select element
void setShapeEdited(const bool value)
set shape edited
void markAsFrontElement()
mark element as front element
bool myShapeEdited
flag to check if element shape is being edited
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
virtual const std::string getOptionalName() const
Returns the name of the object (default "")
GNENetworkElement(GNENet *net, const std::string &id, GUIGlObjectType type, SumoXMLTag tag, FXIcon *icon, const std::vector< GNEJunction * > &junctionParents, const std::vector< GNEEdge * > &edgeParents, const std::vector< GNELane * > &laneParents, const std::vector< GNEAdditional * > &additionalParents, const std::vector< GNEDemandElement * > &demandElementParents, const std::vector< GNEGenericData * > &genericDataParents)
Constructor.
void setNetworkElementID(const std::string &newID)
set network element id
bool isShapeEdited() const
check if shape is being edited
std::string getHierarchyName() const
get Hierarchy Name (Used in AC Hierarchy)
virtual ~GNENetworkElement()
Destructor.
GUIGlObject * getGUIGlObject()
get GUIGlObject associated with this AttributeCarrier
bool isGLObjectLocked() const
check if element is locked
void updateInformationLabel()
update information label
SelectionInformation * getSelectionInformation() const
get modul for selection information
SumoXMLTag getTag() const
get Tag vinculated with this attribute Property
bool isObjectLocked(GUIGlObjectType objectType, const bool selected) const
check if given GLObject is locked for inspect, select, delete and move
const GNEViewNetHelper::EditModes & getEditModes() const
get edit modes
Definition: GNEViewNet.cpp:703
void setFrontAttributeCarrier(GNEAttributeCarrier *AC)
set front attributeCarrier
GNEViewParent * getViewParent() const
get the net object
GNEViewNetHelper::LockManager & getLockManager()
get lock manager
GNESelectorFrame * getSelectorFrame() const
get frame for select elements
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.
Definition: GUIGlObject.h:156
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.
bool isElementSelected(const GUIGlObject *GLObject) const
check if element was already selected
const Boundary & getSelectionBoundary() const
get selection boundary (usually the mouse position)
bool isCurrentSupermodeNetwork() const
@check if current supermode is Network