MUQ  0.4.3
WaitBar.cpp
Go to the documentation of this file.
2 #include <stdio.h>
3 #include <iostream>
4 
5 using namespace muq::Utilities;
6 
7 WaitBar::WaitBar(double minValIn, double maxValIn) : minVal(minValIn), maxVal(maxValIn)
8 {
9  Update(minVal);
10 }
11 
13 {
14  std::cout << std::endl;
15 }
16 
17 void WaitBar::Update(double newVal)
18 {
19  double perc = (newVal-minVal)/(maxVal-minVal);
20  int pos = double(barWidth) * perc ;
21 
22  printf("[");
23  for(int i=0; i<pos; ++i)
24  printf("=");
25 
26  printf(">");
27 
28  for(int i=pos+1; i<barWidth; ++i)
29  printf(" ");
30 
31  printf("] %3.1f%% \r", (perc*100.0));
32 
33  std::cout << std::flush;
34 }
void Update(double newVal)
Definition: WaitBar.cpp:17
const int barWidth
Definition: WaitBar.h:21
WaitBar(double minValIn, double maxValIn)
Definition: WaitBar.cpp:7