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-2018 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:
105 
107  FXButton* myNewTLProgram;
108 
110  FXButton* myDeleteTLProgram;
111  };
112 
113  // ===========================================================================
114  // class TLSAttributes
115  // ===========================================================================
116 
117  class TLSAttributes : protected FXGroupBox {
118 
119  public:
121  TLSAttributes(GNETLSEditorFrame* TLSEditorParent);
122 
124  ~TLSAttributes();
125 
127  void initTLSAttributes(GNEJunction* junction);
128 
130  void clearTLSAttributes();
131 
133  NBTrafficLightDefinition* getCurrentTLSDefinition() const;
134 
136  SUMOTime getOffset() const;
137 
139  void setOffset(SUMOTime offset);
140 
142  int getNumberOfTLSDefinitions() const;
143 
145  int getNumberOfPrograms() const;
146 
147  private:
150 
152  std::vector<NBTrafficLightDefinition*> myTLSDefinitions;
153 
155  FXLabel* myNameLabel;
156 
158  FXTextField* myNameTextField;
159 
161  FXLabel* myProgramLabel;
162 
164  FXComboBox* myProgramComboBox;
165 
167  FXLabel* myOffsetLabel;
168 
170  FXTextField* myOffsetTextField;
171  };
172 
173  // ===========================================================================
174  // class TLSPhases
175  // ===========================================================================
176 
177  class TLSPhases : protected FXGroupBox {
178 
179  public:
181  TLSPhases(GNETLSEditorFrame* TLSEditorParent);
182 
184  ~TLSPhases();
185 
187  FXTable* getPhaseTable() const;
188 
192  void initPhaseTable(int index = 0);
193 
195  void showCycleDuration();
196 
198  void hideCycleDuration();
199 
201  void updateCycleDuration();
202 
203  private:
206 
208  FXFont* myTableFont;
209 
211  FXScrollWindow* myTableScroll;
212 
214  FXTable* myPhaseTable;
215 
217  FXLabel* myCycleDuration;
218 
221 
224  };
225 
226  // ===========================================================================
227  // class TLSModifications
228  // ===========================================================================
229 
230  class TLSModifications : protected FXGroupBox {
231 
232  public:
234  TLSModifications(GNETLSEditorFrame* TLSEditorParent);
235 
237  ~TLSModifications();
238 
240  bool checkHaveModifications() const;
241 
243  void setHaveModifications(bool value);
244 
245  private:
248 
251 
254 
257  };
258 
259  // ===========================================================================
260  // class TLSFile
261  // ===========================================================================
262 
263  class TLSFile : protected FXGroupBox {
265  FXDECLARE(GNETLSEditorFrame::TLSFile)
266 
267  public:
269  TLSFile(GNETLSEditorFrame* TLSEditorParent);
270 
272  ~TLSFile();
273 
277  long onCmdLoadTLSProgram(FXObject*, FXSelector, void*);
278 
280  long onCmdSaveTLSProgram(FXObject*, FXSelector, void*);
281 
283  long onUpdNeedsDef(FXObject*, FXSelector, void*);
285 
286  protected:
288  TLSFile() {}
289 
290  private:
293 
296 
299 
301  std::string writeSUMOTime(SUMOTime steps);
302  };
303 
304 
309  GNETLSEditorFrame(FXHorizontalFrame* horizontalFrameParent, GNEViewNet* viewNet);
310 
313 
316  void editJunction(GNEJunction* junction);
317 
319  bool isTLSSaved();
320 
322  bool parseTLSPrograms(const std::string& file);
323 
328  long onCmdOK(FXObject*, FXSelector, void*);
329 
332  long onCmdCancel(FXObject*, FXSelector, void*);
333 
335  long onCmdToggle(FXObject*, FXSelector, void*);
336 
338  long onCmdGuess(FXObject*, FXSelector, void*);
339 
341  long onCmdDefCreate(FXObject*, FXSelector, void*);
342 
344  long onCmdDefDelete(FXObject*, FXSelector, void*);
345 
347  long onCmdDefOffset(FXObject*, FXSelector, void*);
348 
350  long onCmdDefSwitch(FXObject*, FXSelector, void*);
351 
353  long onCmdDefRename(FXObject*, FXSelector, void*);
354 
356  long onCmdDefSubRename(FXObject*, FXSelector, void*);
357 
359  long onCmdDefAddOff(FXObject*, FXSelector, void*);
360 
362  long onCmdPhaseSwitch(FXObject*, FXSelector, void*);
363 
365  long onCmdPhaseCreate(FXObject*, FXSelector, void*);
366 
368  long onCmdPhaseDelete(FXObject*, FXSelector, void*);
369 
371  long onCmdCleanup(FXObject*, FXSelector, void*);
372 
374  long onCmdAddUnused(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 onUpdNeedsDefAndPhase(FXObject*, FXSelector, void*);
390 
392  long onUpdDefCreate(FXObject*, FXSelector, void*);
393 
395  long onUpdModified(FXObject*, FXSelector, void*);
397 
399  void handleChange(GNEInternalLane* lane);
400 
402  void handleMultiChange(GNELane* lane, FXObject* obj, FXSelector sel, void* data);
403 
405  bool controlsEdge(GNEEdge& edge) 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:36
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
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:47
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 TLSEditor Parent
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.