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.dlr.de/
12 // Copyright (C) 2001-2015 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 long
83  return 0;
84 }
85 
86 long
88  return 0;
89 }
90 
91 FXint
93  return myMouseXPosition;
94 }
95 
96 
97 FXint
99  return myMouseYPosition;
100 }
101 
102 
103 Boundary
105  // avoid division by zero
106  if (myCallback.getHeight() == 0 ||
107  myCallback.getWidth() == 0 ||
108  myViewPort.getHeight() == 0 ||
109  myViewPort.getWidth() == 0) {
110  return myViewPort;
111  }
112  Boundary result = myViewPort;
113  SUMOReal canvasRatio = (SUMOReal)myCallback.getWidth() / myCallback.getHeight();
114  SUMOReal ratio = result.getWidth() / result.getHeight();
115  if (ratio < canvasRatio) {
116  result.growWidth(result.getWidth() * (canvasRatio / ratio - 1) / 2);
117  } else {
118  result.growHeight(result.getHeight() * (ratio / canvasRatio - 1) / 2);
119  }
120  return result;
121 }
122 
123 /****************************************************************************/
124 
SUMOReal getHeight() const
Returns the height of the boundary.
Definition: Boundary.cpp:142
void growWidth(SUMOReal by)
Definition: Boundary.cpp:210
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)
virtual long onKeyPress(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:214
virtual void onMouseMove(void *data)
virtual void onRightBtnPress(void *data)
void growHeight(SUMOReal by)
Definition: Boundary.cpp:217
FXint myMouseXPosition
the current mouse position
virtual long onKeyRelease(void *data)
virtual ~GUIPerspectiveChanger()
Destructor.