添加金属度和粗糙度设置
parent
0d5c513523
commit
dfcad45b8c
|
@ -119,6 +119,10 @@ void EditorWidget::initProjectMenu()
|
|||
currentEditorWidgetItem, &EditorWidgetItem::handleBackgroundColorChange);
|
||||
connect(dialog, &ProjectPropertyDialog::canvasSizeChanged,
|
||||
currentEditorWidgetItem, &EditorWidgetItem::handleCanvasSizeChange);
|
||||
connect(dialog, &ProjectPropertyDialog::canvasRoughnessChanged,
|
||||
currentEditorWidgetItem, &EditorWidgetItem::handleCanvasRoughnessChange);
|
||||
connect(dialog, &ProjectPropertyDialog::canvasMetallicChanged,
|
||||
currentEditorWidgetItem, &EditorWidgetItem::handleCanvasMetallicChange);
|
||||
dialog->exec();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -69,6 +69,8 @@ EditorWidgetItem::EditorWidgetItem(QString filePath,QWidget *parent) : QWidget(p
|
|||
treeWidget->elementManager = elementManager;
|
||||
//qDebug() << layerManager->toJson();
|
||||
previewWindow->initialize(layerManager,QSize(jsonDoc.object().value("width").toInt(),jsonDoc.object().value("height").toInt()));
|
||||
previewWindow->canvasRoughness = jsonDoc.object().value("roughness").toDouble();
|
||||
previewWindow->canvasMetallic = jsonDoc.object().value("metallic").toDouble();
|
||||
|
||||
|
||||
if (layerManager->getRoot() != nullptr)
|
||||
|
@ -147,6 +149,8 @@ void EditorWidgetItem::saveImpl(QString filePath) const
|
|||
QJsonObject source1 = layerManager->toJson();
|
||||
QJsonObject source2 = elementManager->toJson();
|
||||
QJsonObject json;
|
||||
json.insert("roughness", previewWindow->canvasRoughness);
|
||||
json.insert("metallic", previewWindow->canvasMetallic);
|
||||
json.insert("width", previewWindow->referSize.width());
|
||||
json.insert("height", previewWindow->referSize.height());
|
||||
json.insert("root-layer", source1.value("root-layer"));
|
||||
|
@ -182,7 +186,27 @@ void EditorWidgetItem::handleCanvasSizeChange(const QSize& size)
|
|||
previewWindow->resize(size);
|
||||
}
|
||||
|
||||
void EditorWidgetItem::handleCanvasRoughnessChange(const float& roughness)
|
||||
{
|
||||
previewWindow->canvasRoughness = roughness;
|
||||
}
|
||||
|
||||
void EditorWidgetItem::handleCanvasMetallicChange(const float& metallic)
|
||||
{
|
||||
previewWindow->canvasMetallic = metallic;
|
||||
}
|
||||
|
||||
QSize EditorWidgetItem::getCanvasReferSize() const
|
||||
{
|
||||
return previewWindow->referSize;
|
||||
}
|
||||
|
||||
float EditorWidgetItem::getCanvasRoughness() const
|
||||
{
|
||||
return previewWindow->canvasRoughness;
|
||||
}
|
||||
|
||||
float EditorWidgetItem::getCanvasMetallic() const
|
||||
{
|
||||
return previewWindow->canvasMetallic;
|
||||
}
|
|
@ -47,7 +47,11 @@ public:
|
|||
void handleBackgroundColorChange(const QColor& color);
|
||||
void handleProjectNameChange(const QString& name);
|
||||
void handleCanvasSizeChange(const QSize& size);
|
||||
void handleCanvasRoughnessChange(const float& roughness);
|
||||
void handleCanvasMetallicChange(const float& metallic);
|
||||
QSize getCanvasReferSize() const;
|
||||
float getCanvasRoughness() const;
|
||||
float getCanvasMetallic() const;
|
||||
|
||||
private slots:
|
||||
void onLayerChange(LayerWrapper *layer);
|
||||
|
|
|
@ -39,6 +39,8 @@ class PreviewWindow : public QOpenGLWidget, protected QOpenGLFunctions
|
|||
void wheelEvent(QWheelEvent* event) override;
|
||||
|
||||
public:
|
||||
float canvasRoughness;
|
||||
float canvasMetallic;
|
||||
QSize referSize;
|
||||
PreviewWindow(QWidget *parent = nullptr);
|
||||
void initialize(LayerManager *layerManager,QSize referSize, QSize windowSize = QSize(720, 720));
|
||||
|
|
|
@ -4,23 +4,31 @@
|
|||
|
||||
CanvasPropertyWidget::CanvasPropertyWidget(const EditorWidgetItem* editorWidgetItem, QWidget* parent)
|
||||
:PropertyWidget(
|
||||
std::make_unique<CanvasProperties>(editorWidgetItem->backgroundColor, editorWidgetItem->getCanvasReferSize()),
|
||||
std::make_unique<CanvasProperties>(editorWidgetItem->backgroundColor, editorWidgetItem->getCanvasReferSize(), editorWidgetItem->getCanvasRoughness(), editorWidgetItem->getCanvasMetallic()),
|
||||
parent
|
||||
),
|
||||
backgroundColorPicker(new ColorPicker(clonedModel->backgroundColor, this)),
|
||||
canvasWidth(new QtMaterialTextField(this)),
|
||||
canvasHeight(new QtMaterialTextField(this))
|
||||
canvasHeight(new QtMaterialTextField(this)),
|
||||
canvasRoughness(new QtMaterialTextField(this)),
|
||||
canvasMetallic(new QtMaterialTextField(this))
|
||||
{
|
||||
auto* layout = new QFormLayout(this);
|
||||
layout->addRow(QStringLiteral("画布背景颜色"), backgroundColorPicker);
|
||||
layout->addRow(QStringLiteral("画布宽度"), canvasWidth);
|
||||
layout->addRow(QStringLiteral("画布高度"), canvasHeight);
|
||||
layout->addRow(QStringLiteral("»²¼´Ö²Ú¶È"), canvasRoughness);
|
||||
layout->addRow(QStringLiteral("»²¼½ðÊô¶È"), canvasMetallic);
|
||||
|
||||
canvasWidth->setText(QString::number(clonedModel->canvasSize.width()));
|
||||
canvasHeight->setText(QString::number(clonedModel->canvasSize.height()));
|
||||
canvasRoughness->setText(QString::number(clonedModel->canvasRoughness, 10, 3));
|
||||
canvasMetallic->setText(QString::number(clonedModel->canvasMetallic, 10, 3));
|
||||
|
||||
canvasWidth->setValidator(new QIntValidator(1, std::numeric_limits<int>::max()));
|
||||
canvasHeight->setValidator(new QIntValidator(1, std::numeric_limits<int>::max()));
|
||||
canvasRoughness->setValidator(new QDoubleValidator(0, 1, 3));
|
||||
canvasMetallic->setValidator(new QDoubleValidator(0, 1, 3));
|
||||
|
||||
connect(backgroundColorPicker, &ColorPicker::colorChanged, [this](const QColor& color)
|
||||
{
|
||||
|
@ -34,4 +42,12 @@ CanvasPropertyWidget::CanvasPropertyWidget(const EditorWidgetItem* editorWidgetI
|
|||
{
|
||||
this->clonedModel->canvasSize.setHeight(newText.toInt());
|
||||
});
|
||||
connect(canvasRoughness, &QtMaterialTextField::textEdited, [this](const QString& newText)
|
||||
{
|
||||
this->clonedModel->canvasRoughness = newText.toFloat();
|
||||
});
|
||||
connect(canvasMetallic, &QtMaterialTextField::textEdited, [this](const QString& newText)
|
||||
{
|
||||
this->clonedModel->canvasMetallic = newText.toFloat();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -8,6 +8,8 @@ struct CanvasProperties
|
|||
{
|
||||
QColor backgroundColor;
|
||||
QSize canvasSize;
|
||||
float canvasRoughness;
|
||||
float canvasMetallic;
|
||||
};
|
||||
|
||||
class CanvasPropertyWidget : public PropertyWidget<CanvasProperties>
|
||||
|
@ -17,6 +19,8 @@ private:
|
|||
ColorPicker* backgroundColorPicker;
|
||||
QtMaterialTextField* canvasWidth;
|
||||
QtMaterialTextField* canvasHeight;
|
||||
QtMaterialTextField* canvasRoughness;
|
||||
QtMaterialTextField* canvasMetallic;
|
||||
|
||||
public:
|
||||
CanvasPropertyWidget(const EditorWidgetItem* editorWidgetItem, QWidget* parent = nullptr);
|
||||
|
|
|
@ -40,5 +40,13 @@ void ProjectPropertyDialog::accept()
|
|||
{
|
||||
emit canvasSizeChanged(canvasProperties->canvasSize);
|
||||
}
|
||||
if (canvasProperties->canvasRoughness >= 0.0f && canvasProperties->canvasRoughness <= 1.0f)
|
||||
{
|
||||
emit canvasRoughnessChanged(canvasProperties->canvasRoughness);
|
||||
}
|
||||
if (canvasProperties->canvasMetallic >= 0.0f && canvasProperties->canvasMetallic <= 1.0f)
|
||||
{
|
||||
emit canvasMetallicChanged(canvasProperties->canvasMetallic);
|
||||
}
|
||||
QDialog::accept();
|
||||
}
|
||||
|
|
|
@ -19,6 +19,8 @@ signals:
|
|||
void backgroundColorChanged(const QColor& newBackgroundColor);
|
||||
void canvasSizeChanged(const QSize& newCanvasSize);
|
||||
void projectNameChanged(const QString& newProjectName);
|
||||
void canvasRoughnessChanged(const float& newCanvasRoughness);
|
||||
void canvasMetallicChanged(const float& newCanvasMetallic);
|
||||
|
||||
private slots:
|
||||
void accept() override;
|
||||
|
|
Loading…
Reference in New Issue