Eclipse SUMO - Simulation of Urban MObility
GNEAdditionalFrame.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-2020 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials are made available under the
5 // terms of the Eclipse Public License 2.0 which is available at
6 // https://www.eclipse.org/legal/epl-2.0/
7 // This Source Code may also be made available under the following Secondary
8 // Licenses when the conditions for such availability set forth in the Eclipse
9 // Public License 2.0 are satisfied: GNU General Public License, version 2
10 // or later which is available at
11 // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 /****************************************************************************/
18 // The Widget for add additional elements
19 /****************************************************************************/
20 #include <config.h>
21 
23 #include <utils/gui/div/GLHelper.h>
29 #include <netedit/GNENet.h>
30 #include <netedit/GNEViewNet.h>
31 #include <netedit/GNEViewParent.h>
33 
34 #include "GNEAdditionalFrame.h"
35 
36 
37 // ===========================================================================
38 // FOX callback mapping
39 // ===========================================================================
40 
41 FXDEFMAP(GNEAdditionalFrame::SelectorParentLanes) ConsecutiveLaneSelectorMap[] = {
44 };
45 
46 FXDEFMAP(GNEAdditionalFrame::SelectorChildEdges) SelectorParentEdgesMap[] = {
52 };
53 
54 FXDEFMAP(GNEAdditionalFrame::SelectorChildLanes) SelectorParentLanesMap[] = {
60 };
61 
62 FXDEFMAP(GNEAdditionalFrame::E2MultilaneLaneSelector) E2MultilaneLaneSelectorMap[] = {
67 };
68 
69 // Object implementation
70 FXIMPLEMENT(GNEAdditionalFrame::SelectorParentLanes, FXGroupBox, ConsecutiveLaneSelectorMap, ARRAYNUMBER(ConsecutiveLaneSelectorMap))
71 FXIMPLEMENT(GNEAdditionalFrame::SelectorChildEdges, FXGroupBox, SelectorParentEdgesMap, ARRAYNUMBER(SelectorParentEdgesMap))
72 FXIMPLEMENT(GNEAdditionalFrame::SelectorChildLanes, FXGroupBox, SelectorParentLanesMap, ARRAYNUMBER(SelectorParentLanesMap))
73 FXIMPLEMENT(GNEAdditionalFrame::E2MultilaneLaneSelector, FXGroupBox, E2MultilaneLaneSelectorMap, ARRAYNUMBER(E2MultilaneLaneSelectorMap))
74 
75 
76 // ---------------------------------------------------------------------------
77 // GNEAdditionalFrame::SelectorParentLanes - methods
78 // ---------------------------------------------------------------------------
79 
81  FXGroupBox(additionalFrameParent->myContentFrame, "Lane Selector", GUIDesignGroupBoxFrame),
82  myAdditionalFrameParent(additionalFrameParent) {
83  // create start and stop buttons
84  myStopSelectingButton = new FXButton(this, "Stop selecting", nullptr, this, MID_GNE_ADDITIONALFRAME_STOPSELECTION, GUIDesignButton);
85  myAbortSelectingButton = new FXButton(this, "Abort selecting", nullptr, this, MID_GNE_ADDITIONALFRAME_ABORTSELECTION, GUIDesignButton);
86  // disable stop and abort functions as init
87  myStopSelectingButton->disable();
88  myAbortSelectingButton->disable();
89 }
90 
91 
93 
94 
95 void
97  // abort current selection before show
98  abortConsecutiveLaneSelector();
99  // show FXGroupBox
100  FXGroupBox::show();
101 }
102 
103 
104 void
106  // abort current selection before hide
107  abortConsecutiveLaneSelector();
108  // hide FXGroupBox
109  FXGroupBox::hide();
110 }
111 
112 
113 void
115  // Only start selection if SelectorParentLanes modul is shown
116  if (shown()) {
117  // change buttons
118  myStopSelectingButton->enable();
119  myAbortSelectingButton->enable();
120  // add lane
121  addSelectedLane(lane, clickedPosition);
122  }
123 }
124 
125 
126 bool
128  // obtain tagproperty (only for improve code legibility)
129  const auto& tagValues = myAdditionalFrameParent->myAdditionalTagSelector->getCurrentTagProperties();
130  // abort if there isn't at least two lanes
131  if (mySelectedLanes.size() < 2) {
132  WRITE_WARNING(myAdditionalFrameParent->myAdditionalTagSelector->getCurrentTagProperties().getTagStr() + " requires at least two lanes.");
133  // abort consecutive lane selector
134  abortConsecutiveLaneSelector();
135  return false;
136  }
137  // Declare map to keep attributes from Frames from Frame
138  std::map<SumoXMLAttr, std::string> valuesMap = myAdditionalFrameParent->myAdditionalAttributes->getAttributesAndValues(true);
139  // fill valuesOfElement with Netedit attributes from Frame
140  myAdditionalFrameParent->myNeteditAttributes->getNeteditAttributesAndValues(valuesMap, nullptr);
141  // Check if ID has to be generated
142  if (valuesMap.count(SUMO_ATTR_ID) == 0) {
143  valuesMap[SUMO_ATTR_ID] = myAdditionalFrameParent->generateID(nullptr);
144  }
145  // obtain lane IDs
146  std::vector<std::string> laneIDs;
147  for (auto i : mySelectedLanes) {
148  laneIDs.push_back(i.first->getID());
149  }
150  valuesMap[SUMO_ATTR_LANES] = joinToString(laneIDs, " ");
151  // Obtain clicked position over first lane
152  valuesMap[SUMO_ATTR_POSITION] = toString(mySelectedLanes.front().second);
153  // Obtain clicked position over last lane
154  valuesMap[SUMO_ATTR_ENDPOS] = toString(mySelectedLanes.back().second);
155  // parse common attributes
156  if (!myAdditionalFrameParent->buildAdditionalCommonAttributes(valuesMap, tagValues)) {
157  return false;
158  }
159  // show warning dialogbox and stop check if input parameters are valid
160  if (myAdditionalFrameParent->myAdditionalAttributes->areValuesValid() == false) {
161  myAdditionalFrameParent->myAdditionalAttributes->showWarningMessage();
162  return false;
163  } else {
164  // declare SUMOSAXAttributesImpl_Cached to convert valuesMap into SUMOSAXAttributes
165  SUMOSAXAttributesImpl_Cached SUMOSAXAttrs(valuesMap, myAdditionalFrameParent->getPredefinedTagsMML(), toString(tagValues.getTag()));
166  // try to build additional
167  if (GNEAdditionalHandler::buildAdditional(myAdditionalFrameParent->getViewNet()->getNet(), true, myAdditionalFrameParent->myAdditionalTagSelector->getCurrentTagProperties().getTag(), SUMOSAXAttrs, nullptr)) {
168  // abort consecutive lane selector
169  abortConsecutiveLaneSelector();
170  // refresh additional attributes
171  myAdditionalFrameParent->myAdditionalAttributes->refreshRows();
172  return true;
173  } else {
174  return false;
175  }
176  }
177 }
178 
179 
180 void
182  // reset color of all candidate lanes
183  for (const auto& lane : myCandidateLanes) {
184  lane->resetCandidateFlags();
185  }
186  // clear candidate colors
187  myCandidateLanes.clear();
188  // reset color of all selected lanes
189  for (const auto& lane : mySelectedLanes) {
190  lane.first->resetCandidateFlags();
191  }
192  // clear selected lanes
193  mySelectedLanes.clear();
194  // disable buttons
195  myStopSelectingButton->disable();
196  myAbortSelectingButton->disable();
197  // update view (due colors)
198  myAdditionalFrameParent->getViewNet()->updateViewNet();
199 }
200 
201 
202 bool
204  // first check that lane exist
205  if (lane == nullptr) {
206  return false;
207  }
208  // check that lane wasn't already selected
209  for (auto i : mySelectedLanes) {
210  if (i.first == lane) {
211  WRITE_WARNING("Duplicated lanes aren't allowed");
212  return false;
213  }
214  }
215  // check that there is candidate lanes
216  if (mySelectedLanes.size() > 0) {
217  if (myCandidateLanes.empty()) {
218  WRITE_WARNING("Only candidate lanes are allowed");
219  return false;
220  } else if ((myCandidateLanes.size() > 0) && (std::find(myCandidateLanes.begin(), myCandidateLanes.end(), lane) == myCandidateLanes.end())) {
221  WRITE_WARNING("Only consecutive lanes are allowed");
222  return false;
223  }
224  }
225  // select lane and save the clicked position
226  mySelectedLanes.push_back(std::make_pair(lane, lane->getLaneShape().nearest_offset_to_point2D(clickedPosition) / lane->getLengthGeometryFactor()));
227  // change color of selected lane
228  lane->setTargetCandidate(true);
229  // restore original color of candidates (except already selected)
230  for (const auto& candidateLane : myCandidateLanes) {
231  candidateLane->setPossibleCandidate(false);
232  }
233  // clear candidate lanes
234  myCandidateLanes.clear();
235  // fill candidate lanes
236  for (const auto& connection : lane->getParentEdge()->getGNEConnections()) {
237  // check that possible candidate lane isn't already selected
238  if ((lane == connection->getLaneFrom()) && (!isLaneSelected(connection->getLaneTo()))) {
239  // set candidate lane
240  connection->getLaneTo()->setPossibleCandidate(true);
241  myCandidateLanes.push_back(connection->getLaneTo());
242  }
243  }
244  // update view (due colors)
245  myAdditionalFrameParent->getViewNet()->updateViewNet();
246  return true;
247 }
248 
249 
250 void
252  if (mySelectedLanes.size() > 1) {
253  mySelectedLanes.pop_back();
254  } else {
255  WRITE_WARNING("First lane cannot be removed");
256  }
257 }
258 
259 
260 bool
262  return myStopSelectingButton->isEnabled();
263 }
264 
265 
266 bool
268  return shown();
269 }
270 
271 
272 const std::vector<std::pair<GNELane*, double> >&
274  return mySelectedLanes;
275 }
276 
277 
278 long
280  stopConsecutiveLaneSelector();
281  return 0;
282 }
283 
284 
285 long
287  abortConsecutiveLaneSelector();
288  return 0;
289 }
290 
291 
292 bool
294  for (auto i : mySelectedLanes) {
295  if (i.first == lane) {
296  return true;
297  }
298  }
299  return false;
300 }
301 
302 // ---------------------------------------------------------------------------
303 // GNEAdditionalFrame::SelectorChildEdges - methods
304 // ---------------------------------------------------------------------------
305 
307  FXGroupBox(additionalFrameParent->myContentFrame, "Edges", GUIDesignGroupBoxFrame),
308  myAdditionalFrameParent(additionalFrameParent) {
309  // Create menuCheck for selected edges
310  myUseSelectedEdgesCheckButton = new FXCheckButton(this, ("Use selected " + toString(SUMO_TAG_EDGE) + "s").c_str(), this, MID_GNE_ADDITIONALFRAME_USESELECTED, GUIDesignCheckButton);
311 
312  // Create search box
314 
315  // Create list
316  myList = new FXList(this, this, MID_GNE_ADDITIONALFRAME_SELECT, GUIDesignListFixedHeight, 0, 0, 0, 100);
317 
318  // Create horizontal frame
319  FXHorizontalFrame* buttonsFrame = new FXHorizontalFrame(this, GUIDesignAuxiliarHorizontalFrame);
320 
321  // Create button for clear selection
322  myClearEdgesSelection = new FXButton(buttonsFrame, "Clear", nullptr, this, MID_GNE_ADDITIONALFRAME_CLEARSELECTION, GUIDesignButtonRectangular);
323 
324  // Create button for invert selection
325  myInvertEdgesSelection = new FXButton(buttonsFrame, "Invert", nullptr, this, MID_GNE_ADDITIONALFRAME_INVERTSELECTION, GUIDesignButtonRectangular);
326 
327  // Hide List
329 }
330 
331 
333 
334 
335 std::string
337  std::vector<std::string> vectorOfIds;
338  if (myUseSelectedEdgesCheckButton->getCheck()) {
339  // get Selected edges
340  std::vector<GNEEdge*> selectedEdges = myAdditionalFrameParent->getViewNet()->getNet()->retrieveEdges(true);
341  // Iterate over selectedEdges and getId
342  for (auto i : selectedEdges) {
343  vectorOfIds.push_back(i->getID());
344  }
345  } else {
346  // Obtain Id's of list
347  for (int i = 0; i < myList->getNumItems(); i++) {
348  if (myList->isItemSelected(i)) {
349  vectorOfIds.push_back(myList->getItem(i)->getText().text());
350  }
351  }
352  }
353  return joinToString(vectorOfIds, " ");
354 }
355 
356 
357 void
359  // clear list of egdge ids
360  myList->clearItems();
361  // get all edges of net
363  std::vector<GNEEdge*> vectorOfEdges = myAdditionalFrameParent->getViewNet()->getNet()->retrieveEdges(false);
364  // iterate over edges of net
365  for (auto i : vectorOfEdges) {
366  // If search criterium is correct, then append ittem
367  if (i->getID().find(search) != std::string::npos) {
368  myList->appendItem(i->getID().c_str());
369  }
370  }
371  // By default, CheckBox for useSelectedEdges isn't checked
372  myUseSelectedEdgesCheckButton->setCheck(false);
373  // Recalc Frame
374  recalc();
375  // Update Frame
376  update();
377  // Show dialog
378  show();
379 }
380 
381 
382 void
384  FXGroupBox::hide();
385 }
386 
387 
388 void
390  // Enable or disable use selected edges
391  if (myAdditionalFrameParent->getViewNet()->getNet()->retrieveEdges(true).size() > 0) {
392  myUseSelectedEdgesCheckButton->enable();
393  } else {
394  myUseSelectedEdgesCheckButton->disable();
395  }
396 }
397 
398 
399 long
401  if (myUseSelectedEdgesCheckButton->getCheck()) {
402  myEdgesSearch->hide();
403  myList->hide();
404  myClearEdgesSelection->hide();
405  myInvertEdgesSelection->hide();
406  } else {
407  myEdgesSearch->show();
408  myList->show();
409  myClearEdgesSelection->show();
410  myInvertEdgesSelection->show();
411  }
412  // Recalc Frame
413  recalc();
414  // Update Frame
415  update();
416  return 1;
417 }
418 
419 
420 long
422  // Show only Id's of SelectorChildEdges that contains the searched string
423  showSelectorChildEdgesModul(myEdgesSearch->getText().text());
424  return 1;
425 }
426 
427 
428 long
430  return 1;
431 }
432 
433 
434 long
436  for (int i = 0; i < myList->getNumItems(); i++) {
437  if (myList->getItem(i)->isSelected()) {
438  myList->deselectItem(i);
439  }
440  }
441  return 1;
442 }
443 
444 
445 long
447  for (int i = 0; i < myList->getNumItems(); i++) {
448  if (myList->getItem(i)->isSelected()) {
449  myList->deselectItem(i);
450  } else {
451  myList->selectItem(i);
452  }
453  }
454  return 1;
455 }
456 
457 // ---------------------------------------------------------------------------
458 // GNEAdditionalFrame::SelectorChildLanes - methods
459 // ---------------------------------------------------------------------------
460 
462  FXGroupBox(additionalFrameParent->myContentFrame, "Lanes", GUIDesignGroupBoxFrame),
463  myAdditionalFrameParent(additionalFrameParent) {
464  // Create CheckBox for selected lanes
465  myUseSelectedLanesCheckButton = new FXCheckButton(this, ("Use selected " + toString(SUMO_TAG_LANE) + "s").c_str(), this, MID_GNE_ADDITIONALFRAME_USESELECTED, GUIDesignCheckButton);
466 
467  // Create search box
469 
470  // Create list
471  myList = new FXList(this, this, MID_GNE_ADDITIONALFRAME_SELECT, GUIDesignListFixedHeight, 0, 0, 0, 100);
472 
473  // Create horizontal frame
474  FXHorizontalFrame* buttonsFrame = new FXHorizontalFrame(this, GUIDesignAuxiliarHorizontalFrame);
475 
476  // Create button for clear selection
477  clearLanesSelection = new FXButton(buttonsFrame, "clear", nullptr, this, MID_GNE_ADDITIONALFRAME_CLEARSELECTION, GUIDesignButtonRectangular);
478 
479  // Create button for invert selection
480  invertLanesSelection = new FXButton(buttonsFrame, "invert", nullptr, this, MID_GNE_ADDITIONALFRAME_INVERTSELECTION, GUIDesignButtonRectangular);
481 
482  // Hide List
484 }
485 
486 
488 
489 
490 std::string
492  std::vector<std::string> vectorOfIds;
493  if (myUseSelectedLanesCheckButton->getCheck()) {
494  // get Selected lanes
495  std::vector<GNELane*> selectedLanes = myAdditionalFrameParent->getViewNet()->getNet()->retrieveLanes(true);
496  // Iterate over selectedLanes and getId
497  for (auto i : selectedLanes) {
498  vectorOfIds.push_back(i->getID());
499  }
500  } else {
501  // Obtain Id's of list
502  for (int i = 0; i < myList->getNumItems(); i++) {
503  if (myList->isItemSelected(i)) {
504  vectorOfIds.push_back(myList->getItem(i)->getText().text());
505  }
506  }
507  }
508  return joinToString(vectorOfIds, " ");
509 }
510 
511 
512 void
514  myList->clearItems();
515  std::vector<GNELane*> vectorOfLanes = myAdditionalFrameParent->getViewNet()->getNet()->retrieveLanes(false);
516  for (auto i : vectorOfLanes) {
517  if (i->getID().find(search) != std::string::npos) {
518  myList->appendItem(i->getID().c_str());
519  }
520  }
521  // By default, CheckBox for useSelectedLanes isn't checked
522  myUseSelectedLanesCheckButton->setCheck(false);
523  // Show list
524  show();
525 }
526 
527 
528 void
530  FXGroupBox::hide();
531 }
532 
533 
534 void
536  // Enable or disable use selected Lanes
537  if (myAdditionalFrameParent->getViewNet()->getNet()->retrieveLanes(true).size() > 0) {
538  myUseSelectedLanesCheckButton->enable();
539  } else {
540  myUseSelectedLanesCheckButton->disable();
541  }
542 }
543 
544 
545 long
547  if (myUseSelectedLanesCheckButton->getCheck()) {
548  myLanesSearch->hide();
549  myList->hide();
550  clearLanesSelection->hide();
551  invertLanesSelection->hide();
552  } else {
553  myLanesSearch->show();
554  myList->show();
555  clearLanesSelection->show();
556  invertLanesSelection->show();
557  }
558  // Recalc Frame
559  recalc();
560  // Update Frame
561  update();
562  return 1;
563 }
564 
565 
566 long
568  // Show only Id's of SelectorChildLanes that contains the searched string
569  showSelectorChildLanesModul(myLanesSearch->getText().text());
570  return 1;
571 }
572 
573 
574 long
576  return 1;
577 }
578 
579 
580 long
582  for (int i = 0; i < myList->getNumItems(); i++) {
583  if (myList->getItem(i)->isSelected()) {
584  myList->deselectItem(i);
585  }
586  }
587  return 1;
588 }
589 
590 
591 long
593  for (int i = 0; i < myList->getNumItems(); i++) {
594  if (myList->getItem(i)->isSelected()) {
595  myList->deselectItem(i);
596  } else {
597  myList->selectItem(i);
598  }
599  }
600  return 1;
601 }
602 
603 // ---------------------------------------------------------------------------
604 // GNEAdditionalFrame::E2MultilaneLaneSelector - methods
605 // ---------------------------------------------------------------------------
606 
608  FXGroupBox(additionalFrameParent->myContentFrame, "E2Multilane lane selector", GUIDesignGroupBoxFrame),
609  myAdditionalFrameParent(additionalFrameParent) {
610  // create label for route info
611  myInfoRouteLabel = new FXLabel(this, "No lanes selected", 0, GUIDesignLabelFrameThicked);
612  // create button for finish route creation
613  myFinishCreationButton = new FXButton(this, "Finish route creation", nullptr, this, MID_GNE_LANEPATH_FINISH, GUIDesignButton);
614  myFinishCreationButton->disable();
615  // create button for abort route creation
616  myAbortCreationButton = new FXButton(this, "Abort route creation", nullptr, this, MID_GNE_LANEPATH_ABORT, GUIDesignButton);
617  myAbortCreationButton->disable();
618  // create button for remove last inserted lane
619  myRemoveLastInsertedElement = new FXButton(this, "Remove last inserted lane", nullptr, this, MID_GNE_LANEPATH_REMOVELAST, GUIDesignButton);
620  myRemoveLastInsertedElement->disable();
621  // create check button
622  myShowCandidateLanes = new FXCheckButton(this, "Show candidate lanes", this, MID_GNE_LANEPATH_SHOWCANDIDATES, GUIDesignCheckButton);
623  myShowCandidateLanes->setCheck(TRUE);
624  // create backspace label (always shown)
625  new FXLabel(this,
626  "BACKSPACE: undo click",
628 }
629 
630 
632 
633 
634 void
636  // first abort creation
637  abortPathCreation();
638  // disable buttons
639  myFinishCreationButton->disable();
640  myAbortCreationButton->disable();
641  myRemoveLastInsertedElement->disable();
642  // update lane colors
643  updateLaneColors();
644  // recalc before show (to avoid graphic problems)
645  recalc();
646  // show modul
647  show();
648 }
649 
650 
651 void
653  // clear path
654  clearPath();
655  // hide modul
656  hide();
657 }
658 
659 
660 bool
662  // first check if lane is valid
663  if (lane == nullptr) {
664  return false;
665  }
666  // continue depending of number of selected eges
667  if ((myLanePath.size() > 0) && (myLanePath.back().first == lane)) {
668  // Write warning
669  WRITE_WARNING("Double lanes aren't allowed");
670  // abort add lane
671  return false;
672  }
673  // check candidate lane
674  if ((myShowCandidateLanes->getCheck() == TRUE) && !lane->isPossibleCandidate()) {
675  if (lane->isSpecialCandidate() || lane->isConflictedCandidate()) {
676  // Write warning
677  WRITE_WARNING("Invalid lane");
678  // abort add lane
679  return false;
680  }
681  }
682  // get mouse position
683  const Position mousePos = myAdditionalFrameParent->getViewNet()->snapToActiveGrid(myAdditionalFrameParent->getViewNet()->getPositionInformation());
684  // calculate lane offset
685  const double offset = lane->getLaneShape().nearest_offset_to_point2D(mousePos);
686  // All checks ok, then add it in selected elements
687  myLanePath.push_back(std::make_pair(lane, offset));
688  // enable abort route button
689  myAbortCreationButton->enable();
690  // enable finish button
691  myFinishCreationButton->enable();
692  // disable undo/redo
693  myAdditionalFrameParent->getViewNet()->getViewParent()->getGNEAppWindows()->disableUndoRedo("route creation");
694  // enable or disable remove last lane button
695  if (myLanePath.size() > 1) {
696  myRemoveLastInsertedElement->enable();
697  } else {
698  myRemoveLastInsertedElement->disable();
699  }
700  // update info route label
701  updateInfoRouteLabel();
702  // update lane colors
703  updateLaneColors();
704  return true;
705 }
706 
707 
708 bool
710  return (myShowCandidateLanes->getCheck() == TRUE);
711 }
712 
713 
714 void
716  // reset all flags
717  for (const auto& edge : myAdditionalFrameParent->getViewNet()->getNet()->getAttributeCarriers()->getEdges()) {
718  for (const auto& lane : edge.second->getLanes()) {
719  lane->resetCandidateFlags();
720  }
721  }
722  // set reachability
723  if (myLanePath.size() > 0 && (myShowCandidateLanes->getCheck() == TRUE)) {
724  // first mark all lanes as invalid
725  for (const auto& edge : myAdditionalFrameParent->getViewNet()->getNet()->getAttributeCarriers()->getEdges()) {
726  for (const auto& lane : edge.second->getLanes()) {
727  lane->setConflictedCandidate(true);
728  }
729  }
730  // now mark lane paths as valid
731  for (const auto& lane : myLanePath) {
732  // disable conflicted candidate
733  lane.first->setConflictedCandidate(false);
734  if (lane == myLanePath.back()) {
735  lane.first->setSourceCandidate(true);
736  } else {
737  lane.first->setTargetCandidate(true);
738  }
739  }
740  // get parent edge
741  const GNEEdge* edge = myLanePath.back().first->getParentEdge();
742  // iterate over connections
743  for (const auto& connection : edge->getGNEConnections()) {
744  // mark possible candidates
745  if (connection->getLaneFrom() == myLanePath.back().first) {
746  connection->getLaneTo()->setConflictedCandidate(false);
747  connection->getLaneTo()->setPossibleCandidate(true);
748  }
749  }
750  }
751  // update view net
752  myAdditionalFrameParent->getViewNet()->updateViewNet();
753 }
754 
755 
756 void
758  if (myLanePath.size() > 0) {
759  const double lineWidth = 0.35;
760  const double lineWidthin = 0.25;
761  // Add a draw matrix
762  glPushMatrix();
763  // Start with the drawing of the area traslating matrix to origin
764  glTranslated(0, 0, GLO_TEMPORALSHAPE);
765  // set first color
767  // iterate over path
768  for (int i = 0; i < (int)myLanePath.size(); i++) {
769  // get lane
770  const GNELane* lane = myLanePath.at(i).first;
771  // draw box lines
772  GLHelper::drawBoxLines(lane->getLaneShape(), lineWidth);
773  // draw connection between lanes
774  if ((i + 1) < (int)myLanePath.size()) {
775  // get next lane
776  const GNELane* nextLane = myLanePath.at(i + 1).first;
777  if (lane->getLane2laneConnections().exist(nextLane)) {
779  } else {
780  GLHelper::drawBoxLines({lane->getLaneShape().back(), nextLane->getLaneShape().front()}, lineWidth);
781  }
782  }
783  }
784  // move to front
785  glTranslated(0, 0, 0.1);
786  // set color
788  // iterate over path again
789  for (int i = 0; i < (int)myLanePath.size(); i++) {
790  // get lane
791  const GNELane* lane = myLanePath.at(i).first;
792  // draw box lines
793  GLHelper::drawBoxLines(lane->getLaneShape(), lineWidthin);
794  // draw connection between lanes
795  if ((i + 1) < (int)myLanePath.size()) {
796  // get next lane
797  const GNELane* nextLane = myLanePath.at(i + 1).first;
798  if (lane->getLane2laneConnections().exist(nextLane)) {
800  } else {
801  GLHelper::drawBoxLines({lane->getLaneShape().back(), nextLane->getLaneShape().front()}, lineWidthin);
802  }
803  }
804  }
805  // draw points
806  const RGBColor pointColor = RGBColor::RED;
807  const RGBColor darkerColor = pointColor.changedBrightness(-32);
808  // positions
809  const Position firstPosition = myLanePath.front().first->getLaneShape().positionAtOffset2D(myLanePath.front().second);
810  const Position secondPosition = myLanePath.back().first->getLaneShape().positionAtOffset2D(myLanePath.back().second);
811  // draw geometry points
812  GNEGeometry::drawGeometryPoints(s, myAdditionalFrameParent->getViewNet(), {firstPosition, secondPosition}, pointColor, darkerColor, s.neteditSizeSettings.polylineWidth, 1);
813  // Pop last matrix
814  glPopMatrix();
815  }
816 }
817 
818 
819 bool
821  // first check that current tag is valid
822  if (myAdditionalFrameParent->myAdditionalTagSelector->getCurrentTagProperties().getTag() != SUMO_TAG_E2DETECTOR_MULTILANE) {
823  return false;
824  }
825  // now check number of lanes
826  if (myLanePath.size() < 2) {
827  WRITE_WARNING("E2 multilane detectors need at least two consecutive lanes");
828  return false;
829  }
830  // Declare map to keep attributes obtained in frame
831  std::map<SumoXMLAttr, std::string> valuesMap = myAdditionalFrameParent->myAdditionalAttributes->getAttributesAndValues(true);
832  // fill netedit attributes
833  if (!myAdditionalFrameParent->myNeteditAttributes->getNeteditAttributesAndValues(valuesMap, nullptr)) {
834  return false;
835  }
836  // Check if ID has to be generated
837  if (valuesMap.count(SUMO_ATTR_ID) == 0) {
838  valuesMap[SUMO_ATTR_ID] = myAdditionalFrameParent->myViewNet->getNet()->generateAdditionalID(SUMO_TAG_E2DETECTOR_MULTILANE);
839  }
840  // obtain lane IDs
841  std::vector<std::string> laneIDs;
842  for (const auto& lane : myLanePath) {
843  laneIDs.push_back(lane.first->getID());
844  }
845  valuesMap[SUMO_ATTR_LANES] = joinToString(laneIDs, " ");
846  // set positions
847  valuesMap[SUMO_ATTR_POSITION] = toString(myLanePath.front().second);
848  valuesMap[SUMO_ATTR_ENDPOS] = toString(myLanePath.back().second);
849  // parse common attributes
850  if (!myAdditionalFrameParent->buildAdditionalCommonAttributes(valuesMap, myAdditionalFrameParent->myAdditionalTagSelector->getCurrentTagProperties())) {
851  return false;
852  }
853  // show warning dialogbox and stop check if input parameters are valid
854  if (myAdditionalFrameParent->myAdditionalAttributes->areValuesValid() == false) {
855  myAdditionalFrameParent->myAdditionalAttributes->showWarningMessage();
856  return false;
857  }
858  // declare SUMOSAXAttributesImpl_Cached to convert valuesMap into SUMOSAXAttributes
859  SUMOSAXAttributesImpl_Cached SUMOSAXAttrs(valuesMap, myAdditionalFrameParent->getPredefinedTagsMML(), toString(SUMO_TAG_E2DETECTOR_MULTILANE));
860  // try to build additional
861  if (GNEAdditionalHandler::buildAdditional(myAdditionalFrameParent->myViewNet->getNet(), true, SUMO_TAG_E2DETECTOR_MULTILANE, SUMOSAXAttrs, nullptr)) {
862  // Refresh additional Parent Selector (For additionals that have a limited number of children)
863  myAdditionalFrameParent->myParentAdditional->refreshSelectorParentModul();
864  // abort E2 creation
865  abortPathCreation();
866  // refresh additional attributes
867  myAdditionalFrameParent->myAdditionalAttributes->refreshRows();
868  return true;
869  } else {
870  // additional cannot be build
871  return false;
872  }
873 }
874 
875 
876 void
878  // first check that there is elements
879  if (myLanePath.size() > 0) {
880  // unblock undo/redo
881  myAdditionalFrameParent->getViewNet()->getViewParent()->getGNEAppWindows()->enableUndoRedo();
882  // clear lanes
883  clearPath();
884  // disable buttons
885  myFinishCreationButton->disable();
886  myAbortCreationButton->disable();
887  myRemoveLastInsertedElement->disable();
888  // update info route label
889  updateInfoRouteLabel();
890  // update reachability
891  updateLaneColors();
892  // update view (to see the new route)
893  myAdditionalFrameParent->getViewNet()->updateViewNet();
894  }
895 }
896 
897 
898 void
900  if (myLanePath.size() > 1) {
901  // remove special color of last selected lane
902  myLanePath.back().first->resetCandidateFlags();
903  // remove last lane
904  myLanePath.pop_back();
905  // change last lane flag
906  if ((myLanePath.size() > 0) && myLanePath.back().first->isSourceCandidate()) {
907  myLanePath.back().first->setSourceCandidate(false);
908  myLanePath.back().first->setTargetCandidate(true);
909  }
910  // enable or disable remove last lane button
911  if (myLanePath.size() > 1) {
912  myRemoveLastInsertedElement->enable();
913  } else {
914  myRemoveLastInsertedElement->disable();
915  }
916  // update info route label
917  updateInfoRouteLabel();
918  // update reachability
919  updateLaneColors();
920  // update view
921  myAdditionalFrameParent->getViewNet()->updateViewNet();
922  }
923 }
924 
925 
926 long
928  // just call create path
929  createPath();
930  return 1;
931 }
932 
933 
934 long
936  // just call abort path creation
937  abortPathCreation();
938  return 1;
939 }
940 
941 
942 long
944  // just call remove last element
945  removeLastElement();
946  return 1;
947 }
948 
949 
950 long
952  // recalc frame
953  recalc();
954  // update lane colors (view will be updated within function)
955  updateLaneColors();
956  return 1;
957 }
958 
959 
960 void
962  if (myLanePath.size() > 0) {
963  // declare variables for route info
964  double length = 0;
965  for (const auto& lane : myLanePath) {
966  length += lane.first->getParentEdge()->getNBEdge()->getLength();
967  }
968  // declare ostringstream for label and fill it
969  std::ostringstream information;
970  information
971  << "- Selected lanes: " << toString(myLanePath.size()) << "\n"
972  << "- Length: " << toString(length);
973  // set new label
974  myInfoRouteLabel->setText(information.str().c_str());
975  } else {
976  myInfoRouteLabel->setText("No lanes selected");
977  }
978 }
979 
980 
981 void
983  // reset all flags
984  for (const auto& edge : myAdditionalFrameParent->getViewNet()->getNet()->getAttributeCarriers()->getEdges()) {
985  for (const auto& lane : edge.second->getLanes()) {
986  lane->resetCandidateFlags();
987  }
988  }
989  // clear path
990  myLanePath.clear();
991  // update info route label
992  updateInfoRouteLabel();
993 }
994 
995 // ===========================================================================
996 // method definitions
997 // ===========================================================================
998 
999 GNEAdditionalFrame::GNEAdditionalFrame(FXHorizontalFrame* horizontalFrameParent, GNEViewNet* viewNet) :
1000  GNEFrame(horizontalFrameParent, viewNet, "Additionals") {
1001 
1002  // create item Selector modul for additionals
1003  myAdditionalTagSelector = new GNEFrameModuls::TagSelector(this, GNETagProperties::TagType::ADDITIONALELEMENT);
1004 
1005  // Create additional parameters
1007 
1008  // Create Netedit parameter
1010 
1011  // Create consecutive Lane Selector
1013 
1014  // Create selector parent
1016 
1017  // Create selector child edges
1019 
1020  // Create selector child lanes
1022 
1023  // Create list for E2Multilane lane selector
1025 
1026  // set BusStop as default additional
1028 }
1029 
1030 
1032 
1033 
1034 void
1036  // refresh item selector
1038  // show frame
1039  GNEFrame::show();
1040 }
1041 
1042 
1043 bool
1045  // first check that current selected additional is valid
1047  myViewNet->setStatusBarText("Current selected additional isn't valid.");
1048  return false;
1049  }
1050  // obtain tagproperty (only for improve code legibility)
1051  const auto& tagValues = myAdditionalTagSelector->getCurrentTagProperties();
1052  // Declare map to keep attributes obtained in frame
1053  std::map<SumoXMLAttr, std::string> valuesMap = myAdditionalAttributes->getAttributesAndValues(true);
1054  // fill netedit attributes
1055  if (!myNeteditAttributes->getNeteditAttributesAndValues(valuesMap, objectsUnderCursor.getLaneFront())) {
1056  return false;
1057  }
1058  // If element is a slave additional, get id of parent from ParentAdditionalSelector
1059  if (tagValues.isSlave() && !buildSlaveAdditional(valuesMap, objectsUnderCursor.getAdditionalFront(), tagValues)) {
1060  return false;
1061  }
1062  // If consecutive Lane Selector is enabled, it means that either we're selecting lanes or we're finished or we'rent started
1063  if (tagValues.hasAttribute(SUMO_ATTR_EDGE) || (tagValues.getTag() == SUMO_TAG_VAPORIZER)) {
1064  return buildAdditionalOverEdge(valuesMap, objectsUnderCursor.getLaneFront(), tagValues);
1065  } else if (tagValues.hasAttribute(SUMO_ATTR_LANE)) {
1066  return buildAdditionalOverLane(valuesMap, objectsUnderCursor.getLaneFront(), tagValues);
1067  } else if (tagValues.getTag() == SUMO_TAG_E2DETECTOR_MULTILANE) {
1068  return myE2MultilaneLaneSelector->addLane(objectsUnderCursor.getLaneFront());
1069  } else {
1070  return buildAdditionalOverView(valuesMap, tagValues);
1071  }
1072 }
1073 
1074 
1075 void
1077  // Show frame
1078  GNEFrame::show();
1079  // Update UseSelectedLane CheckBox
1081  // Update UseSelectedLane CheckBox
1083 }
1084 
1085 
1088  return mySelectorParentLanes;
1089 }
1090 
1091 
1095 }
1096 
1097 
1098 void
1101  // show additional attributes modul
1103  // show netedit attributes
1105  // Show myAdditionalFrameParent if we're adding an slave element
1108  } else {
1110  }
1111  // Show SelectorChildEdges if we're adding an additional that own the attribute SUMO_ATTR_EDGES
1114  } else {
1116  }
1117  // check if we must show E2 multilane lane selector
1122  // Show SelectorChildLanes or consecutive lane selector if we're adding an additional that own the attribute SUMO_ATTR_LANES
1125  // show selector parent lane and hide selector child lane
1128  } else {
1129  // show selector child lane and hide selector parent lane
1132  }
1133  } else {
1137  }
1138  } else {
1139  // hide all moduls if additional isn't valid
1147  }
1148 }
1149 
1150 
1151 std::string
1153  // obtain current number of additionals to generate a new index faster
1155  // obtain tag Properties (only for improve code legilibility
1156  const auto& tagProperties = myAdditionalTagSelector->getCurrentTagProperties();
1157  if (networkElement) {
1158  // special case for vaporizers
1159  if (tagProperties.getTag() == SUMO_TAG_VAPORIZER) {
1160  return networkElement->getID();
1161  } else {
1162  // generate ID using networkElement
1163  while (myViewNet->getNet()->retrieveAdditional(tagProperties.getTag(), tagProperties.getTagStr() + "_" + networkElement->getID() + "_" + toString(additionalIndex), false) != nullptr) {
1164  additionalIndex++;
1165  }
1166  return tagProperties.getTagStr() + "_" + networkElement->getID() + "_" + toString(additionalIndex);
1167  }
1168  } else {
1169  // generate ID without networkElement
1170  while (myViewNet->getNet()->retrieveAdditional(tagProperties.getTag(), tagProperties.getTagStr() + "_" + toString(additionalIndex), false) != nullptr) {
1171  additionalIndex++;
1172  }
1173  return tagProperties.getTagStr() + "_" + toString(additionalIndex);
1174  }
1175 }
1176 
1177 
1178 bool
1179 GNEAdditionalFrame::buildSlaveAdditional(std::map<SumoXMLAttr, std::string>& valuesMap, GNEAdditional* additionalParent, const GNETagProperties& tagValues) {
1180  // if user click over an additional element parent, mark int in ParentAdditionalSelector
1181  if (additionalParent && (additionalParent->getTagProperty().getTag() == tagValues.getMasterTags().front())) {
1182  valuesMap[GNE_ATTR_PARENT] = additionalParent->getID();
1183  myParentAdditional->setIDSelected(additionalParent->getID());
1184  }
1185  // stop if currently there isn't a valid selected parent
1186  if (myParentAdditional->getIdSelected() != "") {
1188  } else {
1189  myAdditionalAttributes->showWarningMessage("A " + toString(tagValues.getMasterTags().front()) + " must be selected before insertion of " + myAdditionalTagSelector->getCurrentTagProperties().getTagStr() + ".");
1190  return false;
1191  }
1192  return true;
1193 }
1194 
1195 
1196 bool
1197 GNEAdditionalFrame::buildAdditionalCommonAttributes(std::map<SumoXMLAttr, std::string>& valuesMap, const GNETagProperties& tagValues) {
1198  // If additional has a interval defined by a begin or end, check that is valid
1199  if (tagValues.hasAttribute(SUMO_ATTR_STARTTIME) && tagValues.hasAttribute(SUMO_ATTR_END)) {
1200  double begin = GNEAttributeCarrier::parse<double>(valuesMap[SUMO_ATTR_STARTTIME]);
1201  double end = GNEAttributeCarrier::parse<double>(valuesMap[SUMO_ATTR_END]);
1202  if (begin > end) {
1203  myAdditionalAttributes->showWarningMessage("Attribute '" + toString(SUMO_ATTR_STARTTIME) + "' cannot be greater than attribute '" + toString(SUMO_ATTR_END) + "'.");
1204  return false;
1205  }
1206  }
1207  // If additional own the attribute SUMO_ATTR_FILE but was't defined, will defined as <ID>.xml
1208  if (tagValues.hasAttribute(SUMO_ATTR_FILE) && valuesMap[SUMO_ATTR_FILE] == "") {
1210  // SUMO_ATTR_FILE is optional for calibrators and rerouters (fails to load in sumo when given and the file does not exist)
1211  valuesMap[SUMO_ATTR_FILE] = (valuesMap[SUMO_ATTR_ID] + ".xml");
1212  }
1213  }
1214  // If element own a list of SelectorChildEdges as attribute
1215  if (tagValues.hasAttribute(SUMO_ATTR_EDGES) && valuesMap[SUMO_ATTR_EDGES].empty()) {
1216  // obtain edge IDs
1218  // check if attribute has at least one edge
1219  if (valuesMap[SUMO_ATTR_EDGES] == "") {
1220  myAdditionalAttributes->showWarningMessage("List of " + toString(SUMO_TAG_EDGE) + "s cannot be empty");
1221  return false;
1222  }
1223  }
1224  // get values of mySelectorChildLanes, if tag correspond to an element that has lanes as children
1225  if (tagValues.hasAttribute(SUMO_ATTR_LANES) && valuesMap[SUMO_ATTR_LANES].empty()) {
1226  // obtain lane IDs
1228  // check if attribute has at least a lane
1229  if (valuesMap[SUMO_ATTR_LANES] == "") {
1230  myAdditionalAttributes->showWarningMessage("List of " + toString(SUMO_TAG_LANE) + "s cannot be empty");
1231  return false;
1232  }
1233  }
1234  // all ok, continue building additionals
1235  return true;
1236 }
1237 
1238 
1239 bool
1240 GNEAdditionalFrame::buildAdditionalOverEdge(std::map<SumoXMLAttr, std::string>& valuesMap, GNELane* lane, const GNETagProperties& tagValues) {
1241  // check that edge exist
1242  if (lane) {
1243  // Get attribute lane's edge
1244  valuesMap[SUMO_ATTR_EDGE] = lane->getParentEdge()->getID();
1245  // Check if ID has to be generated
1246  if (valuesMap.count(SUMO_ATTR_ID) == 0) {
1247  valuesMap[SUMO_ATTR_ID] = generateID(lane->getParentEdge());
1248  }
1249  } else {
1250  return false;
1251  }
1252  // parse common attributes
1253  if (!buildAdditionalCommonAttributes(valuesMap, tagValues)) {
1254  return false;
1255  }
1256  // show warning dialogbox and stop check if input parameters are valid
1259  return false;
1260  } else {
1261  // declare SUMOSAXAttributesImpl_Cached to convert valuesMap into SUMOSAXAttributes
1262  SUMOSAXAttributesImpl_Cached SUMOSAXAttrs(valuesMap, getPredefinedTagsMML(), toString(tagValues.getTag()));
1263  // try to build additional
1265  // Refresh additional Parent Selector (For additionals that have a limited number of children)
1267  // clear selected eddges and lanes
1268  mySelectorChildEdges->onCmdClearSelection(nullptr, 0, nullptr);
1269  mySelectorChildLanes->onCmdClearSelection(nullptr, 0, nullptr);
1270  // refresh additional attributes
1272  return true;
1273  } else {
1274  return false;
1275  }
1276  }
1277 }
1278 
1279 
1280 bool
1281 GNEAdditionalFrame::buildAdditionalOverLane(std::map<SumoXMLAttr, std::string>& valuesMap, GNELane* lane, const GNETagProperties& tagValues) {
1282  // check that lane exist
1283  if (lane != nullptr) {
1284  // Get attribute lane
1285  valuesMap[SUMO_ATTR_LANE] = lane->getID();
1286  // Check if ID has to be generated
1287  if (valuesMap.count(SUMO_ATTR_ID) == 0) {
1288  valuesMap[SUMO_ATTR_ID] = generateID(lane);
1289  }
1290  } else {
1291  return false;
1292  }
1293  // Obtain position of the mouse over lane (limited over grid)
1295  // set attribute position as mouse position over lane
1296  valuesMap[SUMO_ATTR_POSITION] = toString(mousePositionOverLane);
1297  // parse common attributes
1298  if (!buildAdditionalCommonAttributes(valuesMap, tagValues)) {
1299  return false;
1300  }
1301  // show warning dialogbox and stop check if input parameters are valid
1304  return false;
1305  } else {
1306  // declare SUMOSAXAttributesImpl_Cached to convert valuesMap into SUMOSAXAttributes
1307  SUMOSAXAttributesImpl_Cached SUMOSAXAttrs(valuesMap, getPredefinedTagsMML(), toString(tagValues.getTag()));
1308  // try to build additional
1310  // Refresh additional Parent Selector (For additionals that have a limited number of children)
1312  // clear selected eddges and lanes
1313  mySelectorChildEdges->onCmdClearSelection(nullptr, 0, nullptr);
1314  mySelectorChildLanes->onCmdClearSelection(nullptr, 0, nullptr);
1315  // refresh additional attributes
1317  return true;
1318  } else {
1319  return false;
1320  }
1321  }
1322 }
1323 
1324 
1325 bool
1326 GNEAdditionalFrame::buildAdditionalOverView(std::map<SumoXMLAttr, std::string>& valuesMap, const GNETagProperties& tagValues) {
1327  // Check if ID has to be generated
1328  if (valuesMap.count(SUMO_ATTR_ID) == 0) {
1329  valuesMap[SUMO_ATTR_ID] = generateID(nullptr);
1330  }
1331  // Obtain position as the clicked position over view
1333  // parse common attributes
1334  if (!buildAdditionalCommonAttributes(valuesMap, tagValues)) {
1335  return false;
1336  }
1337  // show warning dialogbox and stop check if input parameters are valid
1338  if (myAdditionalAttributes->areValuesValid() == false) {
1340  return false;
1341  } else {
1342  // declare SUMOSAXAttributesImpl_Cached to convert valuesMap into SUMOSAXAttributes
1343  SUMOSAXAttributesImpl_Cached SUMOSAXAttrs(valuesMap, getPredefinedTagsMML(), toString(tagValues.getTag()));
1344  // try to build additional
1346  // Refresh additional Parent Selector (For additionals that have a limited number of children)
1348  // clear selected eddges and lanes
1349  mySelectorChildEdges->onCmdClearSelection(nullptr, 0, nullptr);
1350  mySelectorChildLanes->onCmdClearSelection(nullptr, 0, nullptr);
1351  // refresh additional attributes
1353  return true;
1354  } else {
1355  return false;
1356  }
1357  }
1358 }
1359 
1360 /****************************************************************************/
FXDEFMAP(GNEAdditionalFrame::SelectorParentLanes) ConsecutiveLaneSelectorMap[]
@ MID_GNE_ADDITIONALFRAME_CLEARSELECTION
clear selection of elements
Definition: GUIAppEnum.h:915
@ MID_GNE_LANEPATH_ABORT
abort lane path creation
Definition: GUIAppEnum.h:763
@ MID_GNE_ADDITIONALFRAME_STOPSELECTION
stop selection of consecutive egdes/lanes
Definition: GUIAppEnum.h:921
@ MID_GNE_ADDITIONALFRAME_USESELECTED
use selected elements
Definition: GUIAppEnum.h:911
@ MID_GNE_LANEPATH_FINISH
finish lane path creation
Definition: GUIAppEnum.h:765
@ MID_GNE_ADDITIONALFRAME_INVERTSELECTION
invert selection of eleents
Definition: GUIAppEnum.h:917
@ MID_GNE_ADDITIONALFRAME_ABORTSELECTION
abort selection of consecutive egdes/lanes
Definition: GUIAppEnum.h:923
@ MID_GNE_LANEPATH_REMOVELAST
remove last inserted element in path
Definition: GUIAppEnum.h:767
@ MID_GNE_ADDITIONALFRAME_SELECT
select element
Definition: GUIAppEnum.h:913
@ MID_GNE_ADDITIONALFRAME_SEARCH
search element
Definition: GUIAppEnum.h:909
@ MID_GNE_LANEPATH_SHOWCANDIDATES
enable or disable show path candidates
Definition: GUIAppEnum.h:769
#define GUIDesignButton
Definition: GUIDesigns.h:62
#define GUIDesignListFixedHeight
design for FXLists with height fixed
Definition: GUIDesigns.h:570
#define GUIDesignTextField
Definition: GUIDesigns.h:36
#define GUIDesignAuxiliarHorizontalFrame
design for auxiliar (Without borders) horizontal frame used to pack another frames
Definition: GUIDesigns.h:313
#define GUIDesignButtonRectangular
little button rectangula used in frames (For example, in "help" buttons)
Definition: GUIDesigns.h:68
#define GUIDesignLabelFrameThicked
label extended over frame without thick and with text justify to left, used to show information in fr...
Definition: GUIDesigns.h:226
#define GUIDesignTextFieldNCol
Num of column of text field.
Definition: GUIDesigns.h:54
#define GUIDesignGroupBoxFrame
Group box design extended over frame.
Definition: GUIDesigns.h:278
#define GUIDesignCheckButton
checkButton placed in left position
Definition: GUIDesigns.h:133
#define GUIDesignLabelFrameInformation
label extended over frame without thick and with text justify to left, used to show information in fr...
Definition: GUIDesigns.h:223
@ GLO_TEMPORALSHAPE
temporal shape (used in NETEDIT)
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:276
@ SUMO_TAG_REROUTER
A rerouter.
@ SUMO_TAG_E2DETECTOR_MULTILANE
an e2 detector over multiple lanes (used by Netedit)
@ SUMO_TAG_NOTHING
invalid tag
@ SUMO_TAG_BUS_STOP
A bus stop.
@ SUMO_TAG_LANE
begin/end of the description of a single lane
@ SUMO_TAG_VAPORIZER
vaporizer of vehicles
@ SUMO_TAG_CALIBRATOR
A calibrator placed over edge.
@ SUMO_TAG_EDGE
begin/end of the description of an edge
@ SUMO_ATTR_LANE
@ SUMO_ATTR_FILE
@ SUMO_ATTR_EDGE
@ SUMO_ATTR_ENDPOS
@ GNE_ATTR_PARENT
parent of an additional element
@ SUMO_ATTR_EDGES
the edges of a route
@ SUMO_ATTR_LANES
@ SUMO_ATTR_STARTTIME
@ SUMO_ATTR_END
weights: time range end
@ SUMO_ATTR_ID
@ SUMO_ATTR_POSITION
std::string joinToString(const std::vector< T > &v, const T_BETWEEN &between, std::streamsize accuracy=gPrecision)
Definition: ToString.h:250
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:44
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
Definition: GLHelper.cpp:446
static void drawBoxLines(const PositionVector &geom, const std::vector< double > &rots, const std::vector< double > &lengths, double width, int cornerDetail=0, double offset=0)
Draws thick lines.
Definition: GLHelper.cpp:181
bool drawCandidateLanesWithSpecialColor() const
draw candidate lanes with special color (Only for candidates, special and conflicted)
long onCmdCreatePath(FXObject *, FXSelector, void *)
void hideE2MultilaneLaneSelectorModul()
show E2MultilaneLaneSelector
E2MultilaneLaneSelector(GNEAdditionalFrame *additionalFrameParent)
FOX-declaration.
long onCmdRemoveLastElement(FXObject *, FXSelector, void *)
Called when the user click over button "Remove las inserted lane".
void drawTemporalE2Multilane(const GUIVisualizationSettings &s) const
draw temporal E2Multilane
FXButton * myRemoveLastInsertedElement
button for removing last inserted element
void showE2MultilaneLaneSelectorModul()
show E2MultilaneLaneSelector
FXLabel * myInfoRouteLabel
label with route info
FXButton * myFinishCreationButton
button for finish route creation
void clearPath()
clear lanes (and restore colors)
FXButton * myAbortCreationButton
button for abort route creation
long onCmdShowCandidateLanes(FXObject *, FXSelector, void *)
Called when the user click over check button "show candidate lanes".
FXCheckButton * myShowCandidateLanes
CheckBox for show candidate lanes.
long onCmdAbortPathCreation(FXObject *, FXSelector, void *)
Called when the user click over button "Abort route creation".
long onCmdTypeInSearchBox(FXObject *, FXSelector, void *)
called when user type in search box
void showSelectorChildEdgesModul(std::string search="")
Show SelectorChildEdges Modul.
long onCmdSelectEdge(FXObject *, FXSelector, void *)
called when user select a edge of the list
FXButton * myClearEdgesSelection
button for clear selection
FXButton * myInvertEdgesSelection
button for invert selection
void updateUseSelectedEdges()
Update use selectedEdges.
FXCheckButton * myUseSelectedEdgesCheckButton
CheckBox for selected edges.
long onCmdInvertSelection(FXObject *, FXSelector, void *)
called when invert selection button is pressed
long onCmdClearSelection(FXObject *, FXSelector, void *)
called when clear selection button is pressed
std::string getEdgeIdsSelected() const
get list of selecte id's in string format
FXList * myList
List of SelectorChildEdges.
FXTextField * myEdgesSearch
text field for search edge IDs
SelectorChildEdges(GNEAdditionalFrame *additionalFrameParent)
FOX-declaration.
void hideSelectorChildEdgesModul()
hide SelectorChildEdges Modul
long onCmdUseSelectedEdges(FXObject *, FXSelector, void *)
FXList * myList
List of SelectorChildLanes.
long onCmdUseSelectedLanes(FXObject *, FXSelector, void *)
void hideSelectorChildLanesModul()
hide SelectorChildLanes Modul
long onCmdClearSelection(FXObject *, FXSelector, void *)
called when clear selection button is pressed
FXTextField * myLanesSearch
text field for search lane IDs
long onCmdTypeInSearchBox(FXObject *, FXSelector, void *)
called when user type in search box
FXButton * clearLanesSelection
button for clear selection
void showSelectorChildLanesModul(std::string search="")
Show list of SelectorChildLanes Modul.
SelectorChildLanes(GNEAdditionalFrame *additionalFrameParent)
FOX-declaration.
long onCmdInvertSelection(FXObject *, FXSelector, void *)
called when invert selection button is pressed
long onCmdSelectLane(FXObject *, FXSelector, void *)
called when user select a lane of the list
FXButton * invertLanesSelection
button for invert selection
FXCheckButton * myUseSelectedLanesCheckButton
CheckBox for selected lanes.
std::string getLaneIdsSelected() const
get list of selecte lane ids in string format
bool isSelectingLanes() const
return true if modul is selecting lane
const std::vector< std::pair< GNELane *, double > > & getSelectedLanes() const
get current selected lanes
void hideSelectorParentLanesModul()
hide SelectorParentLanes
bool isShown() const
return true if modul is shown
bool isLaneSelected(GNELane *lane) const
check if certain lane is selected
long onCmdStopSelection(FXObject *, FXSelector, void *)
bool stopConsecutiveLaneSelector()
stop selection of consecutive lanes
void removeLastSelectedLane()
remove last added point
long onCmdAbortSelection(FXObject *, FXSelector, void *)
Called when the user press abort selection button.
void startConsecutiveLaneSelector(GNELane *lane, const Position &clickedPosition)
start selection of consecutive lanes
void showSelectorParentLanesModul()
show SelectorParentLanes modul
bool addSelectedLane(GNELane *lane, const Position &clickedPosition)
return true if lane can be selected as consecutive lane
void abortConsecutiveLaneSelector()
abort selection of consecutive lanes
void showSelectorChildLanesModul()
show selector child lane and update use selected edges/lanes
SelectorChildEdges * mySelectorChildEdges
Modul for select child edges.
GNEAdditionalFrame(FXHorizontalFrame *horizontalFrameParent, GNEViewNet *viewNet)
Constructor.
SelectorParentLanes * mySelectorParentLanes
Modul for select parent lanes (currently only consecutives)
std::string generateID(GNENetworkElement *networkElement) const
generate a ID for an additiona element
bool buildAdditionalOverEdge(std::map< SumoXMLAttr, std::string > &valuesMap, GNELane *lane, const GNETagProperties &tagValues)
build additional over an edge (parent of lane)
bool buildAdditionalCommonAttributes(std::map< SumoXMLAttr, std::string > &valuesMap, const GNETagProperties &tagValues)
build common additional attributes
SelectorChildLanes * mySelectorChildLanes
Modul for select child lanes.
GNEAdditionalFrame::SelectorParentLanes * getConsecutiveLaneSelector() const
get consecutive Lane Selector
bool buildAdditionalOverLane(std::map< SumoXMLAttr, std::string > &valuesMap, GNELane *lane, const GNETagProperties &tagValues)
build additional over a single lane
void tagSelected()
Tag selected in TagSelector.
GNEFrameModuls::SelectorParent * myParentAdditional
Modul for select a single parent additional.
GNEFrameAttributesModuls::NeteditAttributes * myNeteditAttributes
Netedit parameter.
E2MultilaneLaneSelector * myE2MultilaneLaneSelector
Modul for E2Multilane lane selector.
bool buildAdditionalOverView(std::map< SumoXMLAttr, std::string > &valuesMap, const GNETagProperties &tagValues)
build additional over view
GNEFrameModuls::TagSelector * myAdditionalTagSelector
item selector
~GNEAdditionalFrame()
Destructor.
GNEAdditionalFrame::E2MultilaneLaneSelector * getE2MultilaneLaneSelector() const
getConsecutive Lane Selector
bool addAdditional(const GNEViewNetHelper::ObjectsUnderCursor &objectsUnderCursor)
add additional element
GNEFrameAttributesModuls::AttributesCreator * myAdditionalAttributes
internal additional attributes
bool buildSlaveAdditional(std::map< SumoXMLAttr, std::string > &valuesMap, GNEAdditional *parent, const GNETagProperties &tagValues)
build slave additional
static bool buildAdditional(GNENet *net, bool allowUndoRedo, SumoXMLTag tag, const SUMOSAXAttributes &attrs, LastInsertedElement *insertedAdditionals)
Build additionals.
An Element which don't belongs to GNENet but has influency in the simulation.
Definition: GNEAdditional.h:47
const std::string & getID() const
get ID
const GNETagProperties & getTagProperty() const
get Tag Property assigned to this object
bool isSpecialCandidate() const
check if this element is a special candidate
void setTargetCandidate(const bool value)
set element as target candidate
bool isPossibleCandidate() const
check if this element is a possible candidate
bool isConflictedCandidate() const
check if this element is a conflicted candidate
void setConflictedCandidate(const bool value)
set element as conflicted candidate
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:49
const std::vector< GNEConnection * > & getGNEConnections() const
returns a reference to the GNEConnection vector
Definition: GNEEdge.cpp:729
void refreshRows()
refresh rows (called after creating an element)
void showAttributesCreatorModul(const GNETagProperties &tagProperties, const std::vector< SumoXMLAttr > &hiddenAttributes)
show AttributesCreator modul
std::map< SumoXMLAttr, std::string > getAttributesAndValues(bool includeAll) const
get attributes and their values
bool areValuesValid() const
check if parameters of attributes are valid
void showWarningMessage(std::string extra="") const
show warning message with information about non-valid attributes
void showNeteditAttributesModul(const GNETagProperties &tagValue)
show Netedit attributes modul
bool getNeteditAttributesAndValues(std::map< SumoXMLAttr, std::string > &valuesMap, const GNELane *lane) const
fill valuesMap with netedit attributes
void hideNeteditAttributesModul()
hide Netedit attributes modul
GNEViewNet * myViewNet
View Net.
Definition: GNEFrame.h:113
virtual void createPath()
create path (can be reimplemented in frame children)
Definition: GNEFrame.cpp:197
FXVerticalFrame * myContentFrame
Vertical frame that holds all widgets of frame.
Definition: GNEFrame.h:116
virtual void show()
show Frame
Definition: GNEFrame.cpp:108
virtual void hide()
hide Frame
Definition: GNEFrame.cpp:117
const std::vector< std::string > & getPredefinedTagsMML() const
get predefinedTagsMML
Definition: GNEFrame.cpp:269
void refreshSelectorParentModul()
Refresh list of Additional Parents Modul.
std::string getIdSelected() const
get currently parent additional selected
void hideSelectorParentModul()
hide SelectorParent Modul
bool showSelectorParentModul(SumoXMLTag additionalTypeParent)
Show list of SelectorParent Modul.
void setIDSelected(const std::string &id)
select manually a element of the list
void refreshTagProperties()
due myCurrentTagProperties is a Reference, we need to refresh it when frameParent is show
const GNETagProperties & getCurrentTagProperties() const
get current type tag
void setCurrentTag(SumoXMLTag newTag)
set current type manually
const PositionVector & getShape() const
The shape of the additional element.
bool exist(const GNELane *toLane) const
check if exist a lane2lane geometry for the given tolane
const GNEGeometry::Geometry & getLane2laneGeometry(const GNELane *toLane) const
get lane2lane geometry
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition: GNELane.h:45
const PositionVector & getLaneShape() const
Definition: GNELane.cpp:117
double getLengthGeometryFactor() const
get length geometry factor
Definition: GNELane.cpp:1615
const GNEGeometry::Lane2laneConnection & getLane2laneConnections() const
get Lane2laneConnection struct
Definition: GNELane.cpp:774
GNEEdge * getParentEdge() const
get arent edge
Definition: GNELane.cpp:111
int getNumberOfAdditionals(SumoXMLTag type=SUMO_TAG_NOTHING) const
Returns the number of additionals of the net.
Definition: GNENet.cpp:2349
GNEAdditional * retrieveAdditional(SumoXMLTag type, const std::string &id, bool hardFail=true) const
Returns the named additional.
Definition: GNENet.cpp:2316
const std::string & getID() const
get ID
bool isSlave() const
return true if tag correspond to an element slave of another element (I.e. doesn't have their own ID)
const std::string & getTagStr() const
get Tag vinculated with this attribute Property in String Format (used to avoid multiple calls to toS...
SumoXMLTag getTag() const
get Tag vinculated with this attribute Property
const std::vector< SumoXMLTag > & getMasterTags() const
get master tags
bool hasAttribute(SumoXMLAttr attr) const
check if current TagProperties owns the attribute "attr"
class used to group all variables related with objects under cursor after a click over view
GNELane * getLaneFront() const
get front lane or a pointer to nullptr
GNEAdditional * getAdditionalFront() const
get front additional element or a pointer to nullptr
GNENet * getNet() const
get the net object
void setStatusBarText(const std::string &text)
set staturBar text
Definition: GNEViewNet.cpp:575
Position snapToActiveGrid(const Position &pos, bool snapXY=true) const
Returns a position that is mapped to the closest grid point if the grid is active.
Position getPositionInformation() const
Returns the cursor's x/y position within the network.
Stores the information about how to visualize structures.
GUIVisualizationNeteditSizeSettings neteditSizeSettings
netedit size settings
C++ TraCI client API implementation.
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:36
double nearest_offset_to_point2D(const Position &p, bool perpendicular=true) const
return the nearest offest to point 2D
static const RGBColor GREY
Definition: RGBColor.h:189
static const RGBColor ORANGE
Definition: RGBColor.h:186
RGBColor changedBrightness(int change, int toChange=3) const
Returns a new color with altered brightness.
Definition: RGBColor.cpp:145
static const RGBColor RED
named colors
Definition: RGBColor.h:180
Encapsulated Xerces-SAX-attributes.
static void drawGeometryPoints(const GUIVisualizationSettings &s, const GNEViewNet *viewNet, const PositionVector &shape, const RGBColor &geometryPointColor, const RGBColor &textColor, const double radius, const double exaggeration)
draw geometry points
static const double polylineWidth
poly line width