mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-18 03:52:11 +01:00
Merge branch 'next' of ssh://git.openpilot.org/OpenPilot into pt/CC3D_Release
Conflicts: ground/openpilotgcs/src/plugins/uavobjectbrowser/uavobjectbrowser.ui ground/openpilotgcs/src/plugins/uavobjectbrowser/uavobjectbrowserwidget.cpp ground/openpilotgcs/src/plugins/uavobjectbrowser/uavobjectbrowserwidget.h ground/openpilotgcs/src/plugins/uavobjectbrowser/uavobjecttreemodel.cpp ground/openpilotgcs/src/plugins/uavobjectbrowser/uavobjecttreemodel.h
This commit is contained in:
commit
76773cd1c5
@ -48,8 +48,6 @@
|
||||
#define QINT32MAX std::numeric_limits<qint32>::max()
|
||||
#define QUINT32MAX std::numeric_limits<qint32>::max()
|
||||
|
||||
//#define USE_SCIENTIFIC_NOTATION
|
||||
|
||||
class FieldTreeItem : public TreeItem
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -214,10 +212,10 @@ class FloatFieldTreeItem : public FieldTreeItem
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
FloatFieldTreeItem(UAVObjectField *field, int index, const QList<QVariant> &data, TreeItem *parent = 0) :
|
||||
FieldTreeItem(index, data, parent), m_field(field) { }
|
||||
FloatFieldTreeItem(UAVObjectField *field, int index, const QVariant &data, TreeItem *parent = 0) :
|
||||
FieldTreeItem(index, data, parent), m_field(field) { }
|
||||
FloatFieldTreeItem(UAVObjectField *field, int index, const QList<QVariant> &data, bool scientific = false, TreeItem *parent = 0) :
|
||||
FieldTreeItem(index, data, parent), m_field(field), m_useScientificNotation(scientific){}
|
||||
FloatFieldTreeItem(UAVObjectField *field, int index, const QVariant &data, bool scientific = false, TreeItem *parent = 0) :
|
||||
FieldTreeItem(index, data, parent), m_field(field), m_useScientificNotation(scientific) { }
|
||||
void setData(QVariant value, int column) {
|
||||
setChanged(m_field->getValue(m_index) != value);
|
||||
TreeItem::setData(value, column);
|
||||
@ -233,39 +231,49 @@ public:
|
||||
setHighlight(true);
|
||||
}
|
||||
}
|
||||
|
||||
QWidget *createEditor(QWidget *parent) {
|
||||
#ifdef USE_SCIENTIFIC_NOTATION
|
||||
if(m_useScientificNotation) {
|
||||
QScienceSpinBox *editor = new QScienceSpinBox(parent);
|
||||
editor->setDecimals(6);
|
||||
#else
|
||||
editor->setMinimum(-std::numeric_limits<float>::max());
|
||||
editor->setMaximum(std::numeric_limits<float>::max());
|
||||
return editor;
|
||||
} else {
|
||||
QDoubleSpinBox *editor = new QDoubleSpinBox(parent);
|
||||
editor->setDecimals(8);
|
||||
#endif
|
||||
editor->setMinimum(-std::numeric_limits<float>::max());
|
||||
editor->setMaximum(std::numeric_limits<float>::max());
|
||||
return editor;
|
||||
}
|
||||
}
|
||||
|
||||
QVariant getEditorValue(QWidget *editor) {
|
||||
#ifdef USE_SCIENTIFIC_NOTATION
|
||||
if(m_useScientificNotation) {
|
||||
QScienceSpinBox *spinBox = static_cast<QScienceSpinBox*>(editor);
|
||||
#else
|
||||
spinBox->interpretText();
|
||||
return spinBox->value();
|
||||
} else {
|
||||
QDoubleSpinBox *spinBox = static_cast<QDoubleSpinBox*>(editor);
|
||||
#endif
|
||||
spinBox->interpretText();
|
||||
return spinBox->value();
|
||||
}
|
||||
}
|
||||
|
||||
void setEditorValue(QWidget *editor, QVariant value) {
|
||||
#ifdef USE_SCIENTIFIC_NOTATION
|
||||
|
||||
if(m_useScientificNotation) {
|
||||
QScienceSpinBox *spinBox = static_cast<QScienceSpinBox*>(editor);
|
||||
#else
|
||||
QDoubleSpinBox *spinBox = static_cast<QDoubleSpinBox*>(editor);
|
||||
#endif
|
||||
spinBox->setValue(value.toDouble());
|
||||
} else {
|
||||
QDoubleSpinBox *spinBox = static_cast<QDoubleSpinBox*>(editor);
|
||||
spinBox->setValue(value.toDouble());
|
||||
}
|
||||
}
|
||||
private:
|
||||
UAVObjectField *m_field;
|
||||
bool m_useScientificNotation;
|
||||
|
||||
};
|
||||
|
||||
#endif // FIELDTREEITEM_H
|
||||
|
@ -165,10 +165,9 @@ private:
|
||||
bool m_changed;
|
||||
QTime m_highlightExpires;
|
||||
HighLightManager* m_highlightManager;
|
||||
static int m_highlightTimeMs;
|
||||
public:
|
||||
static const int dataColumn = 1;
|
||||
private:
|
||||
static int m_highlightTimeMs;
|
||||
};
|
||||
|
||||
class DataObjectTreeItem;
|
||||
|
@ -215,6 +215,16 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="scientificNotationCheckbox">
|
||||
<property name="toolTip">
|
||||
<string>Use scientific editors</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Scientific</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
|
@ -60,6 +60,7 @@ UAVObjectBrowserWidget::UAVObjectBrowserWidget(QWidget *parent) : QWidget(parent
|
||||
connect(m_browser->eraseSDButton, SIGNAL(clicked()), this, SLOT(eraseObject()));
|
||||
connect(m_browser->sendButton, SIGNAL(clicked()), this, SLOT(sendUpdate()));
|
||||
connect(m_browser->requestButton, SIGNAL(clicked()), this, SLOT(requestUpdate()));
|
||||
connect(m_browser->scientificNotationCheckbox, SIGNAL(toggled(bool)), this, SLOT(useScientificNotation(bool)));
|
||||
enableSendRequest(false);
|
||||
}
|
||||
|
||||
@ -85,7 +86,7 @@ void UAVObjectBrowserWidget::categorize(bool categorize)
|
||||
Q_ASSERT(objManager);
|
||||
|
||||
UAVObjectTreeModel* tmpModel = m_model;
|
||||
m_model = new UAVObjectTreeModel(0, categorize);
|
||||
m_model = new UAVObjectTreeModel(0, categorize,m_browser->scientificNotationCheckbox->isChecked());
|
||||
m_model->setRecentlyUpdatedColor(m_recentlyUpdatedColor);
|
||||
m_model->setManuallyChangedColor(m_manuallyChangedColor);
|
||||
m_model->setRecentlyUpdatedTimeout(m_recentlyUpdatedTimeout);
|
||||
@ -96,6 +97,24 @@ void UAVObjectBrowserWidget::categorize(bool categorize)
|
||||
delete tmpModel;
|
||||
}
|
||||
|
||||
void UAVObjectBrowserWidget::useScientificNotation(bool scientific)
|
||||
{
|
||||
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
||||
Q_ASSERT(pm);
|
||||
UAVObjectManager *objManager = pm->getObject<UAVObjectManager>();
|
||||
Q_ASSERT(objManager);
|
||||
|
||||
UAVObjectTreeModel* tmpModel = m_model;
|
||||
m_model = new UAVObjectTreeModel(0, m_browser->categorizeCheckbox->isChecked(),scientific);
|
||||
m_model->setRecentlyUpdatedColor(m_recentlyUpdatedColor);
|
||||
m_model->setManuallyChangedColor(m_manuallyChangedColor);
|
||||
m_model->setRecentlyUpdatedTimeout(m_recentlyUpdatedTimeout);
|
||||
m_browser->treeView->setModel(m_model);
|
||||
showMetaData(m_browser->metaCheckBox->isChecked());
|
||||
|
||||
delete tmpModel;
|
||||
}
|
||||
|
||||
void UAVObjectBrowserWidget::sendUpdate()
|
||||
{
|
||||
ObjectTreeItem *objItem = findCurrentObjectTreeItem();
|
||||
|
@ -54,6 +54,7 @@ public:
|
||||
public slots:
|
||||
void showMetaData(bool show);
|
||||
void categorize(bool categorize);
|
||||
void useScientificNotation(bool scientific);
|
||||
|
||||
private slots:
|
||||
void sendUpdate();
|
||||
|
@ -38,8 +38,9 @@
|
||||
#include <QtCore/QSignalMapper>
|
||||
#include <QtCore/QDebug>
|
||||
|
||||
UAVObjectTreeModel::UAVObjectTreeModel(QObject *parent, bool categorize) :
|
||||
UAVObjectTreeModel::UAVObjectTreeModel(QObject *parent, bool categorize, bool useScientificNotation) :
|
||||
QAbstractItemModel(parent),
|
||||
m_useScientificFloatNotation(useScientificNotation),
|
||||
m_recentlyUpdatedTimeout(500), // ms
|
||||
m_recentlyUpdatedColor(QColor(255, 230, 230)),
|
||||
m_manuallyChangedColor(QColor(230, 230, 255))
|
||||
@ -227,7 +228,7 @@ void UAVObjectTreeModel::addSingleField(int index, UAVObjectField *field, TreeIt
|
||||
case UAVObjectField::FLOAT32:
|
||||
data.append(field->getValue(index));
|
||||
data.append(field->getUnits());
|
||||
item = new FloatFieldTreeItem(field, index, data);
|
||||
item = new FloatFieldTreeItem(field, index, data, m_useScientificFloatNotation);
|
||||
break;
|
||||
default:
|
||||
Q_ASSERT(false);
|
||||
|
@ -49,7 +49,7 @@ class UAVObjectTreeModel : public QAbstractItemModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit UAVObjectTreeModel(QObject *parent = 0, bool categorize=true);
|
||||
explicit UAVObjectTreeModel(QObject *parent = 0, bool categorize=true, bool useScientificNotation=false);
|
||||
~UAVObjectTreeModel();
|
||||
|
||||
QVariant data(const QModelIndex &index, int role) const;
|
||||
@ -105,6 +105,7 @@ private:
|
||||
QColor m_recentlyUpdatedColor;
|
||||
QColor m_manuallyChangedColor;
|
||||
bool m_onlyHilightChangedValues;
|
||||
bool m_useScientificFloatNotation;
|
||||
|
||||
// Highlight manager to handle highlighting of tree items.
|
||||
HighLightManager *m_highlightManager;
|
||||
|
Loading…
x
Reference in New Issue
Block a user