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 typedef std::vector<UIntSet> UIntSetVector;
00057 
00081 class IMPEX PanoramaData
00082 {
00083     
00084 public:
00085     
00087     virtual ~PanoramaData() {};
00088     
00089     
00090     /* get a subset of the panorama
00091     *
00092     *  This returns a panorama that contains only the images specified by \imgs
00093     *  Useful for operations on a subset of the panorama
00094     */
00095 //  virtual Panorama getSubset(const UIntSet& imgs) const;
00096     
00097     /* duplicate the panorama
00098     *
00099     *  returns a copy of the pano state, except for the listeners.
00100     */
00101 //  virtual Panorama duplicate() const;
00102     
00104     virtual PanoramaData* getNewSubset(const UIntSet& imgs) const =0;
00105     
00107     virtual PanoramaData* getNewCopy() const =0;
00108     
00109     
00110 // -- Data Access --
00111     
00112 // = images =    
00113     
00115     virtual std::size_t getNrOfImages() const =0;
00116     
00118     virtual const SrcPanoImage& getImage(std::size_t nr) const =0;
00119 
00121     virtual void setImage(std::size_t nr, const SrcPanoImage & img) =0;
00122     
00124 //    virtual unsigned int getImageNr(const PanoImage * image) const =0;
00125     
00131     virtual unsigned int addImage(const SrcPanoImage& img) =0;
00132     
00134 //    virtual int addImageAndLens(const std::string & filename) =0;
00135     
00139 //  virtual unsigned int addImage(const std::string & filename) =0;
00140     
00145     virtual void removeImage(unsigned int nr) =0;
00146     
00151     virtual void swapImages(unsigned int img1, unsigned int img2) =0;
00152 
00157     virtual void moveImage(size_t img1, size_t img2) =0;
00158 
00160     virtual SrcPanoImage getSrcImage(unsigned imgNr) const =0;
00161     
00165     virtual void setSrcImage(unsigned int nr, const SrcPanoImage & img) =0;
00166     
00173     virtual void setImageFilename(unsigned int img, const std::string & fname) =0;
00174     
00186     virtual  void activateImage(unsigned int imgNr, bool active=true) =0;
00187     
00189     virtual  UIntSet getActiveImages() const =0;
00190     
00191         /* Link image variable functions. Used to group image variables which
00192          * should share the same value. The initial value is the one kept by
00193          * the image with number sourceImgNr.
00194          */
00195 #define image_variable( name, type, default_value ) \
00196         virtual void linkImageVariable##name(unsigned int sourceImgNr, unsigned int destImgNr) =0;
00197 #include "image_variables.h"
00198 #undef image_variable
00199 
00200         /* Unlink image variable functions. Makes a image variable independant
00201          * of the other images.
00202          */
00203 #define image_variable( name, type, default_value ) \
00204         virtual void unlinkImageVariable##name(unsigned int imgNr) =0;
00205 #include "image_variables.h"
00206 #undef image_variable    
00207     
00208     
00209 // = CPs =    
00210     
00212     virtual  std::size_t getNrOfCtrlPoints() const =0;
00213     
00215     virtual const ControlPoint & getCtrlPoint(std::size_t nr) const =0;
00216     
00218     virtual const CPVector & getCtrlPoints() const =0;
00219     
00221     virtual std::vector<unsigned int> getCtrlPointsForImage(unsigned int imgNr) const =0;
00222     
00224     virtual void setCtrlPoints(const CPVector & points) =0;
00225     
00227     virtual unsigned int addCtrlPoint(const ControlPoint & point) =0;
00228     
00231     virtual void removeCtrlPoint(unsigned int pNr) =0;
00232     
00235     virtual void removeDuplicateCtrlPoints() =0;
00236 
00239     virtual void changeControlPoint(unsigned int pNr, const ControlPoint & point) =0;
00240     
00242 //  virtual unsigned int getCtrlPointNr(const ControlPoint * point) const =0;
00243     
00245     virtual int getNextCPTypeLineNumber() const =0;
00246     
00248     virtual void updateLineCtrlPoints() =0;
00249     
00250     
00257     virtual void updateCtrlPointErrors(const CPVector & controlPoints) =0;
00258     
00265     virtual void updateCtrlPointErrors(const UIntSet & imgs, const CPVector & cps) =0;
00266     
00267 // = Variables =    
00268 /*   TODO most of this section needs fixing. The image variables are now stored
00269  *        in SrcPanoImage objects, the PanoramaData object should just duplicate
00270  *        the changes across all images sharing variables.
00271  *        We also need access to the links of the variables.
00272  *        At some point, this functions should be removed. Do not create new
00273  *        code using them. Instead, use getSrcImage.
00274  */
00276     virtual VariableMapVector getVariables() const =0;
00277 
00288     virtual const VariableMap getImageVariables(unsigned int imgNr) const =0;
00289     
00295     virtual void updateVariables(const VariableMapVector & vars) =0;
00296     
00298     virtual void updateVariables(const UIntSet & imgs, const VariableMapVector & var) =0;
00299     
00303     virtual void updateVariables(unsigned int imgNr, const VariableMap & var) =0;
00304     
00309     virtual void updateVariable(unsigned int imgNr, const Variable &var) =0;
00310 
00314     virtual void updateWhiteBalance(double redFactor, double blueFactor) =0;
00315     
00316 // = Optimise Vector =    
00317 
00319     virtual const OptimizeVector & getOptimizeVector() const =0;
00320 
00322     virtual void setOptimizeVector(const OptimizeVector & optvec) =0;
00323 
00324 
00326     virtual const int getOptimizerSwitch() const =0;
00328     virtual void setOptimizerSwitch(const int newSwitch) =0;
00329 
00331     virtual const int getPhotometricOptimizerSwitch() const =0;
00333     virtual void setPhotometricOptimizerSwitch(const int newSwitch) =0;
00334 
00335 // = Panorama options =    
00336 
00338     virtual const PanoramaOptions & getOptions() const =0;
00339 
00344     virtual void setOptions(const PanoramaOptions & opt) =0;
00345     
00346 
00347     
00348 // -- script interface --
00349         
00360     virtual void parseOptimizerScript(std::istream & i,
00361                               const UIntSet & imgs,
00362                               VariableMapVector & imgVars,
00363                               CPVector & ctrlPoints) const =0;
00364     
00366     virtual void printPanoramaScript(std::ostream & o,
00367                              const OptimizeVector & optvars,
00368                              const PanoramaOptions & options,
00369                              const UIntSet & imgs,
00370                              bool forPTOptimizer,
00371                              const std::string & stripPrefix="") const =0;
00372     
00374     virtual void printStitcherScript(std::ostream & o,
00375                              const PanoramaOptions & target,
00376                              const UIntSet & imgs) const =0;
00377     
00378     
00379 // -- maintainance --
00380     
00381 public:
00383     virtual void changeFinished() =0;
00384     
00386     virtual void imageChanged(unsigned int imgNr) =0;
00388     virtual void updateMasksForImage(unsigned int imgNr, MaskPolygonVector newMasks)=0;
00394     virtual void updateMasks(bool convertPosMaskToNeg=false)=0;
00397     virtual void transferMask(MaskPolygon mask,unsigned int imgNr, const UIntSet& targetImgs)=0;
00399     virtual void updateOptimizeVector()=0;
00401     virtual std::set<size_t> getRefImages()=0;
00404     virtual void checkRefOptStatus(bool& linkRefImgsYaw, bool& linkRefImgsPitch, bool& linkRefImgsRoll)=0;
00405 
00406 };
00407 
00408 
00409 
00415 class PanoramaObserver
00416 {
00417     public:
00418         
00420         virtual ~PanoramaObserver() {};
00421         
00432         virtual void panoramaChanged(Panorama &pano) =0;
00433         
00443         virtual void panoramaImagesChanged(Panorama& pano,
00444                                            const UIntSet& changed) =0;
00445         
00446         
00447 };
00448 
00449 
00457 class IMPEX PanoramaDataMemento
00458 {
00459     protected: 
00461         PanoramaDataMemento() {};
00462     
00463     public:
00465         virtual ~PanoramaDataMemento() {};
00466 };
00467 
00468 
00470 class IMPEX ManagedPanoramaData : public PanoramaData
00471 {
00472     public:
00473         
00475         virtual ~ManagedPanoramaData() {};
00476         
00477         
00478         // -- Observing --
00479         
00480     public:
00487         virtual void addObserver(PanoramaObserver *o) =0;
00488         
00497         virtual bool removeObserver(PanoramaObserver *observer) =0;
00498         
00503         virtual void clearObservers() =0;
00504         
00511         virtual void changeFinished() =0;
00512         
00514         virtual void clearDirty() =0;
00515 
00521         virtual void imageChanged(unsigned int imgNr) =0;
00522         
00523         
00524         // -- Memento interface --
00525         
00526     public:
00528         virtual PanoramaDataMemento* getNewMemento() const =0;
00529         
00531         virtual bool setMementoToCopyOf(const PanoramaDataMemento* const memento) =0;
00532         
00533         
00534         // -- Optimization Status --
00535         
00536     public:
00540         virtual bool needsOptimization() =0;
00541         
00543         virtual void markAsOptimized(bool optimized=true) =0;
00544         
00545 };
00546 
00547 
00548 } // namespace
00549 
00550 
00551 
00552 
00553 #endif // _PANORAMA_H

Generated on 28 Jul 2015 for Hugintrunk by  doxygen 1.4.7