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