QGCParamSlider.h 2.66 KB
Newer Older
1 2 3 4
#ifndef QGCPARAMSLIDER_H
#define QGCPARAMSLIDER_H

#include <QWidget>
5
#include <QAction>
6 7
#include <QtDesigner/QDesignerExportWidget>

8 9
#include "QGCToolWidgetItem.h"

10 11 12
namespace Ui
{
class QGCParamSlider;
13 14
}

pixhawk's avatar
pixhawk committed
15
class QGCParamSlider : public QGCToolWidgetItem
16 17 18 19 20 21 22
{
    Q_OBJECT

public:
    explicit QGCParamSlider(QWidget *parent = 0);
    ~QGCParamSlider();

23 24 25
public slots:
    void startEditMode();
    void endEditMode();
26 27
    /** @brief Queue parameter for sending to the MAV (add to pending list)*/
    void setParamPending();
pixhawk's avatar
pixhawk committed
28 29 30
    /** @brief Set the slider value as parameter value */
    void setSliderValue(int sliderValue);
    /** @brief Update the UI with the new parameter value */
31
    void setParameterValue(int uas, int componentId, int paramCount, int paramIndex, QString parameterName, const QVariant value);
lm's avatar
lm committed
32 33
    void writeSettings(QSettings& settings);
    void readSettings(const QSettings& settings);
34
    void readSettings(const QString& pre,const QVariantMap& settings);
35
    void refreshParamList();
36 37 38
    void setActiveUAS(UASInterface *uas);
    void selectComponent(int componentIndex);
    void selectParameter(int paramIndex);
39
    /** @brief Set a double parameter value */
40
    void setParamValue(double value);
41 42
    /** @brief Set an integer parameter value */
    void setParamValue(int value);
43 44
    /** @brief Show descriptive text next to slider */
    void showInfo(bool enable);
Lorenz Meier's avatar
Lorenz Meier committed
45 46
    /** @brief Show tool tip of calling element */
    void showTooltip();
47 48 49 50

protected slots:
    /** @brief Request the parameter of this widget from the MAV */
    void requestParameter();
51

52
protected:
53 54 55
    bool visibleEnabled;
    QString visibleParam;
    int visibleVal;
56 57 58 59
    //The below variables, and usage in QGCParamSlider.cc are a bit of a hack, since disconnect() does not seem to take effect
    //immediatly (perhaps it is put into the event loop?) - MLC
    bool valueModLock;              ///< Used to keep the slider/spinboxes from updating each other during user input
    bool valueModLockParam;         ///< Used to keep the slider/spinboxes from udpating each other when a new parametervalue comes in
60
    QString parameterName;         ///< Key/Name of the parameter
61
    QVariant parameterValue;          ///< Value of the parameter
62 63 64
    double parameterScalingFactor; ///< Factor to scale the parameter between slider and true value
    float parameterMin;
    float parameterMax;
65
    int componentId;                 ///< ID of the MAV component to address
pixhawk's avatar
pixhawk committed
66
    double scaledInt;
67 68
    void changeEvent(QEvent *e);

pixhawk's avatar
pixhawk committed
69 70 71 72 73
    /** @brief Convert scaled int to float */

    float scaledIntToFloat(int sliderValue);
    int floatToScaledInt(float value);

74 75 76 77 78
private:
    Ui::QGCParamSlider *ui;
};

#endif // QGCPARAMSLIDER_H