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