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-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
14 // A abstract class for netElements
15 /****************************************************************************/
16 
17 
18 // ===========================================================================
19 // included modules
20 // ===========================================================================
21 #include <config.h>
22 
23 #include <netedit/GNENet.h>
24 #include <netedit/GNEViewNet.h>
25 #include <netedit/GNEViewParent.h>
29 #include <utils/geom/GeomHelper.h>
30 
31 #include "GNENetElement.h"
32 
33 
34 // ===========================================================================
35 // method definitions
36 // ===========================================================================
37 
38 GNENetElement::GNENetElement(GNENet* net, const std::string& id, GUIGlObjectType type, SumoXMLTag tag) :
39  GUIGlObject(type, id),
41  GNEHierarchicalParentElements(this, {}, {}, {}, {}, {}),
42  GNEHierarchicalChildElements(this, {}, {}, {}, {}, {}),
43  myNet(net),
44 myMovingGeometryBoundary() {
45 }
46 
47 
49 
50 
51 std::string
53  return "";
54 }
55 
56 
57 GNENet*
59  return myNet;
60 }
61 
62 
65  // Create table
67  // Iterate over attributes
68  for (const auto& i : myTagProperty) {
69  // Add attribute and set it dynamic if aren't unique
70  if (i.isUnique()) {
71  ret->mkItem(i.getAttrStr().c_str(), false, getAttribute(i.getAttr()));
72  } else {
73  ret->mkItem(i.getAttrStr().c_str(), true, getAttribute(i.getAttr()));
74  }
75  }
76  // close building
77  ret->closeBuilding();
78  return ret;
79 }
80 
81 
82 void
84  if (!myNet) {
85  throw ProcessError("Net cannot be nullptr");
86  } else {
88  // add object into list of selected objects
90  if (changeFlag) {
91  mySelected = true;
92 
93  }
94  }
95 }
96 
97 
98 void
100  if (!myNet) {
101  throw ProcessError("Net cannot be nullptr");
102  } else {
104  // remove object of list of selected objects
106  if (changeFlag) {
107  mySelected = false;
108  }
109  }
110 }
111 
112 
113 bool
115  return mySelected;
116 }
117 
118 
119 bool
122  return true;
123  } else {
124  return false;
125  }
126 }
127 
128 
129 void
131  //
132 }
133 
134 
135 void
137  //
138 }
139 
140 
141 std::string
145  } else {
146  return getTagStr() + ": " + getID();
147  }
148 }
149 
150 
151 std::string
155  } else if (myTagProperty.getTag() == SUMO_TAG_CONNECTION) {
158  return getPopUpID();
159  } else {
160  return getTagStr();
161  }
162 }
163 
164 
165 void
166 GNENetElement::setEnabledAttribute(const int /*enabledAttributes*/) {
167  //
168 }
169 
170 /****************************************************************************/
GUIGlObject::getType
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
Definition: GUIGlObject.cpp:180
GNEViewParent::getSelectorFrame
GNESelectorFrame * getSelectorFrame() const
get frame for GNE_NMODE_SELECT
Definition: GNEViewParent.cpp:186
GNENetElement::unselectAttributeCarrier
void unselectAttributeCarrier(bool changeFlag=true)
unselect attribute carrier using GUIGlobalSelection
Definition: GNENetElement.cpp:99
GUIParameterTableWindow
A window containing a gl-object's parameter.
Definition: GUIParameterTableWindow.h:62
GNEAttributeCarrier::mySelected
bool mySelected
boolean to check if this AC is selected (instead of GUIGlObjectStorage)
Definition: GNEAttributeCarrier.h:788
GNEAttributeCarrier::getID
const std::string getID() const
function to support debugging
Definition: GNEAttributeCarrier.cpp:1289
GUISUMOAbstractView
Definition: GUISUMOAbstractView.h:72
GUIParameterTableWindow.h
GNENet
A NBNetBuilder extended by visualisation and editing capabilities.
Definition: GNENet.h:77
SUMO_ATTR_TO_LANE
Definition: SUMOXMLDefinitions.h:720
GUIGlobalSelection.h
SUMO_TAG_LANE
begin/end of the description of a single lane
Definition: SUMOXMLDefinitions.h:49
GNENetElement::~GNENetElement
~GNENetElement()
Destructor.
Definition: GNENetElement.cpp:48
GNENetElement::enableAttribute
void enableAttribute(SumoXMLAttr key, GNEUndoList *undoList)
Definition: GNENetElement.cpp:130
GNENetElement::drawUsingSelectColor
bool drawUsingSelectColor() const
check if attribute carrier must be drawn using selecting color.
Definition: GNENetElement.cpp:120
GNENetElement::setEnabledAttribute
void setEnabledAttribute(const int enabledAttributes)
method for enabling the attribute and nothing else (used in GNEChange_EnableAttribute)
Definition: GNENetElement.cpp:166
SumoXMLTag
SumoXMLTag
Numbers representing SUMO-XML - element names.
Definition: SUMOXMLDefinitions.h:41
GUIParameterTableWindow::closeBuilding
void closeBuilding(const Parameterised *p=0)
Closes the building of the table.
Definition: GUIParameterTableWindow.cpp:219
GNEAttributeCarrier::TagProperties::getTag
SumoXMLTag getTag() const
get Tag vinculated with this attribute Property
Definition: GNEAttributeCarrier.cpp:523
GNEHierarchicalChildElements
An special type of Attribute carrier that owns hierarchical elements.
Definition: GNEHierarchicalChildElements.h:45
SUMO_ATTR_TO
Definition: SUMOXMLDefinitions.h:640
GUIGlObjectType
GUIGlObjectType
Definition: GUIGlObjectTypes.h:39
GNENetElement::getHierarchyName
std::string getHierarchyName() const
get Hierarchy Name (Used in AC Hierarchy)
Definition: GNENetElement.cpp:152
GUISelectedStorage::select
void select(GUIGlID id, bool update=true)
Adds the object with the given id.
Definition: GUISelectedStorage.cpp:113
GUIParameterTableWindow::mkItem
void mkItem(const char *name, bool dynamic, ValueSource< T > *src)
Adds a row which obtains its value from a ValueSource.
Definition: GUIParameterTableWindow.h:108
GNEViewNet.h
GNENetElement.h
GUIGlObject::getGlID
GUIGlID getGlID() const
Returns the numerical id of the object.
Definition: GUIGlObject.cpp:149
GNENetElement::getAttribute
virtual std::string getAttribute(SumoXMLAttr key) const =0
SUMO_TAG_EDGE
begin/end of the description of an edge
Definition: SUMOXMLDefinitions.h:47
GNE_SUPERMODE_NETWORK
Network mode (Edges, junctions, etc..)
Definition: GNEViewNetHelper.h:46
ProcessError
Definition: UtilExceptions.h:39
GNEViewNetHelper::EditModes::currentSupermode
Supermode currentSupermode
the current supermode
Definition: GNEViewNetHelper.h:305
GNEAttributeCarrier::myTagProperty
const TagProperties & myTagProperty
the xml tag to which this attribute carrier corresponds
Definition: GNEAttributeCarrier.h:785
GNENetElement::generateChildID
virtual std::string generateChildID(SumoXMLTag childTag)=0
gererate a new ID for an element child
Definition: GNENetElement.cpp:52
GNENetElement::isAttributeCarrierSelected
bool isAttributeCarrierSelected() const
check if attribute carrier is selected
Definition: GNENetElement.cpp:114
GUIGlObject
Definition: GUIGlObject.h:65
GNENetElement::getParameterWindow
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
Definition: GNENetElement.cpp:64
GNENet::getViewNet
GNEViewNet * getViewNet() const
get view net
Definition: GNENet.cpp:2117
SUMO_ATTR_FROM_LANE
Definition: SUMOXMLDefinitions.h:719
SUMO_ATTR_INDEX
Definition: SUMOXMLDefinitions.h:804
SUMO_ATTR_FROM
Definition: SUMOXMLDefinitions.h:639
GNEViewParent.h
toString
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:47
GNESelectorFrame.h
GUIMainWindow
Definition: GUIMainWindow.h:46
SUMO_TAG_CROSSING
crossing between edges for pedestrians
Definition: SUMOXMLDefinitions.h:226
GNENetElement::getNet
GNENet * getNet() const
get Net in which this element is placed
Definition: GNENetElement.cpp:58
GNENetElement::GNENetElement
GNENetElement(GNENet *net, const std::string &id, GUIGlObjectType type, SumoXMLTag tag)
Constructor.
Definition: GNENetElement.cpp:38
SUMO_TAG_CONNECTION
connectio between two lanes
Definition: SUMOXMLDefinitions.h:202
gSelected
GUISelectedStorage gSelected
A global holder of selected objects.
Definition: GUIGlobalSelection.cpp:33
GNEHierarchicalParentElements
An special type of Attribute carrier that owns hierarchical elements.
Definition: GNEHierarchicalParentElements.h:49
GNENetElement::disableAttribute
void disableAttribute(SumoXMLAttr key, GNEUndoList *undoList)
Definition: GNENetElement.cpp:136
GNENetElement::myNet
GNENet * myNet
the net to inform about updates
Definition: GNENetElement.h:166
config.h
GeomHelper.h
GNEViewNet::getEditModes
const GNEViewNetHelper::EditModes & getEditModes() const
get edit modes
Definition: GNEViewNet.cpp:434
GNENetElement::selectAttributeCarrier
void selectAttributeCarrier(bool changeFlag=true)
select attribute carrier using GUIGlobalSelection
Definition: GNENetElement.cpp:83
GNESelectorFrame::LockGLObjectTypes::removeLockedObject
void removeLockedObject(const GUIGlObjectType type)
set object unselected
Definition: GNESelectorFrame.cpp:573
GNEAttributeCarrier::getTagStr
const std::string & getTagStr() const
get tag assigned to this object in string format
Definition: GNEAttributeCarrier.cpp:1267
GNEUndoList
Definition: GNEUndoList.h:48
GNENetElement::getPopUpID
std::string getPopUpID() const
get PopPup ID (Used in AC Hierarchy)
Definition: GNENetElement.cpp:142
SumoXMLAttr
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
Definition: SUMOXMLDefinitions.h:372
GNEAttributeCarrier
Definition: GNEAttributeCarrier.h:54
GNENet.h
GUISelectedStorage::deselect
void deselect(GUIGlID id)
Deselects the object with the given id.
Definition: GUISelectedStorage.cpp:130
GNEViewNet::getViewParent
GNEViewParent * getViewParent() const
get the net object
Definition: GNEViewNet.cpp:1008
GNESelectorFrame::getLockGLObjectTypes
LockGLObjectTypes * getLockGLObjectTypes() const
get selected items Modul
Definition: GNESelectorFrame.cpp:459
GNEAttributeCarrier::TagProperties::getNumberOfAttributes
int getNumberOfAttributes() const
get number of attributes
Definition: GNEAttributeCarrier.cpp:648
GNESelectorFrame::LockGLObjectTypes::addedLockedObject
void addedLockedObject(const GUIGlObjectType type)
set object selected
Definition: GNESelectorFrame.cpp:567