Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/netedit/GNENetHelper.h
193674 views
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
/****************************************************************************/
14
/// @file GNENetHelper.h
15
/// @author Pablo Alvarez Lopez
16
/// @date Mar 2020
17
///
18
// Helper for GNENet
19
//
20
/****************************************************************************/
21
#pragma once
22
#include <config.h>
23
24
#include <foreign/rtree/SUMORTree.h>
25
#include <netbuild/NBEdge.h>
26
#include <netbuild/NBTrafficLightLogicCont.h>
27
#include <netbuild/NBVehicle.h>
28
#include <netedit/changes/GNEChange.h>
29
#include <netedit/dialogs/GNEDialog.h>
30
#include <utils/common/IDSupplier.h>
31
#include <utils/common/SUMOVehicleClass.h>
32
#include <utils/foxtools/fxheader.h>
33
#include <utils/geom/Boundary.h>
34
#include <utils/geom/PositionVector.h>
35
#include <utils/geom/Triangle.h>
36
#include <utils/gui/globjects/GUIGlObject.h>
37
#include <utils/gui/globjects/GUIShapeContainer.h>
38
#include <utils/gui/settings/GUIVisualizationSettings.h>
39
#include <utils/router/SUMOAbstractRouter.h>
40
#include <utils/xml/SUMOXMLDefinitions.h>
41
42
// ===========================================================================
43
// class declarations
44
// ===========================================================================
45
46
class GNEAdditional;
47
class GNEApplicationWindow;
48
class GNEAttributeCarrier;
49
class GNEConnection;
50
class GNECrossing;
51
class GNEDataInterval;
52
class GNEDataSet;
53
class GNEDemandElement;
54
class GNEEdge;
55
class GNEEdgeType;
56
class FileBucket;
57
class GNEJunction;
58
class GNELane;
59
class GNELaneType;
60
class GNEMeanData;
61
class GNENet;
62
class GNENetworkElement;
63
class GNEPOI;
64
class GNEPoly;
65
class GNEUndoList;
66
class GNEViewNet;
67
class GNEWalkingArea;
68
class NBNetBuilder;
69
70
// ===========================================================================
71
// class definitions
72
// ===========================================================================
73
74
struct GNENetHelper {
75
76
/// @brief struct used for saving all attribute carriers of net, in different formats
77
class AttributeCarriers {
78
79
/// @brief declare friend class
80
friend class GNEAdditionalHandler;
81
friend class GNEChange_Additional;
82
friend class GNEChange_DataInterval;
83
friend class GNEChange_DataSet;
84
friend class GNEChange_DemandElement;
85
friend class GNEChange_Edge;
86
friend class GNEChange_EdgeType;
87
friend class GNEChange_GenericData;
88
friend class GNEChange_Junction;
89
friend class GNEChange_MeanData;
90
friend class GNEChange_Shape;
91
friend class GNEChange_TAZElement;
92
friend class GNEChange_TAZSourceSink;
93
friend class GNEDataHandler;
94
friend class GNEDataInterval;
95
friend class GNEDataSet;
96
friend class GNEDistributionRefDialog;
97
friend class GNEEdge;
98
friend class GNEJunction;
99
friend class GNEMeanDataHandler;
100
friend class GNERouteHandler;
101
friend class GNETLSEditorFrame;
102
103
public:
104
/// @brief constructor
105
AttributeCarriers(GNENet* net);
106
107
/// @brief destructor
108
~AttributeCarriers();
109
110
/// @brief remap junction and edge IDs
111
void remapJunctionAndEdgeIds();
112
113
/// @brief check if shape of given AC (network element) is around the given triangle
114
bool isNetworkElementAroundTriangle(GNEAttributeCarrier* AC, const Triangle& triangle) const;
115
116
/// @brief functions related with number of elements sorted by categories
117
/// @{
118
/// @brief get number of current network elements saved in AttributeCarriers
119
int getNumberOfNetworkElements() const;
120
121
/// @brief get number of current demand elements saved in AttributeCarriers (default vTypes are NOT included)
122
int getNumberOfDemandElements() const;
123
124
/// @brief get number of current data elements saved in AttributeCarriers
125
int getNumberOfDataElements() const;
126
127
/// @}
128
129
/// @name function for attribute carriers
130
/// @{
131
132
/**@brief get a single attribute carrier based on a GLID
133
* @param[in] ids the GL IDs for which to retrieve the AC
134
* @param[in] hardFail Whether attempts to retrieve a nonexisting AttributeCarrier should result in an exception
135
* @throws InvalidArgument if GL ID doesn't have a associated Attribute Carrier
136
*/
137
GNEAttributeCarrier* retrieveAttributeCarrier(const GUIGlID id, bool hardFail = true) const;
138
139
/**@brief get the attribute carriers based on Type
140
* @param[in] type The GUI-type of the AC. SUMO_TAG_NOTHING returns all elements (Warning: bottleneck)
141
* @note tag could not exist
142
*/
143
std::vector<GNEAttributeCarrier*> retrieveAttributeCarriers(SumoXMLTag tag = SUMO_TAG_NOTHING);
144
145
/// @brief get the attribute carriers based on supermode and selected
146
std::vector<GNEAttributeCarrier*> retrieveAttributeCarriers(Supermode supermode, const bool onlySelected);
147
148
/// @brief get all selected attribute carriers (or only relative to current supermode
149
std::vector<GNEAttributeCarrier*> getSelectedAttributeCarriers(const bool ignoreCurrentSupermode);
150
151
/// @}
152
153
/// @name function for junctions
154
/// @{
155
/**@brief get junction by id
156
* @param[in] id The id of the desired junction
157
* @param[in] hardFail Whether attempts to retrieve a nonexisting junction should result in an exception
158
* @throws UnknownElement
159
*/
160
GNEJunction* retrieveJunction(const std::string& id, bool hardFail = true) const;
161
162
/// @brief get junctions
163
const std::map<std::string, GNEJunction*>& getJunctions() const;
164
165
/// @brief return selected junctions
166
std::vector<GNEJunction*> getSelectedJunctions() const;
167
168
/// @brief registers a junction in containers
169
GNEJunction* registerJunction(GNEJunction* junction);
170
171
/// @brief clear junctions
172
void clearJunctions();
173
174
/// @brief add prefix to all junctions
175
void addPrefixToJunctions(const std::string& prefix);
176
177
/// @brief update junction ID in container
178
void updateJunctionID(GNEJunction* junction, const std::string& newID);
179
180
/// @brief get number of selected junctions
181
int getNumberOfSelectedJunctions() const;
182
183
/// @}
184
185
/// @name function for crossings
186
/// @{
187
/**@brief get Crossing by AC
188
* @param[in] glObject The GUIGlObject associated with the element
189
* @param[in] hardFail Whether attempts to retrieve a nonexisting Crossing should result in an exception
190
* @throws UnknownElement
191
*/
192
GNECrossing* retrieveCrossing(const GUIGlObject* glObject, bool hardFail = true) const;
193
194
/// @brief get crossings
195
const std::unordered_map<const GUIGlObject*, GNECrossing*>& getCrossings() const;
196
197
/// @brief return all selected crossings
198
std::vector<GNECrossing*> getSelectedCrossings() const;
199
200
/// @brief get number of selected crossings
201
int getNumberOfSelectedCrossings() const;
202
203
/// @}
204
205
/// @name function for walkingAreas
206
/// @{
207
/**@brief get WalkingArea by GlObject
208
* @param[in] glObject The GUIGlObject associated with the element
209
* @param[in] hardFail Whether attempts to retrieve a nonexisting WalkingArea should result in an exception
210
* @throws UnknownElement
211
*/
212
GNEWalkingArea* retrieveWalkingArea(const GUIGlObject* glObject, bool hardFail = true) const;
213
214
/// @brief get walkingAreas
215
const std::unordered_map<const GUIGlObject*, GNEWalkingArea*>& getWalkingAreas() const;
216
217
/// @brief return all selected walkingAreas
218
std::vector<GNEWalkingArea*> getSelectedWalkingAreas() const;
219
220
/// @brief get number of selected walkingAreas
221
int getNumberOfSelectedWalkingAreas() const;
222
223
/// @}
224
225
/// @name function for edgeTypes
226
/// @{
227
/**@brief get edge type by id
228
* @param[in] id The id of the desired edge type
229
* @param[in] hardFail Whether attempts to retrieve a nonexisting edge type should result in an exception
230
* @throws UnknownElement
231
*/
232
GNEEdgeType* retrieveEdgeType(const std::string& id, bool hardFail = true) const;
233
234
/// @brief registers a edge in containers
235
GNEEdgeType* registerEdgeType(GNEEdgeType* edgeType);
236
237
/// @brief map with the ID and pointer to edgeTypes of net
238
const std::map<std::string, GNEEdgeType*>& getEdgeTypes() const;
239
240
/// @brief clear edgeTypes
241
void clearEdgeTypes();
242
243
/// @brief update edgeType ID in container
244
void updateEdgeTypeID(GNEEdgeType* edgeType, const std::string& newID);
245
246
/// @brief generate edgeType id
247
std::string generateEdgeTypeID() const;
248
249
/// @}
250
251
/// @name function for edges
252
/// @{
253
/**@brief get edge by id
254
* @param[in] id The id of the desired edge
255
* @param[in] hardFail Whether attempts to retrieve a nonexisting edge should result in an exception
256
* @throws UnknownElement
257
*/
258
GNEEdge* retrieveEdge(const std::string& id, bool hardFail = true) const;
259
260
/**@brief get all edges by from and to GNEJunction
261
* @param[in] id The id of the desired edge
262
* @param[in] hardFail Whether attempts to retrieve a nonexisting edge should result in an exception
263
* @throws UnknownElement
264
*/
265
std::vector<GNEEdge*> retrieveEdges(GNEJunction* from, GNEJunction* to) const;
266
267
/// @brief map with the ID and pointer to edges of net
268
const std::map<std::string, GNEEdge*>& getEdges() const;
269
270
/**@brief return all edges
271
* @param[in] onlySelected Whether to return only selected edges
272
*/
273
std::vector<GNEEdge*> getSelectedEdges() const;
274
275
/// @brief registers an edge with containers
276
GNEEdge* registerEdge(GNEEdge* edge);
277
278
/// @brief clear edges
279
void clearEdges();
280
281
/// @brief add prefix to all edges
282
void addPrefixToEdges(const std::string& prefix);
283
284
/// @brief generate edge ID
285
std::string generateEdgeID() const;
286
287
/// @brief update edge ID in container
288
void updateEdgeID(GNEEdge* edge, const std::string& newID);
289
290
/// @brief get number of selected edges
291
int getNumberOfSelectedEdges() const;
292
293
/// @}
294
295
/// @name function for lanes
296
/// @{
297
/**@brief get lane by id
298
* @param[in] id The id of the desired lane
299
* @param[in] hardFail Whether attempts to retrieve a nonexisting lane should result in an exception
300
* @param[in] checkVolatileChange Used by additionals after recomputing with volatile options.
301
* @throws UnknownElement
302
*/
303
GNELane* retrieveLane(const std::string& id, bool hardFail = true, bool checkVolatileChange = false) const;
304
305
/**@brief get Lane by GlObject
306
* @param[in] glObject The GUIGlObject associated with the element
307
* @param[in] hardFail Whether attempts to retrieve a nonexisting Lane should result in an exception
308
* @throws UnknownElement
309
*/
310
GNELane* retrieveLane(const GUIGlObject* glObject, bool hardFail = true) const;
311
312
/// @brief get lanes
313
const std::unordered_map<const GUIGlObject*, GNELane*>& getLanes() const;
314
315
/// @brief get selected lanes
316
std::vector<GNELane*> getSelectedLanes() const;
317
318
/// @brief get number of selected lanes
319
int getNumberOfSelectedLanes() const;
320
321
/// @}
322
323
/// @name function for connections
324
/// @{
325
/**@brief get Connection by id
326
* @param[in] id The id of the desired Connection
327
* @param[in] hardFail Whether attempts to retrieve a nonexisting Connection should result in an exception
328
* @throws UnknownElement
329
*/
330
GNEConnection* retrieveConnection(const std::string& id, bool hardFail = true) const;
331
332
/**@brief get Connection by GUIGlObject
333
* @param[in] glObject The GUIGlObject associated with the element
334
* @param[in] hardFail Whether attempts to retrieve a nonexisting Connection should result in an exception
335
* @throws UnknownElement
336
*/
337
GNEConnection* retrieveConnection(const GUIGlObject* glObject, bool hardFail = true) const;
338
339
/// @brief get connections
340
const std::unordered_map<const GUIGlObject*, GNEConnection*>& getConnections() const;
341
342
/// @brief get selected connections
343
std::vector<GNEConnection*> getSelectedConnections() const;
344
345
/// @brief get number of selected connections
346
int getNumberOfSelectedConnections() const;
347
348
/// @}
349
350
/// @name function for internalLanes
351
/// @{
352
353
/**@brief get InternalLane by GUIGlObject
354
* @param[in] glObject The GUIGlObject associated with the element
355
* @param[in] hardFail Whether attempts to retrieve a nonexisting InternalLane should result in an exception
356
* @throws UnknownElement
357
*/
358
GNEInternalLane* retrieveInternalLane(const GUIGlObject* glObject, bool hardFail = true) const;
359
360
/// @}
361
362
/// @name function for additionals
363
/// @{
364
/**@brief Returns the named additional
365
* @param[in] id The attribute carrier related with the additional element
366
* @param[in] type tag with the type of additional
367
* @param[in] id The id of the additional to return.
368
* @param[in] hardFail Whether attempts to retrieve a nonexisting additional should result in an exception
369
*/
370
GNEAdditional* retrieveAdditional(SumoXMLTag type, const std::string& id, bool hardFail = true) const;
371
372
/**@brief Returns the named additional
373
* @param[in] id The attribute carrier related with the additional element
374
* @param[in] types tags with the type of additional
375
* @param[in] id The id of the additional to return.
376
* @param[in] hardFail Whether attempts to retrieve a nonexisting additional should result in an exception
377
*/
378
GNEAdditional* retrieveAdditionals(const std::vector<SumoXMLTag> types, const std::string& id, bool hardFail = true) const;
379
380
/**@brief Returns the named additional
381
* @param[in] glObject The GUIGlObject associated with the element
382
* @param[in] hardFail Whether attempts to retrieve a nonexisting additional should result in an exception
383
*/
384
GNEAdditional* retrieveAdditional(const GUIGlObject* glObject, bool hardFail = true) const;
385
386
/**@brief Returns the rerouter interval defined by given begin and end
387
* @param[in] rerouter ID
388
* @param[in] begin SUMOTime begin
389
* @param[in] end SUMOTime begin
390
*/
391
GNEAdditional* retrieveRerouterInterval(const std::string& rerouterID, const SUMOTime begin, const SUMOTime end) const;
392
393
/// @brief get additionals
394
const std::unordered_map<SumoXMLTag, std::unordered_map<const GUIGlObject*, GNEAdditional*>, std::hash<int> >& getAdditionals() const;
395
396
/// @brief get selected additionals
397
std::vector<GNEAdditional*> getSelectedAdditionals() const;
398
399
/// @brief get selected shapes
400
std::vector<GNEAdditional*> getSelectedShapes() const;
401
402
/// @brief get number of additionals
403
int getNumberOfAdditionals() const;
404
405
/// @brief clear additionals
406
void clearAdditionals();
407
408
/// @brief update additional ID in container
409
void updateAdditionalID(GNEAdditional* additional, const std::string& newID);
410
411
/// @brief generate additional id
412
std::string generateAdditionalID(SumoXMLTag type) const;
413
414
/// @brief get number of selected additionals (Including POIs, Polygons, TAZs and Wires)
415
int getNumberOfSelectedAdditionals() const;
416
417
/// @brief get number of selected pure additionals (Except POIs, Polygons, TAZs and Wires)
418
int getNumberOfSelectedPureAdditionals() const;
419
420
/// @brief get number of selected polygons
421
int getNumberOfSelectedPolygons() const;
422
423
/// @brief get number of selected walkable areas
424
int getNumberOfSelectedJpsWalkableAreas() const;
425
426
/// @brief get number of selected obstacles
427
int getNumberOfSelectedJpsObstacles() const;
428
429
/// @brief get number of selected POIs
430
int getNumberOfSelectedPOIs() const;
431
432
/// @brief get number of selected TAZs
433
int getNumberOfSelectedTAZs() const;
434
435
/// @brief get number of selected Wires
436
int getNumberOfSelectedWires() const;
437
438
/// @brief return list of available POI parameters
439
std::vector<std::string> getPOIParamKeys() const;
440
/// @}
441
442
/// @name function for TAZ sourceSinks
443
/// @{
444
/**@brief Returns the named sourceSink
445
* @param[in] sourceSink The GNETAZSourceSink to retrieve
446
* @param[in] hardFail Whether attempts to retrieve a nonexisting sourceSink should result in an exception
447
*/
448
GNETAZSourceSink* retrieveTAZSourceSink(const GNEAttributeCarrier* sourceSink, bool hardFail = true) const;
449
450
/// @brief get sourceSinks
451
const std::unordered_map<SumoXMLTag, std::unordered_map<const GNEAttributeCarrier*, GNETAZSourceSink*>, std::hash<int> >& getTAZSourceSinks() const;
452
453
/// @brief get number of TAZSourceSinks
454
int getNumberOfTAZSourceSinks() const;
455
456
/// @brief clear sourceSinks
457
void clearTAZSourceSinks();
458
459
/// @}
460
461
/// @name function for demand elements
462
/// @{
463
/**@brief Returns the named demand element
464
* @param[in] type tag with the type of demand element
465
* @param[in] id The id of the demand element to return.
466
* @param[in] hardFail Whether attempts to retrieve a nonexisting demand element should result in an exception
467
*/
468
GNEDemandElement* retrieveDemandElement(SumoXMLTag type, const std::string& id, bool hardFail = true) const;
469
470
/**@brief Returns the named demand element
471
* @param[in] types tag with the type of demand element
472
* @param[in] id The id of the demand element to return.
473
* @param[in] hardFail Whether attempts to retrieve a nonexisting demand element should result in an exception
474
*/
475
GNEDemandElement* retrieveDemandElements(const std::vector<SumoXMLTag> types, const std::string& id, bool hardFail = true) const;
476
477
/**@brief Returns the named demand
478
* @param[in] glObject The GUIGlObject associated with the element
479
* @param[in] hardFail Whether attempts to retrieve a nonexisting demand should result in an exception
480
*/
481
GNEDemandElement* retrieveDemandElement(const GUIGlObject* glObject, bool hardFail = true) const;
482
483
/// @brief get selected demand elements
484
std::vector<GNEDemandElement*> getSelectedDemandElements() const;
485
486
/// @brief get demand elements
487
const std::unordered_map<SumoXMLTag, std::unordered_map<const GUIGlObject*, GNEDemandElement*>, std::hash<int> >& getDemandElements() const;
488
489
/// @brief generate demand element id
490
std::string generateDemandElementID(SumoXMLTag tag) const;
491
492
/// @brief get default type
493
GNEDemandElement* getDefaultType() const;
494
495
/// @brief clear demand elements
496
void clearDemandElements();
497
498
/// @brief update demand element ID in container
499
void updateDemandElementID(GNEDemandElement* demandElement, const std::string& newID);
500
501
/// @brief add default VTypes
502
void addDefaultVTypes();
503
504
/// @brief check if we have elements that requires the option junction-taz
505
bool requireJunctionTazOption() const;
506
507
/// @brief get (and update) stop index
508
int getStopIndex();
509
510
/// @brief get number of selected demand elements
511
int getNumberOfSelectedDemandElements() const;
512
513
/// @brief get number of selected routes
514
int getNumberOfSelectedRoutes() const;
515
516
/// @brief get number of selected vehicles
517
int getNumberOfSelectedVehicles() const;
518
519
/// @brief get number of selected persons
520
int getNumberOfSelectedPersons() const;
521
522
/// @brief get number of selected person trips
523
int getNumberOfSelectedPersonTrips() const;
524
525
/// @brief get number of selected walks
526
int getNumberOfSelectedWalks() const;
527
528
/// @brief get number of selected rides
529
int getNumberOfSelectedRides() const;
530
531
/// @brief get number of selected containers
532
int getNumberOfSelectedContainers() const;
533
534
/// @brief get number of selected transports
535
int getNumberOfSelectedTransport() const;
536
537
/// @brief get number of selected tranships
538
int getNumberOfSelectedTranships() const;
539
540
/// @brief get number of selected stops
541
int getNumberOfSelectedStops() const;
542
543
/// @}
544
545
/// @name function for data sets
546
/// @{
547
/**@brief Returns the named data set
548
* @param[in] id The id of the data set to return.
549
* @param[in] hardFail Whether attempts to retrieve a nonexisting data set should result in an exception
550
*/
551
GNEDataSet* retrieveDataSet(const std::string& id, bool hardFail = true) const;
552
553
/// @brief get demand elements
554
const std::map<const std::string, GNEDataSet*>& getDataSets() const;
555
556
/// @brief generate data set id
557
std::string generateDataSetID() const;
558
559
/// @}
560
561
/// @name function for data intervals
562
/// @{
563
/**@brief Returns the data interval
564
* @param[in] id The attribute carrier related with the dataInterval element
565
* @param[in] hardFail Whether attempts to retrieve a nonexisting data set should result in an exception
566
*/
567
GNEDataInterval* retrieveDataInterval(const GNEAttributeCarrier* AC, bool hardFail = true) const;
568
569
/// @brief get all data intervals of network
570
const std::unordered_map<const GNEAttributeCarrier*, GNEDataInterval*>& getDataIntervals() const;
571
572
/// @}
573
574
/// @name function for generic datas
575
/// @{
576
/**@brief Returns the generic data
577
* @param[in] id The attribute carrier related with the genericData element
578
* @param[in] hardFail Whether attempts to retrieve a nonexisting data set should result in an exception
579
*/
580
GNEGenericData* retrieveGenericData(const GUIGlObject* glObject, bool hardFail = true) const;
581
582
/// @brief get selected generic datas
583
std::vector<GNEGenericData*> getSelectedGenericDatas() const;
584
585
/// @brief get all generic datas
586
const std::unordered_map<SumoXMLTag, std::unordered_map<const GUIGlObject*, GNEGenericData*>, std::hash<int> >& getGenericDatas() const;
587
588
/// @brief retrieve generic datas within the given interval
589
std::vector<GNEGenericData*> retrieveGenericDatas(const SumoXMLTag genericDataTag, const double begin, const double end);
590
591
/// @brief Return the number of generic datas
592
int getNumberOfGenericDatas() const;
593
594
/// @brief get number of selected edge datas
595
int getNumberOfSelectedEdgeDatas() const;
596
597
/// @brief get number of selected edge rel datas
598
int getNumberOfSelectedEdgeRelDatas() const;
599
600
/// @brief get number of selected edge TAZ Rels
601
int getNumberOfSelectedEdgeTAZRel() const;
602
603
/// @brief return a set of parameters for the given data Interval
604
std::set<std::string> retrieveGenericDataParameters(const std::string& genericDataTag, const double begin, const double end) const;
605
606
/// @brief return a set of parameters for the given dataSet, generic data Type, begin and end
607
std::set<std::string> retrieveGenericDataParameters(const std::string& dataSetID, const std::string& genericDataTag,
608
const std::string& beginStr, const std::string& endStr) const;
609
610
/// @}
611
612
/// @name function for meanDatas
613
/// @{
614
/**@brief Returns the named meanData
615
* @param[in] id The attribute carrier related with the meanData element
616
* @param[in] type tag with the type of meanData
617
* @param[in] id The id of the meanData to return.
618
* @param[in] hardFail Whether attempts to retrieve a nonexisting meanData should result in an exception
619
*/
620
GNEMeanData* retrieveMeanData(SumoXMLTag type, const std::string& id, bool hardFail = true) const;
621
622
/// @brief get meanDatas
623
const std::unordered_map<SumoXMLTag, std::map<const std::string, GNEMeanData*>, std::hash<int> >& getMeanDatas() const;
624
625
/// @brief get number of meanDatas
626
int getNumberOfMeanDatas() const;
627
628
/// @brief clear meanDatas
629
void clearMeanDatas();
630
631
/// @brief update meanData ID in container
632
void updateMeanDataID(GNEMeanData* meanData, const std::string& newID);
633
634
/// @brief generate meanData id
635
std::string generateMeanDataID(SumoXMLTag type) const;
636
637
/// @}
638
639
protected:
640
/// @name Junctions protected functions
641
/// @{
642
643
/// @brief insert junction in container
644
void insertJunction(GNEJunction* junction);
645
646
/// @brief delete junction from container
647
void deleteSingleJunction(GNEJunction* junction);
648
649
/// @}
650
651
/// @name edge types protected functions
652
/// @{
653
654
/// @brief insert edge type in container
655
void insertEdgeType(GNEEdgeType* edgeType);
656
657
/// @brief delete edge type from container
658
void deleteEdgeType(GNEEdgeType* edgeType);
659
660
/// @}
661
662
/// @name edges protected functions
663
/// @{
664
/// @brief insert edge in container
665
void insertEdge(GNEEdge* edge);
666
667
/// @brief delete edge from container
668
void deleteSingleEdge(GNEEdge* edge);
669
670
/// @}
671
672
/// @name lane protected functions
673
/// @{
674
675
/// @brief insert lane in container
676
void insertLane(GNELane* lane);
677
678
/// @brief delete lane from container
679
void deleteLane(GNELane* lane);
680
681
/// @}
682
683
/// @name crossing protected functions
684
/// @{
685
686
/// @brief insert crossing in container
687
void insertCrossing(GNECrossing* crossing);
688
689
/// @brief delete crossing from container
690
void deleteCrossing(GNECrossing* crossing);
691
692
/// @}
693
694
/// @name walking areas protected functions
695
/// @{
696
697
/// @brief insert walkingArea in container
698
void insertWalkingArea(GNEWalkingArea* walkingArea);
699
700
/// @brief delete walkingArea from container
701
void deleteWalkingArea(GNEWalkingArea* walkingArea);
702
703
/// @}
704
705
/// @name connection protected functions
706
/// @{
707
708
/// @brief insert connection in container
709
void insertConnection(GNEConnection* connection);
710
711
/// @brief delete connection from container
712
void deleteConnection(GNEConnection* connection);
713
714
/// @}
715
716
/// @name internalLane protected functions
717
/// @{
718
719
/// @brief insert internalLane in container
720
void insertInternalLane(GNEInternalLane* internalLane);
721
722
/// @brief delete internalLane from container
723
void deleteInternalLane(GNEInternalLane* internalLane);
724
725
/// @}
726
727
/// @name additionals protected functions
728
/// @{
729
730
/// @brief Insert a additional element in container.
731
void insertAdditional(GNEAdditional* additional);
732
733
/// @brief delete additional element of container
734
void deleteAdditional(GNEAdditional* additional);
735
736
/// @}
737
738
/// @name TAZ Source Sinks protected functions
739
/// @{
740
741
/// @brief Insert a sourceSink element in container.
742
void insertTAZSourceSink(GNETAZSourceSink* sourceSink);
743
744
/// @brief delete sourceSink element of container
745
void deleteTAZSourceSink(GNETAZSourceSink* sourceSink);
746
747
/// @}
748
749
/// @name demand elements protected functions
750
/// @{
751
752
/// @brief Insert a demand element in container.
753
void insertDemandElement(GNEDemandElement* demandElement);
754
755
/// @brief delete demand element of container
756
void deleteDemandElement(GNEDemandElement* demandElement, const bool updateFrames);
757
758
/// @}
759
760
/// @name datas protected functions
761
/// @{
762
763
/// @brief Insert a data set in container.
764
void insertDataSet(GNEDataSet* dataSet);
765
766
/// @brief delete data set of container
767
void deleteDataSet(GNEDataSet* dataSet);
768
769
/// @}
770
771
/// @name data intervals protected functions
772
/// @{
773
774
/// @brief insert data interval in container
775
void insertDataInterval(const GNEAttributeCarrier* AC, GNEDataInterval* dataInterval);
776
777
/// @brief delete data interval of container
778
void deleteDataInterval(GNEDataInterval* dataInterval);
779
780
/// @}
781
782
/// @name generic datas protected functions
783
/// @{
784
785
/// @brief insert generic data in container
786
void insertGenericData(GNEGenericData* genericData);
787
788
/// @brief delete generic data of container
789
void deleteGenericData(GNEGenericData* genericData);
790
791
/// @}
792
793
/// @name Insertion and erasing of GNEMeanDatas items
794
/// @{
795
796
/// @brief Insert a meanData element in container.
797
void insertMeanData(GNEMeanData* meanData);
798
799
/// @brief delete meanData element of container
800
void deleteMeanData(GNEMeanData* meanData);
801
802
/// @}
803
804
/// @brief update demand element frames (called after insert/delete demand element)
805
void updateDemandElementFrames(const GNETagProperties* tagProperty);
806
807
/// @brief retrieve attribute carriers recursively
808
void retrieveAttributeCarriersRecursively(const GNETagProperties* tag, std::vector<GNEAttributeCarrier*>& ACs);
809
810
private:
811
/// @brief pointer to net
812
GNENet* myNet;
813
814
/// @brief stop index
815
int myStopIndex;
816
817
/// @brief number of network elemements inserted in AttributeCarriers
818
int myNumberOfNetworkElements = 0;
819
820
/// @brief number of demand elemements inserted in AttributeCarriers (excluding default vTypes)
821
int myNumberOfDemandElements = 0;
822
823
/// @brief number of data elemements inserted in AttributeCarriers
824
int myNumberOfDataElements = 0;
825
826
/// @brief number of mean data elemements inserted in AttributeCarriers
827
int myNumberOfMeanDataElements = 0;
828
829
/// @brief map with the ID and pointer to junctions of net
830
std::map<std::string, GNEJunction*> myJunctions;
831
832
/// @brief set with crossings
833
std::unordered_map<const GUIGlObject*, GNECrossing*> myCrossings;
834
835
/// @brief set with walkingAreas
836
std::unordered_map<const GUIGlObject*, GNEWalkingArea*> myWalkingAreas;
837
838
/// @brief map with the ID and pointer to edgeTypes of net
839
std::map<std::string, GNEEdgeType*> myEdgeTypes;
840
841
/// @brief map with the ID and pointer to edges of net
842
std::map<std::string, GNEEdge*> myEdges;
843
844
/// @brief map with lanes
845
std::unordered_map<const GUIGlObject*, GNELane*> myLanes;
846
847
/// @brief map with connetions
848
std::unordered_map<const GUIGlObject*, GNEConnection*> myConnections;
849
850
/// @brief map with internal lanes
851
std::unordered_map<const GUIGlObject*, GNEInternalLane*> myInternalLanes;
852
853
/// @brief map with the tag and pointer to additional elements of net, sorted by IDs
854
std::unordered_map<SumoXMLTag, std::map<const std::string, GNEAdditional*>, std::hash<int> > myAdditionalIDs;
855
856
/// @brief map with the tag and pointer to additional elements of net
857
std::unordered_map<SumoXMLTag, std::unordered_map<const GUIGlObject*, GNEAdditional*>, std::hash<int> > myAdditionals;
858
859
/// @brief map with the tag and pointer to TAZSourceSinks elements of net
860
std::unordered_map<SumoXMLTag, std::unordered_map<const GNEAttributeCarrier*, GNETAZSourceSink*>, std::hash<int> > myTAZSourceSinks;
861
862
/// @brief map with the tag and pointer to demand elements of net, sorted by IDs
863
std::unordered_map<SumoXMLTag, std::map<const std::string, GNEDemandElement*>, std::hash<int> > myDemandElementIDs;
864
865
/// @brief map with the tag and pointer to demand elements elements of net
866
std::unordered_map<SumoXMLTag, std::unordered_map<const GUIGlObject*, GNEDemandElement*>, std::hash<int> > myDemandElements;
867
868
/// @brief map with the ID and pointer to all datasets of net
869
std::map<const std::string, GNEDataSet*> myDataSets;
870
871
/// @brief map with all data intervals of network
872
std::unordered_map<const GNEAttributeCarrier*, GNEDataInterval*> myDataIntervals;
873
874
/// @brief map with the tag and pointer to all generic datas
875
std::unordered_map<SumoXMLTag, std::unordered_map<const GUIGlObject*, GNEGenericData*>, std::hash<int> > myGenericDatas;
876
877
/// @brief map with the tag and pointer to meanData elements of net
878
std::unordered_map<SumoXMLTag, std::map<const std::string, GNEMeanData*>, std::hash<int> > myMeanDatas;
879
880
/// @brief Invalidated default constructor.
881
AttributeCarriers() = delete;
882
883
/// @brief Invalidated copy constructor.
884
AttributeCarriers(const AttributeCarriers&) = delete;
885
886
/// @brief Invalidated assignment operator.
887
AttributeCarriers& operator=(const AttributeCarriers&) = delete;
888
};
889
890
/// @brief modul for AC Templates
891
class ACTemplate {
892
893
public:
894
/// @brief constructor
895
ACTemplate(GNENet* net);
896
897
/// @brief build templates
898
void buildTemplates();
899
900
/// @brief destructor
901
~ACTemplate();
902
903
/// @brief get all AC templates
904
std::map<SumoXMLTag, GNEAttributeCarrier*> getACTemplates() const;
905
906
/// @brief get template AC by tag
907
GNEAttributeCarrier* getTemplateAC(const SumoXMLTag tag) const;
908
909
/// @brief get template AC by text (using selector text
910
GNEAttributeCarrier* getTemplateAC(const std::string& selectorText) const;
911
912
/// @brief get default edge type
913
GNEEdgeType* getDefaultEdgeType() const;
914
915
/// @brief get plan templates
916
const std::vector<std::pair<GNETagProperties*, GNEDemandElement*> >& getPlanTemplates(SumoXMLTag tag) const;
917
918
protected:
919
/// @brief fill plan templates
920
void fillPlanTemplates();
921
922
private:
923
/// @brief pointer to net
924
GNENet* myNet = nullptr;
925
926
/// @brief map with templates
927
std::map<SumoXMLTag, GNEAttributeCarrier*> myTemplates;
928
929
/// @brief list with demand templates
930
std::map<SumoXMLTag, std::vector<std::pair<GNETagProperties*, GNEDemandElement*> > > myPlanTemplates;
931
932
/// @brief edge type
933
GNEEdgeType* myEdgeType = nullptr;
934
935
/// @brief Invalidated default constructor.
936
ACTemplate() = delete;
937
938
/// @brief Invalidated copy constructor.
939
ACTemplate(const ACTemplate&) = delete;
940
941
/// @brief Invalidated assignment operator
942
ACTemplate& operator=(const ACTemplate& src) = delete;
943
};
944
945
/// @brief modul for Saving status
946
class SavingStatus {
947
948
public:
949
/// @brief constructor
950
SavingStatus(GNENet* net);
951
952
/// @name SumoConfig
953
/// @{
954
955
/// @brief inform that SumoConfig has to be saved
956
void requireSaveSumoConfig();
957
958
/// @brief mark SumoConfig as saved
959
void SumoConfigSaved();
960
961
/// @brief check if SumoConfig is saved
962
bool isSumoConfigSaved() const;
963
964
/// @}
965
966
/// @name NeteditConfig
967
/// @{
968
969
/// @brief inform that netedit config has to be saved
970
void requireSaveNeteditConfig();
971
972
/// @brief mark netedit config as saved
973
void neteditConfigSaved();
974
975
/// @brief check if netedit config is saved
976
bool isNeteditConfigSaved() const;
977
978
/// @}
979
980
/// @name network
981
/// @{
982
983
/// @brief inform that network has to be saved
984
void requireSaveNetwork();
985
986
/// @brief mark network as saved
987
void networkSaved();
988
989
/// @brief check if network is saved
990
bool isNetworkSaved() const;
991
992
/// @}
993
994
/// @name TLS
995
/// @{
996
997
/// @brief inform that TLS has to be saved
998
void requireSaveTLS();
999
1000
/// @brief mark TLS as saved
1001
void TLSSaved();
1002
1003
/// @brief check if TLS are saved
1004
bool isTLSSaved() const;
1005
1006
/// @}
1007
1008
/// @name edge types
1009
/// @{
1010
1011
/// @brief inform that edgeType has to be saved
1012
void requireSaveEdgeType();
1013
1014
/// @brief mark edgeType as saved
1015
void edgeTypeSaved();
1016
1017
/// @brief check if edgeType are saved
1018
bool isEdgeTypeSaved() const;
1019
1020
/// @}
1021
1022
/// @name additionals
1023
/// @{
1024
1025
/// @brief inform that additionals has to be saved
1026
void requireSaveAdditionals();
1027
1028
/// @brief mark additionals as saved
1029
void additionalsSaved();
1030
1031
/// @brief check if additionals are saved
1032
bool isAdditionalsSaved() const;
1033
1034
/// @}
1035
1036
/// @name demand elements
1037
/// @{
1038
1039
/// @brief inform that demand elements has to be saved
1040
void requireSaveDemandElements();
1041
1042
/// @brief mark demand elements as saved
1043
void demandElementsSaved();
1044
1045
/// @brief check if demand elements are saved
1046
bool isDemandElementsSaved() const;
1047
1048
/// @}
1049
1050
/// @name data elements
1051
/// @{
1052
1053
/// @brief inform that data elements has to be saved
1054
void requireSaveDataElements();
1055
1056
/// @brief mark demand elements as saved
1057
void dataElementsSaved();
1058
1059
/// @brief check if data elements are saved
1060
bool isDataElementsSaved() const;
1061
1062
/// @}
1063
1064
/// @name mean datas
1065
/// @{
1066
1067
/// @brief inform that mean data elements has to be saved
1068
void requireSaveMeanDatas();
1069
1070
/// @brief mark mean data elements as saved
1071
void meanDatasSaved();
1072
1073
/// @brief check if mean data elements are saved
1074
bool isMeanDatasSaved() const;
1075
1076
/// @}
1077
1078
/// @name function to ask if save elements before close/quit
1079
/// @{
1080
1081
/// @brief warns about unsaved changes in network and gives the user the option to abort
1082
GNEDialog::Result askSaveNetwork(GNEDialog::Result& commonResult) const;
1083
1084
/// @brief warns about unsaved changes in additionals and gives the user the option to abort
1085
GNEDialog::Result askSaveAdditionalElements(GNEDialog::Result& commonResult) const;
1086
1087
/// @brief warns about unsaved changes in demand elements and gives the user the option to abort
1088
GNEDialog::Result askSaveDemandElements(GNEDialog::Result& commonResult) const;
1089
1090
/// @brief warns about unsaved changes in data elements and gives the user the option to abort
1091
GNEDialog::Result askSaveDataElements(GNEDialog::Result& commonResult) const;
1092
1093
/// @brief warns about unsaved changes in meanData elements and gives the user the option to abort
1094
GNEDialog::Result askSaveMeanDataElements(GNEDialog::Result& commonResult) const;
1095
1096
/// @}
1097
1098
private:
1099
/// @brief pointer to net
1100
GNENet* myNet;
1101
1102
/// @brief flag for SumoConfigSumoConfig saved
1103
bool mySumoConfigSaved = true;
1104
1105
/// @brief flag for netedit config saved
1106
bool myNeteditConfigSaved = true;
1107
1108
/// @brief flag for network saved
1109
bool myNetworkSaved = true;
1110
1111
/// @brief flag for TLS saved
1112
bool myTLSSaved = true;
1113
1114
/// @brief flag for edgeType saved
1115
bool myEdgeTypeSaved = true;
1116
1117
/// @brief flag for additional elements saved
1118
bool myAdditionalSaved = true;
1119
1120
/// @brief flag for demand elements saved
1121
bool myDemandElementSaved = true;
1122
1123
/// @brief flag for data elements saved
1124
bool myDataElementSaved = true;
1125
1126
/// @brief flag for meanData elements saved
1127
bool myMeanDataElementSaved = true;
1128
1129
/// @brief invalidate default constructor
1130
SavingStatus() = delete;
1131
1132
/// @brief Invalidated copy constructor.
1133
SavingStatus(const SavingStatus&) = delete;
1134
1135
/// @brief Invalidated assignment operator.
1136
SavingStatus& operator=(const SavingStatus&) = delete;
1137
};
1138
1139
/// @brief class for GNEChange_ReplaceEdgeInTLS
1140
class GNEChange_ReplaceEdgeInTLS : public GNEChange {
1141
FXDECLARE_ABSTRACT(GNEChange_ReplaceEdgeInTLS)
1142
1143
public:
1144
/// @brief constructor
1145
GNEChange_ReplaceEdgeInTLS(NBTrafficLightLogicCont& tllcont, NBEdge* replaced, NBEdge* by);
1146
1147
/// @brief destructor
1148
~GNEChange_ReplaceEdgeInTLS();
1149
1150
/// @brief undo action
1151
void undo();
1152
1153
/// @brief redo action
1154
void redo();
1155
1156
/// @brief undo name
1157
std::string undoName() const;
1158
1159
/// @brief get Redo name
1160
std::string redoName() const;
1161
1162
/// @brief wether original and new value differ
1163
bool trueChange();
1164
1165
private:
1166
/// @brief container for traffic light logic
1167
NBTrafficLightLogicCont& myTllcont;
1168
1169
/// @brief replaced NBEdge
1170
NBEdge* myReplaced;
1171
1172
/// @brief replaced by NBEdge
1173
NBEdge* myBy;
1174
};
1175
};
1176
1177