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 #include <fx3d.h>
42 #include <utils/geom/Boundary.h>
43 #include <utils/geom/Position.h>
44 #include <utils/common/RGBColor.h>
45 #include <utils/common/SUMOTime.h>
46 #include <utils/shapes/Polygon.h>
49 
50 
51 // ===========================================================================
52 // class declarations
53 // ===========================================================================
54 class GUIGlChildWindow;
55 class GUIVehicle;
57 class GUIMainWindow;
59 class GUIGlObject;
63 
64 
65 // ===========================================================================
66 // class definitions
67 // ===========================================================================
75  FXDECLARE(GUISUMOAbstractView)
76 public:
78  GUISUMOAbstractView(FXComposite* p, GUIMainWindow& app,
79  GUIGlChildWindow* parent, const SUMORTree& grid,
80  FXGLVisual* glVis, FXGLCanvas* share);
81 
83  virtual ~GUISUMOAbstractView();
84 
87 
89  void recenterView();
90 
97  void centerTo(GUIGlID id, bool applyZoom, SUMOReal zoomDist = 20);
98 
100  void centerTo(const Boundary& bound);
101 
103  virtual void setViewport(SUMOReal zoom, SUMOReal xPos, SUMOReal yPos);
104 
106  SUMOReal m2p(SUMOReal meter) const;
107 
109  SUMOReal p2m(SUMOReal pixel) const;
110 
112 // bool allowRotation() const;
113 
115  void setWindowCursorPosition(FXint x, FXint y);
116 
118  FXbool makeCurrent();
119 
121  bool isInEditMode();
122 
124  return *myChanger;
125  }
126 
128 
129  virtual long onConfigure(FXObject*, FXSelector, void*);
130  virtual long onPaint(FXObject*, FXSelector, void*);
131  virtual long onLeftBtnPress(FXObject*, FXSelector, void*);
132  virtual long onLeftBtnRelease(FXObject*, FXSelector, void*);
133  virtual long onRightBtnPress(FXObject*, FXSelector, void*);
134  virtual long onRightBtnRelease(FXObject*, FXSelector, void*);
135  virtual long onMouseWheel(FXObject*, FXSelector, void*);
136  virtual long onMouseMove(FXObject*, FXSelector, void*);
137  virtual long onMouseLeft(FXObject*, FXSelector, void*);
138 
139  virtual long onKeyPress(FXObject* o, FXSelector sel, void* data);
140  virtual long onKeyRelease(FXObject* o, FXSelector sel, void* data);
141 
142 
143  virtual void openObjectDialog();
144 
146  void updateToolTip();
147 
148 
151 
155  void setSnapshots(std::map<SUMOTime, std::string> snaps);
156 
157 
164  std::string makeSnapshot(const std::string& destFile);
165 
166 
169  void checkSnapshots();
170 
172  virtual SUMOTime getCurrentTimeStep() const {
173  return 0;
174  }
176 
177 
178 
179  void showViewportEditor();
180  virtual void showViewschemeEditor() = 0;
181  void showToolTips(bool val);
182  virtual bool setColorScheme(const std::string&) {
183  return true;
184  }
185 
186  void remove(GUIDialog_EditViewport*) {
187  myViewportChooser = 0;
188  }
189 
190  void remove(GUIDialog_ViewSettings*) {
192  }
193 
194 
195  // @todo: check why this is here
196  SUMOReal getGridWidth() const;
197  // @todo: check why this is here
198  SUMOReal getGridHeight() const;
199 
200  virtual void startTrack(int /*id*/) { }
201  virtual void stopTrack() { }
202  virtual int getTrackedID() const {
203  return -1;
204  }
205 
206  virtual void onGamingClick(Position /*pos*/) { }
207 
210 
216  bool addAdditionalGLVisualisation(GUIGlObject* const which);
217 
218 
224  bool removeAdditionalGLVisualisation(GUIGlObject* const which);
226 
227 
229  void destroyPopup();
230 
231 
232 public:
240  };
241 
242 
246  struct Decal {
249  : filename(), centerX(0), centerY(0),
250  width(1000), height(1000), rot(0),
251  initialised(false), glID(-1) { }
252 
254  std::string filename;
268  int glID;
269  };
270 
271 
272 public:
273  FXComboBox& getColoringSchemesCombo();
274 
275 
280 
281  void addDecals(const std::vector<Decal> &decals) {
282  myDecals.insert(myDecals.end(), decals.begin(), decals.end());
283  }
284 
285 
288  }
289 
290 
291 protected:
293  void paintGL();
294 
295  void updatePositionInformation() const;
296 
297 
298  virtual int doPaintGL(int /*mode*/, const Boundary& /*boundary*/) {
299  return 0;
300  }
301 
302  virtual void doInit() { }
303 
305  void paintGLGrid();
306 
311  void displayLegend();
312 
313 
316 
319 
321  std::vector<GUIGlID> getObjectsInBoundary(const Boundary& bound);
322 
324  void showToolTipFor(unsigned int id);
325 
326 
327 protected:
330  void drawDecals();
331 
332  // applies gl-transformations to fit the Boundary given by myChanger onto
333  // the canvas. If fixRatio is true, this boundary will be enlarged to
334  // prevent anisotropic stretching. (this should be set to false when doing
335  // selections)
336  void applyGLTransform(bool fixRatio = true);
337 
338 protected:
341 
344 
347 
350 
353 
356 
359 
362 
364 
366 
369 
370 
373 
374 
377 
379  std::vector<Decal> myDecals;
380 
384 
385 
386  std::map<SUMOTime, std::string> mySnapshots;
387 
389 
391  std::map<GUIGlObject*, int> myAdditionallyDrawn;
392 
393 
394 protected:
396 
397 };
398 
399 
400 #endif
401 
402 /****************************************************************************/
403