118 GNEFrame(viewParent, viewNet, "Edit Traffic Light"),
119 myEditedDef(
nullptr) {
191 WRITE_DEBUG(
"Opening question FXMessageBox 'save TLS'");
193 FXuint answer = FXMessageBox::question(
this, MBOX_YES_NO_CANCEL,
194 "Save TLS Changes",
"%s",
195 "There is unsaved changes in current edited traffic light.\nDo you want to save it before changing mode?");
196 if (answer == MBOX_CLICKED_YES) {
198 WRITE_DEBUG(
"Closed FXMessageBox 'save TLS' with 'YES'");
202 }
else if (answer == MBOX_CLICKED_NO) {
204 WRITE_DEBUG(
"Closed FXMessageBox 'save TLS' with 'No'");
210 WRITE_DEBUG(
"Closed FXMessageBox 'save TLS' with 'Cancel'");
226 std::set<NBTrafficLightDefinition*> origDefs;
230 if (logic !=
nullptr) {
232 std::vector<NBNode*> nodes = def->getNodes();
233 for (
auto it_node : nodes) {
238 tmpTLLCont.
insert(duplicate);
239 origDefs.insert(duplicate);
241 WRITE_WARNING(
"tlLogic '" + def->getID() +
"', program '" + def->getProgramID() +
"' could not be built");
247 std::vector<NBLoadedSUMOTLDef*> loadedTLS;
250 if (sdef !=
nullptr) {
251 loadedTLS.push_back(sdef);
255 for (
auto def : loadedTLS) {
256 if (origDefs.count(def) != 0) {
261 std::vector<NBNode*> nodes = def->getNodes();
263 for (
auto it_node : nodes) {
271 tmpTLLCont.
removeProgram(def->getID(), def->getProgramID(),
false);
333 for (
const auto& internalLane : internalLanes.second) {
343 if (tlDef !=
nullptr) {
347 const std::string innerID =
":" + nbnCurrentJunction->
getID();
350 for (
const auto& link : links) {
351 int tlIndex = link.getTLIndex();
354 const NBEdge::Connection& con = link.getFrom()->getConnection(link.getFromLane(), link.getTo(), link.getToLane());
358 shape = link.getFrom()->getToNode()->computeInternalLaneShape(link.getFrom(),
NBEdge::Connection(link.getFromLane(),
364 const PositionVector laneShapeFrom = link.getFrom()->getLaneShape(link.getFromLane());
365 const PositionVector laneShapeTo = link.getTo()->getLaneShape(link.getToLane());
375 for (
const auto& nbn : tlDef->
getNodes()) {
376 for (
const auto& crossing : nbn->getCrossings()) {
377 if (crossing->tlLinkIndex2 > 0 && crossing->tlLinkIndex2 != crossing->tlLinkIndex) {
390 myInternalLanes[crossing->tlLinkIndex2].push_back(internalLaneReverse);
446 std::set<std::string> fromIDs;
451 fromIDs.insert(it_lane->getMicrosimID());
457 for (
const auto& edge : selectedEdge) {
458 for (
auto it_lane : edge->getLanes()) {
459 fromIDs.insert(it_lane->getMicrosimID());
466 for (
auto it_lane : selectedLanes) {
467 fromIDs.insert(it_lane->getMicrosimID());
473 for (
auto it : links) {
474 if (fromIDs.count(it.getFrom()->getLaneID(it.getFromLane())) > 0) {
475 std::vector<GNEInternalLane*> lanes =
myInternalLanes[it.getTLIndex()];
476 for (
auto it_lane : lanes) {
477 it_lane->onDefault(obj, sel, eventData);
489 for (
auto it : links) {
532 return TIME2STEPS(GNEAttributeCarrier::parse<double>(
string));
546 myTLSEditorParent(TLSEditorParent) {
561 "Assign E1 detectors\tEnable assign E1 mode\tAssign E1 detectors to the current TLS",
562 "Assign E1 detectors\tDisable assign E1 mode\tAssign E1 detectors to the current TLS",
586 const auto junction = myTLSEditorParent->myTLSJunction->getCurrentJunction();
587 if (junction ==
nullptr) {
591 myOffsetTextField->enable();
594 myButtonEditParameters->enable();
595 myParametersTextField->enable();
598 disableE1DetectorMode();
606 myOffsetTextField->setText(
"");
607 myOffsetTextField->disable();
610 myButtonEditParameters->disable();
611 myParametersTextField->setText(
"");
612 myParametersTextField->disable();
619 return getSUMOTime(myOffsetTextField->getText().text());
632 if (GNEAttributeCarrier::canParse<SUMOTime>(myOffsetTextField->getText().text())) {
644 return myParametersTextField->getText().text();
650 myParametersTextField->setText(parameters.c_str());
673 return (mySetDetectorsToggleButton->getState() == TRUE);
680 const auto laneID =
E1->getParentLanes().front()->getID();
682 for (
auto it = myE1Detectors.begin(); it != myE1Detectors.end(); it++) {
683 if (
E1->getID() == it->second) {
685 myE1Detectors.erase(it);
687 myTLSEditorParent->myEditedDef->unsetParameter(laneID);
688 myParametersTextField->setText(myTLSEditorParent->myEditedDef->getParametersStr().c_str());
690 myTLSEditorParent->myTLSDefinition->markAsModified();
692 }
else if (laneID == it->first) {
694 myE1Detectors.erase(it);
695 myE1Detectors[laneID] =
E1->getID();
697 myTLSEditorParent->myEditedDef->setParameter(laneID,
E1->getID());
698 myParametersTextField->setText(myTLSEditorParent->myEditedDef->getParametersStr().c_str());
700 myTLSEditorParent->myTLSDefinition->markAsModified();
705 myE1Detectors[laneID] =
E1->getID();
706 myTLSEditorParent->myEditedDef->setParameter(laneID,
E1->getID());
707 myParametersTextField->setText(myTLSEditorParent->myEditedDef->getParametersStr().c_str());
709 myTLSEditorParent->myTLSDefinition->markAsModified();
714const std::map<std::string, std::string>&
716 return myE1Detectors;
722 mySetDetectorsToggleButton->setState(FALSE, TRUE);
728 if (isValidOffset()) {
729 myTLSEditorParent->myTLSDefinition->markAsModified();
730 myTLSEditorParent->myEditedDef->setOffset(getOffset());
731 myOffsetTextField->killFocus();
732 myTLSEditorParent->update();
740 if (myTLSEditorParent->myTLSDefinition->getNumberOfTLSDefinitions() == 0) {
741 myOffsetTextField->disable();
743 if (myE1Detectors.size() > 0) {
744 myE1Detectors.clear();
745 myTLSEditorParent->getViewNet()->update();
747 }
else if (isSetDetectorsToggleButtonEnabled()) {
748 myOffsetTextField->disable();
749 }
else if (myTLSEditorParent->myTLSJunction->isJoiningJunctions()) {
751 myOffsetTextField->disable();
753 myOffsetTextField->enable();
761 if (isValidParameters()) {
762 myTLSEditorParent->myTLSDefinition->markAsModified();
763 myTLSEditorParent->myEditedDef->setParametersStr(getParameters());
764 myParametersTextField->killFocus();
765 myTLSEditorParent->update();
774 if (myTLSEditorParent->myEditedDef) {
776 const auto previousParameters = getParameters();
783 setParameters(myTLSEditorParent->myEditedDef->getParametersStr());
785 if (getParameters() != previousParameters) {
786 myTLSEditorParent->myTLSDefinition->markAsModified();
799 if (myTLSEditorParent->myTLSDefinition->getNumberOfTLSDefinitions() == 0) {
800 myButtonEditParameters->disable();
801 myParametersTextField->disable();
803 if (myE1Detectors.size() > 0) {
804 myE1Detectors.clear();
805 myTLSEditorParent->getViewNet()->update();
807 }
else if (isSetDetectorsToggleButtonEnabled()) {
808 myButtonEditParameters->disable();
809 myParametersTextField->disable();
810 }
else if (myTLSEditorParent->myTLSJunction->isJoiningJunctions()) {
812 myButtonEditParameters->disable();
813 myParametersTextField->disable();
815 myButtonEditParameters->enable();
816 myParametersTextField->enable();
824 if (mySetDetectorsToggleButton->getState()) {
826 mySetDetectorsToggleButton->setBackColor(FXRGBA(253, 255, 206, 255));
829 mySetDetectorsToggleButton->setBackColor(4293980400);
832 myTLSEditorParent->getViewNet()->update();
839 if (myTLSEditorParent->myTLSDefinition->getNumberOfTLSDefinitions() == 0) {
840 disableE1DetectorMode();
841 mySetDetectorsToggleButton->disable();
842 }
else if (myTLSEditorParent->myTLSJunction->isJoiningJunctions()) {
844 disableE1DetectorMode();
845 mySetDetectorsToggleButton->disable();
847 disableE1DetectorMode();
848 mySetDetectorsToggleButton->disable();
850 mySetDetectorsToggleButton->enable();
859 myE1Detectors.clear();
861 for (
const auto& parameter : myTLSEditorParent->myEditedDef->getParametersMap()) {
863 if (myTLSEditorParent->getViewNet()->getNet()->getAttributeCarriers()->retrieveLane(parameter.first,
false) &&
864 myTLSEditorParent->getViewNet()->getNet()->getAttributeCarriers()->retrieveAdditional(
SUMO_TAG_INDUCTION_LOOP, parameter.second,
false)) {
866 myE1Detectors[parameter.first] = parameter.second;
870 myTLSEditorParent->getViewNet()->update();
879 myTLSEditorParent(TLSEditorParent),
880 myCurrentJunction(nullptr) {
909 "Join\tEnable join mode\tJoin TLS and junctions in the current junction.",
910 "Join\tDisable join mode\tJoin TLS and junctions in the current junction.",
915 "Disjoin\tDisjoin current TLS\tDisjoin current TLS.",
929 return myCurrentJunction;
935 myCurrentJunction = junction;
937 updateJunctionDescription();
944 myJunctionIDLabel->setText(
TL(
"Junction ID"));
946 mySelectedJunctionIDs.clear();
948 disableJoiningJunctionMode();
950 if (myCurrentJunction ==
nullptr) {
951 myJunctionIDTextField->setText(
TL(
"no junction selected"));
953 const auto nbn = myCurrentJunction->getNBNode();
955 myJunctionIDTextField->setText(nbn->getID().c_str());
957 if (nbn->getControllingTLS().size() > 0) {
959 const auto NBNodes = (*nbn->getControllingTLS().begin())->getNodes();
961 std::string nodesStr;
962 for (
auto it = NBNodes.begin(); it != NBNodes.end(); it++) {
963 if (it == (NBNodes.end() - 1)) {
964 nodesStr += (*it)->getID();
966 nodesStr += (*it)->getID() +
", ";
970 myJunctionIDTextField->setText(nodesStr.c_str());
972 if (NBNodes.size() > 1) {
973 myJunctionIDLabel->setText(
TL(
"Junction IDs"));
976 myTLSIDTextField->setText((*nbn->getControllingTLS().begin())->getID().c_str());
978 myTLSTypeComboBox->setText(myCurrentJunction->getAttribute(
SUMO_ATTR_TLTYPE).c_str());
986 myJoinTLSToggleButton->setState(FALSE, TRUE);
992 return (myJoinTLSToggleButton->getState() == TRUE);
998 return (std::find(mySelectedJunctionIDs.begin(), mySelectedJunctionIDs.end(), junction->
getID()) != mySelectedJunctionIDs.end());
1005 if (junction != myCurrentJunction) {
1007 auto it = std::find(mySelectedJunctionIDs.begin(), mySelectedJunctionIDs.end(), junction->
getID());
1009 if (it == mySelectedJunctionIDs.end()) {
1010 mySelectedJunctionIDs.push_back(junction->
getID());
1012 mySelectedJunctionIDs.erase(it);
1018const std::vector<std::string>&
1020 return mySelectedJunctionIDs;
1027 const std::string currentTLID = (*myCurrentJunction->getNBNode()->getControllingTLS().begin())->getID();
1028 const std::string newTLID = myTLSIDTextField->getText().text();
1030 if (newTLID.empty() || (newTLID == currentTLID)) {
1032 myTLSIDTextField->setTextColor(FXRGB(0, 0, 0));
1033 myTLSIDTextField->setText(currentTLID.c_str());
1034 myTLSIDTextField->killFocus();
1035 myTLSEditorParent->update();
1037 myTLSEditorParent->myTLSDefinition->showTLSDefinition();
1038 myTLSEditorParent->myTLSAttributes->showTLSAttributes();
1039 myTLSEditorParent->myTLSPhases->showTLSPhases();
1040 myTLSEditorParent->myTLSFile->showTLSFile();
1043 myTLSIDTextField->setTextColor(FXRGB(255, 0, 0));
1045 myTLSEditorParent->myTLSDefinition->hideTLSDefinition();
1046 myTLSEditorParent->myTLSAttributes->hideTLSAttributes();
1047 myTLSEditorParent->myTLSPhases->hideTLSPhases();
1048 myTLSEditorParent->myTLSFile->hideTLSFile();
1051 auto junction = myCurrentJunction;
1052 const auto tlDef = myTLSEditorParent->myTLSDefinition->getCurrentTLSDefinition();
1054 myTLSIDTextField->setTextColor(FXRGB(0, 0, 0));
1055 myTLSIDTextField->killFocus();
1056 myTLSEditorParent->update();
1058 myTLSEditorParent->myTLSDefinition->discardChanges(
false);
1060 myTLSEditorParent->getViewNet()->getUndoList()->begin(
GUIIcon::MODETLS,
"rename TLS");
1061 myTLSEditorParent->getViewNet()->getUndoList()->add(
new GNEChange_TLS(junction, tlDef, newTLID),
true);
1062 myTLSEditorParent->getViewNet()->getUndoList()->end();
1064 myTLSEditorParent->myTLSDefinition->showTLSDefinition();
1065 myTLSEditorParent->myTLSAttributes->showTLSAttributes();
1066 myTLSEditorParent->myTLSPhases->showTLSPhases();
1067 myTLSEditorParent->myTLSFile->showTLSFile();
1069 myTLSEditorParent->editJunction(junction);
1077 if (myCurrentJunction ==
nullptr) {
1079 myTLSIDTextField->setText(
"");
1080 myTLSIDTextField->disable();
1081 }
else if (myCurrentJunction->getNBNode()->getControllingTLS().size() == 0) {
1083 myTLSIDTextField->disable();
1084 }
else if (myTLSEditorParent->myTLSAttributes->isSetDetectorsToggleButtonEnabled()) {
1086 myTLSIDTextField->disable();
1087 }
else if (myTLSEditorParent->myTLSJunction->isJoiningJunctions()) {
1089 myTLSIDTextField->disable();
1090 }
else if (myTLSEditorParent->myTLSDefinition->checkHaveModifications()) {
1092 myTLSIDTextField->disable();
1093 }
else if (isJoiningJunctions()) {
1095 myTLSIDTextField->handle(
this, FXSEL(SEL_COMMAND, ID_DISABLE),
nullptr);
1098 myTLSIDTextField->enable();
1107 const std::string currentTLType =
toString((*myCurrentJunction->getNBNode()->getControllingTLS().begin())->getType());
1108 const std::string newTLType = myTLSTypeComboBox->getText().text();
1110 if (newTLType.empty() || (newTLType == currentTLType)) {
1112 myTLSTypeComboBox->setTextColor(FXRGB(0, 0, 0));
1113 myTLSTypeComboBox->setText(currentTLType.c_str());
1114 myTLSTypeComboBox->killFocus();
1115 myTLSEditorParent->update();
1117 myTLSEditorParent->myTLSDefinition->showTLSDefinition();
1118 myTLSEditorParent->myTLSAttributes->showTLSAttributes();
1119 myTLSEditorParent->myTLSPhases->showTLSPhases();
1120 myTLSEditorParent->myTLSFile->showTLSFile();
1123 myTLSTypeComboBox->setTextColor(FXRGB(255, 0, 0));
1125 myTLSEditorParent->myTLSDefinition->hideTLSDefinition();
1126 myTLSEditorParent->myTLSAttributes->hideTLSAttributes();
1127 myTLSEditorParent->myTLSPhases->hideTLSPhases();
1128 myTLSEditorParent->myTLSFile->hideTLSFile();
1131 myTLSTypeComboBox->setTextColor(FXRGB(0, 0, 0));
1132 myTLSTypeComboBox->killFocus();
1133 myTLSEditorParent->update();
1135 auto junction = myCurrentJunction;
1137 myTLSEditorParent->myTLSDefinition->discardChanges(
false);
1139 myTLSEditorParent->getViewNet()->getUndoList()->begin(
GUIIcon::MODETLS,
"change TLS type");
1140 junction->setAttribute(
SUMO_ATTR_TLTYPE, newTLType, myTLSEditorParent->getViewNet()->getUndoList());
1141 myTLSEditorParent->getViewNet()->getUndoList()->end();
1143 myTLSEditorParent->myTLSDefinition->showTLSDefinition();
1144 myTLSEditorParent->myTLSAttributes->showTLSAttributes();
1145 myTLSEditorParent->myTLSPhases->showTLSPhases();
1146 myTLSEditorParent->myTLSFile->showTLSFile();
1148 myTLSEditorParent->editJunction(junction);
1157 if (myCurrentJunction ==
nullptr) {
1159 myTLSTypeComboBox->setText(
"");
1160 myTLSTypeComboBox->disable();
1161 }
else if (myTLSEditorParent->myTLSAttributes->isSetDetectorsToggleButtonEnabled()) {
1163 myTLSTypeComboBox->disable();
1164 }
else if (myTLSEditorParent->myTLSJunction->isJoiningJunctions()) {
1166 myTLSTypeComboBox->disable();
1167 }
else if (myCurrentJunction->getNBNode()->getControllingTLS().size() == 0) {
1169 myTLSTypeComboBox->disable();
1170 }
else if (myTLSEditorParent->myTLSDefinition->checkHaveModifications()) {
1172 myTLSTypeComboBox->disable();
1175 myTLSTypeComboBox->enable();
1183 if (myJoinTLSToggleButton->getState()) {
1185 myJoinTLSToggleButton->setBackColor(FXRGBA(253, 255, 206, 255));
1187 mySelectedJunctionIDs.clear();
1189 const auto TLNodes = (*myCurrentJunction->getNBNode()->getControllingTLS().begin())->getNodes();
1191 mySelectedJunctionIDs.clear();
1192 for (
const auto& TLNode : TLNodes) {
1193 mySelectedJunctionIDs.push_back(TLNode->getID());
1197 const auto currentJunction = myCurrentJunction;
1199 std::vector<GNEJunction*> selectedJunctions, resetTLJunctions;
1201 for (
const auto& selectedJunctionID : mySelectedJunctionIDs) {
1202 if (selectedJunctionID != currentJunction->getID()) {
1203 selectedJunctions.push_back(myTLSEditorParent->getViewNet()->getNet()->getAttributeCarriers()->retrieveJunction(selectedJunctionID));
1207 for (
const auto& TLNBNode : (*currentJunction->getNBNode()->getControllingTLS().begin())->getNodes()) {
1208 if (TLNBNode != currentJunction->getNBNode()) {
1209 resetTLJunctions.push_back(myTLSEditorParent->getViewNet()->getNet()->getAttributeCarriers()->retrieveJunction(TLNBNode->getID()));
1213 myTLSEditorParent->myTLSDefinition->discardChanges(
false);
1215 myTLSEditorParent->getViewNet()->getUndoList()->begin(
GUIIcon::MODETLS,
"join TLS");
1217 for (
const auto& resetTLJunction : resetTLJunctions) {
1218 resetTLJunction->setAttribute(
SUMO_ATTR_TYPE,
"priority", myTLSEditorParent->getViewNet()->getUndoList());
1221 for (
const auto& selectedJunction : selectedJunctions) {
1222 selectedJunction->setAttribute(
SUMO_ATTR_TYPE, currentJunction->getAttribute(
SUMO_ATTR_TYPE), myTLSEditorParent->getViewNet()->getUndoList());
1223 selectedJunction->setAttribute(
SUMO_ATTR_TLID, currentJunction->getAttribute(
SUMO_ATTR_TLID), myTLSEditorParent->getViewNet()->getUndoList());
1226 myTLSEditorParent->getViewNet()->getUndoList()->end();
1228 myJoinTLSToggleButton->setBackColor(4293980400);
1230 mySelectedJunctionIDs.clear();
1232 myTLSEditorParent->editJunction(currentJunction);
1235 myTLSEditorParent->getViewNet()->update();
1242 if (myCurrentJunction ==
nullptr) {
1244 return sender->handle(
this, FXSEL(SEL_COMMAND, ID_DISABLE),
nullptr);
1245 }
else if (myTLSEditorParent->myTLSAttributes->isSetDetectorsToggleButtonEnabled()) {
1247 return sender->handle(
this, FXSEL(SEL_COMMAND, ID_DISABLE),
nullptr);
1248 }
else if (myTLSEditorParent->myTLSDefinition->checkHaveModifications()) {
1250 return sender->handle(
this, FXSEL(SEL_COMMAND, ID_DISABLE),
nullptr);
1251 }
else if (myCurrentJunction->getNBNode()->getControllingTLS().size() == 0) {
1253 return sender->handle(
this, FXSEL(SEL_COMMAND, ID_DISABLE),
nullptr);
1256 return sender->handle(
this, FXSEL(SEL_COMMAND, ID_ENABLE),
nullptr);
1264 const auto currentJunction = myCurrentJunction;
1266 std::vector<GNEJunction*> resetTLJunctions;
1268 for (
const auto& TLNBNode : (*currentJunction->getNBNode()->getControllingTLS().begin())->getNodes()) {
1269 resetTLJunctions.push_back(myTLSEditorParent->getViewNet()->getNet()->getAttributeCarriers()->retrieveJunction(TLNBNode->getID()));
1272 const auto type = resetTLJunctions.front()->getAttribute(
SUMO_ATTR_TYPE);
1273 const auto tlType = resetTLJunctions.front()->getAttribute(
SUMO_ATTR_TLTYPE);
1275 myTLSEditorParent->myTLSDefinition->discardChanges(
false);
1277 myTLSEditorParent->getViewNet()->getUndoList()->begin(
GUIIcon::MODETLS,
"disjoin TLS");
1279 for (
const auto& resetTLJunction : resetTLJunctions) {
1280 resetTLJunction->setAttribute(
SUMO_ATTR_TYPE,
"priority", myTLSEditorParent->getViewNet()->getUndoList());
1281 resetTLJunction->setAttribute(
SUMO_ATTR_TYPE, type, myTLSEditorParent->getViewNet()->getUndoList());
1282 resetTLJunction->setAttribute(
SUMO_ATTR_TLTYPE, tlType, myTLSEditorParent->getViewNet()->getUndoList());
1285 myTLSEditorParent->getViewNet()->getUndoList()->end();
1287 myJoinTLSToggleButton->setBackColor(4293980400);
1289 mySelectedJunctionIDs.clear();
1291 myTLSEditorParent->editJunction(currentJunction);
1298 if (myCurrentJunction ==
nullptr) {
1300 return sender->handle(
this, FXSEL(SEL_COMMAND, ID_DISABLE),
nullptr);
1301 }
else if (myTLSEditorParent->myTLSAttributes->isSetDetectorsToggleButtonEnabled()) {
1303 return sender->handle(
this, FXSEL(SEL_COMMAND, ID_DISABLE),
nullptr);
1304 }
else if (myTLSEditorParent->myTLSJunction->isJoiningJunctions()) {
1306 return sender->handle(
this, FXSEL(SEL_COMMAND, ID_DISABLE),
nullptr);
1307 }
else if (myTLSEditorParent->myTLSDefinition->checkHaveModifications()) {
1309 return sender->handle(
this, FXSEL(SEL_COMMAND, ID_DISABLE),
nullptr);
1310 }
else if (myCurrentJunction->getNBNode()->getControllingTLS().size() == 0) {
1312 return sender->handle(
this, FXSEL(SEL_COMMAND, ID_DISABLE),
nullptr);
1313 }
else if ((*myCurrentJunction->getNBNode()->getControllingTLS().begin())->getNodes().size() == 1) {
1315 return sender->handle(
this, FXSEL(SEL_COMMAND, ID_DISABLE),
nullptr);
1318 return sender->handle(
this, FXSEL(SEL_COMMAND, ID_ENABLE),
nullptr);
1328 myTLSEditorParent(TLSEditorParent) {
1340 myCreateButton =
new FXButton(verticalFrameAuxA,
TL(
"Create TLS\t\tCreate a new traffic light program."),
1343 new FXButton(verticalFrameAuxA,
TL(
"Delete\t\tDelete a traffic light program. If all programs are deleted the junction turns into a priority junction."),
1346 new FXButton(verticalFrameAuxB,
TL(
"Reset single\t\\Reset current TLS program."),
1349 new FXButton(verticalFrameAuxB,
TL(
"Reset all\t\tReset all TLS programs."),
1352 new FXButton(verticalFrameAuxA,
TL(
"Save\t\tSave program modifications. (Enter)"),
1355 new FXButton(verticalFrameAuxB,
TL(
"Cancel\t\tDiscard program modifications. (Esc)"),
1380 const auto junction = myTLSEditorParent->myTLSJunction->getCurrentJunction();
1381 if (junction ==
nullptr) {
1385 myTLSDefinitions.clear();
1387 std::set<std::string> programIDs;
1388 for (
const auto&
TLS : junction->getNBNode()->getControllingTLS()) {
1389 myTLSDefinitions.push_back(
TLS);
1390 programIDs.insert(
TLS->getProgramID());
1392 for (
const auto& programID : programIDs) {
1393 myProgramComboBox->appendItem(programID.c_str());
1396 if (myTLSDefinitions.size() > 0) {
1397 myProgramComboBox->enable();
1398 myProgramComboBox->setCurrentItem(0);
1399 myProgramComboBox->setNumVisible(myProgramComboBox->getNumItems());
1401 return switchProgram();
1411 myTLSDefinitions.clear();
1413 myProgramComboBox->clearItems();
1414 myProgramComboBox->disable();
1420 return myProgramComboBox->getNumItems();
1426 return (
int)myTLSDefinitions.size();
1432 return myHaveModifications;
1438 myHaveModifications =
true;
1446 if (
TLSDefinition->getProgramID() == myProgramComboBox->getText().text()) {
1456 if (myProgramComboBox->getNumItems() == 0) {
1459 return myProgramComboBox->getText().text();
1467 auto currentJunction = myTLSEditorParent->myTLSJunction->getCurrentJunction();
1468 if (currentJunction !=
nullptr) {
1469 myTLSEditorParent->getViewNet()->getUndoList()->abortAllChangeGroups();
1470 myTLSEditorParent->cleanup();
1471 myTLSEditorParent->getViewNet()->updateViewNet();
1473 if (editJunctionAgain) {
1474 myTLSEditorParent->editJunction(currentJunction);
1483 GNEJunction* currentJunction = myTLSEditorParent->myTLSJunction->getCurrentJunction();
1485 discardChanges(
false);
1489 createTLS(currentJunction);
1491 myTLSEditorParent->editJunction(currentJunction);
1493 myProgramComboBox->setCurrentItem(myProgramComboBox->getNumItems() - 1, TRUE);
1496 WRITE_DEBUG(
"Opening warning FXMessageBox 'invalid TLS'");
1498 FXMessageBox::warning(
this, MBOX_OK,
1499 "TLS cannot be created",
"%s",
1500 "Traffic Light cannot be created because junction must have\n at least one incoming edge and one outgoing edge.");
1511 const auto currentJunction = myTLSEditorParent->myTLSJunction->getCurrentJunction();
1513 if (currentJunction ==
nullptr) {
1515 sender->handle(
this, FXSEL(SEL_COMMAND, ID_DISABLE),
nullptr);
1516 }
else if (myHaveModifications) {
1518 sender->handle(
this, FXSEL(SEL_COMMAND, ID_DISABLE),
nullptr);
1519 }
else if (myTLSEditorParent->myTLSAttributes->isSetDetectorsToggleButtonEnabled()) {
1521 sender->handle(
this, FXSEL(SEL_COMMAND, ID_DISABLE),
nullptr);
1522 }
else if (myTLSEditorParent->myTLSJunction->isJoiningJunctions()) {
1524 sender->handle(
this, FXSEL(SEL_COMMAND, ID_DISABLE),
nullptr);
1525 }
else if (myTLSEditorParent->myTLSJunction->isJoiningJunctions()) {
1527 sender->handle(
this, FXSEL(SEL_COMMAND, ID_DISABLE),
nullptr);
1530 sender->handle(
this, FXSEL(SEL_COMMAND, ID_ENABLE),
nullptr);
1533 if (currentJunction ==
nullptr) {
1534 myCreateButton->setText(
TL(
"Create"));
1535 }
else if (currentJunction->getNBNode()->isTLControlled()) {
1536 myCreateButton->setText(
TL(
"Duplicate"));
1538 myCreateButton->setText(
TL(
"Create"));
1547 GNEJunction* currentJunction = myTLSEditorParent->myTLSJunction->getCurrentJunction();
1551 const bool changeJunctionType = (myTLSEditorParent->myTLSDefinition->getNumberOfTLSDefinitions() == 1);
1553 discardChanges(
false);
1555 if (changeJunctionType) {
1559 myTLSEditorParent->getViewNet()->getUndoList()->add(
new GNEChange_TLS(currentJunction, tlDef,
false),
true);
1561 myTLSEditorParent->editJunction(currentJunction);
1570 GNEJunction* junction = myTLSEditorParent->myTLSJunction->getCurrentJunction();
1574 discardChanges(
false);
1576 myTLSEditorParent->getViewNet()->getUndoList()->begin(
GUIIcon::MODETLS,
"reset current program");
1578 myTLSEditorParent->getViewNet()->getUndoList()->add(
new GNEChange_TLS(junction, oldDef,
false),
true);
1581 myTLSEditorParent->getViewNet()->getUndoList()->add(
new GNEChange_TLS(junction, newDef,
true,
true),
true);
1585 myTLSEditorParent->getViewNet()->getUndoList()->end();
1587 myTLSEditorParent->editJunction(junction);
1590 for (
int i = 0; i < myProgramComboBox->getNumItems(); i++) {
1591 if (myProgramComboBox->getItem(i).text() == programID) {
1596 myProgramComboBox->setCurrentItem(index, TRUE);
1605 GNEJunction* junction = myTLSEditorParent->myTLSJunction->getCurrentJunction();
1608 std::vector<GNEJunction*> TLSJunctions;
1609 for (
const auto& TLSNode : oldDef->
getNodes()) {
1610 TLSJunctions.push_back(myTLSEditorParent->getViewNet()->getNet()->getAttributeCarriers()->retrieveJunction(TLSNode->getID()));
1613 discardChanges(
false);
1615 myTLSEditorParent->getViewNet()->getUndoList()->begin(
GUIIcon::MODETLS,
"reset TLS");
1621 createTLS(junction);
1630 myTLSEditorParent->getViewNet()->getUndoList()->end();
1632 myTLSEditorParent->editJunction(junction);
1647 if (getNumberOfTLSDefinitions() == 0) {
1648 return sender->handle(
this, FXSEL(SEL_COMMAND, ID_DISABLE),
nullptr);
1649 }
else if (myTLSEditorParent->myTLSAttributes->isSetDetectorsToggleButtonEnabled()) {
1651 return sender->handle(
this, FXSEL(SEL_COMMAND, ID_DISABLE),
nullptr);
1652 }
else if (myTLSEditorParent->myTLSJunction->isJoiningJunctions()) {
1654 return sender->handle(
this, FXSEL(SEL_COMMAND, ID_DISABLE),
nullptr);
1655 }
else if (myHaveModifications) {
1657 return sender->handle(
this, FXSEL(SEL_COMMAND, ID_ENABLE),
nullptr);
1659 return sender->handle(
this, FXSEL(SEL_COMMAND, ID_DISABLE),
nullptr);
1666 if (getNumberOfTLSDefinitions() == 0) {
1667 return sender->handle(
this, FXSEL(SEL_COMMAND, ID_DISABLE),
nullptr);
1668 }
else if (myTLSEditorParent->myTLSAttributes->isSetDetectorsToggleButtonEnabled()) {
1670 return sender->handle(
this, FXSEL(SEL_COMMAND, ID_DISABLE),
nullptr);
1671 }
else if (myTLSEditorParent->myTLSJunction->isJoiningJunctions()) {
1673 return sender->handle(
this, FXSEL(SEL_COMMAND, ID_DISABLE),
nullptr);
1674 }
else if (myHaveModifications) {
1676 return sender->handle(
this, FXSEL(SEL_COMMAND, ID_DISABLE),
nullptr);
1678 return sender->handle(
this, FXSEL(SEL_COMMAND, ID_ENABLE),
nullptr);
1685 if (getNumberOfTLSDefinitions() <= 1) {
1686 return sender->handle(
this, FXSEL(SEL_COMMAND, ID_DISABLE),
nullptr);
1687 }
else if (myTLSEditorParent->myTLSAttributes->isSetDetectorsToggleButtonEnabled()) {
1689 return sender->handle(
this, FXSEL(SEL_COMMAND, ID_DISABLE),
nullptr);
1690 }
else if (myTLSEditorParent->myTLSJunction->isJoiningJunctions()) {
1692 return sender->handle(
this, FXSEL(SEL_COMMAND, ID_DISABLE),
nullptr);
1693 }
else if (myHaveModifications) {
1695 return sender->handle(
this, FXSEL(SEL_COMMAND, ID_DISABLE),
nullptr);
1697 return sender->handle(
this, FXSEL(SEL_COMMAND, ID_ENABLE),
nullptr);
1705 const auto currentJunction = myTLSEditorParent->myTLSJunction->getCurrentJunction();
1707 const auto currentProgram = myProgramComboBox->getCurrentItem();
1709 if (currentJunction !=
nullptr) {
1710 const auto oldDefinition = getCurrentTLSDefinition();
1711 std::vector<NBNode*> nodes = oldDefinition->getNodes();
1712 for (
const auto& node : nodes) {
1714 myTLSEditorParent->getViewNet()->getUndoList()->add(
new GNEChange_TLS(junction, oldDefinition,
false),
true);
1715 myTLSEditorParent->getViewNet()->getUndoList()->add(
new GNEChange_TLS(junction, myTLSEditorParent->myEditedDef,
true),
true);
1718 myTLSEditorParent->getViewNet()->getUndoList()->end();
1720 myHaveModifications =
false;
1722 myTLSEditorParent->myEditedDef =
nullptr;
1723 myTLSEditorParent->cleanup();
1724 myTLSEditorParent->getViewNet()->updateViewNet();
1726 myTLSEditorParent->editJunction(currentJunction);
1728 myProgramComboBox->setCurrentItem(currentProgram, TRUE);
1731 discardChanges(
true);
1740 discardChanges(
true);
1748 const auto currentTLS = getCurrentTLSProgramID();
1750 if (junction ==
nullptr) {
1759 if (
TLS->getProgramID() == currentTLS) {
1764 if (tpl ==
nullptr) {
1780 myTLSEditorParent->getViewNet()->getUndoList()->add(
new GNEChange_TLS(j, newDef,
true,
false),
true);
1782 myTLSEditorParent->getViewNet()->getUndoList()->end();
1785 myTLSEditorParent->getViewNet()->getUndoList()->add(
new GNEChange_TLS(junction,
nullptr,
true,
true),
true);
1792 if (myTLSEditorParent->myTLSJunction->getCurrentJunction() ==
nullptr) {
1794 }
else if (getNumberOfTLSDefinitions() != getNumberOfPrograms()) {
1795 throw ProcessError(
"myProgramComboBox must have the same number of TLSDefinitions");
1798 myHaveModifications =
false;
1804 myTLSEditorParent->getViewNet()->getNet()->computeJunction(myTLSEditorParent->myTLSJunction->getCurrentJunction());
1808 if (tllogic !=
nullptr) {
1810 myTLSEditorParent->buildInternalLanes(tlDef);
1812 delete myTLSEditorParent->myEditedDef;
1815 myTLSEditorParent->myTLSAttributes->setOffset(myTLSEditorParent->myEditedDef->getLogic()->getOffset());
1816 myTLSEditorParent->myTLSAttributes->setParameters(myTLSEditorParent->myEditedDef->getLogic()->getParametersStr());
1818 myTLSEditorParent->myTLSPhases->initPhaseTable();
1821 discardChanges(
false);
1822 myTLSEditorParent->getViewNet()->setStatusBarText(
"Traffic light does not control any links");
1835 myTLSEditorParent(TLSEditorParent) {
1845 "Clean States\tClean unused states from all phase\tClean unused states from all phase. (Not allowed for multiple programs)",
1849 "Add States\tExtend the state vector for all phases by one entry\tExtend the state vector for all phases by one entry. (Unused until a connection or crossing is assigned to the new index)",
1853 "Group Sig.\tShorten state definition by letting connections with the same signal states use the same index\tShorten state definition by letting connections with the same signal states use the same index. (Not allowed for multiple programs)",
1857 "Ungroup Sig.\tLet every connection use a distinct index (reverse state grouping)\tLet every connection use a distinct index (reverse state grouping). (Not allowed for multiple programs)",
1882 return myTLSEditorParent;
1888 return myPhaseTable;
1895 myPhaseTable->clearTable();
1896 if (myTLSEditorParent->myTLSDefinition->getNumberOfTLSDefinitions() > 0) {
1898 initStaticPhaseTable();
1900 initActuatedPhaseTable();
1902 initDelayBasePhaseTable();
1904 initNEMAPhaseTable();
1907 myPhaseTable->selectRow(0);
1909 myPhaseTable->recalcTableWidth();
1910 myPhaseTable->show();
1912 myPhaseTable->hide();
1921 int colDuration = 1;
1927 int colEarliestEnd = -1;
1928 int colLatestEnd = -1;
1962 if (col == colDuration) {
1963 return setDuration(col, row, value);
1964 }
else if (col == colState) {
1965 return setState(col, row, value);
1966 }
else if (col == colNext) {
1967 return setNext(col, row, value);
1968 }
else if (col == colName) {
1969 return setName(row, value);
1970 }
else if (col == colMinDur) {
1971 return setMinDur(row, value);
1972 }
else if (col == colMaxDur) {
1973 return setMaxDur(row, value);
1974 }
else if (col == colEarliestEnd) {
1975 return setEarliestEnd(row, value);
1976 }
else if (col == colLatestEnd) {
1977 return setLatestEnd(row, value);
1978 }
else if (col == colVehExt) {
1979 return setVehExt(row, value);
1980 }
else if (col == colYellow) {
1981 return setYellow(row, value);
1982 }
else if (col == colRed) {
1983 return setRed(row, value);
1993 myTLSEditorParent->myTLSDefinition->markAsModified();
1995 const int newIndex = buildDefaultPhase(row);
2002 myTLSEditorParent->myEditedDef->getLogic()->overrideState(newIndex, c);
2016 myPhaseTable->selectRow(newIndex);
2018 getPhaseTable()->setFocus();
2025 myTLSEditorParent->myTLSDefinition->markAsModified();
2027 const int newIndex = buildDefaultPhase(row);
2029 myTLSEditorParent->myEditedDef->getLogic()->copyPhase(row, row + 1);
2035 myPhaseTable->selectRow(newIndex);
2037 getPhaseTable()->setFocus();
2044 myTLSEditorParent->myTLSDefinition->markAsModified();
2046 const auto newRow =
MAX2(0, (row - 1));
2048 myTLSEditorParent->myEditedDef->getLogic()->deletePhase(row);
2054 myPhaseTable->selectRow(newRow);
2056 getPhaseTable()->setFocus();
2063 myTLSEditorParent->myTLSDefinition->markAsModified();
2068 myTLSEditorParent->myEditedDef->getLogic()->swapfirstPhase();
2070 myTLSEditorParent->myEditedDef->getLogic()->swapPhase(row, row - 1);
2076 myPhaseTable->selectRow((
int)myTLSEditorParent->myEditedDef->getLogic()->getPhases().size() - 1);
2078 myPhaseTable->selectRow(row - 1);
2081 getPhaseTable()->setFocus();
2088 myTLSEditorParent->myTLSDefinition->markAsModified();
2092 if (row == (
int)myTLSEditorParent->myEditedDef->getLogic()->getPhases().size() - 1) {
2093 myTLSEditorParent->myEditedDef->getLogic()->swaplastPhase();
2095 myTLSEditorParent->myEditedDef->getLogic()->swapPhase(row, row + 1);
2100 if (row == (
int)myTLSEditorParent->myEditedDef->getLogic()->getPhases().size() - 1) {
2101 myPhaseTable->selectRow(0);
2103 myPhaseTable->selectRow(row + 1);
2106 getPhaseTable()->setFocus();
2113 const auto& phase = myTLSEditorParent->getPhase(myPhaseTable->getCurrentSelectedRow());
2115 for (
const auto& internalLane : myTLSEditorParent->myInternalLanes) {
2116 int tlIndex = internalLane.first;
2117 std::vector<GNEInternalLane*> lanes = internalLane.second;
2119 if (tlIndex >= 0 && tlIndex < (
int)phase.state.size()) {
2120 state = (
LinkState)phase.state[tlIndex];
2122 for (
const auto& lane : lanes) {
2123 lane->setLinkState(state);
2127 myTLSEditorParent->getViewNet()->updateViewNet();
2133 if (myTLSEditorParent->myTLSAttributes->isSetDetectorsToggleButtonEnabled()) {
2135 sender->handle(getCollapsableFrame(), FXSEL(SEL_COMMAND, FXWindow::ID_DISABLE),
nullptr);
2137 myPhaseTable->disable();
2138 }
else if (myTLSEditorParent->myTLSJunction->isJoiningJunctions()) {
2140 sender->handle(getCollapsableFrame(), FXSEL(SEL_COMMAND, FXWindow::ID_DISABLE),
nullptr);
2142 myPhaseTable->disable();
2143 }
else if (myTLSEditorParent->myTLSDefinition->getNumberOfTLSDefinitions() > 0) {
2144 sender->handle(
this, FXSEL(SEL_COMMAND, FXWindow::ID_ENABLE),
nullptr);
2146 myPhaseTable->enable();
2148 sender->handle(
this, FXSEL(SEL_COMMAND, FXWindow::ID_DISABLE),
nullptr);
2150 myPhaseTable->disable();
2158 if (myTLSEditorParent->myTLSAttributes->isSetDetectorsToggleButtonEnabled()) {
2160 return sender->handle(getCollapsableFrame(), FXSEL(SEL_COMMAND, FXWindow::ID_DISABLE),
nullptr);
2161 }
else if (myTLSEditorParent->myTLSJunction->isJoiningJunctions()) {
2163 return sender->handle(getCollapsableFrame(), FXSEL(SEL_COMMAND, FXWindow::ID_DISABLE),
nullptr);
2164 }
else if (myTLSEditorParent->myTLSDefinition->getNumberOfTLSDefinitions() == 0) {
2165 return sender->handle(
this, FXSEL(SEL_COMMAND, FXWindow::ID_DISABLE),
nullptr);
2166 }
else if (myPhaseTable->getNumRows() <= 1) {
2167 return sender->handle(
this, FXSEL(SEL_COMMAND, FXWindow::ID_DISABLE),
nullptr);
2169 return sender->handle(
this, FXSEL(SEL_COMMAND, FXWindow::ID_ENABLE),
nullptr);
2176 if (myTLSEditorParent->myEditedDef->cleanupStates()) {
2177 myTLSEditorParent->myTLSDefinition->markAsModified();
2179 myTLSEditorParent->buildInternalLanes(myTLSEditorParent->myEditedDef);
2181 myPhaseTable->setFocus();
2182 myTLSEditorParent->myTLSDefinition->markAsModified();
2190 myTLSEditorParent->myEditedDef->getLogic()->setStateLength(myTLSEditorParent->myEditedDef->getLogic()->getNumLinks() + 1);
2191 myTLSEditorParent->myTLSDefinition->markAsModified();
2193 myPhaseTable->setFocus();
2201 myTLSEditorParent->myEditedDef->groupSignals();
2202 myTLSEditorParent->myTLSDefinition->markAsModified();
2203 myTLSEditorParent->buildInternalLanes(myTLSEditorParent->myEditedDef);
2205 myPhaseTable->setFocus();
2213 myTLSEditorParent->myEditedDef->setParticipantsInformation();
2214 myTLSEditorParent->myEditedDef->ungroupSignals();
2215 myTLSEditorParent->myTLSDefinition->markAsModified();
2216 myTLSEditorParent->buildInternalLanes(myTLSEditorParent->myEditedDef);
2218 myPhaseTable->setFocus();
2226 if (myTLSEditorParent->myTLSAttributes->isSetDetectorsToggleButtonEnabled()) {
2228 return sender->handle(getCollapsableFrame(), FXSEL(SEL_COMMAND, FXWindow::ID_DISABLE),
nullptr);
2229 }
else if (myTLSEditorParent->myTLSJunction->isJoiningJunctions()) {
2231 return sender->handle(getCollapsableFrame(), FXSEL(SEL_COMMAND, FXWindow::ID_DISABLE),
nullptr);
2232 }
else if (myTLSEditorParent->myTLSDefinition->getNumberOfTLSDefinitions() == 1) {
2233 return sender->handle(
this, FXSEL(SEL_COMMAND, FXWindow::ID_ENABLE),
nullptr);
2235 return sender->handle(
this, FXSEL(SEL_COMMAND, FXWindow::ID_DISABLE),
nullptr);
2242 if (myTLSEditorParent->myTLSAttributes->isSetDetectorsToggleButtonEnabled()) {
2244 return sender->handle(getCollapsableFrame(), FXSEL(SEL_COMMAND, FXWindow::ID_DISABLE),
nullptr);
2245 }
else if (myTLSEditorParent->myTLSJunction->isJoiningJunctions()) {
2247 return sender->handle(getCollapsableFrame(), FXSEL(SEL_COMMAND, FXWindow::ID_DISABLE),
nullptr);
2248 }
else if (myTLSEditorParent->myTLSDefinition->getNumberOfTLSDefinitions() != 1) {
2249 return sender->handle(
this, FXSEL(SEL_COMMAND, FXWindow::ID_DISABLE),
nullptr);
2250 }
else if (myTLSEditorParent->myEditedDef ==
nullptr) {
2251 return sender->handle(
this, FXSEL(SEL_COMMAND, FXWindow::ID_DISABLE),
nullptr);
2252 }
else if (myTLSEditorParent->myEditedDef->usingSignalGroups()) {
2253 return sender->handle(
this, FXSEL(SEL_COMMAND, FXWindow::ID_DISABLE),
nullptr);
2255 return sender->handle(
this, FXSEL(SEL_COMMAND, FXWindow::ID_ENABLE),
nullptr);
2263 const int colDuration = 1;
2264 const int colState = 2;
2265 const int colNext = 3;
2266 const int colName = 4;
2268 const auto& phases = myTLSEditorParent->myEditedDef->getLogic()->getPhases();
2270 myPhaseTable->setTableSize(
"sup-midtb", (
int)phases.size());
2272 for (
int row = 0; row < (int)phases.size(); row++) {
2273 myPhaseTable->setItemText(row, colDuration,
getSteps2Time(phases.at(row).duration).c_str());
2274 myPhaseTable->setItemText(row, colState, phases.at(row).state.c_str());
2275 myPhaseTable->setItemText(row, colNext, phases.at(row).next.size() > 0 ?
toString(phases.at(row).next).c_str() :
"");
2276 myPhaseTable->setItemText(row, colName, phases.at(row).name.c_str());
2279 myPhaseTable->setColumnLabelTop(colDuration,
"dur");
2280 myPhaseTable->setColumnLabelTop(colState,
"state");
2281 myPhaseTable->setColumnLabelTop(colNext,
"next");
2282 myPhaseTable->setColumnLabelTop(colName,
"name");
2284 updateCycleDuration(colDuration);
2285 updateStateSize(colState);
2287 myPhaseTable->setFocus();
2294 const int colDuration = 1;
2295 const int colMinDur = 2;
2296 const int colMaxDur = 3;
2297 const int colState = 4;
2298 const int colEarliestEnd = 5;
2299 const int colLatestEnd = 6;
2300 const int colNext = 7;
2301 const int colName = 8;
2303 const auto& phases = myTLSEditorParent->myEditedDef->getLogic()->getPhases();
2305 myPhaseTable->setTableSize(
"suffpff-midtb", (
int)phases.size());
2307 for (
int row = 0; row < (int)phases.size(); row++) {
2308 myPhaseTable->setItemText(row, colDuration,
getSteps2Time(phases.at(row).duration).c_str());
2309 myPhaseTable->setItemText(row, colMinDur,
varDurString(phases.at(row).minDur).c_str());
2310 myPhaseTable->setItemText(row, colMaxDur,
varDurString(phases.at(row).maxDur).c_str());
2311 myPhaseTable->setItemText(row, colState, phases.at(row).state.c_str());
2312 myPhaseTable->setItemText(row, colEarliestEnd,
varDurString(phases.at(row).earliestEnd).c_str());
2313 myPhaseTable->setItemText(row, colLatestEnd,
varDurString(phases.at(row).latestEnd).c_str());
2314 myPhaseTable->setItemText(row, colNext, phases.at(row).next.size() > 0 ?
toString(phases.at(row).next).c_str() :
"");
2315 myPhaseTable->setItemText(row, colName, phases.at(row).name.c_str());
2318 myPhaseTable->setColumnLabelTop(colDuration,
"dur");
2319 myPhaseTable->setColumnLabelTop(colMinDur,
"min");
2320 myPhaseTable->setColumnLabelTop(colMaxDur,
"max");
2321 myPhaseTable->setColumnLabelTop(colEarliestEnd,
"ear.end",
"earlyEnd");
2322 myPhaseTable->setColumnLabelTop(colLatestEnd,
"lat.end",
"latestEnd");
2323 myPhaseTable->setColumnLabelTop(colState,
"state");
2324 myPhaseTable->setColumnLabelTop(colNext,
"next");
2325 myPhaseTable->setColumnLabelTop(colName,
"name");
2327 updateCycleDuration(colDuration);
2328 updateStateSize(colState);
2330 myPhaseTable->setFocus();
2337 const int colDuration = 1;
2338 const int colMinDur = 2;
2339 const int colMaxDur = 3;
2340 const int colState = 4;
2341 const int colNext = 5;
2342 const int colName = 6;
2344 const auto& phases = myTLSEditorParent->myEditedDef->getLogic()->getPhases();
2346 myPhaseTable->setTableSize(
"suffp-midtb", (
int)phases.size());
2348 for (
int row = 0; row < (int)phases.size(); row++) {
2349 myPhaseTable->setItemText(row, colDuration,
getSteps2Time(phases.at(row).duration).c_str());
2350 myPhaseTable->setItemText(row, colMinDur,
varDurString(phases.at(row).minDur).c_str());
2351 myPhaseTable->setItemText(row, colMaxDur,
varDurString(phases.at(row).maxDur).c_str());
2352 myPhaseTable->setItemText(row, colState, phases.at(row).state.c_str());
2353 myPhaseTable->setItemText(row, colNext, phases.at(row).next.size() > 0 ?
toString(phases.at(row).next).c_str() :
"");
2354 myPhaseTable->setItemText(row, colName, phases.at(row).name.c_str());
2357 myPhaseTable->setColumnLabelTop(colDuration,
"dur");
2358 myPhaseTable->setColumnLabelTop(colMinDur,
"min");
2359 myPhaseTable->setColumnLabelTop(colMaxDur,
"max");
2360 myPhaseTable->setColumnLabelTop(colState,
"state");
2361 myPhaseTable->setColumnLabelTop(colNext,
"next");
2362 myPhaseTable->setColumnLabelTop(colName,
"name");
2364 updateCycleDuration(colDuration);
2365 updateStateSize(colState);
2367 myPhaseTable->setFocus();
2374 const int colDuration = 1;
2375 const int colMinDur = 2;
2376 const int colMaxDur = 3;
2377 const int colState = 4;
2378 const int colVehExt = 5;
2379 const int colYellow = 6;
2380 const int colRed = 7;
2381 const int colNext = 8;
2382 const int colName = 9;
2384 const auto& phases = myTLSEditorParent->myEditedDef->getLogic()->getPhases();
2386 myPhaseTable->setTableSize(
"suffpfff-midtb", (
int)phases.size());
2388 for (
int row = 0; row < (int)phases.size(); row++) {
2389 myPhaseTable->setItemText(row, colDuration,
getSteps2Time(phases.at(row).duration).c_str());
2390 myPhaseTable->setItemText(row, colMinDur,
varDurString(phases.at(row).minDur).c_str());
2391 myPhaseTable->setItemText(row, colMaxDur,
varDurString(phases.at(row).maxDur).c_str());
2392 myPhaseTable->setItemText(row, colState, phases.at(row).state.c_str());
2393 myPhaseTable->setItemText(row, colVehExt,
varDurString(phases.at(row).vehExt).c_str());
2394 myPhaseTable->setItemText(row, colYellow,
varDurString(phases.at(row).yellow).c_str());
2395 myPhaseTable->setItemText(row, colRed,
varDurString(phases.at(row).red).c_str());
2396 myPhaseTable->setItemText(row, colNext, phases.at(row).next.size() > 0 ?
toString(phases.at(row).next).c_str() :
"");
2397 myPhaseTable->setItemText(row, colName, phases.at(row).name.c_str());
2400 myPhaseTable->setColumnLabelTop(colDuration,
"dur");
2401 myPhaseTable->setColumnLabelTop(colMinDur,
"min");
2402 myPhaseTable->setColumnLabelTop(colMaxDur,
"max");
2403 myPhaseTable->setColumnLabelTop(colState,
"state");
2404 myPhaseTable->setColumnLabelTop(colVehExt,
"vehExt",
"vehicle extension");
2405 myPhaseTable->setColumnLabelTop(colYellow,
"yellow");
2406 myPhaseTable->setColumnLabelTop(colRed,
"red");
2407 myPhaseTable->setColumnLabelTop(colNext,
"next");
2408 myPhaseTable->setColumnLabelTop(colName,
"name");
2410 updateCycleDuration(colDuration);
2411 updateStateSize(colState);
2413 myPhaseTable->setFocus();
2425 const int newIndex = row + 1;
2427 auto duration =
getSUMOTime(myPhaseTable->getItemText(row, 1));
2428 const auto oldState = myPhaseTable->getItemText(row, TLSStatic ? 2 : 4);
2429 auto state = oldState;
2431 std::set<int> crossingIndices;
2432 for (
const auto& node : myTLSEditorParent->myEditedDef->getNodes()) {
2433 for (
const auto& crossing : node->getCrossings()) {
2434 crossingIndices.insert(crossing->tlLinkIndex);
2435 crossingIndices.insert(crossing->tlLinkIndex2);
2439 bool haveGreen =
false;
2440 bool haveYellow =
false;
2441 for (
const auto& linkStateChar : state) {
2448 if (haveGreen && haveYellow) {
2451 for (
int i = 0; i < (int)state.size(); i++) {
2458 }
else if (haveGreen) {
2460 myTLSEditorParent->myEditedDef->setParticipantsInformation();
2461 duration =
TIME2STEPS(myTLSEditorParent->myEditedDef->computeBrakingTime(oc.
getFloat(
"tls.yellow.min-decel")));
2462 for (
int i = 0; i < (int)state.size(); i++) {
2464 if (crossingIndices.count(i) == 0) {
2471 }
else if (haveYellow) {
2474 for (
int i = 0; i < (int)state.size(); i++) {
2481 const int nextIndex = (myPhaseTable->getNumRows() > newIndex) ? newIndex : 0;
2482 const std::string state2 = myPhaseTable->getItemText(nextIndex, (TLSStatic ? 2 : 4));
2483 for (
int i = 0; i < (int)state.size(); i++) {
2486 state[i] = oldState[i];
2495 myTLSEditorParent->myEditedDef->getLogic()->addStep(duration, state, std::vector<int>(),
"", newIndex);
2505 if (value.empty()) {
2507 getPhaseTable()->setItemText(row, col,
getSteps2Time(myTLSEditorParent->getPhase(row).duration).c_str());
2509 }
else if (GNEAttributeCarrier::canParse<double>(value)) {
2513 myTLSEditorParent->myEditedDef->getLogic()->setPhaseDuration(row, duration);
2514 myTLSEditorParent->myTLSDefinition->markAsModified();
2516 updateCycleDuration(col);
2530 const auto& phase = myTLSEditorParent->getPhase(row);
2532 const auto newState = value.empty() ? phase.state : value;
2535 myTLSEditorParent->myEditedDef->getLogic()->addStep(phase.duration, newState, phase.next, phase.name, row);
2542 myTLSEditorParent->myEditedDef->getLogic()->deletePhase(row + 1);
2548 if (value.size() > 0) {
2549 myTLSEditorParent->myTLSDefinition->markAsModified();
2551 myPhaseTable->selectRow(row);
2554 getPhaseTable()->setItemText(row, col, newState);
2557 updateStateSize(col);
2565 if (value.empty()) {
2567 myPhaseTable->setItemText(row, col,
toString(myTLSEditorParent->getPhase(row).next));
2572 const auto nextEdited = GNEAttributeCarrier::parse<std::vector<int> >(value);
2573 for (
const auto nextPhase : nextEdited) {
2574 if ((nextPhase < 0) || (nextPhase >= myPhaseTable->getNumRows())) {
2579 myTLSEditorParent->myEditedDef->getLogic()->setPhaseNext(row, nextEdited);
2580 myTLSEditorParent->myTLSDefinition->markAsModified();
2592 myTLSEditorParent->myEditedDef->getLogic()->setPhaseName(row, value);
2593 myTLSEditorParent->myTLSDefinition->markAsModified();
2601 if (value.empty()) {
2604 myTLSEditorParent->myTLSDefinition->markAsModified();
2606 }
else if (GNEAttributeCarrier::canParse<double>(value)) {
2610 myTLSEditorParent->myEditedDef->getLogic()->setPhaseMinDuration(row, minDur);
2611 myTLSEditorParent->myTLSDefinition->markAsModified();
2618 myTLSEditorParent->myTLSDefinition->markAsModified();
2629 if (value.empty()) {
2632 myTLSEditorParent->myTLSDefinition->markAsModified();
2634 }
else if (GNEAttributeCarrier::canParse<double>(value)) {
2638 myTLSEditorParent->myEditedDef->getLogic()->setPhaseMaxDuration(row, maxDur);
2639 myTLSEditorParent->myTLSDefinition->markAsModified();
2646 myTLSEditorParent->myTLSDefinition->markAsModified();
2657 if (value.empty()) {
2660 myTLSEditorParent->myTLSDefinition->markAsModified();
2662 }
else if (GNEAttributeCarrier::canParse<double>(value)) {
2665 if (earliestEnd > 0) {
2666 myTLSEditorParent->myEditedDef->getLogic()->setPhaseEarliestEnd(row, earliestEnd);
2667 myTLSEditorParent->myTLSDefinition->markAsModified();
2674 myTLSEditorParent->myTLSDefinition->markAsModified();
2685 if (value.empty()) {
2688 myTLSEditorParent->myTLSDefinition->markAsModified();
2690 }
else if (GNEAttributeCarrier::canParse<double>(value)) {
2693 if (latestEnd > 0) {
2694 myTLSEditorParent->myEditedDef->getLogic()->setPhaseLatestEnd(row, latestEnd);
2695 myTLSEditorParent->myTLSDefinition->markAsModified();
2702 myTLSEditorParent->myTLSDefinition->markAsModified();
2713 if (value.empty()) {
2716 myTLSEditorParent->myTLSDefinition->markAsModified();
2718 }
else if (GNEAttributeCarrier::canParse<double>(value)) {
2722 myTLSEditorParent->myEditedDef->getLogic()->setPhaseVehExt(row, vehExt);
2723 myTLSEditorParent->myTLSDefinition->markAsModified();
2730 myTLSEditorParent->myTLSDefinition->markAsModified();
2741 if (value.empty()) {
2744 myTLSEditorParent->myTLSDefinition->markAsModified();
2746 }
else if (GNEAttributeCarrier::canParse<double>(value)) {
2750 myTLSEditorParent->myEditedDef->getLogic()->setPhaseYellow(row, yellow);
2751 myTLSEditorParent->myTLSDefinition->markAsModified();
2758 myTLSEditorParent->myTLSDefinition->markAsModified();
2769 if (value.empty()) {
2772 myTLSEditorParent->myTLSDefinition->markAsModified();
2774 }
else if (GNEAttributeCarrier::canParse<double>(value)) {
2778 myTLSEditorParent->myEditedDef->getLogic()->setPhaseRed(row, red);
2779 myTLSEditorParent->myTLSDefinition->markAsModified();
2786 myTLSEditorParent->myTLSDefinition->markAsModified();
2797 for (
const auto& phase : myTLSEditorParent->myEditedDef->getLogic()->getPhases()) {
2798 cycleDuration += phase.duration;
2801 myPhaseTable->setColumnLabelBot(col,
getSteps2Time(cycleDuration));
2808 myPhaseTable->setColumnLabelBot(col,
"Links: " +
toString(myTLSEditorParent->myEditedDef->getLogic()->getNumLinks()));
2817 myTLSEditorParent(TLSEditorParent) {
2845 FXFileDialog opendialog(getCollapsableFrame(),
"Load TLS Program");
2847 opendialog.setSelectMode(SELECTFILE_EXISTING);
2848 opendialog.setPatternList(
"XML files (*.xml,*.xml.gz)\nAll files (*)");
2852 if (opendialog.execute()) {
2856 tmpTLLCont.
insert(myTLSEditorParent->myEditedDef);
2860 std::set<NBLoadedSUMOTLDef*> newDefsOtherProgram;
2861 for (
auto item : tmpTLLCont.
getPrograms(myTLSEditorParent->myEditedDef->getID())) {
2862 if (item.second != myTLSEditorParent->myEditedDef) {
2864 if (item.first == myTLSEditorParent->myEditedDef->getProgramID()) {
2865 newDefSameProgram = sdef;
2867 newDefsOtherProgram.insert(sdef);
2871 const int newPrograms = (int)newDefsOtherProgram.size();
2872 if (newPrograms > 0 || newDefSameProgram !=
nullptr) {
2873 std::vector<NBNode*> nodes = myTLSEditorParent->myEditedDef->
getNodes();
2874 for (
auto newProg : newDefsOtherProgram) {
2875 for (
auto it_node : nodes) {
2877 myTLSEditorParent->getViewNet()->getUndoList()->add(
new GNEChange_TLS(junction, newProg,
true),
true);
2880 if (newPrograms > 0) {
2881 WRITE_MESSAGE(
"Loaded " +
toString(newPrograms) +
" new programs for tlLogic '" + myTLSEditorParent->myEditedDef->getID() +
"'");
2883 if (newDefSameProgram !=
nullptr) {
2885 myTLSEditorParent->myEditedDef = newDefSameProgram;
2886 WRITE_MESSAGE(
"Updated program '" + newDefSameProgram->
getProgramID() +
"' for tlLogic '" + myTLSEditorParent->myEditedDef->getID() +
"'");
2889 if (tllHandler.
getSeenIDs().count(myTLSEditorParent->myEditedDef->getID()) == 0) {
2890 myTLSEditorParent->getViewNet()->setStatusBarText(
"No programs found for traffic light '" + myTLSEditorParent->myEditedDef->getID() +
"'");
2896 tmpTLLCont.
removeProgram(def->getID(), def->getProgramID(),
false);
2899 myTLSEditorParent->myTLSPhases->initPhaseTable();
2900 myTLSEditorParent->myTLSDefinition->markAsModified();
2909 TL(
"Save TLS Program as"),
".xml",
2924 myTLSEditorParent->myEditedDef->writeParams(device);
2930 const auto& phases = myTLSEditorParent->myEditedDef->getLogic()->getPhases();
2931 for (
const auto& phase : phases) {
2936 if (TLSActuated || TLSDelayBased) {
2982 if (time == std::floor(time)) {
2992 if (myTLSEditorParent->myTLSDefinition->getNumberOfTLSDefinitions() == 0) {
2993 return sender->handle(getCollapsableFrame(), FXSEL(SEL_COMMAND, FXWindow::ID_DISABLE),
nullptr);
2994 }
else if (myTLSEditorParent->myTLSAttributes->isSetDetectorsToggleButtonEnabled()) {
2996 return sender->handle(getCollapsableFrame(), FXSEL(SEL_COMMAND, FXWindow::ID_DISABLE),
nullptr);
2997 }
else if (myTLSEditorParent->myTLSJunction->isJoiningJunctions()) {
2999 return sender->handle(getCollapsableFrame(), FXSEL(SEL_COMMAND, FXWindow::ID_DISABLE),
nullptr);
3001 return sender->handle(getCollapsableFrame(), FXSEL(SEL_COMMAND, FXWindow::ID_ENABLE),
nullptr);
static const int NUM_POINTS
FXDEFMAP(GNETLSEditorFrame::TLSJunction) TLSJunctionMap[]
@ MID_GNE_TLSFRAME_TLSJUNCTION_DISJOIN
Disjoin TLS.
@ MID_GNE_TLSFRAME_DEFINITION_RESETCURRENT
reset current (single) TLS program
@ MID_GNE_TLSFRAME_PHASES_ADDUNUSED
add unused states
@ MID_GNE_TLSFRAME_ATTRIBUTES_TOGGLEDETECTOR
set detectors in TLS
@ MID_GNE_TLSFRAME_TLSJUNCTION_TOGGLEJOIN
join TLS
@ MID_GNE_TLSFRAME_PHASES_CLEANUP
cleanup unused states
@ MID_GNE_TLSFRAME_PHASES_GROUPSTATES
group states
@ MID_GNE_TLSFRAME_DEFINITION_DELETE
delete TLS
@ MID_GNE_TLSFRAME_FILE_SAVEPROGRAM
cleanup unused states
@ MID_GNE_TLSFRAME_PHASES_UNGROUPSTATES
ungroup states
@ MID_GNE_TLSFRAME_DEFINITION_CREATE
Create TLS.
@ MID_GNE_TLSFRAME_DEFINITION_SAVE
accept TLS modification
@ MID_GNE_TLSFRAME_DEFINITION_SWITCHPROGRAM
switch between programs
@ MID_GNE_TLSFRAME_DEFINITION_DISCARD
cancel TLS modification
@ MID_GNE_TLSFRAME_DEFINITION_RESETALL
reset all TLS programs
@ MID_GNE_TLSFRAME_TLSJUNCTION_TYPE
current TLS ID
@ MID_GNE_TLSFRAME_TLSJUNCTION_ID
current TLS ID
@ MID_GNE_TLSFRAME_ATTRIBUTES_OFFSET
TLS offset.
@ MID_GNE_TLSFRAME_ATTRIBUTES_PARAMETERSDIALOG
TLS parameters.
@ MID_GNE_TLSFRAME_FILE_LOADPROGRAM
Load Program.
@ MID_GNE_TLSFRAME_ATTRIBUTES_PARAMETERS
TLS parameters.
#define GUIDesignButtonAttribute
button extended over over column with thick and raise frame
#define GUIDesignComboBoxAttribute
Combo box static (cannot be edited) extended over the matrix column.
#define GUIDesignComboBoxNCol
number of column of every combo box
#define GUIDesignTextField
#define GUIDesignAuxiliarHorizontalFrame
design for auxiliar (Without borders) horizontal frame used to pack another frames
#define GUIDesignLabelAttribute
label extended over the matrix column with thick frame
#define GUIDesignAuxiliarHorizontalFrameUniform
design for auxiliar (Without borders) horizontal frame used to pack another frames uniform
#define GUIDesignTextFieldNCol
Num of column of text field.
FXString gCurrentFolder
The folder used as last.
#define WRITE_MESSAGE(msg)
#define WRITE_WARNING(msg)
std::vector< NBConnection > NBConnectionVector
Definition of a connection vector.
SUMOTime string2time(const std::string &r)
convert string to SUMOTime
@ SUMO_TAG_PHASE
a single phase description
@ SUMO_TAG_TLLOGIC
a traffic light logic
@ SUMO_TAG_JUNCTION
begin/end of the description of a junction
@ SUMO_TAG_INDUCTION_LOOP
alternative tag for e1 detector
LinkState
The right-of-way state of a link between two lanes used when constructing a NBTrafficLightLogic,...
@ LINKSTATE_TL_YELLOW_MAJOR
The link has yellow light, may pass.
@ LINKSTATE_TL_GREEN_MAJOR
The link has green light, may pass.
@ LINKSTATE_DEADEND
This is a dead end link.
@ LINKSTATE_TL_YELLOW_MINOR
The link has yellow light, has to brake anyway.
@ LINKSTATE_TL_RED
The link has red light (must brake)
@ LINKSTATE_TL_GREEN_MINOR
The link has green light, has to brake.
@ SUMO_ATTR_LATEST_END
The maximum time within the cycle for switching (for coordinated actuation)
@ SUMO_ATTR_TLTYPE
node: the type of traffic light
@ SUMO_ATTR_TLID
link,node: the traffic light id responsible for this link
@ SUMO_ATTR_MAXDURATION
maximum duration of a phase
@ SUMO_ATTR_STATE
The state of a link.
@ SUMO_ATTR_EARLIEST_END
The minimum time within the cycle for switching (for coordinated actuation)
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
static std::string addExtension(const std::string &path, const std::string &extension)
Add an extension to the given file path.
An Element which don't belong to GNENet but has influence in the simulation.
const std::string getID() const
get ID (all Attribute Carriers have one)
bool isAttributeCarrierSelected() const
check if attribute carrier is selected
const GNETagProperties & getTagProperty() const
get tagProperty associated with this Attribute Carrier
static bool canParse(const std::string &string)
true if a value of type T can be parsed from string
GNENet * getNet() const
get pointer to net
A road/street connecting two junctions (netedit-version)
const std::vector< GNELane * > & getLanes() const
returns a reference to the lane vector
GNEViewNet * getViewNet() const
get view net
GNEViewNet * myViewNet
FOX need this.
virtual void show()
show Frame
virtual void hide()
hide Frame
This object is responsible for drawing a shape and for supplying a a popup menu. Messages are routete...
LinkState getLinkState() const
whether link state has been modified
int getTLIndex() const
get Traffic Light index
const std::vector< GNEEdge * > & getGNEIncomingEdges() const
Returns incoming GNEEdges.
std::string getAttribute(SumoXMLAttr key) const
void selectTLS(bool selected)
notify the junction of being selected in tls-mode. (used to control drawing)
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
const std::vector< GNEEdge * > & getGNEOutgoingEdges() const
Returns incoming GNEEdges.
NBNode * getNBNode() const
Return net build node.
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
GNEEdge * getParentEdge() const
get parent edge
GNEJunction * retrieveJunction(const std::string &id, bool hardFail=true) const
get junction by id
std::vector< GNELane * > getSelectedLanes() const
get selected lanes
std::vector< GNEEdge * > getSelectedEdges() const
return all edges
SUMORTree & getGrid()
Returns the RTree used for visualisation speed-up.
NBTrafficLightLogicCont & getTLLogicCont()
returns the tllcont of the underlying netbuilder
GNENetHelper::AttributeCarriers * getAttributeCarriers() const
get all attribute carriers used in this net
NBEdgeCont & getEdgeCont()
returns the NBEdgeCont of the underlying netbuilder
void hideOverlappedInspection()
hide template editor
int getNumberOfOverlappedACs() const
get number of overlapped ACSs
void showOverlappedInspection(const GNEViewNetHelper::ObjectsUnderCursor &objectsUnderCursor, const Position &clickedPosition)
show template editor
Dialog for edit parameters.
long onCmdSetParameters(FXObject *, FXSelector, void *)
Called when the user changes parameters of a TLS.
long onCmdSetOffset(FXObject *, FXSelector, void *)
bool isValidOffset()
is current offset valid
long onCmdParametersDialog(FXObject *, FXSelector, void *ptr)
Called when user press edit parameters button.
long onUpdParameters(FXObject *, FXSelector, void *)
Called when the offset is updated.
MFXToggleButtonTooltip * mySetDetectorsToggleButton
toggle button for set detectors mode
bool isSetDetectorsToggleButtonEnabled() const
toggle button for set detectors mode
bool isValidParameters()
are current parameter valid
FXTextField * myOffsetTextField
the TextField for modifying offset
void updateE1Detectors()
FOX needs this.
void disableE1DetectorMode()
disable detector mode
SUMOTime getOffset() const
get current offset in string format
long onUpdSetDetectorMode(FXObject *, FXSelector, void *)
Called when occurs an update of set detector mode.
void setParameters(const std::string ¶meters)
set new parameters
const std::map< std::string, std::string > & getE1Detectors() const
get E1 detectors vinculated with this TLS
void clearTLSAttributes()
clear TLS attributes
long onUpdOffset(FXObject *, FXSelector, void *)
Called when the offset is updated.
void setOffset(const SUMOTime &offset)
set new offset
std::string getParameters() const
get current parameters in string format
bool toggleE1DetectorSelection(const GNEAdditional *E1)
select or unselect E1 detector in the current TLS
void initTLSAttributes()
initializes the definitions and corresponding listbox
FXButton * myButtonEditParameters
button for edit parameters
TLSAttributes(GNETLSEditorFrame *TLSEditorParent)
FOX-declaration.
FXTextField * myParametersTextField
the TextField for modifying parameters
~TLSAttributes()
destructor
void hideTLSAttributes()
hide TLSAttributes
void showTLSAttributes()
show TLSAttributes
long onCmdToggleDetectorMode(FXObject *, FXSelector, void *ptr)
Called when user toggle set detector mode.
void createTLS(GNEJunction *junction)
FOX needs this.
void clearTLSDefinitions()
clear TLS Definitions
long onCmdDefSwitchTLSProgram(FXObject *, FXSelector, void *)
Called when the user switches a TLS.
bool switchProgram()
switch program
long onUpdTLSDisableResetAll(FXObject *, FXSelector, void *)
Called when occurs an update of switch definition.
bool checkHaveModifications() const
check if current TLS was modified
void hideTLSDefinition()
hide TLSDefinition
long onCmdSaveChanges(FXObject *, FXSelector, void *)
Called when the user presses the save-Button.
long onCmdDiscardChanges(FXObject *, FXSelector, void *)
Called when the user presses the Cancel-button.
void markAsModified()
mark Program as modified
FXComboBox * myProgramComboBox
the comboBox for selecting the tl-definition to edit
const std::string getCurrentTLSProgramID() const
get current program ID
int getNumberOfTLSDefinitions() const
get number of TLS definitions
long onCmdResetCurrentProgram(FXObject *, FXSelector, void *)
Called when the user press button reset current TLS Program.
long onCmdDelete(FXObject *, FXSelector, void *)
Called when the user press button delete TLS Program.
int getNumberOfPrograms() const
get number of programs
void showTLSDefinition()
show TLSDefinition
long onUpdCreate(FXObject *, FXSelector, void *)
Called when occurs an update of create definition.
bool initTLSDefinitions()
init TLS Definitions
NBTrafficLightDefinition * getCurrentTLSDefinition() const
get current definition
~TLSDefinition()
destructor
long onCmdCreate(FXObject *, FXSelector, void *)
TLSDefinition(GNETLSEditorFrame *TLSEditorParent)
FOX-declaration.
void discardChanges(const bool editJunctionAgain)
discard changes
long onUpdTLSEnableModified(FXObject *, FXSelector, void *)
Called when occurs an update of switch definition.
long onCmdResetAll(FXObject *, FXSelector, void *)
Called when the user press button reset all TLS Programs.
FXButton * myCreateButton
button for create new Traffic light program
long onUpdTLSDisableModified(FXObject *, FXSelector, void *)
Called when occurs an update of switch definition.
void showTLSFile()
show TLSPhases
void hideTLSFile()
hide TLSPhases
long onCmdLoadTLSProgram(FXObject *, FXSelector, void *)
TLSFile(GNETLSEditorFrame *TLSEditorParent)
FOX-declaration.
std::string writeSUMOTime(SUMOTime steps)
convert SUMOTime into string
long onUpdButtons(FXObject *, FXSelector, void *)
enable buttons, only when a tlLogic is being edited
long onCmdSaveTLSProgram(FXObject *, FXSelector, void *)
save TLS Program to an additional file
long onCmdChangeType(FXObject *, FXSelector, void *)
Called when the user change TLS Type.
long onCmdDisjoinTLS(FXObject *, FXSelector, void *)
Called when the user join TLS.
const std::vector< std::string > & getSelectedJunctionIDs() const
get selected junction IDs
long onUpdTLSType(FXObject *, FXSelector, void *)
Called when occurs an update of modified.
long onCmdToggleJoinTLS(FXObject *, FXSelector, void *)
Called when the user join TLS.
long onCmdRenameTLS(FXObject *, FXSelector, void *)
TLSJunction(GNETLSEditorFrame *TLSEditorParent)
FOX-declaration.
long onUpdJoinTLS(FXObject *, FXSelector, void *)
Called when update join TLS.
MFXToggleButtonTooltip * myJoinTLSToggleButton
Toggle button for join TLS.
void updateJunctionDescription()
update junction description
void toggleJunctionSelected(const GNEJunction *junction)
select or unselect junction in the current TLS
GNEJunction * getCurrentJunction() const
get current modified junction
void setCurrentJunction(GNEJunction *junction)
set current junction
long onUpdDisjoinTLS(FXObject *, FXSelector, void *)
Called when update join TLS.
FXLabel * myJunctionIDLabel
label for junction ID
bool isJunctionSelected(const GNEJunction *junction) const
check if given junction is selected (used fo joining)
void disableJoiningJunctionMode()
disable joining junction mode
MFXButtonTooltip * myDisjoinTLSButton
button for disjoin TLS
bool isJoiningJunctions() const
is joining junctions
MFXTextFieldTooltip * myTLSIDTextField
text field for junction ID
long onUpdTLSID(FXObject *, FXSelector, void *)
Called when occurs an update of modified.
MFXTextFieldTooltip * myJunctionIDTextField
text field for junction ID
MFXIconComboBox * myTLSTypeComboBox
ComboBox for TLS Types.
bool setEarliestEnd(const int row, const std::string &value)
set earliestEnd
long onCmdUngroupStates(FXObject *, FXSelector, void *)
Called when the user ungroups states.
void showTLSPhases()
show TLSPhases
GNETLSTable * myPhaseTable
table for selecting and rearranging phases and for changing duration
long onCmdCleanStates(FXObject *, FXSelector, void *)
long onCmdGroupStates(FXObject *, FXSelector, void *)
Called when the user groups states.
bool setVehExt(const int row, const std::string &value)
set vehExt
int buildDefaultPhase(const int row)
build default phase
TLSPhases(GNETLSEditorFrame *TLSEditorParent)
FOX-declaration.
void movePhaseDown(const int row)
move phase down
void initActuatedPhaseTable()
init actuated phase table
void initPhaseTable()
initializes the phase table
void initNEMAPhaseTable()
init NEMA phase table
bool setYellow(const int row, const std::string &value)
set yellow
bool changePhaseValue(const int col, const int row, const std::string &value)
change phase value (state, name, next, etc.)
long onUpdNeedsSingleDef(FXObject *, FXSelector, void *)
Called to buttons that modify link indices.
void initDelayBasePhaseTable()
init delayBase phase table
void movePhaseUp(const int row)
move phase up
bool setMinDur(const int row, const std::string &value)
set minDur
bool setLatestEnd(const int row, const std::string &value)
set latestEnd
void updateStateSize(const int col)
update state size
long onCmdAddUnusedStates(FXObject *, FXSelector, void *)
Called when the user cleans up states.
void initStaticPhaseTable()
FOX needs this.
long onUpdUngroupStates(FXObject *, FXSelector, void *)
Called to update the ungroups states button.
bool setDuration(const int col, const int row, const std::string &value)
set duration
bool setMaxDur(const int row, const std::string &value)
set maxDur
long onUpdNeedsDef(FXObject *, FXSelector, void *)
enable buttons, only when a tlLogic is being edited
void updateTLSColoring()
update TLS coloring
GNETLSTable * getPhaseTable() const
get phase table
void removePhase(const int row)
delete phase
bool setRed(const int row, const std::string &value)
set red
bool setName(const int row, const std::string &value)
set name
bool setState(const int col, const int row, const std::string &value)
set state
bool setNext(const int col, const int row, const std::string &value)
set next
long onUpdNeedsDefAndPhase(FXObject *, FXSelector, void *)
Called when occurs an update of needs definition and phase.
void duplicatePhase(const int row)
duplicate phase
void addPhase(const int row, const char c=' ')
add phase
GNETLSEditorFrame * getTLSEditorParent() const
get TLSEditor Parent
void hideTLSPhases()
hide TLSPhases
void updateCycleDuration(const int col)
recomputes cycle duration and updates label
void handleChange(GNEInternalLane *lane)
update phase definition for the current traffic light and phase
GNEOverlappedInspection * myOverlappedInspection
Overlapped Inspection.
GNETLSEditorFrame::TLSAttributes * getTLSAttributes() const
get module for TLS attributes
GNETLSEditorFrame::TLSAttributes * myTLSAttributes
module for TLS attributes
static std::string varDurString(SUMOTime dur)
convert duration (potentially undefined) to string
bool isTLSSaved()
check if modifications in TLS was saved
void editJunction(GNEJunction *junction)
edits the traffic light for the given junction
GNETLSEditorFrame::TLSPhases * myTLSPhases
module for TLS Phases
void selectedOverlappedElement(GNEAttributeCarrier *AC)
open GNEAttributesCreator extended dialog (can be reimplemented in frame children)
std::map< int, std::vector< GNEInternalLane * > > myInternalLanes
the internal lanes belonging the the current junction indexed by their tl-index
bool parseTLSPrograms(const std::string &file)
parse TLS Programs from a file
bool controlsEdge(GNEEdge *edge) const
whether the given edge is controlled by the currently edited tlDef
static const std::string getSteps2Time(const SUMOTime value)
converts to SUMOTime
void buildInternalLanes(const NBTrafficLightDefinition *tlDef)
builds internal lanes for the given tlDef
const NBTrafficLightLogic::PhaseDefinition & getPhase(const int index)
get certain phase of the current traffic light
void handleMultiChange(GNELane *lane, FXObject *obj, FXSelector sel, void *data)
update phase definition for the current traffic light and phase
GNETLSEditorFrame::TLSDefinition * myTLSDefinition
module for TLS Definition
GNETLSEditorFrame::TLSJunction * getTLSJunction() const
get module for TLS Junction
static SUMOTime getSUMOTime(const std::string &value)
converts to SUMOTime
~GNETLSEditorFrame()
Destructor.
NBLoadedSUMOTLDef * myEditedDef
the traffic light definition being edited
void frameWidthUpdated()
function called after setting new width in current frame
GNETLSEditorFrame::TLSJunction * myTLSJunction
module for TLS Junction
void editTLS(const Position &clickedPosition, const GNEViewNetHelper::ObjectsUnderCursor &objectsUnderCursor)
edits the traffic light for the given clicked junction
void cleanup()
cleans up previous lanes
GNETLSEditorFrame::TLSDefinition * getTLSDefinition() const
get module for TLS Definition
void show()
show inspector frame
void selectRow(const int rowIndex)
Select a row.
int getCurrentSelectedRow() const
Get current selected row.
void recalcTableWidth()
recalc width (call when all labels and contents are fill)
SumoXMLTag getTag() const
get Tag vinculated with this attribute Property
void begin(GUIIcon icon, const std::string &description)
Begin undo command sub-group with current supermode. This begins a new group of commands that are tre...
void add(GNEChange *command, bool doit=false, bool merge=true)
Add new command, executing it if desired. The new command will be merged with the previous command if...
class used to group all variables related with objects under cursor after a click over view
GNEAdditional * getAdditionalFront() const
get front additional element or a pointer to nullptr
GNEJunction * getJunctionFront() const
get front junction or a pointer to nullptr
GNENet * getNet() const
get the net object
bool changeAllPhases() const
change all phases
GNEViewParent * getViewParent() const
get the net object
GNEUndoList * getUndoList() const
get the undoList object
void setStatusBarText(const std::string &text)
set statusBar text
A single child window which contains a view of the simulation area.
GNEApplicationWindow * getGNEAppWindows() const
get GNE Application Windows
const std::string & getMicrosimID() const
Returns the id of the object as known to microsim.
static FXIcon * getIcon(const GUIIcon which)
returns a icon previously defined in the enum GUIIcon
MFXStaticToolTip * getStaticTooltipMenu() const
get static toolTip for menus
MFXGroupBoxModule (based on FXGroupBox)
FXVerticalFrame * getCollapsableFrame()
get collapsable frame (used by all elements that will be collapsed if button is toggled)
Options
GroupBoxModule options.
FXint getNumItems() const
Return the number of items in the list.
void setNumVisible(FXint nvis)
Set the number of visible items in the drop down list.
FXint appendIconItem(const FXString &text, FXIcon *icon=nullptr, FXColor bgColor=FXRGB(255, 255, 255), void *ptr=nullptr)
append icon
static FXString getFilename2Write(FXWindow *parent, const FXString &header, const FXString &extension, FXIcon *icon, FXString ¤tFolder)
Returns the file name to write.
static FXColor getFXColor(const RGBColor &col)
converts FXColor to RGBColor
A loaded (complete) traffic light logic.
NBTrafficLightLogic * getLogic()
Returns the internal logic.
void setProgramID(const std::string &programID)
Sets the programID.
Represents a single node (junction) during network building.
const std::set< NBTrafficLightDefinition * > & getControllingTLS() const
Returns the traffic lights that were assigned to this node (The set of tls that control this node)
bool isTLControlled() const
Returns whether this node is controlled by any tls.
A traffic light logics which must be computed (only nodes/edges are given)
The base class for traffic light logic definitions.
const std::vector< NBNode * > & getNodes() const
Returns the list of controlled nodes.
const std::string & getProgramID() const
Returns the ProgramID.
TrafficLightType getType() const
get the algorithm type (static etc..)
virtual void setProgramID(const std::string &programID)
Sets the programID.
SUMOTime getOffset()
Returns the offset.
const NBConnectionVector & getControlledLinks() const
returns the controlled links (depends on previous call to collectLinks)
NBTrafficLightLogic * compute(OptionsCont &oc)
Computes the traffic light logic.
static const SUMOTime UNSPECIFIED_DURATION
The definition of a single phase of the logic.
A container for traffic light definitions and built programs.
bool removeProgram(const std::string id, const std::string programID, bool del=true)
Removes a program of a logic definition from the dictionary.
const std::map< std::string, NBTrafficLightDefinition * > & getPrograms(const std::string &id) const
Returns all programs for the given tl-id.
Definitions getDefinitions() const
NBTrafficLightLogic * getLogic(const std::string &id, const std::string &programID) const
Returns the computed logic for the given name.
std::string getNextProgramID(const std::string &id) const
Returns a new (unused) programID for the given traffic light.
bool insert(NBTrafficLightDefinition *logic, bool forceInsert=false)
Adds a logic definition to the dictionary.
A SUMO-compliant built logic for a traffic light.
void setPhaseState(int phaseIndex, int tlIndex, LinkState linkState)
Modifies the state for an existing phase (used by NETEDIT)
const std::vector< PhaseDefinition > & getPhases() const
Returns the phases.
Importer for edge connections stored in XML.
const std::set< std::string > & getSeenIDs()
const std::string & getID() const
Returns the id.
A storage for options typed value containers)
double getFloat(const std::string &name) const
Returns the double-value of the named option (only for Option_Float)
int getInt(const std::string &name) const
Returns the int-value of the named option (only for Option_Integer)
bool isDefault(const std::string &name) const
Returns the information whether the named option has still the default value.
static OptionsCont & getOptions()
Retrieves the options.
Static storage of an output device and its base (abstract) implementation.
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
void close()
Closes the device and removes it from the dictionary.
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
static OutputDevice & getDevice(const std::string &name, bool usePrefix=true)
Returns the described OutputDevice.
bool writeXMLHeader(const std::string &rootElement, const std::string &schemaFile, std::map< SumoXMLAttr, std::string > attrs=std::map< SumoXMLAttr, std::string >(), bool includeConfig=true)
Writes an XML header with optional configuration.
static bool areParametersValid(const std::string &value, bool report=false, const std::string kvsep="=", const std::string sep="|")
check if given string can be parsed to a parameters map "key1=value1|key2=value2|....
A point in 2D or 3D with translation and scaling methods.
void append(const PositionVector &v, double sameThreshold=2.0)
double length() const
Returns the length.
Position positionAtOffset(double pos, double lateralOffset=0) const
Returns the position at the given length.
void move2side(double amount, double maxExtension=100)
move position vector to side using certain ammount
PositionVector reverse() const
reverse position vector
static const RGBColor BLACK
static const RGBColor RED
named colors
void addAdditionalGLObject(GUIGlObject *o, const double exaggeration=1)
Adds an additional object (detector/shape/trigger) for visualisation.
void removeAdditionalGLObject(GUIGlObject *o, const double exaggeration=1)
Removes an additional object (detector/shape/trigger) from being visualised.
static StringBijection< TrafficLightType > TrafficLightTypes
traffic light types
static bool isValidNetID(const std::string &value)
whether the given string is a valid id for a network element
static std::string prune(const std::string &str)
Removes trailing and leading whitechars.
static bool runParser(GenericSAXHandler &handler, const std::string &file, const bool isNet=false, const bool isRoute=false)
Runs the given handler on the given file; returns if everything's ok.
A structure which describes a connection between edges or lanes.
PositionVector viaShape
shape of via
PositionVector shape
shape of Connection