1 // -*- c-basic-offset: 4 -*-
2 /** @file LensTools.h
3  *
4  *  @brief some helper classes for working with lenses
5  *
6  *  @author T. Modes
7  *
8  */
9 
10 /*
11  *  This is free software; you can redistribute it and/or
12  *  modify it under the terms of the GNU General Public
13  *  License as published by the Free Software Foundation; either
14  *  version 2 of the License, or (at your option) any later version.
15  *
16  *  This software is distributed in the hope that it will be useful,
17  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
18  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19  *  Lesser General Public License for more details.
20  *
21  *  You should have received a copy of the GNU General Public
22  *  License along with this software. If not, see
23  *  <http://www.gnu.org/licenses/>.
24  *
25  */
26 
27 #ifndef LENSTOOLS_H
28 #define LENSTOOLS_H
29 
30 #include <hugin_shared.h>
31 #include "panoinc_WX.h"
32 #include "panoinc.h"
33 #include "base_wx/Command.h"
34 
35 /** Fills a wxControlWithItem with all input projection formats,
36   * the client data contains the associated projection number */
37 WXIMPEX void FillLensProjectionList(wxControlWithItems* list);
38 /** Fills a wxControlWithItem with all possible blender options,
39 * the client data contains the associated blender mod from PanoramaOptions */
40 WXIMPEX void FillBlenderList(wxControlWithItems* list);
41 
42 /** Selects the given value (stored in the client data) in the given list item */
43 WXIMPEX void SelectListValue(wxControlWithItems* list,size_t newValue);
44 /** Returns the client value of the selected item from list */
45 WXIMPEX size_t GetSelectedValue(wxControlWithItems* list);
46 
47 /** Returns translated projection for given image */
48 WXIMPEX wxString getProjectionString(const HuginBase::SrcPanoImage& img);
49 /** Returns translated response type for given SrcPanoImage */
50 WXIMPEX wxString getResponseString(const HuginBase::SrcPanoImage& img);
51 
52 /** save the lens parameters of the image to a lens file named filename */
53 WXIMPEX void SaveLensParameters(const wxString filename, HuginBase::Panorama* pano, unsigned int imgNr);
54 /** saves the lens parameters to ini files, provides all necessary dialogs */
55 WXIMPEX void SaveLensParametersToIni(wxWindow * parent, HuginBase::Panorama *pano, const HuginBase::UIntSet images);
56 
57 /** applies lens parameter from user selected file to pano using GlobalCmdHist
58   *  @param parent parent window for showing message boxes
59   *  @param pano Panorama in which the lens data should read
60   *  @param images images for which the lens parameters should be set, check image sizes before running this function
61   *  @param command pointer to PanoCommand::PanoCommand for insertion into command history
62   *  @returns true if sucessful loaded lens parameters
63   */
64 WXIMPEX bool ApplyLensParameters(wxWindow * parent, HuginBase::Panorama *pano, HuginBase::UIntSet images,PanoCommand::PanoCommand*& command);
65 /** load lens parameters from lens ini file
66   *  @param parent parent window, for showing messageboxes
67   *  @param lens lens, for reading projection and lensparameters
68   *  @param cropped read if cropped enabled
69   *  @param autoCenterCrop read if automatic center crop
70   *  @param cropRect read crop rect
71   *  @returns true if lens parameters were sucessful read
72   */
73 WXIMPEX bool LoadLensParametersChoose(wxWindow * parent, HuginBase::Lens & lens,
74     bool & cropped, bool & autoCenterCrop, vigra::Rect2D & cropRect);
75 
76 /** check, if lens and stacks are correctly linked
77  *   shows message box with short information if not
78  *  @param pano Panorama which should be checked
79  *  @param allowCancel if true the message box contains also a Cancel button, if false there is only ok button
80  *  @returns true, if all conditions are satisfied, false if user selected cancel in dialog box */
81 WXIMPEX bool CheckLensStacks(HuginBase::Panorama* pano, bool allowCancel);
82 
83 namespace FormatString
84 {
85 /** returns Exif DateTimeOriginal as formatted wxString */
86 WXIMPEX wxString GetExifDateTime(const HuginBase::SrcPanoImage* img);
87 /** return focallength and focallength 35 mm as wxString */
88 WXIMPEX wxString GetFocalLength(const HuginBase::SrcPanoImage* img);
89 /** returns formatted aperture value */
90 WXIMPEX wxString GetAperture(const HuginBase::SrcPanoImage* img);
91 /** returns formatted exposure time */
92 WXIMPEX wxString GetExposureTime(const HuginBase::SrcPanoImage* img);
93 /** returns formatted iso value */
94 WXIMPEX wxString GetIso(const HuginBase::SrcPanoImage* img);
95 };
96 
97 #endif // LENSTOOLS_H
98