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-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
15 // The Widget for modifying traffic lights
16 /****************************************************************************/
17 #ifndef GNETLSEditorFrame_h
18 #define GNETLSEditorFrame_h
19 
20 // ===========================================================================
21 // included modules
22 // ===========================================================================
23 #include "GNEFrame.h"
25 
26 // ===========================================================================
27 // class declarations
28 // ===========================================================================
30 class NBLoadedSUMOTLDef;
31 class NBOwnTLDef;
32 class GNEInternalLane;
33 
34 // ===========================================================================
35 // class definitions
36 // ===========================================================================
41 class GNETLSEditorFrame : public GNEFrame {
43  FXDECLARE(GNETLSEditorFrame)
44 
45 public:
46 
47  // ===========================================================================
48  // class TLSJunction
49  // ===========================================================================
50 
51  class TLSJunction : protected FXGroupBox {
52 
53  public:
55  TLSJunction(GNETLSEditorFrame* TLSEditorParent);
56 
58  ~TLSJunction();
59 
62 
64  void setCurrentJunction(GNEJunction* junction);
65 
67  void updateJunctionDescription() const;
68 
69  private:
72 
75 
77  FXTextField* myTextFieldJunctionID;
78 
81 
84 
87  };
88 
89  // ===========================================================================
90  // class TLSDefinition
91  // ===========================================================================
92 
93  class TLSDefinition : protected FXGroupBox {
94 
95  public:
97  TLSDefinition(GNETLSEditorFrame* TLSEditorParent);
98 
100  ~TLSDefinition();
101 
102  private:
104  FXButton* myNewTLProgram;
105 
107  FXButton* myDeleteTLProgram;
108  };
109 
110  // ===========================================================================
111  // class TLSAttributes
112  // ===========================================================================
113 
114  class TLSAttributes : protected FXGroupBox {
115 
116  public:
118  TLSAttributes(GNETLSEditorFrame* TLSEditorParent);
119 
121  ~TLSAttributes();
122 
124  void initTLSAttributes(GNEJunction* junction);
125 
127  void clearTLSAttributes();
128 
130  NBTrafficLightDefinition* getCurrentTLSDefinition() const;
131 
133  SUMOTime getOffset() const;
134 
136  void setOffset(SUMOTime offset);
137 
139  int getNumberOfTLSDefinitions() const;
140 
142  int getNumberOfPrograms() const;
143 
144  private:
147 
149  std::vector<NBTrafficLightDefinition*> myTLSDefinitions;
150 
152  FXLabel* myNameLabel;
153 
155  FXTextField* myNameTextField;
156 
158  FXLabel* myProgramLabel;
159 
161  FXComboBox* myProgramComboBox;
162 
164  FXLabel* myOffsetLabel;
165 
167  FXTextField* myOffsetTextField;
168  };
169 
170  // ===========================================================================
171  // class TLSPhases
172  // ===========================================================================
173 
174  class TLSPhases : protected FXGroupBox {
175 
176  public:
178  TLSPhases(GNETLSEditorFrame* TLSEditorParent);
179 
181  ~TLSPhases();
182 
184  FXTable* getPhaseTable() const;
185 
189  void initPhaseTable(int index = 0);
190 
192  void showCycleDuration();
193 
195  void hideCycleDuration();
196 
198  void updateCycleDuration();
199 
200  private:
203 
205  FXFont* myTableFont;
206 
208  FXScrollWindow* myTableScroll;
209 
211  FXTable* myPhaseTable;
212 
214  FXLabel* myCycleDuration;
215 
218 
221  };
222 
223  // ===========================================================================
224  // class TLSModifications
225  // ===========================================================================
226 
227  class TLSModifications : protected FXGroupBox {
228 
229  public:
231  TLSModifications(GNETLSEditorFrame* TLSEditorParent);
232 
234  ~TLSModifications();
235 
237  bool checkHaveModifications() const;
238 
240  void setHaveModifications(bool value);
241 
242  private:
245 
248 
251 
254  };
255 
256  // ===========================================================================
257  // class TLSFile
258  // ===========================================================================
259 
260  class TLSFile : protected FXGroupBox {
262  FXDECLARE(GNETLSEditorFrame::TLSFile)
263 
264  public:
266  TLSFile(GNETLSEditorFrame* TLSEditorParent);
267 
269  ~TLSFile();
270 
274  long onCmdLoadTLSProgram(FXObject*, FXSelector, void*);
275 
277  long onCmdSaveTLSProgram(FXObject*, FXSelector, void*);
278 
280  long onUpdNeedsDef(FXObject*, FXSelector, void*);
282 
283  protected:
285  TLSFile() {}
286 
287  private:
290 
293 
296 
298  std::string writeSUMOTime(SUMOTime steps);
299  };
300 
301 
306  GNETLSEditorFrame(FXHorizontalFrame* horizontalFrameParent, GNEViewNet* viewNet);
307 
310 
313  void editJunction(GNEJunction* junction);
314 
316  bool isTLSSaved();
317 
319  bool parseTLSPrograms(const std::string& file);
320 
325  long onCmdOK(FXObject*, FXSelector, void*);
326 
329  long onCmdCancel(FXObject*, FXSelector, void*);
330 
332  long onCmdToggle(FXObject*, FXSelector, void*);
333 
335  long onCmdGuess(FXObject*, FXSelector, void*);
336 
338  long onCmdDefCreate(FXObject*, FXSelector, void*);
339 
341  long onCmdDefDelete(FXObject*, FXSelector, void*);
342 
344  long onCmdDefOffset(FXObject*, FXSelector, void*);
345 
347  long onCmdDefSwitch(FXObject*, FXSelector, void*);
348 
350  long onCmdDefRename(FXObject*, FXSelector, void*);
351 
353  long onCmdDefSubRename(FXObject*, FXSelector, void*);
354 
356  long onCmdDefAddOff(FXObject*, FXSelector, void*);
357 
359  long onCmdPhaseSwitch(FXObject*, FXSelector, void*);
360 
362  long onCmdPhaseCreate(FXObject*, FXSelector, void*);
363 
365  long onCmdPhaseDelete(FXObject*, FXSelector, void*);
366 
368  long onCmdCleanup(FXObject*, FXSelector, void*);
369 
371  long onCmdAddUnused(FXObject*, FXSelector, void*);
372 
374  long onCmdPhaseEdit(FXObject*, FXSelector, void*);
375 
377  long onCmdMakeRILSAConforming(FXObject*, FXSelector, void*);
378 
380  long onUpdDefSwitch(FXObject*, FXSelector, void*);
381 
383  long onUpdNeedsDef(FXObject*, FXSelector, void*);
384 
386  long onUpdNeedsDefAndPhase(FXObject*, FXSelector, void*);
387 
389  long onUpdDefCreate(FXObject*, FXSelector, void*);
390 
392  long onUpdModified(FXObject*, FXSelector, void*);
394 
396  void handleChange(GNEInternalLane* lane);
397 
399  void handleMultiChange(GNELane* lane, FXObject* obj, FXSelector sel, void* data);
400 
402  bool controlsEdge(GNEEdge& edge) const;
403 
405  bool fixedDuration() const;
406 
407 protected:
410 
412  static SUMOTime getSUMOTime(const FXString& string);
413 
414 private:
417 
420 
423 
426 
429 
432 
434  typedef std::map<int, std::vector<GNEInternalLane*> > TLIndexMap;
435  TLIndexMap myInternalLanes;
436 
439 
442 
444  void cleanup();
445 
448 
450  const std::vector<NBTrafficLightLogic::PhaseDefinition>& getPhases();
451 
453  static std::string varDurString(SUMOTime dur);
454 };
455 
456 
457 #endif
458 
459 /****************************************************************************/
460 
GNETLSEditorFrame::TLSModifications * myTLSModifications
modul for load/Save TLS Modifications
TLIndexMap myInternalLanes
FXLabel * myLabelJunctionStatus
label for junction status
long onCmdGuess(FXObject *, FXSelector, void *)
Called when the user presses the button Guess.
long long int SUMOTime
Definition: SUMOTime.h:35
FXLabel * myCycleDuration
label with the cycle duration
long onUpdNeedsDefAndPhase(FXObject *, FXSelector, void *)
Called when occurs an update of needs definition an dphase.
long onCmdPhaseDelete(FXObject *, FXSelector, void *)
Called when the user deletes a Phase.
GNETLSEditorFrame::TLSPhases * myTLSPhases
modul for TLS Phases
GNETLSEditorFrame * myTLSEditorParent
pointer to TLSEditor Parent
bool parseTLSPrograms(const std::string &file)
parse TLS Programs from a file
int myPhaseIndex
index of the phase being shown
long onCmdDefCreate(FXObject *, FXSelector, void *)
Called when the user creates a TLS.
long onCmdMakeRILSAConforming(FXObject *, FXSelector, void *)
Called when the user makes RILSA.
FXButton * myDiscardModificationsButtons
button for cancel modifications
FXLabel * myOffsetLabel
offset label
A loaded (complete) traffic light logic.
FXFont * myTableFont
font for the phase table
GNEJunction * getCurrentJunction() const
get current modified junction
long onCmdPhaseSwitch(FXObject *, FXSelector, void *)
Called when the user switchs a Phase.
FXTextField * myTextFieldJunctionStatus
text field for junction status
bool fixedDuration() const
whether the current traffic light uses fixed phase durations
This object is responsible for drawing a shape and for supplying a a popup menu. Messages are routete...
The base class for traffic light logic definitions.
FXComboBox * myProgramComboBox
the comboBox for selecting the tl-definition to edit
bool isTLSSaved()
check if modifications in TLS was saved
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition: GNELane.h:46
void editJunction(GNEJunction *junction)
edits the traffic light for the given junction
GNETLSEditorFrame()
FOX needs this.
FXButton * mySaveTLSProgramButton
button for save TLS Programs
void handleMultiChange(GNELane *lane, FXObject *obj, FXSelector sel, void *data)
update phase definition for the current traffic light and phase
std::map< int, std::vector< GNEInternalLane * > > TLIndexMap
the internal lanes belonging the the current junction indexed by their tl-index
FXLabel * myProgramLabel
program label
TLSJunction(GNETLSEditorFrame *TLSEditorParent)
constructor
long onUpdNeedsDef(FXObject *, FXSelector, void *)
Called when occurs an update of needs definition.
long onCmdCleanup(FXObject *, FXSelector, void *)
Called when the user cleans up states.
bool myHaveModifications
whether the current tls was modified
long onCmdDefDelete(FXObject *, FXSelector, void *)
Called when the user deletes a TLS.
long onCmdDefOffset(FXObject *, FXSelector, void *)
Called when the user changes the offset of a TLS.
FXButton * myDeleteSelectedPhaseButton
delete phase button
long onCmdDefSwitch(FXObject *, FXSelector, void *)
Called when the user switchs a TLS.
long onCmdDefAddOff(FXObject *, FXSelector, void *)
Called when the user adds a OFF.
GNETLSEditorFrame * myTLSEditorParent
pointer to TLSEditor Parent
FXScrollWindow * myTableScroll
window for oversized phase tables
GNETLSEditorFrame * myTLSEditorParent
pointer to TLSEditorParent
FXTextField * myNameTextField
name text field
long onCmdCancel(FXObject *, FXSelector, void *)
Called when the user presses the Cancel-button.
GNETLSEditorFrame::TLSJunction * myTLSJunction
modul for TLS Junction
bool controlsEdge(GNEEdge &edge) const
whether the given edge is controlled by the currently edited tlDef
GNETLSEditorFrame::TLSFile * myTLSFile
modul for load/Save TLS Programs
GNETLSEditorFrame::TLSAttributes * myTLSAttributes
modul for TLS attributes
long onUpdDefCreate(FXObject *, FXSelector, void *)
Called when occurs an update of create definition.
void buildIinternalLanes(NBTrafficLightDefinition *tlDef)
builds internal lanes for the given tlDef
long onCmdPhaseEdit(FXObject *, FXSelector, void *)
Called when the user edits a Phase.
~GNETLSEditorFrame()
Destructor.
void handleChange(GNEInternalLane *lane)
update phase definition for the current traffic light and phase
GNETLSEditorFrame * myTLSEditorParent
pointer to TLSEditor Parent
long onCmdAddUnused(FXObject *, FXSelector, void *)
Called when the user cleans up states.
FXTable * myPhaseTable
table for selecting and rearranging phases and for changing duration
static SUMOTime getSUMOTime(const FXString &string)
converts to SUMOTime
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:50
long onUpdDefSwitch(FXObject *, FXSelector, void *)
Called when occurs an update of switch definition.
GNEJunction * myCurrentJunction
the junction of the tls is being modified
static std::string varDurString(SUMOTime dur)
convert duration (potentially undefined) to string
FXButton * myLoadTLSProgramButton
button for load TLS Programs
long onCmdOK(FXObject *, FXSelector, void *)
void updateJunctionDescription() const
update descrition
long onCmdDefSubRename(FXObject *, FXSelector, void *)
Called when the user sub-renames a TLS.
const std::vector< NBTrafficLightLogic::PhaseDefinition > & getPhases()
the phase of the current traffic light
long onCmdPhaseCreate(FXObject *, FXSelector, void *)
Called when the user creates a Phase.
FXButton * mySaveModificationsButtons
button for save modifications
void setCurrentJunction(GNEJunction *junction)
set current junction
GNETLSEditorFrame::TLSDefinition * myTLSDefinition
modul for TLS Definition
A traffic light logics which must be computed (only nodes/edges are given)
Definition: NBOwnTLDef.h:47
FXLabel * myLabelJunctionID
label for junction ID
long onCmdDefRename(FXObject *, FXSelector, void *)
Called when the user renames a TLS.
long onUpdModified(FXObject *, FXSelector, void *)
Called when occurs an update of modified.
GNETLSEditorFrame * myTLSEditorParent
pointer to TLSEditor Parent
FXButton * myInsertDuplicateButton
insert new phase button
FXButton * myNewTLProgram
button for create new Traffic light program
FXTextField * myOffsetTextField
the control for modifying offset
FXButton * myDeleteTLProgram
button for delete traffic light program
FXTextField * myTextFieldJunctionID
text field for junction ID
NBLoadedSUMOTLDef * myEditedDef
the traffic light definition being edited
std::vector< NBTrafficLightDefinition * > myTLSDefinitions
the list of Definitions for the current junction
void cleanup()
cleans up previous lanes
long onCmdToggle(FXObject *, FXSelector, void *)
Called when the user presses the button Toogle.