00001
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef GUISUMOAbstractView_h
00020 #define GUISUMOAbstractView_h
00021
00022
00023
00024
00025
00026 #ifdef _MSC_VER
00027 #include <windows_config.h>
00028 #else
00029 #include <config.h>
00030 #endif
00031
00032 #include <string>
00033 #include <vector>
00034 #include <fx.h>
00035 #include <fx3d.h>
00036 #include <utils/geom/Boundary.h>
00037 #include <utils/geom/Position2D.h>
00038 #include <utils/common/RGBColor.h>
00039 #include <utils/common/SUMOTime.h>
00040 #include <utils/shapes/Polygon2D.h>
00041 #include <utils/gui/globjects/GUIGlObjectTypes.h>
00042 #include <utils/foxtools/MFXMutex.h>
00043 #include <foreign/rtree/SUMORTree.h>
00044
00045 #ifdef _WIN32
00046 #include <windows.h>
00047 #include <GL/gl.h>
00048 #endif
00049
00050
00051
00052
00053
00054 class GUIGLObjectToolTip;
00055 class GUIGlChildWindow;
00056 class GUIVehicle;
00057 class GUIPerspectiveChanger;
00058 class GUIMainWindow;
00059 class GUIGLObjectPopupMenu;
00060 class GUIGlObject;
00061 class GUIDialog_EditViewport;
00062 class GUIDialog_ViewSettings;
00063 class GUIVisualizationSettings;
00064
00065
00066
00067
00068
00069
00076 class GUISUMOAbstractView : public FXGLCanvas {
00077 FXDECLARE(GUISUMOAbstractView)
00078 public:
00080 GUISUMOAbstractView(FXComposite *p, GUIMainWindow &app,
00081 GUIGlChildWindow *parent, const SUMORTree &grid,
00082 FXGLVisual *glVis, FXGLCanvas *share);
00083
00085 virtual ~GUISUMOAbstractView();
00086
00088 virtual void buildViewToolBars(GUIGlChildWindow &) { }
00089
00091 void recenterView();
00092
00094 virtual void centerTo(const GUIGlObject * const o) throw();
00095
00097 virtual void setViewport(SUMOReal zoom, SUMOReal xPos, SUMOReal yPos);
00098
00100 SUMOReal m2p(SUMOReal meter);
00101
00103 SUMOReal p2m(SUMOReal pixel);
00104
00106
00107
00109 void setWindowCursorPosition(FXint x, FXint y);
00110
00112 FXbool makeCurrent();
00113
00115 bool isInEditMode();
00116
00117
00118
00119 long onConfigure(FXObject*,FXSelector,void*);
00120 long onPaint(FXObject*,FXSelector,void*);
00121 virtual long onLeftBtnPress(FXObject*,FXSelector,void*);
00122 virtual long onLeftBtnRelease(FXObject*,FXSelector,void*);
00123 virtual long onRightBtnPress(FXObject*,FXSelector,void*);
00124 virtual long onRightBtnRelease(FXObject*,FXSelector,void*);
00125 virtual long onMouseWheel(FXObject*,FXSelector,void*);
00126 virtual long onMouseMove(FXObject*,FXSelector,void*);
00127 virtual long onMouseLeft(FXObject*,FXSelector,void*);
00128
00129 long onKeyPress(FXObject *o,FXSelector sel,void *data);
00130 long onKeyRelease(FXObject *o,FXSelector sel,void *data);
00131
00132
00133 virtual void openObjectDialog();
00134
00136 void updateToolTip();
00137
00139 void setSnapshots(std::map<SUMOTime, std::string> snaps);
00141 FXColor *getSnapshot();
00143 void checkSnapshots();
00144
00145 void showViewportEditor();
00146 virtual void showViewschemeEditor() = 0;
00147 void showToolTips(bool val);
00148 virtual void setColorScheme(const std::string &) { }
00149
00150 void remove(GUIDialog_EditViewport *) {
00151 myViewportChooser = 0;
00152 }
00153
00154 void remove(GUIDialog_ViewSettings *) {
00155 myVisualizationChanger = 0;
00156 }
00157
00158
00159 SUMOReal getGridWidth() const;
00160 SUMOReal getGridHeight() const;
00161
00166 virtual void showRoute(GUIVehicle * , int ) throw() { }
00167
00169 virtual void showBestLanes(GUIVehicle * ) { }
00170
00175 virtual void hideRoute(GUIVehicle * , int index=-1) throw() { }
00176
00178 virtual void hideBestLanes(GUIVehicle * ) { }
00179
00180 virtual void startTrack(int ) { }
00181 virtual void stopTrack() { }
00182 virtual int getTrackedID() const {
00183 return -1;
00184 }
00185
00186
00192 virtual bool amShowingRouteFor(GUIVehicle * , int ) throw() {
00193 return false;
00194 }
00195
00196 virtual bool amShowingBestLanesFor(GUIVehicle * ) {
00197 return false;
00198 }
00199
00200 virtual void onGamingClick(Position2D ) { }
00201
00202 public:
00207 enum JunctionColoringScheme {
00209 VCS_BY_TYPE = 0
00210 };
00211
00212
00216 struct Decal {
00218 Decal()
00219 : filename(), centerX(0), centerY(0),
00220 width(1000), height(1000), rot(0),
00221 initialised(false), glID(-1) { }
00222
00224 std::string filename;
00226 SUMOReal centerX;
00228 SUMOReal centerY;
00230 SUMOReal width;
00232 SUMOReal height;
00234 SUMOReal rot;
00236 bool initialised;
00238 int glID;
00239 };
00240
00241
00242 public:
00243 FXComboBox &getColoringSchemesCombo();
00244
00245 Position2D getPositionInformation() const;
00246
00247 void addDecals(const std::vector<Decal> &decals) throw() {
00248 myDecals.insert(myDecals.end(), decals.begin(), decals.end());
00249 }
00250
00251
00252 protected:
00253
00255 void paintGL();
00256
00257 void updatePositionInformation() const;
00258
00259 Position2D getPositionInformation(int x, int y) const;
00260
00261 virtual int doPaintGL(int , SUMOReal ) {
00262 return 0;
00263 }
00264
00265 virtual void doInit() { }
00266
00268 void paintGLGrid();
00269
00271 void applyChanges(SUMOReal scale, size_t xoff, size_t yoff);
00272
00277 void displayLegend() throw();
00278
00279
00281 void centerTo(Boundary bound);
00282
00284 unsigned int getObjectUnderCursor();
00285
00287 void showToolTipFor(unsigned int id);
00288
00289 protected:
00292 void drawDecals() throw();
00293
00294 protected:
00295 double myX1, myY1;
00296 double myCX, myCY;
00297
00298
00300 GUIMainWindow *myApp;
00301
00303 GUIGlChildWindow *myParent;
00304
00306 SUMORTree *myGrid;
00307
00309 int myWidthInPixels, myHeightInPixels;
00310
00312 SUMOReal myNetScale;
00313
00315 GUIPerspectiveChanger *myChanger;
00316
00318 bool myInEditMode;
00319
00321 GUIGLObjectToolTip *myToolTip;
00322
00324 FXint myWindowCursorPositionX, myWindowCursorPositionY;
00325
00327 int myMouseHotspotX, myMouseHotspotY;
00328
00330 SUMOReal myRatio;
00331
00333 SUMOReal myAddScl;
00334
00336 GUIGLObjectPopupMenu *myPopup;
00337
00338 GUIVisualizationSettings *myVisualizationSettings;
00339
00340 bool myUseToolTips;
00341
00343 bool myAmInitialised;
00344
00345
00346 GUIDialog_EditViewport *myViewportChooser;
00347 GUIDialog_ViewSettings *myVisualizationChanger;
00348
00351
00353 std::vector<Decal> myDecals;
00354
00356 MFXMutex myDecalsLock;
00358
00359 std::map<SUMOTime, std::string> mySnapshots;
00360
00361 mutable MFXMutex myPolyDrawLock;
00362
00363 enum VehicleOperationType {
00364 VO_TRACK,
00365 VO_SHOW_BEST_LANES,
00366 VO_SHOW_ROUTE
00367 };
00368
00369 struct VehicleOps {
00370 VehicleOperationType type;
00371 GUIVehicle *vehicle;
00372 int routeNo;
00373 };
00374
00376 std::vector<VehicleOps> myVehicleOps;
00377
00381 class vehicle_in_ops_finder {
00382 public:
00384 explicit vehicle_in_ops_finder(const GUIVehicle * const v)
00385 : myVehicle(v) { }
00386
00388 bool operator()(const VehicleOps &vo) {
00389 return vo.vehicle == myVehicle;
00390 }
00391
00392 private:
00394 const GUIVehicle * const myVehicle;
00395
00396 };
00397
00398 protected:
00399 GUISUMOAbstractView() { }
00400
00401 };
00402
00403
00404 #endif
00405
00406
00407