SUMO - Simulation of Urban MObility
GUISUMOAbstractView.cpp
Go to the documentation of this file.
1 /****************************************************************************/
11 // The base class for a view
12 /****************************************************************************/
13 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
14 // Copyright (C) 2001-2017 DLR (http://www.dlr.de/) and contributors
15 /****************************************************************************/
16 //
17 // This file is part of SUMO.
18 // SUMO is free software: you can redistribute it and/or modify
19 // it under the terms of the GNU General Public License as published by
20 // the Free Software Foundation, either version 3 of the License, or
21 // (at your option) any later version.
22 //
23 /****************************************************************************/
24 
25 
26 // ===========================================================================
27 // included modules
28 // ===========================================================================
29 #ifdef _MSC_VER
30 #include <windows_config.h>
31 #else
32 #include <config.h>
33 #endif
34 
35 #include <iostream>
36 #include <utility>
37 #include <cmath>
38 #include <cassert>
39 #include <limits>
40 #include <fxkeys.h>
42 #include <gl2ps.h>
46 #include <utils/common/RGBColor.h>
47 #include <utils/common/ToString.h>
54 #include <utils/gui/div/GLHelper.h>
65 
66 #include "GUISUMOAbstractView.h"
67 #include "GUIMainWindow.h"
68 #include "GUIGlChildWindow.h"
70 #include "GUIDialog_EditViewport.h"
71 
72 #ifdef HAVE_GDAL
73 #if __GNUC__ > 3
74 #pragma GCC diagnostic push
75 #pragma GCC diagnostic ignored "-Wpedantic"
76 #endif
77 #include <gdal_priv.h>
78 #if __GNUC__ > 3
79 #pragma GCC diagnostic pop
80 #endif
81 #endif
82 
83 
84 // ===========================================================================
85 // member method definitions
86 // ===========================================================================
87 /* -------------------------------------------------------------------------
88  * GUISUMOAbstractView - FOX callback mapping
89  * ----------------------------------------------------------------------- */
90 FXDEFMAP(GUISUMOAbstractView) GUISUMOAbstractViewMap[] = {
91  FXMAPFUNC(SEL_CONFIGURE, 0, GUISUMOAbstractView::onConfigure),
92  FXMAPFUNC(SEL_PAINT, 0, GUISUMOAbstractView::onPaint),
93  FXMAPFUNC(SEL_LEFTBUTTONPRESS, 0, GUISUMOAbstractView::onLeftBtnPress),
94  FXMAPFUNC(SEL_LEFTBUTTONRELEASE, 0, GUISUMOAbstractView::onLeftBtnRelease),
95  FXMAPFUNC(SEL_MIDDLEBUTTONPRESS, 0, GUISUMOAbstractView::onMiddleBtnPress),
96  FXMAPFUNC(SEL_MIDDLEBUTTONRELEASE, 0, GUISUMOAbstractView::onMiddleBtnRelease),
97  FXMAPFUNC(SEL_RIGHTBUTTONPRESS, 0, GUISUMOAbstractView::onRightBtnPress),
98  FXMAPFUNC(SEL_RIGHTBUTTONRELEASE, 0, GUISUMOAbstractView::onRightBtnRelease),
99  FXMAPFUNC(SEL_DOUBLECLICKED, 0, GUISUMOAbstractView::onDoubleClicked),
100  FXMAPFUNC(SEL_MOUSEWHEEL, 0, GUISUMOAbstractView::onMouseWheel),
101  FXMAPFUNC(SEL_MOTION, 0, GUISUMOAbstractView::onMouseMove),
102  FXMAPFUNC(SEL_LEAVE, 0, GUISUMOAbstractView::onMouseLeft),
103  FXMAPFUNC(SEL_KEYPRESS, 0, GUISUMOAbstractView::onKeyPress),
104  FXMAPFUNC(SEL_KEYRELEASE, 0, GUISUMOAbstractView::onKeyRelease),
105 
106 };
107 
108 
109 FXIMPLEMENT_ABSTRACT(GUISUMOAbstractView, FXGLCanvas, GUISUMOAbstractViewMap, ARRAYNUMBER(GUISUMOAbstractViewMap))
110 
111 
112 /* -------------------------------------------------------------------------
113  * GUISUMOAbstractView - methods
114  * ----------------------------------------------------------------------- */
115 GUISUMOAbstractView::GUISUMOAbstractView(FXComposite* p, GUIMainWindow& app, GUIGlChildWindow* parent, const SUMORTree& grid, FXGLVisual* glVis, FXGLCanvas* share) :
116  FXGLCanvas(p, glVis, share, p, MID_GLCANVAS, LAYOUT_SIDE_TOP | LAYOUT_FILL_X | LAYOUT_FILL_Y, 0, 0, 0, 0),
117  myApp(&app),
118  myParent(parent),
119  myGrid(&((SUMORTree&)grid)),
120  myChanger(0),
121  myMouseHotspotX(app.getDefaultCursor()->getHotX()),
122  myMouseHotspotY(app.getDefaultCursor()->getHotY()),
123  myPopup(0),
124  myUseToolTips(false),
125  myAmInitialised(false),
126  myViewportChooser(0),
127  myWindowCursorPositionX(getWidth() / 2),
128  myWindowCursorPositionY(getHeight() / 2),
129  myVisualizationChanger(0) {
130  setTarget(this);
131  enable();
132  flags |= FLAG_ENABLED;
133  myInEditMode = false;
134  // show the middle at the beginning
135  myChanger = new GUIDanielPerspectiveChanger(*this, *myGrid);
136  myVisualizationSettings = &gSchemeStorage.getDefault();
137  myVisualizationSettings->gaming = myApp->isGaming();
139 }
140 
141 
145  delete myPopup;
146  delete myChanger;
147  delete myViewportChooser;
148  delete myVisualizationChanger;
149  // cleanup decals
150  for (std::vector<GUISUMOAbstractView::Decal>::iterator it = myDecals.begin(); it != myDecals.end(); ++it) {
151  delete it->image;
152  }
153 }
154 
155 
156 bool
158  return myInEditMode;
159 }
160 
161 
164  return *myChanger;
165 }
166 
167 
168 void
170  if (!myUseToolTips) {
171  return;
172  }
173  update();
174 }
175 
176 
177 Position
180 }
181 
182 
183 Position
185  Position result = pos;
187  const double xRest = std::fmod(pos.x(), myVisualizationSettings->gridXSize) + (pos.x() < 0 ? myVisualizationSettings->gridXSize : 0);
188  const double yRest = std::fmod(pos.y(), myVisualizationSettings->gridYSize) + (pos.y() < 0 ? myVisualizationSettings->gridYSize : 0);
189  result.setx(pos.x() - xRest + (xRest < myVisualizationSettings->gridXSize * 0.5 ? 0 : myVisualizationSettings->gridXSize));
190  result.sety(pos.y() - yRest + (yRest < myVisualizationSettings->gridYSize * 0.5 ? 0 : myVisualizationSettings->gridYSize));
191  }
192  return result;
193 }
194 
195 
196 Position
198  Boundary bound = myChanger->getViewport();
199  double xNet = bound.xmin() + bound.getWidth() * x / getWidth();
200  // cursor origin is in the top-left corner
201  double yNet = bound.ymin() + bound.getHeight() * (getHeight() - y) / getHeight();
202  return Position(xNet, yNet);
203 }
204 
205 
206 void
207 GUISUMOAbstractView::addDecals(const std::vector<Decal>& decals) {
208  myDecals.insert(myDecals.end(), decals.begin(), decals.end());
209 }
210 
211 
215 }
216 
217 
218 void
221  std::string text = "x:" + toString(pos.x()) + ", y:" + toString(pos.y());
222  myApp->getCartesianLabel().setText(text.c_str());
224  if (GeoConvHelper::getFinal().usingGeoProjection()) {
225  text = "lat:" + toString(pos.y(), gPrecisionGeo) + ", lon:" + toString(pos.x(), gPrecisionGeo);
226  } else {
227  text = "x:" + toString(pos.x()) + ", y:" + toString(pos.y());
228  }
229  myApp->getGeoLabel().setText(text.c_str());
230 }
231 
232 
233 int
234 GUISUMOAbstractView::doPaintGL(int /*mode*/, const Boundary& /*boundary*/) {
235  return 0;
236 }
237 
238 
239 void
241 }
242 
243 
244 Boundary
246  return myChanger->getViewport();
247 }
248 
249 
250 void
252  if (getWidth() == 0 || getHeight() == 0) {
253  return;
254  }
255 
257  centerTo(getTrackedID(), false);
258  }
259 
261  if (myUseToolTips) {
262  id = getObjectUnderCursor();
263  }
264 
265  // draw
266  glClearColor(
271  glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
272  glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
273 
275  glEnable(GL_DITHER);
276  } else {
277  glDisable(GL_DITHER);
278  }
280  glEnable(GL_BLEND);
281  glEnable(GL_POLYGON_SMOOTH);
282  glEnable(GL_LINE_SMOOTH);
283  } else {
284  glDisable(GL_BLEND);
285  glDisable(GL_POLYGON_SMOOTH);
286  glDisable(GL_LINE_SMOOTH);
287  }
288 
290  doPaintGL(GL_RENDER, myChanger->getViewport());
292  displayLegend();
293  }
294  // check whether the select mode /tooltips)
295  // shall be computed, too
296  if (myUseToolTips && id != GUIGlObject::INVALID_ID) {
297  showToolTipFor(id);
298  }
299  swapBuffers();
300 }
301 
302 
303 GUIGlID
306 }
307 
308 
309 GUIGlID
311  const double SENSITIVITY = 0.1; // meters
312  Boundary selection;
313  selection.add(pos);
314  selection.grow(SENSITIVITY);
315  const std::vector<GUIGlID> ids = getObjectsInBoundary(selection);
316  // Interpret results
317  int idMax = 0;
318  double maxLayer = -std::numeric_limits<double>::max();
319  for (std::vector<GUIGlID>::const_iterator it = ids.begin(); it != ids.end(); it++) {
320  GUIGlID id = *it;
322  if (o == 0) {
323  continue;
324  }
325  if (o->getGlID() == 0) {
326  continue;
327  }
328  //std::cout << "point selection hit " << o->getMicrosimID() << "\n";
329  GUIGlObjectType type = o->getType();
330  if (type != 0) {
331  double layer = (double)type;
332  // determine an "abstract" layer for shapes
333  // this "layer" resembles the layer of the shape
334  // taking into account the stac of other objects
335  if (type == GLO_POI || type == GLO_POLYGON) {
336  layer = dynamic_cast<Shape*>(o)->getLayer();
337  }
339  // do not select lanes in meso mode
340  continue;
341  }
342  // check whether the current object is above a previous one
343  if (layer > maxLayer) {
344  idMax = id;
345  maxLayer = layer;
346  }
347  }
349  }
350  return idMax;
351 }
352 
353 
354 std::vector<GUIGlID>
356  Boundary selection;
357  selection.add(pos);
358  selection.grow(radius);
359  const std::vector<GUIGlID> ids = getObjectsInBoundary(selection);
360  std::vector<GUIGlID> result;
361  // Interpret results
362  for (std::vector<GUIGlID>::const_iterator it = ids.begin(); it != ids.end(); it++) {
363  GUIGlID id = *it;
365  if (o == 0) {
366  continue;
367  }
368  if (o->getGlID() == 0) {
369  continue;
370  }
371  //std::cout << "point selection hit " << o->getMicrosimID() << "\n";
372  GUIGlObjectType type = o->getType();
373  if (type != 0) {
374  result.push_back(id);
375  }
377  }
378  return result;
379 }
380 
381 
382 std::vector<GUIGlID>
384  const int NB_HITS_MAX = 1024 * 1024;
385  // Prepare the selection mode
386  static GUIGlID hits[NB_HITS_MAX];
387  static GLint nb_hits = 0;
388  glSelectBuffer(NB_HITS_MAX, hits);
389  glInitNames();
390 
391  Boundary oldViewPort = myChanger->getViewport(false); // backup the actual viewPort
392  myChanger->setViewport(bound);
393  applyGLTransform(false);
394 
395  // paint in select mode
397  int hits2 = doPaintGL(GL_SELECT, bound);
399  // Get the results
400  nb_hits = glRenderMode(GL_RENDER);
401  if (nb_hits == -1) {
402  myApp->setStatusBarText("Selection in boundary failed. Try to select fewer than " + toString(hits2) + " items");
403  }
404  std::vector<GUIGlID> result;
405  GLuint numNames;
406  GLuint* ptr = hits;
407  for (int i = 0; i < nb_hits; ++i) {
408  numNames = *ptr;
409  ptr += 3;
410  for (int j = 0; j < (int)numNames; j++) {
411  result.push_back(*ptr);
412  ptr++;
413  }
414  }
415  // switch viewport back to normal
416  myChanger->setViewport(oldViewPort);
417  return result;
418 }
419 
420 
421 void
423  if (id != 0) {
425  if (object != 0) {
427  pos.add(0, p2m(15));
428  GLHelper::drawTextBox(object->getFullName(), pos, GLO_MAX - 1, p2m(20), RGBColor::BLACK, RGBColor(255, 179, 0, 255));
430  }
431  }
432 }
433 
434 
435 void
437  // obtain minimum grid
439  // Check if the distance is enought to draw grid
441  glEnable(GL_DEPTH_TEST);
442  glLineWidth(1);
443  // get multiplication values (2 is the marging)
444  int multXmin = (int)(myChanger->getViewport().xmin() / myVisualizationSettings->gridXSize) - 2;
445  int multYmin = (int)(myChanger->getViewport().ymin() / myVisualizationSettings->gridYSize) - 2;
446  int multXmax = (int)(myChanger->getViewport().xmax() / myVisualizationSettings->gridXSize) + 2;
447  int multYmax = (int)(myChanger->getViewport().ymax() / myVisualizationSettings->gridYSize) + 2;
448  // obtain references
449  double xmin = myVisualizationSettings->gridXSize * multXmin;
450  double ymin = myVisualizationSettings->gridYSize * multYmin;
451  double xmax = myVisualizationSettings->gridXSize * multXmax;
452  double ymax = myVisualizationSettings->gridYSize * multYmax;
453  double xpos = xmin;
454  double ypos = ymin;
455  // move drawing matrix
456  glTranslated(0, 0, .55);
457  glColor3d(0.5, 0.5, 0.5);
458  // draw horizontal lines
459  glBegin(GL_LINES);
460  while (ypos <= ymax) {
461  glVertex2d(xmin, ypos);
462  glVertex2d(xmax, ypos);
464  }
465  // draw vertical lines
466  while (xpos <= xmax) {
467  glVertex2d(xpos, ymin);
468  glVertex2d(xpos, ymax);
470  }
471  glEnd();
472  glTranslated(0, 0, -.55);
473  }
474 }
475 
476 
477 void
479  // compute the scale bar length
480  int length = 1;
481  const std::string text("10000000000");
482  int noDigits = 1;
483  int pixelSize = (int) m2p((double) length);
484  while (pixelSize <= 20) {
485  length *= 10;
486  noDigits++;
487  if (noDigits > (int)text.length()) {
488  return;
489  }
490  pixelSize = (int) m2p((double) length);
491  }
492  glLineWidth(1.0);
493 
494  glMatrixMode(GL_PROJECTION);
495  glPushMatrix();
496  glLoadIdentity();
497  glMatrixMode(GL_MODELVIEW);
498  glPushMatrix();
499  glLoadIdentity();
500 
501  // draw the scale bar
502  glDisable(GL_TEXTURE_2D);
503  glDisable(GL_ALPHA_TEST);
504  glDisable(GL_BLEND);
505  glEnable(GL_DEPTH_TEST);
506 
507  double len = (double) pixelSize / (double)(getWidth() - 1) * (double) 2.0;
508  glColor3d(0, 0, 0);
509  double o = double(15) / double(getHeight());
510  double o2 = o + o;
511  double oo = double(5) / double(getHeight());
512  glBegin(GL_LINES);
513  // vertical
514  glVertex2d(-.98, -1. + o);
515  glVertex2d(-.98 + len, -1. + o);
516  // tick at begin
517  glVertex2d(-.98, -1. + o);
518  glVertex2d(-.98, -1. + o2);
519  // tick at end
520  glVertex2d(-.98 + len, -1. + o);
521  glVertex2d(-.98 + len, -1. + o2);
522  glEnd();
523 
524  double w = double(35) / double(getWidth());
525  double h = double(35) / double(getHeight());
526  pfSetPosition(double(-0.99), double(1. - o2 - oo));
527  pfSetScaleXY(w, h);
528  glRotated(180, 1, 0, 0);
529  pfDrawString("0m");
530  glRotated(-180, 1, 0, 0);
531 
532  pfSetPosition(double(-.99 + len), double(1. - o2 - oo));
533  glRotated(180, 1, 0, 0);
534  pfDrawString((text.substr(0, noDigits) + "m").c_str());
535  glRotated(-180, 1, 0, 0);
536 
537  // restore matrices
538  glMatrixMode(GL_PROJECTION);
539  glPopMatrix();
540  glMatrixMode(GL_MODELVIEW);
541  glPopMatrix();
542 }
543 
544 
545 double
546 GUISUMOAbstractView::m2p(double meter) const {
547  return meter * getWidth() / myChanger->getViewport().getWidth();
548 }
549 
550 
551 double
552 GUISUMOAbstractView::p2m(double pixel) const {
553  return pixel * myChanger->getViewport().getWidth() / getWidth();
554 }
555 
556 
557 void
560 }
561 
562 
563 void
564 GUISUMOAbstractView::centerTo(GUIGlID id, bool applyZoom, double zoomDist) {
566  if (o != 0 && dynamic_cast<GUIGlObject*>(o) != 0) {
567  if (applyZoom && zoomDist < 0) {
569  update(); // only update when centering onto an object once
570  } else {
571  // called during tracking. update is triggered somewhere else
572  myChanger->centerTo(o->getCenteringBoundary().getCenter(), zoomDist, applyZoom);
574  }
575  }
577 }
578 
579 
580 void
582  myChanger->setViewport(bound);
583  update();
584 }
585 
586 /*
587 bool
588 GUISUMOAbstractView::allowRotation() const
589 {
590  return myParent->allowRotation();
591 }
592 */
593 
594 void
598 }
599 
600 
601 FXbool
603  FXbool ret = FXGLCanvas::makeCurrent();
604  return ret;
605 }
606 
607 
608 long
609 GUISUMOAbstractView::onConfigure(FXObject*, FXSelector, void*) {
610  if (makeCurrent()) {
611  glViewport(0, 0, getWidth() - 1, getHeight() - 1);
612  glClearColor(
617  doInit();
618  myAmInitialised = true;
619  makeNonCurrent();
620  checkSnapshots();
621  }
622  return 1;
623 }
624 
625 
626 long
627 GUISUMOAbstractView::onPaint(FXObject*, FXSelector, void*) {
628  if (!isEnabled() || !myAmInitialised) {
629  return 1;
630  }
631  if (makeCurrent()) {
632  paintGL();
633  makeNonCurrent();
634  }
635  return 1;
636 }
637 
638 
639 void
641  delete myPopup;
642  myPopup = 0;
643 }
644 
645 
646 long
647 GUISUMOAbstractView::onLeftBtnPress(FXObject*, FXSelector , void* data) {
648  destroyPopup();
649  setFocus();
650  FXEvent* e = (FXEvent*) data;
651  // check whether the selection-mode is activated
652  if ((e->state & CONTROLMASK) != 0) {
653  // try to get the object-id if so
654  if (makeCurrent()) {
655  int id = getObjectUnderCursor();
656  if (id != 0) {
658  }
659  makeNonCurrent();
660  if (id != 0) {
661  // possibly, the selection-colouring is used,
662  // so we should update the screen again...
663  update();
664  }
665  }
666  }
667  myChanger->onLeftBtnPress(data);
668  grab();
669  // Check there are double click
670  if (e->click_count == 2) {
671  handle(this, FXSEL(SEL_DOUBLECLICKED, 0), data);
672  }
673  return 1;
674 }
675 
676 
677 long
678 GUISUMOAbstractView::onLeftBtnRelease(FXObject*, FXSelector , void* data) {
679  destroyPopup();
681  if (myApp->isGaming()) {
683  }
684  ungrab();
685  return 1;
686 }
687 
688 
689 long
690 GUISUMOAbstractView::onMiddleBtnPress(FXObject*, FXSelector, void*) {
691  return 1;
692 }
693 
694 
695 long
696 GUISUMOAbstractView::onMiddleBtnRelease(FXObject*, FXSelector, void*) {
697  return 1;
698 }
699 
700 
701 long
702 GUISUMOAbstractView::onRightBtnPress(FXObject*, FXSelector , void* data) {
703  destroyPopup();
704  myChanger->onRightBtnPress(data);
705  grab();
706  return 1;
707 }
708 
709 
710 long
711 GUISUMOAbstractView::onRightBtnRelease(FXObject* o, FXSelector sel, void* data) {
712  destroyPopup();
713  onMouseMove(o, sel, data);
714  if (!myChanger->onRightBtnRelease(data) && !myApp->isGaming()) {
716  }
717  ungrab();
718  return 1;
719 }
720 
721 
722 long
723 GUISUMOAbstractView::onDoubleClicked(FXObject*, FXSelector, void*) {
724  return 1;
725 }
726 
727 
728 long
729 GUISUMOAbstractView::onMouseWheel(FXObject*, FXSelector , void* data) {
730  if (!myApp->isGaming()) {
731  myChanger->onMouseWheel(data);
733  }
734  return 1;
735 }
736 
737 
738 long
739 GUISUMOAbstractView::onMouseMove(FXObject*, FXSelector , void* data) {
741  myChanger->onMouseMove(data);
742  }
743  if (myViewportChooser != 0) {
745  }
747  return 1;
748 }
749 
750 
751 long
752 GUISUMOAbstractView::onMouseLeft(FXObject*, FXSelector , void* /*data*/) {
753  return 1;
754 }
755 
756 
757 void
759  ungrab();
760  if (!isEnabled() || !myAmInitialised) {
761  return;
762  }
763  if (makeCurrent()) {
764  // initialise the select mode
765  int id = getObjectUnderCursor();
766  GUIGlObject* o = 0;
767  if (id != 0) {
769  } else {
771  }
772  if (o != 0) {
773  myPopup = o->getPopUpMenu(*myApp, *this);
774  int x, y;
775  FXuint b;
776  myApp->getCursorPosition(x, y, b);
777  myPopup->setX(x + myApp->getX());
778  myPopup->setY(y + myApp->getY());
779  myPopup->create();
780  myPopup->show();
783  }
784  makeNonCurrent();
785  }
786 }
787 
788 
789 long
790 GUISUMOAbstractView::onKeyPress(FXObject* o, FXSelector sel, void* data) {
791  FXGLCanvas::onKeyPress(o, sel, data);
792  return myChanger->onKeyPress(data);
793 }
794 
795 
796 long
797 GUISUMOAbstractView::onKeyRelease(FXObject* o, FXSelector sel, void* data) {
798  FXGLCanvas::onKeyRelease(o, sel, data);
799  return myChanger->onKeyRelease(data);
800 }
801 
802 
803 // ------------ Dealing with snapshots
804 void
805 GUISUMOAbstractView::setSnapshots(std::map<SUMOTime, std::string> snaps) {
806  mySnapshots.insert(snaps.begin(), snaps.end());
807 }
808 
809 
810 std::string
811 GUISUMOAbstractView::makeSnapshot(const std::string& destFile) {
812  std::string errorMessage;
813  FXString ext = FXPath::extension(destFile.c_str());
814  const bool useGL2PS = ext == "ps" || ext == "eps" || ext == "pdf" || ext == "svg" || ext == "tex" || ext == "pgf";
815 #ifdef HAVE_FFMPEG
816  const bool useVideo = destFile == "" || ext == "h264" || ext == "hevc";
817 #endif
818  for (int i = 0; i < 10 && !makeCurrent(); ++i) {
820  }
821  // draw
822  glClearColor(
827  glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
828  glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
829 
831  glEnable(GL_DITHER);
832  } else {
833  glDisable(GL_DITHER);
834  }
836  glEnable(GL_BLEND);
837  glEnable(GL_POLYGON_SMOOTH);
838  glEnable(GL_LINE_SMOOTH);
839  } else {
840  glDisable(GL_BLEND);
841  glDisable(GL_POLYGON_SMOOTH);
842  glDisable(GL_LINE_SMOOTH);
843  }
844 
846 
847  if (useGL2PS) {
848  GLint format = GL2PS_PS;
849  if (ext == "ps") {
850  format = GL2PS_PS;
851  } else if (ext == "eps") {
852  format = GL2PS_EPS;
853  } else if (ext == "pdf") {
854  format = GL2PS_PDF;
855  } else if (ext == "tex") {
856  format = GL2PS_TEX;
857  } else if (ext == "svg") {
858  format = GL2PS_SVG;
859  } else if (ext == "pgf") {
860  format = GL2PS_PGF;
861  } else {
862  return "Could not save '" + destFile + "'.\n Unrecognized format '" + std::string(ext.text()) + "'.";
863  }
864  FILE* fp = fopen(destFile.c_str(), "wb");
865  if (fp == 0) {
866  return "Could not save '" + destFile + "'.\n Could not open file for writing";
867  }
868  GLint buffsize = 0, state = GL2PS_OVERFLOW;
869  GLint viewport[4];
870  glGetIntegerv(GL_VIEWPORT, viewport);
871  while (state == GL2PS_OVERFLOW) {
872  buffsize += 1024 * 1024;
873  gl2psBeginPage(destFile.c_str(), "sumo-gui; http://sumo.dlr.de", viewport, format, GL2PS_SIMPLE_SORT,
874  GL2PS_DRAW_BACKGROUND | GL2PS_USE_CURRENT_VIEWPORT,
875  GL_RGBA, 0, NULL, 0, 0, 0, buffsize, fp, "out.eps");
876  glMatrixMode(GL_MODELVIEW);
877  glPushMatrix();
878  glDisable(GL_TEXTURE_2D);
879  glDisable(GL_ALPHA_TEST);
880  glDisable(GL_BLEND);
881  glEnable(GL_DEPTH_TEST);
882  // compute lane width
883  // draw decals (if not in grabbing mode)
884  if (!myUseToolTips) {
885  drawDecals();
887  paintGLGrid();
888  }
889  }
890  glLineWidth(1);
891  glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
892  Boundary viewPort = myChanger->getViewport();
893  const float minB[2] = { (float)viewPort.xmin(), (float)viewPort.ymin() };
894  const float maxB[2] = { (float)viewPort.xmax(), (float)viewPort.ymax() };
896  glEnable(GL_POLYGON_OFFSET_FILL);
897  glEnable(GL_POLYGON_OFFSET_LINE);
898  myGrid->Search(minB, maxB, *myVisualizationSettings);
899 
901  displayLegend();
902  }
903  state = gl2psEndPage();
904  glFinish();
905  }
906  fclose(fp);
907  } else {
908  doPaintGL(GL_RENDER, myChanger->getViewport());
910  displayLegend();
911  }
912  swapBuffers();
913  glFinish();
914  FXColor* buf;
915  FXMALLOC(&buf, FXColor, getWidth()*getHeight());
916  // read from the back buffer
917  glReadBuffer(GL_BACK);
918  // Read the pixels
919  glReadPixels(0, 0, getWidth(), getHeight(), GL_RGBA, GL_UNSIGNED_BYTE, (GLvoid*)buf);
920  makeNonCurrent();
921  update();
922  // mirror
923  int mwidth = getWidth();
924  int mheight = getHeight();
925  FXColor* paa = buf;
926  FXColor* pbb = buf + mwidth * (mheight - 1);
927  do {
928  FXColor* pa = paa;
929  paa += mwidth;
930  FXColor* pb = pbb;
931  pbb -= mwidth;
932  do {
933  FXColor t = *pa;
934  *pa++ = *pb;
935  *pb++ = t;
936  } while (pa < paa);
937  } while (paa < pbb);
938  try {
939 #ifdef HAVE_FFMPEG
940  if (useVideo) {
941  try {
942  saveFrame(destFile, buf);
943  errorMessage = "video";
944  } catch (std::runtime_error& err) {
945  errorMessage = err.what();
946  }
947  } else
948 #endif
949  if (!MFXImageHelper::saveImage(destFile, getWidth(), getHeight(), buf)) {
950  errorMessage = "Could not save '" + destFile + "'.";
951  }
952  } catch (InvalidArgument& e) {
953  errorMessage = "Could not save '" + destFile + "'.\n" + e.what();
954  }
955  FXFREE(&buf);
956  }
957  return errorMessage;
958 }
959 
960 
961 void
962 GUISUMOAbstractView::saveFrame(const std::string& destFile, FXColor* buf) {
963  UNUSED_PARAMETER(destFile);
964  UNUSED_PARAMETER(buf);
965 }
966 
967 
968 void
970  std::map<SUMOTime, std::string>::iterator snapIt = mySnapshots.find(getCurrentTimeStep());
971  if (snapIt != mySnapshots.end()) {
972  std::string error = makeSnapshot(snapIt->second);
973  if (error != "") {
974  WRITE_WARNING(error);
975  }
976  }
977 }
978 
979 
980 SUMOTime
982  return 0;
983 }
984 
985 
986 void
988  if (myVisualizationChanger == 0) {
993  myVisualizationChanger->create();
994  } else {
996  }
998 }
999 
1000 
1003  if (myViewportChooser == 0) {
1004  myViewportChooser = new GUIDialog_EditViewport(this, "Edit Viewport", 0, 0);
1005  myViewportChooser->create();
1006  }
1008  return myViewportChooser;
1009 }
1010 
1011 
1012 void
1014  getViewportEditor(); // make sure it exists;
1018 }
1019 
1020 
1021 void
1022 GUISUMOAbstractView::setViewportFromTo(const Position& lookFrom, const Position& /* lookAt */) {
1023  myChanger->setViewportFrom(lookFrom.x(), lookFrom.y(), lookFrom.z());
1024  update();
1025 }
1026 
1027 
1028 void
1030  // look straight down
1033 }
1034 
1035 
1036 void
1038  myUseToolTips = val;
1039 }
1040 
1041 
1042 bool
1044  return true;
1045 }
1046 
1047 
1050  return myVisualizationSettings;
1051 }
1052 
1053 
1054 void
1056  myViewportChooser = 0;
1057 }
1058 
1059 
1060 void
1063 }
1064 
1065 
1066 double
1068  return myGrid->getWidth();
1069 }
1070 
1071 
1072 double
1074  return myGrid->getHeight();
1075 }
1076 
1077 
1078 void
1080 }
1081 
1082 
1083 void
1085 }
1086 
1087 
1088 GUIGlID
1090  return GUIGlObject::INVALID_ID;
1091 }
1092 
1093 
1094 void
1096 }
1097 
1098 
1099 FXComboBox&
1102 }
1103 
1104 
1105 FXImage*
1107 #ifdef HAVE_GDAL
1108  GDALAllRegister();
1109  GDALDataset* poDataset = (GDALDataset*)GDALOpen(d.filename.c_str(), GA_ReadOnly);
1110  if (poDataset == 0) {
1111  return 0;
1112  }
1113  const int xSize = poDataset->GetRasterXSize();
1114  const int ySize = poDataset->GetRasterYSize();
1115  // checking for geodata in the picture and try to adapt position and scale
1116  if (d.width <= 0.) {
1117  double adfGeoTransform[6];
1118  if (poDataset->GetGeoTransform(adfGeoTransform) == CE_None) {
1119  Position topLeft(adfGeoTransform[0], adfGeoTransform[3]);
1120  const double horizontalSize = xSize * adfGeoTransform[1];
1121  const double verticalSize = ySize * adfGeoTransform[5];
1122  Position bottomRight(topLeft.x() + horizontalSize, topLeft.y() + verticalSize);
1124  d.width = bottomRight.x() - topLeft.x();
1125  d.height = topLeft.y() - bottomRight.y();
1126  d.centerX = (topLeft.x() + bottomRight.x()) / 2;
1127  d.centerY = (topLeft.y() + bottomRight.y()) / 2;
1128  //WRITE_MESSAGE("proj: " + toString(poDataset->GetProjectionRef()) + " dim: " + toString(d.width) + "," + toString(d.height) + " center: " + toString(d.centerX) + "," + toString(d.centerY));
1129  } else {
1130  WRITE_WARNING("Could not convert coordinates in " + d.filename + ".");
1131  }
1132  }
1133  }
1134 #endif
1135  if (d.width <= 0.) {
1136  d.width = getGridWidth();
1137  d.height = getGridHeight();
1138  }
1139 
1140  // trying to read the picture
1141 #ifdef HAVE_GDAL
1142  const int picSize = xSize * ySize;
1143  FXColor* result;
1144  if (!FXMALLOC(&result, FXColor, picSize)) {
1145  WRITE_WARNING("Could not allocate memory for " + d.filename + ".");
1146  return 0;
1147  }
1148  for (int j = 0; j < picSize; j++) {
1149  result[j] = FXRGB(0, 0, 0);
1150  }
1151  bool valid = true;
1152  for (int i = 1; i <= poDataset->GetRasterCount(); i++) {
1153  GDALRasterBand* poBand = poDataset->GetRasterBand(i);
1154  int shift = -1;
1155  if (poBand->GetColorInterpretation() == GCI_RedBand) {
1156  shift = 0;
1157  } else if (poBand->GetColorInterpretation() == GCI_GreenBand) {
1158  shift = 1;
1159  } else if (poBand->GetColorInterpretation() == GCI_BlueBand) {
1160  shift = 2;
1161  } else if (poBand->GetColorInterpretation() == GCI_AlphaBand) {
1162  shift = 3;
1163  } else {
1164  WRITE_MESSAGE("Unknown color band in " + d.filename + ", maybe fox can parse it.");
1165  valid = false;
1166  break;
1167  }
1168  assert(xSize == poBand->GetXSize() && ySize == poBand->GetYSize());
1169  if (poBand->RasterIO(GF_Read, 0, 0, xSize, ySize, ((unsigned char*)result) + shift, xSize, ySize, GDT_Byte, 4, 4 * xSize) == CE_Failure) {
1170  valid = false;
1171  break;
1172  }
1173  }
1174  GDALClose(poDataset);
1175  if (valid) {
1176  return new FXImage(getApp(), result, IMAGE_OWNED | IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP, xSize, ySize);
1177  }
1178  FXFREE(&result);
1179 #endif
1180  return 0;
1181 }
1182 
1183 
1184 void
1186  glPushName(0);
1187  myDecalsLock.lock();
1188  for (std::vector<GUISUMOAbstractView::Decal>::iterator l = myDecals.begin(); l != myDecals.end(); ++l) {
1190  if (d.skip2D) {
1191  continue;
1192  }
1193  if (!d.initialised) {
1194  try {
1195  FXImage* img = checkGDALImage(d);
1196  if (img == 0) {
1197  img = MFXImageHelper::loadImage(getApp(), d.filename);
1198  }
1200  d.glID = GUITexturesHelper::add(img);
1201  d.initialised = true;
1202  d.image = img;
1203  } catch (InvalidArgument& e) {
1204  WRITE_ERROR("Could not load '" + d.filename + "'.\n" + e.what());
1205  d.skip2D = true;
1206  }
1207  }
1208  glPushMatrix();
1209  if (d.screenRelative) {
1210  Position center = screenPos2NetPos((int)d.centerX, (int)d.centerY);
1211  glTranslated(center.x(), center.y(), d.layer);
1212  } else {
1213  glTranslated(d.centerX, d.centerY, d.layer);
1214  }
1215  glRotated(d.rot, 0, 0, 1);
1216  glColor3d(1, 1, 1);
1217  double halfWidth = d.width / 2.;
1218  double halfHeight = d.height / 2.;
1219  if (d.screenRelative) {
1220  halfWidth = p2m(halfWidth);
1221  halfHeight = p2m(halfHeight);
1222  }
1223  GUITexturesHelper::drawTexturedBox(d.glID, -halfWidth, -halfHeight, halfWidth, halfHeight);
1224  glPopMatrix();
1225  }
1226  myDecalsLock.unlock();
1227  glPopName();
1228 }
1229 
1230 
1231 // ------------ Additional visualisations
1232 bool
1234  if (myAdditionallyDrawn.find(which) == myAdditionallyDrawn.end()) {
1235  myAdditionallyDrawn[which] = 1;
1236  } else {
1237  myAdditionallyDrawn[which] = myAdditionallyDrawn[which] + 1;
1238  }
1239  update();
1240  return true;
1241 }
1242 
1243 
1244 bool
1246  if (myAdditionallyDrawn.find(which) == myAdditionallyDrawn.end()) {
1247  return false;
1248  }
1249  int cnt = myAdditionallyDrawn[which];
1250  if (cnt == 1) {
1251  myAdditionallyDrawn.erase(which);
1252  } else {
1253  myAdditionallyDrawn[which] = myAdditionallyDrawn[which] - 1;
1254  }
1255  update();
1256  return true;
1257 }
1258 
1259 
1260 bool
1262  if (myAdditionallyDrawn.find(which) == myAdditionallyDrawn.end()) {
1263  return false;
1264  } else {
1265  return true;
1266  }
1267 }
1268 
1269 
1270 void
1272  Boundary bound = myChanger->getViewport(fixRatio);
1273  glMatrixMode(GL_PROJECTION);
1274  glLoadIdentity();
1275  // as a rough rule, each GLObject is drawn at z = -GUIGlObjectType
1276  // thus, objects with a higher value will be closer (drawn on top)
1277  // // @todo last param should be 0 after modifying all glDraw methods
1278  glOrtho(0, getWidth(), 0, getHeight(), -GLO_MAX - 1, GLO_MAX + 1);
1279  glMatrixMode(GL_MODELVIEW);
1280  glLoadIdentity();
1281  double scaleX = (double)getWidth() / bound.getWidth();
1282  double scaleY = (double)getHeight() / bound.getHeight();
1283  glScaled(scaleX, scaleY, 1);
1284  glTranslated(-bound.xmin(), -bound.ymin(), 0);
1285 }
1286 
1287 
1288 double
1290  return myApp->getDelay();
1291 }
1292 
1293 
1294 void
1296  myApp->setDelay(delay);
1297 }
1298 
1299 
1301  filename(),
1302  centerX(0),
1303  centerY(0),
1304  centerZ(0),
1305  width(0),
1306  height(0),
1307  altitude(0),
1308  rot(0),
1309  tilt(0),
1310  roll(0),
1311  layer(0),
1312  initialised(false),
1313  skip2D(false),
1314  screenRelative(false),
1315  glID(-1),
1316  image(0) {
1317 }
1318 
1319 
1320 /****************************************************************************/
1321 
GUIDialog_EditViewport * getViewportEditor()
get the viewport and create it on first access
static void drawTexturedBox(int which, double size)
Draws a named texture as a box with the given size.
void paintGLGrid()
paints a grid
A decal (an image) that can be shown.
virtual long onConfigure(FXObject *, FXSelector, void *)
mouse functions
void showToolTips(bool val)
show tool tips
int pfDrawString(const char *c)
Definition: polyfonts.c:1074
double ymin() const
Returns minimum y-coordinate.
Definition: Boundary.cpp:138
std::vector< GUIGlID > getObjectsAtPosition(Position pos, double radius)
returns the ids of the object at position within the given (rectangular) radius using GL_SELECT ...
double xmax() const
Returns maximum x-coordinate.
Definition: Boundary.cpp:132
bool haveGrabbed() const
Returns the information whether one of the spin dialers is grabbed.
GUICompleteSchemeStorage gSchemeStorage
bool showSizeLegend
Information whether the size legend shall be drawn.
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. Used for: Centering of vehicles and junctions */.
double scale
information about a lane&#39;s width (temporary, used for a single view)
FXImage * checkGDALImage(Decal &d)
check whether we can read image data or position with gdal
FXImage * image
The image pointer for later cleanup.
a polygon
virtual long onDoubleClicked(FXObject *, FXSelector, void *)
void setDefault(const std::string &name)
Makes the scheme with the given name the default.
double z() const
Returns the z-position.
Definition: Position.h:73
virtual void setViewportFromTo(const Position &lookFrom, const Position &lookAt)
applies the given viewport settings
GUIGlObjectType
bool myAmInitialised
Internal information whether doInit() was called.
void add(const Position &pos)
Adds the given position to this one.
Definition: Position.h:133
virtual void recenterView()
recenters the view
SUMORTree * myGrid
The visualization speed-up.
static GUIGlID add(FXImage *i)
Adds a texture to use.
void toggleSelection(GUIGlID id)
Toggles selection of an object.
bool gaming
whether the application is in gaming mode or not
virtual long onMouseMove(FXObject *, FXSelector, void *)
unsigned char alpha() const
Returns the alpha-amount of the color.
Definition: RGBColor.h:99
virtual long onMiddleBtnPress(FXObject *, FXSelector, void *)
Stores the information about how to visualize structures.
The dialog to change the view (gui) settings.
static GeoConvHelper & getProcessing()
the coordinate transformation to use for input conversion and processing
Definition: GeoConvHelper.h:98
void setDelay(double delay)
Sets the delay of the parent application.
const double SUMO_const_laneWidth
Definition: StdDefs.h:48
void displayLegend()
a line with ticks, and the length information.
bool x2cartesian(Position &from, bool includeInBoundary=true)
void updatePositionInformation() const
update position information
double y() const
Returns the y-position.
Definition: Position.h:68
void remove(GUIDialog_EditViewport *)
remove viewport
GUIVisualizationSettings * getVisualisationSettings() const
get visualitation settings
GUIMainWindow * myApp
The application.
Position snapToActiveGrid(const Position &pos) const
Returns a position that is mapped to the closest grid point if the grid is active.
double x() const
Returns the x-position.
Definition: Position.h:63
virtual void saveFrame(const std::string &destFile, FXColor *buf)
Adds a frame to a video snapshot which will be initialized if neccessary.
MFXMutex myDecalsLock
The mutex to use before accessing the decals list in order to avoid thread conficts.
double centerX
The center of the image in x-direction (net coordinates, in m)
bool screenRelative
Whether this image should be skipped in 2D-views.
virtual long onLeftBtnPress(FXObject *, FXSelector, void *)
double getWidth() const
Returns the width of the boudary (x-axis)
Definition: Boundary.cpp:162
bool myInEditMode
Information whether too-tip informations shall be generated.
virtual void openObjectDialog()
virtual Boundary getCenteringBoundary() const =0
virtual long onKeyRelease(FXObject *o, FXSelector sel, void *data)
unsigned char blue() const
Returns the blue-amount of the color.
Definition: RGBColor.h:91
void saveViewport(const double x, const double y, const double z)
Makes the given viewport the default.
bool addAdditionalGLVisualisation(const GUIGlObject *const which)
Adds an object to call its additional visualisation method.
void pfSetPosition(double x, double y)
Definition: polyfonts.c:480
int glID
whether the decal shall be drawn in screen coordinates, rather than network coordinates ...
void setSnapshots(std::map< SUMOTime, std::string > snaps)
Sets the snapshot time to file map.
static const RGBColor BLACK
Definition: RGBColor.h:197
virtual void copyViewportTo(GUISUMOAbstractView *view)
copy the viewport to the given view
virtual void onGamingClick(Position)
on gaming click
GUIDialog_ViewSettings * myVisualizationChanger
Visualization changer.
virtual double getZPos() const =0
Returns the camera height corresponding to the current zoom factor.
virtual void stopTrack()
stop track
GUIDialog_EditViewport * myViewportChooser
viewport chooser
virtual void setDelay(double)
Sets the delay of the parent application.
A RT-tree for efficient storing of SUMO&#39;s GL-objects.
Definition: SUMORTree.h:74
double getGridHeight() const
get grid Height
bool dither
Information whether dithering shall be enabled.
double height
The height of the image (net coordinates in y-direction, in m)
#define UNUSED_PARAMETER(x)
Definition: StdDefs.h:38
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:48
int myMouseHotspotX
Offset to the mouse-hotspot from the mouse position.
void addDecals(const std::vector< Decal > &decals)
add decals
double getDelay() const
Returns the delay of the parent application.
bool removeAdditionalGLVisualisation(const GUIGlObject *const which)
Removes an object from the list of objects that show additional things.
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:200
double layer
The layer of the image.
double p2m(double pixel) const
pixels-to-meters conversion method
std::map< const GUIGlObject *, int > myAdditionallyDrawn
List of objects for which GUIGlObject::drawGLAdditional is called.
void cartesian2geo(Position &cartesian) const
Converts the given cartesian (shifted) position to its geo (lat/long) representation.
FXLabel & getCartesianLabel()
GUIVisualizationSizeSettings addSize
std::vector< Decal > myDecals
double getGridWidth() const
get grid width
GUIGlID getObjectAtPosition(Position pos)
returns the id of the object at position using GL_SELECT
static FXbool scalePower2(FXImage *image, int maxSize=(2<< 29))
virtual GUIGlID getTrackedID() const
get tracked id
virtual void startTrack(int)
star track
#define max(a, b)
Definition: polyfonts.c:65
virtual long onPaint(FXObject *, FXSelector, void *)
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
std::string name
The name of this setting.
double gridXSize
Information about the grid spacings.
void showToolTipFor(const GUIGlID id)
invokes the tooltip for the given object
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:56
virtual void setStatusBarText(const std::string &)
Definition: GUIMainWindow.h:79
virtual long onKeyPress(FXObject *o, FXSelector sel, void *data)
keyboard functions
static void sleep(long ms)
virtual void setViewport(double zoom, double xPos, double yPos)=0
Sets the viewport Used for: Adapting a new viewport.
bool isInEditMode()
returns true, if the edit button was pressed
void show()
show view settings dialog
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:46
void setx(double x)
set position x
Definition: Position.h:78
int gPrecisionGeo
Definition: StdDefs.cpp:31
virtual GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)=0
Returns an own popup-menu.
FXComboBox & getColoringSchemesCombo()
static GUIGlObjectStorage gIDStorage
A single static instance of this class.
double rot
The rotation of the image in the ground plane (in degrees)
virtual void centerTo(GUIGlID id, bool applyZoom, double zoomDist=20)
centers to the chosen artifact
bool isGaming() const
return whether the gui is in gaming mode
Definition: GUIMainWindow.h:85
GUIPerspectiveChanger & getChanger() const
get changer
virtual bool onLeftBtnRelease(void *data)
called when user releases left button
FXComboBox & getColoringSchemesCombo()
get coloring schemes combo
bool initialised
Whether this image was initialised (inserted as a texture)
A 2D- or 3D-Shape.
Definition: Shape.h:46
double xmin() const
Returns minimum x-coordinate.
Definition: Boundary.cpp:126
virtual bool onRightBtnRelease(void *data)
called when user releases right button
virtual void doInit()
doInit
double centerY
The center of the image in y-direction (net coordinates, in m)
FXLabel & getGeoLabel()
Boundary & grow(double by)
extends the boundary by the given amount
Definition: Boundary.cpp:234
virtual long onMouseWheel(FXObject *, FXSelector, void *)
virtual void checkSnapshots()
Checks whether it is time for a snapshot.
virtual ~GUISUMOAbstractView()
destructor
std::string filename
The path to the file the image is located at.
virtual double getZoom() const =0
Returns the zoom factor computed stored in this changer.
virtual int doPaintGL(int, const Boundary &)
paint GL
Position screenPos2NetPos(int x, int y) const
Translate screen position to network position.
std::map< SUMOTime, std::string > mySnapshots
Snapshots.
static FXbool saveImage(const std::string &file, int width, int height, FXColor *data)
GUIPerspectiveChanger * myChanger
The perspective changer.
bool myUseToolTips
use tool tips
std::string makeSnapshot(const std::string &destFile)
Takes a snapshots and writes it into the given file.
virtual void onLeftBtnPress(void *data)
mouse functions
GUIGLObjectPopupMenu * myPopup
The current popup-menu.
RGBColor backgroundColor
The background color to use.
void destroyPopup()
destoys the popup
bool antialiase
Information whether antialiase shall be enabled.
FXint myWindowCursorPositionX
Position of the cursor relative to the window.
virtual long onMiddleBtnRelease(FXObject *, FXSelector, void *)
Boundary getViewport(bool fixRatio=true)
get viewport
double width
The width of the image (net coordinates in x-direction, in m)
virtual bool setColorScheme(const std::string &)
set color scheme
unsigned int GUIGlID
Definition: GUIGlObject.h:50
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:206
void unlock()
release mutex lock
Definition: MFXMutex.cpp:92
virtual void showViewportEditor()
show viewport editor
FXbool makeCurrent()
A reimplementation due to some internal reasons.
void applyGLTransform(bool fixRatio=true)
applies gl-transformations to fit the Boundary given by myChanger onto the canvas. If fixRatio is true, this boundary will be enlarged to prevent anisotropic stretching. (this should be set to false when doing selections)
virtual long onLeftBtnRelease(FXObject *, FXSelector, void *)
GUIVisualizationSettings & getDefault()
Returns the default scheme.
double m2p(double meter) const
meter-to-pixels conversion method
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)
draw Text box with given parameters
Definition: GLHelper.cpp:474
GUIGlObject * getNetObject() const
Returns the network object.
void setViewport(GUISUMOAbstractView *view)
Sets the default viewport.
GUIVisualizationSettings * myVisualizationSettings
visualization settings
double getHeight() const
Returns the height of the boundary (y-axis)
Definition: Boundary.cpp:168
virtual void onMouseWheel(void *data)
called when user changes mouse wheel
bool isAdditionalGLVisualisationEnabled(GUIGlObject *const which) const
Check if an object is added in the additional GL visualitation.
unsigned char green() const
Returns the green-amount of the color.
Definition: RGBColor.h:83
void paintGL()
performs the painting of the simulation
virtual long onKeyPress(void *data)
called when user press a key
void sety(double y)
set position y
Definition: Position.h:83
void setWindowCursorPosition(FXint x, FXint y)
Returns the information whether rotation is allowd.
void setCurrent(GUIVisualizationSettings *settings)
Sets current settings (called if reopened)
void show()
overload show function to focus always in OK Button
static const GUIGlID INVALID_ID
Definition: GUIGlObject.h:77
static FXImage * loadImage(FXApp *a, const std::string &file)
static const GeoConvHelper & getFinal()
the coordinate transformation for writing the location element and for tracking the original coordina...
void lock()
lock mutex
Definition: MFXMutex.cpp:82
virtual double getDelay() const
Returns the delay (should be overwritten by subclasses if applicable)
bool showGrid
Information whether a grid shall be shown.
void drawDecals()
Draws the stored decals.
static int getMaxTextureSize()
return maximum number of pixels in x and y direction
GLCanvas - ID.
Definition: GUIAppEnum.h:213
virtual double getYPos() const =0
Returns the y-offset of the field to show stored in this changer.
GUIGlID getGlID() const
Returns the numerical id of the object.
Position getCenter() const
Returns the center of the boundary.
Definition: Boundary.cpp:120
double getExaggeration(const GUIVisualizationSettings &s, double factor=20) const
return the drawing size including exaggeration and constantSize values
unsigned char red() const
Returns the red-amount of the color.
Definition: RGBColor.h:75
bool skip2D
Whether this image should be skipped in 2D-views.
virtual void onMouseMove(void *data)
called when user moves mouse
virtual SUMOTime getCurrentTimeStep() const
get the current simulation time
Position getPositionInformation() const
Returns the cursor&#39;s x/y position within the network.
Boundary getVisibleBoundary() const
get visible boundary
void updateToolTip()
A method that updates the tooltip.
A dialog to change the viewport.
long long int SUMOTime
Definition: TraCIDefs.h:52
void setValues(double zoom, double xoff, double yoff)
Sets the given values into the dialog.
virtual void onRightBtnPress(void *data)
called when user press right button
empty max
void unblockObject(GUIGlID id)
Marks an object as unblocked.
static bool UseMesoSim
this should be set at the same time as MSGlobals::gUseMesoSim
virtual void setViewportFrom(double xPos, double yPos, double zPos)=0
Alternative method for setting the viewport.
void showViewschemeEditor()
show viewsscheme editor
virtual long onRightBtnPress(FXObject *, FXSelector, void *)
const std::string & getFullName() const
void add(double x, double y, double z=0)
Makes the boundary include the given coordinate.
Definition: Boundary.cpp:86
virtual long onMouseLeft(FXObject *, FXSelector, void *)
GUIGlID getObjectUnderCursor()
returns the id of the object under the cursor using GL_SELECT
bool drawForSelecting
whether drawing is performed for the purpose of selecting objects
double ymax() const
Returns maximum y-coordinate.
Definition: Boundary.cpp:144
#define WRITE_MESSAGE(msg)
Definition: MsgHandler.h:201
GUIGlObject * getObjectBlocking(GUIGlID id)
Returns the object from the container locking it.
virtual long onKeyRelease(void *data)
called when user releases a key
virtual int Search(const float a_min[2], const float a_max[2], const GUIVisualizationSettings &c) const
Find all within search rectangle.
Definition: SUMORTree.h:120
GUISelectedStorage gSelected
A global holder of selected objects.
virtual double getXPos() const =0
Returns the x-offset of the field to show stored in this changer.
void pfSetScaleXY(double sx, double sy)
Definition: polyfonts.c:472
FXDEFMAP(GUISUMOAbstractView) GUISUMOAbstractViewMap[]
GUIGlChildWindow * myParent
The parent window.
virtual long onRightBtnRelease(FXObject *, FXSelector, void *)
static const Position INVALID
used to indicate that a position is valid
Definition: Position.h:278
std::vector< GUIGlID > getObjectsInBoundary(const Boundary &bound)
returns the ids of all objects in the given boundary
void setOldValues(const Position &lookFrom, const Position &lookAt)
Resets old values.