Batch.h

Go to the documentation of this file.
00001 // -*- c-basic-offset: 4 -*-
00002 
00027 #ifndef BATCH_H
00028 #define BATCH_H
00029 
00030 #include <string>
00031 #include "ProjectArray.h"
00032 #include <wx/dir.h>
00033 #ifndef __WXMSW__
00034 #include <sys/wait.h>
00035 #endif
00036 #include "RunStitchFrame.h"
00037 
00038 #ifndef FRAMEARRAY
00039 #define FRAMEARRAY
00040 WX_DEFINE_ARRAY_PTR(RunStitchFrame*,FrameArray);
00041 #endif
00042 
00043 using namespace std;
00044 
00045 struct FailedProject
00046 {
00047     wxString project;
00048     wxString logfile;
00049 };
00050 
00051 class Batch : public wxFrame
00052 {
00053 public:
00054     bool parallel;
00055     bool deleteFiles;
00056     bool shutdown;
00057     bool overwrite;
00058     bool verbose;
00059     bool autostitch;
00060     bool autoremove;
00061     bool saveLog;
00062     bool gui;
00063 
00065     Batch(wxFrame* parent, wxString path, bool bgui);
00066 
00068     void  AddAppToBatch(wxString app);
00070     void  AddProjectToBatch(wxString projectFile, wxString outputFile = _T(""), Project::Target target=Project::STITCHING);
00072     bool  AllDone();
00074     void  AppendBatchFile(wxString file);
00076     void  CancelBatch();
00078     void  CancelProject(int index);
00080     void  ChangePrefix(int index, wxString newPrefix);
00082     bool  CheckProjectExistence();
00084     int   ClearBatch();
00086     bool  CompareProjectsInLists(int stitchListIndex, int batchListIndex);
00088     int   GetFirstAvailable();
00090     int   GetIndex(int id);
00092     Project* GetProject(int index);
00094     int   GetProjectCount();
00096     int   GetProjectCountByPath(wxString path);
00098     int   GetRunningCount();
00100     Project::Status GetStatus(int index);
00102     bool IsRunning();
00104     bool  IsPaused();
00106     const wxString GetLastFile()
00107     {
00108         return m_lastFile;
00109     };
00110     wxDateTime GetLastFileDate()
00111     {
00112         return m_lastmod;
00113     };
00115     void  ListBatch();
00117     int  LoadBatchFile(wxString file);
00119     int   LoadTemp();
00121     bool  NoErrors();
00123     void  OnProcessTerminate(wxProcessEvent& event);
00125     bool  OnStitch(wxString scriptFile, wxString outname, int id);
00127     bool OnDetect(wxString scriptFile, int id);
00129     void  PauseBatch();
00131     void  RemoveProject(int id);
00133     void  RemoveProjectAtIndex(int selIndex);
00135     void  RunBatch();
00137     void  RunNextInBatch();
00139     void  SaveBatchFile(wxString file);
00141     void  SaveTemp();
00143     void  SetStatus(int index,Project::Status status);
00145     void  SwapProject(int index);
00149     void ShowOutput(bool isVisible=true);
00151     size_t GetFailedProjectsCount()
00152     {
00153         return m_failedProjects.size();
00154     };
00156     wxString GetFailedProjectName(unsigned int i);
00158     wxString GetFailedProjectLog(unsigned int i);
00159 
00160 private:
00161     // environment config objects
00162     wxConfigBase* m_config;
00163     //internal list of projects in batch
00164     ProjectArray  m_projList;
00165     //list of projects in progress
00166     FrameArray    m_stitchFrames;
00167     //last saved ptbt file
00168     wxString m_lastFile;
00169     wxDateTime m_lastmod;
00170 
00171     //batch state flags
00172     bool m_cancelled;
00173     bool m_paused;
00174     bool m_running;
00175     bool m_clearedInProgress;
00176 
00177     //vector, which stores the failed projects and filename of saved logfile
00178     std::vector<FailedProject> m_failedProjects;
00179 
00180     //external program config
00181     PTPrograms progs;
00182     AssistantPrograms progsAss;
00183 
00184     DECLARE_EVENT_TABLE()
00185 };
00186 
00187 #if _WINDOWS && defined Hugin_shared
00188 DECLARE_LOCAL_EVENT_TYPE(EVT_BATCH_FAILED,-1)
00189 DECLARE_LOCAL_EVENT_TYPE(EVT_INFORMATION,-1)
00190 DECLARE_LOCAL_EVENT_TYPE(EVT_UPDATE_PARENT, -1)
00191 #else
00192 DECLARE_EVENT_TYPE(EVT_BATCH_FAILED,-1)
00193 DECLARE_EVENT_TYPE(EVT_INFORMATION,-1)
00194 DECLARE_EVENT_TYPE(EVT_UPDATE_PARENT, -1)
00195 #endif
00196 
00197 #endif //BATCH_H

Generated on Wed May 22 01:25:37 2013 for Hugintrunk by  doxygen 1.3.9.1