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