3 #include <sys/socket.h>
12 #include "Application.h"
13 #include "Preference.h"
22 Progress::Progress() {
27 percent = group[
"ProgressBarPercent"];
28 QString temp = (QString) group[
"ProgressBar"];
29 printPercent = temp.toUpper() ==
"ON";
32 if((percent != 1) && (percent != 2) &&
33 (percent != 5) && (percent != 10)) {
34 string m =
"Invalid preference for [ProgressBarPercent] in ";
35 m +=
"group [UserInterface] must be 1, 2, 5, or 10";
36 throw IException(IException::User, m, _FILEINFO_);
44 p_percentIncrement = percent;
45 p_printPercent = printPercent;
50 Progress::~Progress() {
61 void Progress::SetText(
const QString &text) {
72 QString Progress::Text()
const {
85 void Progress::SetMaximumSteps(
const int steps) {
87 string m =
"Value for [steps] must be greater than ";
88 m +=
"or equal to zero in [Progress::SetMaximumSteps]";
89 throw IException(IException::Programmer, m, _FILEINFO_);
91 p_maximumSteps = steps;
105 void Progress::CheckStatus() {
108 if(p_currentStep > p_maximumSteps) {
109 string m =
"Step exceeds maximumSteps in [Progress::CheckStatus]";
110 throw IException(IException::Programmer, m, _FILEINFO_);
113 if(p_currentStep == 0) {
114 if(Isis::iApp != NULL) {
120 if(p_printPercent && p_autoDisplay) {
121 cout << p_text << endl;
127 while(100.0 * p_currentStep / p_maximumSteps >= p_currentPercent) {
128 if(Isis::iApp != NULL) {
134 if(p_printPercent && p_autoDisplay) {
135 if(p_currentPercent < 100) {
136 cout << p_currentPercent <<
"% Processed\r" << flush;
139 cout << p_currentPercent <<
"% Processed" << endl;
143 p_currentPercent += p_percentIncrement;
146 if(p_autoDisplay && Isis::iApp != NULL) {
161 void Progress::DisableAutomaticDisplay() {
162 p_autoDisplay =
false;
172 int Progress::MaximumSteps()
const {
173 return p_maximumSteps;
185 int Progress::CurrentStep()
const {
186 return p_currentStep;
199 void Progress::AddSteps(
const int steps) {
201 string m =
"Value for [steps] must not be zero in [Progress::AddSteps]";
202 throw IException(IException::Programmer, m, _FILEINFO_);
205 p_maximumSteps += steps;
207 if(p_currentStep > p_maximumSteps) {
208 string m =
"Step exceeds maximumSteps in [Progress::AddSteps]";
209 throw IException(IException::Programmer, m, _FILEINFO_);
212 if(p_maximumSteps <= 0) {
213 string m =
"Maximum steps must be greater than zero in [Progress::AddSteps]";
214 throw IException(IException::Programmer, m, _FILEINFO_);