27 #include <wx/config.h>
28 #include <wx/translation.h>
29 #include <wx/fileconf.h>
30 #include <wx/wfstream.h>
45 wxConfigBase* config = wxConfigBase::Get();
47 double celesteThreshold;
54 bool hasUserDefinedOutputIni = (config->Read(
"/Assistant/UserDefinedOutputOption", 0l) == 1l);
55 if (hasUserDefinedOutputIni)
59 hasUserDefinedOutputIni = iniFilename.FileExists();
75 wxT(
"-o ") + quotedProject + wxT(
" ") + quotedProject, _(
"Searching for control points...")));
81 if (celesteSmallRadius)
83 args.Append(wxT(
"-r 1 "));
85 args.Append(wxT(
"-o ") + quotedProject + wxT(
" ") + quotedProject);
87 args, _(
"Removing control points in clouds...")));
93 wxT(
"-o ") + quotedProject + wxT(
" ") + quotedProject, _(
"Statistically cleaning of control points...")));
100 bool hasVerticalLines =
false;
103 for (
size_t i = 0; i < allCP.size() && !hasVerticalLines; i++)
108 if (!hasVerticalLines)
111 wxT(
"--output=") + quotedProject + wxT(
" ") + quotedProject, _(
"Searching for vertical lines...")));
119 (hasUserDefinedOutputIni ? wxT(
"-a -o ") : wxT(
"-a -s -o ")) + quotedProject + wxT(
" ") + quotedProject, _(
"Optimizing...")));
124 (hasUserDefinedOutputIni ? wxT(
"-a -m -l -o ") : wxT(
"-a -m -l -s -o ")) + quotedProject + wxT(
" ") + quotedProject, _(
"Optimizing...")));
126 wxString panoModifyArgs;
127 wxString label(_(
"Searching for best crop..."));
128 if(hasUserDefinedOutputIni)
131 panoModifyArgs << wxT(
"--ini=") <<
wxEscapeFilename(iniFilename.GetFullPath()) << wxT(
" ");
132 label = wxString::Format(
"Setting options from %s", iniFilename.GetFullName().c_str());
141 panoModifyArgs.Append(wxT(
"--crop=AUTO "));
143 panoModifyArgs.Append(wxT(
"--output=") + quotedProject + wxT(
" ") + quotedProject);
155 errStream <<
"ERROR: Project contains no images. Nothing to do." << std::endl;
159 wxFileInputStream input(assistantSetting);
162 errStream <<
"ERROR: Can not open file \"" << assistantSetting.mb_str(wxConvLocal) <<
"\"." << std::endl;
165 wxFileConfig settings(input);
167 settings.Read(wxT(
"/General/StepCount"), &stepCount, 0);
170 errStream <<
"ERROR: User-setting does not define any assistant steps." << std::endl;
175 bool isConnected =
false;
176 bool hasVerticalLines =
false;
186 for (
size_t i = 0; i < allCP.size() && !hasVerticalLines; i++)
192 wxString imageListFile;
194 for (
size_t i = 0; i < stepCount; ++i)
196 wxString stepString(wxT(
"/Step"));
198 if (!settings.HasGroup(stepString))
200 errStream <<
"ERROR: Assistant specifies " << stepCount <<
" steps, but step " << i <<
" is missing in configuration." << std::endl;
204 settings.SetPath(stepString);
207 if (condition.CmpNoCase(
"no cp") == 0 && hascp)
211 if (condition.CmpNoCase(
"not connected") == 0 && isConnected)
215 if (condition.CmpNoCase(
"no line cp") == 0 && hasVerticalLines)
219 if (condition.CmpNoCase(
"single image") == 0 && pano.
getNrOfImages() != 1)
225 if (progName.IsEmpty())
227 errStream <<
"ERROR: Step " << i <<
" has no program name specified." << std::endl;
234 #elif defined __WXMSW__
236 const wxString prog = MSWGetProgname(ExePath, progName);
238 const wxString prog = progName;
243 errStream <<
"ERROR: Step " << i <<
" has no arguments given." << std::endl;
247 args.Replace(
"%project%", quotedProject,
true);
248 args.Replace(
"%image0%", quotedImage0,
true);
250 if (imageListFile.IsEmpty() && args.Find(
"%imagelist%") != wxNOT_FOUND)
252 wxFileName tempImageList(wxFileName::CreateTempFileName(
GetConfigTempDir(wxConfig::Get()) + wxT(
"hi")));
253 imageListFile = tempImageList.GetFullPath();
254 tempFilesDelete.Add(imageListFile);
255 wxFFileOutputStream outputStream(imageListFile);
256 wxTextOutputStream outputFile(outputStream);
264 if (!imageListFile.IsEmpty())
269 commands->push_back(
new NormalCommand(prog, args, description));
const wxString GetSettingString(wxConfigBase *setting, const wxString &name, const wxString defaultValue)
read a string from setting and remove all whitespaces
normal command for queue, processing is stopped if an error occurred in program
const wxString GetConfigTempDir(const wxConfigBase *config)
return the temp dir from the preferences, ensure that it ends with path separator ...
bool IsConnected()
check if all images are connected
wxString GetInternalProgram(const wxString &bindir, const wxString &name)
return path and name of external program, which comes bundled with Hugin
std::size_t getNrOfCtrlPoints() const
number of control points
const CPVector & getCtrlPoints() const
get all control point of this Panorama
CommandQueue * GetAssistantCommandQueue(const HuginBase::Panorama &pano, const wxString &ExePath, const wxString &project)
generates the command queue for running the assistant
std::size_t getNrOfImages() const
number of images.
#define HUGIN_CELESTE_FILTER
#define HUGIN_CELESTE_THRESHOLD
evaluate x, points are on a vertical line
void CleanQueue(CommandQueue *queue)
clean the queue, delete all entries, but not the queue itself
#define HUGIN_ASS_LINEFIND
const wxString GetSettingStringTranslated(wxConfigBase *setting, const wxString &name, const wxString defaultValue)
read a translated string from settings and remove all whitespaces
str wxEscapeFilename(const str &arg)
special escaping routine for CommandQueues
std::string GetUserAppDataDir()
returns the directory for user specific Hugin settings, e.g.
#define HUGIN_ASS_PANO_DOWNSIZE_FACTOR
std::vector< ControlPoint > CPVector
#define HUGIN_ASS_AUTO_CPCLEAN
const SrcPanoImage & getImage(std::size_t nr) const
get a panorama image, counting starts with 0
CommandQueue * GetAssistantCommandQueueUserDefined(const HuginBase::Panorama &pano, const wxString &ExePath, const wxString &project, const wxString &assistantSetting, wxArrayString &tempFilesDelete, std::ostream &errStream)
generates the command queue for running the assistant
wxString GetExternalProgram(wxConfigBase *config, const wxString &bindir, const wxString &name)
return path and name of external program, which can be overwritten by the user
std::vector< NormalCommand * > CommandQueue
#define HUGIN_CELESTE_AUTO
wxString wxStringFromCDouble(double val, int precision)
convert double to wxString, it is always using a '.
create a CommandQueue for running the assistant using CLI tools
class to work with images graphs created from a HuginBase::Panorama class it creates a graph based on...