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-2015 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),
90 };
91 
92 // Object implementation
93 FXIMPLEMENT(GNEViewNet, GUISUMOAbstractView, GNEViewNetMap, ARRAYNUMBER(GNEViewNetMap))
94 
95 // ===========================================================================
96 // static member definitions
97 // ===========================================================================
98 
99 // ===========================================================================
100 // member method definitions
101 // ===========================================================================
103  FXComposite* tmpParent,
104  FXComposite* actualParent,
105  GUIMainWindow& app,
106  GNEViewParent* viewParent,
107  GNENet* net, FXGLVisual* glVis,
108  FXGLCanvas* share,
109  FXToolBar* toolBar) :
110  GUISUMOAbstractView(tmpParent, app, viewParent, net->getVisualisationSpeedUp(), glVis, share),
111  myNet(net),
112  myEditMode(GNE_MODE_MOVE),
113  myPreviousEditMode(GNE_MODE_MOVE),
114  myCreateEdgeSource(0),
115  myJunctionToMove(0),
116  myEdgeToMove(0),
117  myPolyToMove(0),
118  myMoveSelection(false),
119  myAmInRectSelect(false),
120  myToolbar(toolBar),
121  myEditModesCombo(0),
122  myEditModeNames(),
123  myUndoList(((GNEApplicationWindow*)myApp)->getUndoList()),
124  myInspector(0),
125  mySelector(0),
126  myCurrentPoly(0) {
127  // adding order is important
128  myInspector = new GNEInspector(actualParent, myUndoList);
129  myInspector->hide();
130  mySelector = new GNESelector(actualParent, this, myUndoList);
131  mySelector->hide();
132  myConnector = new GNEConnector(actualParent, this, myUndoList);
133  myConnector->hide();
134  myTLSEditor = new GNETLSEditor(actualParent, this, myUndoList);
135  myTLSEditor->hide();
136  // view must be the final member of actualParent
137  reparent(actualParent);
138 
139  buildEditModeControls();
140  myUndoList->mark();
141  myNet->setUpdateTarget(this);
142  ((GUIDanielPerspectiveChanger*)myChanger)->setDragDelay(100000000); // 100 milliseconds
143 
144  // init color schemes
145  GUIColorer laneColorer;
146  GUIColorScheme scheme = GUIColorScheme("uniform", RGBColor::BLACK, "road", true);
147  scheme.addColor(RGBColor::GREY, 1, "sidewalk");
148  scheme.addColor(RGBColor(192, 66, 44), 2, "bike lane");
149  scheme.addColor(RGBColor(200, 255, 200), 3, "green verge");
150  scheme.addColor(RGBColor(150, 200, 200), 4, "waterway");
151  scheme.addColor(RGBColor(92, 92, 92), 5, "no passenger"); // paths, service roads etc
152  laneColorer.addScheme(scheme);
153  scheme = GUIColorScheme("by selection (lane-/streetwise)", RGBColor(128, 128, 128, 255), "unselected", true);
154  scheme.addColor(RGBColor(0, 80, 180, 255), 1, "selected");
155  laneColorer.addScheme(scheme);
156  scheme = GUIColorScheme("by permission code", RGBColor(240, 240, 240), "nobody");
157  scheme.addColor(RGBColor(10, 10, 10), (SUMOReal)SVC_PASSENGER, "passenger");
158  scheme.addColor(RGBColor(128, 128, 128), (SUMOReal)SVC_PEDESTRIAN, "pedestrian");
159  scheme.addColor(RGBColor(80, 80, 80), (SUMOReal)(SVC_PEDESTRIAN | SVC_DELIVERY), "pedestrian_delivery");
160  scheme.addColor(RGBColor(192, 66, 44), (SUMOReal)SVC_BICYCLE, "bicycle");
161  scheme.addColor(RGBColor(40, 100, 40), (SUMOReal)SVC_BUS, "bus");
162  scheme.addColor(RGBColor(166, 147, 26), (SUMOReal)SVC_TAXI, "taxi");
163  scheme.addColor(RGBColor::BLACK, (SUMOReal)(SVCAll & ~SVC_NON_ROAD), "normal_road");
164  scheme.addColor(RGBColor::BLACK, (SUMOReal)(SVCAll & ~(SVC_PEDESTRIAN | SVC_NON_ROAD)), "disallow_pedestrian");
165  scheme.addColor(RGBColor(255, 206, 0), (SUMOReal)(SVCAll & ~(SVC_PEDESTRIAN | SVC_BICYCLE | SVC_MOPED | SVC_NON_ROAD)), "motorway");
166  scheme.addColor(RGBColor(150, 200, 200), (SUMOReal)SVC_SHIP, "waterway");
167  scheme.addColor(RGBColor::GREEN, (SUMOReal)SVCAll, "all");
168  laneColorer.addScheme(scheme);
169 
170  scheme = GUIColorScheme("by allowed speed (lanewise)", RGBColor::RED);
171  scheme.addColor(RGBColor::YELLOW, (SUMOReal)(30 / 3.6));
172  scheme.addColor(RGBColor::GREEN, (SUMOReal)(55 / 3.6));
173  scheme.addColor(RGBColor::CYAN, (SUMOReal)(80 / 3.6));
174  scheme.addColor(RGBColor::BLUE, (SUMOReal)(120 / 3.6));
175  scheme.addColor(RGBColor::MAGENTA, (SUMOReal)(150 / 3.6));
176  laneColorer.addScheme(scheme);
177 
178  scheme = GUIColorScheme("by lane number (streetwise)", RGBColor::RED);
179  scheme.addColor(RGBColor::BLUE, (SUMOReal)5);
180  laneColorer.addScheme(scheme);
181 
182  scheme = GUIColorScheme("by given length/geometrical length", RGBColor::BLACK);
183  scheme.addColor(RGBColor::RED, (SUMOReal)0.25);
184  scheme.addColor(RGBColor::YELLOW, (SUMOReal)0.5);
185  scheme.addColor(RGBColor(179, 179, 179, 255), (SUMOReal)1.0);
186  scheme.addColor(RGBColor::GREEN, (SUMOReal)2.0);
187  scheme.addColor(RGBColor::BLUE, (SUMOReal)4.0);
188  laneColorer.addScheme(scheme);
189  laneColorer.addScheme(GUIColorScheme("by angle", RGBColor::YELLOW, "", true));
190 
191  scheme = GUIColorScheme("by priority", RGBColor::YELLOW);
192  scheme.addColor(RGBColor::RED, (SUMOReal) - 20);
193  scheme.addColor(RGBColor::GREEN, (SUMOReal)20);
194  scheme.setAllowsNegativeValues(true);
195  laneColorer.addScheme(scheme);
196  scheme = GUIColorScheme("by height at start", RGBColor::RED);
197  scheme.addColor(RGBColor::BLUE, (SUMOReal) - 10);
198  scheme.addColor(RGBColor::YELLOW, (SUMOReal)50);
199  scheme.addColor(RGBColor::GREEN, (SUMOReal)100);
200  scheme.addColor(RGBColor::MAGENTA, (SUMOReal)200);
201  scheme.setAllowsNegativeValues(true);
202  laneColorer.addScheme(scheme);
203  scheme = GUIColorScheme("by height at segment start", RGBColor::RED);
204  scheme.addColor(RGBColor::BLUE, (SUMOReal) - 10);
205  scheme.addColor(RGBColor::YELLOW, (SUMOReal)50);
206  scheme.addColor(RGBColor::GREEN, (SUMOReal)100);
207  scheme.addColor(RGBColor::MAGENTA, (SUMOReal)200);
208  scheme.setAllowsNegativeValues(true);
209  laneColorer.addScheme(scheme);
210  scheme = GUIColorScheme("by inclination", RGBColor::GREY);
211  scheme.addColor(RGBColor::YELLOW, (SUMOReal) .1);
212  scheme.addColor(RGBColor::RED, (SUMOReal) .3);
213  scheme.addColor(RGBColor::GREEN, (SUMOReal) - .1);
214  scheme.addColor(RGBColor::BLUE, (SUMOReal) - .3);
215  scheme.setAllowsNegativeValues(true);
216  laneColorer.addScheme(scheme);
217  scheme = GUIColorScheme("by segment inclination", RGBColor::GREY);
218  scheme.addColor(RGBColor::YELLOW, (SUMOReal) .1);
219  scheme.addColor(RGBColor::RED, (SUMOReal) .3);
220  scheme.addColor(RGBColor::GREEN, (SUMOReal) - .1);
221  scheme.addColor(RGBColor::BLUE, (SUMOReal) - .3);
222  scheme.setAllowsNegativeValues(true);
223  laneColorer.addScheme(scheme);
224 
225  myVisualizationSettings->laneColorer = laneColorer;
226 
227  GUIColorer junctionColorer;
228  scheme = GUIColorScheme("uniform", RGBColor(102, 0, 0), "", true);
229  scheme.addColor(RGBColor(204, 0, 0), 1, "shape not computed");
230  scheme.addColor(RGBColor(153, 0, 0), 2, "geometry points");
231  junctionColorer.addScheme(scheme);
232  scheme = GUIColorScheme("by selection", RGBColor(128, 128, 128, 255), "unselected", true);
233  scheme.addColor(RGBColor(0, 80, 180, 255), 1, "selected");
234  junctionColorer.addScheme(scheme);
235  scheme = GUIColorScheme("by type", RGBColor::GREEN, "traffic_light", true);
236  scheme.addColor(RGBColor(0, 128, 0), 1, "traffic_light_unregulated");
237  scheme.addColor(RGBColor::YELLOW, 2, "priority");
238  scheme.addColor(RGBColor::RED, 3, "priority_stop");
239  scheme.addColor(RGBColor::BLUE, 4, "right_before_left");
240  scheme.addColor(RGBColor::CYAN, 5, "allway_stop");
241  scheme.addColor(RGBColor::GREY, 6, "district");
242  scheme.addColor(RGBColor::MAGENTA, 7, "unregulated");
243  scheme.addColor(RGBColor::BLACK, 8, "dead_end");
244  scheme.addColor(RGBColor::ORANGE, 9, "rail_signal");
245  scheme.addColor(RGBColor(192, 128, 64), 10, "zipper");
246  scheme.addColor(RGBColor(192, 255, 192), 11, "traffic_light_right_on_red");
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 long
1015 GNEViewNet::onCmdVisualizeHeight(FXObject*, FXSelector, void* /* data */) {
1016  if (myVisualizeHeight->getCheck()) {
1018  } else {
1020  }
1021  update();
1022  return 1;
1023 }
1024 
1025 // ===========================================================================
1026 // private
1027 // ===========================================================================
1028 void
1030  setStatusBarText("");
1031  abortOperation(false);
1032  if (mode == myEditMode) {
1033  // when trying to switch to the existing mode, toggle with previous instead
1034  // not quite sure whether this is useful
1035  //myEditMode = myPreviousEditMode;
1036  //myPreviousEditMode = mode;
1037  setStatusBarText("Mode already selected");
1038  } else {
1040  myEditMode = mode;
1042  switch (mode) {
1043  case GNE_MODE_CONNECT:
1044  case GNE_MODE_TLS:
1045  // modes which depend on computed data
1047  break;
1048  case GNE_MODE_INSPECT:
1049  if (myVisualizeHeight->getCheck()) {
1051  }
1052  default:
1053  break;
1054  }
1055  }
1057 }
1058 
1059 
1060 void
1062  // initialize mappings
1063  myEditModeNames.insert("(e) Create Edge", GNE_MODE_CREATE_EDGE);
1064  myEditModeNames.insert("(m) Move", GNE_MODE_MOVE);
1065  myEditModeNames.insert("(d) Delete", GNE_MODE_DELETE);
1066  myEditModeNames.insert("(i) Inspect", GNE_MODE_INSPECT);
1067  myEditModeNames.insert("(s) Select", GNE_MODE_SELECT);
1068  myEditModeNames.insert("(c) Connect", GNE_MODE_CONNECT);
1069  myEditModeNames.insert("(t) Traffic Lights", GNE_MODE_TLS);
1070 
1071  // combo
1073  new FXComboBox(myToolbar, 12, this, MID_GNE_MODE_CHANGE,
1074  FRAME_SUNKEN | LAYOUT_LEFT | LAYOUT_TOP | COMBOBOX_STATIC | LAYOUT_CENTER_Y);
1075 
1076  std::vector<std::string> names = myEditModeNames.getStrings();
1077  for (std::vector<std::string>::const_iterator it = names.begin(); it != names.end(); it++) {
1078  myEditModesCombo->appendItem(it->c_str());
1079  }
1080  myEditModesCombo->setNumVisible((int)myEditModeNames.size());
1081 
1082  // initialize mode specific controls
1083  myChainCreateEdge = new FXMenuCheck(myToolbar, "chain\t\tCreate consecutive edges with a single click (hit ESC to cancel chain).", this, 0);
1084  myAutoCreateOppositeEdge = new FXMenuCheck(myToolbar,
1085  "two-way\t\tAutomatically create an edge in the opposite direction", this, 0);
1086  mySelectEdges = new FXMenuCheck(myToolbar, "select edges\t\tToggle whether clicking should select edges or lanes", this, 0);
1087  mySelectEdges->setCheck();
1088  myExtendToEdgeNodes = new FXMenuCheck(myToolbar, "auto-select nodes\t\tToggle whether selecting multiple edges should automatically select their nodes", this, 0);
1089 
1090  myWarnAboutMerge = new FXMenuCheck(myToolbar, "ask for merge\t\tAsk for confirmation before merging junctions.", this, 0);
1091  myWarnAboutMerge->setCheck();
1092  myVisualizeHeight = new FXMenuCheck(myToolbar, "show height\t\tVisualize height by color (green is low, red is high).", this, MID_GNE_VIS_HEIGHT);
1093 
1094  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);
1095  myChangeAllPhases->setCheck(false);
1096 }
1097 
1098 
1099 void
1101  // MAGIC modifier to avoid flicker. at least it is consistent for move AND
1102  // zoom. Probably has to do with spacing
1103  const int addChange = 4;
1104 
1105  // hide all controls
1106  myChainCreateEdge->hide();
1107  myAutoCreateOppositeEdge->hide();
1108  mySelectEdges->hide();
1109  myExtendToEdgeNodes->hide();
1110  myChangeAllPhases->hide();
1111  myWarnAboutMerge->hide();
1112  myVisualizeHeight->hide();
1113  int widthChange = 0;
1114  if (myInspector->shown()) {
1115  widthChange += myInspector->getWidth() + addChange;
1116  myInspector->hide();
1117  myInspector->inspect(std::vector<GNEAttributeCarrier*>());
1118  }
1119  if (mySelector->shown()) {
1120  widthChange += mySelector->getWidth() + addChange;
1121  mySelector->hide();
1122  }
1123  if (myConnector->shown()) {
1124  widthChange += myConnector->getWidth() + addChange;
1125  myConnector->hide();
1126  }
1127  if (myTLSEditor->shown()) {
1128  widthChange += myTLSEditor->getWidth() + addChange;
1129  myTLSEditor->hide();
1130  }
1131 
1132  // enable selected controls
1133  switch (myEditMode) {
1134  case GNE_MODE_CREATE_EDGE:
1135  myChainCreateEdge->show();
1136  myAutoCreateOppositeEdge->show();
1137  break;
1138  case GNE_MODE_DELETE:
1139  mySelectEdges->show();
1140  case GNE_MODE_INSPECT:
1141  widthChange -= myInspector->getWidth() + addChange;
1142  myInspector->show();
1143  mySelectEdges->show();
1144  myVisualizeHeight->show();
1145  break;
1146  case GNE_MODE_SELECT:
1147  widthChange -= mySelector->getWidth() + addChange;
1148  mySelector->show();
1149  mySelectEdges->show();
1150  myExtendToEdgeNodes->show();
1151  break;
1152  case GNE_MODE_MOVE:
1153  myWarnAboutMerge->show();
1154  break;
1155  case GNE_MODE_CONNECT:
1156  widthChange -= myConnector->getWidth() + addChange;
1157  myConnector->show();
1158  break;
1159  case GNE_MODE_TLS:
1160  widthChange -= myTLSEditor->getWidth() + addChange;
1161  myTLSEditor->show();
1162  myChangeAllPhases->show();
1163  break;
1164  default:
1165  break;
1166  }
1167  myChanger->changeCanvassLeft(widthChange);
1168  myToolbar->recalc();
1169  recalc();
1170  onPaint(0, 0, 0); // force repaint because different modes draw different things
1171  //update();
1172 }
1173 
1174 
1175 void
1177  myUndoList->p_begin("delete selected junctions");
1178  std::vector<GNEJunction*> junctions = myNet->retrieveJunctions(true);
1179  for (std::vector<GNEJunction*>::iterator it = junctions.begin(); it != junctions.end(); it++) {
1181  }
1182  myUndoList->p_end();
1183 }
1184 
1185 
1186 void
1188  if (mySelectEdges->getCheck()) {
1189  myUndoList->p_begin("delete selected edges");
1190  std::vector<GNEEdge*> edges = myNet->retrieveEdges(true);
1191  for (std::vector<GNEEdge*>::iterator it = edges.begin(); it != edges.end(); it++) {
1192  myNet->deleteEdge(*it, myUndoList);
1193  }
1194  } else {
1195  myUndoList->p_begin("delete selected lanes");
1196  std::vector<GNELane*> lanes = myNet->retrieveLanes(true);
1197  for (std::vector<GNELane*>::iterator it = lanes.begin(); it != lanes.end(); it++) {
1198  myNet->deleteLane(*it, myUndoList);
1199  }
1200  }
1201  myUndoList->p_end();
1202 }
1203 
1204 
1205 bool
1207  const Position& newPos = moved->getNBNode()->getPosition();
1208  GNEJunction* mergeTarget = 0;
1209  // try to find another junction to merge with
1210  if (makeCurrent()) {
1211  Boundary selection;
1212  selection.add(newPos);
1213  selection.grow(0.1);
1214  const std::vector<GUIGlID> ids = getObjectsInBoundary(selection);
1215  GUIGlObject* object = 0;
1216  for (std::vector<GUIGlID>::const_iterator it = ids.begin(); it != ids.end(); it++) {
1217  GUIGlID id = *it;
1218  if (id == 0) {
1219  continue;
1220  }
1222  if (!object) {
1223  throw ProcessError("Unkown object in selection (id=" + toString(id) + ").");
1224  }
1225  if (object->getType() == GLO_JUNCTION && id != moved->getGlID()) {
1226  mergeTarget = dynamic_cast<GNEJunction*>(object);
1227  }
1229  }
1230  }
1231  if (mergeTarget) {
1232  // optionally ask for confirmation
1233  if (myWarnAboutMerge->getCheck()) {
1234  FXuint answer = FXMessageBox::question(this, MBOX_YES_NO,
1235  "Confirm Junction Merger", "%s",
1236  ("Do you wish to merge junctions '" + moved->getMicrosimID() +
1237  "' and '" + mergeTarget->getMicrosimID() + "'?\n" +
1238  "('" + moved->getMicrosimID() +
1239  "' will be eliminated and its roads added to '" +
1240  mergeTarget->getMicrosimID() + "')").c_str());
1241  if (answer != 1) { //1:yes, 2:no, 4:esc
1242  return false;
1243  }
1244  }
1245  myNet->mergeJunctions(moved, mergeTarget, myUndoList);
1246  return true;
1247  } else {
1248  return false;
1249  }
1250 }
1251 
1252 
1253 void
1255  switch (myEditMode) {
1256  case GNE_MODE_INSPECT:
1257  myInspector->update();
1258  break;
1259  default:
1260  break;
1261  }
1262 }
1263 /****************************************************************************/
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:313
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:233
bool selectEdges()
Definition: GNEViewNet.h:184
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:318
GUICompleteSchemeStorage gSchemeStorage
long onCmdVisualizeHeight(FXObject *, FXSelector, void *)
switch color scheme
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:299
long onMouseMove(FXObject *, FXSelector, void *)
Definition: GNEViewNet.cpp:632
void markAsCreateEdgeSource()
marks as first junction in createEdge-mode
Definition: GNEJunction.h:130
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:248
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:235
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:287
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:154
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:295
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:231
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:261
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:316
std::vector< std::string > getStrings() const
bool myMoveSelection
whether a selection is being moved
Definition: GNEViewNet.h:270
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:167
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:320
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:273
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:307
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:293
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:149
void removeCurrentPoly()
remove the currently edited polygon
Definition: GNEViewNet.cpp:994
GNEJunction * myJunctionToMove
Definition: GNEViewNet.h:258
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:136
void moveSelection(const Position &moveSrc, const Position &moveDest)
Definition: GNENet.cpp:857
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:53
Position mySelCorner1
Definition: GNEViewNet.h:286
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:1591
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:249
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:796
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:310
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:234
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:267
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:243
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
FXMenuCheck * myVisualizeHeight
Definition: GNEViewNet.h:278
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:214
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:284
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:225
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:704
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:304
EditMode myEditMode
Definition: GNEViewNet.h:228
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:264
void finishMoveSelection(GNEUndoList *undoList)
register changes to junction and edge positions with the undoList
Definition: GNENet.cpp:887