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 #if wxCHECK_VERSION(3,1,0)
00038 #include <wx/power.h>
00039 #endif
00040 
00041 #ifndef FRAMEARRAY
00042 #define FRAMEARRAY
00043 WX_DEFINE_ARRAY_PTR(RunStitchFrame*,FrameArray);
00044 #endif
00045 
00046 struct FailedProject
00047 {
00048     wxString project;
00049     wxString logfile;
00050 };
00051 
00052 class Batch : public wxFrame
00053 {
00054 public:
00055     enum EndTask
00056     {
00057         DO_NOTHING = 0,
00058         CLOSE_PTBATCHERGUI = 1,
00059         SHUTDOWN = 2,  // only implemented for GTK and Window in wxWidgets
00060         SUSPEND = 3,   // only implemented for Windows
00061         HIBERNATE = 4  // only implemented for Windows
00062     };
00063     bool deleteFiles;
00064     EndTask atEnd;
00065     bool overwrite;
00066     bool verbose;
00067     bool autostitch;
00068     bool autoremove;
00069     bool saveLog;
00070 
00072     explicit Batch(wxFrame* parent);
00074     ~Batch();
00075 
00077     void  AddAppToBatch(wxString app);
00079     void  AddProjectToBatch(wxString projectFile, wxString outputFile = _T(""), Project::Target target=Project::STITCHING);
00081     bool  AllDone();
00083     void  AppendBatchFile(wxString file);
00085     void  CancelBatch();
00087     void  CancelProject(int index);
00089     void  ChangePrefix(int index, wxString newPrefix);
00091     int   ClearBatch();
00093     bool  CompareProjectsInLists(int stitchListIndex, int batchListIndex);
00095     int   GetFirstAvailable();
00097     int   GetIndex(int id);
00099     Project* GetProject(int index);
00101     int   GetProjectCount();
00103     int   GetProjectCountByPath(wxString path);
00105     int   GetRunningCount();
00107     Project::Status GetStatus(int index);
00109     bool IsRunning();
00111     bool  IsPaused();
00113     const wxString GetLastFile()
00114     {
00115         return m_lastFile;
00116     };
00117     wxDateTime GetLastFileDate()
00118     {
00119         return m_lastmod;
00120     };
00122     void  ListBatch();
00124     int  LoadBatchFile(wxString file);
00126     int   LoadTemp();
00128     bool  NoErrors();
00130     void  OnProcessTerminate(wxProcessEvent& event);
00132     bool  OnStitch(wxString scriptFile, wxString outname, int id);
00134     bool OnDetect(wxString scriptFile, int id);
00136     void  PauseBatch();
00138     void  RemoveProject(int id);
00140     void  RemoveProjectAtIndex(int selIndex);
00142     void  RunBatch();
00144     void  RunNextInBatch();
00146     void  SaveBatchFile(wxString file);
00148     void  SaveTemp();
00150     void  SetStatus(int index,Project::Status status);
00152     void  SwapProject(int index);
00156     void ShowOutput(bool isVisible=true);
00158     size_t GetFailedProjectsCount()
00159     {
00160         return m_failedProjects.size();
00161     };
00163     wxString GetFailedProjectName(unsigned int i);
00165     wxString GetFailedProjectLog(unsigned int i);
00166 
00167 private:
00168     // environment config objects
00169     wxConfigBase* m_config;
00170     //internal list of projects in batch
00171     ProjectArray  m_projList;
00172     //list of projects in progress
00173     FrameArray    m_stitchFrames;
00174     //last saved ptbt file
00175     wxString m_lastFile;
00176     wxDateTime m_lastmod;
00177 
00178     //batch state flags
00179     bool m_cancelled;
00180     bool m_paused;
00181     bool m_running;
00182     bool m_clearedInProgress;
00183 
00184     //vector, which stores the failed projects and filename of saved logfile
00185     std::vector<FailedProject> m_failedProjects;
00186 #if wxCHECK_VERSION(3,1,0)
00187     wxPowerResourceBlocker* m_resBlocker;
00188 #endif
00189 
00190     DECLARE_EVENT_TABLE()
00191 };
00192 
00193 #if defined _WIN32 && defined Hugin_shared
00194 DECLARE_LOCAL_EVENT_TYPE(EVT_BATCH_FAILED,-1)
00195 DECLARE_LOCAL_EVENT_TYPE(EVT_INFORMATION,-1)
00196 DECLARE_LOCAL_EVENT_TYPE(EVT_UPDATE_PARENT, -1)
00197 #else
00198 DECLARE_EVENT_TYPE(EVT_BATCH_FAILED,-1)
00199 DECLARE_EVENT_TYPE(EVT_INFORMATION,-1)
00200 DECLARE_EVENT_TYPE(EVT_UPDATE_PARENT, -1)
00201 #endif
00202 
00203 #endif //BATCH_H

Generated on 25 Sep 2016 for Hugintrunk by  doxygen 1.4.7