SUMO - Simulation of Urban MObility
GNETLSEditor.h
Go to the documentation of this file.
1 /****************************************************************************/
7 // The Widget for modifying traffic lights
8 /****************************************************************************/
9 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
10 // Copyright (C) 2001-2016 DLR (http://www.dlr.de/) and contributors
11 /****************************************************************************/
12 //
13 // This file is part of SUMO.
14 // SUMO is free software: you can redistribute it and/or modify
15 // it under the terms of the GNU General Public License as published by
16 // the Free Software Foundation, either version 3 of the License, or
17 // (at your option) any later version.
18 //
19 /****************************************************************************/
20 #ifndef GNETLSEditor_h
21 #define GNETLSEditor_h
22 
23 
24 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 #ifdef _MSC_VER
28 #include <windows_config.h>
29 #else
30 #include <config.h>
31 #endif
32 
33 #include <fx.h>
37 
38 // ===========================================================================
39 // class declarations
40 // ===========================================================================
42 class NBLoadedSUMOTLDef;
43 class GNEViewNet;
44 class GNEEdge;
45 class GNELane;
46 class GNEUndoList;
47 class GNEInternalLane;
48 class GNEJunction;
49 
50 // ===========================================================================
51 // class definitions
52 // ===========================================================================
57 class GNETLSEditor : public FXScrollWindow {
58  // FOX-declarations
59  FXDECLARE(GNETLSEditor)
60 
61 public:
65  GNETLSEditor(FXComposite* parent, GNEViewNet* updateTarget, GNEUndoList* undoList);
66 
67 
69  ~GNETLSEditor();
70 
71 
72  FXFont* getHeaderFont() {
73  return myHeaderFont;
74  }
75 
79  void editJunction(GNEJunction* junction);
80 
83 
86  long onCmdOK(FXObject*, FXSelector, void*);
87 
91  long onCmdCancel(FXObject*, FXSelector, void*);
92 
94  long onCmdToggle(FXObject*, FXSelector, void*);
95  long onCmdGuess(FXObject*, FXSelector, void*);
96 
97  long onCmdDefCreate(FXObject*, FXSelector, void*);
98  long onCmdDefDelete(FXObject*, FXSelector, void*);
99  long onCmdDefOffset(FXObject*, FXSelector, void*);
100  long onCmdDefSwitch(FXObject*, FXSelector, void*);
101  long onCmdDefRename(FXObject*, FXSelector, void*);
102  long onCmdDefSubRename(FXObject*, FXSelector, void*);
103  long onCmdDefAddOff(FXObject*, FXSelector, void*);
104 
105  long onCmdPhaseSwitch(FXObject*, FXSelector, void*);
106  long onCmdPhaseCreate(FXObject*, FXSelector, void*);
107  long onCmdPhaseDelete(FXObject*, FXSelector, void*);
108  long onCmdPhaseEdit(FXObject*, FXSelector, void*);
109 
110  long onCmdMakeRILSAConforming(FXObject*, FXSelector, void*);
111 
112  long onUpdDefSwitch(FXObject*, FXSelector, void*);
113  long onUpdNeedsDef(FXObject*, FXSelector, void*);
114  long onUpdNeedsDefAndPhase(FXObject*, FXSelector, void*);
115  long onUpdDefCreate(FXObject*, FXSelector, void*);
116  long onUpdModified(FXObject*, FXSelector, void*);
118 
120  void handleChange(GNEInternalLane* lane);
121 
123  void handleMultiChange(GNELane* lane, FXObject* obj, FXSelector sel, void* data);
124 
126  bool controlsEdge(GNEEdge& edge) const;
127 
128 protected:
131 
132 private:
134  FXVerticalFrame* myContentFrame;
135 
137  FXFont* myHeaderFont;
138 
140  FXFont* myTableFont;
141 
143  FXLabel* myDescription;
144 
147 
150 
151  /* @brief the window to inform when the tls is modfied */
153 
156 
158  typedef std::map<int, std::vector<GNEInternalLane*> > TLIndexMap;
159  TLIndexMap myInternalLanes;
160 
162  std::vector<NBTrafficLightDefinition*> myDefinitions;
163 
166 
168  FXListBox* myDefBox;
169 
171  FXTextField* myOffset;
172 
173  FXLabel* myCycleDuration;
174 
176  FXTable* myPhaseTable;
177 
179  unsigned int myPhaseIndex;
180 
182  static const int WIDTH;
183 
184 private:
185  void updateDescription() const;
186 
188  void cleanup();
189 
190  /* @brief builds internal lanes for the given tlDef */
192 
193  /* @brief initializes the definitions and corresponding listbox */
194  void initDefinitions();
195 
196  /* @brief initialies the phase table
197  * @param[in] index The index to select
198  */
199  void initPhaseTable(unsigned int index = 0);
200 
202  const std::vector<NBTrafficLightLogic::PhaseDefinition>& getPhases();
203 
205  void updateCycleDuration();
206 
208  static SUMOTime getSUMOTime(const FXString& string);
209 
210 };
211 
212 
213 #endif
214 
215 /****************************************************************************/
216 
bool controlsEdge(GNEEdge &edge) const
whether the given edge is controlled by the currently edited tlDef
long onCmdDefOffset(FXObject *, FXSelector, void *)
const std::vector< NBTrafficLightLogic::PhaseDefinition > & getPhases()
the phase of the current traffic light
long long int SUMOTime
Definition: SUMOTime.h:43
GNEJunction * myCurrentJunction
the junction of the tls is being modified
Definition: GNETLSEditor.h:146
GNEViewNet * myUpdateTarget
Definition: GNETLSEditor.h:152
FXLabel * myCycleDuration
Definition: GNETLSEditor.h:173
A loaded (complete) traffic light logic.
void handleMultiChange(GNELane *lane, FXObject *obj, FXSelector sel, void *data)
update phase definition for the current traffic light and phase
long onCmdDefDelete(FXObject *, FXSelector, void *)
This object is responsible for drawing a shape and for supplying a a popup menu. Messages are routete...
long onCmdDefCreate(FXObject *, FXSelector, void *)
TLIndexMap myInternalLanes
Definition: GNETLSEditor.h:159
The base class for traffic light logic definitions.
long onCmdDefSwitch(FXObject *, FXSelector, void *)
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition: GNELane.h:56
void updateDescription() const
long onUpdModified(FXObject *, FXSelector, void *)
void initPhaseTable(unsigned int index=0)
FXTextField * myOffset
the control for modifying offset
Definition: GNETLSEditor.h:171
long onUpdDefCreate(FXObject *, FXSelector, void *)
FXFont * getHeaderFont()
Definition: GNETLSEditor.h:72
long onCmdToggle(FXObject *, FXSelector, void *)
Called when the user presses the Corresponding-button.
~GNETLSEditor()
Destructor.
void cleanup()
cleans up previous lanes
long onCmdPhaseCreate(FXObject *, FXSelector, void *)
void updateCycleDuration()
recomputes cycle duration and updates label
long onCmdDefSubRename(FXObject *, FXSelector, void *)
NBLoadedSUMOTLDef * myEditedDef
the traffic light definition being edited
Definition: GNETLSEditor.h:165
long onUpdNeedsDefAndPhase(FXObject *, FXSelector, void *)
FXListBox * myDefBox
the listbox for selecting the tl-definition to edit
Definition: GNETLSEditor.h:168
long onCmdMakeRILSAConforming(FXObject *, FXSelector, void *)
long onCmdPhaseSwitch(FXObject *, FXSelector, void *)
long onCmdCancel(FXObject *, FXSelector, void *)
Called when the user presses the Cancel-button discards any modifications.
void initDefinitions()
void handleChange(GNEInternalLane *lane)
update phase definition for the current traffic light and phase
static SUMOTime getSUMOTime(const FXString &string)
converts to SUMOTime
FXVerticalFrame * myContentFrame
the panel to hold all member widgets
Definition: GNETLSEditor.h:134
GNEUndoList * myUndoList
the undolist with wich to register changes
Definition: GNETLSEditor.h:149
FXTable * myPhaseTable
table for selecting and rearranging phases and for changing duration
Definition: GNETLSEditor.h:176
long onCmdPhaseEdit(FXObject *, FXSelector, void *)
FXFont * myTableFont
font for the phase table
Definition: GNETLSEditor.h:140
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:61
unsigned int myPhaseIndex
index of the phase being shown
Definition: GNETLSEditor.h:179
void editJunction(GNEJunction *junction)
edits the traffic light for the given junction
GNETLSEditor()
FOX needs this.
Definition: GNETLSEditor.h:130
long onUpdNeedsDef(FXObject *, FXSelector, void *)
std::map< int, std::vector< GNEInternalLane * > > TLIndexMap
the internal lanes belonging the the current junction indexed by their tl-index
Definition: GNETLSEditor.h:158
FXLabel * myDescription
the label that shows the current editing state
Definition: GNETLSEditor.h:143
long onCmdDefAddOff(FXObject *, FXSelector, void *)
bool myHaveModifications
whether the current tls was modified
Definition: GNETLSEditor.h:155
std::vector< NBTrafficLightDefinition * > myDefinitions
the list of Definitions for the current junction
Definition: GNETLSEditor.h:162
void buildIinternalLanes(NBTrafficLightDefinition *tlDef)
long onCmdDefRename(FXObject *, FXSelector, void *)
long onCmdGuess(FXObject *, FXSelector, void *)
long onUpdDefSwitch(FXObject *, FXSelector, void *)
long onCmdPhaseDelete(FXObject *, FXSelector, void *)
long onCmdOK(FXObject *, FXSelector, void *)
Called when the user presses the OK-Button saves any modifications.
FXFont * myHeaderFont
Font for the widget.
Definition: GNETLSEditor.h:137
static const int WIDTH
the width of the widget
Definition: GNETLSEditor.h:182