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