Commit 123707a9 authored by Lorenz Meier's avatar Lorenz Meier

Allowed flexible config initialization

parent 179cb286
......@@ -222,6 +222,7 @@ FORMS += src/ui/MainWindow.ui \
src/ui/mission/QGCMissionDoStartSearch.ui \
src/ui/mission/QGCMissionDoFinishSearch.ui \
src/ui/QGCVehicleConfig.ui \
src/ui/QGCPX4VehicleConfig.ui \
src/ui/QGCHilConfiguration.ui \
src/ui/QGCHilFlightGearConfiguration.ui \
src/ui/QGCHilJSBSimConfiguration.ui \
......@@ -261,7 +262,8 @@ FORMS += src/ui/MainWindow.ui \
src/ui/configuration/ParamWidget.ui \
src/ui/configuration/ArduPlanePidConfig.ui \
src/ui/configuration/AdvParameterList.ui \
src/ui/configuration/ArduRoverPidConfig.ui
src/ui/configuration/ArduRoverPidConfig.ui \
src/ui/QGCConfigView.ui
INCLUDEPATH += src \
src/ui \
......@@ -401,6 +403,7 @@ HEADERS += src/MG.h \
src/ui/mission/QGCMissionDoStartSearch.h \
src/ui/mission/QGCMissionDoFinishSearch.h \
src/ui/QGCVehicleConfig.h \
src/ui/QGCPX4VehicleConfig.h \
src/comm/QGCHilLink.h \
src/ui/QGCHilConfiguration.h \
src/ui/QGCHilFlightGearConfiguration.h \
......@@ -451,7 +454,8 @@ HEADERS += src/MG.h \
src/ui/configuration/ParamWidget.h \
src/ui/configuration/ArduPlanePidConfig.h \
src/ui/configuration/AdvParameterList.h \
src/ui/configuration/ArduRoverPidConfig.h
src/ui/configuration/ArduRoverPidConfig.h \
src/ui/QGCConfigView.h
# Google Earth is only supported on Mac OS and Windows with Visual Studio Compiler
macx|macx-g++|macx-g++42|win32-msvc2008|win32-msvc2010|win32-msvc2012::HEADERS += src/ui/map3D/QGCGoogleEarthView.h
......@@ -608,6 +612,7 @@ SOURCES += src/main.cc \
src/ui/mission/QGCMissionDoStartSearch.cc \
src/ui/mission/QGCMissionDoFinishSearch.cc \
src/ui/QGCVehicleConfig.cc \
src/ui/QGCPX4VehicleConfig.cc \
src/ui/QGCHilConfiguration.cc \
src/ui/QGCHilFlightGearConfiguration.cc \
src/ui/QGCHilJSBSimConfiguration.cc \
......@@ -657,7 +662,8 @@ SOURCES += src/main.cc \
src/ui/configuration/ParamWidget.cc \
src/ui/configuration/ArduPlanePidConfig.cc \
src/ui/configuration/AdvParameterList.cc \
src/ui/configuration/ArduRoverPidConfig.cc
src/ui/configuration/ArduRoverPidConfig.cc \
src/ui/QGCConfigView.cc
# Enable Google Earth only on Mac OS and Windows with Visual Studio compiler
macx|macx-g++|macx-g++42|win32-msvc2008|win32-msvc2010|win32-msvc2012::SOURCES += src/ui/map3D/QGCGoogleEarthView.cc
......
......@@ -69,6 +69,7 @@ This file is part of the QGROUNDCONTROL project
#include <apmtoolbar.h>
#include <ApmHardwareConfig.h>
#include <ApmSoftwareConfig.h>
#include <QGCConfigView.h>
#ifdef QGC_OSG_ENABLED
#include "Q3DWidgetFactory.h"
......@@ -199,12 +200,13 @@ void MainWindow::init()
toolBar = new QGCToolBar(this);
this->addToolBar(toolBar);
ui.actionHardwareConfig->setText(tr("Config"));
// Add actions for average users (displayed next to each other)
QList<QAction*> actions;
actions << ui.actionFlightView;
actions << ui.actionMissionView;
actions << ui.actionHardwareConfig;
actions << ui.actionSoftwareConfig;
toolBar->setPerspectiveChangeActions(actions);
// Add actions for advanced users (displayed in dropdown under "advanced")
......@@ -512,22 +514,33 @@ void MainWindow::buildCommonWidgets()
pilotView->setCentralWidget(new QGCMapTool(this));
addCentralWidget(pilotView, "Pilot");
}
if (!configView)
{
configView = new SubMainWindow(this);
configView->setObjectName("VIEW_HARDWARE_CONFIG");
configView->setCentralWidget(new ApmHardwareConfig(this));
addCentralWidget(configView,"Hardware");
centralWidgetToDockWidgetsMap[VIEW_HARDWARE_CONFIG] = QMap<QString,QWidget*>();
if (apmToolBarEnabled) {
if (!configView)
{
configView = new SubMainWindow(this);
configView->setObjectName("VIEW_HARDWARE_CONFIG");
configView->setCentralWidget(new ApmHardwareConfig(this));
addCentralWidget(configView,"Hardware");
centralWidgetToDockWidgetsMap[VIEW_HARDWARE_CONFIG] = QMap<QString,QWidget*>();
}
if (!softwareConfigView)
{
softwareConfigView = new SubMainWindow(this);
softwareConfigView->setObjectName("VIEW_SOFTWARE_CONFIG");
softwareConfigView->setCentralWidget(new ApmSoftwareConfig(this));
addCentralWidget(softwareConfigView,"Software");
centralWidgetToDockWidgetsMap[VIEW_SOFTWARE_CONFIG] = QMap<QString,QWidget*>();
}
if (!softwareConfigView)
{
softwareConfigView = new SubMainWindow(this);
softwareConfigView->setObjectName("VIEW_SOFTWARE_CONFIG");
softwareConfigView->setCentralWidget(new ApmSoftwareConfig(this));
addCentralWidget(softwareConfigView,"Software");
centralWidgetToDockWidgetsMap[VIEW_SOFTWARE_CONFIG] = QMap<QString,QWidget*>();
}
} else {
if (!configView)
{
configView = new SubMainWindow(this);
configView->setObjectName("VIEW_HARDWARE_CONFIG");
configView->setCentralWidget(new QGCConfigView(this));
addCentralWidget(configView,"Config");
centralWidgetToDockWidgetsMap[VIEW_HARDWARE_CONFIG] = QMap<QString,QWidget*>();
}
}
if (!engineeringView)
{
......@@ -1477,7 +1490,9 @@ void MainWindow::connectCommonActions()
connect(ui.actionMissionView, SIGNAL(triggered()), this, SLOT(loadOperatorView()));
connect(ui.actionUnconnectedView, SIGNAL(triggered()), this, SLOT(loadUnconnectedView()));
connect(ui.actionHardwareConfig,SIGNAL(triggered()),this,SLOT(loadHardwareConfigView()));
connect(ui.actionSoftwareConfig,SIGNAL(triggered()),this,SLOT(loadSoftwareConfigView()));
if (apmToolBarEnabled) {
connect(ui.actionSoftwareConfig,SIGNAL(triggered()),this,SLOT(loadSoftwareConfigView()));
}
connect(ui.actionFirmwareUpdateView, SIGNAL(triggered()), this, SLOT(loadFirmwareUpdateView()));
connect(ui.actionMavlinkView, SIGNAL(triggered()), this, SLOT(loadMAVLinkView()));
......@@ -1973,7 +1988,8 @@ void MainWindow::loadViewState()
centerStack->setCurrentWidget(configView);
break;
case VIEW_SOFTWARE_CONFIG:
centerStack->setCurrentWidget(softwareConfigView);
if (softwareConfigView)
centerStack->setCurrentWidget(softwareConfigView);
break;
case VIEW_ENGINEER:
centerStack->setCurrentWidget(engineeringView);
......
#include "QGCConfigView.h"
#include "ui_QGCConfigView.h"
#include "UASManager.h"
#include "QGCPX4VehicleConfig.h"
#include "QGCVehicleConfig.h"
#include "QGCPX4VehicleConfig.h"
QGCConfigView::QGCConfigView(QWidget *parent) :
QWidget(parent),
ui(new Ui::QGCConfigView),
currUAS(NULL)
{
ui->setupUi(this);
connect(UASManager::instance(), SIGNAL(activeUASSet(UASInterface*)), this, SLOT(activeUASChanged(UASInterface*)));
if (ui->waitingLabel) {
ui->gridLayout->removeWidget(ui->waitingLabel);
delete ui->waitingLabel;
ui->waitingLabel = NULL;
}
ui->gridLayout->addWidget(new QGCPX4VehicleConfig());
}
QGCConfigView::~QGCConfigView()
{
delete ui;
}
void QGCConfigView::activeUASChanged(UASInterface* uas)
{
if (currUAS == uas)
return;
if (ui->waitingLabel) {
ui->gridLayout->removeWidget(ui->waitingLabel);
delete ui->waitingLabel;
ui->waitingLabel = NULL;
}
if (currUAS && currUAS->getAutopilotType() != uas->getAutopilotType()) {
foreach (QObject* obj, ui->gridLayout->children()) {
QWidget* w = dynamic_cast<QWidget*>(obj);
if (w) {
ui->gridLayout->removeWidget(w);
delete obj;
}
}
}
switch (uas->getAutopilotType()) {
case MAV_AUTOPILOT_PX4:
ui->gridLayout->addWidget(new QGCPX4VehicleConfig());
default:
ui->gridLayout->addWidget(new QGCVehicleConfig());
}
}
#ifndef QGCCONFIGVIEW_H
#define QGCCONFIGVIEW_H
#include <QWidget>
#include <UASInterface.h>
namespace Ui {
class QGCConfigView;
}
class QGCConfigView : public QWidget
{
Q_OBJECT
public:
explicit QGCConfigView(QWidget *parent = 0);
~QGCConfigView();
public slots:
void activeUASChanged(UASInterface* uas);
private:
Ui::QGCConfigView *ui;
UASInterface* currUAS;
};
#endif // QGCCONFIGVIEW_H
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>QGCConfigView</class>
<widget class="QWidget" name="QGCConfigView">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="waitingLabel">
<property name="text">
<string>Waiting for connection...</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
This diff is collapsed.
#ifndef QGCPX4VehicleConfig_H
#define QGCPX4VehicleConfig_H
#include <QWidget>
#include <QTimer>
#include <QList>
#include <QGroupBox>
#include <QPushButton>
#include "QGCToolWidget.h"
#include "UASInterface.h"
namespace Ui {
class QGCPX4VehicleConfig;
}
class QGCPX4VehicleConfig : public QWidget
{
Q_OBJECT
public:
explicit QGCPX4VehicleConfig(QWidget *parent = 0);
~QGCPX4VehicleConfig();
enum RC_MODE {
RC_MODE_1 = 1,
RC_MODE_2 = 2,
RC_MODE_3 = 3,
RC_MODE_4 = 4,
RC_MODE_NONE = 5
};
public slots:
void rcMenuButtonClicked();
void sensorMenuButtonClicked();
void generalMenuButtonClicked();
void advancedMenuButtonClicked();
/** Set the MAV currently being calibrated */
void setActiveUAS(UASInterface* active);
/** Fallback function, automatically called by loadConfig() upon failure to find and xml file*/
void loadQgcConfig(bool primary);
/** Load configuration from xml file */
void loadConfig();
/** Start the RC calibration routine */
void startCalibrationRC();
/** Stop the RC calibration routine */
void stopCalibrationRC();
/** Start/stop the RC calibration routine */
void toggleCalibrationRC(bool enabled);
/** Set trim positions */
void setTrimPositions();
/** Detect which channels need to be inverted */
void detectChannelInversion();
/** Change the mode setting of the control inputs */
void setRCModeIndex(int newRcMode);
/** Render the data updated */
void updateView();
void updateMinMax();
/** Set the RC channel */
void setRollChan(int channel) {
rcMapping[0] = channel - 1;
updateInvertedCheckboxes(channel - 1);
}
/** Set the RC channel */
void setPitchChan(int channel) {
rcMapping[1] = channel - 1;
updateInvertedCheckboxes(channel - 1);
}
/** Set the RC channel */
void setYawChan(int channel) {
rcMapping[2] = channel - 1;
updateInvertedCheckboxes(channel - 1);
}
/** Set the RC channel */
void setThrottleChan(int channel) {
rcMapping[3] = channel - 1;
updateInvertedCheckboxes(channel - 1);
}
/** Set the RC channel */
void setModeChan(int channel) {
rcMapping[4] = channel - 1;
updateInvertedCheckboxes(channel - 1);
}
/** Set the RC channel */
void setAux1Chan(int channel) {
rcMapping[5] = channel - 1;
updateInvertedCheckboxes(channel - 1);
}
/** Set the RC channel */
void setAux2Chan(int channel) {
rcMapping[6] = channel - 1;
updateInvertedCheckboxes(channel - 1);
}
/** Set the RC channel */
void setAux3Chan(int channel) {
rcMapping[7] = channel - 1;
updateInvertedCheckboxes(channel - 1);
}
/** Set channel inversion status */
void setRollInverted(bool inverted) {
rcRev[rcMapping[0]] = inverted;
}
/** Set channel inversion status */
void setPitchInverted(bool inverted) {
rcRev[rcMapping[1]] = inverted;
}
/** Set channel inversion status */
void setYawInverted(bool inverted) {
rcRev[rcMapping[2]] = inverted;
}
/** Set channel inversion status */
void setThrottleInverted(bool inverted) {
rcRev[rcMapping[3]] = inverted;
}
/** Set channel inversion status */
void setModeInverted(bool inverted) {
rcRev[rcMapping[4]] = inverted;
}
/** Set channel inversion status */
void setAux1Inverted(bool inverted) {
rcRev[rcMapping[5]] = inverted;
}
/** Set channel inversion status */
void setAux2Inverted(bool inverted) {
rcRev[rcMapping[6]] = inverted;
}
/** Set channel inversion status */
void setAux3Inverted(bool inverted) {
rcRev[rcMapping[7]] = inverted;
}
protected slots:
void menuButtonClicked();
/** Reset the RC calibration */
void resetCalibrationRC();
/** Write the RC calibration */
void writeCalibrationRC();
/** Request the RC calibration */
void requestCalibrationRC();
/** Store all parameters in onboard EEPROM */
void writeParameters();
/** Receive remote control updates from MAV */
void remoteControlChannelRawChanged(int chan, float val);
/** Parameter changed onboard */
void parameterChanged(int uas, int component, QString parameterName, QVariant value);
void updateStatus(const QString& str);
void updateError(const QString& str);
void setRCType(int type);
/** Check timeouts */
void checktimeOuts();
/** Update checkbox status */
void updateInvertedCheckboxes(int index);
protected:
bool doneLoadingConfig;
UASInterface* mav; ///< The current MAV
static const unsigned int chanMax = 8; ///< Maximum number of channels
unsigned int chanCount; ///< Actual channels
int rcType; ///< Type of the remote control
quint64 rcTypeUpdateRequested; ///< Zero if not requested, non-zero if requested
static const unsigned int rcTypeTimeout = 5000; ///< 5 seconds timeout, in milliseconds
float rcMin[chanMax]; ///< Minimum values
float rcMax[chanMax]; ///< Maximum values
float rcTrim[chanMax]; ///< Zero-position (center for roll/pitch/yaw, 0 throttle for throttle)
int rcMapping[chanMax]; ///< PWM to function mappings
float rcScaling[chanMax]; ///< Scaling of channel input to control commands
bool rcRev[chanMax]; ///< Channel reverse
int rcValue[chanMax]; ///< Last values
float rcRoll; ///< PPM input channel used as roll control input
float rcPitch; ///< PPM input channel used as pitch control input
float rcYaw; ///< PPM input channel used as yaw control input
float rcThrottle; ///< PPM input channel used as throttle control input
float rcMode; ///< PPM input channel used as mode switch control input
float rcAux1; ///< PPM input channel used as aux 1 input
float rcAux2; ///< PPM input channel used as aux 1 input
float rcAux3; ///< PPM input channel used as aux 1 input
bool rcCalChanged; ///< Set if the calibration changes (and needs to be written)
bool changed; ///< Set if any of the input data changed
QTimer updateTimer; ///< Controls update intervals
enum RC_MODE rc_mode; ///< Mode of the remote control, according to usual convention
QList<QGCToolWidget*> toolWidgets; ///< Configurable widgets
bool calibrationEnabled; ///< calibration mode on / off
QMap<QString,QGCToolWidget*> paramToWidgetMap; ///< Holds the current active MAV's parameter widgets.
QList<QWidget*> additionalTabs; ///< Stores additional tabs loaded for this vehicle/autopilot configuration. Used for cleaning up.
QMap<QString,QGCToolWidget*> libParamToWidgetMap; ///< Holds the library parameter widgets
QMap<QString,QMap<QString,QGCToolWidget*> > systemTypeToParamMap; ///< Holds all loaded MAV specific parameter widgets, for every MAV.
QMap<QGCToolWidget*,QGroupBox*> toolToBoxMap; ///< Easy method of figuring out which QGroupBox is tied to which ToolWidget.
QMap<QString,QString> paramTooltips; ///< Tooltips for the ? button next to a parameter.
private:
Ui::QGCPX4VehicleConfig *ui;
QMap<QPushButton*,QWidget*> buttonToWidgetMap;
signals:
void visibilityChanged(bool visible);
};
#endif // QGCPX4VehicleConfig_H
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment