Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
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-2023 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>
28
29#include "GNENetworkElement.h"
30
31
32// ===========================================================================
33// method definitions
34// ===========================================================================
35
36GNENetworkElement::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
58void
60 myShapeEdited = value;
61}
62
63
64bool
68
69
70bool
71GNENetworkElement::GNENetworkElement::isNetworkElementValid() const {
72 // implement in children
73 return true;
74}
75
76
77std::string
78GNENetworkElement::GNENetworkElement::getNetworkElementProblem() const {
79 // implement in children
80 return "";
81}
82
83
86 // Create table
88 // Iterate over attributes
89 for (const auto& i : myTagProperty) {
90 // Add attribute and set it dynamic if aren't unique
91 if (i.isUnique()) {
92 ret->mkItem(i.getAttrStr().c_str(), false, getAttribute(i.getAttr()));
93 } else {
94 ret->mkItem(i.getAttrStr().c_str(), true, getAttribute(i.getAttr()));
95 }
96 }
97 // close building
98 ret->closeBuilding();
99 return ret;
100}
101
102
107
108
109bool
117
118
119void
123
124
125void
135
136
137const std::string
139 try {
141 } catch (InvalidArgument&) {
142 return "";
143 }
144}
145
146
147std::string
151 } else {
152 return getTagStr() + ": " + getID();
153 }
154}
155
156
157std::string
161 } else if (myTagProperty.getTag() == SUMO_TAG_CONNECTION) {
164 return getPopUpID();
165 } else {
166 return getTagStr();
167 }
168}
169
170/****************************************************************************/
GUIGlObjectType
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
A class that stores a 2D geometrical boundary.
Definition Boundary.h:39
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
A NBNetBuilder extended by visualisation and editing capabilities.
Definition GNENet.h:42
GNEViewNet * getViewNet() const
get view net
Definition GNENet.cpp:2030
std::string getPopUpID() const
get PopPup ID (Used in AC Hierarchy)
virtual std::string getAttribute(SumoXMLAttr key) const =0
bool isGLObjectLocked()
check if element is locked
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.
bool isShapeEdited() const
check if shape is being edited
std::string getHierarchyName() const
get Hierarchy Name (Used in AC Hierarchy)
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
virtual ~GNENetworkElement()
Destructor.
GUIGlObject * getGUIGlObject()
get GUIGlObject associated with this AttributeCarrier
Boundary myBoundary
object boundary
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
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
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
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 isCurrentSupermodeNetwork() const
@check if current supermode is Network