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 
57 #include "GNEViewNet.h"
58 #include "GNEEdge.h"
59 #include "GNELane.h"
60 #include "GNEJunction.h"
61 #include "GNEPOI.h"
62 #include "GNEApplicationWindow.h"
63 #include "GNEViewParent.h"
64 #include "GNENet.h"
65 #include "GNEUndoList.h"
66 #include "GNEInspectorFrame.h"
67 #include "GNESelectorFrame.h"
68 #include "GNEConnectorFrame.h"
69 #include "GNETLSEditorFrame.h"
70 #include "GNEAdditionalFrame.h"
71 #include "GNECrossingFrame.h"
72 #include "GNEDeleteFrame.h"
73 #include "GNEAdditionalHandler.h"
74 #include "GNEPoly.h"
75 #include "GNECrossing.h"
76 #include "GNEAdditional.h"
77 #include "GNEAdditionalDialog.h"
78 #include "GNERerouter.h"
79 #include "GNEConnection.h"
80 
81 
82 // ===========================================================================
83 // FOX callback mapping
84 // ===========================================================================
85 FXDEFMAP(GNEViewNet) GNEViewNetMap[] = {
87  FXMAPFUNC(SEL_COMMAND, MID_GNE_MODE_MOVE, GNEViewNet::onCmdSetModeMove),
88  FXMAPFUNC(SEL_COMMAND, MID_GNE_MODE_DELETE, GNEViewNet::onCmdSetModeDelete),
90  FXMAPFUNC(SEL_COMMAND, MID_GNE_MODE_SELECT, GNEViewNet::onCmdSetModeSelect),
92  FXMAPFUNC(SEL_COMMAND, MID_GNE_MODE_TLS, GNEViewNet::onCmdSetModeTLS),
95  FXMAPFUNC(SEL_COMMAND, MID_GNE_SPLIT_EDGE, GNEViewNet::onCmdSplitEdge),
97  FXMAPFUNC(SEL_COMMAND, MID_GNE_REVERSE_EDGE, GNEViewNet::onCmdReverseEdge),
101  FXMAPFUNC(SEL_COMMAND, MID_GNE_STRAIGHTEN, GNEViewNet::onCmdStraightenEdges),
115  FXMAPFUNC(SEL_COMMAND, MID_GNE_NODE_SHAPE, GNEViewNet::onCmdNodeShape),
116  FXMAPFUNC(SEL_COMMAND, MID_GNE_NODE_REPLACE, GNEViewNet::onCmdNodeReplace),
120  FXMAPFUNC(SEL_COMMAND, MID_GNE_SHOW_GRID, GNEViewNet::onCmdShowGrid)
121 };
122 
123 // Object implementation
124 FXIMPLEMENT(GNEViewNet, GUISUMOAbstractView, GNEViewNetMap, ARRAYNUMBER(GNEViewNetMap))
125 
126 // ===========================================================================
127 // member method definitions
128 // ===========================================================================
129 GNEViewNet::GNEViewNet(FXComposite* tmpParent, FXComposite* actualParent, GUIMainWindow& app,
130  GNEViewParent* viewParent, GNENet* net, GNEUndoList* undoList,
131  FXGLVisual* glVis, FXGLCanvas* share, FXToolBar* toolBar) :
132  GUISUMOAbstractView(tmpParent, app, viewParent, net->getVisualisationSpeedUp(), glVis, share),
133  myViewParent(viewParent),
134  myNet(net),
135  myEditMode(GNE_MODE_MOVE),
136  myPreviousEditMode(GNE_MODE_MOVE),
137  myCurrentFrame(0),
138  myShowConnections(false),
139  mySelectEdges(true),
140  myCreateEdgeSource(0),
141  myJunctionToMove(0),
142  myEdgeToMove(0),
143  myPolyToMove(0),
144  myPoiToMove(0),
145  myAdditionalToMove(0),
146  myMoveSelection(false),
147  myAmInRectSelect(false),
148  myToolbar(toolBar),
149  myEditModeCreateEdge(0),
150  myEditModeMove(0),
151  myEditModeDelete(0),
152  myEditModeInspect(0),
153  myEditModeSelect(0),
154  myEditModeConnection(0),
155  myEditModeTrafficLight(0),
156  myEditModeAdditional(0),
157  myEditModeCrossing(0),
158  myEditModeNames(),
159  myUndoList(undoList),
160  myCurrentPoly(0),
161  myTestingMode(OptionsCont::getOptions().getBool("gui-testing")) {
162  // view must be the final member of actualParent
163  reparent(actualParent);
164 
165  buildEditModeControls();
166  myUndoList->mark();
167  myNet->setViewNet(this);
168 
169  ((GUIDanielPerspectiveChanger*)myChanger)->setDragDelay(100000000); // 100 milliseconds
170 
171  // init color schemes
172  GUIColorer laneColorer;
173  GUIColorScheme scheme = GUIColorScheme("uniform", RGBColor::BLACK, "road", true);
174  scheme.addColor(RGBColor::GREY, 1, "Sidewalk");
175  scheme.addColor(RGBColor(192, 66, 44), 2, "bike lane");
176  scheme.addColor(RGBColor(200, 255, 200), 3, "green verge");
177  scheme.addColor(RGBColor(150, 200, 200), 4, "waterway");
178  scheme.addColor(RGBColor(92, 92, 92), 5, "no passenger"); // paths, service roads etc
179  laneColorer.addScheme(scheme);
180  scheme = GUIColorScheme("by selection (lane-/streetwise)", RGBColor(128, 128, 128, 255), "unselected", true);
181  scheme.addColor(RGBColor(0, 80, 180, 255), 1, "selected");
182  laneColorer.addScheme(scheme);
183  scheme = GUIColorScheme("by permission code", RGBColor(240, 240, 240), "nobody");
184  scheme.addColor(RGBColor(10, 10, 10), (double)SVC_PASSENGER, "passenger");
185  scheme.addColor(RGBColor(128, 128, 128), (double)SVC_PEDESTRIAN, "pedestrian");
186  scheme.addColor(RGBColor(80, 80, 80), (double)(SVC_PEDESTRIAN | SVC_DELIVERY), "pedestrian_delivery");
187  scheme.addColor(RGBColor(192, 66, 44), (double)SVC_BICYCLE, "bicycle");
188  scheme.addColor(RGBColor(40, 100, 40), (double)SVC_BUS, "bus");
189  scheme.addColor(RGBColor(166, 147, 26), (double)SVC_TAXI, "taxi");
190  scheme.addColor(RGBColor::BLACK, (double)(SVCAll & ~SVC_NON_ROAD), "normal_road");
191  scheme.addColor(RGBColor::BLACK, (double)(SVCAll & ~(SVC_PEDESTRIAN | SVC_NON_ROAD)), "disallow_pedestrian");
192  scheme.addColor(RGBColor(255, 206, 0), (double)(SVCAll & ~(SVC_PEDESTRIAN | SVC_BICYCLE | SVC_MOPED | SVC_NON_ROAD)), "motorway");
193  scheme.addColor(RGBColor(150, 200, 200), (double)SVC_SHIP, "waterway");
194  scheme.addColor(RGBColor::GREEN, (double)SVCAll, "all");
195  laneColorer.addScheme(scheme);
196 
197  scheme = GUIColorScheme("by allowed speed (lanewise)", RGBColor::RED);
198  scheme.addColor(RGBColor::YELLOW, (double)(30 / 3.6));
199  scheme.addColor(RGBColor::GREEN, (double)(55 / 3.6));
200  scheme.addColor(RGBColor::CYAN, (double)(80 / 3.6));
201  scheme.addColor(RGBColor::BLUE, (double)(120 / 3.6));
202  scheme.addColor(RGBColor::MAGENTA, (double)(150 / 3.6));
203  laneColorer.addScheme(scheme);
204 
205  scheme = GUIColorScheme("by lane number (streetwise)", RGBColor::RED);
206  scheme.addColor(RGBColor::BLUE, (double)5);
207  laneColorer.addScheme(scheme);
208 
209  scheme = GUIColorScheme("by given length/geometrical length", RGBColor::BLACK);
210  scheme.addColor(RGBColor::RED, 0.25);
211  scheme.addColor(RGBColor::YELLOW, 0.5);
212  scheme.addColor(RGBColor(179, 179, 179, 255), (double)1.0);
213  scheme.addColor(RGBColor::GREEN, (double)2.0);
214  scheme.addColor(RGBColor::BLUE, (double)4.0);
215  laneColorer.addScheme(scheme);
216  laneColorer.addScheme(GUIColorScheme("by angle", RGBColor::YELLOW, "", true));
217 
218  scheme = GUIColorScheme("by priority", RGBColor::YELLOW);
219  scheme.addColor(RGBColor::RED, (double) - 20);
220  scheme.addColor(RGBColor::GREEN, (double)20);
221  scheme.setAllowsNegativeValues(true);
222  laneColorer.addScheme(scheme);
223  scheme = GUIColorScheme("by height at start", RGBColor::RED);
224  scheme.addColor(RGBColor::BLUE, (double) - 10);
225  scheme.addColor(RGBColor::YELLOW, (double)50);
226  scheme.addColor(RGBColor::GREEN, (double)100);
227  scheme.addColor(RGBColor::MAGENTA, (double)200);
228  scheme.setAllowsNegativeValues(true);
229  laneColorer.addScheme(scheme);
230  scheme = GUIColorScheme("by height at segment start", RGBColor::RED);
231  scheme.addColor(RGBColor::BLUE, (double) - 10);
232  scheme.addColor(RGBColor::YELLOW, (double)50);
233  scheme.addColor(RGBColor::GREEN, (double)100);
234  scheme.addColor(RGBColor::MAGENTA, (double)200);
235  scheme.setAllowsNegativeValues(true);
236  laneColorer.addScheme(scheme);
237  scheme = GUIColorScheme("by inclination", RGBColor::GREY);
238  scheme.addColor(RGBColor::YELLOW, (double) .1);
239  scheme.addColor(RGBColor::RED, (double) .3);
240  scheme.addColor(RGBColor::GREEN, (double) - .1);
241  scheme.addColor(RGBColor::BLUE, (double) - .3);
242  scheme.setAllowsNegativeValues(true);
243  laneColorer.addScheme(scheme);
244  scheme = GUIColorScheme("by segment inclination", RGBColor::GREY);
245  scheme.addColor(RGBColor::YELLOW, (double) .1);
246  scheme.addColor(RGBColor::RED, (double) .3);
247  scheme.addColor(RGBColor::GREEN, (double) - .1);
248  scheme.addColor(RGBColor::BLUE, (double) - .3);
249  scheme.setAllowsNegativeValues(true);
250  laneColorer.addScheme(scheme);
251 
252  myVisualizationSettings->laneColorer = laneColorer;
253 
254  GUIColorer junctionColorer;
255  scheme = GUIColorScheme("uniform", RGBColor(102, 0, 0), "", true);
256  scheme.addColor(RGBColor(204, 0, 0), 1, "shape not computed");
257  scheme.addColor(RGBColor(153, 0, 0), 2, "geometry points");
258  junctionColorer.addScheme(scheme);
259  scheme = GUIColorScheme("by selection", RGBColor(128, 128, 128, 255), "unselected", true);
260  scheme.addColor(RGBColor(0, 80, 180, 255), 1, "selected");
261  junctionColorer.addScheme(scheme);
262  scheme = GUIColorScheme("by type", RGBColor::GREEN, "traffic_light", true);
263  scheme.addColor(RGBColor(0, 128, 0), 1, "traffic_light_unregulated");
264  scheme.addColor(RGBColor::YELLOW, 2, "priority");
265  scheme.addColor(RGBColor::RED, 3, "priority_stop");
266  scheme.addColor(RGBColor::BLUE, 4, "right_before_left");
267  scheme.addColor(RGBColor::CYAN, 5, "allway_stop");
268  scheme.addColor(RGBColor::GREY, 6, "district");
269  scheme.addColor(RGBColor::MAGENTA, 7, "unregulated");
270  scheme.addColor(RGBColor::BLACK, 8, "dead_end");
271  scheme.addColor(RGBColor::ORANGE, 9, "rail_signal");
272  scheme.addColor(RGBColor(192, 128, 64), 10, "zipper");
273  scheme.addColor(RGBColor(192, 255, 192), 11, "traffic_light_right_on_red");
274  scheme.addColor(RGBColor(128, 0, 128), 12, "rail_crossing"); // dark purple
275  junctionColorer.addScheme(scheme);
276  myVisualizationSettings->junctionColorer = junctionColorer;
277 
278  if (myTestingMode && OptionsCont::getOptions().isSet("window-size")) {
279  std::vector<std::string> windowSize = OptionsCont::getOptions().getStringVector("window-size");
280  assert(windowSize.size() == 2);
281  myTestingWidth = GNEAttributeCarrier::parse<int>(windowSize[0]);
282  myTestingHeight = GNEAttributeCarrier::parse<int>(windowSize[1]);
283  }
284 }
285 
286 
288 
289 
290 void
292 
293 
294 void
296  // build coloring tools
297  {
298  const std::vector<std::string>& names = gSchemeStorage.getNames();
299  for (std::vector<std::string>::const_iterator i = names.begin(); i != names.end(); ++i) {
300  cw.getColoringSchemesCombo().appendItem((*i).c_str());
301  if ((*i) == myVisualizationSettings->name) {
302  cw.getColoringSchemesCombo().setCurrentItem(cw.getColoringSchemesCombo().getNumItems() - 1);
303  }
304  }
305  cw.getColoringSchemesCombo().setNumVisible(MAX2(5, (int)names.size() + 1));
306  }
307  // for junctions
308  new FXButton(cw.getLocatorPopup(),
309  "\tLocate Junction\tLocate a junction within the network.",
311  ICON_ABOVE_TEXT | FRAME_THICK | FRAME_RAISED);
312  // for edges
313  new FXButton(cw.getLocatorPopup(),
314  "\tLocate Street\tLocate a street within the network.",
316  ICON_ABOVE_TEXT | FRAME_THICK | FRAME_RAISED);
317  // for tls
318  new FXButton(cw.getLocatorPopup(),
319  "\tLocate TLS\tLocate a tls within the network.",
321  ICON_ABOVE_TEXT | FRAME_THICK | FRAME_RAISED);
322  // for additional stuff
323  new FXButton(cw.getLocatorPopup(),
324  "\tLocate Additional\tLocate an additional structure within the network.",
326  ICON_ABOVE_TEXT | FRAME_THICK | FRAME_RAISED);
327  // for pois
328  new FXButton(cw.getLocatorPopup(),
329  "\tLocate PoI\tLocate a PoI within the network.",
331  ICON_ABOVE_TEXT | FRAME_THICK | FRAME_RAISED);
332  // for polygons
333  new FXButton(cw.getLocatorPopup(),
334  "\tLocate Polygon\tLocate a Polygon within the network.",
336  ICON_ABOVE_TEXT | FRAME_THICK | FRAME_RAISED);
337 }
338 
339 
340 bool
341 GNEViewNet::setColorScheme(const std::string& name) {
342  if (!gSchemeStorage.contains(name)) {
343  return false;
344  }
345  if (myVisualizationChanger != 0) {
346  if (myVisualizationChanger->getCurrentScheme() != name) {
348  }
349  }
350  myVisualizationSettings = &gSchemeStorage.get(name.c_str());
351  update();
352  return true;
353 }
354 
355 
356 void
357 GNEViewNet::setStatusBarText(const std::string& text) {
358  myApp->setStatusBarText(text);
359 }
360 
361 
362 bool
364  return mySelectEdges;
365 }
366 
367 
368 bool
370  if (myEditMode == GNE_MODE_CONNECT) {
371  return true;
372  } else if (myMenuCheckShowConnections->shown() == false) {
373  return false;
374  } else {
375  return (myMenuCheckShowConnections->getCheck() != 0);
376  }
377 }
378 
379 
380 bool
382  return (myMenuCheckExtendToEdgeNodes->getCheck() != 0);
383 }
384 
385 
386 void
387 GNEViewNet::setSelectionScaling(double selectionScale) {
388  myVisualizationSettings->selectionScale = selectionScale;
389 }
390 
391 
392 bool
394  return (myMenuCheckChangeAllPhases->getCheck() != 0);
395 }
396 
397 
398 bool
400  return (myEditMode == GNE_MODE_MOVE) && (myMenuCheckShowBubbleOverJunction->getCheck());
401 }
402 
403 
404 bool
406  return myTestingMode;
407 }
408 
409 int
410 GNEViewNet::doPaintGL(int mode, const Boundary& bound) {
411  // init view settings
412  glRenderMode(mode);
413  glMatrixMode(GL_MODELVIEW);
414  glPushMatrix();
415  glDisable(GL_TEXTURE_2D);
416  glDisable(GL_ALPHA_TEST);
417  glDisable(GL_BLEND);
418  glEnable(GL_DEPTH_TEST);
419 
420  // visualize rectangular selection
421  if (myAmInRectSelect) {
422  glPushMatrix();
423  glTranslated(0, 0, GLO_MAX - 1);
425  glLineWidth(2);
426  glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
427  glBegin(GL_QUADS);
428  glVertex2d(mySelCorner1.x(), mySelCorner1.y());
429  glVertex2d(mySelCorner1.x(), mySelCorner2.y());
430  glVertex2d(mySelCorner2.x(), mySelCorner2.y());
431  glVertex2d(mySelCorner2.x(), mySelCorner1.y());
432  glEnd();
433  glPopMatrix();
434  }
435 
436  // compute lane width
437  double lw = m2p(SUMO_const_laneWidth);
438  // draw decals (if not in grabbing mode)
439  if (!myUseToolTips) {
440  drawDecals();
441  // depending of the visualizationSettings, enable or disable check box show grid
443  myMenuCheckShowGrid->setCheck(true);
444  paintGLGrid();
445  } else {
446  myMenuCheckShowGrid->setCheck(false);
447  }
448  if (myTestingMode) {
449  if (myTestingWidth > 0 && (getWidth() != myTestingWidth || getHeight() != myTestingHeight)) {
450  // only resize once to avoid flickering
451  //std::cout << " before resize: view=" << getWidth() << ", " << getHeight() << " app=" << myApp->getWidth() << ", " << myApp->getHeight() << "\n";
452  myApp->resize(myTestingWidth + myTestingWidth - getWidth(), myTestingHeight + myTestingHeight - getHeight());
453  //std::cout << " directly after resize: view=" << getWidth() << ", " << getHeight() << " app=" << myApp->getWidth() << ", " << myApp->getHeight() << "\n";
454  myTestingWidth = 0;
455  }
456  //std::cout << " fixed: view=" << getWidth() << ", " << getHeight() << " app=" << myApp->getWidth() << ", " << myApp->getHeight() << "\n";
457  // draw pink square in the upper left corner on top of everything
458  glPushMatrix();
459  const double size = p2m(32);
460  Position center = screenPos2NetPos(8, 8);
462  glTranslated(center.x(), center.y(), GLO_MAX - 1);
463  glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
464  glBegin(GL_QUADS);
465  glVertex2d(0, 0);
466  glVertex2d(0, -size);
467  glVertex2d(size, -size);
468  glVertex2d(size, 0);
469  glEnd();
470  glPopMatrix();
471 
472  // Reset textures due bug #2780. This solution is only provisional, and must be updated in the future
474  }
475  }
476  glLineWidth(1);
477  glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
478  const float minB[2] = { (float)bound.xmin(), (float)bound.ymin() };
479  const float maxB[2] = { (float)bound.xmax(), (float)bound.ymax() };
481  glEnable(GL_POLYGON_OFFSET_FILL);
482  glEnable(GL_POLYGON_OFFSET_LINE);
484  int hits2 = myGrid->Search(minB, maxB, *myVisualizationSettings);
485 
486  glTranslated(0, 0, GLO_ADDITIONAL);
487  for (std::map<const GUIGlObject*, int>::iterator i = myAdditionallyDrawn.begin(); i != myAdditionallyDrawn.end(); ++i) {
488  (i->first)->drawGLAdditional(this, *myVisualizationSettings);
489  }
490  glPopMatrix();
491  return hits2;
492 }
493 
494 
495 long
496 GNEViewNet::onLeftBtnPress(FXObject*, FXSelector, void* data) {
497  FXEvent* e = (FXEvent*) data;
498  setFocus();
499  // limit position depending of myMenuCheckShowGrid
500  Position clickedPosition = snapToActiveGrid(getPositionInformation());
501 
502  // interpret object under curser
503  if (makeCurrent()) {
504  int id = getObjectUnderCursor();
507  GNEJunction* pointed_junction = 0;
508  GNELane* pointed_lane = 0;
509  GNEEdge* pointed_edge = 0;
510  GNEPOI* pointed_poi = 0;
511  GNEPoly* pointed_poly = 0;
512  GNECrossing* pointed_crossing = 0;
513  GNEAdditional* pointed_additional = 0;
514  GNEConnection* pointed_connection = 0;
515  if (pointed) {
516  switch (pointed->getType()) {
517  case GLO_JUNCTION:
518  pointed_junction = (GNEJunction*)pointed;
519  break;
520  case GLO_EDGE:
521  pointed_edge = (GNEEdge*)pointed;
522  break;
523  case GLO_LANE:
524  pointed_lane = (GNELane*)pointed;
525  pointed_edge = &(pointed_lane->getParentEdge());
526  break;
527  case GLO_POI:
528  pointed_poi = (GNEPOI*)pointed;
529  break;
530  case GLO_POLYGON:
531  pointed_poly = (GNEPoly*)pointed;
532  break;
533  case GLO_CROSSING:
534  pointed_crossing = (GNECrossing*)pointed;
535  break;
536  case GLO_ADDITIONAL:
537  pointed_additional = (GNEAdditional*)pointed;
538  break;
539  case GLO_CONNECTION:
540  pointed_connection = (GNEConnection*)pointed;
541  break;
542  default:
543  pointed = 0;
544  break;
545  }
546  }
547 
548  // decide what to do based on mode
549  switch (myEditMode) {
550  case GNE_MODE_CREATE_EDGE: {
551  if ((e->state & CONTROLMASK) == 0) {
552  // allow moving when control is held down
553  if (!myUndoList->hasCommandGroup()) {
554  myUndoList->p_begin("create new " + toString(SUMO_TAG_EDGE));
555  }
556  if (!pointed_junction) {
557  pointed_junction = myNet->createJunction(clickedPosition, myUndoList);
558  }
559  if (myCreateEdgeSource == 0) {
560  myCreateEdgeSource = pointed_junction;
562  update();
563  } else {
564  if (myCreateEdgeSource != pointed_junction) {
565  // may fail to prevent double edges
566  GNEEdge* newEdge = myNet->createEdge(
568  if (newEdge) {
569  // create another edge, if create opposite edge is enabled
570  if (myAutoCreateOppositeEdge->getCheck()) {
572  }
574 
575  if (myUndoList->hasCommandGroup()) {
576  myUndoList->p_end();
577  } else {
578  std::cout << "edge created without an open CommandGroup )-:\n";
579  }
580  if (myChainCreateEdge->getCheck()) {
581  myCreateEdgeSource = pointed_junction;
583  myUndoList->p_begin("create new " + toString(SUMO_TAG_EDGE));
584  } else {
585  myCreateEdgeSource = 0;
586  }
587  } else {
588  setStatusBarText("An " + toString(SUMO_TAG_EDGE) + " with the same geometry already exists!");
589  }
590  } else {
591  setStatusBarText("Start- and endpoint for an " + toString(SUMO_TAG_EDGE) + " must be distinct!");
592  }
593  update();
594  }
595  }
596  // process click
597  processClick(e, data);
598  break;
599  }
600  case GNE_MODE_MOVE: {
601  if (pointed_poly) {
602  myPolyToMove = pointed_poly;
604  } else if (pointed_poi) {
605  myPoiToMove = pointed_poi;
607  } else if (pointed_junction) {
608  if (gSelected.isSelected(GLO_JUNCTION, pointed_junction->getGlID())) {
609  myMoveSelection = true;
610  } else {
611  myJunctionToMove = pointed_junction;
612  }
614  } else if (pointed_edge) {
615  if (gSelected.isSelected(GLO_EDGE, pointed_edge->getGlID())) {
616  myMoveSelection = true;
617  } else {
618  myEdgeToMove = pointed_edge;
619  }
621  } else if (pointed_additional) {
622  if (gSelected.isSelected(GLO_ADDITIONAL, pointed_additional->getGlID())) {
623  myMoveSelection = true;
624  } else {
625  // Only move additional if can be moved
626  if (pointed_additional->isAdditionalBlocked() == false) {
627  myAdditionalToMove = pointed_additional;
628  if (myAdditionalToMove->getLane()) {
630  // Obtain start position
631  double startPos = GNEAttributeCarrier::parse<double>(myAdditionalToMove->getAttribute(SUMO_ATTR_STARTPOS));
633  // Obtain end position
634  double endPos = GNEAttributeCarrier::parse<double>(myAdditionalToMove->getAttribute(SUMO_ATTR_ENDPOS));
635  // Save both values in myOldAdditionalPosition
636  myOldAdditionalPosition.set(startPos, endPos);
638  // Obtain length attribute
639  double length = GNEAttributeCarrier::parse<double>(myAdditionalToMove->getAttribute(SUMO_ATTR_LENGTH));
640  // Save both values in myOldAdditionalPosition
641  myOldAdditionalPosition.set(startPos, length);
642  } else {
643  // Save only startpos in myOldAdditionalPosition
644  myOldAdditionalPosition.set(startPos, 0);
645  }
647  myOldAdditionalPosition.set(GNEAttributeCarrier::parse<double>(myAdditionalToMove->getAttribute(SUMO_ATTR_POSITION)), 0);
648  }
649  // Set myAdditionalMovingReference
650  myAdditionalMovingReference.set(pointed_additional->getLane()->getShape().nearest_offset_to_point2D(clickedPosition, false), 0, 0);
651  } else {
652  // Set myOldAdditionalPosition and myAdditionalMovingReference
654  myAdditionalMovingReference = pointed_additional->getPositionInView() - clickedPosition;
655  }
656  }
657  }
658  } else {
659  // process click
660  processClick(e, data);
661  }
662  update();
663  break;
664  }
665  case GNE_MODE_DELETE: {
666  // Check if Control key is pressed
667  bool markElementMode = (((FXEvent*)data)->state & CONTROLMASK) != 0;
668  GNEAttributeCarrier* ac = dynamic_cast<GNEAttributeCarrier*>(pointed);
669  if ((pointed_lane != NULL) && (mySelectEdges == true)) {
670  ac = pointed_edge;
671  }
672  if (ac) {
673  // if pointed element is an attribute carrier, remove it or mark it
674  if (markElementMode) {
678  }
679  } else if (myViewParent->getDeleteFrame()->getMarkedAttributeCarrier() != NULL) {
682  } else {
684  }
685  } else {
686  // process click
687  processClick(e, data);
688  }
689  break;
690  }
691  case GNE_MODE_INSPECT: {
692  GNEAttributeCarrier* pointedAC = 0;
693  GUIGlObject* pointedO = 0;
694  if (pointed_junction) {
695  pointedAC = pointed_junction;
696  pointedO = pointed_junction;
697  } else if (pointed_lane) { // implies pointed_edge
698  if (mySelectEdges == true) {
699  pointedAC = pointed_edge;
700  pointedO = pointed_edge;
701  } else {
702  pointedAC = pointed_lane;
703  pointedO = pointed_lane;
704  }
705  } else if (pointed_edge) {
706  pointedAC = pointed_edge;
707  pointedO = pointed_edge;
708  } else if (pointed_crossing) {
709  pointedAC = pointed_crossing;
710  pointedO = pointed_crossing;
711  } else if (pointed_additional) {
712  pointedAC = pointed_additional;
713  pointedO = pointed_additional;
714  } else if (pointed_connection) {
715  pointedAC = pointed_connection;
716  pointedO = pointed_connection;
717  }
718  // obtain selected ACs
719  std::vector<GNEAttributeCarrier*> selectedElements;
720  std::vector<GNEAttributeCarrier*> selectedFilteredElements;
721  if (pointedO && gSelected.isSelected(pointedO->getType(), pointedO->getGlID())) {
722  std::set<GUIGlID> selectedIDs = gSelected.getSelected(pointedO->getType());
723  selectedElements = myNet->retrieveAttributeCarriers(selectedIDs, pointedO->getType());
724  // filter selected elements (example: if we have two E2 and one busStop selected, and user click over one E2,
725  // attribues of busstop musn't be shown
726  for (std::vector<GNEAttributeCarrier*>::iterator i = selectedElements.begin(); i != selectedElements.end(); i++) {
727  if ((*i)->getTag() == pointedAC->getTag()) {
728  selectedFilteredElements.push_back(*i);
729  }
730  }
731  }
732  // Inspect seleted ACs, or single clicked AC
733  if (selectedFilteredElements.size() > 0) {
734  myViewParent->getInspectorFrame()->inspectMultisection(selectedFilteredElements);
735  } else if (pointedAC != NULL) {
737  }
738  // process click
739  processClick(e, data);
740  // focus upper element of inspector frame
741  if ((selectedFilteredElements.size() > 0) || (pointedAC != NULL)) {
743  }
744  update();
745  break;
746  }
747  case GNE_MODE_SELECT:
748  if ((pointed_lane != NULL) && (mySelectEdges == true)) {
749  gSelected.toggleSelection(pointed_edge->getGlID());
750  } else if (pointed) {
751  gSelected.toggleSelection(pointed->getGlID());
752  }
753 
754  myAmInRectSelect = (((FXEvent*)data)->state & SHIFTMASK) != 0;
755  if (myAmInRectSelect) {
758  } else {
759  // process click
760  processClick(e, data);
761  }
762  update();
763  break;
764 
765  case GNE_MODE_CONNECT: {
766  if (pointed_lane) {
767  const bool mayPass = (((FXEvent*)data)->state & SHIFTMASK) != 0;
768  const bool allowConflict = (((FXEvent*)data)->state & CONTROLMASK) != 0;
769  myViewParent->getConnectorFrame()->handleLaneClick(pointed_lane, mayPass, allowConflict, true);
770  update();
771  }
772  // process click
773  processClick(e, data);
774  break;
775  }
776  case GNE_MODE_TLS: {
777  if (pointed_junction) {
778  myViewParent->getTLSEditorFrame()->editJunction(pointed_junction);
779  update();
780  }
781  // process click
782  processClick(e, data);
783  break;
784  }
785  case GNE_MODE_ADDITIONAL: {
786  if (pointed_additional == NULL) {
787  GNENetElement* netElement = dynamic_cast<GNENetElement*>(pointed);
789  // process click or update view depending of the result of "add additional"
791  update();
792  // process click
793  processClick(e, data);
794  }
795  }
796 
797  break;
798  }
799  case GNE_MODE_CROSSING: {
800  if (pointed_crossing == NULL) {
801  GNENetElement* netElement = dynamic_cast<GNENetElement*>(pointed);
802  if (myViewParent->getCrossingFrame()->addCrossing(netElement)) {
803  update();
804  }
805  }
806  // process click
807  processClick(e, data);
808  break;
809  }
810  default: {
811  // process click
812  processClick(e, data);
813  }
814  }
815  makeNonCurrent();
816  }
817  return 1;
818 }
819 
820 
821 long
822 GNEViewNet::onLeftBtnRelease(FXObject* obj, FXSelector sel, void* data) {
824  if (myPolyToMove) {
825  myPolyToMove = 0;
826  } else if (myPoiToMove) {
827  myPoiToMove = 0;
828  } else if (myJunctionToMove) {
829  // position is already up to date but we must register with myUndoList
832  }
833  myJunctionToMove = 0;
834  } else if (myEdgeToMove) {
835  // shape is already up to date but we must register with myUndoList
836  const std::string& newShape = myEdgeToMove->getAttribute(SUMO_ATTR_SHAPE);
838  myEdgeToMove = 0;
839  } else if (myAdditionalToMove) {
840  if (myAdditionalToMove->getLane()) {
842  myAdditionalToMove = 0;
843  } else {
845  myAdditionalToMove = 0;
846  }
847  } else if (myMoveSelection) {
848  // positions and shapes are already up to date but we must register with myUndoList
850  myMoveSelection = false;
851  } else if (myAmInRectSelect) {
852  myAmInRectSelect = false;
853  // shift held down on mouse-down and mouse-up
854  if (((FXEvent*)data)->state & SHIFTMASK) {
855  if (makeCurrent()) {
856  Boundary b;
857  b.add(mySelCorner1);
858  b.add(mySelCorner2);
860  makeNonCurrent();
861  }
862  }
863  update();
864  }
865  return 1;
866 }
867 
868 
869 long
870 GNEViewNet::onDoubleClicked(FXObject*, FXSelector, void*) {
871  // If current edit mode is INSPECT or ADDITIONAL
873  setFocus();
874  // interpret object under curser
875  if (makeCurrent()) {
876  int id = getObjectUnderCursor();
879  GNEAdditional* pointed_additional = dynamic_cast<GNEAdditional*>(pointed);
880  // If pointed element is an additional
881  if (pointed_additional != NULL) {
882  // If additional has a additional dialog, open it.
883  pointed_additional->openAdditionalDialog();
884  }
885  makeNonCurrent();
886  }
887  }
888  return 1;
889 }
890 
891 
892 long
893 GNEViewNet::onMouseMove(FXObject* obj, FXSelector sel, void* data) {
894  GUISUMOAbstractView::onMouseMove(obj, sel, data);
895  // limit position depending of myMenuCheckShowGrid
896  Position clickedPosition = snapToActiveGrid(getPositionInformation());
897  // in delete mode object under cursor must be checked in every mouse movement
898  if (myEditMode == GNE_MODE_DELETE) {
899  setFocus();
900  // show object information in delete frame
901  if (makeCurrent()) {
902  // obtain ac of globjectID
903  int glid = getObjectUnderCursor();
906  // Update current label of delete frame
908  // show childs of object in GNEDeleteFrame if current there isn't a marked element
911  }
912  }
913  } else {
914  if (myPolyToMove) {
915  myMoveSrc = myPolyToMove->moveGeometry(myMoveSrc, clickedPosition);
916  } else if (myPoiToMove) {
917  myPoiToMove->move(clickedPosition);
918  } else if (myJunctionToMove) {
919  // check if one of their junctions neighboors is in the position objective
920  std::vector<GNEJunction*> junctionNeighbours = myJunctionToMove->getJunctionNeighbours();
921  for (std::vector<GNEJunction*>::iterator i = junctionNeighbours.begin(); i != junctionNeighbours.end(); i++) {
922  if ((*i)->getPosition() == clickedPosition) {
923  return 0;
924  }
925  }
926  myJunctionToMove->move(clickedPosition);
927  } else if (myEdgeToMove) {
928  myMoveSrc = myEdgeToMove->moveGeometry(myMoveSrc, clickedPosition);
929  } else if (myAdditionalToMove) {
930  // If additional is placed over lane, move it across it
931  if (myAdditionalToMove->getLane()) {
932  double posOfMouseOverLane = myAdditionalToMove->getLane()->getShape().nearest_offset_to_point2D(clickedPosition, false);
934  myAdditionalMovingReference.set(posOfMouseOverLane, 0, 0);
935  } else {
936  // Calculate offset movement
937  Position offsetPosition = clickedPosition - myOldAdditionalPosition;
938  myAdditionalToMove->moveAdditionalGeometry(myOldAdditionalPosition + offsetPosition + myAdditionalMovingReference);
939  }
940  update();
941  } else if (myMoveSelection) {
942  Position moveTarget = clickedPosition;
943  myNet->moveSelection(myMoveSrc, moveTarget);
944  myMoveSrc = moveTarget;
945  } else if (myAmInRectSelect) {
947  update();
948  }
949  }
950  return 1;
951 }
952 
953 
954 void
955 GNEViewNet::abortOperation(bool clearSelection) {
956  // steal focus from any text fields
957  setFocus();
958  if (myCreateEdgeSource != NULL) {
959  // remove current created edge source
961  myCreateEdgeSource = 0;
962  } else if (myEditMode == GNE_MODE_SELECT) {
963  myAmInRectSelect = false;
964  if (clearSelection) {
965  gSelected.clear();
966  }
967  } else if (myEditMode == GNE_MODE_CONNECT) {
969  } else if (myEditMode == GNE_MODE_TLS) {
971  } else if (myEditMode == GNE_MODE_MOVE) {
973  }
974  myUndoList->p_abort();
975 }
976 
977 
978 void
981  setStatusBarText("Cannot delete in this mode");
982  } else {
983  myUndoList->p_begin("delete selection");
988  myUndoList->p_end();
989  }
990 }
991 
992 
993 void
995  if (myEditMode == GNE_MODE_CONNECT) {
997  } else if (myEditMode == GNE_MODE_TLS) {
999  } else if (myEditMode == GNE_MODE_MOVE && myCurrentPoly != 0) {
1000  if (myCurrentPoly->getEditedJunction() != 0) {
1003  update();
1004  }
1005  }
1006 }
1007 
1008 
1009 void
1011  // if current focus is placed over GNEViewnet, set focus to current frame
1012  if (hasFocus() && (myCurrentFrame != NULL)) {
1014  }
1015 }
1016 
1017 
1018 void
1020  switch (selid) {
1023  break;
1024  case MID_GNE_MODE_MOVE:
1026  break;
1027  case MID_GNE_MODE_DELETE:
1029  break;
1030  case MID_GNE_MODE_INSPECT:
1032  break;
1033  case MID_GNE_MODE_SELECT:
1035  break;
1036  case MID_GNE_MODE_CONNECT:
1038  break;
1039  case MID_GNE_MODE_TLS:
1041  break;
1044  break;
1045  case MID_GNE_MODE_CROSSING:
1047  break;
1048  default:
1049  throw ProcessError("invalid edit mode called by hotkey");
1050  break;
1051  }
1052 }
1053 
1054 
1055 void
1058 }
1059 
1060 
1063  return myViewParent;
1064 }
1065 
1066 
1067 GNENet*
1069  return myNet;
1070 }
1071 
1072 
1073 GNEUndoList*
1075  return myUndoList;
1076 }
1077 
1078 
1079 EditMode
1081  return myEditMode;
1082 }
1083 
1084 
1085 bool
1088 }
1089 
1090 
1091 GNEJunction*
1093  GNEJunction* junction = 0;
1094  if (makeCurrent()) {
1095  int id = getObjectAtPosition(myPopupSpot);
1098  if (pointed) {
1099  switch (pointed->getType()) {
1100  case GLO_JUNCTION:
1101  junction = (GNEJunction*)pointed;
1102  break;
1103  default:
1104  break;
1105  }
1106  }
1107  }
1108  return junction;
1109 }
1110 
1111 
1112 
1113 
1114 GNEEdge*
1116  GNEEdge* edge = 0;
1117  if (makeCurrent()) {
1118  int id = getObjectAtPosition(myPopupSpot);
1121  if (pointed) {
1122  switch (pointed->getType()) {
1123  case GLO_EDGE:
1124  edge = (GNEEdge*)pointed;
1125  break;
1126  case GLO_LANE:
1127  edge = &(((GNELane*)pointed)->getParentEdge());
1128  break;
1129  default:
1130  break;
1131  }
1132  }
1133  }
1134  return edge;
1135 }
1136 
1137 
1138 GNELane*
1140  GNELane* lane = 0;
1141  if (makeCurrent()) {
1142  int id = getObjectAtPosition(myPopupSpot);
1145  if (pointed) {
1146  if (pointed->getType() == GLO_LANE) {
1147  lane = (GNELane*)pointed;
1148  }
1149  }
1150  }
1151  return lane;
1152 }
1153 
1154 
1155 std::set<GNEEdge*>
1157  std::set<GNEEdge*> result;
1158  if (makeCurrent()) {
1159  const std::vector<GUIGlID> ids = getObjectsAtPosition(myPopupSpot, 1.0);
1160  for (std::vector<GUIGlID>::const_iterator it = ids.begin(); it != ids.end(); ++it) {
1163  if (pointed) {
1164  switch (pointed->getType()) {
1165  case GLO_EDGE:
1166  result.insert((GNEEdge*)pointed);
1167  break;
1168  case GLO_LANE:
1169  result.insert(&(((GNELane*)pointed)->getParentEdge()));
1170  break;
1171  default:
1172  break;
1173  }
1174  }
1175  }
1176  }
1177  return result;
1178 }
1179 
1180 
1181 long
1182 GNEViewNet::onCmdSetModeCreateEdge(FXObject*, FXSelector, void*) {
1184  return 1;
1185 }
1186 
1187 
1188 long
1189 GNEViewNet::onCmdSetModeMove(FXObject*, FXSelector, void*) {
1191  return 1;
1192 }
1193 
1194 
1195 long
1196 GNEViewNet::onCmdSetModeDelete(FXObject*, FXSelector, void*) {
1198  return 1;
1199 }
1200 
1201 
1202 long
1203 GNEViewNet::onCmdSetModeInspect(FXObject*, FXSelector, void*) {
1205  return 1;
1206 }
1207 
1208 
1209 long
1210 GNEViewNet::onCmdSetModeSelect(FXObject*, FXSelector, void*) {
1212  return 1;
1213 }
1214 
1215 
1216 long
1217 GNEViewNet::onCmdSetModeConnect(FXObject*, FXSelector, void*) {
1219  return 1;
1220 }
1221 
1222 
1223 long
1224 GNEViewNet::onCmdSetModeTLS(FXObject*, FXSelector, void*) {
1226  return 1;
1227 }
1228 
1229 
1230 long
1231 GNEViewNet::onCmdSetModeAdditional(FXObject*, FXSelector, void*) {
1233  return 1;
1234 }
1235 
1236 
1237 long
1238 GNEViewNet::onCmdSetModeCrossing(FXObject*, FXSelector, void*) {
1240  return 1;
1241 }
1242 
1243 
1244 long
1245 GNEViewNet::onCmdSplitEdge(FXObject*, FXSelector, void*) {
1247  if (edge != 0) {
1249  }
1250  return 1;
1251 }
1252 
1253 
1254 long
1255 GNEViewNet::onCmdSplitEdgeBidi(FXObject*, FXSelector, void*) {
1256  std::set<GNEEdge*> edges = getEdgesAtCursorPosition(myPopupSpot);
1257  if (edges.size() != 0) {
1258  myNet->splitEdgesBidi(edges, (*edges.begin())->getSplitPos(myPopupSpot), myUndoList);
1259  }
1260  return 1;
1261 }
1262 
1263 
1264 long
1265 GNEViewNet::onCmdReverseEdge(FXObject*, FXSelector, void*) {
1267  if (edge != 0) {
1268  myNet->reverseEdge(edge, myUndoList);
1269  }
1270  return 1;
1271 }
1272 
1273 
1274 long
1275 GNEViewNet::onCmdAddReversedEdge(FXObject*, FXSelector, void*) {
1277  if (edge != 0) {
1279  }
1280  return 1;
1281 }
1282 
1283 
1284 long
1285 GNEViewNet::onCmdSetEdgeEndpoint(FXObject*, FXSelector, void*) {
1287  if (edge != 0) {
1289  }
1290  return 1;
1291 }
1292 
1293 
1294 long
1295 GNEViewNet::onCmdResetEdgeEndpoint(FXObject*, FXSelector, void*) {
1297  if (edge != 0) {
1299  }
1300  return 1;
1301 }
1302 
1303 
1304 long
1305 GNEViewNet::onCmdStraightenEdges(FXObject*, FXSelector, void*) {
1307  if (edge != 0) {
1308  if (gSelected.isSelected(GLO_EDGE, edge->getGlID())) {
1309  myUndoList->p_begin("straighten selected " + toString(SUMO_TAG_EDGE) + "s");
1310  std::vector<GNEEdge*> edges = myNet->retrieveEdges(true);
1311  for (std::vector<GNEEdge*>::iterator it = edges.begin(); it != edges.end(); it++) {
1312  (*it)->setAttribute(SUMO_ATTR_SHAPE, "", myUndoList);
1313  }
1314  myUndoList->p_end();
1315  } else {
1316  myUndoList->p_begin("straighten " + toString(SUMO_TAG_EDGE));
1318  myUndoList->p_end();
1319  }
1320  }
1321  return 1;
1322 }
1323 
1324 
1325 long
1326 GNEViewNet::onCmdSimplifyShape(FXObject*, FXSelector, void*) {
1327  if (myCurrentPoly != 0) {
1329  update();
1330  }
1331  return 1;
1332 }
1333 
1334 
1335 long
1336 GNEViewNet::onCmdDeleteGeometry(FXObject*, FXSelector, void*) {
1337  if (myCurrentPoly != 0) {
1339  update();
1340  }
1341  return 1;
1342 }
1343 
1344 
1345 long
1346 GNEViewNet::onCmdDuplicateLane(FXObject*, FXSelector, void*) {
1348  if (lane != 0) {
1349  if (gSelected.isSelected(GLO_LANE, lane->getGlID())) {
1350  myUndoList->p_begin("duplicate selected " + toString(SUMO_TAG_LANE) + "s");
1351  std::vector<GNELane*> lanes = myNet->retrieveLanes(true);
1352  for (std::vector<GNELane*>::iterator it = lanes.begin(); it != lanes.end(); it++) {
1354  }
1355  myUndoList->p_end();
1356  } else {
1357  myUndoList->p_begin("duplicate " + toString(SUMO_TAG_LANE));
1358  myNet->duplicateLane(lane, myUndoList);
1359  myUndoList->p_end();
1360  }
1361  }
1362  return 1;
1363 }
1364 
1365 
1366 long
1367 GNEViewNet::onCmdRestrictLaneSidewalk(FXObject*, FXSelector, void*) {
1368  return restrictLane(SVC_PEDESTRIAN);
1369 }
1370 
1371 
1372 long
1373 GNEViewNet::onCmdRestrictLaneBikelane(FXObject*, FXSelector, void*) {
1374  return restrictLane(SVC_BICYCLE);
1375 }
1376 
1377 
1378 long
1379 GNEViewNet::onCmdRestrictLaneBuslane(FXObject*, FXSelector, void*) {
1380  return restrictLane(SVC_BUS);
1381 }
1382 
1383 
1384 long
1385 GNEViewNet::onCmdAddRestrictedLaneSidewalk(FXObject*, FXSelector, void*) {
1387 }
1388 
1389 
1390 long
1391 GNEViewNet::onCmdAddRestrictedLaneBikelane(FXObject*, FXSelector, void*) {
1393 }
1394 
1395 
1396 long
1397 GNEViewNet::onCmdAddRestrictedLaneBuslane(FXObject*, FXSelector, void*) {
1398  return addRestrictedLane(SVC_BUS);
1399 }
1400 
1401 
1402 long
1403 GNEViewNet::onCmdRemoveRestrictedLaneSidewalk(FXObject*, FXSelector, void*) {
1405 }
1406 
1407 
1408 long
1409 GNEViewNet::onCmdRemoveRestrictedLaneBikelane(FXObject*, FXSelector, void*) {
1411 }
1412 
1413 
1414 long
1415 GNEViewNet::onCmdRemoveRestrictedLaneBuslane(FXObject*, FXSelector, void*) {
1416  return removeRestrictedLane(SVC_BUS);
1417 }
1418 
1419 
1420 bool
1423  if (lane != 0) {
1424  // Get selected lanes
1425  std::vector<GNELane*> lanes = myNet->retrieveLanes(true); ;
1426  // Declare map of edges and lanes
1427  std::map<GNEEdge*, GNELane*> mapOfEdgesAndLanes;
1428  // Iterate over selected lanes
1429  for (std::vector<GNELane*>::iterator i = lanes.begin(); i != lanes.end(); i++) {
1430  mapOfEdgesAndLanes[myNet->retrieveEdge((*i)->getParentEdge().getID())] = (*i);
1431  }
1432  // Throw warning dialog if there hare multiple lanes selected in the same edge
1433  if (mapOfEdgesAndLanes.size() != lanes.size()) {
1434  FXMessageBox::information(getApp(), MBOX_OK,
1435  "Multiple lane in the same edge selected", "%s",
1436  ("There are selected lanes that belong to the same edge.\n Only one lane per edge will be restricted for " + toString(vclass) + ".").c_str());
1437  }
1438  // If we handeln a set of lanes
1439  if (mapOfEdgesAndLanes.size() > 0) {
1440  // declare counter for number of Sidewalks
1441  int counter = 0;
1442  // iterate over selected lanes
1443  for (std::map<GNEEdge*, GNELane*>::iterator i = mapOfEdgesAndLanes.begin(); i != mapOfEdgesAndLanes.end(); i++) {
1444  if (i->first->hasRestrictedLane(vclass)) {
1445  counter++;
1446  }
1447  }
1448  // if all edges parent own a Sidewalk, stop function
1449  if (counter == (int)mapOfEdgesAndLanes.size()) {
1450  FXMessageBox::information(getApp(), MBOX_OK,
1451  ("Set vclass for " + toString(vclass) + " to selected lanes").c_str(), "%s",
1452  ("All lanes own already another lane in the same edge with a restriction for " + toString(vclass)).c_str());
1453  return 0;
1454  } else {
1455  if (myTestingMode == true) {
1456  WRITE_WARNING("Opening FXMessageBox of type 'question'");
1457  }
1458  // Ask confirmation to user
1459  FXuint answer = FXMessageBox::question(getApp(), MBOX_YES_NO,
1460  ("Set vclass for " + toString(vclass) + " to selected lanes").c_str(), "%s",
1461  (toString(mapOfEdgesAndLanes.size() - counter) + " lanes will be restricted for " + toString(vclass) + ". continue?").c_str());
1462  if (answer != 1) { //1:yes, 2:no, 4:esc
1463  // write warning if netedit is running in testing mode
1464  if ((answer == 2) && (myTestingMode == true)) {
1465  WRITE_WARNING("Closed FXMessageBox of type 'question' with 'No'");
1466  } else if ((answer == 4) && (myTestingMode == true)) {
1467  WRITE_WARNING("Closed FXMessageBox of type 'question' with 'ESC'");
1468  }
1469  return 0;
1470  } else {
1471  // write warning if netedit is running in testing mode
1472  if (myTestingMode == true) {
1473  WRITE_WARNING("Closed FXMessageBox of type 'question' with 'Yes'");
1474  }
1475  }
1476  }
1477  // begin undo operation
1478  myUndoList->p_begin("restrict lanes to " + toString(vclass));
1479  // iterate over selected lanes
1480  for (std::map<GNEEdge*, GNELane*>::iterator i = mapOfEdgesAndLanes.begin(); i != mapOfEdgesAndLanes.end(); i++) {
1481  // Transform lane to Sidewalk
1482  myNet->restrictLane(vclass, i->second, myUndoList);
1483  }
1484  // end undo operation
1485  myUndoList->p_end();
1486  } else {
1487  // If only have a single lane, start undo/redo operation
1488  myUndoList->p_begin("restrict lane to " + toString(vclass));
1489  // Transform lane to Sidewalk
1490  myNet->restrictLane(vclass, lane, myUndoList);
1491  // end undo operation
1492  myUndoList->p_end();
1493  }
1494  }
1495  return 1;
1496 }
1497 
1498 
1499 bool
1502  if (lane != 0) {
1503  // Get selected edges
1504  std::vector<GNEEdge*> edges = myNet->retrieveEdges(true);
1505  // get selected lanes
1506  std::vector<GNELane*> lanes = myNet->retrieveLanes(true);
1507  // Declare set of edges
1508  std::set<GNEEdge*> setOfEdges;
1509  // Fill set of edges with vector of edges
1510  for (std::vector<GNEEdge*>::iterator i = edges.begin(); i != edges.end(); i++) {
1511  setOfEdges.insert(*i);
1512  }
1513  // iterate over selected lanes
1514  for (std::vector<GNELane*>::iterator it = lanes.begin(); it != lanes.end(); it++) {
1515  // Insert pointer to edge into set of edges (To avoid duplicates)
1516  setOfEdges.insert(myNet->retrieveEdge((*it)->getParentEdge().getID()));
1517  }
1518  // If we handeln a set of edges
1519  if (setOfEdges.size() > 0) {
1520  // declare counter for number of restrictions
1521  int counter = 0;
1522  // iterate over set of edges
1523  for (std::set<GNEEdge*>::iterator it = setOfEdges.begin(); it != setOfEdges.end(); it++) {
1524  // update counter if edge has already a restricted lane of type "vclass"
1525  if ((*it)->hasRestrictedLane(vclass) == true) {
1526  counter++;
1527  }
1528  }
1529  // if all lanes own a Sidewalk, stop function
1530  if (counter == (int)setOfEdges.size()) {
1531  FXMessageBox::information(getApp(), MBOX_OK,
1532  ("Add vclass for" + toString(vclass) + " to selected lanes").c_str(), "%s",
1533  ("All lanes own already another lane in the same edge with a restriction for " + toString(vclass)).c_str());
1534  return 0;
1535  } else {
1536  if (myTestingMode == true) {
1537  WRITE_WARNING("Opening FXMessageBox of type 'question'");
1538  }
1539  // Ask confirmation to user
1540  FXuint answer = FXMessageBox::question(getApp(), MBOX_YES_NO,
1541  ("Add vclass for " + toString(vclass) + " to selected lanes").c_str(), "%s",
1542  (toString(setOfEdges.size() - counter) + " restrictions for " + toString(vclass) + " will be added. continue?").c_str());
1543  if (answer != 1) { //1:yes, 2:no, 4:esc
1544  // write warning if netedit is running in testing mode
1545  if ((answer == 2) && (myTestingMode == true)) {
1546  WRITE_WARNING("Closed FXMessageBox of type 'question' with 'No'");
1547  } else if ((answer == 4) && (myTestingMode == true)) {
1548  WRITE_WARNING("Closed FXMessageBox of type 'question' with 'ESC'");
1549  }
1550  return 0;
1551  } else {
1552  // write warning if netedit is running in testing mode
1553  if (myTestingMode == true) {
1554  WRITE_WARNING("Closed FXMessageBox of type 'question' with 'Yes'");
1555  }
1556  }
1557  }
1558  // begin undo operation
1559  myUndoList->p_begin("Add restrictions for " + toString(vclass));
1560  // iterate over set of edges
1561  for (std::set<GNEEdge*>::iterator it = setOfEdges.begin(); it != setOfEdges.end(); it++) {
1562  // add Sidewalk
1563  myNet->addSRestrictedLane(vclass, *(*it), myUndoList);
1564  }
1565  // end undo operation
1566  myUndoList->p_end();
1567  } else {
1568  // If only have a single lane, start undo/redo operation
1569  myUndoList->p_begin("Add vclass for " + toString(vclass));
1570  // Add Sidewalk
1571  myNet->addSRestrictedLane(vclass, lane->getParentEdge(), myUndoList);
1572  // end undo/redo operation
1573  myUndoList->p_end();
1574  }
1575  }
1576  return 1;
1577 }
1578 
1579 
1580 bool
1583  if (lane != 0) {
1584  // Get selected edges
1585  std::vector<GNEEdge*> edges = myNet->retrieveEdges(true);
1586  // get selected lanes
1587  std::vector<GNELane*> lanes = myNet->retrieveLanes(true);
1588  // Declare set of edges
1589  std::set<GNEEdge*> setOfEdges;
1590  // Fill set of edges with vector of edges
1591  for (std::vector<GNEEdge*>::iterator i = edges.begin(); i != edges.end(); i++) {
1592  setOfEdges.insert(*i);
1593  }
1594  // iterate over selected lanes
1595  for (std::vector<GNELane*>::iterator it = lanes.begin(); it != lanes.end(); it++) {
1596  // Insert pointer to edge into set of edges (To avoid duplicates)
1597  setOfEdges.insert(myNet->retrieveEdge((*it)->getParentEdge().getID()));
1598  }
1599  // If we handeln a set of edges
1600  if (setOfEdges.size() > 0) {
1601  // declare counter for number of restrictions
1602  int counter = 0;
1603  // iterate over set of edges
1604  for (std::set<GNEEdge*>::iterator it = setOfEdges.begin(); it != setOfEdges.end(); it++) {
1605  // update counter if edge has already a restricted lane of type "vclass"
1606  if ((*it)->hasRestrictedLane(vclass) == true) {
1607  counter++;
1608  }
1609  }
1610  // if all lanes don't own a Sidewalk, stop function
1611  if (counter == 0) {
1612  FXMessageBox::information(getApp(), MBOX_OK,
1613  ("Remove vclass for " + toString(vclass) + " to selected lanes").c_str(), "%s",
1614  ("Selected lanes and edges haven't a restriction for " + toString(vclass)).c_str());
1615  return 0;
1616  } else {
1617  if (myTestingMode == true) {
1618  WRITE_WARNING("Opening FXMessageBox of type 'question'");
1619  }
1620  // Ask confirmation to user
1621  FXuint answer = FXMessageBox::question(getApp(), MBOX_YES_NO,
1622  ("Remove vclass for " + toString(vclass) + " to selected lanes").c_str(), "%s",
1623  (toString(counter) + " restrictions for " + toString(vclass) + " will be removed. continue?").c_str());
1624  if (answer != 1) { //1:yes, 2:no, 4:esc
1625  // write warning if netedit is running in testing mode
1626  if ((answer == 2) && (myTestingMode == true)) {
1627  WRITE_WARNING("Closed FXMessageBox of type 'question' with 'No'");
1628  } else if ((answer == 4) && (myTestingMode == true)) {
1629  WRITE_WARNING("Closed FXMessageBox of type 'question' with 'ESC'");
1630  }
1631  return 0;
1632  } else {
1633  // write warning if netedit is running in testing mode
1634  if (myTestingMode == true) {
1635  WRITE_WARNING("Closed FXMessageBox of type 'question' with 'Yes'");
1636  }
1637  }
1638  }
1639  // begin undo operation
1640  myUndoList->p_begin("Remove restrictions for " + toString(vclass));
1641  // iterate over set of edges
1642  for (std::set<GNEEdge*>::iterator it = setOfEdges.begin(); it != setOfEdges.end(); it++) {
1643  // add Sidewalk
1644  myNet->removeRestrictedLane(vclass, *(*it), myUndoList);
1645  }
1646  // end undo operation
1647  myUndoList->p_end();
1648  } else {
1649  // If only have a single lane, start undo/redo operation
1650  myUndoList->p_begin("Remove vclass for " + toString(vclass));
1651  // Remove Sidewalk
1653  // end undo/redo operation
1654  myUndoList->p_end();
1655  }
1656  }
1657  return 1;
1658 }
1659 
1660 
1661 void
1662 GNEViewNet::processClick(FXEvent* e, void* data) {
1663  // process click
1664  destroyPopup();
1665  setFocus();
1666  myChanger->onLeftBtnPress(data);
1667  grab();
1668  // Check there are double click
1669  if (e->click_count == 2) {
1670  handle(this, FXSEL(SEL_DOUBLECLICKED, 0), data);
1671  }
1672 }
1673 
1674 long
1675 GNEViewNet::onCmdRevertRestriction(FXObject*, FXSelector, void*) {
1677  if (lane != 0) {
1678  // Declare vector of lanes
1679  std::vector<GNELane*> lanes;
1680  // Check if we have a set of selected edges or lanes
1682  // Get selected edgeds
1683  std::vector<GNEEdge*> edges = myNet->retrieveEdges(true);
1684  // fill vector of lanes with the lanes of selected edges
1685  for (std::vector<GNEEdge*>::iterator i = edges.begin(); i != edges.end(); i++) {
1686  for (std::vector<GNELane*>::const_iterator j = (*i)->getLanes().begin(); j != (*i)->getLanes().end(); j++) {
1687  lanes.push_back(*j);
1688  }
1689  }
1690  } else if (gSelected.isSelected(GLO_LANE, lane->getGlID())) {
1691  // get selected lanes
1692  lanes = myNet->retrieveLanes(true);
1693  }
1694  // If we handeln a set of lanes
1695  if (lanes.size() > 0) {
1696  // declare counter for number of Sidewalks
1697  int counter = 0;
1698  // iterate over selected lanes
1699  for (std::vector<GNELane*>::iterator it = lanes.begin(); it != lanes.end(); it++) {
1700  if (((*it)->isRestricted(SVC_PEDESTRIAN)) || ((*it)->isRestricted(SVC_BICYCLE)) || ((*it)->isRestricted(SVC_BUS))) {
1701  counter++;
1702  }
1703  }
1704  // if none of selected lanes has a transformation, stop
1705  if (counter == 0) {
1706  FXMessageBox::information(getApp(), MBOX_OK,
1707  "Revert restriction", "%s",
1708  "None of selected lanes has a previous restriction");
1709  return 0;
1710  } else {
1711  if (myTestingMode == true) {
1712  WRITE_WARNING("Opening FXMessageBox of type 'question'");
1713  }
1714  // Ask confirmation to user
1715  FXuint answer = FXMessageBox::question(getApp(), MBOX_YES_NO,
1716  "Revert restriction", "%s",
1717  (toString(counter) + " restrictions of lanes lanes will be reverted. continue?").c_str());
1718  if (answer != 1) { //1:yes, 2:no, 4:esc
1719  // write warning if netedit is running in testing mode
1720  if ((answer == 2) && (myTestingMode == true)) {
1721  WRITE_WARNING("Closed FXMessageBox of type 'question' with 'No'");
1722  } else if ((answer == 4) && (myTestingMode == true)) {
1723  WRITE_WARNING("Closed FXMessageBox of type 'question' with 'ESC'");
1724  }
1725  return 0;
1726  } else {
1727  // write warning if netedit is running in testing mode
1728  if (myTestingMode == true) {
1729  WRITE_WARNING("Closed FXMessageBox of type 'question' with 'Yes'");
1730  }
1731  }
1732  }
1733  // begin undo operation
1734  myUndoList->p_begin("revert restrictions");
1735  // iterate over selected lanes
1736  for (std::vector<GNELane*>::iterator it = lanes.begin(); it != lanes.end(); it++) {
1737  // revert transformation
1739  }
1740  // end undo operation
1741  myUndoList->p_end();
1742  } else {
1743  // If only have a single lane, start undo/redo operation
1744  myUndoList->p_begin("revert restriction");
1745  // revert transformation
1747  // end undo operation
1748  myUndoList->p_end();
1749  }
1750  }
1751  return 1;
1752 }
1753 
1754 
1755 long
1756 GNEViewNet::onCmdNodeShape(FXObject*, FXSelector, void*) {
1758  if (junction != 0) {
1759  if (myCurrentPoly == 0) {
1760  if (junction->getNBNode()->getShape().size() > 1) {
1762  //std::cout << junction->getNBNode()->getShape() << "\n";
1763  junction->getNBNode()->computeNodeShape(-1);
1764  if (myCurrentPoly != 0) {
1766  delete myCurrentPoly;
1767  myCurrentPoly = 0;
1768  }
1769  PositionVector shape = junction->getNBNode()->getShape();
1770  shape.closePolygon();
1771  myCurrentPoly = new GNEPoly(myNet, junction, "junction_shape:" + junction->getMicrosimID(), "junction shape",
1772  shape, false, RGBColor::GREEN, GLO_POLYGON);
1775 
1776  update();
1777  }
1778  } else {
1781  update();
1782  }
1783  }
1784  return 1;
1785 }
1786 
1787 
1788 void
1790  if (myCurrentPoly != 0) {
1792  delete myCurrentPoly;
1793  myCurrentPoly = 0;
1794  }
1795 }
1796 
1797 
1798 long
1799 GNEViewNet::onCmdNodeReplace(FXObject*, FXSelector, void*) {
1801  if (junction != 0) {
1803  update();
1804  }
1805  return 1;
1806 }
1807 
1808 
1809 long
1810 GNEViewNet::onCmdToogleShowConnection(FXObject*, FXSelector, void*) {
1811  if (!myShowConnections) {
1813  myShowConnections = true;
1814  }
1815  // Update viewnNet to show/hide conections
1816  update();
1817  // Hide/show connections requiere recompute
1818  getNet()->requireRecompute();
1819  return 1;
1820 }
1821 
1822 
1823 long
1824 GNEViewNet::onCmdToogleSelectEdges(FXObject*, FXSelector, void*) {
1825  if (myMenuCheckSelectEdges->getCheck()) {
1826  mySelectEdges = true;
1827  } else {
1828  mySelectEdges = false;
1829  }
1830  return 1;
1831 }
1832 
1833 
1834 long
1835 GNEViewNet::onCmdToogleShowBubbles(FXObject*, FXSelector, void*) {
1836  // Update view net Shapes
1837  update();
1838  return 1;
1839 }
1840 
1841 
1842 long
1843 GNEViewNet::onCmdShowGrid(FXObject*, FXSelector, void*) {
1844  // show or hidde grid depending of myMenuCheckShowGrid
1845  if (myMenuCheckShowGrid->getCheck()) {
1847  } else {
1849  }
1850  update();
1851  return 1;
1852 }
1853 
1854 
1855 // ===========================================================================
1856 // private
1857 // ===========================================================================
1858 
1859 void
1861  setStatusBarText("");
1862  abortOperation(false);
1863  if (mode == myEditMode) {
1864  setStatusBarText("Mode already selected");
1865  if (myCurrentFrame != NULL) {
1867  }
1868  } else {
1870  myEditMode = mode;
1871  switch (mode) {
1872  case GNE_MODE_CONNECT:
1873  case GNE_MODE_TLS:
1874  // modes which depend on computed data
1876  break;
1877  default:
1878  break;
1879  }
1881  }
1882 }
1883 
1884 
1885 void
1887  // initialize mappings
1888  myEditModeNames.insert("(e) Create Edge", GNE_MODE_CREATE_EDGE);
1889  myEditModeNames.insert("(m) Move", GNE_MODE_MOVE);
1890  myEditModeNames.insert("(d) Delete", GNE_MODE_DELETE);
1891  myEditModeNames.insert("(i) Inspect", GNE_MODE_INSPECT);
1892  myEditModeNames.insert("(s) Select", GNE_MODE_SELECT);
1893  myEditModeNames.insert("(c) Connect", GNE_MODE_CONNECT);
1894  myEditModeNames.insert("(t) Traffic Lights", GNE_MODE_TLS);
1895  myEditModeNames.insert("(a) Additionals", GNE_MODE_ADDITIONAL);
1896  myEditModeNames.insert("(r) Crossings", GNE_MODE_CROSSING);
1897 
1898  // initialize buttons for modes
1899  myEditModeCreateEdge = new MFXCheckableButton(false, myToolbar, "\tset create edge mode\tMode for creating junction and edges.",
1901  myEditModeMove = new MFXCheckableButton(false, myToolbar, "\tset move mode\tMode for move elements.",
1903  myEditModeDelete = new MFXCheckableButton(false, myToolbar, "\tset delete mode\tMode for delete elements.",
1905  myEditModeInspect = new MFXCheckableButton(false, myToolbar, "\tset inspect mode\tMode for inspect elements and change their attributes.",
1907  myEditModeSelect = new MFXCheckableButton(false, myToolbar, "\tset select mode\tMode for select elements.",
1909  myEditModeConnection = new MFXCheckableButton(false, myToolbar, "\tset connection mode\tMode for edit connections between lanes.",
1911  myEditModeTrafficLight = new MFXCheckableButton(false, myToolbar, "\tset traffic light mode\tMode for edit traffic lights over junctions.",
1913  myEditModeAdditional = new MFXCheckableButton(false, myToolbar, "\tset additional mode\tMode for adding additional elements.",
1915  myEditModeCrossing = new MFXCheckableButton(false, myToolbar, "\tset crossing mode\tMode for creating crossings between edges.",
1917 
1918  // @ToDo add here new FXToolBarGrip(myNavigationToolBar, NULL, 0, GUIDesignToolbarGrip);
1919 
1920  // initialize mode specific controls
1921  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);
1922  myChainCreateEdge->setCheck(false);
1923 
1924  myAutoCreateOppositeEdge = new FXMenuCheck(myToolbar, ("two-way\t\tAutomatically create an " + toString(SUMO_TAG_EDGE) + " in the opposite direction").c_str(), this, 0);
1925  myAutoCreateOppositeEdge->setCheck(false);
1926 
1927  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_SELECT_EDGES);
1928  myMenuCheckSelectEdges->setCheck(true);
1929 
1930  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_SHOW_CONNECTIONS);
1931  myMenuCheckShowConnections->setCheck(false);
1932 
1933  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);
1934 
1935  myMenuCheckWarnAboutMerge = new FXMenuCheck(myToolbar, ("ask for merge\t\tAsk for confirmation before merging " + toString(SUMO_TAG_JUNCTION) + ".").c_str(), this, 0);
1936  myMenuCheckWarnAboutMerge->setCheck(true);
1937 
1938  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_SHOW_BUBBLES);
1939  myMenuCheckShowBubbleOverJunction->setCheck(false);
1940 
1941  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);
1942  myMenuCheckChangeAllPhases->setCheck(false);
1943 
1944  myMenuCheckShowGrid = new FXMenuCheck(myToolbar, "show grid\t\tshow grid with size defined in visualization options", this, MID_GNE_SHOW_GRID);
1945  myMenuCheckShowGrid->setCheck(false);
1946 }
1947 
1948 
1949 void
1951  // hide grid
1953  // hide all controls (checkboxs)
1954  myChainCreateEdge->hide();
1955  myAutoCreateOppositeEdge->hide();
1956  myMenuCheckSelectEdges->hide();
1960  myMenuCheckWarnAboutMerge->hide();
1962  myMenuCheckShowGrid->hide();
1963  // unckeck all edit modes
1965  myEditModeMove->setChecked(false);
1966  myEditModeDelete->setChecked(false);
1967  myEditModeInspect->setChecked(false);
1968  myEditModeSelect->setChecked(false);
1974  // enable selected controls
1975  switch (myEditMode) {
1976  case GNE_MODE_CREATE_EDGE:
1977  myChainCreateEdge->show();
1978  myAutoCreateOppositeEdge->show();
1980  myMenuCheckShowGrid->show();
1981  break;
1982  case GNE_MODE_MOVE:
1983  myMenuCheckWarnAboutMerge->show();
1985  myEditModeMove->setChecked(true);
1986  myMenuCheckShowGrid->show();
1987  break;
1988  case GNE_MODE_DELETE:
1993  myMenuCheckSelectEdges->show();
1995  break;
1996  case GNE_MODE_INSPECT:
2000  myMenuCheckSelectEdges->show();
2003  break;
2004  case GNE_MODE_SELECT:
2008  myMenuCheckSelectEdges->show();
2012  break;
2013  case GNE_MODE_CONNECT:
2018  break;
2019  case GNE_MODE_TLS:
2025  break;
2026  case GNE_MODE_ADDITIONAL:
2031  myMenuCheckShowGrid->show();
2032  break;
2033  case GNE_MODE_CROSSING:
2038  myMenuCheckShowGrid->setCheck(false);
2039  break;
2040  default:
2041  break;
2042  }
2043  // Update buttons
2044  myEditModeCreateEdge->update();
2045  myEditModeMove->update();
2046  myEditModeDelete->update();
2047  myEditModeInspect->update();
2048  myEditModeSelect->update();
2049  myEditModeConnection->update();
2050  myEditModeTrafficLight->update();
2051  myEditModeAdditional->update();
2052  myEditModeCrossing->update();
2053  // force repaint because different modes draw different things
2054  myToolbar->recalc();
2055  onPaint(0, 0, 0);
2056  update();
2057 }
2058 
2059 
2060 void
2062  myUndoList->p_begin("delete selected " + toString(SUMO_TAG_JUNCTION) + "s");
2063  std::vector<GNEJunction*> junctions = myNet->retrieveJunctions(true);
2064  for (std::vector<GNEJunction*>::iterator it = junctions.begin(); it != junctions.end(); it++) {
2066  }
2067  myUndoList->p_end();
2068 }
2069 
2070 
2071 void
2073  if (mySelectEdges == true) {
2074  myUndoList->p_begin("delete selected " + toString(SUMO_TAG_EDGE) + "s");
2075  std::vector<GNEEdge*> edges = myNet->retrieveEdges(true);
2076  for (std::vector<GNEEdge*>::iterator it = edges.begin(); it != edges.end(); it++) {
2077  myNet->deleteEdge(*it, myUndoList);
2078  }
2079  } else {
2080  myUndoList->p_begin("delete selected " + toString(SUMO_TAG_LANE) + "s");
2081  std::vector<GNELane*> lanes = myNet->retrieveLanes(true);
2082  for (std::vector<GNELane*>::iterator it = lanes.begin(); it != lanes.end(); it++) {
2083  myNet->deleteLane(*it, myUndoList);
2084  }
2085  }
2086  myUndoList->p_end();
2087 }
2088 
2089 
2090 void
2093  std::vector<GNEAdditional*> additionals = myNet->retrieveAdditionals(true);
2094  for (std::vector<GNEAdditional*>::iterator it = additionals.begin(); it != additionals.end(); it++) {
2096  }
2097  myUndoList->p_end();
2098 }
2099 
2100 
2101 bool
2103  const Position& newPos = moved->getNBNode()->getPosition();
2104  GNEJunction* mergeTarget = 0;
2105  // try to find another junction to merge with
2106  if (makeCurrent()) {
2107  Boundary selection;
2108  selection.add(newPos);
2109  selection.grow(0.1);
2110  const std::vector<GUIGlID> ids = getObjectsInBoundary(selection);
2111  GUIGlObject* object = 0;
2112  for (std::vector<GUIGlID>::const_iterator it = ids.begin(); it != ids.end(); it++) {
2113  GUIGlID id = *it;
2114  if (id == 0) {
2115  continue;
2116  }
2118  if (!object) {
2119  throw ProcessError("Unkown object in selection (id=" + toString(id) + ").");
2120  }
2121  if (object->getType() == GLO_JUNCTION && id != moved->getGlID()) {
2122  mergeTarget = dynamic_cast<GNEJunction*>(object);
2123  }
2125  }
2126  }
2127  if (mergeTarget) {
2128  // optionally ask for confirmation
2129  if (myMenuCheckWarnAboutMerge->getCheck()) {
2130  if (myTestingMode == true) {
2131  WRITE_WARNING("Opening FXMessageBox of type 'question'");
2132  }
2133  // open question box
2134  FXuint answer = FXMessageBox::question(this, MBOX_YES_NO,
2135  "Confirm Junction Merger", "%s",
2136  ("Do you wish to merge junctions '" + moved->getMicrosimID() +
2137  "' and '" + mergeTarget->getMicrosimID() + "'?\n" +
2138  "('" + moved->getMicrosimID() +
2139  "' will be eliminated and its roads added to '" +
2140  mergeTarget->getMicrosimID() + "')").c_str());
2141  if (answer != 1) { //1:yes, 2:no, 4:esc
2142  // write warning if netedit is running in testing mode
2143  if ((answer == 2) && (myTestingMode == true)) {
2144  WRITE_WARNING("Closed FXMessageBox of type 'question' with 'No'");
2145  } else if ((answer == 4) && (myTestingMode == true)) {
2146  WRITE_WARNING("Closed FXMessageBox of type 'question' with 'ESC'");
2147  }
2148  return false;
2149  } else {
2150  // write warning if netedit is running in testing mode
2151  if (myTestingMode == true) {
2152  WRITE_WARNING("Closed FXMessageBox of type 'question' with 'Yes'");
2153  }
2154  }
2155  }
2156  myNet->mergeJunctions(moved, mergeTarget, myUndoList);
2157  return true;
2158  } else {
2159  return false;
2160  }
2161 }
2162 
2163 
2164 void
2166  switch (myEditMode) {
2167  case GNE_MODE_INSPECT:
2168  myViewParent->getInspectorFrame()->update();
2169  break;
2170  default:
2171  break;
2172  }
2173 }
2174 /****************************************************************************/
Locate TLS - button.
Definition: GUIAppEnum.h:181
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:540
long onCmdResetEdgeEndpoint(FXObject *, FXSelector, void *)
restore geometry endpoint to node position
long onCmdDeleteGeometry(FXObject *, FXSelector, void *)
delete the closes geometry point
GNEViewParent * myViewParent
view parent
Definition: GNEViewNet.h:320
virtual void openAdditionalDialog()
open Additional Dialog
void paintGLGrid()
paints a grid
std::vector< GNEJunction * > retrieveJunctions(bool onlySelected=false)
return all junctions
Definition: GNENet.cpp:805
long onCmdRestrictLaneBikelane(FXObject *, FXSelector typeOfTransformation, void *)
restrict lane to bikes
a tl-logic
GNELane * getLane() const
get lane of additional, or NULL if additional isn&#39;t placed over a Lane
static const RGBColor BLUE
Definition: RGBColor.h:191
Position moveGeometry(const Position &oldPos, const Position &newPos, bool relative=false)
draw the polygon and also little movement handles
Definition: GNEPoly.cpp:121
FXDEFMAP(GNEViewNet) GNEViewNetMap[]
double ymin() const
Returns minimum y-coordinate.
Definition: Boundary.cpp:138
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:770
const std::set< GUIGlID > & getSelected() const
Returns the set of ids of all selected objects.
bool selectEdges()
whether inspection, selection and inversion should apply to edges or to lanes
Definition: GNEViewNet.cpp:363
GNEJunction * getJunctionAtCursorPosition(Position &pos)
try to retrieve a junction at the given position
GNEInspectorFrame * getInspectorFrame() const
get frame for GNE_MODE_INSPECT
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
double xmax() const
Returns maximum x-coordinate.
Definition: Boundary.cpp:132
Position myPopupSpot
Poput spot.
Definition: GNEViewNet.h:460
GUICompleteSchemeStorage gSchemeStorage
GNEEdge * retrieveEdge(const std::string &id, bool failHard=true)
get edge by id
Definition: GNENet.cpp:743
Locate edge - button.
Definition: GUIAppEnum.h:175
bool isAdditionalBlocked() const
Check if additional item is currently blocked (i.e. cannot be moved with mouse)
double scale
information about a lane&#39;s width (temporary, used for a single view)
void abortOperation(bool clearSelection=true)
abort current edition operation
Definition: GNEViewNet.cpp:955
void deleteSelectedJunctions()
delete all currently selected junctions
GNEEdge * getEdgeTemplate() const
get the template edge (to copy attributes from)
bool setColorScheme(const std::string &name)
set color schieme
Definition: GNEViewNet.cpp:341
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 restrictLane(SUMOVehicleClass vclass)
restrict lane
void move(Position pos)
reposition the POI at pos and informs the edges
Definition: GNEPOI.cpp:81
void inspectElement(GNEAttributeCarrier *AC)
Inspect a single element.
void markPopupPosition()
store the position where a popup-menu was requested
show connections
Definition: GUIAppEnum.h:562
long onCmdDuplicateLane(FXObject *, FXSelector, void *)
duplicate selected lane
begin/end of the description of a junction
bool myShowConnections
whether show connections has been activated once
Definition: GNEViewNet.h:350
begin/end of the description of a single lane
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types...
StringBijection< EditMode > myEditModeNames
since we cannot switch on strings we map the mode names to an enum
Definition: GNEViewNet.h:450
long onMouseMove(FXObject *, FXSelector, void *)
called when user moves mouse
Definition: GNEViewNet.cpp:893
void markAsCreateEdgeSource()
marks as first junction in createEdge-mode
The main window of the Netedit.
bool mySelectEdges
flag to check if select edges is enabled
Definition: GNEViewNet.h:353
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:474
void setAllowsNegativeValues(bool value)
reverse an edge
Definition: GUIAppEnum.h:620
const std::vector< std::string > & getNames() const
Returns a list of stored settings names.
void hotkeyFocusFrame()
handle focus frame keypress
FXMenuCheck * myMenuCheckShowGrid
show grid button
Definition: GNEViewNet.h:347
mode for deleting things
Definition: GUIAppEnum.h:440
bool revertLaneRestriction(GNELane *lane, GNEUndoList *undoList)
revert prevously restricted lane
Definition: GNENet.cpp:485
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:361
mode for deleting things
Definition: GNEViewNet.h:55
Definition: GNEPOI.h:51
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:48
GNEViewParent * getViewParent() const
get the net object
double y() const
Returns the y-position.
Definition: Position.h:68
GUIMainWindow * myApp
The application.
Position snapToActiveGrid(const Position &pos) const
Returns a position that is mapped to the closest grid point if the grid is active.
vehicle is a small delivery vehicle
mode for editing tls
Definition: GUIAppEnum.h:448
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:281
void computeEverything(GNEApplicationWindow *window, bool force=false)
Definition: GNENet.cpp:983
MFXCheckableButton * myEditModeSelect
chekable button for edit mode select
Definition: GNEViewNet.h:432
Position mySelCorner2
second corner of the rectangle-selection
Definition: GNEViewNet.h:411
classes which (normally) do not drive on normal roads
void removeAdditionalGLObject(GUIGlObject *o)
Removes an additional object (detector/shape/trigger) from being visualised.
Definition: SUMORTree.h:141
double x() const
Returns the x-position.
Definition: Position.h:63
mode for editing tls
Definition: GNEViewNet.h:63
turn junction into geometry node
Definition: GUIAppEnum.h:626
void reverseEdge(GNEEdge *edge, GNEUndoList *undoList)
reverse edge
Definition: GNENet.cpp:604
GNEJunction * getEditedJunction() const
retrieve the junction of which the shape is being edited
Definition: GNEPoly.h:153
long onCmdNodeShape(FXObject *, FXSelector, void *)
input custom node shape
select edges
Definition: GUIAppEnum.h:564
static const RGBColor ORANGE
Definition: RGBColor.h:195
MFXCheckableButton * myEditModeMove
chekable button for edit mode move
Definition: GNEViewNet.h:423
T MAX2(T a, T b)
Definition: StdDefs.h:70
MFXCheckableButton * myEditModeDelete
chekable button for edit mode delete
Definition: GNEViewNet.h:426
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:88
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:251
int editMode
the current NETEDIT mode (temporary)
mode for selecting objects
Definition: GUIAppEnum.h:444
void commmitAdditionalGeometryMoved(const Position &oldPos, GNEUndoList *undoList)
updated geometry changes in the attributes of additional
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:82
GNEPOI * myPoiToMove
the poi which is being moved
Definition: GNEViewNet.h:384
void setEditModeFromHotkey(FXushort selid)
sets edit mode (from hotkey)
transform lane to sidewalk
Definition: GUIAppEnum.h:640
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,
static const RGBColor BLACK
Definition: RGBColor.h:197
const std::string & getID() const
Returns the id.
Definition: Named.h:66
Locate polygons - button.
Definition: GUIAppEnum.h:191
const SVCPermissions SVCAll
all VClasses are allowed
void setLineWidth(double lineWidth)
set a new shape and update the tesselation
Definition: GUIPolygon.h:116
GUIDialog_ViewSettings * myVisualizationChanger
Visualization changer.
set non-default geometry endpoint
Definition: GUIAppEnum.h:628
void deleteEdge(GNEEdge *edge, GNEUndoList *undoList)
removes edge
Definition: GNENet.cpp:336
void set(double x, double y)
set positions x and y
Definition: Position.h:93
void updateControls()
update control contents after undo/redo or recompute
EditMode myPreviousEditMode
the previous edit mode used for toggling
Definition: GNEViewNet.h:329
void registerMove(GNEUndoList *undoList)
registers completed movement with the undoList
FXMenuCheck * myMenuCheckChangeAllPhases
menu check to set change all phases
Definition: GNEViewNet.h:344
const PositionVector & getShape() const
Returns whether the shape of the polygon.
Definition: Polygon.h:87
GNEEdge * myEdgeToMove
the edge of which geometry is being moved
Definition: GNEViewNet.h:378
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:48
virtual std::string getAttribute(SumoXMLAttr key) const =0
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:200
A single child window which contains a view of the simulation area.
Definition: GNEViewParent.h:72
split an edge
Definition: GUIAppEnum.h:618
GNETLSEditorFrame * getTLSEditorFrame() const
get frame for GNE_MODE_TLS
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:65
bool isTestingModeEnabled() const
check if netedit is running in testing mode
Definition: GNEViewNet.cpp:405
double p2m(double pixel) const
pixels-to-meters conversion method
std::map< const GUIGlObject *, int > myAdditionallyDrawn
List of objects for which GUIGlObject::drawGLAdditional is called.
bool changeAllPhases() const
change all phases
Definition: GNEViewNet.cpp:393
bool restrictLane(SUMOVehicleClass vclass, GNELane *lane, GNEUndoList *undoList)
transform lane to restricted lane
Definition: GNENet.cpp:459
bool myMoveSelection
whether a selection is being moved
Definition: GNEViewNet.h:399
long onCmdSetModeCrossing(FXObject *, FXSelector, void *)
called when user press the button for crossing mode
GNEAdditionalFrame * getAdditionalFrame() const
get frame for GNE_MODE_ADDITIONAL
simplify polygon geometry
Definition: GUIAppEnum.h:634
restore geometry endpoint to node position
Definition: GUIAppEnum.h:630
add bikelane
Definition: GUIAppEnum.h:650
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...
mode for inspecting object attributes
Definition: GUIAppEnum.h:442
void insert(const std::string str, const T key, bool checkDuplicates=true)
std::string getAttribute(SumoXMLAttr key) const
Definition: GNEEdge.cpp:561
Position myOldAdditionalPosition
variable for saving additional position before moving
Definition: GNEViewNet.h:393
void buildEditModeControls()
adds controls for setting the edit mode
GUIGlID getObjectAtPosition(Position pos)
returns the id of the object at position using GL_SELECT
std::set< GNEEdge * > getEdgesAtCursorPosition(Position &pos)
try to retrieve multiple edges at the given position
GNEUndoList * getUndoList() const
get the undoList object
long onLeftBtnPress(FXObject *, FXSelector, void *)
called when user press mouse&#39;s left button
Definition: GNEViewNet.cpp:496
long onCmdSimplifyShape(FXObject *, FXSelector, void *)
simply shape of current polygon
static const RGBColor GREEN
Definition: RGBColor.h:190
void computeNodeShape(double mismatchThreshold)
Compute the junction shape for this node.
Definition: NBNode.cpp:781
static const RGBColor GREY
Definition: RGBColor.h:198
bool showLockIcon() const
check if lock icon should be visible
virtual long onPaint(FXObject *, FXSelector, void *)
int addColor(const T &color, const double threshold, const std::string &name="")
GNEPoly * myCurrentPoly
current polygon
Definition: GNEViewNet.h:463
long onCmdRemoveRestrictedLaneBuslane(FXObject *, FXSelector typeOfTransformation, void *)
remove restricted lane for bus
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
std::string name
The name of this setting.
bool hasCommandGroup() const
Check if undoList has command group.
bool removeRestrictedLane(SUMOVehicleClass vclass, GNEEdge &edge, GNEUndoList *undoList)
remove restricted lane
Definition: GNENet.cpp:518
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:338
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:79
GNEAdditional * myAdditionalToMove
the stoppingPlace element which shape is being moved
Definition: GNEViewNet.h:387
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
Definition: GLHelper.cpp:439
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:51
GNEEdge & getParentEdge()
Returns underlying parent edge.
Definition: GNELane.cpp:1078
virtual ~GNEViewNet()
destructor
Definition: GNEViewNet.cpp:287
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:89
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:46
mode for adding edges
Definition: GUIAppEnum.h:436
transform lane to bikelane
Definition: GUIAppEnum.h:642
A list of positions.
FXMenuCheck * myMenuCheckSelectEdges
menu check to select only edges
Definition: GNEViewNet.h:335
FXToolBar * myToolbar
a reference to the toolbar in myParent
Definition: GNEViewNet.h:415
FXComboBox & getColoringSchemesCombo()
void deleteLane(GNELane *lane, GNEUndoList *undoList)
removes lane
Definition: GNENet.cpp:382
long onCmdToogleShowConnection(FXObject *, FXSelector, void *)
toogle show connections
MFXCheckableButton * myEditModeCreateEdge
Definition: GNEViewNet.h:420
static GUIGlObjectStorage gIDStorage
A single static instance of this class.
GUIVisualizationSettings & get(const std::string &name)
Returns the named scheme.
void removeAdditional(GNEAdditional *additional)
remove an additional element previously added
bool showJunctionAsBubbles() const
return true if junction must be showed as bubbles
Definition: GNEViewNet.cpp:399
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:381
static const RGBColor MAGENTA
Definition: RGBColor.h:194
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) ...
double xmin() const
Returns minimum x-coordinate.
Definition: Boundary.cpp:126
MFXCheckableButton * myEditModeTrafficLight
chekable button for edit mode traffic light
Definition: GNEViewNet.h:438
void initGNEConnections()
initialize GNEConnections
Definition: GNENet.cpp:1564
long onCmdRemoveRestrictedLaneBikelane(FXObject *, FXSelector typeOfTransformation, void *)
remove restricted lane for bikes
mode for selecting objects
Definition: GNEViewNet.h:59
void removeCurrentPoly()
remove the currently edited polygon
GNEJunction * myJunctionToMove
the Junction to be moved.
Definition: GNEViewNet.h:375
bool addCrossing(GNENetElement *netElement)
add Crossing element
MFXCheckableButton * myEditModeAdditional
chekable button for edit mode additional
Definition: GNEViewNet.h:441
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
GNESelectorFrame * getSelectorFrame() const
get frame for GNE_MODE_SELECT
std::vector< GNEAttributeCarrier * > retrieveAttributeCarriers(const std::set< GUIGlID > &ids, GUIGlObjectType type)
get the attribute carriers based on GlIDs
Definition: GNENet.cpp:847
Boundary & grow(double by)
extends the boundary by the given amount
Definition: Boundary.cpp:234
virtual const std::string & getMicrosimID() const
Returns the id of the object as known to microsim.
Locate poi - button.
Definition: GUIAppEnum.h:189
show grid
Definition: GUIAppEnum.h:568
void unMarkAsCreateEdgeSource()
removes mark as first junction in createEdge-mode
mode for editing crossing
Definition: GUIAppEnum.h:452
void moveSelection(const Position &moveSrc, const Position &moveDest)
move all selected junctions and edges
Definition: GNENet.cpp:1198
Position screenPos2NetPos(int x, int y) const
Translate screen position to network position.
void focusUpperElement()
focus upper element of frame
Definition: GNEFrame.cpp:92
int myTestingWidth
Width of viewNet in testing mode.
Definition: GNEViewNet.h:471
GNEJunction * createJunction(const Position &pos, GNEUndoList *undoList)
creates a new junction
Definition: GNENet.cpp:240
add busLane
Definition: GUIAppEnum.h:652
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:593
Position mySelCorner1
firstcorner of the rectangle-selection
Definition: GNEViewNet.h:408
Position myAdditionalMovingReference
variable for calculating moving offset of additionals
Definition: GNEViewNet.h:390
void p_abort()
reverts and discards ALL active command groups
GUIPerspectiveChanger * myChanger
The perspective changer.
long onCmdRestrictLaneBuslane(FXObject *, FXSelector typeOfTransformation, void *)
restrict lane to buslanes
bool myUseToolTips
use tool tips
virtual void onLeftBtnPress(void *data)
mouse functions
EditMode
Definition: GNEViewNet.h:47
SUMORTree & getVisualisationSpeedUp()
Returns the RTree used for visualisation speed-up.
Definition: GNENet.cpp:228
vehicle is a passenger car (a "normal" car)
void destroyPopup()
destoys the popup
void doInit()
called after some features are already initialized
Definition: GNEViewNet.cpp:291
is an arbitrary ship
begin/end of the description of an edge
FXMenuCheck * myAutoCreateOppositeEdge
Definition: GNEViewNet.h:362
void setSelectionScaling(double selectionScale)
set selection scaling
Definition: GNEViewNet.cpp:387
EditMode getCurrentEditMode() const
get the current edit mode
bool mergeJunctions(GNEJunction *moved)
try to merge moved junction with another junction in that spot return true if merging did take place ...
const PositionVector & getShape() const
retrieve the junction shape
Definition: NBNode.cpp:1716
MFXCheckableButton * myEditModeInspect
chekable button for edit mode inspect
Definition: GNEViewNet.h:429
vehicle is a moped
FXMenuCheck * myMenuCheckExtendToEdgeNodes
menu check to extend to edge nodes
Definition: GNEViewNet.h:341
mode for editing additional
Definition: GUIAppEnum.h:450
void replaceJunctionByGeometry(GNEJunction *junction, GNEUndoList *undoList)
replace the selected junction by geometry node(s) and merge the edges
Definition: GNENet.cpp:1120
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:57
unsigned int GUIGlID
Definition: GUIGlObject.h:50
FXbool makeCurrent()
A reimplementation due to some internal reasons.
long onCmdOK(FXObject *, FXSelector, void *)
vehicle is a taxi
compound additional
virtual long onLeftBtnRelease(FXObject *, FXSelector, void *)
remove busLane
Definition: GUIAppEnum.h:658
vehicle is a bus
AddAdditionalResult addAdditional(GNENetElement *netElement, GUISUMOAbstractView *parent)
add additional element
AddAdditionalResult
FOX-declaration.
edit junction shape
Definition: GUIAppEnum.h:624
static const RGBColor YELLOW
Definition: RGBColor.h:192
static const RGBColor RED
Definition: RGBColor.h:189
const PositionVector & getShape() const
returns the shape of the lane
Definition: GNELane.cpp:621
FXMenuCheck * myMenuCheckWarnAboutMerge
whether we should warn about merging junctions
Definition: GNEViewNet.h:369
double selectionScale
the current selection scaling in NETEDIT (temporary)
double m2p(double meter) const
meter-to-pixels conversion method
#define GUIDesignButtonToolbarCheckable
little checkable button with icon placed in navigation toolbar
Definition: GUIDesigns.h:91
virtual void show()
show Frame
Definition: GNEFrame.cpp:98
void moveAdditionalGeometry(const Position &offset)
change the position of the additional geometry
static const RGBColor CYAN
Definition: RGBColor.h:193
GUIVisualizationSettings * myVisualizationSettings
visualization settings
void show()
show additional frame and update use selected edges/lanes
std::vector< GNEEdge * > retrieveEdges(bool onlySelected=false)
return all edges
Definition: GNENet.cpp:758
Position myMoveSrc
position from which to move edge geometry
Definition: GNEViewNet.h:396
long onCmdAddRestrictedLaneBikelane(FXObject *, FXSelector typeOfTransformation, void *)
Add restricted lane for bikes.
FXMenuCheck * myMenuCheckShowBubbleOverJunction
show connection as buuble in "Move" mode.
Definition: GNEViewNet.h:372
void addAdditionalGLObject(GUIGlObject *o)
Adds an additional object (detector/shape/trigger) for visualisation.
Definition: SUMORTree.h:129
An Element which don&#39;t belongs to GNENet but has influency in the simulation.
Definition: GNEAdditional.h:62
GNEConnectorFrame * getConnectorFrame() const
get frame for GNE_MODE_CONNECT
bool contains(const std::string &name) const
Returns the information whether a setting with the given name is stored.
MFXCheckableButton * myEditModeConnection
chekable button for edit mode connection
Definition: GNEViewNet.h:435
bool showConnections()
show connections over junctions
Definition: GNEViewNet.cpp:369
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
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:410
GNEJunction * myCreateEdgeSource
source junction for new edge 0 if no edge source is selected an existing (or newly created) junction ...
Definition: GNEViewNet.h:358
void move(Position pos)
reposition the node at pos and informs the edges
mode for moving things
Definition: GUIAppEnum.h:438
A storage for options typed value containers)
Definition: OptionsCont.h:99
an edge
long onCmdAddRestrictedLaneBuslane(FXObject *, FXSelector typeOfTransformation, void *)
Add restricted lane for buses.
long onCmdRemoveRestrictedLaneSidewalk(FXObject *, FXSelector typeOfTransformation, void *)
remove restricted lane for pedestrians
add reverse edge
Definition: GUIAppEnum.h:622
GNECrossingFrame * getCrossingFrame() const
get frame for GNE_MODE_CROSSING
void simplifyShape()
replace the current shape with a rectangle
Definition: GNEPoly.cpp:135
void deleteSelectedAdditionals()
delete all currently selected additionals
void showAttributeCarrierChilds(GNEAttributeCarrier *ac)
show child of attributeCarrier in frame if previously there isn&#39;t a marked element ...
void clear()
Clears the list of selected objects.
void deleteJunction(GNEJunction *junction, GNEUndoList *undoList)
removes junction and all incident edges
Definition: GNENet.cpp:306
std::string getCurrentScheme() const
Returns the name of the currently chosen scheme.
bool showGrid
Information whether a grid shall be shown.
show junctions as bubbles
Definition: GUIAppEnum.h:566
void drawDecals()
Draws the stored decals.
GNEDeleteFrame * getDeleteFrame() const
get frame for GNE_MODE_DELETE
void show()
show inspector frame
GNENet * getNet() const
get the net object
Locate addtional structure - button.
Definition: GUIAppEnum.h:187
long onCmdRestrictLaneSidewalk(FXObject *, FXSelector typeOfTransformation, void *)
restrict lane to pedestrians
const Position & getPosition() const
Definition: NBNode.h:232
void updateModeSpecificControls()
updates mode specific controls
GUIGlID getGlID() const
Returns the numerical id of the object.
MFXCheckableButton * myEditModeCrossing
chekable button for edit mode crossing
Definition: GNEViewNet.h:444
std::vector< GNEAdditional * > retrieveAdditionals(bool onlySelected=false)
return all additionals
Definition: GNENet.cpp:1319
mode for connecting lanes
Definition: GUIAppEnum.h:446
GNEEdge * addReversedEdge(GNEEdge *edge, GNEUndoList *undoList)
add reversed edge
Definition: GNENet.cpp:615
void setStatusBarText(const std::string &text)
set staturBar text
Definition: GNEViewNet.cpp:357
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
Position getPositionInformation() const
Returns the cursor&#39;s x/y position within the network.
virtual void buildViewToolBars(GUIGlChildWindow &)
builds the view toolbars
Definition: GNEViewNet.cpp:295
void setEndpoint(Position pos, GNEUndoList *undoList)
makes pos the new geometry endpoint at the appropriate end
Definition: GNEEdge.cpp:364
Locate junction - button.
Definition: GUIAppEnum.h:173
GUIPropertyScheme< RGBColor > GUIColorScheme
static const RGBColor selectionColor
color of selection
Definition: GNENet.h:97
duplicate a lane
Definition: GUIAppEnum.h:638
empty max
Mode for editing crossing.
Definition: GNEViewNet.h:67
remove bikelane
Definition: GUIAppEnum.h:656
GNEAttributeCarrier * getMarkedAttributeCarrier() const
returns marked atrribute carrier
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
split an edge
Definition: GUIAppEnum.h:616
mode for creating new edges
Definition: GNEViewNet.h:51
NBEdge * getNBEdge()
returns the internal NBEdge
Definition: GNEEdge.cpp:261
std::vector< GNEJunction * > getJunctionNeighbours() const
return GNEJunction neighbours
revert transformation
Definition: GUIAppEnum.h:646
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:870
GUIGlID getObjectUnderCursor()
returns the id of the object under the cursor using GL_SELECT
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:649
void inspectMultisection(const std::vector< GNEAttributeCarrier *> &ACs)
Inspect the given multi-selection.
double ymax() const
Returns maximum y-coordinate.
Definition: Boundary.cpp:144
GNEEdge * getEdgeAtCursorPosition(Position &pos)
try to retrieve an edge at the given position
long onCmdNodeReplace(FXObject *, FXSelector, void *)
replace node by geometry
void hotkeyDel()
handle del keypress
Definition: GNEViewNet.cpp:979
long onCmdAddReversedEdge(FXObject *, FXSelector, void *)
add reversed edge
GUIGlObject * getObjectBlocking(GUIGlID id)
Returns the object from the container locking it.
delete geometry point
Definition: GUIAppEnum.h:636
double nearest_offset_to_point2D(const Position &p, bool perpendicular=true) const
return the nearest offest to point 2D
void closePolygon()
ensures that the last position equals the first
NBNode * getNBNode() const
Return net build node.
bool myAmInRectSelect
whether we have started rectangle-selection
Definition: GNEViewNet.h:405
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
Definition: GNEEdge.cpp:635
bool addSRestrictedLane(SUMOVehicleClass vclass, GNEEdge &edge, GNEUndoList *undoList)
add restricted lane to edge
Definition: GNENet.cpp:503
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
GUISelectedStorage gSelected
A global holder of selected objects.
GNENet * myNet
we are not responsible for deletion
Definition: GNEViewNet.h:323
void hotkeyEnter()
handle enter keypress
Definition: GNEViewNet.cpp:994
void resetEndpoint(const Position &pos, GNEUndoList *undoList)
restores the endpoint to the junction position at the appropriate end
Definition: GNEEdge.cpp:387
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:822
Position getSplitPos(const Position &clickPos)
Definition: GNEEdge.cpp:267
void requireRecompute()
inform the net about the need for recomputation
Definition: GNENet.cpp:1024
remove inner geometry
Definition: GUIAppEnum.h:632
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:447
long onCmdSetModeCreateEdge(FXObject *, FXSelector, void *)
called when user press the button for create edge mode
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:457
EditMode myEditMode
the current edit mode
Definition: GNEViewNet.h:326
transform lane to busLane
Definition: GUIAppEnum.h:644
bool addRestrictedLane(SUMOVehicleClass vclass)
add restricted lane
std::vector< GUIGlID > getObjectsInBoundary(const Boundary &bound)
returns the ids of all objects in the given boundary
FXPopup * getLocatorPopup()
bool myTestingMode
Definition: GNEViewNet.h:468
GNEFrame * myCurrentFrame
the current frame
Definition: GNEViewNet.h:332
a junction
void deleteGeometryNear(const Position &pos)
delete the geometry point closest to the given pos
Definition: GNEPoly.cpp:147
GNEPoly * myPolyToMove
the poly of which geometry is being moved
Definition: GNEViewNet.h:381
void finishMoveSelection(GNEUndoList *undoList)
register changes to junction and edge positions with the undoList
Definition: GNENet.cpp:1228
SumoXMLTag getTag() const
get XML Tag assigned to this object
virtual Position getPositionInView() const =0
Returns position of additional in view.