121 GNEFrame(viewParent, viewNet,
TL("Edit Traffic Light")),
122 myEditedDef(
nullptr) {
194 WRITE_DEBUG(
"Opening question FXMessageBox 'save TLS'");
196 FXuint answer = FXMessageBox::question(
this, MBOX_YES_NO_CANCEL,
197 TL(
"Save TLS Changes"),
"%s",
198 TL(
"There is unsaved changes in current edited traffic light.\nDo you want to save it before changing mode?"));
199 if (answer == MBOX_CLICKED_YES) {
201 WRITE_DEBUG(
"Closed FXMessageBox 'save TLS' with 'YES'");
205 }
else if (answer == MBOX_CLICKED_NO) {
207 WRITE_DEBUG(
"Closed FXMessageBox 'save TLS' with 'No'");
213 WRITE_DEBUG(
"Closed FXMessageBox 'save TLS' with 'Cancel'");
229 std::set<NBTrafficLightDefinition*> origDefs;
233 if (logic !=
nullptr) {
235 std::vector<NBNode*> nodes = def->getNodes();
236 for (
auto it_node : nodes) {
241 tmpTLLCont.
insert(duplicate);
242 origDefs.insert(duplicate);
244 WRITE_WARNINGF(
TL(
"tlLogic '%', program '%' could not be built"), def->getID(), def->getProgramID());
250 std::vector<NBLoadedSUMOTLDef*> loadedTLS;
253 if (sdef !=
nullptr) {
254 loadedTLS.push_back(sdef);
258 for (
auto def : loadedTLS) {
259 if (origDefs.count(def) != 0) {
264 std::vector<NBNode*> nodes = def->getNodes();
266 for (
auto it_node : nodes) {
274 tmpTLLCont.
removeProgram(def->getID(), def->getProgramID(),
false);
336 for (
const auto& internalLane : internalLanes.second) {
346 if (tlDef !=
nullptr) {
350 const std::string innerID =
":" + nbnCurrentJunction->
getID();
353 for (
const auto& link : links) {
354 int tlIndex = link.getTLIndex();
357 const NBEdge::Connection& con = link.getFrom()->getConnection(link.getFromLane(), link.getTo(), link.getToLane());
361 shape = link.getFrom()->getToNode()->computeInternalLaneShape(link.getFrom(),
NBEdge::Connection(link.getFromLane(),
367 const PositionVector laneShapeFrom = link.getFrom()->getLaneShape(link.getFromLane());
368 const PositionVector laneShapeTo = link.getTo()->getLaneShape(link.getToLane());
378 for (
const auto& nbn : tlDef->
getNodes()) {
379 for (
const auto& crossing : nbn->getCrossings()) {
380 if (crossing->tlLinkIndex2 > 0 && crossing->tlLinkIndex2 != crossing->tlLinkIndex) {
393 myInternalLanes[crossing->tlLinkIndex2].push_back(internalLaneReverse);
449 std::set<std::string> fromIDs;
454 fromIDs.insert(it_lane->getMicrosimID());
460 for (
const auto& edge : selectedEdge) {
461 for (
auto it_lane : edge->getLanes()) {
462 fromIDs.insert(it_lane->getMicrosimID());
469 for (
auto it_lane : selectedLanes) {
470 fromIDs.insert(it_lane->getMicrosimID());
476 for (
auto it : links) {
477 if (fromIDs.count(it.getFrom()->getLaneID(it.getFromLane())) > 0) {
478 std::vector<GNEInternalLane*> lanes =
myInternalLanes[it.getTLIndex()];
479 for (
auto it_lane : lanes) {
480 it_lane->onDefault(obj, sel, eventData);
492 for (
auto it : links) {
535 return TIME2STEPS(GNEAttributeCarrier::parse<double>(
string));
549 myTLSEditorParent(TLSEditorParent) {
564 TL(
"Assign E1 detectors") + std::string(
"\t") +
TL(
"Enable assign E1 mode") + std::string(
"\t") +
TL(
"Assign E1 detectors to the current TLS"),
565 TL(
"Assign E1 detectors") + std::string(
"\t") +
TL(
"Disable assign E1 mode") + std::string(
"\t") +
TL(
"Assign E1 detectors to the current TLS"),
589 const auto junction = myTLSEditorParent->myTLSJunction->getCurrentJunction();
590 if (junction ==
nullptr) {
594 myOffsetTextField->enable();
597 myButtonEditParameters->enable();
598 myParametersTextField->enable();
601 disableE1DetectorMode();
609 myOffsetTextField->setText(
"");
610 myOffsetTextField->disable();
613 myButtonEditParameters->disable();
614 myParametersTextField->setText(
"");
615 myParametersTextField->disable();
622 return getSUMOTime(myOffsetTextField->getText().text());
635 if (GNEAttributeCarrier::canParse<SUMOTime>(myOffsetTextField->getText().text())) {
647 return myParametersTextField->getText().text();
653 myParametersTextField->setText(parameters.c_str());
676 return (mySetDetectorsToggleButton->getState() == TRUE);
683 const auto laneID =
E1->getParentLanes().front()->getID();
685 for (
auto it = myE1Detectors.begin(); it != myE1Detectors.end(); it++) {
686 if (
E1->getID() == it->second) {
688 myE1Detectors.erase(it);
690 myTLSEditorParent->myEditedDef->unsetParameter(laneID);
691 myParametersTextField->setText(myTLSEditorParent->myEditedDef->getParametersStr().c_str());
693 myTLSEditorParent->myTLSDefinition->markAsModified();
695 }
else if (laneID == it->first) {
697 myE1Detectors.erase(it);
698 myE1Detectors[laneID] =
E1->getID();
700 myTLSEditorParent->myEditedDef->setParameter(laneID,
E1->getID());
701 myParametersTextField->setText(myTLSEditorParent->myEditedDef->getParametersStr().c_str());
703 myTLSEditorParent->myTLSDefinition->markAsModified();
708 myE1Detectors[laneID] =
E1->getID();
709 myTLSEditorParent->myEditedDef->setParameter(laneID,
E1->getID());
710 myParametersTextField->setText(myTLSEditorParent->myEditedDef->getParametersStr().c_str());
712 myTLSEditorParent->myTLSDefinition->markAsModified();
717const std::map<std::string, std::string>&
719 return myE1Detectors;
725 mySetDetectorsToggleButton->setState(FALSE, TRUE);
731 if (isValidOffset()) {
732 myTLSEditorParent->myTLSDefinition->markAsModified();
733 myTLSEditorParent->myEditedDef->setOffset(getOffset());
734 myOffsetTextField->killFocus();
735 myTLSEditorParent->update();
743 if (myTLSEditorParent->myTLSDefinition->getNumberOfTLSDefinitions() == 0) {
744 myOffsetTextField->disable();
746 if (myE1Detectors.size() > 0) {
747 myE1Detectors.clear();
748 myTLSEditorParent->getViewNet()->update();
750 }
else if (isSetDetectorsToggleButtonEnabled()) {
751 myOffsetTextField->disable();
752 }
else if (myTLSEditorParent->myTLSJunction->isJoiningJunctions()) {
754 myOffsetTextField->disable();
756 myOffsetTextField->enable();
764 if (isValidParameters()) {
765 myTLSEditorParent->myTLSDefinition->markAsModified();
766 myTLSEditorParent->myEditedDef->setParametersStr(getParameters());
767 myParametersTextField->killFocus();
768 myTLSEditorParent->update();
777 if (myTLSEditorParent->myEditedDef) {
779 const auto previousParameters = getParameters();
786 setParameters(myTLSEditorParent->myEditedDef->getParametersStr());
788 if (getParameters() != previousParameters) {
789 myTLSEditorParent->myTLSDefinition->markAsModified();
802 if (myTLSEditorParent->myTLSDefinition->getNumberOfTLSDefinitions() == 0) {
803 myButtonEditParameters->disable();
804 myParametersTextField->disable();
806 if (myE1Detectors.size() > 0) {
807 myE1Detectors.clear();
808 myTLSEditorParent->getViewNet()->update();
810 }
else if (isSetDetectorsToggleButtonEnabled()) {
811 myButtonEditParameters->disable();
812 myParametersTextField->disable();
813 }
else if (myTLSEditorParent->myTLSJunction->isJoiningJunctions()) {
815 myButtonEditParameters->disable();
816 myParametersTextField->disable();
818 myButtonEditParameters->enable();
819 myParametersTextField->enable();
827 if (mySetDetectorsToggleButton->getState()) {
829 mySetDetectorsToggleButton->setBackColor(FXRGBA(253, 255, 206, 255));
832 mySetDetectorsToggleButton->setBackColor(4293980400);
835 myTLSEditorParent->getViewNet()->update();
842 if (myTLSEditorParent->myTLSDefinition->getNumberOfTLSDefinitions() == 0) {
843 disableE1DetectorMode();
844 mySetDetectorsToggleButton->disable();
845 }
else if (myTLSEditorParent->myTLSJunction->isJoiningJunctions()) {
847 disableE1DetectorMode();
848 mySetDetectorsToggleButton->disable();
850 disableE1DetectorMode();
851 mySetDetectorsToggleButton->disable();
853 mySetDetectorsToggleButton->enable();
862 myE1Detectors.clear();
864 for (
const auto& parameter : myTLSEditorParent->myEditedDef->getParametersMap()) {
866 if (myTLSEditorParent->getViewNet()->getNet()->getAttributeCarriers()->retrieveLane(parameter.first,
false) &&
867 myTLSEditorParent->getViewNet()->getNet()->getAttributeCarriers()->retrieveAdditional(
SUMO_TAG_INDUCTION_LOOP, parameter.second,
false)) {
869 myE1Detectors[parameter.first] = parameter.second;
873 myTLSEditorParent->getViewNet()->update();
882 myTLSEditorParent(TLSEditorParent),
883 myCurrentJunction(nullptr) {
912 TL(
"Join") + std::string(
"\t") +
TL(
"Enable join mode") + std::string(
"\t") +
TL(
"Join TLS and junctions in the current junction."),
913 TL(
"Join") + std::string(
"\t") +
TL(
"Disable join mode") + std::string(
"\t") +
TL(
"Join TLS and junctions in the current junction."),
918 TL(
"Disjoin") + std::string(
"\t") +
TL(
"Disjoin current TLS") + std::string(
"\t") +
TL(
"Disjoin current TLS."),
940 return myCurrentJunction;
946 myCurrentJunction = junction;
948 updateJunctionDescription();
955 myJunctionIDLabel->setText(
TL(
"Junction ID"));
957 mySelectedJunctionIDs.clear();
959 onCmdCancelJoin(
nullptr, 0,
nullptr);
961 if (myCurrentJunction ==
nullptr) {
962 myJunctionIDTextField->setText(
TL(
"no junction selected"));
964 const auto nbn = myCurrentJunction->getNBNode();
966 myJunctionIDTextField->setText(nbn->getID().c_str());
968 if (nbn->getControllingTLS().size() > 0) {
970 const auto NBNodes = (*nbn->getControllingTLS().begin())->getNodes();
972 std::string nodesStr;
973 for (
auto it = NBNodes.begin(); it != NBNodes.end(); it++) {
974 if (it == (NBNodes.end() - 1)) {
975 nodesStr += (*it)->getID();
977 nodesStr += (*it)->getID() +
", ";
981 myJunctionIDTextField->setText(nodesStr.c_str());
983 if (NBNodes.size() > 1) {
984 myJunctionIDLabel->setText(
TL(
"Junction IDs"));
987 myTLSIDTextField->setText((*nbn->getControllingTLS().begin())->getID().c_str());
989 myTLSTypeComboBox->setText(myCurrentJunction->getAttribute(
SUMO_ATTR_TLTYPE).c_str());
996 return (myJoinTLSToggleButton->getState() == TRUE);
1002 return (std::find(mySelectedJunctionIDs.begin(), mySelectedJunctionIDs.end(), junction->
getID()) != mySelectedJunctionIDs.end());
1009 if (junction != myCurrentJunction) {
1011 auto it = std::find(mySelectedJunctionIDs.begin(), mySelectedJunctionIDs.end(), junction->
getID());
1013 if (it == mySelectedJunctionIDs.end()) {
1014 mySelectedJunctionIDs.push_back(junction->
getID());
1016 mySelectedJunctionIDs.erase(it);
1022const std::vector<std::string>&
1024 return mySelectedJunctionIDs;
1031 const std::string currentTLID = (*myCurrentJunction->getNBNode()->getControllingTLS().begin())->getID();
1032 const std::string newTLID = myTLSIDTextField->getText().text();
1034 if (newTLID.empty() || (newTLID == currentTLID)) {
1036 myTLSIDTextField->setTextColor(FXRGB(0, 0, 0));
1037 myTLSIDTextField->setText(currentTLID.c_str());
1038 myTLSIDTextField->killFocus();
1039 myTLSEditorParent->update();
1041 myTLSEditorParent->myTLSDefinition->showTLSDefinition();
1042 myTLSEditorParent->myTLSAttributes->showTLSAttributes();
1043 myTLSEditorParent->myTLSPhases->showTLSPhases();
1044 myTLSEditorParent->myTLSFile->showTLSFile();
1047 myTLSIDTextField->setTextColor(FXRGB(255, 0, 0));
1049 myTLSEditorParent->myTLSDefinition->hideTLSDefinition();
1050 myTLSEditorParent->myTLSAttributes->hideTLSAttributes();
1051 myTLSEditorParent->myTLSPhases->hideTLSPhases();
1052 myTLSEditorParent->myTLSFile->hideTLSFile();
1055 auto junction = myCurrentJunction;
1056 const auto tlDef = myTLSEditorParent->myTLSDefinition->getCurrentTLSDefinition();
1058 myTLSIDTextField->setTextColor(FXRGB(0, 0, 0));
1059 myTLSIDTextField->killFocus();
1060 myTLSEditorParent->update();
1062 myTLSEditorParent->myTLSDefinition->discardChanges(
false);
1064 myTLSEditorParent->getViewNet()->getUndoList()->begin(
GUIIcon::MODETLS,
TL(
"rename TLS"));
1065 myTLSEditorParent->getViewNet()->getUndoList()->add(
new GNEChange_TLS(junction, tlDef, newTLID),
true);
1066 myTLSEditorParent->getViewNet()->getUndoList()->end();
1068 myTLSEditorParent->myTLSDefinition->showTLSDefinition();
1069 myTLSEditorParent->myTLSAttributes->showTLSAttributes();
1070 myTLSEditorParent->myTLSPhases->showTLSPhases();
1071 myTLSEditorParent->myTLSFile->showTLSFile();
1073 myTLSEditorParent->editJunction(junction);
1081 if (myCurrentJunction ==
nullptr) {
1083 myTLSIDTextField->setText(
"");
1084 myTLSIDTextField->disable();
1085 }
else if (myCurrentJunction->getNBNode()->getControllingTLS().size() == 0) {
1087 myTLSIDTextField->disable();
1088 }
else if (myTLSEditorParent->myTLSAttributes->isSetDetectorsToggleButtonEnabled()) {
1090 myTLSIDTextField->disable();
1091 }
else if (myTLSEditorParent->myTLSJunction->isJoiningJunctions()) {
1093 myTLSIDTextField->disable();
1094 }
else if (myTLSEditorParent->myTLSDefinition->checkHaveModifications()) {
1096 myTLSIDTextField->disable();
1097 }
else if (isJoiningJunctions()) {
1099 myTLSIDTextField->handle(
this, FXSEL(SEL_COMMAND, ID_DISABLE),
nullptr);
1102 myTLSIDTextField->enable();
1111 const std::string currentTLType =
toString((*myCurrentJunction->getNBNode()->getControllingTLS().begin())->getType());
1112 const std::string newTLType = myTLSTypeComboBox->getText().text();
1114 if (newTLType.empty() || (newTLType == currentTLType)) {
1116 myTLSTypeComboBox->setTextColor(FXRGB(0, 0, 0));
1117 myTLSTypeComboBox->setText(currentTLType.c_str());
1118 myTLSTypeComboBox->killFocus();
1119 myTLSEditorParent->update();
1121 myTLSEditorParent->myTLSDefinition->showTLSDefinition();
1122 myTLSEditorParent->myTLSAttributes->showTLSAttributes();
1123 myTLSEditorParent->myTLSPhases->showTLSPhases();
1124 myTLSEditorParent->myTLSFile->showTLSFile();
1127 myTLSTypeComboBox->setTextColor(FXRGB(255, 0, 0));
1129 myTLSEditorParent->myTLSDefinition->hideTLSDefinition();
1130 myTLSEditorParent->myTLSAttributes->hideTLSAttributes();
1131 myTLSEditorParent->myTLSPhases->hideTLSPhases();
1132 myTLSEditorParent->myTLSFile->hideTLSFile();
1135 myTLSTypeComboBox->setTextColor(FXRGB(0, 0, 0));
1136 myTLSTypeComboBox->killFocus();
1137 myTLSEditorParent->update();
1139 auto junction = myCurrentJunction;
1141 myTLSEditorParent->myTLSDefinition->discardChanges(
false);
1143 myTLSEditorParent->getViewNet()->getUndoList()->begin(
GUIIcon::MODETLS,
TL(
"change TLS type"));
1144 junction->setAttribute(
SUMO_ATTR_TLTYPE, newTLType, myTLSEditorParent->getViewNet()->getUndoList());
1145 myTLSEditorParent->getViewNet()->getUndoList()->end();
1147 myTLSEditorParent->myTLSDefinition->showTLSDefinition();
1148 myTLSEditorParent->myTLSAttributes->showTLSAttributes();
1149 myTLSEditorParent->myTLSPhases->showTLSPhases();
1150 myTLSEditorParent->myTLSFile->showTLSFile();
1152 myTLSEditorParent->editJunction(junction);
1161 if (myCurrentJunction ==
nullptr) {
1163 myTLSTypeComboBox->setText(
"");
1164 myTLSTypeComboBox->disable();
1165 }
else if (myTLSEditorParent->myTLSAttributes->isSetDetectorsToggleButtonEnabled()) {
1167 myTLSTypeComboBox->disable();
1168 }
else if (myTLSEditorParent->myTLSJunction->isJoiningJunctions()) {
1170 myTLSTypeComboBox->disable();
1171 }
else if (myCurrentJunction->getNBNode()->getControllingTLS().size() == 0) {
1173 myTLSTypeComboBox->disable();
1174 }
else if (myTLSEditorParent->myTLSDefinition->checkHaveModifications()) {
1176 myTLSTypeComboBox->disable();
1179 myTLSTypeComboBox->enable();
1187 if (myJoinTLSToggleButton->getState()) {
1189 myJoinTLSToggleButton->setBackColor(FXRGBA(253, 255, 206, 255));
1191 mySelectedJunctionIDs.clear();
1193 const auto TLNodes = (*myCurrentJunction->getNBNode()->getControllingTLS().begin())->getNodes();
1195 mySelectedJunctionIDs.clear();
1196 for (
const auto& TLNode : TLNodes) {
1197 mySelectedJunctionIDs.push_back(TLNode->getID());
1200 myOriginalSelectedJunctionIDs = mySelectedJunctionIDs;
1202 myJoinControlButtons->show();
1203 getCollapsableFrame()->recalc();
1206 myJoinControlButtons->hide();
1207 getCollapsableFrame()->recalc();
1209 const auto currentJunction = myCurrentJunction;
1211 std::vector<GNEJunction*> selectedJunctions, resetTLJunctions;
1213 for (
const auto& selectedJunctionID : mySelectedJunctionIDs) {
1214 if (selectedJunctionID != currentJunction->getID()) {
1215 selectedJunctions.push_back(myTLSEditorParent->getViewNet()->getNet()->getAttributeCarriers()->retrieveJunction(selectedJunctionID));
1219 for (
const auto& TLNBNode : (*currentJunction->getNBNode()->getControllingTLS().begin())->getNodes()) {
1220 if (TLNBNode != currentJunction->getNBNode()) {
1221 resetTLJunctions.push_back(myTLSEditorParent->getViewNet()->getNet()->getAttributeCarriers()->retrieveJunction(TLNBNode->getID()));
1225 myTLSEditorParent->myTLSDefinition->discardChanges(
false);
1227 myTLSEditorParent->getViewNet()->getUndoList()->begin(
GUIIcon::MODETLS,
TL(
"join TLS"));
1229 for (
const auto& resetTLJunction : resetTLJunctions) {
1230 resetTLJunction->setAttribute(
SUMO_ATTR_TYPE,
"priority", myTLSEditorParent->getViewNet()->getUndoList());
1233 for (
const auto& selectedJunction : selectedJunctions) {
1234 selectedJunction->setAttribute(
SUMO_ATTR_TYPE, currentJunction->getAttribute(
SUMO_ATTR_TYPE), myTLSEditorParent->getViewNet()->getUndoList());
1235 selectedJunction->setAttribute(
SUMO_ATTR_TLID, currentJunction->getAttribute(
SUMO_ATTR_TLID), myTLSEditorParent->getViewNet()->getUndoList());
1238 myTLSEditorParent->getViewNet()->getUndoList()->end();
1240 myJoinTLSToggleButton->setBackColor(4293980400);
1242 mySelectedJunctionIDs.clear();
1244 myTLSEditorParent->editJunction(currentJunction);
1247 myTLSEditorParent->getViewNet()->update();
1254 if (myCurrentJunction ==
nullptr) {
1256 return sender->handle(
this, FXSEL(SEL_COMMAND, ID_DISABLE),
nullptr);
1257 }
else if (myTLSEditorParent->myTLSAttributes->isSetDetectorsToggleButtonEnabled()) {
1259 return sender->handle(
this, FXSEL(SEL_COMMAND, ID_DISABLE),
nullptr);
1260 }
else if (myTLSEditorParent->myTLSDefinition->checkHaveModifications()) {
1262 return sender->handle(
this, FXSEL(SEL_COMMAND, ID_DISABLE),
nullptr);
1263 }
else if (myCurrentJunction->getNBNode()->getControllingTLS().size() == 0) {
1265 return sender->handle(
this, FXSEL(SEL_COMMAND, ID_DISABLE),
nullptr);
1268 return sender->handle(
this, FXSEL(SEL_COMMAND, ID_ENABLE),
nullptr);
1276 const auto currentJunction = myCurrentJunction;
1278 std::vector<GNEJunction*> resetTLJunctions;
1280 for (
const auto& TLNBNode : (*currentJunction->getNBNode()->getControllingTLS().begin())->getNodes()) {
1281 resetTLJunctions.push_back(myTLSEditorParent->getViewNet()->getNet()->getAttributeCarriers()->retrieveJunction(TLNBNode->getID()));
1284 const auto type = resetTLJunctions.front()->getAttribute(
SUMO_ATTR_TYPE);
1285 const auto tlType = resetTLJunctions.front()->getAttribute(
SUMO_ATTR_TLTYPE);
1287 myTLSEditorParent->myTLSDefinition->discardChanges(
false);
1289 myTLSEditorParent->getViewNet()->getUndoList()->begin(
GUIIcon::MODETLS,
TL(
"disjoin TLS"));
1292 const std::string oldId = currentJunction->getAttribute(
SUMO_ATTR_TLID);
1293 const std::string tmpIdBase = oldId +
"_TMP";
1295 std::string tmpId = tmpIdBase +
toString(tmpIndex);
1296 while (tllCont.
exist(tmpId)) {
1297 tmpId = tmpIdBase +
toString(++tmpIndex);
1300 myTLSEditorParent->getViewNet()->getUndoList()->add(
new GNEChange_TLS(currentJunction, tlDef, tmpId),
true);
1303 for (
const auto& resetTLJunction : resetTLJunctions) {
1304 resetTLJunction->setAttribute(
SUMO_ATTR_TYPE,
"priority", myTLSEditorParent->getViewNet()->getUndoList());
1305 resetTLJunction->setAttribute(
SUMO_ATTR_TYPE, type, myTLSEditorParent->getViewNet()->getUndoList());
1306 resetTLJunction->setAttribute(
SUMO_ATTR_TLTYPE, tlType, myTLSEditorParent->getViewNet()->getUndoList());
1309 myTLSEditorParent->getViewNet()->getUndoList()->end();
1311 myJoinTLSToggleButton->setBackColor(4293980400);
1313 mySelectedJunctionIDs.clear();
1315 myTLSEditorParent->editJunction(currentJunction);
1322 if (myCurrentJunction ==
nullptr) {
1324 return sender->handle(
this, FXSEL(SEL_COMMAND, ID_DISABLE),
nullptr);
1325 }
else if (myTLSEditorParent->myTLSAttributes->isSetDetectorsToggleButtonEnabled()) {
1327 return sender->handle(
this, FXSEL(SEL_COMMAND, ID_DISABLE),
nullptr);
1328 }
else if (myTLSEditorParent->myTLSJunction->isJoiningJunctions()) {
1330 return sender->handle(
this, FXSEL(SEL_COMMAND, ID_DISABLE),
nullptr);
1331 }
else if (myTLSEditorParent->myTLSDefinition->checkHaveModifications()) {
1333 return sender->handle(
this, FXSEL(SEL_COMMAND, ID_DISABLE),
nullptr);
1334 }
else if (myCurrentJunction->getNBNode()->getControllingTLS().size() == 0) {
1336 return sender->handle(
this, FXSEL(SEL_COMMAND, ID_DISABLE),
nullptr);
1337 }
else if ((*myCurrentJunction->getNBNode()->getControllingTLS().begin())->getNodes().size() == 1) {
1339 return sender->handle(
this, FXSEL(SEL_COMMAND, ID_DISABLE),
nullptr);
1342 return sender->handle(
this, FXSEL(SEL_COMMAND, ID_ENABLE),
nullptr);
1349 myJoinTLSToggleButton->setState(FALSE, TRUE);
1357 mySelectedJunctionIDs = myOriginalSelectedJunctionIDs;
1358 myJoinTLSToggleButton->setState(FALSE, TRUE);
1369 myTLSEditorParent(TLSEditorParent) {
1381 myCreateButton =
new FXButton(verticalFrameAuxA, (
TL(
"Create TLS") + std::string(
"\t\t") +
TL(
"Create a new traffic light program.")).c_str(),
1384 new FXButton(verticalFrameAuxA, (
TL(
"Delete") + std::string(
"\t\t") +
TL(
"Delete a traffic light program. If all programs are deleted the junction turns into a priority junction.")).c_str(),
1387 new FXButton(verticalFrameAuxB, (
TL(
"Reset single") + std::string(
"\t\t") +
TL(
"Reset current TLS program.")).c_str(),
1390 new FXButton(verticalFrameAuxB, (
TL(
"Reset all") + std::string(
"\t\t") +
TL(
"Reset all TLS programs.")).c_str(),
1393 new FXButton(verticalFrameAuxA, (
TL(
"Save") + std::string(
"\t\t") +
TL(
"Save program modifications. (Enter)")).c_str(),
1396 new FXButton(verticalFrameAuxB, (
TL(
"Cancel") + std::string(
"\t\t") +
TL(
"Discard program modifications. (Esc)")).c_str(),
1421 const auto junction = myTLSEditorParent->myTLSJunction->getCurrentJunction();
1422 if (junction ==
nullptr) {
1426 myTLSDefinitions.clear();
1428 std::set<std::string> programIDs;
1429 for (
const auto&
TLS : junction->getNBNode()->getControllingTLS()) {
1430 myTLSDefinitions.push_back(
TLS);
1431 programIDs.insert(
TLS->getProgramID());
1433 for (
const auto& programID : programIDs) {
1434 myProgramComboBox->appendItem(programID.c_str());
1437 if (myTLSDefinitions.size() > 0) {
1438 myProgramComboBox->enable();
1439 myProgramComboBox->setCurrentItem(0);
1440 myProgramComboBox->setNumVisible(myProgramComboBox->getNumItems());
1442 return switchProgram();
1452 myTLSDefinitions.clear();
1454 myProgramComboBox->clearItems();
1455 myProgramComboBox->disable();
1461 return myProgramComboBox->getNumItems();
1467 return (
int)myTLSDefinitions.size();
1473 return myHaveModifications;
1479 myHaveModifications =
true;
1487 if (
TLSDefinition->getProgramID() == myProgramComboBox->getText().text()) {
1497 if (myProgramComboBox->getNumItems() == 0) {
1500 return myProgramComboBox->getText().text();
1508 auto currentJunction = myTLSEditorParent->myTLSJunction->getCurrentJunction();
1509 if (currentJunction !=
nullptr) {
1510 myTLSEditorParent->getViewNet()->getUndoList()->abortAllChangeGroups();
1511 myTLSEditorParent->cleanup();
1512 myTLSEditorParent->getViewNet()->updateViewNet();
1514 if (editJunctionAgain) {
1515 myTLSEditorParent->editJunction(currentJunction);
1524 GNEJunction* currentJunction = myTLSEditorParent->myTLSJunction->getCurrentJunction();
1526 discardChanges(
false);
1530 WRITE_DEBUG(
"Opening warning FXMessageBox 'invalid TLS'");
1532 FXMessageBox::warning(
this, MBOX_OK,
1533 TL(
"TLS cannot be created"),
"%s",
1534 (
TL(
"Traffic Light cannot be created because junction must have") + std::string(
"\n") +
1535 TL(
"at least one incoming edge and one outgoing edge.")).c_str());
1543 WRITE_DEBUG(
"Opening warning FXMessageBox 'invalid TLS'");
1545 FXMessageBox::warning(
this, MBOX_OK,
1546 TL(
"TLS cannot be created"),
"%s",
1547 (
TL(
"Traffic Light cannot be created because junction") + std::string(
"\n") +
1548 TL(
"must have at least one connection.")).c_str());
1554 bool connectionControlled =
false;
1556 if (!connection->getNBEdgeConnection().uncontrolled) {
1557 connectionControlled =
true;
1560 if (connectionControlled ==
false) {
1562 WRITE_DEBUG(
"Opening warning FXMessageBox 'invalid TLS'");
1564 FXMessageBox::warning(
this, MBOX_OK,
1565 TL(
"TLS cannot be created"),
"%s",
1566 (
TL(
"Traffic Light cannot be created because junction") + std::string(
"\n") +
1567 TL(
"must have at least one controlled connection.")).c_str());
1573 createTLS(currentJunction);
1575 myTLSEditorParent->editJunction(currentJunction);
1577 myProgramComboBox->setCurrentItem(myProgramComboBox->getNumItems() - 1, TRUE);
1585 const auto currentJunction = myTLSEditorParent->myTLSJunction->getCurrentJunction();
1587 if (currentJunction ==
nullptr) {
1589 sender->handle(
this, FXSEL(SEL_COMMAND, ID_DISABLE),
nullptr);
1590 }
else if (myHaveModifications) {
1592 sender->handle(
this, FXSEL(SEL_COMMAND, ID_DISABLE),
nullptr);
1593 }
else if (myTLSEditorParent->myTLSAttributes->isSetDetectorsToggleButtonEnabled()) {
1595 sender->handle(
this, FXSEL(SEL_COMMAND, ID_DISABLE),
nullptr);
1596 }
else if (myTLSEditorParent->myTLSJunction->isJoiningJunctions()) {
1598 sender->handle(
this, FXSEL(SEL_COMMAND, ID_DISABLE),
nullptr);
1599 }
else if (myTLSEditorParent->myTLSJunction->isJoiningJunctions()) {
1601 sender->handle(
this, FXSEL(SEL_COMMAND, ID_DISABLE),
nullptr);
1604 sender->handle(
this, FXSEL(SEL_COMMAND, ID_ENABLE),
nullptr);
1607 if (currentJunction ==
nullptr) {
1608 myCreateButton->setText(
TL(
"Create"));
1609 }
else if (currentJunction->getNBNode()->isTLControlled()) {
1610 myCreateButton->setText(
TL(
"Duplicate"));
1612 myCreateButton->setText(
TL(
"Create"));
1621 GNEJunction* currentJunction = myTLSEditorParent->myTLSJunction->getCurrentJunction();
1625 const bool changeJunctionType = (myTLSEditorParent->myTLSDefinition->getNumberOfTLSDefinitions() == 1);
1627 discardChanges(
false);
1629 if (changeJunctionType) {
1633 myTLSEditorParent->getViewNet()->getUndoList()->add(
new GNEChange_TLS(currentJunction, tlDef,
false),
true);
1635 myTLSEditorParent->editJunction(currentJunction);
1644 GNEJunction* junction = myTLSEditorParent->myTLSJunction->getCurrentJunction();
1648 discardChanges(
false);
1650 myTLSEditorParent->getViewNet()->getUndoList()->begin(
GUIIcon::MODETLS,
TL(
"reset current program"));
1652 myTLSEditorParent->getViewNet()->getUndoList()->add(
new GNEChange_TLS(junction, oldDef,
false),
true);
1655 myTLSEditorParent->getViewNet()->getUndoList()->add(
new GNEChange_TLS(junction, newDef,
true,
true),
true);
1659 myTLSEditorParent->getViewNet()->getUndoList()->end();
1661 myTLSEditorParent->editJunction(junction);
1664 for (
int i = 0; i < myProgramComboBox->getNumItems(); i++) {
1665 if (myProgramComboBox->getItem(i).text() == programID) {
1670 myProgramComboBox->setCurrentItem(index, TRUE);
1679 GNEJunction* junction = myTLSEditorParent->myTLSJunction->getCurrentJunction();
1682 std::vector<GNEJunction*> TLSJunctions;
1683 for (
const auto& TLSNode : oldDef->
getNodes()) {
1684 TLSJunctions.push_back(myTLSEditorParent->getViewNet()->getNet()->getAttributeCarriers()->retrieveJunction(TLSNode->getID()));
1687 discardChanges(
false);
1689 myTLSEditorParent->getViewNet()->getUndoList()->begin(
GUIIcon::MODETLS,
TL(
"reset TLS"));
1695 createTLS(junction);
1704 myTLSEditorParent->getViewNet()->getUndoList()->end();
1706 myTLSEditorParent->editJunction(junction);
1721 if (getNumberOfTLSDefinitions() == 0) {
1722 return sender->handle(
this, FXSEL(SEL_COMMAND, ID_DISABLE),
nullptr);
1723 }
else if (myTLSEditorParent->myTLSAttributes->isSetDetectorsToggleButtonEnabled()) {
1725 return sender->handle(
this, FXSEL(SEL_COMMAND, ID_DISABLE),
nullptr);
1726 }
else if (myTLSEditorParent->myTLSJunction->isJoiningJunctions()) {
1728 return sender->handle(
this, FXSEL(SEL_COMMAND, ID_DISABLE),
nullptr);
1729 }
else if (myHaveModifications) {
1731 return sender->handle(
this, FXSEL(SEL_COMMAND, ID_ENABLE),
nullptr);
1733 return sender->handle(
this, FXSEL(SEL_COMMAND, ID_DISABLE),
nullptr);
1740 if (getNumberOfTLSDefinitions() == 0) {
1741 return sender->handle(
this, FXSEL(SEL_COMMAND, ID_DISABLE),
nullptr);
1742 }
else if (myTLSEditorParent->myTLSAttributes->isSetDetectorsToggleButtonEnabled()) {
1744 return sender->handle(
this, FXSEL(SEL_COMMAND, ID_DISABLE),
nullptr);
1745 }
else if (myTLSEditorParent->myTLSJunction->isJoiningJunctions()) {
1747 return sender->handle(
this, FXSEL(SEL_COMMAND, ID_DISABLE),
nullptr);
1748 }
else if (myHaveModifications) {
1750 return sender->handle(
this, FXSEL(SEL_COMMAND, ID_DISABLE),
nullptr);
1752 return sender->handle(
this, FXSEL(SEL_COMMAND, ID_ENABLE),
nullptr);
1759 if (getNumberOfTLSDefinitions() <= 1) {
1760 return sender->handle(
this, FXSEL(SEL_COMMAND, ID_DISABLE),
nullptr);
1761 }
else if (myTLSEditorParent->myTLSAttributes->isSetDetectorsToggleButtonEnabled()) {
1763 return sender->handle(
this, FXSEL(SEL_COMMAND, ID_DISABLE),
nullptr);
1764 }
else if (myTLSEditorParent->myTLSJunction->isJoiningJunctions()) {
1766 return sender->handle(
this, FXSEL(SEL_COMMAND, ID_DISABLE),
nullptr);
1767 }
else if (myHaveModifications) {
1769 return sender->handle(
this, FXSEL(SEL_COMMAND, ID_DISABLE),
nullptr);
1771 return sender->handle(
this, FXSEL(SEL_COMMAND, ID_ENABLE),
nullptr);
1779 const auto currentJunction = myTLSEditorParent->myTLSJunction->getCurrentJunction();
1781 const auto currentProgram = myProgramComboBox->getCurrentItem();
1783 if (currentJunction !=
nullptr) {
1784 const auto oldDefinition = getCurrentTLSDefinition();
1785 std::vector<NBNode*> nodes = oldDefinition->getNodes();
1786 for (
const auto& node : nodes) {
1788 myTLSEditorParent->getViewNet()->getUndoList()->add(
new GNEChange_TLS(junction, oldDefinition,
false),
true);
1789 myTLSEditorParent->getViewNet()->getUndoList()->add(
new GNEChange_TLS(junction, myTLSEditorParent->myEditedDef,
true),
true);
1792 myTLSEditorParent->getViewNet()->getUndoList()->end();
1794 myHaveModifications =
false;
1796 myTLSEditorParent->myEditedDef =
nullptr;
1797 myTLSEditorParent->cleanup();
1798 myTLSEditorParent->getViewNet()->updateViewNet();
1800 myTLSEditorParent->editJunction(currentJunction);
1802 myProgramComboBox->setCurrentItem(currentProgram, TRUE);
1805 discardChanges(
true);
1814 discardChanges(
true);
1822 const auto currentTLS = getCurrentTLSProgramID();
1824 if (junction ==
nullptr) {
1833 if (
TLS->getProgramID() == currentTLS) {
1838 if (tpl ==
nullptr) {
1854 myTLSEditorParent->getViewNet()->getUndoList()->add(
new GNEChange_TLS(j, newDef,
true,
false),
true);
1856 myTLSEditorParent->getViewNet()->getUndoList()->end();
1859 myTLSEditorParent->getViewNet()->getUndoList()->add(
new GNEChange_TLS(junction,
nullptr,
true,
true),
true);
1866 if (myTLSEditorParent->myTLSJunction->getCurrentJunction() ==
nullptr) {
1868 }
else if (getNumberOfTLSDefinitions() != getNumberOfPrograms()) {
1869 throw ProcessError(
"myProgramComboBox must have the same number of TLSDefinitions");
1872 myHaveModifications =
false;
1878 myTLSEditorParent->getViewNet()->getNet()->computeJunction(myTLSEditorParent->myTLSJunction->getCurrentJunction());
1882 if (tllogic !=
nullptr) {
1884 myTLSEditorParent->buildInternalLanes(tlDef);
1886 delete myTLSEditorParent->myEditedDef;
1889 myTLSEditorParent->myTLSAttributes->setOffset(myTLSEditorParent->myEditedDef->getLogic()->getOffset());
1890 myTLSEditorParent->myTLSAttributes->setParameters(myTLSEditorParent->myEditedDef->getLogic()->getParametersStr());
1892 myTLSEditorParent->myTLSPhases->initPhaseTable();
1895 discardChanges(
false);
1896 myTLSEditorParent->getViewNet()->setStatusBarText(
TL(
"Traffic light does not control any links"));
1909 myTLSEditorParent(TLSEditorParent) {
1919 TL(
"Clean States") + std::string(
"\t") +
1920 TL(
"Clean unused states from all phase") + std::string(
"\t") +
1921 TL(
"Clean unused states from all phase. (Not allowed for multiple programs)"),
1925 TL(
"Add States") + std::string(
"\t") +
1926 TL(
"Extend the state vector for all phases by one entry") + std::string(
"\t") +
1927 TL(
"Extend the state vector for all phases by one entry. (Unused until a connection or crossing is assigned to the new index)"),
1931 TL(
"Group Sig.") + std::string(
"\t") +
1932 TL(
"Shorten state definition by letting connections with the same signal states use the same index") + std::string(
"\t") +
1933 TL(
"Shorten state definition by letting connections with the same signal states use the same index. (Not allowed for multiple programs)"),
1937 TL(
"Ungroup Sig.") + std::string(
"\t") +
1938 TL(
"Let every connection use a distinct index (reverse state grouping)") + std::string(
"\t") +
1939 TL(
"Let every connection use a distinct index (reverse state grouping). (Not allowed for multiple programs)"),
1964 return myTLSEditorParent;
1970 return myPhaseTable;
1978 if (myTLSEditorParent->myTLSDefinition->getNumberOfTLSDefinitions() > 0) {
1980 initStaticPhaseTable();
1982 initActuatedPhaseTable();
1984 initDelayBasePhaseTable();
1986 initNEMAPhaseTable();
1989 myPhaseTable->selectRow(0);
1991 myPhaseTable->recalcTableWidth();
1992 myPhaseTable->show();
1994 myPhaseTable->hide();
2003 int colDuration = 1;
2009 int colEarliestEnd = -1;
2010 int colLatestEnd = -1;
2044 if (col == colDuration) {
2045 return setDuration(col, row, value);
2046 }
else if (col == colState) {
2047 return setState(col, row, value);
2048 }
else if (col == colNext) {
2049 return setNext(row, value);
2050 }
else if (col == colName) {
2051 return setName(row, value);
2052 }
else if (col == colMinDur) {
2053 return setMinDur(row, value);
2054 }
else if (col == colMaxDur) {
2055 return setMaxDur(row, value);
2056 }
else if (col == colEarliestEnd) {
2057 return setEarliestEnd(row, value);
2058 }
else if (col == colLatestEnd) {
2059 return setLatestEnd(row, value);
2060 }
else if (col == colVehExt) {
2061 return setVehExt(row, value);
2062 }
else if (col == colYellow) {
2063 return setYellow(row, value);
2064 }
else if (col == colRed) {
2065 return setRed(row, value);
2075 myTLSEditorParent->myTLSDefinition->markAsModified();
2077 const int newIndex = buildDefaultPhase(row);
2084 myTLSEditorParent->myEditedDef->getLogic()->overrideState(newIndex, c);
2098 myPhaseTable->selectRow(newIndex);
2100 getPhaseTable()->setFocus();
2107 myTLSEditorParent->myTLSDefinition->markAsModified();
2109 const int newIndex = buildDefaultPhase(row);
2111 myTLSEditorParent->myEditedDef->getLogic()->copyPhase(row, row + 1);
2117 myPhaseTable->selectRow(newIndex);
2119 getPhaseTable()->setFocus();
2126 myTLSEditorParent->myTLSDefinition->markAsModified();
2128 const auto newRow =
MAX2(0, (row - 1));
2130 myTLSEditorParent->myEditedDef->getLogic()->deletePhase(row);
2136 myPhaseTable->selectRow(newRow);
2138 getPhaseTable()->setFocus();
2145 myTLSEditorParent->myTLSDefinition->markAsModified();
2150 myTLSEditorParent->myEditedDef->getLogic()->swapfirstPhase();
2152 myTLSEditorParent->myEditedDef->getLogic()->swapPhase(row, row - 1);
2158 myPhaseTable->selectRow((
int)myTLSEditorParent->myEditedDef->getLogic()->getPhases().size() - 1);
2160 myPhaseTable->selectRow(row - 1);
2163 getPhaseTable()->setFocus();
2170 myTLSEditorParent->myTLSDefinition->markAsModified();
2174 if (row == (
int)myTLSEditorParent->myEditedDef->getLogic()->getPhases().size() - 1) {
2175 myTLSEditorParent->myEditedDef->getLogic()->swaplastPhase();
2177 myTLSEditorParent->myEditedDef->getLogic()->swapPhase(row, row + 1);
2182 if (row == (
int)myTLSEditorParent->myEditedDef->getLogic()->getPhases().size() - 1) {
2183 myPhaseTable->selectRow(0);
2185 myPhaseTable->selectRow(row + 1);
2188 getPhaseTable()->setFocus();
2195 const auto& phase = myTLSEditorParent->getPhase(myPhaseTable->getCurrentSelectedRow());
2197 for (
const auto& internalLane : myTLSEditorParent->myInternalLanes) {
2198 int tlIndex = internalLane.first;
2199 std::vector<GNEInternalLane*> lanes = internalLane.second;
2201 if (tlIndex >= 0 && tlIndex < (
int)phase.state.size()) {
2202 state = (
LinkState)phase.state[tlIndex];
2204 for (
const auto& lane : lanes) {
2205 lane->setLinkState(state);
2209 myTLSEditorParent->getViewNet()->updateViewNet();
2215 if (myTLSEditorParent->myTLSAttributes->isSetDetectorsToggleButtonEnabled()) {
2217 sender->handle(getCollapsableFrame(), FXSEL(SEL_COMMAND, FXWindow::ID_DISABLE),
nullptr);
2219 myPhaseTable->disable();
2220 }
else if (myTLSEditorParent->myTLSJunction->isJoiningJunctions()) {
2222 sender->handle(getCollapsableFrame(), FXSEL(SEL_COMMAND, FXWindow::ID_DISABLE),
nullptr);
2224 myPhaseTable->disable();
2225 }
else if (myTLSEditorParent->myTLSDefinition->getNumberOfTLSDefinitions() > 0) {
2226 sender->handle(
this, FXSEL(SEL_COMMAND, FXWindow::ID_ENABLE),
nullptr);
2228 myPhaseTable->enable();
2230 sender->handle(
this, FXSEL(SEL_COMMAND, FXWindow::ID_DISABLE),
nullptr);
2232 myPhaseTable->disable();
2240 if (myTLSEditorParent->myTLSAttributes->isSetDetectorsToggleButtonEnabled()) {
2242 return sender->handle(getCollapsableFrame(), FXSEL(SEL_COMMAND, FXWindow::ID_DISABLE),
nullptr);
2243 }
else if (myTLSEditorParent->myTLSJunction->isJoiningJunctions()) {
2245 return sender->handle(getCollapsableFrame(), FXSEL(SEL_COMMAND, FXWindow::ID_DISABLE),
nullptr);
2246 }
else if (myTLSEditorParent->myTLSDefinition->getNumberOfTLSDefinitions() == 0) {
2247 return sender->handle(
this, FXSEL(SEL_COMMAND, FXWindow::ID_DISABLE),
nullptr);
2248 }
else if (myPhaseTable->getNumRows() <= 1) {
2249 return sender->handle(
this, FXSEL(SEL_COMMAND, FXWindow::ID_DISABLE),
nullptr);
2251 return sender->handle(
this, FXSEL(SEL_COMMAND, FXWindow::ID_ENABLE),
nullptr);
2258 if (myTLSEditorParent->myEditedDef->cleanupStates()) {
2259 myTLSEditorParent->myTLSDefinition->markAsModified();
2261 myTLSEditorParent->buildInternalLanes(myTLSEditorParent->myEditedDef);
2263 myPhaseTable->setFocus();
2264 myTLSEditorParent->myTLSDefinition->markAsModified();
2272 myTLSEditorParent->myEditedDef->getLogic()->setStateLength(myTLSEditorParent->myEditedDef->getLogic()->getNumLinks() + 1);
2273 myTLSEditorParent->myTLSDefinition->markAsModified();
2275 myPhaseTable->setFocus();
2283 myTLSEditorParent->myEditedDef->groupSignals();
2284 myTLSEditorParent->myTLSDefinition->markAsModified();
2285 myTLSEditorParent->buildInternalLanes(myTLSEditorParent->myEditedDef);
2287 myPhaseTable->setFocus();
2295 myTLSEditorParent->myEditedDef->setParticipantsInformation();
2296 myTLSEditorParent->myEditedDef->ungroupSignals();
2297 myTLSEditorParent->myTLSDefinition->markAsModified();
2298 myTLSEditorParent->buildInternalLanes(myTLSEditorParent->myEditedDef);
2300 myPhaseTable->setFocus();
2308 if (myTLSEditorParent->myTLSAttributes->isSetDetectorsToggleButtonEnabled()) {
2310 return sender->handle(getCollapsableFrame(), FXSEL(SEL_COMMAND, FXWindow::ID_DISABLE),
nullptr);
2311 }
else if (myTLSEditorParent->myTLSJunction->isJoiningJunctions()) {
2313 return sender->handle(getCollapsableFrame(), FXSEL(SEL_COMMAND, FXWindow::ID_DISABLE),
nullptr);
2314 }
else if (myTLSEditorParent->myTLSDefinition->getNumberOfTLSDefinitions() == 1) {
2315 return sender->handle(
this, FXSEL(SEL_COMMAND, FXWindow::ID_ENABLE),
nullptr);
2317 return sender->handle(
this, FXSEL(SEL_COMMAND, FXWindow::ID_DISABLE),
nullptr);
2324 if (myTLSEditorParent->myTLSAttributes->isSetDetectorsToggleButtonEnabled()) {
2326 return sender->handle(getCollapsableFrame(), FXSEL(SEL_COMMAND, FXWindow::ID_DISABLE),
nullptr);
2327 }
else if (myTLSEditorParent->myTLSJunction->isJoiningJunctions()) {
2329 return sender->handle(getCollapsableFrame(), FXSEL(SEL_COMMAND, FXWindow::ID_DISABLE),
nullptr);
2330 }
else if (myTLSEditorParent->myTLSDefinition->getNumberOfTLSDefinitions() != 1) {
2331 return sender->handle(
this, FXSEL(SEL_COMMAND, FXWindow::ID_DISABLE),
nullptr);
2332 }
else if (myTLSEditorParent->myEditedDef ==
nullptr) {
2333 return sender->handle(
this, FXSEL(SEL_COMMAND, FXWindow::ID_DISABLE),
nullptr);
2334 }
else if (myTLSEditorParent->myEditedDef->usingSignalGroups()) {
2335 return sender->handle(
this, FXSEL(SEL_COMMAND, FXWindow::ID_DISABLE),
nullptr);
2337 return sender->handle(
this, FXSEL(SEL_COMMAND, FXWindow::ID_ENABLE),
nullptr);
2345 const int colDuration = 1;
2346 const int colState = 2;
2347 const int colNext = 3;
2348 const int colName = 4;
2350 const auto& phases = myTLSEditorParent->myEditedDef->getLogic()->getPhases();
2352 myPhaseTable->setTableSize(
"sup-midtb", (
int)phases.size());
2354 for (
int row = 0; row < (int)phases.size(); row++) {
2355 myPhaseTable->setItemText(row, colDuration,
getSteps2Time(phases.at(row).duration).c_str());
2356 myPhaseTable->setItemText(row, colState, phases.at(row).state.c_str());
2357 myPhaseTable->setItemText(row, colNext, phases.at(row).next.size() > 0 ?
toString(phases.at(row).next).c_str() :
"");
2358 myPhaseTable->setItemText(row, colName, phases.at(row).name.c_str());
2361 myPhaseTable->setColumnLabelTop(colDuration,
"dur");
2362 myPhaseTable->setColumnLabelTop(colState,
"state");
2363 myPhaseTable->setColumnLabelTop(colNext,
"next");
2364 myPhaseTable->setColumnLabelTop(colName,
"name");
2366 updateCycleDuration(colDuration);
2367 updateStateSize(colState);
2369 myPhaseTable->setFocus();
2376 const int colDuration = 1;
2377 const int colMinDur = 2;
2378 const int colMaxDur = 3;
2379 const int colState = 4;
2380 const int colEarliestEnd = 5;
2381 const int colLatestEnd = 6;
2382 const int colNext = 7;
2383 const int colName = 8;
2385 const auto& phases = myTLSEditorParent->myEditedDef->getLogic()->getPhases();
2387 myPhaseTable->setTableSize(
"suffpff-midtb", (
int)phases.size());
2389 for (
int row = 0; row < (int)phases.size(); row++) {
2390 myPhaseTable->setItemText(row, colDuration,
getSteps2Time(phases.at(row).duration).c_str());
2391 myPhaseTable->setItemText(row, colMinDur,
varDurString(phases.at(row).minDur).c_str());
2392 myPhaseTable->setItemText(row, colMaxDur,
varDurString(phases.at(row).maxDur).c_str());
2393 myPhaseTable->setItemText(row, colState, phases.at(row).state.c_str());
2394 myPhaseTable->setItemText(row, colEarliestEnd,
varDurString(phases.at(row).earliestEnd).c_str());
2395 myPhaseTable->setItemText(row, colLatestEnd,
varDurString(phases.at(row).latestEnd).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(colEarliestEnd,
"ear.end",
"earlyEnd");
2404 myPhaseTable->setColumnLabelTop(colLatestEnd,
"lat.end",
"latestEnd");
2405 myPhaseTable->setColumnLabelTop(colState,
"state");
2406 myPhaseTable->setColumnLabelTop(colNext,
"next");
2407 myPhaseTable->setColumnLabelTop(colName,
"name");
2409 updateCycleDuration(colDuration);
2410 updateStateSize(colState);
2412 myPhaseTable->setFocus();
2419 const int colDuration = 1;
2420 const int colMinDur = 2;
2421 const int colMaxDur = 3;
2422 const int colState = 4;
2423 const int colNext = 5;
2424 const int colName = 6;
2426 const auto& phases = myTLSEditorParent->myEditedDef->getLogic()->getPhases();
2428 myPhaseTable->setTableSize(
"suffp-midtb", (
int)phases.size());
2430 for (
int row = 0; row < (int)phases.size(); row++) {
2431 myPhaseTable->setItemText(row, colDuration,
getSteps2Time(phases.at(row).duration).c_str());
2432 myPhaseTable->setItemText(row, colMinDur,
varDurString(phases.at(row).minDur).c_str());
2433 myPhaseTable->setItemText(row, colMaxDur,
varDurString(phases.at(row).maxDur).c_str());
2434 myPhaseTable->setItemText(row, colState, phases.at(row).state.c_str());
2435 myPhaseTable->setItemText(row, colNext, phases.at(row).next.size() > 0 ?
toString(phases.at(row).next).c_str() :
"");
2436 myPhaseTable->setItemText(row, colName, phases.at(row).name.c_str());
2439 myPhaseTable->setColumnLabelTop(colDuration,
"dur");
2440 myPhaseTable->setColumnLabelTop(colMinDur,
"min");
2441 myPhaseTable->setColumnLabelTop(colMaxDur,
"max");
2442 myPhaseTable->setColumnLabelTop(colState,
"state");
2443 myPhaseTable->setColumnLabelTop(colNext,
"next");
2444 myPhaseTable->setColumnLabelTop(colName,
"name");
2446 updateCycleDuration(colDuration);
2447 updateStateSize(colState);
2449 myPhaseTable->setFocus();
2456 const int colDuration = 1;
2457 const int colMinDur = 2;
2458 const int colMaxDur = 3;
2459 const int colState = 4;
2460 const int colVehExt = 5;
2461 const int colYellow = 6;
2462 const int colRed = 7;
2463 const int colNext = 8;
2464 const int colName = 9;
2466 const auto& phases = myTLSEditorParent->myEditedDef->getLogic()->getPhases();
2468 myPhaseTable->setTableSize(
"suffpfff-midtb", (
int)phases.size());
2470 for (
int row = 0; row < (int)phases.size(); row++) {
2471 myPhaseTable->setItemText(row, colDuration,
getSteps2Time(phases.at(row).duration).c_str());
2472 myPhaseTable->setItemText(row, colMinDur,
varDurString(phases.at(row).minDur).c_str());
2473 myPhaseTable->setItemText(row, colMaxDur,
varDurString(phases.at(row).maxDur).c_str());
2474 myPhaseTable->setItemText(row, colState, phases.at(row).state.c_str());
2475 myPhaseTable->setItemText(row, colVehExt,
varDurString(phases.at(row).vehExt).c_str());
2476 myPhaseTable->setItemText(row, colYellow,
varDurString(phases.at(row).yellow).c_str());
2477 myPhaseTable->setItemText(row, colRed,
varDurString(phases.at(row).red).c_str());
2478 myPhaseTable->setItemText(row, colNext, phases.at(row).next.size() > 0 ?
toString(phases.at(row).next).c_str() :
"");
2479 myPhaseTable->setItemText(row, colName, phases.at(row).name.c_str());
2482 myPhaseTable->setColumnLabelTop(colDuration,
"dur");
2483 myPhaseTable->setColumnLabelTop(colMinDur,
"min");
2484 myPhaseTable->setColumnLabelTop(colMaxDur,
"max");
2485 myPhaseTable->setColumnLabelTop(colState,
"state");
2486 myPhaseTable->setColumnLabelTop(colVehExt,
"vehExt",
"vehicle extension");
2487 myPhaseTable->setColumnLabelTop(colYellow,
"yellow");
2488 myPhaseTable->setColumnLabelTop(colRed,
"red");
2489 myPhaseTable->setColumnLabelTop(colNext,
"next");
2490 myPhaseTable->setColumnLabelTop(colName,
"name");
2492 updateCycleDuration(colDuration);
2493 updateStateSize(colState);
2495 myPhaseTable->setFocus();
2507 const int newIndex = row + 1;
2509 auto duration =
getSUMOTime(myPhaseTable->getItemText(row, 1));
2510 const auto oldState = myPhaseTable->getItemText(row, TLSStatic ? 2 : 4);
2511 auto state = oldState;
2513 std::set<int> crossingIndices;
2514 for (
const auto& node : myTLSEditorParent->myEditedDef->getNodes()) {
2515 for (
const auto& crossing : node->getCrossings()) {
2516 crossingIndices.insert(crossing->tlLinkIndex);
2517 crossingIndices.insert(crossing->tlLinkIndex2);
2521 bool haveGreen =
false;
2522 bool haveYellow =
false;
2523 for (
const auto& linkStateChar : state) {
2530 if (haveGreen && haveYellow) {
2532 duration =
TIME2STEPS(neteditOptions.getInt(
"tls.left-green.time"));
2533 for (
int i = 0; i < (int)state.size(); i++) {
2540 }
else if (haveGreen) {
2542 myTLSEditorParent->myEditedDef->setParticipantsInformation();
2543 duration =
TIME2STEPS(myTLSEditorParent->myEditedDef->computeBrakingTime(neteditOptions.getFloat(
"tls.yellow.min-decel")));
2544 for (
int i = 0; i < (int)state.size(); i++) {
2546 if (crossingIndices.count(i) == 0) {
2553 }
else if (haveYellow) {
2554 duration =
TIME2STEPS(neteditOptions.isDefault(
"tls.allred.time") ? 2 : neteditOptions.getInt(
"tls.allred.time"));
2556 for (
int i = 0; i < (int)state.size(); i++) {
2563 const int nextIndex = (myPhaseTable->getNumRows() > newIndex) ? newIndex : 0;
2564 const std::string state2 = myPhaseTable->getItemText(nextIndex, (TLSStatic ? 2 : 4));
2565 for (
int i = 0; i < (int)state.size(); i++) {
2568 state[i] = oldState[i];
2577 myTLSEditorParent->myEditedDef->getLogic()->addStep(duration, state, std::vector<int>(),
"", newIndex);
2587 if (value.empty()) {
2589 getPhaseTable()->setItemText(row, col,
getSteps2Time(myTLSEditorParent->getPhase(row).duration).c_str());
2591 }
else if (GNEAttributeCarrier::canParse<double>(value)) {
2595 myTLSEditorParent->myEditedDef->getLogic()->setPhaseDuration(row, duration);
2596 myTLSEditorParent->myTLSDefinition->markAsModified();
2598 updateCycleDuration(col);
2612 const auto& phase = myTLSEditorParent->getPhase(row);
2614 const auto newState = value.empty() ? phase.state : value;
2617 myTLSEditorParent->myEditedDef->getLogic()->addStep(phase.duration, newState, phase.next, phase.name, row);
2624 myTLSEditorParent->myEditedDef->getLogic()->deletePhase(row + 1);
2630 if (value.size() > 0) {
2631 myTLSEditorParent->myTLSDefinition->markAsModified();
2633 myPhaseTable->selectRow(row);
2636 getPhaseTable()->setItemText(row, col, newState);
2639 updateStateSize(col);
2648 const auto nextEdited = GNEAttributeCarrier::parse<std::vector<int> >(value);
2649 for (
const auto nextPhase : nextEdited) {
2650 if ((nextPhase < 0) || (nextPhase >= myPhaseTable->getNumRows())) {
2655 myTLSEditorParent->myEditedDef->getLogic()->setPhaseNext(row, nextEdited);
2656 myTLSEditorParent->myTLSDefinition->markAsModified();
2667 myTLSEditorParent->myEditedDef->getLogic()->setPhaseName(row, value);
2668 myTLSEditorParent->myTLSDefinition->markAsModified();
2676 if (value.empty()) {
2679 myTLSEditorParent->myTLSDefinition->markAsModified();
2681 }
else if (GNEAttributeCarrier::canParse<double>(value)) {
2685 myTLSEditorParent->myEditedDef->getLogic()->setPhaseMinDuration(row, minDur);
2686 myTLSEditorParent->myTLSDefinition->markAsModified();
2693 myTLSEditorParent->myTLSDefinition->markAsModified();
2704 if (value.empty()) {
2707 myTLSEditorParent->myTLSDefinition->markAsModified();
2709 }
else if (GNEAttributeCarrier::canParse<double>(value)) {
2713 myTLSEditorParent->myEditedDef->getLogic()->setPhaseMaxDuration(row, maxDur);
2714 myTLSEditorParent->myTLSDefinition->markAsModified();
2721 myTLSEditorParent->myTLSDefinition->markAsModified();
2732 if (value.empty()) {
2735 myTLSEditorParent->myTLSDefinition->markAsModified();
2737 }
else if (GNEAttributeCarrier::canParse<double>(value)) {
2740 if (earliestEnd > 0) {
2741 myTLSEditorParent->myEditedDef->getLogic()->setPhaseEarliestEnd(row, earliestEnd);
2742 myTLSEditorParent->myTLSDefinition->markAsModified();
2749 myTLSEditorParent->myTLSDefinition->markAsModified();
2760 if (value.empty()) {
2763 myTLSEditorParent->myTLSDefinition->markAsModified();
2765 }
else if (GNEAttributeCarrier::canParse<double>(value)) {
2768 if (latestEnd > 0) {
2769 myTLSEditorParent->myEditedDef->getLogic()->setPhaseLatestEnd(row, latestEnd);
2770 myTLSEditorParent->myTLSDefinition->markAsModified();
2777 myTLSEditorParent->myTLSDefinition->markAsModified();
2788 if (value.empty()) {
2791 myTLSEditorParent->myTLSDefinition->markAsModified();
2793 }
else if (GNEAttributeCarrier::canParse<double>(value)) {
2797 myTLSEditorParent->myEditedDef->getLogic()->setPhaseVehExt(row, vehExt);
2798 myTLSEditorParent->myTLSDefinition->markAsModified();
2805 myTLSEditorParent->myTLSDefinition->markAsModified();
2816 if (value.empty()) {
2819 myTLSEditorParent->myTLSDefinition->markAsModified();
2821 }
else if (GNEAttributeCarrier::canParse<double>(value)) {
2825 myTLSEditorParent->myEditedDef->getLogic()->setPhaseYellow(row, yellow);
2826 myTLSEditorParent->myTLSDefinition->markAsModified();
2833 myTLSEditorParent->myTLSDefinition->markAsModified();
2844 if (value.empty()) {
2847 myTLSEditorParent->myTLSDefinition->markAsModified();
2849 }
else if (GNEAttributeCarrier::canParse<double>(value)) {
2853 myTLSEditorParent->myEditedDef->getLogic()->setPhaseRed(row, red);
2854 myTLSEditorParent->myTLSDefinition->markAsModified();
2861 myTLSEditorParent->myTLSDefinition->markAsModified();
2872 for (
const auto& phase : myTLSEditorParent->myEditedDef->getLogic()->getPhases()) {
2873 cycleDuration += phase.duration;
2876 myPhaseTable->setColumnLabelBot(col,
getSteps2Time(cycleDuration));
2883 myPhaseTable->setColumnLabelBot(col,
"Links: " +
toString(myTLSEditorParent->myEditedDef->getLogic()->getNumLinks()));
2892 myTLSEditorParent(TLSEditorParent) {
2920 FXFileDialog opendialog(getCollapsableFrame(),
"Load TLS Program");
2922 opendialog.setSelectMode(SELECTFILE_EXISTING);
2923 opendialog.setPatternList(
"XML files (*.xml,*.xml.gz)\nAll files (*)");
2927 if (opendialog.execute()) {
2931 tmpTLLCont.
insert(myTLSEditorParent->myEditedDef);
2935 std::set<NBLoadedSUMOTLDef*> newDefsOtherProgram;
2936 for (
auto item : tmpTLLCont.
getPrograms(myTLSEditorParent->myEditedDef->getID())) {
2937 if (item.second != myTLSEditorParent->myEditedDef) {
2939 if (item.first == myTLSEditorParent->myEditedDef->getProgramID()) {
2940 newDefSameProgram = sdef;
2942 newDefsOtherProgram.insert(sdef);
2946 const int newPrograms = (int)newDefsOtherProgram.size();
2947 if (newPrograms > 0 || newDefSameProgram !=
nullptr) {
2948 std::vector<NBNode*> nodes = myTLSEditorParent->myEditedDef->
getNodes();
2949 for (
auto newProg : newDefsOtherProgram) {
2950 for (
auto it_node : nodes) {
2952 myTLSEditorParent->getViewNet()->getUndoList()->add(
new GNEChange_TLS(junction, newProg,
true),
true);
2955 if (newPrograms > 0) {
2956 WRITE_MESSAGE(
TL(
"Loaded ") +
toString(newPrograms) +
TL(
" new programs for tlLogic '") + myTLSEditorParent->myEditedDef->getID() +
"'");
2958 if (newDefSameProgram !=
nullptr) {
2960 myTLSEditorParent->myEditedDef = newDefSameProgram;
2961 WRITE_MESSAGE(
TL(
"Updated program '") + newDefSameProgram->
getProgramID() +
TL(
"' for tlLogic '") + myTLSEditorParent->myEditedDef->getID() +
"'");
2964 if (tllHandler.
getSeenIDs().count(myTLSEditorParent->myEditedDef->getID()) == 0) {
2965 myTLSEditorParent->getViewNet()->setStatusBarText(
TL(
"No programs found for traffic light '") + myTLSEditorParent->myEditedDef->getID() +
"'");
2971 tmpTLLCont.
removeProgram(def->getID(), def->getProgramID(),
false);
2974 myTLSEditorParent->myTLSPhases->initPhaseTable();
2975 myTLSEditorParent->myTLSDefinition->markAsModified();
2984 TL(
"Save TLS Program as"),
".xml",
2999 myTLSEditorParent->myEditedDef->writeParams(device);
3005 const auto& phases = myTLSEditorParent->myEditedDef->getLogic()->getPhases();
3006 for (
const auto& phase : phases) {
3011 if (TLSActuated || TLSDelayBased) {
3057 if (time == std::floor(time)) {
3067 if (myTLSEditorParent->myTLSDefinition->getNumberOfTLSDefinitions() == 0) {
3068 return sender->handle(getCollapsableFrame(), FXSEL(SEL_COMMAND, FXWindow::ID_DISABLE),
nullptr);
3069 }
else if (myTLSEditorParent->myTLSAttributes->isSetDetectorsToggleButtonEnabled()) {
3071 return sender->handle(getCollapsableFrame(), FXSEL(SEL_COMMAND, FXWindow::ID_DISABLE),
nullptr);
3072 }
else if (myTLSEditorParent->myTLSJunction->isJoiningJunctions()) {
3074 return sender->handle(getCollapsableFrame(), FXSEL(SEL_COMMAND, FXWindow::ID_DISABLE),
nullptr);
3076 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_BUTTON_CANCEL
cancel button
@ 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_BUTTON_ACCEPT
accept button
@ 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 GUIDesignAuxiliarHorizontalFrameUniform
design for auxiliar (Without borders) horizontal frame used to pack another frames uniform
#define GUIDesignTextFieldNCol
Num of column of text field.
#define GUIDesignLabelThickedFixed(width)
label thicked, icon before text, text centered and custom width
FXString gCurrentFolder
The folder used as last.
#define WRITE_WARNINGF(...)
#define WRITE_MESSAGE(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)
std::vector< GNEConnection * > getGNEConnections() const
Returns all GNEConnections vinculated with this junction.
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.
FXHorizontalFrame * myJoinControlButtons
frame for accept/cancel buttons
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 onCmdCancelJoin(FXObject *, FXSelector, void *)
cancel join
long onUpdJoinTLS(FXObject *, FXSelector, void *)
Called when update join TLS.
MFXComboBoxIcon * myTLSTypeComboBox
ComboBox for TLS Types.
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
long onCmdAcceptJoin(FXObject *, FXSelector, void *)
accept join
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)
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
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
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
bool setNext(const int row, const std::string &value)
set next
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 clearTable()
clear table
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
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
MFXGroupBoxModule (based on FXGroupBox)
FXVerticalFrame * getCollapsableFrame()
get collapsable frame (used by all elements that will be collapsed if button is toggled)
Options
GroupBoxModule options.
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.
NBTrafficLightLogic * compute(const OptionsCont &oc)
Computes the traffic light logic.
SUMOTime getOffset()
Returns the offset.
const NBConnectionVector & getControlledLinks() const
returns the controlled links (depends on previous call to collectLinks)
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.
bool exist(const std::string &newID) const
check if exists a definition with the given ID
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.
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, const bool isExternal=false, const bool catchExceptions=true)
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