00001
00002
00027 #include "ProjectArray.h"
00028 #include <wx/arrimpl.cpp>
00029 #include "base_wx/huginConfig.h"
00030 #include <fstream>
00031
00032 using namespace std;
00033
00034 long Project::idGenerator=1;
00035
00036 Project::Project(wxString pth,wxString pfx, Project::Target newTarget)
00037 {
00038 id = Project::idGenerator;
00039 Project::idGenerator++;
00040 path = pth;
00041 prefix = pfx;
00042 wxFileName file(path);
00043 if(file.FileExists())
00044 {
00045 file.GetTimes(NULL,&modDate,NULL);
00046 }
00047 isAligned = true;
00048 options = ReadOptions(pth);
00049 skip = false;
00050 status = WAITING;
00051 target = newTarget;
00052 }
00053
00054 Project::Project(wxString command)
00055 {
00056 path = command;
00057 id = -Project::idGenerator;
00058 Project::idGenerator++;
00059 skip = false;
00060 isAligned = true;
00061 status = WAITING;
00062 target = STITCHING;
00063 }
00064
00065 wxString Project::GetStatusText()
00066 {
00067 switch(status)
00068 {
00069 case WAITING:
00070 return _("Waiting");
00071 case RUNNING:
00072 return _("In progress");
00073 case FINISHED:
00074 return _("Complete");
00075 case FAILED:
00076 return _("Failed");
00077 case MISSING:
00078 return _("File missing");
00079 case PAUSED:
00080 return _("Paused");
00081 default:
00082 return _T("");
00083 }
00084 }
00085
00086 PanoramaOptions Project::ReadOptions(wxString projectFile)
00087 {
00088 ifstream prjfile((const char*)projectFile.mb_str(HUGIN_CONV_FILENAME));
00089 if (prjfile.bad())
00090 {
00091 wxLogError( wxString::Format(_("could not open script : %s"), projectFile.c_str()) );
00092 }
00093
00094 wxString pathToPTO;
00095 wxFileName::SplitPath(projectFile, &pathToPTO, NULL, NULL);
00096 pathToPTO.Append(wxT("/"));
00097
00098 PT::Panorama pano;
00099 PT::PanoramaMemento newPano;
00100 int ptoVersion = 0;
00101 if (newPano.loadPTScript(prjfile, ptoVersion, (const char*)pathToPTO.mb_str(HUGIN_CONV_FILENAME)))
00102 {
00103 pano.setMemento(newPano);
00104 if (ptoVersion < 2)
00105 {
00106 HuginBase::PanoramaOptions opts = pano.getOptions();
00107
00108 opts.enblendOptions = wxConfigBase::Get()->Read(wxT("/Enblend/Args"), wxT("")).mb_str(wxConvLocal);
00109 opts.enfuseOptions = wxConfigBase::Get()->Read(wxT("/Enfuse/Args"), wxT("")).mb_str(wxConvLocal);
00110 pano.setOptions(opts);
00111 }
00112
00113 if(prefix.IsEmpty())
00114 {
00115 wxFileName prefixFilename(getDefaultOutputName(projectFile, pano));
00116 prefixFilename.Normalize();
00117 prefix=prefixFilename.GetFullPath();
00118 };
00119
00120
00121 if(pano.getNrOfImages()>1 && pano.getNrOfCtrlPoints()==0)
00122 {
00123 isAligned=false;
00124 };
00125 }
00126 else
00127 {
00128 wxLogError( wxString::Format(_("error while parsing panotools script: %s"), projectFile.c_str()) );
00129 }
00130
00131 PanoramaOptions opts = pano.getOptions();
00132 return opts;
00133 }
00134
00135 void Project::ResetOptions()
00136 {
00137 wxFileName file(path);
00138 if(file.FileExists())
00139 {
00140 file.GetTimes(NULL,&modDate,NULL);
00141 }
00142 options = ReadOptions(path);
00143 }
00144
00145 WX_DEFINE_OBJARRAY(ProjectArray);