From 37d8faf2ff749e74ea042ff59e7254b59802b09c Mon Sep 17 00:00:00 2001 From: John Tapsell Date: Sun, 13 Oct 2013 21:33:43 +0100 Subject: [PATCH 1/5] Message view - only show "clear text" context menu when we are actually showing text --- src/ui/uas/QGCMessageView.cc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/ui/uas/QGCMessageView.cc b/src/ui/uas/QGCMessageView.cc index a1fdcce..5c583e0 100644 --- a/src/ui/uas/QGCMessageView.cc +++ b/src/ui/uas/QGCMessageView.cc @@ -87,7 +87,9 @@ void QGCMessageView::handleTextMessage(int uasid, int compId, int severity, QStr void QGCMessageView::contextMenuEvent(QContextMenuEvent* event) { - QMenu menu(this); - menu.addAction(clearAction); - menu.exec(event->globalPos()); + if(activeUAS) { + QMenu menu(this); + menu.addAction(clearAction); + menu.exec(event->globalPos()); + } } From b37fa76b4d872202d6fc63c84e77815d9787ec9a Mon Sep 17 00:00:00 2001 From: John Tapsell Date: Sun, 13 Oct 2013 23:12:53 +0100 Subject: [PATCH 2/5] Allow custom widget to be deleted --- src/ui/MainWindow.cc | 14 ++++++++++++-- src/ui/MainWindow.h | 4 ++++ src/ui/designer/QGCToolWidget.cc | 9 +++++---- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/src/ui/MainWindow.cc b/src/ui/MainWindow.cc index 454c44d..57827bb 100644 --- a/src/ui/MainWindow.cc +++ b/src/ui/MainWindow.cc @@ -753,6 +753,7 @@ void MainWindow::addTool(SubMainWindow *parent,VIEW_SECTIONS view,QDockWidget* w centralWidgetToDockWidgetsMap[view][widget->objectName()]= widget; connect(tempAction,SIGNAL(triggered(bool)),this, SLOT(showTool(bool))); connect(widget, SIGNAL(visibilityChanged(bool)), tempAction, SLOT(setChecked(bool))); + connect(widget, SIGNAL(destroyed()), tempAction, SLOT(deleteLater())); tempAction->setChecked(widget->isVisible()); } else @@ -786,9 +787,20 @@ QDockWidget* MainWindow::createDockWidget(QWidget *parent,QWidget *child,QString widget->setMinimumWidth(minwidth); } addTool(qobject_cast(parent),view,widget,title,area); + connect(child, SIGNAL(destroyed()), widget, SLOT(deleteLater())); + connect(widget, SIGNAL(destroyed()), this, SLOT(dockWidgetDestroyed())); return widget; } +void MainWindow::dockWidgetDestroyed() +{ + QDockWidget *dock = dynamic_cast(QObject::sender()); + Q_ASSERT(dock); + if(!dock) return; + + dockWidgets.removeAll(dock); +} + void MainWindow::loadDockWidget(QString name) { if (centralWidgetToDockWidgetsMap[currentView].contains(name)) @@ -1039,8 +1051,6 @@ void MainWindow::createCustomWidget() settings.setValue(QString("TOOL_PARENT_") + tool->objectName(),currentView); settings.endGroup(); - - //connect(tool, SIGNAL(destroyed()), dock, SLOT(deleteLater())); //dock->setWidget(tool); diff --git a/src/ui/MainWindow.h b/src/ui/MainWindow.h index c5db0bc..b5a5b50 100644 --- a/src/ui/MainWindow.h +++ b/src/ui/MainWindow.h @@ -307,6 +307,10 @@ public slots: void commsWidgetDestroyed(QObject *obj); +protected slots: + /** @brief Called by a dock widget when it is has been deleted */ + void dockWidgetDestroyed(); + signals: void styleChanged(MainWindow::QGC_MAINWINDOW_STYLE newTheme); void styleChanged(); diff --git a/src/ui/designer/QGCToolWidget.cc b/src/ui/designer/QGCToolWidget.cc index 52072e8..73eae34 100644 --- a/src/ui/designer/QGCToolWidget.cc +++ b/src/ui/designer/QGCToolWidget.cc @@ -668,11 +668,12 @@ void QGCToolWidget::deleteWidget() // Hide this->hide(); instances()->remove(getTitle()); - /*QSettings settings; - settings.beginGroup(getTitle()); - settings.remove(""); + + QSettings settings; + settings.beginGroup("QGC_MAINWINDOW"); + settings.remove(QString("TOOL_PARENT_") + objectName()); settings.endGroup(); - storeWidgetsToSettings();*/ + storeWidgetsToSettings(); // Delete From 27c1dd274f7c45994981da417130779f33757d8c Mon Sep 17 00:00:00 2001 From: John Tapsell Date: Sun, 13 Oct 2013 23:33:31 +0100 Subject: [PATCH 3/5] Don't add two horizontal menu seperators for custom widgets --- src/ui/MainWindow.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ui/MainWindow.cc b/src/ui/MainWindow.cc index 57827bb..f3d6523 100644 --- a/src/ui/MainWindow.cc +++ b/src/ui/MainWindow.cc @@ -1038,7 +1038,7 @@ void MainWindow::createCustomWidget() //void MainWindow::createDockWidget(QWidget *parent,QWidget *child,QString title,QString objectname,VIEW_SECTIONS view,Qt::DockWidgetArea area,int minwidth,int minheight) //QDockWidget* dock = new QDockWidget("Unnamed Tool", this); - if (QGCToolWidget::instances()->size() < 2) + if (QGCToolWidget::instances()->isEmpty()) { // This is the first widget ui.menuTools->addSeparator(); From 0694a2ac1b63df0bcdab38297493b5800c7e7acf Mon Sep 17 00:00:00 2001 From: John Tapsell Date: Mon, 14 Oct 2013 10:56:09 +0100 Subject: [PATCH 4/5] The helper text for a line edit should use placeHolderText, not Text --- src/ui/designer/QGCActionButton.ui | 4 ++-- src/ui/designer/QGCCommandButton.ui | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ui/designer/QGCActionButton.ui b/src/ui/designer/QGCActionButton.ui index 8f0fb54..93144ae 100644 --- a/src/ui/designer/QGCActionButton.ui +++ b/src/ui/designer/QGCActionButton.ui @@ -61,14 +61,14 @@ - + Button name - + Description diff --git a/src/ui/designer/QGCCommandButton.ui b/src/ui/designer/QGCCommandButton.ui index eb26a67..854ca81 100644 --- a/src/ui/designer/QGCCommandButton.ui +++ b/src/ui/designer/QGCCommandButton.ui @@ -49,8 +49,8 @@ - - <Button Description Label (in front of button)> + + Button Description From a44dcf3cfe6c143be7dff8a17537683365e208fd Mon Sep 17 00:00:00 2001 From: John Tapsell Date: Mon, 14 Oct 2013 15:21:55 +0100 Subject: [PATCH 5/5] Replace 9 seperate valueChanged() signals with just 1, and remove the resultant tons of code duplication --- src/uas/UASInterface.h | 11 +-- src/ui/HDDisplay.cc | 93 +++++-------------------- src/ui/HDDisplay.h | 20 +----- src/ui/MAVLinkDecoder.h | 12 +--- src/ui/UASRawStatusView.cpp | 53 +++----------- src/ui/UASRawStatusView.h | 10 +-- src/ui/designer/QGCComboBox.ui | 4 +- src/ui/designer/QGCParamSlider.ui | 4 +- src/ui/linechart/LinechartWidget.cc | 133 +++--------------------------------- src/ui/linechart/LinechartWidget.h | 20 +----- src/ui/linechart/Linecharts.cc | 30 +------- src/ui/uas/UASQuickView.cc | 117 +++---------------------------- src/ui/uas/UASQuickView.h | 13 +--- 13 files changed, 64 insertions(+), 456 deletions(-) diff --git a/src/uas/UASInterface.h b/src/uas/UASInterface.h index e97ca67..fba940b 100644 --- a/src/uas/UASInterface.h +++ b/src/uas/UASInterface.h @@ -488,16 +488,7 @@ signals: * @param value the value that changed * @param msec the timestamp of the message, in milliseconds */ - void valueChanged(const int uasId, const QString& name, const QString& unit, const quint8 value, const quint64 msec); - void valueChanged(const int uasId, const QString& name, const QString& unit, const qint8 value, const quint64 msec); - void valueChanged(const int uasId, const QString& name, const QString& unit, const quint16 value, const quint64 msec); - void valueChanged(const int uasId, const QString& name, const QString& unit, const qint16 value, const quint64 msec); - void valueChanged(const int uasId, const QString& name, const QString& unit, const quint32 value, const quint64 msec); - void valueChanged(const int uasId, const QString& name, const QString& unit, const qint32 value, const quint64 msec); - void valueChanged(const int uasId, const QString& name, const QString& unit, const quint64 value, const quint64 msec); - void valueChanged(const int uasId, const QString& name, const QString& unit, const qint64 value, const quint64 msec); - void valueChanged(const int uasId, const QString& name, const QString& unit, const double value, const quint64 msec); - void valueChanged(const int uasid, const QString& name, const QString& unit, const QVariant value,const quint64 msecs); + void valueChanged(const int uasid, const QString& name, const QString& unit, const QVariant &value,const quint64 msecs); void voltageChanged(int uasId, double voltage); void waypointUpdated(int uasId, int id, double x, double y, double z, double yaw, bool autocontinue, bool active); diff --git a/src/ui/HDDisplay.cc b/src/ui/HDDisplay.cc index fe6f280..7c11cd8 100644 --- a/src/ui/HDDisplay.cc +++ b/src/ui/HDDisplay.cc @@ -865,93 +865,36 @@ float HDDisplay::refLineWidthToPen(float line) // Connect a generic source void HDDisplay::addSource(QObject* obj) { - //genericSources.append(obj); - // FIXME XXX HACK -// if (plots.size() > 0) -// { - connect(obj, SIGNAL(valueChanged(int,QString,QString,qint8,quint64)), this, SLOT(updateValue(int,QString,QString,qint8,quint64))); - connect(obj, SIGNAL(valueChanged(int,QString,QString,quint8,quint64)), this, SLOT(updateValue(int,QString,QString,quint8,quint64))); - connect(obj, SIGNAL(valueChanged(int,QString,QString,qint16,quint64)), this, SLOT(updateValue(int,QString,QString,qint16,quint64))); - connect(obj, SIGNAL(valueChanged(int,QString,QString,quint16,quint64)), this, SLOT(updateValue(int,QString,QString,quint16,quint64))); - connect(obj, SIGNAL(valueChanged(int,QString,QString,qint32,quint64)), this, SLOT(updateValue(int,QString,QString,qint32,quint64))); - connect(obj, SIGNAL(valueChanged(int,QString,QString,quint32,quint64)), this, SLOT(updateValue(int,QString,QString,quint32,quint64))); - connect(obj, SIGNAL(valueChanged(int,QString,QString,quint64,quint64)), this, SLOT(updateValue(int,QString,QString,quint64,quint64))); - connect(obj, SIGNAL(valueChanged(int,QString,QString,qint64,quint64)), this, SLOT(updateValue(int,QString,QString,qint64,quint64))); - connect(obj, SIGNAL(valueChanged(int,QString,QString,double,quint64)), this, SLOT(updateValue(int,QString,QString,double,quint64))); -// } + connect(obj, SIGNAL(valueChanged(int,QString,QString,QVariant,quint64)), this, SLOT(updateValue(int,QString,QString,QVariant,quint64))); } // Disconnect a generic source void HDDisplay::removeSource(QObject* obj) { - //genericSources.append(obj); - // FIXME XXX HACK -// if (plots.size() > 0) -// { - disconnect(obj, SIGNAL(valueChanged(int,QString,QString,qint8,quint64)), this, SLOT(updateValue(int,QString,QString,qint8,quint64))); - disconnect(obj, SIGNAL(valueChanged(int,QString,QString,quint8,quint64)), this, SLOT(updateValue(int,QString,QString,quint8,quint64))); - disconnect(obj, SIGNAL(valueChanged(int,QString,QString,qint16,quint64)), this, SLOT(updateValue(int,QString,QString,qint16,quint64))); - disconnect(obj, SIGNAL(valueChanged(int,QString,QString,quint16,quint64)), this, SLOT(updateValue(int,QString,QString,quint16,quint64))); - disconnect(obj, SIGNAL(valueChanged(int,QString,QString,qint32,quint64)), this, SLOT(updateValue(int,QString,QString,qint32,quint64))); - disconnect(obj, SIGNAL(valueChanged(int,QString,QString,quint32,quint64)), this, SLOT(updateValue(int,QString,QString,quint32,quint64))); - disconnect(obj, SIGNAL(valueChanged(int,QString,QString,quint64,quint64)), this, SLOT(updateValue(int,QString,QString,quint64,quint64))); - disconnect(obj, SIGNAL(valueChanged(int,QString,QString,qint64,quint64)), this, SLOT(updateValue(int,QString,QString,qint64,quint64))); - disconnect(obj, SIGNAL(valueChanged(int,QString,QString,double,quint64)), this, SLOT(updateValue(int,QString,QString,double,quint64))); -// } -} - -void HDDisplay::updateValue(const int uasId, const QString& name, const QString& unit, const qint8 value, const quint64 msec) -{ - if (!intValues.contains(name)) intValues.insert(name, true); - updateValue(uasId, name, unit, (double)value, msec); -} - -void HDDisplay::updateValue(const int uasId, const QString& name, const QString& unit, const quint8 value, const quint64 msec) -{ - if (!intValues.contains(name)) intValues.insert(name, true); - updateValue(uasId, name, unit, (double)value, msec); -} - -void HDDisplay::updateValue(const int uasId, const QString& name, const QString& unit, const qint16 value, const quint64 msec) -{ - if (!intValues.contains(name)) intValues.insert(name, true); - updateValue(uasId, name, unit, (double)value, msec); -} - -void HDDisplay::updateValue(const int uasId, const QString& name, const QString& unit, const quint16 value, const quint64 msec) -{ - if (!intValues.contains(name)) intValues.insert(name, true); - updateValue(uasId, name, unit, (double)value, msec); + disconnect(obj, SIGNAL(valueChanged(int,QString,QString,QVariant,quint64)), this, SLOT(updateValue(int,QString,QString,QVariant,quint64))); } -void HDDisplay::updateValue(const int uasId, const QString& name, const QString& unit, const qint32 value, const quint64 msec) +void HDDisplay::updateValue(const int uasId, const QString& name, const QString& unit, const QVariant &variant, const quint64 msec) { - if (!intValues.contains(name)) intValues.insert(name, true); - updateValue(uasId, name, unit, (double)value, msec); -} + Q_UNUSED(uasId); + Q_UNUSED(unit); -void HDDisplay::updateValue(const int uasId, const QString& name, const QString& unit, const quint32 value, const quint64 msec) -{ - if (!intValues.contains(name)) intValues.insert(name, true); - updateValue(uasId, name, unit, (double)value, msec); -} + QMetaType::Type type = static_cast< QMetaType::Type>(variant.type()); + if(type == QMetaType::QByteArray || type == QMetaType::QString) + return; -void HDDisplay::updateValue(const int uasId, const QString& name, const QString& unit, const qint64 value, const quint64 msec) -{ - if (!intValues.contains(name)) intValues.insert(name, true); - updateValue(uasId, name, unit, (double)value, msec); -} + bool ok; + double value = variant.toDouble(&ok); + if(!ok) + return; -void HDDisplay::updateValue(const int uasId, const QString& name, const QString& unit, const quint64 value, const quint64 msec) -{ - if (!intValues.contains(name)) intValues.insert(name, true); - updateValue(uasId, name, unit, (double)value, msec); -} + if(type == QMetaType::Int || type == QMetaType::UInt || type == QMetaType::Long || type == QMetaType::LongLong + || type == QMetaType::Short || type == QMetaType::Char || type == QMetaType::ULong || type == QMetaType::ULongLong + || type == QMetaType::UShort || type == QMetaType::UChar || type == QMetaType::Bool ) { + if (!intValues.contains(name)) + intValues.insert(name, true); + } -void HDDisplay::updateValue(const int uasId, const QString& name, const QString& unit, const double value, const quint64 msec) -{ - Q_UNUSED(uasId); - Q_UNUSED(unit); // Update mean const float oldMean = valuesMean.value(name, 0.0f); const int meanCount = valuesCount.value(name, 0); diff --git a/src/ui/HDDisplay.h b/src/ui/HDDisplay.h index 3993495..f6c5295 100644 --- a/src/ui/HDDisplay.h +++ b/src/ui/HDDisplay.h @@ -64,24 +64,8 @@ public: ~HDDisplay(); public slots: - /** @brief Update the HDD with new int8 data */ - void updateValue(const int uasId, const QString& name, const QString& unit, const qint8 value, const quint64 msec); - /** @brief Update the HDD with new uint8 data */ - void updateValue(const int uasId, const QString& name, const QString& unit, const quint8 value, const quint64 msec); - /** @brief Update the HDD with new int16 data */ - void updateValue(const int uasId, const QString& name, const QString& unit, const qint16 value, const quint64 msec); - /** @brief Update the HDD with new uint16 data */ - void updateValue(const int uasId, const QString& name, const QString& unit, const quint16 value, const quint64 msec); - /** @brief Update the HDD with new int32 data */ - void updateValue(const int uasId, const QString& name, const QString& unit, const qint32 value, const quint64 msec); - /** @brief Update the HDD with new uint32 data */ - void updateValue(const int uasId, const QString& name, const QString& unit, const quint32 value, const quint64 msec); - /** @brief Update the HDD with new int64 data */ - void updateValue(const int uasId, const QString& name, const QString& unit, const qint64 value, const quint64 msec); - /** @brief Update the HDD with new uint64 data */ - void updateValue(const int uasId, const QString& name, const QString& unit, const quint64 value, const quint64 msec); - /** @brief Update the HDD with new double data */ - void updateValue(const int uasId, const QString& name, const QString& unit, const double value, const quint64 msec); + /** @brief Update the HDD with new data */ + void updateValue(const int uasId, const QString& name, const QString& unit, const QVariant &value, const quint64 msec); virtual void setActiveUAS(UASInterface* uas); diff --git a/src/ui/MAVLinkDecoder.h b/src/ui/MAVLinkDecoder.h index 7031882..2feaa63 100644 --- a/src/ui/MAVLinkDecoder.h +++ b/src/ui/MAVLinkDecoder.h @@ -12,17 +12,7 @@ public: signals: void textMessageReceived(int uasid, int componentid, int severity, const QString& text); - void valueChanged(const int uasId, const QString& name, const QString& unit, const quint8 value, const quint64 msec); - void valueChanged(const int uasId, const QString& name, const QString& unit, const qint8 value, const quint64 msec); - void valueChanged(const int uasId, const QString& name, const QString& unit, const quint16 value, const quint64 msec); - void valueChanged(const int uasId, const QString& name, const QString& unit, const qint16 value, const quint64 msec); - void valueChanged(const int uasId, const QString& name, const QString& unit, const quint32 value, const quint64 msec); - void valueChanged(const int uasId, const QString& name, const QString& unit, const qint32 value, const quint64 msec); - void valueChanged(const int uasId, const QString& name, const QString& unit, const quint64 value, const quint64 msec); - void valueChanged(const int uasId, const QString& name, const QString& unit, const qint64 value, const quint64 msec); - void valueChanged(const int uasId, const QString& name, const QString& unit, const double value, const quint64 msec); - //void valueChanged(const int uasId, const QString& name, const QString& unit, const QVariant value, const quint64 msec); - + void valueChanged(const int uasId, const QString& name, const QString& unit, const QVariant& value, const quint64 msec); public slots: /** @brief Receive one message from the protocol and decode it */ diff --git a/src/ui/UASRawStatusView.cpp b/src/ui/UASRawStatusView.cpp index 5824ec6..b46af50 100644 --- a/src/ui/UASRawStatusView.cpp +++ b/src/ui/UASRawStatusView.cpp @@ -20,51 +20,20 @@ UASRawStatusView::UASRawStatusView(QWidget *parent) : QWidget(parent) } void UASRawStatusView::addSource(MAVLinkDecoder *decoder) { - connect(decoder,SIGNAL(valueChanged(int,QString,QString,double,quint64)),this,SLOT(valueChanged(int,QString,QString,double,quint64))); - connect(decoder,SIGNAL(valueChanged(int,QString,QString,qint8,quint64)),this,SLOT(valueChanged(int,QString,QString,qint8,quint64))); - connect(decoder,SIGNAL(valueChanged(int,QString,QString,qint16,quint64)),this,SLOT(valueChanged(int,QString,QString,qint16,quint64))); - connect(decoder,SIGNAL(valueChanged(int,QString,QString,qint32,quint64)),this,SLOT(valueChanged(int,QString,QString,qint32,quint64))); - connect(decoder,SIGNAL(valueChanged(int,QString,QString,qint64,quint64)),this,SLOT(valueChanged(int,QString,QString,qint64,quint64))); - connect(decoder,SIGNAL(valueChanged(int,QString,QString,quint8,quint64)),this,SLOT(valueChanged(int,QString,QString,quint8,quint64))); - connect(decoder,SIGNAL(valueChanged(int,QString,QString,qint16,quint64)),this,SLOT(valueChanged(int,QString,QString,qint16,quint64))); - connect(decoder,SIGNAL(valueChanged(int,QString,QString,quint32,quint64)),this,SLOT(valueChanged(int,QString,QString,quint32,quint64))); - connect(decoder,SIGNAL(valueChanged(int,QString,QString,quint64,quint64)),this,SLOT(valueChanged(int,QString,QString,quint64,quint64))); + connect(decoder,SIGNAL(valueChanged(int,QString,QString,QVariant,quint64)),this,SLOT(valueChanged(int,QString,QString,QVariant,quint64))); } -void UASRawStatusView::valueChanged(const int uasId, const QString& name, const QString& unit, const quint8 value, const quint64 msec) +void UASRawStatusView::valueChanged(const int uasId, const QString& name, const QString& unit, const QVariant &variant, const quint64 msec) { - valueChanged(uasId,name,unit,(double)value,msec); -} -void UASRawStatusView::valueChanged(const int uasId, const QString& name, const QString& unit, const qint8 value, const quint64 msec) -{ - valueChanged(uasId,name,unit,(double)value,msec); -} -void UASRawStatusView::valueChanged(const int uasId, const QString& name, const QString& unit, const quint16 value, const quint64 msec) -{ - valueChanged(uasId,name,unit,(double)value,msec); -} -void UASRawStatusView::valueChanged(const int uasId, const QString& name, const QString& unit, const qint16 value, const quint64 msec) -{ - valueChanged(uasId,name,unit,(double)value,msec); -} -void UASRawStatusView::valueChanged(const int uasId, const QString& name, const QString& unit, const quint32 value, const quint64 msec) -{ - valueChanged(uasId,name,unit,(double)value,msec); -} -void UASRawStatusView::valueChanged(const int uasId, const QString& name, const QString& unit, const qint32 value, const quint64 msec) -{ - valueChanged(uasId,name,unit,(double)value,msec); -} -void UASRawStatusView::valueChanged(const int uasId, const QString& name, const QString& unit, const quint64 value, const quint64 msec) -{ - valueChanged(uasId,name,unit,(double)value,msec); -} -void UASRawStatusView::valueChanged(const int uasId, const QString& name, const QString& unit, const qint64 value, const quint64 msec) -{ - valueChanged(uasId,name,unit,(double)value,msec); -} + Q_UNUSED(uasId); + Q_UNUSED(unit); + Q_UNUSED(msec); + + bool ok; + double value = variant.toDouble(&ok); + QMetaType::Type type = static_cast(variant.type()); + if(!ok || type == QMetaType::QString || type == QMetaType::QByteArray) + return; -void UASRawStatusView::valueChanged(const int uasId, const QString& name, const QString& unit, const double value, const quint64 msec) -{ valueMap[name] = value; if (nameToUpdateWidgetMap.contains(name)) { diff --git a/src/ui/UASRawStatusView.h b/src/ui/UASRawStatusView.h index cc38281..2da632c 100644 --- a/src/ui/UASRawStatusView.h +++ b/src/ui/UASRawStatusView.h @@ -15,15 +15,7 @@ public: void addSource(MAVLinkDecoder *decoder); private slots: void updateTableTimerTick(); - void valueChanged(const int uasId, const QString& name, const QString& unit, const quint8 value, const quint64 msec); - void valueChanged(const int uasId, const QString& name, const QString& unit, const qint8 value, const quint64 msec); - void valueChanged(const int uasId, const QString& name, const QString& unit, const quint16 value, const quint64 msec); - void valueChanged(const int uasId, const QString& name, const QString& unit, const qint16 value, const quint64 msec); - void valueChanged(const int uasId, const QString& name, const QString& unit, const quint32 value, const quint64 msec); - void valueChanged(const int uasId, const QString& name, const QString& unit, const qint32 value, const quint64 msec); - void valueChanged(const int uasId, const QString& name, const QString& unit, const quint64 value, const quint64 msec); - void valueChanged(const int uasId, const QString& name, const QString& unit, const qint64 value, const quint64 msec); - void valueChanged(const int uasId, const QString& name, const QString& unit, const double value, const quint64 msec); + void valueChanged(const int uasId, const QString& name, const QString& unit, const QVariant& value, const quint64 msec); protected: void resizeEvent(QResizeEvent *event); private: diff --git a/src/ui/designer/QGCComboBox.ui b/src/ui/designer/QGCComboBox.ui index f9d4db9..fdfbc79 100644 --- a/src/ui/designer/QGCComboBox.ui +++ b/src/ui/designer/QGCComboBox.ui @@ -75,8 +75,8 @@ - - <Parameter Name / Label> + + Parameter Name diff --git a/src/ui/designer/QGCParamSlider.ui b/src/ui/designer/QGCParamSlider.ui index 4635f01..e38c1f2 100644 --- a/src/ui/designer/QGCParamSlider.ui +++ b/src/ui/designer/QGCParamSlider.ui @@ -190,8 +190,8 @@ - - <Parameter Name / Label> + + Parameter Name / Label diff --git a/src/ui/linechart/LinechartWidget.cc b/src/ui/linechart/LinechartWidget.cc index 1c154f9..39f68c8 100644 --- a/src/ui/linechart/LinechartWidget.cc +++ b/src/ui/linechart/LinechartWidget.cc @@ -318,38 +318,15 @@ void LinechartWidget::toggleLogarithmicScaling(bool checked) activePlot->setLinearScaling(); } -void LinechartWidget::appendData(int uasId, const QString& curve, const QString& unit, qint8 value, quint64 usec) +void LinechartWidget::appendData(int uasId, const QString& curve, const QString& unit, const QVariant &variant, quint64 usec) { - appendData(uasId, curve, unit, static_cast(value), usec); -} - -void LinechartWidget::appendData(int uasId, const QString& curve, const QString& unit, quint8 value, quint64 usec) -{ - appendData(uasId, curve, unit, static_cast(value), usec); -} - -void LinechartWidget::appendData(int uasId, const QString& curve, const QString& unit, qint16 value, quint64 usec) -{ - appendData(uasId, curve, unit, static_cast(value), usec); -} - -void LinechartWidget::appendData(int uasId, const QString& curve, const QString& unit, quint16 value, quint64 usec) -{ - appendData(uasId, curve, unit, static_cast(value), usec); -} - -void LinechartWidget::appendData(int uasId, const QString& curve, const QString& unit, qint32 value, quint64 usec) -{ - appendData(uasId, curve, unit, static_cast(value), usec); -} - -void LinechartWidget::appendData(int uasId, const QString& curve, const QString& unit, quint32 value, quint64 usec) -{ - appendData(uasId, curve, unit, static_cast(value), usec); -} + QMetaType::Type type = static_cast(variant.type()); + bool ok; + double value = variant.toDouble(&ok); + if(!ok || type == QMetaType::QByteArray || type == QMetaType::QString) + return; + bool isDouble = type == QMetaType::Float || type == QMetaType::Double; -void LinechartWidget::appendData(int uasId, const QString& curve, const QString& unit, qint64 value, quint64 usec) -{ if ((selectedMAV == -1 && isVisible()) || (selectedMAV == uasId && isVisible())) { // Order matters here, first append to plot, then update curve list @@ -359,12 +336,14 @@ void LinechartWidget::appendData(int uasId, const QString& curve, const QString& // Make sure the curve will be created if it does not yet exist if(!label) { - intData.insert(curve+unit, 0); + if(!isDouble) + intData.insert(curve+unit, 0); addCurve(curve, unit); } // Add int data - intData.insert(curve+unit, value); + if(!isDouble) + intData.insert(curve+unit, variant.toInt()); } if (lastTimestamp == 0 && usec != 0) @@ -394,96 +373,6 @@ void LinechartWidget::appendData(int uasId, const QString& curve, const QString& } } -void LinechartWidget::appendData(int uasId, const QString& curve, const QString& unit, quint64 value, quint64 usec) -{ - if ((selectedMAV == -1 && isVisible()) || (selectedMAV == uasId && isVisible())) - { - // Order matters here, first append to plot, then update curve list - activePlot->appendData(curve+unit, usec, value); - // Store data - QLabel* label = curveLabels->value(curve+unit, NULL); - // Make sure the curve will be created if it does not yet exist - if(!label) - { - intData.insert(curve+unit, 0); - addCurve(curve, unit); - } - - // Add int data - intData.insert(curve+unit, value); - } - - if (lastTimestamp == 0 && usec != 0) - { - lastTimestamp = usec; - } else if (usec != 0) { - // Difference larger than 5 secs, enforce ground time - if (abs((int)((qint64)usec - (quint64)lastTimestamp)) > 5000) - { - autoGroundTimeSet = true; - if (activePlot) activePlot->groundTime(); - } - } - - // Log data - if (logging) - { - if (activePlot->isVisible(curve+unit)) - { - if (usec == 0) usec = QGC::groundTimeMilliseconds(); - if (logStartTime == 0) logStartTime = usec; - qint64 time = usec - logStartTime; - if (time < 0) time = 0; - - logFile->write(QString(QString::number(time) + "\t" + QString::number(uasId) + "\t" + curve + "\t" + QString::number(value) + "\n").toLatin1()); - logFile->flush(); - } - } -} - -void LinechartWidget::appendData(int uasId, const QString& curve, const QString& unit, double value, quint64 usec) -{ - if ((selectedMAV == -1 && isVisible()) || (selectedMAV == uasId && isVisible())) - { - // Order matters here, first append to plot, then update curve list - activePlot->appendData(curve+unit, usec, value); - // Store data - QLabel* label = curveLabels->value(curve+unit, NULL); - // Make sure the curve will be created if it does not yet exist - if(!label) - { - addCurve(curve, unit); - } - } - - if (lastTimestamp == 0 && usec != 0) - { - lastTimestamp = usec; - } else if (usec != 0) { - // Difference larger than 1 sec, enforce ground time - if (abs((int)((qint64)usec - (quint64)lastTimestamp)) > 1000) - { - autoGroundTimeSet = true; - if (activePlot) activePlot->groundTime(); - } - } - - // Log data - if (logging) - { - if (activePlot->isVisible(curve+unit)) - { - if (usec == 0) usec = QGC::groundTimeMilliseconds(); - if (logStartTime == 0) logStartTime = usec; - qint64 time = usec - logStartTime; - if (time < 0) time = 0; - - logFile->write(QString(QString::number(time) + "\t" + QString::number(uasId) + "\t" + curve + "\t" + QString::number(value,'g',18) + "\n").toLatin1()); - logFile->flush(); - } - } -} - void LinechartWidget::refresh() { setUpdatesEnabled(false); diff --git a/src/ui/linechart/LinechartWidget.h b/src/ui/linechart/LinechartWidget.h index de090b9..4640f2c 100644 --- a/src/ui/linechart/LinechartWidget.h +++ b/src/ui/linechart/LinechartWidget.h @@ -77,24 +77,8 @@ public slots: void recolor(); /** @brief Set short names for curves */ void setShortNames(bool enable); - /** @brief Append int8 data to the given curve. */ - void appendData(int uasId, const QString& curve, const QString& unit, qint8 value, quint64 usec); - /** @brief Append uint8 data to the given curve. */ - void appendData(int uasId, const QString& curve, const QString& unit, quint8 value, quint64 usec); - /** @brief Append int16 data to the given curve. */ - void appendData(int uasId, const QString& curve, const QString& unit, qint16 value, quint64 usec); - /** @brief Append uint16 data to the given curve. */ - void appendData(int uasId, const QString& curve, const QString& unit, quint16 value, quint64 usec); - /** @brief Append int32 data to the given curve. */ - void appendData(int uasId, const QString& curve, const QString& unit, qint32 value, quint64 usec); - /** @brief Append uint32 data to the given curve. */ - void appendData(int uasId, const QString& curve, const QString& unit, quint32 value, quint64 usec); - /** @brief Append int64 data to the given curve. */ - void appendData(int uasId, const QString& curve, const QString& unit, qint64 value, quint64 usec); - /** @brief Append uint64 data to the given curve. */ - void appendData(int uasId, const QString& curve, const QString& unit, quint64 value, quint64 usec); - /** @brief Append double data to the given curve. */ - void appendData(int uasId, const QString& curve, const QString& unit, double value, quint64 usec); + /** @brief Append data to the given curve. */ + void appendData(int uasId, const QString& curve, const QString& unit, const QVariant& value, quint64 usec); void toggleLogarithmicScaling(bool toggled); void takeButtonClick(bool checked); diff --git a/src/ui/linechart/Linecharts.cc b/src/ui/linechart/Linecharts.cc index 36d86d0..19469b8 100644 --- a/src/ui/linechart/Linecharts.cc +++ b/src/ui/linechart/Linecharts.cc @@ -100,15 +100,7 @@ void Linecharts::addSystem(UASInterface* uas) plots.insert(uasid, widget); // Connect valueChanged signals - connect(uas, SIGNAL(valueChanged(int,QString,QString,quint8,quint64)), widget, SLOT(appendData(int,QString,QString,quint8,quint64))); - connect(uas, SIGNAL(valueChanged(int,QString,QString,qint8,quint64)), widget, SLOT(appendData(int,QString,QString,qint8,quint64))); - connect(uas, SIGNAL(valueChanged(int,QString,QString,quint16,quint64)), widget, SLOT(appendData(int,QString,QString,quint16,quint64))); - connect(uas, SIGNAL(valueChanged(int,QString,QString,qint16,quint64)), widget, SLOT(appendData(int,QString,QString,qint16,quint64))); - connect(uas, SIGNAL(valueChanged(int,QString,QString,quint32,quint64)), widget, SLOT(appendData(int,QString,QString,quint32,quint64))); - connect(uas, SIGNAL(valueChanged(int,QString,QString,qint32,quint64)), widget, SLOT(appendData(int,QString,QString,qint32,quint64))); - connect(uas, SIGNAL(valueChanged(int,QString,QString,quint64,quint64)), widget, SLOT(appendData(int,QString,QString,quint64,quint64))); - connect(uas, SIGNAL(valueChanged(int,QString,QString,qint64,quint64)), widget, SLOT(appendData(int,QString,QString,qint64,quint64))); - connect(uas, SIGNAL(valueChanged(int,QString,QString,double,quint64)), widget, SLOT(appendData(int,QString,QString,double,quint64))); + connect(uas, SIGNAL(valueChanged(int,QString,QString,QVariant,quint64)), widget, SLOT(appendData(int,QString,QString,QVariant,quint64))); connect(widget, SIGNAL(logfileWritten(QString)), this, SIGNAL(logfileWritten(QString))); // Set system active if this is the only system @@ -120,15 +112,7 @@ void Linecharts::addSystem(UASInterface* uas) // Connect generic sources for (int i = 0; i < genericSources.count(); ++i) { - connect(genericSources[i], SIGNAL(valueChanged(int,QString,QString,quint8,quint64)), plots.values().first(), SLOT(appendData(int,QString,QString,quint8,quint64))); - connect(genericSources[i], SIGNAL(valueChanged(int,QString,QString,qint8,quint64)), plots.values().first(), SLOT(appendData(int,QString,QString,qint8,quint64))); - connect(genericSources[i], SIGNAL(valueChanged(int,QString,QString,quint16,quint64)), plots.values().first(), SLOT(appendData(int,QString,QString,quint16,quint64))); - connect(genericSources[i], SIGNAL(valueChanged(int,QString,QString,qint16,quint64)), plots.values().first(), SLOT(appendData(int,QString,QString,qint16,quint64))); - connect(genericSources[i], SIGNAL(valueChanged(int,QString,QString,quint32,quint64)), plots.values().first(), SLOT(appendData(int,QString,QString,quint32,quint64))); - connect(genericSources[i], SIGNAL(valueChanged(int,QString,QString,qint32,quint64)), plots.values().first(), SLOT(appendData(int,QString,QString,qint32,quint64))); - connect(genericSources[i], SIGNAL(valueChanged(int,QString,QString,quint64,quint64)), plots.values().first(), SLOT(appendData(int,QString,QString,quint64,quint64))); - connect(genericSources[i], SIGNAL(valueChanged(int,QString,QString,qint64,quint64)), plots.values().first(), SLOT(appendData(int,QString,QString,qint64,quint64))); - connect(genericSources[i], SIGNAL(valueChanged(int,QString,QString,double,quint64)), plots.values().first(), SLOT(appendData(int,QString,QString,double,quint64))); + connect(genericSources[i], SIGNAL(valueChanged(int,QString,QString,QVariant,quint64)), plots.values().first(), SLOT(appendData(int,QString,QString,QVariant,quint64))); } // Select system widget->setActive(true); @@ -145,14 +129,6 @@ void Linecharts::addSource(QObject* obj) if (plots.size() > 0) { // Connect generic source - connect(obj, SIGNAL(valueChanged(int,QString,QString,quint8,quint64)), plots.values().first(), SLOT(appendData(int,QString,QString,quint8,quint64))); - connect(obj, SIGNAL(valueChanged(int,QString,QString,qint8,quint64)), plots.values().first(), SLOT(appendData(int,QString,QString,qint8,quint64))); - connect(obj, SIGNAL(valueChanged(int,QString,QString,quint16,quint64)), plots.values().first(), SLOT(appendData(int,QString,QString,quint16,quint64))); - connect(obj, SIGNAL(valueChanged(int,QString,QString,qint16,quint64)), plots.values().first(), SLOT(appendData(int,QString,QString,qint16,quint64))); - connect(obj, SIGNAL(valueChanged(int,QString,QString,quint32,quint64)), plots.values().first(), SLOT(appendData(int,QString,QString,quint32,quint64))); - connect(obj, SIGNAL(valueChanged(int,QString,QString,qint32,quint64)), plots.values().first(), SLOT(appendData(int,QString,QString,qint32,quint64))); - connect(obj, SIGNAL(valueChanged(int,QString,QString,quint64,quint64)), plots.values().first(), SLOT(appendData(int,QString,QString,quint64,quint64))); - connect(obj, SIGNAL(valueChanged(int,QString,QString,qint64,quint64)), plots.values().first(), SLOT(appendData(int,QString,QString,qint64,quint64))); - connect(obj, SIGNAL(valueChanged(int,QString,QString,double,quint64)), plots.values().first(), SLOT(appendData(int,QString,QString,double,quint64))); + connect(obj, SIGNAL(valueChanged(int,QString,QString,QVariant,quint64)), plots.values().first(), SLOT(appendData(int,QString,QString,QVariant,quint64))); } } diff --git a/src/ui/uas/UASQuickView.cc b/src/ui/uas/UASQuickView.cc index 6d74b31..4eeeab5 100644 --- a/src/ui/uas/UASQuickView.cc +++ b/src/ui/uas/UASQuickView.cc @@ -267,107 +267,18 @@ void UASQuickView::setActiveUAS(UASInterface* uas) } void UASQuickView::addSource(MAVLinkDecoder *decoder) { - connect(decoder,SIGNAL(valueChanged(int,QString,QString,double,quint64)),this,SLOT(valueChanged(int,QString,QString,double,quint64))); - connect(decoder,SIGNAL(valueChanged(int,QString,QString,qint8,quint64)),this,SLOT(valueChanged(int,QString,QString,qint8,quint64))); - connect(decoder,SIGNAL(valueChanged(int,QString,QString,qint16,quint64)),this,SLOT(valueChanged(int,QString,QString,qint16,quint64))); - connect(decoder,SIGNAL(valueChanged(int,QString,QString,qint32,quint64)),this,SLOT(valueChanged(int,QString,QString,qint32,quint64))); - connect(decoder,SIGNAL(valueChanged(int,QString,QString,qint64,quint64)),this,SLOT(valueChanged(int,QString,QString,qint64,quint64))); - connect(decoder,SIGNAL(valueChanged(int,QString,QString,quint8,quint64)),this,SLOT(valueChanged(int,QString,QString,quint8,quint64))); - connect(decoder,SIGNAL(valueChanged(int,QString,QString,quint16,quint64)),this,SLOT(valueChanged(int,QString,QString,quint16,quint64))); - connect(decoder,SIGNAL(valueChanged(int,QString,QString,quint32,quint64)),this,SLOT(valueChanged(int,QString,QString,quint32,quint64))); - connect(decoder,SIGNAL(valueChanged(int,QString,QString,quint64,quint64)),this,SLOT(valueChanged(int,QString,QString,quint64,quint64))); -} -void UASQuickView::valueChanged(const int uasId, const QString& name, const QString& unit, const quint8 value, const quint64 msec) -{ - if (!uasPropertyValueMap.contains(name)) - { - if (quickViewSelectDialog) - { - quickViewSelectDialog->addItem(name); - } - } - uasPropertyValueMap[name] = value; + connect(decoder,SIGNAL(valueChanged(int,QString,QString,QVariant,quint64)),this,SLOT(valueChanged(int,QString,QString,QVariant,quint64))); } -void UASQuickView::valueChanged(const int uasId, const QString& name, const QString& unit, const qint8 value, const quint64 msec) -{ - if (!uasPropertyValueMap.contains(name)) - { - if (quickViewSelectDialog) - { - quickViewSelectDialog->addItem(name); - } - } - uasPropertyValueMap[name] = value; -} -void UASQuickView::valueChanged(const int uasId, const QString& name, const QString& unit, const quint16 value, const quint64 msec) -{ - if (!uasPropertyValueMap.contains(name)) - { - if (quickViewSelectDialog) - { - quickViewSelectDialog->addItem(name); - } - } - uasPropertyValueMap[name] = value; -} -void UASQuickView::valueChanged(const int uasId, const QString& name, const QString& unit, const qint16 value, const quint64 msec) -{ - if (!uasPropertyValueMap.contains(name)) - { - if (quickViewSelectDialog) - { - quickViewSelectDialog->addItem(name); - } - } - uasPropertyValueMap[name] = value; -} -void UASQuickView::valueChanged(const int uasId, const QString& name, const QString& unit, const quint32 value, const quint64 msec) -{ - if (!uasPropertyValueMap.contains(name)) - { - if (quickViewSelectDialog) - { - quickViewSelectDialog->addItem(name); - } - } - uasPropertyValueMap[name] = value; -} -void UASQuickView::valueChanged(const int uasId, const QString& name, const QString& unit, const qint32 value, const quint64 msec) -{ - if (!uasPropertyValueMap.contains(name)) - { - if (quickViewSelectDialog) - { - quickViewSelectDialog->addItem(name); - } - } - uasPropertyValueMap[name] = value; -} -void UASQuickView::valueChanged(const int uasId, const QString& name, const QString& unit, const quint64 value, const quint64 msec) -{ - if (!uasPropertyValueMap.contains(name)) - { - if (quickViewSelectDialog) - { - quickViewSelectDialog->addItem(name); - } - } - uasPropertyValueMap[name] = value; -} -void UASQuickView::valueChanged(const int uasId, const QString& name, const QString& unit, const qint64 value, const quint64 msec) -{ - if (!uasPropertyValueMap.contains(name)) - { - if (quickViewSelectDialog) - { - quickViewSelectDialog->addItem(name); - } - } - uasPropertyValueMap[name] = value; -} -void UASQuickView::valueChanged(const int uasId, const QString& name, const QString& unit, const double value, const quint64 msec) +void UASQuickView::valueChanged(const int uasId, const QString& name, const QString& unit, const QVariant &variant, const quint64 msec) { + Q_UNUSED(uasId); + Q_UNUSED(unit); + bool ok; + double value = variant.toDouble(&ok); + if(!ok || variant.type() == QMetaType::QString || variant.type() == QMetaType::QByteArray) + return; + if (!uasPropertyValueMap.contains(name)) { if (quickViewSelectDialog) @@ -410,13 +321,3 @@ void UASQuickView::actionTriggered(bool checked) } } -void UASQuickView::valueChanged(const int uasid, const QString& name, const QString& unit, const QVariant value,const quint64 msecs) -{ - uasPropertyValueMap[name] = value.toDouble(); -} - -void UASQuickView::valChanged(double val,QString type) -{ - //qDebug() << "Value changed:" << type << val; - // uasPropertyValueMap[type] = val; -} diff --git a/src/ui/uas/UASQuickView.h b/src/ui/uas/UASQuickView.h index 33075bd..1204f59 100644 --- a/src/ui/uas/UASQuickView.h +++ b/src/ui/uas/UASQuickView.h @@ -59,23 +59,12 @@ protected: signals: public slots: - void valueChanged(const int uasId, const QString& name, const QString& unit, const quint8 value, const quint64 msec); - void valueChanged(const int uasId, const QString& name, const QString& unit, const qint8 value, const quint64 msec); - void valueChanged(const int uasId, const QString& name, const QString& unit, const quint16 value, const quint64 msec); - void valueChanged(const int uasId, const QString& name, const QString& unit, const qint16 value, const quint64 msec); - void valueChanged(const int uasId, const QString& name, const QString& unit, const quint32 value, const quint64 msec); - void valueChanged(const int uasId, const QString& name, const QString& unit, const qint32 value, const quint64 msec); - void valueChanged(const int uasId, const QString& name, const QString& unit, const quint64 value, const quint64 msec); - void valueChanged(const int uasId, const QString& name, const QString& unit, const qint64 value, const quint64 msec); - void valueChanged(const int uasId, const QString& name, const QString& unit, const double value, const quint64 msec); - - void valueChanged(const int uasid, const QString& name, const QString& unit, const QVariant value,const quint64 msecs); + void valueChanged(const int uasid, const QString& name, const QString& unit, const QVariant& value,const quint64 msecs); void actionTriggered(bool checked); void actionTriggered(); void updateTimerTick(); void addUAS(UASInterface* uas); void setActiveUAS(UASInterface* uas); - void valChanged(double val,QString type); void selectDialogClosed(); void valueEnabled(QString value); void valueDisabled(QString value);