SUMO - Simulation of Urban MObility
GUIPerspectiveChanger.cpp
Go to the documentation of this file.
1 /****************************************************************************/
9 // A class that allows to steer the visual output in dependence to user
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
12 // Copyright (C) 2001-2014 DLR (http://www.dlr.de/) and contributors
13 /****************************************************************************/
14 //
15 // This file is part of SUMO.
16 // SUMO is free software: you can redistribute it and/or modify
17 // it under the terms of the GNU General Public License as published by
18 // the Free Software Foundation, either version 3 of the License, or
19 // (at your option) any later version.
20 //
21 /****************************************************************************/
22 
23 
24 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 #ifdef _MSC_VER
28 #include <windows_config.h>
29 #else
30 #include <config.h>
31 #endif
32 
33 #include "GUISUMOAbstractView.h"
34 #include "GUIPerspectiveChanger.h"
35 
36 #ifdef CHECK_MEMORY_LEAKS
37 #include <foreign/nvwa/debug_new.h>
38 #endif // CHECK_MEMORY_LEAKS
39 
40 
41 // ===========================================================================
42 // method definitions
43 // ===========================================================================
45  GUISUMOAbstractView& callBack,
46  const Boundary& viewPort) :
47  myCallback(callBack),
48  myViewPort(viewPort) {}
49 
50 
52 
53 
54 void
56 
57 
58 bool
60  return false;
61 }
62 
63 
64 void
66 
67 
68 bool
70  return false;
71 }
72 
73 
74 void
76 
77 
78 void
80 
81 
82 FXint
84  return myMouseXPosition;
85 }
86 
87 
88 FXint
90  return myMouseYPosition;
91 }
92 
93 
96  // avoid division by zero
97  if (myCallback.getHeight() == 0 ||
98  myCallback.getWidth() == 0 ||
99  myViewPort.getHeight() == 0 ||
100  myViewPort.getWidth() == 0) {
101  return myViewPort;
102  }
103  Boundary result = myViewPort;
104  SUMOReal canvasRatio = (SUMOReal)myCallback.getWidth() / myCallback.getHeight();
105  SUMOReal ratio = result.getWidth() / result.getHeight();
106  if (ratio < canvasRatio) {
107  result.growWidth(result.getWidth() * (canvasRatio / ratio - 1) / 2);
108  } else {
109  result.growHeight(result.getHeight() * (ratio / canvasRatio - 1) / 2);
110  }
111  return result;
112 }
113 
114 /****************************************************************************/
115 
SUMOReal getHeight() const
Returns the height of the boundary.
Definition: Boundary.cpp:142
void growWidth(SUMOReal by)
Definition: Boundary.cpp:209
SUMOReal getWidth() const
Returns the width of the boudary.
Definition: Boundary.cpp:136
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:48
virtual bool onLeftBtnRelease(void *data)
virtual bool onRightBtnRelease(void *data)
GUISUMOAbstractView & myCallback
The parent window (canvas to scale)
virtual void onLeftBtnPress(void *data)
FXint getMouseXPosition() const
Returns the last mouse x-position an event occured at.
Boundary myViewPort
the intended viewport
virtual void onMouseWheel(void *data)
FXint getMouseYPosition() const
Returns the last mouse y-position an event occured at.
GUIPerspectiveChanger(GUISUMOAbstractView &callBack, const Boundary &viewPort)
Constructor.
#define SUMOReal
Definition: config.h:215
virtual void onMouseMove(void *data)
virtual void onRightBtnPress(void *data)
void growHeight(SUMOReal by)
Definition: Boundary.cpp:216
FXint myMouseXPosition
the current mouse position
virtual ~GUIPerspectiveChanger()
Destructor.