Eclipse SUMO - Simulation of Urban MObility
GNETLSEditorFrame.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
14 // The Widget for modifying traffic lights
15 /****************************************************************************/
16 
17 
18 // ===========================================================================
19 // included modules
20 // ===========================================================================
21 #include <config.h>
22 
26 #include <utils/xml/XMLSubSys.h>
29 #include <netedit/GNEViewNet.h>
30 #include <netedit/GNENet.h>
34 #include <netedit/GNEUndoList.h>
37 
38 #include "GNETLSEditorFrame.h"
39 
40 // ===========================================================================
41 // FOX callback mapping
42 // ===========================================================================
43 
44 FXDEFMAP(GNETLSEditorFrame) GNETLSEditorFrameMap[] = {
45  FXMAPFUNC(SEL_COMMAND, MID_CANCEL, GNETLSEditorFrame::onCmdCancel),
46  FXMAPFUNC(SEL_UPDATE, MID_CANCEL, GNETLSEditorFrame::onUpdModified),
47  FXMAPFUNC(SEL_COMMAND, MID_OK, GNETLSEditorFrame::onCmdOK),
48  FXMAPFUNC(SEL_UPDATE, MID_OK, GNETLSEditorFrame::onUpdModified),
73 };
74 
75 FXDEFMAP(GNETLSEditorFrame::TLSFile) TLSFileMap[] = {
80 };
81 
82 // Object implementation
83 FXIMPLEMENT(GNETLSEditorFrame, FXVerticalFrame, GNETLSEditorFrameMap, ARRAYNUMBER(GNETLSEditorFrameMap))
84 FXIMPLEMENT(GNETLSEditorFrame::TLSFile, FXGroupBox, TLSFileMap, ARRAYNUMBER(TLSFileMap))
85 
86 
87 // ===========================================================================
88 // method definitions
89 // ===========================================================================
90 
91 GNETLSEditorFrame::GNETLSEditorFrame(FXHorizontalFrame* horizontalFrameParent, GNEViewNet* viewNet):
92  GNEFrame(horizontalFrameParent, viewNet, "Edit Traffic Light"),
93  myEditedDef(nullptr) {
94 
95  // Create Overlapped Inspection modul
96  myOverlappedInspection = new GNEFrameModuls::OverlappedInspection(this, SUMO_TAG_JUNCTION);
97 
98  // create TLSJunction modul
99  myTLSJunction = new GNETLSEditorFrame::TLSJunction(this);
100 
101  // create TLSDefinition modul
102  myTLSDefinition = new GNETLSEditorFrame::TLSDefinition(this);
103 
104  // create TLSAttributes modul
105  myTLSAttributes = new GNETLSEditorFrame::TLSAttributes(this);
106 
107  // create TLSModifications modul
108  myTLSModifications = new GNETLSEditorFrame::TLSModifications(this);
109 
110  // create TLSPhases modul
111  myTLSPhases = new GNETLSEditorFrame::TLSPhases(this);
112 
113  // create TLSFile modul
114  myTLSFile = new GNETLSEditorFrame::TLSFile(this);
115 
116  // "Add 'off' program"
117  /*
118  new FXButton(myContentFrame, "Add \"Off\"-Program\t\tAdds a program for switching off this traffic light",
119  0, this, MID_GNE_TLSFRAME_ADDOFF, GUIDesignButton);
120  */
121 }
122 
123 
125  cleanup();
126 }
127 
128 
129 void
131  // hide myOverlappedInspection
133  GNEFrame::show();
134 }
135 
136 void
137 GNETLSEditorFrame::editTLS(const Position& clickedPosition, const GNEViewNetHelper::ObjectsUnderCursor& objectsUnderCursor) {
138  // first check if in objectsUnderCursor there is a junction
139  if (objectsUnderCursor.getJunctionFront()) {
140  // show objects under cursor
141  myOverlappedInspection->showOverlappedInspection(objectsUnderCursor, clickedPosition);
142  // hide if we inspect only one junction
145  }
146  // set junction
147  editJunction(objectsUnderCursor.getJunctionFront());
148  } else {
149  myViewNet->setStatusBarText("Click over a junction to edit a TLS");
150  }
151 }
152 
153 
154 bool
157  // write warning if netedit is running in testing mode
158  WRITE_DEBUG("Opening question FXMessageBox 'save TLS'");
159  // open question box
160  FXuint answer = FXMessageBox::question(this, MBOX_YES_NO_CANCEL,
161  "Save TLS Changes", "%s",
162  "There is unsaved changes in current edited traffic light.\nDo you want to save it before changing mode?");
163  if (answer == MBOX_CLICKED_YES) { //1:yes, 2:no, 4:esc/cancel
164  // write warning if netedit is running in testing mode
165  WRITE_DEBUG("Closed FXMessageBox 'save TLS' with 'YES'");
166  // save modifications
167  onCmdOK(nullptr, 0, nullptr);
168  return true;
169  } else if (answer == MBOX_CLICKED_NO) {
170  // write warning if netedit is running in testing mode
171  WRITE_DEBUG("Closed FXMessageBox 'save TLS' with 'No'");
172  // cancel modifications
173  onCmdCancel(nullptr, 0, nullptr);
174  return true;
175  } else {
176  // write warning if netedit is running in testing mode
177  WRITE_DEBUG("Closed FXMessageBox 'save TLS' with 'Cancel'");
178  // abort changing mode
179  return false;
180  }
181  } else {
182  return true;
183  }
184 }
185 
186 
187 bool
188 GNETLSEditorFrame::parseTLSPrograms(const std::string& file) {
190  NBTrafficLightLogicCont tmpTLLCont;
191  NIXMLTrafficLightsHandler tllHandler(tmpTLLCont, myViewNet->getNet()->getEdgeCont());
192  // existing definitions must be available to update their programs
193  std::set<NBTrafficLightDefinition*> origDefs;
194  for (NBTrafficLightDefinition* def : tllCont.getDefinitions()) {
195  // make a copy of every program
196  NBTrafficLightLogic* logic = tllCont.getLogic(def->getID(), def->getProgramID());
197  if (logic != nullptr) {
198  NBTrafficLightDefinition* copy = new NBLoadedSUMOTLDef(def, logic);
199  std::vector<NBNode*> nodes = def->getNodes();
200  for (auto it_node : nodes) {
201  GNEJunction* junction = myViewNet->getNet()->retrieveJunction(it_node->getID());
202  myViewNet->getUndoList()->add(new GNEChange_TLS(junction, def, false, false), true);
203  myViewNet->getUndoList()->add(new GNEChange_TLS(junction, copy, true), true);
204  }
205  tmpTLLCont.insert(copy);
206  origDefs.insert(copy);
207  } else {
208  WRITE_WARNING("tlLogic '" + def->getID() + "', program '" + def->getProgramID() + "' could not be built");
209  }
210  }
211  //std::cout << " initialized tmpCont with " << origDefs.size() << " defs\n";
212  XMLSubSys::runParser(tllHandler, file);
213 
214  std::vector<NBLoadedSUMOTLDef*> loadedTLS;
215  for (NBTrafficLightDefinition* def : tmpTLLCont.getDefinitions()) {
216  NBLoadedSUMOTLDef* sdef = dynamic_cast<NBLoadedSUMOTLDef*>(def);
217  if (sdef != nullptr) {
218  loadedTLS.push_back(sdef);
219  }
220  }
221  myViewNet->setStatusBarText("Loaded " + toString(loadedTLS.size()) + " programs");
222  for (auto def : loadedTLS) {
223  if (origDefs.count(def) != 0) {
224  // already add to undolist before
225  //std::cout << " skip " << def->getDescription() << "\n";
226  continue;
227  }
228  std::vector<NBNode*> nodes = def->getNodes();
229  //std::cout << " add " << def->getDescription() << " for nodes=" << toString(nodes) << "\n";
230  for (auto it_node : nodes) {
231  GNEJunction* junction = myViewNet->getNet()->retrieveJunction(it_node->getID());
232  //myViewNet->getUndoList()->add(new GNEChange_TLS(junction, myTLSEditorParent->myEditedDef, false), true);
233  myViewNet->getUndoList()->add(new GNEChange_TLS(junction, def, true), true);
234  }
235  }
236  // clean up temporary container to avoid deletion of defs when it's destruct is called
237  for (NBTrafficLightDefinition* def : tmpTLLCont.getDefinitions()) {
238  tmpTLLCont.removeProgram(def->getID(), def->getProgramID(), false);
239  }
240  return true;
241 }
242 
243 
244 long
245 GNETLSEditorFrame::onCmdCancel(FXObject*, FXSelector, void*) {
246  if (myTLSJunction->getCurrentJunction() != nullptr) {
248  cleanup();
249  myViewNet->update();
250  }
251  return 1;
252 }
253 
254 
255 long
256 GNETLSEditorFrame::onCmdOK(FXObject*, FXSelector, void*) {
257  if (myTLSJunction->getCurrentJunction() != nullptr) {
260  std::vector<NBNode*> nodes = oldDefinition->getNodes();
261  for (auto it : nodes) {
262  GNEJunction* junction = myViewNet->getNet()->retrieveJunction(it->getID());
263  myViewNet->getUndoList()->add(new GNEChange_TLS(junction, oldDefinition, false), true);
264  myViewNet->getUndoList()->add(new GNEChange_TLS(junction, myEditedDef, true), true);
265  }
266  myEditedDef = nullptr;
268  cleanup();
269  myViewNet->update();
270  } else {
271  onCmdCancel(nullptr, 0, nullptr);
272  }
273  }
274  return 1;
275 }
276 
277 
278 long
279 GNETLSEditorFrame::onCmdDefCreate(FXObject*, FXSelector, void*) {
281  // abort because we onCmdOk assumes we wish to save an edited definition
282  onCmdCancel(nullptr, 0, nullptr);
283  // check that current junction has two or more edges
284  if ((junction->getGNEIncomingEdges().size() > 0) && (junction->getGNEOutgoingEdges().size() > 0)) {
287  } else {
288  myViewNet->getUndoList()->add(new GNEChange_TLS(junction, nullptr, true, true), true);
289  }
290  editJunction(junction);
291  } else {
292  // write warning if netedit is running in testing mode
293  WRITE_DEBUG("Opening warning FXMessageBox 'invalid TLS'");
294  // open question box
295  FXMessageBox::warning(this, MBOX_OK,
296  "TLS cannot be created", "%s",
297  "Traffic Light cannot be created because junction must have\n at least one incoming edge and one outgoing edge.");
298  // write warning if netedit is running in testing mode
299  WRITE_DEBUG("Closed FXMessageBox 'invalid TLS'");
300  }
301  return 1;
302 }
303 
304 
305 long
306 GNETLSEditorFrame::onCmdDefDelete(FXObject*, FXSelector, void*) {
308  const bool changeType = myTLSAttributes->getNumberOfTLSDefinitions() == 1;
310  onCmdCancel(nullptr, 0, nullptr); // abort because onCmdOk assumes we wish to save an edited definition
311  if (changeType) {
313  } else {
314  myViewNet->getUndoList()->add(new GNEChange_TLS(junction, tlDef, false), true);
315  }
316  return 1;
317 }
318 
319 
320 long
321 GNETLSEditorFrame::onCmdDefSwitch(FXObject*, FXSelector, void*) {
322  assert(myTLSJunction->getCurrentJunction() != 0);
325  // logic may not have been recomputed yet. recompute to be sure
328  NBTrafficLightLogic* tllogic = tllCont.getLogic(tlDef->getID(), tlDef->getProgramID());
329  if (tllogic != nullptr) {
330  // now we can be sure that the tlDef is up to date (i.e. re-guessed)
331  buildIinternalLanes(tlDef);
332  // create working copy from original def
333  delete myEditedDef;
334  myEditedDef = new NBLoadedSUMOTLDef(tlDef, tllogic);
339  } else {
340  // tlDef has no valid logic (probably because id does not control any links
341  onCmdCancel(nullptr, 0, nullptr);
342  myViewNet->setStatusBarText("Traffic light does not control any links");
343  }
344  return 1;
345 }
346 
347 
348 long
349 GNETLSEditorFrame::onUpdDefSwitch(FXObject* o, FXSelector, void*) {
351  o->handle(this, FXSEL(SEL_COMMAND, enable ? FXWindow::ID_ENABLE : FXWindow::ID_DISABLE), nullptr);
352  return 1;
353 }
354 
355 
356 long
357 GNETLSEditorFrame::onUpdNeedsDef(FXObject* o, FXSelector, void*) {
358  const bool enable = myTLSAttributes->getNumberOfTLSDefinitions() > 0;
359  o->handle(this, FXSEL(SEL_COMMAND, enable ? FXWindow::ID_ENABLE : FXWindow::ID_DISABLE), nullptr);
360  return 1;
361 }
362 
363 
364 long
365 GNETLSEditorFrame::onUpdNeedsDefAndPhase(FXObject* o, FXSelector, void*) {
366  // do not delete the last phase
367  const bool enable = myTLSAttributes->getNumberOfTLSDefinitions() > 0 && myTLSPhases->getPhaseTable()->getNumRows() > 1;
368  o->handle(this, FXSEL(SEL_COMMAND, enable ? FXWindow::ID_ENABLE : FXWindow::ID_DISABLE), nullptr);
369  return 1;
370 }
371 
372 
373 long
374 GNETLSEditorFrame::onUpdDefCreate(FXObject* o, FXSelector, void*) {
375  const bool enable = myTLSJunction->getCurrentJunction() != nullptr && !myTLSModifications->checkHaveModifications();
376  o->handle(this, FXSEL(SEL_COMMAND, enable ? FXWindow::ID_ENABLE : FXWindow::ID_DISABLE), nullptr);
377  return 1;
378 }
379 
380 
381 long
382 GNETLSEditorFrame::onUpdModified(FXObject* o, FXSelector, void*) {
384  o->handle(this, FXSEL(SEL_COMMAND, enable ? FXWindow::ID_ENABLE : FXWindow::ID_DISABLE), nullptr);
385  return 1;
386 }
387 
388 
389 
390 long
391 GNETLSEditorFrame::onCmdDefOffset(FXObject*, FXSelector, void*) {
394  return 1;
395 }
396 
397 
398 long
399 GNETLSEditorFrame::onCmdDefRename(FXObject*, FXSelector, void*) {
400  return 1;
401 }
402 
403 
404 long
405 GNETLSEditorFrame::onCmdDefSubRename(FXObject*, FXSelector, void*) {
406  return 1;
407 }
408 
409 
410 long
411 GNETLSEditorFrame::onCmdDefAddOff(FXObject*, FXSelector, void*) {
412  return 1;
413 }
414 
415 
416 long
417 GNETLSEditorFrame::onCmdGuess(FXObject*, FXSelector, void*) {
418  return 1;
419 }
420 
421 
422 long
423 GNETLSEditorFrame::onCmdPhaseSwitch(FXObject*, FXSelector, void*) {
424  const int index = myTLSPhases->getPhaseTable()->getCurrentRow();
425  const NBTrafficLightLogic::PhaseDefinition& phase = getPhases()[index];
426  myTLSPhases->getPhaseTable()->selectRow(index);
427  // need not hold since links could have been deleted somewhere else and indices may be reused
428  // assert(phase.state.size() == myInternalLanes.size());
429  for (auto it : myInternalLanes) {
430  int tlIndex = it.first;
431  std::vector<GNEInternalLane*> lanes = it.second;
433  if (tlIndex >= 0 && tlIndex < (int)phase.state.size()) {
434  state = (LinkState)phase.state[tlIndex];
435  }
436  for (auto it_lane : lanes) {
437  it_lane->setLinkState(state);
438  }
439  }
440  myViewNet->update();
441  return 1;
442 }
443 
444 
445 bool
447  assert(myEditedDef != nullptr);
448  return myEditedDef->getType() == TLTYPE_STATIC;
449 }
450 
451 
452 void
454  editJunction(dynamic_cast<GNEJunction*>(AC));
455 }
456 
457 
458 long
459 GNETLSEditorFrame::onCmdPhaseCreate(FXObject*, FXSelector, void*) {
461  // allows insertion at first position by deselecting via arrow keys
462  int newIndex = myTLSPhases->getPhaseTable()->getSelStartRow() + 1;
463  int oldIndex = MAX2(0, myTLSPhases->getPhaseTable()->getSelStartRow());
464  // copy current row
465  SUMOTime duration = getSUMOTime(myTLSPhases->getPhaseTable()->getItemText(oldIndex, 0));
466  std::string state = myTLSPhases->getPhaseTable()->getItemText(oldIndex, fixedDuration() ? 1 : 3).text();
467 
468  std::set<int> crossingIndices;
469  for (NBNode* n : myEditedDef->getNodes()) {
470  for (NBNode::Crossing* c : n->getCrossings()) {
471  crossingIndices.insert(c->tlLinkIndex);
472  crossingIndices.insert(c->tlLinkIndex2);
473  }
474  }
475 
476  // smart adapations for new state
477  bool haveGreen = false;
478  bool haveYellow = false;
479  for (char c : state) {
481  haveGreen = true;
482  } else if (c == LINKSTATE_TL_YELLOW_MAJOR || c == LINKSTATE_TL_YELLOW_MINOR) {
483  haveYellow = true;
484  }
485  }
486  const OptionsCont& oc = OptionsCont::getOptions();
487  if (haveGreen && haveYellow) {
488  // guess left-mover state
489  duration = TIME2STEPS(oc.getInt("tls.left-green.time"));
490  for (int i = 0; i < (int)state.size(); i++) {
491  if (state[i] == LINKSTATE_TL_YELLOW_MAJOR || state[i] == LINKSTATE_TL_YELLOW_MINOR) {
492  state[i] = LINKSTATE_TL_RED;
493  } else if (state[i] == LINKSTATE_TL_GREEN_MINOR) {
494  state[i] = LINKSTATE_TL_GREEN_MAJOR;
495  }
496  }
497  } else if (haveGreen) {
498  // guess yellow state
500  duration = TIME2STEPS(myEditedDef->computeBrakingTime(oc.getFloat("tls.yellow.min-decel")));
501  for (int i = 0; i < (int)state.size(); i++) {
502  if (state[i] == LINKSTATE_TL_GREEN_MAJOR || state[i] == LINKSTATE_TL_GREEN_MINOR) {
503  if (crossingIndices.count(i) == 0) {
504  state[i] = LINKSTATE_TL_YELLOW_MINOR;
505  } else {
506  state[i] = LINKSTATE_TL_RED;
507  }
508  }
509  }
510  } else if (haveYellow) {
511  duration = TIME2STEPS(oc.isDefault("tls.allred.time") ? 2 : oc.getInt("tls.allred.time"));
512  // guess all-red state
513  for (int i = 0; i < (int)state.size(); i++) {
514  if (state[i] == LINKSTATE_TL_YELLOW_MAJOR || state[i] == LINKSTATE_TL_YELLOW_MINOR) {
515  state[i] = LINKSTATE_TL_RED;
516  }
517  }
518  }
519 
520  myEditedDef->getLogic()->addStep(duration, state, std::vector<int>(), "", newIndex);
521  myTLSPhases->getPhaseTable()->setCurrentItem(newIndex, 0);
522  myTLSPhases->initPhaseTable(newIndex);
523  myTLSPhases->getPhaseTable()->setFocus();
524  return 1;
525 }
526 
527 
528 long
529 GNETLSEditorFrame::onCmdPhaseDelete(FXObject*, FXSelector, void*) {
531  const int newRow = MAX2((int)0, (int)myTLSPhases->getPhaseTable()->getCurrentRow() - 1);
532  myEditedDef->getLogic()->deletePhase(myTLSPhases->getPhaseTable()->getCurrentRow());
533  myTLSPhases->initPhaseTable(newRow);
534  myTLSPhases->getPhaseTable()->setFocus();
535  return 1;
536 }
537 
538 
539 long
540 GNETLSEditorFrame::onCmdCleanup(FXObject*, FXSelector, void*) {
543  myTLSPhases->getPhaseTable()->setFocus();
544  return 1;
545 }
546 
547 
548 long
549 GNETLSEditorFrame::onCmdAddUnused(FXObject*, FXSelector, void*) {
551  myEditedDef->getLogic()->getNumLinks() + 1);
554  myTLSPhases->getPhaseTable()->setFocus();
555  return 1;
556 }
557 
558 
559 long
560 GNETLSEditorFrame::onCmdPhaseEdit(FXObject*, FXSelector, void* ptr) {
561  /* @note: there is a bug when copying/pasting rows: when this handler is
562  * called the value of the cell is not yet updated. This means you have to
563  * click inside the cell and hit enter to actually update the value */
564  FXTablePos* tp = (FXTablePos*)ptr;
565  FXString value = myTLSPhases->getPhaseTable()->getItemText(tp->row, tp->col);
566  const int colDuration = 0;
567  const int colMinDur = fixedDuration() ? -1 : 1;
568  const int colMaxDur = fixedDuration() ? -1 : 2;
569  const int colState = fixedDuration() ? 1 : 3;
570  const int colNext = fixedDuration() ? 2 : 4;
571  const int colName = fixedDuration() ? 3 : 5;
572 
573  if (tp->col == colDuration) {
574  // duration edited
575  if (GNEAttributeCarrier::canParse<double>(value.text())) {
576  SUMOTime duration = getSUMOTime(value);
577  if (duration > 0) {
578  myEditedDef->getLogic()->setPhaseDuration(tp->row, duration);
581  return 1;
582  }
583  }
584  // input error, reset value
585  myTLSPhases->getPhaseTable()->setItemText(tp->row, colDuration, toString(STEPS2TIME(getPhases()[tp->row].duration)).c_str());
586  } else if (tp->col == colMinDur) {
587  // minDur edited
588  if (GNEAttributeCarrier::canParse<double>(value.text())) {
589  SUMOTime minDur = getSUMOTime(value);
590  if (minDur > 0) {
591  myEditedDef->getLogic()->setPhaseMinDuration(tp->row, minDur);
593  return 1;
594  }
595  } else if (StringUtils::prune(value.text()).empty()) {
598  return 1;
599  }
600  // input error, reset value
601  myTLSPhases->getPhaseTable()->setItemText(tp->row, colMinDur, varDurString(getPhases()[tp->row].minDur).c_str());
602  } else if (tp->col == colMaxDur) {
603  // maxDur edited
604  if (GNEAttributeCarrier::canParse<double>(value.text())) {
605  SUMOTime maxDur = getSUMOTime(value);
606  if (maxDur > 0) {
607  myEditedDef->getLogic()->setPhaseMaxDuration(tp->row, maxDur);
609  return 1;
610  }
611  } else if (StringUtils::prune(value.text()).empty()) {
614  return 1;
615  }
616  // input error, reset value
617  myTLSPhases->getPhaseTable()->setItemText(tp->row, colMaxDur, varDurString(getPhases()[tp->row].maxDur).c_str());
618  } else if (tp->col == colState) {
619  // state edited
620  try {
621  // insert phase with new step and delete the old phase
622  const NBTrafficLightLogic::PhaseDefinition& phase = getPhases()[tp->row];
623  myEditedDef->getLogic()->addStep(phase.duration, value.text(), phase.next, phase.name, tp->row);
624  myEditedDef->getLogic()->deletePhase(tp->row + 1);
626  onCmdPhaseSwitch(nullptr, 0, nullptr);
627  } catch (ProcessError&) {
628  // input error, reset value
629  myTLSPhases->getPhaseTable()->setItemText(tp->row, colState, getPhases()[tp->row].state.c_str());
630  }
631  } else if (tp->col == colNext) {
632  // next edited
633  bool ok = true;
634  if (GNEAttributeCarrier::canParse<std::vector<int> >(value.text())) {
635  std::vector<int> nextEdited = GNEAttributeCarrier::parse<std::vector<int> >(value.text());
636  for (int n : nextEdited) {
637  if (n < 0 || n >= myTLSPhases->getPhaseTable()->getNumRows()) {
638  ok = false;
639  break;
640  }
641  }
642  if (ok) {
643  myEditedDef->getLogic()->setPhaseNext(tp->row, nextEdited);
645  return 1;
646  }
647  }
648  // input error, reset value
649  myTLSPhases->getPhaseTable()->setItemText(tp->row, colNext, "");
650  } else if (tp->col == colName) {
651  // name edited
652  myEditedDef->getLogic()->setPhaseName(tp->row, value.text());
654  return 1;
655  }
656  return 1;
657 }
658 
659 
660 void
666  myViewNet->getNet()->retrieveJunction(node->getID())->selectTLS(false);
667  }
668  }
669  }
670  // clean data structures
673  delete myEditedDef;
674  myEditedDef = nullptr;
675  buildIinternalLanes(nullptr); // only clears
676  // clean up controls
678  myTLSPhases->initPhaseTable(); // only clears when there are no definitions
681 }
682 
683 
684 void
687  // clean up previous objects
688  for (auto it : myInternalLanes) {
689  for (auto it_intLanes : it.second) {
690  rtree.removeAdditionalGLObject(it_intLanes);
691  delete it_intLanes;
692  }
693  }
694  myInternalLanes.clear();
695  // create new internal lanes
696  if (tlDef != nullptr) {
697  const int NUM_POINTS = 10;
699  NBNode* nbnCurrentJunction = myTLSJunction->getCurrentJunction()->getNBNode();
700  std::string innerID = ":" + nbnCurrentJunction->getID(); // see NWWriter_SUMO::writeInternalEdges
701  const NBConnectionVector& links = tlDef->getControlledLinks();
702  for (auto it : links) {
703  int tlIndex = it.getTLIndex();
704  PositionVector shape = it.getFrom()->getToNode()->computeInternalLaneShape(it.getFrom(), NBEdge::Connection(it.getFromLane(),
705  it.getTo(), it.getToLane()), NUM_POINTS);
706  if (shape.length() < 2) {
707  // enlarge shape to ensure visibility
708  shape.clear();
709  PositionVector laneShapeFrom = it.getFrom()->getLaneShape(it.getFromLane());
710  PositionVector laneShapeTo = it.getTo()->getLaneShape(it.getToLane());
711  shape.push_back(laneShapeFrom.positionAtOffset(MAX2(0.0, laneShapeFrom.length() - 1)));
712  shape.push_back(laneShapeTo.positionAtOffset(MIN2(1.0, laneShapeFrom.length())));
713  }
714  GNEInternalLane* ilane = new GNEInternalLane(this, innerID + '_' + toString(tlIndex), shape, tlIndex);
715  rtree.addAdditionalGLObject(ilane);
716  myInternalLanes[tlIndex].push_back(ilane);
717  }
718  for (NBNode* nbn : tlDef->getNodes()) {
719  for (auto c : nbn->getCrossings()) {
720  if (c->tlLinkIndex2 > 0 && c->tlLinkIndex2 != c->tlLinkIndex) {
721  // draw both directions
722  PositionVector forward = c->shape;
723  forward.move2side(c->width / 4);
724  GNEInternalLane* ilane = new GNEInternalLane(this, c->id, forward, c->tlLinkIndex);
725  rtree.addAdditionalGLObject(ilane);
726  myInternalLanes[c->tlLinkIndex].push_back(ilane);
727 
728  PositionVector backward = c->shape.reverse();
729  backward.move2side(c->width / 4);
730  GNEInternalLane* ilane2 = new GNEInternalLane(this, c->id + "_r", backward, c->tlLinkIndex2);
731  rtree.addAdditionalGLObject(ilane2);
732  myInternalLanes[c->tlLinkIndex2].push_back(ilane2);
733  } else {
734  // draw only one lane for both directions
735  GNEInternalLane* ilane = new GNEInternalLane(this, c->id, c->shape, c->tlLinkIndex);
736  rtree.addAdditionalGLObject(ilane);
737  myInternalLanes[c->tlLinkIndex].push_back(ilane);
738  }
739  }
740  }
741  }
742 }
743 
744 
745 std::string
748 }
749 
750 
751 const std::vector<NBTrafficLightLogic::PhaseDefinition>&
753  return myEditedDef->getLogic()->getPhases();
754 }
755 
756 
757 void
760  if (myViewNet->changeAllPhases()) {
761  const std::vector<NBTrafficLightLogic::PhaseDefinition>& phases = getPhases();
762  for (int row = 0; row < (int)phases.size(); row++) {
763  myEditedDef->getLogic()->setPhaseState(row, lane->getTLIndex(), lane->getLinkState());
764  }
765  } else {
766  myEditedDef->getLogic()->setPhaseState(myTLSPhases->getPhaseTable()->getCurrentRow(), lane->getTLIndex(), lane->getLinkState());
767  }
768  myTLSPhases->initPhaseTable(myTLSPhases->getPhaseTable()->getCurrentRow());
769  myTLSPhases->getPhaseTable()->setFocus();
770 }
771 
772 
773 void
774 GNETLSEditorFrame::handleMultiChange(GNELane* lane, FXObject* obj, FXSelector sel, void* eventData) {
775  if (myEditedDef != nullptr) {
778  std::set<std::string> fromIDs;
779  fromIDs.insert(lane->getMicrosimID());
780  // if neither the lane nor its edge are selected, apply changes to the whole edge
782  for (auto it_lane : lane->getParentEdge()->getLanes()) {
783  fromIDs.insert(it_lane->getMicrosimID());
784  }
785  } else {
786  // if the edge is selected, apply changes to all lanes of all selected edges
787  if (lane->getParentEdge()->isAttributeCarrierSelected()) {
788  std::vector<GNEEdge*> edges = myViewNet->getNet()->retrieveEdges(true);
789  for (auto it : edges) {
790  for (auto it_lane : it->getLanes()) {
791  fromIDs.insert(it_lane->getMicrosimID());
792  }
793  }
794  }
795  // if the lane is selected, apply changes to all selected lanes
796  if (lane->isAttributeCarrierSelected()) {
797  std::vector<GNELane*> lanes = myViewNet->getNet()->retrieveLanes(true);
798  for (auto it_lane : lanes) {
799  fromIDs.insert(it_lane->getMicrosimID());
800  }
801  }
802 
803  }
804  // set new state for all connections from the chosen lane IDs
805  for (auto it : links) {
806  if (fromIDs.count(it.getFrom()->getLaneID(it.getFromLane())) > 0) {
807  std::vector<GNEInternalLane*> lanes = myInternalLanes[it.getTLIndex()];
808  for (auto it_lane : lanes) {
809  it_lane->onDefault(obj, sel, eventData);
810  }
811  }
812  }
813  }
814 }
815 
816 
817 bool
819  if (myEditedDef != nullptr) {
821  for (auto it : links) {
822  if (it.getFrom()->getID() == edge->getMicrosimID()) {
823  return true;
824  }
825  }
826  }
827  return false;
828 }
829 
830 
831 void
834  onCmdCancel(nullptr, 0, nullptr);
835  myViewNet->getUndoList()->p_begin("modifying traffic light definition");
839  // only select TLS if getCurrentJunction exist
842  }
845  myViewNet->getNet()->retrieveJunction(node->getID())->selectTLS(true);
846  }
847  }
848  } else {
849  myViewNet->setStatusBarText("Unsaved modifications. Abort or Save");
850  }
851 }
852 
853 
854 SUMOTime
855 GNETLSEditorFrame::getSUMOTime(const FXString& string) {
856  return TIME2STEPS(GNEAttributeCarrier::parse<double>(string.text()));
857 }
858 
859 // ---------------------------------------------------------------------------
860 // GNETLSEditorFrame::TLSAttributes - methods
861 // ---------------------------------------------------------------------------
862 
864  FXGroupBox(TLSEditorParent->myContentFrame, "Traffic light Attributes", GUIDesignGroupBoxFrame),
865  myTLSEditorParent(TLSEditorParent) {
866 
867  // create frame, label and textfield for name (By default disabled)
868  FXHorizontalFrame* nameFrame = new FXHorizontalFrame(this, GUIDesignAuxiliarHorizontalFrame);
869  myNameLabel = new FXLabel(nameFrame, "ID", nullptr, GUIDesignLabelAttribute);
871  myNameTextField->disable();
872 
873  // create frame, label and comboBox for Program (By default hidden)
874  FXHorizontalFrame* programFrame = new FXHorizontalFrame(this, GUIDesignAuxiliarHorizontalFrame);
875  myProgramLabel = new FXLabel(programFrame, "Program", nullptr, GUIDesignLabelAttribute);
877  myProgramComboBox->disable();
878 
879  // create frame, label and TextField for Offset (By default disabled)
880  FXHorizontalFrame* offsetFrame = new FXHorizontalFrame(this, GUIDesignAuxiliarHorizontalFrame);
881  myOffsetLabel = new FXLabel(offsetFrame, "Offset", nullptr, GUIDesignLabelAttribute);
883  myOffsetTextField->disable();
884 }
885 
886 
888 
889 
890 void
892  assert(junction);
893  myTLSDefinitions.clear();
894  // enable name TextField
895  myNameTextField->enable();
896  // enable Offset
897  myOffsetTextField->enable();
898  // obtain TLSs
899  for (auto it : junction->getNBNode()->getControllingTLS()) {
900  myTLSDefinitions.push_back(it);
901  myNameTextField->setText(it->getID().c_str());
902  myNameTextField->enable();
903  myProgramComboBox->appendItem(it->getProgramID().c_str());
904  }
905  if (myTLSDefinitions.size() > 0) {
906  myProgramComboBox->enable();
907  myProgramComboBox->setCurrentItem(0);
908  myProgramComboBox->setNumVisible(myProgramComboBox->getNumItems());
909  myTLSEditorParent->onCmdDefSwitch(nullptr, 0, nullptr);
910  }
911 }
912 
913 
914 void
916  // clear definitions
917  myTLSDefinitions.clear();
918  // clear and disable name TextField
919  myNameTextField->setText("");
920  myNameTextField->disable();
921  // clear and disable myProgramComboBox
922  myProgramComboBox->clearItems();
923  myProgramComboBox->disable();
924  // clear and disable Offset TextField
925  myOffsetTextField->setText("");
926  myOffsetTextField->disable();
927 }
928 
929 
932  return myTLSDefinitions.at(myProgramComboBox->getCurrentItem());
933 }
934 
935 
936 int
938  return (int)myTLSDefinitions.size();
939 }
940 
941 
942 int
944  return myProgramComboBox->getNumItems();
945 }
946 
947 
948 SUMOTime
950  return getSUMOTime(myOffsetTextField->getText());
951 }
952 
953 
954 void
956  myOffsetTextField->setText(toString(STEPS2TIME(offset)).c_str());
957 }
958 
959 // ---------------------------------------------------------------------------
960 // GNETLSEditorFrame::TLSJunction - methods
961 // ---------------------------------------------------------------------------
962 
964  FXGroupBox(TLSEditorParent->myContentFrame, "Junction", GUIDesignGroupBoxFrame),
965  myTLSEditorParent(TLSEditorParent),
966  myCurrentJunction(nullptr) {
967  // Create frame for junction ID
968  FXHorizontalFrame* junctionIDFrame = new FXHorizontalFrame(this, GUIDesignAuxiliarHorizontalFrame);
969  myLabelJunctionID = new FXLabel(junctionIDFrame, "Junction ID", nullptr, GUIDesignLabelAttribute);
971  myTextFieldJunctionID->setEditable(false);
972  // create frame for junction status
973  FXHorizontalFrame* junctionIDStatus = new FXHorizontalFrame(this, GUIDesignAuxiliarHorizontalFrame);
974  myLabelJunctionStatus = new FXLabel(junctionIDStatus, "Status", nullptr, GUIDesignLabelAttribute);
976  myTextFieldJunctionStatus->setEditable(false);
977  // update junction description after creation
979  // show TLS Junction
980  show();
981 }
982 
983 
985 
986 
989  return myCurrentJunction;
990 }
991 
992 
993 void
995  myCurrentJunction = junction;
996 }
997 
998 
999 void
1001  if (myCurrentJunction == nullptr) {
1002  myTextFieldJunctionID->setText("");
1003  myTextFieldJunctionStatus->setText("");
1004  } else {
1005  NBNode* nbn = myCurrentJunction->getNBNode();
1006  myTextFieldJunctionID->setText(nbn->getID().c_str());
1007  if (!nbn->isTLControlled()) {
1008  myTextFieldJunctionStatus->setText("uncontrolled");
1009  } else {
1010  myTextFieldJunctionStatus->setText(myTLSEditorParent->myTLSModifications->checkHaveModifications() ? "modified" : "unmodified");
1011  }
1012  }
1013 }
1014 
1015 // ---------------------------------------------------------------------------
1016 // GNETLSEditorFrame::TLSDefinition - methods
1017 // ---------------------------------------------------------------------------
1018 
1020  FXGroupBox(TLSEditorParent->myContentFrame, "Traffic lights definition", GUIDesignGroupBoxFrame) {
1021  // create create tlDef button
1022  myNewTLProgram = new FXButton(this, "Create TLS\t\tCreate a new traffic light program",
1024  // create delete tlDef button
1025  myDeleteTLProgram = new FXButton(this, "Delete TLS\t\tDelete a traffic light program. If all programs are deleted the junction turns into a priority junction.",
1027  // show TLS TLSDefinition
1028  show();
1029 }
1030 
1031 
1033 
1034 // ---------------------------------------------------------------------------
1035 // GNETLSEditorFrame::TLSPhases - methods
1036 // ---------------------------------------------------------------------------
1037 
1039  FXGroupBox(TLSEditorParent->myContentFrame, "Phases", GUIDesignGroupBoxFrame),
1040  myTLSEditorParent(TLSEditorParent),
1041  myTableFont(new FXFont(getApp(), "Courier New", 9)) {
1042 
1043  // create and configure phase table
1044  myTableScroll = new FXScrollWindow(this, LAYOUT_FILL_X | LAYOUT_FIX_HEIGHT);
1046  myPhaseTable->setColumnHeaderMode(LAYOUT_FIX_HEIGHT);
1047  myPhaseTable->setColumnHeaderHeight(getApp()->getNormalFont()->getFontHeight() + getApp()->getNormalFont()->getFontAscent() / 2);
1048  myPhaseTable->setRowHeaderMode(LAYOUT_FIX_WIDTH);
1049  myPhaseTable->setRowHeaderWidth(0);
1050  myPhaseTable->hide();
1051  myPhaseTable->setFont(myTableFont);
1052  myPhaseTable->setHelpText("phase duration in seconds | phase state");
1053 
1054  // create total duration info label
1055  myCycleDuration = new FXLabel(this, "", nullptr, GUIDesignLabelLeft);
1056 
1057  // create new phase button
1058  myInsertDuplicateButton = new FXButton(this, "Insert Phase\t\tInsert new phase after the selected phase. The new state is deduced from the selected phase.", nullptr, myTLSEditorParent, MID_GNE_TLSFRAME_PHASE_CREATE, GUIDesignButton);
1059 
1060  // create delete phase button
1061  myDeleteSelectedPhaseButton = new FXButton(this, "Delete Phase\t\tDelete selected phase", nullptr, myTLSEditorParent, MID_GNE_TLSFRAME_PHASE_DELETE, GUIDesignButton);
1062 
1063  // create cleanup states button
1064  new FXButton(this, "Cleanup States\t\tClean unused states from all phase.", nullptr, myTLSEditorParent, MID_GNE_TLSFRAME_CLEANUP, GUIDesignButton);
1065 
1066  // add unused states button
1067  new FXButton(this, "Add Unused States\t\tExtend the state vector for all phases by one entry.", nullptr, myTLSEditorParent, MID_GNE_TLSFRAME_ADDUNUSED, GUIDesignButton);
1068 
1069  // show TLSFile
1070  show();
1071 }
1072 
1073 
1075  delete myTableFont;
1076 }
1077 
1078 
1079 FXTable*
1081  return myPhaseTable;
1082 }
1083 
1084 
1085 void
1087  myPhaseTable->setVisibleRows(1);
1088  myPhaseTable->setVisibleColumns(2);
1089  myPhaseTable->hide();
1090  if (myTLSEditorParent->myTLSAttributes->getNumberOfTLSDefinitions() > 0) {
1091  const bool fixed = myTLSEditorParent->fixedDuration();
1092  const int cols = fixed ? 4 : 6;
1093  const int colDuration = 0;
1094  const int colMinDur = fixed ? -1 : 1;
1095  const int colMaxDur = fixed ? -1 : 2;
1096  const int colState = fixed ? 1 : 3;
1097  const int colNext = fixed ? 2 : 4;
1098  const int colName = fixed ? 3 : 5;
1099 
1100  const std::vector<NBTrafficLightLogic::PhaseDefinition>& phases = myTLSEditorParent->getPhases();
1101  myPhaseTable->setTableSize((int)phases.size(), cols);
1102  myPhaseTable->setVisibleRows((int)phases.size());
1103  myPhaseTable->setVisibleColumns(cols);
1104  for (int row = 0; row < (int)phases.size(); row++) {
1105  myPhaseTable->setItemText(row, colDuration, toString(STEPS2TIME(phases[row].duration)).c_str());
1106  if (!fixed) {
1107  myPhaseTable->setItemText(row, colMinDur, varDurString(phases[row].minDur).c_str());
1108  myPhaseTable->setItemText(row, colMaxDur, varDurString(phases[row].maxDur).c_str());
1109  }
1110  myPhaseTable->setItemText(row, colState, phases[row].state.c_str());
1111  myPhaseTable->setItemText(row, colNext, phases[row].next.size() > 0 ? toString(phases[row].next).c_str() : " ");
1112  myPhaseTable->setItemText(row, colName, phases[row].name.c_str());
1113  myPhaseTable->getItem(row, 1)->setJustify(FXTableItem::LEFT);
1114  }
1115  myPhaseTable->fitColumnsToContents(0, cols);
1116  myPhaseTable->setColumnText(colDuration, "dur");
1117  if (colMinDur >= 0) {
1118  myPhaseTable->setColumnText(colMinDur, "min");
1119  myPhaseTable->setColumnText(colMaxDur, "max");
1120  myPhaseTable->setColumnWidth(colMinDur, MAX2(myPhaseTable->getColumnWidth(colMinDur), 30));
1121  myPhaseTable->setColumnWidth(colMaxDur, MAX2(myPhaseTable->getColumnWidth(colMaxDur), 35));
1122  }
1123  myPhaseTable->setColumnText(colState, "state");
1124  myPhaseTable->setColumnText(colNext, "nxt");
1125  myPhaseTable->setColumnText(colName, "name");
1126  myPhaseTable->setColumnWidth(colNext, MAX2(myPhaseTable->getColumnWidth(colNext), 30));
1127  myPhaseTable->setColumnWidth(colName, MAX2(myPhaseTable->getColumnWidth(colName), 45));
1128 
1129  myPhaseTable->setHeight((int)phases.size() * 21 + 21); // experimental
1130  myPhaseTable->setCurrentItem(index, 0);
1131  myPhaseTable->selectRow(index, true);
1132  myPhaseTable->show();
1133  myPhaseTable->setFocus();
1134  myTableScroll->setHeight(myPhaseTable->getHeight() + 15);
1135 
1136  // neither my myPhaseTable->getWidth nor getDefaultWidth return the sum of column widths
1137  // however, the scroll pane uses getDefaultWidth to determine the
1138  // horizontal scrolling area which can only be changed via
1139  // getDefColumnWidth, hence the baroque work-around
1140 
1141  int neededWidth = 0;
1142  for (int i = 0; i < cols; i++) {
1143  neededWidth += myPhaseTable->getColumnWidth(i);
1144  }
1145  myPhaseTable->setDefColumnWidth(neededWidth / cols);
1146  }
1147  update();
1148 }
1149 
1150 
1151 void
1153  myCycleDuration->show();
1154 }
1155 
1156 
1157 void
1159  myCycleDuration->hide();
1160 }
1161 
1162 void
1164  SUMOTime cycleDuration = 0;
1165  for (auto it : myTLSEditorParent->getPhases()) {
1166  cycleDuration += it.duration;
1167  }
1168  std::string text = "Cycle time: " + toString(STEPS2TIME(cycleDuration));
1169  myCycleDuration->setText(text.c_str());
1170 }
1171 
1172 // ---------------------------------------------------------------------------
1173 // GNETLSEditorFrame::TLSModifications - methods
1174 // ---------------------------------------------------------------------------
1175 
1177  FXGroupBox(TLSEditorParent->myContentFrame, "Modifications", GUIDesignGroupBoxFrame),
1178  myTLSEditorParent(TLSEditorParent),
1179  myHaveModifications(false) {
1180  // create save modifications button
1181  mySaveModificationsButtons = new FXButton(this, "Save\t\tSave program modifications (Enter)",
1183  // create discard modifications buttons
1184  myDiscardModificationsButtons = new FXButton(this, "Cancel\t\tDiscard program modifications (Esc)",
1186  // show TLSModifications
1187  show();
1188 }
1189 
1190 
1192 
1193 
1194 bool
1196  return myHaveModifications;
1197 }
1198 
1199 
1200 void
1202  myHaveModifications = value;
1203 }
1204 
1205 // ---------------------------------------------------------------------------
1206 // GNETLSEditorFrame::TLSFile - methods
1207 // ---------------------------------------------------------------------------
1208 
1210  FXGroupBox(TLSEditorParent->myContentFrame, "TLS Program", GUIDesignGroupBoxFrame),
1211  myTLSEditorParent(TLSEditorParent) {
1212  // create create tlDef button
1213  myLoadTLSProgramButton = new FXButton(this, "Load TLS Program", nullptr, this, MID_GNE_TLSFRAME_LOAD_PROGRAM, GUIDesignButton);
1214  // create create tlDef button
1215  mySaveTLSProgramButton = new FXButton(this, "Save TLS Program", nullptr, this, MID_GNE_TLSFRAME_SAVE_PROGRAM, GUIDesignButton);
1216  // show TLSFile
1217  show();
1218 }
1219 
1220 
1222 
1223 
1224 long
1226  FXFileDialog opendialog(this, "Load TLS Program");
1227  opendialog.setIcon(GUIIconSubSys::getIcon(ICON_MODETLS));
1228  opendialog.setSelectMode(SELECTFILE_EXISTING);
1229  opendialog.setPatternList("*.xml");
1230  if (gCurrentFolder.length() != 0) {
1231  opendialog.setDirectory(gCurrentFolder);
1232  }
1233  if (opendialog.execute()) {
1234  // run parser
1235  NBTrafficLightLogicCont tmpTLLCont;
1236  NIXMLTrafficLightsHandler tllHandler(tmpTLLCont, myTLSEditorParent->myViewNet->getNet()->getEdgeCont(), true);
1237  tmpTLLCont.insert(myTLSEditorParent->myEditedDef);
1238  XMLSubSys::runParser(tllHandler, opendialog.getFilename().text());
1239 
1240  NBLoadedSUMOTLDef* newDefSameProgram = nullptr;
1241  std::set<NBLoadedSUMOTLDef*> newDefsOtherProgram;
1242  for (auto item : tmpTLLCont.getPrograms(myTLSEditorParent->myEditedDef->getID())) {
1243  if (item.second != myTLSEditorParent->myEditedDef) {
1244  NBLoadedSUMOTLDef* sdef = dynamic_cast<NBLoadedSUMOTLDef*>(item.second);
1245  if (item.first == myTLSEditorParent->myEditedDef->getProgramID()) {
1246  newDefSameProgram = sdef;
1247  } else {
1248  newDefsOtherProgram.insert(sdef);
1249  }
1250  }
1251  }
1252  const int newPrograms = (int)newDefsOtherProgram.size();
1253  if (newPrograms > 0 || newDefSameProgram != nullptr) {
1254  std::vector<NBNode*> nodes = myTLSEditorParent->myEditedDef->getNodes();
1255  for (auto newProg : newDefsOtherProgram) {
1256  for (auto it_node : nodes) {
1257  GNEJunction* junction = myTLSEditorParent->getViewNet()->getNet()->retrieveJunction(it_node->getID());
1258  myTLSEditorParent->getViewNet()->getUndoList()->add(new GNEChange_TLS(junction, newProg, true), true);
1259  }
1260  }
1261  if (newPrograms > 0) {
1262  WRITE_MESSAGE("Loaded " + toString(newPrograms) + " new programs for tlLogic '" + myTLSEditorParent->myEditedDef->getID() + "'");
1263  }
1264  if (newDefSameProgram != nullptr) {
1265  // replace old program when loading the same program ID
1266  myTLSEditorParent->myEditedDef = newDefSameProgram;
1267  WRITE_MESSAGE("Updated program '" + newDefSameProgram->getProgramID() + "' for tlLogic '" + myTLSEditorParent->myEditedDef->getID() + "'");
1268  }
1269  } else {
1270  myTLSEditorParent->getViewNet()->setStatusBarText("No programs found for traffic light '" + myTLSEditorParent->myEditedDef->getID() + "'");
1271  }
1272 
1273  // clean up temporary container to avoid deletion of defs when it's destruct is called
1274  for (NBTrafficLightDefinition* def : tmpTLLCont.getDefinitions()) {
1275  tmpTLLCont.removeProgram(def->getID(), def->getProgramID(), false);
1276  }
1277 
1278  myTLSEditorParent->myTLSPhases->initPhaseTable();
1279  myTLSEditorParent->myTLSModifications->setHaveModifications(true);
1280  }
1281  return 0;
1282 }
1283 
1284 
1285 long
1287  FXString file = MFXUtils::getFilename2Write(this,
1288  "Save TLS Program as", ".xml",
1290  gCurrentFolder);
1291  if (file == "") {
1292  return 1;
1293  }
1294  OutputDevice& device = OutputDevice::getDevice(file.text());
1295 
1296  // save program
1297  device.writeXMLHeader("additional", "additional_file.xsd");
1298  device.openTag(SUMO_TAG_TLLOGIC);
1299  device.writeAttr(SUMO_ATTR_ID, myTLSEditorParent->myEditedDef->getLogic()->getID());
1300  device.writeAttr(SUMO_ATTR_TYPE, myTLSEditorParent->myEditedDef->getLogic()->getType());
1301  device.writeAttr(SUMO_ATTR_PROGRAMID, myTLSEditorParent->myEditedDef->getLogic()->getProgramID());
1302  device.writeAttr(SUMO_ATTR_OFFSET, writeSUMOTime(myTLSEditorParent->myEditedDef->getLogic()->getOffset()));
1303  // write the phases
1304  const bool varPhaseLength = myTLSEditorParent->myEditedDef->getLogic()->getType() != TLTYPE_STATIC;
1305  const std::vector<NBTrafficLightLogic::PhaseDefinition>& phases = myTLSEditorParent->myEditedDef->getLogic()->getPhases();
1306  for (auto j : phases) {
1307  device.openTag(SUMO_TAG_PHASE);
1308  device.writeAttr(SUMO_ATTR_DURATION, writeSUMOTime(j.duration));
1309  device.writeAttr(SUMO_ATTR_STATE, j.state);
1310  if (varPhaseLength) {
1312  device.writeAttr(SUMO_ATTR_MINDURATION, writeSUMOTime(j.minDur));
1313  }
1315  device.writeAttr(SUMO_ATTR_MAXDURATION, writeSUMOTime(j.maxDur));
1316  }
1317  }
1318  device.closeTag();
1319  }
1320  device.close();
1321  return 1;
1322 }
1323 
1324 
1325 std::string
1327  double time = STEPS2TIME(steps);
1328  if (time == std::floor(time)) {
1329  return toString(int(time));
1330  } else {
1331  return toString(time);
1332  }
1333 }
1334 
1335 long
1336 GNETLSEditorFrame::TLSFile::onUpdNeedsDef(FXObject* o, FXSelector, void*) {
1337  const bool enable = myTLSEditorParent->myTLSAttributes->getNumberOfTLSDefinitions() > 0;
1338  o->handle(this, FXSEL(SEL_COMMAND, enable ? FXWindow::ID_ENABLE : FXWindow::ID_DISABLE), nullptr);
1339  return 1;
1340 }
1341 /****************************************************************************/
GNETLSEditorFrame::TLSAttributes::initTLSAttributes
void initTLSAttributes(GNEJunction *junction)
initializes the definitions and corresponding listbox
Definition: GNETLSEditorFrame.cpp:891
GNEFrameModuls::OverlappedInspection::getNumberOfOverlappedACs
int getNumberOfOverlappedACs() const
get number of overlapped ACSs
Definition: GNEFrameModuls.cpp:1873
MID_GNE_TLSFRAME_ADDOFF
add off to TLS
Definition: GUIAppEnum.h:762
GNETLSEditorFrame::onCmdDefOffset
long onCmdDefOffset(FXObject *, FXSelector, void *)
Called when the user changes the offset of a TLS.
Definition: GNETLSEditorFrame.cpp:391
SUMO_ATTR_TYPE
Definition: SUMOXMLDefinitions.h:381
GNETLSEditorFrame::TLSJunction::myTextFieldJunctionStatus
FXTextField * myTextFieldJunctionStatus
text field for junction status
Definition: GNETLSEditorFrame.h:82
NODETYPE_PRIORITY
Definition: SUMOXMLDefinitions.h:1061
GNETLSEditorFrame::myTLSAttributes
GNETLSEditorFrame::TLSAttributes * myTLSAttributes
modul for TLS attributes
Definition: GNETLSEditorFrame.h:435
GUIDesignAuxiliarHorizontalFrame
#define GUIDesignAuxiliarHorizontalFrame
design for auxiliar (Without borders) horizontal frame used to pack another frames
Definition: GUIDesigns.h:273
GNETLSEditorFrame::TLSAttributes::getCurrentTLSDefinition
NBTrafficLightDefinition * getCurrentTLSDefinition() const
get current definition
Definition: GNETLSEditorFrame.cpp:931
MID_GNE_TLSFRAME_DELETE
delete TLS
Definition: GUIAppEnum.h:756
OptionsCont::getInt
int getInt(const std::string &name) const
Returns the int-value of the named option (only for Option_Integer)
Definition: OptionsCont.cpp:215
XMLSubSys::runParser
static bool runParser(GenericSAXHandler &handler, const std::string &file, const bool isNet=false)
Runs the given handler on the given file; returns if everything's ok.
Definition: XMLSubSys.cpp:112
MIN2
T MIN2(T a, T b)
Definition: StdDefs.h:73
NBTrafficLightLogicCont::getPrograms
const std::map< std::string, NBTrafficLightDefinition * > & getPrograms(const std::string &id) const
Returns all programs for the given tl-id.
Definition: NBTrafficLightLogicCont.cpp:243
GUIDesignTextFieldNCol
#define GUIDesignTextFieldNCol
Num of column of text field.
Definition: GUIDesigns.h:42
GNETLSEditorFrame::TLSJunction::~TLSJunction
~TLSJunction()
destructor
Definition: GNETLSEditorFrame.cpp:984
MID_GNE_TLSFRAME_RENAME
rename TLS
Definition: GUIAppEnum.h:758
GNETLSEditorFrame::myTLSJunction
GNETLSEditorFrame::TLSJunction * myTLSJunction
modul for TLS Junction
Definition: GNETLSEditorFrame.h:429
WRITE_WARNING
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:275
NBTrafficLightLogicCont::removeProgram
bool removeProgram(const std::string id, const std::string programID, bool del=true)
Removes a program of a logic definition from the dictionary.
Definition: NBTrafficLightLogicCont.cpp:119
NBTrafficLightLogic::setPhaseName
void setPhaseName(int phaseIndex, const std::string &name)
Definition: NBTrafficLightLogic.cpp:220
GUIDesignLabelAttribute
#define GUIDesignLabelAttribute
label extended over the matrix column with thick frame and height of 23
Definition: GUIDesigns.h:170
GNETLSEditorFrame::myTLSPhases
GNETLSEditorFrame::TLSPhases * myTLSPhases
modul for TLS Phases
Definition: GNETLSEditorFrame.h:441
GNETLSEditorFrame::onUpdDefSwitch
long onUpdDefSwitch(FXObject *, FXSelector, void *)
Called when occurs an update of switch definition.
Definition: GNETLSEditorFrame.cpp:349
GNEInternalLane.h
GNETLSEditorFrame::onUpdNeedsDef
long onUpdNeedsDef(FXObject *, FXSelector, void *)
Called when occurs an update of needs definition.
Definition: GNETLSEditorFrame.cpp:357
GNETLSEditorFrame::onUpdDefCreate
long onUpdDefCreate(FXObject *, FXSelector, void *)
Called when occurs an update of create definition.
Definition: GNETLSEditorFrame.cpp:374
NBTrafficLightLogicCont
A container for traffic light definitions and built programs.
Definition: NBTrafficLightLogicCont.h:57
NBTrafficLightLogic::getOffset
SUMOTime getOffset() const
Returns the offset of first switch.
Definition: NBTrafficLightLogic.h:214
OutputDevice
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:63
GNETLSEditorFrame::TLSAttributes::getNumberOfTLSDefinitions
int getNumberOfTLSDefinitions() const
get number of definitions
Definition: GNETLSEditorFrame.cpp:937
GNEFrameModuls::OverlappedInspection
Definition: GNEFrameModuls.h:520
GNEUndoList::p_end
void p_end()
End undo command sub-group. If the sub-group is still empty, it will be deleted; otherwise,...
Definition: GNEUndoList.cpp:79
GNELane::getParentEdge
GNEEdge * getParentEdge() const
Returns underlying parent edge.
Definition: GNELane.cpp:1371
OptionsCont.h
GNETLSEditorFrame::TLSAttributes::~TLSAttributes
~TLSAttributes()
destructor
Definition: GNETLSEditorFrame.cpp:887
GNETLSEditorFrame::onCmdDefSwitch
long onCmdDefSwitch(FXObject *, FXSelector, void *)
Called when the user switchs a TLS.
Definition: GNETLSEditorFrame.cpp:321
GNETLSEditorFrame::myOverlappedInspection
GNEFrameModuls::OverlappedInspection * myOverlappedInspection
Overlapped Inspection.
Definition: GNETLSEditorFrame.h:426
TLTYPE_STATIC
Definition: SUMOXMLDefinitions.h:1198
GNETLSEditorFrame::TLSJunction::myLabelJunctionStatus
FXLabel * myLabelJunctionStatus
label for junction status
Definition: GNETLSEditorFrame.h:79
NUM_POINTS
int NUM_POINTS
Definition: GNEConnection.cpp:46
NIXMLTrafficLightsHandler
Importer for edge connections stored in XML.
Definition: NIXMLTrafficLightsHandler.h:49
GNETLSEditorFrame::TLSPhases::initPhaseTable
void initPhaseTable(int index=0)
initialies the phase table
Definition: GNETLSEditorFrame.cpp:1086
GNETLSEditorFrame::onCmdOK
long onCmdOK(FXObject *, FXSelector, void *)
Definition: GNETLSEditorFrame.cpp:256
FXDEFMAP
FXDEFMAP(GNETLSEditorFrame) GNETLSEditorFrameMap[]
NBTrafficLightLogic::PhaseDefinition::next
std::vector< int > next
next phase indices or empty list
Definition: NBTrafficLightLogic.h:68
GNETLSEditorFrame::isTLSSaved
bool isTLSSaved()
check if modifications in TLS was saved
Definition: GNETLSEditorFrame.cpp:155
GNETLSEditorFrame::TLSModifications::checkHaveModifications
bool checkHaveModifications() const
check if current TLS was modified
Definition: GNETLSEditorFrame.cpp:1195
GNETLSEditorFrame::TLSAttributes::getNumberOfPrograms
int getNumberOfPrograms() const
get number of programs
Definition: GNETLSEditorFrame.cpp:943
GNETLSEditorFrame::varDurString
static std::string varDurString(SUMOTime dur)
convert duration (potentially undefined) to string
Definition: GNETLSEditorFrame.cpp:746
GNETLSEditorFrame::onCmdPhaseDelete
long onCmdPhaseDelete(FXObject *, FXSelector, void *)
Called when the user deletes a Phase.
Definition: GNETLSEditorFrame.cpp:529
GNETLSEditorFrame::getPhases
const std::vector< NBTrafficLightLogic::PhaseDefinition > & getPhases()
the phase of the current traffic light
Definition: GNETLSEditorFrame.cpp:752
GNEJunction::getGNEOutgoingEdges
const std::vector< GNEEdge * > & getGNEOutgoingEdges() const
Returns incoming GNEEdges.
Definition: GNEJunction.cpp:487
GNETLSEditorFrame::editJunction
void editJunction(GNEJunction *junction)
edits the traffic light for the given junction
Definition: GNETLSEditorFrame.cpp:832
GNEViewNet::setStatusBarText
void setStatusBarText(const std::string &text)
set staturBar text
Definition: GNEViewNet.cpp:523
SUMOTime
long long int SUMOTime
Definition: SUMOTime.h:34
GNETLSEditorFrame::myTLSModifications
GNETLSEditorFrame::TLSModifications * myTLSModifications
modul for load/Save TLS Modifications
Definition: GNETLSEditorFrame.h:438
GNETLSEditorFrame::TLSAttributes::getOffset
SUMOTime getOffset() const
get current offset in SUMOTIme
Definition: GNETLSEditorFrame.cpp:949
GUIDesignComboBoxNCol
#define GUIDesignComboBoxNCol
number of column of every combo box
Definition: GUIDesigns.h:217
NBTrafficLightLogic::setPhaseDuration
void setPhaseDuration(int phaseIndex, SUMOTime duration)
Modifies the duration for an existing phase (used by NETEDIT)
Definition: NBTrafficLightLogic.cpp:196
MID_GNE_TLSFRAME_PHASE_CREATE
create phase thable
Definition: GUIAppEnum.h:766
GNETLSEditorFrame::TLSPhases
Definition: GNETLSEditorFrame.h:173
GNEFrame
Definition: GNEFrame.h:34
GNETLSEditorFrame::TLSFile::~TLSFile
~TLSFile()
destructor
Definition: GNETLSEditorFrame.cpp:1221
OptionsCont::getOptions
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:57
GNETLSEditorFrame::onUpdModified
long onUpdModified(FXObject *, FXSelector, void *)
Called when occurs an update of modified.
Definition: GNETLSEditorFrame.cpp:382
SUMO_ATTR_MINDURATION
Definition: SUMOXMLDefinitions.h:732
LINKSTATE_TL_GREEN_MINOR
The link has green light, has to brake.
Definition: SUMOXMLDefinitions.h:1141
GNEViewNet
Definition: GNEViewNet.h:42
NBLoadedSUMOTLDef::setOffset
void setOffset(SUMOTime offset)
Sets the offset of this tls.
Definition: NBLoadedSUMOTLDef.cpp:223
MID_GNE_TLSFRAME_SWITCH
switch between programs
Definition: GUIAppEnum.h:752
SUMO_ATTR_ID
Definition: SUMOXMLDefinitions.h:378
GNETLSEditorFrame::TLSPhases::~TLSPhases
~TLSPhases()
destructor
Definition: GNETLSEditorFrame.cpp:1074
PositionVector::length
double length() const
Returns the length.
Definition: PositionVector.cpp:484
GNETLSEditorFrame::TLSFile::myLoadTLSProgramButton
FXButton * myLoadTLSProgramButton
button for load TLS Programs
Definition: GNETLSEditorFrame.h:290
NBLoadedSUMOTLDef::getLogic
NBTrafficLightLogic * getLogic()
Returns the internal logic.
Definition: NBLoadedSUMOTLDef.h:122
GUIDesigns.h
NBTrafficLightLogic::PhaseDefinition::duration
SUMOTime duration
The duration of the phase in s.
Definition: NBTrafficLightLogic.h:60
GNENet::getVisualisationSpeedUp
SUMORTree & getVisualisationSpeedUp()
Returns the RTree used for visualisation speed-up.
Definition: GNENet.cpp:301
MID_GNE_TLSFRAME_UPDATE_STATUS
update TLS status
Definition: GUIAppEnum.h:746
LINKSTATE_TL_GREEN_MAJOR
The link has green light, may pass.
Definition: SUMOXMLDefinitions.h:1139
MID_CANCEL
Cancel-button pressed.
Definition: GUIAppEnum.h:230
GUIDesignTextField
#define GUIDesignTextField
Definition: GUIDesigns.h:33
GNETLSEditorFrame::TLSJunction::myTextFieldJunctionID
FXTextField * myTextFieldJunctionID
text field for junction ID
Definition: GNETLSEditorFrame.h:76
SUMO_TAG_PHASE
a single phase description
Definition: SUMOXMLDefinitions.h:143
GNEViewNet::update
void update() const
Mark the entire GNEViewNet to be repainted later.
Definition: GNEViewNet.cpp:299
PositionVector
A list of positions.
Definition: PositionVector.h:45
GUIIconSubSys::getIcon
static FXIcon * getIcon(GUIIcon which)
returns a icon previously defined in the enum GUIIcon
Definition: GUIIconSubSys.cpp:609
GNETLSEditorFrame::TLSPhases::myTableFont
FXFont * myTableFont
font for the phase table
Definition: GNETLSEditorFrame.h:204
OutputDevice::close
void close()
Closes the device and removes it from the dictionary.
Definition: OutputDevice.cpp:207
GNETLSEditorFrame::cleanup
void cleanup()
cleans up previous lanes
Definition: GNETLSEditorFrame.cpp:661
GNETLSEditorFrame::selectedOverlappedElement
void selectedOverlappedElement(GNEAttributeCarrier *AC)
open AttributesCreator extended dialog (can be reimplemented in frame children)
Definition: GNETLSEditorFrame.cpp:453
GNEFrame::myContentFrame
FXVerticalFrame * myContentFrame
Vertical frame that holds all widgets of frame.
Definition: GNEFrame.h:124
GNEViewNet::changeAllPhases
bool changeAllPhases() const
change all phases
Definition: GNEViewNet.cpp:541
GNETLSEditorFrame::TLSFile::writeSUMOTime
std::string writeSUMOTime(SUMOTime steps)
convert SUMOTime into string
Definition: GNETLSEditorFrame.cpp:1326
GNETLSEditorFrame::TLSJunction::getCurrentJunction
GNEJunction * getCurrentJunction() const
get current modified junction
Definition: GNETLSEditorFrame.cpp:988
GNETLSEditorFrame::TLSPhases::myCycleDuration
FXLabel * myCycleDuration
label with the cycle duration
Definition: GNETLSEditorFrame.h:213
NBTrafficLightLogic::PhaseDefinition
The definition of a single phase of the logic.
Definition: NBTrafficLightLogic.h:57
GNETLSEditorFrame::TLSModifications::~TLSModifications
~TLSModifications()
destructor
Definition: GNETLSEditorFrame.cpp:1191
GNETLSEditorFrame::TLSJunction::updateJunctionDescription
void updateJunctionDescription() const
update descrition
Definition: GNETLSEditorFrame.cpp:1000
MFXUtils::getFilename2Write
static FXString getFilename2Write(FXWindow *parent, const FXString &header, const FXString &extension, FXIcon *icon, FXString &currentFolder)
Returns the file name to write.
Definition: MFXUtils.cpp:83
NBTrafficLightLogic::setPhaseState
void setPhaseState(int phaseIndex, int tlIndex, LinkState linkState)
Modifies the state for an existing phase (used by NETEDIT)
Definition: NBTrafficLightLogic.cpp:187
ICON_REMOVE
Definition: GUIIcons.h:184
GUIDesignButton
#define GUIDesignButton
Definition: GUIDesigns.h:50
GNETLSEditorFrame::TLSFile::TLSFile
TLSFile(GNETLSEditorFrame *TLSEditorParent)
FOX-declaration.
Definition: GNETLSEditorFrame.cpp:1209
OutputDevice::closeTag
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
Definition: OutputDevice.cpp:253
GUIAppEnum.h
GNETLSEditorFrame::TLSAttributes::setOffset
void setOffset(SUMOTime offset)
set new offset
Definition: GNETLSEditorFrame.cpp:955
NBTrafficLightLogic::PhaseDefinition::state
std::string state
The state definition.
Definition: NBTrafficLightLogic.h:65
GNEJunction.h
NBTrafficLightLogic::addStep
void addStep(SUMOTime duration, const std::string &state, const std::vector< int > &next=std::vector< int >(), const std::string &name="", int index=-1)
Adds a phase to the logic.
Definition: NBTrafficLightLogic.cpp:69
GNETLSEditorFrame::TLSModifications::setHaveModifications
void setHaveModifications(bool value)
set if current TLS was modified
Definition: GNETLSEditorFrame.cpp:1201
GNETLSEditorFrame::TLSJunction::myLabelJunctionID
FXLabel * myLabelJunctionID
label for junction ID
Definition: GNETLSEditorFrame.h:73
MAX2
T MAX2(T a, T b)
Definition: StdDefs.h:79
GNEEdge
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:51
GNETLSEditorFrame::TLSAttributes
Definition: GNETLSEditorFrame.h:113
GNEViewNet::getNet
GNENet * getNet() const
get the net object
Definition: GNEViewNet.cpp:1014
GNETLSEditorFrame::onCmdDefSubRename
long onCmdDefSubRename(FXObject *, FXSelector, void *)
Called when the user sub-renames a TLS.
Definition: GNETLSEditorFrame.cpp:405
SUMORTree
A RT-tree for efficient storing of SUMO's GL-objects.
Definition: SUMORTree.h:68
GNETLSEditorFrame::TLSPhases::myTLSEditorParent
GNETLSEditorFrame * myTLSEditorParent
pointer to TLSEditor Parent
Definition: GNETLSEditorFrame.h:201
GNETLSEditorFrame::TLSDefinition::myDeleteTLProgram
FXButton * myDeleteTLProgram
button for delete traffic light program
Definition: GNETLSEditorFrame.h:106
GNETLSEditorFrame::TLSFile::onUpdNeedsDef
long onUpdNeedsDef(FXObject *, FXSelector, void *)
enable buttons, only when a tlLogic is being edited
Definition: GNETLSEditorFrame.cpp:1336
GNEJunction::getNBNode
NBNode * getNBNode() const
Return net build node.
Definition: GNEJunction.cpp:398
OutputDevice::writeAttr
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
Definition: OutputDevice.h:255
LinkState
LinkState
The right-of-way state of a link between two lanes used when constructing a NBTrafficLightLogic,...
Definition: SUMOXMLDefinitions.h:1137
GNETLSEditorFrame::editTLS
void editTLS(const Position &clickedPosition, const GNEViewNetHelper::ObjectsUnderCursor &objectsUnderCursor)
edits the traffic light for the given clicked junction
Definition: GNETLSEditorFrame.cpp:137
GNENet::retrieveLanes
std::vector< GNELane * > retrieveLanes(bool onlySelected=false)
return all lanes
Definition: GNENet.cpp:1213
NBNode::isTLControlled
bool isTLControlled() const
Returns whether this node is controlled by any tls.
Definition: NBNode.h:313
GNETLSEditorFrame::onCmdDefCreate
long onCmdDefCreate(FXObject *, FXSelector, void *)
Called when the user creates a TLS.
Definition: GNETLSEditorFrame.cpp:279
NBTrafficLightDefinition::getType
TrafficLightType getType() const
get the algorithm type (static etc..)
Definition: NBTrafficLightDefinition.h:330
NBTrafficLightLogic::setPhaseMinDuration
void setPhaseMinDuration(int phaseIndex, SUMOTime duration)
Definition: NBTrafficLightLogic.cpp:202
GNETLSEditorFrame::TLSDefinition::~TLSDefinition
~TLSDefinition()
destructor
Definition: GNETLSEditorFrame.cpp:1032
LINKSTATE_TL_YELLOW_MINOR
The link has yellow light, has to brake anyway.
Definition: SUMOXMLDefinitions.h:1149
StringUtils::prune
static std::string prune(const std::string &str)
Removes trailing and leading whitechars.
Definition: StringUtils.cpp:48
MID_GNE_TLSFRAME_CLEANUP
cleanup unused states
Definition: GUIAppEnum.h:770
GNETLSEditorFrame::onCmdGuess
long onCmdGuess(FXObject *, FXSelector, void *)
Called when the user presses the button Guess.
Definition: GNETLSEditorFrame.cpp:417
GNEJunction::getAttribute
std::string getAttribute(SumoXMLAttr key) const
Definition: GNEJunction.cpp:933
GNENet::getEdgeCont
NBEdgeCont & getEdgeCont()
returns the NBEdgeCont of the underlying netbuilder
Definition: GNENet.cpp:2153
TIME2STEPS
#define TIME2STEPS(x)
Definition: SUMOTime.h:58
NBTrafficLightDefinition::UNSPECIFIED_DURATION
static const SUMOTime UNSPECIFIED_DURATION
Definition: NBTrafficLightDefinition.h:70
NBTrafficLightLogic::setStateLength
void setStateLength(int numLinks, LinkState fill=LINKSTATE_TL_RED)
Definition: NBTrafficLightLogic.cpp:111
GNEViewNetHelper::ObjectsUnderCursor
class used to group all variables related with objects under cursor after a click over view
Definition: GNEViewNetHelper.h:148
GNEJunction::setAttribute
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
Definition: GNEJunction.cpp:987
GNETLSEditorFrame::TLSDefinition::myNewTLProgram
FXButton * myNewTLProgram
button for create new Traffic light program
Definition: GNETLSEditorFrame.h:103
GNETLSEditorFrame::TLSJunction::setCurrentJunction
void setCurrentJunction(GNEJunction *junction)
set current junction
Definition: GNETLSEditorFrame.cpp:994
GNETLSEditorFrame::onCmdDefDelete
long onCmdDefDelete(FXObject *, FXSelector, void *)
Called when the user deletes a TLS.
Definition: GNETLSEditorFrame.cpp:306
GNETLSEditorFrame::TLSAttributes::myOffsetTextField
FXTextField * myOffsetTextField
the control for modifying offset
Definition: GNETLSEditorFrame.h:166
NBTrafficLightLogic::PhaseDefinition::name
std::string name
option phase name
Definition: NBTrafficLightLogic.h:70
NBTrafficLightDefinition::getControlledLinks
const NBConnectionVector & getControlledLinks() const
returns the controlled links (depends on previous call to collectLinks)
Definition: NBTrafficLightDefinition.h:294
GNEChange_TLS.h
SUMORTree::removeAdditionalGLObject
void removeAdditionalGLObject(GUIGlObject *o)
Removes an additional object (detector/shape/trigger) from being visualised.
Definition: SUMORTree.h:156
MID_OK
Ok-button pressed.
Definition: GUIAppEnum.h:228
GNEViewNet.h
GNETLSEditorFrame::TLSModifications
Definition: GNETLSEditorFrame.h:226
NBTrafficLightLogic::getPhases
const std::vector< PhaseDefinition > & getPhases() const
Returns the phases.
Definition: NBTrafficLightLogic.h:206
STEPS2TIME
#define STEPS2TIME(x)
Definition: SUMOTime.h:56
PositionVector::positionAtOffset
Position positionAtOffset(double pos, double lateralOffset=0) const
Returns the position at the given length.
Definition: PositionVector.cpp:248
GUIDesignTableLimitedHeight
#define GUIDesignTableLimitedHeight
design for table extended over frame but with limited Height
Definition: GUIDesigns.h:461
GNETLSEditorFrame::onCmdPhaseEdit
long onCmdPhaseEdit(FXObject *, FXSelector, void *)
Called when the user edits a Phase.
Definition: GNETLSEditorFrame.cpp:560
GNETLSEditorFrame::TLSDefinition::TLSDefinition
TLSDefinition(GNETLSEditorFrame *TLSEditorParent)
constructor
Definition: GNETLSEditorFrame.cpp:1019
update
GUIDesignComboBoxAttribute
#define GUIDesignComboBoxAttribute
Combo box static (cannot be edited) extended over the matrix column.
Definition: GUIDesigns.h:211
GNETLSEditorFrame::TLSModifications::myTLSEditorParent
GNETLSEditorFrame * myTLSEditorParent
pointer to TLSEditor Parent
Definition: GNETLSEditorFrame.h:243
GNETLSEditorFrame::parseTLSPrograms
bool parseTLSPrograms(const std::string &file)
parse TLS Programs from a file
Definition: GNETLSEditorFrame.cpp:188
NBTrafficLightLogic::getNumLinks
int getNumLinks()
Returns the number of participating links.
Definition: NBTrafficLightLogic.h:221
GNETLSEditorFrame::onCmdDefRename
long onCmdDefRename(FXObject *, FXSelector, void *)
Called when the user renames a TLS.
Definition: GNETLSEditorFrame.cpp:399
GNETLSEditorFrame::TLSPhases::myDeleteSelectedPhaseButton
FXButton * myDeleteSelectedPhaseButton
delete phase button
Definition: GNETLSEditorFrame.h:219
GNETLSEditorFrame.h
GUIDesignLabelLeft
#define GUIDesignLabelLeft
Definition: GUIDesigns.h:149
NBTrafficLightDefinition::computeBrakingTime
int computeBrakingTime(double minDecel) const
Computes the time vehicles may need to brake.
Definition: NBTrafficLightDefinition.cpp:137
ProcessError
Definition: UtilExceptions.h:39
GNENet::retrieveJunction
GNEJunction * retrieveJunction(const std::string &id, bool failHard=true)
get junction by id
Definition: GNENet.cpp:1050
GNETLSEditorFrame::handleChange
void handleChange(GNEInternalLane *lane)
update phase definition for the current traffic light and phase
Definition: GNETLSEditorFrame.cpp:758
GNETLSEditorFrame::TLSModifications::TLSModifications
TLSModifications(GNETLSEditorFrame *TLSEditorParent)
constructor
Definition: GNETLSEditorFrame.cpp:1176
Position
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:38
GNETLSEditorFrame::TLSPhases::getPhaseTable
FXTable * getPhaseTable() const
get phase table
Definition: GNETLSEditorFrame.cpp:1080
NBTrafficLightDefinition::getNodes
const std::vector< NBNode * > & getNodes() const
Returns the list of controlled nodes.
Definition: NBTrafficLightDefinition.h:172
NIXMLTrafficLightsHandler.h
GNEEdge.h
GNETLSEditorFrame::TLSPhases::hideCycleDuration
void hideCycleDuration()
hide cycle duration
Definition: GNETLSEditorFrame.cpp:1158
GNEFrame::myViewNet
GNEViewNet * myViewNet
View Net.
Definition: GNEFrame.h:121
GNEViewNet::getUndoList
GNEUndoList * getUndoList() const
get the undoList object
Definition: GNEViewNet.cpp:1020
GNENetElement::isAttributeCarrierSelected
bool isAttributeCarrierSelected() const
check if attribute carrier is selected
Definition: GNENetElement.cpp:114
GNEInternalLane::getTLIndex
int getTLIndex() const
get Traffic Light index
Definition: GNEInternalLane.cpp:142
GNEFrameModuls::OverlappedInspection::showOverlappedInspection
void showOverlappedInspection(const GNEViewNetHelper::ObjectsUnderCursor &objectsUnderCursor, const Position &clickedPosition)
show template editor
Definition: GNEFrameModuls.cpp:1826
LINKSTATE_DEADEND
This is a dead end link.
Definition: SUMOXMLDefinitions.h:1167
GNETLSEditorFrame::show
void show()
show inspector frame
Definition: GNETLSEditorFrame.cpp:130
GUIDesignGroupBoxFrame
#define GUIDesignGroupBoxFrame
Group box design extended over frame.
Definition: GUIDesigns.h:239
OptionsCont
A storage for options typed value containers)
Definition: OptionsCont.h:89
GNETLSEditorFrame::TLSFile::onCmdSaveTLSProgram
long onCmdSaveTLSProgram(FXObject *, FXSelector, void *)
save TLS Programm to an additional file
Definition: GNETLSEditorFrame.cpp:1286
GNETLSEditorFrame::TLSAttributes::myOffsetLabel
FXLabel * myOffsetLabel
offset label
Definition: GNETLSEditorFrame.h:163
GNEChange_TLS
Definition: GNEChange_TLS.h:42
MID_GNE_TLSFRAME_OFFSET
definition related controls
Definition: GUIAppEnum.h:750
MID_GNE_TLSFRAME_GUESSPROGRAM
replace program with a newly guessed program
Definition: GUIAppEnum.h:748
GNETLSEditorFrame::onCmdPhaseCreate
long onCmdPhaseCreate(FXObject *, FXSelector, void *)
Called when the user creates a Phase.
Definition: GNETLSEditorFrame.cpp:459
NBLoadedSUMOTLDef::cleanupStates
bool cleanupStates()
Definition: NBLoadedSUMOTLDef.cpp:597
gCurrentFolder
FXString gCurrentFolder
The folder used as last.
Definition: GUIIOGlobals.cpp:32
GNEEdge::getLanes
const std::vector< GNELane * > & getLanes() const
returns a reference to the lane vector
Definition: GNEEdge.cpp:874
GNETLSEditorFrame::~GNETLSEditorFrame
~GNETLSEditorFrame()
Destructor.
Definition: GNETLSEditorFrame.cpp:124
GNETLSEditorFrame::onCmdCancel
long onCmdCancel(FXObject *, FXSelector, void *)
Called when the user presses the Cancel-button.
Definition: GNETLSEditorFrame.cpp:245
GNELane.h
GNEAttributeCarrier::canParse
static bool canParse(const std::string &string)
true if a value of type T can be parsed from string
Definition: GNEAttributeCarrier.h:636
GNETLSEditorFrame::getSUMOTime
static SUMOTime getSUMOTime(const FXString &string)
converts to SUMOTime
Definition: GNETLSEditorFrame.cpp:855
GNEViewNetHelper::ObjectsUnderCursor::getJunctionFront
GNEJunction * getJunctionFront() const
get front junction (or a pointer to nullptr if there isn't)
Definition: GNEViewNetHelper.cpp:258
OptionsCont::isDefault
bool isDefault(const std::string &name) const
Returns the information whether the named option has still the default value.
Definition: OptionsCont.cpp:163
GNEUndoList::p_abort
void p_abort()
reverts and discards ALL active command groups
Definition: GNEUndoList.cpp:93
GNETLSEditorFrame::TLSJunction::TLSJunction
TLSJunction(GNETLSEditorFrame *TLSEditorParent)
constructor
Definition: GNETLSEditorFrame.cpp:963
SUMO_TAG_TLLOGIC
a traffic light logic
Definition: SUMOXMLDefinitions.h:141
GNETLSEditorFrame::TLSPhases::myTableScroll
FXScrollWindow * myTableScroll
window for oversized phase tables
Definition: GNETLSEditorFrame.h:207
GNEJunction::getGNEIncomingEdges
const std::vector< GNEEdge * > & getGNEIncomingEdges() const
Returns incoming GNEEdges.
Definition: GNEJunction.cpp:481
GNETLSEditorFrame::onUpdNeedsDefAndPhase
long onUpdNeedsDefAndPhase(FXObject *, FXSelector, void *)
Called when occurs an update of needs definition an dphase.
Definition: GNETLSEditorFrame.cpp:365
OptionsCont::getFloat
double getFloat(const std::string &name) const
Returns the double-value of the named option (only for Option_Float)
Definition: OptionsCont.cpp:208
OutputDevice::openTag
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
Definition: OutputDevice.cpp:239
toString
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:47
SUMO_ATTR_STATE
The state of a link.
Definition: SUMOXMLDefinitions.h:708
OutputDevice::getDevice
static OutputDevice & getDevice(const std::string &name)
Returns the described OutputDevice.
Definition: OutputDevice.cpp:54
GNENet::getTLLogicCont
NBTrafficLightLogicCont & getTLLogicCont()
returns the tllcont of the underlying netbuilder
Definition: GNENet.cpp:2147
SUMO_ATTR_DURATION
Definition: SUMOXMLDefinitions.h:667
GNETLSEditorFrame::fixedDuration
bool fixedDuration() const
whether the current traffic light uses fixed phase durations
Definition: GNETLSEditorFrame.cpp:446
GNETLSEditorFrame::TLSAttributes::myProgramComboBox
FXComboBox * myProgramComboBox
the comboBox for selecting the tl-definition to edit
Definition: GNETLSEditorFrame.h:160
GNETLSEditorFrame::TLSAttributes::myNameLabel
FXLabel * myNameLabel
name label
Definition: GNETLSEditorFrame.h:151
GNETLSEditorFrame::buildIinternalLanes
void buildIinternalLanes(NBTrafficLightDefinition *tlDef)
builds internal lanes for the given tlDef
Definition: GNETLSEditorFrame.cpp:685
LINKSTATE_TL_YELLOW_MAJOR
The link has yellow light, may pass.
Definition: SUMOXMLDefinitions.h:1147
GNENetElement::getNet
GNENet * getNet() const
get Net in which this element is placed
Definition: GNENetElement.cpp:58
PositionVector::reverse
PositionVector reverse() const
reverse position vector
Definition: PositionVector.cpp:1086
NBTrafficLightLogic::deletePhase
void deletePhase(int index)
Definition: NBTrafficLightLogic.cpp:101
NBNode::getControllingTLS
const std::set< NBTrafficLightDefinition * > & getControllingTLS() const
Returns the traffic lights that were assigned to this node (The set of tls that control this node)
Definition: NBNode.h:318
ICON_CANCEL
Definition: GUIIcons.h:387
GNETLSEditorFrame::TLSFile::mySaveTLSProgramButton
FXButton * mySaveTLSProgramButton
button for save TLS Programs
Definition: GNETLSEditorFrame.h:293
GNETLSEditorFrame::onCmdDefAddOff
long onCmdDefAddOff(FXObject *, FXSelector, void *)
Called when the user adds a OFF.
Definition: GNETLSEditorFrame.cpp:411
GNETLSEditorFrame::myEditedDef
NBLoadedSUMOTLDef * myEditedDef
the traffic light definition being edited
Definition: GNETLSEditorFrame.h:451
ICON_MODETLS
Definition: GUIIcons.h:229
GNETLSEditorFrame::TLSPhases::TLSPhases
TLSPhases(GNETLSEditorFrame *TLSEditorParent)
constructor
Definition: GNETLSEditorFrame.cpp:1038
GNETLSEditorFrame::TLSAttributes::myProgramLabel
FXLabel * myProgramLabel
program label
Definition: GNETLSEditorFrame.h:157
GNETLSEditorFrame::TLSModifications::mySaveModificationsButtons
FXButton * mySaveModificationsButtons
button for save modifications
Definition: GNETLSEditorFrame.h:249
GNETLSEditorFrame::TLSPhases::myInsertDuplicateButton
FXButton * myInsertDuplicateButton
insert new phase button
Definition: GNETLSEditorFrame.h:216
MID_GNE_TLSFRAME_ADDUNUSED
mark unused states
Definition: GUIAppEnum.h:774
NBTrafficLightDefinition::setParticipantsInformation
virtual void setParticipantsInformation()
Builds the list of participating nodes/edges/links.
Definition: NBTrafficLightDefinition.cpp:157
GNEInternalLane
This object is responsible for drawing a shape and for supplying a a popup menu. Messages are routete...
Definition: GNEInternalLane.h:42
GNENet::retrieveEdges
std::vector< GNEEdge * > retrieveEdges(bool onlySelected=false)
return all edges
Definition: GNENet.cpp:1200
NBConnectionVector
std::vector< NBConnection > NBConnectionVector
Definition of a connection vector.
Definition: NBConnectionDefs.h:34
GNETLSEditorFrame::TLSPhases::myPhaseTable
FXTable * myPhaseTable
table for selecting and rearranging phases and for changing duration
Definition: GNETLSEditorFrame.h:210
GNETLSEditorFrame::handleMultiChange
void handleMultiChange(GNELane *lane, FXObject *obj, FXSelector sel, void *data)
update phase definition for the current traffic light and phase
Definition: GNETLSEditorFrame.cpp:774
GNEFrameModuls::OverlappedInspection::hideOverlappedInspection
void hideOverlappedInspection()
hide template editor
Definition: GNEFrameModuls.cpp:1860
MID_GNE_TLSFRAME_LOAD_PROGRAM
Load Program.
Definition: GUIAppEnum.h:776
GNETLSEditorFrame::TLSJunction
FOX-declaration.
Definition: GNETLSEditorFrame.h:50
MID_GNE_TLSFRAME_PHASE_TABLE
select phase thable
Definition: GUIAppEnum.h:764
GNETLSEditorFrame::onCmdPhaseSwitch
long onCmdPhaseSwitch(FXObject *, FXSelector, void *)
Called when the user switchs a Phase.
Definition: GNETLSEditorFrame.cpp:423
GNETLSEditorFrame::controlsEdge
bool controlsEdge(GNEEdge *edge) const
whether the given edge is controlled by the currently edited tlDef
Definition: GNETLSEditorFrame.cpp:818
GNEInternalLane::getLinkState
LinkState getLinkState() const
whether link state has been modfied
Definition: GNEInternalLane.cpp:136
GNETLSEditorFrame::TLSFile::onCmdLoadTLSProgram
long onCmdLoadTLSProgram(FXObject *, FXSelector, void *)
Definition: GNETLSEditorFrame.cpp:1225
GNENet::computeJunction
void computeJunction(GNEJunction *junction)
trigger recomputation of junction shape and logic param[in] window The window to inform about delay
Definition: GNENet.cpp:1551
SUMORTree::addAdditionalGLObject
void addAdditionalGLObject(GUIGlObject *o)
Adds an additional object (detector/shape/trigger) for visualisation.
Definition: SUMORTree.h:126
SUMO_ATTR_MAXDURATION
maximum duration of a phase
Definition: SUMOXMLDefinitions.h:734
config.h
GNETLSEditorFrame::TLSPhases::updateCycleDuration
void updateCycleDuration()
recomputes cycle duration and updates label
Definition: GNETLSEditorFrame.cpp:1163
GNEJunction::selectTLS
void selectTLS(bool selected)
notify the junction of being selected in tls-mode. (used to control drawing)
Definition: GNEJunction.cpp:523
ICON_OK
Definition: GUIIcons.h:385
GNETLSEditorFrame::TLSModifications::myDiscardModificationsButtons
FXButton * myDiscardModificationsButtons
button for cancel modifications
Definition: GNETLSEditorFrame.h:246
GNETLSEditorFrame::onCmdCleanup
long onCmdCleanup(FXObject *, FXSelector, void *)
Called when the user cleans up states.
Definition: GNETLSEditorFrame.cpp:540
MID_GNE_TLSFRAME_SUBRENAME
sub-rename TLS
Definition: GUIAppEnum.h:760
LINKSTATE_TL_RED
The link has red light (must brake)
Definition: SUMOXMLDefinitions.h:1143
SUMO_ATTR_PROGRAMID
Definition: SUMOXMLDefinitions.h:412
GNETLSEditorFrame::onCmdAddUnused
long onCmdAddUnused(FXObject *, FXSelector, void *)
Called when the user cleans up states.
Definition: GNETLSEditorFrame.cpp:549
GNETLSEditorFrame
Definition: GNETLSEditorFrame.h:40
GNETLSEditorFrame::TLSPhases::showCycleDuration
void showCycleDuration()
show cycle duration
Definition: GNETLSEditorFrame.cpp:1152
NBTrafficLightLogic
A SUMO-compliant built logic for a traffic light.
Definition: NBTrafficLightLogic.h:51
OutputDevice::writeXMLHeader
bool writeXMLHeader(const std::string &rootElement, const std::string &schemaFile, std::map< SumoXMLAttr, std::string > attrs=std::map< SumoXMLAttr, std::string >())
Writes an XML header with optional configuration.
Definition: OutputDevice.cpp:227
GNETLSEditorFrame::myInternalLanes
TLIndexMap myInternalLanes
Definition: GNETLSEditorFrame.h:448
NBNode
Represents a single node (junction) during network building.
Definition: NBNode.h:67
MID_GNE_TLSFRAME_SAVE_PROGRAM
cleanup unused states
Definition: GUIAppEnum.h:778
NBTrafficLightLogic::setPhaseNext
void setPhaseNext(int phaseIndex, const std::vector< int > &next)
Definition: NBTrafficLightLogic.cpp:214
NBLoadedSUMOTLDef.h
NBTrafficLightLogicCont::getLogic
NBTrafficLightLogic * getLogic(const std::string &id, const std::string &programID) const
Returns the computed logic for the given name.
Definition: NBTrafficLightLogicCont.cpp:254
GNEJunction
Definition: GNEJunction.h:47
NBNode::Crossing
A definition of a pedestrian crossing.
Definition: NBNode.h:131
NBTrafficLightLogicCont::getDefinitions
Definitions getDefinitions() const
Definition: NBTrafficLightLogicCont.cpp:308
NBEdge::Connection
A structure which describes a connection between edges or lanes.
Definition: NBEdge.h:189
GNEUndoList::p_begin
void p_begin(const std::string &description)
Begin undo command sub-group. This begins a new group of commands that are treated as a single comman...
Definition: GNEUndoList.cpp:72
MID_GNE_TLSFRAME_SELECT_JUNCTION
selected junction von TLS
Definition: GUIAppEnum.h:744
NBTrafficLightLogicCont::insert
bool insert(NBTrafficLightDefinition *logic, bool forceInsert=false)
Adds a logic definition to the dictionary.
Definition: NBTrafficLightLogicCont.cpp:73
MID_GNE_TLSFRAME_PHASE_DELETE
delete phase thable
Definition: GUIAppEnum.h:768
GNEFrame::show
virtual void show()
show Frame
Definition: GNEFrame.cpp:107
GUIGlObject::getMicrosimID
virtual const std::string & getMicrosimID() const
Returns the id of the object as known to microsim.
Definition: GUIGlObject.cpp:163
Named::getID
const std::string & getID() const
Returns the id.
Definition: Named.h:76
GNETLSEditorFrame::TLSAttributes::TLSAttributes
TLSAttributes(GNETLSEditorFrame *TLSEditorParent)
constructor
Definition: GNETLSEditorFrame.cpp:863
GNELane
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition: GNELane.h:45
MID_GNE_TLSFRAME_CREATE
Create TLS.
Definition: GUIAppEnum.h:754
WRITE_MESSAGE
#define WRITE_MESSAGE(msg)
Definition: MsgHandler.h:277
GNETLSEditorFrame::TLSDefinition
Definition: GNETLSEditorFrame.h:92
WRITE_DEBUG
#define WRITE_DEBUG(msg)
Definition: MsgHandler.h:284
GNEAttributeCarrier
Definition: GNEAttributeCarrier.h:54
GNENet.h
GNETLSEditorFrame::TLSAttributes::clearTLSAttributes
void clearTLSAttributes()
clear TLS attributes
Definition: GNETLSEditorFrame.cpp:915
PositionVector::move2side
void move2side(double amount, double maxExtension=100)
move position vector to side using certain ammount
Definition: PositionVector.cpp:1103
NBTrafficLightDefinition
The base class for traffic light logic definitions.
Definition: NBTrafficLightDefinition.h:67
GNETLSEditorFrame::TLSAttributes::myTLSEditorParent
GNETLSEditorFrame * myTLSEditorParent
pointer to TLSEditorParent
Definition: GNETLSEditorFrame.h:145
SUMO_ATTR_OFFSET
Definition: SUMOXMLDefinitions.h:413
SUMO_TAG_JUNCTION
begin/end of the description of a junction
Definition: SUMOXMLDefinitions.h:59
XMLSubSys.h
GNETLSEditorFrame::TLSFile
Definition: GNETLSEditorFrame.h:259
GNEUndoList.h
NBTrafficLightLogic::setPhaseMaxDuration
void setPhaseMaxDuration(int phaseIndex, SUMOTime duration)
Definition: NBTrafficLightLogic.cpp:208
GNETLSEditorFrame::TLSAttributes::myNameTextField
FXTextField * myNameTextField
name text field
Definition: GNETLSEditorFrame.h:154
NODETYPE_TRAFFIC_LIGHT
Definition: SUMOXMLDefinitions.h:1056
NBLoadedSUMOTLDef
A loaded (complete) traffic light logic.
Definition: NBLoadedSUMOTLDef.h:44