KiCad PCB EDA Suite
progress.h File Reference

Go to the source code of this file.

Classes

struct  progress_s
 

Typedefs

typedef struct progress_s progress_t
 

Functions

static void progress_update (double d, progress_t *prog)
 
static void progress_subrange_start (double a, double b, const progress_t *prog, progress_t *sub)
 
static void progress_subrange_end (progress_t *prog, progress_t *sub)
 

Typedef Documentation

typedef struct progress_s progress_t

Definition at line 24 of file progress.h.

Function Documentation

static void progress_subrange_end ( progress_t prog,
progress_t sub 
)
inlinestatic

Definition at line 81 of file progress.h.

References progress_s::b, progress_s::callback, progress_s::d_prev, and progress_update().

Referenced by potrace_trace().

82 {
83  if( prog != NULL && prog->callback != NULL )
84  {
85  if( sub->callback == NULL )
86  {
87  progress_update( sub->b, prog );
88  }
89  else
90  {
91  prog->d_prev = sub->d_prev;
92  }
93  }
94 }
double b
Definition: progress.h:21
double d_prev
Definition: progress.h:22
static void progress_update(double d, progress_t *prog)
Definition: progress.h:29
void(* callback)(double progress, void *privdata)
Definition: progress.h:17
static void progress_subrange_start ( double  a,
double  b,
const progress_t prog,
progress_t sub 
)
inlinestatic

Definition at line 49 of file progress.h.

References progress_s::b, progress_s::callback, progress_s::d_prev, progress_s::data, progress_s::epsilon, progress_s::max, max, progress_s::min, and min.

Referenced by potrace_trace().

53 {
54  double min, max;
55 
56  if( prog == NULL || prog->callback == NULL )
57  {
58  sub->callback = NULL;
59  return;
60  }
61 
62  min = prog->min * (1 - a) + prog->max * a;
63  max = prog->min * (1 - b) + prog->max * b;
64 
65  if( max - min < prog->epsilon )
66  {
67  sub->callback = NULL; /* no further progress info in subrange */
68  sub->b = b;
69  return;
70  }
71 
72  sub->callback = prog->callback;
73  sub->data = prog->data;
74  sub->epsilon = prog->epsilon;
75  sub->min = min;
76  sub->max = max;
77  sub->d_prev = prog->d_prev;
78 }
double b
Definition: progress.h:21
double max
Definition: progress.h:19
double d_prev
Definition: progress.h:22
double min
Definition: progress.h:19
void * data
Definition: progress.h:18
double epsilon
Definition: progress.h:20
#define max(a, b)
Definition: auxiliary.h:86
void(* callback)(double progress, void *privdata)
Definition: progress.h:17
#define min(a, b)
Definition: auxiliary.h:85
static void progress_update ( double  d,
progress_t prog 
)
inlinestatic

Definition at line 29 of file progress.h.

References progress_s::callback, progress_s::d_prev, progress_s::data, progress_s::epsilon, progress_s::max, and progress_s::min.

Referenced by bm_to_pathlist(), process_path(), and progress_subrange_end().

30 {
31  double d_scaled;
32 
33  if( prog != NULL && prog->callback != NULL )
34  {
35  d_scaled = prog->min * (1 - d) + prog->max * d;
36 
37  if( d == 1.0 || d_scaled >= prog->d_prev + prog->epsilon )
38  {
39  prog->callback( prog->min * (1 - d) + prog->max * d, prog->data );
40  prog->d_prev = d_scaled;
41  }
42  }
43 }
double max
Definition: progress.h:19
double d_prev
Definition: progress.h:22
double min
Definition: progress.h:19
void * data
Definition: progress.h:18
double epsilon
Definition: progress.h:20
void(* callback)(double progress, void *privdata)
Definition: progress.h:17