[an error occurred while processing this directive]
Main Page | Modules | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

hugin_base/panodata/PanoramaData.h

Go to the documentation of this file.
00001 // -*- c-basic-offset: 4 -*-
00026 #ifndef _PANORAMA_H
00027 #define _PANORAMA_H
00028 
00029 #include <hugin_shared.h>
00030 #include <vector>
00031 #include <set>
00032 #include <iostream>
00033 
00034 #include <hugin_math/Matrix3.h>
00035 //#include <panodata/PanoImage.h>
00036 #include <panodata/PanoramaVariable.h>
00037 #include <panodata/SrcPanoImage.h>
00038 #include <panodata/ControlPoint.h>
00039 #include <panodata/Lens.h>
00040 #include <panodata/PanoramaOptions.h>
00041 
00042 
00043 
00044 namespace HuginBase {
00045 
00047 typedef std::set<unsigned int> UIntSet;
00048 
00050 typedef std::vector<unsigned int> UIntVector;
00051 
00052 
00076 class IMPEX PanoramaData
00077 {
00078     
00079 public:
00080     
00082     virtual ~PanoramaData() {};
00083     
00084     
00085     /* get a subset of the panorama
00086     *
00087     *  This returns a panorama that contains only the images specified by \imgs
00088     *  Useful for operations on a subset of the panorama
00089     */
00090 //  virtual Panorama getSubset(const UIntSet& imgs) const;
00091     
00092     /* duplicate the panorama
00093     *
00094     *  returns a copy of the pano state, except for the listeners.
00095     */
00096 //  virtual Panorama duplicate() const;
00097     
00099     virtual PanoramaData* getNewSubset(const UIntSet& imgs) const =0;
00100     
00102     virtual PanoramaData* getNewCopy() const =0;
00103     
00104     
00105 // -- Data Access --
00106     
00107 // = images =    
00108     
00110     virtual std::size_t getNrOfImages() const =0;
00111     
00113     virtual const SrcPanoImage& getImage(std::size_t nr) const =0;
00114 
00116     virtual void setImage(std::size_t nr, SrcPanoImage img) =0;
00117     
00119 //    virtual unsigned int getImageNr(const PanoImage * image) const =0;
00120     
00126     virtual unsigned int addImage(const SrcPanoImage& img) =0;
00127     
00129 //    virtual int addImageAndLens(const std::string & filename) =0;
00130     
00134 //  virtual unsigned int addImage(const std::string & filename) =0;
00135     
00140     virtual void removeImage(unsigned int nr) =0;
00141     
00146     virtual void swapImages(unsigned int img1, unsigned int img2) =0;
00147     
00149     virtual SrcPanoImage getSrcImage(unsigned imgNr) const =0;
00150     
00154     virtual void setSrcImage(unsigned int nr, const SrcPanoImage & img) =0;
00155     
00162     virtual void setImageFilename(unsigned int img, const std::string & fname) =0;
00163     
00168     virtual void setImageOptions(unsigned int i, const ImageOptions & opts) =0;
00169     
00181     virtual  void activateImage(unsigned int imgNr, bool active=true) =0;
00182     
00184     virtual  UIntSet getActiveImages() const =0;
00185     
00186         /* Link image variable functions. Used to group image variables which
00187          * should share the same value. The initial value is the one kept by
00188          * the image with number sourceImgNr.
00189          */
00190 #define image_variable( name, type, default_value ) \
00191         virtual void linkImageVariable##name(unsigned int sourceImgNr, unsigned int destImgNr) =0;
00192 #include "image_variables.h"
00193 #undef image_variable
00194 
00195         /* Unlink image variable functions. Makes a image variable independant
00196          * of the other images.
00197          */
00198 #define image_variable( name, type, default_value ) \
00199         virtual void unlinkImageVariable##name(unsigned int imgNr) =0;
00200 #include "image_variables.h"
00201 #undef image_variable    
00202     
00203     
00204 // = CPs =    
00205     
00207     virtual  std::size_t getNrOfCtrlPoints() const =0;
00208     
00210     virtual const ControlPoint & getCtrlPoint(std::size_t nr) const =0;
00211     
00213     virtual const CPVector & getCtrlPoints() const =0;
00214     
00216     virtual std::vector<unsigned int> getCtrlPointsForImage(unsigned int imgNr) const =0;
00217     
00219     virtual void setCtrlPoints(const CPVector & points) =0;
00220     
00222     virtual unsigned int addCtrlPoint(const ControlPoint & point) =0;
00223     
00226     virtual void removeCtrlPoint(unsigned int pNr) =0;
00227     
00230     virtual void removeDuplicateCtrlPoints() =0;
00231 
00234     virtual void changeControlPoint(unsigned int pNr, const ControlPoint & point) =0;
00235     
00237 //  virtual unsigned int getCtrlPointNr(const ControlPoint * point) const =0;
00238     
00240     virtual int getNextCPTypeLineNumber() const =0;
00241     
00243     virtual void updateLineCtrlPoints() =0;
00244     
00245     
00252     virtual void updateCtrlPointErrors(const CPVector & controlPoints) =0;
00253     
00260     virtual void updateCtrlPointErrors(const UIntSet & imgs, const CPVector & cps) =0;
00261     
00262 // = Variables =    
00263 /*   TODO most of this section needs fixing. The image variables are now stored
00264  *        in SrcPanoImage objects, the PanoramaData object should just duplicate
00265  *        the changes across all images sharing variables.
00266  *        We also need access to the links of the variables.
00267  *        At some point, this functions should be removed. Do not create new
00268  *        code using them. Instead, use getSrcImage.
00269  */
00271     virtual VariableMapVector getVariables() const =0;
00272 
00283     virtual const VariableMap getImageVariables(unsigned int imgNr) const =0;
00284     
00290     virtual void updateVariables(const VariableMapVector & vars) =0;
00291     
00293     virtual void updateVariables(const UIntSet & imgs, const VariableMapVector & var) =0;
00294     
00298     virtual void updateVariables(unsigned int imgNr, const VariableMap & var) =0;
00299     
00304     virtual void updateVariable(unsigned int imgNr, const Variable &var) =0;
00305 
00306     
00307 // = Optimise Vector =    
00308 
00310     virtual const OptimizeVector & getOptimizeVector() const =0;
00311 
00313     virtual void setOptimizeVector(const OptimizeVector & optvec) =0;
00314 
00315     
00316 // = Panorama options =    
00317 
00319     virtual const PanoramaOptions & getOptions() const =0;
00320 
00325     virtual void setOptions(const PanoramaOptions & opt) =0;
00326     
00327 
00328     
00329 // -- script interface --
00330         
00341     virtual void parseOptimizerScript(std::istream & i,
00342                               const UIntSet & imgs,
00343                               VariableMapVector & imgVars,
00344                               CPVector & ctrlPoints) const =0;
00345     
00347     virtual void printPanoramaScript(std::ostream & o,
00348                              const OptimizeVector & optvars,
00349                              const PanoramaOptions & options,
00350                              const UIntSet & imgs,
00351                              bool forPTOptimizer,
00352                              const std::string & stripPrefix="") const =0;
00353     
00355     virtual void printStitcherScript(std::ostream & o,
00356                              const PanoramaOptions & target,
00357                              const UIntSet & imgs) const =0;
00358     
00359     
00360 // -- maintainance --
00361     
00362 public:
00364     virtual void changeFinished() =0;
00365     
00367     virtual void imageChanged(unsigned int imgNr) =0;
00368 
00369 };
00370 
00371 
00372 
00378 class PanoramaObserver
00379 {
00380     public:
00381         
00383         virtual ~PanoramaObserver() {};
00384         
00395         virtual void panoramaChanged(PanoramaData &pano) =0;
00396         
00406         virtual void panoramaImagesChanged(PanoramaData& pano,
00407                                            const UIntSet& changed) =0;
00408         
00413     //  virtual void panoramaImageAdded(PanoramaData &pano, unsigned int imgNr)
00414     //        { DEBUG_WARN("DEFAULT handler method"); };
00415         
00421     //  virtual void panoramaImageRemoved(PanoramaData &pano, unsigned int imgNr)
00422     //        { DEBUG_WARN("DEFAULT handler method"); };
00423         
00430     //  virtual void panoramaImageChanged(PanoramaData &pano, unsigned int imgNr)
00431     //        { DEBUG_TRACE(""); };
00432         
00433 };
00434 
00435 
00443 class IMPEX PanoramaDataMemento
00444 {
00445     protected: 
00447         PanoramaDataMemento() {};
00448     
00449     public:
00451         virtual ~PanoramaDataMemento() {};
00452 };
00453 
00454 
00456 class IMPEX ManagedPanoramaData : public PanoramaData
00457 {
00458     public:
00459         
00461         virtual ~ManagedPanoramaData() {};
00462         
00463         
00464         // -- Observing --
00465         
00466     public:
00473         virtual void addObserver(PanoramaObserver *o) =0;
00474         
00483         virtual bool removeObserver(PanoramaObserver *observer) =0;
00484         
00489         virtual void clearObservers() =0;
00490         
00497         virtual void changeFinished() =0;
00498         
00504         virtual void imageChanged(unsigned int imgNr) =0;
00505         
00506         
00507         // -- Memento interface --
00508         
00509     public:
00511         virtual PanoramaDataMemento* getNewMemento() const =0;
00512         
00514         virtual bool setMementoToCopyOf(const PanoramaDataMemento* const memento) =0;
00515         
00516         
00517         // -- Optimization Status --
00518         
00519     public:
00523         virtual bool needsOptimization() =0;
00524         
00526         virtual void markAsOptimized(bool optimized=true) =0;
00527         
00528 };
00529 
00530 
00531 } // namespace
00532 
00533 
00534 
00535 
00536 #endif // _PANORAMA_H

Generated on Mon Sep 20 01:01:27 2010 for Hugintrunk by doxygen 1.3.9.1