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-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 // Abstract class for Shapes uses in netedit
15 /****************************************************************************/
16 
17 
18 // ===========================================================================
19 // included modules
20 // ===========================================================================
21 #include <config.h>
22 
26 #include <netedit/GNENet.h>
27 #include <netedit/GNEViewNet.h>
28 #include <netedit/GNEViewParent.h>
30 
31 #include "GNEShape.h"
32 
33 
34 // ===========================================================================
35 // method definitions
36 // ===========================================================================
37 
38 GNEShape::GNEShape(GNENet* net, SumoXMLTag tag, bool movementBlocked,
39  const std::vector<GNEEdge*>& parentEdges,
40  const std::vector<GNELane*>& parentLanes,
41  const std::vector<GNEShape*>& parentShapes,
42  const std::vector<GNEAdditional*>& parentAdditionals,
43  const std::vector<GNEDemandElement*>& parentDemandElements,
44  const std::vector<GNEEdge*>& childEdges,
45  const std::vector<GNELane*>& childLanes,
46  const std::vector<GNEShape*>& childShapes,
47  const std::vector<GNEAdditional*>& childAdditionals,
48  const std::vector<GNEDemandElement*>& childDemandElements) :
50  GNEHierarchicalParentElements(this, parentEdges, parentLanes, parentShapes, parentAdditionals, parentDemandElements),
51  GNEHierarchicalChildElements(this, childEdges, childLanes, childShapes, childAdditionals, childDemandElements),
52  myNet(net),
53  myBlockMovement(movementBlocked) {
54 }
55 
56 
58 
59 
60 GNENet*
62  return myNet;
63 }
64 
65 
66 bool
68  return myBlockMovement;
69 }
70 
71 
72 void
73 GNEShape::draw(const Position& pos, double layer, double size) const {
74  if (myNet->getViewNet()->showLockIcon()) {
75  // Start pushing matrix
76  glPushMatrix();
77  // Traslate to middle of shape
78  glTranslated(pos.x(), pos.y(), layer + 0.1);
79  // Rotate 180 degrees
80  glRotated(180, 0, 0, 1);
81  // Set draw color
82  glColor3d(1, 1, 1);
83  // Draw icon depending of the selection status
84  if (mySelected) {
85  if (myBlockMovement) {
86  // Draw lock texture if shape is movable, is blocked and is selected
88  } else {
89  // Draw empty texture if shape is movable, isn't blocked and is selected
91  }
92  } else {
93  if (myBlockMovement) {
94  // Draw lock texture if shape is movable and is blocked
96  } else {
97  // Draw empty texture if shape is movable and isn't blocked
99  }
100  }
101  // Pop matrix
102  glPopMatrix();
103  }
104 }
105 
106 
107 void
109  if (!myNet) {
110  throw ProcessError("Net cannot be nullptr");
111  } else {
113  // add object into list of selected objects
115  if (changeFlag) {
116  mySelected = true;
117  }
118  }
119 }
120 
121 
122 void
124  if (!myNet) {
125  throw ProcessError("Net cannot be nullptr");
126  } else {
128  // remove object of list of selected objects
130  if (changeFlag) {
131  mySelected = false;
132  }
133  }
134 }
135 
136 
137 bool
139  return mySelected;
140 }
141 
142 
143 bool
146  return true;
147  } else {
148  return false;
149  }
150 }
151 
152 
153 void
155  //
156 }
157 
158 
159 void
161  //
162 }
163 
164 
165 std::string
167  return getTagStr() + ": " + getID();
168 }
169 
170 
171 std::string
173  return getTagStr();
174 }
175 
176 
177 void
178 GNEShape::setEnabledAttribute(const int /*enabledAttributes*/) {
179  //
180 }
181 
182 /****************************************************************************/
GNEViewParent::getSelectorFrame
GNESelectorFrame * getSelectorFrame() const
get frame for GNE_NMODE_SELECT
Definition: GNEViewParent.cpp:186
GNEShape::disableAttribute
void disableAttribute(SumoXMLAttr key, GNEUndoList *undoList)
Definition: GNEShape.cpp:160
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
GNEShape::~GNEShape
~GNEShape()
Destructor.
Definition: GNEShape.cpp:57
GNEShape::getGUIGlObject
virtual const GUIGlObject * getGUIGlObject() const =0
get GUIGlObject associated to this GNEShape
GNEShape::selectAttributeCarrier
void selectAttributeCarrier(bool changeFlag=true)
Definition: GNEShape.cpp:108
GNENet
A NBNetBuilder extended by visualisation and editing capabilities.
Definition: GNENet.h:77
GNEShape::getHierarchyName
std::string getHierarchyName() const
get Hierarchy Name (Used in AC Hierarchy)
Definition: GNEShape.cpp:172
GUIGlobalSelection.h
GNEShape::setEnabledAttribute
void setEnabledAttribute(const int enabledAttributes)
method for enabling the attribute and nothing else (used in GNEChange_EnableAttribute)
Definition: GNEShape.cpp:178
GNETEXTURE_LOCKSELECTED
@ GNETEXTURE_LOCKSELECTED
Definition: GUITextures.h:39
GNEShape::isMovementBlocked
bool isMovementBlocked() const
return true if movement is blocked
Definition: GNEShape.cpp:67
SumoXMLTag
SumoXMLTag
Numbers representing SUMO-XML - element names.
Definition: SUMOXMLDefinitions.h:41
GUITexturesHelper::drawTexturedBox
static void drawTexturedBox(int which, double size)
Draws a named texture as a box with the given size.
Definition: GUITexturesHelper.cpp:72
GNEHierarchicalChildElements
An special type of Attribute carrier that owns hierarchical elements.
Definition: GNEHierarchicalChildElements.h:45
GNEShape::GNEShape
GNEShape(GNENet *net, SumoXMLTag tag, bool movementBlocked, const std::vector< GNEEdge * > &parentEdges, const std::vector< GNELane * > &parentLanes, const std::vector< GNEShape * > &parentShapes, const std::vector< GNEAdditional * > &parentAdditionals, const std::vector< GNEDemandElement * > &parentDemandElements, 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)
Constructor.
Definition: GNEShape.cpp:38
GNEShape::getPopUpID
std::string getPopUpID() const
get PopPup ID (Used in AC Hierarchy)
Definition: GNEShape.cpp:166
GUISelectedStorage::select
void select(GUIGlID id, bool update=true)
Adds the object with the given id.
Definition: GUISelectedStorage.cpp:113
GNEShape::myNet
GNENet * myNet
the net to inform about updates
Definition: GNEShape.h:197
GNEViewNet.h
GUITextureSubSys::getTexture
static GUIGlID getTexture(GUITexture which)
returns a texture previously defined in the enum GUITexture
Definition: GUITextureSubSys.cpp:101
GNE_SUPERMODE_NETWORK
@ GNE_SUPERMODE_NETWORK
Network mode (Edges, junctions, etc..)
Definition: GNEViewNetHelper.h:46
ProcessError
Definition: UtilExceptions.h:39
GNEShape::drawUsingSelectColor
bool drawUsingSelectColor() const
check if attribute carrier must be drawn using selecting color.
Definition: GNEShape.cpp:144
GNEViewNetHelper::EditModes::currentSupermode
Supermode currentSupermode
the current supermode
Definition: GNEViewNetHelper.h:305
Position
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:38
Position::x
double x() const
Returns the x-position.
Definition: Position.h:56
GNEShape::getNet
GNENet * getNet() const
get Net in which this element is placed
Definition: GNEShape.cpp:61
GNEShape::myBlockMovement
bool myBlockMovement
flag to block movement
Definition: GNEShape.h:203
GNEShape::getGlID
virtual GUIGlID getGlID() const =0
Returns the numerical id of the object.
GNENet::getViewNet
GNEViewNet * getViewNet() const
get view net
Definition: GNENet.cpp:2117
GNEShape.h
GNEViewNet::showLockIcon
bool showLockIcon() const
check if lock icon should be visible
Definition: GNEViewNet.cpp:1038
GNEViewParent.h
GLIncludes.h
GNETEXTURE_EMPTY
@ GNETEXTURE_EMPTY
Definition: GUITextures.h:36
GNESelectorFrame.h
Position::y
double y() const
Returns the y-position.
Definition: Position.h:61
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
GNEShape::draw
void draw(const Position &pos, double layer, double size=0.5) const
draw lock icon
Definition: GNEShape.cpp:73
config.h
GNEViewNet::getEditModes
const GNEViewNetHelper::EditModes & getEditModes() const
get edit modes
Definition: GNEViewNet.cpp:434
GNEShape::enableAttribute
void enableAttribute(SumoXMLAttr key, GNEUndoList *undoList)
Definition: GNEShape.cpp:154
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
GNETEXTURE_LOCK
@ GNETEXTURE_LOCK
Definition: GUITextures.h:38
SumoXMLAttr
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
Definition: SUMOXMLDefinitions.h:372
GNETEXTURE_EMPTYSELECTED
@ GNETEXTURE_EMPTYSELECTED
Definition: GUITextures.h:37
GUITextureSubSys.h
GNEAttributeCarrier
Definition: GNEAttributeCarrier.h:54
GNEShape::unselectAttributeCarrier
void unselectAttributeCarrier(bool changeFlag=true)
unselect attribute carrier using GUIGlobalSelection
Definition: GNEShape.cpp:123
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
GNEShape::isAttributeCarrierSelected
bool isAttributeCarrierSelected() const
check if attribute carrier is selected
Definition: GNEShape.cpp:138
GNESelectorFrame::getLockGLObjectTypes
LockGLObjectTypes * getLockGLObjectTypes() const
get selected items Modul
Definition: GNESelectorFrame.cpp:459
GNESelectorFrame::LockGLObjectTypes::addedLockedObject
void addedLockedObject(const GUIGlObjectType type)
set object selected
Definition: GNESelectorFrame.cpp:567