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-2022 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 #include <config.h>
22 
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 : public FXGroupBoxModule {
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 
74  FXTextField* myTextFieldJunctionID;
75 
78  };
79 
80  // ===========================================================================
81  // class TLSDefinition
82  // ===========================================================================
83 
85 
86  public:
88  TLSDefinition(GNETLSEditorFrame* TLSEditorParent);
89 
92 
93  private:
95  FXButton* myNewTLProgram;
96 
98  FXButton* myDeleteTLProgram;
99  };
100 
101  // ===========================================================================
102  // class TLSAttributes
103  // ===========================================================================
104 
106 
107  public:
109  TLSAttributes(GNETLSEditorFrame* TLSEditorParent);
110 
112  ~TLSAttributes();
113 
115  void initTLSAttributes(GNEJunction* junction);
116 
118  void clearTLSAttributes();
119 
122 
124  const std::string getCurrentTLSProgramID() const;
125 
127  SUMOTime getOffset() const;
128 
130  void setOffset(const SUMOTime& offset);
131 
133  bool isValidOffset();
134 
136  std::string getParameters() const;
137 
139  void setParameters(const std::string& parameters);
140 
142  bool isValidParameters();
143 
145  int getNumberOfTLSDefinitions() const;
146 
148  int getNumberOfPrograms() const;
149 
150  private:
153 
155  std::vector<NBTrafficLightDefinition*> myTLSDefinitions;
156 
158  FXTextField* myNameTextField;
159 
161  FXComboBox* myProgramComboBox;
162 
164  FXTextField* myOffsetTextField;
165 
168 
170  FXTextField* myParametersTextField;
171  };
172 
173  // ===========================================================================
174  // class TLSPhases
175  // ===========================================================================
176 
177  class TLSPhases : public FXGroupBoxModule {
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 
231 
232  public:
234  TLSModifications(GNETLSEditorFrame* TLSEditorParent);
235 
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 : public FXGroupBoxModule {
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:
287  FOX_CONSTRUCTOR(TLSFile)
288 
289  private:
292 
295 
298 
300  std::string writeSUMOTime(SUMOTime steps);
301  };
302 
303 
308  GNETLSEditorFrame(FXHorizontalFrame* horizontalFrameParent, GNEViewNet* viewNet);
309 
312 
314  void show();
315 
320  void editTLS(const Position& clickedPosition, const GNEViewNetHelper::ObjectsUnderCursor& objectsUnderCursor);
321 
323  bool isTLSSaved();
324 
326  bool parseTLSPrograms(const std::string& file);
327 
332  long onCmdOK(FXObject*, FXSelector, void*);
333 
336  long onCmdCancel(FXObject*, FXSelector, void*);
337 
339  long onCmdToggle(FXObject*, FXSelector, void*);
340 
342  long onCmdGuess(FXObject*, FXSelector, void*);
343 
345  long onCmdDefCreate(FXObject*, FXSelector, void*);
346 
348  long onCmdDefDelete(FXObject*, FXSelector, void*);
349 
351  long onCmdSetOffset(FXObject*, FXSelector, void*);
352 
354  long onCmdSetParameters(FXObject*, FXSelector, void*);
355 
357  long onCmdDefSwitch(FXObject*, FXSelector, void*);
358 
360  long onCmdDefRename(FXObject*, FXSelector, void*);
361 
363  long onCmdDefSubRename(FXObject*, FXSelector, void*);
364 
366  long onCmdDefAddOff(FXObject*, FXSelector, void*);
367 
369  long onCmdPhaseSwitch(FXObject*, FXSelector, void*);
370 
372  long onCmdPhaseCreate(FXObject*, FXSelector, void*);
373 
375  long onCmdPhaseDelete(FXObject*, FXSelector, void*);
376 
378  long onCmdCleanup(FXObject*, FXSelector, void*);
379 
381  long onCmdAddUnused(FXObject*, FXSelector, void*);
382 
384  long onCmdGroupStates(FXObject*, FXSelector, void*);
385 
387  long onCmdUngroupStates(FXObject*, FXSelector, void*);
388 
390  long onUpdUngroupStates(FXObject*, FXSelector, void*);
391 
393  long onCmdPhaseEdit(FXObject*, FXSelector, void*);
394 
396  long onCmdEditParameters(FXObject*, FXSelector, void* ptr);
397 
399  long onCmdMakeRILSAConforming(FXObject*, FXSelector, void*);
400 
402  long onUpdDefSwitch(FXObject*, FXSelector, void*);
403 
405  long onUpdNeedsDef(FXObject*, FXSelector, void*);
406 
408  long onUpdNeedsSingleDef(FXObject*, FXSelector, void*);
409 
411  long onUpdNeedsDefAndPhase(FXObject*, FXSelector, void*);
412 
414  long onUpdDefCreate(FXObject*, FXSelector, void*);
415 
417  long onUpdModified(FXObject*, FXSelector, void*);
419 
421  void handleChange(GNEInternalLane* lane);
422 
424  void handleMultiChange(GNELane* lane, FXObject* obj, FXSelector sel, void* data);
425 
427  bool controlsEdge(GNEEdge* edge) const;
428 
430  bool fixedDuration() const;
431 
434 
435 protected:
436  FOX_CONSTRUCTOR(GNETLSEditorFrame)
437 
438 
441  void editJunction(GNEJunction* junction);
442 
444  static SUMOTime getSUMOTime(const FXString& string);
445 
446 private:
449 
452 
455 
458 
461 
464 
467 
469  typedef std::map<int, std::vector<GNEInternalLane*> > TLIndexMap;
471 
474 
477 
479  void cleanup();
480 
483 
485  const std::vector<NBTrafficLightLogic::PhaseDefinition>& getPhases();
486 
488  static std::string varDurString(SUMOTime dur);
489 };
long long int SUMOTime
Definition: SUMOTime.h:32
FXGroupBoxModule (based on FXGroupBox)
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:53
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:46
void initTLSAttributes(GNEJunction *junction)
initializes the definitions and corresponding listbox
bool isValidOffset()
is current offset valid
bool isValidParameters()
are current parameter valid
FXTextField * myOffsetTextField
the TextField for modifying offset
int getNumberOfPrograms() const
get number of programs
SUMOTime getOffset() const
get current offset in string format
const std::string getCurrentTLSProgramID() const
get current program ID
void setParameters(const std::string &parameters)
set new parameters
void clearTLSAttributes()
clear TLS attributes
FXComboBox * myProgramComboBox
the comboBox for selecting the tl-definition to edit
void setOffset(const SUMOTime &offset)
set new offset
std::string getParameters() const
get current parameters in string format
int getNumberOfTLSDefinitions() const
get number of definitions
FXButton * myButtonEditParameters
button for edit parameters
TLSAttributes(GNETLSEditorFrame *TLSEditorParent)
constructor
NBTrafficLightDefinition * getCurrentTLSDefinition() const
get current definition
FXTextField * myParametersTextField
the TextField for modifying parameters
FXTextField * myNameTextField
name text field
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 Toggle.
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
GNEFrameModules::OverlappedInspection * myOverlappedInspection
Overlapped Inspection.
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
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)
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 onCmdSetOffset(FXObject *, FXSelector, void *)
Called when the user changes the offset of a TLS.
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 onCmdSetParameters(FXObject *, FXSelector, void *)
Called when the user changes parameters of a TLS.
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.
long onCmdEditParameters(FXObject *, FXSelector, void *ptr)
Called when user press edit parameters button.
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:37