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-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
17 // Abstract class for Shapes uses in netedit
18 /****************************************************************************/
19 
20 
21 // ===========================================================================
22 // included modules
23 // ===========================================================================
24 #ifdef _MSC_VER
25 #include <windows_config.h>
26 #else
27 #include <config.h>
28 #endif
29 
34 
35 #include "GNEShape.h"
36 #include "GNENet.h"
37 #include "GNEViewNet.h"
38 
39 
40 // ===========================================================================
41 // method definitions
42 // ===========================================================================
43 
44 GNEShape::GNEShape(GNENet* net, SumoXMLTag tag, GUIIcon icon, bool movementBlocked, bool shapeBlocked) :
45  GNEAttributeCarrier(tag, icon),
46  myNet(net),
47  myBlockMovement(movementBlocked),
48  myBlockShape(shapeBlocked) {
49 }
50 
51 
53 
54 
55 GNENet*
57  return myNet;
58 }
59 
60 
61 bool
63  return myBlockMovement;
64 }
65 
66 
67 bool
69  return myBlockShape;
70 }
71 
72 
73 void
74 GNEShape::drawLockIcon(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 (gSelected.isSelected(getGUIGLObject()->getType(), getGlID())) {
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 /****************************************************************************/
static void drawTexturedBox(int which, double size)
Draws a named texture as a box with the given size.
SumoXMLTag
Numbers representing SUMO-XML - element names.
GUIIcon
An enumeration of icons used by the gui applications.
Definition: GUIIcons.h:42
static GUIGlID getTexture(GUITexture which)
returns a texture previously defined in the enum GUITexture
GNEShape(GNENet *net, SumoXMLTag tag, GUIIcon icon, bool movementBlocked, bool shapeBlocked)
Constructor.
Definition: GNEShape.cpp:44
double y() const
Returns the y-position.
Definition: Position.h:67
double x() const
Returns the x-position.
Definition: Position.h:62
bool isSelected(GUIGlObjectType type, GUIGlID id)
Returns the information whether the object with the given type and id is selected.
A NBNetBuilder extended by visualisation and editing capabilities.
Definition: GNENet.h:91
GNENet * myNet
the net to inform about updates
Definition: GNEShape.h:157
void drawLockIcon(const Position &pos, double layer, double size=0.5) const
draw lock icon
Definition: GNEShape.cpp:74
bool showLockIcon() const
check if lock icon should be visible
bool myBlockShape
flag for block shape
Definition: GNEShape.h:163
bool myBlockMovement
flag to block movement
Definition: GNEShape.h:160
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:45
bool isMovementBlocked() const
return true if movement is blocked
Definition: GNEShape.cpp:62
GNENet * getNet() const
get Net in which this element is placed
Definition: GNEShape.cpp:56
virtual GUIGlID getGlID() const =0
Returns the numerical id of the object.
bool isShapeBlocked() const
return true if shape is blocked
Definition: GNEShape.cpp:68
GUISelectedStorage gSelected
A global holder of selected objects.
~GNEShape()
Destructor.
Definition: GNEShape.cpp:52
GNEViewNet * getViewNet() const
get view net
Definition: GNENet.cpp:1607
const GUIGlObject * getGUIGLObject() const
get const pointer to GUIGlObject vinculated with this Attribute Carrier