Eclipse SUMO - Simulation of Urban MObility
GUISUMOAbstractView.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
18 // The base class for a view
19 /****************************************************************************/
20 
21 
22 // ===========================================================================
23 // included modules
24 // ===========================================================================
25 #include <config.h>
26 
27 #include <iostream>
28 #include <utility>
29 #include <cmath>
30 #include <cassert>
31 #include <limits>
32 #include <fxkeys.h>
33 #ifdef HAVE_GL2PS
34 #include <gl2ps.h>
35 #endif
39 #include <utils/common/RGBColor.h>
40 #include <utils/common/ToString.h>
43 #include <utils/common/SysUtils.h>
48 #include <utils/gui/div/GLHelper.h>
56 #include <utils/geom/GeomHelper.h>
61 
62 #include "GUISUMOAbstractView.h"
63 #include "GUIMainWindow.h"
64 #include "GUIGlChildWindow.h"
66 #include "GUIDialog_EditViewport.h"
67 
68 #ifdef HAVE_GDAL
69 #if __GNUC__ > 3
70 #pragma GCC diagnostic push
71 #pragma GCC diagnostic ignored "-Wpedantic"
72 #endif
73 #include <gdal_priv.h>
74 #if __GNUC__ > 3
75 #pragma GCC diagnostic pop
76 #endif
77 #endif
78 
79 
80 // ===========================================================================
81 // debug constants
82 // ===========================================================================
83 //#define DEBUG_SNAPSHOT
84 
85 // ===========================================================================
86 // static members
87 // ===========================================================================
88 
89 const double GUISUMOAbstractView::SENSITIVITY = 0.1; // meters
90 
91 
92 // ===========================================================================
93 // member method definitions
94 // ===========================================================================
95 /* -------------------------------------------------------------------------
96  * GUISUMOAbstractView - FOX callback mapping
97  * ----------------------------------------------------------------------- */
98 FXDEFMAP(GUISUMOAbstractView) GUISUMOAbstractViewMap[] = {
99  FXMAPFUNC(SEL_CONFIGURE, 0, GUISUMOAbstractView::onConfigure),
100  FXMAPFUNC(SEL_PAINT, 0, GUISUMOAbstractView::onPaint),
101  FXMAPFUNC(SEL_LEFTBUTTONPRESS, 0, GUISUMOAbstractView::onLeftBtnPress),
102  FXMAPFUNC(SEL_LEFTBUTTONRELEASE, 0, GUISUMOAbstractView::onLeftBtnRelease),
103  FXMAPFUNC(SEL_MIDDLEBUTTONPRESS, 0, GUISUMOAbstractView::onMiddleBtnPress),
104  FXMAPFUNC(SEL_MIDDLEBUTTONRELEASE, 0, GUISUMOAbstractView::onMiddleBtnRelease),
105  FXMAPFUNC(SEL_RIGHTBUTTONPRESS, 0, GUISUMOAbstractView::onRightBtnPress),
106  FXMAPFUNC(SEL_RIGHTBUTTONRELEASE, 0, GUISUMOAbstractView::onRightBtnRelease),
107  FXMAPFUNC(SEL_DOUBLECLICKED, 0, GUISUMOAbstractView::onDoubleClicked),
108  FXMAPFUNC(SEL_MOUSEWHEEL, 0, GUISUMOAbstractView::onMouseWheel),
109  FXMAPFUNC(SEL_MOTION, 0, GUISUMOAbstractView::onMouseMove),
110  FXMAPFUNC(SEL_LEAVE, 0, GUISUMOAbstractView::onMouseLeft),
111  FXMAPFUNC(SEL_KEYPRESS, 0, GUISUMOAbstractView::onKeyPress),
112  FXMAPFUNC(SEL_KEYRELEASE, 0, GUISUMOAbstractView::onKeyRelease),
113 
114 };
115 
116 
117 FXIMPLEMENT_ABSTRACT(GUISUMOAbstractView, FXGLCanvas, GUISUMOAbstractViewMap, ARRAYNUMBER(GUISUMOAbstractViewMap))
118 
119 
120 /* -------------------------------------------------------------------------
121  * GUISUMOAbstractView - methods
122  * ----------------------------------------------------------------------- */
123 GUISUMOAbstractView::GUISUMOAbstractView(FXComposite* p, GUIMainWindow& app, GUIGlChildWindow* parent, const SUMORTree& grid, FXGLVisual* glVis, FXGLCanvas* share) :
124  FXGLCanvas(p, glVis, share, p, MID_GLCANVAS, LAYOUT_SIDE_TOP | LAYOUT_FILL_X | LAYOUT_FILL_Y, 0, 0, 0, 0),
125  myApp(&app),
126  myParent(parent),
127  myGrid(&((SUMORTree&)grid)),
128  myChanger(nullptr),
129  myMouseHotspotX(app.getDefaultCursor()->getHotX()),
130  myMouseHotspotY(app.getDefaultCursor()->getHotY()),
131  myPopup(nullptr),
132  myPopupPosition(Position(0, 0)),
133  myUseToolTips(false),
134  myAmInitialised(false),
135  myViewportChooser(nullptr),
136  myWindowCursorPositionX(getWidth() / 2),
137  myWindowCursorPositionY(getHeight() / 2),
138  myVisualizationChanger(nullptr) {
139  setTarget(this);
140  enable();
141  flags |= FLAG_ENABLED;
142  myInEditMode = false;
143  // show the middle at the beginning
144  myChanger = new GUIDanielPerspectiveChanger(*this, *myGrid);
145  myVisualizationSettings = &gSchemeStorage.getDefault();
146  myVisualizationSettings->gaming = myApp->isGaming();
148 }
149 
150 
154  delete myPopup;
155  delete myChanger;
156  delete myViewportChooser;
157  delete myVisualizationChanger;
158  // cleanup decals
159  for (std::vector<GUISUMOAbstractView::Decal>::iterator it = myDecals.begin(); it != myDecals.end(); ++it) {
160  delete it->image;
161  }
162  for (auto i : myAdditionallyDrawn) {
163  i.first->removeActiveAddVisualisation(this, ~0); // remove all
164  }
165 }
166 
167 
168 bool
170  return myInEditMode;
171 }
172 
173 
176  return *myChanger;
177 }
178 
179 
180 void
182  if (!myUseToolTips) {
183  return;
184  }
185  update();
186 }
187 
188 
189 Position
192 }
193 
194 
195 Position
196 GUISUMOAbstractView::snapToActiveGrid(const Position& pos, bool snapXY) const {
197  Position result = pos;
199  if (snapXY) {
200  const double xRest = std::fmod(pos.x(), myVisualizationSettings->gridXSize) + (pos.x() < 0 ? myVisualizationSettings->gridXSize : 0);
201  const double yRest = std::fmod(pos.y(), myVisualizationSettings->gridYSize) + (pos.y() < 0 ? myVisualizationSettings->gridYSize : 0);
202  result.setx(pos.x() - xRest + (xRest < myVisualizationSettings->gridXSize * 0.5 ? 0 : myVisualizationSettings->gridXSize));
203  result.sety(pos.y() - yRest + (yRest < myVisualizationSettings->gridYSize * 0.5 ? 0 : myVisualizationSettings->gridYSize));
204  } else {
205  // snapZToActiveGrid uses grid Y Size
206  const double zRest = std::fmod(pos.z(), myVisualizationSettings->gridYSize) + (pos.z() < 0 ? myVisualizationSettings->gridYSize : 0);
207  result.setz(pos.z() - zRest + (zRest < myVisualizationSettings->gridYSize * 0.5 ? 0 : myVisualizationSettings->gridYSize));
208  }
209  }
210  return result;
211 }
212 
213 
214 Position
216  Boundary bound = myChanger->getViewport();
217  double xNet = bound.xmin() + bound.getWidth() * x / getWidth();
218  // cursor origin is in the top-left corner
219  double yNet = bound.ymin() + bound.getHeight() * (getHeight() - y) / getHeight();
220  // rotate around the viewport center
221  if (myChanger->getRotation() != 0) {
222  return Position(xNet, yNet).rotateAround2D(-DEG2RAD(myChanger->getRotation()), bound.getCenter());
223  } else {
224  return Position(xNet, yNet);
225  }
226 }
227 
228 
229 void
230 GUISUMOAbstractView::addDecals(const std::vector<Decal>& decals) {
231  myDecals.insert(myDecals.end(), decals.begin(), decals.end());
232 }
233 
234 
238 }
239 
240 
241 void
244  std::string text = "x:" + toString(pos.x()) + ", y:" + toString(pos.y());
245  myApp->getCartesianLabel().setText(text.c_str());
247  if (GeoConvHelper::getFinal().usingGeoProjection()) {
248  text = "lat:" + toString(pos.y(), gPrecisionGeo) + ", lon:" + toString(pos.x(), gPrecisionGeo);
249  } else {
250  text = "x:" + toString(pos.x()) + ", y:" + toString(pos.y());
251  }
252  myApp->getGeoLabel().setText(text.c_str());
253 }
254 
255 
256 int
257 GUISUMOAbstractView::doPaintGL(int /*mode*/, const Boundary& /*boundary*/) {
258  return 0;
259 }
260 
261 
262 void
264 }
265 
266 
267 Boundary
269  return myChanger->getViewport();
270 }
271 
272 
273 void
275  if (getWidth() == 0 || getHeight() == 0) {
276  return;
277  }
278  const long start = SysUtils::getCurrentMillis();
279 
281  centerTo(getTrackedID(), false);
282  }
283 
285  if (myUseToolTips) {
286  id = getObjectUnderCursor();
287  }
288 
289  // draw
290  glClearColor(
295  glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
296  glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
297 
299  glEnable(GL_DITHER);
300  } else {
301  glDisable(GL_DITHER);
302  }
303  glEnable(GL_BLEND);
304  glDisable(GL_LINE_SMOOTH);
305 
306  Boundary bound = applyGLTransform();
307  doPaintGL(GL_RENDER, bound);
309  displayLegend();
310  }
313  }
314  const long end = SysUtils::getCurrentMillis();
315  myFrameDrawTime = end - start;
317  drawFPS();
318  }
319  // check whether the select mode /tooltips)
320  // shall be computed, too
321  if (myUseToolTips && id != GUIGlObject::INVALID_ID) {
322  showToolTipFor(id);
323  }
324  swapBuffers();
325 }
326 
327 
328 GUIGlID
331 }
332 
333 
334 std::vector<GUIGlID>
337 }
338 
339 
340 std::vector<GUIGlObject*>
344  } else {
346  }
347 }
348 
349 
350 std::vector<GUIGlObject*>
353 }
354 
355 
356 GUIGlID
358  // calculate a boundary for the given position
359  Boundary positionBoundary;
360  positionBoundary.add(pos);
361  positionBoundary.grow(SENSITIVITY);
362  const std::vector<GUIGlID> ids = getObjectsInBoundary(positionBoundary, true);
363  // Interpret results
364  int idMax = 0;
365  double maxLayer = -std::numeric_limits<double>::max();
366  // iterate over obtained GUIGlIDs
367  for (const auto& i : ids) {
368  // obtain GUIGlObject
370  // check that GUIGlObject exist
371  if (o == nullptr) {
372  continue;
373  }
374  // check that GUIGlObject isn't the network
375  if (o->getGlID() == 0) {
376  continue;
377  }
378  //std::cout << "point selection hit " << o->getMicrosimID() << "\n";
379  GUIGlObjectType type = o->getType();
380  // avoid network
381  if (type != GLO_NETWORK) {
382  double layer = (double)type;
383  // determine an "abstract" layer for shapes
384  // this "layer" resembles the layer of the shape
385  // taking into account the stac of other objects
386  if (type == GLO_POI || type == GLO_POLYGON) {
387  layer = dynamic_cast<Shape*>(o)->getShapeLayer();
388  }
390  // do not select lanes in meso mode
391  continue;
392  }
393  // check whether the current object is above a previous one
394  if (layer > maxLayer) {
395  idMax = i;
396  maxLayer = layer;
397  }
398  }
399  // unblock object
401  }
402  return idMax;
403 }
404 
405 
406 std::vector<GUIGlID>
408  // declare result vector
409  std::vector<GUIGlID> result;
410  // calculate boundary
411  Boundary selection;
412  selection.add(pos);
413  selection.grow(radius);
414  // obtain GUIGlID of objects in boundary
415  const std::vector<GUIGlID> ids = getObjectsInBoundary(selection, true);
416  // iterate over obtained GUIGlIDs
417  for (const auto& i : ids) {
418  // obtain GUIGlObject
420  // check that GUIGlObject exist
421  if (o == nullptr) {
422  continue;
423  }
424  // check that GUIGlObject isn't the network
425  if (o->getGlID() == 0) {
426  continue;
427  }
428  //std::cout << "point selection hit " << o->getMicrosimID() << "\n";
429  GUIGlObjectType type = o->getType();
430  // avoid network
431  if (type != GLO_NETWORK) {
432  result.push_back(i);
433  }
434  // unblock object
436  }
437  return result;
438 }
439 
440 
441 std::vector<GUIGlObject*>
443  // declare result vector
444  std::vector<GUIGlObject*> result;
445  // calculate boundary
446  Boundary selection;
447  selection.add(pos);
448  selection.grow(radius);
449  // obtain GUIGlID of objects in boundary
450  const std::vector<GUIGlID> ids = getObjectsInBoundary(selection, true);
451  // iterate over obtained GUIGlIDs
452  for (const auto& i : ids) {
453  // obtain GUIGlObject
455  // check that GUIGlObject exist
456  if (o == nullptr) {
457  continue;
458  }
459  // check that GUIGlObject isn't the network
460  if (o->getGlID() == 0) {
461  continue;
462  }
463  result.push_back(o);
464  // unblock object
466  }
467  return result;
468 }
469 
470 
471 std::vector<GUIGlID>
473  const int NB_HITS_MAX = 1024 * 1024;
474  // Prepare the selection mode
475  static GUIGlID hits[NB_HITS_MAX];
476  static GLint nb_hits = 0;
477  glSelectBuffer(NB_HITS_MAX, hits);
478  glInitNames();
479 
481  Boundary oldViewPort = myChanger->getViewport(false); // backup the actual viewPort
482  myChanger->setViewport(bound);
483  bound = applyGLTransform(false);
484  // enable draw for selecting (to draw objects with less details)
485  if (singlePosition) {
487  } else {
489  }
490  int hits2 = doPaintGL(GL_SELECT, bound);
491  // disable draw for selecting (to draw objects with less details)
492  if (singlePosition) {
494  } else {
496  }
497  // Get the results
498  nb_hits = glRenderMode(GL_RENDER);
499  if (nb_hits == -1) {
500  myApp->setStatusBarText("Selection in boundary failed. Try to select fewer than " + toString(hits2) + " items");
501  }
502  std::vector<GUIGlID> result;
503  GLuint numNames;
504  GLuint* ptr = hits;
505  for (int i = 0; i < nb_hits; ++i) {
506  numNames = *ptr;
507  ptr += 3;
508  for (int j = 0; j < (int)numNames; j++) {
509  result.push_back(*ptr);
510  ptr++;
511  }
512  }
513  // switch viewport back to normal
514  myChanger->setViewport(oldViewPort);
515  return result;
516 }
517 
518 
519 void
521  if (id != 0) {
523  if (object != nullptr) {
525  pos.add(0, p2m(15));
526  std::string label = object->getFullName();
528  (object->getType() == GLO_EDGE || object->getType() == GLO_LANE)) {
529  const int activeScheme = myVisualizationSettings->getLaneEdgeMode();
530  label += " (" + toString(object->getColorValue(*myVisualizationSettings, activeScheme)) + ")";
531  }
532  GLHelper::drawTextBox(label, pos, GLO_MAX - 1, p2m(20), RGBColor::BLACK, RGBColor(255, 179, 0, 255));
534  }
535  }
536 }
537 
538 
539 void
541  // obtain minimum grid
543  // Check if the distance is enought to draw grid
545  glEnable(GL_DEPTH_TEST);
546  glLineWidth(1);
547  // get multiplication values (2 is the marging)
548  int multXmin = (int)(myChanger->getViewport().xmin() / myVisualizationSettings->gridXSize) - 2;
549  int multYmin = (int)(myChanger->getViewport().ymin() / myVisualizationSettings->gridYSize) - 2;
550  int multXmax = (int)(myChanger->getViewport().xmax() / myVisualizationSettings->gridXSize) + 2;
551  int multYmax = (int)(myChanger->getViewport().ymax() / myVisualizationSettings->gridYSize) + 2;
552  // obtain references
553  double xmin = myVisualizationSettings->gridXSize * multXmin;
554  double ymin = myVisualizationSettings->gridYSize * multYmin;
555  double xmax = myVisualizationSettings->gridXSize * multXmax;
556  double ymax = myVisualizationSettings->gridYSize * multYmax;
557  double xpos = xmin;
558  double ypos = ymin;
559  // move drawing matrix
560  glTranslated(0, 0, .55);
561  glColor3d(0.5, 0.5, 0.5);
562  // draw horizontal lines
563  glBegin(GL_LINES);
564  while (ypos <= ymax) {
565  glVertex2d(xmin, ypos);
566  glVertex2d(xmax, ypos);
568  }
569  // draw vertical lines
570  while (xpos <= xmax) {
571  glVertex2d(xpos, ymin);
572  glVertex2d(xpos, ymax);
574  }
575  glEnd();
576  glTranslated(0, 0, -.55);
577  }
578 }
579 
580 
581 void
583  // compute the scale bar length
584  int length = 1;
585  const std::string text("10000000000");
586  int noDigits = 1;
587  int pixelSize = (int) m2p((double) length);
588  while (pixelSize <= 20) {
589  length *= 10;
590  noDigits++;
591  if (noDigits > (int)text.length()) {
592  return;
593  }
594  pixelSize = (int) m2p((double) length);
595  }
596  glLineWidth(1.0);
597 
598  glMatrixMode(GL_PROJECTION);
599  glPushMatrix();
600  glLoadIdentity();
601  glMatrixMode(GL_MODELVIEW);
602  glPushMatrix();
603  glLoadIdentity();
604 
605  // draw the scale bar
606  const double z = -1;
607  glDisable(GL_TEXTURE_2D);
608  glDisable(GL_ALPHA_TEST);
609  glDisable(GL_BLEND);
610  glEnable(GL_DEPTH_TEST);
611  glPushMatrix();
612  glTranslated(0, 0, z);
613 
614  double len = (double) pixelSize / (double)(getWidth() - 1) * (double) 2.0;
615  glColor3d(0, 0, 0);
616  double o = double(15) / double(getHeight());
617  double o2 = o + o;
618  double oo = double(5) / double(getHeight());
619  glBegin(GL_LINES);
620  // vertical
621  glVertex2d(-.98, -1. + o);
622  glVertex2d(-.98 + len, -1. + o);
623  // tick at begin
624  glVertex2d(-.98, -1. + o);
625  glVertex2d(-.98, -1. + o2);
626  // tick at end
627  glVertex2d(-.98 + len, -1. + o);
628  glVertex2d(-.98 + len, -1. + o2);
629  glEnd();
630  glPopMatrix();
631 
632  const double fontHeight = 0.1 * 300. / getHeight();
633  const double fontWidth = 0.1 * 300. / getWidth();
634  // draw 0
635  GLHelper::drawText("0", Position(-.99, -0.99 + o2 + oo), z, fontHeight, RGBColor::BLACK, 0, FONS_ALIGN_LEFT, fontWidth);
636 
637  // draw current scale
638  GLHelper::drawText((text.substr(0, noDigits) + "m").c_str(), Position(-.99 + len, -0.99 + o2 + oo), z, fontHeight, RGBColor::BLACK, 0, FONS_ALIGN_LEFT, fontWidth);
639 
640  // restore matrices
641  glMatrixMode(GL_PROJECTION);
642  glPopMatrix();
643  glMatrixMode(GL_MODELVIEW);
644  glPopMatrix();
645 }
646 
647 void
649  // compute the scale bar length
650  glLineWidth(1.0);
651  glMatrixMode(GL_PROJECTION);
652  glPushMatrix();
653  glLoadIdentity();
654  glMatrixMode(GL_MODELVIEW);
655  glPushMatrix();
656  glLoadIdentity();
657 
658  const double z = -1;
659  glEnable(GL_DEPTH_TEST);
660  glEnable(GL_BLEND);
661  glPushMatrix();
662  glTranslated(0, 0, z);
663 
665  const bool fixed = scheme.isFixed();
666  const int numColors = (int)scheme.getColors().size();
667 
668  // vertical
669  const double right = 0.98;
670  const double left = 0.95;
671  const double top = -0.8;
672  const double bot = 0.8;
673  const double dy = (top - bot) / numColors;
674  const double bot2 = fixed ? bot : bot + dy / 2;
675  glBegin(GL_LINES);
676  glVertex2d(right, top);
677  glVertex2d(right, bot2);
678  glVertex2d(left, bot2);
679  glVertex2d(left, top);
680  glVertex2d(right, top);
681  glVertex2d(left, top);
682  glVertex2d(right, bot2);
683  glVertex2d(left, bot2);
684  glEnd();
685 
686  const double fontHeight = 0.20 * 300. / getHeight();
687  const double fontWidth = 0.20 * 300. / getWidth();
688 
689  const int fadeSteps = fixed ? 1 : 10;
690  double colorStep = dy / fadeSteps;
691  for (int i = 0; i < numColors; i++) {
692  RGBColor col = scheme.getColors()[i];
693  const double topi = top - i * dy;
694  //const double boti = top - (i + 1) * dy;
695  //std::cout << " col=" << scheme.getColors()[i] << " i=" << i << " topi=" << topi << " boti=" << boti << "\n";
696  if (i + 1 < numColors) {
697  // fade
698  RGBColor col2 = scheme.getColors()[i + 1];
699  for (double j = 0.0; j < fadeSteps; j++) {
700  GLHelper::setColor(RGBColor::interpolate(col, col2, j / fadeSteps));
701  glBegin(GL_QUADS);
702  glVertex2d(left, topi - j * colorStep);
703  glVertex2d(right, topi - j * colorStep);
704  glVertex2d(right, topi - (j + 1) * colorStep);
705  glVertex2d(left, topi - (j + 1) * colorStep);
706  glEnd();
707  }
708  } else {
709  GLHelper::setColor(col);
710  glBegin(GL_QUADS);
711  glVertex2d(left, topi);
712  glVertex2d(right, topi);
713  glVertex2d(right, bot2);
714  glVertex2d(left, bot2);
715  glEnd();
716  }
717 
718  const double threshold = scheme.getThresholds()[i];
719  std::string name = scheme.getNames()[i];
720  std::string text = fixed ? name : toString(threshold);
721 
722  const double bgShift = 0.0;
723  const double textShift = 0.02;
724 
726  glTranslated(0, 0, 0.1);
727  glBegin(GL_QUADS);
728  glVertex2d(left, topi + fontHeight * bgShift);
729  glVertex2d(left - fontWidth * text.size() / 2, topi + fontHeight * bgShift);
730  glVertex2d(left - fontWidth * text.size() / 2, topi + fontHeight * (1 + bgShift));
731  glVertex2d(left, topi + fontHeight * (1 + bgShift));
732  glEnd();
733  glTranslated(0, 0, -0.1);
734  GLHelper::drawText(text, Position(left - 0.01, topi + textShift), 0, fontHeight, RGBColor::BLACK, 0, FONS_ALIGN_RIGHT, fontWidth);
735  }
736  glPopMatrix();
737  // restore matrices
738  glMatrixMode(GL_PROJECTION);
739  glPopMatrix();
740  glMatrixMode(GL_MODELVIEW);
741  glPopMatrix();
742 }
743 
744 
745 double
747  return 1000.0 / MAX2((long)1, myFrameDrawTime);
748 }
749 
750 void
752  glMatrixMode(GL_PROJECTION);
753  glPushMatrix();
754  glLoadIdentity();
755  glMatrixMode(GL_MODELVIEW);
756  glPushMatrix();
757  glLoadIdentity();
758  const double fontHeight = 0.2 * 300. / getHeight();
759  const double fontWidth = 0.2 * 300. / getWidth();
760  GLHelper::drawText(toString((int)getFPS()) + " FPS", Position(0.82, 0.88), -1, fontHeight, RGBColor::RED, 0, FONS_ALIGN_LEFT, fontWidth);
761 
762  // restore matrices
763  glMatrixMode(GL_PROJECTION);
764  glPopMatrix();
765  glMatrixMode(GL_MODELVIEW);
766  glPopMatrix();
767 }
768 
769 
770 double
771 GUISUMOAbstractView::m2p(double meter) const {
772  return meter * getWidth() / myChanger->getViewport().getWidth();
773 }
774 
775 
776 double
777 GUISUMOAbstractView::p2m(double pixel) const {
778  return pixel * myChanger->getViewport().getWidth() / getWidth();
779 }
780 
781 
782 void
785 }
786 
787 
788 void
789 GUISUMOAbstractView::centerTo(GUIGlID id, bool applyZoom, double zoomDist) {
791  if (o != nullptr && dynamic_cast<GUIGlObject*>(o) != nullptr) {
792  if (applyZoom && zoomDist < 0) {
794  update(); // only update when centering onto an object once
795  } else {
796  // called during tracking. update is triggered somewhere else
797  myChanger->centerTo(o->getCenteringBoundary().getCenter(), zoomDist, applyZoom);
799  }
800  }
802 }
803 
804 
805 void
806 GUISUMOAbstractView::centerTo(const Position& pos, bool applyZoom, double zoomDist) {
807  // called during tracking. update is triggered somewhere else
808  myChanger->centerTo(pos, zoomDist, applyZoom);
810 }
811 
812 
813 void
815  myChanger->setViewport(bound);
816  update();
817 }
818 
819 /*
820 bool
821 GUISUMOAbstractView::allowRotation() const
822 {
823  return myParent->allowRotation();
824 }
825 */
826 
827 Position
830 }
831 
832 
833 void
837 }
838 
839 
840 FXbool
842  FXbool ret = FXGLCanvas::makeCurrent();
843  return ret;
844 }
845 
846 
847 long
848 GUISUMOAbstractView::onConfigure(FXObject*, FXSelector, void*) {
849  if (makeCurrent()) {
850  glViewport(0, 0, getWidth() - 1, getHeight() - 1);
851  glClearColor(
856  doInit();
857  myAmInitialised = true;
858  makeNonCurrent();
859  checkSnapshots();
860  }
861  return 1;
862 }
863 
864 
865 long
866 GUISUMOAbstractView::onPaint(FXObject*, FXSelector, void*) {
867  if (!isEnabled() || !myAmInitialised) {
868  return 1;
869  }
870  if (makeCurrent()) {
871  paintGL();
872  makeNonCurrent();
873  }
874  return 1;
875 }
876 
877 
878 const Position&
880  return myPopupPosition;
881 }
882 
883 void
885  if (myPopup != nullptr) {
886  delete myPopup;
887  myPopupPosition.set(0, 0);
888  myPopup = nullptr;
889  }
890 }
891 
892 
893 long
894 GUISUMOAbstractView::onLeftBtnPress(FXObject*, FXSelector, void* data) {
895  destroyPopup();
896  setFocus();
897  FXEvent* e = (FXEvent*) data;
898  // check whether the selection-mode is activated
899  if ((e->state & CONTROLMASK) != 0) {
900  // toggle selection of object under cursor
901  if (makeCurrent()) {
902  int id = getObjectUnderCursor();
903  if (id != 0) {
905  }
906  makeNonCurrent();
907  if (id != 0) {
908  // possibly, the selection-colouring is used,
909  // so we should update the screen again...
910  update();
911  }
912  }
913  }
914  if ((e->state & SHIFTMASK) != 0) {
915  // track vehicle or person under cursor
916  if (makeCurrent()) {
917  int id = getObjectUnderCursor();
918  if (id != 0) {
920  if (o != nullptr) {
921  if (o->getType() == GLO_VEHICLE || o->getType() == GLO_PERSON) {
922  startTrack(id);
923  } else if (o->getType() == GLO_REROUTER_EDGE) {
924  o->onLeftBtnPress(data);
925  update();
926  }
927  }
928  }
929  makeNonCurrent();
930  }
931  }
932  myChanger->onLeftBtnPress(data);
933  grab();
934  // Check there are double click
935  if (e->click_count == 2) {
936  handle(this, FXSEL(SEL_DOUBLECLICKED, 0), data);
937  }
938  return 1;
939 }
940 
941 
942 long
943 GUISUMOAbstractView::onLeftBtnRelease(FXObject*, FXSelector, void* data) {
944  destroyPopup();
946  if (myApp->isGaming()) {
948  }
949  ungrab();
950  return 1;
951 }
952 
953 
954 long
955 GUISUMOAbstractView::onMiddleBtnPress(FXObject*, FXSelector, void*) {
956  return 1;
957 }
958 
959 
960 long
961 GUISUMOAbstractView::onMiddleBtnRelease(FXObject*, FXSelector, void*) {
962  return 1;
963 }
964 
965 
966 long
967 GUISUMOAbstractView::onRightBtnPress(FXObject*, FXSelector, void* data) {
968  destroyPopup();
969  myChanger->onRightBtnPress(data);
970  grab();
971  return 1;
972 }
973 
974 
975 long
976 GUISUMOAbstractView::onRightBtnRelease(FXObject* o, FXSelector sel, void* data) {
977  destroyPopup();
978  onMouseMove(o, sel, data);
979  if (!myChanger->onRightBtnRelease(data) && !myApp->isGaming()) {
981  }
982  if (myApp->isGaming()) {
984  }
985  ungrab();
986  return 1;
987 }
988 
989 
990 long
991 GUISUMOAbstractView::onDoubleClicked(FXObject*, FXSelector, void*) {
992  return 1;
993 }
994 
995 
996 long
997 GUISUMOAbstractView::onMouseWheel(FXObject*, FXSelector, void* data) {
998  if (!myApp->isGaming()) {
999  myChanger->onMouseWheel(data);
1000  // upddate viewport
1001  if (myViewportChooser != nullptr) {
1004  myChanger->getRotation());
1005  }
1007  }
1008  return 1;
1009 }
1010 
1011 
1012 long
1013 GUISUMOAbstractView::onMouseMove(FXObject*, FXSelector, void* data) {
1014  // if popup exist but isn't shown, destroy it first
1015  if (myPopup && (myPopup->shown() == false)) {
1016  destroyPopup();
1017  }
1018  if (myPopup == nullptr) {
1019  if (myViewportChooser == nullptr || !myViewportChooser->haveGrabbed()) {
1020  myChanger->onMouseMove(data);
1021  }
1022  if (myViewportChooser != nullptr) {
1025  myChanger->getRotation());
1026  }
1028  }
1029  return 1;
1030 }
1031 
1032 
1033 long
1034 GUISUMOAbstractView::onMouseLeft(FXObject*, FXSelector, void* /*data*/) {
1035  return 1;
1036 }
1037 
1038 
1039 void
1041  ungrab();
1042  if (!isEnabled() || !myAmInitialised) {
1043  return;
1044  }
1045  if (makeCurrent()) {
1046  // initialise the select mode
1047  int id = getObjectUnderCursor();
1048  GUIGlObject* o = nullptr;
1049  if (id != 0) {
1051  } else {
1053  }
1054  if (o != nullptr) {
1055  myPopup = o->getPopUpMenu(*myApp, *this);
1056  int x, y;
1057  FXuint b;
1058  myApp->getCursorPosition(x, y, b);
1059  myPopup->setX(x + myApp->getX());
1060  myPopup->setY(y + myApp->getY());
1061  myPopup->create();
1062  myPopup->show();
1064  myChanger->onRightBtnRelease(nullptr);
1066  setFocus();
1067  }
1068  makeNonCurrent();
1069  }
1070 }
1071 
1072 
1073 long
1074 GUISUMOAbstractView::onKeyPress(FXObject* o, FXSelector sel, void* data) {
1075  if (myPopup != nullptr) {
1076  return myPopup->onKeyPress(o, sel, data);
1077  } else {
1078  FXGLCanvas::onKeyPress(o, sel, data);
1079  return myChanger->onKeyPress(data);
1080  }
1081 }
1082 
1083 
1084 long
1085 GUISUMOAbstractView::onKeyRelease(FXObject* o, FXSelector sel, void* data) {
1086  if (myPopup != nullptr) {
1087  return myPopup->onKeyRelease(o, sel, data);
1088  } else {
1089  FXGLCanvas::onKeyRelease(o, sel, data);
1090  return myChanger->onKeyRelease(data);
1091  }
1092 }
1093 
1094 
1095 // ------------ Dealing with snapshots
1096 void
1097 GUISUMOAbstractView::addSnapshot(SUMOTime time, const std::string& file, const int w, const int h) {
1098 #ifdef DEBUG_SNAPSHOT
1099  std::cout << "add snapshot time=" << time << " file=" << file << "\n";
1100 #endif
1101  FXMutexLock lock(mySnapshotsMutex);
1102  mySnapshots[time].push_back(std::make_tuple(file, w, h));
1103 }
1104 
1105 
1106 std::string
1107 GUISUMOAbstractView::makeSnapshot(const std::string& destFile, const int w, const int h) {
1108  if (w >= 0) {
1109  resize(w, h);
1110  repaint();
1111  }
1112  std::string errorMessage;
1113  FXString ext = FXPath::extension(destFile.c_str());
1114  const bool useGL2PS = ext == "ps" || ext == "eps" || ext == "pdf" || ext == "svg" || ext == "tex" || ext == "pgf";
1115 #ifdef HAVE_FFMPEG
1116  const bool useVideo = destFile == "" || ext == "h264" || ext == "hevc";
1117 #endif
1118  for (int i = 0; i < 10 && !makeCurrent(); ++i) {
1120  }
1121  // draw
1122  glClearColor(
1127  glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
1128  glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
1129 
1131  glEnable(GL_DITHER);
1132  } else {
1133  glDisable(GL_DITHER);
1134  }
1135  glEnable(GL_BLEND);
1136  glDisable(GL_LINE_SMOOTH);
1137 
1138  applyGLTransform();
1139 
1140  if (useGL2PS) {
1141 #ifdef HAVE_GL2PS
1142  GLint format = GL2PS_PS;
1143  if (ext == "ps") {
1144  format = GL2PS_PS;
1145  } else if (ext == "eps") {
1146  format = GL2PS_EPS;
1147  } else if (ext == "pdf") {
1148  format = GL2PS_PDF;
1149  } else if (ext == "tex") {
1150  format = GL2PS_TEX;
1151  } else if (ext == "svg") {
1152  format = GL2PS_SVG;
1153  } else if (ext == "pgf") {
1154  format = GL2PS_PGF;
1155  } else {
1156  return "Could not save '" + destFile + "'.\n Unrecognized format '" + std::string(ext.text()) + "'.";
1157  }
1158  FILE* fp = fopen(destFile.c_str(), "wb");
1159  if (fp == 0) {
1160  return "Could not save '" + destFile + "'.\n Could not open file for writing";
1161  }
1163  GLint buffsize = 0, state = GL2PS_OVERFLOW;
1164  GLint viewport[4];
1165  glGetIntegerv(GL_VIEWPORT, viewport);
1166  while (state == GL2PS_OVERFLOW) {
1167  buffsize += 1024 * 1024;
1168  gl2psBeginPage(destFile.c_str(), "sumo-gui; https://sumo.dlr.de", viewport, format, GL2PS_SIMPLE_SORT,
1169  GL2PS_DRAW_BACKGROUND | GL2PS_USE_CURRENT_VIEWPORT,
1170  GL_RGBA, 0, NULL, 0, 0, 0, buffsize, fp, "out.eps");
1171  glMatrixMode(GL_MODELVIEW);
1172  glPushMatrix();
1173  glDisable(GL_TEXTURE_2D);
1174  glDisable(GL_ALPHA_TEST);
1175  glDisable(GL_BLEND);
1176  glEnable(GL_DEPTH_TEST);
1177  // draw decals (if not in grabbing mode)
1178  if (!myUseToolTips) {
1179  drawDecals();
1181  paintGLGrid();
1182  }
1183  }
1184  glLineWidth(1);
1185  glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
1186  Boundary viewPort = myChanger->getViewport();
1187  const float minB[2] = { (float)viewPort.xmin(), (float)viewPort.ymin() };
1188  const float maxB[2] = { (float)viewPort.xmax(), (float)viewPort.ymax() };
1190  glEnable(GL_POLYGON_OFFSET_FILL);
1191  glEnable(GL_POLYGON_OFFSET_LINE);
1192  myGrid->Search(minB, maxB, *myVisualizationSettings);
1193 
1195  displayLegend();
1196  }
1199  }
1200  state = gl2psEndPage();
1201  glFinish();
1202  }
1203  GLHelper::setGL2PS(false);
1204  fclose(fp);
1205 #else
1206  return "Could not save '" + destFile + "', gl2ps was not enabled at compile time.";
1207 #endif
1208  } else {
1209  doPaintGL(GL_RENDER, myChanger->getViewport());
1211  displayLegend();
1212  }
1215  }
1216  swapBuffers();
1217  glFinish();
1218  FXColor* buf;
1219  FXMALLOC(&buf, FXColor, getWidth()*getHeight());
1220  // read from the back buffer
1221  glReadBuffer(GL_BACK);
1222  // Read the pixels
1223  glReadPixels(0, 0, getWidth(), getHeight(), GL_RGBA, GL_UNSIGNED_BYTE, (GLvoid*)buf);
1224  makeNonCurrent();
1225  update();
1226  // mirror
1227  int mwidth = getWidth();
1228  int mheight = getHeight();
1229  FXColor* paa = buf;
1230  FXColor* pbb = buf + mwidth * (mheight - 1);
1231  do {
1232  FXColor* pa = paa;
1233  paa += mwidth;
1234  FXColor* pb = pbb;
1235  pbb -= mwidth;
1236  do {
1237  FXColor t = *pa;
1238  *pa++ = *pb;
1239  *pb++ = t;
1240  } while (pa < paa);
1241  } while (paa < pbb);
1242  try {
1243 #ifdef HAVE_FFMPEG
1244  if (useVideo) {
1245  try {
1246  saveFrame(destFile, buf);
1247  errorMessage = "video";
1248  } catch (std::runtime_error& err) {
1249  errorMessage = err.what();
1250  }
1251  } else
1252 #endif
1253  if (!MFXImageHelper::saveImage(destFile, getWidth(), getHeight(), buf)) {
1254  errorMessage = "Could not save '" + destFile + "'.";
1255  }
1256  } catch (InvalidArgument& e) {
1257  errorMessage = "Could not save '" + destFile + "'.\n" + e.what();
1258  }
1259  FXFREE(&buf);
1260  }
1261  return errorMessage;
1262 }
1263 
1264 
1265 void
1266 GUISUMOAbstractView::saveFrame(const std::string& destFile, FXColor* buf) {
1267  UNUSED_PARAMETER(destFile);
1268  UNUSED_PARAMETER(buf);
1269 }
1270 
1271 
1272 void
1274  const SUMOTime time = getCurrentTimeStep() - DELTA_T;
1275 #ifdef DEBUG_SNAPSHOT
1276  std::cout << "check snapshots time=" << time << " registeredTimes=" << mySnapshots.size() << "\n";
1277 #endif
1278  FXMutexLock lock(mySnapshotsMutex);
1279  const auto snapIt = mySnapshots.find(time);
1280  if (snapIt == mySnapshots.end()) {
1281  return;
1282  }
1283  std::vector<std::tuple<std::string, int, int> > files = snapIt->second;
1284  lock.unlock();
1285  // decouple map access and painting to avoid deadlock
1286  for (const auto& entry : files) {
1287 #ifdef DEBUG_SNAPSHOT
1288  std::cout << "make snapshot time=" << time << " file=" << file << "\n";
1289 #endif
1290  const std::string& error = makeSnapshot(std::get<0>(entry), std::get<1>(entry), std::get<2>(entry));
1291  if (error != "" && error != "video") {
1292  WRITE_WARNING(error);
1293  }
1294  }
1295  // synchronization with a waiting run thread
1296  lock.lock();
1297  mySnapshots.erase(time);
1298  mySnapshotCondition.signal();
1299 #ifdef DEBUG_SNAPSHOT
1300  std::cout << " files=" << toString(files) << " myApplicationSnapshots=" << joinToString(*myApplicationSnapshots, ",") << "\n";
1301 #endif
1302 }
1303 
1304 
1305 void
1307  FXMutexLock lock(mySnapshotsMutex);
1308  if (mySnapshots.count(snapshotTime) > 0) {
1310  }
1311 }
1312 
1313 
1314 SUMOTime
1316  return 0;
1317 }
1318 
1319 
1320 void
1322  if (myVisualizationChanger == nullptr) {
1326  &myDecals, &myDecalsLock);
1327  myVisualizationChanger->create();
1328  } else {
1330  }
1332 }
1333 
1334 
1337  if (myViewportChooser == nullptr) {
1338  const FXint minSize = 100;
1339  const FXint minTitlebarHeight = 20;
1340  int x = MAX2(0, MIN2(getApp()->reg().readIntEntry(
1341  "VIEWPORT_DIALOG_SETTINGS", "x", 150),
1342  getApp()->getRootWindow()->getWidth() - minSize));
1343  int y = MAX2(minTitlebarHeight, MIN2(getApp()->reg().readIntEntry(
1344  "VIEWPORT_DIALOG_SETTINGS", "y", 150),
1345  getApp()->getRootWindow()->getHeight() - minSize));
1346  myViewportChooser = new GUIDialog_EditViewport(this, "Edit Viewport", x, y);
1347  myViewportChooser->create();
1348  }
1351  myChanger->getRotation());
1352  return myViewportChooser;
1353 }
1354 
1355 
1356 void
1358  getViewportEditor(); // make sure it exists;
1362 }
1363 
1364 
1365 void
1366 GUISUMOAbstractView::setViewportFromToRot(const Position& lookFrom, const Position& /* lookAt */, double rotation) {
1367  myChanger->setViewportFrom(lookFrom.x(), lookFrom.y(), lookFrom.z());
1368  myChanger->setRotation(rotation);
1369  update();
1370 }
1371 
1372 
1373 void
1375  // look straight down
1378  myChanger->getRotation());
1379 }
1380 
1381 
1382 void
1384  myUseToolTips = val;
1385 }
1386 
1387 
1388 bool
1390  return true;
1391 }
1392 
1393 
1396  return myVisualizationSettings;
1397 }
1398 
1399 
1400 void
1402  myViewportChooser = nullptr;
1403 }
1404 
1405 
1406 void
1408  myVisualizationChanger = nullptr;
1409 }
1410 
1411 
1412 double
1414  return myGrid->getWidth();
1415 }
1416 
1417 
1418 double
1420  return myGrid->getHeight();
1421 }
1422 
1423 
1424 void
1426 }
1427 
1428 
1429 void
1431 }
1432 
1433 
1434 GUIGlID
1436  return GUIGlObject::INVALID_ID;
1437 }
1438 
1439 
1440 void
1442 }
1443 
1444 void
1446 }
1447 
1448 
1449 FXComboBox*
1452 }
1453 
1454 
1455 FXImage*
1457 #ifdef HAVE_GDAL
1458  GDALAllRegister();
1459  GDALDataset* poDataset = (GDALDataset*)GDALOpen(d.filename.c_str(), GA_ReadOnly);
1460  if (poDataset == 0) {
1461  return 0;
1462  }
1463  const int xSize = poDataset->GetRasterXSize();
1464  const int ySize = poDataset->GetRasterYSize();
1465  // checking for geodata in the picture and try to adapt position and scale
1466  if (d.width <= 0.) {
1467  double adfGeoTransform[6];
1468  if (poDataset->GetGeoTransform(adfGeoTransform) == CE_None) {
1469  Position topLeft(adfGeoTransform[0], adfGeoTransform[3]);
1470  const double horizontalSize = xSize * adfGeoTransform[1];
1471  const double verticalSize = ySize * adfGeoTransform[5];
1472  Position bottomRight(topLeft.x() + horizontalSize, topLeft.y() + verticalSize);
1473  if (GeoConvHelper::getProcessing().x2cartesian(topLeft) && GeoConvHelper::getProcessing().x2cartesian(bottomRight)) {
1474  d.width = bottomRight.x() - topLeft.x();
1475  d.height = topLeft.y() - bottomRight.y();
1476  d.centerX = (topLeft.x() + bottomRight.x()) / 2;
1477  d.centerY = (topLeft.y() + bottomRight.y()) / 2;
1478  //WRITE_MESSAGE("proj: " + toString(poDataset->GetProjectionRef()) + " dim: " + toString(d.width) + "," + toString(d.height) + " center: " + toString(d.centerX) + "," + toString(d.centerY));
1479  } else {
1480  WRITE_WARNING("Could not convert coordinates in " + d.filename + ".");
1481  }
1482  }
1483  }
1484 #endif
1485  if (d.width <= 0.) {
1486  d.width = getGridWidth();
1487  d.height = getGridHeight();
1488  }
1489 
1490  // trying to read the picture
1491 #ifdef HAVE_GDAL
1492  const int picSize = xSize * ySize;
1493  FXColor* result;
1494  if (!FXMALLOC(&result, FXColor, picSize)) {
1495  WRITE_WARNING("Could not allocate memory for " + d.filename + ".");
1496  return 0;
1497  }
1498  for (int j = 0; j < picSize; j++) {
1499  result[j] = FXRGB(0, 0, 0);
1500  }
1501  bool valid = true;
1502  for (int i = 1; i <= poDataset->GetRasterCount(); i++) {
1503  GDALRasterBand* poBand = poDataset->GetRasterBand(i);
1504  int shift = -1;
1505  if (poBand->GetColorInterpretation() == GCI_RedBand) {
1506  shift = 0;
1507  } else if (poBand->GetColorInterpretation() == GCI_GreenBand) {
1508  shift = 1;
1509  } else if (poBand->GetColorInterpretation() == GCI_BlueBand) {
1510  shift = 2;
1511  } else if (poBand->GetColorInterpretation() == GCI_AlphaBand) {
1512  shift = 3;
1513  } else {
1514  WRITE_MESSAGE("Unknown color band in " + d.filename + ", maybe fox can parse it.");
1515  valid = false;
1516  break;
1517  }
1518  assert(xSize == poBand->GetXSize() && ySize == poBand->GetYSize());
1519  if (poBand->RasterIO(GF_Read, 0, 0, xSize, ySize, ((unsigned char*)result) + shift, xSize, ySize, GDT_Byte, 4, 4 * xSize) == CE_Failure) {
1520  valid = false;
1521  break;
1522  }
1523  }
1524  GDALClose(poDataset);
1525  if (valid) {
1526  return new FXImage(getApp(), result, IMAGE_OWNED | IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP, xSize, ySize);
1527  }
1528  FXFREE(&result);
1529 #endif
1530  return nullptr;
1531 }
1532 
1533 
1534 void
1536  glPushName(0);
1537  myDecalsLock.lock();
1538  for (std::vector<GUISUMOAbstractView::Decal>::iterator l = myDecals.begin(); l != myDecals.end(); ++l) {
1540  if (d.skip2D) {
1541  continue;
1542  }
1543  if (!d.initialised) {
1544  try {
1545  FXImage* img = checkGDALImage(d);
1546  if (img == nullptr) {
1547  img = MFXImageHelper::loadImage(getApp(), d.filename);
1548  }
1550  d.glID = GUITexturesHelper::add(img);
1551  d.initialised = true;
1552  d.image = img;
1553  } catch (InvalidArgument& e) {
1554  WRITE_ERROR("Could not load '" + d.filename + "'.\n" + e.what());
1555  d.skip2D = true;
1556  }
1557  }
1558  glPushMatrix();
1559  if (d.screenRelative) {
1560  Position center = screenPos2NetPos((int)d.centerX, (int)d.centerY);
1561  glTranslated(center.x(), center.y(), d.layer);
1562  } else {
1563  glTranslated(d.centerX, d.centerY, d.layer);
1564  }
1565  glRotated(d.rot, 0, 0, 1);
1566  glColor3d(1, 1, 1);
1567  double halfWidth = d.width / 2.;
1568  double halfHeight = d.height / 2.;
1569  if (d.screenRelative) {
1570  halfWidth = p2m(halfWidth);
1571  halfHeight = p2m(halfHeight);
1572  }
1573  GUITexturesHelper::drawTexturedBox(d.glID, -halfWidth, -halfHeight, halfWidth, halfHeight);
1574  glPopMatrix();
1575  }
1576  myDecalsLock.unlock();
1577  glPopName();
1578 }
1579 
1580 
1581 // ------------ Additional visualisations
1582 bool
1584  if (myAdditionallyDrawn.find(which) == myAdditionallyDrawn.end()) {
1585  myAdditionallyDrawn[which] = 1;
1586  } else {
1587  myAdditionallyDrawn[which] = myAdditionallyDrawn[which] + 1;
1588  }
1589  update();
1590  return true;
1591 }
1592 
1593 
1594 bool
1596  if (myAdditionallyDrawn.find(which) == myAdditionallyDrawn.end()) {
1597  return false;
1598  }
1599  int cnt = myAdditionallyDrawn[which];
1600  if (cnt == 1) {
1601  myAdditionallyDrawn.erase(which);
1602  } else {
1603  myAdditionallyDrawn[which] = myAdditionallyDrawn[which] - 1;
1604  }
1605  update();
1606  return true;
1607 }
1608 
1609 
1610 bool
1612  if (myAdditionallyDrawn.find(which) == myAdditionallyDrawn.end()) {
1613  return false;
1614  } else {
1615  return true;
1616  }
1617 }
1618 
1619 
1620 Boundary
1622  Boundary bound = myChanger->getViewport(fixRatio);
1623  glMatrixMode(GL_PROJECTION);
1624  glLoadIdentity();
1625  // as a rough rule, each GLObject is drawn at z = -GUIGlObjectType
1626  // thus, objects with a higher value will be closer (drawn on top)
1627  // // @todo last param should be 0 after modifying all glDraw methods
1628  glOrtho(0, getWidth(), 0, getHeight(), -GLO_MAX - 1, GLO_MAX + 1);
1629  glMatrixMode(GL_MODELVIEW);
1630  glLoadIdentity();
1631  double scaleX = (double)getWidth() / bound.getWidth();
1632  double scaleY = (double)getHeight() / bound.getHeight();
1633  glScaled(scaleX, scaleY, 1);
1634  glTranslated(-bound.xmin(), -bound.ymin(), 0);
1635  // rotate around the center of the screen
1636  //double angle = -90;
1637  if (myChanger->getRotation() != 0) {
1638  glTranslated(bound.getCenter().x(), bound.getCenter().y(), 0);
1639  glRotated(myChanger->getRotation(), 0, 0, 1);
1640  glTranslated(-bound.getCenter().x(), -bound.getCenter().y(), 0);
1641  Boundary rotBound;
1642  double rad = -DEG2RAD(myChanger->getRotation());
1643  rotBound.add(Position(bound.xmin(), bound.ymin()).rotateAround2D(rad, bound.getCenter()));
1644  rotBound.add(Position(bound.xmin(), bound.ymax()).rotateAround2D(rad, bound.getCenter()));
1645  rotBound.add(Position(bound.xmax(), bound.ymin()).rotateAround2D(rad, bound.getCenter()));
1646  rotBound.add(Position(bound.xmax(), bound.ymax()).rotateAround2D(rad, bound.getCenter()));
1647  bound = rotBound;
1648  }
1650  return bound;
1651 }
1652 
1653 
1654 double
1656  return myApp->getDelay();
1657 }
1658 
1659 
1660 void
1662  myApp->setDelay(delay);
1663 }
1664 
1665 
1666 void
1667 GUISUMOAbstractView::setBreakpoints(const std::vector<SUMOTime>& breakpoints) {
1668  myApp->setBreakpoints(breakpoints);
1669 }
1670 
1671 
1673  filename(),
1674  centerX(0),
1675  centerY(0),
1676  centerZ(0),
1677  width(0),
1678  height(0),
1679  altitude(0),
1680  rot(0),
1681  tilt(0),
1682  roll(0),
1683  layer(0),
1684  initialised(false),
1685  skip2D(false),
1686  screenRelative(false),
1687  glID(-1),
1688  image(nullptr) {
1689 }
1690 
1691 
1692 /****************************************************************************/
RGBColor::alpha
unsigned char alpha() const
Returns the alpha-amount of the color.
Definition: RGBColor.h:82
GUIGlObject::getType
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
Definition: GUIGlObject.cpp:180
GUIPerspectiveChanger
Definition: GUIPerspectiveChanger.h:52
GUISUMOAbstractView::getVisibleBoundary
Boundary getVisibleBoundary() const
get visible boundary
Definition: GUISUMOAbstractView.cpp:268
GUISUMOAbstractView::openObjectDialog
virtual void openObjectDialog()
Definition: GUISUMOAbstractView.cpp:1040
GUICompleteSchemeStorage.h
GUISUMOAbstractView::doInit
virtual void doInit()
doInit
Definition: GUISUMOAbstractView.cpp:263
GUIPerspectiveChanger::getYPos
virtual double getYPos() const =0
Returns the y-offset of the field to show stored in this changer.
MFXImageHelper::loadImage
static FXImage * loadImage(FXApp *a, const std::string &file)
Definition: MFXImageHelper.cpp:59
UNUSED_PARAMETER
#define UNUSED_PARAMETER(x)
Definition: StdDefs.h:31
GUIVisualizationSettings::name
std::string name
The name of this setting.
Definition: GUIVisualizationSettings.h:399
GUISUMOAbstractView::makeCurrent
FXbool makeCurrent()
A reimplementation due to some internal reasons.
Definition: GUISUMOAbstractView.cpp:841
GUIVisualizationSettings::drawForPositionSelection
bool drawForPositionSelection
whether drawing is performed for the purpose of selecting objects with a single click
Definition: GUIVisualizationSettings.h:644
GLO_MAX
@ GLO_MAX
empty max
Definition: GUIGlObjectTypes.h:165
GUIVisualizationSettings::fps
bool fps
Information whether frames-per-second should be drawn.
Definition: GUIVisualizationSettings.h:411
GUIMainWindow::getDelay
virtual double getDelay() const
Returns the delay (should be overwritten by subclasses if applicable)
Definition: GUIMainWindow.h:106
GUIGlObject.h
GUISUMOAbstractView::setViewportFromToRot
virtual void setViewportFromToRot(const Position &lookFrom, const Position &lookAt, double rotation)
applies the given viewport settings
Definition: GUISUMOAbstractView.cpp:1366
MFXImageHelper.h
ToString.h
GUISUMOAbstractView::showViewportEditor
virtual void showViewportEditor()
show viewport editor
Definition: GUISUMOAbstractView.cpp:1357
GUIVisualizationSettings::UseMesoSim
static bool UseMesoSim
this should be set at the same time as MSGlobals::gUseMesoSim
Definition: GUIVisualizationSettings.h:437
GUISUMOAbstractView::copyViewportTo
virtual void copyViewportTo(GUISUMOAbstractView *view)
copy the viewport to the given view
Definition: GUISUMOAbstractView.cpp:1374
GUICompleteSchemeStorage::getDefault
GUIVisualizationSettings & getDefault()
Returns the default scheme.
Definition: GUICompleteSchemeStorage.cpp:68
GUISUMOAbstractView::getGridHeight
double getGridHeight() const
get grid height
Definition: GUISUMOAbstractView.cpp:1419
MIN2
T MIN2(T a, T b)
Definition: StdDefs.h:73
GUISUMOAbstractView::stopTrack
virtual void stopTrack()
stop track
Definition: GUISUMOAbstractView.cpp:1430
GUISUMOAbstractView::myMouseHotspotX
int myMouseHotspotX
Offset to the mouse-hotspot from the mouse position.
Definition: GUISUMOAbstractView.h:462
Position::rotateAround2D
Position rotateAround2D(double rad, const Position &origin)
rotate this position by rad around origin and return the result
Definition: Position.cpp:41
GUISUMOAbstractView::onRightBtnPress
virtual long onRightBtnPress(FXObject *, FXSelector, void *)
Definition: GUISUMOAbstractView.cpp:967
GUISUMOAbstractView::Decal::image
FXImage * image
The image pointer for later cleanup.
Definition: GUISUMOAbstractView.h:338
WRITE_WARNING
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:275
GUISUMOAbstractView
Definition: GUISUMOAbstractView.h:72
FXSingleEventThread::sleep
static void sleep(long ms)
Definition: FXSingleEventThread.cpp:140
GUIGlObject::getColorValue
virtual double getColorValue(const GUIVisualizationSettings &, int) const
Definition: GUIGlObject.h:150
GUISUMOAbstractView::myAdditionallyDrawn
std::map< GUIGlObject *, int > myAdditionallyDrawn
List of objects for which GUIGlObject::drawGLAdditional is called.
Definition: GUISUMOAbstractView.h:510
GUIDialog_ViewSettings
The dialog to change the view (gui) settings.
Definition: GUIDialog_ViewSettings.h:47
Boundary::ymin
double ymin() const
Returns minimum y-coordinate.
Definition: Boundary.cpp:130
GUIVisualizationSettings::getLaneEdgeMode
int getLaneEdgeMode() const
Returns the number of the active lane (edge) coloring schme.
Definition: GUIVisualizationSettings.cpp:1161
GUIVisualizationSettings::gridYSize
double gridYSize
Definition: GUIVisualizationSettings.h:423
DELTA_T
SUMOTime DELTA_T
Definition: SUMOTime.cpp:36
GUIPerspectiveChanger::getZPos
virtual double getZPos() const =0
Returns the camera height corresponding to the current zoom factor.
GUIVisualizationSettings::angle
double angle
The current view rotation angle.
Definition: GUIVisualizationSettings.h:405
GUISUMOAbstractView::isInEditMode
bool isInEditMode()
returns true, if the edit button was pressed
Definition: GUISUMOAbstractView.cpp:169
GUISUMOAbstractView::getObjectsUnderCursor
std::vector< GUIGlID > getObjectsUnderCursor()
returns the id of the objects under the cursor using GL_SELECT (including overlapped objects)
Definition: GUISUMOAbstractView.cpp:335
RGBColor::BLACK
static const RGBColor BLACK
Definition: RGBColor.h:197
Position::z
double z() const
Returns the z-position.
Definition: Position.h:66
GUIVisualizationSettings::drawForRectangleSelection
bool drawForRectangleSelection
whether drawing is performed for the purpose of selecting objects using a rectangle
Definition: GUIVisualizationSettings.h:647
GUISUMOAbstractView::setColorScheme
virtual bool setColorScheme(const std::string &)
set color scheme
Definition: GUISUMOAbstractView.cpp:1389
GUISUMOAbstractView::getColoringSchemesCombo
FXComboBox * getColoringSchemesCombo()
get coloring schemes combo
Definition: GUISUMOAbstractView.cpp:1450
Position::INVALID
static const Position INVALID
used to indicate that a position is valid
Definition: Position.h:284
GUISUMOAbstractView::showViewschemeEditor
void showViewschemeEditor()
show viewsscheme editor
Definition: GUISUMOAbstractView.cpp:1321
GUISUMOAbstractView::myDecals
std::vector< Decal > myDecals
Definition: GUISUMOAbstractView.h:491
GUIMainWindow::setStatusBarText
virtual void setStatusBarText(const std::string &)
Definition: GUIMainWindow.h:76
GUISUMOAbstractView::waitForSnapshots
void waitForSnapshots(const SUMOTime snapshotTime)
Definition: GUISUMOAbstractView.cpp:1306
GUISUMOAbstractView::myParent
GUIGlChildWindow * myParent
The parent window.
Definition: GUISUMOAbstractView.h:450
GUIPolygon.h
GUIGlObject::getPopUpMenu
virtual GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)=0
Returns an own popup-menu.
GUISUMOAbstractView::m2p
double m2p(double meter) const
meter-to-pixels conversion method
Definition: GUISUMOAbstractView.cpp:771
Position::setx
void setx(double x)
set position x
Definition: Position.h:71
GUISUMOAbstractView::onGamingRightClick
virtual void onGamingRightClick(Position)
Definition: GUISUMOAbstractView.cpp:1445
MsgHandler.h
GUIVisualizationSettings::showGrid
bool showGrid
Information whether a grid shall be shown.
Definition: GUIVisualizationSettings.h:420
GUIDanielPerspectiveChanger.h
GUISUMOAbstractView::getGUIGlObjectsUnderCursor
std::vector< GUIGlObject * > getGUIGlObjectsUnderCursor()
returns the GUIGlObject under the cursor using GL_SELECT (including overlapped objects)
Definition: GUISUMOAbstractView.cpp:351
GUIGLObjectPopupMenu.h
GUISUMOAbstractView::getObjectUnderCursor
GUIGlID getObjectUnderCursor()
returns the id of the front object under the cursor using GL_SELECT
Definition: GUISUMOAbstractView.cpp:329
GUIGlobalSelection.h
GUISUMOAbstractView::centerTo
virtual void centerTo(GUIGlID id, bool applyZoom, double zoomDist=20)
centers to the chosen artifact
Definition: GUISUMOAbstractView.cpp:789
GUISUMOAbstractView::Decal::centerY
double centerY
The center of the image in y-direction (net coordinates, in m)
Definition: GUISUMOAbstractView.h:312
GUISUMOAbstractView::showToolTips
void showToolTips(bool val)
show tool tips
Definition: GUISUMOAbstractView.cpp:1383
GUIMainWindow::setDelay
virtual void setDelay(double)
Sets the delay of the parent application.
Definition: GUIMainWindow.h:112
GeoConvHelper::getProcessing
static GeoConvHelper & getProcessing()
the coordinate transformation to use for input conversion and processing
Definition: GeoConvHelper.h:86
GUISUMOAbstractView::Decal::filename
std::string filename
The path to the file the image is located at.
Definition: GUISUMOAbstractView.h:308
GUISUMOAbstractView::drawFPS
void drawFPS()
Draws frames-per-second indicator.
Definition: GUISUMOAbstractView.cpp:751
SUMOTime
long long int SUMOTime
Definition: SUMOTime.h:34
FONS_ALIGN_LEFT
@ FONS_ALIGN_LEFT
Definition: fontstash.h:42
GeoConvHelper.h
Boundary::xmax
double xmax() const
Returns maximum x-coordinate.
Definition: Boundary.cpp:124
GUIPerspectiveChanger::onRightBtnPress
virtual void onRightBtnPress(void *data)
called when user press right button
Definition: GUIPerspectiveChanger.cpp:54
GUISUMOAbstractView::addSnapshot
void addSnapshot(SUMOTime time, const std::string &file, const int w=-1, const int h=-1)
Sets the snapshot time to file map.
Definition: GUISUMOAbstractView.cpp:1097
Boundary::getHeight
double getHeight() const
Returns the height of the boundary (y-axis)
Definition: Boundary.cpp:160
GUISUMOAbstractView::applyGLTransform
Boundary applyGLTransform(bool fixRatio=true)
applies gl-transformations to fit the Boundary given by myChanger onto the canvas....
Definition: GUISUMOAbstractView.cpp:1621
GUIPerspectiveChanger::getRotation
virtual double getRotation() const =0
Returns the rotation of the canvas stored in this changer.
SUMO_const_laneWidth
const double SUMO_const_laneWidth
Definition: StdDefs.h:49
GUISUMOAbstractView::checkSnapshots
virtual void checkSnapshots()
Checks whether it is time for a snapshot.
Definition: GUISUMOAbstractView.cpp:1273
GLO_PERSON
@ GLO_PERSON
Definition: GUIGlObjectTypes.h:159
GUIVisualizationSettings.h
RGBColor::red
unsigned char red() const
Returns the red-amount of the color.
Definition: RGBColor.h:61
GLO_VEHICLE
@ GLO_VEHICLE
Definition: GUIGlObjectTypes.h:141
GLHelper.h
GUISUMOAbstractView::getObjectAtPosition
GUIGlID getObjectAtPosition(Position pos)
returns the id of the object at position using GL_SELECT
Definition: GUISUMOAbstractView.cpp:357
GUIPerspectiveChanger::setRotation
virtual void setRotation(double rotation)=0
Sets the rotation.
GUISUMOAbstractView::Decal::height
double height
The height of the image (net coordinates in y-direction, in m)
Definition: GUISUMOAbstractView.h:318
FONS_ALIGN_RIGHT
@ FONS_ALIGN_RIGHT
Definition: fontstash.h:44
FXDEFMAP
FXDEFMAP(GUISUMOAbstractView) GUISUMOAbstractViewMap[]
GLHelper::setColor
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
Definition: GLHelper.cpp:621
GUISUMOAbstractView::setWindowCursorPosition
void setWindowCursorPosition(FXint x, FXint y)
Returns the gl-id of the object under the given coordinates.
Definition: GUISUMOAbstractView.cpp:834
GUIDialog_ViewSettings::show
void show()
show view settings dialog
Definition: GUIDialog_ViewSettings.cpp:593
GUISUMOAbstractView::updateToolTip
void updateToolTip()
A method that updates the tooltip.
Definition: GUISUMOAbstractView.cpp:181
GUISUMOAbstractView::Decal::skip2D
bool skip2D
Whether this image should be skipped in 2D-views.
Definition: GUISUMOAbstractView.h:332
GUISUMOAbstractView::paintGL
void paintGL()
performs the painting of the simulation
Definition: GUISUMOAbstractView.cpp:274
GUISUMOAbstractView::snapToActiveGrid
Position snapToActiveGrid(const Position &pos, bool snapXY=true) const
Returns a position that is mapped to the closest grid point if the grid is active.
Definition: GUISUMOAbstractView.cpp:196
GUIPerspectiveChanger::onMouseMove
virtual void onMouseMove(void *data)
called when user moves mouse
Definition: GUIPerspectiveChanger.cpp:74
GUIDialog_EditViewport::setOldValues
void setOldValues(const Position &lookFrom, const Position &lookAt, double rotation)
Resets old values.
Definition: GUIDialog_EditViewport.cpp:285
gPrecisionGeo
int gPrecisionGeo
Definition: StdDefs.cpp:27
RGBColor.h
GUITexturesHelper::drawTexturedBox
static void drawTexturedBox(int which, double size)
Draws a named texture as a box with the given size.
Definition: GUITexturesHelper.cpp:72
GUIPerspectiveChanger::getViewport
Boundary getViewport(bool fixRatio=true)
get viewport
Definition: GUIPerspectiveChanger.cpp:103
GUIPerspectiveChanger::onKeyPress
virtual long onKeyPress(void *data)
called when user press a key
Definition: GUIPerspectiveChanger.cpp:79
GUIPerspectiveChanger::centerTo
virtual void centerTo(const Position &pos, double radius, bool applyZoom=true)=0
Centers the view to the given position, setting it to a size that covers the radius....
GUISUMOAbstractView::onMouseWheel
virtual long onMouseWheel(FXObject *, FXSelector, void *)
Definition: GUISUMOAbstractView.cpp:997
GUISUMOAbstractView::updatePositionInformation
void updatePositionInformation() const
update position information
Definition: GUISUMOAbstractView.cpp:242
SysUtils::getCurrentMillis
static long getCurrentMillis()
Returns the current time in milliseconds.
Definition: SysUtils.cpp:38
GUIGlObjectStorage.h
GUIMainWindow.h
GLO_POLYGON
@ GLO_POLYGON
a polygon
Definition: GUIGlObjectTypes.h:104
GUIAppEnum.h
MFXImageHelper::scalePower2
static FXbool scalePower2(FXImage *image, int maxSize=(2<< 29))
Definition: MFXImageHelper.cpp:106
GUIPropertyScheme::getThresholds
const std::vector< double > & getThresholds() const
Definition: GUIPropertyScheme.h:145
GUIVisualizationSettings::getLaneEdgeScheme
GUIColorScheme & getLaneEdgeScheme()
Returns the current lane (edge) coloring schme.
Definition: GUIVisualizationSettings.cpp:1179
GUISUMOAbstractView::onRightBtnRelease
virtual long onRightBtnRelease(FXObject *, FXSelector, void *)
Definition: GUISUMOAbstractView.cpp:976
GUIGlObjectType
GUIGlObjectType
Definition: GUIGlObjectTypes.h:39
MAX2
T MAX2(T a, T b)
Definition: StdDefs.h:79
GUISUMOAbstractView::Decal::layer
double layer
The layer of the image.
Definition: GUISUMOAbstractView.h:328
GUISUMOAbstractView.h
SUMORTree
A RT-tree for efficient storing of SUMO's GL-objects.
Definition: SUMORTree.h:68
GUISUMOAbstractView::myAmInitialised
bool myAmInitialised
Internal information whether doInit() was called.
Definition: GUISUMOAbstractView.h:477
RGBColor::interpolate
static RGBColor interpolate(const RGBColor &minColor, const RGBColor &maxColor, double weight)
Interpolates between two colors.
Definition: RGBColor.cpp:282
GUIDialog_EditViewport
A dialog to change the viewport.
Definition: GUIDialog_EditViewport.h:42
GLHelper::drawText
static void drawText(const std::string &text, const Position &pos, const double layer, const double size, const RGBColor &col=RGBColor::BLACK, const double angle=0, int align=0, double width=-1)
Definition: GLHelper.cpp:673
RGBColor
Definition: RGBColor.h:39
GUIVisualizationSettings::gridXSize
double gridXSize
Information about the grid spacings.
Definition: GUIVisualizationSettings.h:423
GUIVisualizationSettings::backgroundColor
RGBColor backgroundColor
The background color to use.
Definition: GUIVisualizationSettings.h:417
GUIPerspectiveChanger::onRightBtnRelease
virtual bool onRightBtnRelease(void *data)
called when user releases right button
Definition: GUIPerspectiveChanger.cpp:59
GUISUMOAbstractView::getGUIGlObjectsAtPosition
std::vector< GUIGlObject * > getGUIGlObjectsAtPosition(Position pos, double radius)
returns the GUIGlObjects at position within the given (rectangular) radius using GL_SELECT
Definition: GUISUMOAbstractView.cpp:442
GUISUMOAbstractView::myFrameDrawTime
long myFrameDrawTime
counter for measuring rendering time
Definition: GUISUMOAbstractView.h:513
GUISUMOAbstractView::getObjectsAtPosition
std::vector< GUIGlID > getObjectsAtPosition(Position pos, double radius)
returns the ids of the object at position within the given (rectangular) radius using GL_SELECT
Definition: GUISUMOAbstractView.cpp:407
GUIPropertyScheme::getColors
const std::vector< T > & getColors() const
Definition: GUIPropertyScheme.h:141
GUISUMOAbstractView::Decal::screenRelative
bool screenRelative
Whether this image should be skipped in 2D-views.
Definition: GUISUMOAbstractView.h:334
GUISUMOAbstractView::onLeftBtnRelease
virtual long onLeftBtnRelease(FXObject *, FXSelector, void *)
Definition: GUISUMOAbstractView.cpp:943
GUIGlObject::INVALID_ID
static const GUIGlID INVALID_ID
Definition: GUIGlObject.h:69
GUISUMOAbstractView::myMouseHotspotY
int myMouseHotspotY
Definition: GUISUMOAbstractView.h:462
GUIMainWindow::isGaming
bool isGaming() const
return whether the gui is in gaming mode
Definition: GUIMainWindow.h:82
GUISUMOAbstractView::getCurrentTimeStep
virtual SUMOTime getCurrentTimeStep() const
get the current simulation time
Definition: GUISUMOAbstractView.cpp:1315
GUISUMOAbstractView::myInEditMode
bool myInEditMode
Information whether too-tip informations shall be generated.
Definition: GUISUMOAbstractView.h:459
GUISUMOAbstractView::displayLegend
void displayLegend()
Draws a line with ticks, and the length information.
Definition: GUISUMOAbstractView.cpp:582
Boundary::xmin
double xmin() const
Returns minimum x-coordinate.
Definition: Boundary.cpp:118
GUIPointOfInterest.h
GUISUMOAbstractView::Decal::rot
double rot
The rotation of the image in the ground plane (in degrees)
Definition: GUISUMOAbstractView.h:322
GeoConvHelper::getFinal
static const GeoConvHelper & getFinal()
the coordinate transformation for writing the location element and for tracking the original coordina...
Definition: GeoConvHelper.h:105
GUIMainWindow::getCartesianLabel
FXLabel & getCartesianLabel()
Definition: GUIMainWindow.cpp:170
GUITexturesHelper::getMaxTextureSize
static int getMaxTextureSize()
return maximum number of pixels in x and y direction
Definition: GUITexturesHelper.cpp:47
GUIVisualizationSettings::showColorLegend
bool showColorLegend
Information whether the colo legend shall be drawn.
Definition: GUIVisualizationSettings.h:629
GUIDanielPerspectiveChanger
Definition: GUIDanielPerspectiveChanger.h:50
GUISUMOAbstractView::getVisualisationSettings
GUIVisualizationSettings * getVisualisationSettings() const
get visualitation settings
Definition: GUISUMOAbstractView.cpp:1395
SysUtils.h
GUIGlObjectStorage::getNetObject
GUIGlObject * getNetObject() const
Returns the network object.
Definition: GUIGlObjectStorage.h:133
GUISUMOAbstractView::onDoubleClicked
virtual long onDoubleClicked(FXObject *, FXSelector, void *)
Definition: GUISUMOAbstractView.cpp:991
Position::set
void set(double x, double y)
set positions x and y
Definition: Position.h:86
GUIPropertyScheme::isFixed
bool isFixed() const
Definition: GUIPropertyScheme.h:157
GUIMainWindow::setBreakpoints
virtual void setBreakpoints(const std::vector< SUMOTime > &)
Sets the breakpoints of the parent application.
Definition: GUIMainWindow.h:116
GUITexturesHelper.h
GUIPerspectiveChanger::onKeyRelease
virtual long onKeyRelease(void *data)
called when user releases a key
Definition: GUIPerspectiveChanger.cpp:85
GUIPerspectiveChanger::onMouseWheel
virtual void onMouseWheel(void *data)
called when user changes mouse wheel
Definition: GUIPerspectiveChanger.cpp:69
GUISUMOAbstractView::myWindowCursorPositionY
FXint myWindowCursorPositionY
Definition: GUISUMOAbstractView.h:483
GUISUMOAbstractView::onMiddleBtnRelease
virtual long onMiddleBtnRelease(FXObject *, FXSelector, void *)
Definition: GUISUMOAbstractView.cpp:961
GUIGlObject::getGlID
GUIGlID getGlID() const
Returns the numerical id of the object.
Definition: GUIGlObject.cpp:149
GUISUMOAbstractView::onConfigure
virtual long onConfigure(FXObject *, FXSelector, void *)
mouse functions
Definition: GUISUMOAbstractView.cpp:848
update
Boundary
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:41
GUISUMOAbstractView::myWindowCursorPositionX
FXint myWindowCursorPositionX
Position of the cursor relative to the window.
Definition: GUISUMOAbstractView.h:483
FXSingleEventThread.h
GUISUMOAbstractView::mySnapshotCondition
FXCondition mySnapshotCondition
the semaphore when waiting for snapshots to finish
Definition: GUISUMOAbstractView.h:504
Boundary::getWidth
double getWidth() const
Returns the width of the boudary (x-axis)
Definition: Boundary.cpp:154
GUIVisualizationSettings::scale
double scale
information about a lane's width (temporary, used for a single view)
Definition: GUIVisualizationSettings.h:632
GeoConvHelper::cartesian2geo
void cartesian2geo(Position &cartesian) const
Converts the given cartesian (shifted) position to its geo (lat/long) representation.
Definition: GeoConvHelper.cpp:293
Position
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:38
GLO_EDGE
@ GLO_EDGE
an edge
Definition: GUIGlObjectTypes.h:46
GUISUMOAbstractView::onMouseLeft
virtual long onMouseLeft(FXObject *, FXSelector, void *)
Definition: GUISUMOAbstractView.cpp:1034
gSchemeStorage
GUICompleteSchemeStorage gSchemeStorage
Definition: GUICompleteSchemeStorage.cpp:38
Position::x
double x() const
Returns the x-position.
Definition: Position.h:56
Boundary::add
void add(double x, double y, double z=0)
Makes the boundary include the given coordinate.
Definition: Boundary.cpp:78
GUIPerspectiveChanger::getZoom
virtual double getZoom() const =0
Returns the zoom factor computed stored in this changer.
GUIVisualizationSettings::dither
bool dither
Information whether dithering shall be enabled.
Definition: GUIVisualizationSettings.h:408
GUISUMOAbstractView::remove
void remove(GUIDialog_EditViewport *)
remove viewport
Definition: GUISUMOAbstractView.cpp:1401
RGBColor::RED
static const RGBColor RED
named colors
Definition: RGBColor.h:189
GLO_POI
@ GLO_POI
a poi
Definition: GUIGlObjectTypes.h:106
GLO_LANE
@ GLO_LANE
a lane
Definition: GUIGlObjectTypes.h:48
GUISUMOAbstractView::SENSITIVITY
static const double SENSITIVITY
Definition: GUISUMOAbstractView.h:517
GUIMainWindow::getGeoLabel
FXLabel & getGeoLabel()
Definition: GUIMainWindow.cpp:176
GUISUMOAbstractView::myVisualizationSettings
GUIVisualizationSettings * myVisualizationSettings
visualization settings
Definition: GUISUMOAbstractView.h:471
GUISUMOAbstractView::drawDecals
void drawDecals()
Draws the stored decals.
Definition: GUISUMOAbstractView.cpp:1535
GUITexturesHelper::add
static GUIGlID add(FXImage *i)
Adds a texture to use.
Definition: GUITexturesHelper.cpp:55
GUIGlObjectStorage::getObjectBlocking
GUIGlObject * getObjectBlocking(GUIGlID id)
Returns the object from the container locking it.
Definition: GUIGlObjectStorage.cpp:62
GUICompleteSchemeStorage::setDefault
void setDefault(const std::string &name)
Makes the scheme with the given name the default.
Definition: GUICompleteSchemeStorage.cpp:90
Shape
A 2D- or 3D-Shape.
Definition: Shape.h:38
GUIVisualizationTextSettings::show
bool show
flag show
Definition: GUIVisualizationSettings.h:68
GUIGlObject
Definition: GUIGlObject.h:65
GUISUMOAbstractView::getPositionInformation
Position getPositionInformation() const
Returns the cursor's x/y position within the network.
Definition: GUISUMOAbstractView.cpp:190
RGBColor::green
unsigned char green() const
Returns the green-amount of the color.
Definition: RGBColor.h:68
GUIDialog_ViewSettings.h
GUISUMOAbstractView::onKeyRelease
virtual long onKeyRelease(FXObject *o, FXSelector sel, void *data)
Definition: GUISUMOAbstractView.cpp:1085
GUISUMOAbstractView::startTrack
virtual void startTrack(int)
star track
Definition: GUISUMOAbstractView.cpp:1425
GUISUMOAbstractView::getPopupPosition
const Position & getPopupPosition() const
get position of current popup
Definition: GUISUMOAbstractView.cpp:879
DEG2RAD
#define DEG2RAD(x)
Definition: GeomHelper.h:37
GUISUMOAbstractView::getViewportEditor
GUIDialog_EditViewport * getViewportEditor()
get the viewport and create it on first access
Definition: GUISUMOAbstractView.cpp:1336
MID_GLCANVAS
@ MID_GLCANVAS
GLCanvas - ID.
Definition: GUIAppEnum.h:361
GLIncludes.h
GUIGlObjectStorage::unblockObject
void unblockObject(GUIGlID id)
Marks an object as unblocked.
Definition: GUIGlObjectStorage.cpp:119
GUIVisualizationSettings::showSizeLegend
bool showSizeLegend
Information whether the size legend shall be drawn.
Definition: GUIVisualizationSettings.h:626
GUISUMOAbstractView::onGamingClick
virtual void onGamingClick(Position)
on gaming click
Definition: GUISUMOAbstractView.cpp:1441
toString
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:47
StringUtils.h
GUISUMOAbstractView::makeSnapshot
std::string makeSnapshot(const std::string &destFile, const int w=-1, const int h=-1)
Takes a snapshots and writes it into the given file.
Definition: GUISUMOAbstractView.cpp:1107
PointOfInterest.h
GUIPerspectiveChanger::onLeftBtnPress
virtual void onLeftBtnPress(void *data)
mouse functions
Definition: GUIPerspectiveChanger.cpp:43
GUISUMOAbstractView::removeAdditionalGLVisualisation
bool removeAdditionalGLVisualisation(GUIGlObject *const which)
Removes an object from the list of objects that show additional things.
Definition: GUISUMOAbstractView.cpp:1595
GUIMainWindow
Definition: GUIMainWindow.h:46
Position::y
double y() const
Returns the y-position.
Definition: Position.h:61
GUISUMOAbstractView::getChanger
GUIPerspectiveChanger & getChanger() const
get changer
Definition: GUISUMOAbstractView.cpp:175
GUIGlObject::getCenteringBoundary
virtual Boundary getCenteringBoundary() const =0
RGBColor::blue
unsigned char blue() const
Returns the blue-amount of the color.
Definition: RGBColor.h:75
GUISUMOAbstractView::getFPS
double getFPS() const
retrieve FPS
Definition: GUISUMOAbstractView.cpp:746
GUISUMOAbstractView::addAdditionalGLVisualisation
bool addAdditionalGLVisualisation(GUIGlObject *const which)
Adds an object to call its additional visualisation method.
Definition: GUISUMOAbstractView.cpp:1583
GUISUMOAbstractView::setDelay
void setDelay(double delay)
Sets the delay of the parent application.
Definition: GUISUMOAbstractView.cpp:1661
Boundary::getCenter
Position getCenter() const
Returns the center of the boundary.
Definition: Boundary.cpp:112
GUISUMOAbstractView::p2m
double p2m(double pixel) const
pixels-to-meters conversion method
Definition: GUISUMOAbstractView.cpp:777
GUISUMOAbstractView::getDelay
double getDelay() const
Returns the delay of the parent application.
Definition: GUISUMOAbstractView.cpp:1655
GUISUMOAbstractView::checkGDALImage
FXImage * checkGDALImage(Decal &d)
check whether we can read image data or position with gdal
Definition: GUISUMOAbstractView.cpp:1456
GUISUMOAbstractView::getWindowCursorPosition
Position getWindowCursorPosition() const
Returns the information whether rotation is allowd.
Definition: GUISUMOAbstractView.cpp:828
GUISUMOAbstractView::showToolTipFor
void showToolTipFor(const GUIGlID id)
invokes the tooltip for the given object
Definition: GUISUMOAbstractView.cpp:520
GUIGlID
unsigned int GUIGlID
Definition: GUIGlObject.h:42
InvalidArgument
Definition: UtilExceptions.h:56
GUIDialog_EditViewport::show
void show()
overload show function to focus always in OK Button
Definition: GUIDialog_EditViewport.cpp:145
GUISUMOAbstractView::Decal::Decal
Decal()
Constructor.
Definition: GUISUMOAbstractView.cpp:1672
GUISUMOAbstractView::myApp
GUIMainWindow * myApp
The application.
Definition: GUISUMOAbstractView.h:447
GUIGlChildWindow.h
GUIPerspectiveChanger::setViewport
virtual void setViewport(double zoom, double xPos, double yPos)=0
Sets the viewport Used for: Adapting a new viewport.
GUICompleteSchemeStorage::saveViewport
void saveViewport(const double x, const double y, const double z, const double rot)
Makes the given viewport the default.
Definition: GUICompleteSchemeStorage.cpp:227
GUISUMOAbstractView::myGrid
SUMORTree * myGrid
The visualization speed-up.
Definition: GUISUMOAbstractView.h:453
GUIGlObjectStorage::gIDStorage
static GUIGlObjectStorage gIDStorage
A single static instance of this class.
Definition: GUIGlObjectStorage.h:140
GUISUMOAbstractView::~GUISUMOAbstractView
virtual ~GUISUMOAbstractView()
destructor
Definition: GUISUMOAbstractView.cpp:151
GUISUMOAbstractView::paintGLGrid
void paintGLGrid()
paints a grid
Definition: GUISUMOAbstractView.cpp:540
gSelected
GUISelectedStorage gSelected
A global holder of selected objects.
Definition: GUIGlobalSelection.cpp:33
GUIGlChildWindow::getColoringSchemesCombo
FXComboBox * getColoringSchemesCombo()
return combobox with the current coloring schemes (standard, fastest standard, real world....
Definition: GUIGlChildWindow.cpp:183
joinToString
std::string joinToString(const std::vector< T > &v, const T_BETWEEN &between, std::streamsize accuracy=gPrecision)
Definition: ToString.h:246
GUISUMOAbstractView::onMiddleBtnPress
virtual long onMiddleBtnPress(FXObject *, FXSelector, void *)
Definition: GUISUMOAbstractView.cpp:955
GUISUMOAbstractView::setBreakpoints
void setBreakpoints(const std::vector< SUMOTime > &breakpoints)
Sets the breakpoints of the parent application.
Definition: GUISUMOAbstractView.cpp:1667
GUIDialog_EditViewport.h
GUISUMOAbstractView::myUseToolTips
bool myUseToolTips
use tool tips
Definition: GUISUMOAbstractView.h:474
MFXImageHelper::saveImage
static FXbool saveImage(const std::string &file, int width, int height, FXColor *data)
Definition: MFXImageHelper.cpp:138
GUISUMOAbstractView::onKeyPress
virtual long onKeyPress(FXObject *o, FXSelector sel, void *data)
keyboard functions
Definition: GUISUMOAbstractView.cpp:1074
GUISUMOAbstractView::Decal::initialised
bool initialised
Whether this image was initialised (inserted as a texture)
Definition: GUISUMOAbstractView.h:330
GUISUMOAbstractView::getGUIGlObjectsUnderGrippedCursor
std::vector< GUIGlObject * > getGUIGlObjectsUnderGrippedCursor()
returns the GUIGlObject under the gripped cursor using GL_SELECT (including overlapped objects)
Definition: GUISUMOAbstractView.cpp:341
GUISUMOAbstractView::addDecals
void addDecals(const std::vector< Decal > &decals)
add decals
Definition: GUISUMOAbstractView.cpp:230
GUIDialog_EditViewport::setValues
void setValues(double zoom, double xoff, double yoff, double rotation)
Sets the given values into the dialog.
Definition: GUIDialog_EditViewport.cpp:258
GUISUMOAbstractView::myPopup
GUIGLObjectPopupMenu * myPopup
The current popup-menu.
Definition: GUISUMOAbstractView.h:465
GUIPropertyScheme::getNames
const std::vector< std::string > & getNames() const
Definition: GUIPropertyScheme.h:153
config.h
SUMORTree::Search
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:118
GUIVisualizationSettings::addSize
GUIVisualizationSizeSettings addSize
Definition: GUIVisualizationSettings.h:589
GUIPerspectiveChanger::setViewportFrom
virtual void setViewportFrom(double xPos, double yPos, double zPos)=0
Alternative method for setting the viewport.
GUISUMOAbstractView::myVisualizationChanger
GUIDialog_ViewSettings * myVisualizationChanger
Visualization changer.
Definition: GUISUMOAbstractView.h:486
Position::add
void add(const Position &pos)
Adds the given position to this one.
Definition: Position.h:126
GeomHelper.h
Boundary::grow
Boundary & grow(double by)
extends the boundary by the given amount
Definition: Boundary.cpp:300
GUIGlObject::onLeftBtnPress
virtual void onLeftBtnPress(void *)
notify object about left click
Definition: GUIGlObject.h:165
GUISUMOAbstractView::recenterView
virtual void recenterView()
recenters the view
Definition: GUISUMOAbstractView.cpp:783
GUISUMOAbstractView::mySnapshotsMutex
FXMutex mySnapshotsMutex
The mutex to use before accessing the decals list in order to avoid thread conflicts.
Definition: GUISUMOAbstractView.h:501
GUIPerspectiveChanger::getXPos
virtual double getXPos() const =0
Returns the x-offset of the field to show stored in this changer.
GUISUMOAbstractView::getObjectsInBoundary
std::vector< GUIGlID > getObjectsInBoundary(Boundary bound, bool singlePosition)
returns the ids of all objects in the given boundary
Definition: GUISUMOAbstractView.cpp:472
GUISUMOAbstractView::saveFrame
virtual void saveFrame(const std::string &destFile, FXColor *buf)
Adds a frame to a video snapshot which will be initialized if neccessary.
Definition: GUISUMOAbstractView.cpp:1266
GUISUMOAbstractView::onLeftBtnPress
virtual long onLeftBtnPress(FXObject *, FXSelector, void *)
Definition: GUISUMOAbstractView.cpp:894
GUISUMOAbstractView::myViewportChooser
GUIDialog_EditViewport * myViewportChooser
viewport chooser
Definition: GUISUMOAbstractView.h:480
GUISUMOAbstractView::screenPos2NetPos
Position screenPos2NetPos(int x, int y) const
Translate screen position to network position.
Definition: GUISUMOAbstractView.cpp:215
GUIPerspectiveChanger::onLeftBtnRelease
virtual bool onLeftBtnRelease(void *data)
called when user releases left button
Definition: GUIPerspectiveChanger.cpp:48
GUIGlChildWindow
Definition: GUIGlChildWindow.h:40
GUIVisualizationSettings
Stores the information about how to visualize structures.
Definition: GUIVisualizationSettings.h:345
GUICompleteSchemeStorage::setViewport
void setViewport(GUISUMOAbstractView *view)
Sets the default viewport.
Definition: GUICompleteSchemeStorage.cpp:234
GUISelectedStorage::toggleSelection
void toggleSelection(GUIGlID id)
Toggles selection of an object.
Definition: GUISelectedStorage.cpp:147
GUISUMOAbstractView::destroyPopup
void destroyPopup()
destoys the popup
Definition: GUISUMOAbstractView.cpp:884
GUISUMOAbstractView::mySnapshots
std::map< SUMOTime, std::vector< std::tuple< std::string, int, int > > > mySnapshots
Snapshots.
Definition: GUISUMOAbstractView.h:498
GUISUMOAbstractView::myChanger
GUIPerspectiveChanger * myChanger
The perspective changer.
Definition: GUISUMOAbstractView.h:456
Position::sety
void sety(double y)
set position y
Definition: Position.h:76
GUISUMOAbstractView::onMouseMove
virtual long onMouseMove(FXObject *, FXSelector, void *)
Definition: GUISUMOAbstractView.cpp:1013
GUISUMOAbstractView::displayColorLegend
void displayColorLegend()
Draws a legend for the current edge coloring scheme.
Definition: GUISUMOAbstractView.cpp:648
GUIDialog_EditViewport::haveGrabbed
bool haveGrabbed() const
Returns the information whether one of the spin dialers is grabbed.
Definition: GUIDialog_EditViewport.cpp:294
GUISUMOAbstractView::Decal::width
double width
The width of the image (net coordinates in x-direction, in m)
Definition: GUISUMOAbstractView.h:316
GUISUMOAbstractView::myPopupPosition
Position myPopupPosition
The current popup-menu position.
Definition: GUISUMOAbstractView.h:468
GLO_REROUTER_EDGE
@ GLO_REROUTER_EDGE
a Rerouter
Definition: GUIGlObjectTypes.h:87
GUIDialog_ViewSettings::setCurrent
void setCurrent(GUIVisualizationSettings *settings)
Sets current settings (called if reopened)
Definition: GUIDialog_ViewSettings.cpp:601
Position::setz
void setz(double z)
set position z
Definition: Position.h:81
GUISUMOAbstractView::Decal::centerX
double centerX
The center of the image in x-direction (net coordinates, in m)
Definition: GUISUMOAbstractView.h:310
GUIVisualizationSettings::gaming
bool gaming
whether the application is in gaming mode or not
Definition: GUIVisualizationSettings.h:635
GUISUMOAbstractView::Decal
A decal (an image) that can be shown.
Definition: GUISUMOAbstractView.h:303
WRITE_ERROR
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:283
GUISUMOAbstractView::Decal::glID
int glID
whether the decal shall be drawn in screen coordinates, rather than network coordinates
Definition: GUISUMOAbstractView.h:336
WRITE_MESSAGE
#define WRITE_MESSAGE(msg)
Definition: MsgHandler.h:277
GLHelper::setGL2PS
static void setGL2PS(bool active=true)
Definition: GLHelper.h:350
GUIVisualizationSettings::edgeValue
GUIVisualizationTextSettings edgeValue
Definition: GUIVisualizationSettings.h:461
GLHelper::drawTextBox
static void drawTextBox(const std::string &text, const Position &pos, const double layer, const double size, const RGBColor &txtColor=RGBColor::BLACK, const RGBColor &bgColor=RGBColor::WHITE, const RGBColor &borderColor=RGBColor::BLACK, const double angle=0, const double relBorder=0.05, const double relMargin=0.5)
draw Text box with given parameters
Definition: GLHelper.cpp:722
GUIPropertyScheme
Definition: GUIPropertyScheme.h:45
GUISUMOAbstractView::doPaintGL
virtual int doPaintGL(int, const Boundary &)
paint GL
Definition: GUISUMOAbstractView.cpp:257
GUISUMOAbstractView::getTrackedID
virtual GUIGlID getTrackedID() const
get tracked id
Definition: GUISUMOAbstractView.cpp:1435
GUIVisualizationSizeSettings::getExaggeration
double getExaggeration(const GUIVisualizationSettings &s, const GUIGlObject *o, double factor=20) const
return the drawing size including exaggeration and constantSize values
Definition: GUIVisualizationSettings.cpp:212
GUISUMOAbstractView::myDecalsLock
FXMutex myDecalsLock
The mutex to use before accessing the decals list in order to avoid thread conflicts.
Definition: GUISUMOAbstractView.h:494
GLO_NETWORK
@ GLO_NETWORK
The network - empty.
Definition: GUIGlObjectTypes.h:41
GUISUMOAbstractView::onPaint
virtual long onPaint(FXObject *, FXSelector, void *)
Definition: GUISUMOAbstractView.cpp:866
GUISUMOAbstractView::getGridWidth
double getGridWidth() const
get grid width
Definition: GUISUMOAbstractView.cpp:1413
MFXCheckableButton.h
RGBColor::WHITE
static const RGBColor WHITE
Definition: RGBColor.h:196
Boundary::ymax
double ymax() const
Returns maximum y-coordinate.
Definition: Boundary.cpp:136
GUISUMOAbstractView::isAdditionalGLVisualisationEnabled
bool isAdditionalGLVisualisationEnabled(GUIGlObject *const which) const
Check if an object is added in the additional GL visualitation.
Definition: GUISUMOAbstractView.cpp:1611
fontstash.h