SUMO - Simulation of Urban MObility
GNEViewNet.cpp
Go to the documentation of this file.
1 /****************************************************************************/
7 // A view on the network being edited (adapted from GUIViewTraffic)
8 /****************************************************************************/
9 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
10 // Copyright (C) 2001-2016 DLR (http://www.dlr.de/) and contributors
11 /****************************************************************************/
12 //
13 // This file is part of SUMO.
14 // SUMO is free software: you can redistribute it and/or modify
15 // it under the terms of the GNU General Public License as published by
16 // the Free Software Foundation, either version 3 of the License, or
17 // (at your option) any later version.
18 //
19 /****************************************************************************/
20 
21 
22 // ===========================================================================
23 // included modules
24 // ===========================================================================
25 #ifdef _MSC_VER
26 #include <windows_config.h>
27 #else
28 #include <config.h>
29 #endif
30 
31 #include <iostream>
32 #include <utility>
33 #include <cmath>
34 #include <limits>
39 #include <utils/common/RGBColor.h>
50 #include <utils/gui/div/GLHelper.h>
52 #include <utils/xml/XMLSubSys.h>
53 
54 #include "GNEViewNet.h"
55 #include "GNEEdge.h"
56 #include "GNELane.h"
57 #include "GNEJunction.h"
58 #include "GNEPOI.h"
59 #include "GNEApplicationWindow.h"
60 #include "GNEViewParent.h"
61 #include "GNENet.h"
62 #include "GNEUndoList.h"
63 #include "GNEInspectorFrame.h"
64 #include "GNESelectorFrame.h"
65 #include "GNEConnectorFrame.h"
66 #include "GNETLSEditorFrame.h"
67 #include "GNEAdditionalFrame.h"
68 #include "GNEAdditionalHandler.h"
69 #include "GNEPoly.h"
70 #include "GNECrossing.h"
71 #include "GNEAdditional.h"
72 #include "GNEAdditionalSet.h"
73 #include "GNEAdditionalDialog.h"
74 #include "GNERerouter.h"
75 #include "GNEConnection.h"
76 
77 
78 #ifdef CHECK_MEMORY_LEAKS
79 #include <foreign/nvwa/debug_new.h>
80 #endif // CHECK_MEMORY_LEAKS
81 
82 // ===========================================================================
83 // FOX callback mapping
84 // ===========================================================================
85 FXDEFMAP(GNEViewNet) GNEViewNetMap[] = {
86  FXMAPFUNC(SEL_COMMAND, MID_GNE_MODE_CHANGE, GNEViewNet::onCmdChangeMode),
87  FXMAPFUNC(SEL_COMMAND, MID_GNE_SPLIT_EDGE, GNEViewNet::onCmdSplitEdge),
89  FXMAPFUNC(SEL_COMMAND, MID_GNE_REVERSE_EDGE, GNEViewNet::onCmdReverseEdge),
107  FXMAPFUNC(SEL_COMMAND, MID_GNE_NODE_SHAPE, GNEViewNet::onCmdNodeShape),
108  FXMAPFUNC(SEL_COMMAND, MID_GNE_NODE_REPLACE, GNEViewNet::onCmdNodeReplace),
111 };
112 
113 // Object implementation
114 FXIMPLEMENT(GNEViewNet, GUISUMOAbstractView, GNEViewNetMap, ARRAYNUMBER(GNEViewNetMap))
115 
116 // ===========================================================================
117 // member method definitions
118 // ===========================================================================
119 GNEViewNet::GNEViewNet(FXComposite* tmpParent, FXComposite* actualParent, GUIMainWindow& app,
120  GNEViewParent* viewParent, GNENet* net, GNEUndoList* undoList,
121  FXGLVisual* glVis, FXGLCanvas* share, FXToolBar* toolBar) :
122  GUISUMOAbstractView(tmpParent, app, viewParent, net->getVisualisationSpeedUp(), glVis, share),
123  myViewParent(viewParent),
124  myNet(net),
125  myEditMode(GNE_MODE_MOVE),
126  myPreviousEditMode(GNE_MODE_MOVE),
127  myShowConnectionActivated(false),
128  myCreateEdgeSource(0),
129  myJunctionToMove(0),
130  myEdgeToMove(0),
131  myPolyToMove(0),
132  myAdditionalToMove(0),
133  myMoveSelection(false),
134  myAmInRectSelect(false),
135  myToolbar(toolBar),
136  myEditModesCombo(0),
137  myEditModeNames(),
138  myUndoList(undoList),
139  myCurrentPoly(0) {
140  // view must be the final member of actualParent
141  reparent(actualParent);
142 
143  buildEditModeControls();
144  myUndoList->mark();
145  myNet->setViewNet(this);
146 
147  ((GUIDanielPerspectiveChanger*)myChanger)->setDragDelay(100000000); // 100 milliseconds
148 
149  // init color schemes
150  GUIColorer laneColorer;
151  GUIColorScheme scheme = GUIColorScheme("uniform", RGBColor::BLACK, "road", true);
152  scheme.addColor(RGBColor::GREY, 1, "Sidewalk");
153  scheme.addColor(RGBColor(192, 66, 44), 2, "bike lane");
154  scheme.addColor(RGBColor(200, 255, 200), 3, "green verge");
155  scheme.addColor(RGBColor(150, 200, 200), 4, "waterway");
156  scheme.addColor(RGBColor(92, 92, 92), 5, "no passenger"); // paths, service roads etc
157  laneColorer.addScheme(scheme);
158  scheme = GUIColorScheme("by selection (lane-/streetwise)", RGBColor(128, 128, 128, 255), "unselected", true);
159  scheme.addColor(RGBColor(0, 80, 180, 255), 1, "selected");
160  laneColorer.addScheme(scheme);
161  scheme = GUIColorScheme("by permission code", RGBColor(240, 240, 240), "nobody");
162  scheme.addColor(RGBColor(10, 10, 10), (SUMOReal)SVC_PASSENGER, "passenger");
163  scheme.addColor(RGBColor(128, 128, 128), (SUMOReal)SVC_PEDESTRIAN, "pedestrian");
164  scheme.addColor(RGBColor(80, 80, 80), (SUMOReal)(SVC_PEDESTRIAN | SVC_DELIVERY), "pedestrian_delivery");
165  scheme.addColor(RGBColor(192, 66, 44), (SUMOReal)SVC_BICYCLE, "bicycle");
166  scheme.addColor(RGBColor(40, 100, 40), (SUMOReal)SVC_BUS, "bus");
167  scheme.addColor(RGBColor(166, 147, 26), (SUMOReal)SVC_TAXI, "taxi");
168  scheme.addColor(RGBColor::BLACK, (SUMOReal)(SVCAll & ~SVC_NON_ROAD), "normal_road");
169  scheme.addColor(RGBColor::BLACK, (SUMOReal)(SVCAll & ~(SVC_PEDESTRIAN | SVC_NON_ROAD)), "disallow_pedestrian");
170  scheme.addColor(RGBColor(255, 206, 0), (SUMOReal)(SVCAll & ~(SVC_PEDESTRIAN | SVC_BICYCLE | SVC_MOPED | SVC_NON_ROAD)), "motorway");
171  scheme.addColor(RGBColor(150, 200, 200), (SUMOReal)SVC_SHIP, "waterway");
172  scheme.addColor(RGBColor::GREEN, (SUMOReal)SVCAll, "all");
173  laneColorer.addScheme(scheme);
174 
175  scheme = GUIColorScheme("by allowed speed (lanewise)", RGBColor::RED);
176  scheme.addColor(RGBColor::YELLOW, (SUMOReal)(30 / 3.6));
177  scheme.addColor(RGBColor::GREEN, (SUMOReal)(55 / 3.6));
178  scheme.addColor(RGBColor::CYAN, (SUMOReal)(80 / 3.6));
179  scheme.addColor(RGBColor::BLUE, (SUMOReal)(120 / 3.6));
180  scheme.addColor(RGBColor::MAGENTA, (SUMOReal)(150 / 3.6));
181  laneColorer.addScheme(scheme);
182 
183  scheme = GUIColorScheme("by lane number (streetwise)", RGBColor::RED);
184  scheme.addColor(RGBColor::BLUE, (SUMOReal)5);
185  laneColorer.addScheme(scheme);
186 
187  scheme = GUIColorScheme("by given length/geometrical length", RGBColor::BLACK);
188  scheme.addColor(RGBColor::RED, (SUMOReal)0.25);
189  scheme.addColor(RGBColor::YELLOW, (SUMOReal)0.5);
190  scheme.addColor(RGBColor(179, 179, 179, 255), (SUMOReal)1.0);
191  scheme.addColor(RGBColor::GREEN, (SUMOReal)2.0);
192  scheme.addColor(RGBColor::BLUE, (SUMOReal)4.0);
193  laneColorer.addScheme(scheme);
194  laneColorer.addScheme(GUIColorScheme("by angle", RGBColor::YELLOW, "", true));
195 
196  scheme = GUIColorScheme("by priority", RGBColor::YELLOW);
197  scheme.addColor(RGBColor::RED, (SUMOReal) - 20);
198  scheme.addColor(RGBColor::GREEN, (SUMOReal)20);
199  scheme.setAllowsNegativeValues(true);
200  laneColorer.addScheme(scheme);
201  scheme = GUIColorScheme("by height at start", RGBColor::RED);
202  scheme.addColor(RGBColor::BLUE, (SUMOReal) - 10);
203  scheme.addColor(RGBColor::YELLOW, (SUMOReal)50);
204  scheme.addColor(RGBColor::GREEN, (SUMOReal)100);
205  scheme.addColor(RGBColor::MAGENTA, (SUMOReal)200);
206  scheme.setAllowsNegativeValues(true);
207  laneColorer.addScheme(scheme);
208  scheme = GUIColorScheme("by height at segment start", RGBColor::RED);
209  scheme.addColor(RGBColor::BLUE, (SUMOReal) - 10);
210  scheme.addColor(RGBColor::YELLOW, (SUMOReal)50);
211  scheme.addColor(RGBColor::GREEN, (SUMOReal)100);
212  scheme.addColor(RGBColor::MAGENTA, (SUMOReal)200);
213  scheme.setAllowsNegativeValues(true);
214  laneColorer.addScheme(scheme);
215  scheme = GUIColorScheme("by inclination", RGBColor::GREY);
216  scheme.addColor(RGBColor::YELLOW, (SUMOReal) .1);
217  scheme.addColor(RGBColor::RED, (SUMOReal) .3);
218  scheme.addColor(RGBColor::GREEN, (SUMOReal) - .1);
219  scheme.addColor(RGBColor::BLUE, (SUMOReal) - .3);
220  scheme.setAllowsNegativeValues(true);
221  laneColorer.addScheme(scheme);
222  scheme = GUIColorScheme("by segment inclination", RGBColor::GREY);
223  scheme.addColor(RGBColor::YELLOW, (SUMOReal) .1);
224  scheme.addColor(RGBColor::RED, (SUMOReal) .3);
225  scheme.addColor(RGBColor::GREEN, (SUMOReal) - .1);
226  scheme.addColor(RGBColor::BLUE, (SUMOReal) - .3);
227  scheme.setAllowsNegativeValues(true);
228  laneColorer.addScheme(scheme);
229 
230  myVisualizationSettings->laneColorer = laneColorer;
231 
232  GUIColorer junctionColorer;
233  scheme = GUIColorScheme("uniform", RGBColor(102, 0, 0), "", true);
234  scheme.addColor(RGBColor(204, 0, 0), 1, "shape not computed");
235  scheme.addColor(RGBColor(153, 0, 0), 2, "geometry points");
236  junctionColorer.addScheme(scheme);
237  scheme = GUIColorScheme("by selection", RGBColor(128, 128, 128, 255), "unselected", true);
238  scheme.addColor(RGBColor(0, 80, 180, 255), 1, "selected");
239  junctionColorer.addScheme(scheme);
240  scheme = GUIColorScheme("by type", RGBColor::GREEN, "traffic_light", true);
241  scheme.addColor(RGBColor(0, 128, 0), 1, "traffic_light_unregulated");
242  scheme.addColor(RGBColor::YELLOW, 2, "priority");
243  scheme.addColor(RGBColor::RED, 3, "priority_stop");
244  scheme.addColor(RGBColor::BLUE, 4, "right_before_left");
245  scheme.addColor(RGBColor::CYAN, 5, "allway_stop");
246  scheme.addColor(RGBColor::GREY, 6, "district");
247  scheme.addColor(RGBColor::MAGENTA, 7, "unregulated");
248  scheme.addColor(RGBColor::BLACK, 8, "dead_end");
249  scheme.addColor(RGBColor::ORANGE, 9, "rail_signal");
250  scheme.addColor(RGBColor(192, 128, 64), 10, "zipper");
251  scheme.addColor(RGBColor(192, 255, 192), 11, "traffic_light_right_on_red");
252  scheme.addColor(RGBColor(128, 0, 128), 12, "rail_crossing"); // dark purple
253  junctionColorer.addScheme(scheme);
254  myVisualizationSettings->junctionColorer = junctionColorer;
255 }
256 
257 
259 
260 
261 void
263 
264 
265 void
267  /*
268  // build coloring tools
269  {
270  const std::vector<std::string> &names = gSchemeStorage.getNames();
271  for (std::vector<std::string>::const_iterator i=names.begin(); i!=names.end(); ++i) {
272  v.getColoringSchemesCombo().appendItem((*i).c_str());
273  if ((*i) == myVisualizationSettings->name) {
274  v.getColoringSchemesCombo().setCurrentItem(v.getColoringSchemesCombo().getNumItems()-1);
275  }
276  }
277  v.getColoringSchemesCombo().setNumVisible(5);
278  }
279  */
280 
281  // locator button for junctions
282  new FXButton(cw.getLocatorPopup(),
283  "\tLocate Junction\tLocate a junction within the network.",
285  ICON_ABOVE_TEXT | FRAME_THICK | FRAME_RAISED);
286  // locator button for edges
287  new FXButton(cw.getLocatorPopup(),
288  "\tLocate Street\tLocate a street within the network.",
290  ICON_ABOVE_TEXT | FRAME_THICK | FRAME_RAISED);
291  // locator button for tls
292  new FXButton(cw.getLocatorPopup(),
293  "\tLocate TLS\tLocate a traffic light within the network.",
295  ICON_ABOVE_TEXT | FRAME_THICK | FRAME_RAISED);
296 }
297 
298 
299 bool
300 GNEViewNet::setColorScheme(const std::string& name) {
301  if (!gSchemeStorage.contains(name)) {
302  return false;
303  }
304  if (myVisualizationChanger != 0) {
305  if (myVisualizationChanger->getCurrentScheme() != name) {
307  }
308  }
309  myVisualizationSettings = &gSchemeStorage.get(name.c_str());
310  update();
311  return true;
312 }
313 
314 
315 void
316 GNEViewNet::setStatusBarText(const std::string& text) {
317  myApp->setStatusBarText(text);
318 }
319 
320 
321 bool
323  return mySelectEdges->getCheck() != 0;
324 }
325 
326 
327 bool
329  if (myEditMode == GNE_MODE_CONNECT) {
330  return true;
331  } else if (myShowConnections->shown() == false) {
332  return false;
333  } else {
334  return (myShowConnections->getCheck() == 1);
335  }
336 }
337 
338 
339 bool
341  return myExtendToEdgeNodes->getCheck() != 0;
342 }
343 
344 
345 void
347  myVisualizationSettings->selectionScale = selectionScale;
348 }
349 
350 
351 bool
353  return myChangeAllPhases->getCheck() != FALSE;
354 }
355 
356 
357 bool
359  return (myEditMode == GNE_MODE_MOVE) && (myShowJunctionAsBubble->getCheck());
360 }
361 
362 
363 int
364 GNEViewNet::doPaintGL(int mode, const Boundary& bound) {
365  // init view settings
366  glRenderMode(mode);
367  glMatrixMode(GL_MODELVIEW);
368  glPushMatrix();
369  glDisable(GL_TEXTURE_2D);
370  glDisable(GL_ALPHA_TEST);
371  glDisable(GL_BLEND);
372  glEnable(GL_DEPTH_TEST);
373 
374  // visualize rectangular selection
375  if (myAmInRectSelect) {
376  glPushMatrix();
377  glTranslated(0, 0, GLO_MAX - 1);
379  glLineWidth(2);
380  glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
381  glBegin(GL_QUADS);
382  glVertex2d(mySelCorner1.x(), mySelCorner1.y());
383  glVertex2d(mySelCorner1.x(), mySelCorner2.y());
384  glVertex2d(mySelCorner2.x(), mySelCorner2.y());
385  glVertex2d(mySelCorner2.x(), mySelCorner1.y());
386  glEnd();
387  glPopMatrix();
388  }
389 
390  // compute lane width
392  // draw decals (if not in grabbing mode)
393  if (!myUseToolTips) {
394  drawDecals();
396  paintGLGrid();
397  }
398  }
399  glLineWidth(1);
400  glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
401  const float minB[2] = { (float)bound.xmin(), (float)bound.ymin() };
402  const float maxB[2] = { (float)bound.xmax(), (float)bound.ymax() };
404  glEnable(GL_POLYGON_OFFSET_FILL);
405  glEnable(GL_POLYGON_OFFSET_LINE);
407  int hits2 = myGrid->Search(minB, maxB, *myVisualizationSettings);
408 
409  glTranslated(0, 0, GLO_ADDITIONAL);
410  for (std::map<const GUIGlObject*, int>::iterator i = myAdditionallyDrawn.begin(); i != myAdditionallyDrawn.end(); ++i) {
411  (i->first)->drawGLAdditional(this, *myVisualizationSettings);
412  }
413  glPopMatrix();
414  return hits2;
415 }
416 
417 
418 long
419 GNEViewNet::onLeftBtnPress(FXObject* obj, FXSelector sel, void* data) {
420  FXEvent* e = (FXEvent*) data;
421  setFocus();
422  // interpret object under curser
423  if (makeCurrent()) {
424  int id = getObjectUnderCursor();
427  GNEJunction* pointed_junction = 0;
428  GNELane* pointed_lane = 0;
429  GNEEdge* pointed_edge = 0;
430  GNEPOI* pointed_poi = 0;
431  GNEPoly* pointed_poly = 0;
432  GNECrossing* pointed_crossing = 0;
433  GNEAdditional* pointed_additional = 0;
434  GNEConnection* pointed_connection = 0;
435  if (pointed) {
436  switch (pointed->getType()) {
437  case GLO_JUNCTION:
438  pointed_junction = (GNEJunction*)pointed;
439  break;
440  case GLO_EDGE:
441  pointed_edge = (GNEEdge*)pointed;
442  break;
443  case GLO_LANE:
444  pointed_lane = (GNELane*)pointed;
445  pointed_edge = &(pointed_lane->getParentEdge());
446  break;
447  case GLO_POI:
448  pointed_poi = (GNEPOI*)pointed;
449  break;
450  case GLO_POLYGON:
451  pointed_poly = (GNEPoly*)pointed;
452  break;
453  case GLO_CROSSING:
454  pointed_crossing = (GNECrossing*)pointed;
455  break;
456  case GLO_ADDITIONAL:
457  pointed_additional = (GNEAdditional*)pointed;
458  break;
459  case GLO_CONNECTION:
460  pointed_connection = (GNEConnection*)pointed;
461  break;
462  default:
463  pointed = 0;
464  break;
465  }
466  }
467 
468  // decide what to do based on mode
469  switch (myEditMode) {
471  if ((e->state & CONTROLMASK) == 0) {
472  // allow moving when control is held down
473  if (!myUndoList->hasCommandGroup()) {
474  myUndoList->p_begin("create new edge");
475  }
476  if (!pointed_junction) {
477  pointed_junction = myNet->createJunction(getPositionInformation(), myUndoList);
478  }
479  if (myCreateEdgeSource == 0) {
480  myCreateEdgeSource = pointed_junction;
482  update();
483  } else {
484  if (myCreateEdgeSource != pointed_junction) {
485  // may fail to prevent double edges
486  GNEEdge* newEdge = myNet->createEdge(
488  if (newEdge) {
489  if (myAutoCreateOppositeEdge->getCheck()) {
490  myNet->createEdge(
491  pointed_junction, myCreateEdgeSource, myViewParent->getInspectorFrame()->getEdgeTemplate(), myUndoList, "-" + newEdge->getNBEdge()->getID());
492  }
494  if (myUndoList->hasCommandGroup()) {
495  myUndoList->p_end();
496  } else {
497  std::cout << "edge created without an open CommandGroup )-:\n";
498  }
499  if (myChainCreateEdge->getCheck()) {
500  myCreateEdgeSource = pointed_junction;
502  myUndoList->p_begin("create new edge");
503  } else {
504  myCreateEdgeSource = 0;
505  }
506  } else {
507  setStatusBarText("An edge with the same geometry already exists!");
508  }
509  } else {
510  setStatusBarText("Start- and endpoint for an edge must be distinct!");
511  }
512  update();
513  }
514  }
515  GUISUMOAbstractView::onLeftBtnPress(obj, sel, data);
516  break;
517 
518  case GNE_MODE_MOVE:
519  if (pointed_poly) {
520  myPolyToMove = pointed_poly;
522  } else if (pointed_junction) {
523  if (gSelected.isSelected(GLO_JUNCTION, pointed_junction->getGlID())) {
524  myMoveSelection = true;
525  } else {
526  myJunctionToMove = pointed_junction;
527  }
529  } else if (pointed_edge) {
530  if (gSelected.isSelected(GLO_EDGE, pointed_edge->getGlID())) {
531  myMoveSelection = true;
532  } else {
533  myEdgeToMove = pointed_edge;
534  }
536  } else if (pointed_additional) {
537  if (gSelected.isSelected(GLO_ADDITIONAL, pointed_additional->getGlID())) {
538  myMoveSelection = true;
539  } else {
540  // Only move additional if can be moved
541  if (pointed_additional->isAdditionalBlocked() == false) {
542  myAdditionalToMove = pointed_additional;
543  if (myAdditionalToMove->getLane()) {
545  // Obtain start position
546  SUMOReal startPos = GNEAttributeCarrier::parse<SUMOReal>(myAdditionalToMove->getAttribute(SUMO_ATTR_STARTPOS));
548  // Obtain end position
549  SUMOReal endPos = GNEAttributeCarrier::parse<SUMOReal>(myAdditionalToMove->getAttribute(SUMO_ATTR_ENDPOS));
550  // Save both values in myOldAdditionalPosition
551  myOldAdditionalPosition.set(startPos, endPos);
553  // Obtain length attribute
554  SUMOReal length = GNEAttributeCarrier::parse<SUMOReal>(myAdditionalToMove->getAttribute(SUMO_ATTR_LENGTH));
555  // Save both values in myOldAdditionalPosition
556  myOldAdditionalPosition.set(startPos, length);
557  } else {
558  // Save only startpos in myOldAdditionalPosition
559  myOldAdditionalPosition.set(startPos, 0);
560  }
561  }
562  // Set myAdditionalMovingReference
564  } else {
565  // Set myOldAdditionalPosition and myAdditionalMovingReference
568  }
569  }
570  }
571  } else {
572  GUISUMOAbstractView::onLeftBtnPress(obj, sel, data);
573  }
574  update();
575  break;
576 
577  case GNE_MODE_DELETE:
578  if (pointed_junction) {
579  /*
580  if (gSelected.isSelected(GLO_JUNCTION, pointed_junction->getGlID())) {
581  deleteSelectedJunctions();
582  }
583  */
584  myNet->deleteJunction(pointed_junction, myUndoList);
585  } else if (pointed_lane && !mySelectEdges->getCheck()) {
586  myNet->deleteLane(pointed_lane, myUndoList);
587  } else if (pointed_edge) {
588  /*
589  if (gSelected.isSelected(GLO_EDGE, pointed_edge->getGlID())) {
590  deleteSelectedEdges();
591  }
592  */
594  } else if (pointed_poi) {
595  // XXX this is a dirty dirty hack! implemente GNEChange_POI
596  myNet->getShapeContainer().removePOI(pointed_poi->getMicrosimID());
597  update();
598  } else if (pointed_additional) {
599  myViewParent->getAdditionalFrame()->removeAdditional(pointed_additional);
600  update();
601  } else if (pointed_connection) {
602  myNet->deleteConnection(pointed_connection, myUndoList);
603  update();
604  } else {
605  GUISUMOAbstractView::onLeftBtnPress(obj, sel, data);
606  }
607  break;
608 
609  case GNE_MODE_INSPECT: {
610  GNEAttributeCarrier* pointedAC = 0;
611  GUIGlObject* pointedO = 0;
612  if (pointed_junction) {
613  pointedAC = pointed_junction;
614  pointedO = pointed_junction;
615  } else if (pointed_lane) { // implies pointed_edge
616  if (selectEdges()) {
617  pointedAC = pointed_edge;
618  pointedO = pointed_edge;
619  } else {
620  pointedAC = pointed_lane;
621  pointedO = pointed_lane;
622  }
623  } else if (pointed_edge) {
624  pointedAC = pointed_edge;
625  pointedO = pointed_edge;
626  } else if (pointed_crossing) {
627  pointedAC = pointed_crossing;
628  pointedO = pointed_crossing;
629  } else if (pointed_additional) {
630  pointedAC = pointed_additional;
631  pointedO = pointed_additional;
632  } else if (pointed_connection) {
633  pointedAC = pointed_connection;
634  pointedO = pointed_connection;
635  }
636 
637  std::vector<GNEAttributeCarrier*> selected;
638  if (pointedO && gSelected.isSelected(pointedO->getType(), pointedO->getGlID())) {
639  std::set<GUIGlID> selectedIDs = gSelected.getSelected(pointedO->getType());
640  selected = myNet->retrieveAttributeCarriers(selectedIDs, pointedO->getType());
641  } else if (pointedAC != 0) {
642  selected.push_back(pointedAC);
643  }
644  myViewParent->getInspectorFrame()->inspect(selected);
645  GUISUMOAbstractView::onLeftBtnPress(obj, sel, data);
646  update();
647  break;
648  }
649 
650  case GNE_MODE_SELECT:
651  if (pointed_lane && selectEdges()) {
652  gSelected.toggleSelection(pointed_edge->getGlID());
653  } else if (pointed) {
654  gSelected.toggleSelection(pointed->getGlID());
655  }
656 
657  myAmInRectSelect = (((FXEvent*)data)->state & SHIFTMASK) != 0;
658  if (myAmInRectSelect) {
661  } else {
662  GUISUMOAbstractView::onLeftBtnPress(obj, sel, data);
663  }
664  update();
665  break;
666 
667  case GNE_MODE_CONNECT:
668  if (pointed_lane) {
669  const bool mayPass = (((FXEvent*)data)->state & SHIFTMASK) != 0;
670  const bool allowConflict = (((FXEvent*)data)->state & CONTROLMASK) != 0;
671  myViewParent->getConnectorFrame()->handleLaneClick(pointed_lane, mayPass, allowConflict, true);
672  update();
673  }
674  GUISUMOAbstractView::onLeftBtnPress(obj, sel, data);
675  break;
676 
677  case GNE_MODE_TLS:
678  if (pointed_junction) {
679  myViewParent->getTLSEditorFrame()->editJunction(pointed_junction);
680  update();
681  }
682  GUISUMOAbstractView::onLeftBtnPress(obj, sel, data);
683  break;
684 
685  case GNE_MODE_ADDITIONAL:
686  if (pointed_additional == NULL) {
687  GNENetElement* netElement = dynamic_cast<GNENetElement*>(pointed);
688  if (myViewParent->getAdditionalFrame()->addAdditional(netElement, this)) {
689  update();
690  }
691  }
692  GUISUMOAbstractView::onLeftBtnPress(obj, sel, data);
693  break;
694 
695  default:
696  GUISUMOAbstractView::onLeftBtnPress(obj, sel, data);
697  }
698  makeNonCurrent();
699  }
700  return 1;
701 }
702 
703 
704 long
705 GNEViewNet::onLeftBtnRelease(FXObject* obj, FXSelector sel, void* data) {
707  if (myPolyToMove) {
708  myPolyToMove = 0;
709  } else if (myJunctionToMove) {
710  // position is already up to date but we must register with myUndoList
713  }
714  myJunctionToMove = 0;
715  } else if (myEdgeToMove) {
716  // shape is already up to date but we must register with myUndoList
717  const std::string& newShape = myEdgeToMove->getAttribute(SUMO_ATTR_SHAPE);
719  myEdgeToMove = 0;
720  } else if (myAdditionalToMove) {
721  if (myAdditionalToMove->getLane()) {
723  myAdditionalToMove = 0;
724  } else {
726  myAdditionalToMove = 0;
727  }
728  } else if (myMoveSelection) {
729  // positions and shapes are already up to date but we must register with myUndoList
731  myMoveSelection = false;
732  } else if (myAmInRectSelect) {
733  myAmInRectSelect = false;
734  // shift held down on mouse-down and mouse-up
735  if (((FXEvent*)data)->state & SHIFTMASK) {
736  if (makeCurrent()) {
737  Boundary b;
738  b.add(mySelCorner1);
739  b.add(mySelCorner2);
741  makeNonCurrent();
742  }
743  }
744  update();
745  }
746  return 1;
747 }
748 
749 
750 long
751 GNEViewNet::onDoubleClicked(FXObject*, FXSelector, void*) {
752  // If current edit mode is INSPECT or ADDITIONAL
754  setFocus();
755  // interpret object under curser
756  if (makeCurrent()) {
757  int id = getObjectUnderCursor();
760  // If there are a pointed element an is an additional
761  if (pointed && pointed->getType() == GLO_ADDITIONAL) {
762  // Obtain pointer additional an open an AdditionalDialog if item own it
763  GNEAdditional* pointed_additional = (GNEAdditional*)pointed;
764  pointed_additional->openAdditionalDialog();
765  }
766  makeNonCurrent();
767  }
768  }
769  return 1;
770 }
771 
772 
773 long
774 GNEViewNet::onMouseMove(FXObject* obj, FXSelector sel, void* data) {
775  GUISUMOAbstractView::onMouseMove(obj, sel, data);
776  if (myPolyToMove) {
778  } else if (myJunctionToMove) {
780  } else if (myEdgeToMove) {
782  } else if (myAdditionalToMove) {
783  // If additional is placed over lane, move it across it
784  if (myAdditionalToMove->getLane()) {
787  myAdditionalMovingReference.set(posOfMouseOverLane, 0, 0);
788  } else {
789  // Calculate offset movement
792  }
793  update();
794  } else if (myMoveSelection) {
795  Position moveTarget = getPositionInformation();
796  myNet->moveSelection(myMoveSrc, moveTarget);
797  myMoveSrc = moveTarget;
798  } else if (myAmInRectSelect) {
800  update();
801  }
802  return 1;
803 }
804 
805 
806 void
807 GNEViewNet::abortOperation(bool clearSelection) {
808  setFocus(); // steal focus from any text fields
809  if (myCreateEdgeSource) {
811  myCreateEdgeSource = 0;
812  } else if (myEditMode == GNE_MODE_SELECT) {
813  myAmInRectSelect = false;
814  if (clearSelection) {
815  gSelected.clear();
816  }
817  } else if (myEditMode == GNE_MODE_CONNECT) {
819  } else if (myEditMode == GNE_MODE_TLS) {
821  } else if (myEditMode == GNE_MODE_MOVE) {
823  }
824  myUndoList->p_abort();
825 }
826 
827 
828 void
831  setStatusBarText("Cannot delete in this mode");
832  } else {
833  myUndoList->p_begin("delete selection");
836  myUndoList->p_end();
837  }
838 }
839 
840 
841 void
843  if (myEditMode == GNE_MODE_CONNECT) {
845  } else if (myEditMode == GNE_MODE_TLS) {
847  } else if (myEditMode == GNE_MODE_MOVE && myCurrentPoly != 0) {
848  if (myCurrentPoly->getEditedJunction() != 0) {
851  update();
852  }
853  }
854 }
855 
856 
857 long
858 GNEViewNet::onCmdChangeMode(FXObject*, FXSelector, void* data) {
859  setEditMode(myEditModeNames.get((char*) data));
860  return 1;
861 }
862 
863 
864 void
866  switch (selid) {
869  break;
870  case MID_GNE_MODE_MOVE:
872  break;
873  case MID_GNE_MODE_DELETE:
875  break;
878  break;
879  case MID_GNE_MODE_SELECT:
881  break;
884  break;
885  case MID_GNE_MODE_TLS:
887  break;
890  break;
891  default:
892  FXMessageBox::error(this, MBOX_OK, "invalid edit mode", "%s", "...");
893  break;
894  }
895  myEditModesCombo->setCurrentItem(myEditModesCombo->findItem(myEditModeNames.getString(myEditMode).c_str()));
896 }
897 
898 
899 void
902 }
903 
904 
907  return myViewParent;
908 }
909 
910 
911 GNENet*
913  return myNet;
914 }
915 
916 
919  return myUndoList;
920 }
921 
922 
923 EditMode
925  return myEditMode;
926 }
927 
928 
929 bool
932 }
933 
934 
937  GNEJunction* junction = 0;
938  if (makeCurrent()) {
942  if (pointed) {
943  switch (pointed->getType()) {
944  case GLO_JUNCTION:
945  junction = (GNEJunction*)pointed;
946  break;
947  default:
948  break;
949  }
950  }
951  }
952  return junction;
953 }
954 
955 
956 
957 
958 GNEEdge*
960  GNEEdge* edge = 0;
961  if (makeCurrent()) {
965  if (pointed) {
966  switch (pointed->getType()) {
967  case GLO_EDGE:
968  edge = (GNEEdge*)pointed;
969  break;
970  case GLO_LANE:
971  edge = &(((GNELane*)pointed)->getParentEdge());
972  break;
973  default:
974  break;
975  }
976  }
977  }
978  return edge;
979 }
980 
981 
982 GNELane*
984  GNELane* lane = 0;
985  if (makeCurrent()) {
989  if (pointed) {
990  if (pointed->getType() == GLO_LANE) {
991  lane = (GNELane*)pointed;
992  }
993  }
994  }
995  return lane;
996 }
997 
998 
999 std::set<GNEEdge*>
1001  std::set<GNEEdge*> result;
1002  if (makeCurrent()) {
1003  const std::vector<GUIGlID> ids = getObjectsAtPosition(myPopupSpot, 1.0);
1004  for (std::vector<GUIGlID>::const_iterator it = ids.begin(); it != ids.end(); ++it) {
1007  if (pointed) {
1008  switch (pointed->getType()) {
1009  case GLO_EDGE:
1010  result.insert((GNEEdge*)pointed);
1011  break;
1012  case GLO_LANE:
1013  result.insert(&(((GNELane*)pointed)->getParentEdge()));
1014  break;
1015  default:
1016  break;
1017  }
1018  }
1019  }
1020  }
1021  return result;
1022 }
1023 
1024 
1025 long
1026 GNEViewNet::onCmdSplitEdge(FXObject*, FXSelector, void*) {
1028  if (edge != 0) {
1030  }
1031  return 1;
1032 }
1033 
1034 
1035 long
1036 GNEViewNet::onCmdSplitEdgeBidi(FXObject*, FXSelector, void*) {
1037  std::set<GNEEdge*> edges = getEdgesAtCursorPosition(myPopupSpot);
1038  if (edges.size() != 0) {
1039  myNet->splitEdgesBidi(edges, (*edges.begin())->getSplitPos(myPopupSpot), myUndoList);
1040  }
1041  return 1;
1042 }
1043 
1044 
1045 long
1046 GNEViewNet::onCmdReverseEdge(FXObject*, FXSelector, void*) {
1048  if (edge != 0) {
1049  myNet->reverseEdge(edge, myUndoList);
1050  }
1051  return 1;
1052 }
1053 
1054 
1055 long
1056 GNEViewNet::onCmdAddReversedEdge(FXObject*, FXSelector, void*) {
1058  if (edge != 0) {
1060  }
1061  return 1;
1062 }
1063 
1064 
1065 long
1066 GNEViewNet::onCmdSetEdgeEndpoint(FXObject*, FXSelector, void*) {
1068  if (edge != 0) {
1070  }
1071  return 1;
1072 }
1073 
1074 
1075 long
1076 GNEViewNet::onCmdResetEdgeEndpoint(FXObject*, FXSelector, void*) {
1078  if (edge != 0) {
1080  }
1081  return 1;
1082 }
1083 
1084 
1085 long
1086 GNEViewNet::onCmdStraightenEdges(FXObject*, FXSelector, void*) {
1088  if (edge != 0) {
1089  if (gSelected.isSelected(GLO_EDGE, edge->getGlID())) {
1090  myUndoList->p_begin("straighten selected edges");
1091  std::vector<GNEEdge*> edges = myNet->retrieveEdges(true);
1092  for (std::vector<GNEEdge*>::iterator it = edges.begin(); it != edges.end(); it++) {
1093  (*it)->setAttribute(SUMO_ATTR_SHAPE, "", myUndoList);
1094  }
1095  myUndoList->p_end();
1096  } else {
1097  myUndoList->p_begin("straighten edge");
1099  myUndoList->p_end();
1100  }
1101  }
1102  return 1;
1103 }
1104 
1105 
1106 long
1107 GNEViewNet::onCmdSimplifyShape(FXObject*, FXSelector, void*) {
1108  if (myCurrentPoly != 0) {
1110  update();
1111  }
1112  return 1;
1113 }
1114 
1115 
1116 long
1117 GNEViewNet::onCmdDeleteGeometry(FXObject*, FXSelector, void*) {
1118  if (myCurrentPoly != 0) {
1120  update();
1121  }
1122  return 1;
1123 }
1124 
1125 
1126 long
1127 GNEViewNet::onCmdDuplicateLane(FXObject*, FXSelector, void*) {
1129  if (lane != 0) {
1130  if (gSelected.isSelected(GLO_LANE, lane->getGlID())) {
1131  myUndoList->p_begin("duplicate selected lanes");
1132  std::vector<GNELane*> lanes = myNet->retrieveLanes(true);
1133  for (std::vector<GNELane*>::iterator it = lanes.begin(); it != lanes.end(); it++) {
1135  }
1136  myUndoList->p_end();
1137  } else {
1138  myUndoList->p_begin("duplicate lane");
1139  myNet->duplicateLane(lane, myUndoList);
1140  myUndoList->p_end();
1141  }
1142  }
1143  return 1;
1144 }
1145 
1146 
1147 long
1148 GNEViewNet::onCmdRestrictLaneSidewalk(FXObject*, FXSelector, void*) {
1149  return restrictLane(SVC_PEDESTRIAN);
1150 }
1151 
1152 
1153 long
1154 GNEViewNet::onCmdRestrictLaneBikelane(FXObject*, FXSelector, void*) {
1155  return restrictLane(SVC_BICYCLE);
1156 }
1157 
1158 
1159 long
1160 GNEViewNet::onCmdRestrictLaneBuslane(FXObject*, FXSelector, void*) {
1161  return restrictLane(SVC_BUS);
1162 }
1163 
1164 
1165 long
1166 GNEViewNet::onCmdAddRestrictedLaneSidewalk(FXObject*, FXSelector, void*) {
1168 }
1169 
1170 
1171 long
1172 GNEViewNet::onCmdAddRestrictedLaneBikelane(FXObject*, FXSelector, void*) {
1174 }
1175 
1176 
1177 long
1178 GNEViewNet::onCmdAddRestrictedLaneBuslane(FXObject*, FXSelector, void*) {
1179  return addRestrictedLane(SVC_BUS);
1180 }
1181 
1182 
1183 long
1184 GNEViewNet::onCmdRemoveRestrictedLaneSidewalk(FXObject*, FXSelector, void*) {
1186 }
1187 
1188 
1189 long
1190 GNEViewNet::onCmdRemoveRestrictedLaneBikelane(FXObject*, FXSelector, void*) {
1192 }
1193 
1194 
1195 long
1196 GNEViewNet::onCmdRemoveRestrictedLaneBuslane(FXObject*, FXSelector, void*) {
1197  return removeRestrictedLane(SVC_BUS);
1198 }
1199 
1200 
1201 bool
1204  if (lane != 0) {
1205  // Get selected lanes
1206  std::vector<GNELane*> lanes = myNet->retrieveLanes(true); ;
1207  // Declare map of edges and lanes
1208  std::map<GNEEdge*, GNELane*> mapOfEdgesAndLanes;
1209  // Iterate over selected lanes
1210  for (std::vector<GNELane*>::iterator i = lanes.begin(); i != lanes.end(); i++) {
1211  mapOfEdgesAndLanes[myNet->retrieveEdge((*i)->getParentEdge().getID())] = (*i);
1212  }
1213  // Throw warning dialog if there hare multiple lanes selected in the same edge
1214  if (mapOfEdgesAndLanes.size() != lanes.size()) {
1215  FXMessageBox::information(getApp(), MBOX_OK,
1216  ("Multiple lane in the same edge selected"), "%s",
1217  ("There are selected lanes that belong to the same edge.\n Only one lane pro edge will be restricted for " + toString(vclass) + ".").c_str());
1218  }
1219  // If we handeln a set of lanes
1220  if (mapOfEdgesAndLanes.size() > 0) {
1221  // declare counter for number of Sidewalks
1222  int counter = 0;
1223  // iterate over selected lanes
1224  for (std::map<GNEEdge*, GNELane*>::iterator i = mapOfEdgesAndLanes.begin(); i != mapOfEdgesAndLanes.end(); i++) {
1225  if (i->first->hasRestrictedLane(vclass)) {
1226  counter++;
1227  }
1228  }
1229  // if all edges parent own a Sidewalk, stop function
1230  if (counter == (int)mapOfEdgesAndLanes.size()) {
1231  FXMessageBox::information(getApp(), MBOX_OK, "%s",
1232  ("Set vclass for " + toString(vclass) + " to selected lanes").c_str(), "%s",
1233  ("All lanes own already another lane in the same edge with a restriction for " + toString(vclass)).c_str());
1234  return 0;
1235  } else {
1236  // Ask confirmation to user
1237  FXuint answer = FXMessageBox::question(getApp(), MBOX_YES_NO,
1238  ("Set vclass for " + toString(vclass) + " to selected lanes").c_str(), "%s",
1239  (toString(mapOfEdgesAndLanes.size() - counter) + " lanes will be restricted for " + toString(vclass) + ". continue?").c_str());
1240  if (answer != 1) { //1:yes, 2:no, 4:esc
1241  return 0;
1242  }
1243  }
1244  // begin undo operation
1245  myUndoList->p_begin("restrict lanes to " + toString(vclass));
1246  // iterate over selected lanes
1247  for (std::map<GNEEdge*, GNELane*>::iterator i = mapOfEdgesAndLanes.begin(); i != mapOfEdgesAndLanes.end(); i++) {
1248  // Transform lane to Sidewalk
1249  myNet->restrictLane(vclass, i->second, myUndoList);
1250  }
1251  // end undo operation
1252  myUndoList->p_end();
1253  } else {
1254  // If only have a single lane, start undo/redo operation
1255  myUndoList->p_begin("restrict lane to " + toString(vclass));
1256  // Transform lane to Sidewalk
1257  myNet->restrictLane(vclass, lane, myUndoList);
1258  // end undo operation
1259  myUndoList->p_end();
1260  }
1261  }
1262  return 1;
1263 }
1264 
1265 
1266 bool
1269  if (lane != 0) {
1270  // Get selected edges
1271  std::vector<GNEEdge*> edges = myNet->retrieveEdges(true);
1272  // get selected lanes
1273  std::vector<GNELane*> lanes = myNet->retrieveLanes(true);
1274  // Declare set of edges
1275  std::set<GNEEdge*> setOfEdges;
1276  // Fill set of edges with vector of edges
1277  for (std::vector<GNEEdge*>::iterator i = edges.begin(); i != edges.end(); i++) {
1278  setOfEdges.insert(*i);
1279  }
1280  // iterate over selected lanes
1281  for (std::vector<GNELane*>::iterator it = lanes.begin(); it != lanes.end(); it++) {
1282  // Insert pointer to edge into set of edges (To avoid duplicates)
1283  setOfEdges.insert(myNet->retrieveEdge((*it)->getParentEdge().getID()));
1284  }
1285  // If we handeln a set of edges
1286  if (setOfEdges.size() > 0) {
1287  // declare counter for number of restrictions
1288  int counter = 0;
1289  // iterate over set of edges
1290  for (std::set<GNEEdge*>::iterator it = setOfEdges.begin(); it != setOfEdges.end(); it++) {
1291  // update counter if edge has already a restricted lane of type "vclass"
1292  if ((*it)->hasRestrictedLane(vclass) == true) {
1293  counter++;
1294  }
1295  }
1296  // if all lanes own a Sidewalk, stop function
1297  if (counter == (int)setOfEdges.size()) {
1298  FXMessageBox::information(getApp(), MBOX_OK, "%s",
1299  ("Add vclass for" + toString(vclass) + " to selected lanes").c_str(), "%s",
1300  ("All lanes own already another lane in the same edge with a restriction for " + toString(vclass)).c_str());
1301  return 0;
1302  } else {
1303  // Ask confirmation to user
1304  FXuint answer = FXMessageBox::question(getApp(), MBOX_YES_NO,
1305  ("Add vclass for " + toString(vclass) + " to selected lanes").c_str(), "%s",
1306  (toString(setOfEdges.size() - counter) + " restrictions for " + toString(vclass) + " will be added. continue?").c_str());
1307  if (answer != 1) { //1:yes, 2:no, 4:esc
1308  return 0;
1309  }
1310  }
1311  // begin undo operation
1312  myUndoList->p_begin("Add restrictions for " + toString(vclass));
1313  // iterate over set of edges
1314  for (std::set<GNEEdge*>::iterator it = setOfEdges.begin(); it != setOfEdges.end(); it++) {
1315  // add Sidewalk
1316  myNet->addSRestrictedLane(vclass, *(*it), myUndoList);
1317  }
1318  // end undo operation
1319  myUndoList->p_end();
1320  } else {
1321  // If only have a single lane, start undo/redo operation
1322  myUndoList->p_begin("Add vclass for " + toString(vclass));
1323  // Add Sidewalk
1324  myNet->addSRestrictedLane(vclass, lane->getParentEdge(), myUndoList);
1325  // end undo/redo operation
1326  myUndoList->p_end();
1327  }
1328  }
1329  return 1;
1330 }
1331 
1332 
1333 bool
1336  if (lane != 0) {
1337  // Get selected edges
1338  std::vector<GNEEdge*> edges = myNet->retrieveEdges(true);
1339  // get selected lanes
1340  std::vector<GNELane*> lanes = myNet->retrieveLanes(true);
1341  // Declare set of edges
1342  std::set<GNEEdge*> setOfEdges;
1343  // Fill set of edges with vector of edges
1344  for (std::vector<GNEEdge*>::iterator i = edges.begin(); i != edges.end(); i++) {
1345  setOfEdges.insert(*i);
1346  }
1347  // iterate over selected lanes
1348  for (std::vector<GNELane*>::iterator it = lanes.begin(); it != lanes.end(); it++) {
1349  // Insert pointer to edge into set of edges (To avoid duplicates)
1350  setOfEdges.insert(myNet->retrieveEdge((*it)->getParentEdge().getID()));
1351  }
1352  // If we handeln a set of edges
1353  if (setOfEdges.size() > 0) {
1354  // declare counter for number of restrictions
1355  int counter = 0;
1356  // iterate over set of edges
1357  for (std::set<GNEEdge*>::iterator it = setOfEdges.begin(); it != setOfEdges.end(); it++) {
1358  // update counter if edge has already a restricted lane of type "vclass"
1359  if ((*it)->hasRestrictedLane(vclass) == true) {
1360  counter++;
1361  }
1362  }
1363  // if all lanes don't own a Sidewalk, stop function
1364  if (counter == 0) {
1365  FXMessageBox::information(getApp(), MBOX_OK, "%s",
1366  ("Remove vclass for " + toString(vclass) + " to selected lanes").c_str(), "%s",
1367  ("Selected lanes and edges haven't a restriction for " + toString(vclass)).c_str());
1368  return 0;
1369  } else {
1370  // Ask confirmation to user
1371  FXuint answer = FXMessageBox::question(getApp(), MBOX_YES_NO,
1372  ("Remove vclass for " + toString(vclass) + " to selected lanes").c_str(), "%s",
1373  (toString(counter) + " restrictions for " + toString(vclass) + " will be removed. continue?").c_str());
1374  if (answer != 1) { //1:yes, 2:no, 4:esc
1375  return 0;
1376  }
1377  }
1378  // begin undo operation
1379  myUndoList->p_begin("Remove restrictions for " + toString(vclass));
1380  // iterate over set of edges
1381  for (std::set<GNEEdge*>::iterator it = setOfEdges.begin(); it != setOfEdges.end(); it++) {
1382  // add Sidewalk
1383  myNet->removeRestrictedLane(vclass, *(*it), myUndoList);
1384  }
1385  // end undo operation
1386  myUndoList->p_end();
1387  } else {
1388  // If only have a single lane, start undo/redo operation
1389  myUndoList->p_begin("Remove vclass for " + toString(vclass));
1390  // Remove Sidewalk
1392  // end undo/redo operation
1393  myUndoList->p_end();
1394  }
1395  }
1396  return 1;
1397 }
1398 
1399 
1400 long
1401 GNEViewNet::onCmdRevertRestriction(FXObject*, FXSelector, void*) {
1403  if (lane != 0) {
1404  // Declare vector of lanes
1405  std::vector<GNELane*> lanes;
1406  // Check if we have a set of selected edges or lanes
1408  // Get selected edgeds
1409  std::vector<GNEEdge*> edges = myNet->retrieveEdges(true);
1410  // fill vector of lanes with the lanes of selected edges
1411  for (std::vector<GNEEdge*>::iterator i = edges.begin(); i != edges.end(); i++) {
1412  for (std::vector<GNELane*>::const_iterator j = (*i)->getLanes().begin(); j != (*i)->getLanes().end(); j++) {
1413  lanes.push_back(*j);
1414  }
1415  }
1416  } else if (gSelected.isSelected(GLO_LANE, lane->getGlID())) {
1417  // get selected lanes
1418  lanes = myNet->retrieveLanes(true);
1419  }
1420  // If we handeln a set of lanes
1421  if (lanes.size() > 0) {
1422  // declare counter for number of Sidewalks
1423  int counter = 0;
1424  // iterate over selected lanes
1425  for (std::vector<GNELane*>::iterator it = lanes.begin(); it != lanes.end(); it++) {
1426  if (((*it)->isRestricted(SVC_PEDESTRIAN)) || ((*it)->isRestricted(SVC_BICYCLE)) || ((*it)->isRestricted(SVC_BUS))) {
1427  counter++;
1428  }
1429  }
1430  // if none of selected lanes has a transformation, stop
1431  if (counter == 0) {
1432  FXMessageBox::information(getApp(), MBOX_OK,
1433  "Revert restriction", "None of selected lanes has a previous restriction");
1434  return 0;
1435  } else {
1436  // Ask confirmation to user
1437  FXuint answer = FXMessageBox::question(getApp(), MBOX_YES_NO,
1438  "Revert restriction", "%s",
1439  (toString(counter) + " restrictions of lanes lanes will be reverted. continue?").c_str());
1440  if (answer != 1) { //1:yes, 2:no, 4:esc
1441  return 0;
1442  }
1443  }
1444  // begin undo operation
1445  myUndoList->p_begin("revert restrictions");
1446  // iterate over selected lanes
1447  for (std::vector<GNELane*>::iterator it = lanes.begin(); it != lanes.end(); it++) {
1448  // revert transformation
1450  }
1451  // end undo operation
1452  myUndoList->p_end();
1453  } else {
1454  // If only have a single lane, start undo/redo operation
1455  myUndoList->p_begin("revert restriction");
1456  // revert transformation
1458  // end undo operation
1459  myUndoList->p_end();
1460  }
1461  }
1462  return 1;
1463 }
1464 
1465 
1466 long
1467 GNEViewNet::onCmdNodeShape(FXObject*, FXSelector, void*) {
1469  if (junction != 0) {
1470  if (myCurrentPoly == 0) {
1471  if (junction->getNBNode()->getShape().size() > 1) {
1473  //std::cout << junction->getNBNode()->getShape() << "\n";
1474  junction->getNBNode()->computeNodeShape(-1);
1475  if (myCurrentPoly != 0) {
1477  delete myCurrentPoly;
1478  myCurrentPoly = 0;
1479  }
1480  PositionVector shape = junction->getNBNode()->getShape();
1481  shape.closePolygon();
1482  myCurrentPoly = new GNEPoly(myNet, junction, "node_shape:" + junction->getMicrosimID(), "node shape",
1483  shape, false, RGBColor::GREEN, GLO_POLYGON);
1486 
1487  update();
1488  }
1489  } else {
1492  update();
1493  }
1494  }
1495  return 1;
1496 }
1497 
1498 
1499 void
1501  if (myCurrentPoly != 0) {
1503  delete myCurrentPoly;
1504  myCurrentPoly = 0;
1505  }
1506 }
1507 
1508 
1509 long
1510 GNEViewNet::onCmdNodeReplace(FXObject*, FXSelector, void*) {
1512  if (junction != 0) {
1514  update();
1515  }
1516  return 1;
1517 }
1518 
1519 
1520 long
1521 GNEViewNet::onCmdToogleShowConnection(FXObject*, FXSelector, void*) {
1525  }
1526  // Update viewnNet to show/hide conections
1527  update();
1528  // Hide/show connections requiere recompute
1529  getNet()->requireRecompute();
1530  return 1;
1531 }
1532 
1533 
1534 long
1535 GNEViewNet::onCmdToogleShowBubbles(FXObject*, FXSelector, void*) {
1536  // Update Junction Shapes
1538  return 1;
1539 }
1540 
1541 
1542 // ===========================================================================
1543 // private
1544 // ===========================================================================
1545 
1546 void
1548  setStatusBarText("");
1549  abortOperation(false);
1550  if (mode == myEditMode) {
1551  setStatusBarText("Mode already selected");
1552  } else {
1554  myEditMode = mode;
1555  // First check if previous mode was MOVE
1557  // Update junctions again to calculate connections and disable bubbles
1559  myShowJunctionAsBubble->setCheck(false);
1560  }
1561  switch (mode) {
1562  case GNE_MODE_CONNECT:
1563  case GNE_MODE_TLS:
1564  // modes which depend on computed data
1566  break;
1567  default:
1568  break;
1569  }
1570  }
1572 }
1573 
1574 
1575 void
1577  // initialize mappings
1578  myEditModeNames.insert("(e) Create Edge", GNE_MODE_CREATE_EDGE);
1579  myEditModeNames.insert("(m) Move", GNE_MODE_MOVE);
1580  myEditModeNames.insert("(d) Delete", GNE_MODE_DELETE);
1581  myEditModeNames.insert("(i) Inspect", GNE_MODE_INSPECT);
1582  myEditModeNames.insert("(s) Select", GNE_MODE_SELECT);
1583  myEditModeNames.insert("(c) Connect", GNE_MODE_CONNECT);
1584  myEditModeNames.insert("(t) Traffic Lights", GNE_MODE_TLS);
1585  myEditModeNames.insert("(a) Additionals", GNE_MODE_ADDITIONAL);
1586 
1587  // initialize combo for modes
1589  new FXComboBox(myToolbar, 12, this, MID_GNE_MODE_CHANGE,
1590  FRAME_SUNKEN | LAYOUT_LEFT | LAYOUT_TOP | COMBOBOX_STATIC | LAYOUT_CENTER_Y);
1591 
1592  std::vector<std::string> names = myEditModeNames.getStrings();
1593  for (std::vector<std::string>::const_iterator it = names.begin(); it != names.end(); it++) {
1594  myEditModesCombo->appendItem(it->c_str());
1595  }
1596  myEditModesCombo->setNumVisible((int)myEditModeNames.size());
1597 
1598  // initialize mode specific controls
1599  myChainCreateEdge = new FXMenuCheck(myToolbar, "chain\t\tCreate consecutive edges with a single click (hit ESC to cancel chain).", this, 0);
1600  myAutoCreateOppositeEdge = new FXMenuCheck(myToolbar,
1601  "two-way\t\tAutomatically create an edge in the opposite direction", this, 0);
1602  mySelectEdges = new FXMenuCheck(myToolbar, "select edges\t\tToggle whether clicking should select edges or lanes", this, 0);
1603  mySelectEdges->setCheck();
1604 
1605  myShowConnections = new FXMenuCheck(myToolbar, "show connections\t\tToggle show connections over junctions", this, MID_GNE_SHOW_CONNECTIONS);
1606  myShowConnections->setCheck(false);
1607 
1608  myExtendToEdgeNodes = new FXMenuCheck(myToolbar, "auto-select nodes\t\tToggle whether selecting multiple edges should automatically select their nodes", this, 0);
1609 
1610  myWarnAboutMerge = new FXMenuCheck(myToolbar, "ask for merge\t\tAsk for confirmation before merging junctions.", this, 0);
1611  myWarnAboutMerge->setCheck(true);
1612 
1613  myShowJunctionAsBubble = new FXMenuCheck(myToolbar, "Show junction as bubbles\t\tShow juntion's shape as a bubble.", this, MID_GNE_SHOW_BUBBLES);
1614  myShowJunctionAsBubble->setCheck(false);
1615 
1616  myChangeAllPhases = new FXMenuCheck(myToolbar, "apply change to all phases\t\tToggle whether clicking should apply state changes to all phases of the current traffic light plan", this, 0);
1617  myChangeAllPhases->setCheck(false);
1618 }
1619 
1620 
1621 void
1623  // MAGIC modifier to avoid flicker. at least it is consistent for move AND
1624  // zoom. Probably has to do with spacing
1625  const int addChange = 4;
1626 
1627  // hide all controls
1628  myChainCreateEdge->hide();
1629  myAutoCreateOppositeEdge->hide();
1630  mySelectEdges->hide();
1631  myShowConnections->hide();
1632  myExtendToEdgeNodes->hide();
1633  myChangeAllPhases->hide();
1634  myWarnAboutMerge->hide();
1635  myShowJunctionAsBubble->hide();
1636  int widthChange = 0;
1637  // Close all Frames
1638  if (myViewParent->getInspectorFrame()->shown()) {
1639  widthChange += myViewParent->getInspectorFrame()->getWidth() + addChange;
1641  }
1642  if (myViewParent->getSelectorFrame()->shown()) {
1643  widthChange += myViewParent->getSelectorFrame()->getWidth() + addChange;
1645  }
1646  if (myViewParent->getConnectorFrame()->shown()) {
1647  widthChange += myViewParent->getConnectorFrame()->getWidth() + addChange;
1649  }
1650  if (myViewParent->getTLSEditorFrame()->shown()) {
1651  widthChange += myViewParent->getTLSEditorFrame()->getWidth() + addChange;
1653  }
1654  if (myViewParent->getAdditionalFrame()->shown()) {
1655  widthChange += myViewParent->getAdditionalFrame()->getWidth() + addChange;
1657  }
1658  // enable selected controls
1659  switch (myEditMode) {
1660  case GNE_MODE_CREATE_EDGE:
1661  myChainCreateEdge->show();
1662  myAutoCreateOppositeEdge->show();
1663  break;
1664  case GNE_MODE_DELETE:
1665  mySelectEdges->show();
1666  myShowConnections->show();
1667  break;
1668  case GNE_MODE_INSPECT:
1669  widthChange -= myViewParent->getInspectorFrame()->getWidth() + addChange;
1671  mySelectEdges->show();
1672  myShowConnections->show();
1673  break;
1674  case GNE_MODE_SELECT:
1675  widthChange -= myViewParent->getSelectorFrame()->getWidth() + addChange;
1677  mySelectEdges->show();
1678  myShowConnections->show();
1679  myExtendToEdgeNodes->show();
1680  break;
1681  case GNE_MODE_MOVE:
1682  myWarnAboutMerge->show();
1683  myShowJunctionAsBubble->show();
1684  break;
1685  case GNE_MODE_CONNECT:
1686  widthChange -= myViewParent->getConnectorFrame()->getWidth() + addChange;
1688  break;
1689  case GNE_MODE_TLS:
1690  widthChange -= myViewParent->getTLSEditorFrame()->getWidth() + addChange;
1692  myChangeAllPhases->show();
1693  break;
1694  case GNE_MODE_ADDITIONAL:
1695  widthChange -= myViewParent->getAdditionalFrame()->getWidth() + addChange;
1697  break;
1698  default:
1699  break;
1700  }
1701  myChanger->changeCanvassLeft(widthChange);
1702  myToolbar->recalc();
1703  recalc();
1704  onPaint(0, 0, 0); // force repaint because different modes draw different things
1705  update();
1706 }
1707 
1708 
1709 void
1711  myUndoList->p_begin("delete selected junctions");
1712  std::vector<GNEJunction*> junctions = myNet->retrieveJunctions(true);
1713  for (std::vector<GNEJunction*>::iterator it = junctions.begin(); it != junctions.end(); it++) {
1715  }
1716  myUndoList->p_end();
1717 }
1718 
1719 
1720 void
1722  if (mySelectEdges->getCheck()) {
1723  myUndoList->p_begin("delete selected edges");
1724  std::vector<GNEEdge*> edges = myNet->retrieveEdges(true);
1725  for (std::vector<GNEEdge*>::iterator it = edges.begin(); it != edges.end(); it++) {
1726  myNet->deleteEdge(*it, myUndoList);
1727  }
1728  } else {
1729  myUndoList->p_begin("delete selected lanes");
1730  std::vector<GNELane*> lanes = myNet->retrieveLanes(true);
1731  for (std::vector<GNELane*>::iterator it = lanes.begin(); it != lanes.end(); it++) {
1732  myNet->deleteLane(*it, myUndoList);
1733  }
1734  }
1735  myUndoList->p_end();
1736 }
1737 
1738 
1739 bool
1741  const Position& newPos = moved->getNBNode()->getPosition();
1742  GNEJunction* mergeTarget = 0;
1743  // try to find another junction to merge with
1744  if (makeCurrent()) {
1745  Boundary selection;
1746  selection.add(newPos);
1747  selection.grow(0.1);
1748  const std::vector<GUIGlID> ids = getObjectsInBoundary(selection);
1749  GUIGlObject* object = 0;
1750  for (std::vector<GUIGlID>::const_iterator it = ids.begin(); it != ids.end(); it++) {
1751  GUIGlID id = *it;
1752  if (id == 0) {
1753  continue;
1754  }
1756  if (!object) {
1757  throw ProcessError("Unkown object in selection (id=" + toString(id) + ").");
1758  }
1759  if (object->getType() == GLO_JUNCTION && id != moved->getGlID()) {
1760  mergeTarget = dynamic_cast<GNEJunction*>(object);
1761  }
1763  }
1764  }
1765  if (mergeTarget) {
1766  // optionally ask for confirmation
1767  if (myWarnAboutMerge->getCheck()) {
1768  FXuint answer = FXMessageBox::question(this, MBOX_YES_NO,
1769  "Confirm Junction Merger", "%s",
1770  ("Do you wish to merge junctions '" + moved->getMicrosimID() +
1771  "' and '" + mergeTarget->getMicrosimID() + "'?\n" +
1772  "('" + moved->getMicrosimID() +
1773  "' will be eliminated and its roads added to '" +
1774  mergeTarget->getMicrosimID() + "')").c_str());
1775  if (answer != 1) { //1:yes, 2:no, 4:esc
1776  return false;
1777  }
1778  }
1779  myNet->mergeJunctions(moved, mergeTarget, myUndoList);
1780  return true;
1781  } else {
1782  return false;
1783  }
1784 }
1785 
1786 
1787 void
1789  switch (myEditMode) {
1790  case GNE_MODE_INSPECT:
1791  myViewParent->getInspectorFrame()->update();
1792  break;
1793  default:
1794  break;
1795  }
1796 }
1797 /****************************************************************************/
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:496
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:272
virtual void openAdditionalDialog()
open Additional Dialog
void paintGLGrid()
paints a grid
std::vector< GNEJunction * > retrieveJunctions(bool onlySelected=false)
return all junctions
Definition: GNENet.cpp:764
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
ShapeContainer & getShapeContainer()
get shape container
Definition: GNENet.cpp:1169
Position moveGeometry(const Position &oldPos, const Position &newPos, bool relative=false)
draw the polygon and also little movement handles
Definition: GNEPoly.cpp:126
FXDEFMAP(GNEViewNet) GNEViewNetMap[]
std::vector< GNELane * > retrieveLanes(bool onlySelected=false)
return all lanes
Definition: GNENet.cpp:729
FXMenuCheck * mySelectEdges
menu check to select only edges
Definition: GNEViewNet.h:284
const std::set< GUIGlID > & getSelected() const
Returns the list of ids of all selected objects.
bool selectEdges()
whether inspection, selection and inversion should apply to edges or to lanes
Definition: GNEViewNet.cpp:322
GNEJunction * getJunctionAtCursorPosition(Position &pos)
try to retrieve a junction at the given position
Definition: GNEViewNet.cpp:936
GNEInspectorFrame * getInspectorFrame() const
get frame for GNE_MODE_INSPECT
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
Position myPopupSpot
Poput spot.
Definition: GNEViewNet.h:370
GUICompleteSchemeStorage gSchemeStorage
GNEEdge * retrieveEdge(const std::string &id, bool failHard=true)
get edge by id
Definition: GNENet.cpp:702
bool isAdditionalBlocked() const
Check if additional item is currently blocked (i.e. cannot be moved with mouse)
void abortOperation(bool clearSelection=true)
abort current edition operation
Definition: GNEViewNet.cpp:807
void deleteSelectedJunctions()
delete all currently selected junctions
GNEEdge * getEdgeTemplate() const
get the template edge (to copy attributes from)
const SUMOReal SUMO_const_laneWidth
Definition: StdDefs.h:49
bool setColorScheme(const std::string &name)
set color schieme
Definition: GNEViewNet.cpp:300
is a pedestrian
a polygon
mode for moving things
Definition: GNEViewNet.h:52
bool restrictLane(SUMOVehicleClass vclass)
restrict lane
void markPopupPosition()
store the position where a popup-menu was requested
Definition: GNEViewNet.cpp:900
long onCmdDuplicateLane(FXObject *, FXSelector, void *)
duplicate selected lane
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types...
void show()
show Frame
StringBijection< EditMode > myEditModeNames
since we cannot switch on strings we map the mode names to an enum
Definition: GNEViewNet.h:362
long onMouseMove(FXObject *, FXSelector, void *)
called when user moves mouse
Definition: GNEViewNet.cpp:774
void markAsCreateEdgeSource()
marks as first junction in createEdge-mode
The main window of the Netedit.
SUMORTree * myGrid
The visualization speed-up.
virtual void changeCanvassLeft(int change)=0
void setAllowsNegativeValues(bool value)
Locate TLS - button.
Definition: GUIAppEnum.h:179
bool revertLaneRestriction(GNELane *lane, GNEUndoList *undoList)
revert prevously restricted lane
Definition: GNENet.cpp:441
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:304
FXMenuCheck * myShowConnections
menu check to show connections
Definition: GNEViewNet.h:287
mode for deleting things
Definition: GNEViewNet.h:54
Definition: GNEPOI.h:51
void show()
show Frame
long onCmdSplitEdge(FXObject *, FXSelector, void *)
split edge at cursor position
a connection
const std::string & getString(const T key) const
vehicle is a bicycle
void show()
show Frame
GNEViewParent * getViewParent() const
get the net object
Definition: GNEViewNet.cpp:906
GUIMainWindow * myApp
The application.
FXMenuCheck * myChangeAllPhases
menu check to set change all phases
Definition: GNEViewNet.h:296
vehicle is a small delivery vehicle
void setEditMode(EditMode mode)
set edit mode
void hide()
hide Frame
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:911
Position mySelCorner2
second corner of the rectangle-selection
Definition: GNEViewNet.h:350
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
mode for editing tls
Definition: GNEViewNet.h:62
SUMOReal ymin() const
Returns minimum y-coordinate.
Definition: Boundary.cpp:142
void reverseEdge(GNEEdge *edge, GNEUndoList *undoList)
reverse edge
Definition: GNENet.cpp:560
void setSelectionScaling(SUMOReal selectionScale)
set selection scaling
Definition: GNEViewNet.cpp:346
GNEJunction * getEditedJunction() const
retrieve the junction of which the shape is being edited
Definition: GNEPoly.h:153
void updateJunctionShapes()
update junction shapes
Definition: GNENet.cpp:952
void setLineWidth(SUMOReal lineWidth)
set a new shape and update the tesselation
Definition: GUIPolygon.h:116
long onCmdNodeShape(FXObject *, FXSelector, void *)
input custom node shape
static const RGBColor ORANGE
Definition: RGBColor.h:195
virtual long onLeftBtnPress(FXObject *, FXSelector, void *)
void deleteConnection(GNEConnection *connection, GNEUndoList *undoList)
remove connectino
Definition: GNENet.cpp:384
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:87
FXComboBox * myEditModesCombo
combo box for selecting the edit mode
Definition: GNEViewNet.h:359
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition: GNELane.h:55
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)
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:86
void inspect(GNEAttributeCarrier *AC, GNEAttributeCarrier *previousElement=NULL)
Inspect a single element.
void setEditModeFromHotkey(FXushort selid)
sets edit mode (from hotkey)
Definition: GNEViewNet.cpp:865
bool addAdditional(GNENetElement *netElement, GUISUMOAbstractView *parent)
add additional element
long onCmdSetEdgeEndpoint(FXObject *, FXSelector, void *)
set non-default geometry endpoint
SUMOReal ymax() const
Returns maximum y-coordinate.
Definition: Boundary.cpp:148
static const RGBColor BLACK
Definition: RGBColor.h:197
const std::string & getID() const
Returns the id.
Definition: Named.h:66
const SVCPermissions SVCAll
GUIDialog_ViewSettings * myVisualizationChanger
Visualization changer.
void deleteEdge(GNEEdge *edge, GNEUndoList *undoList)
removes edge
Definition: GNENet.cpp:331
void updateControls()
update control contents after undo/redo or recompute
EditMode myPreviousEditMode
the previous edit mode used for toggling
Definition: GNEViewNet.h:281
void registerMove(GNEUndoList *undoList)
registers completed movement with the undoList
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:314
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:48
SUMOReal xmin() const
Returns minimum x-coordinate.
Definition: Boundary.cpp:130
long onCmdChangeMode(FXObject *, FXSelector, void *)
sets edit mode via combo box
Definition: GNEViewNet.cpp:858
virtual std::string getAttribute(SumoXMLAttr key) const =0
bool myShowConnectionActivated
whether show connections has been activated once
Definition: GNEViewNet.h:290
std::vector< std::string > getStrings() const
A single child window which contains a view of the simulation area.
Definition: GNEViewParent.h:69
GNETLSEditorFrame * getTLSEditorFrame() const
get frame for GNE_MODE_TLS
SUMOReal scale
information about a lane&#39;s width (temporary, used for a single view)
SUMOReal nearest_offset_to_point2D(const Position &p, bool perpendicular=true) const
return the nearest offest to point 2D
std::map< const GUIGlObject *, int > myAdditionallyDrawn
List of objects for which GUIGlObject::drawGLAdditional is called.
bool changeAllPhases() const
change all phases
Definition: GNEViewNet.cpp:352
bool restrictLane(SUMOVehicleClass vclass, GNELane *lane, GNEUndoList *undoList)
transform lane to restricted lane
Definition: GNENet.cpp:414
bool myMoveSelection
whether a selection is being moved
Definition: GNEViewNet.h:332
void hide()
hidde additional frame
GNEAdditionalFrame * getAdditionalFrame() const
get frame for GNE_MODE_ADDITIONAL
void hide()
hide Frame
int size() const
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...
std::vector< GUIGlID > getObjectsAtPosition(Position pos, SUMOReal radius)
returns the ids of the object at position within the given (rectangular) radius using GL_SELECT ...
void insert(const std::string str, const T key, bool checkDuplicates=true)
std::string getAttribute(SumoXMLAttr key) const
Definition: GNEEdge.cpp:503
Position myOldAdditionalPosition
variable for saving additional position before moving
Definition: GNEViewNet.h:326
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
Definition: GNEViewNet.cpp:918
long onLeftBtnPress(FXObject *, FXSelector, void *)
overloaded handlers
Definition: GNEViewNet.cpp:419
long onCmdSimplifyShape(FXObject *, FXSelector, void *)
simply shape of current polygon
int addColor(const T &color, const SUMOReal threshold, const std::string &name="")
static const RGBColor GREEN
Definition: RGBColor.h:190
static const RGBColor GREY
Definition: RGBColor.h:198
bool showLockIcon() const
check if lock icon should be visible
Definition: GNEViewNet.cpp:930
virtual long onPaint(FXObject *, FXSelector, void *)
GNEPoly * myCurrentPoly
current polygon
Definition: GNEViewNet.h:373
FXMenuCheck * myShowJunctionAsBubble
show connection as buuble in "Move" mode.
Definition: GNEViewNet.h:338
SUMOReal selectionScale
the current selection scaling in NETEDIT (temporary)
long onCmdRemoveRestrictedLaneBuslane(FXObject *, FXSelector typeOfTransformation, void *)
remove restricted lane for bus
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
bool hasCommandGroup() const
Check if undoList has command group.
bool removeRestrictedLane(SUMOVehicleClass vclass, GNEEdge &edge, GNEUndoList *undoList)
remove restricted lane
Definition: GNENet.cpp:474
FXMenuCheck * myWarnAboutMerge
whether we should warn about merging junctions
Definition: GNEViewNet.h:335
mode for inspecting object attributes
Definition: GNEViewNet.h:56
void setCurrentScheme(const std::string &)
Sets the named scheme as the current.
static bool hasAttribute(SumoXMLTag tag, SumoXMLAttr attr)
check if a 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:320
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
Definition: GLHelper.cpp:443
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:1061
virtual ~GNEViewNet()
destructor
Definition: GNEViewNet.cpp:258
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:46
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:93
virtual bool removePOI(const std::string &id)
Removes a PoI from the container.
A list of positions.
Locate edge - button.
Definition: GUIAppEnum.h:173
FXToolBar * myToolbar
Definition: GNEViewNet.h:356
void deleteLane(GNELane *lane, GNEUndoList *undoList)
removes lane
Definition: GNENet.cpp:356
void deleteGeometryOrEdge(GNEEdge *edge, const Position &pos, GNEUndoList *undoList)
removes geometry when pos is close to a geometry node, deletes the whole edge otherwise ...
Definition: GNENet.cpp:488
long onCmdToogleShowConnection(FXObject *, FXSelector, void *)
toogle show connections
T get(const std::string &str) const
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:358
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:340
static const RGBColor MAGENTA
Definition: RGBColor.h:194
SUMOReal x() const
Returns the x-position.
Definition: Position.h:63
void initGNEConnections()
initialize GNEConnections
Definition: GNENet.cpp:1396
long onCmdRemoveRestrictedLaneBikelane(FXObject *, FXSelector typeOfTransformation, void *)
remove restricted lane for bikes
mode for selecting objects
Definition: GNEViewNet.h:58
void removeCurrentPoly()
remove the currently edited polygon
GNEJunction * myJunctionToMove
the Junction to be moved.
Definition: GNEViewNet.h:311
GNELane * getLaneAtCurserPosition(Position &pos)
try to retrieve a lane at the given position
Definition: GNEViewNet.cpp:983
Locate junction - button.
Definition: GUIAppEnum.h:171
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:796
virtual const std::string & getMicrosimID() const
Returns the id of the object as known to microsim.
void unMarkAsCreateEdgeSource()
removes mark as first junction in createEdge-mode
void moveSelection(const Position &moveSrc, const Position &moveDest)
move all selected junctions and edges
Definition: GNENet.cpp:1115
GNEJunction * createJunction(const Position &pos, GNEUndoList *undoList)
creates a new junction
Definition: GNENet.cpp:240
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:549
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
Definition: ToString.h:55
Position mySelCorner1
firstcorner of the rectangle-selection
Definition: GNEViewNet.h:347
Position myAdditionalMovingReference
variable for calculating moving offset of additionals
Definition: GNEViewNet.h:323
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
EditMode
Definition: GNEViewNet.h:46
SUMORTree & getVisualisationSpeedUp()
Returns the RTree used for visualisation speed-up.
Definition: GNENet.cpp:228
vehicle is a passenger car (a "normal" car)
void doInit()
called after some features are already initialized
Definition: GNEViewNet.cpp:262
is an arbitrary ship
FXMenuCheck * myAutoCreateOppositeEdge
Definition: GNEViewNet.h:305
EditMode getCurrentEditMode() const
get the current edit mode
Definition: GNEViewNet.cpp:924
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:1722
vehicle is a moped
void replaceJunctionByGeometry(GNEJunction *junction, GNEUndoList *undoList)
Definition: GNENet.cpp:1042
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:55
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 *)
vehicle is a bus
void hide()
hide Frame
static const RGBColor YELLOW
Definition: RGBColor.h:192
Boundary & grow(SUMOReal by)
extends the boundary by the given amount
Definition: Boundary.cpp:232
static const RGBColor RED
Definition: RGBColor.h:189
const PositionVector & getShape() const
returns the shape of the lane
Definition: GNELane.cpp:583
FXMenuCheck * myExtendToEdgeNodes
menu check to extend to edge nodes
Definition: GNEViewNet.h:293
void moveAdditionalGeometry(const Position &offset)
change the position of the additional geometry
static const RGBColor CYAN
Definition: RGBColor.h:193
GUIVisualizationSettings * myVisualizationSettings
visualization settings
SUMOReal xmax() const
Returns maximum x-coordinate.
Definition: Boundary.cpp:136
void show()
show additional frame
std::vector< GNEEdge * > retrieveEdges(bool onlySelected=false)
return all edges
Definition: GNENet.cpp:717
Position myMoveSrc
position from which to move edge geometry
Definition: GNEViewNet.h:329
void add(SUMOReal x, SUMOReal y, SUMOReal z=0)
Makes the boundary include the given coordinate.
Definition: Boundary.cpp:90
long onCmdAddRestrictedLaneBikelane(FXObject *, FXSelector typeOfTransformation, void *)
Add restricted lane for bikes.
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:63
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.
bool showConnections()
show connections over junctions
Definition: GNEViewNet.cpp:328
long onCmdOK(FXObject *, FXSelector, void *)
long onCmdReverseEdge(FXObject *, FXSelector, void *)
reverse edge
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:364
GNEJunction * myCreateEdgeSource
source junction for new edge 0 if no edge source is selected an existing (or newly created) junction ...
Definition: GNEViewNet.h:301
void move(Position pos)
reposition the node at pos and informs the edges
void set(SUMOReal x, SUMOReal y)
Definition: Position.h:78
an edge
SUMOReal m2p(SUMOReal meter) const
meter-to-pixels conversion method
long onCmdAddRestrictedLaneBuslane(FXObject *, FXSelector typeOfTransformation, void *)
Add restricted lane for buses.
long onCmdRemoveRestrictedLaneSidewalk(FXObject *, FXSelector typeOfTransformation, void *)
remove restricted lane for pedestrians
void simplifyShape()
replace the current shape with a rectangle
Definition: GNEPoly.cpp:140
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.
void handleIDs(std::vector< GUIGlID > ids, bool selectEdges, SetOperation setop=SET_DEFAULT)
apply list of ids to the current selection according to SetOperation,
bool showGrid
Information whether a grid shall be shown.
void drawDecals()
Draws the stored decals.
void show()
show Frame
GNENet * getNet() const
get the net object
Definition: GNEViewNet.cpp:912
long onCmdRestrictLaneSidewalk(FXObject *, FXSelector typeOfTransformation, void *)
restrict lane to pedestrians
const Position & getPosition() const
Returns the position of this node.
Definition: NBNode.h:228
void updateModeSpecificControls()
updates mode specific controls
GUIGlID getGlID() const
Returns the numerical id of the object.
GNEEdge * addReversedEdge(GNEEdge *edge, GNEUndoList *undoList)
add reversed edge
Definition: GNENet.cpp:571
void setStatusBarText(const std::string &text)
set staturBar text
Definition: GNEViewNet.cpp:316
#define SUMOReal
Definition: config.h:213
Mode for editing additionals.
Definition: GNEViewNet.h:64
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:266
void setEndpoint(Position pos, GNEUndoList *undoList)
makes pos the new geometry endpoint at the appropriate end
Definition: GNEEdge.cpp:364
GUIPropertyScheme< RGBColor > GUIColorScheme
static const RGBColor selectionColor
color of selection
Definition: GNENet.h:96
empty max
void unblockObject(GUIGlID id)
Marks an object as unblocked.
long onCmdStraightenEdges(FXObject *, FXSelector, void *)
makes selected edges straight
mode for connecting lanes
Definition: GNEViewNet.h:60
void hide()
hide Frame
mode for creating new edges
Definition: GNEViewNet.h:50
NBEdge * getNBEdge()
returns the internal NBEdge
Definition: GNEEdge.cpp:261
long onDoubleClicked(FXObject *, FXSelector, void *)
called when user press mouse&#39;s left button two times
Definition: GNEViewNet.cpp:751
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:604
GNEEdge * getEdgeAtCursorPosition(Position &pos)
try to retrieve an edge at the given position
Definition: GNEViewNet.cpp:959
long onCmdNodeReplace(FXObject *, FXSelector, void *)
replace node by geometry
void hotkeyDel()
handle del keypress
Definition: GNEViewNet.cpp:829
long onCmdAddReversedEdge(FXObject *, FXSelector, void *)
add reversed edge
GUIGlObject * getObjectBlocking(GUIGlID id)
Returns the object from the container locking it.
SUMOReal y() const
Returns the y-position.
Definition: Position.h:68
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:344
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
Definition: GNEEdge.cpp:569
bool addSRestrictedLane(SUMOVehicleClass vclass, GNEEdge &edge, GNEUndoList *undoList)
add restricted lane to edge
Definition: GNENet.cpp:459
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:275
void hotkeyEnter()
handle enter keypress
Definition: GNEViewNet.cpp:842
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:705
Position getSplitPos(const Position &clickPos)
Definition: GNEEdge.cpp:267
void requireRecompute()
inform the net about the need for recomputation
Definition: GNENet.cpp:963
void computeNodeShape(SUMOReal mismatchThreshold)
Compute the junction shape for this node.
Definition: NBNode.cpp:790
void duplicateLane(GNELane *lane, GNEUndoList *undoList)
duplicates lane
Definition: GNENet.cpp:402
void deleteSelectedEdges()
delete all currently selected edges
GNEUndoList * myUndoList
a reference to the undolist maintained in the application
Definition: GNEViewNet.h:367
EditMode myEditMode
the current edit mode
Definition: GNEViewNet.h:278
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()
a junction
void deleteGeometryNear(const Position &pos)
delete the geometry point closest to the given pos
Definition: GNEPoly.cpp:152
GNEPoly * myPolyToMove
the poly of which geometry is being moved
Definition: GNEViewNet.h:317
void finishMoveSelection(GNEUndoList *undoList)
register changes to junction and edge positions with the undoList
Definition: GNENet.cpp:1145
SumoXMLTag getTag() const
get Tag assigned to this object
virtual Position getPositionInView() const =0
Returns position of additional in view.