src/utilities/plot/ProgressBar.hpp
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /*********************************************************************************************************************** | ||
| 2 | * OpenStudio(R), Copyright (c) Alliance for Energy Innovation, LLC. | ||
| 3 | * See also https://openstudio.net/license | ||
| 4 | ***********************************************************************************************************************/ | ||
| 5 | |||
| 6 | #ifndef UTILITIES_PLOT_PROGRESSBAR_HPP | ||
| 7 | #define UTILITIES_PLOT_PROGRESSBAR_HPP | ||
| 8 | |||
| 9 | #include "../UtilitiesAPI.hpp" | ||
| 10 | #include "../core/Macro.hpp" | ||
| 11 | #include "../core/String.hpp" | ||
| 12 | |||
| 13 | #include <nano/nano_signal_slot.hpp> | ||
| 14 | |||
| 15 | #include <memory> | ||
| 16 | |||
| 17 | namespace openstudio { | ||
| 18 | |||
| 19 | /** ProgressBar is a pure virtual class providing virtual methods setRange, setValue, and setWindowTitle | ||
| 20 | * which may be overridden. | ||
| 21 | **/ | ||
| 22 | class UTILITIES_API ProgressBar | ||
| 23 | { | ||
| 24 | |||
| 25 | public: | ||
| 26 | /// virtual destructor | ||
| 27 | ✗ | virtual ~ProgressBar() = default; | |
| 28 | |||
| 29 | /// get min | ||
| 30 | virtual int minimum() const = 0; | ||
| 31 | |||
| 32 | /// set min | ||
| 33 | virtual void setMinimum(int min) = 0; | ||
| 34 | |||
| 35 | /// get max | ||
| 36 | virtual int maximum() const = 0; | ||
| 37 | |||
| 38 | /// set max | ||
| 39 | virtual void setMaximum(int max) = 0; | ||
| 40 | |||
| 41 | /// get value | ||
| 42 | virtual int value() const = 0; | ||
| 43 | |||
| 44 | /// get the window title | ||
| 45 | virtual std::string windowTitle() const = 0; | ||
| 46 | |||
| 47 | /// set the window title | ||
| 48 | virtual void setWindowTitle(const std::string& title) = 0; | ||
| 49 | |||
| 50 | /// get the text | ||
| 51 | virtual std::string text() const = 0; | ||
| 52 | |||
| 53 | /// get if visible | ||
| 54 | virtual bool isVisible() const = 0; | ||
| 55 | |||
| 56 | /// set if visible | ||
| 57 | virtual void setVisible(bool visible) = 0; | ||
| 58 | |||
| 59 | /// virtual method called every time percentageUpdated fires | ||
| 60 | virtual void onPercentageUpdated(double percentage); | ||
| 61 | |||
| 62 | // public slots: | ||
| 63 | |||
| 64 | /// set range | ||
| 65 | virtual void setRange(int min, int max) = 0; | ||
| 66 | |||
| 67 | /// set value | ||
| 68 | virtual void setValue(int value) = 0; | ||
| 69 | |||
| 70 | // signals: | ||
| 71 | |||
| 72 | /// called every time progress increases by 1% more than last progress | ||
| 73 | Nano::Signal<void(double)> percentageUpdated; | ||
| 74 | |||
| 75 | protected: | ||
| 76 | ProgressBar(); | ||
| 77 | |||
| 78 | void updatePercentage(); | ||
| 79 | |||
| 80 | private: | ||
| 81 | double m_percentage; | ||
| 82 | }; | ||
| 83 | |||
| 84 | } // namespace openstudio | ||
| 85 | |||
| 86 | #endif //UTILITIES_PLOT_PROGRESSBAR_HPP | ||
| 87 |