Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

[9e26cc]: src / hugin1 / ptbatcher / Batch.h Maximize Restore History

Download this file

Batch.h    183 lines (166 with data), 6.0 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
// -*- c-basic-offset: 4 -*-
/** @file Batch.h
*
* @brief Batch processor for Hugin
*
* @author Marko Kuder <marko.kuder@gmail.com>
*
* $Id: Batch.h 3322 2008-08-18 1:10:07Z mkuder $
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this software; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifndef BATCH_H
#define BATCH_H
#include <string>
#include "ProjectArray.h"
#include <wx/dir.h>
#ifndef __WXMSW__
#include <sys/wait.h>
#endif
//#include <wx/wfstream.h>
//#include <wx/event.h>
#include "RunStitchFrame.h"
//#include <hugin_config.h>
#ifndef FRAMEARRAY
#define FRAMEARRAY
WX_DEFINE_ARRAY_PTR(RunStitchFrame*,FrameArray);
#endif
using namespace std;
struct FailedProject
{
wxString project;
wxString logfile;
};
class Batch : public wxFrame
{
public:
bool parallel;
bool deleteFiles;
bool shutdown;
bool overwrite;
bool verbose;
bool gui;
//Main constructor
Batch(wxFrame* parent, wxString path, bool bgui);
//Adds an application entry in the batch list
void AddAppToBatch(wxString app);
//Adds a project entry in the batch list
void AddProjectToBatch(wxString projectFile, wxString outputFile = _T(""), Project::Target target=Project::STITCHING);
//Returns true if there are no more projects pending execution
bool AllDone();
//Appends projects from file to batch list
void AppendBatchFile(wxString file);
//Stops batch run, failing projects in progress
void CancelBatch();
//Cancels project at index in batch, failing it
void CancelProject(int index);
//Changes output prefix for project at index
void ChangePrefix(int index, wxString newPrefix);
//Called internally in console mode. Waits for running projects to complete and then runs next in batch
bool CheckProjectExistence();
//Clears batch list and returns 0 if succesful
int ClearBatch();
//Compares two project at indexes in both lists and returns true if they have identical project ids
bool CompareProjectsInLists(int stitchListIndex, int batchListIndex);
//Returns index of first waiting project in batch
int GetFirstAvailable();
//Returns index of project with selected id
int GetIndex(int id);
//Returns project at index
Project* GetProject(int index);
//Returns number of projects in batch list
int GetProjectCount();
//Returns number of projects in batch list with the input file path
int GetProjectCountByPath(wxString path);
//Returns number of projects currently in progress
int GetRunningCount();
//Returns current status of project at index
Project::Status GetStatus(int index);
//Returns true if batch execution is currently paused
bool IsPaused();
//Returns last saved batch file
const wxString GetLastFile() { return m_lastFile; };
wxDateTime GetLastFileDate() { return m_lastmod; };
//Used in console mode. Prints out all projects and their statuses to the console
void ListBatch();
//Clears current batch list and loads projects from batch file
int LoadBatchFile(wxString file);
//Loads temporary batch file
int LoadTemp();
//Returns true if there are no failed projects in batch
bool NoErrors();
//Called internally when all running processes have completed and need to be removed from running list
void OnProcessTerminate(wxProcessEvent & event);
//Called to start stitch of project with input scriptFile
bool OnStitch(wxString scriptFile, wxString outname, int id);
/** called to start detecting */
bool OnDetect(wxString scriptFile, int id);
//Pauses and continues batch execution
void PauseBatch();
//Removes project with id from batch list
void RemoveProject(int id);
//Removes project at index from batch list
void RemoveProjectAtIndex(int selIndex);
//Starts batch execution
void RunBatch();
//Starts execution of next waiting project in batch
void RunNextInBatch();
//Saves batch list to file
void SaveBatchFile(wxString file);
//Saves batch list to temporary file
void SaveTemp();
//Used internally to set status of selected project
void SetStatus(int index,Project::Status status);
//Swaps position in batch of project at index with project at index+1
void SwapProject(int index);
/** Set visibility of all running projects
* @param isVisible If true display the project output, otherwise hide it.
*/
void ShowOutput(bool isVisible=true);
/** returns number of failed projects */
size_t GetFailedProjectsCount() { return m_failedProjects.size(); };
/** returns project file name of failed project with index i */
wxString GetFailedProjectName(unsigned int i);
/** returns log file name of failed project with index i */
wxString GetFailedProjectLog(unsigned int i);
private:
//environment config objects
wxConfigBase* m_config;
//internal list of projects in batch
ProjectArray m_projList;
//list of projects in progress
FrameArray m_stitchFrames;
//last saved ptbt file
wxString m_lastFile;
wxDateTime m_lastmod;
//batch state flags
bool m_cancelled;
bool m_paused;
bool m_running;
bool m_clearedInProgress;
//vector, which stores the failed projects and filename of saved logfile
std::vector<FailedProject> m_failedProjects;
//external program config
PTPrograms progs;
AssistantPrograms progsAss;
DECLARE_EVENT_TABLE()
};
#if _WINDOWS && defined Hugin_shared
DECLARE_LOCAL_EVENT_TYPE(EVT_BATCH_FAILED,-1)
#else
DECLARE_EVENT_TYPE(EVT_BATCH_FAILED,-1)
#endif
#endif //BATCH_H