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