00001
00026 #ifndef _APPBASE_POGRESSDISPLAYOLD_H
00027 #define _APPBASE_POGRESSDISPLAYOLD_H
00028
00029 #include <hugin_shared.h>
00030 #include <string>
00031 #include <vector>
00032 #include <iostream>
00033 #include <cstdio>
00034
00035 #include <appbase/ProgressDisplay.h>
00036
00037
00038 namespace AppBase
00039 {
00040
00053 struct IMPEX ProgressTask
00054 {
00056 ProgressTask(std::string shortMessage, std::string message,
00057 double subStepProgress, double progress=0);
00058
00060 ProgressTask(std::string shortMessage, std::string message);
00061
00062
00063 std::string shortMessage;
00064 std::string message;
00065 double subStepProgress;
00066 double progress;
00067
00068 bool measureProgress;
00069 double last_displayed_progress;
00070
00071 inline const std::string& getShortMessage()
00072 { return shortMessage; }
00073
00074 inline const std::string& getMessage()
00075 { return message; }
00076
00077 inline double getProgress()
00078 { return progress; }
00079 };
00080
00081
00092 class IMPEX MultiProgressDisplay
00093 {
00094 public:
00095
00096 MultiProgressDisplay(double minPrintStep=0.02);
00097
00098 virtual ~MultiProgressDisplay() {};
00099
00110 void pushTask(const ProgressTask & task);
00111
00113 void popTask();
00114
00116 void setShortMessage(const std::string & msg);
00117
00119 void setMessage(const std::string & msg);
00120
00122 void setProgress(double progress);
00123
00125 void increase();
00126
00127
00128 protected:
00133 virtual void updateProgressDisplay() {};
00134
00136 virtual void taskAdded() {};
00137
00141 virtual void taskRemove() {};
00142
00143
00144 protected:
00146 void propagateProgress(double progress);
00147
00148 std::vector<ProgressTask> tasks;
00149 double m_minProgressStep;
00150 };
00151
00152
00153
00157 class DummyMultiProgressDisplay : public MultiProgressDisplay
00158 {
00159 public:
00160 void pushTask(const ProgressTask & task) {};
00161 void popTask() {};
00162 void setShortMessage(const std::string & msg) {};
00163 void setMessage(const std::string & msg) {};
00164 void setProgress(double progress) {};
00165 void increase() {};
00166
00167 virtual void updateProgressDisplay() {};
00168 virtual void taskAdded() {};
00169 virtual void taskRemove() {};
00170 };
00171
00172
00176 class MultiProgressDisplayAdaptor : public MultiProgressDisplay
00177 {
00178
00179 public:
00181 MultiProgressDisplayAdaptor(ProgressDisplay& myProgressDisplay);
00182
00184 virtual ~MultiProgressDisplayAdaptor() {};
00185
00187 static MultiProgressDisplay* newMultiProgressDisplay(ProgressDisplay* myProgressDisplay);
00188
00189
00190 protected:
00192 void taskAdded();
00193
00195 void taskRemove();
00196
00198 void updateProgressDisplay();
00199
00200
00201 protected:
00202 ProgressDisplay& o_progressDisplay;
00203
00204 };
00205
00206
00210 class IMPEX StreamMultiProgressDisplay : public MultiProgressDisplay
00211 {
00212 public:
00214 StreamMultiProgressDisplay(std::ostream& o, double minPrintStep=0.02);
00215
00217 virtual ~StreamMultiProgressDisplay() {};
00218
00219
00220 protected:
00222 virtual void updateProgressDisplay();
00223 virtual void taskAdded() {};
00224 virtual void taskRemove() {};
00225
00226 protected:
00227 std::ostream & m_stream;
00228 int m_printedLines;
00229 std::string m_whizz;
00230 int m_whizzCount;
00231 };
00232
00233
00234 }
00235
00236
00237 #endif // _H