SUMO - Simulation of Urban MObility

GUIPerspectiveChanger.cpp

Go to the documentation of this file.
00001 /****************************************************************************/
00007 // A class that allows to steer the visual output in dependence to user
00008 /****************************************************************************/
00009 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
00010 // Copyright (C) 2001-2011 DLR (http://www.dlr.de/) and contributors
00011 /****************************************************************************/
00012 //
00013 //   This program is free software; you can redistribute it and/or modify
00014 //   it under the terms of the GNU General Public License as published by
00015 //   the Free Software Foundation; either version 2 of the License, or
00016 //   (at your option) any later version.
00017 //
00018 /****************************************************************************/
00019 
00020 
00021 // ===========================================================================
00022 // included modules
00023 // ===========================================================================
00024 #ifdef _MSC_VER
00025 #include <windows_config.h>
00026 #else
00027 #include <config.h>
00028 #endif
00029 
00030 #include "GUISUMOAbstractView.h"
00031 #include "GUIPerspectiveChanger.h"
00032 
00033 #ifdef CHECK_MEMORY_LEAKS
00034 #include <foreign/nvwa/debug_new.h>
00035 #endif // CHECK_MEMORY_LEAKS
00036 
00037 
00038 // ===========================================================================
00039 // method definitions
00040 // ===========================================================================
00041 GUIPerspectiveChanger::GUIPerspectiveChanger(
00042     GUISUMOAbstractView& callBack,
00043     const Boundary& viewPort) :
00044     myCallback(callBack),
00045     myViewPort(viewPort) {}
00046 
00047 
00048 GUIPerspectiveChanger::~GUIPerspectiveChanger() {}
00049 
00050 
00051 void
00052 GUIPerspectiveChanger::onLeftBtnPress(void*) {}
00053 
00054 
00055 bool
00056 GUIPerspectiveChanger::onLeftBtnRelease(void*) {
00057     return false;
00058 }
00059 
00060 
00061 void
00062 GUIPerspectiveChanger::onRightBtnPress(void*) {}
00063 
00064 
00065 bool
00066 GUIPerspectiveChanger::onRightBtnRelease(void*) {
00067     return false;
00068 }
00069 
00070 
00071 void
00072 GUIPerspectiveChanger::onMouseWheel(void*) {}
00073 
00074 
00075 void
00076 GUIPerspectiveChanger::onMouseMove(void*) {}
00077 
00078 
00079 FXint
00080 GUIPerspectiveChanger::getMouseXPosition() const {
00081     return myMouseXPosition;
00082 }
00083 
00084 
00085 FXint
00086 GUIPerspectiveChanger::getMouseYPosition() const {
00087     return myMouseYPosition;
00088 }
00089 
00090 
00091 Boundary
00092 GUIPerspectiveChanger::patchedViewPort() {
00093     // avoid division by zero
00094     if (myCallback.getHeight() == 0 ||
00095             myCallback.getWidth() == 0 ||
00096             myViewPort.getHeight() == 0 ||
00097             myViewPort.getWidth() == 0) {
00098         return myViewPort;
00099     }
00100     Boundary result = myViewPort;
00101     SUMOReal canvasRatio = (SUMOReal)myCallback.getWidth() / myCallback.getHeight();
00102     SUMOReal ratio = result.getWidth() / result.getHeight();
00103     if (ratio < canvasRatio) {
00104         result.growWidth(result.getWidth() *(canvasRatio / ratio - 1) / 2);
00105     } else {
00106         result.growHeight(result.getHeight() *(ratio / canvasRatio - 1) / 2);
00107     }
00108     return result;
00109 }
00110 
00111 /****************************************************************************/
00112 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines