mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-12-10 18:24:11 +01:00
Added option (#define USE_SCIENTIFIC_NOTATION) to use scientific notation (or not as the case maybe)
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@2872 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
223b3089ed
commit
3883a561e4
@ -32,6 +32,7 @@
|
|||||||
#include <QtCore/QStringList>
|
#include <QtCore/QStringList>
|
||||||
#include <QtGui/QWidget>
|
#include <QtGui/QWidget>
|
||||||
#include <QtGui/QSpinBox>
|
#include <QtGui/QSpinBox>
|
||||||
|
#include <QtGui/QDoubleSpinBox>
|
||||||
#include <qscispinbox/QScienceSpinBox.h>
|
#include <qscispinbox/QScienceSpinBox.h>
|
||||||
#include <QtGui/QComboBox>
|
#include <QtGui/QComboBox>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
@ -47,6 +48,8 @@
|
|||||||
#define QINT32MAX std::numeric_limits<qint32>::max()
|
#define QINT32MAX std::numeric_limits<qint32>::max()
|
||||||
#define QUINT32MAX std::numeric_limits<qint32>::max()
|
#define QUINT32MAX std::numeric_limits<qint32>::max()
|
||||||
|
|
||||||
|
#define USE_SCIENTIFIC_NOTATION
|
||||||
|
|
||||||
class FieldTreeItem : public TreeItem
|
class FieldTreeItem : public TreeItem
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -231,21 +234,34 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
QWidget *createEditor(QWidget *parent) {
|
QWidget *createEditor(QWidget *parent) {
|
||||||
|
#idef USE_SCIENTIFIC_NOTATION
|
||||||
QScienceSpinBox *editor = new QScienceSpinBox(parent);
|
QScienceSpinBox *editor = new QScienceSpinBox(parent);
|
||||||
editor->setDecimals(6);
|
editor->setDecimals(6);
|
||||||
|
#else
|
||||||
|
QDoubleSpinBox *editor = new QDoubleSpinBox(parent);
|
||||||
|
editor->setDecimals(8);
|
||||||
|
#endif
|
||||||
editor->setMinimum(-std::numeric_limits<float>::max());
|
editor->setMinimum(-std::numeric_limits<float>::max());
|
||||||
editor->setMaximum(std::numeric_limits<float>::max());
|
editor->setMaximum(std::numeric_limits<float>::max());
|
||||||
return editor;
|
return editor;
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant getEditorValue(QWidget *editor) {
|
QVariant getEditorValue(QWidget *editor) {
|
||||||
|
#idef USE_SCIENTIFIC_NOTATION
|
||||||
QScienceSpinBox *spinBox = static_cast<QScienceSpinBox*>(editor);
|
QScienceSpinBox *spinBox = static_cast<QScienceSpinBox*>(editor);
|
||||||
|
#else
|
||||||
|
QDoubleSpinBox *spinBox = static_cast<QDoubleSpinBox*>(editor);
|
||||||
|
#endif
|
||||||
spinBox->interpretText();
|
spinBox->interpretText();
|
||||||
return spinBox->value();
|
return spinBox->value();
|
||||||
}
|
}
|
||||||
|
|
||||||
void setEditorValue(QWidget *editor, QVariant value) {
|
void setEditorValue(QWidget *editor, QVariant value) {
|
||||||
|
#idef USE_SCIENTIFIC_NOTATION
|
||||||
QScienceSpinBox *spinBox = static_cast<QScienceSpinBox*>(editor);
|
QScienceSpinBox *spinBox = static_cast<QScienceSpinBox*>(editor);
|
||||||
|
#else
|
||||||
|
QDoubleSpinBox *spinBox = static_cast<QDoubleSpinBox*>(editor);
|
||||||
|
#endif
|
||||||
spinBox->setValue(value.toDouble());
|
spinBox->setValue(value.toDouble());
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
|
Loading…
Reference in New Issue
Block a user