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-2016 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>
64 
65 #include "GUISUMOAbstractView.h"
66 #include "GUIMainWindow.h"
67 #include "GUIGlChildWindow.h"
69 #include "GUIDialog_EditViewport.h"
70 
71 #ifdef HAVE_GDAL
72 #include <gdal_priv.h>
73 #endif
74 
75 #ifdef CHECK_MEMORY_LEAKS
76 #include <foreign/nvwa/debug_new.h>
77 #endif // CHECK_MEMORY_LEAKS
78 
79 
80 // ===========================================================================
81 // member method definitions
82 // ===========================================================================
83 /* -------------------------------------------------------------------------
84  * GUISUMOAbstractView - FOX callback mapping
85  * ----------------------------------------------------------------------- */
86 FXDEFMAP(GUISUMOAbstractView) GUISUMOAbstractViewMap[] = {
87  FXMAPFUNC(SEL_CONFIGURE, 0, GUISUMOAbstractView::onConfigure),
88  FXMAPFUNC(SEL_PAINT, 0, GUISUMOAbstractView::onPaint),
89  FXMAPFUNC(SEL_LEFTBUTTONPRESS, 0, GUISUMOAbstractView::onLeftBtnPress),
90  FXMAPFUNC(SEL_LEFTBUTTONRELEASE, 0, GUISUMOAbstractView::onLeftBtnRelease),
91  FXMAPFUNC(SEL_MIDDLEBUTTONPRESS, 0, GUISUMOAbstractView::onMiddleBtnPress),
92  FXMAPFUNC(SEL_MIDDLEBUTTONRELEASE, 0, GUISUMOAbstractView::onMiddleBtnRelease),
93  FXMAPFUNC(SEL_RIGHTBUTTONPRESS, 0, GUISUMOAbstractView::onRightBtnPress),
94  FXMAPFUNC(SEL_RIGHTBUTTONRELEASE, 0, GUISUMOAbstractView::onRightBtnRelease),
95  FXMAPFUNC(SEL_DOUBLECLICKED, 0, GUISUMOAbstractView::onDoubleClicked),
96  FXMAPFUNC(SEL_MOUSEWHEEL, 0, GUISUMOAbstractView::onMouseWheel),
97  FXMAPFUNC(SEL_MOTION, 0, GUISUMOAbstractView::onMouseMove),
98  FXMAPFUNC(SEL_LEAVE, 0, GUISUMOAbstractView::onMouseLeft),
99  FXMAPFUNC(SEL_KEYPRESS, 0, GUISUMOAbstractView::onKeyPress),
100  FXMAPFUNC(SEL_KEYRELEASE, 0, GUISUMOAbstractView::onKeyRelease),
101 
102 };
103 
104 
105 FXIMPLEMENT_ABSTRACT(GUISUMOAbstractView, FXGLCanvas, GUISUMOAbstractViewMap, ARRAYNUMBER(GUISUMOAbstractViewMap))
106 
107 
108 /* -------------------------------------------------------------------------
109  * GUISUMOAbstractView - methods
110  * ----------------------------------------------------------------------- */
111 GUISUMOAbstractView::GUISUMOAbstractView(FXComposite* p, GUIMainWindow& app, GUIGlChildWindow* parent, const SUMORTree& grid, FXGLVisual* glVis, FXGLCanvas* share) :
112  FXGLCanvas(p, glVis, share, p, MID_GLCANVAS,
113  LAYOUT_SIDE_TOP | LAYOUT_FILL_X | LAYOUT_FILL_Y, 0, 0, 0, 0),
114  myApp(&app),
115  myParent(parent),
116  myGrid(&((SUMORTree&)grid)),
117  myChanger(0),
118  myMouseHotspotX(app.getDefaultCursor()->getHotX()),
119  myMouseHotspotY(app.getDefaultCursor()->getHotY()),
120  myPopup(0),
121  myUseToolTips(false),
122  myAmInitialised(false),
123  myViewportChooser(0),
124  myWindowCursorPositionX(getWidth() / 2),
125  myWindowCursorPositionY(getHeight() / 2),
126  myVisualizationChanger(0) {
127  setTarget(this);
128  enable();
129  flags |= FLAG_ENABLED;
130  myInEditMode = false;
131  // show the middle at the beginning
132  myChanger = new GUIDanielPerspectiveChanger(*this, *myGrid);
133  myVisualizationSettings = &gSchemeStorage.getDefault();
134  myVisualizationSettings->gaming = myApp->isGaming();
136 }
137 
138 
142  delete myPopup;
143  delete myChanger;
144  delete myViewportChooser;
145  delete myVisualizationChanger;
146  // cleanup decals
147  for (std::vector<GUISUMOAbstractView::Decal>::iterator it = myDecals.begin(); it != myDecals.end(); ++it) {
148  delete it->image;
149  }
150 }
151 
152 
153 bool
155  return myInEditMode;
156 }
157 
158 
161  return *myChanger;
162 }
163 
164 
165 void
167  if (!myUseToolTips) {
168  return;
169  }
170  update();
171 }
172 
173 
174 Position
176  Boundary bound = myChanger->getViewport();
177  SUMOReal x = bound.xmin() + bound.getWidth() * myWindowCursorPositionX / getWidth();
178  // cursor origin is in the top-left corner
179  SUMOReal y = bound.ymin() + bound.getHeight() * (getHeight() - myWindowCursorPositionY) / getHeight();
180  return Position(x, y);
181 }
182 
183 
184 void
185 GUISUMOAbstractView::addDecals(const std::vector<Decal>& decals) {
186  myDecals.insert(myDecals.end(), decals.begin(), decals.end());
187 }
188 
189 
193 }
194 
195 
196 void
199  std::string text = "x:" + toString(pos.x()) + ", y:" + toString(pos.y());
200  myApp->getCartesianLabel().setText(text.c_str());
202  if (GeoConvHelper::getFinal().usingGeoProjection()) {
203  text = "lat:" + toString(pos.y(), GEO_OUTPUT_ACCURACY) + ", lon:" + toString(pos.x(), GEO_OUTPUT_ACCURACY);
204  } else {
205  text = "x:" + toString(pos.x()) + ", y:" + toString(pos.y());
206  }
207  myApp->getGeoLabel().setText(text.c_str());
208 }
209 
210 
211 int
212 GUISUMOAbstractView::doPaintGL(int /*mode*/, const Boundary& /*boundary*/) {
213  return 0;
214 }
215 
216 
217 void
219 }
220 
221 
222 Boundary
224  return myChanger->getViewport();
225 }
226 
227 
228 void
230  if (getWidth() == 0 || getHeight() == 0) {
231  return;
232  }
233 
235  centerTo(getTrackedID(), false);
236  }
237 
239  if (myUseToolTips) {
240  id = getObjectUnderCursor();
241  }
242 
243  // draw
244  glClearColor(
249  glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
250  glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
251 
253  glEnable(GL_DITHER);
254  } else {
255  glDisable(GL_DITHER);
256  }
258  glEnable(GL_BLEND);
259  glEnable(GL_POLYGON_SMOOTH);
260  glEnable(GL_LINE_SMOOTH);
261  } else {
262  glDisable(GL_BLEND);
263  glDisable(GL_POLYGON_SMOOTH);
264  glDisable(GL_LINE_SMOOTH);
265  }
266 
268  doPaintGL(GL_RENDER, myChanger->getViewport());
270  displayLegend();
271  }
272  // check whether the select mode /tooltips)
273  // shall be computed, too
274  if (myUseToolTips && id != GUIGlObject::INVALID_ID) {
275  showToolTipFor(id);
276  }
277  swapBuffers();
278 }
279 
280 
281 GUIGlID
284 }
285 
286 
287 GUIGlID
289  const SUMOReal SENSITIVITY = 0.1; // meters
290  Boundary selection;
291  selection.add(pos);
292  selection.grow(SENSITIVITY);
293  const std::vector<GUIGlID> ids = getObjectsInBoundary(selection);
294  // Interpret results
295  int idMax = 0;
297  for (std::vector<GUIGlID>::const_iterator it = ids.begin(); it != ids.end(); it++) {
298  GUIGlID id = *it;
300  if (o == 0) {
301  continue;
302  }
303  if (o->getGlID() == 0) {
304  continue;
305  }
306  //std::cout << "point selection hit " << o->getMicrosimID() << "\n";
307  GUIGlObjectType type = o->getType();
308  if (type != 0) {
309  SUMOReal layer = (SUMOReal)type;
310  // determine an "abstract" layer for shapes
311  // this "layer" resembles the layer of the shape
312  // taking into account the stac of other objects
313  if (type == GLO_POI || type == GLO_POLYGON) {
314  layer = dynamic_cast<Shape*>(o)->getLayer();
315  }
317  // do not select lanes in meso mode
318  continue;
319  }
320  // check whether the current object is above a previous one
321  if (layer > maxLayer) {
322  idMax = id;
323  maxLayer = layer;
324  }
325  }
327  }
328  return idMax;
329 }
330 
331 
332 std::vector<GUIGlID>
334  Boundary selection;
335  selection.add(pos);
336  selection.grow(radius);
337  const std::vector<GUIGlID> ids = getObjectsInBoundary(selection);
338  std::vector<GUIGlID> result;
339  // Interpret results
340  for (std::vector<GUIGlID>::const_iterator it = ids.begin(); it != ids.end(); it++) {
341  GUIGlID id = *it;
343  if (o == 0) {
344  continue;
345  }
346  if (o->getGlID() == 0) {
347  continue;
348  }
349  //std::cout << "point selection hit " << o->getMicrosimID() << "\n";
350  GUIGlObjectType type = o->getType();
351  if (type != 0) {
352  result.push_back(id);
353  }
355  }
356  return result;
357 }
358 
359 
360 std::vector<GUIGlID>
362  const int NB_HITS_MAX = 1024 * 1024;
363  // Prepare the selection mode
364  static GUIGlID hits[NB_HITS_MAX];
365  static GLint nb_hits = 0;
366  glSelectBuffer(NB_HITS_MAX, hits);
367  glInitNames();
368 
369  Boundary oldViewPort = myChanger->getViewport(false); // backup the actual viewPort
370  myChanger->setViewport(bound);
371  applyGLTransform(false);
372 
373  // paint in select mode
375  int hits2 = doPaintGL(GL_SELECT, bound);
377  // Get the results
378  nb_hits = glRenderMode(GL_RENDER);
379  if (nb_hits == -1) {
380  myApp->setStatusBarText("Selection in boundary failed. Try to select fewer than " + toString(hits2) + " items");
381  }
382  std::vector<GUIGlID> result;
383  GLuint numNames;
384  GLuint* ptr = hits;
385  for (int i = 0; i < nb_hits; ++i) {
386  numNames = *ptr;
387  ptr += 3;
388  for (int j = 0; j < (int)numNames; j++) {
389  result.push_back(*ptr);
390  ptr++;
391  }
392  }
393  // switch viewport back to normal
394  myChanger->setViewport(oldViewPort);
395  return result;
396 }
397 
398 
399 void
401  if (id != 0) {
403  if (object != 0) {
405  pos.add(0, p2m(15));
406  GLHelper::drawTextBox(object->getFullName(), pos, GLO_MAX - 1, p2m(20), RGBColor::BLACK, RGBColor(255, 179, 0, 255));
408  }
409  }
410 }
411 
412 
413 void
415  glEnable(GL_DEPTH_TEST);
416  glLineWidth(1);
417 
418  SUMOReal xmin = myGrid->xmin();
419  SUMOReal ymin = myGrid->ymin();
420  SUMOReal ypos = ymin;
421  SUMOReal xpos = xmin;
422  SUMOReal xend = myGrid->xmax();
423  SUMOReal yend = myGrid->ymax();
424 
425  glTranslated(0, 0, .55);
426  glColor3d(0.5, 0.5, 0.5);
427  // draw horizontal lines
428  glBegin(GL_LINES);
429  for (; ypos < yend;) {
430  glVertex2d(xmin, ypos);
431  glVertex2d(xend, ypos);
433  }
434  // draw vertical lines
435  for (; xpos < xend;) {
436  glVertex2d(xpos, ymin);
437  glVertex2d(xpos, yend);
439  }
440  glEnd();
441  glTranslated(0, 0, -.55);
442 }
443 
444 
445 void
447  // compute the scale bar length
448  int length = 1;
449  const std::string text("10000000000");
450  int noDigits = 1;
451  int pixelSize = (int) m2p((SUMOReal) length);
452  while (pixelSize <= 20) {
453  length *= 10;
454  noDigits++;
455  if (noDigits > (int)text.length()) {
456  return;
457  }
458  pixelSize = (int) m2p((SUMOReal) length);
459  }
460  SUMOReal lineWidth = 1.0;
461  glLineWidth((SUMOReal) lineWidth);
462 
463  glMatrixMode(GL_PROJECTION);
464  glPushMatrix();
465  glLoadIdentity();
466  glMatrixMode(GL_MODELVIEW);
467  glPushMatrix();
468  glLoadIdentity();
469 
470  // draw the scale bar
471  glDisable(GL_TEXTURE_2D);
472  glDisable(GL_ALPHA_TEST);
473  glDisable(GL_BLEND);
474  glEnable(GL_DEPTH_TEST);
475 
476  SUMOReal len = (SUMOReal) pixelSize / (SUMOReal)(getWidth() - 1) * (SUMOReal) 2.0;
477  glColor3d(0, 0, 0);
478  double o = double(15) / double(getHeight());
479  double o2 = o + o;
480  double oo = double(5) / double(getHeight());
481  glBegin(GL_LINES);
482  // vertical
483  glVertex2d(-.98, -1. + o);
484  glVertex2d(-.98 + len, -1. + o);
485  // tick at begin
486  glVertex2d(-.98, -1. + o);
487  glVertex2d(-.98, -1. + o2);
488  // tick at end
489  glVertex2d(-.98 + len, -1. + o);
490  glVertex2d(-.98 + len, -1. + o2);
491  glEnd();
492 
493  SUMOReal w = SUMOReal(35) / SUMOReal(getWidth());
494  SUMOReal h = SUMOReal(35) / SUMOReal(getHeight());
495  pfSetPosition(SUMOReal(-0.99), SUMOReal(1. - o2 - oo));
496  pfSetScaleXY(w, h);
497  glRotated(180, 1, 0, 0);
498  pfDrawString("0m");
499  glRotated(-180, 1, 0, 0);
500 
501  pfSetPosition(SUMOReal(-.99 + len), SUMOReal(1. - o2 - oo));
502  glRotated(180, 1, 0, 0);
503  pfDrawString((text.substr(0, noDigits) + "m").c_str());
504  glRotated(-180, 1, 0, 0);
505 
506  // restore matrices
507  glMatrixMode(GL_PROJECTION);
508  glPopMatrix();
509  glMatrixMode(GL_MODELVIEW);
510  glPopMatrix();
511 }
512 
513 
514 SUMOReal
516  return meter * getWidth() / myChanger->getViewport().getWidth();
517 }
518 
519 
520 SUMOReal
522  return pixel * myChanger->getViewport().getWidth() / getWidth();
523 }
524 
525 
526 void
529 }
530 
531 
532 void
533 GUISUMOAbstractView::centerTo(GUIGlID id, bool applyZoom, SUMOReal zoomDist) {
535  if (o != 0 && dynamic_cast<GUIGlObject*>(o) != 0) {
536  if (applyZoom && zoomDist < 0) {
538  update(); // only update when centering onto an object once
539  } else {
540  // called during tracking. update is triggered somewhere else
541  myChanger->centerTo(o->getCenteringBoundary().getCenter(), zoomDist, applyZoom);
543  }
544  }
546 }
547 
548 
549 void
551  myChanger->setViewport(bound);
552  update();
553 }
554 
555 /*
556 bool
557 GUISUMOAbstractView::allowRotation() const
558 {
559  return myParent->allowRotation();
560 }
561 */
562 
563 void
567 }
568 
569 
570 FXbool
572  FXbool ret = FXGLCanvas::makeCurrent();
573  return ret;
574 }
575 
576 
577 long
578 GUISUMOAbstractView::onConfigure(FXObject*, FXSelector, void*) {
579  if (makeCurrent()) {
580  glViewport(0, 0, getWidth() - 1, getHeight() - 1);
581  glClearColor(
586  doInit();
587  myAmInitialised = true;
588  makeNonCurrent();
589  checkSnapshots();
590  }
591  return 1;
592 }
593 
594 
595 long
596 GUISUMOAbstractView::onPaint(FXObject*, FXSelector, void*) {
597  if (!isEnabled() || !myAmInitialised) {
598  return 1;
599  }
600  if (makeCurrent()) {
601  paintGL();
602  makeNonCurrent();
603  }
604  return 1;
605 }
606 
607 
608 void
610  delete myPopup;
611  myPopup = 0;
612 }
613 
614 
615 long
616 GUISUMOAbstractView::onLeftBtnPress(FXObject*, FXSelector , void* data) {
617  destroyPopup();
618  setFocus();
619  FXEvent* e = (FXEvent*) data;
620  // check whether the selection-mode is activated
621  if ((e->state & CONTROLMASK) != 0) {
622  // try to get the object-id if so
623  if (makeCurrent()) {
624  int id = getObjectUnderCursor();
625  if (id != 0) {
627  }
628  makeNonCurrent();
629  if (id != 0) {
630  // possibly, the selection-colouring is used,
631  // so we should update the screen again...
632  update();
633  }
634  }
635  }
636  myChanger->onLeftBtnPress(data);
637  grab();
638  // Check there are double click
639  if (e->click_count == 2) {
640  handle(this, FXSEL(SEL_DOUBLECLICKED, 0), data);
641  }
642  return 1;
643 }
644 
645 
646 long
647 GUISUMOAbstractView::onLeftBtnRelease(FXObject*, FXSelector , void* data) {
648  destroyPopup();
650  if (myApp->isGaming()) {
652  }
653  ungrab();
654  return 1;
655 }
656 
657 
658 long
659 GUISUMOAbstractView::onMiddleBtnPress(FXObject*, FXSelector, void*) {
660  return 1;
661 }
662 
663 
664 long
665 GUISUMOAbstractView::onMiddleBtnRelease(FXObject*, FXSelector, void*) {
666  return 1;
667 }
668 
669 
670 long
671 GUISUMOAbstractView::onRightBtnPress(FXObject*, FXSelector , void* data) {
672  destroyPopup();
673  myChanger->onRightBtnPress(data);
674  grab();
675  return 1;
676 }
677 
678 
679 long
680 GUISUMOAbstractView::onRightBtnRelease(FXObject* o, FXSelector sel, void* data) {
681  destroyPopup();
682  onMouseMove(o, sel, data);
683  if (!myChanger->onRightBtnRelease(data) && !myApp->isGaming()) {
685  }
686  ungrab();
687  return 1;
688 }
689 
690 
691 long
692 GUISUMOAbstractView::onDoubleClicked(FXObject*, FXSelector, void*) {
693  return 1;
694 }
695 
696 
697 long
698 GUISUMOAbstractView::onMouseWheel(FXObject*, FXSelector , void* data) {
699  if (!myApp->isGaming()) {
700  myChanger->onMouseWheel(data);
702  }
703  return 1;
704 }
705 
706 
707 long
708 GUISUMOAbstractView::onMouseMove(FXObject*, FXSelector , void* data) {
710  myChanger->onMouseMove(data);
711  }
712  if (myViewportChooser != 0) {
714  }
716  return 1;
717 }
718 
719 
720 long
721 GUISUMOAbstractView::onMouseLeft(FXObject*, FXSelector , void* /*data*/) {
722  return 1;
723 }
724 
725 
726 void
728  ungrab();
729  if (!isEnabled() || !myAmInitialised) {
730  return;
731  }
732  if (makeCurrent()) {
733  // initialise the select mode
734  int id = getObjectUnderCursor();
735  GUIGlObject* o = 0;
736  if (id != 0) {
738  } else {
740  }
741  if (o != 0) {
742  myPopup = o->getPopUpMenu(*myApp, *this);
743  int x, y;
744  FXuint b;
745  myApp->getCursorPosition(x, y, b);
746  myPopup->setX(x + myApp->getX());
747  myPopup->setY(y + myApp->getY());
748  myPopup->create();
749  myPopup->show();
752  }
753  makeNonCurrent();
754  }
755 }
756 
757 
758 long
759 GUISUMOAbstractView::onKeyPress(FXObject* o, FXSelector sel, void* data) {
760  FXGLCanvas::onKeyPress(o, sel, data);
761  return myChanger->onKeyPress(data);
762 }
763 
764 
765 long
766 GUISUMOAbstractView::onKeyRelease(FXObject* o, FXSelector sel, void* data) {
767  FXGLCanvas::onKeyRelease(o, sel, data);
768  return myChanger->onKeyRelease(data);
769 }
770 
771 
772 // ------------ Dealing with snapshots
773 void
774 GUISUMOAbstractView::setSnapshots(std::map<SUMOTime, std::string> snaps) {
775  mySnapshots.insert(snaps.begin(), snaps.end());
776 }
777 
778 
779 std::string
780 GUISUMOAbstractView::makeSnapshot(const std::string& destFile) {
781  std::string errorMessage;
782  FXString ext = FXPath::extension(destFile.c_str());
783  const bool useGL2PS = ext == "ps" || ext == "eps" || ext == "pdf" || ext == "svg" || ext == "tex" || ext == "pgf";
784 #ifdef HAVE_FFMPEG
785  const bool useVideo = destFile == "" || ext == "h264" || ext == "hevc";
786 #endif
787  for (int i = 0; i < 10 && !makeCurrent(); ++i) {
789  }
790  // draw
791  glClearColor(
796  glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
797  glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
798 
800  glEnable(GL_DITHER);
801  } else {
802  glDisable(GL_DITHER);
803  }
805  glEnable(GL_BLEND);
806  glEnable(GL_POLYGON_SMOOTH);
807  glEnable(GL_LINE_SMOOTH);
808  } else {
809  glDisable(GL_BLEND);
810  glDisable(GL_POLYGON_SMOOTH);
811  glDisable(GL_LINE_SMOOTH);
812  }
813 
815 
816  if (useGL2PS) {
817  GLint format = GL2PS_PS;
818  if (ext == "ps") {
819  format = GL2PS_PS;
820  } else if (ext == "eps") {
821  format = GL2PS_EPS;
822  } else if (ext == "pdf") {
823  format = GL2PS_PDF;
824  } else if (ext == "tex") {
825  format = GL2PS_TEX;
826  } else if (ext == "svg") {
827  format = GL2PS_SVG;
828  } else if (ext == "pgf") {
829  format = GL2PS_PGF;
830  } else {
831  return "Could not save '" + destFile + "'.\n Unrecognized format '" + std::string(ext.text()) + "'.";
832  }
833  FILE* fp = fopen(destFile.c_str(), "wb");
834  if (fp == 0) {
835  return "Could not save '" + destFile + "'.\n Could not open file for writing";
836  }
837  GLint buffsize = 0, state = GL2PS_OVERFLOW;
838  GLint viewport[4];
839  glGetIntegerv(GL_VIEWPORT, viewport);
840  while (state == GL2PS_OVERFLOW) {
841  buffsize += 1024 * 1024;
842  gl2psBeginPage(destFile.c_str(), "sumo-gui; http://sumo.dlr.de", viewport, format, GL2PS_SIMPLE_SORT,
843  GL2PS_DRAW_BACKGROUND | GL2PS_USE_CURRENT_VIEWPORT,
844  GL_RGBA, 0, NULL, 0, 0, 0, buffsize, fp, "out.eps");
845  glMatrixMode(GL_MODELVIEW);
846  glPushMatrix();
847  glDisable(GL_TEXTURE_2D);
848  glDisable(GL_ALPHA_TEST);
849  glDisable(GL_BLEND);
850  glEnable(GL_DEPTH_TEST);
851  // compute lane width
852  // draw decals (if not in grabbing mode)
853  if (!myUseToolTips) {
854  drawDecals();
856  paintGLGrid();
857  }
858  }
859  glLineWidth(1);
860  glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
861  Boundary viewPort = myChanger->getViewport();
862  float minB[2];
863  float maxB[2];
864  minB[0] = viewPort.xmin();
865  minB[1] = viewPort.ymin();
866  maxB[0] = viewPort.xmax();
867  maxB[1] = viewPort.ymax();
869  glEnable(GL_POLYGON_OFFSET_FILL);
870  glEnable(GL_POLYGON_OFFSET_LINE);
871  myGrid->Search(minB, maxB, *myVisualizationSettings);
872 
874  displayLegend();
875  }
876  state = gl2psEndPage();
877  glFinish();
878  }
879  fclose(fp);
880  } else {
881  doPaintGL(GL_RENDER, myChanger->getViewport());
883  displayLegend();
884  }
885  swapBuffers();
886  glFinish();
887  FXColor* buf;
888  FXMALLOC(&buf, FXColor, getWidth()*getHeight());
889  // read from the back buffer
890  glReadBuffer(GL_BACK);
891  // Read the pixels
892  glReadPixels(0, 0, getWidth(), getHeight(), GL_RGBA, GL_UNSIGNED_BYTE, (GLvoid*)buf);
893  makeNonCurrent();
894  update();
895  // mirror
896  int mwidth = getWidth();
897  int mheight = getHeight();
898  FXColor* paa = buf;
899  FXColor* pbb = buf + mwidth * (mheight - 1);
900  do {
901  FXColor* pa = paa;
902  paa += mwidth;
903  FXColor* pb = pbb;
904  pbb -= mwidth;
905  do {
906  FXColor t = *pa;
907  *pa++ = *pb;
908  *pb++ = t;
909  } while (pa < paa);
910  } while (paa < pbb);
911  try {
912 #ifdef HAVE_FFMPEG
913  if (useVideo) {
914  try {
915  saveFrame(destFile, buf);
916  errorMessage = "video";
917  } catch (std::runtime_error& err) {
918  errorMessage = err.what();
919  }
920  } else
921 #endif
922  if (!MFXImageHelper::saveImage(destFile, getWidth(), getHeight(), buf)) {
923  errorMessage = "Could not save '" + destFile + "'.";
924  }
925  } catch (InvalidArgument& e) {
926  errorMessage = "Could not save '" + destFile + "'.\n" + e.what();
927  }
928  FXFREE(&buf);
929  }
930  return errorMessage;
931 }
932 
933 
934 void
935 GUISUMOAbstractView::saveFrame(const std::string& destFile, FXColor* buf) {
936  UNUSED_PARAMETER(destFile);
937  UNUSED_PARAMETER(buf);
938 }
939 
940 
941 void
943  std::map<SUMOTime, std::string>::iterator snapIt = mySnapshots.find(getCurrentTimeStep());
944  if (snapIt != mySnapshots.end()) {
945  std::string error = makeSnapshot(snapIt->second);
946  if (error != "") {
947  WRITE_WARNING(error);
948  }
949  }
950 }
951 
952 
953 SUMOTime
955  return 0;
956 }
957 
958 
959 void
961  if (myVisualizationChanger == 0) {
966  myVisualizationChanger->create();
967  } else {
969  }
970  myVisualizationChanger->show();
971 }
972 
973 
976  if (myViewportChooser == 0) {
978  new GUIDialog_EditViewport(this, "Edit Viewport...", 0, 0);
979  myViewportChooser->create();
980  }
982  return myViewportChooser;
983 }
984 
985 
986 void
988  getViewportEditor(); // make sure it exists;
991  myViewportChooser->show();
992 }
993 
994 
995 void
996 GUISUMOAbstractView::setViewportFromTo(const Position& lookFrom, const Position& /* lookAt */) {
997  myChanger->setViewportFrom(lookFrom.x(), lookFrom.y(), lookFrom.z());
998  update();
999 }
1000 
1001 
1002 void
1004  // look straight down
1007 }
1008 
1009 
1010 void
1012  myUseToolTips = val;
1013 }
1014 
1015 
1016 bool
1018  return true;
1019 }
1020 
1021 
1024  return myVisualizationSettings;
1025 }
1026 
1027 
1028 void
1030  myViewportChooser = 0;
1031 }
1032 
1033 
1034 void
1037 }
1038 
1039 
1040 SUMOReal
1042  return myGrid->getWidth();
1043 }
1044 
1045 
1046 SUMOReal
1048  return myGrid->getHeight();
1049 }
1050 
1051 
1052 void
1054 }
1055 
1056 
1057 void
1059 }
1060 
1061 
1062 GUIGlID
1064  return GUIGlObject::INVALID_ID;
1065 }
1066 
1067 
1068 void
1070 }
1071 
1072 
1073 FXComboBox&
1076 }
1077 
1078 
1079 FXImage*
1081 #ifdef HAVE_GDAL
1082  GDALAllRegister();
1083  GDALDataset* poDataset = (GDALDataset*)GDALOpen(d.filename.c_str(), GA_ReadOnly);
1084  if (poDataset == 0) {
1085  return 0;
1086  }
1087  const int xSize = poDataset->GetRasterXSize();
1088  const int ySize = poDataset->GetRasterYSize();
1089  // checking for geodata in the picture and try to adapt position and scale
1090  if (d.width <= 0.) {
1091  double adfGeoTransform[6];
1092  if (poDataset->GetGeoTransform(adfGeoTransform) == CE_None) {
1093  Position topLeft(adfGeoTransform[0], adfGeoTransform[3]);
1094  const double horizontalSize = xSize * adfGeoTransform[1];
1095  const double verticalSize = ySize * adfGeoTransform[5];
1096  Position bottomRight(topLeft.x() + horizontalSize, topLeft.y() + verticalSize);
1098  d.width = bottomRight.x() - topLeft.x();
1099  d.height = topLeft.y() - bottomRight.y();
1100  d.centerX = (topLeft.x() + bottomRight.x()) / 2;
1101  d.centerY = (topLeft.y() + bottomRight.y()) / 2;
1102  //WRITE_MESSAGE("proj: " + toString(poDataset->GetProjectionRef()) + " dim: " + toString(d.width) + "," + toString(d.height) + " center: " + toString(d.centerX) + "," + toString(d.centerY));
1103  } else {
1104  WRITE_WARNING("Could not convert coordinates in " + d.filename + ".");
1105  }
1106  }
1107  }
1108 #endif
1109  if (d.width <= 0.) {
1110  d.width = getGridWidth();
1111  d.height = getGridHeight();
1112  }
1113 
1114  // trying to read the picture
1115 #ifdef HAVE_GDAL
1116  const int picSize = xSize * ySize;
1117  FXColor* result;
1118  if (!FXMALLOC(&result, FXColor, picSize)) {
1119  WRITE_WARNING("Could not allocate memory for " + d.filename + ".");
1120  return 0;
1121  }
1122  for (int j = 0; j < picSize; j++) {
1123  result[j] = FXRGB(0, 0, 0);
1124  }
1125  bool valid = true;
1126  for (int i = 1; i <= poDataset->GetRasterCount(); i++) {
1127  GDALRasterBand* poBand = poDataset->GetRasterBand(i);
1128  int shift = -1;
1129  if (poBand->GetColorInterpretation() == GCI_RedBand) {
1130  shift = 0;
1131  } else if (poBand->GetColorInterpretation() == GCI_GreenBand) {
1132  shift = 1;
1133  } else if (poBand->GetColorInterpretation() == GCI_BlueBand) {
1134  shift = 2;
1135  } else if (poBand->GetColorInterpretation() == GCI_AlphaBand) {
1136  shift = 3;
1137  } else {
1138  WRITE_MESSAGE("Unknown color band in " + d.filename + ", maybe fox can parse it.");
1139  valid = false;
1140  break;
1141  }
1142  assert(xSize == poBand->GetXSize() && ySize == poBand->GetYSize());
1143  if (poBand->RasterIO(GF_Read, 0, 0, xSize, ySize, ((unsigned char*)result) + shift, xSize, ySize, GDT_Byte, 4, 4 * xSize) == CE_Failure) {
1144  valid = false;
1145  break;
1146  }
1147  }
1148  GDALClose(poDataset);
1149  if (valid) {
1150  return new FXImage(getApp(), result, IMAGE_OWNED | IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP, xSize, ySize);
1151  }
1152  FXFREE(&result);
1153 #endif
1154  return 0;
1155 }
1156 
1157 
1158 void
1160  glPushName(0);
1161  myDecalsLock.lock();
1162  for (std::vector<GUISUMOAbstractView::Decal>::iterator l = myDecals.begin(); l != myDecals.end(); ++l) {
1164  if (d.skip2D) {
1165  continue;
1166  }
1167  if (!d.initialised) {
1168  try {
1169  FXImage* img = checkGDALImage(d);
1170  if (img == 0) {
1171  img = MFXImageHelper::loadImage(getApp(), d.filename);
1172  }
1174  d.glID = GUITexturesHelper::add(img);
1175  d.initialised = true;
1176  d.image = img;
1177  } catch (InvalidArgument& e) {
1178  WRITE_ERROR("Could not load '" + d.filename + "'.\n" + e.what());
1179  d.skip2D = true;
1180  }
1181  }
1182  glPushMatrix();
1183  glTranslated(d.centerX, d.centerY, d.layer);
1184  glRotated(d.rot, 0, 0, 1);
1185  glColor3d(1, 1, 1);
1186  const SUMOReal halfWidth = d.width / 2.;
1187  const SUMOReal halfHeight = d.height / 2.;
1188  GUITexturesHelper::drawTexturedBox(d.glID, -halfWidth, -halfHeight, halfWidth, halfHeight);
1189  glPopMatrix();
1190  }
1191  myDecalsLock.unlock();
1192  glPopName();
1193 }
1194 
1195 
1196 // ------------ Additional visualisations
1197 bool
1199  if (myAdditionallyDrawn.find(which) == myAdditionallyDrawn.end()) {
1200  myAdditionallyDrawn[which] = 1;
1201  } else {
1202  myAdditionallyDrawn[which] = myAdditionallyDrawn[which] + 1;
1203  }
1204  update();
1205  return true;
1206 }
1207 
1208 
1209 bool
1211  if (getTrackedID() == which->getGlID()) {
1212  stopTrack();
1213  }
1214  if (myAdditionallyDrawn.find(which) == myAdditionallyDrawn.end()) {
1215  return false;
1216  }
1217  int cnt = myAdditionallyDrawn[which];
1218  if (cnt == 1) {
1219  myAdditionallyDrawn.erase(which);
1220  } else {
1221  myAdditionallyDrawn[which] = myAdditionallyDrawn[which] - 1;
1222  }
1223  update();
1224  return true;
1225 }
1226 
1227 
1228 bool
1230  if (myAdditionallyDrawn.find(which) == myAdditionallyDrawn.end()) {
1231  return false;
1232  } else {
1233  return true;
1234  }
1235 }
1236 
1237 
1238 void
1240  Boundary bound = myChanger->getViewport(fixRatio);
1241  glMatrixMode(GL_PROJECTION);
1242  glLoadIdentity();
1243  // as a rough rule, each GLObject is drawn at z = -GUIGlObjectType
1244  // thus, objects with a higher value will be closer (drawn on top)
1245  // // @todo last param should be 0 after modifying all glDraw methods
1246  glOrtho(0, getWidth(), 0, getHeight(), -GLO_MAX - 1, GLO_MAX + 1);
1247  glMatrixMode(GL_MODELVIEW);
1248  glLoadIdentity();
1249  SUMOReal scaleX = (SUMOReal)getWidth() / bound.getWidth();
1250  SUMOReal scaleY = (SUMOReal)getHeight() / bound.getHeight();
1251  glScaled(scaleX, scaleY, 1);
1252  glTranslated(-bound.xmin(), -bound.ymin(), 0);
1253 }
1254 
1255 
1256 SUMOReal
1258  return myApp->getDelay();
1259 }
1260 
1261 
1262 void
1264  myApp->setDelay(delay);
1265 }
1266 
1267 
1269  filename(),
1270  centerX(0),
1271  centerY(0),
1272  centerZ(0),
1273  width(0),
1274  height(0),
1275  altitude(0),
1276  rot(0),
1277  tilt(0),
1278  roll(0),
1279  layer(0),
1280  initialised(false),
1281  skip2D(false),
1282  glID(-1),
1283  image(0) {
1284 }
1285 
1286 
1287 /****************************************************************************/
1288 
GUIDialog_EditViewport * getViewportEditor()
get the viewport and create it on first access
void paintGLGrid()
paints a grid
A decal (an image) that can be shown.
virtual long onConfigure(FXObject *, FXSelector, void *)
mouse functions
void setValues(SUMOReal zoom, SUMOReal xoff, SUMOReal yoff)
Sets the given values into the dialog.
void showToolTips(bool val)
show tool tips
int pfDrawString(const char *c)
Definition: polyfonts.c:1074
SUMOReal getHeight() const
Returns the height of the boundary.
Definition: Boundary.cpp:142
GUICompleteSchemeStorage gSchemeStorage
bool showSizeLegend
Information whether the size legend shall be drawn.
void cartesian2geo(Position &cartesian) const
Converts the given cartesian (shifted) position to its geo (lat/long) representation.
long long int SUMOTime
Definition: SUMOTime.h:43
FXImage * checkGDALImage(Decal &d)
check whether we can read image data or position with gdal
virtual void setViewport(SUMOReal zoom, SUMOReal xPos, SUMOReal yPos)=0
Sets the viewport Used for: Adapting a new viewport.
FXImage * image
The image pointer for later cleanup.
const SUMOReal SUMO_const_laneWidth
Definition: StdDefs.h:49
SUMOReal getWidth() const
Returns the width of the boudary.
Definition: Boundary.cpp:136
a polygon
virtual long onDoubleClicked(FXObject *, FXSelector, void *)
virtual SUMOReal getDelay() const
Returns the delay (should be overwritten by subclasses if applicable)
Definition: GUIMainWindow.h:99
void setDefault(const std::string &name)
Makes the scheme with the given name the default.
virtual void setViewportFromTo(const Position &lookFrom, const Position &lookAt)
applies the given viewport settings
Position getCenter() const
Returns the center of the boundary.
Definition: Boundary.cpp:106
GUIGlObjectType
virtual void centerTo(GUIGlID id, bool applyZoom, SUMOReal zoomDist=20)
centers to the chosen artifact
bool myAmInitialised
Internal information whether doInit() was called.
void add(const Position &pos)
Adds the given position to this one.
Definition: Position.h:119
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 *)
const std::string & getFullName() const
virtual SUMOReal getZoom() const =0
Returns the zoom factor computed stored in this changer.
SUMOReal ymin() const
Returns minimum y-coordinate.
Definition: Boundary.cpp:124
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
#define GEO_OUTPUT_ACCURACY
Definition: config.h:16
void displayLegend()
a line with ticks, and the length information.
bool x2cartesian(Position &from, bool includeInBoundary=true)
void remove(GUIDialog_EditViewport *)
remove viewport
GUIMainWindow * myApp
The application.
SUMOReal xmin() const
Returns minimum x-coordinate.
Definition: Boundary.cpp:112
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.
void pfSetPosition(SUMOReal x, SUMOReal y)
Definition: polyfonts.c:480
SUMOReal p2m(SUMOReal pixel) const
pixels-to-meters conversion method
virtual long onLeftBtnPress(FXObject *, FXSelector, void *)
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)
GUIGlObject * getNetObject() const
Returns the network object.
SUMOReal getGridHeight() const
get grid Height
bool addAdditionalGLVisualisation(const GUIGlObject *const which)
Adds an object to call its additional visualisation method.
int glID
The gl-id of the texture that holds this image.
void setSnapshots(std::map< SUMOTime, std::string > snaps)
Sets the snapshot time to file map.
static const RGBColor BLACK
Definition: RGBColor.h:197
SUMOReal width
The width of the image (net coordinates in x-direction, in m)
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 void setViewportFrom(SUMOReal xPos, SUMOReal yPos, SUMOReal zPos)=0
Alternative method for setting the viewport.
virtual void stopTrack()
stop track
bool isGaming() const
return whether the gui is in gaming mode
Definition: GUIMainWindow.h:85
GUIDialog_EditViewport * myViewportChooser
viewport chooser
A RT-tree for efficient storing of SUMO&#39;s GL-objects.
Definition: SUMORTree.h:74
SUMOReal x() const
Returns the x-position.
Definition: Position.h:63
bool dither
Information whether dithering shall be enabled.
GUIGlID getGlID() const
Returns the numerical id of the object.
#define UNUSED_PARAMETER(x)
Definition: StdDefs.h:39
SUMOReal xmax() const
Returns maximum x-coordinate.
Definition: Boundary.cpp:118
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
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
SUMOReal scale
information about a lane&#39;s width (temporary, used for a single view)
std::map< const GUIGlObject *, int > myAdditionallyDrawn
List of objects for which GUIGlObject::drawGLAdditional is called.
virtual GUIGlID getTrackedID() const
get tracked id
unsigned char blue() const
Returns the blue-amount of the color.
Definition: RGBColor.h:91
FXLabel & getCartesianLabel()
virtual void setDelay(SUMOReal)
Sets the delay of the parent application.
std::vector< GUIGlID > getObjectsAtPosition(Position pos, SUMOReal radius)
returns the ids of the object at position within the given (rectangular) radius using GL_SELECT ...
std::vector< Decal > myDecals
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
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 void startTrack(int)
star track
#define max(a, b)
Definition: polyfonts.c:65
virtual long onPaint(FXObject *, FXSelector, void *)
std::string name
The name of this setting.
void showToolTipFor(const GUIGlID id)
invokes the tooltip for the given object
Boundary getVisibleBoundary() const
get visible boundary
virtual void setStatusBarText(const std::string &)
Definition: GUIMainWindow.h:79
virtual long onKeyPress(FXObject *o, FXSelector sel, void *data)
keyboard functions
virtual SUMOReal getXPos() const =0
Returns the x-offset of the field to show stored in this changer.
static void sleep(long ms)
bool isInEditMode()
returns true, if the edit button was pressed
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:46
SUMOReal centerY
The center of the image in y-direction (net coordinates, in m)
virtual GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)=0
Returns an own popup-menu.
FXComboBox & getColoringSchemesCombo()
unsigned char alpha() const
Returns the alpha-amount of the color.
Definition: RGBColor.h:99
static GUIGlObjectStorage gIDStorage
A single static instance of this class.
SUMOReal z() const
Returns the z-position.
Definition: Position.h:73
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
virtual bool onRightBtnRelease(void *data)
called when user releases right button
virtual void doInit()
doInit
FXLabel & getGeoLabel()
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 int doPaintGL(int, const Boundary &)
paint GL
void pfSetScaleXY(SUMOReal sx, SUMOReal sy)
Definition: polyfonts.c:472
SUMOReal gridXSize
Information about the grid spacings.
std::map< SUMOTime, std::string > mySnapshots
Snapshots.
static FXbool saveImage(const std::string &file, int width, int height, FXColor *data)
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
Definition: ToString.h:55
void updatePositionInformation() const
update position information
static void drawTextBox(const std::string &text, const Position &pos, const SUMOReal layer, const SUMOReal size, const RGBColor &txtColor=RGBColor::BLACK, const RGBColor &bgColor=RGBColor::WHITE, const RGBColor &borderColor=RGBColor::BLACK, const SUMOReal angle=0)
draw Text box with given parameters
Definition: GLHelper.cpp:478
SUMOReal getDelay() const
Returns the delay of the parent application.
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 SUMOReal getZPos() const =0
Returns the camera height corresponding to the current zoom factor.
virtual long onMiddleBtnRelease(FXObject *, FXSelector, void *)
Boundary getViewport(bool fixRatio=true)
get viewport
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:96
virtual void showViewportEditor()
show viewport editor
FXbool makeCurrent()
A reimplementation due to some internal reasons.
SUMOReal height
The height of the image (net coordinates in y-direction, in m)
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 *)
void add(SUMOReal x, SUMOReal y)
Makes the boundary include the given coordinate.
Definition: Boundary.cpp:76
SUMOReal centerX
The center of the image in x-direction (net coordinates, in m)
GUIVisualizationSettings & getDefault()
Returns the default scheme.
Boundary & grow(SUMOReal by)
extends the boundary by the given amount
Definition: Boundary.cpp:201
void saveViewport(const SUMOReal x, const SUMOReal y, const SUMOReal z)
Makes the given viewport the default.
void setViewport(GUISUMOAbstractView *view)
Sets the default viewport.
GUIVisualizationSettings * myVisualizationSettings
visualization settings
virtual void onMouseWheel(void *data)
called when user changes mouse wheel
SUMOReal m2p(SUMOReal meter) const
meter-to-pixels conversion method
void paintGL()
performs the painting of the simulation
virtual long onKeyPress(void *data)
called when user press a key
virtual SUMOTime getCurrentTimeStep() const
get the current simulation time
GLCanvas - ID.
Definition: GUIAppEnum.h:211
SUMOReal y() const
Returns the y-position.
Definition: Position.h:68
void setWindowCursorPosition(FXint x, FXint y)
Returns the information whether rotation is allowd.
void setCurrent(GUIVisualizationSettings *settings)
Sets current settings (called if reopened)
static const GUIGlID INVALID_ID
Definition: GUIGlObject.h:77
static FXImage * loadImage(FXApp *a, const std::string &file)
SUMOReal getGridWidth() const
get grid width
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:86
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
bool isAdditionalGLVisualisationEnabled(GUIGlObject *const which) const
Check if an object is added in the additional GL visualitation.
GUIPerspectiveChanger & getChanger() const
get changer
SUMOReal layer
The layer of the image.
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
virtual void centerTo(const Position &pos, SUMOReal 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 */.
void setDelay(SUMOReal delay)
Sets the delay of the parent application.
GUIVisualizationSettings * getVisualisationSettings() const
get visualitation settings
bool skip2D
Whether this image should be skipped in 2D-views.
unsigned char green() const
Returns the green-amount of the color.
Definition: RGBColor.h:83
#define SUMOReal
Definition: config.h:213
virtual void onMouseMove(void *data)
called when user moves mouse
void updateToolTip()
A method that updates the tooltip.
A dialog to change the viewport.
SUMOReal ymax() const
Returns maximum y-coordinate.
Definition: Boundary.cpp:130
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 SUMOReal getYPos() const =0
Returns the y-offset of the field to show stored in this changer.
void showViewschemeEditor()
show viewsscheme editor
virtual long onRightBtnPress(FXObject *, FXSelector, void *)
bool haveGrabbed() const
Returns the information whether one of the spin dialers is grabbed.
virtual long onMouseLeft(FXObject *, FXSelector, void *)
Position getPositionInformation() const
Returns the cursor&#39;s x/y position within the network.
GUIGlID getObjectUnderCursor()
returns the id of the object under the cursor using GL_SELECT
bool drawForSelecting
whether drawing is performed for the purpose of selecting objects
#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
unsigned char red() const
Returns the red-amount of the color.
Definition: RGBColor.h:75
GUISelectedStorage gSelected
A global holder of selected objects.
static void drawTexturedBox(int which, SUMOReal size)
Draws a named texture as a box with the given size.
FXDEFMAP(GUISUMOAbstractView) GUISUMOAbstractViewMap[]
SUMOReal rot
The rotation of the image in the ground plane (in degrees)
GUIGlChildWindow * myParent
The parent window.
virtual long onRightBtnRelease(FXObject *, FXSelector, void *)
static const Position INVALID
Definition: Position.h:261
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.