Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
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-2026 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>
24#include <unordered_map>
25#include <utils/geom/Triangle.h>
28
29// ===========================================================================
30// class declaration
31// ===========================================================================
32
33class GNEJunction;
34class GNEEdge;
35class GNELane;
36class GNERoute;
37class GNEPathElement;
38class GNESegment;
39
40// ===========================================================================
41// class definitions
42// ===========================================================================
43
45
46public:
49
51 ObjectContainer(const GUIGlObject* object_) :
52 object(object_) {}
53
55 const GUIGlObject* object = nullptr;
56
58 std::vector<int> geometryPoints;
59
62
64 double offset = 0;
65 };
66
68 struct ObjectContainerLayer : public std::vector<ObjectContainer> {
69
72
73 // @brief append object container and resize if neccesary
74 void append(const ObjectContainer& objectContainer);
75 };
76
78 typedef std::map<double, ObjectContainerLayer > GLObjectsSortedContainer;
79
82
84 void reset();
85
89 const Position& getSelectionPosition() const;
90
92 const Triangle& getSelectionTriangle() const;
93
95 void setSelectionPosition(const Position& pos);
96
98 void setSelectionTriangle(const Triangle& triangle);
99
101 bool selectingUsingRectangle() const;
102
104
109 const double layer, const GUIGlObject* parent);
110
113 const Position& center, const double radius, const double layer);
114
117 const PositionVector& shape, const int index, const double layer, const double radius);
118
121 const PositionVector& shape, const double layer, const double distance);
122
124 bool checkShapeObject(const GUIVisualizationSettings& s, const GUIGlObject* GLObject, const PositionVector& shape,
125 const Boundary& shapeBoundary, const double layer, const GNESegment* segment);
127
132 bool selectObject(const GUIVisualizationSettings& s, const GUIGlObject* GLObject, const double layer,
133 const bool checkDuplicated, const GNESegment* segment);
134
136 bool selectGeometryPoint(const GUIGlObject* GLObject, const int newIndex, const double layer);
137
139 bool selectPositionOverShape(const GUIGlObject* GLObject, const Position& pos, const double layer, const double offset);
140
142 bool isObjectSelected(const GUIGlObject* GLObject) const;
143
145 bool checkRectangleSelection(const GUIVisualizationSettings& s, const GUIGlObject* GLObject,
146 const double layer, const GUIGlObject* parent);
147
150
152 const GNESegment* getSelectedSegment(const GUIGlObject* GLObject) const;
153
155 const std::vector<int>& getSelectedGeometryPoints(const GUIGlObject* GLObject) const;
156
158 const Position& getSelectedPositionOverShape(const GUIGlObject* GLObject) const;
159
161 int getNumberOfSelectedObjects() const;
162
165
167
171 const std::set<const GNEPathElement*>& getRedrawPathElements() const;
172
174 bool isPathElementMarkForRedraw(const GNEPathElement* pathElement) const;
175
177 void addToRedrawPathElements(const GNEPathElement* pathElement);
178
180
184 const std::vector<const GNEJunction*>& getMergingJunctions() const;
185
187 bool addMergingJunctions(const GNEJunction* junction);
188
190
192 void updateFrontObject(const GUIGlObject* GLObject);
193
196
199
201 const GNEEdge* markedEdge = nullptr;
202
204 const GNELane* markedLane = nullptr;
205
207 const GUIGlObject* markedTAZ = nullptr;
208
210 const GNERoute* markedRoute = nullptr;
211
214
217
218protected:
221
223 std::unordered_map<const GUIGlObject*, const GNESegment*> mySelectedObjects;
224
227
229 std::set<const GNEPathElement*> myRedrawPathElements;
230
233
236
238 std::vector<int> myEmptyGeometryPoints;
239
241 std::vector<const GNEJunction*> myMergingJunctions;
242
243private:
246
249};
GUIGlObjectType
@ GLO_NETWORK
The network - empty.
A class that stores a 2D geometrical boundary.
Definition Boundary.h:39
Triangle mySelectionTriangle
selection triangle
void setSelectionPosition(const Position &pos)
set selection position
void addToRedrawPathElements(const GNEPathElement *pathElement)
add path element to redrawing set
bool selectObject(const GUIVisualizationSettings &s, const GUIGlObject *GLObject, const double layer, const bool checkDuplicated, const GNESegment *segment)
std::unordered_map< const GUIGlObject *, const GNESegment * > mySelectedObjects
map with selected elements and if was selected with full boundary (used only to avoid double selectio...
const GNERoute * markedRoute
marked route (used in create vehicle mode)
bool selectGeometryPoint(const GUIGlObject *GLObject, const int newIndex, const double layer)
add geometryPoint into list of elements under cursor
int getNumberOfSelectedObjects() const
get number of selected objects
std::vector< const GNEJunction * > myMergingJunctions
merging junctions
GUIViewObjectsHandler(const GUIViewObjectsHandler &)=default
set copy constructor private
const Position & getSelectionPosition() const
const Triangle & getSelectionTriangle() const
get selection triangle
void reverseSelectedObjects()
reverse selected objects
void isolateEdgeGeometryPoints()
isolate edge geometry points (used for moving)
void reset()
reset view objects handler
const GUIGlObject * markedTAZ
marked TAZ (used in create TAZRel mode)
const Position & getSelectedPositionOverShape(const GUIGlObject *GLObject) const
get position over shape
bool checkCircleObject(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const GUIGlObject *GLObject, const Position &center, const double radius, const double layer)
check if mouse is within elements geometry (for circles)
bool addMergingJunctions(const GNEJunction *junction)
add to merging junctions (used for marking junctions to merge)
std::map< double, ObjectContainerLayer > GLObjectsSortedContainer
typedef for pack elements sorted by layer
void setSelectionTriangle(const Triangle &triangle)
set selection triangle
GUIGlObjectType recomputeBoundaries
recompute boundaries
const GLObjectsSortedContainer & getSelectedObjects() const
get all elements under cursor sorted by layer
const GNEEdge * markedEdge
marked edge (used in create edge mode, for splitting)
int myNumberOfSelectedObjects
number of selected objects
const GNELane * markedLane
marked lane (used in create edge mode, for splitting)
bool checkBoundaryParentObject(const GUIVisualizationSettings &s, const GUIGlObject *GLObject, const double layer, const GUIGlObject *parent)
bool checkShapeObject(const GUIVisualizationSettings &s, const GUIGlObject *GLObject, const PositionVector &shape, const Boundary &shapeBoundary, const double layer, const GNESegment *segment)
check (closed) shape element
bool checkGeometryPoint(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const GUIGlObject *GLObject, const PositionVector &shape, const int index, const double layer, const double radius)
check if mouse is within geometry point
Position mySelectionPosition
position
bool isPathElementMarkForRedraw(const GNEPathElement *pathElement) const
check if the given path element has to be redraw again
const GUIGlObject * markedSecondGeometryPoint
marked first geometry point (used for moving/delete geometry points)
bool isObjectSelected(const GUIGlObject *GLObject) const
check if element was already selected
const std::vector< int > & getSelectedGeometryPoints(const GUIGlObject *GLObject) const
get geometry points for the given glObject
void updateFrontObject(const GUIGlObject *GLObject)
move the given object to the front (currently used only in netedit)
bool checkPositionOverShape(const GUIVisualizationSettings::Detail d, const GUIGlObject *GLObject, const PositionVector &shape, const double layer, const double distance)
check if mouse is within geometry point
std::set< const GNEPathElement * > myRedrawPathElements
set with path elements marked for redrawing
const GNESegment * getSelectedSegment(const GUIGlObject *GLObject) const
get segment associated with the given GLObject (if exist)
GLObjectsSortedContainer mySortedSelectedObjects
selected element sorted by layer
bool selectingUsingRectangle() const
return true if we're selecting using a triangle
std::vector< int > myEmptyGeometryPoints
empty geometry points
bool checkRectangleSelection(const GUIVisualizationSettings &s, const GUIGlObject *GLObject, const double layer, const GUIGlObject *parent)
check rectangle selection
const GUIGlObject * markedFirstGeometryPoint
marked first geometry point (used for moving/delete geometry points)
GUIViewObjectsHandler & operator=(const GUIViewObjectsHandler &)=default
set assignment operator private
const std::set< const GNEPathElement * > & getRedrawPathElements() const
bool selectPositionOverShape(const GUIGlObject *GLObject, const Position &pos, const double layer, const double offset)
select position over shape (for example, the position over a lane shape)
const std::vector< const GNEJunction * > & getMergingJunctions() const
Stores the information about how to visualize structures.
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:323
A list of positions.
A simple triangle defined in 3D.
Definition Triangle.h:35
ObjectContainer(const GUIGlObject *object_)
parameter constructor
std::vector< int > geometryPoints
vector with geometry points
double offset
offset of position over shape
void append(const ObjectContainer &objectContainer)