|
QGroundControl
Ground Control Station for MAVLink Drones
|
#include <ProgressState.h>
Inheritance diagram for ProgressState:
Collaboration diagram for ProgressState:Public Types | |
| using | ProgressCallback = std::function< float()> |
| using | Action = std::function< void()> |
Public Types inherited from QGCAbstractState | |
| using | EntryCallback = std::function< void()> |
| using | ExitCallback = std::function< void()> |
| using | EventHandler = std::function< bool(QEvent *)> |
Signals | |
| void | progressChanged (float progress) |
| Emitted when the state is entered with the current progress value. | |
Signals inherited from QGCAbstractState | |
| void | advance () |
| void | error () |
Public Member Functions | |
| ProgressState (const QString &stateName, QState *parent, float progress, Action action=nullptr) | |
| ProgressState (const QString &stateName, QState *parent, ProgressCallback progressCallback, Action action=nullptr) | |
| float | progress () const |
| Get the current progress value. | |
| void | setProgress (float progress) |
| Set a fixed progress value. | |
| void | setProgressCallback (ProgressCallback callback) |
| Set a progress callback. | |
Public Member Functions inherited from QGCState | |
| QGCState (const QString &stateName, QState *parentState) | |
| template<typename PointerToMemberFunction > | |
| QSignalTransition * | addThisTransition (PointerToMemberFunction signal, QAbstractState *target) |
| Simpler version of QState::addTransition which assumes the sender is this. | |
| void | setLocalErrorState (QAbstractState *errorState) |
| QAbstractState * | localErrorState () const |
| Get the per-state error state (nullptr if using global) | |
| void | setProperty (QObject *object, const char *name, const QVariant &value) |
| void | setEnabled (QObject *object, bool enabled) |
| Convenience overload for setting enabled state on widgets/controls. | |
| void | setVisible (QObject *object, bool visible) |
| Convenience overload for setting visible state on widgets/controls. | |
Public Member Functions inherited from QGCAbstractState | |
| QGCAbstractState (const QString &stateName, QState *parent) | |
| QGCStateMachine * | machine () const |
| Vehicle * | vehicle () const |
| QString | stateName () const |
| class StateContext * | context () const |
| void | setOnEntry (EntryCallback callback) |
| Set a callback to be invoked when the state is entered. | |
| void | setOnExit (ExitCallback callback) |
| Set a callback to be invoked when the state is exited. | |
| void | setCallbacks (EntryCallback onEntry, ExitCallback onExit=nullptr) |
| Set both entry and exit callbacks. | |
| void | setEventHandler (EventHandler handler) |
| Set a custom event handler for this state. | |
Protected Member Functions | |
| void | onEnter () override |
| Override to perform actions on state entry. | |
Protected Member Functions inherited from QGCAbstractState | |
| virtual void | onLeave () |
| Override to perform actions on state exit. | |
| void | onEntry (QEvent *event) override |
| void | onExit (QEvent *event) override |
| bool | event (QEvent *event) override |
State that reports progress on entry. Useful for state machines that need to track progress through a sequence of states.
Progress can be reported as:
Example usage:
Definition at line 25 of file ProgressState.h.
| using ProgressState::Action = std::function<void()> |
Definition at line 32 of file ProgressState.h.
| using ProgressState::ProgressCallback = std::function<float()> |
Definition at line 31 of file ProgressState.h.
| ProgressState::ProgressState | ( | const QString & | stateName, |
| QState * | parent, | ||
| float | progress, | ||
| Action | action = nullptr |
||
| ) |
Create a progress state with a fixed progress value
| stateName | Name for this state |
| parent | Parent state |
| progress | Fixed progress value (0.0 to 1.0) |
| action | Optional action to execute on entry |
Definition at line 5 of file ProgressState.cc.
| ProgressState::ProgressState | ( | const QString & | stateName, |
| QState * | parent, | ||
| ProgressCallback | progressCallback, | ||
| Action | action = nullptr |
||
| ) |
Create a progress state with a dynamic progress callback
| stateName | Name for this state |
| parent | Parent state |
| progressCallback | Function that returns current progress (0.0 to 1.0) |
| action | Optional action to execute on entry |
Definition at line 13 of file ProgressState.cc.
|
overrideprotectedvirtual |
Override to perform actions on state entry.
Reimplemented from QGCAbstractState.
Definition at line 41 of file ProgressState.cc.
References QGCAbstractState::advance(), progress(), and progressChanged().
| float ProgressState::progress | ( | ) | const |
Get the current progress value.
Definition at line 21 of file ProgressState.cc.
Referenced by onEnter(), and setProgress().
|
signal |
Emitted when the state is entered with the current progress value.
Referenced by onEnter().
| void ProgressState::setProgress | ( | float | progress | ) |
| void ProgressState::setProgressCallback | ( | ProgressCallback | callback | ) |
Set a progress callback.
Definition at line 35 of file ProgressState.cc.