Easy3D 2.6.1
Loading...
Searching...
No Matches
progress.h
1/********************************************************************
2 * Copyright (C) 2015-2021 by Liangliang Nan <liangliang.nan@gmail.com>
3 * Copyright (C) 2000-2005 INRIA - Project ALICE
4 *
5 * The code in this file is partly from OGF/Graphite (2.0 alpha-4) with
6 * modifications and enhancement:
7 * https://gforge.inria.fr/forum/forum.php?forum_id=11459
8 * The original code was distributed under the GNU GPL license.
9 ********************************************************************/
10
11#ifndef EASY3D_UTIL_PROGRESS_H
12#define EASY3D_UTIL_PROGRESS_H
13
14
15#include <string>
16
17
18namespace easy3d {
19
25 public:
33 virtual ~ProgressClient() = default;
39 virtual void notify(std::size_t percent, bool update_viewer) = 0;
43 virtual void cancel();
44 };
45
46 //_________________________________________________________
47
53 public:
60 ProgressLogger(std::size_t max_val, bool update_viewer, bool quiet = false);
64 virtual ~ProgressLogger();
69 virtual void notify(std::size_t new_value);
73 virtual void next();
77 virtual void done() { notify(max_val_); }
82 bool is_canceled() const;
83
87 void reset() { notify(0); }
92 void reset(std::size_t max_val);
93
94 protected:
95 virtual void update();
96
97 private:
98 std::size_t max_val_;
99 std::size_t cur_val_;
100 std::size_t cur_percent_;
101 bool quiet_;
102 bool update_viewer_;
103 };
104
111 void print_progress(float percentage);
112
113} // namespace easy3d
114
115
116#endif // EASY3D_UTIL_PROGRESS_H
117
virtual void cancel()
Cancel the progress.
Definition progress.cpp:78
ProgressClient()
Constructor.
Definition progress.cpp:74
virtual void notify(std::size_t percent, bool update_viewer)=0
Notify the progress.
virtual ~ProgressClient()=default
Destructor.
virtual void next()
Move to the next step.
Definition progress.cpp:112
virtual ~ProgressLogger()
Destructor.
Definition progress.cpp:99
virtual void done()
Mark the progress as done.
Definition progress.h:77
ProgressLogger(std::size_t max_val, bool update_viewer, bool quiet=false)
Constructor.
Definition progress.cpp:85
bool is_canceled() const
Check if the progress is canceled.
Definition progress.cpp:118
virtual void notify(std::size_t new_value)
Notify the progress.
Definition progress.cpp:106
void reset()
Resets the progress logger without changing the progress range.
Definition progress.h:87
Definition collider.cpp:182
void print_progress(float percentage)
A simple progress indicator for console applications.
Definition progress.cpp:140