diff --git a/src/ui/DebugConsole.cc b/src/ui/DebugConsole.cc index 6da73bfcaae2b31232c5dbb305537fd78d9e1954..f5af15c5f4a2b250b798883d1a3680b81dfd4f53 100644 --- a/src/ui/DebugConsole.cc +++ b/src/ui/DebugConsole.cc @@ -454,18 +454,10 @@ void DebugConsole::handleConnectButton() if (currLink->isConnected()) { currLink->disconnect(); - m_ui->connectButton->setText(tr("Connect")); } else { - if (currLink->connect()) - { - m_ui->connectButton->setText(tr("Disconn.")); - } - else - { - m_ui->receiveText->appendHtml(QString("%2").arg(QGC::colorRed.name(), tr("Could not connect link %1 ! Please check link hardware.").arg(currLink->getName()))); - } + currLink->connect(); } } } diff --git a/src/ui/MainWindow.cc b/src/ui/MainWindow.cc index 3fba2a607ac03a6144ea30c0ef49b6ad49f3be5b..7844374f28b6d836bae7fa7e9236c58a75da9cc0 100644 --- a/src/ui/MainWindow.cc +++ b/src/ui/MainWindow.cc @@ -745,6 +745,7 @@ void MainWindow::connectSlugsWidgets() void MainWindow::arrangeCommonCenterStack() { centerStack = new QStackedWidget(this); + centerStack->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); if (!centerStack) return; diff --git a/src/ui/MainWindow.ui b/src/ui/MainWindow.ui index 5eafe8d01109c4f0a2f2689fdebb5fb18296f657..285640565f732a0be70aadf02632ec65e7d95955 100644 --- a/src/ui/MainWindow.ui +++ b/src/ui/MainWindow.ui @@ -38,7 +38,7 @@ 0 0 1000 - 22 + 25 diff --git a/src/ui/UASControl.ui b/src/ui/UASControl.ui index 1dfe7861b79ee81f4c2b2e2faa949601f5e0e898..d1a6f6c8656bc2e549656c86f237230ac6566c64 100644 --- a/src/ui/UASControl.ui +++ b/src/ui/UASControl.ui @@ -6,8 +6,8 @@ 0 0 - 210 - 141 + 222 + 172 @@ -18,14 +18,23 @@ - 210 - 130 + 222 + 172 + + + + + 267 + 194 Form - + + Control widget to send basic control actions to the micro air vehicle + + @@ -93,7 +102,7 @@ - Liftoff + Start diff --git a/src/ui/designer/QGCActionButton.cc b/src/ui/designer/QGCActionButton.cc index 1b38f3a94e85d45e55d1f0ee28679293d7556a8f..461e3a9beba1d380e80e5f812f294658f8de1241 100644 --- a/src/ui/designer/QGCActionButton.cc +++ b/src/ui/designer/QGCActionButton.cc @@ -42,17 +42,12 @@ const char* kActionLabels[MAV_ACTION_NB] = "RESET MAP"}; QGCActionButton::QGCActionButton(QWidget *parent) : - QGCToolWidgetItem(parent), + QGCToolWidgetItem("Button", parent), ui(new Ui::QGCActionButton), uas(NULL) { ui->setupUi(this); - connect(UASManager::instance(), SIGNAL(activeUASSet(UASInterface*)), - this, SLOT(setActiveUAS(UASInterface*))); - // Set first UAS if it exists - this->setActiveUAS(UASManager::instance()->getActiveUAS()); - connect(ui->actionButton, SIGNAL(clicked()), this, SLOT(sendAction())); connect(ui->editFinishButton, SIGNAL(clicked()), this, SLOT(endEditMode())); connect(ui->editButtonName, SIGNAL(textChanged(QString)), this, SLOT(setActionButtonName(QString))); @@ -73,12 +68,16 @@ QGCActionButton::~QGCActionButton() void QGCActionButton::sendAction() { - if (uas) + if (QGCToolWidgetItem::uas) { MAV_ACTION action = static_cast( ui->editActionComboBox->currentIndex()); - uas->setAction(action); + QGCToolWidgetItem::uas->setAction(action); + } + else + { + qDebug() << __FILE__ << __LINE__ << "NO UAS SET, DOING NOTHING"; } } @@ -110,8 +109,3 @@ void QGCActionButton::endEditMode() isInEditMode = false; } - -void QGCActionButton::setActiveUAS(UASInterface *uas) -{ - this->uas = uas; -} diff --git a/src/ui/designer/QGCActionButton.h b/src/ui/designer/QGCActionButton.h index 9f21b7338a3aca431a4d3ba97384b91fe3536e71..b018514f8bcdfeb565132d28bd37889f934f8a66 100644 --- a/src/ui/designer/QGCActionButton.h +++ b/src/ui/designer/QGCActionButton.h @@ -23,9 +23,6 @@ public slots: void startEditMode(); void endEditMode(); -private slots: - void setActiveUAS(UASInterface* uas); - private: Ui::QGCActionButton *ui; UASInterface* uas; diff --git a/src/ui/designer/QGCParamSlider.cc b/src/ui/designer/QGCParamSlider.cc index 3b8435e8dcb397f97ffcd9ce4aba21a76a0b80df..e76c69a20bd06a980413a592acafc33dee5e5fb4 100644 --- a/src/ui/designer/QGCParamSlider.cc +++ b/src/ui/designer/QGCParamSlider.cc @@ -3,9 +3,16 @@ #include "QGCParamSlider.h" #include "ui_QGCParamSlider.h" +#include "UASInterface.h" QGCParamSlider::QGCParamSlider(QWidget *parent) : - QGCToolWidgetItem(parent), + QGCToolWidgetItem("Slider", parent), + parameterName(""), + parameterValue(0.0f), + parameterScalingFactor(0.0), + parameterMin(0.0f), + parameterMax(0.0f), + component(0), ui(new Ui::QGCParamSlider) { ui->setupUi(this); @@ -48,6 +55,18 @@ void QGCParamSlider::endEditMode() isInEditMode = false; } +void QGCParamSlider::sendParameter() +{ + if (QGCToolWidgetItem::uas) + { + QGCToolWidgetItem::uas->setParameter(component, parameterName, parameterValue); + } + else + { + qDebug() << __FILE__ << __LINE__ << "NO UAS SET, DOING NOTHING"; + } +} + void QGCParamSlider::changeEvent(QEvent *e) { QWidget::changeEvent(e); diff --git a/src/ui/designer/QGCParamSlider.h b/src/ui/designer/QGCParamSlider.h index dadc288d09387e884bf2a629483813d5efcb60a2..97e0e8eb008af860f5cb6cc5031774cf3f30c2d3 100644 --- a/src/ui/designer/QGCParamSlider.h +++ b/src/ui/designer/QGCParamSlider.h @@ -22,8 +22,16 @@ public: public slots: void startEditMode(); void endEditMode(); + /** @brief Send the parameter to the MAV */ + void sendParameter(); protected: + 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 void changeEvent(QEvent *e); private: diff --git a/src/ui/designer/QGCToolWidget.cc b/src/ui/designer/QGCToolWidget.cc index ff52d6af2693204565e04bf39f0bcd67009d6e4f..4a3992b912ef0c274c17a3ccced481269b4d1ce6 100644 --- a/src/ui/designer/QGCToolWidget.cc +++ b/src/ui/designer/QGCToolWidget.cc @@ -50,7 +50,7 @@ void QGCToolWidget::addUAS(UASInterface* uas) void QGCToolWidget::contextMenuEvent (QContextMenuEvent* event) { QMenu menu(this); - menu.addAction(addParamAction); + //menu.addAction(addParamAction); menu.addAction(addButtonAction); menu.addAction(setTitleAction); menu.exec(event->globalPos()); diff --git a/src/ui/designer/QGCToolWidgetItem.cc b/src/ui/designer/QGCToolWidgetItem.cc index b1f9559899f43e68aac8471c63ee563a70845811..e66ab0b0c0db05d69258b6e96492d6915105cab8 100644 --- a/src/ui/designer/QGCToolWidgetItem.cc +++ b/src/ui/designer/QGCToolWidgetItem.cc @@ -3,16 +3,25 @@ #include #include -QGCToolWidgetItem::QGCToolWidgetItem(QWidget *parent) : +#include "UASManager.h" + +QGCToolWidgetItem::QGCToolWidgetItem(const QString& name, QWidget *parent) : QWidget(parent), isInEditMode(false), + qgcToolWidgetItemName(name), + uas(NULL), _component(-1) { - startEditAction = new QAction("Edit Slider", this); + startEditAction = new QAction("Edit "+qgcToolWidgetItemName, this); connect(startEditAction, SIGNAL(triggered()), this, SLOT(startEditMode())); stopEditAction = new QAction("Finish Editing Slider", this); connect(stopEditAction, SIGNAL(triggered()), this, SLOT(endEditMode())); + connect(UASManager::instance(), SIGNAL(activeUASSet(UASInterface*)), + this, SLOT(setActiveUAS(UASInterface*))); + // Set first UAS if it exists + setActiveUAS(UASManager::instance()->getActiveUAS()); + endEditMode(); } @@ -35,3 +44,8 @@ void QGCToolWidgetItem::contextMenuEvent (QContextMenuEvent* event) } menu.exec(event->globalPos()); } + +void QGCToolWidgetItem::setActiveUAS(UASInterface *uas) +{ + this->uas = uas; +} diff --git a/src/ui/designer/QGCToolWidgetItem.h b/src/ui/designer/QGCToolWidgetItem.h index 2577f438e2e69daa790ce742304bbb7a21874e67..a3ee5b6f4d86ce205a43f3e1625cc3a1f24ee2aa 100644 --- a/src/ui/designer/QGCToolWidgetItem.h +++ b/src/ui/designer/QGCToolWidgetItem.h @@ -4,11 +4,13 @@ #include #include +#include "UASInterface.h" + class QGCToolWidgetItem : public QWidget { Q_OBJECT public: - explicit QGCToolWidgetItem(QWidget *parent = 0); + QGCToolWidgetItem(const QString& name, QWidget *parent = 0); ~QGCToolWidgetItem(); int component() {return _component;} @@ -17,12 +19,14 @@ public slots: virtual void startEditMode() {} virtual void endEditMode() {} virtual void setComponent(int comp) {_component = comp;} + void setActiveUAS(UASInterface *uas); protected: QAction* startEditAction; QAction* stopEditAction; - bool isInEditMode; + QString qgcToolWidgetItemName; + UASInterface* uas; int _component; ///< The MAV component (the process or device ID) void contextMenuEvent (QContextMenuEvent* event); diff --git a/src/ui/uas/UASControlWidget.cc b/src/ui/uas/UASControlWidget.cc index 88dd3dd75b463254e68f5ea2d8b90adc6938cd35..842c15046dddcab5fed21d94239b855d8cbdc404 100644 --- a/src/ui/uas/UASControlWidget.cc +++ b/src/ui/uas/UASControlWidget.cc @@ -114,18 +114,18 @@ void UASControlWidget::setUAS(UASInterface* uas) // Check if additional controls should be loaded UAS* mav = dynamic_cast(uas); if (mav) - { + { QPushButton* startRecButton = new QPushButton(tr("Record")); connect(startRecButton, SIGNAL(clicked()), mav, SLOT(startDataRecording())); - ui.gridLayout->addWidget(startRecButton, 10, 0, 0, 2); + ui.gridLayout->addWidget(startRecButton, 7, 1); QPushButton* pauseRecButton = new QPushButton(tr("Pause")); connect(pauseRecButton, SIGNAL(clicked()), mav, SLOT(pauseDataRecording())); - ui.gridLayout->addWidget(pauseRecButton, 10, 2, 0, 2); + ui.gridLayout->addWidget(pauseRecButton, 7, 3); QPushButton* stopRecButton = new QPushButton(tr("Stop")); connect(stopRecButton, SIGNAL(clicked()), mav, SLOT(stopDataRecording())); - ui.gridLayout->addWidget(stopRecButton, 10, 4, 0, 2); + ui.gridLayout->addWidget(stopRecButton, 7, 4); }