SUMO - Simulation of Urban MObility
GNEViewNet.cpp
Go to the documentation of this file.
1 /****************************************************************************/
8 // A view on the network being edited (adapted from GUIViewTraffic)
9 /****************************************************************************/
10 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
11 // Copyright (C) 2001-2017 DLR (http://www.dlr.de/) and contributors
12 /****************************************************************************/
13 //
14 // This file is part of SUMO.
15 // SUMO is free software: you can redistribute it and/or modify
16 // it under the terms of the GNU General Public License as published by
17 // the Free Software Foundation, either version 3 of the License, or
18 // (at your option) any later version.
19 //
20 /****************************************************************************/
21 
22 
23 // ===========================================================================
24 // included modules
25 // ===========================================================================
26 #ifdef _MSC_VER
27 #include <windows_config.h>
28 #else
29 #include <config.h>
30 #endif
31 
32 #include <iostream>
33 #include <utility>
34 #include <cmath>
35 #include <limits>
40 #include <utils/common/RGBColor.h>
52 #include <utils/gui/div/GLHelper.h>
55 #include <utils/xml/XMLSubSys.h>
56 #include <netbuild/NBEdge.h>
57 
58 #include "GNEViewNet.h"
59 #include "GNEEdge.h"
60 #include "GNELane.h"
61 #include "GNEJunction.h"
62 #include "GNEPOI.h"
63 #include "GNEApplicationWindow.h"
64 #include "GNEViewParent.h"
65 #include "GNENet.h"
66 #include "GNEUndoList.h"
67 #include "GNEInspectorFrame.h"
68 #include "GNESelectorFrame.h"
69 #include "GNEConnectorFrame.h"
70 #include "GNETLSEditorFrame.h"
71 #include "GNEAdditionalFrame.h"
72 #include "GNECrossingFrame.h"
73 #include "GNEPolygonFrame.h"
74 #include "GNEDeleteFrame.h"
75 #include "GNEAdditionalHandler.h"
76 #include "GNEPoly.h"
77 #include "GNECrossing.h"
78 #include "GNEAdditional.h"
79 #include "GNEAdditionalDialog.h"
80 #include "GNERerouter.h"
81 #include "GNEConnection.h"
82 #include "GNEChange_POI.h"
83 #include "GNEChange_Poly.h"
84 
85 
86 // ===========================================================================
87 // FOX callback mapping
88 // ===========================================================================
89 FXDEFMAP(GNEViewNet) GNEViewNetMap[] = {
90  // Modes
92  FXMAPFUNC(SEL_COMMAND, MID_GNE_MODE_MOVE, GNEViewNet::onCmdSetModeMove),
93  FXMAPFUNC(SEL_COMMAND, MID_GNE_MODE_DELETE, GNEViewNet::onCmdSetModeDelete),
95  FXMAPFUNC(SEL_COMMAND, MID_GNE_MODE_SELECT, GNEViewNet::onCmdSetModeSelect),
97  FXMAPFUNC(SEL_COMMAND, MID_GNE_MODE_TLS, GNEViewNet::onCmdSetModeTLS),
100  FXMAPFUNC(SEL_COMMAND, MID_GNE_MODE_POLYGON, GNEViewNet::onCmdSetModePolygon),
101  // Viewnet
105  FXMAPFUNC(SEL_COMMAND, MID_GNE_VIEWNET_SHOW_GRID, GNEViewNet::onCmdShowGrid),
107  // Junctions
110  // Edges
111  FXMAPFUNC(SEL_COMMAND, MID_GNE_EDGE_SPLIT, GNEViewNet::onCmdSplitEdge),
113  FXMAPFUNC(SEL_COMMAND, MID_GNE_EDGE_REVERSE, GNEViewNet::onCmdReverseEdge),
118  // Lanes
130  // Polygons
132  FXMAPFUNC(SEL_COMMAND, MID_GNE_POLYGON_CLOSE, GNEViewNet::onCmdClosePolygon),
133  FXMAPFUNC(SEL_COMMAND, MID_GNE_POLYGON_OPEN, GNEViewNet::onCmdOpenPolygon),
135 };
136 
137 
138 // Object implementation
139 FXIMPLEMENT(GNEViewNet, GUISUMOAbstractView, GNEViewNetMap, ARRAYNUMBER(GNEViewNetMap))
140 
141 
142 // ===========================================================================
143 // member method definitions
144 // ===========================================================================
145 
146 GNEViewNet::GNEViewNet(FXComposite* tmpParent, FXComposite* actualParent, GUIMainWindow& app,
147  GNEViewParent* viewParent, GNENet* net, GNEUndoList* undoList,
148  FXGLVisual* glVis, FXGLCanvas* share, FXToolBar* toolBar) :
149  GUISUMOAbstractView(tmpParent, app, viewParent, net->getVisualisationSpeedUp(), glVis, share),
150  myViewParent(viewParent),
151  myNet(net),
152  myEditMode(GNE_MODE_MOVE),
153  myCurrentFrame(0),
154  myShowConnections(false),
155  mySelectEdges(true),
156  myCreateEdgeSource(0),
157  myJunctionToMove(0),
158  myEdgeToMove(0),
159  myPolyToMove(0),
160  myPoiToMove(0),
161  myAdditionalToMove(0),
162  myMovingIndexShape(-1),
163  myMovingSelection(false),
164  myAmInRectSelect(false),
165  myToolbar(toolBar),
166  myEditModeCreateEdge(0),
167  myEditModeMove(0),
168  myEditModeDelete(0),
169  myEditModeInspect(0),
170  myEditModeSelect(0),
171  myEditModeConnection(0),
172  myEditModeTrafficLight(0),
173  myEditModeAdditional(0),
174  myEditModeCrossing(0),
175  myEditModePolygon(0),
176  myEditModeNames(),
177  myUndoList(undoList),
178  myEditJunctionShapePoly(0),
179  myTestingMode(OptionsCont::getOptions().getBool("gui-testing")) {
180  // view must be the final member of actualParent
181  reparent(actualParent);
182 
183  buildEditModeControls();
184  myUndoList->mark();
185  myNet->setViewNet(this);
186 
187  ((GUIDanielPerspectiveChanger*)myChanger)->setDragDelay(100000000); // 100 milliseconds
188 
189  if (myTestingMode && OptionsCont::getOptions().isSet("window-size")) {
190  std::vector<std::string> windowSize = OptionsCont::getOptions().getStringVector("window-size");
191  assert(windowSize.size() == 2);
192  myTestingWidth = GNEAttributeCarrier::parse<int>(windowSize[0]);
193  myTestingHeight = GNEAttributeCarrier::parse<int>(windowSize[1]);
194  }
195 }
196 
197 
199 
200 
201 void
203 
204 
205 void
207  // build coloring tools
208  {
209  for (auto it_names : gSchemeStorage.getNames()) {
210  cw.getColoringSchemesCombo().appendItem(it_names.c_str());
211  if (it_names == myVisualizationSettings->name) {
212  cw.getColoringSchemesCombo().setCurrentItem(cw.getColoringSchemesCombo().getNumItems() - 1);
213  }
214  }
215  cw.getColoringSchemesCombo().setNumVisible(MAX2(5, (int)gSchemeStorage.getNames().size() + 1));
216  }
217  // for junctions
218  new FXButton(cw.getLocatorPopup(),
219  "\tLocate Junction\tLocate a junction within the network.",
221  ICON_ABOVE_TEXT | FRAME_THICK | FRAME_RAISED);
222  // for edges
223  new FXButton(cw.getLocatorPopup(),
224  "\tLocate Street\tLocate a street within the network.",
226  ICON_ABOVE_TEXT | FRAME_THICK | FRAME_RAISED);
227  // for tls
228  new FXButton(cw.getLocatorPopup(),
229  "\tLocate TLS\tLocate a tls within the network.",
231  ICON_ABOVE_TEXT | FRAME_THICK | FRAME_RAISED);
232  // for additional stuff
233  new FXButton(cw.getLocatorPopup(),
234  "\tLocate Additional\tLocate an additional structure within the network.",
236  ICON_ABOVE_TEXT | FRAME_THICK | FRAME_RAISED);
237  // for pois
238  new FXButton(cw.getLocatorPopup(),
239  "\tLocate PoI\tLocate a PoI within the network.",
241  ICON_ABOVE_TEXT | FRAME_THICK | FRAME_RAISED);
242  // for polygons
243  new FXButton(cw.getLocatorPopup(),
244  "\tLocate Polygon\tLocate a Polygon within the network.",
246  ICON_ABOVE_TEXT | FRAME_THICK | FRAME_RAISED);
247 }
248 
249 
250 bool
251 GNEViewNet::setColorScheme(const std::string& name) {
252  if (!gSchemeStorage.contains(name)) {
253  return false;
254  }
255  if (myVisualizationChanger != 0) {
256  if (myVisualizationChanger->getCurrentScheme() != name) {
258  }
259  }
260  myVisualizationSettings = &gSchemeStorage.get(name.c_str());
261  update();
262  return true;
263 }
264 
265 
266 void
268  if (objectType == GLO_LANE) {
269  assert(!scheme.isFixed());
270  // retrieve range
271  double minValue = std::numeric_limits<double>::infinity();
272  double maxValue = -std::numeric_limits<double>::infinity();
273  // XXX (see #3409) multi-colors are not currently handled. this is a quick hack
274  if (active == 9) {
275  active = 8; // segment height, fall back to start height
276  }
277  const std::vector<GNELane*> lanes = myNet->retrieveLanes();
278  for (auto it : lanes) {
279  const double val = it->getColorValue(active);
280  minValue = MIN2(minValue, val);
281  maxValue = MAX2(maxValue, val);
282  }
283  scheme.clear();
284  // add new thresholds
285  double range = maxValue - minValue;
286  scheme.addColor(RGBColor::RED, (minValue));
287  scheme.addColor(RGBColor::ORANGE, (minValue + range * 1 / 6.0));
288  scheme.addColor(RGBColor::YELLOW, (minValue + range * 2 / 6.0));
289  scheme.addColor(RGBColor::GREEN, (minValue + range * 3 / 6.0));
290  scheme.addColor(RGBColor::CYAN, (minValue + range * 4 / 6.0));
291  scheme.addColor(RGBColor::BLUE, (minValue + range * 5 / 6.0));
292  scheme.addColor(RGBColor::MAGENTA, (maxValue));
293  }
294 }
295 
296 
297 void
298 GNEViewNet::setStatusBarText(const std::string& text) {
299  myApp->setStatusBarText(text);
300 }
301 
302 
303 bool
305  return mySelectEdges;
306 }
307 
308 
309 bool
311  if (myEditMode == GNE_MODE_CONNECT) {
312  return true;
313  } else if (myMenuCheckShowConnections->shown() == false) {
314  return false;
315  } else {
317  }
318 }
319 
320 
321 bool
323  return (myMenuCheckExtendToEdgeNodes->getCheck() != 0);
324 }
325 
326 
327 void
328 GNEViewNet::setSelectionScaling(double selectionScale) {
329  myVisualizationSettings->selectionScale = selectionScale;
330 }
331 
332 
333 bool
335  return (myMenuCheckChangeAllPhases->getCheck() != 0);
336 }
337 
338 
339 bool
341  return (myEditMode == GNE_MODE_MOVE) && (myMenuCheckShowBubbleOverJunction->getCheck());
342 }
343 
344 
345 void
347  if ((myEditJunctionShapePoly == NULL) && (junction != NULL) && (junction->getNBNode()->getShape().size() > 1)) {
348  // save current edit mode before starting
351  junction->getNBNode()->computeNodeShape(-1);
352  // add special GNEPoly fo edit shapes
354  // update view net to show the new myEditJunctionShapePoly
355  update();
356  }
357 }
358 
359 
360 void
362  // stop edit shape junction deleting myEditJunctionShapePoly
363  if (myEditJunctionShapePoly != 0) {
367  // restore previous edit mode
370  }
371  }
372 
373 }
374 
375 
376 int
377 GNEViewNet::doPaintGL(int mode, const Boundary& bound) {
378  // init view settings
379  glRenderMode(mode);
380  glMatrixMode(GL_MODELVIEW);
381  glPushMatrix();
382  glDisable(GL_TEXTURE_2D);
383  glDisable(GL_ALPHA_TEST);
384  glDisable(GL_BLEND);
385  glEnable(GL_DEPTH_TEST);
386 
387  // visualize rectangular selection
388  if (myAmInRectSelect) {
389  glPushMatrix();
390  glTranslated(0, 0, GLO_MAX - 1);
392  glLineWidth(2);
393  glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
394  glBegin(GL_QUADS);
395  glVertex2d(mySelCorner1.x(), mySelCorner1.y());
396  glVertex2d(mySelCorner1.x(), mySelCorner2.y());
397  glVertex2d(mySelCorner2.x(), mySelCorner2.y());
398  glVertex2d(mySelCorner2.x(), mySelCorner1.y());
399  glEnd();
400  glPopMatrix();
401  }
402 
403  // compute lane width
404  double lw = m2p(SUMO_const_laneWidth);
405  // draw decals (if not in grabbing mode)
406  if (!myUseToolTips) {
407  drawDecals();
408  // depending of the visualizationSettings, enable or disable check box show grid
410  myMenuCheckShowGrid->setCheck(true);
411  paintGLGrid();
412  } else {
413  myMenuCheckShowGrid->setCheck(false);
414  }
416  if (myTestingMode) {
417  if (myTestingWidth > 0 && (getWidth() != myTestingWidth || getHeight() != myTestingHeight)) {
418  // only resize once to avoid flickering
419  //std::cout << " before resize: view=" << getWidth() << ", " << getHeight() << " app=" << myApp->getWidth() << ", " << myApp->getHeight() << "\n";
420  myApp->resize(myTestingWidth + myTestingWidth - getWidth(), myTestingHeight + myTestingHeight - getHeight());
421  //std::cout << " directly after resize: view=" << getWidth() << ", " << getHeight() << " app=" << myApp->getWidth() << ", " << myApp->getHeight() << "\n";
422  myTestingWidth = 0;
423  }
424  //std::cout << " fixed: view=" << getWidth() << ", " << getHeight() << " app=" << myApp->getWidth() << ", " << myApp->getHeight() << "\n";
425  // draw pink square in the upper left corner on top of everything
426  glPushMatrix();
427  const double size = p2m(32);
428  Position center = screenPos2NetPos(8, 8);
430  glTranslated(center.x(), center.y(), GLO_MAX - 1);
431  glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
432  glBegin(GL_QUADS);
433  glVertex2d(0, 0);
434  glVertex2d(0, -size);
435  glVertex2d(size, -size);
436  glVertex2d(size, 0);
437  glEnd();
438  glPopMatrix();
439 
440  // Reset textures due bug #2780. This solution is only provisional, and must be updated in the future
442  }
443  }
444 
445  // draw temporal shape of polygon during drawing
447  const PositionVector& temporalDrawingShape = myViewParent->getPolygonFrame()->getDrawingMode()->getTemporalShape();
448  // draw blue line with the current drawed shape
449  glPushMatrix();
450  glLineWidth(2);
452  GLHelper::drawLine(temporalDrawingShape);
453  glPopMatrix();
454  // draw red line from the last point of shape to the current mouse position
455  if (temporalDrawingShape.size() > 0) {
456  glPushMatrix();
457  glLineWidth(2);
459  GLHelper::drawLine(temporalDrawingShape.back(), snapToActiveGrid(getPositionInformation()));
460  glPopMatrix();
461  }
462  }
463 
464  glLineWidth(1);
465  glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
466  const float minB[2] = { (float)bound.xmin(), (float)bound.ymin() };
467  const float maxB[2] = { (float)bound.xmax(), (float)bound.ymax() };
469  glEnable(GL_POLYGON_OFFSET_FILL);
470  glEnable(GL_POLYGON_OFFSET_LINE);
472  int hits2 = myGrid->Search(minB, maxB, *myVisualizationSettings);
473 
474  glTranslated(0, 0, GLO_ADDITIONAL);
475  for (std::map<const GUIGlObject*, int>::iterator i = myAdditionallyDrawn.begin(); i != myAdditionallyDrawn.end(); ++i) {
476  (i->first)->drawGLAdditional(this, *myVisualizationSettings);
477  }
478 
479  glPopMatrix();
480  return hits2;
481 }
482 
483 
484 long
485 GNEViewNet::onLeftBtnPress(FXObject*, FXSelector, void* eventData) {
486  FXEvent* e = (FXEvent*) eventData;
487  setFocus();
488  // interpret object under curser
489  if (makeCurrent()) {
490  int id = getObjectUnderCursor();
493  GNEJunction* pointed_junction = 0;
494  GNELane* pointed_lane = 0;
495  GNEEdge* pointed_edge = 0;
496  GNEPOI* pointed_poi = 0;
497  GNEPoly* pointed_poly = 0;
498  GNECrossing* pointed_crossing = 0;
499  GNEAdditional* pointed_additional = 0;
500  GNEConnection* pointed_connection = 0;
501  if (pointed) {
502  switch (pointed->getType()) {
503  case GLO_JUNCTION:
504  pointed_junction = (GNEJunction*)pointed;
505  break;
506  case GLO_EDGE:
507  pointed_edge = (GNEEdge*)pointed;
508  break;
509  case GLO_LANE:
510  pointed_lane = (GNELane*)pointed;
511  pointed_edge = &(pointed_lane->getParentEdge());
512  break;
513  case GLO_POI:
514  pointed_poi = (GNEPOI*)pointed;
515  break;
516  case GLO_POLYGON:
517  pointed_poly = (GNEPoly*)pointed;
518  break;
519  case GLO_CROSSING:
520  pointed_crossing = (GNECrossing*)pointed;
521  break;
522  case GLO_ADDITIONAL:
523  pointed_additional = (GNEAdditional*)pointed;
524  break;
525  case GLO_CONNECTION:
526  pointed_connection = (GNEConnection*)pointed;
527  break;
528  default:
529  pointed = 0;
530  break;
531  }
532  }
533 
534  // decide what to do based on mode
535  switch (myEditMode) {
536  case GNE_MODE_CREATE_EDGE: {
537  if ((e->state & CONTROLMASK) == 0) {
538  // allow moving when control is held down
539  if (!myUndoList->hasCommandGroup()) {
540  myUndoList->p_begin("create new " + toString(SUMO_TAG_EDGE));
541  }
542  if (!pointed_junction) {
544  }
545  if (myCreateEdgeSource == 0) {
546  myCreateEdgeSource = pointed_junction;
548  update();
549  } else {
550  if (myCreateEdgeSource != pointed_junction) {
551  // may fail to prevent double edges
552  GNEEdge* newEdge = myNet->createEdge(
554  if (newEdge) {
555  // create another edge, if create opposite edge is enabled
556  if (myAutoCreateOppositeEdge->getCheck()) {
558  }
560 
561  if (myUndoList->hasCommandGroup()) {
562  myUndoList->p_end();
563  } else {
564  std::cout << "edge created without an open CommandGroup )-:\n";
565  }
566  if (myChainCreateEdge->getCheck()) {
567  myCreateEdgeSource = pointed_junction;
569  myUndoList->p_begin("create new " + toString(SUMO_TAG_EDGE));
570  } else {
571  myCreateEdgeSource = 0;
572  }
573  } else {
574  setStatusBarText("An " + toString(SUMO_TAG_EDGE) + " with the same geometry already exists!");
575  }
576  } else {
577  setStatusBarText("Start- and endpoint for an " + toString(SUMO_TAG_EDGE) + " must be distinct!");
578  }
579  update();
580  }
581  }
582  // process click
583  processClick(e, eventData);
584  break;
585  }
586  case GNE_MODE_MOVE: {
587  if (pointed_poly) {
588  // set Poly to move
589  myPolyToMove = pointed_poly;
590  // save original shape (needed for commit change)
592  // obtain index of vertex to move if shape isn't blocked
593  if ((myPolyToMove->isShapeBlocked() == false) && (myPolyToMove->isMovementBlocked() == false)) {
594  // obtain index of vertex to move and moving reference
596  } else {
597  myMovingIndexShape = -1;
598  }
599  // obtain moving reference
601  } else if (pointed_poi) {
602  myPoiToMove = pointed_poi;
603  // Save original Position of Element and obtain moving reference
606  } else if (pointed_junction) {
607  if (gSelected.isSelected(GLO_JUNCTION, pointed_junction->getGlID())) {
608  myMovingSelection = true;
609  // save position of current selected junctions (Needed when mouse is released)
610  std::vector<GNEJunction*> selectedJunctions = myNet->retrieveJunctions(true);
611  for (std::vector<GNEJunction*>::const_iterator i = selectedJunctions.begin(); i != selectedJunctions.end(); i++) {
612  myOriginPostionOfMovedJunctions[*i] = (*i)->getPositionInView();
613  }
614  } else {
615  myJunctionToMove = pointed_junction;
616  }
617  // Save original Position of Element and obtain moving reference
618  myMovingOriginalPosition = pointed_junction->getPositionInView();
620  } else if (pointed_edge) {
621  if (gSelected.isSelected(GLO_EDGE, pointed_edge->getGlID())) {
622  myMovingSelection = true;
623  } else {
624  myEdgeToMove = pointed_edge;
626  }
628  } else if (pointed_additional) {
629  if (gSelected.isSelected(GLO_ADDITIONAL, pointed_additional->getGlID())) {
630  myMovingSelection = true;
631  } else {
632  myAdditionalToMove = pointed_additional;
633  if (myAdditionalToMove->getLane()) {
635  // Obtain start position
636  double startPos = GNEAttributeCarrier::parse<double>(myAdditionalToMove->getAttribute(SUMO_ATTR_STARTPOS));
638  // Obtain end position
639  double endPos = GNEAttributeCarrier::parse<double>(myAdditionalToMove->getAttribute(SUMO_ATTR_ENDPOS));
640  // Save both values in myMovingOriginalPosition
641  myMovingOriginalPosition.set(startPos, endPos);
643  // Obtain length attribute
644  double length = GNEAttributeCarrier::parse<double>(myAdditionalToMove->getAttribute(SUMO_ATTR_LENGTH));
645  // Save both values in myMovingOriginalPosition
646  myMovingOriginalPosition.set(startPos, length);
647  } else {
648  // Save only startpos in myMovingOriginalPosition
649  myMovingOriginalPosition.set(startPos, 0);
650  }
652  myMovingOriginalPosition.set(GNEAttributeCarrier::parse<double>(myAdditionalToMove->getAttribute(SUMO_ATTR_POSITION)), 0);
653  }
654  // Set myMovingReference
655  myMovingReference.set(pointed_additional->getLane()->getShape().nearest_offset_to_point2D(getPositionInformation(), false), 0, 0);
656  } else {
657  // Save original Position of Element and obtain moving reference
658  myMovingOriginalPosition = pointed_additional->getPositionInView();
660  }
661  }
662  } else {
663  // process click
664  processClick(e, eventData);
665  }
666  update();
667  break;
668  }
669  case GNE_MODE_DELETE: {
670  // Check if Control key is pressed
671  bool markElementMode = (((FXEvent*)eventData)->state & CONTROLMASK) != 0;
672  GNEAttributeCarrier* ac = dynamic_cast<GNEAttributeCarrier*>(pointed);
673  if ((pointed_lane != NULL) && mySelectEdges) {
674  ac = pointed_edge;
675  }
676  if (ac) {
677  // if pointed element is an attribute carrier, remove it or mark it
678  if (markElementMode) {
681  }
682  } else if (myViewParent->getDeleteFrame()->getMarkedAttributeCarrier() != NULL) {
684  } else {
686  }
687  } else {
688  // process click
689  processClick(e, eventData);
690  }
691  break;
692  }
693  case GNE_MODE_INSPECT: {
694  GNEAttributeCarrier* pointedAC = 0;
695  GUIGlObject* pointedO = 0;
696  if (pointed_junction) {
697  pointedAC = pointed_junction;
698  pointedO = pointed_junction;
699  } else if (pointed_lane) { // implies pointed_edge
700  if (mySelectEdges) {
701  pointedAC = pointed_edge;
702  pointedO = pointed_edge;
703  } else {
704  pointedAC = pointed_lane;
705  pointedO = pointed_lane;
706  }
707  } else if (pointed_edge) {
708  pointedAC = pointed_edge;
709  pointedO = pointed_edge;
710  } else if (pointed_crossing) {
711  pointedAC = pointed_crossing;
712  pointedO = pointed_crossing;
713  } else if (pointed_additional) {
714  pointedAC = pointed_additional;
715  pointedO = pointed_additional;
716  } else if (pointed_connection) {
717  pointedAC = pointed_connection;
718  pointedO = pointed_connection;
719  } else if (pointed_poly) {
720  pointedAC = pointed_poly;
721  pointedO = pointed_poly;
722  } else if (pointed_poi) {
723  pointedAC = pointed_poi;
724  pointedO = pointed_poi;
725  }
726  // obtain selected ACs
727  std::vector<GNEAttributeCarrier*> selectedElements;
728  std::vector<GNEAttributeCarrier*> selectedFilteredElements;
729  if (pointedO && gSelected.isSelected(pointedO->getType(), pointedO->getGlID())) {
730  std::set<GUIGlID> selectedIDs = gSelected.getSelected(pointedO->getType());
731  selectedElements = myNet->retrieveAttributeCarriers(selectedIDs, pointedO->getType());
732  // filter selected elements (example: if we have two E2 and one busStop selected, and user click over one E2,
733  // attribues of busstop musn't be shown
734  for (auto i : selectedElements) {
735  if (i->getTag() == pointedAC->getTag()) {
736  selectedFilteredElements.push_back(i);
737  }
738  }
739  }
740  // Inspect seleted ACs, or single clicked AC
741  if (selectedFilteredElements.size() > 0) {
742  myViewParent->getInspectorFrame()->inspectMultisection(selectedFilteredElements);
743  } else if (pointedAC != NULL) {
745  }
746  // process click
747  processClick(e, eventData);
748  // focus upper element of inspector frame
749  if ((selectedFilteredElements.size() > 0) || (pointedAC != NULL)) {
751  }
752  update();
753  break;
754  }
755  case GNE_MODE_SELECT:
756  if ((pointed_lane != NULL) && mySelectEdges) {
757  gSelected.toggleSelection(pointed_edge->getGlID());
758  } else if (pointed) {
759  gSelected.toggleSelection(pointed->getGlID());
760  }
761 
762  myAmInRectSelect = (((FXEvent*)eventData)->state & SHIFTMASK) != 0;
763  if (myAmInRectSelect) {
766  } else {
767  // process click
768  processClick(e, eventData);
769  }
770  update();
771  break;
772 
773  case GNE_MODE_CONNECT: {
774  if (pointed_lane) {
775  const bool mayPass = (((FXEvent*)eventData)->state & SHIFTMASK) != 0;
776  const bool allowConflict = (((FXEvent*)eventData)->state & CONTROLMASK) != 0;
777  myViewParent->getConnectorFrame()->handleLaneClick(pointed_lane, mayPass, allowConflict, true);
778  update();
779  }
780  // process click
781  processClick(e, eventData);
782  break;
783  }
784  case GNE_MODE_TLS: {
785  if (pointed_junction) {
786  myViewParent->getTLSEditorFrame()->editJunction(pointed_junction);
787  update();
788  }
789  // process click
790  processClick(e, eventData);
791  break;
792  }
793  case GNE_MODE_ADDITIONAL: {
794  if (pointed_additional == NULL) {
795  GNENetElement* netElement = dynamic_cast<GNENetElement*>(pointed);
797  // process click or update view depending of the result of "add additional"
799  update();
800  // process click
801  processClick(e, eventData);
802  }
803  }
804 
805  break;
806  }
807  case GNE_MODE_CROSSING: {
808  if (pointed_crossing == NULL) {
809  GNENetElement* netElement = dynamic_cast<GNENetElement*>(pointed);
810  if (myViewParent->getCrossingFrame()->addCrossing(netElement)) {
811  update();
812  }
813  }
814  // process click
815  processClick(e, eventData);
816  break;
817  }
818  case GNE_MODE_POLYGON: {
819  if (pointed_poi == NULL) {
821  // view net must be always update
822  update();
823  // process clickw depending of the result of "add additional"
824  if ((result != GNEPolygonFrame::ADDSHAPE_NEWPOINT)) {
825  // process click
826  processClick(e, eventData);
827  }
828  }
829  break;
830  }
831  default: {
832  // process click
833  processClick(e, eventData);
834  }
835  }
836  makeNonCurrent();
837  }
838  return 1;
839 }
840 
841 
842 long
843 GNEViewNet::onLeftBtnRelease(FXObject* obj, FXSelector sel, void* eventData) {
844  GUISUMOAbstractView::onLeftBtnRelease(obj, sel, eventData);
845  if (myPolyToMove) {
847  myPolyToMove = 0;
848  } else if (myPoiToMove) {
850  myPoiToMove = 0;
851  } else if (myJunctionToMove) {
852  // position is already up to date but we must register with myUndoList
855  }
856  myJunctionToMove = 0;
857  } else if (myEdgeToMove) {
858  // set cleaned shape
861  myUndoList);
862  myEdgeToMove = 0;
863  } else if (myAdditionalToMove) {
865  myAdditionalToMove = 0;
866  } else if (myMovingSelection) {
867  // positions and shapes are already up to date but we must register with myUndoList
869  // commit new positions of selected junctions
870  if (myOriginPostionOfMovedJunctions.size() > 0) {
871  myUndoList->p_begin("position of selected elements");
872  for (std::map<GNEJunction*, Position>::const_iterator i = myOriginPostionOfMovedJunctions.begin(); i != myOriginPostionOfMovedJunctions.end(); i++) {
873  i->first->commitGeometryMoving(i->second, myUndoList);
874  }
875  myUndoList->p_end();
877  }
878  myMovingSelection = false;
879  } else if (myAmInRectSelect) {
880  myAmInRectSelect = false;
881  // shift held down on mouse-down and mouse-up
882  if (((FXEvent*)eventData)->state & SHIFTMASK) {
883  if (makeCurrent()) {
884  Boundary b;
885  b.add(mySelCorner1);
886  b.add(mySelCorner2);
888  makeNonCurrent();
889  }
890  }
891  update();
892  }
893  return 1;
894 }
895 
896 
897 long GNEViewNet::onRightBtnPress(FXObject* obj, FXSelector sel, void* eventData) {
899  // during drawing of a polygon, right click removes the last created point
901  // update view
902  update();
903  return 1;
904  } else {
905  return GUISUMOAbstractView::onRightBtnPress(obj, sel, eventData);
906  }
907 }
908 
909 
910 long GNEViewNet::onRightBtnRelease(FXObject* obj, FXSelector sel, void* eventData) {
912  // during drawing of a polygon, right click removes the last created point
913  return 1;
914  } else {
915  return GUISUMOAbstractView::onRightBtnRelease(obj, sel, eventData);
916  }
917 }
918 
919 
920 long
921 GNEViewNet::onDoubleClicked(FXObject*, FXSelector, void*) {
922  // If current edit mode is INSPECT or ADDITIONAL
924  setFocus();
925  // interpret object under curser
926  if (makeCurrent()) {
927  int id = getObjectUnderCursor();
930  GNEAdditional* pointed_additional = dynamic_cast<GNEAdditional*>(pointed);
931  // If pointed element is an additional
932  if (pointed_additional != NULL) {
933  // If additional has a additional dialog, open it.
934  pointed_additional->openAdditionalDialog();
935  }
936  makeNonCurrent();
937  }
938  }
939  return 1;
940 }
941 
942 
943 long
944 GNEViewNet::onMouseMove(FXObject* obj, FXSelector sel, void* eventData) {
945  GUISUMOAbstractView::onMouseMove(obj, sel, eventData);
946  // in delete mode object under cursor must be checked in every mouse movement
947  if (myEditMode == GNE_MODE_DELETE) {
948  setFocus();
949  // show object information in delete frame
950  if (makeCurrent()) {
951  // obtain ac of globjectID
952  int glid = getObjectUnderCursor();
955  // Update current label of delete frame
957  }
958  } else {
959  if (myPolyToMove) {
960  // Calculate movement offset and move geometry of shape
962  if (myPolyToMove->isShapeBlocked()) {
964  } else {
966  }
967  } else if (myPoiToMove) {
968  // Calculate movement offset and move geometry of junction
971  } else if (myJunctionToMove) {
972  // check if one of their junctions neighboors is in the position objective
973  std::vector<GNEJunction*> junctionNeighbours = myJunctionToMove->getJunctionNeighbours();
974  for (auto i : junctionNeighbours) {
975  if (i->getPositionInView() == getPositionInformation()) {
976  return 0;
977  }
978  }
979  // Calculate movement offset and move geometry of junction
982  } else if (myEdgeToMove) {
984  double minimumMovingRadius = GNEJunction::BUBBLE_RADIUS / 2;
985  if ((newPosition.distanceTo2D(myEdgeToMove->getGNEJunctionSource()->getPositionInView()) >= minimumMovingRadius) &&
986  (newPosition.distanceTo2D(myEdgeToMove->getGNEJunctionDestiny()->getPositionInView()) >= minimumMovingRadius)) {
988  }
989  } else if (myAdditionalToMove && (myAdditionalToMove->isAdditionalBlocked() == false)) {
990  // If additional is placed over lane, move it across it
991  if (myAdditionalToMove->getLane()) {
992  double posOfMouseOverLane = myAdditionalToMove->getLane()->getShape().nearest_offset_to_point2D(getPositionInformation(), false);
993  myAdditionalToMove->moveGeometry(Position(posOfMouseOverLane - myMovingReference.x(), 0));
994  myMovingReference.set(posOfMouseOverLane, 0, 0);
995  } else {
996  // Calculate movement offset and move geometry of junction
999  }
1000  } else if (myMovingSelection) {
1001  Position moveTarget = getPositionInformation();
1003  myMovingOriginalPosition = moveTarget;
1004  } else if (myAmInRectSelect) {
1006  }
1007  }
1008 
1009  // update view
1010  update();
1011  return 1;
1012 }
1013 
1014 
1015 long
1016 GNEViewNet::onKeyPress(FXObject* o, FXSelector sel, void* eventData) {
1017  return GUISUMOAbstractView::onKeyPress(o, sel, eventData);
1018 }
1019 
1020 
1021 long
1022 GNEViewNet::onKeyRelease(FXObject* o, FXSelector sel, void* eventData) {
1023  if (myAmInRectSelect && ((((FXEvent*)eventData)->state & SHIFTMASK) == false)) {
1024  myAmInRectSelect = false;
1025  update();
1026  }
1027  return GUISUMOAbstractView::onKeyRelease(o, sel, eventData);
1028 }
1029 
1030 
1031 void
1032 GNEViewNet::abortOperation(bool clearSelection) {
1033  // steal focus from any text fields
1034  setFocus();
1035  if (myCreateEdgeSource != NULL) {
1036  // remove current created edge source
1038  myCreateEdgeSource = 0;
1039  } else if (myEditMode == GNE_MODE_SELECT) {
1040  myAmInRectSelect = false;
1041  if (clearSelection) {
1042  gSelected.clear();
1043  }
1044  } else if (myEditMode == GNE_MODE_CONNECT) {
1046  } else if (myEditMode == GNE_MODE_TLS) {
1048  } else if (myEditMode == GNE_MODE_MOVE) {
1050  } else if (myEditMode == GNE_MODE_POLYGON) {
1051  // abort current drawing
1053  }
1054  myUndoList->p_abort();
1055 }
1056 
1057 
1058 void
1061  setStatusBarText("Cannot delete in this mode");
1062  } else {
1063  myUndoList->p_begin("delete selection");
1072  myUndoList->p_end();
1073  }
1074 }
1075 
1076 
1077 void
1079  if (myEditMode == GNE_MODE_CONNECT) {
1080  myViewParent->getConnectorFrame()->onCmdOK(0, 0, 0);
1081  } else if (myEditMode == GNE_MODE_TLS) {
1082  myViewParent->getTLSEditorFrame()->onCmdOK(0, 0, 0);
1083  } else if ((myEditMode == GNE_MODE_MOVE) && (myEditJunctionShapePoly != 0)) {
1084  // save edited junction's shape
1085  if (myEditJunctionShapePoly != 0) {
1086  myUndoList->p_begin("custom junction shape");
1088  myUndoList->p_end();
1090  update();
1091  }
1092  } else if (myEditMode == GNE_MODE_POLYGON) {
1094  // stop current drawing
1096  } else {
1097  // start drawing
1099  }
1100  }
1101 }
1102 
1103 
1104 void
1106  // if there is a visible frame, set focus over it. In other case, set focus over ViewNet
1107  if (myCurrentFrame != NULL) {
1109  } else {
1110  setFocus();
1111  }
1112 }
1113 
1114 
1115 void
1117  switch (selid) {
1120  break;
1121  case MID_GNE_MODE_MOVE:
1123  break;
1124  case MID_GNE_MODE_DELETE:
1126  break;
1127  case MID_GNE_MODE_INSPECT:
1129  break;
1130  case MID_GNE_MODE_SELECT:
1132  break;
1133  case MID_GNE_MODE_CONNECT:
1135  break;
1136  case MID_GNE_MODE_TLS:
1138  break;
1141  break;
1142  case MID_GNE_MODE_CROSSING:
1144  break;
1145  case MID_GNE_MODE_POLYGON:
1147  break;
1148  default:
1149  throw ProcessError("invalid edit mode called by hotkey");
1150  break;
1151  }
1152 }
1153 
1154 
1155 void
1158 }
1159 
1160 
1163  return myViewParent;
1164 }
1165 
1166 
1167 GNENet*
1169  return myNet;
1170 }
1171 
1172 
1173 GNEUndoList*
1175  return myUndoList;
1176 }
1177 
1178 
1179 EditMode
1181  return myEditMode;
1182 }
1183 
1184 
1185 bool
1188 }
1189 
1190 
1191 GNEJunction*
1193  GNEJunction* junction = 0;
1194  if (makeCurrent()) {
1195  int id = getObjectAtPosition(myPopupSpot);
1198  if (pointed) {
1199  switch (pointed->getType()) {
1200  case GLO_JUNCTION:
1201  junction = (GNEJunction*)pointed;
1202  break;
1203  default:
1204  break;
1205  }
1206  }
1207  }
1208  return junction;
1209 }
1210 
1211 
1212 GNEEdge*
1214  GNEEdge* edge = 0;
1215  if (makeCurrent()) {
1216  int id = getObjectAtPosition(myPopupSpot);
1219  if (pointed) {
1220  switch (pointed->getType()) {
1221  case GLO_EDGE:
1222  edge = (GNEEdge*)pointed;
1223  break;
1224  case GLO_LANE:
1225  edge = &(((GNELane*)pointed)->getParentEdge());
1226  break;
1227  default:
1228  break;
1229  }
1230  }
1231  }
1232  return edge;
1233 }
1234 
1235 
1236 GNELane*
1238  GNELane* lane = 0;
1239  if (makeCurrent()) {
1240  int id = getObjectAtPosition(myPopupSpot);
1243  if (pointed) {
1244  if (pointed->getType() == GLO_LANE) {
1245  lane = (GNELane*)pointed;
1246  }
1247  }
1248  }
1249  return lane;
1250 }
1251 
1252 
1253 std::set<GNEEdge*>
1255  std::set<GNEEdge*> result;
1256  if (makeCurrent()) {
1257  const std::vector<GUIGlID> ids = getObjectsAtPosition(myPopupSpot, 1.0);
1258  for (auto it : ids) {
1261  if (pointed) {
1262  switch (pointed->getType()) {
1263  case GLO_EDGE:
1264  result.insert((GNEEdge*)pointed);
1265  break;
1266  case GLO_LANE:
1267  result.insert(&(((GNELane*)pointed)->getParentEdge()));
1268  break;
1269  default:
1270  break;
1271  }
1272  }
1273  }
1274  }
1275  return result;
1276 }
1277 
1278 
1279 GNEPoly*
1281  if (makeCurrent()) {
1282  int id = getObjectAtPosition(pos);
1285  if (pointed && (pointed->getType() == GLO_POLYGON)) {
1286  return dynamic_cast<GNEPoly*>(pointed);
1287  }
1288  }
1289  return 0;
1290 }
1291 
1292 
1293 long
1294 GNEViewNet::onCmdSetModeCreateEdge(FXObject*, FXSelector, void*) {
1296  return 1;
1297 }
1298 
1299 
1300 long
1301 GNEViewNet::onCmdSetModeMove(FXObject*, FXSelector, void*) {
1303  return 1;
1304 }
1305 
1306 
1307 long
1308 GNEViewNet::onCmdSetModeDelete(FXObject*, FXSelector, void*) {
1310  return 1;
1311 }
1312 
1313 
1314 long
1315 GNEViewNet::onCmdSetModeInspect(FXObject*, FXSelector, void*) {
1317  return 1;
1318 }
1319 
1320 
1321 long
1322 GNEViewNet::onCmdSetModeSelect(FXObject*, FXSelector, void*) {
1324  return 1;
1325 }
1326 
1327 
1328 long
1329 GNEViewNet::onCmdSetModeConnect(FXObject*, FXSelector, void*) {
1331  return 1;
1332 }
1333 
1334 
1335 long
1336 GNEViewNet::onCmdSetModeTLS(FXObject*, FXSelector, void*) {
1338  return 1;
1339 }
1340 
1341 
1342 long
1343 GNEViewNet::onCmdSetModeAdditional(FXObject*, FXSelector, void*) {
1345  return 1;
1346 }
1347 
1348 
1349 long
1350 GNEViewNet::onCmdSetModeCrossing(FXObject*, FXSelector, void*) {
1352  return 1;
1353 }
1354 
1355 
1356 long
1357 GNEViewNet::onCmdSetModePolygon(FXObject*, FXSelector, void*) {
1359  return 1;
1360 }
1361 
1362 
1363 long
1364 GNEViewNet::onCmdSplitEdge(FXObject*, FXSelector, void*) {
1366  if (edge != 0) {
1368  }
1369  return 1;
1370 }
1371 
1372 
1373 long
1374 GNEViewNet::onCmdSplitEdgeBidi(FXObject*, FXSelector, void*) {
1375  std::set<GNEEdge*> edges = getEdgesAtCursorPosition(myPopupSpot);
1376  if (edges.size() != 0) {
1377  myNet->splitEdgesBidi(edges, (*edges.begin())->getSplitPos(myPopupSpot), myUndoList);
1378  }
1379  return 1;
1380 }
1381 
1382 
1383 long
1384 GNEViewNet::onCmdReverseEdge(FXObject*, FXSelector, void*) {
1386  if (edge != 0) {
1387  myNet->reverseEdge(edge, myUndoList);
1388  }
1389  return 1;
1390 }
1391 
1392 
1393 long
1394 GNEViewNet::onCmdAddReversedEdge(FXObject*, FXSelector, void*) {
1396  if (edge != 0) {
1398  }
1399  return 1;
1400 }
1401 
1402 
1403 long
1404 GNEViewNet::onCmdSetEdgeEndpoint(FXObject*, FXSelector, void*) {
1406  if (edge != 0) {
1408  }
1409  return 1;
1410 }
1411 
1412 
1413 long
1414 GNEViewNet::onCmdResetEdgeEndpoint(FXObject*, FXSelector, void*) {
1416  if (edge != 0) {
1418  }
1419  return 1;
1420 }
1421 
1422 
1423 long
1424 GNEViewNet::onCmdStraightenEdges(FXObject*, FXSelector, void*) {
1426  if (edge != 0) {
1427  if (gSelected.isSelected(GLO_EDGE, edge->getGlID())) {
1428  myUndoList->p_begin("straighten selected " + toString(SUMO_TAG_EDGE) + "s");
1429  std::vector<GNEEdge*> edges = myNet->retrieveEdges(true);
1430  for (auto it : edges) {
1431  it->setAttribute(SUMO_ATTR_SHAPE, "", myUndoList);
1432  }
1433  myUndoList->p_end();
1434  } else {
1435  myUndoList->p_begin("straighten " + toString(SUMO_TAG_EDGE));
1437  myUndoList->p_end();
1438  }
1439  }
1440  return 1;
1441 }
1442 
1443 
1444 long
1445 GNEViewNet::onCmdSimplifyShape(FXObject*, FXSelector, void*) {
1446  if (myEditJunctionShapePoly != 0) {
1448  update();
1449  } else {
1450  GNEPoly* polygonUnderMouse = getPolygonAtCursorPosition(myPopupSpot);
1451  if (polygonUnderMouse) {
1452  polygonUnderMouse->simplifyShape();
1453  }
1454  }
1455  return 1;
1456 }
1457 
1458 
1459 long
1460 GNEViewNet::onCmdDeleteGeometryPoint(FXObject*, FXSelector, void*) {
1461  if (myEditJunctionShapePoly != 0) {
1463  update();
1464  } else {
1465  GNEPoly* polygonUnderMouse = getPolygonAtCursorPosition(myPopupSpot);
1466  if (polygonUnderMouse) {
1467  polygonUnderMouse->deleteGeometryNear(myPopupSpot);
1468  }
1469  }
1470  return 1;
1471 }
1472 
1473 
1474 long
1475 GNEViewNet::onCmdClosePolygon(FXObject*, FXSelector, void*) {
1476  if (myEditJunctionShapePoly != 0) {
1478  update();
1479  } else {
1480  GNEPoly* polygonUnderMouse = getPolygonAtCursorPosition(myPopupSpot);
1481  if (polygonUnderMouse) {
1482  polygonUnderMouse->closePolygon();
1483  }
1484  }
1485  return 1;
1486 }
1487 
1488 
1489 long
1490 GNEViewNet::onCmdOpenPolygon(FXObject*, FXSelector, void*) {
1491  if (myEditJunctionShapePoly != 0) {
1493  update();
1494  } else {
1495  GNEPoly* polygonUnderMouse = getPolygonAtCursorPosition(myPopupSpot);
1496  if (polygonUnderMouse) {
1497  polygonUnderMouse->openPolygon();
1498  }
1499  }
1500  return 1;
1501 }
1502 
1503 
1504 long
1505 GNEViewNet::onCmdSetFirstGeometryPoint(FXObject*, FXSelector, void*) {
1506  if (myEditJunctionShapePoly != 0) {
1508  update();
1509  } else {
1510  GNEPoly* polygonUnderMouse = getPolygonAtCursorPosition(myPopupSpot);
1511  if (polygonUnderMouse) {
1512  polygonUnderMouse->changeFirstGeometryPoint(polygonUnderMouse->getVertexIndex(myPopupSpot, false));
1513  }
1514  }
1515  return 1;
1516 }
1517 
1518 
1519 long
1520 GNEViewNet::onCmdDuplicateLane(FXObject*, FXSelector, void*) {
1522  if (lane != 0) {
1523  if (gSelected.isSelected(GLO_LANE, lane->getGlID())) {
1524  myUndoList->p_begin("duplicate selected " + toString(SUMO_TAG_LANE) + "s");
1525  std::vector<GNELane*> lanes = myNet->retrieveLanes(true);
1526  for (auto it : lanes) {
1528  }
1529  myUndoList->p_end();
1530  } else {
1531  myUndoList->p_begin("duplicate " + toString(SUMO_TAG_LANE));
1532  myNet->duplicateLane(lane, myUndoList);
1533  myUndoList->p_end();
1534  }
1535  }
1536  return 1;
1537 }
1538 
1539 
1540 long
1541 GNEViewNet::onCmdRestrictLaneSidewalk(FXObject*, FXSelector, void*) {
1542  return restrictLane(SVC_PEDESTRIAN);
1543 }
1544 
1545 
1546 long
1547 GNEViewNet::onCmdRestrictLaneBikelane(FXObject*, FXSelector, void*) {
1548  return restrictLane(SVC_BICYCLE);
1549 }
1550 
1551 
1552 long
1553 GNEViewNet::onCmdRestrictLaneBuslane(FXObject*, FXSelector, void*) {
1554  return restrictLane(SVC_BUS);
1555 }
1556 
1557 
1558 long
1559 GNEViewNet::onCmdAddRestrictedLaneSidewalk(FXObject*, FXSelector, void*) {
1561 }
1562 
1563 
1564 long
1565 GNEViewNet::onCmdAddRestrictedLaneBikelane(FXObject*, FXSelector, void*) {
1567 }
1568 
1569 
1570 long
1571 GNEViewNet::onCmdAddRestrictedLaneBuslane(FXObject*, FXSelector, void*) {
1572  return addRestrictedLane(SVC_BUS);
1573 }
1574 
1575 
1576 long
1577 GNEViewNet::onCmdRemoveRestrictedLaneSidewalk(FXObject*, FXSelector, void*) {
1579 }
1580 
1581 
1582 long
1583 GNEViewNet::onCmdRemoveRestrictedLaneBikelane(FXObject*, FXSelector, void*) {
1585 }
1586 
1587 
1588 long
1589 GNEViewNet::onCmdRemoveRestrictedLaneBuslane(FXObject*, FXSelector, void*) {
1590  return removeRestrictedLane(SVC_BUS);
1591 }
1592 
1593 
1594 bool
1597  if (lane != 0) {
1598  // Get selected lanes
1599  std::vector<GNELane*> lanes = myNet->retrieveLanes(true); ;
1600  // Declare map of edges and lanes
1601  std::map<GNEEdge*, GNELane*> mapOfEdgesAndLanes;
1602  // Iterate over selected lanes
1603  for (auto i : lanes) {
1604  mapOfEdgesAndLanes[myNet->retrieveEdge(i->getParentEdge().getID())] = i;
1605  }
1606  // Throw warning dialog if there hare multiple lanes selected in the same edge
1607  if (mapOfEdgesAndLanes.size() != lanes.size()) {
1608  FXMessageBox::information(getApp(), MBOX_OK,
1609  "Multiple lane in the same edge selected", "%s",
1610  ("There are selected lanes that belong to the same edge.\n Only one lane per edge will be restricted for " + toString(vclass) + ".").c_str());
1611  }
1612  // If we handeln a set of lanes
1613  if (mapOfEdgesAndLanes.size() > 0) {
1614  // declare counter for number of Sidewalks
1615  int counter = 0;
1616  // iterate over selected lanes
1617  for (auto i : mapOfEdgesAndLanes) {
1618  if (i.first->hasRestrictedLane(vclass)) {
1619  counter++;
1620  }
1621  }
1622  // if all edges parent own a Sidewalk, stop function
1623  if (counter == (int)mapOfEdgesAndLanes.size()) {
1624  FXMessageBox::information(getApp(), MBOX_OK,
1625  ("Set vclass for " + toString(vclass) + " to selected lanes").c_str(), "%s",
1626  ("All lanes own already another lane in the same edge with a restriction for " + toString(vclass)).c_str());
1627  return 0;
1628  } else {
1629  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
1630  WRITE_WARNING("Opening FXMessageBox 'restrict lanes'");
1631  }
1632  // Ask confirmation to user
1633  FXuint answer = FXMessageBox::question(getApp(), MBOX_YES_NO,
1634  ("Set vclass for " + toString(vclass) + " to selected lanes").c_str(), "%s",
1635  (toString(mapOfEdgesAndLanes.size() - counter) + " lanes will be restricted for " + toString(vclass) + ". continue?").c_str());
1636  if (answer != 1) { //1:yes, 2:no, 4:esc
1637  // write warning if netedit is running in testing mode
1638  if ((answer == 2) && (OptionsCont::getOptions().getBool("gui-testing-debug"))) {
1639  WRITE_WARNING("Closed FXMessageBox 'restrict lanes' with 'No'");
1640  } else if ((answer == 4) && (OptionsCont::getOptions().getBool("gui-testing-debug"))) {
1641  WRITE_WARNING("Closed FXMessageBox 'restrict lanes' with 'ESC'");
1642  }
1643  return 0;
1644  } else {
1645  // write warning if netedit is running in testing mode
1646  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
1647  WRITE_WARNING("Closed FXMessageBox 'restrict lanes' with 'Yes'");
1648  }
1649  }
1650  }
1651  // begin undo operation
1652  myUndoList->p_begin("restrict lanes to " + toString(vclass));
1653  // iterate over selected lanes
1654  for (std::map<GNEEdge*, GNELane*>::iterator i = mapOfEdgesAndLanes.begin(); i != mapOfEdgesAndLanes.end(); i++) {
1655  // Transform lane to Sidewalk
1656  myNet->restrictLane(vclass, i->second, myUndoList);
1657  }
1658  // end undo operation
1659  myUndoList->p_end();
1660  } else {
1661  // If only have a single lane, start undo/redo operation
1662  myUndoList->p_begin("restrict lane to " + toString(vclass));
1663  // Transform lane to Sidewalk
1664  myNet->restrictLane(vclass, lane, myUndoList);
1665  // end undo operation
1666  myUndoList->p_end();
1667  }
1668  }
1669  return 1;
1670 }
1671 
1672 
1673 bool
1676  if (lane != 0) {
1677  // Get selected edges
1678  std::vector<GNEEdge*> edges = myNet->retrieveEdges(true);
1679  // get selected lanes
1680  std::vector<GNELane*> lanes = myNet->retrieveLanes(true);
1681  // Declare set of edges
1682  std::set<GNEEdge*> setOfEdges;
1683  // Fill set of edges with vector of edges
1684  for (auto i : edges) {
1685  setOfEdges.insert(i);
1686  }
1687  // iterate over selected lanes
1688  for (auto it : lanes) {
1689  // Insert pointer to edge into set of edges (To avoid duplicates)
1690  setOfEdges.insert(myNet->retrieveEdge(it->getParentEdge().getID()));
1691  }
1692  // If we handeln a set of edges
1693  if (setOfEdges.size() > 0) {
1694  // declare counter for number of restrictions
1695  int counter = 0;
1696  // iterate over set of edges
1697  for (std::set<GNEEdge*>::iterator it = setOfEdges.begin(); it != setOfEdges.end(); it++) {
1698  // update counter if edge has already a restricted lane of type "vclass"
1699  if ((*it)->hasRestrictedLane(vclass)) {
1700  counter++;
1701  }
1702  }
1703  // if all lanes own a Sidewalk, stop function
1704  if (counter == (int)setOfEdges.size()) {
1705  FXMessageBox::information(getApp(), MBOX_OK,
1706  ("Add vclass for" + toString(vclass) + " to selected lanes").c_str(), "%s",
1707  ("All lanes own already another lane in the same edge with a restriction for " + toString(vclass)).c_str());
1708  return 0;
1709  } else {
1710  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
1711  WRITE_WARNING("Opening FXMessageBox 'restrict lanes'");
1712  }
1713  // Ask confirmation to user
1714  FXuint answer = FXMessageBox::question(getApp(), MBOX_YES_NO,
1715  ("Add vclass for " + toString(vclass) + " to selected lanes").c_str(), "%s",
1716  (toString(setOfEdges.size() - counter) + " restrictions for " + toString(vclass) + " will be added. continue?").c_str());
1717  if (answer != 1) { //1:yes, 2:no, 4:esc
1718  // write warning if netedit is running in testing mode
1719  if ((answer == 2) && (OptionsCont::getOptions().getBool("gui-testing-debug"))) {
1720  WRITE_WARNING("Closed FXMessageBox 'restrict lanes' with 'No'");
1721  } else if ((answer == 4) && (OptionsCont::getOptions().getBool("gui-testing-debug"))) {
1722  WRITE_WARNING("Closed FXMessageBox 'restrict lanes' with 'ESC'");
1723  }
1724  return 0;
1725  } else {
1726  // write warning if netedit is running in testing mode
1727  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
1728  WRITE_WARNING("Closed FXMessageBox 'restrict lanes' with 'Yes'");
1729  }
1730  }
1731  }
1732  // begin undo operation
1733  myUndoList->p_begin("Add restrictions for " + toString(vclass));
1734  // iterate over set of edges
1735  for (std::set<GNEEdge*>::iterator it = setOfEdges.begin(); it != setOfEdges.end(); it++) {
1736  // add Sidewalk
1737  myNet->addSRestrictedLane(vclass, *(*it), myUndoList);
1738  }
1739  // end undo operation
1740  myUndoList->p_end();
1741  } else {
1742  // If only have a single lane, start undo/redo operation
1743  myUndoList->p_begin("Add vclass for " + toString(vclass));
1744  // Add Sidewalk
1745  myNet->addSRestrictedLane(vclass, lane->getParentEdge(), myUndoList);
1746  // end undo/redo operation
1747  myUndoList->p_end();
1748  }
1749  }
1750  return 1;
1751 }
1752 
1753 
1754 bool
1757  if (lane != 0) {
1758  // Get selected edges
1759  std::vector<GNEEdge*> edges = myNet->retrieveEdges(true);
1760  // get selected lanes
1761  std::vector<GNELane*> lanes = myNet->retrieveLanes(true);
1762  // Declare set of edges
1763  std::set<GNEEdge*> setOfEdges;
1764  // Fill set of edges with vector of edges
1765  for (auto i : edges) {
1766  setOfEdges.insert(i);
1767  }
1768  // iterate over selected lanes
1769  for (auto it : lanes) {
1770  // Insert pointer to edge into set of edges (To avoid duplicates)
1771  setOfEdges.insert(myNet->retrieveEdge(it->getParentEdge().getID()));
1772  }
1773  // If we handeln a set of edges
1774  if (setOfEdges.size() > 0) {
1775  // declare counter for number of restrictions
1776  int counter = 0;
1777  // iterate over set of edges
1778  for (std::set<GNEEdge*>::iterator it = setOfEdges.begin(); it != setOfEdges.end(); it++) {
1779  // update counter if edge has already a restricted lane of type "vclass"
1780  if ((*it)->hasRestrictedLane(vclass)) {
1781  counter++;
1782  }
1783  }
1784  // if all lanes don't own a Sidewalk, stop function
1785  if (counter == 0) {
1786  FXMessageBox::information(getApp(), MBOX_OK,
1787  ("Remove vclass for " + toString(vclass) + " to selected lanes").c_str(), "%s",
1788  ("Selected lanes and edges haven't a restriction for " + toString(vclass)).c_str());
1789  return 0;
1790  } else {
1791  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
1792  WRITE_WARNING("Opening FXMessageBox 'restrict lanes'");
1793  }
1794  // Ask confirmation to user
1795  FXuint answer = FXMessageBox::question(getApp(), MBOX_YES_NO,
1796  ("Remove vclass for " + toString(vclass) + " to selected lanes").c_str(), "%s",
1797  (toString(counter) + " restrictions for " + toString(vclass) + " will be removed. continue?").c_str());
1798  if (answer != 1) { //1:yes, 2:no, 4:esc
1799  // write warning if netedit is running in testing mode
1800  if ((answer == 2) && (OptionsCont::getOptions().getBool("gui-testing-debug"))) {
1801  WRITE_WARNING("Closed FXMessageBox 'restrict lanes' with 'No'");
1802  } else if ((answer == 4) && (OptionsCont::getOptions().getBool("gui-testing-debug"))) {
1803  WRITE_WARNING("Closed FXMessageBox 'restrict lanes' with 'ESC'");
1804  }
1805  return 0;
1806  } else {
1807  // write warning if netedit is running in testing mode
1808  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
1809  WRITE_WARNING("Closed FXMessageBox 'restrict lanes' with 'Yes'");
1810  }
1811  }
1812  }
1813  // begin undo operation
1814  myUndoList->p_begin("Remove restrictions for " + toString(vclass));
1815  // iterate over set of edges
1816  for (std::set<GNEEdge*>::iterator it = setOfEdges.begin(); it != setOfEdges.end(); it++) {
1817  // add Sidewalk
1818  myNet->removeRestrictedLane(vclass, *(*it), myUndoList);
1819  }
1820  // end undo operation
1821  myUndoList->p_end();
1822  } else {
1823  // If only have a single lane, start undo/redo operation
1824  myUndoList->p_begin("Remove vclass for " + toString(vclass));
1825  // Remove Sidewalk
1827  // end undo/redo operation
1828  myUndoList->p_end();
1829  }
1830  }
1831  return 1;
1832 }
1833 
1834 
1835 void
1836 GNEViewNet::processClick(FXEvent* e, void* eventData) {
1837  // process click
1838  destroyPopup();
1839  setFocus();
1840  myChanger->onLeftBtnPress(eventData);
1841  grab();
1842  // Check there are double click
1843  if (e->click_count == 2) {
1844  handle(this, FXSEL(SEL_DOUBLECLICKED, 0), eventData);
1845  }
1846 }
1847 
1848 long
1849 GNEViewNet::onCmdRevertRestriction(FXObject*, FXSelector, void*) {
1851  if (lane != 0) {
1852  // Declare vector of lanes
1853  std::vector<GNELane*> lanes;
1854  // Check if we have a set of selected edges or lanes
1856  // Get selected edgeds
1857  std::vector<GNEEdge*> edges = myNet->retrieveEdges(true);
1858  // fill vector of lanes with the lanes of selected edges
1859  for (auto i : edges) {
1860  for (auto j : i->getLanes()) {
1861  lanes.push_back(j);
1862  }
1863  }
1864  } else if (gSelected.isSelected(GLO_LANE, lane->getGlID())) {
1865  // get selected lanes
1866  lanes = myNet->retrieveLanes(true);
1867  }
1868  // If we handeln a set of lanes
1869  if (lanes.size() > 0) {
1870  // declare counter for number of Sidewalks
1871  int counter = 0;
1872  // iterate over selected lanes
1873  for (auto it : lanes) {
1874  if ((it->isRestricted(SVC_PEDESTRIAN)) || (it->isRestricted(SVC_BICYCLE)) || (it->isRestricted(SVC_BUS))) {
1875  counter++;
1876  }
1877  }
1878  // if none of selected lanes has a transformation, stop
1879  if (counter == 0) {
1880  FXMessageBox::information(getApp(), MBOX_OK,
1881  "Revert restriction", "%s",
1882  "None of selected lanes has a previous restriction");
1883  return 0;
1884  } else {
1885  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
1886  WRITE_WARNING("Opening FXMessageBox 'restrict lanes'");
1887  }
1888  // Ask confirmation to user
1889  FXuint answer = FXMessageBox::question(getApp(), MBOX_YES_NO,
1890  "Revert restriction", "%s",
1891  (toString(counter) + " restrictions of lanes lanes will be reverted. continue?").c_str());
1892  if (answer != 1) { //1:yes, 2:no, 4:esc
1893  // write warning if netedit is running in testing mode
1894  if ((answer == 2) && (OptionsCont::getOptions().getBool("gui-testing-debug"))) {
1895  WRITE_WARNING("Closed FXMessageBox 'restrict lanes' with 'No'");
1896  } else if ((answer == 4) && (OptionsCont::getOptions().getBool("gui-testing-debug"))) {
1897  WRITE_WARNING("Closed FXMessageBox 'restrict lanes' with 'ESC'");
1898  }
1899  return 0;
1900  } else {
1901  // write warning if netedit is running in testing mode
1902  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
1903  WRITE_WARNING("Closed FXMessageBox 'restrict lanes' with 'Yes'");
1904  }
1905  }
1906  }
1907  // begin undo operation
1908  myUndoList->p_begin("revert restrictions");
1909  // iterate over selected lanes
1910  for (auto it : lanes) {
1911  // revert transformation
1913  }
1914  // end undo operation
1915  myUndoList->p_end();
1916  } else {
1917  // If only have a single lane, start undo/redo operation
1918  myUndoList->p_begin("revert restriction");
1919  // revert transformation
1921  // end undo operation
1922  myUndoList->p_end();
1923  }
1924  }
1925  return 1;
1926 }
1927 
1928 
1929 long
1930 GNEViewNet::onCmdEditJunctionShape(FXObject*, FXSelector, void*) {
1931  // Obtain junction under mouse
1933  if (junction) {
1934  startEditShapeJunction(junction);
1935  }
1936  return 1;
1937 }
1938 
1939 
1940 long
1941 GNEViewNet::onCmdReplaceJunction(FXObject*, FXSelector, void*) {
1943  if (junction != 0) {
1945  update();
1946  }
1947  return 1;
1948 }
1949 
1950 
1951 long
1952 GNEViewNet::onCmdToogleShowConnection(FXObject*, FXSelector, void*) {
1953  if (!myShowConnections) {
1955  myShowConnections = true;
1956  }
1958  // Update viewnNet to show/hide conections
1959  update();
1960  // Hide/show connections requiere recompute
1961  getNet()->requireRecompute();
1962  return 1;
1963 }
1964 
1965 
1966 long
1967 GNEViewNet::onCmdToogleSelectEdges(FXObject*, FXSelector, void*) {
1968  if (myMenuCheckSelectEdges->getCheck()) {
1969  mySelectEdges = true;
1970  } else {
1971  mySelectEdges = false;
1972  }
1973  return 1;
1974 }
1975 
1976 
1977 long
1978 GNEViewNet::onCmdToogleShowBubbles(FXObject*, FXSelector, void*) {
1979  // Update view net Shapes
1980  update();
1981  return 1;
1982 }
1983 
1984 
1985 long
1986 GNEViewNet::onCmdShowGrid(FXObject*, FXSelector, void*) {
1987  // show or hidde grid depending of myMenuCheckShowGrid
1988  if (myMenuCheckShowGrid->getCheck()) {
1990  } else {
1992  }
1993  update();
1994  return 1;
1995 }
1996 
1997 
1998 // ===========================================================================
1999 // private
2000 // ===========================================================================
2001 
2002 void
2004  setStatusBarText("");
2005  abortOperation(false);
2006  // stop editing of shape's junction
2008 
2009  if (mode == myEditMode) {
2010  setStatusBarText("Mode already selected");
2011  if (myCurrentFrame != NULL) {
2013  }
2014  } else {
2015  myEditMode = mode;
2016  switch (mode) {
2017  case GNE_MODE_CONNECT:
2018  case GNE_MODE_TLS:
2019  // modes which depend on computed data
2021  break;
2022  default:
2023  break;
2024  }
2026  }
2027 }
2028 
2029 
2030 void
2032  // initialize mappings
2033  myEditModeNames.insert("(e) Create Edge", GNE_MODE_CREATE_EDGE);
2034  myEditModeNames.insert("(m) Move", GNE_MODE_MOVE);
2035  myEditModeNames.insert("(d) Delete", GNE_MODE_DELETE);
2036  myEditModeNames.insert("(i) Inspect", GNE_MODE_INSPECT);
2037  myEditModeNames.insert("(s) Select", GNE_MODE_SELECT);
2038  myEditModeNames.insert("(c) Connect", GNE_MODE_CONNECT);
2039  myEditModeNames.insert("(t) Traffic Lights", GNE_MODE_TLS);
2040  myEditModeNames.insert("(a) Additionals", GNE_MODE_ADDITIONAL);
2041  myEditModeNames.insert("(r) Crossings", GNE_MODE_CROSSING);
2042  myEditModeNames.insert("(p) Polygons", GNE_MODE_POLYGON);
2043 
2044  // initialize buttons for modes
2045  myEditModeCreateEdge = new MFXCheckableButton(false, myToolbar, "\tset create edge mode\tMode for creating junction and edges.",
2047  myEditModeMove = new MFXCheckableButton(false, myToolbar, "\tset move mode\tMode for move elements.",
2049  myEditModeDelete = new MFXCheckableButton(false, myToolbar, "\tset delete mode\tMode for delete elements.",
2051  myEditModeInspect = new MFXCheckableButton(false, myToolbar, "\tset inspect mode\tMode for inspect elements and change their attributes.",
2053  myEditModeSelect = new MFXCheckableButton(false, myToolbar, "\tset select mode\tMode for select elements.",
2055  myEditModeConnection = new MFXCheckableButton(false, myToolbar, "\tset connection mode\tMode for edit connections between lanes.",
2057  myEditModeTrafficLight = new MFXCheckableButton(false, myToolbar, "\tset traffic light mode\tMode for edit traffic lights over junctions.",
2059  myEditModeAdditional = new MFXCheckableButton(false, myToolbar, "\tset additional mode\tMode for adding additional elements.",
2061  myEditModeCrossing = new MFXCheckableButton(false, myToolbar, "\tset crossing mode\tMode for creating crossings between edges.",
2063  myEditModePolygon = new MFXCheckableButton(false, myToolbar, "\tset polygon mode\tMode for creating polygons and POIs.",
2065 
2066  // @ToDo add here new FXToolBarGrip(myNavigationToolBar, NULL, 0, GUIDesignToolbarGrip);
2067 
2068  // initialize mode specific controls
2069  myChainCreateEdge = new FXMenuCheck(myToolbar, ("chain\t\tCreate consecutive " + toString(SUMO_TAG_EDGE) + "s with a single click (hit ESC to cancel chain).").c_str(), this, 0);
2070  myChainCreateEdge->setCheck(false);
2071 
2072  myAutoCreateOppositeEdge = new FXMenuCheck(myToolbar, ("two-way\t\tAutomatically create an " + toString(SUMO_TAG_EDGE) + " in the opposite direction").c_str(), this, 0);
2073  myAutoCreateOppositeEdge->setCheck(false);
2074 
2075  myMenuCheckSelectEdges = new FXMenuCheck(myToolbar, ("select edges\t\tToggle whether clicking should select " + toString(SUMO_TAG_EDGE) + "s or " + toString(SUMO_TAG_LANE) + "s").c_str(), this, MID_GNE_VIEWNET_SELECT_EDGES);
2076  myMenuCheckSelectEdges->setCheck(true);
2077 
2078  myMenuCheckShowConnections = new FXMenuCheck(myToolbar, ("show " + toString(SUMO_TAG_CONNECTION) + "s\t\tToggle show " + toString(SUMO_TAG_CONNECTION) + "s over " + toString(SUMO_TAG_JUNCTION) + "s").c_str(), this, MID_GNE_VIEWNET_SHOW_CONNECTIONS);
2080 
2081  myMenuCheckExtendToEdgeNodes = new FXMenuCheck(myToolbar, ("auto-select " + toString(SUMO_TAG_JUNCTION) + "s\t\tToggle whether selecting multiple " + toString(SUMO_TAG_EDGE) + "s should automatically select their " + toString(SUMO_TAG_JUNCTION) + "s").c_str(), this, 0);
2082 
2083  myMenuCheckWarnAboutMerge = new FXMenuCheck(myToolbar, ("ask for merge\t\tAsk for confirmation before merging " + toString(SUMO_TAG_JUNCTION) + ".").c_str(), this, 0);
2084  myMenuCheckWarnAboutMerge->setCheck(true);
2085 
2086  myMenuCheckShowBubbleOverJunction = new FXMenuCheck(myToolbar, ("Show bubbles over " + toString(SUMO_TAG_JUNCTION) + "s \t\tShow bubbles over " + toString(SUMO_TAG_JUNCTION) + "'s shapes.").c_str(), this, MID_GNE_VIEWNET_SHOW_BUBBLES);
2087  myMenuCheckShowBubbleOverJunction->setCheck(false);
2088 
2089  myMenuCheckChangeAllPhases = new FXMenuCheck(myToolbar, ("apply change to all phases\t\tToggle whether clicking should apply state changes to all phases of the current " + toString(SUMO_TAG_TRAFFIC_LIGHT) + " plan").c_str(), this, 0);
2090  myMenuCheckChangeAllPhases->setCheck(false);
2091 
2092  myMenuCheckShowGrid = new FXMenuCheck(myToolbar, "show grid\t\tshow grid with size defined in visualization options", this, MID_GNE_VIEWNET_SHOW_GRID);
2093  myMenuCheckShowGrid->setCheck(false);
2094 }
2095 
2096 
2097 void
2099  // hide grid
2101  // hide all controls (checkboxs)
2102  myChainCreateEdge->hide();
2103  myAutoCreateOppositeEdge->hide();
2104  myMenuCheckSelectEdges->hide();
2108  myMenuCheckWarnAboutMerge->hide();
2110  myMenuCheckShowGrid->hide();
2111  // unckeck all edit modes
2113  myEditModeMove->setChecked(false);
2114  myEditModeDelete->setChecked(false);
2115  myEditModeInspect->setChecked(false);
2116  myEditModeSelect->setChecked(false);
2121  myEditModePolygon->setChecked(false);
2123  // enable selected controls
2124  switch (myEditMode) {
2125  case GNE_MODE_CREATE_EDGE:
2126  myChainCreateEdge->show();
2127  myAutoCreateOppositeEdge->show();
2129  myMenuCheckShowGrid->show();
2130  break;
2131  case GNE_MODE_MOVE:
2132  myMenuCheckWarnAboutMerge->show();
2134  myEditModeMove->setChecked(true);
2135  myMenuCheckShowGrid->show();
2136  break;
2137  case GNE_MODE_DELETE:
2142  myMenuCheckSelectEdges->show();
2144  break;
2145  case GNE_MODE_INSPECT:
2149  myMenuCheckSelectEdges->show();
2152  break;
2153  case GNE_MODE_SELECT:
2157  myMenuCheckSelectEdges->show();
2161  break;
2162  case GNE_MODE_CONNECT:
2167  break;
2168  case GNE_MODE_TLS:
2174  break;
2175  case GNE_MODE_ADDITIONAL:
2180  myMenuCheckShowGrid->show();
2181  break;
2182  case GNE_MODE_CROSSING:
2187  myMenuCheckShowGrid->setCheck(false);
2188  break;
2189  case GNE_MODE_POLYGON:
2194  myMenuCheckShowGrid->show();
2195  break;
2196  default:
2197  break;
2198  }
2199  // Update buttons
2200  myEditModeCreateEdge->update();
2201  myEditModeMove->update();
2202  myEditModeDelete->update();
2203  myEditModeInspect->update();
2204  myEditModeSelect->update();
2205  myEditModeConnection->update();
2206  myEditModeTrafficLight->update();
2207  myEditModeAdditional->update();
2208  myEditModeCrossing->update();
2209  myEditModePolygon->update();
2210  // force repaint because different modes draw different things
2211  myToolbar->recalc();
2212  onPaint(0, 0, 0);
2213  update();
2214 }
2215 
2216 
2217 void
2219  std::vector<GNEJunction*> junctions = myNet->retrieveJunctions(true);
2220  if (junctions.size() > 0) {
2221  std::string plural = junctions.size() == 1 ? ("") : ("s");
2222  myUndoList->p_begin("delete selected " + toString(SUMO_TAG_JUNCTION) + plural);
2223  for (auto i : junctions) {
2225  }
2226  myUndoList->p_end();
2227  }
2228 }
2229 
2230 
2231 void
2233  std::vector<GNELane*> lanes = myNet->retrieveLanes(true);
2234  if (lanes.size() > 0) {
2235  std::string plural = lanes.size() == 1 ? ("") : ("s");
2236  myUndoList->p_begin("delete selected " + toString(SUMO_TAG_LANE) + plural);
2237  for (auto i : lanes) {
2239  }
2240  myUndoList->p_end();
2241  }
2242 }
2243 
2244 
2245 void
2247  std::vector<GNEEdge*> edges = myNet->retrieveEdges(true);
2248  if (edges.size() > 0) {
2249  std::string plural = edges.size() == 1 ? ("") : ("s");
2250  myUndoList->p_begin("delete selected " + toString(SUMO_TAG_EDGE) + plural);
2251  for (auto i : edges) {
2253  }
2254  myUndoList->p_end();
2255  }
2256 }
2257 
2258 
2259 void
2261  std::vector<GNEAdditional*> additionals = myNet->retrieveAdditionals(true);
2262  if (additionals.size() > 0) {
2263  std::string plural = additionals.size() == 1 ? ("") : ("s");
2264  myUndoList->p_begin("delete selected additional" + plural);
2265  for (auto i : additionals) {
2267  }
2268  myUndoList->p_end();
2269  }
2270 }
2271 
2272 
2273 
2274 void
2276  // obtain selected crossings
2277  std::vector<GNEJunction*> junctions = myNet->retrieveJunctions();
2278  std::vector<GNECrossing*> crossings;
2279  for (auto i : junctions) {
2280  for (auto j : i->getGNECrossings()) {
2281  if (gSelected.isSelected(GLO_CROSSING, j->getGlID())) {
2282  crossings.push_back(j);
2283  }
2284  }
2285  }
2286  // remove selected crossings
2287  if (crossings.size() > 0) {
2288  std::string plural = crossings.size() == 1 ? ("") : ("s");
2289  myUndoList->p_begin("delete selected " + toString(SUMO_TAG_CROSSING) + "s");
2290  for (auto i : crossings) {
2292  }
2293  myUndoList->p_end();
2294  }
2295 }
2296 
2297 
2298 void
2300  // obtain selected connections
2301  std::vector<GNEEdge*> edges = myNet->retrieveEdges();
2302  std::vector<GNEConnection*> connections;
2303  for (auto i : edges) {
2304  for (auto j : i->getGNEConnections()) {
2305  if (gSelected.isSelected(GLO_CONNECTION, j->getGlID())) {
2306  connections.push_back(j);
2307  }
2308  }
2309  }
2310  // remove selected connections
2311  if (connections.size() > 0) {
2312  std::string plural = connections.size() == 1 ? ("") : ("s");
2313  myUndoList->p_begin("delete selected " + toString(SUMO_TAG_CONNECTION) + plural);
2314  for (auto i : connections) {
2316  }
2317  myUndoList->p_end();
2318  }
2319 }
2320 
2321 
2322 void
2324  // obtain selected POIs
2325  std::vector<GNEPOI*> selectedPOIs;
2326  for (auto i : myNet->getPOIs().getMyMap()) {
2327  GNEPOI* poi = reinterpret_cast<GNEPOI*>(i.second);
2328  if (gSelected.isSelected(GLO_POI, poi->getGlID())) {
2329  selectedPOIs.push_back(poi);
2330  }
2331  }
2332  if (selectedPOIs.size() > 0) {
2333  std::string plural = selectedPOIs.size() == 1 ? ("") : ("s");
2334  myUndoList->p_begin("delete selected " + toString(SUMO_TAG_POI) + plural);
2335  for (auto i : selectedPOIs) {
2336  myNet->deletePOI(i, myUndoList);
2337  }
2338  myUndoList->p_end();
2339  }
2340 }
2341 
2342 
2343 void
2345  // obtain selected Polygons
2346  std::vector<GNEPoly*> selectedPolygons;
2347  for (auto i : myNet->getPolygons().getMyMap()) {
2348  GNEPoly* Polygon = reinterpret_cast<GNEPoly*>(i.second);
2349  if (gSelected.isSelected(GLO_POLYGON, Polygon->getGlID())) {
2350  selectedPolygons.push_back(Polygon);
2351  }
2352  }
2353  if (selectedPolygons.size() > 0) {
2354  std::string plural = selectedPolygons.size() == 1 ? ("") : ("s");
2355  myUndoList->p_begin("delete selected " + toString(SUMO_TAG_POLY) + plural);
2356  for (auto i : selectedPolygons) {
2358  }
2359  myUndoList->p_end();
2360  }
2361 }
2362 
2363 
2364 bool
2366  const Position& newPos = moved->getNBNode()->getPosition();
2367  GNEJunction* mergeTarget = 0;
2368  // try to find another junction to merge with
2369  if (makeCurrent()) {
2370  Boundary selection;
2371  selection.add(newPos);
2372  selection.grow(0.1);
2373  const std::vector<GUIGlID> ids = getObjectsInBoundary(selection);
2374  GUIGlObject* object = 0;
2375  for (auto it_ids : ids) {
2376  if (it_ids == 0) {
2377  continue;
2378  }
2380  if (!object) {
2381  throw ProcessError("Unkown object in selection (id=" + toString(it_ids) + ").");
2382  }
2383  if ((object->getType() == GLO_JUNCTION) && (it_ids != moved->getGlID())) {
2384  mergeTarget = dynamic_cast<GNEJunction*>(object);
2385  }
2387  }
2388  }
2389  if (mergeTarget) {
2390  // optionally ask for confirmation
2391  if (myMenuCheckWarnAboutMerge->getCheck()) {
2392  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
2393  WRITE_WARNING("Opening FXMessageBox 'merge junctions'");
2394  }
2395  // open question box
2396  FXuint answer = FXMessageBox::question(this, MBOX_YES_NO,
2397  "Confirm Junction Merger", "%s",
2398  ("Do you wish to merge junctions '" + moved->getMicrosimID() +
2399  "' and '" + mergeTarget->getMicrosimID() + "'?\n" +
2400  "('" + moved->getMicrosimID() +
2401  "' will be eliminated and its roads added to '" +
2402  mergeTarget->getMicrosimID() + "')").c_str());
2403  if (answer != 1) { //1:yes, 2:no, 4:esc
2404  // write warning if netedit is running in testing mode
2405  if ((answer == 2) && (OptionsCont::getOptions().getBool("gui-testing-debug"))) {
2406  WRITE_WARNING("Closed FXMessageBox 'merge junctions' with 'No'");
2407  } else if ((answer == 4) && (OptionsCont::getOptions().getBool("gui-testing-debug"))) {
2408  WRITE_WARNING("Closed FXMessageBox 'merge junctions' with 'ESC'");
2409  }
2410  return false;
2411  } else {
2412  // write warning if netedit is running in testing mode
2413  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
2414  WRITE_WARNING("Closed FXMessageBox 'merge junctions' with 'Yes'");
2415  }
2416  }
2417  }
2418  myNet->mergeJunctions(moved, mergeTarget, myUndoList);
2419  return true;
2420  } else {
2421  return false;
2422  }
2423 }
2424 
2425 
2426 void
2428  switch (myEditMode) {
2429  case GNE_MODE_INSPECT:
2430  myViewParent->getInspectorFrame()->update();
2431  break;
2432  default:
2433  break;
2434  }
2435 }
2436 /****************************************************************************/
GUIVisualizationSizeSettings junctionSize
long onCmdAddRestrictedLaneSidewalk(FXObject *, FXSelector typeOfTransformation, void *)
Add restricted lane for pedestrians.
GNEJunction * splitEdge(GNEEdge *edge, const Position &pos, GNEUndoList *undoList, GNEJunction *newJunction=0)
split edge at position by inserting a new junction
Definition: GNENet.cpp:637
void buildColorRainbow(GUIColorScheme &scheme, int active, GUIGlObjectType objectType)
recalibrate color scheme according to the current value range
Definition: GNEViewNet.cpp:267
long onCmdResetEdgeEndpoint(FXObject *, FXSelector, void *)
restore geometry endpoint to node position
GNEViewParent * myViewParent
view parent
Definition: GNEViewNet.h:349
virtual void openAdditionalDialog()
open Additional Dialog
void paintGLGrid()
paints a grid
EditMode getCurrentEditMode() const
get the current edit mode
std::vector< GNEJunction * > retrieveJunctions(bool onlySelected=false)
return all junctions
Definition: GNENet.cpp:978
double xmax() const
Returns maximum x-coordinate.
Definition: Boundary.cpp:132
long onCmdRestrictLaneBikelane(FXObject *, FXSelector typeOfTransformation, void *)
restrict lane to bikes
a tl-logic
void moveJunctionGeometry2D(Position pos2D)
reposition the node as above but keep the old z value
static const RGBColor BLUE
Definition: RGBColor.h:181
bool showLockIcon() const
check if lock icon should be visible
FXDEFMAP(GNEViewNet) GNEViewNetMap[]
std::vector< std::string > getStringVector(const std::string &name) const
Returns the list of string-vector-value of the named option (only for Option_String) ...
std::vector< GUIGlID > getObjectsAtPosition(Position pos, double radius)
returns the ids of the object at position within the given (rectangular) radius using GL_SELECT ...
std::vector< GNELane * > retrieveLanes(bool onlySelected=false)
return all lanes
Definition: GNENet.cpp:944
bool selectEdges()
whether inspection, selection and inversion should apply to edges or to lanes
Definition: GNEViewNet.cpp:304
GNEJunction * getJunctionAtCursorPosition(Position &pos)
try to retrieve a junction at the given position
void openPolygon(bool allowUndo=true)
open polygon
Definition: GNEPoly.cpp:351
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
Position myPopupSpot
Poput spot.
Definition: GNEViewNet.h:498
GUICompleteSchemeStorage gSchemeStorage
AddAdditionalResult addAdditional(GNENetElement *netElement, GUISUMOAbstractView *abstractViewParent)
add additional element
GNEEdge * retrieveEdge(const std::string &id, bool failHard=true)
get edge by id
Definition: GNENet.cpp:899
double scale
information about a lane&#39;s width (temporary, used for a single view)
mode for inspecting object attributes
Definition: GUIAppEnum.h:442
GNEJunction * getGNEJunctionSource() const
returns the source-junction
Definition: GNEEdge.cpp:194
void removePolygonOfView(GNEPoly *p)
remove polygon of view net
Definition: GNENet.cpp:1872
void abortOperation(bool clearSelection=true)
abort current edition operation
turn junction into geometry node
Definition: GUIAppEnum.h:648
void deleteSelectedJunctions()
delete all currently selected junctions
double distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
Definition: Position.h:250
bool setColorScheme(const std::string &name)
set color scheme
Definition: GNEViewNet.cpp:251
is a pedestrian
a polygon
long onCmdSetModeAdditional(FXObject *, FXSelector, void *)
called when user press the button for additional mode
mode for moving things
Definition: GNEViewNet.h:53
bool changeAllPhases() const
change all phases
Definition: GNEViewNet.cpp:334
bool restrictLane(SUMOVehicleClass vclass)
restrict lane
void stopEditShapeJunction()
edit edit junction shape
Definition: GNEViewNet.cpp:361
void deletePOI(GNEPOI *POI, GNEUndoList *undoList)
remove POI
Definition: GNENet.cpp:514
void inspectElement(GNEAttributeCarrier *AC)
Inspect a single element.
void markPopupPosition()
store the position where a popup-menu was requested
Position myMovingReference
variable for calculating moving offset (Used when user doesn&#39;t click exactly over the center of shape...
Definition: GNEViewNet.h:418
GUIGlObjectType
long onCmdDuplicateLane(FXObject *, FXSelector, void *)
duplicate selected lane
begin/end of the description of a junction
long onRightBtnPress(FXObject *, FXSelector, void *)
called when user press mouse&#39;s right button
Definition: GNEViewNet.cpp:897
bool myShowConnections
whether show connections has been activated once
Definition: GNEViewNet.h:376
void stopDrawing()
stop drawing and create polygon or
remove inner geometry
Definition: GUIAppEnum.h:654
begin/end of the description of a single lane
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types...
bool removePolygon(const std::string &id)
Removes a polygon from the container.
Definition: GNENet.cpp:1847
StringBijection< EditMode > myEditModeNames
since we cannot switch on strings we map the mode names to an enum
Definition: GNEViewNet.h:488
long onMouseMove(FXObject *, FXSelector, void *)
called when user moves mouse
Definition: GNEViewNet.cpp:944
GNEPoly * addPolygonForEditShapes(GNEJunction *junction)
Builds a special polygon used for edit Junctions&#39;s shapes.
Definition: GNENet.cpp:1826
void markAsCreateEdgeSource()
marks as first junction in createEdge-mode
GNEDeleteFrame * getDeleteFrame() const
get frame for GNE_MODE_DELETE
The main window of the Netedit.
bool mySelectEdges
flag to check if select edges is enabled
Definition: GNEViewNet.h:379
SUMORTree * myGrid
The visualization speed-up.
long onCmdSetModeSelect(FXObject *, FXSelector, void *)
called when user press the button for select mode
int myTestingHeight
Height of viewNet in testing mode.
Definition: GNEViewNet.h:518
GNEEdge * getEdgeTemplate() const
get the template edge (to copy attributes from)
Locate TLS - button.
Definition: GUIAppEnum.h:181
void hotkeyFocusFrame()
handle focus frame keypress
AddShapeResult
FOX-declaration.
FXMenuCheck * myMenuCheckShowGrid
show grid button
Definition: GNEViewNet.h:373
bool revertLaneRestriction(GNELane *lane, GNEUndoList *undoList)
revert prevously restricted lane
Definition: GNENet.cpp:582
double nearest_offset_to_point2D(const Position &p, bool perpendicular=true) const
return the nearest offest to point 2D
void removeAttributeCarrier(GNEAttributeCarrier *ac)
remove attribute carrier (element)
void toggleSelection(GUIGlID id)
Toggles selection of an object.
virtual long onMouseMove(FXObject *, FXSelector, void *)
FXMenuCheck * myChainCreateEdge
whether the endpoint for a created edge should be set as the new source
Definition: GNEViewNet.h:387
double exaggeration
The size exaggeration (upscale)
Set a vertex of polygon as first verte.
Definition: GUIAppEnum.h:664
double ymax() const
Returns maximum y-coordinate.
Definition: Boundary.cpp:144
double x() const
Returns the x-position.
Definition: Position.h:63
mode for deleting things
Definition: GNEViewNet.h:55
Definition: GNEPOI.h:52
connectio between two lanes
long onCmdSplitEdge(FXObject *, FXSelector, void *)
split edge at cursor position
void updateCurrentLabel(GNEAttributeCarrier *ac)
update current label
a connection
void setChecked(bool val)
check or uncheck this MFXCheckableButton
long onCmdToogleSelectEdges(FXObject *, FXSelector, void *)
toogle selet edges
vehicle is a bicycle
void show()
show Frame
const double SUMO_const_laneWidth
Definition: StdDefs.h:50
void commitShapeChange(const PositionVector &oldShape, GNEUndoList *undoList)
commit geometry changes in the attributes of an element after use of changeShapeGeometry(...)
Definition: GNEPoly.cpp:134
GUIMainWindow * myApp
The application.
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
void setEditMode(EditMode mode)
set edit mode
static void resetTextures()
Reset textures.
Position moveGeometry(const Position &oldPos, const Position &newPos, bool relative=false)
change the edge geometry It is up to the Edge to decide whether an new geometry node should be genera...
Definition: GNEEdge.cpp:326
Locate poi - button.
Definition: GUIAppEnum.h:189
MFXCheckableButton * myEditModeSelect
chekable button for edit mode select
Definition: GNEViewNet.h:467
long onCmdOpenPolygon(FXObject *, FXSelector, void *)
open closed polygon
Position mySelCorner2
second corner of the rectangle-selection
Definition: GNEViewNet.h:446
AddShapeResult processClick(const Position &clickedPosition)
process click over Viewnet
simplify polygon geometry
Definition: GUIAppEnum.h:656
GNEAdditionalFrame * getAdditionalFrame() const
get frame for GNE_MODE_ADDITIONAL
const PositionVector & getShape() const
Returns whether the shape of the polygon.
Definition: SUMOPolygon.h:84
mode for editing tls
Definition: GNEViewNet.h:63
NBNode * getNBNode() const
Return net build node.
int getVertexIndex(const Position &pos, bool createIfNoExist=true)
return index of a vertex of shape, or of a new vertex if position is over an shape&#39;s edge ...
Definition: GNEPoly.cpp:314
void reverseEdge(GNEEdge *edge, GNEUndoList *undoList)
reverse edge
Definition: GNENet.cpp:700
virtual Position getPositionInView() const =0
Returns position of additional in view.
static const RGBColor ORANGE
Definition: RGBColor.h:185
MFXCheckableButton * myEditModeMove
chekable button for edit mode move
Definition: GNEViewNet.h:458
T MAX2(T a, T b)
Definition: StdDefs.h:74
void deleteConnection(GNEConnection *connection, GNEUndoList *undoList)
remove connection
Definition: GNENet.cpp:478
void splitEdgesBidi(const std::set< GNEEdge * > &edges, const Position &pos, GNEUndoList *undoList)
split all edges at position by inserting one new junction
Definition: GNENet.cpp:689
mode for moving things
Definition: GUIAppEnum.h:438
Position getPositionInView() const
Return current position.
A 2D- or 3D-polygon.
Definition: SUMOPolygon.h:44
MFXCheckableButton * myEditModeDelete
chekable button for edit mode delete
Definition: GNEViewNet.h:461
bool isSelected(GUIGlObjectType type, GUIGlID id)
Returns the information whether the object with the given type and id is selected.
A NBNetBuilder extended by visualisation and editing capabilities.
Definition: GNENet.h:92
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition: GNELane.h:54
void editJunction(GNEJunction *junction)
edits the traffic light for the given junction
GNEEdge * createEdge(GNEJunction *src, GNEJunction *dest, GNEEdge *tpl, GNEUndoList *undoList, const std::string &suggestedName="", bool wasSplit=false, bool allowDuplicateGeom=false)
creates a new edge (unless an edge with the same geometry already exists)
Definition: GNENet.cpp:225
int editMode
the current NETEDIT mode (temporary)
remove bikelane
Definition: GUIAppEnum.h:684
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:85
GNEPOI * myPoiToMove
the poi which is being moved
Definition: GNEViewNet.h:412
void setEditModeFromHotkey(FXushort selid)
sets edit mode (from hotkey)
virtual long onKeyRelease(FXObject *o, FXSelector sel, void *data)
long onKeyPress(FXObject *o, FXSelector sel, void *data)
called when user press a key
void deleteSelectedPolygons()
delete all currently selected Polygons
begin/end of the description of a polygon
GNEPolygonFrame::DrawingMode * getDrawingMode() const
get drawing mode
long onCmdSetEdgeEndpoint(FXObject *, FXSelector, void *)
set non-default geometry endpoint
void handleIDs(std::vector< GUIGlID > ids, bool selectEdgesEnabled, SetOperation setop=SET_DEFAULT)
apply list of ids to the current selection according to SetOperation,
PositionVector myMovingOriginalShape
Shape of elements before moving (needed for commmit shape changes)
Definition: GNEViewNet.h:424
Position snapToActiveGrid(const Position &pos) const
Returns a position that is mapped to the closest grid point if the grid is active.
GUIDialog_ViewSettings * myVisualizationChanger
Visualization changer.
GNEViewParent * getViewParent() const
get the net object
void deleteEdge(GNEEdge *edge, GNEUndoList *undoList)
removes edge
Definition: GNENet.cpp:332
void set(double x, double y)
set positions x and y
Definition: Position.h:93
int myMovingIndexShape
current index of shape that are being moved
Definition: GNEViewNet.h:427
void updateControls()
update control contents after undo/redo or recompute
EditMode myPreviousEditMode
the previous edit mode before edit junction&#39;s shapes
Definition: GNEViewNet.h:506
bool isMovementBlocked() const
return true if movement is blocked
Definition: GNEShape.cpp:63
const Polygons & getPolygons() const
Returns all polygons.
FXMenuCheck * myMenuCheckChangeAllPhases
menu check to set change all phases
Definition: GNEViewNet.h:370
GUIGlID getGlID() const
Returns the numerical id of the object.
GNEEdge * myEdgeToMove
the edge of which geometry is being moved
Definition: GNEViewNet.h:406
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:48
void closePolygon(bool allowUndo=true)
close polygon
Definition: GNEPoly.cpp:373
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:200
A single child window which contains a view of the simulation area.
Definition: GNEViewParent.h:73
transform lane to sidewalk
Definition: GUIAppEnum.h:668
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:65
Position screenPos2NetPos(int x, int y) const
Translate screen position to network position.
GNEPoly * myEditJunctionShapePoly
Definition: GNEViewNet.h:503
mode for adding edges
Definition: GUIAppEnum.h:436
GNEUndoList * getUndoList() const
get the undoList object
virtual void commitGeometryMoving(const Position &oldPos, GNEUndoList *undoList)=0
commit geometry changes in the attributes of an element after use of moveGeometry(...)
std::map< const GUIGlObject *, int > myAdditionallyDrawn
List of objects for which GUIGlObject::drawGLAdditional is called.
bool restrictLane(SUMOVehicleClass vclass, GNELane *lane, GNEUndoList *undoList)
transform lane to restricted lane
Definition: GNENet.cpp:556
long onCmdSetModeCrossing(FXObject *, FXSelector, void *)
called when user press the button for crossing mode
void moveGeometry(const Position &newPosition)
change the position of the element geometry without saving in undoList
Definition: GNEPOI.cpp:84
virtual const std::string & getMicrosimID() const
Returns the id of the object as known to microsim.
bool isFixed() const
Locate addtional structure - button.
Definition: GUIAppEnum.h:187
void handleLaneClick(GNELane *lane, bool mayDefinitelyPass, bool allowConflict, bool toggle)
either sets the current lane or toggles the connection of the current lane to this lane (if they shar...
const std::string & getID() const
Returns the id.
Definition: Named.h:66
edit junction shape
Definition: GUIAppEnum.h:646
void insert(const std::string str, const T key, bool checkDuplicates=true)
mode for editing additional
Definition: GUIAppEnum.h:450
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
void buildEditModeControls()
adds controls for setting the edit mode
std::vector< GNEJunction * > getJunctionNeighbours() const
return GNEJunction neighbours
GUIGlID getObjectAtPosition(Position pos)
returns the id of the object at position using GL_SELECT
remove busLane
Definition: GUIAppEnum.h:686
std::set< GNEEdge * > getEdgesAtCursorPosition(Position &pos)
try to retrieve multiple edges at the given position
const std::vector< std::string > & getNames() const
Returns a list of stored settings names.
transform lane to busLane
Definition: GUIAppEnum.h:672
const PositionVector getInnerGeometry() const
Returns the geometry of the edge without the endpoints.
Definition: NBEdge.cpp:494
void removeLastPoint()
remove last added point
long onLeftBtnPress(FXObject *, FXSelector, void *)
Definition: GNEViewNet.cpp:485
long onRightBtnRelease(FXObject *, FXSelector, void *)
called when user releases mouse&#39;s right button
Definition: GNEViewNet.cpp:910
const Position & getPosition() const
Definition: NBNode.h:235
long onCmdSimplifyShape(FXObject *, FXSelector, void *)
simply shape of current polygon
static const RGBColor GREEN
Definition: RGBColor.h:180
void computeNodeShape(double mismatchThreshold)
Compute the junction shape for this node.
Definition: NBNode.cpp:771
void commitGeometryMoving(const Position &oldPos, GNEUndoList *undoList)
commit geometry changes in the attributes of an element after use of moveGeometry(...)
Definition: GNEPOI.cpp:93
virtual long onPaint(FXObject *, FXSelector, void *)
const std::set< GUIGlID > & getSelected() const
Returns the set of ids of all selected objects.
int addColor(const T &color, const double threshold, const std::string &name="")
close opened polygon
Definition: GUIAppEnum.h:660
long onCmdRemoveRestrictedLaneBuslane(FXObject *, FXSelector typeOfTransformation, void *)
remove restricted lane for bus
std::string name
The name of this setting.
void deleteSelectedConnections()
delete all currently selected connections
bool removeRestrictedLane(SUMOVehicleClass vclass, GNEEdge &edge, GNEUndoList *undoList)
remove restricted lane
Definition: GNENet.cpp:615
mode for creating polygons
Definition: GUIAppEnum.h:454
mode for inspecting object attributes
Definition: GNEViewNet.h:57
void setCurrentScheme(const std::string &)
Sets the named scheme as the current.
FXMenuCheck * myMenuCheckShowConnections
menu check to show connections
Definition: GNEViewNet.h:364
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:56
static bool hasAttribute(SumoXMLTag tag, SumoXMLAttr attr)
check if an element with certain tag has a certain attribute
virtual void setStatusBarText(const std::string &)
Definition: GUIMainWindow.h:81
void deleteSelectedCrossings()
delete all currently selected crossings
GNEAdditional * myAdditionalToMove
the stoppingPlace element which shape is being moved
Definition: GNEViewNet.h:415
GNELane * getLane() const
get lane of additional, or NULL if additional isn&#39;t placed over a Lane
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
Definition: GLHelper.cpp:438
long onCmdCancel(FXObject *, FXSelector, void *)
Called when the user presses the Cancel-button.
This object is responsible for drawing a shape and for supplying a a popup menu. Messages are routete...
Definition: GNECrossing.h:52
GNEEdge & getParentEdge()
Returns underlying parent edge.
Definition: GNELane.cpp:1085
virtual long onKeyPress(FXObject *o, FXSelector sel, void *data)
keyboard functions
std::map< GNEJunction *, Position > myOriginPostionOfMovedJunctions
Junctions that are being moved.
Definition: GNEViewNet.h:434
virtual ~GNEViewNet()
destructor
Definition: GNEViewNet.cpp:198
set non-default geometry endpoint
Definition: GUIAppEnum.h:650
int moveVertexShape(int index, const Position &newPos)
change position of a vertex of shape without commiting change
Definition: GNEPoly.cpp:90
long onCmdSetModeMove(FXObject *, FXSelector, void *)
called when user press the button for move mode
void p_end()
End undo command sub-group. If the sub-group is still empty, it will be deleted; otherwise, the sub-group will be added as a new command into parent group. A matching begin() must have been called previously.
Definition: GNEUndoList.cpp:92
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:46
double m2p(double meter) const
meter-to-pixels conversion method
double p2m(double pixel) const
pixels-to-meters conversion method
A list of positions.
long onCmdReplaceJunction(FXObject *, FXSelector, void *)
replace node by geometry
FXMenuCheck * myMenuCheckSelectEdges
menu check to select only edges
Definition: GNEViewNet.h:361
Locate edge - button.
Definition: GUIAppEnum.h:175
FXToolBar * myToolbar
a reference to the toolbar in myParent
Definition: GNEViewNet.h:450
FXComboBox & getColoringSchemesCombo()
void deleteLane(GNELane *lane, GNEUndoList *undoList)
removes lane
Definition: GNENet.cpp:436
long onCmdToogleShowConnection(FXObject *, FXSelector, void *)
toogle show connections
bool contains(const std::string &name) const
Returns the information whether a setting with the given name is stored.
MFXCheckableButton * myEditModeCreateEdge
Definition: GNEViewNet.h:455
open closed polygon
Definition: GUIAppEnum.h:662
static GUIGlObjectStorage gIDStorage
A single static instance of this class.
double y() const
Returns the y-position.
Definition: Position.h:68
show junctions as bubbles
Definition: GUIAppEnum.h:582
GUIVisualizationSettings & get(const std::string &name)
Returns the named scheme.
void commitGeometryMoving(const Position &oldPos, GNEUndoList *undoList)
registers completed movement with the undoList
void removeAdditional(GNEAdditional *additional)
remove an additional element previously added
void deleteSelectedPOIs()
delete all currently selected POIs
revert transformation
Definition: GUIAppEnum.h:674
long onCmdRevertRestriction(FXObject *, FXSelector, void *)
revert transformation
bool removeRestrictedLane(SUMOVehicleClass vclass)
remove restricted lane
long onCmdSplitEdgeBidi(FXObject *, FXSelector, void *)
split edge at cursor position
bool autoSelectNodes()
whether to autoselect nodes or to lanes
Definition: GNEViewNet.cpp:322
static const RGBColor MAGENTA
Definition: RGBColor.h:184
T MIN2(T a, T b)
Definition: StdDefs.h:68
bool isDrawing() const
return true if currently a shape is drawed
virtual void moveGeometry(const Position &newPosition)=0
change the position of the element geometry without saving in undoList
MFXCheckableButton * myEditModeTrafficLight
chekable button for edit mode traffic light
Definition: GNEViewNet.h:473
GNECrossingFrame * getCrossingFrame() const
get frame for GNE_MODE_CROSSING
void initGNEConnections()
initialize GNEConnections
Definition: GNENet.cpp:2227
#define POSITION_EPS
Definition: config.h:176
long onCmdRemoveRestrictedLaneBikelane(FXObject *, FXSelector typeOfTransformation, void *)
remove restricted lane for bikes
mode for selecting objects
Definition: GNEViewNet.h:59
GNEJunction * myJunctionToMove
the Junction to be moved.
Definition: GNEViewNet.h:403
bool addCrossing(GNENetElement *netElement)
add Crossing element
MFXCheckableButton * myEditModeAdditional
chekable button for edit mode additional
Definition: GNEViewNet.h:476
void markAttributeCarrier(GNEAttributeCarrier *ac)
mark attribute carrier (element)
GNELane * getLaneAtCurserPosition(Position &pos)
try to retrieve a lane at the given position
edge: the shape in xml-definition
Locate junction - button.
Definition: GUIAppEnum.h:173
mode for selecting objects
Definition: GUIAppEnum.h:444
std::vector< GNEAttributeCarrier * > retrieveAttributeCarriers(const std::set< GUIGlID > &ids, GUIGlObjectType type)
get the attribute carriers based on GlIDs
Definition: GNENet.cpp:1020
Boundary & grow(double by)
extends the boundary by the given amount
Definition: Boundary.cpp:302
std::string getCurrentScheme() const
Returns the name of the currently chosen scheme.
mode for editing crossing
Definition: GUIAppEnum.h:452
GNEInspectorFrame * getInspectorFrame() const
get frame for GNE_MODE_INSPECT
void deleteCrossing(GNECrossing *crossing, GNEUndoList *undoList)
remove crossing
Definition: GNENet.cpp:498
GNEConnectorFrame * getConnectorFrame() const
get frame for GNE_MODE_CONNECT
void unMarkAsCreateEdgeSource()
removes mark as first junction in createEdge-mode
void startDrawing()
start drawing
static void drawLine(const Position &beg, double rot, double visLength)
Draws a thin line.
Definition: GLHelper.cpp:265
const PositionVector & getTemporalShape() const
get Temporal shape
void moveSelection(const Position &moveSrc, const Position &moveDest)
move all selected junctions and edges
Definition: GNENet.cpp:1552
Position getPositionInView() const
Returns position of additional in view.
Definition: GNEPOI.cpp:105
void focusUpperElement()
focus upper element of frame
Definition: GNEFrame.cpp:92
int myTestingWidth
Width of viewNet in testing mode.
Definition: GNEViewNet.h:515
GNEJunction * createJunction(const Position &pos, GNEUndoList *undoList)
creates a new junction
Definition: GNENet.cpp:214
const POIs & getPOIs() const
Returns all pois.
virtual std::string getAttribute(SumoXMLAttr key) const =0
This functions has to be implemented in allGNEAttributeCarrier.
Position mySelCorner1
firstcorner of the rectangle-selection
Definition: GNEViewNet.h:443
void p_abort()
reverts and discards ALL active command groups
const PositionVector & getShape() const
retrieve the junction shape
Definition: NBNode.cpp:1726
GUIPerspectiveChanger * myChanger
The perspective changer.
long onCmdRestrictLaneBuslane(FXObject *, FXSelector typeOfTransformation, void *)
restrict lane to buslanes
GNEJunction * getShapeEditedJunction() const
retrieve the junction of which the shape is being edited
Definition: GNEPoly.cpp:345
bool myUseToolTips
use tool tips
virtual void onLeftBtnPress(void *data)
mouse functions
EditMode
Definition: GNEViewNet.h:47
void destroyPopup()
destoys the popup
void doInit()
called after some features are already initialized
Definition: GNEViewNet.cpp:202
begin/end of the description of an edge
duplicate a lane
Definition: GUIAppEnum.h:666
FXMenuCheck * myAutoCreateOppositeEdge
Definition: GNEViewNet.h:388
void setSelectionScaling(double selectionScale)
set selection scaling
Definition: GNEViewNet.cpp:328
bool mergeJunctions(GNEJunction *moved)
try to merge moved junction with another junction in that spot return true if merging did take place ...
MFXCheckableButton * myEditModeInspect
chekable button for edit mode inspect
Definition: GNEViewNet.h:464
FXMenuCheck * myMenuCheckExtendToEdgeNodes
menu check to extend to edge nodes
Definition: GNEViewNet.h:367
long onCmdClosePolygon(FXObject *, FXSelector, void *)
close opened polygon
const IDMap & getMyMap() const
Returns a reference to the internal map.
void commitGeometryMoving(const PositionVector &oldShape, double minDistToEnd, GNEUndoList *undoList)
registers completed movement with the undoList
Definition: GNEEdge.cpp:136
void replaceJunctionByGeometry(GNEJunction *junction, GNEUndoList *undoList)
replace the selected junction by geometry node(s) and merge the edges
Definition: GNENet.cpp:1460
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:58
void deleteGeometryNear(const Position &pos, bool allowUndo=true)
delete the geometry point closest to the given pos
Definition: GNEPoly.cpp:469
reverse an edge
Definition: GUIAppEnum.h:642
long onKeyRelease(FXObject *o, FXSelector sel, void *data)
called when user release a key
FXbool makeCurrent()
A reimplementation due to some internal reasons.
add reverse edge
Definition: GUIAppEnum.h:644
long onCmdOK(FXObject *, FXSelector, void *)
compound additional
virtual long onLeftBtnRelease(FXObject *, FXSelector, void *)
vehicle is a bus
add busLane
Definition: GUIAppEnum.h:680
AddAdditionalResult
FOX-declaration.
static const double BUBBLE_RADIUS
Definition: GNEJunction.h:62
void deletePolygon(GNEPoly *polygon, GNEUndoList *undoList)
remove Polygon
Definition: GNENet.cpp:529
static const RGBColor YELLOW
Definition: RGBColor.h:182
Mode for editing Polygons.
Definition: GNEViewNet.h:69
static const RGBColor RED
named colors
Definition: RGBColor.h:179
const PositionVector & getShape() const
returns the shape of the lane
Definition: GNELane.cpp:625
FXMenuCheck * myMenuCheckWarnAboutMerge
whether we should warn about merging junctions
Definition: GNEViewNet.h:394
double selectionScale
the current selection scaling in NETEDIT (temporary)
#define GUIDesignButtonToolbarCheckable
little checkable button with icon placed in navigation toolbar
Definition: GUIDesigns.h:91
virtual void show()
show Frame
Definition: GNEFrame.cpp:98
static const RGBColor CYAN
Definition: RGBColor.h:183
bool hasCommandGroup() const
Check if undoList has command group.
GUIVisualizationSettings * myVisualizationSettings
visualization settings
void simplifyShape(bool allowUndo=true)
replace the current shape with a rectangle
Definition: GNEPoly.cpp:437
long onCmdDeleteGeometryPoint(FXObject *, FXSelector, void *)
delete the closes geometry point
void show()
show additional frame and update use selected edges/lanes
std::vector< GNEEdge * > retrieveEdges(bool onlySelected=false)
return all edges
Definition: GNENet.cpp:932
long onCmdAddRestrictedLaneBikelane(FXObject *, FXSelector typeOfTransformation, void *)
Add restricted lane for bikes.
FXMenuCheck * myMenuCheckShowBubbleOverJunction
show connection as buuble in "Move" mode.
Definition: GNEViewNet.h:397
An Element which don&#39;t belongs to GNENet but has influency in the simulation.
Definition: GNEAdditional.h:62
void show()
show additional frame and update use selected edges/lanes
mode for editing tls
Definition: GUIAppEnum.h:448
MFXCheckableButton * myEditModeConnection
chekable button for edit mode connection
Definition: GNEViewNet.h:470
bool showConnections()
show connections over junctions
Definition: GNEViewNet.cpp:310
double xmin() const
Returns minimum x-coordinate.
Definition: Boundary.cpp:126
long onCmdOK(FXObject *, FXSelector, void *)
long onCmdReverseEdge(FXObject *, FXSelector, void *)
reverse edge
long onCmdSetModeTLS(FXObject *, FXSelector, void *)
called when user press the button for traffic lights mode
bool isShapeBlocked() const
return true if shape is blocked
Definition: GNEShape.cpp:69
GNEPoly * getPolygonAtCursorPosition(Position &pos)
try to retrieve a Polygon at the given position
long onCmdCancel(FXObject *, FXSelector, void *)
Called when the user presses the Cancel-button discards any connection modifications.
int doPaintGL(int mode, const Boundary &bound)
do paintGL
Definition: GNEViewNet.cpp:377
GNEJunction * myCreateEdgeSource
source junction for new edge 0 if no edge source is selected an existing (or newly created) junction ...
Definition: GNEViewNet.h:384
void abortDrawing()
abort drawing
A storage for options typed value containers)
Definition: OptionsCont.h:99
Locate polygons - button.
Definition: GUIAppEnum.h:191
an edge
long onCmdAddRestrictedLaneBuslane(FXObject *, FXSelector typeOfTransformation, void *)
Add restricted lane for buses.
long onCmdRemoveRestrictedLaneSidewalk(FXObject *, FXSelector typeOfTransformation, void *)
remove restricted lane for pedestrians
transform lane to bikelane
Definition: GUIAppEnum.h:670
GNEAttributeCarrier * getMarkedAttributeCarrier() const
returns marked atrribute carrier
void computeEverything(GNEApplicationWindow *window, bool force=false, bool volatileOptions=false, std::string additionalPath="", std::string shapePath="")
trigger full netbuild computation param[in] window The window to inform about delay param[in] force W...
Definition: GNENet.cpp:1167
void deleteSelectedAdditionals()
delete all currently selected additionals
crossing between edges for pedestrians
GNENet * getNet() const
get the net object
void clear()
Clears the list of selected objects.
void deleteJunction(GNEJunction *junction, GNEUndoList *undoList)
removes junction and all incident edges
Definition: GNENet.cpp:280
double ymin() const
Returns minimum y-coordinate.
Definition: Boundary.cpp:138
void text()
Definition: gl2psTest.c:260
bool showGrid
Information whether a grid shall be shown.
void drawDecals()
Draws the stored decals.
void show()
show inspector frame
split an edge
Definition: GUIAppEnum.h:638
bool isAdditionalBlocked() const
Check if additional item is currently blocked (i.e. cannot be moved with mouse)
long onCmdRestrictLaneSidewalk(FXObject *, FXSelector typeOfTransformation, void *)
restrict lane to pedestrians
add bikelane
Definition: GUIAppEnum.h:678
void updateModeSpecificControls()
updates mode specific controls
MFXCheckableButton * myEditModeCrossing
chekable button for edit mode crossing
Definition: GNEViewNet.h:479
virtual int Search(const float a_min[2], const float a_max[2], const GUIVisualizationSettings &c) const
Find all within search rectangle.
Definition: SUMORTree.h:120
std::vector< GNEAdditional * > retrieveAdditionals(bool onlySelected=false)
return all additionals
Definition: GNENet.cpp:1668
mode for deleting things
Definition: GUIAppEnum.h:440
SumoXMLTag getTag() const
get XML Tag assigned to this object
GNEEdge * addReversedEdge(GNEEdge *edge, GNEUndoList *undoList)
add reversed edge
Definition: GNENet.cpp:711
void setStatusBarText(const std::string &text)
set staturBar text
Definition: GNEViewNet.cpp:298
bool showLane2Lane
Information whether lane-to-lane arrows shall be drawn.
void hideAllFrames()
hide all frames
long onCmdSetModeConnect(FXObject *, FXSelector, void *)
called when user press the button for connect mode
Mode for editing additionals.
Definition: GNEViewNet.h:65
virtual void buildViewToolBars(GUIGlChildWindow &)
builds the view toolbars
Definition: GNEViewNet.cpp:206
void setEndpoint(Position pos, GNEUndoList *undoList)
makes pos the new geometry endpoint at the appropriate end
Definition: GNEEdge.cpp:411
long onCmdSetModePolygon(FXObject *, FXSelector, void *)
called when user press the button for polygon mode
static const RGBColor selectionColor
Definition: GNENet.h:103
empty max
Mode for editing crossing.
Definition: GNEViewNet.h:67
void unblockObject(GUIGlID id)
Marks an object as unblocked.
long onCmdStraightenEdges(FXObject *, FXSelector, void *)
makes selected edges straight
long onCmdSetModeInspect(FXObject *, FXSelector, void *)
called when user press the button for inspect mode
mode for connecting lanes
Definition: GNEViewNet.h:61
bool myMovingSelection
whether a selection is being moved
Definition: GNEViewNet.h:430
mode for creating new edges
Definition: GNEViewNet.h:51
virtual long onRightBtnPress(FXObject *, FXSelector, void *)
NBEdge * getNBEdge()
returns the internal NBEdge
Definition: GNEEdge.cpp:306
GNETLSEditorFrame * getTLSEditorFrame() const
get frame for GNE_MODE_TLS
long onCmdSetFirstGeometryPoint(FXObject *, FXSelector, void *)
set as first geometry point the closes geometry point
void add(double x, double y, double z=0)
Makes the boundary include the given coordinate.
Definition: Boundary.cpp:86
long onDoubleClicked(FXObject *, FXSelector, void *)
called when user press mouse&#39;s left button two times
Definition: GNEViewNet.cpp:921
Position getPositionInformation() const
Returns the cursor&#39;s x/y position within the network.
GUIGlID getObjectUnderCursor()
returns the id of the object under the cursor using GL_SELECT
void inspectMultisection(const std::vector< GNEAttributeCarrier * > &ACs)
Inspect the given multi-selection.
long onCmdToogleShowBubbles(FXObject *, FXSelector, void *)
toogle show bubbles
void mergeJunctions(GNEJunction *moved, GNEJunction *target, GNEUndoList *undoList)
merge the given junctions edges between the given junctions will be deleted
Definition: GNENet.cpp:745
GNEEdge * getEdgeAtCursorPosition(Position &pos)
try to retrieve an edge at the given position
bool showJunctionAsBubbles() const
return true if junction must be showed as bubbles
Definition: GNEViewNet.cpp:340
void hotkeyDel()
handle del keypress
void startEditShapeJunction(GNEJunction *junction)
start edit junction shape
Definition: GNEViewNet.cpp:346
long onCmdAddReversedEdge(FXObject *, FXSelector, void *)
add reversed edge
GUIGlObject * getObjectBlocking(GUIGlID id)
Returns the object from the container locking it.
bool myAmInRectSelect
whether we have started rectangle-selection
Definition: GNEViewNet.h:440
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
Definition: GNEEdge.cpp:693
bool addSRestrictedLane(SUMOVehicleClass vclass, GNEEdge &edge, GNEUndoList *undoList)
add restricted lane to edge
Definition: GNENet.cpp:600
GUISelectedStorage gSelected
A global holder of selected objects.
GNENet * myNet
Pointer to current net. (We are not responsible for deletion)
Definition: GNEViewNet.h:352
void hotkeyEnter()
handle enter keypress
GNEPolygonFrame * getPolygonFrame() const
get frame for GNE_MODE_POLYGON
void resetEndpoint(const Position &pos, GNEUndoList *undoList)
restores the endpoint to the junction position at the appropriate end
Definition: GNEEdge.cpp:434
void deleteSelectedLanes()
delete all currently selected lanes
long onCmdEditJunctionShape(FXObject *, FXSelector, void *)
edit junction shape
void changeFirstGeometryPoint(int oldIndex, bool allowUndo=true)
change first geometry point
Definition: GNEPoly.cpp:395
restore geometry endpoint to node position
Definition: GUIAppEnum.h:652
static FXIcon * getIcon(GUIIcon which)
returns a icon previously defined in the enum GUIIcon
long onLeftBtnRelease(FXObject *, FXSelector, void *)
called when user releases mouse&#39;s left button
Definition: GNEViewNet.cpp:843
split an edge
Definition: GUIAppEnum.h:640
Position getSplitPos(const Position &clickPos)
Definition: GNEEdge.cpp:312
void requireRecompute()
inform the net about the need for recomputation
Definition: GNENet.cpp:1232
long onCmdShowGrid(FXObject *, FXSelector, void *)
toogle show grid
void processClick(FXEvent *e, void *data)
Auxiliar function used by onLeftBtnPress(...)
void duplicateLane(GNELane *lane, GNEUndoList *undoList)
duplicates lane
Definition: GNENet.cpp:544
long onCmdSetModeCreateEdge(FXObject *, FXSelector, void *)
long onCmdSetModeDelete(FXObject *, FXSelector, void *)
called when user press the button for delete mode
void deleteSelectedEdges()
delete all currently selected edges
GNEUndoList * myUndoList
a reference to the undolist maintained in the application
Definition: GNEViewNet.h:495
EditMode myEditMode
the current edit mode
Definition: GNEViewNet.h:355
virtual long onRightBtnRelease(FXObject *, FXSelector, void *)
mode for connecting lanes
Definition: GUIAppEnum.h:446
bool addRestrictedLane(SUMOVehicleClass vclass)
add restricted lane
std::vector< GUIGlID > getObjectsInBoundary(const Boundary &bound)
returns the ids of all objects in the given boundary
MFXCheckableButton * myEditModePolygon
chekable button for edit mode polygon
Definition: GNEViewNet.h:482
begin/end of the description of a polygon
void moveEntireShape(const PositionVector &oldShape, const Position &offset)
move entire shape without commiting change
Definition: GNEPoly.cpp:117
FXPopup * getLocatorPopup()
bool myTestingMode
Definition: GNEViewNet.h:512
GNEFrame * myCurrentFrame
the current frame
Definition: GNEViewNet.h:358
GNESelectorFrame * getSelectorFrame() const
get frame for GNE_MODE_SELECT
Position myMovingOriginalPosition
original Position of element before moving (needed for commmit position changes)
Definition: GNEViewNet.h:421
a junction
GNEJunction * getGNEJunctionDestiny() const
returns the destination-junction
Definition: GNEEdge.cpp:200
GNEPoly * myPolyToMove
the poly of which geometry is being moved
Definition: GNEViewNet.h:409
void finishMoveSelection(GNEUndoList *undoList)
register changes to junction and edge positions with the undoList
Definition: GNENet.cpp:1582