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 #include <wx/power.h>
34 
35 #ifndef FRAMEARRAY
36 #define FRAMEARRAY
38 #endif
39 
41 {
42  wxString project;
43  wxString logfile;
44 };
45 
46 class Batch : public wxFrame
47 {
48 public:
49  enum EndTask
50  {
53  SHUTDOWN = 2, // only implemented for GTK and Window in wxWidgets
54  SUSPEND = 3, // only implemented for Windows
55  HIBERNATE = 4 // only implemented for Windows
56  };
59  bool overwrite;
60  bool verbose;
61  bool autostitch;
62  bool autoremove;
63  bool saveLog;
64 
66  explicit Batch(wxFrame* parent);
68  ~Batch();
69 
71  void AddAppToBatch(wxString app);
73  void AddProjectToBatch(wxString projectFile, wxString outputFile = wxEmptyString, wxString userDefinedSequence = wxEmptyString, Project::Target target = Project::STITCHING);
75  bool AllDone();
77  void AppendBatchFile(wxString file);
79  void CancelBatch();
81  void CancelProject(int index);
83  void ChangePrefix(int index, wxString newPrefix);
85  void ChangeUserDefined(int index, wxString newUserDefined);
87  int ClearBatch();
89  bool CompareProjectsInLists(int stitchListIndex, int batchListIndex);
91  int GetFirstAvailable();
93  int GetIndex(int id);
95  Project* GetProject(int index);
97  int GetProjectCount();
99  int GetProjectCountByPath(wxString path);
101  int GetRunningCount();
103  Project::Status GetStatus(int index);
105  bool IsRunning();
107  bool IsPaused();
109  int LoadBatchFile(wxString file);
111  int LoadTemp();
113  bool NoErrors();
115  void OnProcessTerminate(wxProcessEvent& event);
117  bool OnStitch(wxString scriptFile, wxString outname, wxString userDefinedOutput, int id);
119  bool OnDetect(wxString scriptFile, wxString userDefinedAssistant, int id);
121  void PauseBatch();
123  void RemoveProject(int id);
125  void RemoveProjectAtIndex(int selIndex);
127  void RunBatch();
129  void RunNextInBatch();
131  void SaveBatchFile(wxString file);
133  wxString GetBatchFilename();
135  void SaveTemp();
137  void SetStatus(int index,Project::Status status);
139  void SwapProject(int index);
143  void ShowOutput(bool isVisible=true);
146  {
147  return m_failedProjects.size();
148  };
150  wxString GetFailedProjectName(unsigned int i);
152  wxString GetFailedProjectLog(unsigned int i);
153 
154 private:
155  // environment config objects
156  wxConfigBase* m_config;
157  //internal list of projects in batch
158  ProjectArray m_projList;
159  //list of projects in progress
160  FrameArray m_stitchFrames;
161 
162  //batch state flags
164  bool m_paused;
165  bool m_running;
167 
168  //vector, which stores the failed projects and filename of saved logfile
169  std::vector<FailedProject> m_failedProjects;
170  wxPowerResourceBlocker* m_resBlocker;
171 };
172 
173 wxDECLARE_EVENT(EVT_BATCH_FAILED, wxCommandEvent);
174 wxDECLARE_EVENT(EVT_INFORMATION, wxCommandEvent);
175 wxDECLARE_EVENT(EVT_UPDATE_PARENT, wxCommandEvent);
176 
177 #endif //BATCH_H
bool NoErrors()
Returns true if there are no failed projects in batch.
Definition: Batch.cpp:378
int GetRunningCount()
Returns number of projects currently in progress.
Definition: Batch.cpp:319
int ClearBatch()
Clears batch list and returns 0 if succesful.
Definition: Batch.cpp:220
Stitch a pto project file, with GUI output etc.
int GetFirstAvailable()
Returns index of first waiting project in batch.
Definition: Batch.cpp:259
void SwapProject(int index)
Swaps position in batch of project at index with project at index+1.
Definition: Batch.cpp:918
void RemoveProjectAtIndex(int selIndex)
Removes project at index from batch list.
Definition: Batch.cpp:742
int GetProjectCount()
Returns number of projects in batch list.
Definition: Batch.cpp:301
bool verbose
Definition: Batch.h:60
FrameArray m_stitchFrames
Definition: Batch.h:160
bool deleteFiles
Definition: Batch.h:57
int GetIndex(int id)
Returns index of project with selected id.
Definition: Batch.cpp:284
bool saveLog
Definition: Batch.h:63
void SetStatus(int index, Project::Status status)
Used internally to set status of selected project.
Definition: Batch.cpp:906
size_t GetFailedProjectsCount()
returns number of failed projects
Definition: Batch.h:145
WX_DEFINE_ARRAY_PTR(MyPipedProcess *, MyProcessesArray)
void CancelBatch()
Stops batch run, failing projects in progress.
Definition: Batch.cpp:183
bool autostitch
Definition: Batch.h:61
bool OnDetect(wxString scriptFile, wxString userDefinedAssistant, int id)
called to start detecting
Definition: Batch.cpp:668
void RemoveProject(int id)
Removes project with id from batch list.
Definition: Batch.cpp:730
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:79
void AddAppToBatch(wxString app)
Adds an application entry in the batch list.
Definition: Batch.cpp:73
int LoadBatchFile(wxString file)
Clears current batch list and loads projects from batch file.
Definition: Batch.cpp:347
bool IsPaused()
Returns true if batch execution is currently paused.
Definition: Batch.cpp:342
void ChangePrefix(int index, wxString newPrefix)
Changes output prefix for project at index.
Definition: Batch.cpp:210
void AppendBatchFile(wxString file)
Appends projects from file to batch list.
Definition: Batch.cpp:113
Project::Status GetStatus(int index)
Returns current status of project at index.
Definition: Batch.cpp:324
bool IsRunning()
return true, if batch is running
Definition: Batch.cpp:337
void RunNextInBatch()
Starts execution of next waiting project in batch.
Definition: Batch.cpp:781
wxString GetFailedProjectName(unsigned int i)
returns project file name of failed project with index i
Definition: Batch.cpp:932
void PauseBatch()
Pauses and continues batch execution.
Definition: Batch.cpp:696
ProjectArray m_projList
Definition: Batch.h:158
EndTask atEnd
Definition: Batch.h:58
wxPowerResourceBlocker * m_resBlocker
Definition: Batch.h:170
bool m_paused
Definition: Batch.h:164
wxDECLARE_EVENT(wxEVT_COMMAND_THUMBNAILTHREAD_UPDATE, wxCommandEvent)
void SaveTemp()
Saves batch list to temporary file.
Definition: Batch.cpp:901
Project * GetProject(int index)
Returns project at index.
Definition: Batch.cpp:296
Definition: Batch.h:46
void ShowOutput(bool isVisible=true)
Set visibility of all running projects.
Definition: Batch.cpp:924
bool m_cancelled
Definition: Batch.h:163
wxString project
Definition: Batch.h:42
int GetProjectCountByPath(wxString path)
Returns number of projects in batch list with the input file path.
Definition: Batch.cpp:306
void RunBatch()
Starts batch execution.
Definition: Batch.cpp:765
bool m_clearedInProgress
Definition: Batch.h:166
std::vector< FailedProject > m_failedProjects
Definition: Batch.h:169
bool autoremove
Definition: Batch.h:62
Batch(wxFrame *parent)
Main constructor.
Definition: Batch.cpp:47
void CancelProject(int index)
Cancels project at index in batch, failing it.
Definition: Batch.cpp:197
void SaveBatchFile(wxString file)
Saves batch list to file.
Definition: Batch.cpp:852
EndTask
Definition: Batch.h:49
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:254
wxString GetBatchFilename()
returns the filename of the default queue file
Definition: Batch.cpp:889
bool m_running
Definition: Batch.h:165
bool AllDone()
Returns true if there are no more projects pending execution.
Definition: Batch.cpp:99
void OnProcessTerminate(wxProcessEvent &event)
Called internally when all running processes have completed and need to be removed from running list...
Definition: Batch.cpp:390
Batch processor for Hugin.
~Batch()
destructor
Definition: Batch.cpp:65
wxString GetFailedProjectLog(unsigned int i)
returns log file name of failed project with index i
Definition: Batch.cpp:944
bool overwrite
Definition: Batch.h:59
int LoadTemp()
Loads temporary batch file.
Definition: Batch.cpp:367
wxString logfile
Definition: Batch.h:43
bool OnStitch(wxString scriptFile, wxString outname, wxString userDefinedOutput, int id)
Called to start stitch of project with input scriptFile.
Definition: Batch.cpp:585
void ChangeUserDefined(int index, wxString newUserDefined)
Changes user defined sequence for project at index.
Definition: Batch.cpp:215
wxConfigBase * m_config
Definition: Batch.h:156