Hugin trunk 0.1
Loading...
Searching...
No Matches
CPDetectorDialog.cpp
Go to the documentation of this file.
1// -*- c-basic-offset: 4 -*-
2
12/* This is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public
14 * License as published by the Free Software Foundation; either
15 * version 2 of the License, or (at your option) any later version.
16 *
17 * This software is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * Lesser General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public
23 * License along with this software. If not, see
24 * <http://www.gnu.org/licenses/>.
25 *
26 */
27
28#ifdef _WIN32
29#include "wx/msw/wrapwin.h"
30 // Mingw define still DIFFERENCE, which conflicts with vigra, so disable it
31#undef DIFFERENCE
32#endif
34#include "hugin_config.h"
35#include "base_wx/huginConfig.h"
36#include "base_wx/wxutils.h"
38#include "hugin/huginApp.h"
39
40#if defined MAC_SELF_CONTAINED_BUNDLE
41 #include "base_wx/platform.h"
42 #include <wx/dir.h>
43 #include <CoreFoundation/CFBundle.h>
44#endif
45
46// dialog for showing settings of one autopano setting
48{
49 wxXmlResource::Get()->LoadDialog(this, parent, "cpdetector_dialog");
50
51 //restore frame position and size
52 hugin_utils::RestoreFramePosition(this,"CPDetectorDialog");
53
54 m_edit_desc = XRCCTRL(*this, "prefs_cpdetector_desc", wxTextCtrl);
55 m_edit_prog = XRCCTRL(*this, "prefs_cpdetector_program", wxTextCtrl);
56 m_edit_args = XRCCTRL(*this, "prefs_cpdetector_args", wxTextCtrl);
57 m_label_args_cleanup = XRCCTRL(*this, "prefs_cpdetector_args_label_cleanup", wxStaticText);
58 m_edit_args_cleanup = XRCCTRL(*this, "prefs_cpdetector_args_cleanup", wxTextCtrl);
59 m_edit_prog_descriptor = XRCCTRL(*this, "prefs_cpdetector_program_descriptor", wxTextCtrl);
60 m_edit_args_descriptor = XRCCTRL(*this, "prefs_cpdetector_args_descriptor", wxTextCtrl);
61 m_edit_prog_matcher = XRCCTRL(*this, "prefs_cpdetector_program_matcher", wxTextCtrl);
62 m_edit_args_matcher = XRCCTRL(*this, "prefs_cpdetector_args_matcher", wxTextCtrl);
63 m_edit_prog_stack = XRCCTRL(*this, "prefs_cpdetector_program_stack", wxTextCtrl);
64 m_edit_args_stack = XRCCTRL(*this, "prefs_cpdetector_args_stack", wxTextCtrl);
65 m_check_option = XRCCTRL(*this, "prefs_cpdetector_option", wxCheckBox);
66 m_cpdetector_type = XRCCTRL(*this, "prefs_cpdetector_type", wxChoice);
67 m_choice_step = XRCCTRL(*this, "choicebook_steps", wxChoicebook);
68 // enable auto completion
69 m_edit_prog->AutoCompleteFileNames();
70 m_edit_prog_descriptor->AutoCompleteFileNames();
71 m_edit_prog_matcher->AutoCompleteFileNames();
72 m_edit_prog_stack->AutoCompleteFileNames();
73 m_cpdetector_type->SetSelection(1);
74 ChangeType();
75 // bind events
78 Bind(wxEVT_BUTTON, &CPDetectorDialog::OnSelectPath, this, XRCID("prefs_cpdetector_program_select"));
79 Bind(wxEVT_BUTTON, &CPDetectorDialog::OnSelectPathDescriptor, this, XRCID("prefs_cpdetector_program_descriptor_select"));
80 Bind(wxEVT_BUTTON, &CPDetectorDialog::OnSelectPathMatcher, this, XRCID("prefs_cpdetector_program_matcher_select"));
81 Bind(wxEVT_BUTTON, &CPDetectorDialog::OnSelectPathStack, this, XRCID("prefs_cpdetector_program_stack_select"));
83};
84
89
90void CPDetectorDialog::OnOk(wxCommandEvent & e)
91{
92#ifdef __WXMAC__
93 if(m_cpdetector_type->GetSelection()==0)
94 {
95 hugin_utils::HuginMessageBox(_("Autopano from http://autopano.kolor.com is not available for OS X"),
96 _("Hugin"),wxOK|wxICON_EXCLAMATION, this);
97 m_cpdetector_type->SetSelection(1);
98 };
99#endif
100 bool valid=true;
101 valid=valid && (m_edit_desc->GetValue().Trim().Len()>0);
102 if(m_choice_step->GetSelection()==0)
103 {
104 //detector with one step
105 valid=valid && (m_edit_prog->GetValue().Trim().Len()>0);
106 valid=valid && (m_edit_args->GetValue().Trim().Len()>0);
107 }
108 else
109 {
110 //detector with two steps
111 valid=valid && (m_edit_prog_descriptor->GetValue().Trim().Len()>0);
112 valid=valid && (m_edit_prog_matcher->GetValue().Trim().Len()>0);
113 valid=valid && (m_edit_args_descriptor->GetValue().Trim().Len()>0);
114 valid=valid && (m_edit_args_matcher->GetValue().Trim().Len()>0);
115 };
117 if(m_edit_prog_stack->GetValue().Trim().Len()>0)
118 valid=valid && (m_edit_args_stack->GetValue().Trim().Len()>0);
119 if (valid)
120 this->EndModal(wxOK);
121 else
122 hugin_utils::HuginMessageBox(_("At least one input field is empty.\nPlease check your inputs."),
123 _("Hugin"), wxOK | wxICON_ERROR, this);
124};
125
127{
128 m_edit_desc->SetValue(cpdet_config->settings[index].GetCPDetectorDesc());
129 //program names and arguments
130 if(cpdet_config->settings[index].IsTwoStepDetector())
131 {
132 m_choice_step->SetSelection(1);
133 m_edit_prog_descriptor->SetValue(cpdet_config->settings[index].GetProg());
134 m_edit_prog_matcher->SetValue(cpdet_config->settings[index].GetProgMatcher());
135 m_edit_args_descriptor->SetValue(cpdet_config->settings[index].GetArgs());
136 m_edit_args_matcher->SetValue(cpdet_config->settings[index].GetArgsMatcher());
137 }
138 else
139 {
140 m_choice_step->SetSelection(0);
141 m_edit_prog->SetValue(cpdet_config->settings[index].GetProg());
142 m_edit_args->SetValue(cpdet_config->settings[index].GetArgs());
143 if(cpdet_config->settings[index].IsCleanupPossible())
144 {
145 m_edit_args_cleanup->SetValue(cpdet_config->settings[index].GetArgsCleanup());
146 };
147 };
148 if(cpdet_config->settings[index].ContainsStacks())
149 {
150 m_edit_prog_stack->SetValue(cpdet_config->settings[index].GetProgStack());
151 m_edit_args_stack->SetValue(cpdet_config->settings[index].GetArgsStack());
152 };
153 m_cpdetector_type->SetSelection(cpdet_config->settings[index].GetType());
154 m_check_option->SetValue(cpdet_config->settings[index].GetOption());
155 ChangeType();
156};
157
159{
160 cpdet_config->settings[index].SetCPDetectorDesc(m_edit_desc->GetValue().Trim());
161 cpdet_config->settings[index].SetType((CPDetectorType)m_cpdetector_type->GetSelection());
162 if(m_choice_step->GetSelection()==0)
163 {
164 cpdet_config->settings[index].SetProg(m_edit_prog->GetValue().Trim());
165 cpdet_config->settings[index].SetArgs(m_edit_args->GetValue().Trim());
166 if(cpdet_config->settings[index].IsCleanupPossible())
167 {
168 cpdet_config->settings[index].SetArgsCleanup(m_edit_args_cleanup->GetValue().Trim());
169 }
170 else
171 {
172 cpdet_config->settings[index].SetArgsCleanup(wxEmptyString);
173 };
174 }
175 else
176 {
177 cpdet_config->settings[index].SetProg(m_edit_prog_descriptor->GetValue().Trim());
178 cpdet_config->settings[index].SetArgs(m_edit_args_descriptor->GetValue().Trim());
179 cpdet_config->settings[index].SetProgMatcher(m_edit_prog_matcher->GetValue().Trim());
180 cpdet_config->settings[index].SetArgsMatcher(m_edit_args_matcher->GetValue().Trim());
181 };
182 if(cpdet_config->settings[index].ContainsStacks())
183 {
184 cpdet_config->settings[index].SetProgStack(m_edit_prog_stack->GetValue().Trim());
185 cpdet_config->settings[index].SetArgsStack(m_edit_args_stack->GetValue().Trim());
186 }
187 else
188 {
189 cpdet_config->settings[index].SetProgStack(wxEmptyString);
190 cpdet_config->settings[index].SetArgsStack(wxEmptyString);
191 }
192 cpdet_config->settings[index].SetOption(m_check_option->IsChecked());
193};
194
195void CPDetectorDialog::OnTypeChange(wxCommandEvent &e)
196{
197 ChangeType();
198};
199
201{
202 CPDetectorType type=(CPDetectorType)m_cpdetector_type->GetSelection();
203 if(type==CPDetector_AutoPano)
204 {
205 m_choice_step->SetSelection(0);
206 twoStepAllowed=false;
207 }
208 else
209 {
210 twoStepAllowed=true;
211 }
212 XRCCTRL(*this,"panel_stack",wxPanel)->Enable(CPDetectorSetting::ContainsStacks(type));
213 switch(type)
214 {
217 m_check_option->SetLabel(_("Try to connect all overlapping images."));
218 m_check_option->Enable(true);
219 m_check_option->Show(true);
220 XRCCTRL(*this, "prefs_cpdetector_no_option",wxStaticText)->Show(false);
221 break;
223 m_check_option->SetLabel(_("Only work on image pairs without control points."));
224 m_check_option->Enable(true);
225 m_check_option->Show(true);
226 XRCCTRL(*this, "prefs_cpdetector_no_option",wxStaticText)->Show(false);
227 break;
228 default:
229 XRCCTRL(*this, "prefs_cpdetector_no_option",wxStaticText)->Show(true);
230 m_check_option->Enable(false);
231 m_check_option->Show(false);
232 break;
233 };
234 m_check_option->GetParent()->Layout();
240 m_label_args_cleanup->GetParent()->Layout();
241 Layout();
242};
243
244
246{
248#ifdef MAC_SELF_CONTAINED_BUNDLE
250#endif
251 wxFileDialog dlg(this,_("Select control point detector program"),
254#else
255 executable.GetPath(),
256#endif
257 executable.GetFullName(),
259 _("Executables (*.exe,*.vbs,*.cmd, *.bat)|*.exe;*.vbs;*.cmd;*.bat"),
260#else
262#endif
264 if (dlg.ShowModal() == wxID_OK)
265 {
266 prog=dlg.GetPath();
267 return true;
268 }
269 else
270 return false;
271};
272
273void CPDetectorDialog::OnSelectPath(wxCommandEvent &e)
274{
275 wxString prog=m_edit_prog->GetValue();
276 if (ShowFileDialog(prog))
277 m_edit_prog->SetValue(prog);
278};
279
281{
282 wxString prog=m_edit_prog_descriptor->GetValue();
283 if (ShowFileDialog(prog))
284 m_edit_prog_descriptor->SetValue(prog);
285};
286
288{
289 wxString prog=m_edit_prog_matcher->GetValue();
290 if (ShowFileDialog(prog))
291 m_edit_prog_matcher->SetValue(prog);
292};
293
295{
296 wxString prog=m_edit_prog_stack->GetValue();
297 if (ShowFileDialog(prog))
298 m_edit_prog_stack->SetValue(prog);
299};
300
302{
303 if(!twoStepAllowed && e.GetOldSelection()==0)
304 {
305 wxBell();
306 e.Veto();
307 };
308};
CPDetectorType
@ CPDetector_AutoPanoSiftMultiRow
@ CPDetector_AutoPanoSiftMultiRowStack
@ CPDetector_AutoPanoSiftPreAlign
@ CPDetector_AutoPano
declaration of CPDetectorDialog class, which are for storing and changing settings of different autop...
class for storing settings of different control point generators
wxTextCtrl * m_edit_args_matcher
wxTextCtrl * m_edit_prog_descriptor
bool ShowFileDialog(wxString &prog)
shows file dialog
void OnSelectPathMatcher(wxCommandEvent &e)
select program for feature matcher with file open dialog
wxTextCtrl * m_edit_desc
void OnTypeChange(wxCommandEvent &e)
update dialog, when other cp detector type is changed
wxTextCtrl * m_edit_args_cleanup
virtual ~CPDetectorDialog()
destructor, saves position and size
void OnSelectPathDescriptor(wxCommandEvent &e)
select program for feature descriptor with file open dialog
wxStaticText * m_label_args_cleanup
wxChoice * m_cpdetector_type
void OnStepChanging(wxChoicebookEvent &e)
block selection of two step detector for autopano setting
void UpdateSettings(CPDetectorConfig *cpdet_config, int index)
return inputed settings
wxTextCtrl * m_edit_args
void OnSelectPath(wxCommandEvent &e)
select program with file open dialog
wxChoicebook * m_choice_step
wxTextCtrl * m_edit_args_stack
wxTextCtrl * m_edit_prog
void UpdateFields(CPDetectorConfig *cpdet_config, int index)
updates edit fields with values from settings
void OnOk(wxCommandEvent &e)
check inputs
wxCheckBox * m_check_option
wxTextCtrl * m_edit_prog_stack
CPDetectorDialog(wxWindow *parent)
constructor
wxTextCtrl * m_edit_prog_matcher
wxTextCtrl * m_edit_args_descriptor
void OnSelectPathStack(wxCommandEvent &e)
select program for stack with file open dialog
const bool IsCleanupPossible()
const bool ContainsStacks()
implementation of huginApp Class
functions for interaction with the hugin configuration file
int HuginMessageBox(const wxString &message, const wxString &caption, int style, wxWindow *parent)
Definition wxutils.cpp:176
void StoreFramePosition(wxTopLevelWindow *frame, const wxString &basename, const bool ignoreMaximize)
Definition wxutils.cpp:106
void RestoreFramePosition(wxTopLevelWindow *frame, const wxString &basename, const bool ignoreMaximize)
Definition wxutils.cpp:67
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