102 GNEFrame(viewParent, viewNet,
TL("Edit Traffic Light")),
103 myEditedDef(
nullptr) {
181 for (
const auto& junction : viewObjects.
getJunctions()) {
201 TL(
"Save TLS Changes"),
202 TL(
"There are unsaved changes in the currently edited traffic light."),
203 TL(
"Do you want to save it before changing mode?"));
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);
345 for (
const auto& internalLane : internalLanes.second) {
355 if (tlDef !=
nullptr) {
356 const int NUM_POINTS = 10;
359 const std::string innerID =
":" + nbnCurrentJunction->
getID();
362 for (
const auto& link : links) {
363 int tlIndex = link.getTLIndex();
366 const NBEdge::Connection& con = link.getFrom()->getConnection(link.getFromLane(), link.getTo(), link.getToLane());
370 shape = link.getFrom()->getToNode()->computeInternalLaneShape(link.getFrom(),
NBEdge::Connection(link.getFromLane(),
371 link.getTo(), link.getToLane()), NUM_POINTS);
376 const PositionVector laneShapeFrom = link.getFrom()->getLaneShape(link.getFromLane());
377 const PositionVector laneShapeTo = link.getTo()->getLaneShape(link.getToLane());
387 for (
const auto& nbn : tlDef->
getNodes()) {
388 for (
const auto& crossing : nbn->getCrossings()) {
389 if (crossing->tlLinkIndex2 > 0 && crossing->tlLinkIndex2 != crossing->tlLinkIndex) {
402 myInternalLanes[crossing->tlLinkIndex2].push_back(internalLaneReverse);
458 std::set<std::string> fromIDs;
463 fromIDs.insert(it_lane->getMicrosimID());
469 for (
const auto& edge : selectedEdge) {
470 for (
auto it_lane : edge->getChildLanes()) {
471 fromIDs.insert(it_lane->getMicrosimID());
478 for (
auto it_lane : selectedLanes) {
479 fromIDs.insert(it_lane->getMicrosimID());
485 for (
auto it : links) {
486 if (fromIDs.count(it.getFrom()->getLaneID(it.getFromLane())) > 0) {
487 std::vector<GNEInternalLane*> lanes =
myInternalLanes[it.getTLIndex()];
488 for (
auto it_lane : lanes) {
489 it_lane->onDefault(obj, sel, eventData);
501 for (
auto it : links) {
545 return TIME2STEPS(GNEAttributeCarrier::parse<double>(
string));
559 myTLSEditorParent(TLSEditorParent) {
574 TL(
"Assign E1 detectors") + std::string(
"\t") +
TL(
"Enable assign E1 mode") + std::string(
"\t") +
TL(
"Assign E1 detectors to the current TLS"),
575 TL(
"Assign E1 detectors") + std::string(
"\t") +
TL(
"Disable assign E1 mode") + std::string(
"\t") +
TL(
"Assign E1 detectors to the current TLS"),
587 if (myTLSEditorParent->myTLSPrograms->getNumberOfPrograms() == 0) {
589 myOffsetTextField->disable();
590 myButtonEditParameters->disable();
591 myParametersTextField->disable();
593 disableE1DetectorMode();
594 mySetDetectorsToggleButton->disable();
596 if (myE1Detectors.size() > 0) {
597 myE1Detectors.clear();
598 myTLSEditorParent->getViewNet()->update();
600 }
else if (myTLSEditorParent->myTLSJunction->isJoiningJunctions()) {
602 myOffsetTextField->disable();
603 myButtonEditParameters->disable();
604 myParametersTextField->disable();
606 disableE1DetectorMode();
607 mySetDetectorsToggleButton->disable();
609 if (myE1Detectors.size() > 0) {
610 myE1Detectors.clear();
611 myTLSEditorParent->getViewNet()->update();
613 }
else if (isSetDetectorsToggleButtonEnabled()) {
615 myOffsetTextField->disable();
616 myButtonEditParameters->disable();
617 myParametersTextField->disable();
619 myOffsetTextField->enable();
620 myButtonEditParameters->enable();
621 myParametersTextField->enable();
625 disableE1DetectorMode();
626 mySetDetectorsToggleButton->disable();
628 if (myE1Detectors.size() > 0) {
629 myE1Detectors.clear();
630 myTLSEditorParent->getViewNet()->update();
633 mySetDetectorsToggleButton->enable();
654 const auto junction = myTLSEditorParent->myTLSJunction->getCurrentJunction();
655 if (junction ==
nullptr) {
659 myOffsetTextField->enable();
662 myButtonEditParameters->enable();
663 myParametersTextField->enable();
666 disableE1DetectorMode();
674 myOffsetTextField->setText(
"");
675 myOffsetTextField->disable();
678 myButtonEditParameters->disable();
679 myParametersTextField->setText(
"");
680 myParametersTextField->disable();
687 return getSUMOTime(myOffsetTextField->getText().text());
700 if (GNEAttributeCarrier::canParse<SUMOTime>(myOffsetTextField->getText().text())) {
712 return myParametersTextField->getText().text();
718 myParametersTextField->setText(parameters.c_str());
741 return (mySetDetectorsToggleButton->getState() == TRUE);
748 const auto laneID =
E1->getParentLanes().front()->getID();
750 for (
auto it = myE1Detectors.begin(); it != myE1Detectors.end(); it++) {
751 if (
E1->getID() == it->second) {
753 myE1Detectors.erase(it);
755 myTLSEditorParent->myEditedDef->unsetParameter(laneID);
756 myParametersTextField->setText(myTLSEditorParent->myEditedDef->getParametersStr().c_str());
758 myTLSEditorParent->myTLSPrograms->markAsModified();
760 }
else if (laneID == it->first) {
762 myE1Detectors.erase(it);
763 myE1Detectors[laneID] =
E1->getID();
765 myTLSEditorParent->myEditedDef->setParameter(laneID,
E1->getID());
766 myParametersTextField->setText(myTLSEditorParent->myEditedDef->getParametersStr().c_str());
768 myTLSEditorParent->myTLSPrograms->markAsModified();
773 myE1Detectors[laneID] =
E1->getID();
774 myTLSEditorParent->myEditedDef->setParameter(laneID,
E1->getID());
775 myParametersTextField->setText(myTLSEditorParent->myEditedDef->getParametersStr().c_str());
777 myTLSEditorParent->myTLSPrograms->markAsModified();
782const std::map<std::string, std::string>&
784 return myE1Detectors;
790 mySetDetectorsToggleButton->setState(FALSE, TRUE);
796 if (isValidOffset()) {
797 myTLSEditorParent->myTLSPrograms->markAsModified();
798 myTLSEditorParent->myEditedDef->setOffset(getOffset());
799 myOffsetTextField->killFocus();
800 myTLSEditorParent->updateModules();
808 if (isValidParameters()) {
809 myTLSEditorParent->myTLSPrograms->markAsModified();
810 myTLSEditorParent->myEditedDef->setParametersStr(getParameters());
811 myParametersTextField->killFocus();
812 myTLSEditorParent->updateModules();
821 if (myTLSEditorParent->myEditedDef) {
823 const auto previousParameters = getParameters();
825 const auto parametersDialog =
GNEParametersDialog(myTLSEditorParent->getViewNet()->getViewParent()->getGNEAppWindows(),
826 myTLSEditorParent->myEditedDef->getParametersMap());
830 myTLSEditorParent->myEditedDef->setParameters(parametersDialog.getEditedParameters());
832 setParameters(myTLSEditorParent->myEditedDef->getParametersStr());
834 if (getParameters() != previousParameters) {
835 myTLSEditorParent->myTLSPrograms->markAsModified();
838 myTLSEditorParent->updateModules();
846 if (mySetDetectorsToggleButton->getState()) {
848 mySetDetectorsToggleButton->setBackColor(FXRGBA(253, 255, 206, 255));
851 mySetDetectorsToggleButton->setBackColor(4293980400);
853 myTLSEditorParent->updateModules();
855 myTLSEditorParent->getViewNet()->update();
863 myE1Detectors.clear();
865 for (
const auto& parameter : myTLSEditorParent->myEditedDef->getParametersMap()) {
867 if (myTLSEditorParent->getViewNet()->getNet()->getAttributeCarriers()->retrieveLane(parameter.first,
false) &&
868 myTLSEditorParent->getViewNet()->getNet()->getAttributeCarriers()->retrieveAdditional(
SUMO_TAG_INDUCTION_LOOP, parameter.second,
false)) {
870 myE1Detectors[parameter.first] = parameter.second;
873 myTLSEditorParent->updateModules();
875 myTLSEditorParent->getViewNet()->update();
884 myTLSEditorParent(TLSEditorParent),
885 myCurrentJunction(nullptr) {
911 TL(
"Join") + std::string(
"\t") +
TL(
"Enable join mode") + std::string(
"\t") +
TL(
"Join TLS and junctions in the current junction."),
912 TL(
"Join") + std::string(
"\t") +
TL(
"Disable join mode") + std::string(
"\t") +
TL(
"Join TLS and junctions in the current junction."),
916 TL(
"Disjoin") + std::string(
"\t") +
TL(
"Disjoin current TLS") + std::string(
"\t") +
TL(
"Disjoin current TLS."),
937 if ((myCurrentJunction ==
nullptr) ||
938 (myCurrentJunction->getNBNode()->getControllingTLS().size() == 0)) {
940 myJunctionIDTextField->setText(
TL(
"No junction selected"));
941 myTLSIDTextField->setText(
"");
942 myTLSIDTextField->disable();
943 myTLSTypeComboBox->disable();
944 myJoinTLSToggleButton->disable();
945 myDisjoinTLSButton->disable();
946 myJoinControlButtons->hide();
949 const auto TLS = (*myCurrentJunction->getNBNode()->getControllingTLS().begin());
951 const int index = myTLSTypeComboBox->findItem(myCurrentJunction->getAttribute(
SUMO_ATTR_TLTYPE).c_str());
953 myTLSTypeComboBox->setCurrentItem(index, FALSE);
956 myJunctionIDTextField->setText(myCurrentJunction->getID().c_str());
957 myTLSIDTextField->setText(
TLS->getID().c_str());
959 if (myTLSEditorParent->myTLSAttributes->isSetDetectorsToggleButtonEnabled() ||
960 myTLSEditorParent->myTLSPrograms->checkHaveModifications()) {
962 myTLSIDTextField->setText(
"");
963 myTLSIDTextField->disable();
964 myTLSTypeComboBox->disable();
965 myJoinTLSToggleButton->disable();
966 myDisjoinTLSButton->disable();
967 myJoinControlButtons->hide();
968 }
else if (myTLSEditorParent->myTLSJunction->isJoiningJunctions()) {
970 myTLSIDTextField->setText(
"");
971 myTLSIDTextField->disable();
972 myTLSTypeComboBox->disable();
973 myDisjoinTLSButton->disable();
975 myJoinTLSToggleButton->enable();
976 myJoinControlButtons->show();
979 myTLSIDTextField->enable();
980 myTLSTypeComboBox->enable();
981 myJoinTLSToggleButton->enable();
983 if (
TLS->getNodes().size() == 1) {
984 myDisjoinTLSButton->disable();
986 myDisjoinTLSButton->enable();
995 return myCurrentJunction;
1001 myCurrentJunction = junction;
1003 refreshTLSJunction();
1009 return (myJoinTLSToggleButton->getState() == TRUE);
1015 return (std::find(mySelectedJunctionIDs.begin(), mySelectedJunctionIDs.end(), junction->
getID()) != mySelectedJunctionIDs.end());
1022 if (junction != myCurrentJunction) {
1024 auto it = std::find(mySelectedJunctionIDs.begin(), mySelectedJunctionIDs.end(), junction->
getID());
1026 if (it == mySelectedJunctionIDs.end()) {
1027 mySelectedJunctionIDs.push_back(junction->
getID());
1029 mySelectedJunctionIDs.erase(it);
1035const std::vector<std::string>&
1037 return mySelectedJunctionIDs;
1044 const std::string currentTLID = (*myCurrentJunction->getNBNode()->getControllingTLS().begin())->getID();
1045 const std::string newTLID = myTLSIDTextField->getText().text();
1047 if (newTLID.empty() || (newTLID == currentTLID)) {
1050 myTLSIDTextField->setText(currentTLID.c_str());
1051 myTLSIDTextField->killFocus();
1052 myTLSEditorParent->update();
1054 myTLSEditorParent->myTLSPrograms->showTLSPrograms();
1055 myTLSEditorParent->myTLSAttributes->showTLSAttributes();
1056 myTLSEditorParent->myTLSPhases->showTLSPhases();
1057 myTLSEditorParent->myTLSFile->showTLSFile();
1062 myTLSEditorParent->myTLSPrograms->hideTLSPrograms();
1063 myTLSEditorParent->myTLSAttributes->hideTLSAttributes();
1064 myTLSEditorParent->myTLSPhases->hideTLSPhases();
1065 myTLSEditorParent->myTLSFile->hideTLSFile();
1068 auto junction = myCurrentJunction;
1069 const auto tlDef = myTLSEditorParent->myTLSPrograms->getCurrentTLSPrograms();
1072 myTLSIDTextField->killFocus();
1073 myTLSEditorParent->update();
1075 myTLSEditorParent->myTLSPrograms->discardChanges(
false);
1077 myTLSEditorParent->getViewNet()->getUndoList()->begin(
GUIIcon::MODETLS,
TL(
"rename TLS"));
1078 myTLSEditorParent->getViewNet()->getUndoList()->add(
new GNEChange_TLS(junction, tlDef, newTLID),
true);
1079 myTLSEditorParent->getViewNet()->getUndoList()->end();
1081 myTLSEditorParent->myTLSPrograms->showTLSPrograms();
1082 myTLSEditorParent->myTLSAttributes->showTLSAttributes();
1083 myTLSEditorParent->myTLSPhases->showTLSPhases();
1084 myTLSEditorParent->myTLSFile->showTLSFile();
1086 myTLSEditorParent->editJunction(junction);
1088 myTLSEditorParent->updateModules();
1096 const std::string currentTLType =
toString((*myCurrentJunction->getNBNode()->getControllingTLS().begin())->getType());
1097 const std::string newTLType = myTLSTypeComboBox->getText().text();
1099 if (newTLType.empty() || (newTLType == currentTLType)) {
1103 const int index = myTLSTypeComboBox->findItem(currentTLType.c_str());
1105 myTLSTypeComboBox->disable();
1107 myTLSTypeComboBox->setCurrentItem(index);
1108 myTLSTypeComboBox->enable();
1110 myTLSTypeComboBox->killFocus();
1111 myTLSEditorParent->update();
1113 myTLSEditorParent->myTLSPrograms->showTLSPrograms();
1114 myTLSEditorParent->myTLSAttributes->showTLSAttributes();
1115 myTLSEditorParent->myTLSPhases->showTLSPhases();
1116 myTLSEditorParent->myTLSFile->showTLSFile();
1121 myTLSEditorParent->myTLSPrograms->hideTLSPrograms();
1122 myTLSEditorParent->myTLSAttributes->hideTLSAttributes();
1123 myTLSEditorParent->myTLSPhases->hideTLSPhases();
1124 myTLSEditorParent->myTLSFile->hideTLSFile();
1128 myTLSTypeComboBox->killFocus();
1129 myTLSEditorParent->update();
1131 auto junction = myCurrentJunction;
1133 myTLSEditorParent->myTLSPrograms->discardChanges(
false);
1135 myTLSEditorParent->getViewNet()->getUndoList()->begin(
GUIIcon::MODETLS,
TL(
"change TLS type"));
1136 junction->setAttribute(
SUMO_ATTR_TLTYPE, newTLType, myTLSEditorParent->getViewNet()->getUndoList());
1137 myTLSEditorParent->getViewNet()->getUndoList()->end();
1139 myTLSEditorParent->myTLSPrograms->showTLSPrograms();
1140 myTLSEditorParent->myTLSAttributes->showTLSAttributes();
1141 myTLSEditorParent->myTLSPhases->showTLSPhases();
1142 myTLSEditorParent->myTLSFile->showTLSFile();
1144 myTLSEditorParent->editJunction(junction);
1146 myTLSEditorParent->updateModules();
1154 if (myJoinTLSToggleButton->getState()) {
1156 myJoinTLSToggleButton->setBackColor(FXRGBA(253, 255, 206, 255));
1158 mySelectedJunctionIDs.clear();
1160 const auto TLNodes = (*myCurrentJunction->getNBNode()->getControllingTLS().begin())->getNodes();
1162 mySelectedJunctionIDs.clear();
1163 for (
const auto& TLNode : TLNodes) {
1164 mySelectedJunctionIDs.push_back(TLNode->getID());
1167 myOriginalSelectedJunctionIDs = mySelectedJunctionIDs;
1169 myJoinControlButtons->show();
1170 getCollapsableFrame()->recalc();
1173 myJoinControlButtons->hide();
1174 getCollapsableFrame()->recalc();
1176 const auto currentJunction = myCurrentJunction;
1178 std::vector<GNEJunction*> selectedJunctions, resetTLJunctions;
1180 for (
const auto& selectedJunctionID : mySelectedJunctionIDs) {
1181 if (selectedJunctionID != currentJunction->getID()) {
1182 selectedJunctions.push_back(myTLSEditorParent->getViewNet()->getNet()->getAttributeCarriers()->retrieveJunction(selectedJunctionID));
1186 for (
const auto& TLNBNode : (*currentJunction->getNBNode()->getControllingTLS().begin())->getNodes()) {
1187 if (TLNBNode != currentJunction->getNBNode()) {
1188 resetTLJunctions.push_back(myTLSEditorParent->getViewNet()->getNet()->getAttributeCarriers()->retrieveJunction(TLNBNode->getID()));
1192 myTLSEditorParent->myTLSPrograms->discardChanges(
false);
1194 myTLSEditorParent->getViewNet()->getUndoList()->begin(
GUIIcon::MODETLS,
TL(
"join TLS"));
1196 for (
const auto& resetTLJunction : resetTLJunctions) {
1197 resetTLJunction->setAttribute(
SUMO_ATTR_TYPE,
"priority", myTLSEditorParent->getViewNet()->getUndoList());
1200 for (
const auto& selectedJunction : selectedJunctions) {
1201 selectedJunction->setAttribute(
SUMO_ATTR_TYPE, currentJunction->getAttribute(
SUMO_ATTR_TYPE), myTLSEditorParent->getViewNet()->getUndoList());
1202 selectedJunction->setAttribute(
SUMO_ATTR_TLID, currentJunction->getAttribute(
SUMO_ATTR_TLID), myTLSEditorParent->getViewNet()->getUndoList());
1205 myTLSEditorParent->getViewNet()->getUndoList()->end();
1207 myJoinTLSToggleButton->setBackColor(4293980400);
1209 mySelectedJunctionIDs.clear();
1211 myTLSEditorParent->editJunction(currentJunction);
1213 myTLSEditorParent->updateModules();
1215 myTLSEditorParent->getViewNet()->update();
1223 const auto currentJunction = myCurrentJunction;
1225 std::vector<GNEJunction*> resetTLJunctions;
1227 for (
const auto& TLNBNode : (*currentJunction->getNBNode()->getControllingTLS().begin())->getNodes()) {
1228 resetTLJunctions.push_back(myTLSEditorParent->getViewNet()->getNet()->getAttributeCarriers()->retrieveJunction(TLNBNode->getID()));
1231 const auto type = resetTLJunctions.front()->getAttribute(
SUMO_ATTR_TYPE);
1232 const auto tlType = resetTLJunctions.front()->getAttribute(
SUMO_ATTR_TLTYPE);
1234 myTLSEditorParent->myTLSPrograms->discardChanges(
false);
1236 myTLSEditorParent->getViewNet()->getUndoList()->begin(
GUIIcon::MODETLS,
TL(
"disjoin TLS"));
1239 const std::string oldId = currentJunction->getAttribute(
SUMO_ATTR_TLID);
1240 const std::string tmpIdBase = oldId +
"_TMP";
1242 std::string tmpId = tmpIdBase +
toString(tmpIndex);
1243 while (tllCont.
exist(tmpId)) {
1244 tmpId = tmpIdBase +
toString(++tmpIndex);
1247 myTLSEditorParent->getViewNet()->getUndoList()->add(
new GNEChange_TLS(currentJunction, tlDef, tmpId),
true);
1250 for (
const auto& resetTLJunction : resetTLJunctions) {
1251 resetTLJunction->setAttribute(
SUMO_ATTR_TYPE,
"priority", myTLSEditorParent->getViewNet()->getUndoList());
1252 resetTLJunction->setAttribute(
SUMO_ATTR_TYPE, type, myTLSEditorParent->getViewNet()->getUndoList());
1253 resetTLJunction->setAttribute(
SUMO_ATTR_TLTYPE, tlType, myTLSEditorParent->getViewNet()->getUndoList());
1256 myTLSEditorParent->getViewNet()->getUndoList()->end();
1258 myJoinTLSToggleButton->setBackColor(4293980400);
1260 mySelectedJunctionIDs.clear();
1262 myTLSEditorParent->editJunction(currentJunction);
1263 myTLSEditorParent->updateModules();
1270 myJoinTLSToggleButton->setState(FALSE, TRUE);
1271 myTLSEditorParent->updateModules();
1279 mySelectedJunctionIDs = myOriginalSelectedJunctionIDs;
1280 myJoinTLSToggleButton->setState(FALSE, TRUE);
1281 myTLSEditorParent->updateModules();
1289 myJunctionIDLabel->setText(
TL(
"Junction ID"));
1291 mySelectedJunctionIDs.clear();
1293 onCmdCancelJoin(
nullptr, 0,
nullptr);
1295 if (myCurrentJunction ==
nullptr) {
1296 myJunctionIDTextField->setText(
TL(
"No junction selected"));
1299 const auto& TLSs = myCurrentJunction->getNBNode()->getControllingTLS();
1301 if (TLSs.size() > 0) {
1303 const auto TLS = (*TLSs.begin());
1305 if (
TLS->getNodes().size() > 1) {
1307 std::string TLSNodesStr;
1308 for (
auto it =
TLS->getNodes().begin(); it !=
TLS->getNodes().end(); it++) {
1309 if (it == (
TLS->getNodes().end() - 1)) {
1310 TLSNodesStr += (*it)->getID();
1312 TLSNodesStr += (*it)->getID() +
", ";
1316 myJunctionIDTextField->setText(TLSNodesStr.c_str());
1318 if (
TLS->getNodes().size() > 1) {
1319 myJunctionIDLabel->setText(
TL(
"Junction IDs"));
1322 const int index = myTLSTypeComboBox->findItem(myCurrentJunction->getAttribute(
SUMO_ATTR_TLTYPE).c_str());
1324 myTLSTypeComboBox->setCurrentItem(index, FALSE);
1329 myJunctionIDTextField->setText(myCurrentJunction->getID().c_str());
1330 myTLSTypeComboBox->setCurrentItem(0, FALSE);
1334 updateTLSJunction();
1343 myTLSEditorParent(TLSEditorParent) {
1388 if (getNumberOfPrograms() == 0) {
1390 if (myTLSEditorParent->getTLSJunction()->getCurrentJunction() !=
nullptr) {
1391 myCreateButton->enable();
1393 myCreateButton->disable();
1395 myDeleteButton->disable();
1396 myResetSingleButton->disable();
1397 myProgramComboBox->disable();
1398 myResetAllButton->disable();
1399 mySaveButon->disable();
1400 myCancelButon->disable();
1401 }
else if (myTLSEditorParent->myTLSAttributes->isSetDetectorsToggleButtonEnabled()) {
1403 myCreateButton->disable();
1404 myDeleteButton->disable();
1405 myResetSingleButton->disable();
1406 myProgramComboBox->disable();
1407 myResetAllButton->disable();
1408 mySaveButon->disable();
1409 myCancelButon->disable();
1410 }
else if (myTLSEditorParent->myTLSJunction->isJoiningJunctions()) {
1412 myCreateButton->disable();
1413 myDeleteButton->disable();
1414 myResetSingleButton->disable();
1415 myProgramComboBox->disable();
1416 myResetAllButton->disable();
1417 mySaveButon->disable();
1418 myCancelButon->disable();
1419 }
else if (myHaveModifications) {
1421 myCreateButton->disable();
1422 myDeleteButton->disable();
1423 myResetSingleButton->disable();
1424 myProgramComboBox->disable();
1425 myResetAllButton->disable();
1427 mySaveButon->enable();
1428 myCancelButon->enable();
1430 myCreateButton->enable();
1431 myDeleteButton->enable();
1432 myResetSingleButton->enable();
1433 myProgramComboBox->enable();
1435 mySaveButon->disable();
1436 myCancelButon->disable();
1438 if (getNumberOfPrograms() > 1) {
1439 myResetAllButton->enable();
1441 myResetAllButton->disable();
1445 const auto currentJunction = myTLSEditorParent->myTLSJunction->getCurrentJunction();
1447 if (currentJunction ==
nullptr) {
1448 myCreateButton->setText(
TL(
"Create"));
1449 }
else if (currentJunction->getNBNode()->isTLControlled()) {
1450 myCreateButton->setText(
TL(
"Duplicate"));
1452 myCreateButton->setText(
TL(
"Create"));
1472 const auto junction = myTLSEditorParent->myTLSJunction->getCurrentJunction();
1473 if (junction ==
nullptr) {
1479 std::set<std::string> programIDs;
1480 for (
const auto&
TLS : junction->getNBNode()->getControllingTLS()) {
1482 programIDs.insert(
TLS->getProgramID());
1484 for (
const auto& programID : programIDs) {
1485 myProgramComboBox->appendIconItem(programID.c_str());
1489 myProgramComboBox->enable();
1490 myProgramComboBox->setCurrentItem(0);
1492 return switchProgram();
1504 myProgramComboBox->clearItems();
1505 myProgramComboBox->disable();
1511 return myProgramComboBox->getNumItems();
1517 return myHaveModifications;
1523 myHaveModifications =
true;
1524 myTLSEditorParent->updateModules();
1532 if (
TLSPrograms->getProgramID() == myProgramComboBox->getText().text()) {
1542 if (myProgramComboBox->getNumItems() == 0) {
1545 return myProgramComboBox->getText().text();
1553 auto currentJunction = myTLSEditorParent->myTLSJunction->getCurrentJunction();
1554 if (currentJunction !=
nullptr) {
1555 myTLSEditorParent->getViewNet()->getUndoList()->abortAllChangeGroups();
1556 myTLSEditorParent->cleanup();
1557 myTLSEditorParent->getViewNet()->updateViewNet();
1559 if (editJunctionAgain) {
1560 myTLSEditorParent->editJunction(currentJunction);
1563 myTLSEditorParent->updateModules();
1570 GNEJunction* currentJunction = myTLSEditorParent->myTLSJunction->getCurrentJunction();
1572 discardChanges(
false);
1577 TL(
"TLS cannot be created"),
1578 TL(
"Traffic Light cannot be created because junction must have"),
1579 TL(
"at least one incoming edge and one outgoing edge.")
1587 TL(
"TLS cannot be created"),
1588 TL(
"Traffic Light cannot be created because junction"),
1589 TL(
"must have at least one connection.")
1594 bool connectionControlled =
false;
1596 if (!connection->getNBEdgeConnection().uncontrolled) {
1597 connectionControlled =
true;
1600 if (!connectionControlled) {
1603 TL(
"TLS cannot be created"),
1604 TL(
"Traffic Light cannot be created because junction"),
1605 TL(
"must have at least one controlled connection.")
1610 createTLS(currentJunction);
1612 myTLSEditorParent->editJunction(currentJunction);
1614 myProgramComboBox->setCurrentItem(myProgramComboBox->getNumItems() - 1, TRUE);
1615 myTLSEditorParent->updateModules();
1623 GNEJunction* currentJunction = myTLSEditorParent->myTLSJunction->getCurrentJunction();
1627 const bool changeJunctionType = (myTLSEditorParent->myTLSPrograms->getNumberOfPrograms() == 1);
1629 discardChanges(
false);
1631 if (changeJunctionType) {
1635 myTLSEditorParent->getViewNet()->getUndoList()->add(
new GNEChange_TLS(currentJunction, tlDef,
false),
true);
1637 myTLSEditorParent->editJunction(currentJunction);
1639 myTLSEditorParent->updateModules();
1647 GNEJunction* junction = myTLSEditorParent->myTLSJunction->getCurrentJunction();
1651 discardChanges(
false);
1653 myTLSEditorParent->getViewNet()->getUndoList()->begin(
GUIIcon::MODETLS,
TL(
"reset current program"));
1655 myTLSEditorParent->getViewNet()->getUndoList()->add(
new GNEChange_TLS(junction, oldDef,
false),
true);
1659 myTLSEditorParent->getViewNet()->getUndoList()->add(
new GNEChange_TLS(junction, newDef,
true,
true),
true);
1662 myTLSEditorParent->getViewNet()->getUndoList()->end();
1664 myTLSEditorParent->editJunction(junction);
1667 for (
int i = 0; i < myProgramComboBox->getNumItems(); i++) {
1668 if (myProgramComboBox->getItemText(i) == programID) {
1673 myProgramComboBox->setCurrentItem(index, TRUE);
1675 myTLSEditorParent->updateModules();
1683 GNEJunction* junction = myTLSEditorParent->myTLSJunction->getCurrentJunction();
1686 std::vector<GNEJunction*> TLSJunctions;
1687 for (
const auto& TLSNode : oldDef->
getNodes()) {
1688 TLSJunctions.push_back(myTLSEditorParent->getViewNet()->getNet()->getAttributeCarriers()->retrieveJunction(TLSNode->getID()));
1691 discardChanges(
false);
1693 myTLSEditorParent->getViewNet()->getUndoList()->begin(
GUIIcon::MODETLS,
TL(
"reset TLS"));
1699 createTLS(junction);
1708 myTLSEditorParent->getViewNet()->getUndoList()->end();
1710 myTLSEditorParent->editJunction(junction);
1720 if (
TLSPrograms->getProgramID() == myProgramComboBox->getText().text()) {
1737 const auto currentJunction = myTLSEditorParent->myTLSJunction->getCurrentJunction();
1739 const auto currentProgram = myProgramComboBox->getCurrentItem();
1741 if (currentJunction !=
nullptr) {
1742 const auto oldDefinition = getCurrentTLSPrograms();
1743 std::vector<NBNode*> nodes = oldDefinition->getNodes();
1744 GNEUndoList* undoList = myTLSEditorParent->getViewNet()->getUndoList();
1745 for (
const auto& node : nodes) {
1748 undoList->
add(
new GNEChange_TLS(junction, myTLSEditorParent->myEditedDef,
true),
true);
1761 myTLSEditorParent->getViewNet()->getUndoList()->end();
1763 myHaveModifications =
false;
1765 myTLSEditorParent->myEditedDef =
nullptr;
1766 myTLSEditorParent->cleanup();
1767 myTLSEditorParent->getViewNet()->updateViewNet();
1769 myTLSEditorParent->editJunction(currentJunction);
1771 myProgramComboBox->setCurrentItem(currentProgram, TRUE);
1774 discardChanges(
true);
1776 myTLSEditorParent->updateModules();
1784 discardChanges(
true);
1792 const auto currentTLS = getCurrentTLSProgramID();
1794 if (junction ==
nullptr) {
1803 if (
TLS->getProgramID() == currentTLS) {
1808 if (tpl ==
nullptr) {
1824 myTLSEditorParent->getViewNet()->getUndoList()->add(
new GNEChange_TLS(j, newDef,
true,
false),
true);
1826 myTLSEditorParent->getViewNet()->getUndoList()->end();
1829 myTLSEditorParent->getViewNet()->getUndoList()->add(
new GNEChange_TLS(junction,
nullptr,
true,
true),
true);
1836 if (myTLSEditorParent->myTLSJunction->getCurrentJunction() ==
nullptr) {
1840 myHaveModifications =
false;
1846 myTLSEditorParent->getViewNet()->getNet()->computeJunction(myTLSEditorParent->myTLSJunction->getCurrentJunction());
1850 if (tllogic !=
nullptr) {
1852 myTLSEditorParent->buildInternalLanes(tlDef);
1854 delete myTLSEditorParent->myEditedDef;
1857 myTLSEditorParent->myTLSAttributes->setOffset(myTLSEditorParent->myEditedDef->getLogic()->getOffset());
1858 myTLSEditorParent->myTLSAttributes->setParameters(myTLSEditorParent->myEditedDef->getLogic()->getParametersStr());
1860 myTLSEditorParent->myTLSPhases->initPhaseTable();
1863 discardChanges(
false);
1864 myTLSEditorParent->getViewNet()->setStatusBarText(
TL(
"Traffic Light does not control any links"));
1877 myTLSEditorParent(TLSEditorParent) {
1887 TL(
"Clean States") + std::string(
"\t") +
1888 TL(
"Clean unused states from all phase") + std::string(
"\t") +
1889 TL(
"Clean unused states from all phase. (Not allowed for multiple programs)"),
1894 TL(
"Add States") + std::string(
"\t") +
1895 TL(
"Extend the state vector for all phases by one entry") + std::string(
"\t") +
1896 TL(
"Extend the state vector for all phases by one entry. (Unused until a connection or crossing is assigned to the new index)"),
1901 TL(
"Group Sig.") + std::string(
"\t") +
1902 TL(
"Shorten state definition by letting connections with the same signal states use the same index") + std::string(
"\t") +
1903 TL(
"Shorten state definition by letting connections with the same signal states use the same index. (Not allowed for multiple programs)"),
1908 TL(
"Ungroup Sig.") + std::string(
"\t") +
1909 TL(
"Let every connection use a distinct index (reverse state grouping)") + std::string(
"\t") +
1910 TL(
"Let every connection use a distinct index (reverse state grouping). (Not allowed for multiple programs)"),
1924 if (myTLSEditorParent->myTLSAttributes->isSetDetectorsToggleButtonEnabled()) {
1926 myPhaseTable->disable();
1927 myCleanStatesButton->disable();
1928 myAddStates->disable();
1929 myGroupSignalsButton->disable();
1930 myUngroupSignalsButton->disable();
1931 }
else if (myTLSEditorParent->myTLSJunction->isJoiningJunctions()) {
1933 myPhaseTable->disable();
1934 myCleanStatesButton->disable();
1935 myAddStates->disable();
1936 myGroupSignalsButton->disable();
1937 myUngroupSignalsButton->disable();
1938 myUngroupSignalsButton->disable();
1939 }
else if (myTLSEditorParent->myTLSPrograms->getNumberOfPrograms() == 0) {
1941 myPhaseTable->disable();
1942 myCleanStatesButton->disable();
1943 myAddStates->disable();
1944 myGroupSignalsButton->disable();
1945 myUngroupSignalsButton->disable();
1946 }
else if (myTLSEditorParent->myEditedDef ==
nullptr) {
1948 myPhaseTable->disable();
1949 myCleanStatesButton->disable();
1950 myAddStates->disable();
1951 myGroupSignalsButton->disable();
1952 myUngroupSignalsButton->disable();
1954 myPhaseTable->enable();
1955 myCleanStatesButton->enable();
1956 myAddStates->enable();
1957 myGroupSignalsButton->enable();
1958 if (myTLSEditorParent->myEditedDef->usingSignalGroups()) {
1959 myUngroupSignalsButton->enable();
1961 myUngroupSignalsButton->disable();
1981 return myTLSEditorParent;
1987 return myPhaseTable;
1995 if (myTLSEditorParent->myTLSPrograms->getNumberOfPrograms() > 0) {
1997 initStaticPhaseTable();
1999 initActuatedPhaseTable();
2001 initDelayBasePhaseTable();
2003 initNEMAPhaseTable();
2006 myPhaseTable->selectRow(0);
2008 myPhaseTable->recalcTableWidth();
2009 myPhaseTable->show();
2011 myPhaseTable->hide();
2019 myPhaseTable->clearTable();
2026 int colDuration = 1;
2032 int colEarliestEnd = -1;
2033 int colLatestEnd = -1;
2067 if (col == colDuration) {
2068 return setDuration(col, row, value);
2069 }
else if (col == colState) {
2070 return setState(col, row, value);
2071 }
else if (col == colNext) {
2072 return setNext(row, value);
2073 }
else if (col == colName) {
2074 return setName(row, value);
2075 }
else if (col == colMinDur) {
2076 return setMinDur(row, value);
2077 }
else if (col == colMaxDur) {
2078 return setMaxDur(row, value);
2079 }
else if (col == colEarliestEnd) {
2080 return setEarliestEnd(row, value);
2081 }
else if (col == colLatestEnd) {
2082 return setLatestEnd(row, value);
2083 }
else if (col == colVehExt) {
2084 return setVehExt(row, value);
2085 }
else if (col == colYellow) {
2086 return setYellow(row, value);
2087 }
else if (col == colRed) {
2088 return setRed(row, value);
2098 myTLSEditorParent->myTLSPrograms->markAsModified();
2100 const int newIndex = buildDefaultPhase(row);
2107 myTLSEditorParent->myEditedDef->getLogic()->overrideState(newIndex, c);
2115 myPhaseTable->selectRow(newIndex);
2117 getPhaseTable()->setFocus();
2124 myTLSEditorParent->myTLSPrograms->markAsModified();
2126 const int newIndex = buildDefaultPhase(row);
2128 myTLSEditorParent->myEditedDef->getLogic()->copyPhase(row, row + 1);
2132 myPhaseTable->selectRow(newIndex);
2134 getPhaseTable()->setFocus();
2141 myTLSEditorParent->myTLSPrograms->markAsModified();
2143 const auto newRow =
MAX2(0, (row - 1));
2145 myTLSEditorParent->myEditedDef->getLogic()->deletePhase(row);
2149 myPhaseTable->selectRow(newRow);
2151 getPhaseTable()->setFocus();
2158 myTLSEditorParent->myTLSPrograms->markAsModified();
2161 myTLSEditorParent->myEditedDef->getLogic()->swapfirstPhase();
2163 myTLSEditorParent->myEditedDef->getLogic()->swapPhase(row, row - 1);
2169 myPhaseTable->selectRow((
int)myTLSEditorParent->myEditedDef->getLogic()->getPhases().size() - 1);
2171 myPhaseTable->selectRow(row - 1);
2174 getPhaseTable()->setFocus();
2181 myTLSEditorParent->myTLSPrograms->markAsModified();
2183 if (row == (
int)myTLSEditorParent->myEditedDef->getLogic()->getPhases().size() - 1) {
2184 myTLSEditorParent->myEditedDef->getLogic()->swaplastPhase();
2186 myTLSEditorParent->myEditedDef->getLogic()->swapPhase(row, row + 1);
2191 if (row == (
int)myTLSEditorParent->myEditedDef->getLogic()->getPhases().size() - 1) {
2192 myPhaseTable->selectRow(0);
2194 myPhaseTable->selectRow(row + 1);
2197 getPhaseTable()->setFocus();
2204 const auto& phase = myTLSEditorParent->getPhase(myPhaseTable->getCurrentSelectedRow());
2206 for (
const auto& internalLane : myTLSEditorParent->myInternalLanes) {
2207 int tlIndex = internalLane.first;
2208 std::vector<GNEInternalLane*> lanes = internalLane.second;
2210 if (tlIndex >= 0 && tlIndex < (
int)phase.state.size()) {
2211 state = (
LinkState)phase.state[tlIndex];
2213 for (
const auto& lane : lanes) {
2214 lane->setLinkState(state);
2218 myTLSEditorParent->getViewNet()->updateViewNet();
2224 if (myTLSEditorParent->myEditedDef->cleanupStates()) {
2225 myTLSEditorParent->myTLSPrograms->markAsModified();
2227 myTLSEditorParent->buildInternalLanes(myTLSEditorParent->myEditedDef);
2229 myPhaseTable->setFocus();
2230 myTLSEditorParent->myTLSPrograms->markAsModified();
2231 myTLSEditorParent->updateModules();
2238 myTLSEditorParent->myEditedDef->getLogic()->setStateLength(myTLSEditorParent->myEditedDef->getLogic()->getNumLinks() + 1);
2239 myTLSEditorParent->myTLSPrograms->markAsModified();
2241 myPhaseTable->setFocus();
2242 myTLSEditorParent->updateModules();
2249 myTLSEditorParent->myEditedDef->groupSignals();
2250 myTLSEditorParent->myTLSPrograms->markAsModified();
2251 myTLSEditorParent->buildInternalLanes(myTLSEditorParent->myEditedDef);
2253 myPhaseTable->setFocus();
2254 myTLSEditorParent->updateModules();
2261 myTLSEditorParent->myEditedDef->setParticipantsInformation();
2262 myTLSEditorParent->myEditedDef->ungroupSignals();
2263 myTLSEditorParent->myTLSPrograms->markAsModified();
2264 myTLSEditorParent->buildInternalLanes(myTLSEditorParent->myEditedDef);
2266 myPhaseTable->setFocus();
2267 myTLSEditorParent->updateModules();
2275 const int colDuration = 1;
2276 const int colState = 2;
2277 const int colNext = 3;
2278 const int colName = 4;
2280 const auto& phases = myTLSEditorParent->myEditedDef->getLogic()->getPhases();
2282 myPhaseTable->setTableSize(
"sup-midtb", (
int)phases.size());
2284 for (
int row = 0; row < (int)phases.size(); row++) {
2285 myPhaseTable->setItemText(row, colDuration,
getSteps2Time(phases.at(row).duration).c_str());
2286 myPhaseTable->setItemText(row, colState, phases.at(row).state.c_str());
2287 myPhaseTable->setItemText(row, colNext, phases.at(row).next.size() > 0 ?
toString(phases.at(row).next).c_str() :
"");
2288 myPhaseTable->setItemText(row, colName, phases.at(row).name.c_str());
2291 myPhaseTable->setColumnLabelTop(colDuration,
"dur");
2292 myPhaseTable->setColumnLabelTop(colState,
"state");
2293 myPhaseTable->setColumnLabelTop(colNext,
"next");
2294 myPhaseTable->setColumnLabelTop(colName,
"name");
2296 updateCycleDuration(colDuration);
2297 updateStateSize(colState);
2299 myPhaseTable->setFocus();
2306 const int colDuration = 1;
2307 const int colMinDur = 2;
2308 const int colMaxDur = 3;
2309 const int colState = 4;
2310 const int colEarliestEnd = 5;
2311 const int colLatestEnd = 6;
2312 const int colNext = 7;
2313 const int colName = 8;
2315 const auto& phases = myTLSEditorParent->myEditedDef->getLogic()->getPhases();
2317 myPhaseTable->setTableSize(
"suffpff-midtb", (
int)phases.size());
2319 for (
int row = 0; row < (int)phases.size(); row++) {
2320 myPhaseTable->setItemText(row, colDuration,
getSteps2Time(phases.at(row).duration).c_str());
2321 myPhaseTable->setItemText(row, colMinDur,
varDurString(phases.at(row).minDur).c_str());
2322 myPhaseTable->setItemText(row, colMaxDur,
varDurString(phases.at(row).maxDur).c_str());
2323 myPhaseTable->setItemText(row, colState, phases.at(row).state.c_str());
2324 myPhaseTable->setItemText(row, colEarliestEnd,
varDurString(phases.at(row).earliestEnd).c_str());
2325 myPhaseTable->setItemText(row, colLatestEnd,
varDurString(phases.at(row).latestEnd).c_str());
2326 myPhaseTable->setItemText(row, colNext, phases.at(row).next.size() > 0 ?
toString(phases.at(row).next).c_str() :
"");
2327 myPhaseTable->setItemText(row, colName, phases.at(row).name.c_str());
2330 myPhaseTable->setColumnLabelTop(colDuration,
"dur");
2331 myPhaseTable->setColumnLabelTop(colMinDur,
"min");
2332 myPhaseTable->setColumnLabelTop(colMaxDur,
"max");
2333 myPhaseTable->setColumnLabelTop(colEarliestEnd,
"ear.end",
"earlyEnd");
2334 myPhaseTable->setColumnLabelTop(colLatestEnd,
"lat.end",
"latestEnd");
2335 myPhaseTable->setColumnLabelTop(colState,
"state");
2336 myPhaseTable->setColumnLabelTop(colNext,
"next");
2337 myPhaseTable->setColumnLabelTop(colName,
"name");
2339 updateCycleDuration(colDuration);
2340 updateStateSize(colState);
2342 myPhaseTable->setFocus();
2349 const int colDuration = 1;
2350 const int colMinDur = 2;
2351 const int colMaxDur = 3;
2352 const int colState = 4;
2353 const int colNext = 5;
2354 const int colName = 6;
2356 const auto& phases = myTLSEditorParent->myEditedDef->getLogic()->getPhases();
2358 myPhaseTable->setTableSize(
"suffp-midtb", (
int)phases.size());
2360 for (
int row = 0; row < (int)phases.size(); row++) {
2361 myPhaseTable->setItemText(row, colDuration,
getSteps2Time(phases.at(row).duration).c_str());
2362 myPhaseTable->setItemText(row, colMinDur,
varDurString(phases.at(row).minDur).c_str());
2363 myPhaseTable->setItemText(row, colMaxDur,
varDurString(phases.at(row).maxDur).c_str());
2364 myPhaseTable->setItemText(row, colState, phases.at(row).state.c_str());
2365 myPhaseTable->setItemText(row, colNext, phases.at(row).next.size() > 0 ?
toString(phases.at(row).next).c_str() :
"");
2366 myPhaseTable->setItemText(row, colName, phases.at(row).name.c_str());
2369 myPhaseTable->setColumnLabelTop(colDuration,
"dur");
2370 myPhaseTable->setColumnLabelTop(colMinDur,
"min");
2371 myPhaseTable->setColumnLabelTop(colMaxDur,
"max");
2372 myPhaseTable->setColumnLabelTop(colState,
"state");
2373 myPhaseTable->setColumnLabelTop(colNext,
"next");
2374 myPhaseTable->setColumnLabelTop(colName,
"name");
2376 updateCycleDuration(colDuration);
2377 updateStateSize(colState);
2379 myPhaseTable->setFocus();
2386 const int colDuration = 1;
2387 const int colMinDur = 2;
2388 const int colMaxDur = 3;
2389 const int colState = 4;
2390 const int colVehExt = 5;
2391 const int colYellow = 6;
2392 const int colRed = 7;
2393 const int colNext = 8;
2394 const int colName = 9;
2396 const auto& phases = myTLSEditorParent->myEditedDef->getLogic()->getPhases();
2398 myPhaseTable->setTableSize(
"suffpfff-midtb", (
int)phases.size());
2400 for (
int row = 0; row < (int)phases.size(); row++) {
2401 myPhaseTable->setItemText(row, colDuration,
getSteps2Time(phases.at(row).duration).c_str());
2402 myPhaseTable->setItemText(row, colMinDur,
varDurString(phases.at(row).minDur).c_str());
2403 myPhaseTable->setItemText(row, colMaxDur,
varDurString(phases.at(row).maxDur).c_str());
2404 myPhaseTable->setItemText(row, colState, phases.at(row).state.c_str());
2405 myPhaseTable->setItemText(row, colVehExt,
varDurString(phases.at(row).vehExt).c_str());
2406 myPhaseTable->setItemText(row, colYellow,
varDurString(phases.at(row).yellow).c_str());
2407 myPhaseTable->setItemText(row, colRed,
varDurString(phases.at(row).red).c_str());
2408 myPhaseTable->setItemText(row, colNext, phases.at(row).next.size() > 0 ?
toString(phases.at(row).next).c_str() :
"");
2409 myPhaseTable->setItemText(row, colName, phases.at(row).name.c_str());
2412 myPhaseTable->setColumnLabelTop(colDuration,
"dur");
2413 myPhaseTable->setColumnLabelTop(colMinDur,
"min");
2414 myPhaseTable->setColumnLabelTop(colMaxDur,
"max");
2415 myPhaseTable->setColumnLabelTop(colState,
"state");
2416 myPhaseTable->setColumnLabelTop(colVehExt,
"vehExt",
"vehicle extension");
2417 myPhaseTable->setColumnLabelTop(colYellow,
"yellow");
2418 myPhaseTable->setColumnLabelTop(colRed,
"red");
2419 myPhaseTable->setColumnLabelTop(colNext,
"next");
2420 myPhaseTable->setColumnLabelTop(colName,
"name");
2422 updateCycleDuration(colDuration);
2423 updateStateSize(colState);
2425 myPhaseTable->setFocus();
2437 const int newIndex = row + 1;
2439 auto duration =
getSUMOTime(myPhaseTable->getItemText(row, 1));
2440 const auto oldState = myPhaseTable->getItemText(row, TLSStatic ? 2 : 4);
2441 auto state = oldState;
2443 std::set<int> crossingIndices;
2444 for (
const auto& node : myTLSEditorParent->myEditedDef->getNodes()) {
2445 for (
const auto& crossing : node->getCrossings()) {
2446 crossingIndices.insert(crossing->tlLinkIndex);
2447 crossingIndices.insert(crossing->tlLinkIndex2);
2451 bool haveGreen =
false;
2452 bool haveYellow =
false;
2453 for (
const auto& linkStateChar : state) {
2460 if (haveGreen && haveYellow) {
2462 duration =
TIME2STEPS(neteditOptions.getInt(
"tls.left-green.time"));
2463 for (
int i = 0; i < (int)state.size(); i++) {
2470 }
else if (haveGreen) {
2472 myTLSEditorParent->myEditedDef->setParticipantsInformation();
2473 duration =
TIME2STEPS(myTLSEditorParent->myEditedDef->computeBrakingTime(neteditOptions.getFloat(
"tls.yellow.min-decel")));
2474 for (
int i = 0; i < (int)state.size(); i++) {
2476 if (crossingIndices.count(i) == 0) {
2483 }
else if (haveYellow) {
2484 duration =
TIME2STEPS(neteditOptions.isDefault(
"tls.allred.time") ? 2 : neteditOptions.getInt(
"tls.allred.time"));
2486 for (
int i = 0; i < (int)state.size(); i++) {
2493 const int nextIndex = (myPhaseTable->getNumRows() > newIndex) ? newIndex : 0;
2494 const std::string state2 = myPhaseTable->getItemText(nextIndex, (TLSStatic ? 2 : 4));
2495 for (
int i = 0; i < (int)state.size(); i++) {
2498 state[i] = oldState[i];
2507 myTLSEditorParent->myEditedDef->getLogic()->addStep(duration, state, std::vector<int>(),
"", newIndex);
2517 if (value.empty()) {
2519 getPhaseTable()->setItemText(row, col,
getSteps2Time(myTLSEditorParent->getPhase(row).duration).c_str());
2521 }
else if (GNEAttributeCarrier::canParse<double>(value)) {
2525 myTLSEditorParent->myEditedDef->getLogic()->setPhaseDuration(row, duration);
2526 myTLSEditorParent->myTLSPrograms->markAsModified();
2528 updateCycleDuration(col);
2542 const auto& phase = myTLSEditorParent->getPhase(row);
2544 const auto newState = value.empty() ? phase.state : value;
2547 myTLSEditorParent->myEditedDef->getLogic()->addStep(phase.duration, newState, phase.next, phase.name, row);
2554 myTLSEditorParent->myEditedDef->getLogic()->deletePhase(row + 1);
2560 if (value.size() > 0) {
2561 myTLSEditorParent->myTLSPrograms->markAsModified();
2563 myPhaseTable->selectRow(row);
2566 getPhaseTable()->setItemText(row, col, newState);
2569 updateStateSize(col);
2578 const auto nextEdited = GNEAttributeCarrier::parse<std::vector<int> >(value);
2579 for (
const auto nextPhase : nextEdited) {
2580 if ((nextPhase < 0) || (nextPhase >= myPhaseTable->getNumRows())) {
2585 myTLSEditorParent->myEditedDef->getLogic()->setPhaseNext(row, nextEdited);
2586 myTLSEditorParent->myTLSPrograms->markAsModified();
2597 myTLSEditorParent->myEditedDef->getLogic()->setPhaseName(row, value);
2598 myTLSEditorParent->myTLSPrograms->markAsModified();
2606 if (value.empty()) {
2609 myTLSEditorParent->myTLSPrograms->markAsModified();
2611 }
else if (GNEAttributeCarrier::canParse<double>(value)) {
2615 myTLSEditorParent->myEditedDef->getLogic()->setPhaseMinDuration(row, minDur);
2616 myTLSEditorParent->myTLSPrograms->markAsModified();
2623 myTLSEditorParent->myTLSPrograms->markAsModified();
2634 if (value.empty()) {
2637 myTLSEditorParent->myTLSPrograms->markAsModified();
2639 }
else if (GNEAttributeCarrier::canParse<double>(value)) {
2643 myTLSEditorParent->myEditedDef->getLogic()->setPhaseMaxDuration(row, maxDur);
2644 myTLSEditorParent->myTLSPrograms->markAsModified();
2651 myTLSEditorParent->myTLSPrograms->markAsModified();
2662 if (value.empty()) {
2665 myTLSEditorParent->myTLSPrograms->markAsModified();
2667 }
else if (GNEAttributeCarrier::canParse<double>(value)) {
2670 if (earliestEnd > 0) {
2671 myTLSEditorParent->myEditedDef->getLogic()->setPhaseEarliestEnd(row, earliestEnd);
2672 myTLSEditorParent->myTLSPrograms->markAsModified();
2679 myTLSEditorParent->myTLSPrograms->markAsModified();
2690 if (value.empty()) {
2693 myTLSEditorParent->myTLSPrograms->markAsModified();
2695 }
else if (GNEAttributeCarrier::canParse<double>(value)) {
2698 if (latestEnd > 0) {
2699 myTLSEditorParent->myEditedDef->getLogic()->setPhaseLatestEnd(row, latestEnd);
2700 myTLSEditorParent->myTLSPrograms->markAsModified();
2707 myTLSEditorParent->myTLSPrograms->markAsModified();
2718 if (value.empty()) {
2721 myTLSEditorParent->myTLSPrograms->markAsModified();
2723 }
else if (GNEAttributeCarrier::canParse<double>(value)) {
2727 myTLSEditorParent->myEditedDef->getLogic()->setPhaseVehExt(row, vehExt);
2728 myTLSEditorParent->myTLSPrograms->markAsModified();
2735 myTLSEditorParent->myTLSPrograms->markAsModified();
2746 if (value.empty()) {
2749 myTLSEditorParent->myTLSPrograms->markAsModified();
2751 }
else if (GNEAttributeCarrier::canParse<double>(value)) {
2755 myTLSEditorParent->myEditedDef->getLogic()->setPhaseYellow(row, yellow);
2756 myTLSEditorParent->myTLSPrograms->markAsModified();
2763 myTLSEditorParent->myTLSPrograms->markAsModified();
2774 if (value.empty()) {
2777 myTLSEditorParent->myTLSPrograms->markAsModified();
2779 }
else if (GNEAttributeCarrier::canParse<double>(value)) {
2783 myTLSEditorParent->myEditedDef->getLogic()->setPhaseRed(row, red);
2784 myTLSEditorParent->myTLSPrograms->markAsModified();
2791 myTLSEditorParent->myTLSPrograms->markAsModified();
2802 for (
const auto& phase : myTLSEditorParent->myEditedDef->getLogic()->getPhases()) {
2803 cycleDuration += phase.duration;
2806 myPhaseTable->setColumnLabelBot(col,
getSteps2Time(cycleDuration));
2813 myPhaseTable->setColumnLabelBot(col,
"Links: " +
toString(myTLSEditorParent->myEditedDef->getLogic()->getNumLinks()));
2822 myTLSEditorParent(TLSEditorParent) {
2840 if (myTLSEditorParent->myTLSPrograms->getNumberOfPrograms() == 0) {
2841 myLoadButton->disable();
2842 mySaveButton->disable();
2843 }
else if (myTLSEditorParent->myTLSAttributes->isSetDetectorsToggleButtonEnabled()) {
2845 myLoadButton->disable();
2846 mySaveButton->disable();
2847 }
else if (myTLSEditorParent->myTLSJunction->isJoiningJunctions()) {
2849 myLoadButton->disable();
2850 mySaveButton->disable();
2852 myLoadButton->enable();
2853 mySaveButton->enable();
2872 FXFileDialog opendialog(getCollapsableFrame(),
"Load TLS Program");
2874 opendialog.setSelectMode(SELECTFILE_EXISTING);
2879 if (opendialog.execute()) {
2883 tmpTLLCont.
insert(myTLSEditorParent->myEditedDef);
2887 std::set<NBLoadedSUMOTLDef*> newDefsOtherProgram;
2888 for (
auto item : tmpTLLCont.
getPrograms(myTLSEditorParent->myEditedDef->getID())) {
2889 if (item.second != myTLSEditorParent->myEditedDef) {
2891 if (item.first == myTLSEditorParent->myEditedDef->getProgramID()) {
2892 newDefSameProgram = sdef;
2894 newDefsOtherProgram.insert(sdef);
2898 const int newPrograms = (int)newDefsOtherProgram.size();
2899 if (newPrograms > 0 || newDefSameProgram !=
nullptr) {
2900 std::vector<NBNode*> nodes = myTLSEditorParent->myEditedDef->
getNodes();
2901 for (
auto newProg : newDefsOtherProgram) {
2902 for (
auto it_node : nodes) {
2904 myTLSEditorParent->getViewNet()->getUndoList()->add(
new GNEChange_TLS(junction, newProg,
true),
true);
2907 if (newPrograms > 0) {
2908 WRITE_MESSAGE(
TL(
"Loaded ") +
toString(newPrograms) +
TL(
" new programs for tlLogic '") + myTLSEditorParent->myEditedDef->getID() +
"'");
2910 if (newDefSameProgram !=
nullptr) {
2912 myTLSEditorParent->myEditedDef = newDefSameProgram;
2913 WRITE_MESSAGE(
TL(
"Updated program '") + newDefSameProgram->
getProgramID() +
TL(
"' for tlLogic '") + myTLSEditorParent->myEditedDef->getID() +
"'");
2916 if (tllHandler.
getSeenIDs().count(myTLSEditorParent->myEditedDef->getID()) == 0) {
2917 myTLSEditorParent->getViewNet()->setStatusBarText(
TL(
"No programs found for traffic light '") + myTLSEditorParent->myEditedDef->getID() +
"'");
2923 tmpTLLCont.
removeProgram(def->getID(), def->getProgramID(),
false);
2926 myTLSEditorParent->myTLSPhases->initPhaseTable();
2927 myTLSEditorParent->myTLSPrograms->markAsModified();
2929 myTLSEditorParent->updateModules();
2949 myTLSEditorParent->updateModules();
2957 if (time == std::floor(time)) {
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 GUIDesignTextColorRed
red color (for invalid text)
#define GUIDesignComboBoxAttribute
Combo box static (cannot be edited) extended over the matrix column.
#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 GUIDesignComboBoxVisibleItems
#define GUIDesignTextColorBlack
black color (for correct text)
#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_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_TLLINKINDEX2
link: the index of the opposite direction link of a pedestrian crossing
@ SUMO_ATTR_TLTYPE
node: the type of traffic light
@ SUMO_ATTR_TLID
link,node: the traffic light id responsible for this link
@ SUMO_ATTR_TLLINKINDEX
link: the index of the link within the traffic light
const unsigned char TLS[]
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.
bool isAttributeCarrierSelected() const
check if attribute carrier is selected
const std::string getID() const override
get ID (all Attribute Carriers have one)
static bool canParse(const std::string &string)
true if a value of type T can be parsed from string
const GNETagProperties * getTagProperty() const
get tagProperty associated with this Attribute Carrier
GNENet * getNet() const
get pointer to net
GNEViewNet * getViewNet() const
get view net
GNEViewNet * myViewNet
FOX need this.
virtual void show()
show Frame
virtual void hide()
hide Frame
const GNEHierarchicalContainerChildren< GNELane * > & getChildLanes() const
get child lanes
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.
const std::vector< GNECrossing * > & getGNECrossings() const
Returns GNECrossings.
std::string getAttribute(SumoXMLAttr key) const override
void selectTLS(bool selected)
notify the junction of being selected in tls-mode. (used to control drawing)
std::vector< GNEConnection * > getGNEConnections() const
Returns all GNEConnections vinculated with this junction.
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList) override
const std::vector< GNEEdge * > & getGNEOutgoingEdges() const
Returns incoming GNEEdges.
NBNode * getNBNode() const
Return net build node.
GNEEdge * getParentEdge() const
get parent edge
void deleteInternalLane(GNEInternalLane *internalLane)
delete internalLane from container
void insertInternalLane(GNEInternalLane *internalLane)
insert internalLane in container
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
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 clearOverlappedInspection()
clear overlapped inspection
GNEAttributeCarrier * getCurrentAC() const
get current AC
void hiderOverlappedInspection()
hide overlapped inspection
void showOverlappedInspection(GNEViewNetHelper::ViewObjectsSelector &viewObjects, const Position &clickedPosition, const bool shiftKeyPressed)
show overlapped inspection
int getNumberOfOverlappedACs() const
get number of overlapped ACs
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.
MFXToggleButtonTooltip * mySetDetectorsToggleButton
toggle button for set detectors mode
bool isSetDetectorsToggleButtonEnabled() const
toggle button for set detectors mode
bool isValidParameters()
are current parameter valid
void updateTLSAttributes()
update TLSAttributes module
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
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
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 updateTLSFile()
update TLSFile module
FXButton * myLoadButton
load button
void showTLSFile()
show TLSPhases
void hideTLSFile()
hide TLSPhases
FXButton * mySaveButton
save button
long onCmdLoadTLSProgram(FXObject *, FXSelector, void *)
load TLS Program from an additional file
TLSFile(GNETLSEditorFrame *TLSEditorParent)
FOX-declaration.
std::string writeSUMOTime(SUMOTime steps)
FOX needs this.
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.
void refreshTLSJunction()
FOX needs this.
FXHorizontalFrame * myJoinControlButtons
frame for accept/cancel buttons
const std::vector< std::string > & getSelectedJunctionIDs() const
get selected junction IDs
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
MFXComboBoxIcon * myTLSTypeComboBox
ComboBox for TLS Types.
MFXToggleButtonTooltip * myJoinTLSToggleButton
Toggle button for join TLS.
void updateTLSJunction()
update TLSJunction module
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
FXLabel * myJunctionIDLabel
label for junction ID
bool isJunctionSelected(const GNEJunction *junction) const
check if given junction is selected (used fo joining)
MFXTextFieldIcon * myJunctionIDTextField
text field for junction ID
MFXButtonTooltip * myDisjoinTLSButton
button for disjoin TLS
bool isJoiningJunctions() const
is joining junctions
MFXTextFieldIcon * myTLSIDTextField
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.
void clearPhaseTable()
clear phase thable
MFXButtonTooltip * myGroupSignalsButton
group signals button
bool setVehExt(const int row, const std::string &value)
set vehExt
MFXButtonTooltip * myAddStates
add states button
int buildDefaultPhase(const int row)
build default phase
void updateTLSPhases()
update TLSPhases module
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.)
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
MFXButtonTooltip * myCleanStatesButton
clean states button
void updateStateSize(const int col)
update state size
MFXButtonTooltip * myUngroupSignalsButton
ungroup signals button
long onCmdAddUnusedStates(FXObject *, FXSelector, void *)
Called when the user cleans up states.
void initStaticPhaseTable()
init static phase table
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
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
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
bool checkHaveModifications() const
check if current TLS was modified
FXButton * mySaveButon
button for save TLS program
void updateTLSPrograms()
update TLSPrograms module
bool initTLSPrograms()
init TLS Definitions
long onCmdDefSwitchTLSProgram(FXObject *, FXSelector, void *)
Called when the user switches a TLS.
MFXComboBoxIcon * myProgramComboBox
the comboBox for selecting the tl-definition to edit
FXButton * myCancelButon
button for cancel TLS program
void clearTLSProgramss()
clear TLS Definitions
int getNumberOfPrograms() const
get number of programs
long onCmdSaveChanges(FXObject *, FXSelector, void *)
Called when the user presses the save-Button.
void hideTLSPrograms()
hide TLSPrograms
bool switchProgram()
switch program
void createTLS(GNEJunction *junction)
FOX needs this.
FXButton * myDeleteButton
button for delete existent TLS program
long onCmdDiscardChanges(FXObject *, FXSelector, void *)
Called when the user presses the Cancel-button.
void discardChanges(const bool editJunctionAgain)
discard changes
long onCmdCreate(FXObject *, FXSelector, void *)
FXButton * myResetAllButton
button for reset all TLS program
long onCmdResetAll(FXObject *, FXSelector, void *)
Called when the user press button reset all TLS Programs.
FXButton * myResetSingleButton
button for reset TLS program
long onCmdResetCurrentProgram(FXObject *, FXSelector, void *)
Called when the user press button reset current TLS Program.
NBTrafficLightDefinition * getCurrentTLSPrograms() const
get current definition
TLSPrograms(GNETLSEditorFrame *TLSEditorParent)
FOX-declaration.
void showTLSPrograms()
show TLSPrograms
void markAsModified()
mark Program as modified
long onCmdDelete(FXObject *, FXSelector, void *)
Called when the user press button delete TLS Program.
const std::string getCurrentTLSProgramID() const
get current program ID
FXButton * myCreateButton
button for create new TLS program
GNETLSEditorFrame::TLSFile * myTLSFile
module for load/Save TLS Programs
GNETLSEditorFrame::TLSPrograms * myTLSPrograms
module for TLS Definition
void handleChange(GNEInternalLane *lane)
update phase definition for the current traffic light and phase
GNEOverlappedInspection * myOverlappedInspection
Overlapped Inspection.
GNETLSEditorFrame::TLSPhases * getTLSPhases() const
get module for TLS Phases
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 to the current junction indexed by their tl-index
void updateModules()
update modules
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::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
void editTLS(GNEViewNetHelper::ViewObjectsSelector &viewObjects, const Position &clickedPosition, const bool shiftKeyPressed)
edits the traffic light for the given clicked junction
GNETLSEditorFrame::TLSJunction * myTLSJunction
module for TLS Junction
GNETLSEditorFrame::TLSPrograms * getTLSPrograms() const
get module for TLS Definition
void cleanup()
cleans up previous lanes
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
const std::vector< GNEJunction * > & getJunctions() const
get vector with junctions
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
static FXButton * buildFXButton(FXComposite *p, const std::string &text, const std::string &tip, const std::string &help, FXIcon *ic, FXObject *tgt, FXSelector sel, FXuint opts=BUTTON_NORMAL, FXint x=0, FXint y=0, FXint w=0, FXint h=0, FXint pl=DEFAULT_PAD, FXint pr=DEFAULT_PAD, FXint pt=DEFAULT_PAD, FXint pb=DEFAULT_PAD)
build button
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
void disable()
Disable combo box.
FXint appendIconItem(const FXString &text, FXIcon *icon=nullptr, FXColor bgColor=FXRGB(255, 255, 255), void *ptr=nullptr)
append icon item in the last position
MFXGroupBoxModule (based on FXGroupBox)
FXVerticalFrame * getCollapsableFrame()
get collapsable frame (used by all elements that will be collapsed if button is toggled)
void setText(const std::string &text)
set text
Options
GroupBoxModule options.
virtual void disable()
Disable text field.
static FXString getFilename2Write(FXWindow *parent, const FXString &header, const FXString &extensions, 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.
A definition of a pedestrian crossing.
int tlLinkIndex
the traffic light index of this crossing (if controlled)
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 exist(const std::string &newID, bool requireComputed=true) const
check if exists a definition with the given ID
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()
static void writeTrafficLight(OutputDevice &into, const NBTrafficLightLogic *logic)
writes a single traffic light logic to the given device
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.
void close()
Closes the device and removes it from the dictionary.
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 amount
PositionVector reverse() const
reverse position vector
static const RGBColor BLACK
static const RGBColor RED
named colors
static StringBijection< TrafficLightType > TrafficLightTypes
traffic light types
static StringBijection< XMLFileExtension > XMLFileExtensions
XML file Extensions.
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