Skip to content
QGCParamWidget.h 3.82 KiB
Newer Older
/*=====================================================================

QGroundControl Open Source Ground Control Station

(c) 2009, 2010 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>

This file is part of the QGROUNDCONTROL project

    QGROUNDCONTROL is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    QGROUNDCONTROL is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.

======================================================================*/

/**
 * @file
 *   @brief Declaration of class QGCParamWidget
 *   @author Lorenz Meier <mail@qgroundcontrol.org>
 */

pixhawk's avatar
pixhawk committed
#ifndef QGCPARAMWIDGET_H
#define QGCPARAMWIDGET_H

#include <QWidget>
#include <QTreeWidget>
#include <QTreeWidgetItem>
#include <QMap>
lm's avatar
lm committed
#include <QLabel>
pixhawk's avatar
pixhawk committed

#include "QGCUASParamManager.h"
pixhawk's avatar
pixhawk committed
#include "UASInterface.h"

/**
 * @brief Widget to read/set onboard parameters
 */
class QGCParamWidget : public QGCUASParamManager
pixhawk's avatar
pixhawk committed
{
pixhawk's avatar
pixhawk committed
public:
    QGCParamWidget(UASInterface* uas, QWidget *parent = 0);
LM's avatar
LM committed

tstellanova's avatar
tstellanova committed
protected:
    virtual void setParameterStatusMsg(const QString& msg);
    virtual void layoutWidget();
tstellanova's avatar
tstellanova committed

pixhawk's avatar
pixhawk committed
signals:
    /** @brief A parameter was changed in the widget, NOT onboard */
oberion's avatar
oberion committed
    //void parameterChanged(int component, QString parametername, float value); // defined in QGCUASParamManager already
tstellanova's avatar
tstellanova committed

pixhawk's avatar
pixhawk committed
public slots:
tstellanova's avatar
tstellanova committed
    /** @brief Add a component to the list
     * @param compId Component id of the component
     * @param compName Human friendly name of the component
     */
    void addComponentItem(int compId, QString compName);

lm's avatar
lm committed
    /** @brief Add a parameter to the list with retransmission / safety checks */
tstellanova's avatar
tstellanova committed
//    void receivedParameterUpdate(int uas, int component, int paramCount, int paramId, QString parameterName, QVariant value);

tstellanova's avatar
tstellanova committed
    virtual void handleParameterUpdate(int component,const QString& parameterName, QVariant value);
tstellanova's avatar
tstellanova committed
    virtual void handleParameterListUpToDate();

    virtual void handleParamStatusMsgUpdate(QString msg, int level);
tstellanova's avatar
tstellanova committed

    /** @brief Ensure that view of parameter matches data in the model */
    void updateParameterDisplay(int component, QString parameterName, QVariant value);
    /** @brief Request list of parameters from MAV */
    void requestAllParamsUpdate();
    /** @brief Set one parameter, changes value in RAM of MAV */
tstellanova's avatar
tstellanova committed
//    virtual void setParameter(int component, QString parameterName, QVariant value);
    /** @brief Set all parameters, changes the value in RAM of MAV */
    void setParameters();
    /** @brief Write the current parameters to permanent storage (EEPROM/HDD) */
    void writeParameters();
    /** @brief Read the parameters from permanent storage to RAM */
    void readParameters();
    /** @brief Clear the parameter list */
pixhawk's avatar
pixhawk committed
    void clear();
lm's avatar
lm committed
    /** @brief Update when user changes parameters */
    void parameterItemChanged(QTreeWidgetItem* prev, int column);

    /** @brief Store parameters to a file */
    void saveParametersToFile();
    /** @brief Load parameters from a file */
    void loadParametersFromFile();

tstellanova's avatar
tstellanova committed

pixhawk's avatar
pixhawk committed
protected:
lm's avatar
lm committed
    QTreeWidget* tree;   ///< The parameter tree
tstellanova's avatar
tstellanova committed
    QLabel* statusLabel; ///< User-facing parameter status label
    QMap<int, QTreeWidgetItem*>* componentItems; ///< The tree of component items, stored by component ID
    QMap<int, QMap<QString, QTreeWidgetItem*>* > paramGroups; ///< Parameter groups to organize component items
lm's avatar
lm committed

pixhawk's avatar
pixhawk committed
};

#endif // QGCPARAMWIDGET_H