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-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
31class GNEJunction;
32class GNEEdge;
33class GNELane;
34class GNERoute;
35class GNEPathElement;
36class GNESegment;
37
38// ===========================================================================
39// class definitions
40// ===========================================================================
41
43
44public:
47
49 ObjectContainer(const GUIGlObject* object_) :
50 object(object_) {}
51
53 const GUIGlObject* object = nullptr;
54
56 std::vector<int> geometryPoints;
57
60
62 double offset = 0;
63 };
64
66 typedef std::map<double, std::vector<ObjectContainer> > GLObjectsSortedContainer;
67
70
72 void reset();
73
77 const Position& getSelectionPosition() const;
78
80 const Boundary& getSelectionBoundary() const;
81
83 void setSelectionPosition(const Position& pos);
84
86 void setSelectionBoundary(const Boundary& boundary);
87
89
93 bool checkBoundaryParentObject(const GUIGlObject* GLObject, const GUIGlObject* parent, const double layer);
94
97 const Position& center, const double radius, const Boundary& circleBoundary,
98 const double layer);
99
102 const PositionVector& shape, const int index, const double layer, const double radius);
103
106 const PositionVector& shape, const double layer, const double distance);
107
109 bool checkShapeObject(const GUIGlObject* GLObject, const PositionVector& shape, const Boundary& shapeBoundary,
110 const double layer, const GNESegment* segment);
112
116 bool selectObject(const GUIGlObject* GLObject, const double layer, const bool checkDuplicated,
117 const bool fullBoundary, const GNESegment* segment);
118
120 bool selectGeometryPoint(const GUIGlObject* GLObject, const int newIndex, const double layer);
121
123 bool selectPositionOverShape(const GUIGlObject* GLObject, const Position& pos, const double layer, const double offset);
124
126 bool isObjectSelected(const GUIGlObject* GLObject) const;
127
130
132 const GNESegment* getSelectedSegment(const GUIGlObject* GLObject) const;
133
135 const std::vector<int>& getSelectedGeometryPoints(const GUIGlObject* GLObject) const;
136
138 const Position& getSelectedPositionOverShape(const GUIGlObject* GLObject) const;
139
141
145 const std::set<const GNEPathElement*>& getRedrawPathElements() const;
146
148 bool isPathElementMarkForRedraw(const GNEPathElement* pathElement) const;
149
151 void addToRedrawPathElements(const GNEPathElement* pathElement);
152
154
158 const std::vector<const GNEJunction*>& getMergingJunctions() const;
159
161 bool addMergingJunctions(const GNEJunction* junction);
162
164
166 void updateFrontObject(const GUIGlObject* GLObject);
167
170
173
175 const GNEEdge* markedEdge = nullptr;
176
178 const GNELane* markedLane = nullptr;
179
181 const GUIGlObject* markedTAZ = nullptr;
182
184 const GNERoute* markedRoute = nullptr;
185
188
191
192protected:
195
197 std::map<const GUIGlObject*, std::pair<bool, const GNESegment*> > mySelectedObjects;
198
200 std::set<const GNEPathElement*> myRedrawPathElements;
201
204
207
210
212 std::vector<int> myEmptyGeometryPoints;
213
215 std::vector<const GNEJunction*> myMergingJunctions;
216
217private:
220
223};
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 checkShapeObject(const GUIGlObject *GLObject, const PositionVector &shape, const Boundary &shapeBoundary, const double layer, const GNESegment *segment)
check (closed) shape element
PositionVector mySelectionBoundaryShape
selection boundary (shape)
bool checkCircleObject(const GUIVisualizationSettings::Detail d, const GUIGlObject *GLObject, const Position &center, const double radius, const Boundary &circleBoundary, const double layer)
check if mouse is within elements geometry (for circles)
const Boundary & getSelectionBoundary() const
get selection boundary
void setSelectionPosition(const Position &pos)
set selection position
void addToRedrawPathElements(const GNEPathElement *pathElement)
add path element to redrawing set
std::map< const GUIGlObject *, std::pair< bool, 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
std::vector< const GNEJunction * > myMergingJunctions
merging junctions
GUIViewObjectsHandler(const GUIViewObjectsHandler &)=default
set copy constructor private
const Position & getSelectionPosition() const
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
std::map< double, std::vector< ObjectContainer > > GLObjectsSortedContainer
typedef for pack elements sorted by layer
bool selectObject(const GUIGlObject *GLObject, const double layer, const bool checkDuplicated, const bool fullBoundary, const GNESegment *segment)
bool addMergingJunctions(const GNEJunction *junction)
add to merging junctions (used for marking junctions to merge)
void setSelectionBoundary(const Boundary &boundary)
set selection boundary
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)
const GNELane * markedLane
marked lane (used in create edge mode, for splitting)
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
bool checkBoundaryParentObject(const GUIGlObject *GLObject, const GUIGlObject *parent, const double layer)
void updateFrontObject(const GUIGlObject *GLObject)
move the given object to the front (currently used only in netedit)
bool checkGeometryPoint(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
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
std::vector< int > myEmptyGeometryPoints
empty geometry points
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
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:322
A list of positions.
ObjectContainer(const GUIGlObject *object_)
parameter constructor
std::vector< int > geometryPoints
vector with geometry points
double offset
offset of position over shape