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 struct FailedProject
00044 {
00045     wxString project;
00046     wxString logfile;
00047 };
00048 
00049 class Batch : public wxFrame
00050 {
00051 public:
00052     enum EndTask
00053     {
00054         DO_NOTHING = 0,
00055         CLOSE_PTBATCHERGUI = 1,
00056         SHUTDOWN = 2,  // only implemented for GTK and Window in wxWidgets
00057         SUSPEND = 3,   // only implemented for Windows
00058         HIBERNATE = 4  // only implemented for Windows
00059     };
00060     bool deleteFiles;
00061     EndTask atEnd;
00062     bool overwrite;
00063     bool verbose;
00064     bool autostitch;
00065     bool autoremove;
00066     bool saveLog;
00067 
00069     explicit Batch(wxFrame* parent);
00070 
00072     void  AddAppToBatch(wxString app);
00074     void  AddProjectToBatch(wxString projectFile, wxString outputFile = _T(""), Project::Target target=Project::STITCHING);
00076     bool  AllDone();
00078     void  AppendBatchFile(wxString file);
00080     void  CancelBatch();
00082     void  CancelProject(int index);
00084     void  ChangePrefix(int index, wxString newPrefix);
00086     int   ClearBatch();
00088     bool  CompareProjectsInLists(int stitchListIndex, int batchListIndex);
00090     int   GetFirstAvailable();
00092     int   GetIndex(int id);
00094     Project* GetProject(int index);
00096     int   GetProjectCount();
00098     int   GetProjectCountByPath(wxString path);
00100     int   GetRunningCount();
00102     Project::Status GetStatus(int index);
00104     bool IsRunning();
00106     bool  IsPaused();
00108     const wxString GetLastFile()
00109     {
00110         return m_lastFile;
00111     };
00112     wxDateTime GetLastFileDate()
00113     {
00114         return m_lastmod;
00115     };
00117     void  ListBatch();
00119     int  LoadBatchFile(wxString file);
00121     int   LoadTemp();
00123     bool  NoErrors();
00125     void  OnProcessTerminate(wxProcessEvent& event);
00127     bool  OnStitch(wxString scriptFile, wxString outname, int id);
00129     bool OnDetect(wxString scriptFile, int id);
00131     void  PauseBatch();
00133     void  RemoveProject(int id);
00135     void  RemoveProjectAtIndex(int selIndex);
00137     void  RunBatch();
00139     void  RunNextInBatch();
00141     void  SaveBatchFile(wxString file);
00143     void  SaveTemp();
00145     void  SetStatus(int index,Project::Status status);
00147     void  SwapProject(int index);
00151     void ShowOutput(bool isVisible=true);
00153     size_t GetFailedProjectsCount()
00154     {
00155         return m_failedProjects.size();
00156     };
00158     wxString GetFailedProjectName(unsigned int i);
00160     wxString GetFailedProjectLog(unsigned int i);
00161 
00162 private:
00163     // environment config objects
00164     wxConfigBase* m_config;
00165     //internal list of projects in batch
00166     ProjectArray  m_projList;
00167     //list of projects in progress
00168     FrameArray    m_stitchFrames;
00169     //last saved ptbt file
00170     wxString m_lastFile;
00171     wxDateTime m_lastmod;
00172 
00173     //batch state flags
00174     bool m_cancelled;
00175     bool m_paused;
00176     bool m_running;
00177     bool m_clearedInProgress;
00178 
00179     //vector, which stores the failed projects and filename of saved logfile
00180     std::vector<FailedProject> m_failedProjects;
00181 
00182     DECLARE_EVENT_TABLE()
00183 };
00184 
00185 #if defined _WIN32 && defined Hugin_shared
00186 DECLARE_LOCAL_EVENT_TYPE(EVT_BATCH_FAILED,-1)
00187 DECLARE_LOCAL_EVENT_TYPE(EVT_INFORMATION,-1)
00188 DECLARE_LOCAL_EVENT_TYPE(EVT_UPDATE_PARENT, -1)
00189 #else
00190 DECLARE_EVENT_TYPE(EVT_BATCH_FAILED,-1)
00191 DECLARE_EVENT_TYPE(EVT_INFORMATION,-1)
00192 DECLARE_EVENT_TYPE(EVT_UPDATE_PARENT, -1)
00193 #endif
00194 
00195 #endif //BATCH_H

Generated on 9 Feb 2016 for Hugintrunk by  doxygen 1.4.7