1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-12-01 09:24:10 +01:00

Uncrustify

This commit is contained in:
Alessio Morale 2014-11-03 23:09:26 +01:00
parent 6681d54ca9
commit 236b8e5f78
9 changed files with 74 additions and 48 deletions

View File

@ -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<QwtPlotCanvas *>(ui->expoPlot->canvas());
QwtPlotCanvas *plotCanvas = dynamic_cast<QwtPlotCanvas *>(ui->expoPlot->canvas());
if (plotCanvas) {
plotCanvas->setFrameStyle(QFrame::NoFrame);
}

View File

@ -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;
}

View File

@ -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();
};

View File

@ -65,7 +65,7 @@ ScopeGadgetWidget::ScopeGadgetWidget(QWidget *parent) : QwtPlot(parent),
{
setMouseTracking(true);
QwtPlotCanvas * plotCanvas = dynamic_cast<QwtPlotCanvas *>(canvas());
QwtPlotCanvas *plotCanvas = dynamic_cast<QwtPlotCanvas *>(canvas());
if (plotCanvas) {
plotCanvas->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken);
plotCanvas->setBorderRadius(8);
@ -103,6 +103,7 @@ ScopeGadgetWidget::~ScopeGadgetWidget()
UAVObjectManager *objManager = pm->getObject<UAVObjectManager>();
foreach(QString uavObjName, m_connectedUAVObjects) {
UAVDataObject *obj = dynamic_cast<UAVDataObject *>(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()) {

View File

@ -170,7 +170,7 @@ private:
QFile m_csvLoggingFile;
QMutex m_mutex;
QwtLegend* m_plotLegend;
QwtLegend *m_plotLegend;
int csvLoggingInsertHeader();
int csvLoggingAddData();

View File

@ -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();

View File

@ -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<UAVObjectManager>();
Q_ASSERT(uavObjectManager);
ActuatorCommand *actuatorCommand = ActuatorCommand::GetInstance(uavObjectManager);
ActuatorCommand *actuatorCommand = ActuatorCommand::GetInstance(uavObjectManager);
Q_ASSERT(actuatorCommand);
return actuatorCommand;

View File

@ -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);

View File

@ -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;
}
}