Eclipse SUMO - Simulation of Urban MObility
GNETLSEditorFrame.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2020 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 
24 
25 // ===========================================================================
26 // class declarations
27 // ===========================================================================
29 class NBLoadedSUMOTLDef;
30 class NBOwnTLDef;
31 class GNEInternalLane;
32 
33 // ===========================================================================
34 // class definitions
35 // ===========================================================================
40 class GNETLSEditorFrame : public GNEFrame {
42  FXDECLARE(GNETLSEditorFrame)
43 
44 public:
45 
46  // ===========================================================================
47  // class TLSJunction
48  // ===========================================================================
49 
50  class TLSJunction : protected FXGroupBox {
51 
52  public:
54  TLSJunction(GNETLSEditorFrame* tlsEditorParent);
55 
57  ~TLSJunction();
58 
61 
63  void setCurrentJunction(GNEJunction* junction);
64 
66  void updateJunctionDescription() const;
67 
68  private:
71 
73  FXTextField* myTextFieldJunctionID;
74 
77  };
78 
79  // ===========================================================================
80  // class TLSDefinition
81  // ===========================================================================
82 
83  class TLSDefinition : protected FXGroupBox {
84 
85  public:
87  TLSDefinition(GNETLSEditorFrame* TLSEditorParent);
88 
91 
92  private:
94  FXButton* myNewTLProgram;
95 
97  FXButton* myDeleteTLProgram;
98  };
99 
100  // ===========================================================================
101  // class TLSAttributes
102  // ===========================================================================
103 
104  class TLSAttributes : protected FXGroupBox {
105 
106  public:
108  TLSAttributes(GNETLSEditorFrame* TLSEditorParent);
109 
111  ~TLSAttributes();
112 
114  void initTLSAttributes(GNEJunction* junction);
115 
117  void clearTLSAttributes();
118 
121 
123  SUMOTime getOffset() const;
124 
126  void setOffset(SUMOTime offset);
127 
129  int getNumberOfTLSDefinitions() const;
130 
132  int getNumberOfPrograms() const;
133 
134  private:
137 
139  std::vector<NBTrafficLightDefinition*> myTLSDefinitions;
140 
142  FXLabel* myNameLabel;
143 
145  FXTextField* myNameTextField;
146 
148  FXLabel* myProgramLabel;
149 
151  FXComboBox* myProgramComboBox;
152 
154  FXLabel* myOffsetLabel;
155 
157  FXTextField* myOffsetTextField;
158  };
159 
160  // ===========================================================================
161  // class TLSPhases
162  // ===========================================================================
163 
164  class TLSPhases : protected FXGroupBox {
165 
166  public:
168  TLSPhases(GNETLSEditorFrame* TLSEditorParent);
169 
171  ~TLSPhases();
172 
174  FXTable* getPhaseTable() const;
175 
179  void initPhaseTable(int index = 0);
180 
182  void showCycleDuration();
183 
185  void hideCycleDuration();
186 
188  void updateCycleDuration();
189 
190  private:
193 
195  FXFont* myTableFont;
196 
198  FXScrollWindow* myTableScroll;
199 
201  FXTable* myPhaseTable;
202 
204  FXLabel* myCycleDuration;
205 
208 
211  };
212 
213  // ===========================================================================
214  // class TLSModifications
215  // ===========================================================================
216 
217  class TLSModifications : protected FXGroupBox {
218 
219  public:
221  TLSModifications(GNETLSEditorFrame* TLSEditorParent);
222 
225 
227  bool checkHaveModifications() const;
228 
230  void setHaveModifications(bool value);
231 
232  private:
235 
238 
241 
244  };
245 
246  // ===========================================================================
247  // class TLSFile
248  // ===========================================================================
249 
250  class TLSFile : protected FXGroupBox {
252  FXDECLARE(GNETLSEditorFrame::TLSFile)
253 
254  public:
256  TLSFile(GNETLSEditorFrame* TLSEditorParent);
257 
259  ~TLSFile();
260 
264  long onCmdLoadTLSProgram(FXObject*, FXSelector, void*);
265 
267  long onCmdSaveTLSProgram(FXObject*, FXSelector, void*);
268 
270  long onUpdNeedsDef(FXObject*, FXSelector, void*);
272 
273  protected:
274  FOX_CONSTRUCTOR(TLSFile)
275 
276  private:
279 
282 
285 
287  std::string writeSUMOTime(SUMOTime steps);
288  };
289 
290 
295  GNETLSEditorFrame(FXHorizontalFrame* horizontalFrameParent, GNEViewNet* viewNet);
296 
299 
301  void show();
302 
307  void editTLS(const Position& clickedPosition, const GNEViewNetHelper::ObjectsUnderCursor& objectsUnderCursor);
308 
310  bool isTLSSaved();
311 
313  bool parseTLSPrograms(const std::string& file);
314 
319  long onCmdOK(FXObject*, FXSelector, void*);
320 
323  long onCmdCancel(FXObject*, FXSelector, void*);
324 
326  long onCmdToggle(FXObject*, FXSelector, void*);
327 
329  long onCmdGuess(FXObject*, FXSelector, void*);
330 
332  long onCmdDefCreate(FXObject*, FXSelector, void*);
333 
335  long onCmdDefDelete(FXObject*, FXSelector, void*);
336 
338  long onCmdDefOffset(FXObject*, FXSelector, void*);
339 
341  long onCmdDefSwitch(FXObject*, FXSelector, void*);
342 
344  long onCmdDefRename(FXObject*, FXSelector, void*);
345 
347  long onCmdDefSubRename(FXObject*, FXSelector, void*);
348 
350  long onCmdDefAddOff(FXObject*, FXSelector, void*);
351 
353  long onCmdPhaseSwitch(FXObject*, FXSelector, void*);
354 
356  long onCmdPhaseCreate(FXObject*, FXSelector, void*);
357 
359  long onCmdPhaseDelete(FXObject*, FXSelector, void*);
360 
362  long onCmdCleanup(FXObject*, FXSelector, void*);
363 
365  long onCmdAddUnused(FXObject*, FXSelector, void*);
366 
368  long onCmdGroupStates(FXObject*, FXSelector, void*);
369 
371  long onCmdUngroupStates(FXObject*, FXSelector, void*);
372 
374  long onUpdUngroupStates(FXObject*, FXSelector, void*);
375 
377  long onCmdPhaseEdit(FXObject*, FXSelector, void*);
378 
380  long onCmdMakeRILSAConforming(FXObject*, FXSelector, void*);
381 
383  long onUpdDefSwitch(FXObject*, FXSelector, void*);
384 
386  long onUpdNeedsDef(FXObject*, FXSelector, void*);
387 
389  long onUpdNeedsSingleDef(FXObject*, FXSelector, void*);
390 
392  long onUpdNeedsDefAndPhase(FXObject*, FXSelector, void*);
393 
395  long onUpdDefCreate(FXObject*, FXSelector, void*);
396 
398  long onUpdModified(FXObject*, FXSelector, void*);
400 
402  void handleChange(GNEInternalLane* lane);
403 
405  void handleMultiChange(GNELane* lane, FXObject* obj, FXSelector sel, void* data);
406 
408  bool controlsEdge(GNEEdge* edge) const;
409 
411  bool fixedDuration() const;
412 
415 
416 protected:
417  FOX_CONSTRUCTOR(GNETLSEditorFrame)
418 
419 
422  void editJunction(GNEJunction* junction);
423 
425  static SUMOTime getSUMOTime(const FXString& string);
426 
427 private:
430 
433 
436 
439 
442 
445 
448 
450  typedef std::map<int, std::vector<GNEInternalLane*> > TLIndexMap;
452 
455 
458 
460  void cleanup();
461 
464 
466  const std::vector<NBTrafficLightLogic::PhaseDefinition>& getPhases();
467 
469  static std::string varDurString(SUMOTime dur);
470 };
long long int SUMOTime
Definition: SUMOTime.h:31
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:49
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:45
void initTLSAttributes(GNEJunction *junction)
initializes the definitions and corresponding listbox
FXLabel * myProgramLabel
program label
FXTextField * myOffsetTextField
the control for modifying offset
int getNumberOfPrograms() const
get number of programs
SUMOTime getOffset() const
get current offset in SUMOTIme
void setOffset(SUMOTime offset)
set new offset
void clearTLSAttributes()
clear TLS attributes
FXComboBox * myProgramComboBox
the comboBox for selecting the tl-definition to edit
int getNumberOfTLSDefinitions() const
get number of definitions
TLSAttributes(GNETLSEditorFrame *TLSEditorParent)
constructor
NBTrafficLightDefinition * getCurrentTLSDefinition() const
get current definition
FXTextField * myNameTextField
name text field
FXLabel * myOffsetLabel
offset label
GNETLSEditorFrame * myTLSEditorParent
pointer to TLSEditorParent
std::vector< NBTrafficLightDefinition * > myTLSDefinitions
the list of Definitions for the current junction
FXButton * myNewTLProgram
button for create new Traffic light program
FXButton * myDeleteTLProgram
button for delete traffic light program
TLSDefinition(GNETLSEditorFrame *TLSEditorParent)
constructor
FXButton * mySaveTLSProgramButton
button for save TLS Programs
FXButton * myLoadTLSProgramButton
button for load TLS Programs
long onCmdLoadTLSProgram(FXObject *, FXSelector, void *)
TLSFile(GNETLSEditorFrame *TLSEditorParent)
FOX-declaration.
std::string writeSUMOTime(SUMOTime steps)
convert SUMOTime into string
long onCmdSaveTLSProgram(FXObject *, FXSelector, void *)
save TLS Programm to an additional file
GNETLSEditorFrame * myTLSEditorParent
pointer to TLSEditor Parent
long onUpdNeedsDef(FXObject *, FXSelector, void *)
enable buttons, only when a tlLogic is being edited
FXLabel * myLabelJunctionID
label for junction ID
FXTextField * myTextFieldJunctionID
text field for junction ID
GNEJunction * getCurrentJunction() const
get current modified junction
void setCurrentJunction(GNEJunction *junction)
set current junction
void updateJunctionDescription() const
update descrition
GNEJunction * myCurrentJunction
the junction of the tls is being modified
TLSJunction(GNETLSEditorFrame *tlsEditorParent)
constructor
TLSModifications(GNETLSEditorFrame *TLSEditorParent)
constructor
void setHaveModifications(bool value)
set if current TLS was modified
FXButton * myDiscardModificationsButtons
button for cancel modifications
bool checkHaveModifications() const
check if current TLS was modified
GNETLSEditorFrame * myTLSEditorParent
pointer to TLSEditor Parent
FXButton * mySaveModificationsButtons
button for save modifications
bool myHaveModifications
whether the current tls was modified
FXScrollWindow * myTableScroll
window for oversized phase tables
FXLabel * myCycleDuration
label with the cycle duration
void showCycleDuration()
show cycle duration
FXButton * myDeleteSelectedPhaseButton
delete phase button
FXFont * myTableFont
font for the phase table
FXButton * myInsertDuplicateButton
insert new phase button
TLSPhases(GNETLSEditorFrame *TLSEditorParent)
constructor
FXTable * myPhaseTable
table for selecting and rearranging phases and for changing duration
FXTable * getPhaseTable() const
get phase table
GNETLSEditorFrame * myTLSEditorParent
pointer to TLSEditor Parent
void updateCycleDuration()
recomputes cycle duration and updates label
void initPhaseTable(int index=0)
initialies the phase table
void hideCycleDuration()
hide cycle duration
long onCmdToggle(FXObject *, FXSelector, void *)
Called when the user presses the button Toogle.
const std::vector< NBTrafficLightLogic::PhaseDefinition > & getPhases()
the phase of the current traffic light
long onCmdOK(FXObject *, FXSelector, void *)
GNETLSEditorFrame::TLSFile * myTLSFile
modul for load/Save TLS Programs
void handleChange(GNEInternalLane *lane)
update phase definition for the current traffic light and phase
long onCmdGuess(FXObject *, FXSelector, void *)
Called when the user presses the button Guess.
void buildInternalLanes(NBTrafficLightDefinition *tlDef)
builds internal lanes for the given tlDef
GNETLSEditorFrame::TLSAttributes * myTLSAttributes
modul for TLS attributes
static std::string varDurString(SUMOTime dur)
convert duration (potentially undefined) to string
long onCmdDefCreate(FXObject *, FXSelector, void *)
Called when the user creates a TLS.
long onCmdDefAddOff(FXObject *, FXSelector, void *)
Called when the user adds a OFF.
long onCmdDefDelete(FXObject *, FXSelector, void *)
Called when the user deletes a TLS.
bool isTLSSaved()
check if modifications in TLS was saved
void editJunction(GNEJunction *junction)
edits the traffic light for the given junction
int myPhaseIndex
index of the phase being shown
GNEFrameModuls::OverlappedInspection * myOverlappedInspection
Overlapped Inspection.
std::map< int, std::vector< GNEInternalLane * > > TLIndexMap
the internal lanes belonging the the current junction indexed by their tl-index
GNETLSEditorFrame::TLSModifications * myTLSModifications
modul for load/Save TLS Modifications
long onCmdPhaseEdit(FXObject *, FXSelector, void *)
Called when the user edits a Phase.
long onUpdDefCreate(FXObject *, FXSelector, void *)
Called when occurs an update of create definition.
GNETLSEditorFrame::TLSPhases * myTLSPhases
modul for TLS Phases
void selectedOverlappedElement(GNEAttributeCarrier *AC)
open AttributesCreator extended dialog (can be reimplemented in frame children)
long onCmdDefOffset(FXObject *, FXSelector, void *)
Called when the user changes the offset of a TLS.
TLIndexMap myInternalLanes
long onUpdNeedsSingleDef(FXObject *, FXSelector, void *)
Called to buttons that modify link indices.
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
long onCmdDefSubRename(FXObject *, FXSelector, void *)
Called when the user sub-renames a TLS.
long onUpdUngroupStates(FXObject *, FXSelector, void *)
Called to update the ungroups states button.
long onCmdPhaseDelete(FXObject *, FXSelector, void *)
Called when the user deletes a Phase.
long onCmdCancel(FXObject *, FXSelector, void *)
Called when the user presses the Cancel-button.
long onUpdModified(FXObject *, FXSelector, void *)
Called when occurs an update of modified.
static SUMOTime getSUMOTime(const FXString &string)
converts to SUMOTime
void handleMultiChange(GNELane *lane, FXObject *obj, FXSelector sel, void *data)
update phase definition for the current traffic light and phase
long onCmdDefRename(FXObject *, FXSelector, void *)
Called when the user renames a TLS.
long onUpdNeedsDef(FXObject *, FXSelector, void *)
Called when occurs an update of needs definition.
GNETLSEditorFrame::TLSDefinition * myTLSDefinition
modul for TLS Definition
long onUpdNeedsDefAndPhase(FXObject *, FXSelector, void *)
Called when occurs an update of needs definition an dphase.
long onCmdUngroupStates(FXObject *, FXSelector, void *)
Called when the user ungroups states.
~GNETLSEditorFrame()
Destructor.
long onCmdMakeRILSAConforming(FXObject *, FXSelector, void *)
Called when the user makes RILSA.
long onCmdGroupStates(FXObject *, FXSelector, void *)
Called when the user groups states.
NBLoadedSUMOTLDef * myEditedDef
the traffic light definition being edited
long onUpdDefSwitch(FXObject *, FXSelector, void *)
Called when occurs an update of switch definition.
long onCmdPhaseCreate(FXObject *, FXSelector, void *)
Called when the user creates a Phase.
GNETLSEditorFrame::TLSJunction * myTLSJunction
modul for TLS Junction
bool fixedDuration() const
whether the current traffic light uses fixed phase durations
void editTLS(const Position &clickedPosition, const GNEViewNetHelper::ObjectsUnderCursor &objectsUnderCursor)
edits the traffic light for the given clicked junction
long onCmdPhaseSwitch(FXObject *, FXSelector, void *)
Called when the user switchs a Phase.
void cleanup()
cleans up previous lanes
long onCmdAddUnused(FXObject *, FXSelector, void *)
Called when the user cleans up states.
long onCmdDefSwitch(FXObject *, FXSelector, void *)
Called when the user switchs a TLS.
GNETLSEditorFrame(FXHorizontalFrame *horizontalFrameParent, GNEViewNet *viewNet)
Constructor.
void show()
show inspector frame
long onCmdCleanup(FXObject *, FXSelector, void *)
Called when the user cleans up states.
class used to group all variables related with objects under cursor after a click over view
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.
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:36