85 FXIMPLEMENT(
GNETLSEditorFrame, FXVerticalFrame, GNETLSEditorFrameMap, ARRAYNUMBER(GNETLSEditorFrameMap))
91 GNEFrame(horizontalFrameParent, viewNet, "Edit Traffic Light"),
92 myTableFont(new FXFont(getApp(), "Courier New", 9)),
94 myHaveModifications(false),
100 myDescription =
new FXLabel(myGroupBoxJunction,
"No Junction Selected\n", 0,
GUIDesignLabelLeft);
109 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_DEF_DELETE,
GUIDesignButton);
138 myPhaseTable->setColumnHeaderMode(LAYOUT_FIX_HEIGHT);
139 myPhaseTable->setColumnHeaderHeight(0);
140 myPhaseTable->setRowHeaderMode(LAYOUT_FIX_WIDTH);
141 myPhaseTable->setRowHeaderWidth(0);
142 myPhaseTable->hide();
143 myPhaseTable->setFont(myTableFont);
144 myPhaseTable->setHelpText(
"phase duration in seconds | phase state");
159 myDiscardModificationsButtons =
new FXButton(myGroupBoxModifications,
"Cancel\t\tDiscard program modifications (Esc)", 0,
this,
MID_CANCEL,
GUIDesignButton);
162 mySaveModificationsButtons =
new FXButton(myGroupBoxModifications,
"Save\t\tSave program modifications (Enter)", 0,
this,
MID_OK,
GUIDesignButton);
209 std::vector<NBNode*> nodes = old->
getNodes();
210 for (std::vector<NBNode*>::iterator it = nodes.begin(); it != nodes.end(); it++) {
286 o->handle(
this, FXSEL(SEL_COMMAND, enable ? FXWindow::ID_ENABLE : FXWindow::ID_DISABLE), 0);
294 o->handle(
this, FXSEL(SEL_COMMAND, enable ? FXWindow::ID_ENABLE : FXWindow::ID_DISABLE), 0);
303 o->handle(
this, FXSEL(SEL_COMMAND, enable ? FXWindow::ID_ENABLE : FXWindow::ID_DISABLE), 0);
311 o->handle(
this, FXSEL(SEL_COMMAND, enable ? FXWindow::ID_ENABLE : FXWindow::ID_DISABLE), 0);
319 o->handle(
this, FXSEL(SEL_COMMAND, enable ? FXWindow::ID_ENABLE : FXWindow::ID_DISABLE), 0);
365 int tlIndex = it->first;
366 std::vector<GNEInternalLane*> lanes = it->second;
367 assert(tlIndex >= 0);
368 assert(tlIndex < (
int)phase.
state.size());
369 for (std::vector<GNEInternalLane*>::iterator it_lane = lanes.begin(); it_lane != lanes.end(); it_lane++) {
386 const std::string state =
myPhaseTable->getItemText(oldIndex, 1).text();
411 FXTablePos* tp = (FXTablePos*)ptr;
412 FXString value =
myPhaseTable->getItemText(tp->row, tp->col);
415 if (GNEAttributeCarrier::canParse<double>(value.text())) {
445 std::string description;
447 description =
"No Junction Selected\n";
450 description =
"Current junction: " + nbn->
getID() +
"\n(";
452 description +=
"uncontrolled, ";
487 std::vector<GNEInternalLane*> lanes = it->second;
488 for (std::vector<GNEInternalLane*>::iterator it_lane = lanes.begin(); it_lane != lanes.end(); it_lane++) {
499 std::string innerID =
":" + nbn->
getID();
501 for (NBConnectionVector::const_iterator it = links.begin(); it != links.end(); it++) {
502 int tlIndex = it->getTLIndex();
504 it->getTo(), it->getToLane()), NUM_POINTS);
509 const std::vector<NBNode::Crossing>& crossings = nbn->
getCrossings();
510 for (std::vector<NBNode::Crossing>::const_iterator it = crossings.begin(); it != crossings.end(); it++) {
528 for (std::set<NBTrafficLightDefinition*>::iterator it = tldefs.begin(); it != tldefs.end(); it++) {
549 const std::vector<NBTrafficLightLogic::PhaseDefinition>& phases =
getPhases();
553 for (
int row = 0; row < (int)phases.size(); row++) {
555 myPhaseTable->setItemText(row, 1, phases[row].state.c_str());
556 myPhaseTable->getItem(row, 1)->setJustify(FXTableItem::LEFT);
569 const std::vector<NBTrafficLightLogic::PhaseDefinition>&
579 const std::vector<NBTrafficLightLogic::PhaseDefinition>& phases =
getPhases();
580 for (
int row = 0; row < (int)phases.size(); row++) {
596 std::set<std::string> fromIDs;
601 for (GNEEdge::LaneVector::const_iterator it_lane = edge.
getLanes().begin(); it_lane != edge.
getLanes().end(); it_lane++) {
602 fromIDs.insert((*it_lane)->getMicrosimID());
608 for (std::vector<GNEEdge*>::iterator it = edges.begin(); it != edges.end(); it++) {
609 for (GNEEdge::LaneVector::const_iterator it_lane = (*it)->getLanes().begin(); it_lane != (*it)->getLanes().end(); it_lane++) {
610 fromIDs.insert((*it_lane)->getMicrosimID());
617 for (std::vector<GNELane*>::iterator it_lane = lanes.begin(); it_lane != lanes.end(); it_lane++) {
618 fromIDs.insert((*it_lane)->getMicrosimID());
624 for (NBConnectionVector::const_iterator it = links.begin(); it != links.end(); it++) {
628 for (std::vector<GNEInternalLane*>::iterator it_lane = lanes.begin(); it_lane != lanes.end(); it_lane++) {
629 (*it_lane)->onDefault(obj, sel, data);
641 for (NBConnectionVector::const_iterator it = links.begin(); it != links.end(); it++) {
653 assert(GNEAttributeCarrier::canParse<double>(
string.text()));
654 return TIME2STEPS(GNEAttributeCarrier::parse<double>(
string.text()));
661 for (std::vector<NBTrafficLightLogic::PhaseDefinition>::const_iterator it =
getPhases().begin(); it !=
getPhases().end(); it++) {
662 cycleDuration += it->duration;
replace program with a newly guessed program
TLIndexMap myInternalLanes
long onCmdGuess(FXObject *, FXSelector, void *)
Called when the user presses the button Guess.
std::vector< NBTrafficLightDefinition * > myDefinitions
the list of Definitions for the current junction
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
FXLabel * myDescription
the label that shows the current editing state
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.
std::string id
the (edge)-id of this crossing
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.
#define GUIDesignTableLimitedHeight
design for table extended over frame but with limited Height
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.
long onCmdPhaseSwitch(FXObject *, FXSelector, void *)
Called when the user switchs a Phase.
void deletePhase(int index)
const std::vector< Crossing > & getCrossings() const
return this junctions pedestrian crossings
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.
bool isSelected(GUIGlObjectType type, GUIGlID id)
Returns the information whether the object with the given type and id is selected.
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
PositionVector shape
The lane's shape.
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...
NBEdge * getFrom() const
returns the from-edge (start of the connection)
void selectTLS(bool selected)
notify the junction of being selected in tls-mode. (used to control drawing)
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.
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
LinkState getLinkState() const
whether link state has been modfied
#define GUIDesignMatrixAttributes
Matrix design extended over Frame and used for represent attributes and their values (Deprecated) ...
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
the window to inform when the tls is modfied
FXTextField * myNameTextField
name text field
bool isTLControlled() const
Returns whether this node is controlled by any tls.
std::string getAttribute(SumoXMLAttr key) const
GNEUndoList * getUndoList() const
get the undoList object
#define GUIDesignTextField
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
long onCmdCancel(FXObject *, FXSelector, void *)
Called when the user presses the Cancel-button.
GNEEdge & getParentEdge()
Returns underlying parent edge.
std::string getLaneID(int lane) const
get Lane ID (Secure)
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
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
definition related controls
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)
~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[]
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.
FXTextField * myOffset
the control for modifying offset
static SUMOTime getSUMOTime(const FXString &string)
converts to SUMOTime
A road/street connecting two junctions (netedit-version)
#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
const std::vector< GNELane * > & getLanes()
returns a reference to the lane vector
void initDefinitions()
initializes the definitions and corresponding listbox
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) ...
int tlLinkNo
the traffic light index of this crossing (if controlled)
long onCmdOK(FXObject *, FXSelector, void *)
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.
FXComboBox * myProgramComboBox
the comboBox for selecting the tl-definition to edit
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.
int getFromLane() const
returns the from-lane
Represents a single node (junction) during network building.
GUIGlID getGlID() const
Returns the numerical id of the object.
A definition of a pedestrian crossing.
void setStatusBarText(const std::string &text)
set staturBar text
int getTLIndex() const
returns the index within the controlling tls or InvalidTLIndex if this link is unontrolled ...
#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
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
void cleanup()
cleans up previous lanes
FXLabel * myCycleDuration
label with the cycle duration
void initPhaseTable(int index=0)
initialies the phase table