56 #ifdef CHECK_MEMORY_LEAKS 58 #endif // CHECK_MEMORY_LEAKS 93 FXIMPLEMENT(
GNETLSEditorFrame, FXScrollWindow, GNETLSEditorFrameMap, ARRAYNUMBER(GNETLSEditorFrameMap))
99 GNEFrame(parent, viewNet, "Edit Traffic Light"),
100 myTableFont(
new FXFont(getApp(), "Courier New", 9)),
101 myCurrentJunction(0),
102 myHaveModifications(false),
105 myDescription =
new FXLabel(myContentFrame,
"", 0, JUSTIFY_LEFT);
106 new FXHorizontalSeparator(myContentFrame, SEPARATOR_GROOVE | LAYOUT_FILL_X, 0, 0, 0, 2, 2, 2, 4, 4);
109 new FXButton(myContentFrame,
"Create TLS\t\tCreate a new traffic light program", 0,
this,
MID_GNE_DEF_CREATE,
110 ICON_BEFORE_TEXT | LAYOUT_FILL_X | FRAME_THICK | FRAME_RAISED,
111 0, 0, 0, 0, 4, 4, 3, 3);
114 new FXButton(myContentFrame,
115 "Delete TLS\t\tDelete a traffic light program. If all programs are deleted the junction turns into a priority junction.",
116 0,
this,
MID_GNE_DEF_DELETE, ICON_BEFORE_TEXT | LAYOUT_FILL_X | FRAME_THICK | FRAME_RAISED,
117 0, 0, 0, 0, 4, 4, 3, 3);
120 new FXLabel(myContentFrame,
"Name, Program");
122 FRAME_SUNKEN | FRAME_THICK | LISTBOX_NORMAL | LAYOUT_FIX_WIDTH);
125 new FXLabel(myContentFrame,
"Offset");
126 myOffset =
new FXTextField(myContentFrame, 6,
127 this,
MID_GNE_DEF_OFFSET, TEXTFIELD_NORMAL | TEXTFIELD_REAL, 0, 0, 0, 0, 4, 2, 0, 2);
129 new FXHorizontalSeparator(myContentFrame, SEPARATOR_GROOVE | LAYOUT_FILL_X, 0, 0, 0, 2, 2, 2, 4, 4);
132 new FXLabel(myContentFrame,
"Phases");
133 myPhaseTable =
new FXTable(myContentFrame,
this,
MID_GNE_PHASE_TABLE, LAYOUT_FIX_HEIGHT | LAYOUT_FIX_WIDTH);
134 myPhaseTable->setColumnHeaderMode(LAYOUT_FIX_HEIGHT);
135 myPhaseTable->setColumnHeaderHeight(0);
136 myPhaseTable->setRowHeaderMode(LAYOUT_FIX_WIDTH);
137 myPhaseTable->setRowHeaderWidth(0);
138 myPhaseTable->hide();
139 myPhaseTable->setFont(myTableFont);
140 myPhaseTable->setHelpText(
"phase duration in seconds | phase state");
143 myCycleDuration =
new FXLabel(myContentFrame,
"");
146 new FXButton(myContentFrame,
"Copy Phase\t\tInsert duplicate phase after selected phase", 0,
this,
MID_GNE_PHASE_CREATE,
147 ICON_BEFORE_TEXT | LAYOUT_FILL_X | FRAME_THICK | FRAME_RAISED,
148 0, 0, 0, 0, 4, 4, 3, 3);
151 new FXButton(myContentFrame,
"Delete Phase\t\tDelete selected phase", 0,
this,
MID_GNE_PHASE_DELETE,
152 ICON_BEFORE_TEXT | LAYOUT_FILL_X | FRAME_THICK | FRAME_RAISED,
153 0, 0, 0, 0, 4, 4, 3, 3);
155 new FXHorizontalSeparator(myContentFrame, SEPARATOR_GROOVE | LAYOUT_FILL_X, 0, 0, 0, 2, 2, 2, 4, 4);
158 new FXButton(myContentFrame,
"Cancel\t\tDiscard program modifications (Esc)", 0,
this,
MID_CANCEL,
159 ICON_BEFORE_TEXT | LAYOUT_FILL_X | FRAME_THICK | FRAME_RAISED,
160 0, 0, 0, 0, 4, 4, 3, 3);
162 new FXButton(myContentFrame,
"Save\t\tSave program modifications (Enter)", 0,
this,
MID_OK,
163 ICON_BEFORE_TEXT | LAYOUT_FILL_X | FRAME_THICK | FRAME_RAISED,
164 0, 0, 0, 0, 4, 4, 3, 3);
165 new FXHorizontalSeparator(myContentFrame, SEPARATOR_GROOVE | LAYOUT_FILL_X, 0, 0, 0, 2, 2, 2, 4, 4);
185 FXScrollWindow::show();
194 FXScrollWindow::hide();
229 std::vector<NBNode*> nodes = old->
getNodes();
230 for (std::vector<NBNode*>::iterator it = nodes.begin(); it != nodes.end(); it++) {
306 o->handle(
this, FXSEL(SEL_COMMAND, enable ? FXWindow::ID_ENABLE : FXWindow::ID_DISABLE), 0);
314 o->handle(
this, FXSEL(SEL_COMMAND, enable ? FXWindow::ID_ENABLE : FXWindow::ID_DISABLE), 0);
323 o->handle(
this, FXSEL(SEL_COMMAND, enable ? FXWindow::ID_ENABLE : FXWindow::ID_DISABLE), 0);
331 o->handle(
this, FXSEL(SEL_COMMAND, enable ? FXWindow::ID_ENABLE : FXWindow::ID_DISABLE), 0);
339 o->handle(
this, FXSEL(SEL_COMMAND, enable ? FXWindow::ID_ENABLE : FXWindow::ID_DISABLE), 0);
385 int tlIndex = it->first;
386 std::vector<GNEInternalLane*> lanes = it->second;
387 assert(tlIndex >= 0);
388 assert(tlIndex < (
int)phase.
state.size());
389 for (std::vector<GNEInternalLane*>::iterator it_lane = lanes.begin(); it_lane != lanes.end(); it_lane++) {
406 const std::string state =
myPhaseTable->getItemText(oldIndex, 1).text();
431 FXTablePos* tp = (FXTablePos*)ptr;
432 FXString value =
myPhaseTable->getItemText(tp->row, tp->col);
435 if (GNEAttributeCarrier::canParse<SUMOReal>(value.text())) {
465 std::string description;
467 description =
"No Junction Selected\n";
470 description =
"Junction '" + nbn->
getID() +
"'\n(";
472 description +=
"uncontrolled, ";
506 std::vector<GNEInternalLane*> lanes = it->second;
507 for (std::vector<GNEInternalLane*>::iterator it_lane = lanes.begin(); it_lane != lanes.end(); it_lane++) {
518 std::string innerID =
":" + nbn->
getID();
520 for (NBConnectionVector::const_iterator it = links.begin(); it != links.end(); it++) {
521 int tlIndex = it->getTLIndex();
523 it->getTo(), it->getToLane()), NUM_POINTS);
528 const std::vector<NBNode::Crossing>& crossings = nbn->
getCrossings();
529 for (std::vector<NBNode::Crossing>::const_iterator it = crossings.begin(); it != crossings.end(); it++) {
546 for (std::set<NBTrafficLightDefinition*>::iterator it = tldefs.begin(); it != tldefs.end(); it++) {
548 std::string item = (*it)->getID() +
", " + (*it)->getProgramID();
567 const std::vector<NBTrafficLightLogic::PhaseDefinition>& phases =
getPhases();
571 for (
int row = 0; row < (int)phases.size(); row++) {
573 myPhaseTable->setItemText(row, 1, phases[row].state.c_str());
574 myPhaseTable->getItem(row, 1)->setJustify(FXTableItem::LEFT);
577 const int maxWidth = 140 - 4;
580 int spaceForScrollBar = desiredWidth > maxWidth ? 15 : 0;
581 myPhaseTable->setHeight((
int)phases.size() * 21 + spaceForScrollBar);
592 const std::vector<NBTrafficLightLogic::PhaseDefinition>&
602 const std::vector<NBTrafficLightLogic::PhaseDefinition>& phases =
getPhases();
603 for (
int row = 0; row < (int)phases.size(); row++) {
619 std::set<std::string> fromIDs;
624 for (GNEEdge::LaneVector::const_iterator it_lane = edge.
getLanes().begin(); it_lane != edge.
getLanes().end(); it_lane++) {
625 fromIDs.insert((*it_lane)->getMicrosimID());
631 for (std::vector<GNEEdge*>::iterator it = edges.begin(); it != edges.end(); it++) {
632 for (GNEEdge::LaneVector::const_iterator it_lane = (*it)->getLanes().begin(); it_lane != (*it)->getLanes().end(); it_lane++) {
633 fromIDs.insert((*it_lane)->getMicrosimID());
640 for (std::vector<GNELane*>::iterator it_lane = lanes.begin(); it_lane != lanes.end(); it_lane++) {
641 fromIDs.insert((*it_lane)->getMicrosimID());
647 for (NBConnectionVector::const_iterator it = links.begin(); it != links.end(); it++) {
651 for (std::vector<GNEInternalLane*>::iterator it_lane = lanes.begin(); it_lane != lanes.end(); it_lane++) {
652 (*it_lane)->onDefault(obj, sel, data);
664 for (NBConnectionVector::const_iterator it = links.begin(); it != links.end(); it++) {
676 assert(GNEAttributeCarrier::canParse<SUMOReal>(
string.text()));
677 return TIME2STEPS(GNEAttributeCarrier::parse<SUMOReal>(
string.text()));
684 for (std::vector<NBTrafficLightLogic::PhaseDefinition>::const_iterator it =
getPhases().begin(); it !=
getPhases().end(); it++) {
685 cycleDuration += it->duration;
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.
FXLabel * myDescription
the label that shows the current editing state
void hideFramesArea()
hide frames area if all GNEFrames are hidden
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.
PositionVector computeInternalLaneShape(NBEdge *fromE, const NBEdge::Connection &con, int numPoints, NBNode *recordError=0) const
Compute the shape for an internal lane.
long onCmdPhaseSwitch(FXObject *, FXSelector, void *)
Called when the user switchs a Phase.
GNEViewParent * getViewParent() const
get the net object
void deletePhase(int index)
FXListBox * myDefBox
the listbox for selecting the tl-definition to edit
void showFramesArea()
show frames area if at least a GNEFrame is showed
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
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
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
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
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[]
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
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)
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.
const std::set< NBTrafficLightDefinition * > & getControllingTLS() const
Returns the traffic lights that were assigned to 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.
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
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 ...
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.
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