Hugintrunk  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PanoramaData.h
Go to the documentation of this file.
1 // -*- c-basic-offset: 4 -*-
26 #ifndef _PANORAMA_H
27 #define _PANORAMA_H
28 
29 // if this file is preprocessed for SWIG, we want to ignore
30 // all the header inclusions that follow:
31 
32 #ifndef _HSI_IGNORE_SECTION
33 
34 #include <hugin_shared.h>
35 #include <vector>
36 #include <set>
37 #include <iostream>
38 
39 #include <hugin_math/Matrix3.h>
41 #include <panodata/SrcPanoImage.h>
42 #include <panodata/ControlPoint.h>
43 #include <panodata/Lens.h>
45 
46 #endif // _HSI_IGNORE_SECTION
47 
48 namespace HuginBase {
49 
51 typedef std::set<unsigned int> UIntSet;
52 
54 typedef std::vector<unsigned int> UIntVector;
55 
56 typedef std::vector<UIntSet> UIntSetVector;
57 
82 {
83 
84 public:
85 
87  virtual ~PanoramaData() {};
88 
89 
90  /* get a subset of the panorama
91  *
92  * This returns a panorama that contains only the images specified by \imgs
93  * Useful for operations on a subset of the panorama
94  */
95 // virtual Panorama getSubset(const UIntSet& imgs) const;
96 
97  /* duplicate the panorama
98  *
99  * returns a copy of the pano state, except for the listeners.
100  */
101 // virtual Panorama duplicate() const;
102 
104  virtual PanoramaData* getNewSubset(const UIntSet& imgs) const =0;
105 
107  virtual PanoramaData* getNewCopy() const =0;
108 
109  virtual PanoramaData* getUnlinkedSubset(UIntSetVector& imageGroups) const = 0;
110 
111 // -- Data Access --
112 
113 // = images =
114 
116  virtual std::size_t getNrOfImages() const =0;
117 
119  virtual const SrcPanoImage& getImage(std::size_t nr) const =0;
120 
122  virtual void setImage(std::size_t nr, const SrcPanoImage & img) =0;
123 
125 // virtual unsigned int getImageNr(const PanoImage * image) const =0;
126 
132  virtual unsigned int addImage(const SrcPanoImage& img) =0;
133 
135 // virtual int addImageAndLens(const std::string & filename) =0;
136 
140 // virtual unsigned int addImage(const std::string & filename) =0;
141 
146  virtual void removeImage(unsigned int nr) =0;
147 
152  virtual void swapImages(unsigned int img1, unsigned int img2) =0;
153 
158  virtual void moveImage(size_t img1, size_t img2) =0;
159 
161  virtual SrcPanoImage getSrcImage(unsigned imgNr) const =0;
162 
166  virtual void setSrcImage(unsigned int nr, const SrcPanoImage & img) =0;
167 
174  virtual void setImageFilename(unsigned int img, const std::string & fname) =0;
175 
187  virtual void activateImage(unsigned int imgNr, bool active=true) =0;
188 
190  virtual UIntSet getActiveImages() const =0;
191 
192  /* Link image variable functions. Used to group image variables which
193  * should share the same value. The initial value is the one kept by
194  * the image with number sourceImgNr.
195  */
196 #define image_variable( name, type, default_value ) \
197  virtual void linkImageVariable##name(unsigned int sourceImgNr, unsigned int destImgNr) =0;
198 #include "image_variables.h"
199 #undef image_variable
200 
201  /* Unlink image variable functions. Makes a image variable independant
202  * of the other images.
203  */
204 #define image_variable( name, type, default_value ) \
205  virtual void unlinkImageVariable##name(unsigned int imgNr) =0;
206 #include "image_variables.h"
207 #undef image_variable
208 
209 
210 // = CPs =
211 
213  virtual std::size_t getNrOfCtrlPoints() const =0;
214 
216  virtual const ControlPoint & getCtrlPoint(std::size_t nr) const =0;
217 
219  virtual const CPVector & getCtrlPoints() const =0;
220 
222  virtual std::vector<unsigned int> getCtrlPointsForImage(unsigned int imgNr) const =0;
223 
225  virtual void setCtrlPoints(const CPVector & points) =0;
226 
228  virtual unsigned int addCtrlPoint(const ControlPoint & point) =0;
229 
232  virtual void removeCtrlPoint(unsigned int pNr) =0;
233 
236  virtual void removeDuplicateCtrlPoints() =0;
237 
240  virtual void changeControlPoint(unsigned int pNr, const ControlPoint & point) =0;
241 
243 // virtual unsigned int getCtrlPointNr(const ControlPoint * point) const =0;
244 
246  virtual int getNextCPTypeLineNumber() const =0;
247 
249  virtual void updateLineCtrlPoints() =0;
250 
251 
258  virtual void updateCtrlPointErrors(const CPVector & controlPoints) =0;
259 
266  virtual void updateCtrlPointErrors(const UIntSet & imgs, const CPVector & cps) =0;
267 
268 // = Variables =
269 /* TODO most of this section needs fixing. The image variables are now stored
270  * in SrcPanoImage objects, the PanoramaData object should just duplicate
271  * the changes across all images sharing variables.
272  * We also need access to the links of the variables.
273  * At some point, this functions should be removed. Do not create new
274  * code using them. Instead, use getSrcImage.
275  */
277  virtual VariableMapVector getVariables() const =0;
278 
289  virtual const VariableMap getImageVariables(unsigned int imgNr) const =0;
290 
296  virtual void updateVariables(const VariableMapVector & vars) =0;
297 
299  virtual void updateVariables(const UIntSet & imgs, const VariableMapVector & var) =0;
300 
304  virtual void updateVariables(unsigned int imgNr, const VariableMap & var) =0;
305 
310  virtual void updateVariable(unsigned int imgNr, const Variable &var) =0;
311 
315  virtual void updateWhiteBalance(double redFactor, double blueFactor) =0;
316 
317 // = Optimise Vector =
318 
320  virtual const OptimizeVector & getOptimizeVector() const =0;
321 
323  virtual void setOptimizeVector(const OptimizeVector & optvec) =0;
324 
325 
327  virtual const int getOptimizerSwitch() const =0;
329  virtual void setOptimizerSwitch(const int newSwitch) =0;
330 
332  virtual const int getPhotometricOptimizerSwitch() const =0;
334  virtual void setPhotometricOptimizerSwitch(const int newSwitch) =0;
335 
336 // = Panorama options =
337 
339  virtual const PanoramaOptions & getOptions() const =0;
340 
345  virtual void setOptions(const PanoramaOptions & opt) =0;
346 
347 
348 
349 // -- script interface --
350 
352  virtual void printPanoramaScript(std::ostream & o,
353  const OptimizeVector & optvars,
354  const PanoramaOptions & options,
355  const UIntSet & imgs,
356  bool forPTOptimizer,
357  const std::string & stripPrefix="") const =0;
358 
360  virtual void printStitcherScript(std::ostream & o,
361  const PanoramaOptions & target,
362  const UIntSet & imgs) const =0;
363 
364 
365 // -- maintainance --
366 
367 public:
369  virtual void changeFinished() =0;
370 
372  virtual void imageChanged(unsigned int imgNr) =0;
374  virtual void updateMasksForImage(unsigned int imgNr, MaskPolygonVector newMasks)=0;
380  virtual void updateMasks(bool convertPosMaskToNeg=false)=0;
383  virtual void transferMask(MaskPolygon mask,unsigned int imgNr, const UIntSet& targetImgs)=0;
385  virtual void updateOptimizeVector()=0;
387  virtual std::set<size_t> getRefImages()=0;
390  virtual void checkRefOptStatus(bool& linkRefImgsYaw, bool& linkRefImgsPitch, bool& linkRefImgsRoll)=0;
391 
392 };
393 
394 
395 
402 {
403  public:
404 
406  virtual ~PanoramaObserver() {};
407 
418  virtual void panoramaChanged(Panorama &pano) =0;
419 
429  virtual void panoramaImagesChanged(Panorama& pano,
430  const UIntSet& changed) =0;
431 
432 
433 };
434 
435 
444 {
445  protected:
448 
449  public:
451  virtual ~PanoramaDataMemento() {};
452 };
453 
454 
457 {
458  public:
459 
461  virtual ~ManagedPanoramaData() {};
462 
463 
464  // -- Observing --
465 
466  public:
473  virtual void addObserver(PanoramaObserver *o) =0;
474 
483  virtual bool removeObserver(PanoramaObserver *observer) =0;
484 
489  virtual void clearObservers() =0;
490 
497  virtual void changeFinished() =0;
498 
500  virtual void clearDirty() =0;
501 
507  virtual void imageChanged(unsigned int imgNr) =0;
508 
509 
510  // -- Memento interface --
511 
512  public:
514  virtual PanoramaDataMemento* getNewMemento() const =0;
515 
517  virtual bool setMementoToCopyOf(const PanoramaDataMemento* const memento) =0;
518 
519 
520  // -- Optimization Status --
521 
522  public:
526  virtual bool needsOptimization() =0;
527 
529  virtual void markAsOptimized(bool optimized=true) =0;
530 
531 };
532 
533 
534 } // namespace
535 
536 
537 
538 
539 #endif // _PANORAMA_H
virtual void panoramaChanged(Panorama &pano)=0
Notification about a Panorama change.
PanoramaDataMemento()
force pure abstract behaviour
Definition: PanoramaData.h:447
virtual void panoramaImagesChanged(Panorama &pano, const UIntSet &changed)=0
notifies about changes to images
std::vector< UIntSet > UIntSetVector
Definition: PanoramaData.h:56
a variable has a value and a name.
represents a control point
Definition: ControlPoint.h:38
std::set< unsigned int > UIntSet
Definition: PanoramaData.h:51
std::vector< VariableMap > VariableMapVector
Model for a panorama.
Definition: Panorama.h:152
std::vector< unsigned int > UIntVector
Definition: PanoramaData.h:54
Model for a panorama.
Definition: PanoramaData.h:81
std::vector< MaskPolygon > MaskPolygonVector
Definition: Mask.h:147
#define IMPEX
Definition: hugin_shared.h:39
std::map< std::string, Variable > VariableMap
Lens class.
this handler class will receive change events from the Panorama.
Definition: PanoramaData.h:401
Memento class for a PanoramaData object.
Definition: PanoramaData.h:443
std::vector< ControlPoint > CPVector
Definition: ControlPoint.h:99
std::vector< std::set< std::string > > OptimizeVector
All variables of a source image.
Definition: SrcPanoImage.h:194
Panorama image options.
This file specifies what image variables SrcPanoImg should have.
base class, which stores one mask polygon
Definition: Mask.h:52