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 <config.h>
24 
25 #include "GNEFrame.h"
26 
27 // ===========================================================================
28 // class declarations
29 // ===========================================================================
31 class NBLoadedSUMOTLDef;
32 class GNEEdge;
33 class GNELane;
34 class GNEInternalLane;
35 class GNEJunction;
36 class NBOwnTLDef;
37 
38 // ===========================================================================
39 // class definitions
40 // ===========================================================================
45 class GNETLSEditorFrame : public GNEFrame {
47  FXDECLARE(GNETLSEditorFrame)
48 
49 public:
50 
51  // ===========================================================================
52  // class TLSJunction
53  // ===========================================================================
54 
55  class TLSJunction : protected FXGroupBox {
56 
57  public:
59  TLSJunction(GNETLSEditorFrame* TLSEditorParent);
60 
62  ~TLSJunction();
63 
66 
68  void setCurrentJunction(GNEJunction* junction);
69 
71  void updateJunctionDescription() const;
72 
73  private:
76 
79 
81  FXTextField* myTextFieldJunctionID;
82 
85 
88 
91  };
92 
93  // ===========================================================================
94  // class TLSDefinition
95  // ===========================================================================
96 
97  class TLSDefinition : protected FXGroupBox {
98 
99  public:
101  TLSDefinition(GNETLSEditorFrame* TLSEditorParent);
102 
104  ~TLSDefinition();
105 
106  private:
109 
111  FXButton* myNewTLProgram;
112 
114  FXButton* myDeleteTLProgram;
115  };
116 
117  // ===========================================================================
118  // class TLSAttributes
119  // ===========================================================================
120 
121  class TLSAttributes : protected FXGroupBox {
122 
123  public:
125  TLSAttributes(GNETLSEditorFrame* TLSEditorParent);
126 
128  ~TLSAttributes();
129 
131  void initTLSAttributes(GNEJunction* junction);
132 
134  void clearTLSAttributes();
135 
137  NBTrafficLightDefinition* getCurrentTLSDefinition() const;
138 
140  SUMOTime getOffset() const;
141 
143  void setOffset(SUMOTime offset);
144 
146  int getNumberOfTLSDefinitions() const;
147 
149  int getNumberOfPrograms() const;
150 
151  private:
154 
156  std::vector<NBTrafficLightDefinition*> myTLSDefinitions;
157 
159  FXLabel* myNameLabel;
160 
162  FXTextField* myNameTextField;
163 
165  FXLabel* myProgramLabel;
166 
168  FXComboBox* myProgramComboBox;
169 
171  FXLabel* myOffsetLabel;
172 
174  FXTextField* myOffsetTextField;
175  };
176 
177  // ===========================================================================
178  // class TLSPhases
179  // ===========================================================================
180 
181  class TLSPhases : protected FXGroupBox {
182 
183  public:
185  TLSPhases(GNETLSEditorFrame* TLSEditorParent);
186 
188  ~TLSPhases();
189 
191  FXTable* getPhaseTable() const;
192 
196  void initPhaseTable(int index = 0);
197 
199  void showCycleDuration();
200 
202  void hideCycleDuration();
203 
205  void updateCycleDuration();
206 
207  private:
210 
212  FXFont* myTableFont;
213 
215  FXScrollWindow* myTableScroll;
216 
218  FXTable* myPhaseTable;
219 
221  FXLabel* myCycleDuration;
222 
225 
228  };
229 
230  // ===========================================================================
231  // class TLSModifications
232  // ===========================================================================
233 
234  class TLSModifications : protected FXGroupBox {
235 
236  public:
238  TLSModifications(GNETLSEditorFrame* TLSEditorParent);
239 
241  ~TLSModifications();
242 
244  bool checkHaveModifications() const;
245 
247  void setHaveModifications(bool value);
248 
249  private:
252 
255 
258 
261  };
262 
263  // ===========================================================================
264  // class TLSFile
265  // ===========================================================================
266 
267  class TLSFile : protected FXGroupBox, public SUMOSAXHandler {
269  FXDECLARE(GNETLSEditorFrame::TLSFile)
270 
271  public:
273  TLSFile(GNETLSEditorFrame* TLSEditorParent);
274 
276  ~TLSFile();
277 
279 
280 
287  void myStartElement(int element, const SUMOSAXAttributes& attrs);
289 
291  void enableTLSFile();
292 
294  void disableTLSFile();
295 
297  void clearLoadedTLS();
298 
300  bool checkTLSValids();
301 
303  const std::vector<NBLoadedSUMOTLDef*>& getLoadedTLS() const;
304 
308  long onCmdLoadTLSProgram(FXObject*, FXSelector, void*);
309 
311  long onCmdSaveTLSProgram(FXObject*, FXSelector, void*);
313 
314  protected:
316  TLSFile() {}
317 
318  private:
321 
324 
327 
329  std::vector<NBLoadedSUMOTLDef*> myLoadedTLS;
330 
332  std::string writeSUMOTime(SUMOTime steps);
333  };
334 
335 
340  GNETLSEditorFrame(FXHorizontalFrame* horizontalFrameParent, GNEViewNet* viewNet);
341 
344 
347  void editJunction(GNEJunction* junction);
348 
350  bool isTLSSaved();
351 
353  bool parseTLSPrograms(const std::string& file);
354 
359  long onCmdOK(FXObject*, FXSelector, void*);
360 
363  long onCmdCancel(FXObject*, FXSelector, void*);
364 
366  long onCmdToggle(FXObject*, FXSelector, void*);
367 
369  long onCmdGuess(FXObject*, FXSelector, void*);
370 
372  long onCmdDefCreate(FXObject*, FXSelector, void*);
373 
375  long onCmdDefDelete(FXObject*, FXSelector, void*);
376 
378  long onCmdDefOffset(FXObject*, FXSelector, void*);
379 
381  long onCmdDefSwitch(FXObject*, FXSelector, void*);
382 
384  long onCmdDefRename(FXObject*, FXSelector, void*);
385 
387  long onCmdDefSubRename(FXObject*, FXSelector, void*);
388 
390  long onCmdDefAddOff(FXObject*, FXSelector, void*);
391 
393  long onCmdPhaseSwitch(FXObject*, FXSelector, void*);
394 
396  long onCmdPhaseCreate(FXObject*, FXSelector, void*);
397 
399  long onCmdPhaseDelete(FXObject*, FXSelector, void*);
400 
402  long onCmdCleanup(FXObject*, FXSelector, void*);
403 
405  long onCmdAddUnused(FXObject*, FXSelector, void*);
406 
408  long onCmdPhaseEdit(FXObject*, FXSelector, void*);
409 
411  long onCmdMakeRILSAConforming(FXObject*, FXSelector, void*);
412 
414  long onUpdDefSwitch(FXObject*, FXSelector, void*);
415 
417  long onUpdNeedsDef(FXObject*, FXSelector, void*);
418 
420  long onUpdNeedsDefAndPhase(FXObject*, FXSelector, void*);
421 
423  long onUpdDefCreate(FXObject*, FXSelector, void*);
424 
426  long onUpdModified(FXObject*, FXSelector, void*);
428 
430  void handleChange(GNEInternalLane* lane);
431 
433  void handleMultiChange(GNELane* lane, FXObject* obj, FXSelector sel, void* data);
434 
436  bool controlsEdge(GNEEdge& edge) const;
437 
438 protected:
441 
443  static SUMOTime getSUMOTime(const FXString& string);
444 
445 private:
448 
451 
454 
457 
460 
463 
465  typedef std::map<int, std::vector<GNEInternalLane*> > TLIndexMap;
466  TLIndexMap myInternalLanes;
467 
470 
473 
475  void cleanup();
476 
479 
481  const std::vector<NBTrafficLightLogic::PhaseDefinition>& getPhases();
482 
484  static std::string varDurString(SUMOTime dur);
485 };
486 
487 
488 #endif
489 
490 /****************************************************************************/
491 
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
SAX-handler base for SUMO-files.
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.
Encapsulated SAX-Attributes.
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.
std::vector< NBLoadedSUMOTLDef * > myLoadedTLS
container used to save loaded TLSs