add cylinder
This commit is contained in:
@@ -5,8 +5,6 @@
|
||||
#include <QLabel>
|
||||
#include <QHBoxLayout>
|
||||
#include <QVBoxLayout>
|
||||
#include <QDoubleSpinBox>
|
||||
#include <QSpinBox>
|
||||
#include <QLineEdit>
|
||||
#include <QCheckBox>
|
||||
#include <QScrollArea>
|
||||
@@ -16,6 +14,7 @@
|
||||
|
||||
#include "Core/Property.h"
|
||||
#include "Core/Object.h"
|
||||
#include "Math/Dense.h"
|
||||
|
||||
namespace uLib {
|
||||
namespace Qt {
|
||||
@@ -33,34 +32,90 @@ protected:
|
||||
QLabel* m_Label;
|
||||
};
|
||||
|
||||
class UnitLineEdit : public QLineEdit {
|
||||
Q_OBJECT
|
||||
public:
|
||||
UnitLineEdit(QWidget* parent = nullptr);
|
||||
void setValue(double val);
|
||||
double getValue() const { return m_Value; }
|
||||
void setIntegerOnly(bool b);
|
||||
|
||||
signals:
|
||||
void valueManualChanged(double val);
|
||||
|
||||
private slots:
|
||||
void onEditingFinished();
|
||||
|
||||
private:
|
||||
void updateText();
|
||||
double m_Value;
|
||||
double m_Factor;
|
||||
QString m_Suffix;
|
||||
bool m_IsInteger;
|
||||
};
|
||||
|
||||
class DoublePropertyWidget : public PropertyWidgetBase {
|
||||
Q_OBJECT
|
||||
public:
|
||||
DoublePropertyWidget(Property<double>* prop, QWidget* parent = nullptr);
|
||||
virtual ~DoublePropertyWidget();
|
||||
private:
|
||||
Property<double>* m_Prop;
|
||||
QDoubleSpinBox* m_SpinBox;
|
||||
UnitLineEdit* m_Edit;
|
||||
};
|
||||
|
||||
class FloatPropertyWidget : public PropertyWidgetBase {
|
||||
Q_OBJECT
|
||||
public:
|
||||
FloatPropertyWidget(Property<float>* prop, QWidget* parent = nullptr);
|
||||
virtual ~FloatPropertyWidget();
|
||||
private:
|
||||
Property<float>* m_Prop;
|
||||
QDoubleSpinBox* m_SpinBox;
|
||||
UnitLineEdit* m_Edit;
|
||||
};
|
||||
|
||||
class IntPropertyWidget : public PropertyWidgetBase {
|
||||
Q_OBJECT
|
||||
public:
|
||||
IntPropertyWidget(Property<int>* prop, QWidget* parent = nullptr);
|
||||
virtual ~IntPropertyWidget();
|
||||
private:
|
||||
Property<int>* m_Prop;
|
||||
QSpinBox* m_SpinBox;
|
||||
UnitLineEdit* m_Edit;
|
||||
};
|
||||
|
||||
template <typename VecT, int Size>
|
||||
class VectorPropertyWidget : public PropertyWidgetBase {
|
||||
public:
|
||||
VectorPropertyWidget(Property<VecT>* prop, QWidget* parent = nullptr)
|
||||
: PropertyWidgetBase(prop, parent), m_Prop(prop) {
|
||||
for (int i = 0; i < Size; ++i) {
|
||||
m_Edits[i] = new UnitLineEdit(this);
|
||||
if (std::is_integral<typename VecT::Scalar>::value) {
|
||||
m_Edits[i]->setIntegerOnly(true);
|
||||
}
|
||||
m_Layout->addWidget(m_Edits[i], 1);
|
||||
|
||||
connect(m_Edits[i], &UnitLineEdit::valueManualChanged, [this, i](double val){
|
||||
VecT v = m_Prop->Get();
|
||||
v(i) = (typename VecT::Scalar)val;
|
||||
if (m_Prop->Get() != v) m_Prop->Set(v);
|
||||
});
|
||||
}
|
||||
updateEdits();
|
||||
uLib::Object::connect(m_Prop, &Property<VecT>::PropertyChanged, [this](){
|
||||
updateEdits();
|
||||
});
|
||||
}
|
||||
|
||||
private:
|
||||
void updateEdits() {
|
||||
VecT v = m_Prop->Get();
|
||||
for (int i = 0; i < Size; ++i) {
|
||||
if (!m_Edits[i]->hasFocus()) {
|
||||
m_Edits[i]->setValue((double)v(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
Property<VecT>* m_Prop;
|
||||
UnitLineEdit* m_Edits[Size];
|
||||
};
|
||||
|
||||
class BoolPropertyWidget : public PropertyWidgetBase {
|
||||
|
||||
Reference in New Issue
Block a user