Hugintrunk  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Batch.h
Go to the documentation of this file.
1 // -*- c-basic-offset: 4 -*-
2 
27 #ifndef BATCH_H
28 #define BATCH_H
29 
30 #include <string>
31 #include "ProjectArray.h"
32 #include "RunStitchFrame.h"
33 #if wxCHECK_VERSION(3,1,0)
34 #include <wx/power.h>
35 #endif
36 
37 #ifndef FRAMEARRAY
38 #define FRAMEARRAY
40 #endif
41 
43 {
44  wxString project;
45  wxString logfile;
46 };
47 
48 class Batch : public wxFrame
49 {
50 public:
51  enum EndTask
52  {
55  SHUTDOWN = 2, // only implemented for GTK and Window in wxWidgets
56  SUSPEND = 3, // only implemented for Windows
57  HIBERNATE = 4 // only implemented for Windows
58  };
61  bool overwrite;
62  bool verbose;
63  bool autostitch;
64  bool autoremove;
65  bool saveLog;
66 
68  explicit Batch(wxFrame* parent);
70  ~Batch();
71 
73  void AddAppToBatch(wxString app);
75  void AddProjectToBatch(wxString projectFile, wxString outputFile = wxEmptyString, wxString userDefinedSequence = wxEmptyString, Project::Target target = Project::STITCHING);
77  bool AllDone();
79  void AppendBatchFile(wxString file);
81  void CancelBatch();
83  void CancelProject(int index);
85  void ChangePrefix(int index, wxString newPrefix);
87  void ChangeUserDefined(int index, wxString newUserDefined);
89  int ClearBatch();
91  bool CompareProjectsInLists(int stitchListIndex, int batchListIndex);
93  int GetFirstAvailable();
95  int GetIndex(int id);
97  Project* GetProject(int index);
99  int GetProjectCount();
101  int GetProjectCountByPath(wxString path);
103  int GetRunningCount();
105  Project::Status GetStatus(int index);
107  bool IsRunning();
109  bool IsPaused();
111  int LoadBatchFile(wxString file);
113  int LoadTemp();
115  bool NoErrors();
117  void OnProcessTerminate(wxProcessEvent& event);
119  bool OnStitch(wxString scriptFile, wxString outname, wxString userDefinedOutput, int id);
121  bool OnDetect(wxString scriptFile, wxString userDefinedAssistant, int id);
123  void PauseBatch();
125  void RemoveProject(int id);
127  void RemoveProjectAtIndex(int selIndex);
129  void RunBatch();
131  void RunNextInBatch();
133  void SaveBatchFile(wxString file);
135  wxString GetBatchFilename();
137  void SaveTemp();
139  void SetStatus(int index,Project::Status status);
141  void SwapProject(int index);
145  void ShowOutput(bool isVisible=true);
148  {
149  return m_failedProjects.size();
150  };
152  wxString GetFailedProjectName(unsigned int i);
154  wxString GetFailedProjectLog(unsigned int i);
155 
156 private:
157  // environment config objects
158  wxConfigBase* m_config;
159  //internal list of projects in batch
160  ProjectArray m_projList;
161  //list of projects in progress
162  FrameArray m_stitchFrames;
163 
164  //batch state flags
166  bool m_paused;
167  bool m_running;
169 
170  //vector, which stores the failed projects and filename of saved logfile
171  std::vector<FailedProject> m_failedProjects;
172 #if wxCHECK_VERSION(3,1,0)
173  wxPowerResourceBlocker* m_resBlocker;
174 #endif
175 
176  DECLARE_EVENT_TABLE()
177 };
178 
179 #if defined _WIN32 && defined Hugin_shared
180 DECLARE_LOCAL_EVENT_TYPE(EVT_BATCH_FAILED,-1)
181 DECLARE_LOCAL_EVENT_TYPE(EVT_INFORMATION,-1)
182 DECLARE_LOCAL_EVENT_TYPE(EVT_UPDATE_PARENT, -1)
183 #else
184 DECLARE_EVENT_TYPE(EVT_BATCH_FAILED,-1)
185 DECLARE_EVENT_TYPE(EVT_INFORMATION,-1)
186 DECLARE_EVENT_TYPE(EVT_UPDATE_PARENT, -1)
187 #endif
188 
189 #endif //BATCH_H
bool NoErrors()
Returns true if there are no failed projects in batch.
Definition: Batch.cpp:393
int GetRunningCount()
Returns number of projects currently in progress.
Definition: Batch.cpp:334
int ClearBatch()
Clears batch list and returns 0 if succesful.
Definition: Batch.cpp:235
Stitch a pto project file, with GUI output etc.
int GetFirstAvailable()
Returns index of first waiting project in batch.
Definition: Batch.cpp:274
void SwapProject(int index)
Swaps position in batch of project at index with project at index+1.
Definition: Batch.cpp:937
void RemoveProjectAtIndex(int selIndex)
Removes project at index from batch list.
Definition: Batch.cpp:759
int GetProjectCount()
Returns number of projects in batch list.
Definition: Batch.cpp:316
bool verbose
Definition: Batch.h:62
FrameArray m_stitchFrames
Definition: Batch.h:162
bool deleteFiles
Definition: Batch.h:59
int GetIndex(int id)
Returns index of project with selected id.
Definition: Batch.cpp:299
bool saveLog
Definition: Batch.h:65
void SetStatus(int index, Project::Status status)
Used internally to set status of selected project.
Definition: Batch.cpp:925
size_t GetFailedProjectsCount()
returns number of failed projects
Definition: Batch.h:147
WX_DEFINE_ARRAY_PTR(MyPipedProcess *, MyProcessesArray)
void CancelBatch()
Stops batch run, failing projects in progress.
Definition: Batch.cpp:196
bool autostitch
Definition: Batch.h:63
bool OnDetect(wxString scriptFile, wxString userDefinedAssistant, int id)
called to start detecting
Definition: Batch.cpp:685
void RemoveProject(int id)
Removes project with id from batch list.
Definition: Batch.cpp:747
void AddProjectToBatch(wxString projectFile, wxString outputFile=wxEmptyString, wxString userDefinedSequence=wxEmptyString, Project::Target target=Project::STITCHING)
Adds a project entry in the batch list.
Definition: Batch.cpp:92
void AddAppToBatch(wxString app)
Adds an application entry in the batch list.
Definition: Batch.cpp:86
int LoadBatchFile(wxString file)
Clears current batch list and loads projects from batch file.
Definition: Batch.cpp:362
bool IsPaused()
Returns true if batch execution is currently paused.
Definition: Batch.cpp:357
void ChangePrefix(int index, wxString newPrefix)
Changes output prefix for project at index.
Definition: Batch.cpp:225
void AppendBatchFile(wxString file)
Appends projects from file to batch list.
Definition: Batch.cpp:126
Project::Status GetStatus(int index)
Returns current status of project at index.
Definition: Batch.cpp:339
bool IsRunning()
return true, if batch is running
Definition: Batch.cpp:352
void RunNextInBatch()
Starts execution of next waiting project in batch.
Definition: Batch.cpp:800
wxString GetFailedProjectName(unsigned int i)
returns project file name of failed project with index i
Definition: Batch.cpp:951
void PauseBatch()
Pauses and continues batch execution.
Definition: Batch.cpp:713
ProjectArray m_projList
Definition: Batch.h:160
EndTask atEnd
Definition: Batch.h:60
bool m_paused
Definition: Batch.h:166
void SaveTemp()
Saves batch list to temporary file.
Definition: Batch.cpp:920
Project * GetProject(int index)
Returns project at index.
Definition: Batch.cpp:311
Definition: Batch.h:48
void ShowOutput(bool isVisible=true)
Set visibility of all running projects.
Definition: Batch.cpp:943
bool m_cancelled
Definition: Batch.h:165
wxString project
Definition: Batch.h:44
int GetProjectCountByPath(wxString path)
Returns number of projects in batch list with the input file path.
Definition: Batch.cpp:321
void RunBatch()
Starts batch execution.
Definition: Batch.cpp:782
bool m_clearedInProgress
Definition: Batch.h:168
std::vector< FailedProject > m_failedProjects
Definition: Batch.h:171
bool autoremove
Definition: Batch.h:64
Batch(wxFrame *parent)
Main constructor.
Definition: Batch.cpp:57
void CancelProject(int index)
Cancels project at index in batch, failing it.
Definition: Batch.cpp:212
void SaveBatchFile(wxString file)
Saves batch list to file.
Definition: Batch.cpp:871
EndTask
Definition: Batch.h:51
bool CompareProjectsInLists(int stitchListIndex, int batchListIndex)
Compares two project at indexes in both lists and returns true if they have identical project ids...
Definition: Batch.cpp:269
wxString GetBatchFilename()
returns the filename of the default queue file
Definition: Batch.cpp:908
bool m_running
Definition: Batch.h:167
bool AllDone()
Returns true if there are no more projects pending execution.
Definition: Batch.cpp:112
void OnProcessTerminate(wxProcessEvent &event)
Called internally when all running processes have completed and need to be removed from running list...
Definition: Batch.cpp:405
Batch processor for Hugin.
~Batch()
destructor
Definition: Batch.cpp:76
wxString GetFailedProjectLog(unsigned int i)
returns log file name of failed project with index i
Definition: Batch.cpp:963
bool overwrite
Definition: Batch.h:61
int LoadTemp()
Loads temporary batch file.
Definition: Batch.cpp:382
wxString logfile
Definition: Batch.h:45
bool OnStitch(wxString scriptFile, wxString outname, wxString userDefinedOutput, int id)
Called to start stitch of project with input scriptFile.
Definition: Batch.cpp:602
void ChangeUserDefined(int index, wxString newUserDefined)
Changes user defined sequence for project at index.
Definition: Batch.cpp:230
wxConfigBase * m_config
Definition: Batch.h:158