Eclipse SUMO - Simulation of Urban MObility
GNEViewNetHelper.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
15 // A file used to reduce the size of GNEViewNet.h grouping structs and classes
16 /****************************************************************************/
17 #ifndef GNEViewNetHelper_h
18 #define GNEViewNetHelper_h
19 
20 
21 // ===========================================================================
22 // included modules
23 // ===========================================================================
24 #include <config.h>
25 
28 #include <utils/geom/Position.h>
36 
37 
38 // ===========================================================================
39 // enum
40 // ===========================================================================
41 
43 enum Supermode {
50 };
51 
80 };
81 
108 };
109 
110 // ===========================================================================
111 // class declarations
112 // ===========================================================================
113 
114 // main elements
115 class GNEViewParent;
116 class GNEViewNet;
117 class GNEUndoList;
118 class GNEFrame;
119 class GNEAttributeCarrier;
120 // net elements
121 class GNENet;
122 class GNENetElement;
123 class GNEJunction;
124 class GNEEdge;
125 class GNELane;
126 class GNEConnection;
127 class GNECrossing;
128 class GNEInternalLane;
129 // additional elements
130 class GNEAdditional;
131 class GNEShape;
132 class GNEPoly;
133 class GNEPOI;
134 class GNETAZ;
135 // demand elements
136 class GNEDemandElement;
137 class GNEVehicleType;
138 class GNEFlow;
139 class GNEVehicle;
140 class GNEtrip;
141 
142 // ===========================================================================
143 // classes and structs definitions
144 // ===========================================================================
145 
147 
150  public:
153 
155  void updateObjectUnderCursor(const std::vector<GUIGlObject*>& GUIGlObjects, GNEPoly* editedPolyShape);
156 
158  void swapLane2Edge();
159 
161  void setCreatedJunction(GNEJunction* junction);
162 
164  GUIGlID getGlIDFront() const;
165 
168 
171 
174 
177 
179  GNEShape* getShapeFront() const;
180 
183 
185  GNEJunction* getJunctionFront() const;
186 
188  GNEEdge* getEdgeFront() const;
189 
191  GNELane* getLaneFront() const;
192 
194  GNECrossing* getCrossingFront() const;
195 
198 
200  GNETAZ* getTAZFront() const;
201 
203  GNEPOI* getPOIFront() const;
204 
206  GNEPoly* getPolyFront() const;
207 
209  const std::vector<GNEAttributeCarrier*>& getClickedAttributeCarriers() const;
210 
211  private:
213  std::vector<GUIGlObject*> myGUIGlObjects;
214 
216  std::vector<GNEAttributeCarrier*> myAttributeCarriers;
217 
219  std::vector<GNENetElement*> myNetElements;
220 
222  std::vector<GNEAdditional*> myAdditionals;
223 
225  std::vector<GNEShape*> myShapes;
226 
228  std::vector<GNEDemandElement*> myDemandElements;
229 
231  std::vector<GNEJunction*> myJunctions;
232 
234  std::vector<GNEEdge*> myEdges;
235 
237  std::vector<GNELane*> myLanes;
238 
240  std::vector<GNECrossing*> myCrossings;
241 
243  std::vector<GNEConnection*> myConnections;
244 
246  std::vector<GNETAZ*> myTAZs;
247 
249  std::vector<GNEPOI*> myPOIs;
250 
252  std::vector<GNEPoly*> myPolys;
253 
255  void sortGUIGlObjectsByAltitude(const std::vector<GUIGlObject*>& GUIGlObjects);
256 
258  ObjectsUnderCursor(const ObjectsUnderCursor&) = delete;
259 
262  };
263 
265  struct KeyPressed {
266 
268  KeyPressed();
269 
271  void update(void* eventData);
272 
274  bool shiftKeyPressed() const;
275 
277  bool controlKeyPressed() const;
278 
279  private:
281  FXEvent* myEventInfo;
282 
284  KeyPressed(const KeyPressed&) = delete;
285 
287  KeyPressed& operator=(const KeyPressed&) = delete;
288  };
289 
291  struct EditModes {
292 
294  EditModes(GNEViewNet* viewNet);
295 
297  void buildSuperModeButtons();
298 
300  void setSupermode(Supermode supermode);
301 
303  void setNetworkEditMode(NetworkEditMode networkMode, bool force = false);
304 
306  void setDemandEditMode(DemandEditMode demandMode, bool force = false);
307 
310 
313 
316 
319 
322 
323  private:
326 
328  EditModes(const EditModes&) = delete;
329 
331  EditModes& operator=(const EditModes&) = delete;
332  };
333 
336 
338  CommonViewOptions(GNEViewNet* viewNet);
339 
341  void buildCommonViewOptionsMenuChecks();
342 
344  void hideCommonViewOptionsMenuChecks();
345 
347  void getVisibleCommonMenuCommands(std::vector<FXMenuCheck*>& commands) const;
348 
350  FXMenuCheck* menuCheckShowGrid;
351 
352  private:
355 
357  CommonViewOptions(const CommonViewOptions&) = delete;
358 
361  };
362 
365 
367  NetworkViewOptions(GNEViewNet* viewNet);
368 
370  void buildNetworkViewOptionsMenuChecks();
371 
373  void hideNetworkViewOptionsMenuChecks();
374 
376  void getVisibleNetworkMenuCommands(std::vector<FXMenuCheck*>& commands) const;
377 
379  bool showDemandElements() const;
380 
382  bool selectEdges() const;
383 
385  bool showConnections() const;
386 
388  bool editingElevation() const;
389 
392 
394  FXMenuCheck* menuCheckSelectEdges;
395 
398 
401 
404 
407 
410 
413 
416 
418  FXMenuCheck* menuCheckChainEdges;
419 
422  private:
425 
427  NetworkViewOptions(const NetworkViewOptions&) = delete;
428 
431  };
432 
435 
437  DemandViewOptions(GNEViewNet* viewNet);
438 
440  void buildDemandViewOptionsMenuChecks();
441 
443  void hideDemandViewOptionsMenuChecks();
444 
446  void getVisibleDemandMenuCommands(std::vector<FXMenuCheck*>& commands) const;
447 
449  bool showNonInspectedDemandElements(const GNEDemandElement* demandElement) const;
450 
452  bool showShapes() const;
453 
455  bool showAllPersonPlans() const;
456 
458  void lockPerson(const GNEDemandElement* person);
459 
461  void unlockPerson();
462 
464  const GNEDemandElement* getLockedPerson() const;
465 
467  FXMenuCheck* menuCheckHideShapes;
468 
471 
474 
476  FXMenuCheck* menuCheckLockPerson;
477 
478  private:
481 
484 
486  DemandViewOptions(const DemandViewOptions&) = delete;
487 
490  };
491 
494 
497 
499  bool beginMoveSingleElementNetworkMode();
500 
502  bool beginMoveSingleElementDemandMode();
503 
505  void moveSingleElement();
506 
508  void finishMoveSingleElement();
509 
512 
515 
518 
519  private:
521  bool calculatePolyValues();
522 
524  bool calculateEdgeValues();
525 
527  bool calculateTAZValues();
528 
531 
534 
537 
540 
543 
546 
549 
552 
555 
558 
561  };
562 
565 
568 
570  void beginMoveSelection(GNEAttributeCarrier* originAC);
571 
573  void moveSelection();
574 
576  void finishMoveSelection();
577 
579  bool isMovingSelection() const;
580 
581  private:
584 
587 
590 
592  std::map<GNEJunction*, Position> myMovedJunctionOriginPositions;
593 
595  std::map<GNEEdge*, PositionVector> myMovedEdgesOriginShape;
596 
598  std::map<GNEEdge*, MoveSingleElementValues*> myMovedEgdesGeometryPoints;
599  };
600 
602  struct VehicleOptions {
603 
605  VehicleOptions(GNEViewNet* viewNet);
606 
608  void buildVehicleOptionsMenuChecks();
609 
611  void hideVehicleOptionsMenuChecks();
612 
613  private:
616  };
617 
620 
622  VehicleTypeOptions(GNEViewNet* viewNet);
623 
625  void buildVehicleTypeOptionsMenuChecks();
626 
628  void hideVehicleTypeOptionsMenuChecks();
629 
630  private:
633  };
634 
637  struct SelectingArea {
638 
640  SelectingArea(GNEViewNet* viewNet);
641 
643  void beginRectangleSelection();
644 
646  void moveRectangleSelection();
647 
649  void finishRectangleSelection();
650 
652  void processRectangleSelection();
653 
655  std::vector<GNEEdge*> processEdgeRectangleSelection();
656 
658  void processShapeSelection(const PositionVector& shape);
659 
661  void drawRectangleSelection(const RGBColor& color) const;
662 
665 
668 
669  private:
671  void processBoundarySelection(const Boundary& boundary);
672 
675 
678 
681  };
682 
684  struct TestingMode {
685 
687  TestingMode(GNEViewNet* viewNet);
688 
690  void initTestingMode();
691 
693  void drawTestingElements(GUIMainWindow* mainWindow);
694 
695  private:
698 
701 
704 
707  };
708 
711 
714 
716  void buildCommonCheckableButtons();
717 
719  void showCommonCheckableButtons();
720 
722  void hideCommonCheckableButtons();
723 
725  void disableCommonCheckableButtons();
726 
728  void updateCommonCheckableButtons();
729 
732 
735 
738 
741 
742  private:
745  };
746 
749 
752 
754  void buildNetworkCheckableButtons();
755 
757  void showNetworkCheckableButtons();
758 
760  void hideNetworkCheckableButtons();
761 
763  void disableNetworkCheckableButtons();
764 
766  void updateNetworkCheckableButtons();
767 
770 
773 
776 
779 
782 
785 
788 
791 
792  private:
795  };
796 
799 
802 
804  void buildDemandCheckableButtons();
805 
807  void showDemandCheckableButtons();
808 
810  void hideDemandCheckableButtons();
811 
813  void disableDemandCheckableButtons();
814 
816  void updateDemandCheckableButtons();
817 
820 
823 
826 
829 
832 
835 
838 
839  private:
842  };
843 
845  struct EditShapes {
846 
848  EditShapes(GNEViewNet* viewNet);
849 
851  void startEditCustomShape(GNENetElement* element, const PositionVector& shape, bool fill);
852 
854  void stopEditCustomShape();
855 
857  void saveEditedShape();
858 
861 
864 
865  private:
868 
871  };
872 };
873 
874 #endif
875 
876 /****************************************************************************/
empty Network mode
MFXCheckableButton * networkButton
chekable button for supermode Network
struct used to group all variables related with Network chekable Buttons
Position myClickedPosition
original clicked position when moveSelection is called (used for calculate offset during moveSelectio...
const GNEDemandElement * myLockedPerson
pointer to locked person
void sortGUIGlObjectsByAltitude(const std::vector< GUIGlObject *> &GUIGlObjects)
invert GUIGlObjects
Mode for editing crossing.
GNECrossing * getCrossingFront() const
get front crossing (or a pointer to nullptr if there isn&#39;t)
bool myMovingEndPos
bool to indicate that end pos of an edge is being moved
empty Demand mode
MFXCheckableButton * personTypeButton
chekable button for edit mode create person type
GNETAZ * getTAZFront() const
get front TAZ (or a pointer to nullptr if there isn&#39;t)
GNEViewNet * myViewNet
pointer to viewNet
MFXCheckableButton * demandButton
chekable button for supermode Demand
std::vector< GNEConnection * > myConnections
vector with the clicked connections
GUIGlObjectType
MFXCheckableButton * connectionButton
chekable button for edit mode connection
Mode for editing TAZ.
class used to group all variables related with key pressed after certain events
bool myMovingSelection
flag to check if a selection is being moved
FXMenuCheck * menuCheckShowAllPersonPlans
show all person plans
struct used to group all variables related to view options in supermode Network
NetworkEditMode
enum for network edit modes
MFXCheckableButton * createEdgeButton
chekable button for edit mode create edge
GNEViewNet * myViewNet
pointer to viewNet
PositionVector originalShapeBeforeMoving
original shape of element before start moving (used by polygons, edges, etc., needed for commmit posi...
Definition: GNEPOI.h:45
FXMenuCheck * menuCheckChangeAllPhases
menu check to set change all phases
GNEJunction * myJunctionToMove
the Junction to be moved.
MFXCheckableButton * personButton
chekable button for edit mode create persons
GNEAdditional * myAdditionalToMove
the additional element which position is being moved
Mode for editing connection prohibitions.
MFXCheckableButton * trafficLightButton
chekable button for edit mode traffic light
This object is responsible for drawing a shape and for supplying a a popup menu. Messages are routete...
ObjectsUnderCursor & operator=(const ObjectsUnderCursor &)=delete
Invalidated assignment operator.
mode for selecting network elements
GNEPoly * editedShapePoly
polygon used for edit shapes
bool myMovingStartPos
bool to indicate that startPos of an edge is being moved
int myTestingWidth
Width of viewNet in testing mode.
std::vector< GNETAZ * > myTAZs
vector with the clicked TAZ elements (needed because uses a shape instead a position) ...
GNEViewNet * myViewNet
pointer to viewNet
NetworkEditMode myPreviousNetworkEditMode
the previous edit mode before edit NetElement&#39;s shapes
mode for moving demand elements
FXMenuCheck * menuCheckWarnAboutMerge
menu check to we should warn about merging junctions
A NBNetBuilder extended by visualisation and editing capabilities.
Definition: GNENet.h:78
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition: GNELane.h:46
mode for selecting demand elements
const std::vector< GNEAttributeCarrier * > & getClickedAttributeCarriers() const
get vector with clicked ACs
GNEAttributeCarrier * getAttributeCarrierFront() const
get front attribute carrier (or a pointer to nullptr if there isn&#39;t)
struct used to group all variables related with movement of single elements
bool editingNetElementShapes
flag to edit net element shapes
GNEViewNet * myViewNet
pointer to viewNet
FXMenuCheck * menuCheckShowGrid
menu check to show grid button
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:42
MFXCheckableButton * deleteButton
chekable button for edit mode delete
mode for editing tls
A single child window which contains a view of the simulation area.
Definition: GNEViewParent.h:72
Mode for editing stops.
mode for moving network elements
DemandEditMode demandEditMode
the current Demand edit mode
MFXCheckableButton * crossingButton
chekable button for edit mode crossing
std::vector< GNEAdditional * > myAdditionals
vector with the clicked additional elements
GNEPOI * getPOIFront() const
get front POI (or a pointer to nullptr if there isn&#39;t)
MFXCheckableButton * routeButton
chekable button for edit mode create routes
MFXCheckableButton * shapeButton
chekable button for edit mode shape
struct used to group all variables related with selecting using a square or polygon ...
std::vector< GNEAttributeCarrier * > myAttributeCarriers
vector with the clicked attribute carriers
GNEViewNet * myViewNet
pointer to viewNet
Mode for editing vehicles.
GNEDemandElement * getDemandElementFront() const
get front net element element (or a pointer to nullptr if there isn&#39;t)
FXMenuCheck * menuCheckShowDemandElements
menu check to show Demand Elements
FXMenuCheck * menuCheckHideConnections
menu check to hide connections in connect mode
mode for inspecting network elements
struct used to group all variables related with movement of groups of elements
Mode for editing additionals.
FXMenuCheck * menuCheckMoveElevation
menu check to apply movement to elevation
FXMenuCheck * menuCheckAutoOppositeEdge
menu check to create auto create opposite edge
Mode for editing vehicle types.
FXMenuCheck * menuCheckHideNonInspectedDemandElements
Hide non inspected demand elements.
MFXCheckableButton * vehicleButton
chekable button for edit mode create vehicles
This object is responsible for drawing a shape and for supplying a a popup menu. Messages are routete...
Definition: GNECrossing.h:45
GNEJunction * getJunctionFront() const
get front junction (or a pointer to nullptr if there isn&#39;t)
struct used to group all variables related with movement of groups of elements
bool startDrawing
whether we have started rectangle-selection
int myTestingHeight
Height of viewNet in testing mode.
GNEViewNet * myViewNet
pointer to viewNet
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:39
FXMenuCheck * menuCheckChainEdges
menu check to the endpoint for a created edge should be set as the new source
A list of positions.
Supermode currentSupermode
the current supermode
FXMenuCheck * menuCheckSelectEdges
menu check to select only edges
GNEPOI * myPOIToMove
the poi which position is being moved
GUIGlID getGlIDFront() const
get front GUI GL ID (or a pointer to nullptr if there isn&#39;t)
mode for creating new edges
GNEViewNet * myViewNet
pointer to viewNet
Mode for editing Polygons.
class used to group all variables related with objects under cursor after a click over view ...
struct used to group all variables related with testing
Definition: GNETAZ.h:35
GNELane * getLaneFront() const
get front lane (or a pointer to nullptr if there isn&#39;t)
std::vector< GNECrossing * > myCrossings
vector with the clicked crossings
void updateObjectUnderCursor(const std::vector< GUIGlObject *> &GUIGlObjects, GNEPoly *editedPolyShape)
update objects under cursor (Called only in onLeftBtnPress(...) function)
bool myTestingEnabled
flag to enable or disable testing mode
GNEEdge * getEdgeFront() const
get front edge (or a pointer to nullptr if there isn&#39;t)
GNEPoly * myPolyToMove
the poly of which geometry is being moved
mode for deleting network elements
void setCreatedJunction(GNEJunction *junction)
set created junction
std::vector< GNELane * > myLanes
vector with the clicked lanes
FXMenuCheck * menuCheckExtendSelection
menu check to extend to edge nodes
GNEAdditional * getAdditionalFront() const
get front additional element (or a pointer to nullptr if there isn&#39;t)
Mode for editing routes.
GNENetElement * getNetElementFront() const
get front net element (or a pointer to nullptr if there isn&#39;t)
std::vector< GNEJunction * > myJunctions
vector with the clicked junctions
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:50
unsigned int GUIGlID
Definition: GUIGlObject.h:43
GNEViewNet * myViewNet
pointer to viewNet
std::map< GNEEdge *, PositionVector > myMovedEdgesOriginShape
container used for move entire edges
Mode for editing person plan.
Position originalPositionInView
original position of geometry position (needed for commmit position changes)
struct used to group all variables related with edit shapes of NetElements
GNEViewNet * myViewNet
pointer to viewNet
std::vector< GNEEdge * > myEdges
vector with the clicked edges
Position selectionCorner1
firstcorner of the rectangle-selection
MFXCheckableButton * TAZButton
chekable button for edit mode TAZ
FXMenuCheck * menuCheckShowConnections
menu check to show connections
std::vector< GNENetElement * > myNetElements
vector with the clicked net elements
An Element which don&#39;t belongs to GNENet but has influency in the simulation.
Definition: GNEAdditional.h:47
MFXCheckableButton * vehicleTypeButton
chekable button for edit mode create vehicle type
FXMenuCheck * menuCheckShowJunctionBubble
menu check to show connection as buuble in "Move" mode.
MFXCheckableButton * additionalButton
chekable button for edit mode additional
MFXCheckableButton * moveButton
chekable button for edit mode move
FXEvent * myEventInfo
information of event
Demanding mode (Routes, Vehicles etc..)
MFXCheckableButton * stopButton
chekable button for edit mode create stops
std::vector< GNEPoly * > myPolys
vector with the clicked Polys
GNEViewNet * myViewNet
pointer to viewNet
GNEViewNet * myViewNet
pointer to viewNet
struct used to group all variables related with movement of groups of elements
GNEShape * getShapeFront() const
get front shape element (or a pointer to nullptr if there isn&#39;t)
MFXCheckableButton * personPlanButton
chekable button for edit mode create person plans
Position selectionCorner2
second corner of the rectangle-selection
struct used to group all variables related with Demand checkable Buttons
mode for inspecting demand elements
struct used to group all variables related with Supermodes
Supermode
enum for supermodes
mode for connecting lanes
Mode for editing person types.
GNEConnection * getConnectionFront() const
get front connection (or a pointer to nullptr if there isn&#39;t)
void swapLane2Edge()
swap lane to edge
std::vector< GNEDemandElement * > myDemandElements
vector with the clicked demand elements
NetworkEditMode networkEditMode
the current Network edit mode
std::vector< GNEPOI * > myPOIs
vector with the clicked POIs
DemandEditMode
enum for demand edit modes
FXMenuCheck * menuCheckHideShapes
Hide shapes (Polygons and POIs)
Position myRelativeClickedPosition
relative position of Clicked Position regarding to originalGeometryPointPosition (Used when user does...
std::map< GNEEdge *, MoveSingleElementValues * > myMovedEgdesGeometryPoints
container used for move GeometryPoints of edges
GNEPoly * getPolyFront() const
get front Poly (or a pointer to nullptr if there isn&#39;t)
struct used to group all variables related to view options in all supermodes
std::vector< GNEShape * > myShapes
vector with the clicked shape elements (Poly and POIs)
std::vector< GUIGlObject * > myGUIGlObjects
vector with the clicked GUIGlObjects
GNEViewNet * myViewNet
pointer to viewNet
MFXCheckableButton * prohibitionButton
checkable button for edit mode polygon
GNEDemandElement * myDemandElementToMove
the demand element which position is being moved
GUIGlObjectType getGlTypeFront() const
get front GUI GL object type (or a pointer to nullptr if there isn&#39;t)
mode for deleting demand elements
Network mode (Edges, junctions, etc..)
GNEViewNet * myViewNet
pointer to viewNet
bool selectingUsingRectangle
whether we have started rectangle-selection
Mode for editing person.
MFXCheckableButton * inspectButton
chekable button for edit mode inspect
struct used to group all variables related to view options in supermode Demand
GNEViewNet * myViewNet
pointer to viewNet
struct used to group all variables related with common chekable Buttons
empty super mode
An Element which don&#39;t belongs to GNENet but has influency in the simulation.
GNEEdge * myEdgeToMove
the edge of which geometry is being moved
FXMenuCheck * menuCheckLockPerson
Lock Person.
std::map< GNEJunction *, Position > myMovedJunctionOriginPositions
container used for move junctions
MFXCheckableButton * selectButton
chekable button for edit mode select
GNETAZ * myTAZToMove
the TAZ element which their Shape is being moved (it&#39;s the only additional with a shape instead a pos...