55 #ifdef CHECK_MEMORY_LEAKS 57 #endif // CHECK_MEMORY_LEAKS 92 FXIMPLEMENT(
GNETLSEditor, FXScrollWindow, GNETLSEditorMap, ARRAYNUMBER(GNETLSEditorMap))
103 FXScrollWindow(parent, LAYOUT_FILL_Y | LAYOUT_FIX_WIDTH, 0, 0, WIDTH, 0),
104 myHeaderFont(
new FXFont(getApp(), "Arial", 11, FXFont::Bold)),
105 myTableFont(
new FXFont(getApp(), "Courier New", 9)),
106 myCurrentJunction(0),
107 myUndoList(undoList),
108 myUpdateTarget(updateTarget),
109 myHaveModifications(false),
112 myContentFrame =
new FXVerticalFrame(
this, LAYOUT_FILL_Y | LAYOUT_FIX_WIDTH, 0, 0, WIDTH, 0);
113 FXLabel* heading =
new FXLabel(myContentFrame,
"Edit Traffic Light", 0, JUSTIFY_LEFT);
114 heading->setFont(myHeaderFont);
115 myDescription =
new FXLabel(myContentFrame,
"", 0, JUSTIFY_LEFT);
116 new FXHorizontalSeparator(myContentFrame, SEPARATOR_GROOVE | LAYOUT_FILL_X, 0, 0, 0, 2, 2, 2, 4, 4);
119 new FXButton(myContentFrame,
"Create TLS\t\tCreate a new traffic light program", 0,
this,
MID_GNE_DEF_CREATE,
120 ICON_BEFORE_TEXT | LAYOUT_FILL_X | FRAME_THICK | FRAME_RAISED,
121 0, 0, 0, 0, 4, 4, 3, 3);
124 new FXButton(myContentFrame,
125 "Delete TLS\t\tDelete a traffic light program. If all programs are deleted the junction turns into a priority junction.",
126 0,
this,
MID_GNE_DEF_DELETE, ICON_BEFORE_TEXT | LAYOUT_FILL_X | FRAME_THICK | FRAME_RAISED,
127 0, 0, 0, 0, 4, 4, 3, 3);
130 new FXLabel(myContentFrame,
"Name, Program");
132 FRAME_SUNKEN | FRAME_THICK | LISTBOX_NORMAL | LAYOUT_FIX_WIDTH, 0, 0, WIDTH - 4);
135 new FXLabel(myContentFrame,
"Offset");
136 myOffset =
new FXTextField(myContentFrame, 6,
137 this,
MID_GNE_DEF_OFFSET, TEXTFIELD_NORMAL | TEXTFIELD_REAL, 0, 0, 0, 0, 4, 2, 0, 2);
139 new FXHorizontalSeparator(myContentFrame, SEPARATOR_GROOVE | LAYOUT_FILL_X, 0, 0, 0, 2, 2, 2, 4, 4);
142 new FXLabel(myContentFrame,
"Phases");
143 myPhaseTable =
new FXTable(myContentFrame,
this,
MID_GNE_PHASE_TABLE, LAYOUT_FIX_HEIGHT | LAYOUT_FIX_WIDTH);
144 myPhaseTable->setColumnHeaderMode(LAYOUT_FIX_HEIGHT);
145 myPhaseTable->setColumnHeaderHeight(0);
146 myPhaseTable->setRowHeaderMode(LAYOUT_FIX_WIDTH);
147 myPhaseTable->setRowHeaderWidth(0);
148 myPhaseTable->hide();
149 myPhaseTable->setFont(myTableFont);
150 myPhaseTable->setHelpText(
"phase duration in seconds | phase state");
153 myCycleDuration =
new FXLabel(myContentFrame,
"");
156 new FXButton(myContentFrame,
"Copy Phase\t\tInsert duplicate phase after selected phase", 0,
this,
MID_GNE_PHASE_CREATE,
157 ICON_BEFORE_TEXT | LAYOUT_FILL_X | FRAME_THICK | FRAME_RAISED,
158 0, 0, 0, 0, 4, 4, 3, 3);
161 new FXButton(myContentFrame,
"Delete Phase\t\tDelete selected phase", 0,
this,
MID_GNE_PHASE_DELETE,
162 ICON_BEFORE_TEXT | LAYOUT_FILL_X | FRAME_THICK | FRAME_RAISED,
163 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);
168 new FXButton(myContentFrame,
"Cancel\t\tDiscard program modifications (Esc)", 0,
this,
MID_CANCEL,
169 ICON_BEFORE_TEXT | LAYOUT_FILL_X | FRAME_THICK | FRAME_RAISED,
170 0, 0, 0, 0, 4, 4, 3, 3);
172 new FXButton(myContentFrame,
"Save\t\tSave program modifications (Enter)", 0,
this,
MID_OK,
173 ICON_BEFORE_TEXT | LAYOUT_FILL_X | FRAME_THICK | FRAME_RAISED,
174 0, 0, 0, 0, 4, 4, 3, 3);
175 new FXHorizontalSeparator(myContentFrame, SEPARATOR_GROOVE | LAYOUT_FILL_X, 0, 0, 0, 2, 2, 2, 4, 4);
223 std::vector<NBNode*> nodes = old->
getNodes();
224 for (std::vector<NBNode*>::iterator it = nodes.begin(); it != nodes.end(); it++) {
300 o->handle(
this, FXSEL(SEL_COMMAND, enable ? FXWindow::ID_ENABLE : FXWindow::ID_DISABLE), 0);
308 o->handle(
this, FXSEL(SEL_COMMAND, enable ? FXWindow::ID_ENABLE : FXWindow::ID_DISABLE), 0);
317 o->handle(
this, FXSEL(SEL_COMMAND, enable ? FXWindow::ID_ENABLE : FXWindow::ID_DISABLE), 0);
325 o->handle(
this, FXSEL(SEL_COMMAND, enable ? FXWindow::ID_ENABLE : FXWindow::ID_DISABLE), 0);
333 o->handle(
this, FXSEL(SEL_COMMAND, enable ? FXWindow::ID_ENABLE : FXWindow::ID_DISABLE), 0);
373 const unsigned int index =
myPhaseTable->getCurrentRow();
379 int tlIndex = it->first;
380 std::vector<GNEInternalLane*> lanes = it->second;
381 assert(tlIndex >= 0);
382 assert(tlIndex < (
int)phase.
state.size());
383 for (std::vector<GNEInternalLane*>::iterator it_lane = lanes.begin(); it_lane != lanes.end(); it_lane++) {
396 unsigned int newIndex =
myPhaseTable->getSelStartRow() + 1;
400 const std::string state =
myPhaseTable->getItemText(oldIndex, 1).text();
425 FXTablePos* tp = (FXTablePos*)ptr;
426 FXString value =
myPhaseTable->getItemText(tp->row, tp->col);
429 if (GNEAttributeCarrier::canParse<SUMOReal>(value.text())) {
459 std::string description;
461 description =
"No Junction Selected\n";
464 description =
"Junction '" + nbn->
getID() +
"'\n(";
466 description +=
"uncontrolled, ";
500 std::vector<GNEInternalLane*> lanes = it->second;
501 for (std::vector<GNEInternalLane*>::iterator it_lane = lanes.begin(); it_lane != lanes.end(); it_lane++) {
508 const int NUM_POINTS = 10;
512 std::string innerID =
":" + nbn->
getID();
514 for (NBConnectionVector::const_iterator it = links.begin(); it != links.end(); it++) {
515 int tlIndex = it->getTLIndex();
517 it->getTo(), it->getToLane()), NUM_POINTS);
522 const std::vector<NBNode::Crossing>& crossings = nbn->
getCrossings();
523 for (std::vector<NBNode::Crossing>::const_iterator it = crossings.begin(); it != crossings.end(); it++) {
540 for (std::set<NBTrafficLightDefinition*>::iterator it = tldefs.begin(); it != tldefs.end(); it++) {
542 std::string item = (*it)->getID() +
", " + (*it)->getProgramID();
561 const std::vector<NBTrafficLightLogic::PhaseDefinition>& phases =
getPhases();
565 for (
unsigned int row = 0; row < phases.size(); row++) {
567 myPhaseTable->setItemText(row, 1, phases[row].state.c_str());
568 myPhaseTable->getItem(row, 1)->setJustify(FXTableItem::LEFT);
571 const int maxWidth =
WIDTH - 4;
574 int spaceForScrollBar = desiredWidth > maxWidth ? 15 : 0;
575 myPhaseTable->setHeight((
int)phases.size() * 21 + spaceForScrollBar);
586 const std::vector<NBTrafficLightLogic::PhaseDefinition>&
596 const std::vector<NBTrafficLightLogic::PhaseDefinition>& phases =
getPhases();
597 for (
unsigned int row = 0; row < phases.size(); row++) {
613 std::set<std::string> fromIDs;
618 for (GNEEdge::LaneVector::const_iterator it_lane = edge.
getLanes().begin(); it_lane != edge.
getLanes().end(); it_lane++) {
619 fromIDs.insert((*it_lane)->getMicrosimID());
625 for (std::vector<GNEEdge*>::iterator it = edges.begin(); it != edges.end(); it++) {
626 for (GNEEdge::LaneVector::const_iterator it_lane = (*it)->getLanes().begin(); it_lane != (*it)->getLanes().end(); it_lane++) {
627 fromIDs.insert((*it_lane)->getMicrosimID());
634 for (std::vector<GNELane*>::iterator it_lane = lanes.begin(); it_lane != lanes.end(); it_lane++) {
635 fromIDs.insert((*it_lane)->getMicrosimID());
641 for (NBConnectionVector::const_iterator it = links.begin(); it != links.end(); it++) {
645 for (std::vector<GNEInternalLane*>::iterator it_lane = lanes.begin(); it_lane != lanes.end(); it_lane++) {
646 (*it_lane)->onDefault(obj, sel, data);
658 for (NBConnectionVector::const_iterator it = links.begin(); it != links.end(); it++) {
670 assert(GNEAttributeCarrier::canParse<SUMOReal>(
string.text()));
671 return TIME2STEPS(GNEAttributeCarrier::parse<SUMOReal>(
string.text()));
678 for (std::vector<NBTrafficLightLogic::PhaseDefinition>::const_iterator it =
getPhases().begin(); it !=
getPhases().end(); it++) {
679 cycleDuration += it->duration;
bool controlsEdge(GNEEdge &edge) const
whether the given edge is controlled by the currently edited tlDef
long onCmdDefOffset(FXObject *, FXSelector, void *)
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.
const std::vector< NBTrafficLightLogic::PhaseDefinition > & getPhases()
the phase of the current traffic light
GNEJunction * myCurrentJunction
the junction of the tls is being modified
bool changeAllPhases() const
GNEViewNet * myUpdateTarget
FXLabel * myCycleDuration
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.
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.
void handleMultiChange(GNELane *lane, FXObject *obj, FXSelector sel, void *data)
update phase definition for the current traffic light and phase
long onCmdDefDelete(FXObject *, FXSelector, void *)
GNEEdge & getParentEdge()
Returns underlying parent edge.
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...
FXDEFMAP(GNETLSEditor) GNETLSEditorMap[]
void removeAdditionalGLObject(GUIGlObject *o)
Removes an additional object (detector/shape/trigger) from being visualised.
long onCmdDefCreate(FXObject *, FXSelector, void *)
TLIndexMap myInternalLanes
const std::vector< Crossing > & getCrossings() const
return this junctions pedestrian crossings
The base class for traffic light logic definitions.
const std::string & getMicrosimID() const
Returns the id of the object as known to microsim.
long onCmdDefSwitch(FXObject *, FXSelector, void *)
NBTrafficLightLogicCont & getTLLogicCont()
returns the tllcont of the underlying netbuilder
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 p_begin(const std::string &description)
void updateDescription() const
void selectTLS(bool selected)
notify the junction of being selected in tls-mode. (used to control drawing)
The definition of a single phase of the logic.
long onUpdModified(FXObject *, FXSelector, void *)
A RT-tree for efficient storing of SUMO's GL-objects.
void initPhaseTable(unsigned int index=0)
FXTextField * myOffset
the control for modifying offset
NBEdge * getFrom() const
returns the from-edge (start of the connection)
GUIGlID getGlID() const
Returns the numerical id of the object.
long onUpdDefCreate(FXObject *, FXSelector, void *)
~GNETLSEditor()
Destructor.
const std::string & getID() const
Returns the id.
void cleanup()
cleans up previous lanes
long onCmdPhaseCreate(FXObject *, FXSelector, void *)
void updateCycleDuration()
recomputes cycle duration and updates label
long onCmdDefSubRename(FXObject *, FXSelector, void *)
NBLoadedSUMOTLDef * myEditedDef
the traffic light definition being edited
long onUpdNeedsDefAndPhase(FXObject *, FXSelector, void *)
LinkState getLinkState()
whether link state has been modfied
const std::set< NBTrafficLightDefinition * > & getControllingTLS() const
Returns the traffic lights that were assigned to this node.
std::string getLaneID(unsigned int lane) const
const std::vector< PhaseDefinition > & getPhases() const
Returns the phases.
FXListBox * myDefBox
the listbox for selecting the tl-definition to edit
long onCmdPhaseSwitch(FXObject *, FXSelector, void *)
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 onCmdCancel(FXObject *, FXSelector, void *)
Called when the user presses the Cancel-button discards any modifications.
void setPhaseDuration(unsigned int phaseIndex, SUMOTime duration)
Modifies the duration for an existing phase (used by NETEDIT)
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)
void handleChange(GNEInternalLane *lane)
update phase definition for the current traffic light and phase
NBNode * getNBNode()
returns the internal NBNode
NBTrafficLightLogic * getLogic()
Returns the internal logic.
void setPhaseState(unsigned int phaseIndex, unsigned int tlIndex, LinkState linkState)
Modifies the state for an existing phase (used by NETEDIT)
static SUMOTime getSUMOTime(const FXString &string)
converts to SUMOTime
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
void p_abort()
reverts and discards ALL active command groups
GNEUndoList * myUndoList
the undolist with wich to register changes
FXTable * myPhaseTable
table for selecting and rearranging phases and for changing duration
const std::vector< NBNode * > & getNodes() const
Returns the list of controlled nodes.
long onCmdPhaseEdit(FXObject *, FXSelector, void *)
std::vector< NBConnection > NBConnectionVector
Definition of a connection vector.
FXFont * myTableFont
font for the phase table
SUMOTime getOffset() const
Returns the offset of first switch.
A road/street connecting two junctions (netedit-version)
NBTrafficLightLogic * getLogic(const std::string &id, const std::string &programID) const
Returns the computed logic for the given name.
SUMORTree & getVisualisationSpeedUp()
Returns the RTree used for visualisation speed-up.
PositionVector computeInternalLaneShape(NBEdge *fromE, const NBEdge::Connection &con, int numPoints) const
Compute the shape for an internal lane.
void deletePhase(unsigned int index)
std::vector< GNEEdge * > retrieveEdges(bool onlySelected=false)
return all edges
void addAdditionalGLObject(GUIGlObject *o)
Adds an additional object (detector/shape/trigger) for visualisation.
int tlLinkNo
the traffic light index of this crossing (if controlled)
void editJunction(GNEJunction *junction)
edits the traffic light for the given junction
long onUpdNeedsDef(FXObject *, FXSelector, void *)
Represents a single node (junction) during network building.
FXLabel * myDescription
the label that shows the current editing state
A definition of a pedestrian crossing.
void setStatusBarText(const std::string &text)
long onCmdDefAddOff(FXObject *, FXSelector, void *)
bool myHaveModifications
whether the current tls was modified
std::vector< NBTrafficLightDefinition * > myDefinitions
the list of Definitions for the current junction
std::string getAttribute(SumoXMLAttr key) const
void buildIinternalLanes(NBTrafficLightDefinition *tlDef)
void addStep(SUMOTime duration, const std::string &state, int index=-1)
Adds a phase to the logic.
long onCmdDefRename(FXObject *, FXSelector, void *)
long onCmdGuess(FXObject *, FXSelector, void *)
long onUpdDefSwitch(FXObject *, FXSelector, void *)
long onCmdPhaseDelete(FXObject *, FXSelector, void *)
GUISelectedStorage gSelected
A global holder of selected objects.
long onCmdOK(FXObject *, FXSelector, void *)
Called when the user presses the OK-Button saves any modifications.
FXFont * myHeaderFont
Font for the widget.
const LaneVector & getLanes()
static const int WIDTH
the width of the widget