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>
49 #include <utils/gui/div/GLHelper.h>
51 
52 #include "GNEViewNet.h"
53 #include "GNEEdge.h"
54 #include "GNELane.h"
55 #include "GNEJunction.h"
56 #include "GNEPOI.h"
57 #include "GNEApplicationWindow.h"
58 #include "GNEViewParent.h"
59 #include "GNENet.h"
60 #include "GNEUndoList.h"
61 #include "GNEInspector.h"
62 #include "GNESelector.h"
63 #include "GNEConnector.h"
64 #include "GNETLSEditor.h"
65 #include "GNEPoly.h"
66 #include "GNECrossing.h"
67 
68 #ifdef CHECK_MEMORY_LEAKS
69 #include <foreign/nvwa/debug_new.h>
70 #endif // CHECK_MEMORY_LEAKS
71 
72 // ===========================================================================
73 // FOX callback mapping
74 // ===========================================================================
75 FXDEFMAP(GNEViewNet) GNEViewNetMap[] = {
76  FXMAPFUNC(SEL_COMMAND, MID_GNE_MODE_CHANGE, GNEViewNet::onCmdChangeMode),
77  FXMAPFUNC(SEL_COMMAND, MID_GNE_SPLIT_EDGE, GNEViewNet::onCmdSplitEdge),
79  FXMAPFUNC(SEL_COMMAND, MID_GNE_REVERSE_EDGE, GNEViewNet::onCmdReverseEdge),
87  FXMAPFUNC(SEL_COMMAND, MID_GNE_NODE_SHAPE, GNEViewNet::onCmdNodeShape),
88  FXMAPFUNC(SEL_COMMAND, MID_GNE_NODE_REPLACE, GNEViewNet::onCmdNodeReplace)
89 };
90 
91 // Object implementation
92 FXIMPLEMENT(GNEViewNet, GUISUMOAbstractView, GNEViewNetMap, ARRAYNUMBER(GNEViewNetMap))
93 
94 // ===========================================================================
95 // static member definitions
96 // ===========================================================================
97 
98 // ===========================================================================
99 // member method definitions
100 // ===========================================================================
102  FXComposite* tmpParent,
103  FXComposite* actualParent,
104  GUIMainWindow& app,
105  GNEViewParent* viewParent,
106  GNENet* net, FXGLVisual* glVis,
107  FXGLCanvas* share,
108  FXToolBar* toolBar) :
109  GUISUMOAbstractView(tmpParent, app, viewParent, net->getVisualisationSpeedUp(), glVis, share),
110  myNet(net),
111  myEditMode(GNE_MODE_MOVE),
112  myPreviousEditMode(GNE_MODE_MOVE),
113  myCreateEdgeSource(0),
114  myJunctionToMove(0),
115  myEdgeToMove(0),
116  myPolyToMove(0),
117  myMoveSelection(false),
118  myAmInRectSelect(false),
119  myToolbar(toolBar),
120  myEditModesCombo(0),
121  myEditModeNames(),
122  myUndoList(((GNEApplicationWindow*)myApp)->getUndoList()),
123  myInspector(0),
124  mySelector(0),
125  myCurrentPoly(0) {
126  // adding order is important
127  myInspector = new GNEInspector(actualParent, myUndoList);
128  myInspector->hide();
129  mySelector = new GNESelector(actualParent, this, myUndoList);
130  mySelector->hide();
131  myConnector = new GNEConnector(actualParent, this, myUndoList);
132  myConnector->hide();
133  myTLSEditor = new GNETLSEditor(actualParent, this, myUndoList);
134  myTLSEditor->hide();
135  // view must be the final member of actualParent
136  reparent(actualParent);
137 
138  buildEditModeControls();
139  myUndoList->mark();
140  myNet->setUpdateTarget(this);
141  ((GUIDanielPerspectiveChanger*)myChanger)->setDragDelay(100000000); // 100 milliseconds
142 
143  // init color schemes
144  GUIColorer laneColorer;
145  GUIColorScheme scheme = GUIColorScheme("uniform", RGBColor::BLACK, "road", true);
146  scheme.addColor(RGBColor::GREY, 1, "sidewalk");
147  scheme.addColor(RGBColor(192, 66, 44), 2, "bike lane");
148  scheme.addColor(RGBColor(200, 255, 200), 3, "green verge");
149  scheme.addColor(RGBColor(150, 200, 200), 4, "waterway");
150  scheme.addColor(RGBColor(92, 92, 92), 5, "no passenger"); // paths, service roads etc
151  laneColorer.addScheme(scheme);
152  scheme = GUIColorScheme("by selection (lane-/streetwise)", RGBColor(128, 128, 128, 255), "unselected", true);
153  scheme.addColor(RGBColor(0, 80, 180, 255), 1, "selected");
154  laneColorer.addScheme(scheme);
155  scheme = GUIColorScheme("by permission code", RGBColor(240, 240, 240), "nobody");
156  scheme.addColor(RGBColor(10, 10, 10), (SUMOReal)SVC_PASSENGER, "passenger");
157  scheme.addColor(RGBColor(128, 128, 128), (SUMOReal)SVC_PEDESTRIAN, "pedestrian");
158  scheme.addColor(RGBColor(80, 80, 80), (SUMOReal)(SVC_PEDESTRIAN | SVC_DELIVERY), "pedestrian_delivery");
159  scheme.addColor(RGBColor(192, 66, 44), (SUMOReal)SVC_BICYCLE, "bicycle");
160  scheme.addColor(RGBColor(40, 100, 40), (SUMOReal)SVC_BUS, "bus");
161  scheme.addColor(RGBColor(166, 147, 26), (SUMOReal)SVC_TAXI, "taxi");
162  scheme.addColor(RGBColor::BLACK, (SUMOReal)(SVCAll & ~SVC_NON_ROAD), "normal_road");
163  scheme.addColor(RGBColor::BLACK, (SUMOReal)(SVCAll & ~(SVC_PEDESTRIAN | SVC_NON_ROAD)), "disallow_pedestrian");
164  scheme.addColor(RGBColor(255, 206, 0), (SUMOReal)(SVCAll & ~(SVC_PEDESTRIAN | SVC_BICYCLE | SVC_MOPED | SVC_NON_ROAD)), "motorway");
165  scheme.addColor(RGBColor(150, 200, 200), (SUMOReal)SVC_SHIP, "waterway");
166  scheme.addColor(RGBColor::GREEN, (SUMOReal)SVCAll, "all");
167  laneColorer.addScheme(scheme);
168 
169  scheme = GUIColorScheme("by allowed speed (lanewise)", RGBColor::RED);
170  scheme.addColor(RGBColor::YELLOW, (SUMOReal)(30 / 3.6));
171  scheme.addColor(RGBColor::GREEN, (SUMOReal)(55 / 3.6));
172  scheme.addColor(RGBColor::CYAN, (SUMOReal)(80 / 3.6));
173  scheme.addColor(RGBColor::BLUE, (SUMOReal)(120 / 3.6));
174  scheme.addColor(RGBColor::MAGENTA, (SUMOReal)(150 / 3.6));
175  laneColorer.addScheme(scheme);
176 
177  scheme = GUIColorScheme("by lane number (streetwise)", RGBColor::RED);
178  scheme.addColor(RGBColor::BLUE, (SUMOReal)5);
179  laneColorer.addScheme(scheme);
180 
181  scheme = GUIColorScheme("by given length/geometrical length", RGBColor::BLACK);
182  scheme.addColor(RGBColor::RED, (SUMOReal)0.25);
183  scheme.addColor(RGBColor::YELLOW, (SUMOReal)0.5);
184  scheme.addColor(RGBColor(179, 179, 179, 255), (SUMOReal)1.0);
185  scheme.addColor(RGBColor::GREEN, (SUMOReal)2.0);
186  scheme.addColor(RGBColor::BLUE, (SUMOReal)4.0);
187  laneColorer.addScheme(scheme);
188  laneColorer.addScheme(GUIColorScheme("by angle", RGBColor::YELLOW, "", true));
189 
190  scheme = GUIColorScheme("by priority", RGBColor::YELLOW);
191  scheme.addColor(RGBColor::RED, (SUMOReal) - 20);
192  scheme.addColor(RGBColor::GREEN, (SUMOReal)20);
193  scheme.setAllowsNegativeValues(true);
194  laneColorer.addScheme(scheme);
195  scheme = GUIColorScheme("by height at start", RGBColor::RED);
196  scheme.addColor(RGBColor::BLUE, (SUMOReal) - 10);
197  scheme.addColor(RGBColor::YELLOW, (SUMOReal)50);
198  scheme.addColor(RGBColor::GREEN, (SUMOReal)100);
199  scheme.addColor(RGBColor::MAGENTA, (SUMOReal)200);
200  scheme.setAllowsNegativeValues(true);
201  laneColorer.addScheme(scheme);
202  scheme = GUIColorScheme("by height at segment start", RGBColor::RED);
203  scheme.addColor(RGBColor::BLUE, (SUMOReal) - 10);
204  scheme.addColor(RGBColor::YELLOW, (SUMOReal)50);
205  scheme.addColor(RGBColor::GREEN, (SUMOReal)100);
206  scheme.addColor(RGBColor::MAGENTA, (SUMOReal)200);
207  scheme.setAllowsNegativeValues(true);
208  laneColorer.addScheme(scheme);
209  scheme = GUIColorScheme("by inclination", RGBColor::GREY);
210  scheme.addColor(RGBColor::YELLOW, (SUMOReal) .1);
211  scheme.addColor(RGBColor::RED, (SUMOReal) .3);
212  scheme.addColor(RGBColor::GREEN, (SUMOReal) - .1);
213  scheme.addColor(RGBColor::BLUE, (SUMOReal) - .3);
214  scheme.setAllowsNegativeValues(true);
215  laneColorer.addScheme(scheme);
216  scheme = GUIColorScheme("by segment inclination", RGBColor::GREY);
217  scheme.addColor(RGBColor::YELLOW, (SUMOReal) .1);
218  scheme.addColor(RGBColor::RED, (SUMOReal) .3);
219  scheme.addColor(RGBColor::GREEN, (SUMOReal) - .1);
220  scheme.addColor(RGBColor::BLUE, (SUMOReal) - .3);
221  scheme.setAllowsNegativeValues(true);
222  laneColorer.addScheme(scheme);
223 
224  myVisualizationSettings->laneColorer = laneColorer;
225 
226  GUIColorer junctionColorer;
227  scheme = GUIColorScheme("uniform", RGBColor(102, 0, 0), "", true);
228  scheme.addColor(RGBColor(204, 0, 0), 1, "shape not computed");
229  scheme.addColor(RGBColor(153, 0, 0), 2, "geometry points");
230  junctionColorer.addScheme(scheme);
231  scheme = GUIColorScheme("by selection", RGBColor(128, 128, 128, 255), "unselected", true);
232  scheme.addColor(RGBColor(0, 80, 180, 255), 1, "selected");
233  junctionColorer.addScheme(scheme);
234  scheme = GUIColorScheme("by type", RGBColor::GREEN, "traffic_light", true);
235  scheme.addColor(RGBColor(0, 128, 0), 1, "traffic_light_unregulated");
236  scheme.addColor(RGBColor::YELLOW, 2, "priority");
237  scheme.addColor(RGBColor::RED, 3, "priority_stop");
238  scheme.addColor(RGBColor::BLUE, 4, "right_before_left");
239  scheme.addColor(RGBColor::CYAN, 5, "allway_stop");
240  scheme.addColor(RGBColor::GREY, 6, "district");
241  scheme.addColor(RGBColor::MAGENTA, 7, "unregulated");
242  scheme.addColor(RGBColor::BLACK, 8, "dead_end");
243  scheme.addColor(RGBColor::ORANGE, 9, "rail_signal");
244  scheme.addColor(RGBColor(192, 128, 64), 10, "zipper");
245  scheme.addColor(RGBColor(192, 255, 192), 11, "traffic_light_right_on_red");
246  scheme.addColor(RGBColor(128, 0, 128), 12, "rail_crossing"); // dark purple
247  junctionColorer.addScheme(scheme);
248  myVisualizationSettings->junctionColorer = junctionColorer;
249 }
250 
251 
253 
254 
255 void
257 
258 
259 void
261  /*
262  // build coloring tools
263  {
264  const std::vector<std::string> &names = gSchemeStorage.getNames();
265  for (std::vector<std::string>::const_iterator i=names.begin(); i!=names.end(); ++i) {
266  v.getColoringSchemesCombo().appendItem((*i).c_str());
267  if ((*i) == myVisualizationSettings->name) {
268  v.getColoringSchemesCombo().setCurrentItem(v.getColoringSchemesCombo().getNumItems()-1);
269  }
270  }
271  v.getColoringSchemesCombo().setNumVisible(5);
272  }
273  */
274 
275  // locator button for junctions
276  new FXButton(cw.getLocatorPopup(),
277  "\tLocate Junction\tLocate a junction within the network.",
279  ICON_ABOVE_TEXT | FRAME_THICK | FRAME_RAISED);
280  // locator button for edges
281  new FXButton(cw.getLocatorPopup(),
282  "\tLocate Street\tLocate a street within the network.",
284  ICON_ABOVE_TEXT | FRAME_THICK | FRAME_RAISED);
285  // locator button for tls
286  new FXButton(cw.getLocatorPopup(),
287  "\tLocate TLS\tLocate a traffic light within the network.",
289  ICON_ABOVE_TEXT | FRAME_THICK | FRAME_RAISED);
290 }
291 
292 
293 bool
294 GNEViewNet::setColorScheme(const std::string& name) {
295  if (!gSchemeStorage.contains(name)) {
296  return false;
297  }
298  if (myVisualizationChanger != 0) {
299  if (myVisualizationChanger->getCurrentScheme() != name) {
301  }
302  }
303  myVisualizationSettings = &gSchemeStorage.get(name.c_str());
304  update();
305  return true;
306 }
307 
308 
309 void
310 GNEViewNet::setStatusBarText(const std::string& text) {
311  myApp->setStatusBarText(text);
312 }
313 
314 
315 int
316 GNEViewNet::doPaintGL(int mode, const Boundary& bound) {
317  // init view settings
318  glRenderMode(mode);
319  glMatrixMode(GL_MODELVIEW);
320  glPushMatrix();
321  glDisable(GL_TEXTURE_2D);
322  glDisable(GL_ALPHA_TEST);
323  glDisable(GL_BLEND);
324  glEnable(GL_DEPTH_TEST);
325 
326  // visualize rectangular selection
327  if (myAmInRectSelect) {
328  glPushMatrix();
329  glTranslated(0, 0, GLO_MAX - 1);
331  glLineWidth(2);
332  glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
333  glBegin(GL_QUADS);
334  glVertex2d(mySelCorner1.x(), mySelCorner1.y());
335  glVertex2d(mySelCorner1.x(), mySelCorner2.y());
336  glVertex2d(mySelCorner2.x(), mySelCorner2.y());
337  glVertex2d(mySelCorner2.x(), mySelCorner1.y());
338  glEnd();
339  glPopMatrix();
340  }
341 
342  // compute lane width
344  // draw decals (if not in grabbing mode)
345  if (!myUseToolTips) {
346  drawDecals();
348  paintGLGrid();
349  }
350  }
351  glLineWidth(1);
352  glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
353  float minB[2];
354  float maxB[2];
355  minB[0] = bound.xmin();
356  minB[1] = bound.ymin();
357  maxB[0] = bound.xmax();
358  maxB[1] = bound.ymax();
360  glEnable(GL_POLYGON_OFFSET_FILL);
361  glEnable(GL_POLYGON_OFFSET_LINE);
363  int hits2 = myGrid->Search(minB, maxB, *myVisualizationSettings);
364 
365  glTranslated(0, 0, GLO_ADDITIONAL);
366  for (std::map<GUIGlObject*, int>::iterator i = myAdditionallyDrawn.begin(); i != myAdditionallyDrawn.end(); ++i) {
367  (i->first)->drawGLAdditional(this, *myVisualizationSettings);
368  }
369  glPopMatrix();
370  return hits2;
371 }
372 
373 
374 long
375 GNEViewNet::onLeftBtnPress(FXObject* obj, FXSelector sel, void* data) {
376  FXEvent* e = (FXEvent*) data;
377  setFocus();
378  // interpret object under curser
379  if (makeCurrent()) {
380  unsigned int id = getObjectUnderCursor();
383  GNEJunction* pointed_junction = 0;
384  GNELane* pointed_lane = 0;
385  GNEEdge* pointed_edge = 0;
386  GNEPOI* pointed_poi = 0;
387  GNEPoly* pointed_poly = 0;
388  GNECrossing* pointed_crossing = 0;
389  if (pointed) {
390  switch (pointed->getType()) {
391  case GLO_JUNCTION:
392  pointed_junction = (GNEJunction*)pointed;
393  break;
394  case GLO_EDGE:
395  pointed_edge = (GNEEdge*)pointed;
396  break;
397  case GLO_LANE:
398  pointed_lane = (GNELane*)pointed;
399  pointed_edge = &(pointed_lane->getParentEdge());
400  break;
401  case GLO_POI:
402  pointed_poi = (GNEPOI*)pointed;
403  break;
404  case GLO_POLYGON:
405  pointed_poly = (GNEPoly*)pointed;
406  break;
407  case GLO_CROSSING:
408  pointed_crossing = (GNECrossing*)pointed;
409  break;
410  default:
411  pointed = 0;
412  break;
413  }
414  }
415 
416  // decide what to do based on mode
417  switch (myEditMode) {
419  if ((e->state & CONTROLMASK) == 0) {
420  // allow moving when control is held down
421  if (!myUndoList->hasCommandGroup()) {
422  myUndoList->p_begin("create new edge");
423  }
424  if (!pointed_junction) {
425  pointed_junction = myNet->createJunction(getPositionInformation(), myUndoList);
426  }
427  if (myCreateEdgeSource == 0) {
428  myCreateEdgeSource = pointed_junction;
430  update();
431  } else {
432  if (myCreateEdgeSource != pointed_junction) {
433  // may fail to prevent double edges
434  GNEEdge* newEdge = myNet->createEdge(
436  if (newEdge) {
437  if (myAutoCreateOppositeEdge->getCheck()) {
438  myNet->createEdge(
440  }
442  if (myUndoList->hasCommandGroup()) {
443  myUndoList->p_end();
444  } else {
445  std::cout << "edge created without an open CommandGroup )-:\n";
446  }
447  if (myChainCreateEdge->getCheck()) {
448  myCreateEdgeSource = pointed_junction;
450  myUndoList->p_begin("create new edge");
451  } else {
452  myCreateEdgeSource = 0;
453  }
454  } else {
455  setStatusBarText("An edge with the same geometry already exists!");
456  }
457  } else {
458  setStatusBarText("Start- and endpoint for an edge must be distinct!");
459  }
460  update();
461  }
462  }
463  GUISUMOAbstractView::onLeftBtnPress(obj, sel, data);
464  break;
465 
466  case GNE_MODE_MOVE:
467  if (pointed_poly) {
469  myPolyToMove = pointed_poly;
470  } else if (pointed_junction) {
471  if (gSelected.isSelected(GLO_JUNCTION, pointed_junction->getGlID())) {
472  myMoveSelection = true;
474  } else {
475  myJunctionToMove = pointed_junction;
476  }
477  } else if (pointed_edge) {
478  if (gSelected.isSelected(GLO_EDGE, pointed_edge->getGlID())) {
479  myMoveSelection = true;
480  } else {
481  myEdgeToMove = pointed_edge;
482  }
484  } else {
485  GUISUMOAbstractView::onLeftBtnPress(obj, sel, data);
486  }
487  update();
488  break;
489 
490  case GNE_MODE_DELETE:
491  if (pointed_junction) {
492  /*
493  if (gSelected.isSelected(GLO_JUNCTION, pointed_junction->getGlID())) {
494  deleteSelectedJunctions();
495  }
496  */
497  myNet->deleteJunction(pointed_junction, myUndoList);
498  } else if (pointed_lane && !mySelectEdges->getCheck()) {
499  myNet->deleteLane(pointed_lane, myUndoList);
500  } else if (pointed_edge) {
501  /*
502  if (gSelected.isSelected(GLO_EDGE, pointed_edge->getGlID())) {
503  deleteSelectedEdges();
504  }
505  */
507  } else if (pointed_poi) {
508  // XXX this is a dirty dirty hack! implemente GNEChange_POI
509  myNet->getShapeContainer().removePOI(pointed_poi->getMicrosimID());
510  update();
511  } else {
512  GUISUMOAbstractView::onLeftBtnPress(obj, sel, data);
513  }
514  break;
515 
516  case GNE_MODE_INSPECT: {
517  GNEAttributeCarrier* pointedAC = 0;
518  GUIGlObject* pointedO = 0;
519  if (pointed_junction) {
520  pointedAC = pointed_junction;
521  pointedO = pointed_junction;
522  } else if (pointed_lane) { // implies pointed_edge
523  if (selectEdges()) {
524  pointedAC = pointed_edge;
525  pointedO = pointed_edge;
526  } else {
527  pointedAC = pointed_lane;
528  pointedO = pointed_lane;
529  }
530  } else if (pointed_edge) {
531  pointedAC = pointed_edge;
532  pointedO = pointed_edge;
533  } else if (pointed_crossing) {
534  pointedAC = pointed_crossing;
535  pointedO = pointed_crossing;
536  }
537  std::vector<GNEAttributeCarrier*> selected;
538  if (pointedO && gSelected.isSelected(pointedO->getType(), pointedO->getGlID())) {
539  std::set<GUIGlID> selectedIDs = gSelected.getSelected(pointedO->getType());
540  selected = myNet->retrieveAttributeCarriers(selectedIDs, pointedO->getType());
541  } else if (pointedAC != 0) {
542  selected.push_back(pointedAC);
543  }
544  myInspector->inspect(selected);
545  GUISUMOAbstractView::onLeftBtnPress(obj, sel, data);
546  update();
547  break;
548  }
549 
550  case GNE_MODE_SELECT:
551  if (pointed_lane && selectEdges()) {
552  gSelected.toggleSelection(pointed_edge->getGlID());
553  } else if (pointed) {
554  gSelected.toggleSelection(pointed->getGlID());
555  }
556 
557  myAmInRectSelect = (((FXEvent*)data)->state & SHIFTMASK) != 0;
558  if (myAmInRectSelect) {
561  } else {
562  GUISUMOAbstractView::onLeftBtnPress(obj, sel, data);
563  }
564  update();
565  break;
566 
567  case GNE_MODE_CONNECT:
568  if (pointed_lane) {
569  const bool mayPass = (((FXEvent*)data)->state & SHIFTMASK) != 0;
570  const bool allowConflict = (((FXEvent*)data)->state & CONTROLMASK) != 0;
571  myConnector->handleLaneClick(pointed_lane, mayPass, allowConflict, true);
572  update();
573  }
574  GUISUMOAbstractView::onLeftBtnPress(obj, sel, data);
575  break;
576 
577  case GNE_MODE_TLS:
578  if (pointed_junction) {
579  myTLSEditor->editJunction(pointed_junction);
580  update();
581  }
582  GUISUMOAbstractView::onLeftBtnPress(obj, sel, data);
583  break;
584 
585  default:
586  GUISUMOAbstractView::onLeftBtnPress(obj, sel, data);
587  }
588  makeNonCurrent();
589  }
590  return 1;
591 }
592 
593 
594 long
595 GNEViewNet::onLeftBtnRelease(FXObject* obj, FXSelector sel, void* data) {
597  if (myPolyToMove) {
598  myPolyToMove = 0;
599  } else if (myJunctionToMove) {
600  // position is already up to date but we must register with myUndoList
603  }
604  myJunctionToMove = 0;
605  } else if (myEdgeToMove) {
606  // shape is already up to date but we must register with myUndoList
607  const std::string& newShape = myEdgeToMove->getAttribute(SUMO_ATTR_SHAPE);
609  myEdgeToMove = 0;
610  } else if (myMoveSelection) {
611  // positions and shapes are already up to date but we must register with myUndoList
613  myMoveSelection = false;
614  } else if (myAmInRectSelect) {
615  myAmInRectSelect = false;
616  // shift held down on mouse-down and mouse-up
617  if (((FXEvent*)data)->state & SHIFTMASK) {
618  if (makeCurrent()) {
619  Boundary b;
620  b.add(mySelCorner1);
621  b.add(mySelCorner2);
623  makeNonCurrent();
624  }
625  }
626  update();
627  }
628  return 1;
629 }
630 
631 long
632 GNEViewNet::onMouseMove(FXObject* obj, FXSelector sel, void* data) {
633  GUISUMOAbstractView::onMouseMove(obj, sel, data);
634  if (myPolyToMove) {
636  } else if (myJunctionToMove) {
638  } else if (myEdgeToMove) {
640  } else if (myMoveSelection) {
641  Position moveTarget = getPositionInformation();
642  myNet->moveSelection(myMoveSrc, moveTarget);
643  myMoveSrc = moveTarget;
644  } else if (myAmInRectSelect) {
646  update();
647  }
648  return 1;
649 }
650 
651 
652 void
653 GNEViewNet::abortOperation(bool clearSelection) {
654  setFocus(); // steal focus from any text fields
655  if (myCreateEdgeSource) {
657  myCreateEdgeSource = 0;
658  } else if (myEditMode == GNE_MODE_SELECT) {
659  myAmInRectSelect = false;
660  if (clearSelection) {
661  gSelected.clear();
662  }
663  } else if (myEditMode == GNE_MODE_CONNECT) {
664  myConnector->onCmdCancel(0, 0, 0);
665  } else if (myEditMode == GNE_MODE_TLS) {
666  myTLSEditor->onCmdCancel(0, 0, 0);
667  } else if (myEditMode == GNE_MODE_MOVE) {
669  }
670  myUndoList->p_abort();
671 }
672 
673 
674 void
677  setStatusBarText("Cannot delete in this mode");
678  } else {
679  myUndoList->p_begin("delete selection");
682  myUndoList->p_end();
683  }
684 }
685 
686 
687 void
689  if (myEditMode == GNE_MODE_CONNECT) {
690  myConnector->onCmdOK(0, 0, 0);
691  } else if (myEditMode == GNE_MODE_TLS) {
692  myTLSEditor->onCmdOK(0, 0, 0);
693  } else if (myEditMode == GNE_MODE_MOVE && myCurrentPoly != 0) {
694  if (myCurrentPoly->getEditedJunction() != 0) {
697  update();
698  }
699  }
700 }
701 
702 
703 long
704 GNEViewNet::onCmdChangeMode(FXObject*, FXSelector, void* data) {
705  setEditMode(myEditModeNames.get((char*) data));
706  return 1;
707 }
708 
709 
710 void
712  switch (selid) {
715  break;
716  case MID_GNE_MODE_MOVE:
718  break;
719  case MID_GNE_MODE_DELETE:
721  break;
724  break;
725  case MID_GNE_MODE_SELECT:
727  break;
730  break;
731  case MID_GNE_MODE_TLS:
733  break;
734  default:
735  FXMessageBox::error(this, MBOX_OK, "invalid edit mode", "%s", "...");
736  break;
737  }
738  myEditModesCombo->setCurrentItem(myEditModesCombo->findItem(myEditModeNames.getString(myEditMode).c_str()));
739 }
740 
741 
742 void
745 }
746 
747 
750  GNEJunction* junction = 0;
751  if (makeCurrent()) {
752  unsigned int id = getObjectAtPosition(myPopupSpot);
755  if (pointed) {
756  switch (pointed->getType()) {
757  case GLO_JUNCTION:
758  junction = (GNEJunction*)pointed;
759  break;
760  default:
761  break;
762  }
763  }
764  }
765  return junction;
766 }
767 
768 
769 
770 
771 GNEEdge*
773  GNEEdge* edge = 0;
774  if (makeCurrent()) {
775  unsigned int id = getObjectAtPosition(myPopupSpot);
778  if (pointed) {
779  switch (pointed->getType()) {
780  case GLO_EDGE:
781  edge = (GNEEdge*)pointed;
782  break;
783  case GLO_LANE:
784  edge = &(((GNELane*)pointed)->getParentEdge());
785  break;
786  default:
787  break;
788  }
789  }
790  }
791  return edge;
792 }
793 
794 
795 GNELane*
797  GNELane* lane = 0;
798  if (makeCurrent()) {
799  unsigned int id = getObjectAtPosition(myPopupSpot);
802  if (pointed) {
803  if (pointed->getType() == GLO_LANE) {
804  lane = (GNELane*)pointed;
805  }
806  }
807  }
808  return lane;
809 }
810 
811 
812 std::set<GNEEdge*>
814  std::set<GNEEdge*> result;
815  if (makeCurrent()) {
816  const std::vector<GUIGlID> ids = getObjectsAtPosition(myPopupSpot, 1.0);
817  for (std::vector<GUIGlID>::const_iterator it = ids.begin(); it != ids.end(); ++it) {
820  if (pointed) {
821  switch (pointed->getType()) {
822  case GLO_EDGE:
823  result.insert((GNEEdge*)pointed);
824  break;
825  case GLO_LANE:
826  result.insert(&(((GNELane*)pointed)->getParentEdge()));
827  break;
828  default:
829  break;
830  }
831  }
832  }
833  }
834  return result;
835 }
836 
837 
838 long
839 GNEViewNet::onCmdSplitEdge(FXObject*, FXSelector, void*) {
841  if (edge != 0) {
843  }
844  return 1;
845 }
846 
847 
848 long
849 GNEViewNet::onCmdSplitEdgeBidi(FXObject*, FXSelector, void*) {
850  std::set<GNEEdge*> edges = getEdgesAtCursorPosition(myPopupSpot);
851  if (edges.size() != 0) {
852  myNet->splitEdgesBidi(edges, (*edges.begin())->getSplitPos(myPopupSpot), myUndoList);
853  }
854  return 1;
855 }
856 
857 
858 long
859 GNEViewNet::onCmdReverseEdge(FXObject*, FXSelector, void*) {
861  if (edge != 0) {
862  myNet->reverseEdge(edge, myUndoList);
863  }
864  return 1;
865 }
866 
867 
868 long
869 GNEViewNet::onCmdAddReversedEdge(FXObject*, FXSelector, void*) {
871  if (edge != 0) {
873  }
874  return 1;
875 }
876 
877 
878 long
879 GNEViewNet::onCmdSetEdgeEndpoint(FXObject*, FXSelector, void*) {
881  if (edge != 0) {
883  }
884  return 1;
885 }
886 
887 
888 long
889 GNEViewNet::onCmdResetEdgeEndpoint(FXObject*, FXSelector, void*) {
891  if (edge != 0) {
893  }
894  return 1;
895 }
896 
897 
898 long
899 GNEViewNet::onCmdStraightenEdges(FXObject*, FXSelector, void*) {
901  if (edge != 0) {
902  if (gSelected.isSelected(GLO_EDGE, edge->getGlID())) {
903  myUndoList->p_begin("straighten selected edges");
904  std::vector<GNEEdge*> edges = myNet->retrieveEdges(true);
905  for (std::vector<GNEEdge*>::iterator it = edges.begin(); it != edges.end(); it++) {
906  (*it)->setAttribute(SUMO_ATTR_SHAPE, "", myUndoList);
907  }
908  myUndoList->p_end();
909  } else {
910  myUndoList->p_begin("straighten edge");
912  myUndoList->p_end();
913  }
914  }
915  return 1;
916 }
917 
918 
919 long
920 GNEViewNet::onCmdSimplifyShape(FXObject*, FXSelector, void*) {
921  if (myCurrentPoly != 0) {
923  update();
924  }
925  return 1;
926 }
927 
928 
929 long
930 GNEViewNet::onCmdDeleteGeometry(FXObject*, FXSelector, void*) {
931  if (myCurrentPoly != 0) {
933  update();
934  }
935  return 1;
936 }
937 
938 
939 long
940 GNEViewNet::onCmdDuplicateLane(FXObject*, FXSelector, void*) {
942  if (lane != 0) {
943  if (gSelected.isSelected(GLO_LANE, lane->getGlID())) {
944  myUndoList->p_begin("duplicate selected lanes");
945  std::vector<GNELane*> lanes = myNet->retrieveLanes(true);
946  for (std::vector<GNELane*>::iterator it = lanes.begin(); it != lanes.end(); it++) {
948  }
949  myUndoList->p_end();
950  } else {
951  myUndoList->p_begin("duplicate lane");
953  myUndoList->p_end();
954  }
955  }
956  return 1;
957 }
958 
959 
960 long
961 GNEViewNet::onCmdNodeShape(FXObject*, FXSelector, void*) {
963  if (junction != 0) {
964  if (myCurrentPoly == 0) {
965  if (junction->getNBNode()->getShape().size() > 1) {
967  //std::cout << junction->getNBNode()->getShape() << "\n";
968  junction->getNBNode()->computeNodeShape(-1);
969  if (myCurrentPoly != 0) {
971  delete myCurrentPoly;
972  myCurrentPoly = 0;
973  }
974  PositionVector shape = junction->getNBNode()->getShape();
975  shape.closePolygon();
976  myCurrentPoly = new GNEPoly(myNet, junction, "node_shape:" + junction->getMicrosimID(), "node shape",
977  shape, false, RGBColor::GREEN, GLO_POLYGON);
980 
981  update();
982  }
983  } else {
986  update();
987  }
988  }
989  return 1;
990 }
991 
992 
993 void
995  if (myCurrentPoly != 0) {
997  delete myCurrentPoly;
998  myCurrentPoly = 0;
999  }
1000 }
1001 
1002 
1003 long
1004 GNEViewNet::onCmdNodeReplace(FXObject*, FXSelector, void*) {
1006  if (junction != 0) {
1008  update();
1009  }
1010  return 1;
1011 }
1012 
1013 
1014 // ===========================================================================
1015 // private
1016 // ===========================================================================
1017 void
1019  setStatusBarText("");
1020  abortOperation(false);
1021  if (mode == myEditMode) {
1022  // when trying to switch to the existing mode, toggle with previous instead
1023  // not quite sure whether this is useful
1024  //myEditMode = myPreviousEditMode;
1025  //myPreviousEditMode = mode;
1026  setStatusBarText("Mode already selected");
1027  } else {
1029  myEditMode = mode;
1031  switch (mode) {
1032  case GNE_MODE_CONNECT:
1033  case GNE_MODE_TLS:
1034  // modes which depend on computed data
1036  break;
1037  default:
1038  break;
1039  }
1040  }
1042 }
1043 
1044 
1045 void
1047  // initialize mappings
1048  myEditModeNames.insert("(e) Create Edge", GNE_MODE_CREATE_EDGE);
1049  myEditModeNames.insert("(m) Move", GNE_MODE_MOVE);
1050  myEditModeNames.insert("(d) Delete", GNE_MODE_DELETE);
1051  myEditModeNames.insert("(i) Inspect", GNE_MODE_INSPECT);
1052  myEditModeNames.insert("(s) Select", GNE_MODE_SELECT);
1053  myEditModeNames.insert("(c) Connect", GNE_MODE_CONNECT);
1054  myEditModeNames.insert("(t) Traffic Lights", GNE_MODE_TLS);
1055 
1056  // combo
1058  new FXComboBox(myToolbar, 12, this, MID_GNE_MODE_CHANGE,
1059  FRAME_SUNKEN | LAYOUT_LEFT | LAYOUT_TOP | COMBOBOX_STATIC | LAYOUT_CENTER_Y);
1060 
1061  std::vector<std::string> names = myEditModeNames.getStrings();
1062  for (std::vector<std::string>::const_iterator it = names.begin(); it != names.end(); it++) {
1063  myEditModesCombo->appendItem(it->c_str());
1064  }
1065  myEditModesCombo->setNumVisible((int)myEditModeNames.size());
1066 
1067  // initialize mode specific controls
1068  myChainCreateEdge = new FXMenuCheck(myToolbar, "chain\t\tCreate consecutive edges with a single click (hit ESC to cancel chain).", this, 0);
1069  myAutoCreateOppositeEdge = new FXMenuCheck(myToolbar,
1070  "two-way\t\tAutomatically create an edge in the opposite direction", this, 0);
1071  mySelectEdges = new FXMenuCheck(myToolbar, "select edges\t\tToggle whether clicking should select edges or lanes", this, 0);
1072  mySelectEdges->setCheck();
1073  myExtendToEdgeNodes = new FXMenuCheck(myToolbar, "auto-select nodes\t\tToggle whether selecting multiple edges should automatically select their nodes", this, 0);
1074 
1075  myWarnAboutMerge = new FXMenuCheck(myToolbar, "ask for merge\t\tAsk for confirmation before merging junctions.", this, 0);
1076  myWarnAboutMerge->setCheck();
1077 
1078  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);
1079  myChangeAllPhases->setCheck(false);
1080 }
1081 
1082 
1083 void
1085  // MAGIC modifier to avoid flicker. at least it is consistent for move AND
1086  // zoom. Probably has to do with spacing
1087  const int addChange = 4;
1088 
1089  // hide all controls
1090  myChainCreateEdge->hide();
1091  myAutoCreateOppositeEdge->hide();
1092  mySelectEdges->hide();
1093  myExtendToEdgeNodes->hide();
1094  myChangeAllPhases->hide();
1095  myWarnAboutMerge->hide();
1096  int widthChange = 0;
1097  if (myInspector->shown()) {
1098  widthChange += myInspector->getWidth() + addChange;
1099  myInspector->hide();
1100  myInspector->inspect(std::vector<GNEAttributeCarrier*>());
1101  }
1102  if (mySelector->shown()) {
1103  widthChange += mySelector->getWidth() + addChange;
1104  mySelector->hide();
1105  }
1106  if (myConnector->shown()) {
1107  widthChange += myConnector->getWidth() + addChange;
1108  myConnector->hide();
1109  }
1110  if (myTLSEditor->shown()) {
1111  widthChange += myTLSEditor->getWidth() + addChange;
1112  myTLSEditor->hide();
1113  }
1114 
1115  // enable selected controls
1116  switch (myEditMode) {
1117  case GNE_MODE_CREATE_EDGE:
1118  myChainCreateEdge->show();
1119  myAutoCreateOppositeEdge->show();
1120  break;
1121  case GNE_MODE_DELETE:
1122  mySelectEdges->show();
1123  case GNE_MODE_INSPECT:
1124  widthChange -= myInspector->getWidth() + addChange;
1125  myInspector->show();
1126  mySelectEdges->show();
1127  break;
1128  case GNE_MODE_SELECT:
1129  widthChange -= mySelector->getWidth() + addChange;
1130  mySelector->show();
1131  mySelectEdges->show();
1132  myExtendToEdgeNodes->show();
1133  break;
1134  case GNE_MODE_MOVE:
1135  myWarnAboutMerge->show();
1136  break;
1137  case GNE_MODE_CONNECT:
1138  widthChange -= myConnector->getWidth() + addChange;
1139  myConnector->show();
1140  break;
1141  case GNE_MODE_TLS:
1142  widthChange -= myTLSEditor->getWidth() + addChange;
1143  myTLSEditor->show();
1144  myChangeAllPhases->show();
1145  break;
1146  default:
1147  break;
1148  }
1149  myChanger->changeCanvassLeft(widthChange);
1150  myToolbar->recalc();
1151  recalc();
1152  onPaint(0, 0, 0); // force repaint because different modes draw different things
1153  //update();
1154 }
1155 
1156 
1157 void
1159  myUndoList->p_begin("delete selected junctions");
1160  std::vector<GNEJunction*> junctions = myNet->retrieveJunctions(true);
1161  for (std::vector<GNEJunction*>::iterator it = junctions.begin(); it != junctions.end(); it++) {
1163  }
1164  myUndoList->p_end();
1165 }
1166 
1167 
1168 void
1170  if (mySelectEdges->getCheck()) {
1171  myUndoList->p_begin("delete selected edges");
1172  std::vector<GNEEdge*> edges = myNet->retrieveEdges(true);
1173  for (std::vector<GNEEdge*>::iterator it = edges.begin(); it != edges.end(); it++) {
1174  myNet->deleteEdge(*it, myUndoList);
1175  }
1176  } else {
1177  myUndoList->p_begin("delete selected lanes");
1178  std::vector<GNELane*> lanes = myNet->retrieveLanes(true);
1179  for (std::vector<GNELane*>::iterator it = lanes.begin(); it != lanes.end(); it++) {
1180  myNet->deleteLane(*it, myUndoList);
1181  }
1182  }
1183  myUndoList->p_end();
1184 }
1185 
1186 
1187 bool
1189  const Position& newPos = moved->getNBNode()->getPosition();
1190  GNEJunction* mergeTarget = 0;
1191  // try to find another junction to merge with
1192  if (makeCurrent()) {
1193  Boundary selection;
1194  selection.add(newPos);
1195  selection.grow(0.1);
1196  const std::vector<GUIGlID> ids = getObjectsInBoundary(selection);
1197  GUIGlObject* object = 0;
1198  for (std::vector<GUIGlID>::const_iterator it = ids.begin(); it != ids.end(); it++) {
1199  GUIGlID id = *it;
1200  if (id == 0) {
1201  continue;
1202  }
1204  if (!object) {
1205  throw ProcessError("Unkown object in selection (id=" + toString(id) + ").");
1206  }
1207  if (object->getType() == GLO_JUNCTION && id != moved->getGlID()) {
1208  mergeTarget = dynamic_cast<GNEJunction*>(object);
1209  }
1211  }
1212  }
1213  if (mergeTarget) {
1214  // optionally ask for confirmation
1215  if (myWarnAboutMerge->getCheck()) {
1216  FXuint answer = FXMessageBox::question(this, MBOX_YES_NO,
1217  "Confirm Junction Merger", "%s",
1218  ("Do you wish to merge junctions '" + moved->getMicrosimID() +
1219  "' and '" + mergeTarget->getMicrosimID() + "'?\n" +
1220  "('" + moved->getMicrosimID() +
1221  "' will be eliminated and its roads added to '" +
1222  mergeTarget->getMicrosimID() + "')").c_str());
1223  if (answer != 1) { //1:yes, 2:no, 4:esc
1224  return false;
1225  }
1226  }
1227  myNet->mergeJunctions(moved, mergeTarget, myUndoList);
1228  return true;
1229  } else {
1230  return false;
1231  }
1232 }
1233 
1234 
1235 void
1237  switch (myEditMode) {
1238  case GNE_MODE_INSPECT:
1239  myInspector->update();
1240  break;
1241  default:
1242  break;
1243  }
1244 }
1245 /****************************************************************************/
GNEJunction * splitEdge(GNEEdge *edge, const Position &pos, GNEUndoList *undoList, GNEJunction *newJunction=0)
split edge at position by inserting a new junction
Definition: GNENet.cpp:360
long onCmdResetEdgeEndpoint(FXObject *, FXSelector, void *)
restore geometry endpoint to node position
Definition: GNEViewNet.cpp:889
long onCmdDeleteGeometry(FXObject *, FXSelector, void *)
delete the closes geometry point
Definition: GNEViewNet.cpp:930
void paintGLGrid()
paints a grid
std::vector< GNEJunction * > retrieveJunctions(bool onlySelected=false)
return all junctions
Definition: GNENet.cpp:580
a tl-logic
GNEConnector * myConnector
Definition: GNEViewNet.h:307
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:126
FXDEFMAP(GNEViewNet) GNEViewNetMap[]
std::vector< GNELane * > retrieveLanes(bool onlySelected=false)
return all lanes
Definition: GNENet.cpp:565
FXMenuCheck * mySelectEdges
Definition: GNEViewNet.h:230
bool selectEdges()
Definition: GNEViewNet.h:181
GNEJunction * getJunctionAtCursorPosition(Position &pos)
try to retrieve a junction at the given position
Definition: GNEViewNet.cpp:749
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
Position myPopupSpot
Definition: GNEViewNet.h:312
GUICompleteSchemeStorage gSchemeStorage
void abortOperation(bool clearSelection=true)
Definition: GNEViewNet.cpp:653
void deleteSelectedJunctions()
delete all currently selected junctions
const SUMOReal SUMO_const_laneWidth
Definition: StdDefs.h:49
bool setColorScheme(const std::string &name)
Definition: GNEViewNet.cpp:294
is a pedestrian
a polygon
void inspect(const std::vector< GNEAttributeCarrier * > &ACs)
Inspect the given multi-selection.
void markPopupPosition()
Definition: GNEViewNet.cpp:743
long onCmdDuplicateLane(FXObject *, FXSelector, void *)
duplicate selected lane
Definition: GNEViewNet.cpp:940
StringBijection< EditMode > myEditModeNames
since we cannot switch on strings we map the mode names to an enum
Definition: GNEViewNet.h:293
long onMouseMove(FXObject *, FXSelector, void *)
Definition: GNEViewNet.cpp:632
void markAsCreateEdgeSource()
marks as first junction in createEdge-mode
Definition: GNEJunction.h:134
The main window of the Netedit.
SUMORTree * myGrid
The visualization speed-up.
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...
virtual void changeCanvassLeft(int change)=0
void setAllowsNegativeValues(bool value)
Locate TLS - button.
Definition: GUIAppEnum.h:171
void toggleSelection(GUIGlID id)
Toggles selection of an object.
virtual long onMouseMove(FXObject *, FXSelector, void *)
FXMenuCheck * myChainCreateEdge
Definition: GNEViewNet.h:245
GUIColorer laneColorer
The lane colorer.
SUMOReal ymin() const
Returns minimum y-coordinate.
Definition: Boundary.cpp:124
Definition: GNEPOI.h:57
long onCmdSplitEdge(FXObject *, FXSelector, void *)
split edge at cursor position
Definition: GNEViewNet.cpp:839
const PositionVector & getShape() const
Returns whether the shape of the polygon.
Definition: Polygon.h:82
vehicle is a bicycle
long onCmdOK(FXObject *, FXSelector, void *)
Called when the user presses the OK-Button saves any connection modifications.
GUIMainWindow * myApp
The application.
FXMenuCheck * myChangeAllPhases
Definition: GNEViewNet.h:232
vehicle is a small delivery vehicle
void setEditMode(EditMode mode)
Position moveGeometry(const Position &oldPos, const Position &newPos, bool relative=false)
change the edge geometry without registering undo/redo It is up to the Edge to decide whether an new ...
Definition: GNEEdge.cpp:231
void computeEverything(GNEApplicationWindow *window, bool force=false)
Definition: GNENet.cpp:687
GNEEdge & getParentEdge()
Returns underlying parent edge.
Definition: GNELane.h:108
GNEEdge * getEdgeTemplate()
Definition: GNEInspector.h:128
SUMOReal xmin() const
Returns minimum x-coordinate.
Definition: Boundary.cpp:112
Position mySelCorner2
Definition: GNEViewNet.h:281
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
void reverseEdge(GNEEdge *edge, GNEUndoList *undoList)
reverse edge
Definition: GNENet.cpp:425
const std::string & getMicrosimID() const
Returns the id of the object as known to microsim.
Definition: GUIGlObject.h:167
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
Definition: GNEViewNet.cpp:961
static const RGBColor ORANGE
Definition: RGBColor.h:195
std::string getAttribute(SumoXMLAttr key) const
Definition: GNEEdge.cpp:401
virtual long onLeftBtnPress(FXObject *, FXSelector, void *)
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:414
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:77
FXComboBox * myEditModesCombo
combo box for selecting the edit mode
Definition: GNEViewNet.h:289
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition: GNELane.h:56
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:219
int editMode
the current NETEDIT mode (temporary)
void p_begin(const std::string &description)
Definition: GNEUndoList.cpp:75
void setEditModeFromHotkey(FXushort selid)
sets edit mode (from hotkey)
Definition: GNEViewNet.cpp:711
long onCmdSetEdgeEndpoint(FXObject *, FXSelector, void *)
set non-default geometry endpoint
Definition: GNEViewNet.cpp:879
static const RGBColor BLACK
Definition: RGBColor.h:197
const SVCPermissions SVCAll
GUIDialog_ViewSettings * myVisualizationChanger
void deleteEdge(GNEEdge *edge, GNEUndoList *undoList)
removes edge
Definition: GNENet.cpp:299
void updateControls()
update control contents after undo/redo or recompute
EditMode myPreviousEditMode
Definition: GNEViewNet.h:228
void registerMove(GNEUndoList *undoList)
registers completed movement with the undoList
SUMOReal x() const
Returns the x-position.
Definition: Position.h:63
GUIGlID getGlID() const
Returns the numerical id of the object.
Definition: GUIGlObject.h:123
SUMOReal xmax() const
Returns maximum x-coordinate.
Definition: Boundary.cpp:118
GNEEdge * myEdgeToMove
the edge of which geometry is being moved
Definition: GNEViewNet.h:258
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:48
long onCmdChangeMode(FXObject *, FXSelector, void *)
sets edit mode via combo box
Definition: GNEViewNet.cpp:704
A single child window which contains a view of the simulation area.
Definition: GNEViewParent.h:65
SUMOReal scale
information about a lane&#39;s width (temporary, used for a single view)
GNETLSEditor * myTLSEditor
Definition: GNEViewNet.h:310
std::vector< std::string > getStrings() const
bool myMoveSelection
whether a selection is being moved
Definition: GNEViewNet.h:267
long onCmdCancel(FXObject *, FXSelector, void *)
Called when the user presses the Cancel-button discards any connection modifications.
size_t size() const
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)
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
Definition: GUIGlObject.h:180
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
Definition: GNEViewNet.cpp:813
long onLeftBtnPress(FXObject *, FXSelector, void *)
Definition: GNEViewNet.cpp:375
const Position & getPosition() const
Returns the position of this node.
Definition: NBNode.h:228
long onCmdSimplifyShape(FXObject *, FXSelector, void *)
simply shape of current polygon
Definition: GNEViewNet.cpp:920
static const RGBColor GREEN
Definition: RGBColor.h:190
static const RGBColor GREY
Definition: RGBColor.h:198
virtual long onPaint(FXObject *, FXSelector, void *)
const std::set< GUIGlID > & getSelected() const
Returns the list of ids of all selected objects.
GNEPoly * myCurrentPoly
Definition: GNEViewNet.h:314
ShapeContainer & getShapeContainer()
Definition: GNENet.h:402
std::map< GUIGlObject *, int > myAdditionallyDrawn
List of objects for which GUIGlObject::drawGLAdditional is called.
FXMenuCheck * myWarnAboutMerge
whether we should warn about merging junctions
Definition: GNEViewNet.h:270
void setCurrentScheme(const std::string &)
Sets the named scheme as the current.
virtual void setStatusBarText(const std::string &)
Definition: GUIMainWindow.h:78
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
Definition: GLHelper.cpp:443
This object is responsible for drawing a shape and for supplying a a popup menu. Messages are routete...
Definition: GNECrossing.h:55
virtual ~GNEViewNet()
destructor
Definition: GNEViewNet.cpp:252
GNEInspector * myInspector
Definition: GNEViewNet.h:301
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:46
void p_end()
Definition: GNEUndoList.cpp:82
virtual bool removePOI(const std::string &id)
Removes a PoI from the container.
A list of positions.
Locate edge - button.
Definition: GUIAppEnum.h:165
FXToolBar * myToolbar
a reference to the toolbar in myParent
Definition: GNEViewNet.h:287
void deleteLane(GNELane *lane, GNEUndoList *undoList)
removes lane
Definition: GNENet.cpp:317
long onCmdCancel(FXObject *, FXSelector, void *)
Called when the user presses the Cancel-button discards any modifications.
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:352
bool contains(const std::string &name) const
Returns the information whether a setting with the given name is stored.
static GUIGlObjectStorage gIDStorage
A single static instance of this class.
void update()
update the widget
GUIVisualizationSettings & get(const std::string &name)
Returns the named scheme.
const std::string & getString(const T key) const
long onCmdSplitEdgeBidi(FXObject *, FXSelector, void *)
split edge at cursor position
Definition: GNEViewNet.cpp:849
static const RGBColor MAGENTA
Definition: RGBColor.h:194
NBNode * getNBNode()
returns the internal NBNode
Definition: GNEJunction.h:153
void removeCurrentPoly()
remove the currently edited polygon
Definition: GNEViewNet.cpp:994
GNEJunction * myJunctionToMove
Definition: GNEViewNet.h:255
GNELane * getLaneAtCurserPosition(Position &pos)
try to retrieve a lane at the given position
Definition: GNEViewNet.cpp:796
Locate junction - button.
Definition: GUIAppEnum.h:163
std::vector< GNEAttributeCarrier * > retrieveAttributeCarriers(const std::set< GUIGlID > &ids, GUIGlObjectType type)
get the attribute carriers based on GlIDs
Definition: GNENet.cpp:600
std::string getCurrentScheme() const
Returns the name of the currently chosen scheme.
void unMarkAsCreateEdgeSource()
removes mark as first junction in createEdge-mode
Definition: GNEJunction.h:140
void moveSelection(const Position &moveSrc, const Position &moveDest)
Definition: GNENet.cpp:856
GNEJunction * createJunction(const Position &pos, GNEUndoList *undoList)
creates a new junction
Definition: GNENet.cpp:208
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
Definition: ToString.h:54
Position mySelCorner1
Definition: GNEViewNet.h:280
void p_abort()
reverts and discards ALL active command groups
Definition: GNEUndoList.cpp:96
const PositionVector & getShape() const
retrieve the junction shape
Definition: NBNode.cpp:1638
GUIPerspectiveChanger * myChanger
The perspective changer.
unsigned int addColor(const T &color, const SUMOReal threshold, const std::string &name="")
EditMode
Definition: GNEViewNet.h:46
vehicle is a passenger car (a "normal" car)
void doInit()
called after some features are already initialized
Definition: GNEViewNet.cpp:256
is an arbitrary ship
FXMenuCheck * myAutoCreateOppositeEdge
Definition: GNEViewNet.h:246
bool mergeJunctions(GNEJunction *moved)
try to merge moved junction with another junction in that spot return true if merging did take place ...
vehicle is a moped
void replaceJunctionByGeometry(GNEJunction *junction, GNEUndoList *undoList)
Definition: GNENet.cpp:795
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:61
unsigned int GUIGlID
Definition: GUIGlObject.h:49
FXbool makeCurrent()
A reimplementation due to some internal reasons.
GNESelector * mySelector
Definition: GNEViewNet.h:304
vehicle is a taxi
compound additional
virtual long onLeftBtnRelease(FXObject *, FXSelector, void *)
vehicle is a bus
SUMORTree & getVisualisationSpeedUp()
Returns the RTree used for visualisation speed-up.
Definition: GNENet.h:154
void add(SUMOReal x, SUMOReal y)
Makes the boundary include the given coordinate.
Definition: Boundary.cpp:76
static const RGBColor YELLOW
Definition: RGBColor.h:192
Boundary & grow(SUMOReal by)
extends the boundary by the given amount
Definition: Boundary.cpp:201
static const RGBColor RED
Definition: RGBColor.h:189
FXMenuCheck * myExtendToEdgeNodes
Definition: GNEViewNet.h:231
static const RGBColor CYAN
Definition: RGBColor.h:193
bool hasCommandGroup() const
Definition: GNEUndoList.h:111
GUIVisualizationSettings * myVisualizationSettings
std::vector< GNEEdge * > retrieveEdges(bool onlySelected=false)
return all edges
Definition: GNENet.cpp:553
Position myMoveSrc
position from which to move edge geometry
Definition: GNEViewNet.h:264
void addAdditionalGLObject(GUIGlObject *o)
Adds an additional object (detector/shape/trigger) for visualisation.
Definition: SUMORTree.h:129
SUMOReal m2p(SUMOReal meter) const
meter-to-pixels conversion method
long onCmdReverseEdge(FXObject *, FXSelector, void *)
reverse edge
Definition: GNEViewNet.cpp:859
SUMOReal y() const
Returns the y-position.
Definition: Position.h:68
int doPaintGL(int mode, const Boundary &bound)
Definition: GNEViewNet.cpp:316
GNEJunction * myCreateEdgeSource
Definition: GNEViewNet.h:240
void editJunction(GNEJunction *junction)
edits the traffic light for the given junction
void move(Position pos)
reposition the node at pos and informs the edges
an edge
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:274
bool showGrid
Information whether a grid shall be shown.
void drawDecals()
Draws the stored decals.
void updateModeSpecificControls()
updates mode specific controls
T get(const std::string &str) const
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
GNEEdge * addReversedEdge(GNEEdge *edge, GNEUndoList *undoList)
add reversed edge
Definition: GNENet.cpp:436
void setStatusBarText(const std::string &text)
Definition: GNEViewNet.cpp:310
#define SUMOReal
Definition: config.h:213
virtual void buildViewToolBars(GUIGlChildWindow &)
builds the view toolbars
Definition: GNEViewNet.cpp:260
void setEndpoint(Position pos, GNEUndoList *undoList)
makes pos the new geometry endpoint at the appropriate end
Definition: GNEEdge.cpp:314
SUMOReal ymax() const
Returns maximum y-coordinate.
Definition: Boundary.cpp:130
GUIPropertyScheme< RGBColor > GUIColorScheme
static const RGBColor selectionColor
Definition: GNENet.h:83
empty max
void unblockObject(GUIGlID id)
Marks an object as unblocked.
long onCmdStraightenEdges(FXObject *, FXSelector, void *)
makes selected edges straight
Definition: GNEViewNet.cpp:899
void handleIDs(std::vector< GUIGlID > ids, bool selectEdges, SetOperation setop=SET_DEFAULT)
Position getPositionInformation() const
Returns the cursor&#39;s x/y position within the network.
GUIGlID getObjectUnderCursor()
returns the id of the object under the cursor using GL_SELECT
void mergeJunctions(GNEJunction *moved, GNEJunction *target, GNEUndoList *undoList)
merge the given junctions edges between the given junctions will be deleted
Definition: GNENet.cpp:469
GNEEdge * getEdgeAtCursorPosition(Position &pos)
try to retrieve an edge at the given position
Definition: GNEViewNet.cpp:772
long onCmdNodeReplace(FXObject *, FXSelector, void *)
replace node by geometry
void hotkeyDel()
Definition: GNEViewNet.cpp:675
long onCmdAddReversedEdge(FXObject *, FXSelector, void *)
add reversed edge
Definition: GNEViewNet.cpp:869
GUIGlObject * getObjectBlocking(GUIGlID id)
Returns the object from the container locking it.
void closePolygon()
ensures that the last position equals the first
GNEJunction * getEditedJunction() const
retrieve the junction of which the shape is being edited
Definition: GNEPoly.h:157
bool myAmInRectSelect
Definition: GNEViewNet.h:278
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
Definition: GNEEdge.cpp:467
GUISelectedStorage gSelected
A global holder of selected objects.
GNENet * myNet
Definition: GNEViewNet.h:222
void hotkeyEnter()
Definition: GNEViewNet.cpp:688
void resetEndpoint(const Position &pos, GNEUndoList *undoList)
restores the endpoint to the junction position at the appropriate end
Definition: GNEEdge.cpp:337
long onCmdOK(FXObject *, FXSelector, void *)
Called when the user presses the OK-Button saves any modifications.
static FXIcon * getIcon(GUIIcon which)
long onLeftBtnRelease(FXObject *, FXSelector, void *)
Definition: GNEViewNet.cpp:595
Position getSplitPos(const Position &clickPos)
Definition: GNEEdge.cpp:217
void computeNodeShape(SUMOReal mismatchThreshold)
Compute the junction shape for this node.
Definition: NBNode.cpp:709
void duplicateLane(GNELane *lane, GNEUndoList *undoList)
duplicates lane
Definition: GNENet.cpp:340
void deleteSelectedEdges()
delete all currently selected edges
GNEUndoList * myUndoList
a reference to the undolist maintained in the application
Definition: GNEViewNet.h:298
EditMode myEditMode
Definition: GNEViewNet.h:225
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:261
void finishMoveSelection(GNEUndoList *undoList)
register changes to junction and edge positions with the undoList
Definition: GNENet.cpp:886