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     virtual PanoramaData* getUnlinkedSubset(UIntSetVector& imageGroups) const = 0;
00110     
00111 // -- Data Access --
00112     
00113 // = images =    
00114     
00116     virtual std::size_t getNrOfImages() const =0;
00117     
00119     virtual const SrcPanoImage& getImage(std::size_t nr) const =0;
00120 
00122     virtual void setImage(std::size_t nr, const SrcPanoImage & img) =0;
00123     
00125 //    virtual unsigned int getImageNr(const PanoImage * image) const =0;
00126     
00132     virtual unsigned int addImage(const SrcPanoImage& img) =0;
00133     
00135 //    virtual int addImageAndLens(const std::string & filename) =0;
00136     
00140 //  virtual unsigned int addImage(const std::string & filename) =0;
00141     
00146     virtual void removeImage(unsigned int nr) =0;
00147     
00152     virtual void swapImages(unsigned int img1, unsigned int img2) =0;
00153 
00158     virtual void moveImage(size_t img1, size_t img2) =0;
00159 
00161     virtual SrcPanoImage getSrcImage(unsigned imgNr) const =0;
00162     
00166     virtual void setSrcImage(unsigned int nr, const SrcPanoImage & img) =0;
00167     
00174     virtual void setImageFilename(unsigned int img, const std::string & fname) =0;
00175     
00187     virtual  void activateImage(unsigned int imgNr, bool active=true) =0;
00188     
00190     virtual  UIntSet getActiveImages() const =0;
00191     
00192         /* Link image variable functions. Used to group image variables which
00193          * should share the same value. The initial value is the one kept by
00194          * the image with number sourceImgNr.
00195          */
00196 #define image_variable( name, type, default_value ) \
00197         virtual void linkImageVariable##name(unsigned int sourceImgNr, unsigned int destImgNr) =0;
00198 #include "image_variables.h"
00199 #undef image_variable
00200 
00201         /* Unlink image variable functions. Makes a image variable independant
00202          * of the other images.
00203          */
00204 #define image_variable( name, type, default_value ) \
00205         virtual void unlinkImageVariable##name(unsigned int imgNr) =0;
00206 #include "image_variables.h"
00207 #undef image_variable    
00208     
00209     
00210 // = CPs =    
00211     
00213     virtual  std::size_t getNrOfCtrlPoints() const =0;
00214     
00216     virtual const ControlPoint & getCtrlPoint(std::size_t nr) const =0;
00217     
00219     virtual const CPVector & getCtrlPoints() const =0;
00220     
00222     virtual std::vector<unsigned int> getCtrlPointsForImage(unsigned int imgNr) const =0;
00223     
00225     virtual void setCtrlPoints(const CPVector & points) =0;
00226     
00228     virtual unsigned int addCtrlPoint(const ControlPoint & point) =0;
00229     
00232     virtual void removeCtrlPoint(unsigned int pNr) =0;
00233     
00236     virtual void removeDuplicateCtrlPoints() =0;
00237 
00240     virtual void changeControlPoint(unsigned int pNr, const ControlPoint & point) =0;
00241     
00243 //  virtual unsigned int getCtrlPointNr(const ControlPoint * point) const =0;
00244     
00246     virtual int getNextCPTypeLineNumber() const =0;
00247     
00249     virtual void updateLineCtrlPoints() =0;
00250     
00251     
00258     virtual void updateCtrlPointErrors(const CPVector & controlPoints) =0;
00259     
00266     virtual void updateCtrlPointErrors(const UIntSet & imgs, const CPVector & cps) =0;
00267     
00268 // = Variables =    
00269 /*   TODO most of this section needs fixing. The image variables are now stored
00270  *        in SrcPanoImage objects, the PanoramaData object should just duplicate
00271  *        the changes across all images sharing variables.
00272  *        We also need access to the links of the variables.
00273  *        At some point, this functions should be removed. Do not create new
00274  *        code using them. Instead, use getSrcImage.
00275  */
00277     virtual VariableMapVector getVariables() const =0;
00278 
00289     virtual const VariableMap getImageVariables(unsigned int imgNr) const =0;
00290     
00296     virtual void updateVariables(const VariableMapVector & vars) =0;
00297     
00299     virtual void updateVariables(const UIntSet & imgs, const VariableMapVector & var) =0;
00300     
00304     virtual void updateVariables(unsigned int imgNr, const VariableMap & var) =0;
00305     
00310     virtual void updateVariable(unsigned int imgNr, const Variable &var) =0;
00311 
00315     virtual void updateWhiteBalance(double redFactor, double blueFactor) =0;
00316     
00317 // = Optimise Vector =    
00318 
00320     virtual const OptimizeVector & getOptimizeVector() const =0;
00321 
00323     virtual void setOptimizeVector(const OptimizeVector & optvec) =0;
00324 
00325 
00327     virtual const int getOptimizerSwitch() const =0;
00329     virtual void setOptimizerSwitch(const int newSwitch) =0;
00330 
00332     virtual const int getPhotometricOptimizerSwitch() const =0;
00334     virtual void setPhotometricOptimizerSwitch(const int newSwitch) =0;
00335 
00336 // = Panorama options =    
00337 
00339     virtual const PanoramaOptions & getOptions() const =0;
00340 
00345     virtual void setOptions(const PanoramaOptions & opt) =0;
00346     
00347 
00348     
00349 // -- script interface --
00350         
00361     virtual void parseOptimizerScript(std::istream & i,
00362                               const UIntSet & imgs,
00363                               VariableMapVector & imgVars,
00364                               CPVector & ctrlPoints) const =0;
00365     
00367     virtual void printPanoramaScript(std::ostream & o,
00368                              const OptimizeVector & optvars,
00369                              const PanoramaOptions & options,
00370                              const UIntSet & imgs,
00371                              bool forPTOptimizer,
00372                              const std::string & stripPrefix="") const =0;
00373     
00375     virtual void printStitcherScript(std::ostream & o,
00376                              const PanoramaOptions & target,
00377                              const UIntSet & imgs) const =0;
00378     
00379     
00380 // -- maintainance --
00381     
00382 public:
00384     virtual void changeFinished() =0;
00385     
00387     virtual void imageChanged(unsigned int imgNr) =0;
00389     virtual void updateMasksForImage(unsigned int imgNr, MaskPolygonVector newMasks)=0;
00395     virtual void updateMasks(bool convertPosMaskToNeg=false)=0;
00398     virtual void transferMask(MaskPolygon mask,unsigned int imgNr, const UIntSet& targetImgs)=0;
00400     virtual void updateOptimizeVector()=0;
00402     virtual std::set<size_t> getRefImages()=0;
00405     virtual void checkRefOptStatus(bool& linkRefImgsYaw, bool& linkRefImgsPitch, bool& linkRefImgsRoll)=0;
00406 
00407 };
00408 
00409 
00410 
00416 class PanoramaObserver
00417 {
00418     public:
00419         
00421         virtual ~PanoramaObserver() {};
00422         
00433         virtual void panoramaChanged(Panorama &pano) =0;
00434         
00444         virtual void panoramaImagesChanged(Panorama& pano,
00445                                            const UIntSet& changed) =0;
00446         
00447         
00448 };
00449 
00450 
00458 class IMPEX PanoramaDataMemento
00459 {
00460     protected: 
00462         PanoramaDataMemento() {};
00463     
00464     public:
00466         virtual ~PanoramaDataMemento() {};
00467 };
00468 
00469 
00471 class IMPEX ManagedPanoramaData : public PanoramaData
00472 {
00473     public:
00474         
00476         virtual ~ManagedPanoramaData() {};
00477         
00478         
00479         // -- Observing --
00480         
00481     public:
00488         virtual void addObserver(PanoramaObserver *o) =0;
00489         
00498         virtual bool removeObserver(PanoramaObserver *observer) =0;
00499         
00504         virtual void clearObservers() =0;
00505         
00512         virtual void changeFinished() =0;
00513         
00515         virtual void clearDirty() =0;
00516 
00522         virtual void imageChanged(unsigned int imgNr) =0;
00523         
00524         
00525         // -- Memento interface --
00526         
00527     public:
00529         virtual PanoramaDataMemento* getNewMemento() const =0;
00530         
00532         virtual bool setMementoToCopyOf(const PanoramaDataMemento* const memento) =0;
00533         
00534         
00535         // -- Optimization Status --
00536         
00537     public:
00541         virtual bool needsOptimization() =0;
00542         
00544         virtual void markAsOptimized(bool optimized=true) =0;
00545         
00546 };
00547 
00548 
00549 } // namespace
00550 
00551 
00552 
00553 
00554 #endif // _PANORAMA_H

Generated on 6 Feb 2016 for Hugintrunk by  doxygen 1.4.7