1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
//#include "cstring"<--- Skipping configuration 'DBL_MAX' since the value of 'DBL_MAX' is unknown. Use -D if you want to check it. You can use -U to skip it explicitly.<--- Skipping configuration 'DBL_MIN' since the value of 'DBL_MIN' is unknown. Use -D if you want to check it. You can use -U to skip it explicitly.<--- Skipping configuration 'M_PI' since the value of 'M_PI' is unknown. Use -D if you want to check it. You can use -U to skip it explicitly.
#include "TextProgressTool.hpp"
#include "CubitMessage.hpp"

//=============================================================================
// Description: constructor
// Notes:  This will initialize the progress bar and display it
//         The difference between nLower and nUpper will be the number of
//         integral steps the progress bar will before the process is complete
// Author: sjowen
// Date: 11/7/01
//=============================================================================
TextProgressTool::TextProgressTool()
{
  nTotal = 0;
  nCurrent = 0;
  nShown = 0;
}

TextProgressTool::~TextProgressTool()
{
}

void TextProgressTool::start(int nLower, int nUpper,
                           const char* title           /* = NULL */,
                           const char* info_string     /* = NULL      */,
                           CubitBoolean ,
                           CubitBoolean )
{
  const char* progress_title = title ? title : "Progress";

  //bSmooth; bHasCancelButton;
  PRINT_INFO("%s\n",progress_title);
  if (info_string != NULL)
  {
    PRINT_INFO("%s\n",info_string);
  }
  PRINT_INFO("0   |    |    |    |    50   |    |    |    |  100\n");

  nTotal = nUpper - nLower;
  nCurrent = 0;
  nShown = 0;
}

//=============================================================================
// Description: end
// Notes:  closes/finishes the prgress bar window
// Author: sjowen
// Date: 11/7/01
//=============================================================================
void TextProgressTool::end()
{
  PRINT_INFO("\n");
}

//=============================================================================
// Description: makes one integer step of the progress bar
// Notes:
// Author: sjowen
// Date: 11/7/01
//=============================================================================
void TextProgressTool::step()
{
  if( nTotal > 0 )
  {
    nCurrent++;  
    int n = 50 * nCurrent / nTotal;
    for( ; nShown < n; nShown++ )
      PRINT_INFO("*");
  }
}

//=============================================================================
// Description: moves the progress bar to the specified percentage
// Notes:  only moves if percentage is greater the the current step
//         pcnt should be between 0 and 1
// Author: sjowen
// Date: 11/7/01
//=============================================================================
void TextProgressTool::percent( double pcnt )
{
  int ncur = (int)(pcnt * (double)nTotal + 0.5);
  if(ncur > nTotal) 
    ncur = nTotal;
  if (ncur > nCurrent)
  {
    int ii;
    for (ii=nCurrent; ii<ncur; ii++)
    {
      step();
    }
    nCurrent = ncur;
  }
}

void TextProgressTool::check_interrupt()
{
}