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