Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
GNETLSEditorFrame.h
Go to the documentation of this file.
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/****************************************************************************/
18// The Widget for modifying traffic lights
19/****************************************************************************/
20#pragma once
21#include <config.h>
22
27
28// ===========================================================================
29// class declarations
30// ===========================================================================
31
33class GNETLSTable;
34class MFXComboBoxIcon;
39
40// ===========================================================================
41// class definitions
42// ===========================================================================
43
45
46public:
47 // ===========================================================================
48 // class TLSJunction
49 // ===========================================================================
50
54
55 public:
57 TLSJunction(GNETLSEditorFrame* TLSEditorParent);
58
61
63 void updateTLSJunction();
64
67
69 void setCurrentJunction(GNEJunction* junction);
70
72 bool isJoiningJunctions() const;
73
75 bool isJunctionSelected(const GNEJunction* junction) const;
76
78 void toggleJunctionSelected(const GNEJunction* junction);
79
81 const std::vector<std::string>& getSelectedJunctionIDs() const;
82
86 long onCmdRenameTLS(FXObject*, FXSelector, void*);
87
89 long onCmdChangeType(FXObject*, FXSelector, void*);
90
92 long onCmdToggleJoinTLS(FXObject*, FXSelector, void*);
93
95 long onCmdDisjoinTLS(FXObject*, FXSelector, void*);
96
98 long onCmdAcceptJoin(FXObject*, FXSelector, void*);
99
101 long onCmdCancelJoin(FXObject*, FXSelector, void*);
102
104
105 protected:
107 FOX_CONSTRUCTOR(TLSJunction)
108
109
110 void refreshTLSJunction();
111
112 private:
115
117 FXLabel* myJunctionIDLabel = nullptr;
118
121
124
127
130
133
135 FXHorizontalFrame* myJoinControlButtons = nullptr;
136
139
141 std::vector<std::string> mySelectedJunctionIDs;
142
144 std::vector<std::string> myOriginalSelectedJunctionIDs;
145
147 TLSJunction(const TLSJunction&) = delete;
148
151 };
152
153 // ===========================================================================
154 // class TLSPrograms
155 // ===========================================================================
156
160
161 public:
163 TLSPrograms(GNETLSEditorFrame* TLSEditorParent);
164
166 ~TLSPrograms();
167
169 void updateTLSPrograms();
170
172 void showTLSPrograms();
173
175 void hideTLSPrograms();
176
178 bool initTLSPrograms();
179
181 void clearTLSProgramss();
182
184 int getNumberOfPrograms() const;
185
187 bool checkHaveModifications() const;
188
190 void markAsModified();
191
194
196 const std::string getCurrentTLSProgramID() const;
197
199 void discardChanges(const bool editJunctionAgain);
200
204 long onCmdCreate(FXObject*, FXSelector, void*);
205
207 long onCmdDelete(FXObject*, FXSelector, void*);
208
210 long onCmdResetCurrentProgram(FXObject*, FXSelector, void*);
211
213 long onCmdResetAll(FXObject*, FXSelector, void*);
214
216 long onCmdDefSwitchTLSProgram(FXObject*, FXSelector, void*);
217
219 long onCmdSaveChanges(FXObject*, FXSelector, void*);
220
222 long onCmdDiscardChanges(FXObject*, FXSelector, void*);
223
225
226 protected:
228 FOX_CONSTRUCTOR(TLSPrograms)
229
230
231 void createTLS(GNEJunction* junction);
232
234 bool switchProgram();
235
236 private:
239
241 std::vector<NBTrafficLightDefinition*> myTLSPrograms;
242
245
248
250 FXButton* myCreateButton = nullptr;
251
253 FXButton* myDeleteButton = nullptr;
254
256 FXButton* myResetSingleButton = nullptr;
257
259 FXButton* myResetAllButton = nullptr;
260
262 FXButton* mySaveButon = nullptr;
263
265 FXButton* myCancelButon = nullptr;
266
268 TLSPrograms(const TLSPrograms&) = delete;
269
272 };
273
274 // ===========================================================================
275 // class TLSAttributes
276 // ===========================================================================
277
281
282 public:
284 TLSAttributes(GNETLSEditorFrame* TLSEditorParent);
285
288
290 void updateTLSAttributes();
291
293 void showTLSAttributes();
294
296 void hideTLSAttributes();
297
299 void initTLSAttributes();
300
302 void clearTLSAttributes();
303
305 SUMOTime getOffset() const;
306
308 void setOffset(const SUMOTime& offset);
309
311 bool isValidOffset();
312
314 std::string getParameters() const;
315
317 void setParameters(const std::string& parameters);
318
320 bool isValidParameters();
321
324
327
329 const std::map<std::string, std::string>& getE1Detectors() const;
330
333
337 long onCmdSetOffset(FXObject*, FXSelector, void*);
338
340 long onCmdSetParameters(FXObject*, FXSelector, void*);
341
343 long onCmdParametersDialog(FXObject*, FXSelector, void* ptr);
344
346 long onCmdToggleDetectorMode(FXObject*, FXSelector, void* ptr);
347
349
350 protected:
352 FOX_CONSTRUCTOR(TLSAttributes)
353
354
355 void updateE1Detectors();
356
357 private:
360
362 FXTextField* myOffsetTextField = nullptr;
363
365 FXButton* myButtonEditParameters = nullptr;
366
368 FXTextField* myParametersTextField = nullptr;
369
372
374 std::map<std::string, std::string> myE1Detectors;
375
377 TLSAttributes(const TLSAttributes&) = delete;
378
381 };
382
383 // ===========================================================================
384 // class TLSPhases
385 // ===========================================================================
386
390
391 public:
393 TLSPhases(GNETLSEditorFrame* TLSEditorParent);
394
396 ~TLSPhases();
397
399 void updateTLSPhases();
400
402 void showTLSPhases();
403
405 void hideTLSPhases();
406
409
411 GNETLSTable* getPhaseTable() const;
412
416 void initPhaseTable();
417
419 void clearPhaseTable();
420
422 bool changePhaseValue(const int col, const int row, const std::string& value);
423
425 void addPhase(const int row, const char c = ' ');
426
428 void duplicatePhase(const int row);
429
431 void removePhase(const int row);
432
434 void movePhaseUp(const int row);
435
437 void movePhaseDown(const int row);
438
440 void updateTLSColoring();
441
445 long onCmdCleanStates(FXObject*, FXSelector, void*);
446
448 long onCmdAddUnusedStates(FXObject*, FXSelector, void*);
449
451 long onCmdGroupStates(FXObject*, FXSelector, void*);
452
454 long onCmdUngroupStates(FXObject*, FXSelector, void*);
455
457
458 protected:
460 FOX_CONSTRUCTOR(TLSPhases)
461
462
464
465 private:
468
471
474
476 void initNEMAPhaseTable();
477
479 int buildDefaultPhase(const int row);
480
482 bool setDuration(const int col, const int row, const std::string& value);
483
485 bool setState(const int col, const int row, const std::string& value);
486
488 bool setNext(const int row, const std::string& value);
489
491 bool setName(const int row, const std::string& value);
492
494 bool setMinDur(const int row, const std::string& value);
495
497 bool setMaxDur(const int row, const std::string& value);
498
500 bool setEarliestEnd(const int row, const std::string& value);
501
503 bool setLatestEnd(const int row, const std::string& value);
504
506 bool setVehExt(const int row, const std::string& value);
507
509 bool setYellow(const int row, const std::string& value);
510
512 bool setRed(const int row, const std::string& value);
513
515 void updateCycleDuration(const int col);
516
518 void updateStateSize(const int col);
519
522
525
528
531
534
537
539 TLSPhases(const TLSPhases&) = delete;
540
542 TLSPhases& operator=(const TLSPhases&) = delete;
543 };
544
545 // ===========================================================================
546 // class TLSFile
547 // ===========================================================================
548
552
553 public:
555 TLSFile(GNETLSEditorFrame* TLSEditorParent);
556
558 ~TLSFile();
559
561 void updateTLSFile();
562
564 void showTLSFile();
565
567 void hideTLSFile();
568
571
573 long onCmdLoadTLSProgram(FXObject*, FXSelector, void*);
574
576 long onCmdSaveTLSProgram(FXObject*, FXSelector, void*);
577
579
580 protected:
582 FOX_CONSTRUCTOR(TLSFile)
583
584
585 std::string writeSUMOTime(SUMOTime steps);
586
587 private:
590
592 FXButton* myLoadButton = nullptr;
593
595 FXButton* mySaveButton = nullptr;
596
598 TLSFile(const TLSFile&) = delete;
599
601 TLSFile& operator=(const TLSFile&) = delete;
602 };
603
608 GNETLSEditorFrame(GNEViewParent* viewParent, GNEViewNet* viewNet);
609
612
614 void show();
615
617 void frameWidthUpdated();
618
620 void updateModules();
621
626 void editTLS(GNEViewNetHelper::ViewObjectsSelector& viewObjects, const Position& clickedPosition, const bool shiftKeyPressed);
627
629 bool isTLSSaved();
630
632 bool parseTLSPrograms(const std::string& file);
633
635 void handleChange(GNEInternalLane* lane);
636
638 void handleMultiChange(GNELane* lane, FXObject* obj, FXSelector sel, void* data);
639
641 bool controlsEdge(GNEEdge* edge) const;
642
645
649 void editJunction(GNEJunction* junction);
650
653
656
659
662
663protected:
665 static SUMOTime getSUMOTime(const std::string& value);
666
668 static const std::string getSteps2Time(const SUMOTime value);
669
670private:
673
676
679
682
685
688
690 std::map<int, std::vector<GNEInternalLane*> > myInternalLanes;
691
694
696 void cleanup();
697
700
702 const NBTrafficLightLogic::PhaseDefinition& getPhase(const int index);
703
705 static std::string varDurString(SUMOTime dur);
706
709
712};
long long int SUMOTime
Definition GUI.h:36
long onCmdSetParameters(FXObject *, FXSelector, void *)
Called when the user changes parameters of a TLS.
long onCmdSetOffset(FXObject *, FXSelector, void *)
bool isValidOffset()
is current offset valid
long onCmdParametersDialog(FXObject *, FXSelector, void *ptr)
Called when user press edit parameters button.
MFXToggleButtonTooltip * mySetDetectorsToggleButton
toggle button for set detectors mode
bool isSetDetectorsToggleButtonEnabled() const
toggle button for set detectors mode
bool isValidParameters()
are current parameter valid
void updateTLSAttributes()
update TLSAttributes module
FXTextField * myOffsetTextField
the TextField for modifying offset
TLSAttributes(const TLSAttributes &)=delete
Invalidated copy constructor.
void disableE1DetectorMode()
disable detector mode
SUMOTime getOffset() const
get current offset in string format
void setParameters(const std::string &parameters)
set new parameters
const std::map< std::string, std::string > & getE1Detectors() const
get E1 detectors vinculated with this TLS
void clearTLSAttributes()
clear TLS attributes
void setOffset(const SUMOTime &offset)
set new offset
std::map< std::string, std::string > myE1Detectors
set with E1 detector IDs and their lanes vinculated with the TLS <laneID, E1ID>
std::string getParameters() const
get current parameters in string format
bool toggleE1DetectorSelection(const GNEAdditional *E1)
select or unselect E1 detector in the current TLS
void initTLSAttributes()
initializes the definitions and corresponding listbox
TLSAttributes & operator=(const TLSAttributes &)=delete
Invalidated assignment operator.
FXButton * myButtonEditParameters
button for edit parameters
FXTextField * myParametersTextField
the TextField for modifying parameters
void hideTLSAttributes()
hide TLSAttributes
void showTLSAttributes()
show TLSAttributes
GNETLSEditorFrame * myTLSEditorParent
pointer to TLSEditorParent
long onCmdToggleDetectorMode(FXObject *, FXSelector, void *ptr)
Called when user toggle set detector mode.
TLSFile & operator=(const TLSFile &)=delete
Invalidated assignment operator.
TLSFile(const TLSFile &)=delete
Invalidated copy constructor.
GNETLSEditorFrame * myTLSEditorParent
pointer to TLSEditor Parent
long onCmdChangeType(FXObject *, FXSelector, void *)
Called when the user change TLS Type.
long onCmdDisjoinTLS(FXObject *, FXSelector, void *)
Called when the user join TLS.
std::vector< std::string > mySelectedJunctionIDs
selected junction (used for join)
GNETLSEditorFrame * myTLSEditorParent
TLS editor frame parent.
void refreshTLSJunction()
FOX needs this.
FXHorizontalFrame * myJoinControlButtons
frame for accept/cancel buttons
const std::vector< std::string > & getSelectedJunctionIDs() const
get selected junction IDs
long onCmdToggleJoinTLS(FXObject *, FXSelector, void *)
Called when the user join TLS.
std::vector< std::string > myOriginalSelectedJunctionIDs
original selected junction (used for join)
long onCmdRenameTLS(FXObject *, FXSelector, void *)
long onCmdCancelJoin(FXObject *, FXSelector, void *)
cancel join
MFXComboBoxIcon * myTLSTypeComboBox
ComboBox for TLS Types.
MFXToggleButtonTooltip * myJoinTLSToggleButton
Toggle button for join TLS.
void updateTLSJunction()
update TLSJunction module
TLSJunction & operator=(const TLSJunction &)=delete
Invalidated assignment operator.
void toggleJunctionSelected(const GNEJunction *junction)
select or unselect junction in the current TLS
long onCmdAcceptJoin(FXObject *, FXSelector, void *)
accept join
GNEJunction * getCurrentJunction() const
get current modified junction
void setCurrentJunction(GNEJunction *junction)
set current junction
TLSJunction(const TLSJunction &)=delete
Invalidated copy constructor.
FXLabel * myJunctionIDLabel
label for junction ID
GNEJunction * myCurrentJunction
the junction of the tls is being modified
bool isJunctionSelected(const GNEJunction *junction) const
check if given junction is selected (used fo joining)
MFXTextFieldIcon * myJunctionIDTextField
text field for junction ID
MFXButtonTooltip * myDisjoinTLSButton
button for disjoin TLS
bool isJoiningJunctions() const
is joining junctions
MFXTextFieldIcon * myTLSIDTextField
text field for junction ID
bool setEarliestEnd(const int row, const std::string &value)
set earliestEnd
void updateTable()
FOX needs this.
long onCmdUngroupStates(FXObject *, FXSelector, void *)
Called when the user ungroups states.
GNETLSTable * myPhaseTable
table for selecting and rearranging phases and for changing duration
long onCmdCleanStates(FXObject *, FXSelector, void *)
long onCmdGroupStates(FXObject *, FXSelector, void *)
Called when the user groups states.
void clearPhaseTable()
clear phase thable
MFXButtonTooltip * myGroupSignalsButton
group signals button
bool setVehExt(const int row, const std::string &value)
set vehExt
MFXButtonTooltip * myAddStates
add states button
int buildDefaultPhase(const int row)
build default phase
void updateTLSPhases()
update TLSPhases module
void movePhaseDown(const int row)
move phase down
void initActuatedPhaseTable()
init actuated phase table
void initPhaseTable()
initializes the phase table
void initNEMAPhaseTable()
init NEMA phase table
bool setYellow(const int row, const std::string &value)
set yellow
bool changePhaseValue(const int col, const int row, const std::string &value)
change phase value (state, name, next, etc.)
void initDelayBasePhaseTable()
init delayBase phase table
void movePhaseUp(const int row)
move phase up
bool setMinDur(const int row, const std::string &value)
set minDur
bool setLatestEnd(const int row, const std::string &value)
set latestEnd
MFXButtonTooltip * myCleanStatesButton
clean states button
void updateStateSize(const int col)
update state size
MFXButtonTooltip * myUngroupSignalsButton
ungroup signals button
long onCmdAddUnusedStates(FXObject *, FXSelector, void *)
Called when the user cleans up states.
void initStaticPhaseTable()
init static phase table
GNETLSEditorFrame * myTLSEditorParent
pointer to TLSEditor Parent
bool setDuration(const int col, const int row, const std::string &value)
set duration
bool setMaxDur(const int row, const std::string &value)
set maxDur
void updateTLSColoring()
update TLS coloring
GNETLSTable * getPhaseTable() const
get phase table
void removePhase(const int row)
delete phase
bool setRed(const int row, const std::string &value)
set red
bool setName(const int row, const std::string &value)
set name
bool setState(const int col, const int row, const std::string &value)
set state
void duplicatePhase(const int row)
duplicate phase
void addPhase(const int row, const char c=' ')
add phase
GNETLSEditorFrame * getTLSEditorParent() const
get TLSEditor Parent
bool setNext(const int row, const std::string &value)
set next
void updateCycleDuration(const int col)
recomputes cycle duration and updates label
bool checkHaveModifications() const
check if current TLS was modified
FXButton * mySaveButon
button for save TLS program
void updateTLSPrograms()
update TLSPrograms module
bool initTLSPrograms()
init TLS Definitions
long onCmdDefSwitchTLSProgram(FXObject *, FXSelector, void *)
Called when the user switches a TLS.
MFXComboBoxIcon * myProgramComboBox
the comboBox for selecting the tl-definition to edit
GNETLSEditorFrame * myTLSEditorParent
pointer to GNETLSEditorFrame parent
FXButton * myCancelButon
button for cancel TLS program
void clearTLSProgramss()
clear TLS Definitions
int getNumberOfPrograms() const
get number of programs
long onCmdSaveChanges(FXObject *, FXSelector, void *)
Called when the user presses the save-Button.
void hideTLSPrograms()
hide TLSPrograms
void createTLS(GNEJunction *junction)
FOX needs this.
bool myHaveModifications
whether the current tls was modified
TLSPrograms(const TLSPrograms &)=delete
Invalidated copy constructor.
std::vector< NBTrafficLightDefinition * > myTLSPrograms
the list of Definitions for the current junction
FXButton * myDeleteButton
button for delete existent TLS program
long onCmdDiscardChanges(FXObject *, FXSelector, void *)
Called when the user presses the Cancel-button.
void discardChanges(const bool editJunctionAgain)
discard changes
long onCmdCreate(FXObject *, FXSelector, void *)
FXButton * myResetAllButton
button for reset all TLS program
long onCmdResetAll(FXObject *, FXSelector, void *)
Called when the user press button reset all TLS Programs.
FXButton * myResetSingleButton
button for reset TLS program
long onCmdResetCurrentProgram(FXObject *, FXSelector, void *)
Called when the user press button reset current TLS Program.
NBTrafficLightDefinition * getCurrentTLSPrograms() const
get current definition
TLSPrograms & operator=(const TLSPrograms &)=delete
Invalidated assignment operator.
void showTLSPrograms()
show TLSPrograms
void markAsModified()
mark Program as modified
long onCmdDelete(FXObject *, FXSelector, void *)
Called when the user press button delete TLS Program.
const std::string getCurrentTLSProgramID() const
get current program ID
FXButton * myCreateButton
button for create new TLS program
GNETLSEditorFrame::TLSFile * myTLSFile
module for load/Save TLS Programs
GNETLSEditorFrame::TLSPrograms * myTLSPrograms
module for TLS Definition
void handleChange(GNEInternalLane *lane)
update phase definition for the current traffic light and phase
GNEOverlappedInspection * myOverlappedInspection
Overlapped Inspection.
GNETLSEditorFrame::TLSPhases * getTLSPhases() const
get module for TLS Phases
GNETLSEditorFrame::TLSAttributes * getTLSAttributes() const
get module for TLS attributes
GNETLSEditorFrame::TLSAttributes * myTLSAttributes
module for TLS attributes
static std::string varDurString(SUMOTime dur)
convert duration (potentially undefined) to string
bool isTLSSaved()
check if modifications in TLS was saved
void editJunction(GNEJunction *junction)
edits the traffic light for the given junction
GNETLSEditorFrame(const GNETLSEditorFrame &)=delete
Invalidated copy constructor.
GNETLSEditorFrame::TLSPhases * myTLSPhases
module for TLS Phases
void selectedOverlappedElement(GNEAttributeCarrier *AC)
open GNEAttributesCreator extended dialog (can be reimplemented in frame children)
std::map< int, std::vector< GNEInternalLane * > > myInternalLanes
the internal lanes belonging to the current junction indexed by their tl-index
void updateModules()
update modules
bool parseTLSPrograms(const std::string &file)
parse TLS Programs from a file
bool controlsEdge(GNEEdge *edge) const
whether the given edge is controlled by the currently edited tlDef
static const std::string getSteps2Time(const SUMOTime value)
converts to SUMOTime
void buildInternalLanes(const NBTrafficLightDefinition *tlDef)
builds internal lanes for the given tlDef
const NBTrafficLightLogic::PhaseDefinition & getPhase(const int index)
get certain phase of the current traffic light
void handleMultiChange(GNELane *lane, FXObject *obj, FXSelector sel, void *data)
update phase definition for the current traffic light and phase
GNETLSEditorFrame::TLSJunction * getTLSJunction() const
get module for TLS Junction
static SUMOTime getSUMOTime(const std::string &value)
converts to SUMOTime
~GNETLSEditorFrame()
Destructor.
GNETLSEditorFrame & operator=(const GNETLSEditorFrame &)=delete
Invalidated assignment operator.
NBLoadedSUMOTLDef * myEditedDef
the traffic light definition being edited
void frameWidthUpdated()
function called after setting new width in current frame
void editTLS(GNEViewNetHelper::ViewObjectsSelector &viewObjects, const Position &clickedPosition, const bool shiftKeyPressed)
edits the traffic light for the given clicked junction
GNETLSEditorFrame::TLSJunction * myTLSJunction
module for TLS Junction
GNETLSEditorFrame::TLSPrograms * getTLSPrograms() const
get module for TLS Definition
void cleanup()
cleans up previous lanes
void show()
show inspector frame
class used to group all variables related with objects under cursor after a click over view
A single child window which contains a view of the simulation area.
MFXGroupBoxModule (based on FXGroupBox)
FXButton * mySaveButton
button for save elements
FXButton * myLoadButton
button for load elements
A loaded (complete) traffic light logic.
The base class for traffic light logic definitions.
The definition of a single phase of the logic.
A point in 2D or 3D with translation and scaling methods.
Definition Position.h:37
Definition json.hpp:4471
every row value