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-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
21 // The base class for a view
22 /****************************************************************************/
23 
24 
25 // ===========================================================================
26 // included modules
27 // ===========================================================================
28 #ifdef _MSC_VER
29 #include <windows_config.h>
30 #else
31 #include <config.h>
32 #endif
33 
34 #include <iostream>
35 #include <utility>
36 #include <cmath>
37 #include <cassert>
38 #include <limits>
39 #include <fxkeys.h>
40 #include <gl2ps.h>
44 #include <utils/common/RGBColor.h>
45 #include <utils/common/ToString.h>
52 #include <utils/gui/div/GLHelper.h>
64 
65 #include "GUISUMOAbstractView.h"
66 #include "GUIMainWindow.h"
67 #include "GUIGlChildWindow.h"
69 #include "GUIDialog_EditViewport.h"
70 
71 #ifdef HAVE_GDAL
72 #if __GNUC__ > 3
73 #pragma GCC diagnostic push
74 #pragma GCC diagnostic ignored "-Wpedantic"
75 #endif
76 #include <gdal_priv.h>
77 #if __GNUC__ > 3
78 #pragma GCC diagnostic pop
79 #endif
80 #endif
81 
82 
83 // ===========================================================================
84 // debug constants
85 // ===========================================================================
86 //#define DEBUG_SNAPSHOT
87 
88 
89 // ===========================================================================
90 // member method definitions
91 // ===========================================================================
92 /* -------------------------------------------------------------------------
93  * GUISUMOAbstractView - FOX callback mapping
94  * ----------------------------------------------------------------------- */
95 FXDEFMAP(GUISUMOAbstractView) GUISUMOAbstractViewMap[] = {
96  FXMAPFUNC(SEL_CONFIGURE, 0, GUISUMOAbstractView::onConfigure),
97  FXMAPFUNC(SEL_PAINT, 0, GUISUMOAbstractView::onPaint),
98  FXMAPFUNC(SEL_LEFTBUTTONPRESS, 0, GUISUMOAbstractView::onLeftBtnPress),
99  FXMAPFUNC(SEL_LEFTBUTTONRELEASE, 0, GUISUMOAbstractView::onLeftBtnRelease),
100  FXMAPFUNC(SEL_MIDDLEBUTTONPRESS, 0, GUISUMOAbstractView::onMiddleBtnPress),
101  FXMAPFUNC(SEL_MIDDLEBUTTONRELEASE, 0, GUISUMOAbstractView::onMiddleBtnRelease),
102  FXMAPFUNC(SEL_RIGHTBUTTONPRESS, 0, GUISUMOAbstractView::onRightBtnPress),
103  FXMAPFUNC(SEL_RIGHTBUTTONRELEASE, 0, GUISUMOAbstractView::onRightBtnRelease),
104  FXMAPFUNC(SEL_DOUBLECLICKED, 0, GUISUMOAbstractView::onDoubleClicked),
105  FXMAPFUNC(SEL_MOUSEWHEEL, 0, GUISUMOAbstractView::onMouseWheel),
106  FXMAPFUNC(SEL_MOTION, 0, GUISUMOAbstractView::onMouseMove),
107  FXMAPFUNC(SEL_LEAVE, 0, GUISUMOAbstractView::onMouseLeft),
108  FXMAPFUNC(SEL_KEYPRESS, 0, GUISUMOAbstractView::onKeyPress),
109  FXMAPFUNC(SEL_KEYRELEASE, 0, GUISUMOAbstractView::onKeyRelease),
110 
111 };
112 
113 
114 FXIMPLEMENT_ABSTRACT(GUISUMOAbstractView, FXGLCanvas, GUISUMOAbstractViewMap, ARRAYNUMBER(GUISUMOAbstractViewMap))
115 
116 
117 /* -------------------------------------------------------------------------
118  * GUISUMOAbstractView - methods
119  * ----------------------------------------------------------------------- */
120 GUISUMOAbstractView::GUISUMOAbstractView(FXComposite* p, GUIMainWindow& app, GUIGlChildWindow* parent, const SUMORTree& grid, FXGLVisual* glVis, FXGLCanvas* share) :
121  FXGLCanvas(p, glVis, share, p, MID_GLCANVAS, LAYOUT_SIDE_TOP | LAYOUT_FILL_X | LAYOUT_FILL_Y, 0, 0, 0, 0),
122  myApp(&app),
123  myParent(parent),
124  myGrid(&((SUMORTree&)grid)),
125  myChanger(0),
126  myMouseHotspotX(app.getDefaultCursor()->getHotX()),
127  myMouseHotspotY(app.getDefaultCursor()->getHotY()),
128  myPopup(0),
129  myPopupPosition(Position(0, 0)),
130  myUseToolTips(false),
131  myAmInitialised(false),
132  myViewportChooser(0),
133  myWindowCursorPositionX(getWidth() / 2),
134  myWindowCursorPositionY(getHeight() / 2),
135  myVisualizationChanger(0),
136  myApplicationSnapshots(0),
137  myApplicationSnapshotsLock(0) {
138  setTarget(this);
139  enable();
140  flags |= FLAG_ENABLED;
141  myInEditMode = false;
142  // show the middle at the beginning
143  myChanger = new GUIDanielPerspectiveChanger(*this, *myGrid);
144  myVisualizationSettings = &gSchemeStorage.getDefault();
145  myVisualizationSettings->gaming = myApp->isGaming();
147 }
148 
149 
153  delete myPopup;
154  delete myChanger;
155  delete myViewportChooser;
156  delete myVisualizationChanger;
157  // cleanup decals
158  for (std::vector<GUISUMOAbstractView::Decal>::iterator it = myDecals.begin(); it != myDecals.end(); ++it) {
159  delete it->image;
160  }
161 }
162 
163 
164 bool
166  return myInEditMode;
167 }
168 
169 
172  return *myChanger;
173 }
174 
175 
176 void
178  if (!myUseToolTips) {
179  return;
180  }
181  update();
182 }
183 
184 
185 Position
188 }
189 
190 
191 Position
193  Position result = pos;
195  const double xRest = std::fmod(pos.x(), myVisualizationSettings->gridXSize) + (pos.x() < 0 ? myVisualizationSettings->gridXSize : 0);
196  const double yRest = std::fmod(pos.y(), myVisualizationSettings->gridYSize) + (pos.y() < 0 ? myVisualizationSettings->gridYSize : 0);
197  result.setx(pos.x() - xRest + (xRest < myVisualizationSettings->gridXSize * 0.5 ? 0 : myVisualizationSettings->gridXSize));
198  result.sety(pos.y() - yRest + (yRest < myVisualizationSettings->gridYSize * 0.5 ? 0 : myVisualizationSettings->gridYSize));
199  }
200  return result;
201 }
202 
203 
204 Position
206  Boundary bound = myChanger->getViewport();
207  double xNet = bound.xmin() + bound.getWidth() * x / getWidth();
208  // cursor origin is in the top-left corner
209  double yNet = bound.ymin() + bound.getHeight() * (getHeight() - y) / getHeight();
210  return Position(xNet, yNet);
211 }
212 
213 
214 void
215 GUISUMOAbstractView::addDecals(const std::vector<Decal>& decals) {
216  myDecals.insert(myDecals.end(), decals.begin(), decals.end());
217 }
218 
219 
223 }
224 
225 
226 void
229  std::string text = "x:" + toString(pos.x()) + ", y:" + toString(pos.y());
230  myApp->getCartesianLabel().setText(text.c_str());
232  if (GeoConvHelper::getFinal().usingGeoProjection()) {
233  text = "lat:" + toString(pos.y(), gPrecisionGeo) + ", lon:" + toString(pos.x(), gPrecisionGeo);
234  } else {
235  text = "x:" + toString(pos.x()) + ", y:" + toString(pos.y());
236  }
237  myApp->getGeoLabel().setText(text.c_str());
238 }
239 
240 
241 int
242 GUISUMOAbstractView::doPaintGL(int /*mode*/, const Boundary& /*boundary*/) {
243  return 0;
244 }
245 
246 
247 void
249 }
250 
251 
252 Boundary
254  return myChanger->getViewport();
255 }
256 
257 
258 void
260  if (getWidth() == 0 || getHeight() == 0) {
261  return;
262  }
263 
265  centerTo(getTrackedID(), false);
266  }
267 
269  if (myUseToolTips) {
270  id = getObjectUnderCursor();
271  }
272 
273  // draw
274  glClearColor(
279  glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
280  glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
281 
283  glEnable(GL_DITHER);
284  } else {
285  glDisable(GL_DITHER);
286  }
287  glEnable(GL_BLEND);
288  glDisable(GL_LINE_SMOOTH);
289 
291  doPaintGL(GL_RENDER, myChanger->getViewport());
293  displayLegend();
294  }
295  // check whether the select mode /tooltips)
296  // shall be computed, too
297  if (myUseToolTips && id != GUIGlObject::INVALID_ID) {
298  showToolTipFor(id);
299  }
300  swapBuffers();
301 }
302 
303 
304 GUIGlID
307 }
308 
309 
310 GUIGlID
312  const double SENSITIVITY = 0.1; // meters
313  Boundary selection;
314  selection.add(pos);
315  selection.grow(SENSITIVITY);
316  const std::vector<GUIGlID> ids = getObjectsInBoundary(selection);
317  // Interpret results
318  int idMax = 0;
319  double maxLayer = -std::numeric_limits<double>::max();
320  for (std::vector<GUIGlID>::const_iterator it = ids.begin(); it != ids.end(); it++) {
321  GUIGlID id = *it;
323  if (o == 0) {
324  continue;
325  }
326  if (o->getGlID() == 0) {
327  continue;
328  }
329  //std::cout << "point selection hit " << o->getMicrosimID() << "\n";
330  GUIGlObjectType type = o->getType();
331  if (type != 0) {
332  double layer = (double)type;
333  // determine an "abstract" layer for shapes
334  // this "layer" resembles the layer of the shape
335  // taking into account the stac of other objects
336  if (type == GLO_POI || type == GLO_POLYGON) {
337  layer = dynamic_cast<Shape*>(o)->getLayer();
338  }
340  // do not select lanes in meso mode
341  continue;
342  }
343  // check whether the current object is above a previous one
344  if (layer > maxLayer) {
345  idMax = id;
346  maxLayer = layer;
347  }
348  }
350  }
351  return idMax;
352 }
353 
354 
355 std::vector<GUIGlID>
357  Boundary selection;
358  selection.add(pos);
359  selection.grow(radius);
360  const std::vector<GUIGlID> ids = getObjectsInBoundary(selection);
361  std::vector<GUIGlID> result;
362  // Interpret results
363  for (std::vector<GUIGlID>::const_iterator it = ids.begin(); it != ids.end(); it++) {
364  GUIGlID id = *it;
366  if (o == 0) {
367  continue;
368  }
369  if (o->getGlID() == 0) {
370  continue;
371  }
372  //std::cout << "point selection hit " << o->getMicrosimID() << "\n";
373  GUIGlObjectType type = o->getType();
374  if (type != 0) {
375  result.push_back(id);
376  }
378  }
379  return result;
380 }
381 
382 
383 std::vector<GUIGlID>
385  const int NB_HITS_MAX = 1024 * 1024;
386  // Prepare the selection mode
387  static GUIGlID hits[NB_HITS_MAX];
388  static GLint nb_hits = 0;
389  glSelectBuffer(NB_HITS_MAX, hits);
390  glInitNames();
391 
392  Boundary oldViewPort = myChanger->getViewport(false); // backup the actual viewPort
393  myChanger->setViewport(bound);
394  applyGLTransform(false);
395 
396  // paint in select mode
398  int hits2 = doPaintGL(GL_SELECT, bound);
400  // Get the results
401  nb_hits = glRenderMode(GL_RENDER);
402  if (nb_hits == -1) {
403  myApp->setStatusBarText("Selection in boundary failed. Try to select fewer than " + toString(hits2) + " items");
404  }
405  std::vector<GUIGlID> result;
406  GLuint numNames;
407  GLuint* ptr = hits;
408  for (int i = 0; i < nb_hits; ++i) {
409  numNames = *ptr;
410  ptr += 3;
411  for (int j = 0; j < (int)numNames; j++) {
412  result.push_back(*ptr);
413  ptr++;
414  }
415  }
416  // switch viewport back to normal
417  myChanger->setViewport(oldViewPort);
418  return result;
419 }
420 
421 
422 void
424  if (id != 0) {
426  if (object != 0) {
428  pos.add(0, p2m(15));
429  GLHelper::drawTextBox(object->getFullName(), pos, GLO_MAX - 1, p2m(20), RGBColor::BLACK, RGBColor(255, 179, 0, 255));
431  }
432  }
433 }
434 
435 
436 void
438  // obtain minimum grid
440  // Check if the distance is enought to draw grid
442  glEnable(GL_DEPTH_TEST);
443  glLineWidth(1);
444  // get multiplication values (2 is the marging)
445  int multXmin = (int)(myChanger->getViewport().xmin() / myVisualizationSettings->gridXSize) - 2;
446  int multYmin = (int)(myChanger->getViewport().ymin() / myVisualizationSettings->gridYSize) - 2;
447  int multXmax = (int)(myChanger->getViewport().xmax() / myVisualizationSettings->gridXSize) + 2;
448  int multYmax = (int)(myChanger->getViewport().ymax() / myVisualizationSettings->gridYSize) + 2;
449  // obtain references
450  double xmin = myVisualizationSettings->gridXSize * multXmin;
451  double ymin = myVisualizationSettings->gridYSize * multYmin;
452  double xmax = myVisualizationSettings->gridXSize * multXmax;
453  double ymax = myVisualizationSettings->gridYSize * multYmax;
454  double xpos = xmin;
455  double ypos = ymin;
456  // move drawing matrix
457  glTranslated(0, 0, .55);
458  glColor3d(0.5, 0.5, 0.5);
459  // draw horizontal lines
460  glBegin(GL_LINES);
461  while (ypos <= ymax) {
462  glVertex2d(xmin, ypos);
463  glVertex2d(xmax, ypos);
465  }
466  // draw vertical lines
467  while (xpos <= xmax) {
468  glVertex2d(xpos, ymin);
469  glVertex2d(xpos, ymax);
471  }
472  glEnd();
473  glTranslated(0, 0, -.55);
474  }
475 }
476 
477 
478 void
480  // compute the scale bar length
481  int length = 1;
482  const std::string text("10000000000");
483  int noDigits = 1;
484  int pixelSize = (int) m2p((double) length);
485  while (pixelSize <= 20) {
486  length *= 10;
487  noDigits++;
488  if (noDigits > (int)text.length()) {
489  return;
490  }
491  pixelSize = (int) m2p((double) length);
492  }
493  glLineWidth(1.0);
494 
495  glMatrixMode(GL_PROJECTION);
496  glPushMatrix();
497  glLoadIdentity();
498  glMatrixMode(GL_MODELVIEW);
499  glPushMatrix();
500  glLoadIdentity();
501 
502  // draw the scale bar
503  glDisable(GL_TEXTURE_2D);
504  glDisable(GL_ALPHA_TEST);
505  glDisable(GL_BLEND);
506  glEnable(GL_DEPTH_TEST);
507 
508  double len = (double) pixelSize / (double)(getWidth() - 1) * (double) 2.0;
509  glColor3d(0, 0, 0);
510  double o = double(15) / double(getHeight());
511  double o2 = o + o;
512  double oo = double(5) / double(getHeight());
513  glBegin(GL_LINES);
514  // vertical
515  glVertex2d(-.98, -1. + o);
516  glVertex2d(-.98 + len, -1. + o);
517  // tick at begin
518  glVertex2d(-.98, -1. + o);
519  glVertex2d(-.98, -1. + o2);
520  // tick at end
521  glVertex2d(-.98 + len, -1. + o);
522  glVertex2d(-.98 + len, -1. + o2);
523  glEnd();
524 
525  const double fontHeight = 0.1 * 300. / getHeight();
526  const double fontWidth = 0.1 * 300. / getWidth();
527  // draw 0
528  GLHelper::drawText("0", Position(-.99, -0.99 + o2 + oo), 0.1, fontHeight, RGBColor::BLACK, 0, FONS_ALIGN_LEFT, fontWidth);
529 
530  // draw current scale
531  GLHelper::drawText((text.substr(0, noDigits) + "m").c_str(), Position(-.99 + len, -0.99 + o2 + oo), 0.1, fontHeight, RGBColor::BLACK, 0, FONS_ALIGN_LEFT, fontWidth);
532 
533  // restore matrices
534  glMatrixMode(GL_PROJECTION);
535  glPopMatrix();
536  glMatrixMode(GL_MODELVIEW);
537  glPopMatrix();
538 }
539 
540 
541 double
542 GUISUMOAbstractView::m2p(double meter) const {
543  return meter * getWidth() / myChanger->getViewport().getWidth();
544 }
545 
546 
547 double
548 GUISUMOAbstractView::p2m(double pixel) const {
549  return pixel * myChanger->getViewport().getWidth() / getWidth();
550 }
551 
552 
553 void
556 }
557 
558 
559 void
560 GUISUMOAbstractView::centerTo(GUIGlID id, bool applyZoom, double zoomDist) {
562  if (o != 0 && dynamic_cast<GUIGlObject*>(o) != 0) {
563  if (applyZoom && zoomDist < 0) {
565  update(); // only update when centering onto an object once
566  } else {
567  // called during tracking. update is triggered somewhere else
568  myChanger->centerTo(o->getCenteringBoundary().getCenter(), zoomDist, applyZoom);
570  }
571  }
573 }
574 
575 
576 void
578  myChanger->setViewport(bound);
579  update();
580 }
581 
582 /*
583 bool
584 GUISUMOAbstractView::allowRotation() const
585 {
586  return myParent->allowRotation();
587 }
588 */
589 
590 void
594 }
595 
596 
597 FXbool
599  FXbool ret = FXGLCanvas::makeCurrent();
600  return ret;
601 }
602 
603 
604 long
605 GUISUMOAbstractView::onConfigure(FXObject*, FXSelector, void*) {
606  if (makeCurrent()) {
607  glViewport(0, 0, getWidth() - 1, getHeight() - 1);
608  glClearColor(
613  doInit();
614  myAmInitialised = true;
615  makeNonCurrent();
616  checkSnapshots();
617  }
618  return 1;
619 }
620 
621 
622 long
623 GUISUMOAbstractView::onPaint(FXObject*, FXSelector, void*) {
624  if (!isEnabled() || !myAmInitialised) {
625  return 1;
626  }
627  if (makeCurrent()) {
628  paintGL();
629  makeNonCurrent();
630  }
631  return 1;
632 }
633 
634 
635 const Position&
637  return myPopupPosition;
638 }
639 
640 void
642  if (myPopup != NULL) {
643  delete myPopup;
644  myPopupPosition.set(0, 0);
645  myPopup = NULL;
646  }
647 }
648 
649 
650 long
651 GUISUMOAbstractView::onLeftBtnPress(FXObject*, FXSelector , void* data) {
652  destroyPopup();
653  setFocus();
654  FXEvent* e = (FXEvent*) data;
655  // check whether the selection-mode is activated
656  if ((e->state & CONTROLMASK) != 0) {
657  // try to get the object-id if so
658  if (makeCurrent()) {
659  int id = getObjectUnderCursor();
660  if (id != 0) {
662  }
663  makeNonCurrent();
664  if (id != 0) {
665  // possibly, the selection-colouring is used,
666  // so we should update the screen again...
667  update();
668  }
669  }
670  }
671  myChanger->onLeftBtnPress(data);
672  grab();
673  // Check there are double click
674  if (e->click_count == 2) {
675  handle(this, FXSEL(SEL_DOUBLECLICKED, 0), data);
676  }
677  return 1;
678 }
679 
680 
681 long
682 GUISUMOAbstractView::onLeftBtnRelease(FXObject*, FXSelector , void* data) {
683  destroyPopup();
685  if (myApp->isGaming()) {
687  }
688  ungrab();
689  return 1;
690 }
691 
692 
693 long
694 GUISUMOAbstractView::onMiddleBtnPress(FXObject*, FXSelector, void*) {
695  return 1;
696 }
697 
698 
699 long
700 GUISUMOAbstractView::onMiddleBtnRelease(FXObject*, FXSelector, void*) {
701  return 1;
702 }
703 
704 
705 long
706 GUISUMOAbstractView::onRightBtnPress(FXObject*, FXSelector , void* data) {
707  destroyPopup();
708  myChanger->onRightBtnPress(data);
709  grab();
710  return 1;
711 }
712 
713 
714 long
715 GUISUMOAbstractView::onRightBtnRelease(FXObject* o, FXSelector sel, void* data) {
716  destroyPopup();
717  onMouseMove(o, sel, data);
718  if (!myChanger->onRightBtnRelease(data) && !myApp->isGaming()) {
720  }
721  ungrab();
722  return 1;
723 }
724 
725 
726 long
727 GUISUMOAbstractView::onDoubleClicked(FXObject*, FXSelector, void*) {
728  return 1;
729 }
730 
731 
732 long
733 GUISUMOAbstractView::onMouseWheel(FXObject*, FXSelector , void* data) {
734  if (!myApp->isGaming()) {
735  myChanger->onMouseWheel(data);
737  }
738  return 1;
739 }
740 
741 
742 long
743 GUISUMOAbstractView::onMouseMove(FXObject*, FXSelector , void* data) {
744  // if popup exist but isn't shown, destroy it first
745  if (myPopup && (myPopup->shown() == false)) {
746  destroyPopup();
747  }
748  if (myPopup == NULL) {
750  myChanger->onMouseMove(data);
751  }
752  if (myViewportChooser != 0) {
754  }
756  }
757  return 1;
758 }
759 
760 
761 long
762 GUISUMOAbstractView::onMouseLeft(FXObject*, FXSelector , void* /*data*/) {
763  return 1;
764 }
765 
766 
767 void
769  ungrab();
770  if (!isEnabled() || !myAmInitialised) {
771  return;
772  }
773  if (makeCurrent()) {
774  // initialise the select mode
775  int id = getObjectUnderCursor();
776  GUIGlObject* o = 0;
777  if (id != 0) {
779  } else {
781  }
782  if (o != 0) {
783  myPopup = o->getPopUpMenu(*myApp, *this);
784  int x, y;
785  FXuint b;
786  myApp->getCursorPosition(x, y, b);
787  myPopup->setX(x + myApp->getX());
788  myPopup->setY(y + myApp->getY());
789  myPopup->create();
790  myPopup->show();
794  setFocus();
795  }
796  makeNonCurrent();
797  }
798 }
799 
800 
801 long
802 GUISUMOAbstractView::onKeyPress(FXObject* o, FXSelector sel, void* data) {
803  if (myPopup != NULL) {
804  return myPopup->onKeyPress(o, sel, data);
805  } else {
806  FXGLCanvas::onKeyPress(o, sel, data);
807  return myChanger->onKeyPress(data);
808  }
809 }
810 
811 
812 long
813 GUISUMOAbstractView::onKeyRelease(FXObject* o, FXSelector sel, void* data) {
814  if (myPopup != NULL) {
815  return myPopup->onKeyRelease(o, sel, data);
816  } else {
817  FXGLCanvas::onKeyRelease(o, sel, data);
818  return myChanger->onKeyRelease(data);
819  }
820 }
821 
822 
823 // ------------ Dealing with snapshots
824 void
825 GUISUMOAbstractView::addSnapshot(SUMOTime time, const std::string& file) {
826 #ifdef DEBUG_SNAPSHOT
827  std::cout << "add snappshot time=" << time << " file=" << file << "\n";
828 #endif
830  mySnapshots[time].push_back(file);
832  if (myApplicationSnapshots != 0) {
834  myApplicationSnapshots->insert(time);
835  myApplicationSnapshotsLock->unlock();
836  }
837 }
838 
839 std::string
840 GUISUMOAbstractView::makeSnapshot(const std::string& destFile) {
841  std::string errorMessage;
842  FXString ext = FXPath::extension(destFile.c_str());
843  const bool useGL2PS = ext == "ps" || ext == "eps" || ext == "pdf" || ext == "svg" || ext == "tex" || ext == "pgf";
844 #ifdef HAVE_FFMPEG
845  const bool useVideo = destFile == "" || ext == "h264" || ext == "hevc";
846 #endif
847  for (int i = 0; i < 10 && !makeCurrent(); ++i) {
849  }
850  // draw
851  glClearColor(
856  glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
857  glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
858 
860  glEnable(GL_DITHER);
861  } else {
862  glDisable(GL_DITHER);
863  }
864  glEnable(GL_BLEND);
865  glDisable(GL_LINE_SMOOTH);
866 
868 
869  if (useGL2PS) {
870  GLint format = GL2PS_PS;
871  if (ext == "ps") {
872  format = GL2PS_PS;
873  } else if (ext == "eps") {
874  format = GL2PS_EPS;
875  } else if (ext == "pdf") {
876  format = GL2PS_PDF;
877  } else if (ext == "tex") {
878  format = GL2PS_TEX;
879  } else if (ext == "svg") {
880  format = GL2PS_SVG;
881  } else if (ext == "pgf") {
882  format = GL2PS_PGF;
883  } else {
884  return "Could not save '" + destFile + "'.\n Unrecognized format '" + std::string(ext.text()) + "'.";
885  }
886  FILE* fp = fopen(destFile.c_str(), "wb");
887  if (fp == 0) {
888  return "Could not save '" + destFile + "'.\n Could not open file for writing";
889  }
890  GLint buffsize = 0, state = GL2PS_OVERFLOW;
891  GLint viewport[4];
892  glGetIntegerv(GL_VIEWPORT, viewport);
893  while (state == GL2PS_OVERFLOW) {
894  buffsize += 1024 * 1024;
895  gl2psBeginPage(destFile.c_str(), "sumo-gui; http://sumo.dlr.de", viewport, format, GL2PS_SIMPLE_SORT,
896  GL2PS_DRAW_BACKGROUND | GL2PS_USE_CURRENT_VIEWPORT,
897  GL_RGBA, 0, NULL, 0, 0, 0, buffsize, fp, "out.eps");
898  glMatrixMode(GL_MODELVIEW);
899  glPushMatrix();
900  glDisable(GL_TEXTURE_2D);
901  glDisable(GL_ALPHA_TEST);
902  glDisable(GL_BLEND);
903  glEnable(GL_DEPTH_TEST);
904  // compute lane width
905  // draw decals (if not in grabbing mode)
906  if (!myUseToolTips) {
907  drawDecals();
909  paintGLGrid();
910  }
911  }
912  glLineWidth(1);
913  glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
914  Boundary viewPort = myChanger->getViewport();
915  const float minB[2] = { (float)viewPort.xmin(), (float)viewPort.ymin() };
916  const float maxB[2] = { (float)viewPort.xmax(), (float)viewPort.ymax() };
918  glEnable(GL_POLYGON_OFFSET_FILL);
919  glEnable(GL_POLYGON_OFFSET_LINE);
920  myGrid->Search(minB, maxB, *myVisualizationSettings);
921 
923  displayLegend();
924  }
925  state = gl2psEndPage();
926  glFinish();
927  }
928  fclose(fp);
929  } else {
930  doPaintGL(GL_RENDER, myChanger->getViewport());
932  displayLegend();
933  }
934  swapBuffers();
935  glFinish();
936  FXColor* buf;
937  FXMALLOC(&buf, FXColor, getWidth()*getHeight());
938  // read from the back buffer
939  glReadBuffer(GL_BACK);
940  // Read the pixels
941  glReadPixels(0, 0, getWidth(), getHeight(), GL_RGBA, GL_UNSIGNED_BYTE, (GLvoid*)buf);
942  makeNonCurrent();
943  update();
944  // mirror
945  int mwidth = getWidth();
946  int mheight = getHeight();
947  FXColor* paa = buf;
948  FXColor* pbb = buf + mwidth * (mheight - 1);
949  do {
950  FXColor* pa = paa;
951  paa += mwidth;
952  FXColor* pb = pbb;
953  pbb -= mwidth;
954  do {
955  FXColor t = *pa;
956  *pa++ = *pb;
957  *pb++ = t;
958  } while (pa < paa);
959  } while (paa < pbb);
960  try {
961 #ifdef HAVE_FFMPEG
962  if (useVideo) {
963  try {
964  saveFrame(destFile, buf);
965  errorMessage = "video";
966  } catch (std::runtime_error& err) {
967  errorMessage = err.what();
968  }
969  } else
970 #endif
971  if (!MFXImageHelper::saveImage(destFile, getWidth(), getHeight(), buf)) {
972  errorMessage = "Could not save '" + destFile + "'.";
973  }
974  } catch (InvalidArgument& e) {
975  errorMessage = "Could not save '" + destFile + "'.\n" + e.what();
976  }
977  FXFREE(&buf);
978  }
979  return errorMessage;
980 }
981 
982 
983 void
984 GUISUMOAbstractView::saveFrame(const std::string& destFile, FXColor* buf) {
985  UNUSED_PARAMETER(destFile);
986  UNUSED_PARAMETER(buf);
987 }
988 
989 
990 void
993 #ifdef DEBUG_SNAPSHOT
994  std::cout << "check snappshots time=" << time << " registeredTimes=" << mySnapshots.size() << "\n";
995 #endif
997  std::map<SUMOTime, std::vector<std::string> >::iterator snapIt = mySnapshots.find(time);
998  std::vector<std::string> files;
999  if (snapIt != mySnapshots.end()) {
1000  files = snapIt->second;
1001  mySnapshots.erase(snapIt);
1002  }
1004  // decouple map access and painting to avoid deadlock
1005  for (auto file : files) {
1006 #ifdef DEBUG_SNAPSHOT
1007  std::cout << "make snappshot time=" << time << " file=" << file << "\n";
1008 #endif
1009  std::string error = makeSnapshot(file);
1010  if (error != "") {
1011  WRITE_WARNING(error);
1012  }
1013  }
1014  // synchronization with a waiting run thread
1015  if (!files.empty()) {
1016  assert(myApplicationSnapshots != 0);
1017  assert(myApplicationSnapshotsLock != 0);
1019  myApplicationSnapshots->erase(time);
1020  myApplicationSnapshotsLock->unlock();
1021  }
1022 #ifdef DEBUG_SNAPSHOT
1023  std::cout << " files=" << toString(files) << " myApplicationSnapshots=" << joinToString(*myApplicationSnapshots, ",") << "\n";
1024 #endif
1025 }
1026 
1027 
1028 SUMOTime
1030  return 0;
1031 }
1032 
1033 
1034 void
1036  if (myVisualizationChanger == 0) {
1040  &myDecals, &myDecalsLock);
1041  myVisualizationChanger->create();
1042  } else {
1044  }
1046 }
1047 
1048 
1051  if (myViewportChooser == 0) {
1052  myViewportChooser = new GUIDialog_EditViewport(this, "Edit Viewport", 0, 0);
1053  myViewportChooser->create();
1054  }
1056  return myViewportChooser;
1057 }
1058 
1059 
1060 void
1062  getViewportEditor(); // make sure it exists;
1066 }
1067 
1068 
1069 void
1070 GUISUMOAbstractView::setViewportFromTo(const Position& lookFrom, const Position& /* lookAt */) {
1071  myChanger->setViewportFrom(lookFrom.x(), lookFrom.y(), lookFrom.z());
1072  update();
1073 }
1074 
1075 
1076 void
1078  // look straight down
1081 }
1082 
1083 
1084 void
1086  myUseToolTips = val;
1087 }
1088 
1089 
1090 bool
1092  return true;
1093 }
1094 
1095 
1098  return myVisualizationSettings;
1099 }
1100 
1101 
1102 void
1104  myViewportChooser = 0;
1105 }
1106 
1107 
1108 void
1111 }
1112 
1113 
1114 double
1116  return myGrid->getWidth();
1117 }
1118 
1119 
1120 double
1122  return myGrid->getHeight();
1123 }
1124 
1125 
1126 void
1128 }
1129 
1130 
1131 void
1133 }
1134 
1135 
1136 GUIGlID
1138  return GUIGlObject::INVALID_ID;
1139 }
1140 
1141 
1142 void
1144 }
1145 
1146 
1147 FXComboBox&
1150 }
1151 
1152 
1153 FXImage*
1155 #ifdef HAVE_GDAL
1156  GDALAllRegister();
1157  GDALDataset* poDataset = (GDALDataset*)GDALOpen(d.filename.c_str(), GA_ReadOnly);
1158  if (poDataset == 0) {
1159  return 0;
1160  }
1161  const int xSize = poDataset->GetRasterXSize();
1162  const int ySize = poDataset->GetRasterYSize();
1163  // checking for geodata in the picture and try to adapt position and scale
1164  if (d.width <= 0.) {
1165  double adfGeoTransform[6];
1166  if (poDataset->GetGeoTransform(adfGeoTransform) == CE_None) {
1167  Position topLeft(adfGeoTransform[0], adfGeoTransform[3]);
1168  const double horizontalSize = xSize * adfGeoTransform[1];
1169  const double verticalSize = ySize * adfGeoTransform[5];
1170  Position bottomRight(topLeft.x() + horizontalSize, topLeft.y() + verticalSize);
1172  d.width = bottomRight.x() - topLeft.x();
1173  d.height = topLeft.y() - bottomRight.y();
1174  d.centerX = (topLeft.x() + bottomRight.x()) / 2;
1175  d.centerY = (topLeft.y() + bottomRight.y()) / 2;
1176  //WRITE_MESSAGE("proj: " + toString(poDataset->GetProjectionRef()) + " dim: " + toString(d.width) + "," + toString(d.height) + " center: " + toString(d.centerX) + "," + toString(d.centerY));
1177  } else {
1178  WRITE_WARNING("Could not convert coordinates in " + d.filename + ".");
1179  }
1180  }
1181  }
1182 #endif
1183  if (d.width <= 0.) {
1184  d.width = getGridWidth();
1185  d.height = getGridHeight();
1186  }
1187 
1188  // trying to read the picture
1189 #ifdef HAVE_GDAL
1190  const int picSize = xSize * ySize;
1191  FXColor* result;
1192  if (!FXMALLOC(&result, FXColor, picSize)) {
1193  WRITE_WARNING("Could not allocate memory for " + d.filename + ".");
1194  return 0;
1195  }
1196  for (int j = 0; j < picSize; j++) {
1197  result[j] = FXRGB(0, 0, 0);
1198  }
1199  bool valid = true;
1200  for (int i = 1; i <= poDataset->GetRasterCount(); i++) {
1201  GDALRasterBand* poBand = poDataset->GetRasterBand(i);
1202  int shift = -1;
1203  if (poBand->GetColorInterpretation() == GCI_RedBand) {
1204  shift = 0;
1205  } else if (poBand->GetColorInterpretation() == GCI_GreenBand) {
1206  shift = 1;
1207  } else if (poBand->GetColorInterpretation() == GCI_BlueBand) {
1208  shift = 2;
1209  } else if (poBand->GetColorInterpretation() == GCI_AlphaBand) {
1210  shift = 3;
1211  } else {
1212  WRITE_MESSAGE("Unknown color band in " + d.filename + ", maybe fox can parse it.");
1213  valid = false;
1214  break;
1215  }
1216  assert(xSize == poBand->GetXSize() && ySize == poBand->GetYSize());
1217  if (poBand->RasterIO(GF_Read, 0, 0, xSize, ySize, ((unsigned char*)result) + shift, xSize, ySize, GDT_Byte, 4, 4 * xSize) == CE_Failure) {
1218  valid = false;
1219  break;
1220  }
1221  }
1222  GDALClose(poDataset);
1223  if (valid) {
1224  return new FXImage(getApp(), result, IMAGE_OWNED | IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP, xSize, ySize);
1225  }
1226  FXFREE(&result);
1227 #endif
1228  return 0;
1229 }
1230 
1231 
1232 void
1234  glPushName(0);
1235  myDecalsLock.lock();
1236  for (std::vector<GUISUMOAbstractView::Decal>::iterator l = myDecals.begin(); l != myDecals.end(); ++l) {
1238  if (d.skip2D) {
1239  continue;
1240  }
1241  if (!d.initialised) {
1242  try {
1243  FXImage* img = checkGDALImage(d);
1244  if (img == 0) {
1245  img = MFXImageHelper::loadImage(getApp(), d.filename);
1246  }
1248  d.glID = GUITexturesHelper::add(img);
1249  d.initialised = true;
1250  d.image = img;
1251  } catch (InvalidArgument& e) {
1252  WRITE_ERROR("Could not load '" + d.filename + "'.\n" + e.what());
1253  d.skip2D = true;
1254  }
1255  }
1256  glPushMatrix();
1257  if (d.screenRelative) {
1258  Position center = screenPos2NetPos((int)d.centerX, (int)d.centerY);
1259  glTranslated(center.x(), center.y(), d.layer);
1260  } else {
1261  glTranslated(d.centerX, d.centerY, d.layer);
1262  }
1263  glRotated(d.rot, 0, 0, 1);
1264  glColor3d(1, 1, 1);
1265  double halfWidth = d.width / 2.;
1266  double halfHeight = d.height / 2.;
1267  if (d.screenRelative) {
1268  halfWidth = p2m(halfWidth);
1269  halfHeight = p2m(halfHeight);
1270  }
1271  GUITexturesHelper::drawTexturedBox(d.glID, -halfWidth, -halfHeight, halfWidth, halfHeight);
1272  glPopMatrix();
1273  }
1274  myDecalsLock.unlock();
1275  glPopName();
1276 }
1277 
1278 
1279 // ------------ Additional visualisations
1280 bool
1282  if (myAdditionallyDrawn.find(which) == myAdditionallyDrawn.end()) {
1283  myAdditionallyDrawn[which] = 1;
1284  } else {
1285  myAdditionallyDrawn[which] = myAdditionallyDrawn[which] + 1;
1286  }
1287  update();
1288  return true;
1289 }
1290 
1291 
1292 bool
1294  if (myAdditionallyDrawn.find(which) == myAdditionallyDrawn.end()) {
1295  return false;
1296  }
1297  int cnt = myAdditionallyDrawn[which];
1298  if (cnt == 1) {
1299  myAdditionallyDrawn.erase(which);
1300  } else {
1301  myAdditionallyDrawn[which] = myAdditionallyDrawn[which] - 1;
1302  }
1303  update();
1304  return true;
1305 }
1306 
1307 
1308 bool
1310  if (myAdditionallyDrawn.find(which) == myAdditionallyDrawn.end()) {
1311  return false;
1312  } else {
1313  return true;
1314  }
1315 }
1316 
1317 
1318 void
1320  Boundary bound = myChanger->getViewport(fixRatio);
1321  glMatrixMode(GL_PROJECTION);
1322  glLoadIdentity();
1323  // as a rough rule, each GLObject is drawn at z = -GUIGlObjectType
1324  // thus, objects with a higher value will be closer (drawn on top)
1325  // // @todo last param should be 0 after modifying all glDraw methods
1326  glOrtho(0, getWidth(), 0, getHeight(), -GLO_MAX - 1, GLO_MAX + 1);
1327  glMatrixMode(GL_MODELVIEW);
1328  glLoadIdentity();
1329  double scaleX = (double)getWidth() / bound.getWidth();
1330  double scaleY = (double)getHeight() / bound.getHeight();
1331  glScaled(scaleX, scaleY, 1);
1332  glTranslated(-bound.xmin(), -bound.ymin(), 0);
1333 }
1334 
1335 
1336 double
1338  return myApp->getDelay();
1339 }
1340 
1341 
1342 void
1344  myApp->setDelay(delay);
1345 }
1346 
1347 
1349  filename(),
1350  centerX(0),
1351  centerY(0),
1352  centerZ(0),
1353  width(0),
1354  height(0),
1355  altitude(0),
1356  rot(0),
1357  tilt(0),
1358  roll(0),
1359  layer(0),
1360  initialised(false),
1361  skip2D(false),
1362  screenRelative(false),
1363  glID(-1),
1364  image(0) {
1365 }
1366 
1367 
1368 /****************************************************************************/
1369 
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
double ymin() const
Returns minimum y-coordinate.
Definition: Boundary.cpp:137
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:131
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:72
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:132
virtual void recenterView()
recenters the view
GLCanvas - ID.
Definition: GUIAppEnum.h:208
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:89
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:90
void setDelay(double delay)
Sets the delay of the parent application.
const double SUMO_const_laneWidth
Definition: StdDefs.h:49
void displayLegend()
a line with ticks, and the length information.
bool x2cartesian(Position &from, bool includeInBoundary=true)
Converts the given coordinate into a cartesian and optionally update myConvBoundary.
void updatePositionInformation() const
update position information
double y() const
Returns the y-position.
Definition: Position.h:67
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.
void addSnapshot(SUMOTime time, const std::string &file)
Sets the snapshot time to file map.
double x() const
Returns the x-position.
Definition: Position.h:62
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.
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:487
virtual long onLeftBtnPress(FXObject *, FXSelector, void *)
double getWidth() const
Returns the width of the boudary (x-axis)
Definition: Boundary.cpp:161
bool myInEditMode
Information whether too-tip informations shall be generated.
virtual void openObjectDialog()
SUMOTime DELTA_T
Definition: SUMOTime.cpp:39
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:82
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.
int glID
whether the decal shall be drawn in screen coordinates, rather than network coordinates ...
static const RGBColor BLACK
Definition: RGBColor.h:186
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.
std::map< SUMOTime, std::vector< std::string > > mySnapshots
Snapshots.
void set(double x, double y)
set positions x and y
Definition: Position.h:92
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:73
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:39
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:47
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:199
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
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:55
virtual void setStatusBarText(const std::string &)
Definition: GUIMainWindow.h:80
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:45
void setx(double x)
set position x
Definition: Position.h:77
int gPrecisionGeo
Definition: StdDefs.cpp:30
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:86
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:45
double xmin() const
Returns minimum x-coordinate.
Definition: Boundary.cpp:125
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:301
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.
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.
FXMutex * myApplicationSnapshotsLock
void destroyPopup()
destoys the popup
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:49
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:205
void unlock()
release mutex lock
Definition: MFXMutex.cpp:93
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:511
GUIGlObject * getNetObject() const
Returns the network object.
void setViewport(GUISUMOAbstractView *view)
Sets the default viewport.
GUIVisualizationSettings * myVisualizationSettings
visualization settings
Position myPopupPosition
The current popup-menu position.
double getHeight() const
Returns the height of the boundary (y-axis)
Definition: Boundary.cpp:167
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:75
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:82
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:76
static FXImage * loadImage(FXApp *a, const std::string &file)
MFXMutex mySnapshotsLock
The mutex to use before accessing the decals list in order to avoid thread conficts.
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:83
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
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:119
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:68
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:51
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:85
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:143
#define WRITE_MESSAGE(msg)
Definition: MsgHandler.h:200
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:119
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.
FXDEFMAP(GUISUMOAbstractView) GUISUMOAbstractViewMap[]
std::string joinToString(const std::vector< T > &v, const T_BETWEEN &between, std::streamsize accuracy=gPrecision)
Definition: ToString.h:236
GUIGlChildWindow * myParent
The parent window.
virtual long onRightBtnRelease(FXObject *, FXSelector, void *)
std::set< SUMOTime > * myApplicationSnapshots
static const Position INVALID
used to indicate that a position is valid
Definition: Position.h:277
std::vector< GUIGlID > getObjectsInBoundary(const Boundary &bound)
returns the ids of all objects in the given boundary
const Position & getPopupPosition() const
get position of current popup
void setOldValues(const Position &lookFrom, const Position &lookAt)
Resets old values.