Hugin trunk 0.1
Loading...
Searching...
No Matches
CPDetectorConfig.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 <wx/fileconf.h>
36
40#ifdef _WIN32
42#else
44#endif
47
49{
50 settings.Clear();
51 int count=config->Read("/AutoPano/AutoPanoCount",0l);
52 default_generator=config->Read("/AutoPano/Default",0l);
53 if(count>0)
54 {
55 for(int i=0;i<count;i++)
57 };
58 if(settings.GetCount()==0)
59 {
60 if(loadFromFile.IsEmpty())
61 {
63 }
64 else
65 {
67 };
68 };
69 if(default_generator>=settings.GetCount())
71};
72
74{
75 if(wxFile::Exists(filename))
76 {
77 wxFileConfig fconfig("hugin",wxEmptyString,filename);
78 Read(&fconfig);
79 }
80 else
81 {
83 };
84};
85
87{
88 wxString path=wxString::Format("/AutoPano/AutoPano_%d",i);
89 if(config->HasGroup(path))
90 {
92 if(gen->Read(config,path))
93 {
94 settings.Add(gen);
96 {
97 default_generator=settings.Index(*gen,true);
98 };
99 };
100 };
101};
102
104{
105 int count=settings.Count();
106 config->Write("/AutoPano/AutoPanoCount",count);
107 config->Write("/AutoPano/Default",(int)default_generator);
108 if(count>0)
109 {
110 for(int i=0;i<count;i++)
112 };
113};
114
116{
117 wxFileConfig fconfig("hugin",wxEmptyString,filename);
118 Write(&fconfig);
119 fconfig.Flush();
120};
121
123{
124 wxString path=wxString::Format("/AutoPano/AutoPano_%d",i);
125 settings[i].Write(config,path);
126};
127
129{
130 settings.Clear();
131 settings.Add(new CPDetectorSetting());
133};
134
136{
137 control->Clear();
138 for(unsigned int i=0;i<settings.GetCount();i++)
139 {
140 wxString s=settings[i].GetCPDetectorDesc();
142 s=s+" ("+_("Default")+")";
143 control->Append(s);
144 };
146 control->SetSelection(default_generator);
147};
148
150{
151 CPDetectorSetting* setting=settings.Detach(index);
152 settings.Insert(setting,index+1);
153 if(default_generator==index)
154 default_generator=index+1;
155 else
156 if(default_generator==index+1)
157 default_generator=index;
158};
159
167
168#include <wx/arrimpl.cpp>
170
185
187{
189 {
190 if(!prog_matcher.IsEmpty())
191 {
194 };
195 };
196};
197
204
209
211{
212 if(!config->Exists(path))
213 {
214 return false;
215 }
217 desc=config->Read(path+"/Description",default_cpgenerator_desc);
218 prog=config->Read(path+"/Program",default_cpgenerator_prog);
219 args=config->Read(path+"/Arguments",default_cpgenerator_args);
221 {
222 args_cleanup=config->Read(path+"/ArgumentsCleanup",wxEmptyString);
223 }
224 else
225 {
227 };
228 prog_matcher=config->Read(path+"/ProgramMatcher",wxEmptyString);
229 args_matcher=config->Read(path+"/ArgumentsMatcher",wxEmptyString);
230 if(ContainsStacks())
231 {
232 prog_stack=config->Read(path+"/ProgramStack",wxEmptyString);
233 args_stack=config->Read(path+"/ArgumentsStack",wxEmptyString);
234 }
235 else
236 {
239 };
240 config->Read(path+"/Option",&option,true);
241 CheckValues();
242 return true;
243};
244
246{
247 config->Write(path+"/Type",int(type));
248 config->Write(path+"/Description",desc);
249 config->Write(path+"/Program",prog);
250 config->Write(path+"/Arguments",args);
251 config->Write(path+"/ProgramMatcher",prog_matcher);
252 config->Write(path+"/ArgumentsMatcher",args_matcher);
254 {
255 config->Write(path+"/ArgumentsCleanup",args_cleanup);
256 };
257 if(ContainsStacks())
258 {
259 config->Write(path+"/ProgramStack",prog_stack);
260 config->Write(path+"/ArgumentsStack",args_stack);
261 };
262 config->Write(path+"/Option",option);
263};
264
265
WX_DEFINE_OBJARRAY(ArraySettings)
wxString default_cpgenerator_prog("cpfind")
program name of default cp generator, for fall back procedure
wxString default_cpgenerator_args("-o %o %s")
arguments for default cp generator, for fall back procedure
wxString default_cpgenerator_desc("Hugin's Cpfind")
description of default cp generator, for fall back procedure
declaration of CPDetectorSetting and CPDetectorConfig classes, which are for storing and changing set...
CPDetectorType
@ CPDetector_AutoPanoSiftMultiRow
@ CPDetector_AutoPanoSiftStack
@ CPDetector_AutoPanoSiftMultiRowStack
@ CPDetector_AutoPanoSift
@ CPDetector_AutoPanoSiftPreAlign
@ CPDetector_AutoPano
unsigned int GetCount()
return counts of cp detector settings
void ReadIndex(wxConfigBase *config, int i)
unsigned int default_generator
void FillControl(wxControlWithItems *control, bool select_default=false, bool show_default=false)
fills a wxControlWithItems with the available generators
void Read(wxConfigBase *config=wxConfigBase::Get(), wxString loadFromFile=wxEmptyString)
read the settings of different cp generators from config
void ReadFromFile(wxString filename)
import the cp detector settings from external file
void Write(wxConfigBase *config=wxConfigBase::Get())
writes the settings of different cp generators to config
ArraySettings settings
array which stores the different autopano settings
void SetDefaultGenerator(unsigned int new_default_generator)
sets new default generator, which is used by assistent
void WriteToFile(wxString filename)
exporth the cp detector settings to external file
void ResetToDefault()
reset values to default
void Swap(int index)
swaps setting which index and index+1
void WriteIndex(wxConfigBase *config, int i)
class, which stores all settings of one cp detector
const bool IsCleanupPossible()
bool Read(wxConfigBase *config, wxString path)
read setting for this generator from config
void Write(wxConfigBase *config, wxString path)
writes setting for this generator to config
CPDetectorType type
const bool ContainsStacks()
CPDetectorSetting()
constructor
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