Hugin trunk 0.1
Loading...
Searching...
No Matches
HDRMergeOptionDialog.cpp
Go to the documentation of this file.
1// -*- c-basic-offset: 4 -*-
2
13/* This is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public
15 * License as published by the Free Software Foundation; either
16 * version 2 of the License, or (at your option) any later version.
17 *
18 * This software is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 * Lesser General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public
24 * License along with this software. If not, see
25 * <http://www.gnu.org/licenses/>.
26 *
27 */
28
30#include "base_wx/wxPlatform.h"
31#ifdef __APPLE__
32#include "panoinc_WX.h"
33#include "panoinc.h"
34#endif
36#include "hugin/huginApp.h"
37#include "base_wx/wxutils.h"
38
39// somewhere SetDesc gets defined.. this breaks wx/cmdline.h on OSX
40#ifdef SetDesc
41#undef SetDesc
42#endif
43
44#include <wx/cmdline.h>
45
47{
48 wxXmlResource::Get()->LoadDialog(this, parent, "hdrmerge_options_dialog");
49
50 m_mode=XRCCTRL(*this,"hdrmerge_option_mode",wxChoice);
52 m_panel_avg=XRCCTRL(*this,"hdrmerge_option_panel_avg",wxPanel);
53 m_panel_avgslow=XRCCTRL(*this,"hdrmerge_option_panel_avgslow",wxPanel);
54 m_panel_khan=XRCCTRL(*this,"hdrmerge_option_panel_khan",wxPanel);
55 m_option_c=XRCCTRL(*this,"hdrmerge_option_c",wxCheckBox);
56 m_khan_iter=XRCCTRL(*this,"hdrmerge_option_khan_iter",wxSpinCtrl);
57 m_khan_iter->SetRange(1,100);
58 m_khan_sigma=XRCCTRL(*this,"hdrmerge_option_khan_sigma",wxTextCtrl);
59 m_option_khan_af=XRCCTRL(*this,"hdrmerge_option_khan_af",wxCheckBox);
60 m_option_khan_ag=XRCCTRL(*this,"hdrmerge_option_khan_ag",wxCheckBox);
61 m_option_khan_am=XRCCTRL(*this,"hdrmerge_option_khan_am",wxCheckBox);
62 this->CenterOnParent();
64};
65
67{
68 m_cmd=cmd;
69 if (m_cmd.IsEmpty())
71 m_cmd.LowerCase();
72 // parse arguments
73 static const wxCmdLineEntryDesc cmdLineDesc[] =
74 {
76 { wxCMD_LINE_SWITCH, "c", NULL, NULL},
81 };
83 parser.SetDesc(cmdLineDesc);
84 parser.SetCmdLine(m_cmd);
85 parser.Parse(false);
86 wxString param;
87 if(parser.Found("m",&param))
88 {
89 if(param.CmpNoCase("avg_slow")==0)
90 m_mode->SetSelection(1);
91 else
92 {
93 if(param.CmpNoCase("khan")==0)
94 m_mode->SetSelection(2);
95 else
96 m_mode->SetSelection(0);
97 };
98 }
99 else
100 m_mode->SetSelection(0);
101 m_option_c->SetValue(parser.Found("c"));
102 long i;
103 if(parser.Found("i",&i))
104 m_khan_iter->SetValue(i);
105 else
106 m_khan_iter->SetValue(4);
107 if(parser.Found("s",&param))
108 {
109 //change locale for correct numeric output
110 char * p = setlocale(LC_NUMERIC,NULL);
111 char * old_locale = strdup(p);
113 double sigma=0.0;
114 param.ToDouble(&sigma);
115 //reset locale
118 //using current locale for value in GUI
119 m_khan_sigma->SetValue(wxString::Format("%.2f",sigma));
120 }
121 else
122 m_khan_sigma->SetValue("30");
123 if(parser.Found("a",&param))
124 {
125 m_option_khan_af->SetValue(param.Contains("f"));
126 m_option_khan_ag->SetValue(param.Contains("g"));
127 m_option_khan_am->SetValue(param.Contains("m"));
128 }
129 wxCommandEvent dummy;
131};
132
134{
135 int selection=m_mode->GetSelection();
136 m_cmd.Clear();
137 bool correct_input=true;
138 double i = 0;
139 wxString errorstring(_("Invalid input\n"));
140 switch(selection)
141 {
142 case 0:
143 m_cmd.Append("-m avg");
144 if(m_option_c->IsChecked())
145 m_cmd.Append(" -c");
146 break;
147 case 1:
148 m_cmd.Append("-m avg_slow");
149 break;
150 case 2:
151 m_cmd.Append("-m khan");
152 if(m_khan_iter->GetValue())
153 {
154 m_cmd.Append(wxString::Format(" -i %d",m_khan_iter->GetValue()));
155 }
156 else
157 {
158 correct_input=false;
159 errorstring.Append(wxString::Format(_("Input \"%s\" for %s is not a valid number\n"),
160 m_khan_iter->GetValue(),_("Iteration")));
161 };
162 if(m_khan_sigma->GetValue().ToDouble(&i))
163 {
164 //change locale for correct numeric output
165 char * p = setlocale(LC_NUMERIC,NULL);
166 char * old_locale = strdup(p);
168 m_cmd.Append(wxString::Format(" -s %f",i));
169 //reset locale
172 }
173 else
174 {
175 correct_input=false;
176 errorstring.Append(wxString::Format(_("Input \"%s\" for %s is not a valid number\n"),
177 m_khan_iter->GetValue(),_("Sigma")));
178 };
179 if(m_option_khan_af->IsChecked() || m_option_khan_ag->IsChecked() ||
180 m_option_khan_am->IsChecked())
181 {
182 m_cmd.Append(" -a ");
183 if(m_option_khan_af->IsChecked())
184 m_cmd.Append("f");
185 if(m_option_khan_ag->IsChecked())
186 m_cmd.Append("g");
187 if(m_option_khan_am->IsChecked())
188 m_cmd.Append("m");
189 }
190 break;
191 };
192 if(!correct_input)
194 return correct_input;
195};
196
198{
199 int selection=m_mode->GetSelection();
200 m_panel_avg->Show(selection==0);
201 m_panel_avgslow->Show(selection==1);
202 m_panel_khan->Show(selection==2);
203 GetSizer()->Fit(this);
204};
205
206void HDRMergeOptionsDialog::OnOk(wxCommandEvent & e)
207{
209 this->EndModal(wxOK);
210};
211
Definition of dialog for hdrmerge options.
void OnOk(wxCommandEvent &e)
check inputs
HDRMergeOptionsDialog(wxWindow *parent)
Constructor, read from xrc ressource.
void SetCommandLineArgument(wxString cmd)
sets the currents state of the hdrmerge options
void OnModeChanged(wxCommandEvent &e)
event handler when user selected different mode, refresh advanced option display
#define HUGIN_HDRMERGE_ARGS
static double sigma
int HuginMessageBox(const wxString &message, const wxString &caption, int style, wxWindow *parent)
Definition wxutils.cpp:176
include file for the hugin project
include file for the hugin project
std::vector< deghosting::BImagePtr > threshold(const std::vector< deghosting::FImagePtr > &inputImages, const double threshold, const uint16_t flags)
Threshold function used for creating alpha masks for images.
Definition threshold.h:41
platform/compiler specific stuff.