00001
00002
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063 #ifndef __VIEWSTATE_H
00064 #define __VIEWSTATE_H
00065
00066 #include "hugin_utils/utils.h"
00067 #include <panodata/PanoramaData.h>
00068 #include <panodata/Panorama.h>
00069 #include "PT/Panorama.h"
00070 #include "OutputProjectionInfo.h"
00071 #include <vigra/diff2d.hxx>
00072 #include "TextureManager.h"
00073 #include "MeshManager.h"
00074
00075 #include <panodata/PanoramaOptions.h>
00076
00077 class GLViewer;
00078 class VisualizationState;
00079
00080
00081 class ViewState : public HuginBase::PanoramaObserver
00082 {
00083 public:
00084
00085 ViewState(PT::Panorama *pano, bool supportMultiTexture);
00086 ~ViewState();
00087
00088
00089 void panoramaChanged(HuginBase::PanoramaData &pano);
00090 void panoramaImagesChanged(HuginBase::PanoramaData&, const HuginBase::UIntSet&);
00091
00092
00093
00094 void SetOptions(const HuginBase::PanoramaOptions *new_opts);
00095 void SetSrcImage(unsigned int image_nr, HuginBase::SrcPanoImage *new_img);
00096 void SetLens(unsigned int lens_nr, HuginBase::Lens *new_lens);
00097
00098 void ForceRequireRedraw();
00099
00100
00101 HuginBase::PanoramaOptions *GetOptions();
00102 OutputProjectionInfo *GetProjectionInfo();
00103 HuginBase::SrcPanoImage *GetSrcImage(unsigned int image_nr);
00104
00105 TextureManager * GetTextureManager() {return m_tex_manager;}
00106
00107 bool GetSupportMultiTexture() const { return m_multiTexture; };
00108
00109
00110
00111 bool RequireRecalculatePhotometric();
00112
00113 bool RequireRecalculateImageSizes();
00114
00115 bool RequireRecalculateMasks(unsigned int image_nr);
00116
00117 bool ImagesRemoved();
00118
00119
00120
00121 void FinishedDraw();
00122
00123
00124 void DoUpdates();
00125
00126 void Redraw();
00127
00128 std::map<VisualizationState*, bool> vis_states;
00129
00130 protected:
00131
00132 PT::Panorama *m_pano;
00133 std::map<unsigned int, HuginBase::SrcPanoImage> img_states;
00134 HuginBase::PanoramaOptions opts;
00135 OutputProjectionInfo *projection_info;
00136
00137 unsigned int number_of_images;
00138 class fbool
00139 {
00140 public:
00141 fbool()
00142 {
00143 val = false;
00144 }
00145 bool val;
00146 };
00147
00148 bool dirty_photometrics;
00149 std::map<unsigned int, bool> active;
00150 std::map<unsigned int, fbool> dirty_mask;
00151 bool dirty_image_sizes, images_removed;
00152
00153 void Clean();
00154
00155
00156 TextureManager *m_tex_manager;
00157 bool m_multiTexture;
00158 };
00159
00160 class VisualizationState
00161 {
00162 public:
00163
00164 template <class M>
00165 VisualizationState(PT::Panorama* pano, ViewState* view_state, GLViewer * viewer, void (*RefreshFunction)(void*), void *arg, M* classArg)
00166 {
00167 m_pano = pano;
00168 m_view_state = view_state;
00169 RefreshFunc = RefreshFunction;
00170 refreshArg = arg;
00171 dirty_draw = true;
00172 dirty_viewport = true;
00173 unsigned int number_of_images = m_pano->getNrOfImages();
00174 for (unsigned int img = 0; img < number_of_images; img++)
00175 {
00176 dirty_mesh[img].val = true;
00177 }
00178 genscale = 0.0;
00179 m_mesh_manager = new M(m_pano, this);
00180 m_view_state->vis_states[this] = true;
00181 m_viewer = viewer;
00182 }
00183
00184 virtual ~VisualizationState();
00185
00186 virtual HuginBase::PanoramaOptions *GetOptions();
00187 virtual OutputProjectionInfo *GetProjectionInfo();
00188 virtual HuginBase::SrcPanoImage *GetSrcImage(unsigned int image_nr);
00189
00190 virtual void SetOptions(const HuginBase::PanoramaOptions *new_opts) {}
00191 virtual void SetSrcImage(unsigned int image_nr, HuginBase::SrcPanoImage * new_img) {}
00192
00193
00194 bool RequireRecalculateMesh (unsigned int image_nr);
00195
00196 bool RequireDraw();
00197
00198 bool RequireRecalculateViewport();
00199
00200
00201 float GetScale();
00202 void SetScale(float scale);
00203
00204
00205 unsigned int GetMeshDisplayList(unsigned int image_nr);
00206 MeshManager * GetMeshManager() {return m_mesh_manager;}
00207
00208 void FinishedDraw();
00209
00210
00211
00212 void SetVisibleArea(vigra::Rect2D area)
00213 {
00214
00215
00216
00217
00218
00219 visible_area = area;
00220 }
00221 vigra::Rect2D GetVisibleArea()
00222 {
00223 return visible_area;
00224 }
00225
00226 ViewState* getViewState() {return m_view_state;}
00227
00228
00229 void Redraw();
00230
00231
00232 void DoUpdates();
00233
00234 void SetDirtyMesh(int image_nr) {dirty_mesh[image_nr].val = true;}
00235 void ForceRequireRedraw();
00236 void SetDirtyViewport() {dirty_viewport = true;}
00237
00238 GLViewer * GetViewer() {return m_viewer;}
00239
00240 protected:
00241
00242 PT::Panorama *m_pano;
00243
00244 class fbool
00245 {
00246 public:
00247 fbool()
00248 {
00249 val = false;
00250 }
00251 bool val;
00252 };
00253
00254 std::map<unsigned int, fbool> dirty_mesh;
00255 bool dirty_draw, dirty_viewport;
00256
00257 float scale, genscale, gl_scale;
00258 vigra::Rect2D visible_area;
00259 void (*RefreshFunc)(void *);
00260 void *refreshArg;
00261
00262
00263 MeshManager *m_mesh_manager;
00264 ViewState *m_view_state;
00265
00266 GLViewer * m_viewer;
00267
00268 };
00269
00270 class OverviewVisualizationState : public VisualizationState
00271 {
00272 public:
00273 template <class M>
00274 OverviewVisualizationState(PT::Panorama* pano, ViewState* view_state, GLViewer * viewer, void (*RefreshFunction)(void*), void *arg, M* classArg)
00275 : VisualizationState(pano, view_state, viewer, RefreshFunction, arg, (M*) classArg) {}
00276
00277 };
00278
00279 class PanosphereOverviewVisualizationState : public OverviewVisualizationState
00280 {
00281 public:
00282
00283 PanosphereOverviewVisualizationState(PT::Panorama* pano, ViewState* view_state, GLViewer * viewer, void (*RefreshFunction)(void*), void *arg);
00284 ~PanosphereOverviewVisualizationState();
00285
00286 HuginBase::PanoramaOptions *GetOptions();
00287 OutputProjectionInfo *GetProjectionInfo();
00288
00289
00290
00291
00292 void SetOptions(const HuginBase::PanoramaOptions * new_opts);
00293
00294
00295 double getAngY() {return angy;}
00296 double getAngX() {return angx;}
00297 double getR() {return R;}
00298 double getFOV() {return fov;}
00299
00300 double getSphereRadius() {return sphere_radius;}
00301
00302 void setAngX(double angx_in);
00303 void setAngY(double angy_in);
00304 void setR(double r) {R = r;}
00305
00306
00307 protected:
00308
00309 double angy;
00310 double angx;
00311 double R;
00312 double fov;
00313
00314 double sphere_radius;
00315
00316
00317 HuginBase::PanoramaOptions opts;
00318 OutputProjectionInfo *projection_info;
00319
00320
00321 };
00322
00323 class PlaneOverviewVisualizationState : public OverviewVisualizationState
00324 {
00325 public:
00326
00327 PlaneOverviewVisualizationState(PT::Panorama* pano, ViewState* view_state, GLViewer * viewer, void (*RefreshFunction)(void*), void *arg);
00328 ~PlaneOverviewVisualizationState();
00329
00330 HuginBase::PanoramaOptions *GetOptions();
00331 OutputProjectionInfo *GetProjectionInfo();
00332
00333 void SetOptions(const HuginBase::PanoramaOptions * new_opts);
00334
00335
00336 double getR() {return R;}
00337 double getFOV() {return fov;}
00338 double getX() {return X;}
00339 double getY() {return Y;}
00340
00341 void setR(double r) {R = r;}
00342 void setX(double x) {X = x;}
00343 void setY(double y) {Y = y;}
00344
00345 protected:
00346
00347 double X;
00348 double Y;
00349 double R;
00350 double fov;
00351
00352 HuginBase::PanoramaOptions opts;
00353 OutputProjectionInfo *projection_info;
00354
00355 };
00356
00357 #endif
00358