SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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
177 }
178 
179 
180 Position
182  Boundary bound = myChanger->getViewport();
183  SUMOReal xNet = bound.xmin() + bound.getWidth() * x / getWidth();
184  // cursor origin is in the top-left corner
185  SUMOReal yNet = bound.ymin() + bound.getHeight() * (getHeight() - y) / getHeight();
186  return Position(xNet, yNet);
187 }
188 
189 
190 void
191 GUISUMOAbstractView::addDecals(const std::vector<Decal>& decals) {
192  myDecals.insert(myDecals.end(), decals.begin(), decals.end());
193 }
194 
195 
199 }
200 
201 
202 void
205  std::string text = "x:" + toString(pos.x()) + ", y:" + toString(pos.y());
206  myApp->getCartesianLabel().setText(text.c_str());
208  if (GeoConvHelper::getFinal().usingGeoProjection()) {
209  text = "lat:" + toString(pos.y(), GEO_OUTPUT_ACCURACY) + ", lon:" + toString(pos.x(), GEO_OUTPUT_ACCURACY);
210  } else {
211  text = "x:" + toString(pos.x()) + ", y:" + toString(pos.y());
212  }
213  myApp->getGeoLabel().setText(text.c_str());
214 }
215 
216 
217 int
218 GUISUMOAbstractView::doPaintGL(int /*mode*/, const Boundary& /*boundary*/) {
219  return 0;
220 }
221 
222 
223 void
225 }
226 
227 
228 Boundary
230  return myChanger->getViewport();
231 }
232 
233 
234 void
236  if (getWidth() == 0 || getHeight() == 0) {
237  return;
238  }
239 
241  centerTo(getTrackedID(), false);
242  }
243 
245  if (myUseToolTips) {
246  id = getObjectUnderCursor();
247  }
248 
249  // draw
250  glClearColor(
255  glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
256  glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
257 
259  glEnable(GL_DITHER);
260  } else {
261  glDisable(GL_DITHER);
262  }
264  glEnable(GL_BLEND);
265  glEnable(GL_POLYGON_SMOOTH);
266  glEnable(GL_LINE_SMOOTH);
267  } else {
268  glDisable(GL_BLEND);
269  glDisable(GL_POLYGON_SMOOTH);
270  glDisable(GL_LINE_SMOOTH);
271  }
272 
274  doPaintGL(GL_RENDER, myChanger->getViewport());
276  displayLegend();
277  }
278  // check whether the select mode /tooltips)
279  // shall be computed, too
280  if (myUseToolTips && id != GUIGlObject::INVALID_ID) {
281  showToolTipFor(id);
282  }
283  swapBuffers();
284 }
285 
286 
287 GUIGlID
290 }
291 
292 
293 GUIGlID
295  const SUMOReal SENSITIVITY = 0.1; // meters
296  Boundary selection;
297  selection.add(pos);
298  selection.grow(SENSITIVITY);
299  const std::vector<GUIGlID> ids = getObjectsInBoundary(selection);
300  // Interpret results
301  int idMax = 0;
303  for (std::vector<GUIGlID>::const_iterator it = ids.begin(); it != ids.end(); it++) {
304  GUIGlID id = *it;
306  if (o == 0) {
307  continue;
308  }
309  if (o->getGlID() == 0) {
310  continue;
311  }
312  //std::cout << "point selection hit " << o->getMicrosimID() << "\n";
313  GUIGlObjectType type = o->getType();
314  if (type != 0) {
315  SUMOReal layer = (SUMOReal)type;
316  // determine an "abstract" layer for shapes
317  // this "layer" resembles the layer of the shape
318  // taking into account the stac of other objects
319  if (type == GLO_POI || type == GLO_POLYGON) {
320  layer = dynamic_cast<Shape*>(o)->getLayer();
321  }
323  // do not select lanes in meso mode
324  continue;
325  }
326  // check whether the current object is above a previous one
327  if (layer > maxLayer) {
328  idMax = id;
329  maxLayer = layer;
330  }
331  }
333  }
334  return idMax;
335 }
336 
337 
338 std::vector<GUIGlID>
340  Boundary selection;
341  selection.add(pos);
342  selection.grow(radius);
343  const std::vector<GUIGlID> ids = getObjectsInBoundary(selection);
344  std::vector<GUIGlID> result;
345  // Interpret results
346  for (std::vector<GUIGlID>::const_iterator it = ids.begin(); it != ids.end(); it++) {
347  GUIGlID id = *it;
349  if (o == 0) {
350  continue;
351  }
352  if (o->getGlID() == 0) {
353  continue;
354  }
355  //std::cout << "point selection hit " << o->getMicrosimID() << "\n";
356  GUIGlObjectType type = o->getType();
357  if (type != 0) {
358  result.push_back(id);
359  }
361  }
362  return result;
363 }
364 
365 
366 std::vector<GUIGlID>
368  const int NB_HITS_MAX = 1024 * 1024;
369  // Prepare the selection mode
370  static GUIGlID hits[NB_HITS_MAX];
371  static GLint nb_hits = 0;
372  glSelectBuffer(NB_HITS_MAX, hits);
373  glInitNames();
374 
375  Boundary oldViewPort = myChanger->getViewport(false); // backup the actual viewPort
376  myChanger->setViewport(bound);
377  applyGLTransform(false);
378 
379  // paint in select mode
381  int hits2 = doPaintGL(GL_SELECT, bound);
383  // Get the results
384  nb_hits = glRenderMode(GL_RENDER);
385  if (nb_hits == -1) {
386  myApp->setStatusBarText("Selection in boundary failed. Try to select fewer than " + toString(hits2) + " items");
387  }
388  std::vector<GUIGlID> result;
389  GLuint numNames;
390  GLuint* ptr = hits;
391  for (int i = 0; i < nb_hits; ++i) {
392  numNames = *ptr;
393  ptr += 3;
394  for (int j = 0; j < (int)numNames; j++) {
395  result.push_back(*ptr);
396  ptr++;
397  }
398  }
399  // switch viewport back to normal
400  myChanger->setViewport(oldViewPort);
401  return result;
402 }
403 
404 
405 void
407  if (id != 0) {
409  if (object != 0) {
411  pos.add(0, p2m(15));
412  GLHelper::drawTextBox(object->getFullName(), pos, GLO_MAX - 1, p2m(20), RGBColor::BLACK, RGBColor(255, 179, 0, 255));
414  }
415  }
416 }
417 
418 
419 void
421  glEnable(GL_DEPTH_TEST);
422  glLineWidth(1);
423 
424  SUMOReal xmin = myGrid->xmin();
425  SUMOReal ymin = myGrid->ymin();
426  SUMOReal ypos = ymin;
427  SUMOReal xpos = xmin;
428  SUMOReal xend = myGrid->xmax();
429  SUMOReal yend = myGrid->ymax();
430 
431  glTranslated(0, 0, .55);
432  glColor3d(0.5, 0.5, 0.5);
433  // draw horizontal lines
434  glBegin(GL_LINES);
435  for (; ypos < yend;) {
436  glVertex2d(xmin, ypos);
437  glVertex2d(xend, ypos);
439  }
440  // draw vertical lines
441  for (; xpos < xend;) {
442  glVertex2d(xpos, ymin);
443  glVertex2d(xpos, yend);
445  }
446  glEnd();
447  glTranslated(0, 0, -.55);
448 }
449 
450 
451 void
453  // compute the scale bar length
454  int length = 1;
455  const std::string text("10000000000");
456  int noDigits = 1;
457  int pixelSize = (int) m2p((SUMOReal) length);
458  while (pixelSize <= 20) {
459  length *= 10;
460  noDigits++;
461  if (noDigits > (int)text.length()) {
462  return;
463  }
464  pixelSize = (int) m2p((SUMOReal) length);
465  }
466  glLineWidth(1.0);
467 
468  glMatrixMode(GL_PROJECTION);
469  glPushMatrix();
470  glLoadIdentity();
471  glMatrixMode(GL_MODELVIEW);
472  glPushMatrix();
473  glLoadIdentity();
474 
475  // draw the scale bar
476  glDisable(GL_TEXTURE_2D);
477  glDisable(GL_ALPHA_TEST);
478  glDisable(GL_BLEND);
479  glEnable(GL_DEPTH_TEST);
480 
481  SUMOReal len = (SUMOReal) pixelSize / (SUMOReal)(getWidth() - 1) * (SUMOReal) 2.0;
482  glColor3d(0, 0, 0);
483  double o = double(15) / double(getHeight());
484  double o2 = o + o;
485  double oo = double(5) / double(getHeight());
486  glBegin(GL_LINES);
487  // vertical
488  glVertex2d(-.98, -1. + o);
489  glVertex2d(-.98 + len, -1. + o);
490  // tick at begin
491  glVertex2d(-.98, -1. + o);
492  glVertex2d(-.98, -1. + o2);
493  // tick at end
494  glVertex2d(-.98 + len, -1. + o);
495  glVertex2d(-.98 + len, -1. + o2);
496  glEnd();
497 
498  SUMOReal w = SUMOReal(35) / SUMOReal(getWidth());
499  SUMOReal h = SUMOReal(35) / SUMOReal(getHeight());
500  pfSetPosition(SUMOReal(-0.99), SUMOReal(1. - o2 - oo));
501  pfSetScaleXY(w, h);
502  glRotated(180, 1, 0, 0);
503  pfDrawString("0m");
504  glRotated(-180, 1, 0, 0);
505 
506  pfSetPosition(SUMOReal(-.99 + len), SUMOReal(1. - o2 - oo));
507  glRotated(180, 1, 0, 0);
508  pfDrawString((text.substr(0, noDigits) + "m").c_str());
509  glRotated(-180, 1, 0, 0);
510 
511  // restore matrices
512  glMatrixMode(GL_PROJECTION);
513  glPopMatrix();
514  glMatrixMode(GL_MODELVIEW);
515  glPopMatrix();
516 }
517 
518 
519 SUMOReal
521  return meter * getWidth() / myChanger->getViewport().getWidth();
522 }
523 
524 
525 SUMOReal
527  return pixel * myChanger->getViewport().getWidth() / getWidth();
528 }
529 
530 
531 void
534 }
535 
536 
537 void
538 GUISUMOAbstractView::centerTo(GUIGlID id, bool applyZoom, SUMOReal zoomDist) {
540  if (o != 0 && dynamic_cast<GUIGlObject*>(o) != 0) {
541  if (applyZoom && zoomDist < 0) {
543  update(); // only update when centering onto an object once
544  } else {
545  // called during tracking. update is triggered somewhere else
546  myChanger->centerTo(o->getCenteringBoundary().getCenter(), zoomDist, applyZoom);
548  }
549  }
551 }
552 
553 
554 void
556  myChanger->setViewport(bound);
557  update();
558 }
559 
560 /*
561 bool
562 GUISUMOAbstractView::allowRotation() const
563 {
564  return myParent->allowRotation();
565 }
566 */
567 
568 void
572 }
573 
574 
575 FXbool
577  FXbool ret = FXGLCanvas::makeCurrent();
578  return ret;
579 }
580 
581 
582 long
583 GUISUMOAbstractView::onConfigure(FXObject*, FXSelector, void*) {
584  if (makeCurrent()) {
585  glViewport(0, 0, getWidth() - 1, getHeight() - 1);
586  glClearColor(
591  doInit();
592  myAmInitialised = true;
593  makeNonCurrent();
594  checkSnapshots();
595  }
596  return 1;
597 }
598 
599 
600 long
601 GUISUMOAbstractView::onPaint(FXObject*, FXSelector, void*) {
602  if (!isEnabled() || !myAmInitialised) {
603  return 1;
604  }
605  if (makeCurrent()) {
606  paintGL();
607  makeNonCurrent();
608  }
609  return 1;
610 }
611 
612 
613 void
615  delete myPopup;
616  myPopup = 0;
617 }
618 
619 
620 long
621 GUISUMOAbstractView::onLeftBtnPress(FXObject*, FXSelector , void* data) {
622  destroyPopup();
623  setFocus();
624  FXEvent* e = (FXEvent*) data;
625  // check whether the selection-mode is activated
626  if ((e->state & CONTROLMASK) != 0) {
627  // try to get the object-id if so
628  if (makeCurrent()) {
629  int id = getObjectUnderCursor();
630  if (id != 0) {
632  }
633  makeNonCurrent();
634  if (id != 0) {
635  // possibly, the selection-colouring is used,
636  // so we should update the screen again...
637  update();
638  }
639  }
640  }
641  myChanger->onLeftBtnPress(data);
642  grab();
643  // Check there are double click
644  if (e->click_count == 2) {
645  handle(this, FXSEL(SEL_DOUBLECLICKED, 0), data);
646  }
647  return 1;
648 }
649 
650 
651 long
652 GUISUMOAbstractView::onLeftBtnRelease(FXObject*, FXSelector , void* data) {
653  destroyPopup();
655  if (myApp->isGaming()) {
657  }
658  ungrab();
659  return 1;
660 }
661 
662 
663 long
664 GUISUMOAbstractView::onMiddleBtnPress(FXObject*, FXSelector, void*) {
665  return 1;
666 }
667 
668 
669 long
670 GUISUMOAbstractView::onMiddleBtnRelease(FXObject*, FXSelector, void*) {
671  return 1;
672 }
673 
674 
675 long
676 GUISUMOAbstractView::onRightBtnPress(FXObject*, FXSelector , void* data) {
677  destroyPopup();
678  myChanger->onRightBtnPress(data);
679  grab();
680  return 1;
681 }
682 
683 
684 long
685 GUISUMOAbstractView::onRightBtnRelease(FXObject* o, FXSelector sel, void* data) {
686  destroyPopup();
687  onMouseMove(o, sel, data);
688  if (!myChanger->onRightBtnRelease(data) && !myApp->isGaming()) {
690  }
691  ungrab();
692  return 1;
693 }
694 
695 
696 long
697 GUISUMOAbstractView::onDoubleClicked(FXObject*, FXSelector, void*) {
698  return 1;
699 }
700 
701 
702 long
703 GUISUMOAbstractView::onMouseWheel(FXObject*, FXSelector , void* data) {
704  if (!myApp->isGaming()) {
705  myChanger->onMouseWheel(data);
707  }
708  return 1;
709 }
710 
711 
712 long
713 GUISUMOAbstractView::onMouseMove(FXObject*, FXSelector , void* data) {
715  myChanger->onMouseMove(data);
716  }
717  if (myViewportChooser != 0) {
719  }
721  return 1;
722 }
723 
724 
725 long
726 GUISUMOAbstractView::onMouseLeft(FXObject*, FXSelector , void* /*data*/) {
727  return 1;
728 }
729 
730 
731 void
733  ungrab();
734  if (!isEnabled() || !myAmInitialised) {
735  return;
736  }
737  if (makeCurrent()) {
738  // initialise the select mode
739  int id = getObjectUnderCursor();
740  GUIGlObject* o = 0;
741  if (id != 0) {
743  } else {
745  }
746  if (o != 0) {
747  myPopup = o->getPopUpMenu(*myApp, *this);
748  int x, y;
749  FXuint b;
750  myApp->getCursorPosition(x, y, b);
751  myPopup->setX(x + myApp->getX());
752  myPopup->setY(y + myApp->getY());
753  myPopup->create();
754  myPopup->show();
757  }
758  makeNonCurrent();
759  }
760 }
761 
762 
763 long
764 GUISUMOAbstractView::onKeyPress(FXObject* o, FXSelector sel, void* data) {
765  FXGLCanvas::onKeyPress(o, sel, data);
766  return myChanger->onKeyPress(data);
767 }
768 
769 
770 long
771 GUISUMOAbstractView::onKeyRelease(FXObject* o, FXSelector sel, void* data) {
772  FXGLCanvas::onKeyRelease(o, sel, data);
773  return myChanger->onKeyRelease(data);
774 }
775 
776 
777 // ------------ Dealing with snapshots
778 void
779 GUISUMOAbstractView::setSnapshots(std::map<SUMOTime, std::string> snaps) {
780  mySnapshots.insert(snaps.begin(), snaps.end());
781 }
782 
783 
784 std::string
785 GUISUMOAbstractView::makeSnapshot(const std::string& destFile) {
786  std::string errorMessage;
787  FXString ext = FXPath::extension(destFile.c_str());
788  const bool useGL2PS = ext == "ps" || ext == "eps" || ext == "pdf" || ext == "svg" || ext == "tex" || ext == "pgf";
789 #ifdef HAVE_FFMPEG
790  const bool useVideo = destFile == "" || ext == "h264" || ext == "hevc";
791 #endif
792  for (int i = 0; i < 10 && !makeCurrent(); ++i) {
794  }
795  // draw
796  glClearColor(
801  glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
802  glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
803 
805  glEnable(GL_DITHER);
806  } else {
807  glDisable(GL_DITHER);
808  }
810  glEnable(GL_BLEND);
811  glEnable(GL_POLYGON_SMOOTH);
812  glEnable(GL_LINE_SMOOTH);
813  } else {
814  glDisable(GL_BLEND);
815  glDisable(GL_POLYGON_SMOOTH);
816  glDisable(GL_LINE_SMOOTH);
817  }
818 
820 
821  if (useGL2PS) {
822  GLint format = GL2PS_PS;
823  if (ext == "ps") {
824  format = GL2PS_PS;
825  } else if (ext == "eps") {
826  format = GL2PS_EPS;
827  } else if (ext == "pdf") {
828  format = GL2PS_PDF;
829  } else if (ext == "tex") {
830  format = GL2PS_TEX;
831  } else if (ext == "svg") {
832  format = GL2PS_SVG;
833  } else if (ext == "pgf") {
834  format = GL2PS_PGF;
835  } else {
836  return "Could not save '" + destFile + "'.\n Unrecognized format '" + std::string(ext.text()) + "'.";
837  }
838  FILE* fp = fopen(destFile.c_str(), "wb");
839  if (fp == 0) {
840  return "Could not save '" + destFile + "'.\n Could not open file for writing";
841  }
842  GLint buffsize = 0, state = GL2PS_OVERFLOW;
843  GLint viewport[4];
844  glGetIntegerv(GL_VIEWPORT, viewport);
845  while (state == GL2PS_OVERFLOW) {
846  buffsize += 1024 * 1024;
847  gl2psBeginPage(destFile.c_str(), "sumo-gui; http://sumo.dlr.de", viewport, format, GL2PS_SIMPLE_SORT,
848  GL2PS_DRAW_BACKGROUND | GL2PS_USE_CURRENT_VIEWPORT,
849  GL_RGBA, 0, NULL, 0, 0, 0, buffsize, fp, "out.eps");
850  glMatrixMode(GL_MODELVIEW);
851  glPushMatrix();
852  glDisable(GL_TEXTURE_2D);
853  glDisable(GL_ALPHA_TEST);
854  glDisable(GL_BLEND);
855  glEnable(GL_DEPTH_TEST);
856  // compute lane width
857  // draw decals (if not in grabbing mode)
858  if (!myUseToolTips) {
859  drawDecals();
861  paintGLGrid();
862  }
863  }
864  glLineWidth(1);
865  glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
866  Boundary viewPort = myChanger->getViewport();
867  const float minB[2] = { (float)viewPort.xmin(), (float)viewPort.ymin() };
868  const float maxB[2] = { (float)viewPort.xmax(), (float)viewPort.ymax() };
870  glEnable(GL_POLYGON_OFFSET_FILL);
871  glEnable(GL_POLYGON_OFFSET_LINE);
872  myGrid->Search(minB, maxB, *myVisualizationSettings);
873 
875  displayLegend();
876  }
877  state = gl2psEndPage();
878  glFinish();
879  }
880  fclose(fp);
881  } else {
882  doPaintGL(GL_RENDER, myChanger->getViewport());
884  displayLegend();
885  }
886  swapBuffers();
887  glFinish();
888  FXColor* buf;
889  FXMALLOC(&buf, FXColor, getWidth()*getHeight());
890  // read from the back buffer
891  glReadBuffer(GL_BACK);
892  // Read the pixels
893  glReadPixels(0, 0, getWidth(), getHeight(), GL_RGBA, GL_UNSIGNED_BYTE, (GLvoid*)buf);
894  makeNonCurrent();
895  update();
896  // mirror
897  int mwidth = getWidth();
898  int mheight = getHeight();
899  FXColor* paa = buf;
900  FXColor* pbb = buf + mwidth * (mheight - 1);
901  do {
902  FXColor* pa = paa;
903  paa += mwidth;
904  FXColor* pb = pbb;
905  pbb -= mwidth;
906  do {
907  FXColor t = *pa;
908  *pa++ = *pb;
909  *pb++ = t;
910  } while (pa < paa);
911  } while (paa < pbb);
912  try {
913 #ifdef HAVE_FFMPEG
914  if (useVideo) {
915  try {
916  saveFrame(destFile, buf);
917  errorMessage = "video";
918  } catch (std::runtime_error& err) {
919  errorMessage = err.what();
920  }
921  } else
922 #endif
923  if (!MFXImageHelper::saveImage(destFile, getWidth(), getHeight(), buf)) {
924  errorMessage = "Could not save '" + destFile + "'.";
925  }
926  } catch (InvalidArgument& e) {
927  errorMessage = "Could not save '" + destFile + "'.\n" + e.what();
928  }
929  FXFREE(&buf);
930  }
931  return errorMessage;
932 }
933 
934 
935 void
936 GUISUMOAbstractView::saveFrame(const std::string& destFile, FXColor* buf) {
937  UNUSED_PARAMETER(destFile);
938  UNUSED_PARAMETER(buf);
939 }
940 
941 
942 void
944  std::map<SUMOTime, std::string>::iterator snapIt = mySnapshots.find(getCurrentTimeStep());
945  if (snapIt != mySnapshots.end()) {
946  std::string error = makeSnapshot(snapIt->second);
947  if (error != "") {
948  WRITE_WARNING(error);
949  }
950  }
951 }
952 
953 
954 SUMOTime
956  return 0;
957 }
958 
959 
960 void
962  if (myVisualizationChanger == 0) {
967  myVisualizationChanger->create();
968  } else {
970  }
971  myVisualizationChanger->show();
972 }
973 
974 
977  if (myViewportChooser == 0) {
979  new GUIDialog_EditViewport(this, "Edit Viewport...", 0, 0);
980  myViewportChooser->create();
981  }
983  return myViewportChooser;
984 }
985 
986 
987 void
989  getViewportEditor(); // make sure it exists;
992  myViewportChooser->show();
993 }
994 
995 
996 void
997 GUISUMOAbstractView::setViewportFromTo(const Position& lookFrom, const Position& /* lookAt */) {
998  myChanger->setViewportFrom(lookFrom.x(), lookFrom.y(), lookFrom.z());
999  update();
1000 }
1001 
1002 
1003 void
1005  // look straight down
1008 }
1009 
1010 
1011 void
1013  myUseToolTips = val;
1014 }
1015 
1016 
1017 bool
1019  return true;
1020 }
1021 
1022 
1025  return myVisualizationSettings;
1026 }
1027 
1028 
1029 void
1031  myViewportChooser = 0;
1032 }
1033 
1034 
1035 void
1038 }
1039 
1040 
1041 SUMOReal
1043  return myGrid->getWidth();
1044 }
1045 
1046 
1047 SUMOReal
1049  return myGrid->getHeight();
1050 }
1051 
1052 
1053 void
1055 }
1056 
1057 
1058 void
1060 }
1061 
1062 
1063 GUIGlID
1065  return GUIGlObject::INVALID_ID;
1066 }
1067 
1068 
1069 void
1071 }
1072 
1073 
1074 FXComboBox&
1077 }
1078 
1079 
1080 FXImage*
1082 #ifdef HAVE_GDAL
1083  GDALAllRegister();
1084  GDALDataset* poDataset = (GDALDataset*)GDALOpen(d.filename.c_str(), GA_ReadOnly);
1085  if (poDataset == 0) {
1086  return 0;
1087  }
1088  const int xSize = poDataset->GetRasterXSize();
1089  const int ySize = poDataset->GetRasterYSize();
1090  // checking for geodata in the picture and try to adapt position and scale
1091  if (d.width <= 0.) {
1092  double adfGeoTransform[6];
1093  if (poDataset->GetGeoTransform(adfGeoTransform) == CE_None) {
1094  Position topLeft(adfGeoTransform[0], adfGeoTransform[3]);
1095  const double horizontalSize = xSize * adfGeoTransform[1];
1096  const double verticalSize = ySize * adfGeoTransform[5];
1097  Position bottomRight(topLeft.x() + horizontalSize, topLeft.y() + verticalSize);
1099  d.width = bottomRight.x() - topLeft.x();
1100  d.height = topLeft.y() - bottomRight.y();
1101  d.centerX = (topLeft.x() + bottomRight.x()) / 2;
1102  d.centerY = (topLeft.y() + bottomRight.y()) / 2;
1103  //WRITE_MESSAGE("proj: " + toString(poDataset->GetProjectionRef()) + " dim: " + toString(d.width) + "," + toString(d.height) + " center: " + toString(d.centerX) + "," + toString(d.centerY));
1104  } else {
1105  WRITE_WARNING("Could not convert coordinates in " + d.filename + ".");
1106  }
1107  }
1108  }
1109 #endif
1110  if (d.width <= 0.) {
1111  d.width = getGridWidth();
1112  d.height = getGridHeight();
1113  }
1114 
1115  // trying to read the picture
1116 #ifdef HAVE_GDAL
1117  const int picSize = xSize * ySize;
1118  FXColor* result;
1119  if (!FXMALLOC(&result, FXColor, picSize)) {
1120  WRITE_WARNING("Could not allocate memory for " + d.filename + ".");
1121  return 0;
1122  }
1123  for (int j = 0; j < picSize; j++) {
1124  result[j] = FXRGB(0, 0, 0);
1125  }
1126  bool valid = true;
1127  for (int i = 1; i <= poDataset->GetRasterCount(); i++) {
1128  GDALRasterBand* poBand = poDataset->GetRasterBand(i);
1129  int shift = -1;
1130  if (poBand->GetColorInterpretation() == GCI_RedBand) {
1131  shift = 0;
1132  } else if (poBand->GetColorInterpretation() == GCI_GreenBand) {
1133  shift = 1;
1134  } else if (poBand->GetColorInterpretation() == GCI_BlueBand) {
1135  shift = 2;
1136  } else if (poBand->GetColorInterpretation() == GCI_AlphaBand) {
1137  shift = 3;
1138  } else {
1139  WRITE_MESSAGE("Unknown color band in " + d.filename + ", maybe fox can parse it.");
1140  valid = false;
1141  break;
1142  }
1143  assert(xSize == poBand->GetXSize() && ySize == poBand->GetYSize());
1144  if (poBand->RasterIO(GF_Read, 0, 0, xSize, ySize, ((unsigned char*)result) + shift, xSize, ySize, GDT_Byte, 4, 4 * xSize) == CE_Failure) {
1145  valid = false;
1146  break;
1147  }
1148  }
1149  GDALClose(poDataset);
1150  if (valid) {
1151  return new FXImage(getApp(), result, IMAGE_OWNED | IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP, xSize, ySize);
1152  }
1153  FXFREE(&result);
1154 #endif
1155  return 0;
1156 }
1157 
1158 
1159 void
1161  glPushName(0);
1162  myDecalsLock.lock();
1163  for (std::vector<GUISUMOAbstractView::Decal>::iterator l = myDecals.begin(); l != myDecals.end(); ++l) {
1165  if (d.skip2D) {
1166  continue;
1167  }
1168  if (!d.initialised) {
1169  try {
1170  FXImage* img = checkGDALImage(d);
1171  if (img == 0) {
1172  img = MFXImageHelper::loadImage(getApp(), d.filename);
1173  }
1175  d.glID = GUITexturesHelper::add(img);
1176  d.initialised = true;
1177  d.image = img;
1178  } catch (InvalidArgument& e) {
1179  WRITE_ERROR("Could not load '" + d.filename + "'.\n" + e.what());
1180  d.skip2D = true;
1181  }
1182  }
1183  glPushMatrix();
1184  if (d.screenRelative) {
1185  Position center = screenPos2NetPos((int)d.centerX, (int)d.centerY);
1186  glTranslated(center.x(), center.y(), d.layer);
1187  } else {
1188  glTranslated(d.centerX, d.centerY, d.layer);
1189  }
1190  glRotated(d.rot, 0, 0, 1);
1191  glColor3d(1, 1, 1);
1192  SUMOReal halfWidth = d.width / 2.;
1193  SUMOReal halfHeight = d.height / 2.;
1194  if (d.screenRelative) {
1195  halfWidth = p2m(halfWidth);
1196  halfHeight = p2m(halfHeight);
1197  }
1198  GUITexturesHelper::drawTexturedBox(d.glID, -halfWidth, -halfHeight, halfWidth, halfHeight);
1199  glPopMatrix();
1200  }
1201  myDecalsLock.unlock();
1202  glPopName();
1203 }
1204 
1205 
1206 // ------------ Additional visualisations
1207 bool
1209  if (myAdditionallyDrawn.find(which) == myAdditionallyDrawn.end()) {
1210  myAdditionallyDrawn[which] = 1;
1211  } else {
1212  myAdditionallyDrawn[which] = myAdditionallyDrawn[which] + 1;
1213  }
1214  update();
1215  return true;
1216 }
1217 
1218 
1219 bool
1221  if (getTrackedID() == which->getGlID()) {
1222  stopTrack();
1223  }
1224  if (myAdditionallyDrawn.find(which) == myAdditionallyDrawn.end()) {
1225  return false;
1226  }
1227  int cnt = myAdditionallyDrawn[which];
1228  if (cnt == 1) {
1229  myAdditionallyDrawn.erase(which);
1230  } else {
1231  myAdditionallyDrawn[which] = myAdditionallyDrawn[which] - 1;
1232  }
1233  update();
1234  return true;
1235 }
1236 
1237 
1238 bool
1240  if (myAdditionallyDrawn.find(which) == myAdditionallyDrawn.end()) {
1241  return false;
1242  } else {
1243  return true;
1244  }
1245 }
1246 
1247 
1248 void
1250  Boundary bound = myChanger->getViewport(fixRatio);
1251  glMatrixMode(GL_PROJECTION);
1252  glLoadIdentity();
1253  // as a rough rule, each GLObject is drawn at z = -GUIGlObjectType
1254  // thus, objects with a higher value will be closer (drawn on top)
1255  // // @todo last param should be 0 after modifying all glDraw methods
1256  glOrtho(0, getWidth(), 0, getHeight(), -GLO_MAX - 1, GLO_MAX + 1);
1257  glMatrixMode(GL_MODELVIEW);
1258  glLoadIdentity();
1259  SUMOReal scaleX = (SUMOReal)getWidth() / bound.getWidth();
1260  SUMOReal scaleY = (SUMOReal)getHeight() / bound.getHeight();
1261  glScaled(scaleX, scaleY, 1);
1262  glTranslated(-bound.xmin(), -bound.ymin(), 0);
1263 }
1264 
1265 
1266 SUMOReal
1268  return myApp->getDelay();
1269 }
1270 
1271 
1272 void
1274  myApp->setDelay(delay);
1275 }
1276 
1277 
1279  filename(),
1280  centerX(0),
1281  centerY(0),
1282  centerZ(0),
1283  width(0),
1284  height(0),
1285  altitude(0),
1286  rot(0),
1287  tilt(0),
1288  roll(0),
1289  layer(0),
1290  initialised(false),
1291  skip2D(false),
1292  screenRelative(false),
1293  glID(-1),
1294  image(0) {
1295 }
1296 
1297 
1298 /****************************************************************************/
1299 
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 (y-axis)
Definition: Boundary.cpp:172
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 (x-axis)
Definition: Boundary.cpp:166
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:124
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:142
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:130
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
bool screenRelative
Whether this image should be skipped in 2D-views.
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
whether the decal shall be drawn in screen coordinates, rather than network coordinates ...
void setSnapshots(std::map< SUMOTime, std::string > snaps)
Sets the snapshot time to file map.
static const RGBColor BLACK
Definition: RGBColor.h:197
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'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:136
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's width (temporary, used for a single view)
Position screenPos2NetPos(int x, int y) const
Translate screen position to network position.
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 *)
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:232
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
void add(SUMOReal x, SUMOReal y, SUMOReal z=0)
Makes the boundary include the given coordinate.
Definition: Boundary.cpp:90
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:214
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:148
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'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.