ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
GenericProgressCallback.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - CloudViewer: www.cloudViewer.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2024 www.cloudViewer.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
8 #pragma once
9 
10 // Local
11 #include "CVConst.h"
12 #include "CVCoreLib.h"
13 
14 class AtomicCounter;
15 
16 namespace cloudViewer {
17 
21 public:
23  virtual ~GenericProgressCallback() = default;
24 
26 
32  virtual void update(float percent) = 0;
33 
35 
38  virtual void setMethodTitle(const char* methodTitle) = 0;
39 
41 
44  virtual void setInfo(const char* infoStr) = 0;
45 
48 
51  virtual void start() = 0;
52 
54 
57  virtual void stop() = 0;
58 
60 
67  virtual bool isCancelRequested() = 0;
68 
70  virtual bool textCanBeEdited() const { return true; }
71 };
72 
75 
79 public:
81 
86  unsigned totalSteps,
87  unsigned totalPercentage = 100);
88 
90  virtual ~NormalizedProgress();
91 
94  void scale(unsigned totalSteps,
95  unsigned totalPercentage = 100,
96  bool updateCurrentProgress = false);
97 
99  void reset();
100 
102  bool oneStep();
103 
105  bool steps(unsigned n);
106 
107 protected:
109  float m_percent;
110 
113  unsigned m_step;
114 
117 
119 
122 
125 };
126 
127 } // namespace cloudViewer
#define CV_CORE_LIB_API
Definition: CVCoreLibWin.h:15
std::function< void(std::shared_ptr< core::Tensor >)> callback
Fake QAtomicInt.
virtual void stop()=0
Notifies the fact that the process has ended.
virtual void setInfo(const char *infoStr)=0
Notifies some information about the ongoing process.
virtual void setMethodTitle(const char *methodTitle)=0
Notifies the algorithm title.
virtual bool textCanBeEdited() const
Returns whether the dialog title and info can be updated or not.
virtual void update(float percent)=0
Notifies the algorithm progress.
virtual bool isCancelRequested()=0
Checks if the process should be canceled.
virtual ~GenericProgressCallback()=default
Default destructor.
float m_percentAdd
Percentage added to total progress value at each step.
AtomicCounter * m_counter
Current number of calls to 'oneStep'.
float m_percent
Total progress value (in percent)
GenericProgressCallback * progressCallback
associated GenericProgressCallback
Generic file read and write utility for python interface.