From 236b8e5f7897e1341bea7247e604a44b9d6b9ce9 Mon Sep 17 00:00:00 2001 From: Alessio Morale Date: Mon, 3 Nov 2014 23:09:26 +0100 Subject: [PATCH] Uncrustify --- .../config/configstabilizationwidget.cpp | 2 +- .../src/plugins/scope/plotdata.cpp | 24 +++++----- .../openpilotgcs/src/plugins/scope/plotdata.h | 48 ++++++++++++++----- .../src/plugins/scope/scopegadgetwidget.cpp | 18 +++---- .../src/plugins/scope/scopegadgetwidget.h | 2 +- .../src/plugins/scope/scopeplugin.h | 2 +- .../setupwizard/outputcalibrationutil.cpp | 8 ++-- .../setupwizard/outputcalibrationutil.h | 2 +- .../pages/airframeinitialtuningpage.cpp | 16 +++---- 9 files changed, 74 insertions(+), 48 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/config/configstabilizationwidget.cpp b/ground/openpilotgcs/src/plugins/config/configstabilizationwidget.cpp index d1b862db9..588c60ba5 100644 --- a/ground/openpilotgcs/src/plugins/config/configstabilizationwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/configstabilizationwidget.cpp @@ -240,7 +240,7 @@ void ConfigStabilizationWidget::setupExpoPlot() title.setText(tr("Output %")); title.setFont(ui->expoPlot->axisFont(QwtPlot::yLeft)); ui->expoPlot->setAxisTitle(QwtPlot::yLeft, title); - QwtPlotCanvas * plotCanvas = dynamic_cast(ui->expoPlot->canvas()); + QwtPlotCanvas *plotCanvas = dynamic_cast(ui->expoPlot->canvas()); if (plotCanvas) { plotCanvas->setFrameStyle(QFrame::NoFrame); } diff --git a/ground/openpilotgcs/src/plugins/scope/plotdata.cpp b/ground/openpilotgcs/src/plugins/scope/plotdata.cpp index b0e821128..ff1d7abc9 100644 --- a/ground/openpilotgcs/src/plugins/scope/plotdata.cpp +++ b/ground/openpilotgcs/src/plugins/scope/plotdata.cpp @@ -77,11 +77,13 @@ PlotData::~PlotData() delete m_plotCurve; } -bool PlotData::isVisible() const { +bool PlotData::isVisible() const +{ return m_plotCurve->isVisible(); } -void PlotData::setVisible(bool visible) { +void PlotData::setVisible(bool visible) +{ m_plotCurve->setVisible(visible); visibilityChanged(m_plotCurve); } @@ -91,7 +93,8 @@ void PlotData::updatePlotData() m_plotCurve->setSamples(m_xDataEntries, m_yDataEntries); } -bool PlotData::hasData() const { +bool PlotData::hasData() const +{ if (!m_isEnumPlot) { return !m_xDataEntries.isEmpty(); } else { @@ -99,7 +102,8 @@ bool PlotData::hasData() const { } } -QString PlotData::lastDataAsString() { +QString PlotData::lastDataAsString() +{ if (!m_isEnumPlot) { return QString().sprintf("%3.10g", m_yDataEntries.last()); } else { @@ -115,7 +119,7 @@ void PlotData::attach(QwtPlot *plot) void PlotData::visibilityChanged(QwtPlotItem *item) { if (m_plotCurve == item) { - foreach (QwtPlotMarker* marker, m_enumMarkerList) { + foreach(QwtPlotMarker * marker, m_enumMarkerList) { m_plotCurve->isVisible() ? marker->attach(m_plotCurve->plot()) : marker->detach(); } } @@ -157,6 +161,7 @@ void PlotData::calcMathFunction(double currentValue) QwtPlotMarker *PlotData::createMarker(QString value) { QwtPlotMarker *marker = new QwtPlotMarker(value); + marker->setZ(10); QwtText label(QString(" %1 ").arg(value)); label.setColor(QColor(Qt::black)); @@ -204,7 +209,6 @@ bool SequentialPlotData::append(UAVObject *obj) QwtPlotMarker *marker = m_enumMarkerList.isEmpty() ? NULL : m_enumMarkerList.last(); if (!marker || marker->title() != value) { - marker = createMarker(value); marker->setXValue(m_enumMarkerList.size()); @@ -237,14 +241,12 @@ bool ChronoPlotData::append(UAVObject *obj) } m_xDataEntries.append(xValue); - } else { // Enum markers QString value = m_field->getValue(m_element).toString(); QwtPlotMarker *marker = m_enumMarkerList.isEmpty() ? NULL : m_enumMarkerList.last(); if (!marker || marker->title() != value) { - marker = createMarker(value); marker->setXValue(xValue); @@ -264,12 +266,12 @@ void ChronoPlotData::removeStaleData() { while (!m_xDataEntries.isEmpty() && (m_xDataEntries.last() - m_xDataEntries.first()) > m_plotDataSize) { - m_yDataEntries.pop_front(); - m_xDataEntries.pop_front(); + m_yDataEntries.pop_front(); + m_xDataEntries.pop_front(); } while (!m_enumMarkerList.isEmpty() && (m_enumMarkerList.last()->xValue() - m_enumMarkerList.first()->xValue()) > m_plotDataSize) { - QwtPlotMarker* marker = m_enumMarkerList.takeFirst(); + QwtPlotMarker *marker = m_enumMarkerList.takeFirst(); marker->detach(); delete marker; } diff --git a/ground/openpilotgcs/src/plugins/scope/plotdata.h b/ground/openpilotgcs/src/plugins/scope/plotdata.h index fa4846725..c180157d4 100644 --- a/ground/openpilotgcs/src/plugins/scope/plotdata.h +++ b/ground/openpilotgcs/src/plugins/scope/plotdata.h @@ -45,7 +45,7 @@ /*! \brief Defines the different type of plots. */ -enum PlotType {SequentialPlot, ChronoPlot}; +enum PlotType { SequentialPlot, ChronoPlot }; /*! \brief Base class that keeps the data for each curve in the plot. @@ -58,20 +58,38 @@ public: QString mathFunction, double plotDataSize, QPen pen, bool antialiased); ~PlotData(); - QString plotName() const { return m_plotName; } + QString plotName() const + { + return m_plotName; + } - UAVObject *object() const { return m_object; } - UAVObjectField *field() const { return m_field; } - int element() const { return m_element; } - QString elementName() const { return m_elementName; } + UAVObject *object() const + { + return m_object; + } + UAVObjectField *field() const + { + return m_field; + } + int element() const + { + return m_element; + } + QString elementName() const + { + return m_elementName; + } bool isVisible() const; void setVisible(bool visible); - bool wantsInitialData() { return m_isEnumPlot; } + bool wantsInitialData() + { + return m_isEnumPlot; + } virtual bool append(UAVObject *obj) = 0; - virtual PlotType plotType() const = 0; + virtual PlotType plotType() const = 0; virtual void removeStaleData() = 0; void updatePlotData(); @@ -110,7 +128,6 @@ protected: bool m_isEnumPlot; virtual void calcMathFunction(double currentValue); QwtPlotMarker *createMarker(QString value); - }; /*! @@ -128,7 +145,10 @@ public: ~SequentialPlotData() {} bool append(UAVObject *obj); - PlotType plotType() const { return SequentialPlot; } + PlotType plotType() const + { + return SequentialPlot; + } void removeStaleData() {} }; @@ -143,12 +163,14 @@ public: double plotDataSize, QPen pen, bool antialiased) : PlotData(object, field, element, scaleFactor, meanSamples, mathFunction, plotDataSize, pen, antialiased) - { - } + {} ~ChronoPlotData() {} bool append(UAVObject *obj); - PlotType plotType() const { return ChronoPlot; } + PlotType plotType() const + { + return ChronoPlot; + } void removeStaleData(); }; diff --git a/ground/openpilotgcs/src/plugins/scope/scopegadgetwidget.cpp b/ground/openpilotgcs/src/plugins/scope/scopegadgetwidget.cpp index f2eeade36..6a2c22ee7 100644 --- a/ground/openpilotgcs/src/plugins/scope/scopegadgetwidget.cpp +++ b/ground/openpilotgcs/src/plugins/scope/scopegadgetwidget.cpp @@ -65,7 +65,7 @@ ScopeGadgetWidget::ScopeGadgetWidget(QWidget *parent) : QwtPlot(parent), { setMouseTracking(true); - QwtPlotCanvas * plotCanvas = dynamic_cast(canvas()); + QwtPlotCanvas *plotCanvas = dynamic_cast(canvas()); if (plotCanvas) { plotCanvas->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken); plotCanvas->setBorderRadius(8); @@ -103,6 +103,7 @@ ScopeGadgetWidget::~ScopeGadgetWidget() UAVObjectManager *objManager = pm->getObject(); foreach(QString uavObjName, m_connectedUAVObjects) { UAVDataObject *obj = dynamic_cast(objManager->getObject(uavObjName)); + disconnect(obj, SIGNAL(objectUpdated(UAVObject *)), this, SLOT(uavObjectReceived(UAVObject *))); } @@ -230,12 +231,13 @@ void ScopeGadgetWidget::addLegend() // not visible, and then un-hiding it. foreach(QwtPlotItem * plotItem, itemList()) { QWidget *legendWidget = m_plotLegend->legendWidget(QwtPlot::itemToInfo(plotItem)); + if (legendWidget && legendWidget->inherits("QwtLegendLabel")) { ((QwtLegendLabel *)legendWidget)->setChecked(!plotItem->isVisible()); } } - connect(m_plotLegend, SIGNAL(checked(QVariant, bool, int)), this, SLOT(showCurve(QVariant,bool,int))); + connect(m_plotLegend, SIGNAL(checked(QVariant, bool, int)), this, SLOT(showCurve(QVariant, bool, int))); } void ScopeGadgetWidget::preparePlot(PlotType plotType) @@ -325,8 +327,8 @@ void ScopeGadgetWidget::addCurvePlot(QString objectName, QString fieldPlusSubFie if (fieldPlusSubField.contains("-")) { QStringList fieldSubfield = fieldName.split("-", QString::SkipEmptyParts); - fieldName = fieldSubfield.at(0); - elementName = fieldSubfield.at(1); + fieldName = fieldSubfield.at(0); + elementName = fieldSubfield.at(1); } // Get the uav object @@ -341,7 +343,7 @@ void ScopeGadgetWidget::addCurvePlot(QString objectName, QString fieldPlusSubFie UAVObjectField *field = object->getField(fieldName); if (!field) { qDebug() << "In scope gadget, in fields loaded from GCS config file, field" << - fieldName << "of object" << objectName << "is missing"; + fieldName << "of object" << objectName << "is missing"; return; } @@ -349,7 +351,7 @@ void ScopeGadgetWidget::addCurvePlot(QString objectName, QString fieldPlusSubFie element = field->getElementNames().indexOf(QRegExp(elementName, Qt::CaseSensitive, QRegExp::FixedString)); if (element < 0) { qDebug() << "In scope gadget, in fields loaded from GCS config file, field" << - fieldName << "of object" << objectName << "element name" << elementName << "is missing"; + fieldName << "of object" << objectName << "element name" << elementName << "is missing"; return; } } @@ -363,9 +365,9 @@ void ScopeGadgetWidget::addCurvePlot(QString objectName, QString fieldPlusSubFie } else if (m_plotType == ChronoPlot) { plotData = new ChronoPlotData(object, field, element, scaleFactor, meanSamples, mathFunction, m_plotDataSize, - pen, antialiased); + pen, antialiased); } - connect(this, SIGNAL(visibilityChanged(QwtPlotItem*)), plotData, SLOT(visibilityChanged(QwtPlotItem*))); + connect(this, SIGNAL(visibilityChanged(QwtPlotItem *)), plotData, SLOT(visibilityChanged(QwtPlotItem *))); plotData->attach(this); if (plotData->wantsInitialData()) { diff --git a/ground/openpilotgcs/src/plugins/scope/scopegadgetwidget.h b/ground/openpilotgcs/src/plugins/scope/scopegadgetwidget.h index 10f8efbc0..cf725f46e 100644 --- a/ground/openpilotgcs/src/plugins/scope/scopegadgetwidget.h +++ b/ground/openpilotgcs/src/plugins/scope/scopegadgetwidget.h @@ -170,7 +170,7 @@ private: QFile m_csvLoggingFile; QMutex m_mutex; - QwtLegend* m_plotLegend; + QwtLegend *m_plotLegend; int csvLoggingInsertHeader(); int csvLoggingAddData(); diff --git a/ground/openpilotgcs/src/plugins/scope/scopeplugin.h b/ground/openpilotgcs/src/plugins/scope/scopeplugin.h index d4412a5b4..b227460ec 100644 --- a/ground/openpilotgcs/src/plugins/scope/scopeplugin.h +++ b/ground/openpilotgcs/src/plugins/scope/scopeplugin.h @@ -34,7 +34,7 @@ class ScopeGadgetFactory; class ScopePlugin : public ExtensionSystem::IPlugin { Q_OBJECT - Q_PLUGIN_METADATA(IID "OpenPilot.Scope") + Q_PLUGIN_METADATA(IID "OpenPilot.Scope") public: ScopePlugin(); diff --git a/ground/openpilotgcs/src/plugins/setupwizard/outputcalibrationutil.cpp b/ground/openpilotgcs/src/plugins/setupwizard/outputcalibrationutil.cpp index d39abf3bc..a51f25c30 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/outputcalibrationutil.cpp +++ b/ground/openpilotgcs/src/plugins/setupwizard/outputcalibrationutil.cpp @@ -37,23 +37,23 @@ ActuatorCommand::Metadata OutputCalibrationUtil::c_savedActuatorCommandMetaData; OutputCalibrationUtil::OutputCalibrationUtil(QObject *parent) : QObject(parent), m_outputChannel(-1), m_safeValue(1000) -{ -} +{} OutputCalibrationUtil::~OutputCalibrationUtil() { stopChannelOutput(); } -ActuatorCommand * OutputCalibrationUtil::getActuatorCommandObject() +ActuatorCommand *OutputCalibrationUtil::getActuatorCommandObject() { ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); + Q_ASSERT(pm); UAVObjectManager *uavObjectManager = pm->getObject(); Q_ASSERT(uavObjectManager); - ActuatorCommand *actuatorCommand = ActuatorCommand::GetInstance(uavObjectManager); + ActuatorCommand *actuatorCommand = ActuatorCommand::GetInstance(uavObjectManager); Q_ASSERT(actuatorCommand); return actuatorCommand; diff --git a/ground/openpilotgcs/src/plugins/setupwizard/outputcalibrationutil.h b/ground/openpilotgcs/src/plugins/setupwizard/outputcalibrationutil.h index 3ca5bb78e..042ee8c67 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/outputcalibrationutil.h +++ b/ground/openpilotgcs/src/plugins/setupwizard/outputcalibrationutil.h @@ -40,7 +40,7 @@ public: static void startOutputCalibration(); static void stopOutputCalibration(); - static ActuatorCommand * getActuatorCommandObject(); + static ActuatorCommand *getActuatorCommandObject(); public slots: void startChannelOutput(quint16 channel, quint16 safeValue); diff --git a/ground/openpilotgcs/src/plugins/setupwizard/pages/airframeinitialtuningpage.cpp b/ground/openpilotgcs/src/plugins/setupwizard/pages/airframeinitialtuningpage.cpp index e5e83efb9..4829cf43d 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/pages/airframeinitialtuningpage.cpp +++ b/ground/openpilotgcs/src/plugins/setupwizard/pages/airframeinitialtuningpage.cpp @@ -159,14 +159,14 @@ bool AirframeInitialTuningPage::airframeIsCompatible(int vehicleType, int vehicl int wizSubType = getWizard()->getVehicleSubType(); switch (vehicleType) { - case VehicleConfigurationSource::MULTI_ROTOR_QUAD_H: - case VehicleConfigurationSource::MULTI_ROTOR_QUAD_X: - { - return wizSubType == VehicleConfigurationSource::MULTI_ROTOR_QUAD_H || - wizSubType == VehicleConfigurationSource::MULTI_ROTOR_QUAD_X; - } - default: - return vehicleSubType == wizSubType; + case VehicleConfigurationSource::MULTI_ROTOR_QUAD_H: + case VehicleConfigurationSource::MULTI_ROTOR_QUAD_X: + { + return wizSubType == VehicleConfigurationSource::MULTI_ROTOR_QUAD_H || + wizSubType == VehicleConfigurationSource::MULTI_ROTOR_QUAD_X; + } + default: + return vehicleSubType == wizSubType; } }