source: branches/pixel-map-branch/src/Utils/feedback.hh @ 1339

Last change on this file since 1339 was 253, checked in by Matthew Whiting, 17 years ago
  • Added a mergeList(vector<Scan>) function to the PixelMap? namespace. This is usefu

l for combining lists of Scans into a set of independent ones.

  • Wrote a new spectralSelection function to deal with selection of a spectrum for development applications.
File size: 2.4 KB
Line 
1#ifndef FEEDBACK_HH
2#define FEEDBACK_HH
3
4#include <iostream>
5#include <string>
6
7// Simple functions to print a given number of backspaces or spaces
8//  to std::cout
9inline void printBackSpace(int num){for(int i=0;i<num;i++) std::cout << '\b';};
10inline void printSpace(int num){ for(int i=0;i<num;i++) std::cout << ' '; };
11inline void printHash(int num){ for(int i=0;i<num;i++) std::cout << '#'; };
12
13/**
14 *  Controls printing out a progress bar.
15 *
16 *   A class that prints out a progress bar in the form
17 *    \f$|\#\#\#\ \ \ \ \ \ \ \ \ \ |\f$
18 *    that shows how far through a function or loop you are.
19 *   The length of it defaults to 20 hashes, but can be set when
20 *   declaring the object.
21 *   There are five functions:
22 *    <ul><li>init(int)   Prints an empty bar, and defines the increment
23 *        <li>update(int) Prints the correct number of #s, but only when
24 *                         num is a multiple of the increment.
25 *        <li>rewind()    Prints backspaces to cover the entire bar.
26 *        <li>remove()    Does a rewind(), then prints spaces to overwrite
27 *                         the bar area -- more clean.
28 *        <li>fillSpace(std::string) Does a remove(), then writes
29 *                                    the string into the same space.
30 * </ul>
31 */
32class ProgressBar
33{
34public:
35  ProgressBar();                          ///< Default Constructor
36  ProgressBar(int newlength);             ///< Alternative constructor
37  virtual ~ProgressBar();                 ///< Destructor.
38  enum POS {BEG=0,END};                   ///< So that we can record
39                                          ///   where we are.
40
41  void init(int size);                    ///< Prints empty bar,
42                                          ///   defines increment.
43  void update(int num);                   ///< Prints correct number of hashes
44  void rewind();                          ///< Prints backspaces over bar.
45  void remove();                          ///< Overwrites bar with blanks
46  void fillSpace(std::string someString); ///< Overwrites bar with a string.
47
48private:
49  POS loc;                                ///< Are we at the start or end?
50  float stepSize;                         ///< What is the interval
51                                          ///   between hashes?
52  int length;                             ///< What's the maximum
53                                          ///   number of hashes?
54  int numVisible;                         ///< How many hashes are
55                                          ///   there currently visible?
56};
57
58
59
60#endif // FEEDBACK_HH
Note: See TracBrowser for help on using the repository browser.