SUMO - Simulation of Urban MObility
GNEShape.cpp
Go to the documentation of this file.
1 /****************************************************************************/
7 // Abstract class for Shapes uses in netedit
8 /****************************************************************************/
9 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
10 // Copyright (C) 2001-2017 DLR (http://www.dlr.de/) and contributors
11 /****************************************************************************/
12 //
13 // This file is part of SUMO.
14 // SUMO is free software: you can redistribute it and/or modify
15 // it under the terms of the GNU General Public License as published by
16 // the Free Software Foundation, either version 3 of the License, or
17 // (at your option) any later version.
18 //
19 /****************************************************************************/
20 
21 
22 // ===========================================================================
23 // included modules
24 // ===========================================================================
25 #ifdef _MSC_VER
26 #include <windows_config.h>
27 #else
28 #include <config.h>
29 #endif
30 
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  myShapeVisible(false) {
50 }
51 
52 
54 
55 
56 GNENet*
58  return myNet;
59 }
60 
61 
62 bool
64  return myBlockMovement;
65 }
66 
67 
68 bool
70  return myBlockShape;
71 }
72 
73 
74 bool
76  return myShapeVisible;
77 }
78 
79 
80 void
82  myShapeVisible = visible;
83 }
84 
85 
86 void
87 GNEShape::drawLockIcon(const Position& pos, double layer, double size) const {
88  if (myNet->getViewNet()->showLockIcon()) {
89  // Start pushing matrix
90  glPushMatrix();
91  // Traslate to middle of shape
92  glTranslated(pos.x(), pos.y(), layer + 0.1);
93  // Rotate 180 degrees
94  glRotated(180, 0, 0, 1);
95  // Set draw color
96  glColor3d(1, 1, 1);
97  // Draw icon depending of the state of additional
98  if (myNet->isShapeSelected(getTag(), getID())) {
99  if (myBlockMovement) {
100  // Draw lock texture if additional is movable, is blocked and is selected
102  } else {
103  // Draw empty texture if additional is movable, isn't blocked and is selected
105  }
106  } else {
107  if (myBlockMovement) {
108  // Draw lock texture if additional is movable and is blocked
110  } else {
111  // Draw empty texture if additional is movable and isn't blocked
113  }
114  }
115  // Pop matrix
116  glPopMatrix();
117  }
118 }
119 
120 /****************************************************************************/
static void drawTexturedBox(int which, double size)
Draws a named texture as a box with the given size.
bool showLockIcon() const
check if lock icon should be visible
SumoXMLTag
Numbers representing SUMO-XML - element names.
GUIIcon
An enumeration of icons used by the gui applications.
Definition: GUIIcons.h:43
static GUIGlID getTexture(GUITexture which)
returns a texture previously defined in the enum GUITexture
double x() const
Returns the x-position.
Definition: Position.h:63
GNEShape(GNENet *net, SumoXMLTag tag, GUIIcon icon, bool movementBlocked, bool shapeBlocked)
Constructor.
Definition: GNEShape.cpp:44
A NBNetBuilder extended by visualisation and editing capabilities.
Definition: GNENet.h:92
bool isMovementBlocked() const
return true if movement is blocked
Definition: GNEShape.cpp:63
GNENet * myNet
the net to inform about updates
Definition: GNEShape.h:156
void drawLockIcon(const Position &pos, double layer, double size=0.5) const
draw lock icon
Definition: GNEShape.cpp:87
bool myBlockShape
flag for block shape
Definition: GNEShape.h:162
bool myBlockMovement
flag to block movement
Definition: GNEShape.h:159
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:46
void setShapeVisible(bool visible)
set flag to enable or disable if shape is visible
Definition: GNEShape.cpp:81
bool isShapeSelected(SumoXMLTag tag, const std::string &ID) const
Check if shape item is selected.
Definition: GNENet.cpp:2077
double y() const
Returns the y-position.
Definition: Position.h:68
GNENet * getNet() const
get Net in which this element is placed
Definition: GNEShape.cpp:57
const std::string getID() const
function to support debugging
bool myShapeVisible
flag for visible shape
Definition: GNEShape.h:165
bool isShapeBlocked() const
return true if shape is blocked
Definition: GNEShape.cpp:69
SumoXMLTag getTag() const
get XML Tag assigned to this object
bool isShapeVisible() const
check if shape is visible (Was added into view using insertPolygon/POIInView)
Definition: GNEShape.cpp:75
GNEViewNet * getViewNet() const
get view net
Definition: GNENet.cpp:1519
~GNEShape()
Destructor.
Definition: GNEShape.cpp:53