1 // -*- c-basic-offset: 4 -*-
2 /** @file hugin1/base_wx/PanoCommand.h
3 *
4 *  @author Pablo d'Angelo <pablo.dangelo@web.de>
5 *
6 *  $Id$
7 *
8 *  This is free software; you can redistribute it and/or
9 *  modify it under the terms of the GNU General Public
10 *  License as published by the Free Software Foundation; either
11 *  version 2 of the License, or (at your option) any later version.
12 *
13 *  This software is distributed in the hope that it will be useful,
14 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
15 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16 *  Lesser General Public License for more details.
17 *
18 *  You should have received a copy of the GNU General Public
19 *  License along with this software. If not, see
20 *  <http://www.gnu.org/licenses/>.
21 *
22 */
23 
24 #ifndef _Hgn1_PANOCOMMAND_H
25 #define _Hgn1_PANOCOMMAND_H
26 
27 
28 #include "Command.h"
29 
30 #include "panodata/Panorama.h"
31 #include <panodata/StandardImageVariableGroups.h>
32 
33 namespace PanoCommand
34 {
35     /** PanoCommand to combine other PanoCommands.
36     Use to get one Undo step from what would normally be several
37     PanoCommands.
38     */
39     class WXIMPEX CombinedPanoCommand : public PanoCommand
40     {
41     public:
42         /** Constructor.
43         *  @param commands List of pointers to commands. They applied from
44         *  beginning to end. CombinedPanoCommand deletes the commands when it is itself deleted.
45         */
CombinedPanoCommand(HuginBase::Panorama & pano,std::vector<PanoCommand * > & commands)46         CombinedPanoCommand(HuginBase::Panorama & pano, std::vector<PanoCommand*> & commands)
47             : PanoCommand(pano), commands(commands) { setName("multiple commands");};
48         ~CombinedPanoCommand();
49         virtual bool processPanorama(HuginBase::Panorama & pano);
50     private:
51         std::vector<PanoCommand*> commands;
52     };
53 
54     /** reset the panorama */
55     class WXIMPEX NewPanoCmd : public PanoCommand
56     {
57     public:
NewPanoCmd(HuginBase::Panorama & pano)58         explicit NewPanoCmd(HuginBase::Panorama & pano) : PanoCommand(pano) { m_clearDirty = true; };
59         virtual bool processPanorama(HuginBase::Panorama& pano);
getName()60         virtual std::string getName() const { return "new panorama"; };
61     };
62 
63     /** add image(s) to a panorama */
64     class WXIMPEX AddImagesCmd : public PanoCommand
65     {
66     public:
AddImagesCmd(HuginBase::Panorama & pano,const std::vector<HuginBase::SrcPanoImage> & images)67         AddImagesCmd(HuginBase::Panorama & pano, const std::vector<HuginBase::SrcPanoImage> & images)
68             : PanoCommand(pano), imgs(images) { };
69         virtual bool processPanorama(HuginBase::Panorama& pano);
getName()70         virtual std::string getName() const { return "add images"; };
71     private:
72         std::vector<HuginBase::SrcPanoImage> imgs;
73     };
74 
75     /** remove an image from a panorama
76     *
77     *  @todo would be nice to remove multiple at once
78     */
79     class WXIMPEX RemoveImageCmd : public PanoCommand
80     {
81     public:
RemoveImageCmd(HuginBase::Panorama & p,unsigned int imgNr)82         RemoveImageCmd(HuginBase::Panorama & p, unsigned int imgNr)
83             : PanoCommand(p), imgNr(imgNr)
84         { };
85 
86         virtual bool processPanorama(HuginBase::Panorama& pano);
getName()87         virtual std::string getName() const { return "remove image"; };
88     private:
89         unsigned int imgNr;
90     };
91 
92     /** remove multiple images from a panorama
93     */
94     class WXIMPEX RemoveImagesCmd : public PanoCommand
95     {
96     public:
RemoveImagesCmd(HuginBase::Panorama & p,HuginBase::UIntSet imgs)97         RemoveImagesCmd(HuginBase::Panorama & p, HuginBase::UIntSet imgs) : PanoCommand(p), imgNrs(imgs) {};
98         virtual bool processPanorama(HuginBase::Panorama& pano);
getName()99         virtual std::string getName() const { return "remove images"; };
100     private:
101         HuginBase::UIntSet imgNrs;
102     };
103 
104     /** update all variables */
105     class WXIMPEX UpdateVariablesCmd : public PanoCommand
106     {
107     public:
UpdateVariablesCmd(HuginBase::Panorama & p,const HuginBase::VariableMapVector & vars)108         UpdateVariablesCmd(HuginBase::Panorama & p, const HuginBase::VariableMapVector & vars)
109             : PanoCommand(p), vars(vars) {};
110         virtual bool processPanorama(HuginBase::Panorama& pano);
getName()111         virtual std::string getName() const { return "update variables"; };
112     private:
113         HuginBase::VariableMapVector vars;
114     };
115 
116     /** update all control points*/
117     class WXIMPEX UpdateCPsCmd : public PanoCommand
118     {
119     public:
120         UpdateCPsCmd(HuginBase::Panorama & p, const HuginBase::CPVector & cps, bool doUpdateCPError = true)
PanoCommand(p)121             : PanoCommand(p), cps(cps), updateCPError(doUpdateCPError)
122         { };
123         virtual bool processPanorama(HuginBase::Panorama& pano);
getName()124         virtual std::string getName() const { return "update control points"; };
125     private:
126         HuginBase::CPVector cps;
127         bool updateCPError;
128     };
129 
130     /** update all variables & control points*/
131     class WXIMPEX UpdateVariablesCPCmd : public PanoCommand
132     {
133     public:
UpdateVariablesCPCmd(HuginBase::Panorama & p,const HuginBase::VariableMapVector & vars,const HuginBase::CPVector & cps)134         UpdateVariablesCPCmd(HuginBase::Panorama & p, const HuginBase::VariableMapVector & vars, const HuginBase::CPVector& cps)
135             : PanoCommand(p), vars(vars), cps(cps)
136         { };
137         virtual bool processPanorama(HuginBase::Panorama& pano);
getName()138         virtual std::string getName() const { return "update variables and control points"; };
139     private:
140         HuginBase::VariableMapVector vars;
141         HuginBase::CPVector cps;
142     };
143 
144     /** update all variables & control points*/
145     class WXIMPEX UpdateVariablesCPSetCmd : public PanoCommand
146     {
147     public:
UpdateVariablesCPSetCmd(HuginBase::Panorama & p,HuginBase::UIntSet imgs,const HuginBase::VariableMapVector & vars,const HuginBase::CPVector & cps)148         UpdateVariablesCPSetCmd(HuginBase::Panorama & p, HuginBase::UIntSet imgs, const HuginBase::VariableMapVector & vars, const HuginBase::CPVector & cps)
149             : PanoCommand(p), m_imgs(imgs), vars(vars), cps(cps)
150         { };
151         virtual bool processPanorama(HuginBase::Panorama& pano);
getName()152         virtual std::string getName() const { return "update variables and control points"; };
153     private:
154         HuginBase::UIntSet m_imgs;
155         HuginBase::VariableMapVector vars;
156         HuginBase::CPVector cps;
157     };
158 
159     /** update variables of a single image */
160     class WXIMPEX UpdateImageVariablesCmd : public PanoCommand
161     {
162     public:
UpdateImageVariablesCmd(HuginBase::Panorama & p,unsigned int ImgNr,const HuginBase::VariableMap & vars)163         UpdateImageVariablesCmd(HuginBase::Panorama & p, unsigned int ImgNr, const HuginBase::VariableMap & vars)
164             : PanoCommand(p), imgNr(ImgNr), vars(vars)
165         { };
166         virtual bool processPanorama(HuginBase::Panorama& pano);
getName()167         virtual std::string getName() const { return "update image variables"; };
168     private:
169         unsigned int imgNr;
170         HuginBase::VariableMap vars;
171     };
172 
173     /** update variables of a group of images */
174     class WXIMPEX UpdateImagesVariablesCmd : public PanoCommand
175     {
176     public:
UpdateImagesVariablesCmd(HuginBase::Panorama & p,const HuginBase::UIntSet & change,const HuginBase::VariableMapVector & vars)177         UpdateImagesVariablesCmd(HuginBase::Panorama & p, const HuginBase::UIntSet & change, const HuginBase::VariableMapVector & vars)
178             : PanoCommand(p), change(change), vars(vars)
179         { };
180         virtual bool processPanorama(HuginBase::Panorama& pano);
getName()181         virtual std::string getName() const { return "update image variables"; }
182     private:
183         HuginBase::UIntSet change;
184         HuginBase::VariableMapVector vars;
185     };
186 
187     /** update variables by parsing a expression */
188     class WXIMPEX UpdateVariablesByParseExpression : public PanoCommand
189     {
190     public:
UpdateVariablesByParseExpression(HuginBase::Panorama & p,const std::string & expression)191         UpdateVariablesByParseExpression(HuginBase::Panorama & p, const std::string& expression)
192             : PanoCommand(p), m_expression(expression)
193         { };
194         virtual bool processPanorama(HuginBase::Panorama& pano);
getName()195         virtual std::string getName() const { return "update image variables by parsing expression"; }
196     private:
197         std::string m_expression;
198     };
199 
200     /** updates the optimize vector, aka all variables which should be optimized */
201     class WXIMPEX UpdateOptimizeVectorCmd : public PanoCommand
202     {
203     public:
UpdateOptimizeVectorCmd(HuginBase::Panorama & p,HuginBase::OptimizeVector optvec)204         UpdateOptimizeVectorCmd(HuginBase::Panorama &p, HuginBase::OptimizeVector optvec)
205             : PanoCommand(p), m_optvec(optvec)
206         { };
207         virtual bool processPanorama(HuginBase::Panorama & pano);
getName()208         virtual std::string getName() const { return "update optimize vector"; }
209     private:
210         HuginBase::OptimizeVector m_optvec;
211     };
212 
213     /** update the optimizer master switch */
214     class WXIMPEX UpdateOptimizerSwitchCmd : public PanoCommand
215     {
216     public:
UpdateOptimizerSwitchCmd(HuginBase::Panorama & p,int mode)217         UpdateOptimizerSwitchCmd(HuginBase::Panorama &p, int mode) : PanoCommand(p), m_mode(mode) { };
218         virtual bool processPanorama(HuginBase::Panorama & pano);
getName()219         virtual std::string getName() const { return "update optimizer master switch"; }
220     private:
221         int m_mode;
222     };
223 
224     /** update the photometric optimizer master switch */
225     class WXIMPEX UpdatePhotometricOptimizerSwitchCmd : public PanoCommand
226     {
227     public:
UpdatePhotometricOptimizerSwitchCmd(HuginBase::Panorama & p,int mode)228         UpdatePhotometricOptimizerSwitchCmd(HuginBase::Panorama &p, int mode) : PanoCommand(p), m_mode(mode) { };
229         virtual bool processPanorama(HuginBase::Panorama & pano);
getName()230         virtual std::string getName() const { return "update photometric optimizer master switch"; }
231     private:
232         int m_mode;
233     };
234 
235     /** update a single variable, possibly for a group of images */
236     class WXIMPEX SetVariableCmd : public PanoCommand
237     {
238     public:
SetVariableCmd(HuginBase::Panorama & p,const HuginBase::UIntSet & images,const HuginBase::Variable & var)239         SetVariableCmd(HuginBase::Panorama & p, const HuginBase::UIntSet & images, const HuginBase::Variable & var)
240             : PanoCommand(p), images(images), var(var)
241         { };
242         virtual bool processPanorama(HuginBase::Panorama& pano);
getName()243         virtual std::string getName() const { return "set image variable"; }
244     private:
245         HuginBase::UIntSet images;
246         HuginBase::Variable var;
247     };
248 
249     /** center panorama horizontically */
250     class WXIMPEX CenterPanoCmd : public PanoCommand
251     {
252     public:
CenterPanoCmd(HuginBase::Panorama & p)253         explicit CenterPanoCmd(HuginBase::Panorama & p) : PanoCommand(p) { };
254         virtual bool processPanorama(HuginBase::Panorama& pano);
getName()255         virtual std::string getName() const { return "center panorama"; }
256     };
257 
258     /** straighten panorama horizontically */
259     class WXIMPEX StraightenPanoCmd : public PanoCommand
260     {
261     public:
StraightenPanoCmd(HuginBase::Panorama & p)262         explicit StraightenPanoCmd(HuginBase::Panorama & p) : PanoCommand(p) { };
263         virtual bool processPanorama(HuginBase::Panorama& pano);
getName()264         virtual std::string getName() const { return "straighten panorama"; };
265     };
266 
267     /** add a control point */
268     class WXIMPEX AddCtrlPointCmd : public PanoCommand
269     {
270     public:
AddCtrlPointCmd(HuginBase::Panorama & p,const HuginBase::ControlPoint & cpoint)271         AddCtrlPointCmd(HuginBase::Panorama & p, const HuginBase::ControlPoint & cpoint)
272             : PanoCommand(p), point(cpoint)
273         {};
274         virtual bool processPanorama(HuginBase::Panorama& pano);
getName()275         virtual std::string getName() const { return "add control point"; };
276     private:
277         HuginBase::ControlPoint point;
278     };
279 
280     /** add multiple control points */
281     class WXIMPEX AddCtrlPointsCmd : public PanoCommand
282     {
283     public:
AddCtrlPointsCmd(HuginBase::Panorama & p,const HuginBase::CPVector & cpoints)284         AddCtrlPointsCmd(HuginBase::Panorama & p, const HuginBase::CPVector & cpoints)
285             : PanoCommand(p), cps(cpoints)
286         { }
287         virtual bool processPanorama(HuginBase::Panorama& pano);
getName()288         virtual std::string getName() const { return "add control points"; };
289     private:
290         HuginBase::CPVector cps;
291     };
292 
293     /** remove a control point */
294     class WXIMPEX RemoveCtrlPointCmd : public PanoCommand
295     {
296     public:
RemoveCtrlPointCmd(HuginBase::Panorama & p,unsigned int cpNr)297         RemoveCtrlPointCmd(HuginBase::Panorama & p, unsigned int cpNr)
298             : PanoCommand(p), pointNr(cpNr)
299         { }
300         virtual bool processPanorama(HuginBase::Panorama& pano);
getName()301         virtual std::string getName() const { return "remove control point"; };
302     private:
303         unsigned int pointNr;
304     };
305 
306     /** remove several  control points */
307     class WXIMPEX RemoveCtrlPointsCmd : public PanoCommand
308     {
309     public:
RemoveCtrlPointsCmd(HuginBase::Panorama & p,const HuginBase::UIntSet & points)310         RemoveCtrlPointsCmd(HuginBase::Panorama & p, const HuginBase::UIntSet & points)
311             : PanoCommand(p), m_points(points)
312         { }
313         virtual bool processPanorama(HuginBase::Panorama& pano);
getName()314         virtual std::string getName() const { return "remove control points"; };
315     private:
316         HuginBase::UIntSet m_points;
317     };
318 
319     /** change a control point */
320     class WXIMPEX ChangeCtrlPointCmd : public PanoCommand
321     {
322     public:
ChangeCtrlPointCmd(HuginBase::Panorama & p,unsigned int nr,HuginBase::ControlPoint point)323         ChangeCtrlPointCmd(HuginBase::Panorama & p, unsigned int nr, HuginBase::ControlPoint point)
324             : PanoCommand(p), pNr(nr), point(point)
325         {};
326         virtual bool processPanorama(HuginBase::Panorama& pano);
getName()327         virtual std::string getName() const { return "change control point"; };
328     private:
329         unsigned int pNr;
330         HuginBase::ControlPoint point;
331     };
332 
333     /** set active images */
334     class WXIMPEX SetActiveImagesCmd : public PanoCommand
335     {
336     public:
SetActiveImagesCmd(HuginBase::Panorama & p,HuginBase::UIntSet & active)337         SetActiveImagesCmd(HuginBase::Panorama & p, HuginBase::UIntSet & active)
338             : PanoCommand(p), m_active(active)
339         { };
340         virtual bool processPanorama(HuginBase::Panorama& pano);
getName()341         virtual std::string getName() const { return "change active images"; };
342     private:
343         HuginBase::UIntSet m_active;
344     };
345 
346     /** swap two images */
347     class WXIMPEX SwapImagesCmd : public PanoCommand
348     {
349     public:
SwapImagesCmd(HuginBase::Panorama & p,unsigned int i1,unsigned int i2)350         SwapImagesCmd(HuginBase::Panorama & p, unsigned int i1, unsigned int i2)
351             : PanoCommand(p), m_i1(i1), m_i2(i2)
352         { };
353         virtual bool processPanorama(HuginBase::Panorama& pano);
getName()354         virtual std::string getName() const { return "swap images"; };
355     private:
356         unsigned int m_i1;
357         unsigned int m_i2;
358     };
359 
360     /** move image from position1 to position2 */
361     class WXIMPEX MoveImageCmd : public PanoCommand
362     {
363     public:
MoveImageCmd(HuginBase::Panorama & p,size_t i1,size_t i2)364         MoveImageCmd(HuginBase::Panorama & p, size_t i1, size_t i2)
365             : PanoCommand(p), m_i1(i1), m_i2(i2)
366         { };
367         virtual bool processPanorama(HuginBase::Panorama& pano);
getName()368         virtual std::string getName() const { return "move images"; };
369     private:
370         unsigned int m_i1;
371         unsigned int m_i2;
372     };
373 
374     /** merge two project files */
375     class WXIMPEX MergePanoCmd : public PanoCommand
376     {
377     public:
MergePanoCmd(HuginBase::Panorama & p,HuginBase::Panorama & p2)378         MergePanoCmd(HuginBase::Panorama & p, HuginBase::Panorama & p2)
379             : PanoCommand(p), newPano(p2)
380         { };
381         virtual bool processPanorama(HuginBase::Panorama& pano);
getName()382         virtual std::string getName() const { return "merge panorama"; };
383     private:
384         HuginBase::Panorama newPano;
385     };
386 
387     /** update source image
388     */
389     class WXIMPEX UpdateSrcImageCmd : public PanoCommand
390     {
391     public:
UpdateSrcImageCmd(HuginBase::Panorama & p,unsigned i,HuginBase::SrcPanoImage img)392         UpdateSrcImageCmd(HuginBase::Panorama & p, unsigned i, HuginBase::SrcPanoImage img)
393             : PanoCommand(p), img(img), imgNr(i)
394         { };
395         virtual bool processPanorama(HuginBase::Panorama& pano);
getName()396         virtual std::string getName() const{ return "update source image"; };
397     private:
398         HuginBase::SrcPanoImage img;
399         unsigned imgNr;
400     };
401 
402     /** update source images
403     */
404     class WXIMPEX UpdateSrcImagesCmd : public PanoCommand
405     {
406     public:
UpdateSrcImagesCmd(HuginBase::Panorama & p,HuginBase::UIntSet i,std::vector<HuginBase::SrcPanoImage> imgs)407         UpdateSrcImagesCmd(HuginBase::Panorama & p, HuginBase::UIntSet i, std::vector<HuginBase::SrcPanoImage> imgs)
408             : PanoCommand(p), imgs(imgs), imgNrs(i)
409         { };
410         virtual bool processPanorama(HuginBase::Panorama& pano);
getName()411         virtual std::string getName() const { return "update source images"; };
412     private:
413         std::vector<HuginBase::SrcPanoImage> imgs;
414         HuginBase::UIntSet imgNrs;
415     };
416 
417     /** set the panorama options */
418     class WXIMPEX SetPanoOptionsCmd : public PanoCommand
419     {
420     public:
SetPanoOptionsCmd(HuginBase::Panorama & p,const HuginBase::PanoramaOptions & opts)421         SetPanoOptionsCmd(HuginBase::Panorama & p, const HuginBase::PanoramaOptions & opts)
422             : PanoCommand(p), options(opts)
423         { };
424         virtual bool processPanorama(HuginBase::Panorama& pano);
getName()425         virtual std::string getName() const { return "set panorama options"; };
426     private:
427         HuginBase::PanoramaOptions options;
428     };
429 
430     /** dump the current project and load a new one.
431     *
432     *  Use this for  style projects.
433     *
434     */
435     class WXIMPEX LoadPTProjectCmd : public PanoCommand
436     {
437     public:
438         LoadPTProjectCmd(HuginBase::Panorama & p, const std::string  & filename, const std::string & prefix = "");
439         virtual bool processPanorama(HuginBase::Panorama& pano);
getName()440         virtual std::string getName() const { return "load project"; };
441     private:
442         const std::string &filename;
443         const std::string &prefix;
444     };
445 
446     /** Rotate the panorama
447     */
448     class WXIMPEX RotatePanoCmd : public PanoCommand
449     {
450     public:
RotatePanoCmd(HuginBase::Panorama & p,double yaw,double pitch,double roll)451         RotatePanoCmd(HuginBase::Panorama & p, double yaw, double pitch, double roll)
452             : PanoCommand(p), y(yaw), p(pitch), r(roll)
453         { };
454         virtual bool processPanorama(HuginBase::Panorama& pano);
getName()455         virtual std::string getName() const { return "rotate panorama"; };
456     private:
457         double y, p, r;
458     };
459 
460     /** Translate the panorama
461     */
462     class WXIMPEX TranslatePanoCmd : public PanoCommand
463     {
464     public:
TranslatePanoCmd(HuginBase::Panorama & p,double TrX,double TrY,double TrZ)465         TranslatePanoCmd(HuginBase::Panorama & p, double TrX, double TrY, double TrZ)
466             : PanoCommand(p), X(TrX), Y(TrY), Z(TrZ)
467         { };
468         virtual bool processPanorama(HuginBase::Panorama& pano);
getName()469         virtual std::string getName() const{ return "translate panorama"; };
470     private:
471         double X, Y, Z;
472     };
473 
474     /** Update the focal length
475     */
476     class WXIMPEX UpdateFocalLengthCmd : public PanoCommand
477     {
478     public:
UpdateFocalLengthCmd(HuginBase::Panorama & p,HuginBase::UIntSet imgs,double newFocalLength)479         UpdateFocalLengthCmd(HuginBase::Panorama & p, HuginBase::UIntSet imgs, double newFocalLength)
480             : PanoCommand(p), imgNrs(imgs), m_focalLength(newFocalLength)
481         { };
482         virtual bool processPanorama(HuginBase::Panorama& pano);
getName()483         virtual std::string getName() const { return "update focal length"; };
484     private:
485         HuginBase::UIntSet imgNrs;
486         double m_focalLength;
487     };
488 
489     /** Update the crop factor
490     */
491     class WXIMPEX UpdateCropFactorCmd : public PanoCommand
492     {
493     public:
UpdateCropFactorCmd(HuginBase::Panorama & p,HuginBase::UIntSet imgs,double newCropFactor)494         UpdateCropFactorCmd(HuginBase::Panorama & p, HuginBase::UIntSet imgs, double newCropFactor)
495             : PanoCommand(p), imgNrs(imgs), m_cropFactor(newCropFactor)
496         { };
497         virtual bool processPanorama(HuginBase::Panorama& pano);
getName()498         virtual std::string getName() const { return "update crop factor"; };
499     private:
500         HuginBase::UIntSet imgNrs;
501         double m_cropFactor;
502     };
503 
504     /** Switch the part number of an image
505     */
506     class WXIMPEX ChangePartNumberCmd : public PanoCommand
507     {
508     public:
ChangePartNumberCmd(HuginBase::Panorama & p,HuginBase::UIntSet image_numbers,std::size_t new_part_number,std::set<HuginBase::ImageVariableGroup::ImageVariableEnum> variables)509         ChangePartNumberCmd(HuginBase::Panorama & p, HuginBase::UIntSet image_numbers, std::size_t new_part_number,
510             std::set<HuginBase::ImageVariableGroup::ImageVariableEnum> variables)
511             : PanoCommand(p), image_numbers(image_numbers), new_part_number(new_part_number),variables(variables)
512         { };
513         virtual bool processPanorama(HuginBase::Panorama& pano);
getName()514         virtual std::string getName() const { return "Change part number"; };
515     private:
516         HuginBase::UIntSet image_numbers;
517         std::size_t new_part_number;
518         std::set<HuginBase::ImageVariableGroup::ImageVariableEnum> variables;
519     };
520 
521     /** Change the linking of some variables across parts of an
522     * ImageVariableGroup containing some specified images.
523     */
524     class WXIMPEX ChangePartImagesLinkingCmd : public PanoCommand
525     {
526     public:
527         /** Constructor.
528         * @param p the panorama this affects
529         * @param image_numbers the set of image numbers that are contained
530         * within the parts you would like to link or unlink.
531         * @param changeVariables the set of variables you would like to change
532         * the linking of across those parts.
533         * @param new_linked_state true to link variables, false to unlink them.
534         * @param groupVariables the variables that make the ImageVariableGroup
535         * that will define which images belong to which parts.
536         */
ChangePartImagesLinkingCmd(HuginBase::Panorama & p,HuginBase::UIntSet image_numbers,std::set<HuginBase::ImageVariableGroup::ImageVariableEnum> changeVariables,bool new_linked_state,std::set<HuginBase::ImageVariableGroup::ImageVariableEnum> groupVariables)537         ChangePartImagesLinkingCmd(HuginBase::Panorama & p,
538             HuginBase::UIntSet image_numbers, std::set<HuginBase::ImageVariableGroup::ImageVariableEnum> changeVariables,
539             bool new_linked_state, std::set<HuginBase::ImageVariableGroup::ImageVariableEnum> groupVariables)
540             : PanoCommand(p), image_numbers(image_numbers), changeVariables(changeVariables),
541             new_linked_state(new_linked_state), groupVariables(groupVariables)
542         { };
543         virtual bool processPanorama(HuginBase::Panorama& pano);
getName()544         virtual std::string getName() const { return "Change image variable links"; };
545     private:
546         HuginBase::UIntSet image_numbers;
547         std::set<HuginBase::ImageVariableGroup::ImageVariableEnum> changeVariables;
548         bool new_linked_state;
549         std::set<HuginBase::ImageVariableGroup::ImageVariableEnum> groupVariables;
550     };
551 
552     /** Link a set of lens variables for some lens.
553     */
554     class WXIMPEX LinkLensVarsCmd : public PanoCommand
555     {
556     public:
LinkLensVarsCmd(HuginBase::Panorama & p,std::size_t lens_number,std::set<HuginBase::ImageVariableGroup::ImageVariableEnum> variables)557         LinkLensVarsCmd(HuginBase::Panorama & p, std::size_t lens_number, std::set<HuginBase::ImageVariableGroup::ImageVariableEnum> variables)
558             : PanoCommand(p), lens_number(lens_number), variables(variables)
559         { };
560         virtual bool processPanorama(HuginBase::Panorama& pano);
getName()561         virtual std::string getName() const { return "Link lens variables"; };
562     private:
563         std::size_t lens_number;
564         std::set<HuginBase::ImageVariableGroup::ImageVariableEnum> variables;
565     };
566 
567     /// @todo avoid copying image data in processPanorama
568 #define image_variable( name, type, default_value )\
569     class WXIMPEX ChangeImage##name##Cmd : public PanoCommand\
570                 {\
571     public:\
572         ChangeImage##name##Cmd(HuginBase::Panorama & p,\
573                                HuginBase::UIntSet image_numbers,\
574                                type value)\
575             :   PanoCommand(p),\
576                 image_numbers(image_numbers),\
577                 value(value)\
578                         { };\
579         virtual bool processPanorama(HuginBase::Panorama& pano);\
580         virtual std::string getName() const { return "Change image's " #name; };\
581     private:\
582         HuginBase::UIntSet image_numbers;\
583         type value;\
584         };
585 #include <panodata/image_variables.h>
586 #undef image_variable
587 
588     /** Make a new part in a ImageVariableGroup for a set of images, given the
589     * variables that make up the group.
590     */
591     class WXIMPEX NewPartCmd : public PanoCommand
592     {
593     public:
594         /** Constructor.
595         * @param p HuginBase::Panorama to act up
596         * @param image_numbers A set of images which should all be in a single
597         * new group.
598         * @param vars The set of image variables that make up the group. Should
599         * be got from StandardVariableGroups.
600         */
NewPartCmd(HuginBase::Panorama & p,HuginBase::UIntSet image_numbers,std::set<HuginBase::ImageVariableGroup::ImageVariableEnum> vars)601         NewPartCmd(HuginBase::Panorama & p, HuginBase::UIntSet image_numbers, std::set<HuginBase::ImageVariableGroup::ImageVariableEnum> vars)
602             : PanoCommand(p), image_numbers(image_numbers), vars(vars)
603         { }
604         virtual bool processPanorama(HuginBase::Panorama& pano);
getName()605         virtual std::string getName() const { return "New Part"; };
606     private:
607         HuginBase::UIntSet image_numbers;
608         std::set<HuginBase::ImageVariableGroup::ImageVariableEnum> vars;
609     };
610 
611     /** update mask for given image */
612     class WXIMPEX UpdateMaskForImgCmd : public PanoCommand
613     {
614     public:
UpdateMaskForImgCmd(HuginBase::Panorama & p,unsigned int img,const HuginBase::MaskPolygonVector & mask)615         UpdateMaskForImgCmd(HuginBase::Panorama & p, unsigned int img, const HuginBase::MaskPolygonVector & mask)
616             : PanoCommand(p), m_img(img), m_mask(mask)
617         { };
618         virtual bool processPanorama(HuginBase::Panorama& pano);
getName()619         virtual std::string getName() const { return "update mask"; };
620     private:
621         unsigned int m_img;
622         HuginBase::MaskPolygonVector m_mask;
623     };
624 
625     /** update global white balance */
626     class WXIMPEX UpdateWhiteBalance : public PanoCommand
627     {
628     public:
UpdateWhiteBalance(HuginBase::Panorama & p,double redFactor,double blueFactor)629         UpdateWhiteBalance(HuginBase::Panorama & p, double redFactor, double blueFactor)
630             : PanoCommand(p), m_red(redFactor), m_blue(blueFactor)
631         { };
632         virtual bool processPanorama(HuginBase::Panorama& pano);
getName()633         virtual std::string getName() const { return "update global white balance"; };
634     private:
635         double m_red;
636         double m_blue;
637     };
638 
639     /** reset output exposure to mean exposure of all images */
640     class WXIMPEX ResetToMeanExposure : public PanoCommand
641     {
642     public:
ResetToMeanExposure(HuginBase::Panorama & p)643         explicit ResetToMeanExposure(HuginBase::Panorama & p) : PanoCommand(p) { };
644         virtual bool processPanorama(HuginBase::Panorama& pano);
getName()645         virtual std::string getName() const { return "set exposure to mean exposure"; };
646     };
647 
648     /** distributes all images above the sphere, for the assistant */
649     class WXIMPEX DistributeImagesCmd : public PanoCommand
650     {
651     public:
DistributeImagesCmd(HuginBase::Panorama & p)652         explicit DistributeImagesCmd(HuginBase::Panorama & p) : PanoCommand(p) { };
653         virtual bool processPanorama(HuginBase::Panorama& pano);
getName()654         virtual std::string getName() const { return "distribute images"; };
655     };
656 
657 
658 } // namespace PanoCommand
659 
660 #endif // _PANOCOMMAND_H
661