[800bc1]: src / panocanvas.h  Maximize  Restore  History

Download this file

205 lines (172 with data), 4.5 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
/***************************************************************************
panocanvas.h - description
-------------------
begin : Mon Jun 2 2003
copyright : (C) 2003 by Fabian Wenzel
email : f.wenzel@gmx.net
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef PANOCANVAS_H
#define PANOCANVAS_H
#include <wx/glcanvas.h>
#include <wx/image.h>
#include <wx/thread.h>
#include <wx/progdlg.h>
#include <wx/timer.h>
#include <GL/gl.h>
#include <vector>
#include <cmath>
#include "boundaries.h"
#ifndef M_PI
#define M_PI 3.14159263
#endif
#ifndef M_PI_2
#define M_PI_2 M_PI/2.0
#endif
template <class T> inline T DEG(const T rad){
return rad * 180.0 / M_PI;
}
template <class T> inline T RAD(const T deg){
return deg * M_PI / 180.0;
}
class CPosition{
public:
CPosition() :
m_pan (0.0),
m_tilt(0.0),
m_fov (0.0)
{
}
CPosition(const double &pan, const double &tilt, const double &fov) :
m_pan (pan),
m_tilt(tilt),
m_fov (fov)
{
}
void shiftPan()
{
if(m_pan < 0.0)
m_pan += 180.0;
else
m_pan -=180.0;
}
void setPan(const double &pan)
{
m_pan = pan;
}
void setTilt(const double &tilt)
{
m_tilt = tilt;
}
void setFov(const double &fov)
{
m_fov = fov;
}
const double &getPan() const
{
return m_pan;
}
const double &getTilt() const
{
return m_tilt;
}
const double &getFov() const
{
return m_fov;
}
void incrementPan(const double &increment)
{
m_pan += increment;
if(m_pan > 360.0)
m_pan-=360.0;
else if (m_pan < 0.0)
m_pan += 360.0;
}
void incrementTilt(const double &increment)
{
m_tilt += increment;
}
void incrementFov(const double &increment)
{
m_fov += increment;
}
const CPosition &operator+=(const CPosition &other)
{
incrementPan (other.getPan());
incrementTilt(other.getTilt());
incrementFov (other.getFov());
return *this;
}
CPosition operator+(const CPosition &other) const
{
CPosition result = *this;
result += other;
return result;
}
private:
double m_pan;
double m_tilt;
double m_fov;
};
/**
*@author Fabian Wenzel
*/
class panoCanvas : public wxGLCanvas {
public:
panoCanvas(wxWindow *parent, int id, const wxPoint &position=wxDefaultPosition, const wxSize &size=wxDefaultSize);
virtual ~panoCanvas();
void OnPaint(wxPaintEvent &event);
void OnSize(wxSizeEvent &event);
void OnEraseBackground(wxEraseEvent& event);
CBoundaries calculateViewBoundaries(const CPosition &offset = CPosition());
void incrementPosition(CPosition increment);
void setPosition(const CPosition &position);
const CPosition &getPosition();
void createPanorama(const wxImage &image);
void deletePanorama();
const CBoundaries &getImageBoundaries() const
{
return m_imageboundaries;
}
void setImageBoundaries(const CBoundaries &newboundaries)
{
m_imageboundaries = newboundaries;
}
protected:
void position();
void showPanorama();
void initGL();
CPosition getPanTilt(int x, int y, const CPosition &offset = CPosition());
GLfloat m_projectionmatrix[16];
GLdouble m_aspectratio;
GLuint *m_textures;
wxSize m_winsize;
bool m_hasimage;
GLint m_maxsize;
wxPoint m_numOfTexPatches;
wxPoint m_stepsPerTexture;
wxPoint m_pixelsPerTexture;
CPosition m_position;
bool *m_viewableTexPatches;
int m_divisions;
double m_phiinterval;
double m_thetainterval;
double m_phistep;
double m_thetastep;
double m_phistart;
double m_thetastart;
double m_maxtexturex;
double m_maxtexturey;
CBoundaries m_currentboundaries;
CBoundaries m_imageboundaries;
bool m_initialized;
DECLARE_EVENT_TABLE();
};
#endif

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks