70#include "utils/ProgressBar.hpp"
76 const char* progressSpinner_ =
"|/-\\";
78 ProgressBar::ProgressBar() :
79 value_(0.0), maximum_(-1.0), iteration_(0), start_(time(NULL)) {}
81 void ProgressBar::clear() {
84 MPI_Comm_rank(MPI_COMM_WORLD, &myRank);
98 void ProgressBar::update() {
101 MPI_Comm_rank(MPI_COMM_WORLD, &myRank);
106 if (isatty(fileno(stdout)) && (getenv(
"SGE_TASK_ID") == NULL)) {
111 CONSOLE_SCREEN_BUFFER_INFO csbi;
112 HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
113 int ret = GetConsoleScreenBufferInfo(hConsole, &csbi);
114 if (ret) { width = csbi.dwSize.X - 1; }
117 ioctl(fileno(stdout), TIOCGWINSZ, &w);
122 if (width <= 0) width = 80;
129 int avail = width - 31 - 6 - 2;
133 if (maximum_ > 0.0) {
137 std::min(std::max(value_ * 100.0 / maximum_, 1e-6), 100.0);
139 int hashes = int(percent * avail / 100.0);
142 time_t current_ = time(NULL);
143 time_t end_ =
static_cast<time_t
>(start_ + (current_ - start_) *
145 struct tm* ender = localtime(&end_);
147 strftime(buffer, 22,
"%a %b %d @ %I:%M %p", ender);
150 csbi.dwCursorPosition.X = 0;
151 SetConsoleCursorPosition(hConsole, csbi.dwCursorPosition);
156 cout << right << int(percent);
160 if (hashes + 1 < avail) {
161 cout.width(hashes + 1);
162 cout << progressSpinner_[iteration_ & 3];
168 if (avail - hashes - 1 > 0) {
169 cout.width(avail - hashes - 1);
173 cout <<
"] Estimate:";
184 void ProgressBar::setStatus(RealType val, RealType max) {
This basic Periodic Table class was originally taken from the data.cpp file in OpenBabel.