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

#include <QWidget>
5
#include <QAction>
dogmaphobic's avatar
dogmaphobic committed
6
#ifndef __android__
7
#include <QtDesigner/QDesignerExportWidget>
dogmaphobic's avatar
dogmaphobic committed
8
#endif
9

10 11
#include "QGCToolWidgetItem.h"

12 13 14
namespace Ui
{
class QGCParamSlider;
15 16
}

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

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

25
    virtual void setEditMode(bool editMode);
26

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

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

54
protected:
55 56 57
    bool visibleEnabled;
    QString visibleParam;
    int visibleVal;
58 59 60 61
    //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
62
    QString parameterName;         ///< Key/Name of the parameter
63
    QVariant parameterValue;          ///< Value of the parameter
64 65 66
    double parameterScalingFactor; ///< Factor to scale the parameter between slider and true value
    float parameterMin;
    float parameterMax;
67
    int componentId;                 ///< ID of the MAV component to address
pixhawk's avatar
pixhawk committed
68
    double scaledInt;
69 70
    void changeEvent(QEvent *e);

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

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

76 77 78 79 80
private:
    Ui::QGCParamSlider *ui;
};

#endif // QGCPARAMSLIDER_H