Store ToolBox Transform fields as members.
This commit is contained in:
parent
3d4df2eb76
commit
dc94d0a130
@ -47,6 +47,42 @@ void ToolBox::removePages()
|
||||
}
|
||||
}
|
||||
|
||||
void ToolBox::createTransformPanel(const Object * object)
|
||||
{
|
||||
auto rowLayout = transformPanel_.layout = new QHBoxLayout;
|
||||
transformPanel_.spinBox.label = new QLabel(tr("Translation:"));
|
||||
rowLayout->addWidget(transformPanel_.spinBox.label);
|
||||
int minWidth = 75;
|
||||
for (size_t i = 0; i < 3; i++) {
|
||||
QDoubleSpinBox * spinBox;
|
||||
if (i == 0) {
|
||||
spinBox = transformPanel_.spinBox.x = new QDoubleSpinBox;
|
||||
connect(spinBox,
|
||||
&QDoubleSpinBox::valueChanged,
|
||||
object,
|
||||
&Object::setTranslationX);
|
||||
} else if (i == 1) {
|
||||
spinBox = transformPanel_.spinBox.y = new QDoubleSpinBox;
|
||||
connect(spinBox,
|
||||
&QDoubleSpinBox::valueChanged,
|
||||
object,
|
||||
&Object::setTranslationY);
|
||||
} else if (i == 2) {
|
||||
spinBox = transformPanel_.spinBox.z = new QDoubleSpinBox;
|
||||
connect(spinBox,
|
||||
&QDoubleSpinBox::valueChanged,
|
||||
object,
|
||||
&Object::setTranslationZ);
|
||||
}
|
||||
spinBox->setMinimum(std::numeric_limits<double>::lowest());
|
||||
spinBox->setSingleStep(0.1);
|
||||
spinBox->setValue(object->getTransform().getTranslation()[i]);
|
||||
spinBox->setFixedWidth(minWidth);
|
||||
|
||||
rowLayout->addWidget(spinBox);
|
||||
}
|
||||
}
|
||||
|
||||
void ToolBox::createPageProperties(const Object * object)
|
||||
{
|
||||
auto transform = object->getTransform();
|
||||
@ -55,43 +91,18 @@ void ToolBox::createPageProperties(const Object * object)
|
||||
ui->toolBox->addItem(widget, "Properties");
|
||||
ui->toolBox->setCurrentWidget(widget);
|
||||
|
||||
auto * layout = new QFormLayout;
|
||||
layout->addRow(new QLabel(tr("Name:")), new QLabel(object->getName()));
|
||||
formLayout_ = new QFormLayout;
|
||||
formLayout_->addRow(new QLabel(tr("Name:")), new QLabel(object->getName()));
|
||||
|
||||
layout->addRow(new QLabel(tr("Type:")),
|
||||
new QLabel(type == Object::Type::QTK_MESH ? "Mesh" : "Model"));
|
||||
formLayout_->addRow(
|
||||
new QLabel(tr("Type:")),
|
||||
new QLabel(type == Object::Type::QTK_MESH ? "Mesh" : "Model"));
|
||||
|
||||
createTransformPanel(object);
|
||||
formLayout_->addRow(transformPanel_.layout);
|
||||
|
||||
auto rowLayout = new QHBoxLayout;
|
||||
rowLayout->addWidget(new QLabel(tr("Translation:")));
|
||||
int minWidth = 75;
|
||||
for (size_t i = 0; i < 3; i++) {
|
||||
auto spinBox = new QDoubleSpinBox;
|
||||
spinBox->setMinimum(std::numeric_limits<double>::lowest());
|
||||
spinBox->setSingleStep(0.1);
|
||||
spinBox->setValue(transform.getTranslation()[i]);
|
||||
spinBox->setFixedWidth(minWidth);
|
||||
rowLayout->addWidget(spinBox);
|
||||
|
||||
if (i == 0) {
|
||||
connect(spinBox,
|
||||
&QDoubleSpinBox::valueChanged,
|
||||
object,
|
||||
&Object::setTranslationX);
|
||||
} else if (i == 1) {
|
||||
connect(spinBox,
|
||||
&QDoubleSpinBox::valueChanged,
|
||||
object,
|
||||
&Object::setTranslationY);
|
||||
} else if (i == 2) {
|
||||
connect(spinBox,
|
||||
&QDoubleSpinBox::valueChanged,
|
||||
object,
|
||||
&Object::setTranslationZ);
|
||||
}
|
||||
}
|
||||
layout->addRow(rowLayout);
|
||||
|
||||
rowLayout = new QHBoxLayout;
|
||||
auto rowLayout = new QHBoxLayout;
|
||||
rowLayout->addWidget(new QLabel(tr("Scale:")));
|
||||
for (size_t i = 0; i < 3; i++) {
|
||||
auto spinBox = new QDoubleSpinBox;
|
||||
@ -112,8 +123,8 @@ void ToolBox::createPageProperties(const Object * object)
|
||||
spinBox, &QDoubleSpinBox::valueChanged, object, &Object::setScaleZ);
|
||||
}
|
||||
}
|
||||
layout->addRow(rowLayout);
|
||||
widget->setLayout(layout);
|
||||
formLayout_->addRow(rowLayout);
|
||||
widget->setLayout(formLayout_);
|
||||
}
|
||||
|
||||
void ToolBox::createPageShader(const Object * object)
|
||||
|
@ -13,7 +13,10 @@
|
||||
#include <QDesignerExportWidget>
|
||||
#include <QDockWidget>
|
||||
#include <QDoubleSpinBox>
|
||||
#include <QFormLayout>
|
||||
#include <QGroupBox>
|
||||
#include <QHBoxLayout>
|
||||
#include <QLabel>
|
||||
|
||||
|
||||
#include "qtk/scene.h"
|
||||
@ -40,6 +43,13 @@ namespace Qtk
|
||||
|
||||
void removePages();
|
||||
|
||||
/**
|
||||
* Creates the transform panel and controls.
|
||||
*
|
||||
* @param object The Qtk::Object associated with this panel.
|
||||
*/
|
||||
void createTransformPanel(const Object * object);
|
||||
|
||||
void createPageProperties(const Object * object);
|
||||
|
||||
void createPageShader(const Object * object);
|
||||
@ -52,6 +62,31 @@ namespace Qtk
|
||||
* Private Members
|
||||
************************************************************************/
|
||||
|
||||
/// Spinbox with 3 fields and label.
|
||||
struct SpinBox3D {
|
||||
QLabel * label;
|
||||
QDoubleSpinBox * x;
|
||||
QDoubleSpinBox * y;
|
||||
QDoubleSpinBox * z;
|
||||
};
|
||||
|
||||
/// Transform controls and layout.
|
||||
struct TransformPanel {
|
||||
QHBoxLayout * layout;
|
||||
SpinBox3D spinBox;
|
||||
};
|
||||
TransformPanel transformPanel_;
|
||||
|
||||
/// Scale controls and layout.
|
||||
struct ScalePanel {
|
||||
QHBoxLayout * layout;
|
||||
SpinBox3D spinBox;
|
||||
};
|
||||
ScalePanel scalePanel_;
|
||||
|
||||
/// The root layout for the primary widget.
|
||||
QFormLayout * formLayout_;
|
||||
|
||||
Ui::ToolBox * ui;
|
||||
};
|
||||
} // namespace Qtk
|
||||
|
Loading…
x
Reference in New Issue
Block a user