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-2023 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
25
26
27// ===========================================================================
28// class declarations
29// ===========================================================================
32class NBOwnTLDef;
33class GNEInternalLane;
34class GNETLSTable;
36
37// ===========================================================================
38// class definitions
39// ===========================================================================
45
46public:
47 // ===========================================================================
48 // class TLSJunction
49 // ===========================================================================
50
54
55 public:
57 TLSJunction(GNETLSEditorFrame* TLSEditorParent);
58
61
64
66 void setCurrentJunction(GNEJunction* junction);
67
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 onUpdTLSID(FXObject*, FXSelector, void*);
90
92 long onCmdChangeType(FXObject*, FXSelector, void*);
93
95 long onUpdTLSType(FXObject*, FXSelector, void*);
96
98 long onCmdToggleJoinTLS(FXObject*, FXSelector, void*);
99
101 long onUpdJoinTLS(FXObject*, FXSelector, void*);
102
104 long onCmdDisjoinTLS(FXObject*, FXSelector, void*);
105
107 long onUpdDisjoinTLS(FXObject*, FXSelector, void*);
108
110 long onCmdAcceptJoin(FXObject*, FXSelector, void*);
111
113 long onCmdCancelJoin(FXObject*, FXSelector, void*);
114
116
117 protected:
119 FOX_CONSTRUCTOR(TLSJunction)
120
121 private:
124
126 FXLabel* myJunctionIDLabel = nullptr;
127
130
133
136
139
142
144 FXHorizontalFrame* myJoinControlButtons = nullptr;
145
148
150 std::vector<std::string> mySelectedJunctionIDs;
151
153 std::vector<std::string> myOriginalSelectedJunctionIDs;
154 };
155
156 // ===========================================================================
157 // class TLSDefinition
158 // ===========================================================================
159
163
164 public:
166 TLSDefinition(GNETLSEditorFrame* TLSEditorParent);
167
170
172 void showTLSDefinition();
173
175 void hideTLSDefinition();
176
178 bool initTLSDefinitions();
179
181 void clearTLSDefinitions();
182
184 int getNumberOfPrograms() const;
185
187 int getNumberOfTLSDefinitions() const;
188
190 bool checkHaveModifications() const;
191
193 void markAsModified();
194
197
199 const std::string getCurrentTLSProgramID() const;
200
202 void discardChanges(const bool editJunctionAgain);
203
207 long onCmdCreate(FXObject*, FXSelector, void*);
208
210 long onUpdCreate(FXObject*, FXSelector, void*);
211
213 long onCmdDelete(FXObject*, FXSelector, void*);
214
216 long onCmdResetCurrentProgram(FXObject*, FXSelector, void*);
217
219 long onCmdResetAll(FXObject*, FXSelector, void*);
220
222 long onCmdDefSwitchTLSProgram(FXObject*, FXSelector, void*);
223
225 long onUpdTLSEnableModified(FXObject*, FXSelector, void*);
226
228 long onUpdTLSDisableModified(FXObject*, FXSelector, void*);
229
231 long onUpdTLSDisableResetAll(FXObject*, FXSelector, void*);
232
234 long onCmdSaveChanges(FXObject*, FXSelector, void*);
235
237 long onCmdDiscardChanges(FXObject*, FXSelector, void*);
238
240
241 protected:
243 FOX_CONSTRUCTOR(TLSDefinition)
244
245
246 void createTLS(GNEJunction* junction);
247
249 bool switchProgram();
250
251 private:
254
256 std::vector<NBTrafficLightDefinition*> myTLSDefinitions;
257
259 FXComboBox* myProgramComboBox;
260
263
265 FXButton* myCreateButton = nullptr;
266 };
267
268 // ===========================================================================
269 // class TLSAttributes
270 // ===========================================================================
271
275
276 public:
278 TLSAttributes(GNETLSEditorFrame* TLSEditorParent);
279
282
284 void showTLSAttributes();
285
287 void hideTLSAttributes();
288
290 void initTLSAttributes();
291
293 void clearTLSAttributes();
294
296 SUMOTime getOffset() const;
297
299 void setOffset(const SUMOTime& offset);
300
302 bool isValidOffset();
303
305 std::string getParameters() const;
306
308 void setParameters(const std::string& parameters);
309
311 bool isValidParameters();
312
315
318
320 const std::map<std::string, std::string>& getE1Detectors() const;
321
324
328 long onCmdSetOffset(FXObject*, FXSelector, void*);
329
331 long onUpdOffset(FXObject*, FXSelector, void*);
332
334 long onCmdSetParameters(FXObject*, FXSelector, void*);
335
337 long onCmdParametersDialog(FXObject*, FXSelector, void* ptr);
338
340 long onUpdParameters(FXObject*, FXSelector, void*);
341
343 long onCmdToggleDetectorMode(FXObject*, FXSelector, void* ptr);
344
346 long onUpdSetDetectorMode(FXObject*, FXSelector, void*);
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 };
376
377 // ===========================================================================
378 // class TLSPhases
379 // ===========================================================================
380
384
385 public:
387 TLSPhases(GNETLSEditorFrame* TLSEditorParent);
388
390 ~TLSPhases();
391
393 void showTLSPhases();
394
396 void hideTLSPhases();
397
400
402 GNETLSTable* getPhaseTable() const;
403
407 void initPhaseTable();
408
410 bool changePhaseValue(const int col, const int row, const std::string& value);
411
413 void addPhase(const int row, const char c = ' ');
414
416 void duplicatePhase(const int row);
417
419 void removePhase(const int row);
420
422 void movePhaseUp(const int row);
423
425 void movePhaseDown(const int row);
426
428 void updateTLSColoring();
429
433 long onCmdCleanStates(FXObject*, FXSelector, void*);
434
436 long onCmdAddUnusedStates(FXObject*, FXSelector, void*);
437
439 long onCmdGroupStates(FXObject*, FXSelector, void*);
440
442 long onCmdUngroupStates(FXObject*, FXSelector, void*);
443
445 long onUpdUngroupStates(FXObject*, FXSelector, void*);
446
448 long onUpdNeedsSingleDef(FXObject*, FXSelector, void*);
449
451 long onUpdNeedsDef(FXObject*, FXSelector, void*);
452
454 long onUpdNeedsDefAndPhase(FXObject*, FXSelector, void*);
455
457
458 protected:
460 FOX_CONSTRUCTOR(TLSPhases)
461
462 private:
465
468
471
473 void initNEMAPhaseTable();
474
476 int buildDefaultPhase(const int row);
477
479 bool setDuration(const int col, const int row, const std::string& value);
480
482 bool setState(const int col, const int row, const std::string& value);
483
485 bool setNext(const int row, const std::string &value);
486
488 bool setName(const int row, const std::string& value);
489
491 bool setMinDur(const int row, const std::string& value);
492
494 bool setMaxDur(const int row, const std::string& value);
495
497 bool setEarliestEnd(const int row, const std::string& value);
498
500 bool setLatestEnd(const int row, const std::string& value);
501
503 bool setVehExt(const int row, const std::string& value);
504
506 bool setYellow(const int row, const std::string& value);
507
509 bool setRed(const int row, const std::string& value);
510
512 void updateCycleDuration(const int col);
513
515 void updateStateSize(const int col);
516
519
522 };
523
524 // ===========================================================================
525 // class TLSFile
526 // ===========================================================================
527
528 class TLSFile : public MFXGroupBoxModule {
531
532 public:
534 TLSFile(GNETLSEditorFrame* TLSEditorParent);
535
537 ~TLSFile();
538
540 void showTLSFile();
541
543 void hideTLSFile();
544
548 long onCmdLoadTLSProgram(FXObject*, FXSelector, void*);
549
551 long onCmdSaveTLSProgram(FXObject*, FXSelector, void*);
552
554 long onUpdButtons(FXObject*, FXSelector, void*);
556
557 protected:
559 FOX_CONSTRUCTOR(TLSFile)
560
561 private:
564
566 std::string writeSUMOTime(SUMOTime steps);
567 };
568
573 GNETLSEditorFrame(GNEViewParent* viewParent, GNEViewNet* viewNet);
574
577
579 void show();
580
582 void frameWidthUpdated();
583
588 void editTLS(const Position& clickedPosition, const GNEViewNetHelper::ObjectsUnderCursor& objectsUnderCursor);
589
591 bool isTLSSaved();
592
594 bool parseTLSPrograms(const std::string& file);
595
597 void handleChange(GNEInternalLane* lane);
598
600 void handleMultiChange(GNELane* lane, FXObject* obj, FXSelector sel, void* data);
601
603 bool controlsEdge(GNEEdge* edge) const;
604
607
611 void editJunction(GNEJunction* junction);
612
615
618
621
622protected:
624 static SUMOTime getSUMOTime(const std::string& value);
625
627 static const std::string getSteps2Time(const SUMOTime value);
628
629private:
632
635
638
641
644
647
649 std::map<int, std::vector<GNEInternalLane*> > myInternalLanes;
650
653
655 void cleanup();
656
659
661 const NBTrafficLightLogic::PhaseDefinition& getPhase(const int index);
662
664 static std::string varDurString(SUMOTime dur);
665};
long long int SUMOTime
Definition GUI.h:36
An Element which don't belong to GNENet but has influence in the simulation.
A road/street connecting two junctions (netedit-version)
Definition GNEEdge.h:53
This object is responsible for drawing a shape and for supplying a a popup menu. Messages are routete...
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition GNELane.h:46
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.
long onUpdParameters(FXObject *, FXSelector, void *)
Called when the offset is updated.
MFXToggleButtonTooltip * mySetDetectorsToggleButton
toggle button for set detectors mode
bool isSetDetectorsToggleButtonEnabled() const
toggle button for set detectors mode
bool isValidParameters()
are current parameter valid
FXTextField * myOffsetTextField
the TextField for modifying offset
void disableE1DetectorMode()
disable detector mode
SUMOTime getOffset() const
get current offset in string format
long onUpdSetDetectorMode(FXObject *, FXSelector, void *)
Called when occurs an update of set detector mode.
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
long onUpdOffset(FXObject *, FXSelector, void *)
Called when the offset is updated.
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
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.
void createTLS(GNEJunction *junction)
FOX needs this.
void clearTLSDefinitions()
clear TLS Definitions
long onCmdDefSwitchTLSProgram(FXObject *, FXSelector, void *)
Called when the user switches a TLS.
std::vector< NBTrafficLightDefinition * > myTLSDefinitions
the list of Definitions for the current junction
long onUpdTLSDisableResetAll(FXObject *, FXSelector, void *)
Called when occurs an update of switch definition.
bool myHaveModifications
whether the current tls was modified
bool checkHaveModifications() const
check if current TLS was modified
void hideTLSDefinition()
hide TLSDefinition
long onCmdSaveChanges(FXObject *, FXSelector, void *)
Called when the user presses the save-Button.
long onCmdDiscardChanges(FXObject *, FXSelector, void *)
Called when the user presses the Cancel-button.
void markAsModified()
mark Program as modified
FXComboBox * myProgramComboBox
the comboBox for selecting the tl-definition to edit
const std::string getCurrentTLSProgramID() const
get current program ID
int getNumberOfTLSDefinitions() const
get number of TLS definitions
long onCmdResetCurrentProgram(FXObject *, FXSelector, void *)
Called when the user press button reset current TLS Program.
long onCmdDelete(FXObject *, FXSelector, void *)
Called when the user press button delete TLS Program.
int getNumberOfPrograms() const
get number of programs
void showTLSDefinition()
show TLSDefinition
long onUpdCreate(FXObject *, FXSelector, void *)
Called when occurs an update of create definition.
bool initTLSDefinitions()
init TLS Definitions
NBTrafficLightDefinition * getCurrentTLSDefinition() const
get current definition
long onCmdCreate(FXObject *, FXSelector, void *)
GNETLSEditorFrame * myTLSEditorParent
pointer to GNETLSEditorFrame parent
void discardChanges(const bool editJunctionAgain)
discard changes
long onUpdTLSEnableModified(FXObject *, FXSelector, void *)
Called when occurs an update of switch definition.
long onCmdResetAll(FXObject *, FXSelector, void *)
Called when the user press button reset all TLS Programs.
FXButton * myCreateButton
button for create new Traffic light program
long onUpdTLSDisableModified(FXObject *, FXSelector, void *)
Called when occurs an update of switch definition.
long onCmdLoadTLSProgram(FXObject *, FXSelector, void *)
std::string writeSUMOTime(SUMOTime steps)
convert SUMOTime into string
long onUpdButtons(FXObject *, FXSelector, void *)
enable buttons, only when a tlLogic is being edited
long onCmdSaveTLSProgram(FXObject *, FXSelector, void *)
save TLS Program to an additional file
GNETLSEditorFrame * myTLSEditorParent
FOX needs this.
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
FOX needs this.
FXHorizontalFrame * myJoinControlButtons
frame for accept/cancel buttons
const std::vector< std::string > & getSelectedJunctionIDs() const
get selected junction IDs
long onUpdTLSType(FXObject *, FXSelector, void *)
Called when occurs an update of modified.
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
long onUpdJoinTLS(FXObject *, FXSelector, void *)
Called when update join TLS.
MFXComboBoxIcon * myTLSTypeComboBox
ComboBox for TLS Types.
MFXToggleButtonTooltip * myJoinTLSToggleButton
Toggle button for join TLS.
void updateJunctionDescription()
update junction description
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
long onUpdDisjoinTLS(FXObject *, FXSelector, void *)
Called when update join TLS.
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)
MFXButtonTooltip * myDisjoinTLSButton
button for disjoin TLS
bool isJoiningJunctions() const
is joining junctions
MFXTextFieldTooltip * myTLSIDTextField
text field for junction ID
long onUpdTLSID(FXObject *, FXSelector, void *)
Called when occurs an update of modified.
MFXTextFieldTooltip * myJunctionIDTextField
text field for junction ID
bool setEarliestEnd(const int row, const std::string &value)
set earliestEnd
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.
bool setVehExt(const int row, const std::string &value)
set vehExt
int buildDefaultPhase(const int row)
build default phase
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.)
long onUpdNeedsSingleDef(FXObject *, FXSelector, void *)
Called to buttons that modify link indices.
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
void updateStateSize(const int col)
update state size
long onCmdAddUnusedStates(FXObject *, FXSelector, void *)
Called when the user cleans up states.
void initStaticPhaseTable()
FOX needs this.
GNETLSEditorFrame * myTLSEditorParent
pointer to TLSEditor Parent
long onUpdUngroupStates(FXObject *, FXSelector, void *)
Called to update the ungroups states button.
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
long onUpdNeedsDef(FXObject *, FXSelector, void *)
enable buttons, only when a tlLogic is being edited
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
long onUpdNeedsDefAndPhase(FXObject *, FXSelector, void *)
Called when occurs an update of needs definition and phase.
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
GNETLSEditorFrame::TLSFile * myTLSFile
module for load/Save TLS Programs
void handleChange(GNEInternalLane *lane)
update phase definition for the current traffic light and phase
GNEOverlappedInspection * myOverlappedInspection
Overlapped Inspection.
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::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 the the current junction indexed by their tl-index
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::TLSDefinition * myTLSDefinition
module for TLS Definition
GNETLSEditorFrame::TLSJunction * getTLSJunction() const
get module for TLS Junction
static SUMOTime getSUMOTime(const std::string &value)
converts to SUMOTime
~GNETLSEditorFrame()
Destructor.
NBLoadedSUMOTLDef * myEditedDef
the traffic light definition being edited
void frameWidthUpdated()
function called after setting new width in current frame
GNETLSEditorFrame::TLSJunction * myTLSJunction
module for TLS Junction
void editTLS(const Position &clickedPosition, const GNEViewNetHelper::ObjectsUnderCursor &objectsUnderCursor)
edits the traffic light for the given clicked junction
void cleanup()
cleans up previous lanes
GNETLSEditorFrame::TLSDefinition * getTLSDefinition() const
get module for TLS Definition
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.
ComboBox with icon.
MFXGroupBoxModule (based on FXGroupBox)
A loaded (complete) traffic light logic.
A traffic light logics which must be computed (only nodes/edges are given)
Definition NBOwnTLDef.h:44
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