58 #ifdef CHECK_MEMORY_LEAKS 60 #endif // CHECK_MEMORY_LEAKS 94 FXIMPLEMENT(
GNETLSEditorFrame, FXVerticalFrame, GNETLSEditorFrameMap, ARRAYNUMBER(GNETLSEditorFrameMap))
100 GNEFrame(horizontalFrameParent, viewNet, "Edit Traffic Light"),
101 myTableFont(
new FXFont(getApp(), "Courier New", 9)),
102 myCurrentJunction(0),
103 myHaveModifications(false),
109 myDescription =
new FXLabel(myGroupBoxJunction,
"No Junction Selected\n", 0,
GUIDesignLabelLeft);
118 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);
147 myPhaseTable->setColumnHeaderMode(LAYOUT_FIX_HEIGHT);
148 myPhaseTable->setColumnHeaderHeight(0);
149 myPhaseTable->setRowHeaderMode(LAYOUT_FIX_WIDTH);
150 myPhaseTable->setRowHeaderWidth(0);
151 myPhaseTable->hide();
152 myPhaseTable->setFont(myTableFont);
153 myPhaseTable->setHelpText(
"phase duration in seconds | phase state");
168 myDiscardModificationsButtons =
new FXButton(myGroupBoxModifications,
"Cancel\t\tDiscard program modifications (Esc)", 0,
this,
MID_CANCEL,
GUIDesignButton);
171 mySaveModificationsButtons =
new FXButton(myGroupBoxModifications,
"Save\t\tSave program modifications (Enter)", 0,
this,
MID_OK,
GUIDesignButton);
218 std::vector<NBNode*> nodes = old->
getNodes();
219 for (std::vector<NBNode*>::iterator it = nodes.begin(); it != nodes.end(); it++) {
295 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);
312 o->handle(
this, FXSEL(SEL_COMMAND, enable ? FXWindow::ID_ENABLE : FXWindow::ID_DISABLE), 0);
320 o->handle(
this, FXSEL(SEL_COMMAND, enable ? FXWindow::ID_ENABLE : FXWindow::ID_DISABLE), 0);
328 o->handle(
this, FXSEL(SEL_COMMAND, enable ? FXWindow::ID_ENABLE : FXWindow::ID_DISABLE), 0);
374 int tlIndex = it->first;
375 std::vector<GNEInternalLane*> lanes = it->second;
376 assert(tlIndex >= 0);
377 assert(tlIndex < (
int)phase.
state.size());
378 for (std::vector<GNEInternalLane*>::iterator it_lane = lanes.begin(); it_lane != lanes.end(); it_lane++) {
395 const std::string state =
myPhaseTable->getItemText(oldIndex, 1).text();
420 FXTablePos* tp = (FXTablePos*)ptr;
421 FXString value =
myPhaseTable->getItemText(tp->row, tp->col);
424 if (GNEAttributeCarrier::canParse<SUMOReal>(value.text())) {
454 std::string description;
456 description =
"No Junction Selected\n";
459 description =
"Current junction: " + nbn->
getID() +
"\n(";
461 description +=
"uncontrolled, ";
496 std::vector<GNEInternalLane*> lanes = it->second;
497 for (std::vector<GNEInternalLane*>::iterator it_lane = lanes.begin(); it_lane != lanes.end(); it_lane++) {
508 std::string innerID =
":" + nbn->
getID();
510 for (NBConnectionVector::const_iterator it = links.begin(); it != links.end(); it++) {
511 int tlIndex = it->getTLIndex();
513 it->getTo(), it->getToLane()), NUM_POINTS);
518 const std::vector<NBNode::Crossing>& crossings = nbn->
getCrossings();
519 for (std::vector<NBNode::Crossing>::const_iterator it = crossings.begin(); it != crossings.end(); it++) {
537 for (std::set<NBTrafficLightDefinition*>::iterator it = tldefs.begin(); it != tldefs.end(); it++) {
558 const std::vector<NBTrafficLightLogic::PhaseDefinition>& phases =
getPhases();
562 for (
int row = 0; row < (int)phases.size(); row++) {
564 myPhaseTable->setItemText(row, 1, phases[row].state.c_str());
565 myPhaseTable->getItem(row, 1)->setJustify(FXTableItem::LEFT);
578 const std::vector<NBTrafficLightLogic::PhaseDefinition>&
588 const std::vector<NBTrafficLightLogic::PhaseDefinition>& phases =
getPhases();
589 for (
int row = 0; row < (int)phases.size(); row++) {
605 std::set<std::string> fromIDs;
610 for (GNEEdge::LaneVector::const_iterator it_lane = edge.
getLanes().begin(); it_lane != edge.
getLanes().end(); it_lane++) {
611 fromIDs.insert((*it_lane)->getMicrosimID());
617 for (std::vector<GNEEdge*>::iterator it = edges.begin(); it != edges.end(); it++) {
618 for (GNEEdge::LaneVector::const_iterator it_lane = (*it)->getLanes().begin(); it_lane != (*it)->getLanes().end(); it_lane++) {
619 fromIDs.insert((*it_lane)->getMicrosimID());
626 for (std::vector<GNELane*>::iterator it_lane = lanes.begin(); it_lane != lanes.end(); it_lane++) {
627 fromIDs.insert((*it_lane)->getMicrosimID());
633 for (NBConnectionVector::const_iterator it = links.begin(); it != links.end(); it++) {
637 for (std::vector<GNEInternalLane*>::iterator it_lane = lanes.begin(); it_lane != lanes.end(); it_lane++) {
638 (*it_lane)->onDefault(obj, sel, data);
650 for (NBConnectionVector::const_iterator it = links.begin(); it != links.end(); it++) {
662 assert(GNEAttributeCarrier::canParse<SUMOReal>(
string.
text()));
663 return TIME2STEPS(GNEAttributeCarrier::parse<SUMOReal>(
string.
text()));
670 for (std::vector<NBTrafficLightLogic::PhaseDefinition>::const_iterator it =
getPhases().begin(); it !=
getPhases().end(); it++) {
671 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)
bool controlsEdge(GNEEdge &edge) const
whether the given edge is controlled by the currently edited tlDef
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.
long onCmdDefCreate(FXObject *, FXSelector, void *)
Called when the user creates a TLS.
int getTLIndex() const
returns the index within the controlling tls or InvalidTLIndex if this link is unontrolled ...
bool changeAllPhases() const
change all phases
std::string id
the (edge)-id of this crossing
void setOffset(SUMOTime offset)
Sets the offset of this tls.
#define GUIDesignTextFieldAttributeStr
text field extended over the matrix column with thick frame
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.
bool isTLControlled() const
Returns whether this node is controlled by any tls.
#define GUIDesignTableLimitedHeight
design for table extended over frame but with limited Height
#define GUIDesignTextFieldAttributeReal
text field extended over the matrix column with thick frame and limited to real
#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)
int getFromLane() const
returns the from-lane
This object is responsible for drawing a shape and for supplying a a popup menu. Messages are routete...
void removeAdditionalGLObject(GUIGlObject *o)
Removes an additional object (detector/shape/trigger) from being visualised.
definition related controls
NBNode * getNBNode() const
Return net build node.
const std::vector< Crossing > & getCrossings() const
return this junctions pedestrian crossings
The base class for traffic light logic definitions.
PositionVector computeInternalLaneShape(NBEdge *fromE, const NBEdge::Connection &con, int numPoints, NBNode *recordError=0) const
Compute the shape for an internal lane.
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...
void selectTLS(bool selected)
notify the junction of being selected in tls-mode. (used to control drawing)
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
NBEdge * getFrom() const
returns the from-edge (start of the connection)
GUIGlID getGlID() const
Returns the numerical id of the object.
#define GUIDesignMatrixAttributes
Matrix design extended over Frame and used for represent attributes and their values.
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.
replace program with a newly guessed program
GNEUndoList * getUndoList() const
get the undoList object
GNEViewNet * myViewNet
the window to inform when the tls is modfied
void updateDescription() const
update descrition
FXTextField * myNameTextField
name text field
virtual const std::string & getMicrosimID() const
Returns the id of the object as known to microsim.
const std::string & getID() const
Returns the id.
const std::set< NBTrafficLightDefinition * > & getControllingTLS() const
Returns the traffic lights that were assigned to this node (The set of tls that control this node) ...
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.
const std::vector< PhaseDefinition > & getPhases() const
Returns the phases.
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
const NBConnectionVector & getControlledLinks() const
returns the controlled links (depends on previous call to collectLinks)
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
NBTrafficLightLogic * getLogic()
Returns the internal logic.
FXDEFMAP(GNETLSEditorFrame) GNETLSEditorFrameMap[]
int getTLIndex() const
get Traffic Light index
void p_abort()
reverts and discards ALL active command groups
const std::vector< NBNode * > & getNodes() const
Returns the list of controlled nodes.
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
SUMOTime getOffset() const
Returns the offset of first switch.
A road/street connecting two junctions (netedit-version)
#define GUIDesignTextFieldNCol
Num of column of text field.
NBTrafficLightLogic * getLogic(const std::string &id, const std::string &programID) const
Returns the computed logic for the given name.
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.
int tlLinkNo
the traffic light index of this crossing (if controlled)
long onCmdOK(FXObject *, FXSelector, void *)
long onCmdDefSubRename(FXObject *, FXSelector, void *)
Called when the user sub-renames a TLS.
FXComboBox * myProgramComboBox
the comboBox for selecting the tl-definition to edit
GNENet * getNet() const
get the net object
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)
long onCmdPhaseCreate(FXObject *, FXSelector, void *)
Called when the user creates a Phase.
Represents a single node (junction) during network building.
A definition of a pedestrian crossing.
void setStatusBarText(const std::string &text)
set staturBar text
std::string getLaneID(int lane) const
get Lane ID (Secure)
std::string getAttribute(SumoXMLAttr key) const
#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
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 cleanup()
cleans up previous lanes
FXLabel * myCycleDuration
label with the cycle duration
LinkState getLinkState() const
whether link state has been modfied
void initPhaseTable(int index=0)
initialies the phase table