KerMor  0.9
Model order reduction for nonlinear dynamical systems and nonlinear approximation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ProcessIndicator.m
Go to the documentation of this file.
1 
2 
3 /* (Autoinserted by mtoc++)
4  * This source code has been filtered by the mtoc++ executable,
5  * which generates code that can be processed by the doxygen documentation tool.
6  *
7  * On the other hand, it can neither be interpreted by MATLAB, nor can it be compiled with a C++ compiler.
8  * Except for the comments, the function bodies of your M-file functions are untouched.
9  * Consequently, the FILTER_SOURCE_FILES doxygen switch (default in our Doxyfile.template) will produce
10  * attached source files that are highly readable by humans.
11  *
12  * Additionally, links in the doxygen generated documentation to the source code of functions and class members refer to
13  * the correct locations in the source code browser.
14  * However, the line numbers most likely do not correspond to the line numbers in the original MATLAB source files.
15  */
16 
18  :public handle {
49  public:
50 
61  private:
62 
63  total;
64 
65  p;
66 
67  wb;
68 
69  title;
70 
71  cur;
72 
73 
74  public:
75 
76  ProcessIndicator(char title,double total,logical wb,varargin) {
77  if nargin < 3
78  wb = false;
79  end
80  if ~isempty(varargin)
81  this.title= sprintf(title,varargin[:]);
82  else
83  this.title= sprintf(" %s (%d total) ",title,total);
84  end
85  this.UseWaitbar= wb;
86  if nargin > 1
87  this.start(total);
88  end
89  }
107  function start(double total) {
108  if isempty(total) || ~isscalar(total) || total <= 0
109  error(" Total must be a positve scalar value ");
110  end
111  this.total= total;
112  this.cur= 0;
113  this.p= 0;
114  if this.UseWaitbar
115  this.wb= waitbar(0,this.title," Visible "," off ");
116  /* Place at main monitor middle */
117  mpos = get(0," MonitorPositions ");
118  if size(mpos,1) > 1
119  npos = get(this.wb," Position ");
120  npos(1) = (mpos(1,3)/2-npos(3));
121  set(this.wb," Position ",npos);
122  end
123  set(this.wb," Visible "," on ");
124  else
125  fprintf(" %s: ",this.title);
126  end
127  }
136  function set(value) {
137  if nargin == 1
138  error(" Set requires a value to set. ");
139  end
140  if value > this.total
141  value = this.total;
142  elseif value < 0
143  value = 0;
144  end
145  this.cur= value;
146  this.update;
147  }
158  function step(double value) {
159  if nargin == 1
160  value = 1;
161  end
162  if value + this.cur > this.total
163  value = this.total - this.cur;
164  elseif value < -this.cur
165  value = -this.cur;
166  end
167  this.cur= this.cur + value;
168  this.update;
169  }
182  function stop() {
183  if this.UseWaitbar
184  if ~isempty(this.wb) && ishandle(this.wb)
185  close(this.wb);
186  end
187  else
188  fprintf(" done!\n ");
189  end
190  }
198 #if 0 //mtoc++: 'set.UseWaitbar'
199 function UseWaitbar(value) {
200  if ~islogical(value) || ~isscalar(value)
201  error(" UseWaitbar must be a logical scalar ");
202  end
203  this.UseWaitbar= value;
204  }
205 
206 #endif
207 
208 
209  private:
210 
211  function update() {
212  perc = this.cur/this.total;
213  pstr = sprintf(" %2.0f%% ",round(perc*100));
214  if this.UseWaitbar
215  waitbar(perc,this.wb,sprintf(" %s: %s ",this.title,pstr));
216  else
217  if perc > this.p
218  fprintf(" %s ",pstr);
219  this.p= ceil(perc*10)/10;
220  end
221  end
222  }
223 
224 
230 };
231 
function start(double total)
Starts the process indicator with the given total process amount.
function set(value)
Directly sets the current process value.
ProcessIndicator(char title,double total,logical wb, varargin)
Creates a new ProcessIndicator.
Matlab's base handle class (documentation generation substitute)
A boolean value.
A variable number of input arguments.
function step(double value)
Reports process to the indicator and triggers waitbar or text output.
function stop()
Stops the process indication and closes the waitbar, if any.
ProcessIndicator: A simple class that indicates process either via waitbar or text output...
logical UseWaitbar
Flag that indicates if a waitbar should be used.