Eclipse SUMO - Simulation of Urban MObility
GUIViewObjectsHandler.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3 // Copyright (C) 2001-2024 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 // class used for handle objects over view
19 /****************************************************************************/
20 #pragma once
21 #include <config.h>
22 
23 #include <vector>
26 
27 // ===========================================================================
28 // class declaration
29 // ===========================================================================
30 
31 class GNEEdge;
32 class GNELane;
33 class GNERoute;
34 
35 // ===========================================================================
36 // class definitions
37 // ===========================================================================
38 
40 
41 public:
43  struct ObjectContainer {
44 
46  ObjectContainer(const GUIGlObject* object_) :
47  object(object_) {}
48 
50  const GUIGlObject* object = nullptr;
51 
53  std::vector<int> geometryPoints;
54 
57 
59  double offset = 0;
60  };
61 
63  typedef std::map<double, std::vector<ObjectContainer> > GLObjectsSortedContainer;
64 
67 
69  void clearSelectedElements();
70 
72  const Position& getSelectionPosition() const;
73 
75  const Boundary& getSelectionBoundary() const;
76 
78  void setSelectionPosition(const Position& pos);
79 
81  void setSelectionBoundary(const Boundary& boundary);
82 
84  bool isElementSelected(const GUIGlObject* GLObject) const;
85 
87  bool checkBoundaryParentElement(const GUIGlObject* GLObject, const GUIGlObject* parent);
88 
91  const Position& center, const double radius, const Boundary& circleBoundary);
92 
95  const PositionVector& shape, const int index, const double radius);
96 
99  const PositionVector& shape, const double distance);
100 
102  bool checkShapeElement(const GUIGlObject* GLObject, const PositionVector& shape,
103  const Boundary& shapeBoundary);
104 
106  bool addElementUnderCursor(const GUIGlObject* GLObject, const bool checkDuplicated, const bool fullBoundary);
107 
109  bool addGeometryPointUnderCursor(const GUIGlObject* GLObject, const int newIndex);
110 
112  bool addPositionOverShape(const GUIGlObject* GLObject, const Position& pos, const double offset);
113 
116 
118  const std::vector<int>& getGeometryPoints(const GUIGlObject* GLObject) const;
119 
121  const Position& getPositionOverShape(const GUIGlObject* GLObject) const;
122 
124  void updateFrontElement(const GUIGlObject* GLObject);
125 
128 
131 
133  const GNEEdge* markedEdge = nullptr;
134 
136  const GNELane* markedLane = nullptr;
137 
139  const GUIGlObject* markedTAZ = nullptr;
140 
142  const GNERoute* markedRoute = nullptr;
143 
146 
149 
150 protected:
153 
155  std::map<const GUIGlObject*, bool> mySelectedObjects;
156 
159 
162 
165 
167  std::vector<int> myEmptyGeometryPoints;
168 
169 private:
172 
175 };
GUIGlObjectType
@ GLO_NETWORK
The network - empty.
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:39
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:53
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition: GNELane.h:46
Boundary mySelectionBoundary
selection boundary
bool addPositionOverShape(const GUIGlObject *GLObject, const Position &pos, const double offset)
add position over shape
void updateFrontElement(const GUIGlObject *GLObject)
move front element in elements under cursor (currently used only in netedit)
PositionVector mySelectionBoundaryShape
selection boundary (shape)
GUIViewObjectsHandler & operator=(const GUIViewObjectsHandler &)=default
set assignment operator private
bool isElementSelected(const GUIGlObject *GLObject) const
check if element was already selected
const Boundary & getSelectionBoundary() const
get selection boundary (usually the mouse position)
void setSelectionPosition(const Position &pos)
set selection position (usually the mouse position)
const GNERoute * markedRoute
marked route (used in create vehicle mode)
bool checkBoundaryParentElement(const GUIGlObject *GLObject, const GUIGlObject *parent)
check boundary parent element
GUIViewObjectsHandler(const GUIViewObjectsHandler &)=default
set copy constructor private
const Position & getSelectionPosition() const
get selection position (usually the mouse position)
bool checkShapeElement(const GUIGlObject *GLObject, const PositionVector &shape, const Boundary &shapeBoundary)
check (closed) shape element
void isolateEdgeGeometryPoints()
isolate edge geometry points (used for moving)
const GUIGlObject * markedTAZ
marked TAZ (used in create TAZRel mode)
std::map< double, std::vector< ObjectContainer > > GLObjectsSortedContainer
typedef
void setSelectionBoundary(const Boundary &boundary)
set selection boundary (usually the mouse position)
std::map< const GUIGlObject *, bool > mySelectedObjects
map with selected elements and if was selected with full boundary (used only to avoid double seletion...
GUIGlObjectType recomputeBoundaries
recompute boundaries
const GLObjectsSortedContainer & getSelectedObjects() const
get all elements under cursor sorted by layer
void clearSelectedElements()
clear selected elements
const std::vector< int > & getGeometryPoints(const GUIGlObject *GLObject) const
get geometry points for the given glObject
const GNEEdge * markedEdge
marked edge (used in create edge mode, for splitting)
const GNELane * markedLane
marked lane (used in create edge mode, for splitting)
Position mySelectionPosition
position
const GUIGlObject * markedSecondGeometryPoint
marked first geometry point (used for moving/delete geometry points)
bool addElementUnderCursor(const GUIGlObject *GLObject, const bool checkDuplicated, const bool fullBoundary)
add element into list of elements under cursor
const Position & getPositionOverShape(const GUIGlObject *GLObject) const
get position over shape
bool checkCircleElement(const GUIVisualizationSettings::Detail d, const GUIGlObject *GLObject, const Position &center, const double radius, const Boundary &circleBoundary)
check if mouse is within elements geometry (for circles)
GLObjectsSortedContainer mySortedSelectedObjects
selected element sorted by layer
bool checkGeometryPoint(const GUIVisualizationSettings::Detail d, const GUIGlObject *GLObject, const PositionVector &shape, const int index, const double radius)
check if mouse is within geometry point
bool checkPositionOverShape(const GUIVisualizationSettings::Detail d, const GUIGlObject *GLObject, const PositionVector &shape, const double distance)
check if mouse is within geometry point
std::vector< int > myEmptyGeometryPoints
empty geometry points
const GUIGlObject * markedFirstGeometryPoint
marked first geometry point (used for moving/delete geometry points)
bool addGeometryPointUnderCursor(const GUIGlObject *GLObject, const int newIndex)
add geometryPoint into list of elements under cursor
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:37
static const Position INVALID
used to indicate that a position is valid
Definition: Position.h:317
A list of positions.
ObjectContainer(const GUIGlObject *object_)
parameter constructor
Position posOverShape
position over shape
std::vector< int > geometryPoints
vector with geometry points
double offset
offset of position over shape