details: http://hugin.hg.sourceforge.net/hgweb/hugin/hugin/hgrepo/h/hu/hugin/hugin/rev/c9a154eaa43a
changeset: 4237:c9a154eaa43a
user: tmodes
date: Tue Aug 24 20:23:28 2010 +0200
description:
Make hugin gui use new makefilelib
details: http://hugin.hg.sourceforge.net/hgweb/hugin/hugin/hgrepo/h/hu/hugin/hugin/rev/94ef9df0f4ea
changeset: 4238:94ef9df0f4ea
user: tmodes
date: Tue Aug 24 20:52:52 2010 +0200
description:
Make assistant batchable
diffstat:
src/hugin1/CMakeLists.txt | 1 +
src/hugin1/base_wx/MyExternalCmdExecDialog.cpp | 7 +-
src/hugin1/base_wx/MyExternalCmdExecDialog.h | 2 +-
src/hugin1/base_wx/RunStitchPanel.cpp | 138 +-
src/hugin1/base_wx/RunStitchPanel.h | 9 +-
src/hugin1/base_wx/huginConfig.cpp | 45 +
src/hugin1/base_wx/huginConfig.h | 7 +-
src/hugin1/hugin/AssistantPanel.cpp | 467 +--
src/hugin1/hugin/AssistantPanel.h | 1 +
src/hugin1/hugin/AutoCtrlPointCreator.cpp | 1118 -------
src/hugin1/hugin/AutoCtrlPointCreator.h | 193 -
src/hugin1/hugin/CMakeLists.txt | 8 +-
src/hugin1/hugin/CPDetectorConfig.cpp | 470 ---
src/hugin1/hugin/CPDetectorConfig.h | 201 -
src/hugin1/hugin/CPDetectorConfig_default.h | 97 -
src/hugin1/hugin/CPDetectorDialog.cpp | 284 +
src/hugin1/hugin/CPDetectorDialog.h | 88 +
src/hugin1/hugin/ImagesPanel.cpp | 2 +-
src/hugin1/hugin/ImagesPanel.h | 2 +-
src/hugin1/hugin/MainFrame.cpp | 2 +-
src/hugin1/hugin/PreferencesDialog.cpp | 1 +
src/hugin1/hugin/PreferencesDialog.h | 2 +-
src/hugin1/hugin/wxPanoCommand.cpp | 4 +
src/hugin1/hugin/wxPanoCommand.h | 6 +-
src/hugin1/hugin/xrc/assistant_panel.xrc | 26 +-
src/hugin1/hugin/xrc/batch_frame.xrc | 177 +-
src/hugin1/hugin/xrc/batch_menu.xrc | 6 +-
src/hugin1/icpfind/AutoCtrlPointCreator.cpp | 1119 +++++++
src/hugin1/icpfind/AutoCtrlPointCreator.h | 169 +
src/hugin1/icpfind/CMakeLists.txt | 24 +
src/hugin1/icpfind/CPDetectorConfig.cpp | 214 +
src/hugin1/icpfind/CPDetectorConfig.h | 146 +
src/hugin1/icpfind/CPDetectorConfig_default.h | 97 +
src/hugin1/icpfind/icpfind.cpp | 145 +
src/hugin1/icpfind/icpfind.h | 36 +
src/hugin1/ptbatcher/Batch.cpp | 72 +-
src/hugin1/ptbatcher/Batch.h | 5 +-
src/hugin1/ptbatcher/BatchFrame.cpp | 99 +-
src/hugin1/ptbatcher/BatchFrame.h | 3 +-
src/hugin1/ptbatcher/CMakeLists.txt | 105 +-
src/hugin1/ptbatcher/FindPanoDialog.cpp | 580 ++++
src/hugin1/ptbatcher/FindPanoDialog.h | 147 +
src/hugin1/ptbatcher/PTBatcherGUI.cpp | 180 +-
src/hugin1/ptbatcher/PTBatcherGUI.h | 1 -
src/hugin1/ptbatcher/ProjectArray.cpp | 4 +-
src/hugin1/ptbatcher/ProjectArray.h | 8 +-
src/hugin1/ptbatcher/ProjectListBox.cpp | 14 +-
src/hugin1/ptbatcher/ProjectListBox.h | 2 +
src/hugin1/ptbatcher/RunStitchFrame.cpp | 30 +-
src/hugin1/ptbatcher/RunStitchFrame.h | 6 +-
src/hugin1/stitch_project/hugin_stitch_project.cpp | 4 +-
src/hugin_base/CMakeLists.txt | 4 +-
src/hugin_base/algorithms/assistant_makefile/AssistantMakefilelibExport.cpp | 147 +
src/hugin_base/algorithms/assistant_makefile/AssistantMakefilelibExport.h | 138 +
src/hugin_base/algorithms/panorama_makefile/PanoramaMakefileExport.cpp | 982 ------
src/hugin_base/algorithms/panorama_makefile/PanoramaMakefileExport.h | 145 -
src/hugin_base/algorithms/panorama_makefile/PanoramaMakefilelibExport.cpp | 1435 +++++----
src/hugin_base/algorithms/panorama_makefile/PanoramaMakefilelibExport.h | 13 +-
src/hugin_base/makefilelib/CMakeLists.txt | 6 +-
src/hugin_base/makefilelib/Makefile.cpp | 4 +-
src/hugin_base/panodata/SrcPanoImage.h | 6 +-
src/tools/CMakeLists.txt | 5 +-
src/tools/checkpto.cpp | 85 +
src/tools/pano_modify.cpp | 841 ++--
src/tools/pto2mkold.cpp | 157 -
65 files changed, 5443 insertions(+), 5099 deletions(-)
diffs (truncated from 11672 to 500 lines):
diff -r 6a1e77698314 -r 94ef9df0f4ea src/hugin1/CMakeLists.txt
--- a/src/hugin1/CMakeLists.txt Sun Aug 15 21:59:19 2010 +0200
+++ b/src/hugin1/CMakeLists.txt Tue Aug 24 20:52:52 2010 +0200
@@ -14,6 +14,7 @@
add_subdirectory(base_wx)
add_subdirectory(stitch_project)
+ add_subdirectory(icpfind)
# build Hugin only if OpenGL was found
IF(OPENGL_FOUND)
add_subdirectory(hugin)
diff -r 6a1e77698314 -r 94ef9df0f4ea src/hugin1/base_wx/MyExternalCmdExecDialog.cpp
--- a/src/hugin1/base_wx/MyExternalCmdExecDialog.cpp Sun Aug 15 21:59:19 2010 +0200
+++ b/src/hugin1/base_wx/MyExternalCmdExecDialog.cpp Tue Aug 24 20:52:52 2010 +0200
@@ -642,9 +642,12 @@
}
int MyExecuteCommandOnDialog(wxString command, wxString args, wxWindow* parent,
- wxString title)
+ wxString title, bool isQuoted)
{
- command = utils::wxQuoteFilename(command);
+ if(!isQuoted)
+ {
+ command = utils::wxQuoteFilename(command);
+ };
wxString cmdline = command + wxT(" ") + args;
MyExecDialog dlg(parent, title,
wxDefaultPosition, wxSize(640, 400));
diff -r 6a1e77698314 -r 94ef9df0f4ea src/hugin1/base_wx/MyExternalCmdExecDialog.h
--- a/src/hugin1/base_wx/MyExternalCmdExecDialog.h Sun Aug 15 21:59:19 2010 +0200
+++ b/src/hugin1/base_wx/MyExternalCmdExecDialog.h Tue Aug 24 20:52:52 2010 +0200
@@ -33,7 +33,7 @@
class MyExternalCmdExecDialog;
class HuginPipedProcess;
-WXIMPEX int MyExecuteCommandOnDialog(wxString command, wxString args, wxWindow* parent, wxString title);
+WXIMPEX int MyExecuteCommandOnDialog(wxString command, wxString args, wxWindow* parent, wxString title, bool isQuoted=false);
//#define HUGIN_EXEC_LISTBOX 1
diff -r 6a1e77698314 -r 94ef9df0f4ea src/hugin1/base_wx/RunStitchPanel.cpp
--- a/src/hugin1/base_wx/RunStitchPanel.cpp Sun Aug 15 21:59:19 2010 +0200
+++ b/src/hugin1/base_wx/RunStitchPanel.cpp Tue Aug 24 20:52:52 2010 +0200
@@ -98,9 +98,36 @@
// topsizer->SetSizeHints( this ); // set size hints to honour minimum size
}
+wxString getGNUMakeCmd(const wxString &args)
+{
+#if defined __WXMAC__ && defined MAC_SELF_CONTAINED_BUNDLE
+ wxString cmd = MacGetPathToBundledExecutableFile(CFSTR("gnumake"));
+ if(cmd != wxT(""))
+ {
+ cmd = wxQuoteString(cmd);
+ }
+ else
+ {
+ wxMessageBox(wxString::Format(_("External program %s not found in the bundle, reverting to system path"), wxT("gnumake")), _("Error"));
+ cmd = wxT("make");
+ }
+ cmd += wxT(" ") + args;
+#elif defined __FreeBSD__
+ wxString cmd = wxT("gmake ") + args;
+#elif defined __WXMSW__
+ wxString cmdExe;
+ if(!wxGetEnv(wxT("ComSpec"),&cmdExe))
+ cmdExe=wxT("cmd");
+ wxString cmd = cmdExe + wxString::Format(wxT(" /C \"chcp %d >NUL && "),GetACP())+
+ wxT("\"") + getExePath(wxTheApp->argv[0])+wxT("\\make\" ") + args + wxT("\"");
+#else
+ wxString cmd = wxT("make ") + args;
+#endif
+ return cmd;
+};
bool RunStitchPanel::StitchProject(wxString scriptFile, wxString outname,
- HuginBase::PanoramaMakefileExport::PTPrograms progs)
+ HuginBase::PanoramaMakefilelibExport::PTPrograms progs)
{
DEBUG_TRACE("");
wxFileName fname(scriptFile);
@@ -203,7 +230,7 @@
std::string tmpDir((wxConfigBase::Get()->Read(wxT("tempDir"),wxT(""))).mb_str(HUGIN_CONV_FILENAME));
std::vector<std::string> outputFiles;
- HuginBase::PanoramaMakefileExport::createMakefile(pano,
+ HuginBase::PanoramaMakefilelibExport::createMakefile(pano,
activeImgs,
tmpPTOfnC,
resultFn,
@@ -243,26 +270,7 @@
wxString caption = wxString::Format(_("Stitching %s"), scriptFile.c_str());
-#if defined __WXMAC__ && defined MAC_SELF_CONTAINED_BUNDLE
- wxString cmd = MacGetPathToBundledExecutableFile(CFSTR("gnumake"));
- if(cmd != wxT("")) {
- cmd = wxQuoteString(cmd);
- } else {
- wxMessageBox(wxString::Format(_("External program %s not found in the bundle, reverting to system path"), wxT("gnumake")), _("Error"));
- cmd = wxT("make");
- }
- cmd += wxT(" ") + args;
-#elif defined __FreeBSD__
- wxString cmd = wxT("gmake ") + args;
-#elif defined __WXMSW__
- wxString cmdExe;
- if(!wxGetEnv(wxT("ComSpec"),&cmdExe))
- cmdExe=wxT("cmd");
- wxString cmd = cmdExe + wxString::Format(wxT(" /C \"chcp %d >NUL && "),GetACP())+
- wxT("\"") + getExePath(wxTheApp->argv[0])+wxT("\\make\" ") + args + wxT("\"");
-#else
- wxString cmd = wxT("make ") + args;
-#endif
+ wxString cmd=getGNUMakeCmd(args);
if (m_execPanel->ExecWithRedirect(cmd) == -1) {
wxMessageBox(wxString::Format(_("Error while stitching project\n%s"), cmd.c_str()),
_("Error during stitching"), wxICON_ERROR | wxOK );
@@ -276,6 +284,86 @@
return true;
}
+bool RunStitchPanel::DetectProject(wxString scriptFile,
+ HuginBase::AssistantMakefilelibExport::AssistantPrograms progs)
+{
+ m_currentPTOfn=wxEmptyString;
+ wxFileName fname(scriptFile);
+ if ( !fname.FileExists() ) {
+ wxLogError( _("Could not open project file:") + scriptFile);
+ return false;
+ }
+
+ //read project file
+ ifstream prjfile((const char *)scriptFile.mb_str(HUGIN_CONV_FILENAME));
+ if (prjfile.bad())
+ {
+ wxLogError( wxString::Format(_("could not open script : %s"), scriptFile.c_str()));
+ return false;
+ }
+ PT::Panorama pano;
+ PT::PanoramaMemento newPano;
+ int ptoVersion = 0;
+ if (!newPano.loadPTScript(prjfile, ptoVersion))
+ {
+ wxLogError(wxString::Format(_("error while parsing panotools script: %s"), scriptFile.c_str()));
+ return false;
+ }
+ pano.setMemento(newPano);
+
+ //read settings
+ wxConfig config(wxT("hugin"));
+ bool runCeleste=config.Read(wxT("/Celeste/Auto"), HUGIN_CELESTE_AUTO)!=0;
+ double celesteThreshold;
+ config.Read(wxT("/Celeste/Threshold"), &celesteThreshold, HUGIN_CELESTE_THRESHOLD);
+ bool celesteSmall=config.Read(wxT("/Celeste/Filter"), HUGIN_CELESTE_FILTER)!=0;
+ bool runCPClean=config.Read(wxT("/Assistant/AutoCPClean"), HUGIN_ASS_AUTO_CPCLEAN)!=0;
+ double scale;
+ config.Read(wxT("/Assistant/panoDownsizeFactor"), &scale, HUGIN_ASS_PANO_DOWNSIZE_FACTOR);
+ int scalei=roundi(scale*100);
+ wxString tempDir= config.Read(wxT("tempDir"),wxT(""));
+ if(!tempDir.IsEmpty())
+ if(tempDir.Last()!=wxFileName::GetPathSeparator())
+ tempDir.Append(wxFileName::GetPathSeparator());
+
+ try {
+ //generate makefile
+ m_currentMakefn=wxFileName::CreateTempFileName(tempDir+wxT("ham"));
+ if(m_currentMakefn.size() == 0)
+ {
+ wxLogError(_("Could not create temporary file"));
+ return false;
+ }
+ std::ofstream makefile(m_currentMakefn.mb_str(HUGIN_CONV_FILENAME));
+ makefile.exceptions( std::ofstream::eofbit | std::ofstream::failbit | std::ofstream::badbit );
+ std::string scriptString(scriptFile.mb_str(HUGIN_CONV_FILENAME));
+ HuginBase::AssistantMakefilelibExport::createMakefile(pano,progs,runCeleste,celesteThreshold,celesteSmall,
+ runCPClean,scale,makefile,scriptString);
+ makefile.close();
+
+ //execute makefile
+ wxString args = wxT("-f ") + wxQuoteFilename(m_currentMakefn) + wxT(" all");
+ wxString cmd=getGNUMakeCmd(args);
+ wxFileName path(scriptFile);
+ path.MakeAbsolute();
+ wxString oldcwd=path.GetCwd();
+ path.SetCwd();
+ if (m_execPanel->ExecWithRedirect(cmd) == -1)
+ {
+ wxMessageBox(wxString::Format(_("Error while running assistant\n%s"), cmd.c_str()),
+ _("Error during running assistant"), wxICON_ERROR | wxOK );
+ }
+ wxFileName::SetCwd(oldcwd);
+ }
+ catch (std::exception & e)
+ {
+ cerr << "caught exception: " << e.what() << std::endl;
+ wxMessageBox(wxString(e.what(), wxConvLocal),
+ _("Error during running assistant"), wxICON_ERROR | wxOK );
+ }
+ return true;
+}
+
void RunStitchPanel::OnProcessTerminate(wxProcessEvent & event)
{
DEBUG_TRACE("");
@@ -283,8 +371,14 @@
//{
// delete temporary files
#ifndef DEBUG
+ if(!m_currentMakefn.IsEmpty())
+ {
wxRemoveFile(m_currentMakefn);
+ };
+ if(!m_currentPTOfn.IsEmpty())
+ {
wxRemoveFile(m_currentPTOfn);
+ };
#endif
// notify parent of exit
if (this->GetParent()) {
diff -r 6a1e77698314 -r 94ef9df0f4ea src/hugin1/base_wx/RunStitchPanel.h
--- a/src/hugin1/base_wx/RunStitchPanel.h Sun Aug 15 21:59:19 2010 +0200
+++ b/src/hugin1/base_wx/RunStitchPanel.h Tue Aug 24 20:52:52 2010 +0200
@@ -36,7 +36,8 @@
#include <PT/Panorama.h>
-#include <algorithms/panorama_makefile/PanoramaMakefileExport.h>
+#include <algorithms/panorama_makefile/PanoramaMakefilelibExport.h>
+#include <algorithms/assistant_makefile/AssistantMakefilelibExport.h>
#include "MyExternalCmdExecDialog.h"
@@ -54,13 +55,17 @@
bool error;
};
+WXIMPEX wxString getGNUMakeCmd(const wxString& args);
+
class WXIMPEX RunStitchPanel: public wxPanel
{
public:
RunStitchPanel(wxWindow * parent);
bool StitchProject(wxString scriptFile, wxString outname,
- HuginBase::PanoramaMakefileExport::PTPrograms progs);
+ HuginBase::PanoramaMakefilelibExport::PTPrograms progs);
+ bool DetectProject(wxString scriptFile,
+ HuginBase::AssistantMakefilelibExport::AssistantPrograms progs);
void CancelStitch();
bool IsPaused();
void SetOverwrite(bool over = true);
diff -r 6a1e77698314 -r 94ef9df0f4ea src/hugin1/base_wx/huginConfig.cpp
--- a/src/hugin1/base_wx/huginConfig.cpp Sun Aug 15 21:59:19 2010 +0200
+++ b/src/hugin1/base_wx/huginConfig.cpp Tue Aug 24 20:52:52 2010 +0200
@@ -202,6 +202,51 @@
return progs;
}
+AssistantPrograms getAssistantProgramsConfig(wxString bundledBinDir, wxConfigBase * config)
+{
+ AssistantPrograms progs;
+
+ wxString bindir;
+#ifndef __WXGTK__
+ // add trailing directory separator, if needed
+ wxFileName bindirFN = wxFileName::DirName(bundledBinDir);
+ bindir = bindirFN.GetPath();
+#endif
+
+ try {
+ progs.icpfind = getProgram(config,bindir, wxT("icpfind"), wxT("icpfind"));
+ } catch (wxString s) {
+ wxMessageBox(s, _("Warning"));
+ }
+ try {
+ progs.celeste= getProgram(config,bindir, wxT("celeste_standalone"), wxT("celeste_standalone"));
+ } catch (wxString s) {
+ wxMessageBox(s, _("Warning"));
+ }
+
+ try {
+ progs.cpclean = getProgram(config,bindir, wxT("cpclean"), wxT("cpclean"));
+ } catch (wxString s) {
+ wxMessageBox(s, _("Warning"));
+ }
+ try {
+ progs.autooptimiser= getProgram(config,bindir, wxT("autooptimiser"), wxT("autooptimiser"));
+ } catch (wxString s) {
+ wxMessageBox(s, _("Warning"));
+ }
+ try {
+ progs.pano_modify= getProgram(config,bindir, wxT("pano_modify"), wxT("pano_modify"));
+ } catch (wxString s) {
+ wxMessageBox(s, _("Warning"));
+ }
+ try {
+ progs.checkpto= getProgram(config,bindir, wxT("checkpto"), wxT("checkpto"));
+ } catch (wxString s) {
+ wxMessageBox(s, _("Warning"));
+ }
+ return progs;
+}
+
wxString getExePath(wxString argv0)
{
wxString huginPath;
diff -r 6a1e77698314 -r 94ef9df0f4ea src/hugin1/base_wx/huginConfig.h
--- a/src/hugin1/base_wx/huginConfig.h Sun Aug 15 21:59:19 2010 +0200
+++ b/src/hugin1/base_wx/huginConfig.h Tue Aug 24 20:52:52 2010 +0200
@@ -31,13 +31,16 @@
#include <panoinc_WX.h>
#include "PT/Panorama.h"
-#include <algorithms/panorama_makefile/PanoramaMakefileExport.h>
+#include <algorithms/panorama_makefile/PanoramaMakefilelibExport.h>
+#include <algorithms/assistant_makefile/AssistantMakefilelibExport.h>
namespace PT {
-struct PTPrograms : public HuginBase::PanoramaMakefileExport::PTPrograms {};
+struct PTPrograms : public HuginBase::PanoramaMakefilelibExport::PTPrograms {};
+struct AssistantPrograms : public HuginBase::AssistantMakefilelibExport::AssistantPrograms {};
}
WXIMPEX PT::PTPrograms getPTProgramsConfig(wxString huginRoot, wxConfigBase * config);
+WXIMPEX PT::AssistantPrograms getAssistantProgramsConfig(wxString huginRoot, wxConfigBase * config);
/** get the path to the directory where the currently running executable is
* stored.
diff -r 6a1e77698314 -r 94ef9df0f4ea src/hugin1/hugin/AssistantPanel.cpp
--- a/src/hugin1/hugin/AssistantPanel.cpp Sun Aug 15 21:59:19 2010 +0200
+++ b/src/hugin1/hugin/AssistantPanel.cpp Tue Aug 24 20:52:52 2010 +0200
@@ -6,8 +6,6 @@
*
* @author Pablo d'Angelo <pablo.dangelo@...>
*
- * $Id$
- *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
@@ -29,47 +27,25 @@
#include "panoinc.h"
#include "base_wx/platform.h"
+#include "base_wx/huginConfig.h"
-#include "common/stl_utils.h"
-
-#include <map>
-
-//#include <vigra_ext/PointMatching.h>
-//#include <vigra_ext/LoweSIFT.h>
-
-#include <PT/RandomPointSampler.h>
-#include <PT/PhotometricOptimizer.h>
-#include <PT/PTOptimise.h>
-
+#include "PT/ImageGraph.h"
#include "common/wxPlatform.h"
#include "hugin/AssistantPanel.h"
#include "hugin/CommandHistory.h"
-#include "base_wx/ImageCache.h"
+#include "base_wx/RunStitchPanel.h"
#include "hugin/ImagesList.h"
#include "hugin/LensPanel.h"
#include "hugin/MainFrame.h"
#include "hugin/huginApp.h"
-#include "hugin/AutoCtrlPointCreator.h"
#include "hugin/TextKillFocusHandler.h"
-#include "base_wx/PTWXDlg.h"
-#include "base_wx/MyProgressDialog.h"
#include "hugin/HFOVDialog.h"
#include "hugin/config_defaults.h"
-#include <algorithms/control_points/CleanCP.h>
+#include "hugin/wxPanoCommand.h"
-// Celeste header
-#include "Celeste.h"
-#include "CelesteGlobals.h"
-#include "Utilities.h"
-
-using namespace PT;
-using namespace PTools;
using namespace utils;
-using namespace vigra;
-using namespace vigra_ext;
using namespace std;
-
//------------------------------------------------------------------------------
// utility function
static wxString Components2Str(const CPComponents & comp)
@@ -110,6 +86,7 @@
EVT_BUTTON ( XRCID("ass_load_images_button"), AssistantPanel::OnLoadImages)
EVT_BUTTON ( XRCID("ass_align_button"), AssistantPanel::OnAlign)
EVT_BUTTON ( XRCID("ass_create_button"), AssistantPanel::OnCreate)
+ EVT_BUTTON ( XRCID("ass_align_batch_button"), AssistantPanel::OnAlignSendToBatch)
END_EVENT_TABLE()
@@ -369,173 +346,68 @@
void AssistantPanel::OnAlign( wxCommandEvent & e )
{
- // create control points
- // all images..
- UIntSet imgs;
if (m_pano->getNrOfImages() < 2) {
wxMessageBox(_("At least two images are required.\nPlease add more images."),_("Error"), wxOK, this);
return;
}
- fill_set(imgs, 0, m_pano->getNrOfImages()-1);
+ //generate list of all necessary programs with full path
+ wxString bindir = huginApp::Get()->GetUtilsBinDir();
+ wxConfigBase* config=wxConfigBase::Get();
+ AssistantPrograms progs = getAssistantProgramsConfig(bindir, config);
- long nFeatures = wxConfigBase::Get()->Read(wxT("/Assistant/nControlPoints"), HUGIN_ASS_NCONTROLPOINTS);
+ //read main settings
+ bool runCeleste=config->Read(wxT("/Celeste/Auto"), HUGIN_CELESTE_AUTO)!=0;
+ double celesteThreshold;
+ config->Read(wxT("/Celeste/Threshold"), &celesteThreshold, HUGIN_CELESTE_THRESHOLD);
+ bool celesteSmall=config->Read(wxT("/Celeste/Filter"), HUGIN_CELESTE_FILTER)!=0;
+ bool runCPClean=config->Read(wxT("/Assistant/AutoCPClean"), HUGIN_ASS_AUTO_CPCLEAN)!=0;
+ double scale;
+ config->Read(wxT("/Assistant/panoDownsizeFactor"), &scale, HUGIN_ASS_PANO_DOWNSIZE_FACTOR);
+ int scalei=roundi(scale*100);
- /*
- bool createCtrlP = true;
- // TODO: handle existing control points properly instead of adding them twice.
- if (m_pano->getNrOfCtrlPoints() > 0) {
- int a = wxMessageBox(wxString::Format(_("The panorama already has %d control points.\n\nSkip control points creation?"), m_pano->getNrOfCtrlPoints()),
- _("Skip control point creation?"), wxICON_QUESTION | wxYES_NO);
- createCtrlP = a != wxYES;
- }
- */
+ //save project into temp directory
+ wxString tempDir= config->Read(wxT("tempDir"),wxT(""));
+ if(!tempDir.IsEmpty())
+ if(tempDir.Last()!=wxFileName::GetPathSeparator())
+ tempDir.Append(wxFileName::GetPathSeparator());
+ wxString scriptName=wxFileName::CreateTempFileName(tempDir+wxT("ha"));
+ std::ofstream script(scriptName.mb_str(HUGIN_CONV_FILENAME));
+ script.exceptions ( std::ofstream::eofbit | std::ofstream::failbit | std::ofstream::badbit );
+ PT::UIntSet all;
+ fill_set(all, 0, m_pano->getNrOfImages()-1);
+ m_pano->printPanoramaScript(script, m_pano->getOptimizeVector(), m_pano->getOptions(), all, false);
+ script.close();
+ //generate makefile
+ wxString makefileName=wxFileName::CreateTempFileName(tempDir+wxT("ham"));
+ std::ofstream makefile(makefileName.mb_str(HUGIN_CONV_FILENAME));
+ makefile.exceptions( std::ofstream::eofbit | std::ofstream::failbit | std::ofstream::badbit );
+ std::string scriptString(scriptName.mb_str(HUGIN_CONV_FILENAME));
+ HuginBase::AssistantMakefilelibExport::createMakefile(*m_pano,progs,runCeleste,celesteThreshold,celesteSmall,
+ runCPClean,scale,makefile,scriptString);
+ makefile.close();
- bool createCtrlP = m_pano->getNrOfCtrlPoints() == 0;
+ //execute makefile
+ wxString args = wxT("-f ") + wxQuoteFilename(makefileName) + wxT(" all");
+ int ret=MyExecuteCommandOnDialog(getGNUMakeCmd(args),wxEmptyString,this,_("Running assistant"),true);
- ProgressReporterDialog progress(6, _("Aligning images"), _("Finding corresponding points"),this);
- wxString alignMsg;
- if (createCtrlP) {
- AutoCtrlPointCreator matcher;
- CPVector cps = matcher.automatch(MainFrame::Get()->GetDefaultSetting(),*m_pano, imgs, nFeatures,this);
- GlobalCmdHist::getInstance().addCommand(
- new PT::AddCtrlPointsCmd(*m_pano, cps)
- );
- }
+ //read back panofile
+ GlobalCmdHist::getInstance().addCommand(new wxLoadPTProjectCmd(*m_pano,
+ (const char *)scriptName.mb_str(HUGIN_CONV_FILENAME),"",ret==0));
- // Run Celeste
- bool t = (wxConfigBase::Get()->Read(wxT("/Celeste/Auto"), HUGIN_CELESTE_AUTO) != 0);
- if (t && createCtrlP && m_pano->getNrOfCtrlPoints())
+ //delete temporary files
+ wxRemoveFile(scriptName);
+ wxRemoveFile(makefileName);
+ //if return value is non-zero, an error occured in assistant makefile
+ if(ret!=0)
{
-
- DEBUG_TRACE("Running Celeste");
- progress.increaseProgress(1, std::wstring(wxString(_("Running Celeste")).wc_str(wxConvLocal)));
-
- // determine file name of SVM model file
- // get XRC path from application
- wxString wxstrModelFileName = huginApp::Get()->GetDataPath() + wxT(HUGIN_CELESTE_MODEL);
- // convert wxString to string
- string strModelFileName(wxstrModelFileName.mb_str(wxConvUTF8));
-
- // SVM model file
- if ( wxFile::Exists(wxstrModelFileName) )
|