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-2020 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 // Abstract class for Shapes uses in netedit
19 /****************************************************************************/
20 #include <config.h>
21 
23 #include <netedit/GNENet.h>
24 #include <netedit/GNEViewNet.h>
26 
27 #include "GNEShape.h"
28 
29 
30 // ===========================================================================
31 // method definitions
32 // ===========================================================================
33 
34 GNEShape::GNEShape(const std::string& id, GNENet* net, GUIGlObjectType type, SumoXMLTag tag, bool movementBlocked,
35  const std::vector<GNEJunction*>& junctionParents,
36  const std::vector<GNEEdge*>& edgeParents,
37  const std::vector<GNELane*>& laneParents,
38  const std::vector<GNEAdditional*>& additionalParents,
39  const std::vector<GNEShape*>& shapeParents,
40  const std::vector<GNETAZElement*>& TAZElementParents,
41  const std::vector<GNEDemandElement*>& demandElementParents,
42  const std::vector<GNEGenericData*>& genericDataParents) :
43  GUIGlObject(type, id),
44  GNEHierarchicalElement(net, tag, junctionParents, edgeParents, laneParents, additionalParents, shapeParents, TAZElementParents, demandElementParents, genericDataParents),
45  myBlockMovement(movementBlocked) {
46 }
47 
48 
50 
51 
52 const std::string&
53 GNEShape::getID() const {
54  return getMicrosimID();
55 }
56 
57 
60  return this;
61 }
62 
63 
64 bool
66  return myBlockMovement;
67 }
68 
69 
70 void
71 GNEShape::draw(const Position& pos, double layer, double size) const {
72  if (myNet->getViewNet()->showLockIcon()) {
73  // Start pushing matrix
74  glPushMatrix();
75  // Traslate to middle of shape
76  glTranslated(pos.x(), pos.y(), layer + 0.1);
77  // Rotate 180 degrees
78  glRotated(180, 0, 0, 1);
79  // Set draw color
80  glColor3d(1, 1, 1);
81  // Draw icon depending of the selection status
82  if (mySelected) {
83  if (myBlockMovement) {
84  // Draw lock texture if shape is movable, is blocked and is selected
86  } else {
87  // Draw empty texture if shape is movable, isn't blocked and is selected
89  }
90  } else {
91  if (myBlockMovement) {
92  // Draw lock texture if shape is movable and is blocked
94  } else {
95  // Draw empty texture if shape is movable and isn't blocked
97  }
98  }
99  // Pop matrix
100  glPopMatrix();
101  }
102 }
103 
104 
105 Position
107  return myBoundary.getCenter();
108 }
109 
110 
111 Boundary
113  return myBoundary;
114 }
115 
116 
117 void
119  //
120 }
121 
122 
123 void
125  //
126 }
127 
128 
129 std::string
131  return getTagStr() + ": " + getID();
132 }
133 
134 
135 std::string
137  return getTagStr();
138 }
139 
140 
141 void
142 GNEShape::replaceShapeParentLanes(const std::string& value) {
143  replaceParentElements(this, parse<std::vector<GNELane*> >(getNet(), value));
144 }
145 
146 
147 void
148 GNEShape::setEnabledAttribute(const int /*enabledAttributes*/) {
149  //
150 }
151 
152 
153 /****************************************************************************/
GUIGlObjectType
@ GNETEXTURE_EMPTYSELECTED
Definition: GUITextures.h:35
@ GNETEXTURE_LOCKSELECTED
Definition: GUITextures.h:37
@ GNETEXTURE_EMPTY
Definition: GUITextures.h:34
@ GNETEXTURE_LOCK
Definition: GUITextures.h:36
SumoXMLTag
Numbers representing SUMO-XML - element names.
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:39
Position getCenter() const
Returns the center of the boundary.
Definition: Boundary.cpp:111
bool mySelected
boolean to check if this AC is selected (instead of GUIGlObjectStorage)
static T parse(const std::string &string)
parses a value of type T from string (used for basic types: int, double, bool, etc....
const std::string & getTagStr() const
get tag assigned to this object in string format
GNENet * myNet
pointer to net
GNENet * getNet() const
get pointer to net
void replaceParentElements(T *elementChild, const U &newParents)
replace parent elements
A NBNetBuilder extended by visualisation and editing capabilities.
Definition: GNENet.h:40
GNEViewNet * getViewNet() const
get view net
Definition: GNENet.cpp:2245
std::string getHierarchyName() const
get Hierarchy Name (Used in AC Hierarchy)
Definition: GNEShape.cpp:136
void disableAttribute(SumoXMLAttr key, GNEUndoList *undoList)
Definition: GNEShape.cpp:124
void enableAttribute(SumoXMLAttr key, GNEUndoList *undoList)
Definition: GNEShape.cpp:118
Boundary myBoundary
object boundary
Definition: GNEShape.h:204
std::string getPopUpID() const
get PopPup ID (Used in AC Hierarchy)
Definition: GNEShape.cpp:130
Position getPositionInView() const
Returns position of additional in view.
Definition: GNEShape.cpp:106
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GNEShape.cpp:112
GNEShape(const std::string &id, GNENet *net, GUIGlObjectType type, SumoXMLTag tag, bool movementBlocked, const std::vector< GNEJunction * > &junctionParents, const std::vector< GNEEdge * > &edgeParents, const std::vector< GNELane * > &laneParents, const std::vector< GNEAdditional * > &additionalParents, const std::vector< GNEShape * > &shapeParents, const std::vector< GNETAZElement * > &TAZElementParents, const std::vector< GNEDemandElement * > &demandElementParents, const std::vector< GNEGenericData * > &genericDataParents)
Constructor.
Definition: GNEShape.cpp:34
void setEnabledAttribute(const int enabledAttributes)
method for enabling the attribute and nothing else (used in GNEChange_EnableAttribute)
Definition: GNEShape.cpp:148
bool isMovementBlocked() const
return true if movement is blocked
Definition: GNEShape.cpp:65
GUIGlObject * getGUIGlObject()
get GUIGlObject associated with this AttributeCarrier
Definition: GNEShape.cpp:59
const std::string & getID() const
get ID (all shapes have one)
Definition: GNEShape.cpp:53
void draw(const Position &pos, double layer, double size=0.5) const
draw lock icon
Definition: GNEShape.cpp:71
virtual ~GNEShape()
Destructor.
Definition: GNEShape.cpp:49
bool myBlockMovement
flag to block movement
Definition: GNEShape.h:207
void replaceShapeParentLanes(const std::string &value)
replace shape parent lanes
Definition: GNEShape.cpp:142
bool showLockIcon() const
check if lock icon should be visible
virtual const std::string & getMicrosimID() const
Returns the id of the object as known to microsim.
static GUIGlID getTexture(GUITexture which)
returns a texture previously defined in the enum GUITexture
static void drawTexturedBox(int which, double size)
Draws a named texture as a box with the given size.
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:36
double x() const
Returns the x-position.
Definition: Position.h:54
double y() const
Returns the y-position.
Definition: Position.h:59