QGCParamSlider.h 1.78 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 13
namespace Ui {
    class QGCParamSlider;
}

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

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

22 23 24
public slots:
    void startEditMode();
    void endEditMode();
25 26
    /** @brief Send the parameter to the MAV */
    void sendParameter();
pixhawk's avatar
pixhawk committed
27 28 29
    /** @brief Set the slider value as parameter value */
    void setSliderValue(int sliderValue);
    /** @brief Update the UI with the new parameter value */
30
    void setParameterValue(int uas, int component, int paramCount, int paramIndex, QString parameterName, float value);
lm's avatar
lm committed
31 32
    void writeSettings(QSettings& settings);
    void readSettings(const QSettings& settings);
33
    void refreshParamList();
34 35 36
    void setActiveUAS(UASInterface *uas);
    void selectComponent(int componentIndex);
    void selectParameter(int paramIndex);
37
    void setParamValue(double value);
38 39 40 41

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

43
protected:
44 45 46 47 48 49
    QString parameterName;         ///< Key/Name of the parameter
    float parameterValue;          ///< Value of the parameter
    double parameterScalingFactor; ///< Factor to scale the parameter between slider and true value
    float parameterMin;
    float parameterMax;
    int component;                 ///< ID of the MAV component to address
50
    int parameterIndex;
pixhawk's avatar
pixhawk committed
51
    double scaledInt;
52 53
    void changeEvent(QEvent *e);

pixhawk's avatar
pixhawk committed
54 55 56 57 58
    /** @brief Convert scaled int to float */

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

59 60 61 62 63
private:
    Ui::QGCParamSlider *ui;
};

#endif // QGCPARAMSLIDER_H