PanoramaData.h

Go to the documentation of this file.
00001 // -*- c-basic-offset: 4 -*-
00026 #ifndef _PANORAMA_H
00027 #define _PANORAMA_H
00028 
00029 // if this file is preprocessed for SWIG, we want to ignore
00030 // all the header inclusions that follow:
00031 
00032 #ifndef _HSI_IGNORE_SECTION
00033 
00034 #include <hugin_shared.h>
00035 #include <vector>
00036 #include <set>
00037 #include <iostream>
00038 
00039 #include <hugin_math/Matrix3.h>
00040 #include <panodata/PanoramaVariable.h>
00041 #include <panodata/SrcPanoImage.h>
00042 #include <panodata/ControlPoint.h>
00043 #include <panodata/Lens.h>
00044 #include <panodata/PanoramaOptions.h>
00045 
00046 #endif // _HSI_IGNORE_SECTION
00047 
00048 namespace HuginBase {
00049 
00051 typedef std::set<unsigned int> UIntSet;
00052 
00054 typedef std::vector<unsigned int> UIntVector;
00055 
00056 
00080 class IMPEX PanoramaData
00081 {
00082     
00083 public:
00084     
00086     virtual ~PanoramaData() {};
00087     
00088     
00089     /* get a subset of the panorama
00090     *
00091     *  This returns a panorama that contains only the images specified by \imgs
00092     *  Useful for operations on a subset of the panorama
00093     */
00094 //  virtual Panorama getSubset(const UIntSet& imgs) const;
00095     
00096     /* duplicate the panorama
00097     *
00098     *  returns a copy of the pano state, except for the listeners.
00099     */
00100 //  virtual Panorama duplicate() const;
00101     
00103     virtual PanoramaData* getNewSubset(const UIntSet& imgs) const =0;
00104     
00106     virtual PanoramaData* getNewCopy() const =0;
00107     
00108     
00109 // -- Data Access --
00110     
00111 // = images =    
00112     
00114     virtual std::size_t getNrOfImages() const =0;
00115     
00117     virtual const SrcPanoImage& getImage(std::size_t nr) const =0;
00118 
00120     virtual void setImage(std::size_t nr, const SrcPanoImage & img) =0;
00121     
00123 //    virtual unsigned int getImageNr(const PanoImage * image) const =0;
00124     
00130     virtual unsigned int addImage(const SrcPanoImage& img) =0;
00131     
00133 //    virtual int addImageAndLens(const std::string & filename) =0;
00134     
00138 //  virtual unsigned int addImage(const std::string & filename) =0;
00139     
00144     virtual void removeImage(unsigned int nr) =0;
00145     
00150     virtual void swapImages(unsigned int img1, unsigned int img2) =0;
00151 
00156     virtual void moveImage(size_t img1, size_t img2) =0;
00157 
00159     virtual SrcPanoImage getSrcImage(unsigned imgNr) const =0;
00160     
00164     virtual void setSrcImage(unsigned int nr, const SrcPanoImage & img) =0;
00165     
00172     virtual void setImageFilename(unsigned int img, const std::string & fname) =0;
00173     
00185     virtual  void activateImage(unsigned int imgNr, bool active=true) =0;
00186     
00188     virtual  UIntSet getActiveImages() const =0;
00189     
00190         /* Link image variable functions. Used to group image variables which
00191          * should share the same value. The initial value is the one kept by
00192          * the image with number sourceImgNr.
00193          */
00194 #define image_variable( name, type, default_value ) \
00195         virtual void linkImageVariable##name(unsigned int sourceImgNr, unsigned int destImgNr) =0;
00196 #include "image_variables.h"
00197 #undef image_variable
00198 
00199         /* Unlink image variable functions. Makes a image variable independant
00200          * of the other images.
00201          */
00202 #define image_variable( name, type, default_value ) \
00203         virtual void unlinkImageVariable##name(unsigned int imgNr) =0;
00204 #include "image_variables.h"
00205 #undef image_variable    
00206     
00207     
00208 // = CPs =    
00209     
00211     virtual  std::size_t getNrOfCtrlPoints() const =0;
00212     
00214     virtual const ControlPoint & getCtrlPoint(std::size_t nr) const =0;
00215     
00217     virtual const CPVector & getCtrlPoints() const =0;
00218     
00220     virtual std::vector<unsigned int> getCtrlPointsForImage(unsigned int imgNr) const =0;
00221     
00223     virtual void setCtrlPoints(const CPVector & points) =0;
00224     
00226     virtual unsigned int addCtrlPoint(const ControlPoint & point) =0;
00227     
00230     virtual void removeCtrlPoint(unsigned int pNr) =0;
00231     
00234     virtual void removeDuplicateCtrlPoints() =0;
00235 
00238     virtual void changeControlPoint(unsigned int pNr, const ControlPoint & point) =0;
00239     
00241 //  virtual unsigned int getCtrlPointNr(const ControlPoint * point) const =0;
00242     
00244     virtual int getNextCPTypeLineNumber() const =0;
00245     
00247     virtual void updateLineCtrlPoints() =0;
00248     
00249     
00256     virtual void updateCtrlPointErrors(const CPVector & controlPoints) =0;
00257     
00264     virtual void updateCtrlPointErrors(const UIntSet & imgs, const CPVector & cps) =0;
00265     
00266 // = Variables =    
00267 /*   TODO most of this section needs fixing. The image variables are now stored
00268  *        in SrcPanoImage objects, the PanoramaData object should just duplicate
00269  *        the changes across all images sharing variables.
00270  *        We also need access to the links of the variables.
00271  *        At some point, this functions should be removed. Do not create new
00272  *        code using them. Instead, use getSrcImage.
00273  */
00275     virtual VariableMapVector getVariables() const =0;
00276 
00287     virtual const VariableMap getImageVariables(unsigned int imgNr) const =0;
00288     
00294     virtual void updateVariables(const VariableMapVector & vars) =0;
00295     
00297     virtual void updateVariables(const UIntSet & imgs, const VariableMapVector & var) =0;
00298     
00302     virtual void updateVariables(unsigned int imgNr, const VariableMap & var) =0;
00303     
00308     virtual void updateVariable(unsigned int imgNr, const Variable &var) =0;
00309 
00313     virtual void updateWhiteBalance(double redFactor, double blueFactor) =0;
00314     
00315 // = Optimise Vector =    
00316 
00318     virtual const OptimizeVector & getOptimizeVector() const =0;
00319 
00321     virtual void setOptimizeVector(const OptimizeVector & optvec) =0;
00322 
00323 
00325     virtual const int getOptimizerSwitch() const =0;
00327     virtual void setOptimizerSwitch(const int newSwitch) =0;
00328 
00330     virtual const int getPhotometricOptimizerSwitch() const =0;
00332     virtual void setPhotometricOptimizerSwitch(const int newSwitch) =0;
00333 
00334 // = Panorama options =    
00335 
00337     virtual const PanoramaOptions & getOptions() const =0;
00338 
00343     virtual void setOptions(const PanoramaOptions & opt) =0;
00344     
00345 
00346     
00347 // -- script interface --
00348         
00359     virtual void parseOptimizerScript(std::istream & i,
00360                               const UIntSet & imgs,
00361                               VariableMapVector & imgVars,
00362                               CPVector & ctrlPoints) const =0;
00363     
00365     virtual void printPanoramaScript(std::ostream & o,
00366                              const OptimizeVector & optvars,
00367                              const PanoramaOptions & options,
00368                              const UIntSet & imgs,
00369                              bool forPTOptimizer,
00370                              const std::string & stripPrefix="") const =0;
00371     
00373     virtual void printStitcherScript(std::ostream & o,
00374                              const PanoramaOptions & target,
00375                              const UIntSet & imgs) const =0;
00376     
00377     
00378 // -- maintainance --
00379     
00380 public:
00382     virtual void changeFinished() =0;
00383     
00385     virtual void imageChanged(unsigned int imgNr) =0;
00387     virtual void updateMasksForImage(unsigned int imgNr, MaskPolygonVector newMasks)=0;
00393     virtual void updateMasks(bool convertPosMaskToNeg=false)=0;
00396     virtual void transferMask(MaskPolygon mask,unsigned int imgNr, const UIntSet targetImgs)=0;
00398     virtual void updateOptimizeVector()=0;
00400     virtual std::set<size_t> getRefImages()=0;
00403     virtual void checkRefOptStatus(bool& linkRefImgsYaw, bool& linkRefImgsPitch, bool& linkRefImgsRoll)=0;
00404 
00405 };
00406 
00407 
00408 
00414 class PanoramaObserver
00415 {
00416     public:
00417         
00419         virtual ~PanoramaObserver() {};
00420         
00431         virtual void panoramaChanged(PanoramaData &pano) =0;
00432         
00442         virtual void panoramaImagesChanged(PanoramaData& pano,
00443                                            const UIntSet& changed) =0;
00444         
00449     //  virtual void panoramaImageAdded(PanoramaData &pano, unsigned int imgNr)
00450     //        { DEBUG_WARN("DEFAULT handler method"); };
00451         
00457     //  virtual void panoramaImageRemoved(PanoramaData &pano, unsigned int imgNr)
00458     //        { DEBUG_WARN("DEFAULT handler method"); };
00459         
00466     //  virtual void panoramaImageChanged(PanoramaData &pano, unsigned int imgNr)
00467     //        { DEBUG_TRACE(""); };
00468         
00469 };
00470 
00471 
00479 class IMPEX PanoramaDataMemento
00480 {
00481     protected: 
00483         PanoramaDataMemento() {};
00484     
00485     public:
00487         virtual ~PanoramaDataMemento() {};
00488 };
00489 
00490 
00492 class IMPEX ManagedPanoramaData : public PanoramaData
00493 {
00494     public:
00495         
00497         virtual ~ManagedPanoramaData() {};
00498         
00499         
00500         // -- Observing --
00501         
00502     public:
00509         virtual void addObserver(PanoramaObserver *o) =0;
00510         
00519         virtual bool removeObserver(PanoramaObserver *observer) =0;
00520         
00525         virtual void clearObservers() =0;
00526         
00533         virtual void changeFinished() =0;
00534         
00536         virtual void clearDirty() =0;
00537 
00543         virtual void imageChanged(unsigned int imgNr) =0;
00544         
00545         
00546         // -- Memento interface --
00547         
00548     public:
00550         virtual PanoramaDataMemento* getNewMemento() const =0;
00551         
00553         virtual bool setMementoToCopyOf(const PanoramaDataMemento* const memento) =0;
00554         
00555         
00556         // -- Optimization Status --
00557         
00558     public:
00562         virtual bool needsOptimization() =0;
00563         
00565         virtual void markAsOptimized(bool optimized=true) =0;
00566         
00567 };
00568 
00569 
00570 } // namespace
00571 
00572 
00573 
00574 
00575 #endif // _PANORAMA_H

Generated on Thu Aug 21 01:25:40 2014 for Hugintrunk by  doxygen 1.3.9.1