SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GUISUMOAbstractView.h
Go to the documentation of this file.
1 /****************************************************************************/
10 // The base class for a view
11 /****************************************************************************/
12 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
13 // Copyright (C) 2001-2012 DLR (http://www.dlr.de/) and contributors
14 /****************************************************************************/
15 //
16 // This file is part of SUMO.
17 // SUMO is free software: you can redistribute it and/or modify
18 // it under the terms of the GNU General Public License as published by
19 // the Free Software Foundation, either version 3 of the License, or
20 // (at your option) any later version.
21 //
22 /****************************************************************************/
23 #ifndef GUISUMOAbstractView_h
24 #define GUISUMOAbstractView_h
25 
26 
27 // ===========================================================================
28 // included modules
29 // ===========================================================================
30 #ifdef _MSC_VER
31 #include <windows_config.h>
32 #else
33 #include <config.h>
34 #endif
35 
36 #include <string>
37 #include <vector>
38 #include <map>
39 #include <fx.h>
40 // fx3d includes windows.h so we need to guard against macro pollution
41 #ifdef WIN32
42 #define NOMINMAX
43 #endif
44 #include <fx3d.h>
45 #ifdef WIN32
46 #undef NOMINMAX
47 #endif
48 
50 #include <utils/geom/Boundary.h>
51 #include <utils/geom/Position.h>
52 #include <utils/common/RGBColor.h>
53 #include <utils/common/SUMOTime.h>
54 #include <utils/shapes/Polygon.h>
57 
58 
59 // ===========================================================================
60 // class declarations
61 // ===========================================================================
62 class GUIGlChildWindow;
63 class GUIVehicle;
65 class GUIMainWindow;
67 class GUIGlObject;
71 
72 
73 // ===========================================================================
74 // class definitions
75 // ===========================================================================
83  FXDECLARE(GUISUMOAbstractView)
84 public:
86  GUISUMOAbstractView(FXComposite* p, GUIMainWindow& app,
87  GUIGlChildWindow* parent, const SUMORTree& grid,
88  FXGLVisual* glVis, FXGLCanvas* share);
89 
91  virtual ~GUISUMOAbstractView();
92 
95 
97  virtual void recenterView();
98 
105  void centerTo(GUIGlID id, bool applyZoom, SUMOReal zoomDist = 20);
106 
108  void centerTo(const Boundary& bound);
109 
111  virtual void setViewport(SUMOReal zoom, SUMOReal xPos, SUMOReal yPos);
112 
114  SUMOReal m2p(SUMOReal meter) const;
115 
117  SUMOReal p2m(SUMOReal pixel) const;
118 
120 // bool allowRotation() const;
121 
123  void setWindowCursorPosition(FXint x, FXint y);
124 
126  FXbool makeCurrent();
127 
129  bool isInEditMode();
130 
132  return *myChanger;
133  }
134 
136 
137  virtual long onConfigure(FXObject*, FXSelector, void*);
138  virtual long onPaint(FXObject*, FXSelector, void*);
139  virtual long onLeftBtnPress(FXObject*, FXSelector, void*);
140  virtual long onLeftBtnRelease(FXObject*, FXSelector, void*);
141  virtual long onRightBtnPress(FXObject*, FXSelector, void*);
142  virtual long onRightBtnRelease(FXObject*, FXSelector, void*);
143  virtual long onMouseWheel(FXObject*, FXSelector, void*);
144  virtual long onMouseMove(FXObject*, FXSelector, void*);
145  virtual long onMouseLeft(FXObject*, FXSelector, void*);
146 
147  virtual long onKeyPress(FXObject* o, FXSelector sel, void* data);
148  virtual long onKeyRelease(FXObject* o, FXSelector sel, void* data);
149 
150 
151  virtual void openObjectDialog();
152 
154  void updateToolTip();
155 
156 
159 
163  void setSnapshots(std::map<SUMOTime, std::string> snaps);
164 
165 
172  std::string makeSnapshot(const std::string& destFile);
173 
174 
177  void checkSnapshots();
178 
180  virtual SUMOTime getCurrentTimeStep() const {
181  return 0;
182  }
184 
185 
186 
187  void showViewportEditor();
188  virtual void showViewschemeEditor() = 0;
189  void showToolTips(bool val);
190  virtual bool setColorScheme(const std::string&) {
191  return true;
192  }
193 
194  void remove(GUIDialog_EditViewport*) {
195  myViewportChooser = 0;
196  }
197 
198  void remove(GUIDialog_ViewSettings*) {
200  }
201 
202 
203  // @todo: check why this is here
204  SUMOReal getGridWidth() const;
205  // @todo: check why this is here
206  SUMOReal getGridHeight() const;
207 
208  virtual void startTrack(int /*id*/) { }
209  virtual void stopTrack() { }
210  virtual int getTrackedID() const {
211  return -1;
212  }
213 
214  virtual void onGamingClick(Position /*pos*/) { }
215 
218 
224  bool addAdditionalGLVisualisation(GUIGlObject* const which);
225 
226 
232  bool removeAdditionalGLVisualisation(GUIGlObject* const which);
234 
235 
237  void destroyPopup();
238 
239 
240 public:
241 
245  struct Decal {
248  : filename(), centerX(0), centerY(0),
249  width(1000), height(1000), rot(0), layer(0),
250  initialised(false), glID(-1), image(0) { }
251 
253  std::string filename;
269  int glID;
271  FXImage* image;
272  };
273 
274 
275 public:
276  FXComboBox& getColoringSchemesCombo();
277 
278 
283 
284  void addDecals(const std::vector<Decal>& decals) {
285  myDecals.insert(myDecals.end(), decals.begin(), decals.end());
286  }
287 
288 
291  }
292 
293 
294 protected:
296  void paintGL();
297 
298  void updatePositionInformation() const;
299 
300 
301  virtual int doPaintGL(int /*mode*/, const Boundary& /*boundary*/) {
302  return 0;
303  }
304 
305  virtual void doInit() { }
306 
308  void paintGLGrid();
309 
314  void displayLegend();
315 
316 
319 
322 
324  std::vector<GUIGlID> getObjectsInBoundary(const Boundary& bound);
325 
327  void showToolTipFor(unsigned int id);
328 
329 
330 protected:
333  void drawDecals();
334 
335  // applies gl-transformations to fit the Boundary given by myChanger onto
336  // the canvas. If fixRatio is true, this boundary will be enlarged to
337  // prevent anisotropic stretching. (this should be set to false when doing
338  // selections)
339  void applyGLTransform(bool fixRatio = true);
340 
341 protected:
344 
347 
350 
353 
356 
359 
362 
365 
367 
369 
372 
373 
376 
377 
380 
382  std::vector<Decal> myDecals;
383 
387 
388 
389  std::map<SUMOTime, std::string> mySnapshots;
390 
392 
394  std::map<GUIGlObject*, int> myAdditionallyDrawn;
395 
396 
397 protected:
399 
400 };
401 
402 
403 #endif
404 
405 /****************************************************************************/
406