SUMO - Simulation of Urban MObility
GNEViewNet.cpp
Go to the documentation of this file.
1 /****************************************************************************/
7 // A view on the network being edited (adapted from GUIViewTraffic)
8 /****************************************************************************/
9 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
10 // Copyright (C) 2001-2016 DLR (http://www.dlr.de/) and contributors
11 /****************************************************************************/
12 //
13 // This file is part of SUMO.
14 // SUMO is free software: you can redistribute it and/or modify
15 // it under the terms of the GNU General Public License as published by
16 // the Free Software Foundation, either version 3 of the License, or
17 // (at your option) any later version.
18 //
19 /****************************************************************************/
20 
21 
22 // ===========================================================================
23 // included modules
24 // ===========================================================================
25 #ifdef _MSC_VER
26 #include <windows_config.h>
27 #else
28 #include <config.h>
29 #endif
30 
31 #include <iostream>
32 #include <utility>
33 #include <cmath>
34 #include <limits>
39 #include <utils/common/RGBColor.h>
50 #include <utils/gui/div/GLHelper.h>
52 
53 #include "GNEViewNet.h"
54 #include "GNEEdge.h"
55 #include "GNELane.h"
56 #include "GNEJunction.h"
57 #include "GNEPOI.h"
58 #include "GNEApplicationWindow.h"
59 #include "GNEViewParent.h"
60 #include "GNENet.h"
61 #include "GNEUndoList.h"
62 #include "GNEInspectorFrame.h"
63 #include "GNESelectorFrame.h"
64 #include "GNEConnectorFrame.h"
65 #include "GNETLSEditorFrame.h"
66 #include "GNEAdditionalFrame.h"
67 #include "GNEAdditionalHandler.h"
68 #include "GNEPoly.h"
69 #include "GNECrossing.h"
70 #include "GNEAdditional.h"
71 #include "GNEAdditionalSet.h"
72 #include "GNEAdditionalDialog.h"
73 #include "GNERerouter.h"
74 #include "GNEChange_Attribute.h"
75 
76 
77 #ifdef CHECK_MEMORY_LEAKS
78 #include <foreign/nvwa/debug_new.h>
79 #endif // CHECK_MEMORY_LEAKS
80 
81 // ===========================================================================
82 // FOX callback mapping
83 // ===========================================================================
84 FXDEFMAP(GNEViewNet) GNEViewNetMap[] = {
85  FXMAPFUNC(SEL_COMMAND, MID_GNE_MODE_CHANGE, GNEViewNet::onCmdChangeMode),
86  FXMAPFUNC(SEL_COMMAND, MID_GNE_SPLIT_EDGE, GNEViewNet::onCmdSplitEdge),
88  FXMAPFUNC(SEL_COMMAND, MID_GNE_REVERSE_EDGE, GNEViewNet::onCmdReverseEdge),
96  FXMAPFUNC(SEL_COMMAND, MID_GNE_NODE_SHAPE, GNEViewNet::onCmdNodeShape),
97  FXMAPFUNC(SEL_COMMAND, MID_GNE_NODE_REPLACE, GNEViewNet::onCmdNodeReplace)
98 };
99 
100 // Object implementation
101 FXIMPLEMENT(GNEViewNet, GUISUMOAbstractView, GNEViewNetMap, ARRAYNUMBER(GNEViewNetMap))
102 
103 // ===========================================================================
104 // member method definitions
105 // ===========================================================================
106 GNEViewNet::GNEViewNet(FXComposite* tmpParent, FXComposite* actualParent, GUIMainWindow& app,
107  GNEViewParent* viewParent, GNENet* net, GNEUndoList* undoList,
108  FXGLVisual* glVis, FXGLCanvas* share, FXToolBar* toolBar) :
109  GUISUMOAbstractView(tmpParent, app, viewParent, net->getVisualisationSpeedUp(), glVis, share),
110  myViewParent(viewParent),
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  myAdditionalToMove(0),
119  myMoveSelection(false),
120  myAmInRectSelect(false),
121  myToolbar(toolBar),
122  myEditModesCombo(0),
123  myEditModeNames(),
124  myUndoList(undoList),
125  myCurrentPoly(0) {
126  // view must be the final member of actualParent
127  reparent(actualParent);
128 
129  buildEditModeControls();
130  myUndoList->mark();
131  myNet->setUpdateTarget(this);
132  ((GUIDanielPerspectiveChanger*)myChanger)->setDragDelay(100000000); // 100 milliseconds
133 
134  // init color schemes
135  GUIColorer laneColorer;
136  GUIColorScheme scheme = GUIColorScheme("uniform", RGBColor::BLACK, "road", true);
137  scheme.addColor(RGBColor::GREY, 1, "sidewalk");
138  scheme.addColor(RGBColor(192, 66, 44), 2, "bike lane");
139  scheme.addColor(RGBColor(200, 255, 200), 3, "green verge");
140  scheme.addColor(RGBColor(150, 200, 200), 4, "waterway");
141  scheme.addColor(RGBColor(92, 92, 92), 5, "no passenger"); // paths, service roads etc
142  laneColorer.addScheme(scheme);
143  scheme = GUIColorScheme("by selection (lane-/streetwise)", RGBColor(128, 128, 128, 255), "unselected", true);
144  scheme.addColor(RGBColor(0, 80, 180, 255), 1, "selected");
145  laneColorer.addScheme(scheme);
146  scheme = GUIColorScheme("by permission code", RGBColor(240, 240, 240), "nobody");
147  scheme.addColor(RGBColor(10, 10, 10), (SUMOReal)SVC_PASSENGER, "passenger");
148  scheme.addColor(RGBColor(128, 128, 128), (SUMOReal)SVC_PEDESTRIAN, "pedestrian");
149  scheme.addColor(RGBColor(80, 80, 80), (SUMOReal)(SVC_PEDESTRIAN | SVC_DELIVERY), "pedestrian_delivery");
150  scheme.addColor(RGBColor(192, 66, 44), (SUMOReal)SVC_BICYCLE, "bicycle");
151  scheme.addColor(RGBColor(40, 100, 40), (SUMOReal)SVC_BUS, "bus");
152  scheme.addColor(RGBColor(166, 147, 26), (SUMOReal)SVC_TAXI, "taxi");
153  scheme.addColor(RGBColor::BLACK, (SUMOReal)(SVCAll & ~SVC_NON_ROAD), "normal_road");
154  scheme.addColor(RGBColor::BLACK, (SUMOReal)(SVCAll & ~(SVC_PEDESTRIAN | SVC_NON_ROAD)), "disallow_pedestrian");
155  scheme.addColor(RGBColor(255, 206, 0), (SUMOReal)(SVCAll & ~(SVC_PEDESTRIAN | SVC_BICYCLE | SVC_MOPED | SVC_NON_ROAD)), "motorway");
156  scheme.addColor(RGBColor(150, 200, 200), (SUMOReal)SVC_SHIP, "waterway");
157  scheme.addColor(RGBColor::GREEN, (SUMOReal)SVCAll, "all");
158  laneColorer.addScheme(scheme);
159 
160  scheme = GUIColorScheme("by allowed speed (lanewise)", RGBColor::RED);
161  scheme.addColor(RGBColor::YELLOW, (SUMOReal)(30 / 3.6));
162  scheme.addColor(RGBColor::GREEN, (SUMOReal)(55 / 3.6));
163  scheme.addColor(RGBColor::CYAN, (SUMOReal)(80 / 3.6));
164  scheme.addColor(RGBColor::BLUE, (SUMOReal)(120 / 3.6));
165  scheme.addColor(RGBColor::MAGENTA, (SUMOReal)(150 / 3.6));
166  laneColorer.addScheme(scheme);
167 
168  scheme = GUIColorScheme("by lane number (streetwise)", RGBColor::RED);
169  scheme.addColor(RGBColor::BLUE, (SUMOReal)5);
170  laneColorer.addScheme(scheme);
171 
172  scheme = GUIColorScheme("by given length/geometrical length", RGBColor::BLACK);
173  scheme.addColor(RGBColor::RED, (SUMOReal)0.25);
174  scheme.addColor(RGBColor::YELLOW, (SUMOReal)0.5);
175  scheme.addColor(RGBColor(179, 179, 179, 255), (SUMOReal)1.0);
176  scheme.addColor(RGBColor::GREEN, (SUMOReal)2.0);
177  scheme.addColor(RGBColor::BLUE, (SUMOReal)4.0);
178  laneColorer.addScheme(scheme);
179  laneColorer.addScheme(GUIColorScheme("by angle", RGBColor::YELLOW, "", true));
180 
181  scheme = GUIColorScheme("by priority", RGBColor::YELLOW);
182  scheme.addColor(RGBColor::RED, (SUMOReal) - 20);
183  scheme.addColor(RGBColor::GREEN, (SUMOReal)20);
184  scheme.setAllowsNegativeValues(true);
185  laneColorer.addScheme(scheme);
186  scheme = GUIColorScheme("by height at start", RGBColor::RED);
187  scheme.addColor(RGBColor::BLUE, (SUMOReal) - 10);
188  scheme.addColor(RGBColor::YELLOW, (SUMOReal)50);
189  scheme.addColor(RGBColor::GREEN, (SUMOReal)100);
190  scheme.addColor(RGBColor::MAGENTA, (SUMOReal)200);
191  scheme.setAllowsNegativeValues(true);
192  laneColorer.addScheme(scheme);
193  scheme = GUIColorScheme("by height at segment start", RGBColor::RED);
194  scheme.addColor(RGBColor::BLUE, (SUMOReal) - 10);
195  scheme.addColor(RGBColor::YELLOW, (SUMOReal)50);
196  scheme.addColor(RGBColor::GREEN, (SUMOReal)100);
197  scheme.addColor(RGBColor::MAGENTA, (SUMOReal)200);
198  scheme.setAllowsNegativeValues(true);
199  laneColorer.addScheme(scheme);
200  scheme = GUIColorScheme("by inclination", RGBColor::GREY);
201  scheme.addColor(RGBColor::YELLOW, (SUMOReal) .1);
202  scheme.addColor(RGBColor::RED, (SUMOReal) .3);
203  scheme.addColor(RGBColor::GREEN, (SUMOReal) - .1);
204  scheme.addColor(RGBColor::BLUE, (SUMOReal) - .3);
205  scheme.setAllowsNegativeValues(true);
206  laneColorer.addScheme(scheme);
207  scheme = GUIColorScheme("by segment inclination", RGBColor::GREY);
208  scheme.addColor(RGBColor::YELLOW, (SUMOReal) .1);
209  scheme.addColor(RGBColor::RED, (SUMOReal) .3);
210  scheme.addColor(RGBColor::GREEN, (SUMOReal) - .1);
211  scheme.addColor(RGBColor::BLUE, (SUMOReal) - .3);
212  scheme.setAllowsNegativeValues(true);
213  laneColorer.addScheme(scheme);
214 
215  myVisualizationSettings->laneColorer = laneColorer;
216 
217  GUIColorer junctionColorer;
218  scheme = GUIColorScheme("uniform", RGBColor(102, 0, 0), "", true);
219  scheme.addColor(RGBColor(204, 0, 0), 1, "shape not computed");
220  scheme.addColor(RGBColor(153, 0, 0), 2, "geometry points");
221  junctionColorer.addScheme(scheme);
222  scheme = GUIColorScheme("by selection", RGBColor(128, 128, 128, 255), "unselected", true);
223  scheme.addColor(RGBColor(0, 80, 180, 255), 1, "selected");
224  junctionColorer.addScheme(scheme);
225  scheme = GUIColorScheme("by type", RGBColor::GREEN, "traffic_light", true);
226  scheme.addColor(RGBColor(0, 128, 0), 1, "traffic_light_unregulated");
227  scheme.addColor(RGBColor::YELLOW, 2, "priority");
228  scheme.addColor(RGBColor::RED, 3, "priority_stop");
229  scheme.addColor(RGBColor::BLUE, 4, "right_before_left");
230  scheme.addColor(RGBColor::CYAN, 5, "allway_stop");
231  scheme.addColor(RGBColor::GREY, 6, "district");
232  scheme.addColor(RGBColor::MAGENTA, 7, "unregulated");
233  scheme.addColor(RGBColor::BLACK, 8, "dead_end");
234  scheme.addColor(RGBColor::ORANGE, 9, "rail_signal");
235  scheme.addColor(RGBColor(192, 128, 64), 10, "zipper");
236  scheme.addColor(RGBColor(192, 255, 192), 11, "traffic_light_right_on_red");
237  scheme.addColor(RGBColor(128, 0, 128), 12, "rail_crossing"); // dark purple
238  junctionColorer.addScheme(scheme);
239  myVisualizationSettings->junctionColorer = junctionColorer;
240 }
241 
242 
244 
245 
246 void
248 
249 
250 void
252  /*
253  // build coloring tools
254  {
255  const std::vector<std::string> &names = gSchemeStorage.getNames();
256  for (std::vector<std::string>::const_iterator i=names.begin(); i!=names.end(); ++i) {
257  v.getColoringSchemesCombo().appendItem((*i).c_str());
258  if ((*i) == myVisualizationSettings->name) {
259  v.getColoringSchemesCombo().setCurrentItem(v.getColoringSchemesCombo().getNumItems()-1);
260  }
261  }
262  v.getColoringSchemesCombo().setNumVisible(5);
263  }
264  */
265 
266  // locator button for junctions
267  new FXButton(cw.getLocatorPopup(),
268  "\tLocate Junction\tLocate a junction within the network.",
270  ICON_ABOVE_TEXT | FRAME_THICK | FRAME_RAISED);
271  // locator button for edges
272  new FXButton(cw.getLocatorPopup(),
273  "\tLocate Street\tLocate a street within the network.",
275  ICON_ABOVE_TEXT | FRAME_THICK | FRAME_RAISED);
276  // locator button for tls
277  new FXButton(cw.getLocatorPopup(),
278  "\tLocate TLS\tLocate a traffic light within the network.",
280  ICON_ABOVE_TEXT | FRAME_THICK | FRAME_RAISED);
281 }
282 
283 
284 bool
285 GNEViewNet::setColorScheme(const std::string& name) {
286  if (!gSchemeStorage.contains(name)) {
287  return false;
288  }
289  if (myVisualizationChanger != 0) {
290  if (myVisualizationChanger->getCurrentScheme() != name) {
292  }
293  }
294  myVisualizationSettings = &gSchemeStorage.get(name.c_str());
295  update();
296  return true;
297 }
298 
299 
300 void
301 GNEViewNet::setStatusBarText(const std::string& text) {
302  myApp->setStatusBarText(text);
303 }
304 
305 
306 bool
308  return mySelectEdges->getCheck() != 0;
309 }
310 
311 
312 bool
314  return myExtendToEdgeNodes->getCheck() != 0;
315 }
316 
317 
318 void
320  myVisualizationSettings->selectionScale = selectionScale;
321 }
322 
323 
324 bool
326  return myChangeAllPhases->getCheck() != FALSE;
327 }
328 
329 
330 int
331 GNEViewNet::doPaintGL(int mode, const Boundary& bound) {
332  // init view settings
333  glRenderMode(mode);
334  glMatrixMode(GL_MODELVIEW);
335  glPushMatrix();
336  glDisable(GL_TEXTURE_2D);
337  glDisable(GL_ALPHA_TEST);
338  glDisable(GL_BLEND);
339  glEnable(GL_DEPTH_TEST);
340 
341  // visualize rectangular selection
342  if (myAmInRectSelect) {
343  glPushMatrix();
344  glTranslated(0, 0, GLO_MAX - 1);
346  glLineWidth(2);
347  glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
348  glBegin(GL_QUADS);
349  glVertex2d(mySelCorner1.x(), mySelCorner1.y());
350  glVertex2d(mySelCorner1.x(), mySelCorner2.y());
351  glVertex2d(mySelCorner2.x(), mySelCorner2.y());
352  glVertex2d(mySelCorner2.x(), mySelCorner1.y());
353  glEnd();
354  glPopMatrix();
355  }
356 
357  // compute lane width
359  // draw decals (if not in grabbing mode)
360  if (!myUseToolTips) {
361  drawDecals();
363  paintGLGrid();
364  }
365  }
366  glLineWidth(1);
367  glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
368  float minB[2];
369  float maxB[2];
370  minB[0] = bound.xmin();
371  minB[1] = bound.ymin();
372  maxB[0] = bound.xmax();
373  maxB[1] = bound.ymax();
375  glEnable(GL_POLYGON_OFFSET_FILL);
376  glEnable(GL_POLYGON_OFFSET_LINE);
378  int hits2 = myGrid->Search(minB, maxB, *myVisualizationSettings);
379 
380  glTranslated(0, 0, GLO_ADDITIONAL);
381  for (std::map<const GUIGlObject*, int>::iterator i = myAdditionallyDrawn.begin(); i != myAdditionallyDrawn.end(); ++i) {
382  (i->first)->drawGLAdditional(this, *myVisualizationSettings);
383  }
384  glPopMatrix();
385  return hits2;
386 }
387 
388 
389 long
390 GNEViewNet::onLeftBtnPress(FXObject* obj, FXSelector sel, void* data) {
391  FXEvent* e = (FXEvent*) data;
392  setFocus();
393  // interpret object under curser
394  if (makeCurrent()) {
395  int id = getObjectUnderCursor();
398  GNEJunction* pointed_junction = 0;
399  GNELane* pointed_lane = 0;
400  GNEEdge* pointed_edge = 0;
401  GNEPOI* pointed_poi = 0;
402  GNEPoly* pointed_poly = 0;
403  GNECrossing* pointed_crossing = 0;
404  GNEAdditional* pointed_additional = 0;
405  if (pointed) {
406  switch (pointed->getType()) {
407  case GLO_JUNCTION:
408  pointed_junction = (GNEJunction*)pointed;
409  break;
410  case GLO_EDGE:
411  pointed_edge = (GNEEdge*)pointed;
412  break;
413  case GLO_LANE:
414  pointed_lane = (GNELane*)pointed;
415  pointed_edge = &(pointed_lane->getParentEdge());
416  break;
417  case GLO_POI:
418  pointed_poi = (GNEPOI*)pointed;
419  break;
420  case GLO_POLYGON:
421  pointed_poly = (GNEPoly*)pointed;
422  break;
423  case GLO_CROSSING:
424  pointed_crossing = (GNECrossing*)pointed;
425  break;
426  case GLO_ADDITIONAL:
427  pointed_additional = (GNEAdditional*)pointed;
428  break;
429  default:
430  pointed = 0;
431  break;
432  }
433  }
434 
435  // decide what to do based on mode
436  switch (myEditMode) {
438  if ((e->state & CONTROLMASK) == 0) {
439  // allow moving when control is held down
440  if (!myUndoList->hasCommandGroup()) {
441  myUndoList->p_begin("create new edge");
442  }
443  if (!pointed_junction) {
444  pointed_junction = myNet->createJunction(getPositionInformation(), myUndoList);
445  }
446  if (myCreateEdgeSource == 0) {
447  myCreateEdgeSource = pointed_junction;
449  update();
450  } else {
451  if (myCreateEdgeSource != pointed_junction) {
452  // may fail to prevent double edges
453  GNEEdge* newEdge = myNet->createEdge(
455  if (newEdge) {
456  if (myAutoCreateOppositeEdge->getCheck()) {
457  myNet->createEdge(
458  pointed_junction, myCreateEdgeSource, myViewParent->getInspectorFrame()->getEdgeTemplate(), myUndoList, "-" + newEdge->getNBEdge()->getID());
459  }
461  if (myUndoList->hasCommandGroup()) {
462  myUndoList->p_end();
463  } else {
464  std::cout << "edge created without an open CommandGroup )-:\n";
465  }
466  if (myChainCreateEdge->getCheck()) {
467  myCreateEdgeSource = pointed_junction;
469  myUndoList->p_begin("create new edge");
470  } else {
471  myCreateEdgeSource = 0;
472  }
473  } else {
474  setStatusBarText("An edge with the same geometry already exists!");
475  }
476  } else {
477  setStatusBarText("Start- and endpoint for an edge must be distinct!");
478  }
479  update();
480  }
481  }
482  GUISUMOAbstractView::onLeftBtnPress(obj, sel, data);
483  break;
484 
485  case GNE_MODE_MOVE:
486  if (pointed_poly) {
487  myPolyToMove = pointed_poly;
489  } else if (pointed_junction) {
490  if (gSelected.isSelected(GLO_JUNCTION, pointed_junction->getGlID())) {
491  myMoveSelection = true;
492  } else {
493  myJunctionToMove = pointed_junction;
494  }
496  } else if (pointed_edge) {
497  if (gSelected.isSelected(GLO_EDGE, pointed_edge->getGlID())) {
498  myMoveSelection = true;
499  } else {
500  myEdgeToMove = pointed_edge;
501  }
503  } else if (pointed_additional) {
504  if (gSelected.isSelected(GLO_ADDITIONAL, pointed_additional->getGlID())) {
505  myMoveSelection = true;
506  } else {
507  myAdditionalToMove = pointed_additional;
508  if (myAdditionalToMove->getLane()) {
510  myUndoList->p_begin("position of " + toString(pointed_additional->getTag()));
511  } else {
512  myAdditionalFirstPosition = pointed_additional->getPositionInView();
513  myUndoList->p_begin("position of " + toString(pointed_additional->getTag()));
514  }
515  }
516  } else {
517  GUISUMOAbstractView::onLeftBtnPress(obj, sel, data);
518  }
519  update();
520  break;
521 
522  case GNE_MODE_DELETE:
523  if (pointed_junction) {
524  /*
525  if (gSelected.isSelected(GLO_JUNCTION, pointed_junction->getGlID())) {
526  deleteSelectedJunctions();
527  }
528  */
529  myNet->deleteJunction(pointed_junction, myUndoList);
530  } else if (pointed_lane && !mySelectEdges->getCheck()) {
531  myNet->deleteLane(pointed_lane, myUndoList);
532  } else if (pointed_edge) {
533  /*
534  if (gSelected.isSelected(GLO_EDGE, pointed_edge->getGlID())) {
535  deleteSelectedEdges();
536  }
537  */
539  } else if (pointed_poi) {
540  // XXX this is a dirty dirty hack! implemente GNEChange_POI
541  myNet->getShapeContainer().removePOI(pointed_poi->getMicrosimID());
542  update();
543  } else if (pointed_additional) {
544  myViewParent->getAdditionalFrame()->removeAdditional(pointed_additional);
545  update();
546  } else {
547  GUISUMOAbstractView::onLeftBtnPress(obj, sel, data);
548  }
549  break;
550 
551  case GNE_MODE_INSPECT: {
552  GNEAttributeCarrier* pointedAC = 0;
553  GUIGlObject* pointedO = 0;
554  if (pointed_junction) {
555  pointedAC = pointed_junction;
556  pointedO = pointed_junction;
557  } else if (pointed_lane) { // implies pointed_edge
558  if (selectEdges()) {
559  pointedAC = pointed_edge;
560  pointedO = pointed_edge;
561  } else {
562  pointedAC = pointed_lane;
563  pointedO = pointed_lane;
564  }
565  } else if (pointed_edge) {
566  pointedAC = pointed_edge;
567  pointedO = pointed_edge;
568  } else if (pointed_crossing) {
569  pointedAC = pointed_crossing;
570  pointedO = pointed_crossing;
571  } else if (pointed_additional) {
572  pointedAC = pointed_additional;
573  pointedO = pointed_additional;
574  }
575 
576  std::vector<GNEAttributeCarrier*> selected;
577  if (pointedO && gSelected.isSelected(pointedO->getType(), pointedO->getGlID())) {
578  std::set<GUIGlID> selectedIDs = gSelected.getSelected(pointedO->getType());
579  selected = myNet->retrieveAttributeCarriers(selectedIDs, pointedO->getType());
580  } else if (pointedAC != 0) {
581  selected.push_back(pointedAC);
582  }
583  myViewParent->getInspectorFrame()->inspect(selected);
584  GUISUMOAbstractView::onLeftBtnPress(obj, sel, data);
585  update();
586  break;
587  }
588 
589  case GNE_MODE_SELECT:
590  if (pointed_lane && selectEdges()) {
591  gSelected.toggleSelection(pointed_edge->getGlID());
592  } else if (pointed) {
593  gSelected.toggleSelection(pointed->getGlID());
594  }
595 
596  myAmInRectSelect = (((FXEvent*)data)->state & SHIFTMASK) != 0;
597  if (myAmInRectSelect) {
600  } else {
601  GUISUMOAbstractView::onLeftBtnPress(obj, sel, data);
602  }
603  update();
604  break;
605 
606  case GNE_MODE_CONNECT:
607  if (pointed_lane) {
608  const bool mayPass = (((FXEvent*)data)->state & SHIFTMASK) != 0;
609  const bool allowConflict = (((FXEvent*)data)->state & CONTROLMASK) != 0;
610  myViewParent->getConnectorFrame()->handleLaneClick(pointed_lane, mayPass, allowConflict, true);
611  update();
612  }
613  GUISUMOAbstractView::onLeftBtnPress(obj, sel, data);
614  break;
615 
616  case GNE_MODE_TLS:
617  if (pointed_junction) {
618  myViewParent->getTLSEditorFrame()->editJunction(pointed_junction);
619  update();
620  }
621  GUISUMOAbstractView::onLeftBtnPress(obj, sel, data);
622  break;
623 
624  case GNE_MODE_ADDITIONAL:
625  if (pointed_additional == NULL) {
626  GNENetElement* netElement = dynamic_cast<GNENetElement*>(pointed);
627  if (myViewParent->getAdditionalFrame()->addAdditional(netElement, this)) {
628  update();
629  }
630  }
631  GUISUMOAbstractView::onLeftBtnPress(obj, sel, data);
632  break;
633 
634  default:
635  GUISUMOAbstractView::onLeftBtnPress(obj, sel, data);
636  }
637  makeNonCurrent();
638  }
639  return 1;
640 }
641 
642 
643 long
644 GNEViewNet::onLeftBtnRelease(FXObject* obj, FXSelector sel, void* data) {
646  if (myPolyToMove) {
647  myPolyToMove = 0;
648  } else if (myJunctionToMove) {
649  // position is already up to date but we must register with myUndoList
652  }
653  myJunctionToMove = 0;
654  } else if (myEdgeToMove) {
655  // shape is already up to date but we must register with myUndoList
656  const std::string& newShape = myEdgeToMove->getAttribute(SUMO_ATTR_SHAPE);
658  myEdgeToMove = 0;
659  } else if (myAdditionalToMove) {
660  myUndoList->p_end();
661  myAdditionalToMove = 0;
662  } else if (myMoveSelection) {
663  // positions and shapes are already up to date but we must register with myUndoList
665  myMoveSelection = false;
666  } else if (myAmInRectSelect) {
667  myAmInRectSelect = false;
668  // shift held down on mouse-down and mouse-up
669  if (((FXEvent*)data)->state & SHIFTMASK) {
670  if (makeCurrent()) {
671  Boundary b;
672  b.add(mySelCorner1);
673  b.add(mySelCorner2);
675  makeNonCurrent();
676  }
677  }
678  update();
679  }
680  return 1;
681 }
682 
683 
684 long
685 GNEViewNet::onDoubleClicked(FXObject*, FXSelector, void*) {
686  // If current edit mode is INSPECT or ADDITIONAL
688  setFocus();
689  // interpret object under curser
690  if (makeCurrent()) {
691  int id = getObjectUnderCursor();
694  // If there are a pointed element an is an additional
695  if (pointed && pointed->getType() == GLO_ADDITIONAL) {
696  // Obtain pointer additional an open an AdditionalDialog if item own it
697  GNEAdditional* pointed_additional = (GNEAdditional*)pointed;
698  pointed_additional->openAdditionalDialog();
699  }
700  makeNonCurrent();
701  }
702  }
703  return 1;
704 }
705 
706 
707 long
708 GNEViewNet::onMouseMove(FXObject* obj, FXSelector sel, void* data) {
709  GUISUMOAbstractView::onMouseMove(obj, sel, data);
710  if (myPolyToMove) {
712  } else if (myJunctionToMove) {
714  } else if (myEdgeToMove) {
716  } else if (myAdditionalToMove) {
717  // If additional is placed over lane, move it across it
718  if (myAdditionalToMove->getLane()) {
721  myAdditionalFirstPosition.set(posOfMouseOverLane, 0, 0);
722  } else {
725  }
726  update();
727  } else if (myMoveSelection) {
728  Position moveTarget = getPositionInformation();
729  myNet->moveSelection(myMoveSrc, moveTarget);
730  myMoveSrc = moveTarget;
731  } else if (myAmInRectSelect) {
733  update();
734  }
735  return 1;
736 }
737 
738 
739 void
740 GNEViewNet::abortOperation(bool clearSelection) {
741  setFocus(); // steal focus from any text fields
742  if (myCreateEdgeSource) {
744  myCreateEdgeSource = 0;
745  } else if (myEditMode == GNE_MODE_SELECT) {
746  myAmInRectSelect = false;
747  if (clearSelection) {
748  gSelected.clear();
749  }
750  } else if (myEditMode == GNE_MODE_CONNECT) {
752  } else if (myEditMode == GNE_MODE_TLS) {
754  } else if (myEditMode == GNE_MODE_MOVE) {
756  }
757  myUndoList->p_abort();
758 }
759 
760 
761 void
764  setStatusBarText("Cannot delete in this mode");
765  } else {
766  myUndoList->p_begin("delete selection");
769  myUndoList->p_end();
770  }
771 }
772 
773 
774 void
776  if (myEditMode == GNE_MODE_CONNECT) {
778  } else if (myEditMode == GNE_MODE_TLS) {
780  } else if (myEditMode == GNE_MODE_MOVE && myCurrentPoly != 0) {
781  if (myCurrentPoly->getEditedJunction() != 0) {
784  update();
785  }
786  }
787 }
788 
789 
790 long
791 GNEViewNet::onCmdChangeMode(FXObject*, FXSelector, void* data) {
792  setEditMode(myEditModeNames.get((char*) data));
793  return 1;
794 }
795 
796 
797 void
799  switch (selid) {
802  break;
803  case MID_GNE_MODE_MOVE:
805  break;
806  case MID_GNE_MODE_DELETE:
808  break;
811  break;
812  case MID_GNE_MODE_SELECT:
814  break;
817  break;
818  case MID_GNE_MODE_TLS:
820  break;
823  break;
824  default:
825  FXMessageBox::error(this, MBOX_OK, "invalid edit mode", "%s", "...");
826  break;
827  }
828  myEditModesCombo->setCurrentItem(myEditModesCombo->findItem(myEditModeNames.getString(myEditMode).c_str()));
829 }
830 
831 
832 void
835 }
836 
837 
840  return myViewParent;
841 }
842 
843 
844 GNENet*
846  return myNet;
847 };
848 
849 
852  return myUndoList;
853 }
854 
855 
856 EditMode
858  return myEditMode;
859 }
860 
861 
862 bool
865 }
866 
867 
870  GNEJunction* junction = 0;
871  if (makeCurrent()) {
875  if (pointed) {
876  switch (pointed->getType()) {
877  case GLO_JUNCTION:
878  junction = (GNEJunction*)pointed;
879  break;
880  default:
881  break;
882  }
883  }
884  }
885  return junction;
886 }
887 
888 
889 
890 
891 GNEEdge*
893  GNEEdge* edge = 0;
894  if (makeCurrent()) {
898  if (pointed) {
899  switch (pointed->getType()) {
900  case GLO_EDGE:
901  edge = (GNEEdge*)pointed;
902  break;
903  case GLO_LANE:
904  edge = &(((GNELane*)pointed)->getParentEdge());
905  break;
906  default:
907  break;
908  }
909  }
910  }
911  return edge;
912 }
913 
914 
915 GNELane*
917  GNELane* lane = 0;
918  if (makeCurrent()) {
922  if (pointed) {
923  if (pointed->getType() == GLO_LANE) {
924  lane = (GNELane*)pointed;
925  }
926  }
927  }
928  return lane;
929 }
930 
931 
932 std::set<GNEEdge*>
934  std::set<GNEEdge*> result;
935  if (makeCurrent()) {
936  const std::vector<GUIGlID> ids = getObjectsAtPosition(myPopupSpot, 1.0);
937  for (std::vector<GUIGlID>::const_iterator it = ids.begin(); it != ids.end(); ++it) {
940  if (pointed) {
941  switch (pointed->getType()) {
942  case GLO_EDGE:
943  result.insert((GNEEdge*)pointed);
944  break;
945  case GLO_LANE:
946  result.insert(&(((GNELane*)pointed)->getParentEdge()));
947  break;
948  default:
949  break;
950  }
951  }
952  }
953  }
954  return result;
955 }
956 
957 
958 long
959 GNEViewNet::onCmdSplitEdge(FXObject*, FXSelector, void*) {
961  if (edge != 0) {
963  }
964  return 1;
965 }
966 
967 
968 long
969 GNEViewNet::onCmdSplitEdgeBidi(FXObject*, FXSelector, void*) {
970  std::set<GNEEdge*> edges = getEdgesAtCursorPosition(myPopupSpot);
971  if (edges.size() != 0) {
972  myNet->splitEdgesBidi(edges, (*edges.begin())->getSplitPos(myPopupSpot), myUndoList);
973  }
974  return 1;
975 }
976 
977 
978 long
979 GNEViewNet::onCmdReverseEdge(FXObject*, FXSelector, void*) {
981  if (edge != 0) {
982  myNet->reverseEdge(edge, myUndoList);
983  }
984  return 1;
985 }
986 
987 
988 long
989 GNEViewNet::onCmdAddReversedEdge(FXObject*, FXSelector, void*) {
991  if (edge != 0) {
993  }
994  return 1;
995 }
996 
997 
998 long
999 GNEViewNet::onCmdSetEdgeEndpoint(FXObject*, FXSelector, void*) {
1001  if (edge != 0) {
1003  }
1004  return 1;
1005 }
1006 
1007 
1008 long
1009 GNEViewNet::onCmdResetEdgeEndpoint(FXObject*, FXSelector, void*) {
1011  if (edge != 0) {
1013  }
1014  return 1;
1015 }
1016 
1017 
1018 long
1019 GNEViewNet::onCmdStraightenEdges(FXObject*, FXSelector, void*) {
1021  if (edge != 0) {
1022  if (gSelected.isSelected(GLO_EDGE, edge->getGlID())) {
1023  myUndoList->p_begin("straighten selected edges");
1024  std::vector<GNEEdge*> edges = myNet->retrieveEdges(true);
1025  for (std::vector<GNEEdge*>::iterator it = edges.begin(); it != edges.end(); it++) {
1026  (*it)->setAttribute(SUMO_ATTR_SHAPE, "", myUndoList);
1027  }
1028  myUndoList->p_end();
1029  } else {
1030  myUndoList->p_begin("straighten edge");
1032  myUndoList->p_end();
1033  }
1034  }
1035  return 1;
1036 }
1037 
1038 
1039 long
1040 GNEViewNet::onCmdSimplifyShape(FXObject*, FXSelector, void*) {
1041  if (myCurrentPoly != 0) {
1043  update();
1044  }
1045  return 1;
1046 }
1047 
1048 
1049 long
1050 GNEViewNet::onCmdDeleteGeometry(FXObject*, FXSelector, void*) {
1051  if (myCurrentPoly != 0) {
1053  update();
1054  }
1055  return 1;
1056 }
1057 
1058 
1059 long
1060 GNEViewNet::onCmdDuplicateLane(FXObject*, FXSelector, void*) {
1062  if (lane != 0) {
1063  if (gSelected.isSelected(GLO_LANE, lane->getGlID())) {
1064  myUndoList->p_begin("duplicate selected lanes");
1065  std::vector<GNELane*> lanes = myNet->retrieveLanes(true);
1066  for (std::vector<GNELane*>::iterator it = lanes.begin(); it != lanes.end(); it++) {
1068  }
1069  myUndoList->p_end();
1070  } else {
1071  myUndoList->p_begin("duplicate lane");
1072  myNet->duplicateLane(lane, myUndoList);
1073  myUndoList->p_end();
1074  }
1075  }
1076  return 1;
1077 }
1078 
1079 
1080 long
1081 GNEViewNet::onCmdNodeShape(FXObject*, FXSelector, void*) {
1083  if (junction != 0) {
1084  if (myCurrentPoly == 0) {
1085  if (junction->getNBNode()->getShape().size() > 1) {
1087  //std::cout << junction->getNBNode()->getShape() << "\n";
1088  junction->getNBNode()->computeNodeShape(-1);
1089  if (myCurrentPoly != 0) {
1091  delete myCurrentPoly;
1092  myCurrentPoly = 0;
1093  }
1094  PositionVector shape = junction->getNBNode()->getShape();
1095  shape.closePolygon();
1096  myCurrentPoly = new GNEPoly(myNet, junction, "node_shape:" + junction->getMicrosimID(), "node shape",
1097  shape, false, RGBColor::GREEN, GLO_POLYGON);
1100 
1101  update();
1102  }
1103  } else {
1106  update();
1107  }
1108  }
1109  return 1;
1110 }
1111 
1112 
1113 void
1115  if (myCurrentPoly != 0) {
1117  delete myCurrentPoly;
1118  myCurrentPoly = 0;
1119  }
1120 }
1121 
1122 
1123 long
1124 GNEViewNet::onCmdNodeReplace(FXObject*, FXSelector, void*) {
1126  if (junction != 0) {
1128  update();
1129  }
1130  return 1;
1131 }
1132 
1133 // ===========================================================================
1134 // private
1135 // ===========================================================================
1136 
1137 void
1139  setStatusBarText("");
1140  abortOperation(false);
1141  if (mode == myEditMode) {
1142  setStatusBarText("Mode already selected");
1143  } else {
1145  myEditMode = mode;
1146  switch (mode) {
1147  case GNE_MODE_CONNECT:
1148  case GNE_MODE_TLS:
1149  // modes which depend on computed data
1151  break;
1152  default:
1153  break;
1154  }
1155  }
1157 }
1158 
1159 
1160 void
1162  // initialize mappings
1163  myEditModeNames.insert("(e) Create Edge", GNE_MODE_CREATE_EDGE);
1164  myEditModeNames.insert("(m) Move", GNE_MODE_MOVE);
1165  myEditModeNames.insert("(d) Delete", GNE_MODE_DELETE);
1166  myEditModeNames.insert("(i) Inspect", GNE_MODE_INSPECT);
1167  myEditModeNames.insert("(s) Select", GNE_MODE_SELECT);
1168  myEditModeNames.insert("(c) Connect", GNE_MODE_CONNECT);
1169  myEditModeNames.insert("(t) Traffic Lights", GNE_MODE_TLS);
1170  myEditModeNames.insert("(a) Additionals", GNE_MODE_ADDITIONAL);
1171 
1172  // initialize combo for modes
1174  new FXComboBox(myToolbar, 12, this, MID_GNE_MODE_CHANGE,
1175  FRAME_SUNKEN | LAYOUT_LEFT | LAYOUT_TOP | COMBOBOX_STATIC | LAYOUT_CENTER_Y);
1176 
1177  std::vector<std::string> names = myEditModeNames.getStrings();
1178  for (std::vector<std::string>::const_iterator it = names.begin(); it != names.end(); it++) {
1179  myEditModesCombo->appendItem(it->c_str());
1180  }
1181  myEditModesCombo->setNumVisible((int)myEditModeNames.size());
1182 
1183  // initialize mode specific controls
1184  myChainCreateEdge = new FXMenuCheck(myToolbar, "chain\t\tCreate consecutive edges with a single click (hit ESC to cancel chain).", this, 0);
1185  myAutoCreateOppositeEdge = new FXMenuCheck(myToolbar,
1186  "two-way\t\tAutomatically create an edge in the opposite direction", this, 0);
1187  mySelectEdges = new FXMenuCheck(myToolbar, "select edges\t\tToggle whether clicking should select edges or lanes", this, 0);
1188  mySelectEdges->setCheck();
1189  myExtendToEdgeNodes = new FXMenuCheck(myToolbar, "auto-select nodes\t\tToggle whether selecting multiple edges should automatically select their nodes", this, 0);
1190 
1191  myWarnAboutMerge = new FXMenuCheck(myToolbar, "ask for merge\t\tAsk for confirmation before merging junctions.", this, 0);
1192  myWarnAboutMerge->setCheck();
1193 
1194  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);
1195  myChangeAllPhases->setCheck(false);
1196 }
1197 
1198 
1199 void
1201  // MAGIC modifier to avoid flicker. at least it is consistent for move AND
1202  // zoom. Probably has to do with spacing
1203  const int addChange = 4;
1204 
1205  // hide all controls
1206  myChainCreateEdge->hide();
1207  myAutoCreateOppositeEdge->hide();
1208  mySelectEdges->hide();
1209  myExtendToEdgeNodes->hide();
1210  myChangeAllPhases->hide();
1211  myWarnAboutMerge->hide();
1212  int widthChange = 0;
1213  // Close all Frames
1214  if (myViewParent->getInspectorFrame()->shown()) {
1215  widthChange += myViewParent->getInspectorFrame()->getWidth() + addChange;
1217  }
1218  if (myViewParent->getSelectorFrame()->shown()) {
1219  widthChange += myViewParent->getSelectorFrame()->getWidth() + addChange;
1221  }
1222  if (myViewParent->getConnectorFrame()->shown()) {
1223  widthChange += myViewParent->getConnectorFrame()->getWidth() + addChange;
1225  }
1226  if (myViewParent->getTLSEditorFrame()->shown()) {
1227  widthChange += myViewParent->getTLSEditorFrame()->getWidth() + addChange;
1229  }
1230  if (myViewParent->getAdditionalFrame()->shown()) {
1231  widthChange += myViewParent->getAdditionalFrame()->getWidth() + addChange;
1233  }
1234  // enable selected controls
1235  switch (myEditMode) {
1236  case GNE_MODE_CREATE_EDGE:
1237  myChainCreateEdge->show();
1238  myAutoCreateOppositeEdge->show();
1239  break;
1240  case GNE_MODE_DELETE:
1241  mySelectEdges->show();
1242  break;
1243  case GNE_MODE_INSPECT:
1244  widthChange -= myViewParent->getInspectorFrame()->getWidth() + addChange;
1246  mySelectEdges->show();
1247  break;
1248  case GNE_MODE_SELECT:
1249  widthChange -= myViewParent->getSelectorFrame()->getWidth() + addChange;
1251  mySelectEdges->show();
1252  myExtendToEdgeNodes->show();
1253  break;
1254  case GNE_MODE_MOVE:
1255  myWarnAboutMerge->show();
1256  break;
1257  case GNE_MODE_CONNECT:
1258  widthChange -= myViewParent->getConnectorFrame()->getWidth() + addChange;
1260  break;
1261  case GNE_MODE_TLS:
1262  widthChange -= myViewParent->getTLSEditorFrame()->getWidth() + addChange;
1264  myChangeAllPhases->show();
1265  break;
1266  case GNE_MODE_ADDITIONAL:
1267  widthChange -= myViewParent->getAdditionalFrame()->getWidth() + addChange;
1269  break;
1270  default:
1271  break;
1272  }
1273  myChanger->changeCanvassLeft(widthChange);
1274  myToolbar->recalc();
1275  recalc();
1276  onPaint(0, 0, 0); // force repaint because different modes draw different things
1277  update();
1278 }
1279 
1280 
1281 void
1283  myUndoList->p_begin("delete selected junctions");
1284  std::vector<GNEJunction*> junctions = myNet->retrieveJunctions(true);
1285  for (std::vector<GNEJunction*>::iterator it = junctions.begin(); it != junctions.end(); it++) {
1287  }
1288  myUndoList->p_end();
1289 }
1290 
1291 
1292 void
1294  if (mySelectEdges->getCheck()) {
1295  myUndoList->p_begin("delete selected edges");
1296  std::vector<GNEEdge*> edges = myNet->retrieveEdges(true);
1297  for (std::vector<GNEEdge*>::iterator it = edges.begin(); it != edges.end(); it++) {
1298  myNet->deleteEdge(*it, myUndoList);
1299  }
1300  } else {
1301  myUndoList->p_begin("delete selected lanes");
1302  std::vector<GNELane*> lanes = myNet->retrieveLanes(true);
1303  for (std::vector<GNELane*>::iterator it = lanes.begin(); it != lanes.end(); it++) {
1304  myNet->deleteLane(*it, myUndoList);
1305  }
1306  }
1307  myUndoList->p_end();
1308 }
1309 
1310 
1311 bool
1313  const Position& newPos = moved->getNBNode()->getPosition();
1314  GNEJunction* mergeTarget = 0;
1315  // try to find another junction to merge with
1316  if (makeCurrent()) {
1317  Boundary selection;
1318  selection.add(newPos);
1319  selection.grow(0.1);
1320  const std::vector<GUIGlID> ids = getObjectsInBoundary(selection);
1321  GUIGlObject* object = 0;
1322  for (std::vector<GUIGlID>::const_iterator it = ids.begin(); it != ids.end(); it++) {
1323  GUIGlID id = *it;
1324  if (id == 0) {
1325  continue;
1326  }
1328  if (!object) {
1329  throw ProcessError("Unkown object in selection (id=" + toString(id) + ").");
1330  }
1331  if (object->getType() == GLO_JUNCTION && id != moved->getGlID()) {
1332  mergeTarget = dynamic_cast<GNEJunction*>(object);
1333  }
1335  }
1336  }
1337  if (mergeTarget) {
1338  // optionally ask for confirmation
1339  if (myWarnAboutMerge->getCheck()) {
1340  FXuint answer = FXMessageBox::question(this, MBOX_YES_NO,
1341  "Confirm Junction Merger", "%s",
1342  ("Do you wish to merge junctions '" + moved->getMicrosimID() +
1343  "' and '" + mergeTarget->getMicrosimID() + "'?\n" +
1344  "('" + moved->getMicrosimID() +
1345  "' will be eliminated and its roads added to '" +
1346  mergeTarget->getMicrosimID() + "')").c_str());
1347  if (answer != 1) { //1:yes, 2:no, 4:esc
1348  return false;
1349  }
1350  }
1351  myNet->mergeJunctions(moved, mergeTarget, myUndoList);
1352  return true;
1353  } else {
1354  return false;
1355  }
1356 }
1357 
1358 
1359 void
1361  switch (myEditMode) {
1362  case GNE_MODE_INSPECT:
1363  myViewParent->getInspectorFrame()->update();
1364  break;
1365  default:
1366  break;
1367  }
1368 }
1369 /****************************************************************************/
GNEJunction * splitEdge(GNEEdge *edge, const Position &pos, GNEUndoList *undoList, GNEJunction *newJunction=0)
split edge at position by inserting a new junction
Definition: GNENet.cpp:409
long onCmdResetEdgeEndpoint(FXObject *, FXSelector, void *)
restore geometry endpoint to node position
long onCmdDeleteGeometry(FXObject *, FXSelector, void *)
delete the closes geometry point
GNEViewParent * myViewParent
view parent
Definition: GNEViewNet.h:230
virtual void openAdditionalDialog()
open Additional Dialog
void paintGLGrid()
paints a grid
EditMode getCurrentEditMode() const
get the current edit mode
Definition: GNEViewNet.cpp:857
std::vector< GNEJunction * > retrieveJunctions(bool onlySelected=false)
return all junctions
Definition: GNENet.cpp:678
a tl-logic
static const RGBColor BLUE
Definition: RGBColor.h:191
bool showLockIcon() const
check if lock icon should be visible
Definition: GNEViewNet.cpp:863
ShapeContainer & getShapeContainer()
get shape container
Definition: GNENet.cpp:1040
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:643
FXMenuCheck * mySelectEdges
menu check to select only edges
Definition: GNEViewNet.h:242
bool selectEdges()
whether inspection, selection and inversion should apply to edges or to lanes
Definition: GNEViewNet.cpp:307
GNEJunction * getJunctionAtCursorPosition(Position &pos)
try to retrieve a junction at the given position
Definition: GNEViewNet.cpp:869
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
Position myPopupSpot
Poput spot.
Definition: GNEViewNet.h:316
GUICompleteSchemeStorage gSchemeStorage
void abortOperation(bool clearSelection=true)
abort current edition operation
Definition: GNEViewNet.cpp:740
void deleteSelectedJunctions()
delete all currently selected junctions
const SUMOReal SUMO_const_laneWidth
Definition: StdDefs.h:49
bool setColorScheme(const std::string &name)
set color schieme
Definition: GNEViewNet.cpp:285
is a pedestrian
a polygon
mode for moving things
Definition: GNEViewNet.h:52
bool changeAllPhases() const
change all phases
Definition: GNEViewNet.cpp:325
SUMOReal nearest_offset_to_point2D(const Position &p, bool perpendicular=true) const
return the nearest offest to point 2D
void markPopupPosition()
store the position where a popup-menu was requested
Definition: GNEViewNet.cpp:833
long onCmdDuplicateLane(FXObject *, FXSelector, void *)
duplicate selected lane
void show()
show Frame
StringBijection< EditMode > myEditModeNames
since we cannot switch on strings we map the mode names to an enum
Definition: GNEViewNet.h:308
long onMouseMove(FXObject *, FXSelector, void *)
called when user moves mouse
Definition: GNEViewNet.cpp:708
void markAsCreateEdgeSource()
marks as first junction in createEdge-mode
The main window of the Netedit.
SUMORTree * myGrid
The visualization speed-up.
virtual void changeCanvassLeft(int change)=0
GNEEdge * getEdgeTemplate() const
get the template edge (to copy attributes from)
void setAllowsNegativeValues(bool value)
Locate TLS - button.
Definition: GUIAppEnum.h:179
void toggleSelection(GUIGlID id)
Toggles selection of an object.
virtual long onMouseMove(FXObject *, FXSelector, void *)
FXMenuCheck * myChainCreateEdge
whether the endpoint for a created edge should be set as the new source
Definition: GNEViewNet.h:256
SUMOReal ymin() const
Returns minimum y-coordinate.
Definition: Boundary.cpp:124
mode for deleting things
Definition: GNEViewNet.h:54
Definition: GNEPOI.h:51
void show()
show Frame
long onCmdSplitEdge(FXObject *, FXSelector, void *)
split edge at cursor position
Definition: GNEViewNet.cpp:959
const PositionVector & getShape() const
Returns whether the shape of the polygon.
Definition: Polygon.h:87
vehicle is a bicycle
void show()
show Frame
GUIMainWindow * myApp
The application.
FXMenuCheck * myChangeAllPhases
menu check to set change all phases
Definition: GNEViewNet.h:248
vehicle is a small delivery vehicle
void setEditMode(EditMode mode)
set edit mode
void hide()
hide Frame
Position moveGeometry(const Position &oldPos, const Position &newPos, bool relative=false)
change the edge geometry It is up to the Edge to decide whether an new geometry node should be genera...
Definition: GNEEdge.cpp:245
void computeEverything(GNEApplicationWindow *window, bool force=false)
Definition: GNENet.cpp:799
SUMOReal xmin() const
Returns minimum x-coordinate.
Definition: Boundary.cpp:112
Position mySelCorner2
second corner of the rectangle-selection
Definition: GNEViewNet.h:296
GNEAdditionalFrame * getAdditionalFrame() const
get frame for GNE_MODE_ADDITIONAL
classes which (normally) do not drive on normal roads
void removeAdditionalGLObject(GUIGlObject *o)
Removes an additional object (detector/shape/trigger) from being visualised.
Definition: SUMORTree.h:141
mode for editing tls
Definition: GNEViewNet.h:62
NBNode * getNBNode() const
Return net build node.
void reverseEdge(GNEEdge *edge, GNEUndoList *undoList)
reverse edge
Definition: GNENet.cpp:474
void setSelectionScaling(SUMOReal selectionScale)
set selection scaling
Definition: GNEViewNet.cpp:319
void setLineWidth(SUMOReal lineWidth)
set a new shape and update the tesselation
Definition: GUIPolygon.h:116
long onCmdNodeShape(FXObject *, FXSelector, void *)
input custom node shape
static const RGBColor ORANGE
Definition: RGBColor.h:195
std::string getAttribute(SumoXMLAttr key) const
Definition: GNEEdge.cpp:436
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:463
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:86
FXComboBox * myEditModesCombo
combo box for selecting the edit mode
Definition: GNEViewNet.h:305
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition: GNELane.h:54
void editJunction(GNEJunction *junction)
edits the traffic light for the given junction
GNEEdge * createEdge(GNEJunction *src, GNEJunction *dest, GNEEdge *tpl, GNEUndoList *undoList, const std::string &suggestedName="", bool wasSplit=false, bool allowDuplicateGeom=false)
creates a new edge (unless an edge with the same geometry already exists)
Definition: GNENet.cpp:246
int editMode
the current NETEDIT mode (temporary)
void p_begin(const std::string &description)
Begin undo command sub-group. This begins a new group of commands that are treated as a single comman...
Definition: GNEUndoList.cpp:86
void setEditModeFromHotkey(FXushort selid)
sets edit mode (from hotkey)
Definition: GNEViewNet.cpp:798
bool addAdditional(GNENetElement *netElement, GUISUMOAbstractView *parent)
add additional element
long onCmdSetEdgeEndpoint(FXObject *, FXSelector, void *)
set non-default geometry endpoint
Definition: GNEViewNet.cpp:999
static const RGBColor BLACK
Definition: RGBColor.h:197
const SVCPermissions SVCAll
GUIDialog_ViewSettings * myVisualizationChanger
Visualization changer.
GNEViewParent * getViewParent() const
get the net object
Definition: GNEViewNet.cpp:839
void deleteEdge(GNEEdge *edge, GNEUndoList *undoList)
removes edge
Definition: GNENet.cpp:326
void updateControls()
update control contents after undo/redo or recompute
EditMode myPreviousEditMode
the previous edit mode used for toggling
Definition: GNEViewNet.h:239
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.
SUMOReal xmax() const
Returns maximum x-coordinate.
Definition: Boundary.cpp:118
GNEEdge * myEdgeToMove
the edge of which geometry is being moved
Definition: GNEViewNet.h:266
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:791
A single child window which contains a view of the simulation area.
Definition: GNEViewParent.h:69
SUMOReal scale
information about a lane&#39;s width (temporary, used for a single view)
GNEUndoList * getUndoList() const
get the undoList object
Definition: GNEViewNet.cpp:851
std::map< const GUIGlObject *, int > myAdditionallyDrawn
List of objects for which GUIGlObject::drawGLAdditional is called.
std::vector< std::string > getStrings() const
bool myMoveSelection
whether a selection is being moved
Definition: GNEViewNet.h:281
void hide()
hidde additional frame
void hide()
hide Frame
virtual const std::string & getMicrosimID() const
Returns the id of the object as known to microsim.
void handleLaneClick(GNELane *lane, bool mayDefinitelyPass, bool allowConflict, bool toggle)
either sets the current lane or toggles the connection of the current lane to this lane (if they shar...
const std::string & getID() const
Returns the id.
Definition: Named.h:66
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.
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:933
long onLeftBtnPress(FXObject *, FXSelector, void *)
overloaded handlers
Definition: GNEViewNet.cpp:390
const Position & getPosition() const
Returns the position of this node.
Definition: NBNode.h:228
long onCmdSimplifyShape(FXObject *, FXSelector, void *)
simply shape of current polygon
int addColor(const T &color, const SUMOReal threshold, const std::string &name="")
static const RGBColor GREEN
Definition: RGBColor.h:190
static const RGBColor GREY
Definition: RGBColor.h:198
virtual long onPaint(FXObject *, FXSelector, void *)
const std::set< GUIGlID > & getSelected() const
Returns the list of ids of all selected objects.
GNEPoly * myCurrentPoly
current polygon
Definition: GNEViewNet.h:319
SUMOReal selectionScale
the current selection scaling in NETEDIT (temporary)
FXMenuCheck * myWarnAboutMerge
whether we should warn about merging junctions
Definition: GNEViewNet.h:284
mode for inspecting object attributes
Definition: GNEViewNet.h:56
void setCurrentScheme(const std::string &)
Sets the named scheme as the current.
virtual void setStatusBarText(const std::string &)
Definition: GUIMainWindow.h:79
GNEAdditional * myAdditionalToMove
the stoppingPlace element which shape is being moved
Definition: GNEViewNet.h:272
virtual GNELane * getLane() const
get lane of additional, or NULL if additional isn&#39;t placed over a Lane
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
Definition: GLHelper.cpp:443
long onCmdCancel(FXObject *, FXSelector, void *)
Called when the user presses the Cancel-button.
This object is responsible for drawing a shape and for supplying a a popup menu. Messages are routete...
Definition: GNECrossing.h:51
GNEEdge & getParentEdge()
Returns underlying parent edge.
Definition: GNELane.cpp:870
virtual ~GNEViewNet()
destructor
Definition: GNEViewNet.cpp:243
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:46
void p_end()
End undo command sub-group. If the sub-group is still empty, it will be deleted; otherwise, the sub-group will be added as a new command into parent group. A matching begin() must have been called previously.
Definition: GNEUndoList.cpp:93
virtual bool removePOI(const std::string &id)
Removes a PoI from the container.
A list of positions.
Locate edge - button.
Definition: GUIAppEnum.h:173
FXToolBar * myToolbar
Definition: GNEViewNet.h:302
void deleteLane(GNELane *lane, GNEUndoList *undoList)
removes lane
Definition: GNENet.cpp:361
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:401
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.
GUIVisualizationSettings & get(const std::string &name)
Returns the named scheme.
void inspect(const std::vector< GNEAttributeCarrier * > &ACs)
Inspect the given multi-selection.
void removeAdditional(GNEAdditional *additional)
remove an additional element previously added
const std::string & getString(const T key) const
long onCmdSplitEdgeBidi(FXObject *, FXSelector, void *)
split edge at cursor position
Definition: GNEViewNet.cpp:969
bool autoSelectNodes()
whether to autoselect nodes or to lanes
Definition: GNEViewNet.cpp:313
static const RGBColor MAGENTA
Definition: RGBColor.h:194
Position myAdditionalFirstPosition
variable to save the firstposition of the additional before move
Definition: GNEViewNet.h:275
mode for selecting objects
Definition: GNEViewNet.h:58
void removeCurrentPoly()
remove the currently edited polygon
GNEJunction * myJunctionToMove
the Junction to be moved.
Definition: GNEViewNet.h:263
GNELane * getLaneAtCurserPosition(Position &pos)
try to retrieve a lane at the given position
Definition: GNEViewNet.cpp:916
Locate junction - button.
Definition: GUIAppEnum.h:171
std::vector< GNEAttributeCarrier * > retrieveAttributeCarriers(const std::set< GUIGlID > &ids, GUIGlObjectType type)
get the attribute carriers based on GlIDs
Definition: GNENet.cpp:698
std::string getCurrentScheme() const
Returns the name of the currently chosen scheme.
GNEInspectorFrame * getInspectorFrame() const
get frame for GNE_MODE_INSPECT
GNEConnectorFrame * getConnectorFrame() const
get frame for GNE_MODE_CONNECT
void unMarkAsCreateEdgeSource()
removes mark as first junction in createEdge-mode
void moveSelection(const Position &moveSrc, const Position &moveDest)
move all selected junctions and edges
Definition: GNENet.cpp:986
GNEJunction * createJunction(const Position &pos, GNEUndoList *undoList)
creates a new junction
Definition: GNENet.cpp:235
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
Definition: ToString.h:55
Position mySelCorner1
firstcorner of the rectangle-selection
Definition: GNEViewNet.h:293
void p_abort()
reverts and discards ALL active command groups
const PositionVector & getShape() const
retrieve the junction shape
Definition: NBNode.cpp:1699
GUIPerspectiveChanger * myChanger
The perspective changer.
bool myUseToolTips
use tool tips
EditMode
Definition: GNEViewNet.h:46
SUMORTree & getVisualisationSpeedUp()
Returns the RTree used for visualisation speed-up.
Definition: GNENet.cpp:223
vehicle is a passenger car (a "normal" car)
void doInit()
called after some features are already initialized
Definition: GNEViewNet.cpp:247
is an arbitrary ship
FXMenuCheck * myAutoCreateOppositeEdge
Definition: GNEViewNet.h:257
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:919
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:54
unsigned int GUIGlID
Definition: GUIGlObject.h:50
FXbool makeCurrent()
A reimplementation due to some internal reasons.
long onCmdOK(FXObject *, FXSelector, void *)
vehicle is a taxi
compound additional
virtual long onLeftBtnRelease(FXObject *, FXSelector, void *)
vehicle is a bus
void add(SUMOReal x, SUMOReal y)
Makes the boundary include the given coordinate.
Definition: Boundary.cpp:76
void hide()
hide Frame
static const RGBColor YELLOW
Definition: RGBColor.h:192
Boundary & grow(SUMOReal by)
extends the boundary by the given amount
Definition: Boundary.cpp:201
static const RGBColor RED
Definition: RGBColor.h:189
const PositionVector & getShape() const
returns the shape of the lane
Definition: GNELane.cpp:456
FXMenuCheck * myExtendToEdgeNodes
menu check to extend to edge nodes
Definition: GNEViewNet.h:245
static const RGBColor CYAN
Definition: RGBColor.h:193
bool hasCommandGroup() const
Check if undoList has command group.
GUIVisualizationSettings * myVisualizationSettings
visualization settings
void show()
show additional frame
std::vector< GNEEdge * > retrieveEdges(bool onlySelected=false)
return all edges
Definition: GNENet.cpp:631
Position myMoveSrc
position from which to move edge geometry
Definition: GNEViewNet.h:278
void addAdditionalGLObject(GUIGlObject *o)
Adds an additional object (detector/shape/trigger) for visualisation.
Definition: SUMORTree.h:129
An Element which don&#39;t belongs to GNENet but has influency in the simulation.
Definition: GNEAdditional.h:63
SUMOReal m2p(SUMOReal meter) const
meter-to-pixels conversion method
long onCmdOK(FXObject *, FXSelector, void *)
long onCmdReverseEdge(FXObject *, FXSelector, void *)
reverse edge
Definition: GNEViewNet.cpp:979
SUMOReal y() const
Returns the y-position.
Definition: Position.h:68
long onCmdCancel(FXObject *, FXSelector, void *)
Called when the user presses the Cancel-button discards any connection modifications.
int doPaintGL(int mode, const Boundary &bound)
do paintGL
Definition: GNEViewNet.cpp:331
GNEJunction * myCreateEdgeSource
source junction for new edge 0 if no edge source is selected an existing (or newly created) junction ...
Definition: GNEViewNet.h:253
void move(Position pos)
reposition the node at pos and informs the edges
void set(SUMOReal x, SUMOReal y)
Definition: Position.h:78
an edge
void simplifyShape()
replace the current shape with a rectangle
Definition: GNEPoly.cpp:140
GNENet * getNet() const
get the net object
Definition: GNEViewNet.cpp:845
void clear()
Clears the list of selected objects.
void deleteJunction(GNEJunction *junction, GNEUndoList *undoList)
removes junction and all incident edges
Definition: GNENet.cpp:301
void handleIDs(std::vector< GUIGlID > ids, bool selectEdges, SetOperation setop=SET_DEFAULT)
apply list of ids to the current selection according to SetOperation,
bool showGrid
Information whether a grid shall be shown.
void drawDecals()
Draws the stored decals.
void show()
show Frame
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
SumoXMLTag getTag() const
get Tag assigned to this object
GNEEdge * addReversedEdge(GNEEdge *edge, GNEUndoList *undoList)
add reversed edge
Definition: GNENet.cpp:485
void setStatusBarText(const std::string &text)
set staturBar text
Definition: GNEViewNet.cpp:301
#define SUMOReal
Definition: config.h:213
Mode for editing additionals.
Definition: GNEViewNet.h:64
virtual void buildViewToolBars(GUIGlChildWindow &)
builds the view toolbars
Definition: GNEViewNet.cpp:251
void setEndpoint(Position pos, GNEUndoList *undoList)
makes pos the new geometry endpoint at the appropriate end
Definition: GNEEdge.cpp:328
SUMOReal ymax() const
Returns maximum y-coordinate.
Definition: Boundary.cpp:130
GUIPropertyScheme< RGBColor > GUIColorScheme
static const RGBColor selectionColor
color of selection
Definition: GNENet.h:95
empty max
void unblockObject(GUIGlID id)
Marks an object as unblocked.
int size() const
long onCmdStraightenEdges(FXObject *, FXSelector, void *)
makes selected edges straight
mode for connecting lanes
Definition: GNEViewNet.h:60
void hide()
hide Frame
mode for creating new edges
Definition: GNEViewNet.h:50
NBEdge * getNBEdge()
returns the internal NBEdge
Definition: GNEEdge.cpp:225
GNETLSEditorFrame * getTLSEditorFrame() const
get frame for GNE_MODE_TLS
long onDoubleClicked(FXObject *, FXSelector, void *)
called when user press mouse&#39;s left button two times
Definition: GNEViewNet.cpp:685
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:518
GNEEdge * getEdgeAtCursorPosition(Position &pos)
try to retrieve an edge at the given position
Definition: GNEViewNet.cpp:892
long onCmdNodeReplace(FXObject *, FXSelector, void *)
replace node by geometry
void hotkeyDel()
handle del keypress
Definition: GNEViewNet.cpp:762
long onCmdAddReversedEdge(FXObject *, FXSelector, void *)
add reversed edge
Definition: GNEViewNet.cpp:989
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:153
bool myAmInRectSelect
whether we have started rectangle-selection
Definition: GNEViewNet.h:290
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
Definition: GNEEdge.cpp:502
GUISelectedStorage gSelected
A global holder of selected objects.
GNENet * myNet
we are not responsible for deletion
Definition: GNEViewNet.h:233
void hotkeyEnter()
handle enter keypress
Definition: GNEViewNet.cpp:775
void resetEndpoint(const Position &pos, GNEUndoList *undoList)
restores the endpoint to the junction position at the appropriate end
Definition: GNEEdge.cpp:351
static FXIcon * getIcon(GUIIcon which)
returns a icon previously defined in the enum GUIIcon
long onLeftBtnRelease(FXObject *, FXSelector, void *)
called when user releases mouse&#39;s left button
Definition: GNEViewNet.cpp:644
Position getSplitPos(const Position &clickPos)
Definition: GNEEdge.cpp:231
void computeNodeShape(SUMOReal mismatchThreshold)
Compute the junction shape for this node.
Definition: NBNode.cpp:767
void duplicateLane(GNELane *lane, GNEUndoList *undoList)
duplicates lane
Definition: GNENet.cpp:389
void deleteSelectedEdges()
delete all currently selected edges
GNEUndoList * myUndoList
a reference to the undolist maintained in the application
Definition: GNEViewNet.h:313
EditMode myEditMode
the current edit mode
Definition: GNEViewNet.h:236
std::vector< GUIGlID > getObjectsInBoundary(const Boundary &bound)
returns the ids of all objects in the given boundary
virtual void moveAdditional(SUMOReal posx, SUMOReal posy, GNEUndoList *undoList)=0
change the position of the additional geometry
FXPopup * getLocatorPopup()
GNESelectorFrame * getSelectorFrame() const
get frame for GNE_MODE_SELECT
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:269
void finishMoveSelection(GNEUndoList *undoList)
register changes to junction and edge positions with the undoList
Definition: GNENet.cpp:1016
virtual Position getPositionInView() const =0
Returns position of additional in view.