110 const Position& center,
const double radius,
const Boundary& circleBoundary) {
116 const double squaredRadius = (radius * radius);
135 if (vertex.distanceSquaredTo2D(center) <= squaredRadius) {
165 const PositionVector& shape,
const int index,
const double radius) {
167 const auto geometryPointPos = shape[index];
169 const double squaredRadius = (radius * radius);
176 geometryPointBoundary.
add(geometryPointPos);
177 geometryPointBoundary.
grow(radius);
186 if (vertex.distanceSquaredTo2D(geometryPointPos) <= squaredRadius) {
250 for (
int i = 1; i < (int)shape.size(); i++) {
277 const auto layer =
dynamic_cast<const Shape*
>(GLObject);
280 layerContainer.insert(layerContainer.begin(),
ObjectContainer(GLObject));
281 }
else if (GLObject) {
283 layerContainer.insert(layerContainer.begin(),
ObjectContainer(GLObject));
295 for (
auto& element : elementLayer.second) {
296 if (element.object == GLObject) {
298 for (
auto& index : element.geometryPoints) {
299 if (index == newIndex) {
304 element.geometryPoints.push_back(newIndex);
310 const auto layer =
dynamic_cast<const Shape*
>(GLObject);
313 auto it = layerContainer.insert(layerContainer.begin(),
ObjectContainer(GLObject));
314 it->geometryPoints.push_back(newIndex);
315 }
else if (GLObject) {
317 auto it = layerContainer.insert(layerContainer.begin(),
ObjectContainer(GLObject));
318 it->geometryPoints.push_back(newIndex);
329 for (
auto& element : elementLayer.second) {
330 if (element.object == GLObject) {
335 element.posOverShape = pos;
336 element.offset = offset;
343 const auto layer =
dynamic_cast<const Shape*
>(GLObject);
346 auto it = layerContainer.insert(layerContainer.begin(),
ObjectContainer(GLObject));
347 it->posOverShape = pos;
348 }
else if (GLObject) {
350 auto it = layerContainer.insert(layerContainer.begin(),
ObjectContainer(GLObject));
351 it->posOverShape = pos;
364 const std::vector<int>&
368 for (
auto& element : elementLayer.second) {
369 if (element.object == GLObject) {
370 return element.geometryPoints;
382 for (
auto& element : elementLayer.second) {
383 if (element.object == GLObject) {
384 return element.posOverShape;
397 auto it = elementLayer.second.begin();
398 while (it != elementLayer.second.end()) {
399 if (it->object == GLObject) {
401 frontElement.
object = it->object;
404 it = elementLayer.second.erase(it);
411 if (frontElement.
object) {
423 for (
auto element : elementLayer.second) {
424 if ((element.object->getType() ==
GLO_EDGE) && (element.geometryPoints.size() > 0)) {
425 edgeWithGeometryPoints = element;
430 if (edgeWithGeometryPoints.
object !=
nullptr) {
@ GLO_FRONTELEMENT
front element (used in netedit)
@ GLO_NETWORK
The network - empty.
A class that stores a 2D geometrical boundary.
void add(double x, double y, double z=0)
Makes the boundary include the given coordinate.
bool isInitialised() const
check if Boundary is Initialised
void reset()
Resets the boundary.
Boundary & grow(double by)
extends the boundary by the given amount
bool overlapsWith(const AbstractPoly &poly, double offset=0) const
Returns whether the boundary overlaps with the given polygon.
PositionVector getShape(const bool closeShape) const
get position vector (shape) based on this boundary
bool around2D(const Position &p, double offset=0) const
Returns whether the boundary contains the given 2D coordinate.
bool crosses(const Position &p1, const Position &p2) const
Returns whether the boundary crosses the given line.
double contains(const Boundary &b) const
return true if this boundary contains the given boundary (only X-Y)
virtual Boundary getCenteringBoundary() const =0
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
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)
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
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
GUIViewObjectsHandler()
constructor
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 ¢er, 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.
double distanceSquaredTo2D(const Position &p2) const
returns the square of the distance to another position (Only using x and y positions)
static const Position INVALID
used to indicate that a position is valid
double nearest_offset_to_point2D(const Position &p, bool perpendicular=true) const
return the nearest offest to point 2D
Position positionAtOffset2D(double pos, double lateralOffset=0) const
Returns the position at the given length.
bool around(const Position &p, double offset=0) const
Returns the information whether the position vector describes a polygon lying around the given point.
std::vector< int > geometryPoints
vector with geometry points
const GUIGlObject * object
object