LCOV - code coverage report
Current view: top level - src/utils/gui/div - GUIViewObjectsHandler.h (source / functions) Coverage Total Hit
Test: lcov.info Lines: 0.0 % 3 0
Test Date: 2024-11-20 15:55:46 Functions: - 0 0

            Line data    Source code
       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              : /****************************************************************************/
      14              : /// @file    GUIViewObjectsHandler.h
      15              : /// @author  Pablo Alvarez Lopez
      16              : /// @date    Jun 22
      17              : ///
      18              : // class used for handle objects over view
      19              : /****************************************************************************/
      20              : #pragma once
      21              : #include <config.h>
      22              : 
      23              : #include <vector>
      24              : #include <utils/gui/globjects/GUIGlObject.h>
      25              : #include <utils/gui/settings/GUIVisualizationSettings.h>
      26              : 
      27              : // ===========================================================================
      28              : // class declaration
      29              : // ===========================================================================
      30              : 
      31              : class GNEJunction;
      32              : class GNEEdge;
      33              : class GNELane;
      34              : class GNERoute;
      35              : class GNEPathElement;
      36              : class GNESegment;
      37              : 
      38              : // ===========================================================================
      39              : // class definitions
      40              : // ===========================================================================
      41              : 
      42              : class GUIViewObjectsHandler {
      43              : 
      44              : public:
      45              :     /// @brief object container
      46            0 :     struct ObjectContainer {
      47              : 
      48              :         /// @brief parameter constructor
      49            0 :         ObjectContainer(const GUIGlObject* object_) :
      50            0 :             object(object_) {}
      51              : 
      52              :         /// @brief object
      53              :         const GUIGlObject* object = nullptr;
      54              : 
      55              :         /// @brief vector with geometry points
      56              :         std::vector<int> geometryPoints;
      57              : 
      58              :         /// @brief position over shape
      59              :         Position posOverShape = Position::INVALID;
      60              : 
      61              :         /// @brief offset of position over shape
      62              :         double offset = 0;
      63              :     };
      64              : 
      65              :     /// @brief typedef for pack elements sorted by layer
      66              :     typedef std::map<double, std::vector<ObjectContainer> > GLObjectsSortedContainer;
      67              : 
      68              :     /// @brief constructor
      69              :     GUIViewObjectsHandler();
      70              : 
      71              :     /// @brief reset view objects handler
      72              :     void reset();
      73              : 
      74              :     /// @name position and boundary functions. used for defining the posion that will be check (usually the mouse position)
      75              :     /// @{
      76              :     /// @brief get selection position
      77              :     const Position& getSelectionPosition() const;
      78              : 
      79              :     /// @brief get selection boundary
      80              :     const Boundary& getSelectionBoundary() const;
      81              : 
      82              :     /// @brief set selection position
      83              :     void setSelectionPosition(const Position& pos);
      84              : 
      85              :     /// @brief set selection boundary
      86              :     void setSelectionBoundary(const Boundary& boundary);
      87              : 
      88              :     /// @}
      89              : 
      90              :     /// @name check functions. If the result is positive, the given GLObject will be added to elementUnderCursor
      91              :     /// @{
      92              :     /// @brief check boundary parent element
      93              :     bool checkBoundaryParentObject(const GUIGlObject* GLObject, const GUIGlObject* parent, const double layer);
      94              : 
      95              :     /// @brief check if mouse is within elements geometry (for circles)
      96              :     bool checkCircleObject(const GUIVisualizationSettings::Detail d, const GUIGlObject* GLObject,
      97              :                            const Position& center, const double radius, const Boundary& circleBoundary,
      98              :                            const double layer);
      99              : 
     100              :     /// @brief check if mouse is within geometry point
     101              :     bool checkGeometryPoint(const GUIVisualizationSettings::Detail d, const GUIGlObject* GLObject,
     102              :                             const PositionVector& shape, const int index, const double layer, const double radius);
     103              : 
     104              :     /// @brief check if mouse is within geometry point
     105              :     bool checkPositionOverShape(const GUIVisualizationSettings::Detail d, const GUIGlObject* GLObject,
     106              :                                 const PositionVector& shape, const double layer, const double distance);
     107              : 
     108              :     /// @brief check (closed) shape element
     109              :     bool checkShapeObject(const GUIGlObject* GLObject, const PositionVector& shape, const Boundary& shapeBoundary,
     110              :                           const double layer, const GNESegment* segment);
     111              :     /// @}
     112              : 
     113              :     /// @name functions used for mark (select) elements
     114              :     /// @{
     115              :     /// @brief add element into list of elements under cursor
     116              :     bool selectObject(const GUIGlObject* GLObject, const double layer, const bool checkDuplicated,
     117              :                       const bool fullBoundary, const GNESegment* segment);
     118              : 
     119              :     /// @brief add geometryPoint into list of elements under cursor
     120              :     bool selectGeometryPoint(const GUIGlObject* GLObject, const int newIndex, const double layer);
     121              : 
     122              :     /// @brief select position over shape (for example, the position over a lane shape)
     123              :     bool selectPositionOverShape(const GUIGlObject* GLObject, const Position& pos, const double layer, const double offset);
     124              : 
     125              :     /// @brief check if element was already selected
     126              :     bool isObjectSelected(const GUIGlObject* GLObject) const;
     127              : 
     128              :     /// @brief get all elements under cursor sorted by layer
     129              :     const GLObjectsSortedContainer& getSelectedObjects() const;
     130              : 
     131              :     /// @brief get segment associated with the given GLObject (if exist)
     132              :     const GNESegment* getSelectedSegment(const GUIGlObject* GLObject) const;
     133              : 
     134              :     /// @brief get geometry points for the given glObject
     135              :     const std::vector<int>& getSelectedGeometryPoints(const GUIGlObject* GLObject) const;
     136              : 
     137              :     /// @brief get position over shape
     138              :     const Position& getSelectedPositionOverShape(const GUIGlObject* GLObject) const;
     139              : 
     140              :     /// @}
     141              : 
     142              :     /// @name functions related with redrawing path elements
     143              :     /// @{
     144              :     /// @brief get redrawing objects
     145              :     const std::set<const GNEPathElement*>& getRedrawPathElements() const;
     146              : 
     147              :     /// @brief check if the given path element has to be redraw again
     148              :     bool isPathElementMarkForRedraw(const GNEPathElement* pathElement) const;
     149              : 
     150              :     /// @brief add path element to redrawing set
     151              :     void addToRedrawPathElements(const GNEPathElement* pathElement);
     152              : 
     153              :     /// @}
     154              : 
     155              :     /// @name functions related with merging junctions
     156              :     /// @{
     157              :     /// @brief get merging junctions
     158              :     const std::vector<const GNEJunction*>& getMergingJunctions() const;
     159              : 
     160              :     /// @brief add to merging junctions (used for marking junctions to merge)
     161              :     bool addMergingJunctions(const GNEJunction* junction);
     162              : 
     163              :     /// @}
     164              : 
     165              :     /// @brief move the given object to the front (currently used only in netedit)
     166              :     void updateFrontObject(const GUIGlObject* GLObject);
     167              : 
     168              :     /// @brief isolate edge geometry points (used for moving)
     169              :     void isolateEdgeGeometryPoints();
     170              : 
     171              :     /// @brief recompute boundaries
     172              :     GUIGlObjectType recomputeBoundaries = GLO_NETWORK;
     173              : 
     174              :     /// @brief marked edge (used in create edge mode, for splitting)
     175              :     const GNEEdge* markedEdge = nullptr;
     176              : 
     177              :     /// @brief marked lane (used in create edge mode, for splitting)
     178              :     const GNELane* markedLane = nullptr;
     179              : 
     180              :     /// @brief marked TAZ (used in create TAZRel mode)
     181              :     const GUIGlObject* markedTAZ = nullptr;
     182              : 
     183              :     /// @brief marked route (used in create vehicle mode)
     184              :     const GNERoute* markedRoute = nullptr;
     185              : 
     186              :     /// @brief marked first geometry point (used for moving/delete geometry points)
     187              :     const GUIGlObject* markedFirstGeometryPoint = nullptr;
     188              : 
     189              :     /// @brief marked first geometry point (used for moving/delete geometry points)
     190              :     const GUIGlObject* markedSecondGeometryPoint = nullptr;
     191              : 
     192              : protected:
     193              :     /// @brief selected element sorted by layer
     194              :     GLObjectsSortedContainer mySortedSelectedObjects;
     195              : 
     196              :     /// @brief map with selected elements and if was selected with full boundary (used only to avoid double selections)
     197              :     std::map<const GUIGlObject*, std::pair<bool, const GNESegment*> > mySelectedObjects;
     198              : 
     199              :     /// @brief set with path elements marked for redrawing
     200              :     std::set<const GNEPathElement*> myRedrawPathElements;
     201              : 
     202              :     /// @brief selection boundary
     203              :     Boundary mySelectionBoundary;
     204              : 
     205              :     /// @brief selection boundary (shape)
     206              :     PositionVector mySelectionBoundaryShape;
     207              : 
     208              :     /// @brief position
     209              :     Position mySelectionPosition;
     210              : 
     211              :     /// @brief empty geometry points
     212              :     std::vector<int> myEmptyGeometryPoints;
     213              : 
     214              :     /// @brief merging junctions
     215              :     std::vector<const GNEJunction*> myMergingJunctions;
     216              : 
     217              : private:
     218              :     /// @brief set copy constructor private
     219              :     GUIViewObjectsHandler(const GUIViewObjectsHandler&) = default;
     220              : 
     221              :     /// @brief set assignment operator private
     222              :     GUIViewObjectsHandler& operator=(const GUIViewObjectsHandler&) = default;
     223              : };
        

Generated by: LCOV version 2.0-1