88 FXIMPLEMENT(
GNETLSEditorFrame, FXVerticalFrame, GNETLSEditorFrameMap, ARRAYNUMBER(GNETLSEditorFrameMap))
95 GNEFrame(horizontalFrameParent, viewNet, "Edit Traffic Light"),
96 myTableFont(new FXFont(getApp(), "Courier New", 9)),
98 myHaveModifications(false),
106 myTextFieldJunctionID->setEditable(
false);
111 myTextFieldJunctionStatus->setEditable(
false);
120 myDeleteTLProgram =
new FXButton(myGroupBoxTLSDef,
"Delete TLS\t\tDelete a traffic light program. If all programs are deleted the junction turns into a priority junction.", 0,
this,
MID_GNE_TLSFRAME_DELETE,
GUIDesignButton);
129 myTableScroll =
new FXScrollWindow(myGroupBoxPhases, LAYOUT_FILL_X | LAYOUT_FIX_HEIGHT);
131 myPhaseTable->setColumnHeaderMode(LAYOUT_FIX_HEIGHT);
132 myPhaseTable->setColumnHeaderHeight(0);
133 myPhaseTable->setRowHeaderMode(LAYOUT_FIX_WIDTH);
134 myPhaseTable->setRowHeaderWidth(0);
135 myPhaseTable->hide();
136 myPhaseTable->setFont(myTableFont);
137 myPhaseTable->setHelpText(
"phase duration in seconds | phase state");
153 myDiscardModificationsButtons =
new FXButton(myGroupBoxModifications,
"Cancel\t\tDiscard program modifications (Esc)", 0,
this,
MID_CANCEL,
GUIDesignButton);
156 mySaveModificationsButtons =
new FXButton(myGroupBoxModifications,
"Save\t\tSave program modifications (Enter)", 0,
this,
MID_OK,
GUIDesignButton);
206 std::vector<NBNode*> nodes = oldDefinition->
getNodes();
207 for (
auto it : nodes) {
285 o->handle(
this, FXSEL(SEL_COMMAND, enable ? FXWindow::ID_ENABLE : FXWindow::ID_DISABLE), 0);
293 o->handle(
this, FXSEL(SEL_COMMAND, enable ? FXWindow::ID_ENABLE : FXWindow::ID_DISABLE), 0);
302 o->handle(
this, FXSEL(SEL_COMMAND, enable ? FXWindow::ID_ENABLE : FXWindow::ID_DISABLE), 0);
310 o->handle(
this, FXSEL(SEL_COMMAND, enable ? FXWindow::ID_ENABLE : FXWindow::ID_DISABLE), 0);
318 o->handle(
this, FXSEL(SEL_COMMAND, enable ? FXWindow::ID_ENABLE : FXWindow::ID_DISABLE), 0);
364 int tlIndex = it.first;
365 std::vector<GNEInternalLane*> lanes = it.second;
366 assert(tlIndex >= 0);
367 assert(tlIndex < (
int)phase.
state.size());
368 for (
auto it_lane : lanes) {
386 const std::string state =
myPhaseTable->getItemText(oldIndex, fixed ? 1 : 3).text();
420 FXTablePos* tp = (FXTablePos*)ptr;
421 FXString value =
myPhaseTable->getItemText(tp->row, tp->col);
425 if (GNEAttributeCarrier::canParse<double>(value.text())) {
436 }
else if (!fixed && tp->col == 1) {
438 if (GNEAttributeCarrier::canParse<double>(value.text())) {
452 }
else if (!fixed && tp->col == 2) {
454 if (GNEAttributeCarrier::canParse<double>(value.text())) {
526 for (
auto it_intLanes : it.second) {
531 myInternalLanes.clear();
537 std::string innerID =
":" + nbn->
getID();
539 for (
auto it : links) {
540 int tlIndex = it.getTLIndex();
542 it.getTo(), it.getToLane()), NUM_POINTS);
545 myInternalLanes[tlIndex].push_back(ilane);
550 myInternalLanes[c->tlLinkNo].push_back(ilane);
568 const std::vector<NBTrafficLightLogic::PhaseDefinition>& phases =
getPhases();
569 myPhaseTable->setTableSize((
int)phases.size(), fixed ? 2 : 4);
572 for (
int row = 0; row < (int)phases.size(); row++) {
578 myPhaseTable->setItemText(row, fixed ? 1 : 3, phases[row].state.c_str());
579 myPhaseTable->getItem(row, 1)->setJustify(FXTableItem::LEFT);
594 const std::vector<NBTrafficLightLogic::PhaseDefinition>&
604 const std::vector<NBTrafficLightLogic::PhaseDefinition>& phases =
getPhases();
605 for (
int row = 0; row < (int)phases.size(); row++) {
621 std::set<std::string> fromIDs;
626 for (
auto it_lane : edge.
getLanes()) {
627 fromIDs.insert(it_lane->getMicrosimID());
633 for (
auto it : edges) {
634 for (
auto it_lane : it->getLanes()) {
635 fromIDs.insert(it_lane->getMicrosimID());
642 for (
auto it_lane : lanes) {
643 fromIDs.insert(it_lane->getMicrosimID());
649 for (
auto it : links) {
650 if (fromIDs.count(it.getFrom()->getLaneID(it.getFromLane())) > 0) {
651 std::vector<GNEInternalLane*> lanes =
myInternalLanes[it.getTLIndex()];
652 for (
auto it_lane : lanes) {
653 it_lane->onDefault(obj, sel, eventData);
665 for (
auto it : links) {
677 assert(GNEAttributeCarrier::canParse<double>(
string.text()));
678 return TIME2STEPS(GNEAttributeCarrier::parse<double>(
string.text()));
686 cycleDuration += it.duration;
699 myTLSEditorParent(TLSEditorParent) {
TLIndexMap myInternalLanes
selected junction von TLS
long onCmdGuess(FXObject *, FXSelector, void *)
Called when the user presses the button Guess.
std::vector< GNELane * > retrieveLanes(bool onlySelected=false)
return all lanes
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
A structure which describes a connection between edges or lanes.
#define GUIDesignComboBoxNCol
number of column of every combo box
FXTable * myPhaseTable
table for selecting and rearranging phases and for changing 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.
SUMOTime getOffset() const
Returns the offset of first switch.
long onCmdDefCreate(FXObject *, FXSelector, void *)
Called when the user creates a TLS.
void setPhaseMaxDuration(int phaseIndex, SUMOTime duration)
FXLabel * myOffsetLabel
offset label
void setOffset(SUMOTime offset)
Sets the offset of this tls.
A loaded (complete) traffic light logic.
void setPhaseState(int phaseIndex, int tlIndex, LinkState linkState)
Modifies the state for an existing phase (used by NETEDIT)
A container for traffic light definitions and built programs.
A SUMO-compliant built logic for a traffic light.
FXLabel * myNameLabel
name label
#define GUIDesignTableLimitedHeight
design for table extended over frame but with limited Height
TLSAttributes * myTLSAttributes
TLS attributes.
PositionVector computeInternalLaneShape(NBEdge *fromE, const NBEdge::Connection &con, int numPoints, NBNode *recordError=0) const
Compute the shape for an internal lane.
#define GUIDesignComboBoxAttribute
Combo box static (cannot be edited) extended over the matrix column.
std::vector< Crossing * > getCrossings() const
return this junctions pedestrian crossings
long onCmdPhaseSwitch(FXObject *, FXSelector, void *)
Called when the user switchs a Phase.
void deletePhase(int index)
TrafficLightType getType() const
get the algorithm type (static etc..)
const std::vector< PhaseDefinition > & getPhases() const
Returns the phases.
This object is responsible for drawing a shape and for supplying a a popup menu. Messages are routete...
const NBConnectionVector & getControlledLinks() const
returns the controlled links (depends on previous call to collectLinks)
void removeAdditionalGLObject(GUIGlObject *o)
Removes an additional object (detector/shape/trigger) from being visualised.
The base class for traffic light logic definitions.
FXScrollWindow * myTableScroll
window for oversized phase tables
void setPhaseMinDuration(int phaseIndex, SUMOTime duration)
FXComboBox * myProgramComboBox
the comboBox for selecting the tl-definition to edit
bool isSelected(GUIGlObjectType type, GUIGlID id)
Returns the information whether the object with the given type and id is selected.
static const SUMOTime UNSPECIFIED_DURATION
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
void editJunction(GNEJunction *junction)
edits the traffic light for the given junction
void p_begin(const std::string &description)
Begin undo command sub-group. This begins a new group of commands that are treated as a single comman...
void selectTLS(bool selected)
notify the junction of being selected in tls-mode. (used to control drawing)
replace program with a newly guessed program
const std::string & getID() const
Returns the id.
void handleMultiChange(GNELane *lane, FXObject *obj, FXSelector sel, void *data)
update phase definition for the current traffic light and phase
The definition of a single phase of the logic.
FXLabel * myProgramLabel
program label
long onUpdNeedsDef(FXObject *, FXSelector, void *)
Called when occurs an update of needs definition.
A RT-tree for efficient storing of SUMO's GL-objects.
FXFont * myTableFont
font for the phase table
long onCmdCleanup(FXObject *, FXSelector, void *)
Called when the user cleans up states.
LinkState getLinkState() const
whether link state has been modfied
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.
long onCmdDefSwitch(FXObject *, FXSelector, void *)
Called when the user switchs a TLS.
long onCmdDefAddOff(FXObject *, FXSelector, void *)
Called when the user adds a OFF.
bool changeAllPhases() const
change all phases
GNEViewNet * myViewNet
View Net for changes.
void clearTLSAttributes()
clear TLS attributes
bool isTLControlled() const
Returns whether this node is controlled by any tls.
std::string getAttribute(SumoXMLAttr key) const
This functions has to be implemented in all GNEAttributeCarriers.
GNEUndoList * getUndoList() const
get the undoList object
GNETLSEditorFrame * myTLSEditorParent
pointer to TLSEditorParent
FXTextField * myNameTextField
name text field
#define GUIDesignTextField
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
void initTLSAttributes(GNEJunction *junction)
initializes the definitions and corresponding listbox
long onCmdCancel(FXObject *, FXSelector, void *)
Called when the user presses the Cancel-button.
GNEEdge & getParentEdge()
Returns underlying parent edge.
NBTrafficLightDefinition * getCurrentTLSDefinition() const
get current definition
void p_end()
End undo command sub-group. If the sub-group is still empty, it will be deleted; otherwise, the sub-group will be added as a new command into parent group. A matching begin() must have been called previously.
GNEJunction * retrieveJunction(const std::string &id, bool failHard=true)
get junction by id
#define GUIDesignAuxiliarHorizontalFrame
design for auxiliar (Without borders) horizontal frame used to pack another frames ...
bool controlsEdge(GNEEdge &edge) const
whether the given edge is controlled by the currently edited tlDef
long onUpdDefCreate(FXObject *, FXSelector, void *)
Called when occurs an update of create definition.
void buildIinternalLanes(NBTrafficLightDefinition *tlDef)
builds internal lanes for the given tlDef
bool myHaveModifications
whether the current tls was modified
long onCmdPhaseEdit(FXObject *, FXSelector, void *)
Called when the user edits a Phase.
std::string state
The state definition.
LinkState
The right-of-way state of a link between two lanes used when constructing a NBTrafficLightLogic, in MSLink and GNEInternalLane.
void computeJunction(GNEJunction *junction)
trigger recomputation of junction shape and logic param[in] window The window to inform about delay ...
~GNETLSEditorFrame()
Destructor.
void handleChange(GNEInternalLane *lane)
update phase definition for the current traffic light and phase
int getTLIndex() const
get Traffic Light index
NBTrafficLightLogic * getLogic()
Returns the internal logic.
virtual const std::string & getMicrosimID() const
Returns the id of the object as known to microsim.
FXDEFMAP(GNETLSEditorFrame) GNETLSEditorFrameMap[]
~TLSAttributes()
destructor
void p_abort()
reverts and discards ALL active command groups
SUMORTree & getVisualisationSpeedUp()
Returns the RTree used for visualisation speed-up.
std::vector< NBConnection > NBConnectionVector
Definition of a connection vector.
static SUMOTime getSUMOTime(const FXString &string)
converts to SUMOTime
A road/street connecting two junctions (netedit-version)
int getNumberOfTLSDefinitions() const
get number of definitions
#define GUIDesignTextFieldNCol
Num of column of text field.
long onUpdDefSwitch(FXObject *, FXSelector, void *)
Called when occurs an update of switch definition.
void updateCycleDuration()
recomputes cycle duration and updates label
static std::string varDurString(SUMOTime dur)
convert duration (potentially undefined) to string
static std::string prune(const std::string &str)
Removes trailing and leading whitechars.
const std::vector< GNELane * > & getLanes()
returns a reference to the lane vector
int getNumberOfPrograms() const
get number of programs
std::vector< GNEEdge * > retrieveEdges(bool onlySelected=false)
return all edges
void addAdditionalGLObject(GUIGlObject *o)
Adds an additional object (detector/shape/trigger) for visualisation.
#define GUIDesignGroupBoxFrame
Group box design extended over frame.
const std::set< NBTrafficLightDefinition * > & getControllingTLS() const
Returns the traffic lights that were assigned to this node (The set of tls that control this node) ...
TLSAttributes(FXComposite *parent, GNETLSEditorFrame *TLSEditorParent)
constructor
long onCmdOK(FXObject *, FXSelector, void *)
SUMOTime getOffset() const
get current offset in SUMOTIme
const std::vector< NBNode * > & getNodes() const
Returns the list of controlled nodes.
long onCmdDefSubRename(FXObject *, FXSelector, void *)
Called when the user sub-renames a TLS.
void setOffset(SUMOTime offset)
set new offset
GNEJunction * myCurrentJunction
the junction of the tls is being modified
const std::vector< NBTrafficLightLogic::PhaseDefinition > & getPhases()
the phase of the current traffic light
void setPhaseDuration(int phaseIndex, SUMOTime duration)
Modifies the duration for an existing phase (used by NETEDIT)
GNENet * getNet() const
get the net object
#define GUIDesignTextFieldReal
text field extended over Frame with thick frame and limited to Doubles/doubles
long onCmdPhaseCreate(FXObject *, FXSelector, void *)
Called when the user creates a Phase.
Represents a single node (junction) during network building.
GUIGlID getGlID() const
Returns the numerical id of the object.
void setStatusBarText(const std::string &text)
set staturBar text
FXTextField * myTextFieldJunctionStatus
text field for junction status
definition related controls
#define GUIDesignLabelLeft
void addStep(SUMOTime duration, const std::string &state, int index=-1)
Adds a phase to the logic.
long onCmdDefRename(FXObject *, FXSelector, void *)
Called when the user renames a TLS.
long onUpdModified(FXObject *, FXSelector, void *)
Called when occurs an update of modified.
#define GUIDesignLabelAttribute
label extended over the matrix column with thick frame and height of 23
FXTextField * myOffsetTextField
the control for modifying offset
NBNode * getNBNode() const
Return net build node.
NBTrafficLightLogic * getLogic(const std::string &id, const std::string &programID) const
Returns the computed logic for the given name.
GUISelectedStorage gSelected
A global holder of selected objects.
NBTrafficLightLogicCont & getTLLogicCont()
returns the tllcont of the underlying netbuilder
NBLoadedSUMOTLDef * myEditedDef
the traffic light definition being edited
void updateDescription() const
update descrition
FXTextField * myTextFieldJunctionID
text field for junction ID
std::vector< NBTrafficLightDefinition * > myTLSDefinitions
the list of Definitions for the current junction
void cleanup()
cleans up previous lanes
FXLabel * myCycleDuration
label with the cycle duration
void initPhaseTable(int index=0)
initialies the phase table