From d55b49e119b6b0adb7091974704dcde7fa0d9b51 Mon Sep 17 00:00:00 2001 From: ArgonarioD Date: Mon, 20 Mar 2023 21:10:01 +0800 Subject: [PATCH 1/2] =?UTF-8?q?[editor/style]=20fix:=20stroke=E5=AF=B9?= =?UTF-8?q?=E4=BA=8E=E7=A9=BA=E6=8F=8F=E8=BE=B9=E7=9A=84=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/Editor/EditorWidgetComponent/ColorPicker.cpp | 3 --- .../EditorWidgetComponent/StrokeStyleWidget.cpp | 11 +++-------- ArchitectureColoredPainting/src/Editor/LayerStyle.h | 4 ++-- 3 files changed, 5 insertions(+), 13 deletions(-) diff --git a/ArchitectureColoredPainting/src/Editor/EditorWidgetComponent/ColorPicker.cpp b/ArchitectureColoredPainting/src/Editor/EditorWidgetComponent/ColorPicker.cpp index 4ccb504..a7027cf 100644 --- a/ArchitectureColoredPainting/src/Editor/EditorWidgetComponent/ColorPicker.cpp +++ b/ArchitectureColoredPainting/src/Editor/EditorWidgetComponent/ColorPicker.cpp @@ -1,6 +1,4 @@ #include "ColorPicker.h" -#include -#include QString getStyleSheet(const QColor& color) { @@ -27,7 +25,6 @@ QColor ColorPicker::getColor() const void ColorPicker::onClicked() { - //const QColor newColor = QColorDialog::getColor(this->color, this); const QColor newColor = ColorHelper::execColorDialog(this->color, this); if (newColor.isValid() && this->color != newColor) { diff --git a/ArchitectureColoredPainting/src/Editor/EditorWidgetComponent/StrokeStyleWidget.cpp b/ArchitectureColoredPainting/src/Editor/EditorWidgetComponent/StrokeStyleWidget.cpp index 7422763..a8699f9 100644 --- a/ArchitectureColoredPainting/src/Editor/EditorWidgetComponent/StrokeStyleWidget.cpp +++ b/ArchitectureColoredPainting/src/Editor/EditorWidgetComponent/StrokeStyleWidget.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include @@ -28,12 +29,6 @@ StrokeStyleWidget::StrokeStyleWidget( QWidget* parent ) : QWidget(parent), stroke(stroke) { - auto& materialMap = radialStroke(stroke)->materialMap; - if (materialMap.empty()) - { - materialMap[1.f] = newMaterial(); - } - auto* viewLayout = new QVBoxLayout(this); this->setLayout(viewLayout); @@ -115,7 +110,7 @@ void StrokeStyleWidget::initTable(const std::shared_ptrsetHorizontalHeaderLabels(headers); - strokeTable->setMinimumHeight(strokeTable->rowHeight(0) * 5); + strokeTable->setMinimumHeight(strokeTable->horizontalHeader()->height() * 6); strokeTable->setMinimumWidth(strokeTable->sizeHint().width()); int row = 0; // 内容 @@ -131,7 +126,7 @@ void StrokeStyleWidget::initTable(const std::shared_ptraddButton = new QtMaterialRaisedButton("+", strokeTable); - addButton->setFixedHeight(this->strokeTable->rowHeight(0)); + addButton->setFixedHeight(30); addButton->setBackgroundColor(ColorHelper::instance().getPrimary1()); connect(addButton, &QtMaterialRaisedButton::clicked, [this] { handlingRowInsert = true; diff --git a/ArchitectureColoredPainting/src/Editor/LayerStyle.h b/ArchitectureColoredPainting/src/Editor/LayerStyle.h index 3eba1ad..45888a1 100644 --- a/ArchitectureColoredPainting/src/Editor/LayerStyle.h +++ b/ArchitectureColoredPainting/src/Editor/LayerStyle.h @@ -19,8 +19,8 @@ using Renderer::MaterialStyleFill; QString getDisplayName() const override { return QStringLiteral(display_name); } \ static QString typeName() { return type_name; } \ QString getTypeName() const override { return type_name; } -#define radialStroke(stroke) std::static_pointer_cast(stroke->materialStroke) -#define plainFill(fill) std::static_pointer_cast(fill->materialFill) +#define radialStroke(stroke) std::static_pointer_cast((stroke)->materialStroke) +#define plainFill(fill) std::static_pointer_cast((fill)->materialFill) class LayerStyle : public Renderer::ElementStyle { From a07bf3bcedf189c5506c74e859186804c53c4918 Mon Sep 17 00:00:00 2001 From: wuyize Date: Mon, 20 Mar 2023 21:49:02 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=8C=85=E5=9B=B4?= =?UTF-8?q?=E7=9B=92=E8=AE=A1=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 4_L0.json | 424 ++++++++++++++++++ .../res/Shaders/painting.comp | 2 +- .../src/Editor/util/PaintingUtil.cpp | 5 +- .../src/Editor/util/PaintingUtil.h | 2 +- svg/4_L0-fill.svg | 12 + test.json | 4 +- 6 files changed, 442 insertions(+), 7 deletions(-) create mode 100644 4_L0.json create mode 100644 svg/4_L0-fill.svg diff --git a/4_L0.json b/4_L0.json new file mode 100644 index 0000000..2465bb6 --- /dev/null +++ b/4_L0.json @@ -0,0 +1,424 @@ +{ + "background-color": "#b7a386", + "elements": [ + { + "data": { + "include": "../svg/2.svg" + }, + "name": "ababa", + "type": "svg-file" + }, + { + "data": { + "reference-layer": "0.0" + }, + "name": "ababa-group", + "type": "group" + }, + { + "data": { + "include": "../svg/0.svg" + }, + "name": "ababa2", + "type": "svg-file" + }, + { + "data": { + "include": "D:/BigC2022/temp/ArchitectureColoredPainting/svg/4_L0-fill.svg" + }, + "name": "4_L0-fill.svg", + "type": "svg-file" + } + ], + "height": 1080, + "project-name": "鏍蜂緥1", + "root-layer": { + "children": [ + { + "children": [ + { + "element": 3, + "is-folder": false, + "name": "4_L0", + "styles": [ + { + "material": "AH8A/2pkiv8=", + "type": "fill" + }, + { + "enableEachSideIndependent": true, + "left": "AADAQAEAJJwAf///9dKG/w==", + "right": "AADgQAAACpw=", + "type": "stroke" + } + ], + "transform": { + "offset": { + "x": -230, + "y": -533 + }, + "rotation": 0, + "scale": { + "x": 0.32341007644113307, + "y": 0.32341007644113307 + } + } + } + ], + "is-folder": true, + "name": "GroupFolderExample", + "referenced-by": 1, + "transform": { + "offset": { + "x": 50, + "y": 50 + }, + "rotation": 0, + "scale": { + "x": 1, + "y": 1 + } + } + }, + { + "element": 1, + "is-folder": false, + "name": "aaaa2", + "styles": [ + ], + "transform": { + "offset": { + "x": 127, + "y": -109 + }, + "rotation": 90, + "scale": { + "x": 1, + "y": 1 + } + } + }, + { + "element": 1, + "is-folder": false, + "name": "aaaa3", + "styles": [ + ], + "transform": { + "offset": { + "x": 232, + "y": 17 + }, + "rotation": 180, + "scale": { + "x": 1, + "y": 1 + } + } + }, + { + "element": 1, + "is-folder": false, + "name": "aaaa4", + "styles": [ + ], + "transform": { + "offset": { + "x": 103, + "y": 130 + }, + "rotation": 270, + "scale": { + "x": 1, + "y": 1 + } + } + }, + { + "element": 1, + "is-folder": false, + "name": "bbbb1", + "styles": [ + ], + "transform": { + "offset": { + "x": 197, + "y": 265 + }, + "rotation": 0, + "scale": { + "x": 1, + "y": 1 + } + } + }, + { + "element": 1, + "is-folder": false, + "name": "bbbb2", + "styles": [ + ], + "transform": { + "offset": { + "x": 323, + "y": 156 + }, + "rotation": 90, + "scale": { + "x": 1, + "y": 1 + } + } + }, + { + "element": 1, + "is-folder": false, + "name": "bbbb3", + "styles": [ + ], + "transform": { + "offset": { + "x": 432, + "y": 285 + }, + "rotation": 180, + "scale": { + "x": 1, + "y": 1 + } + } + }, + { + "element": 1, + "is-folder": false, + "name": "bbbb4", + "styles": [ + ], + "transform": { + "offset": { + "x": 302, + "y": 399 + }, + "rotation": 270, + "scale": { + "x": 1, + "y": 1 + } + } + }, + { + "element": 1, + "is-folder": false, + "name": "cccc1", + "styles": [ + ], + "transform": { + "offset": { + "x": 467, + "y": 71 + }, + "rotation": 0, + "scale": { + "x": 1, + "y": 1 + } + } + }, + { + "element": 1, + "is-folder": false, + "name": "cccc2", + "styles": [ + ], + "transform": { + "offset": { + "x": 361, + "y": -70 + }, + "rotation": 90, + "scale": { + "x": 1, + "y": 1 + } + } + }, + { + "element": 1, + "is-folder": false, + "name": "cccc3", + "styles": [ + ], + "transform": { + "offset": { + "x": 273, + "y": -211 + }, + "rotation": 180, + "scale": { + "x": 1, + "y": 1 + } + } + }, + { + "element": 1, + "is-folder": false, + "name": "cccc4", + "styles": [ + ], + "transform": { + "offset": { + "x": 574, + "y": 198 + }, + "rotation": 270, + "scale": { + "x": 1, + "y": 1 + } + } + }, + { + "element": 1, + "is-folder": false, + "name": "dddd1", + "styles": [ + ], + "transform": { + "offset": { + "x": 33, + "y": -231 + }, + "rotation": 0, + "scale": { + "x": 1, + "y": 1 + } + } + }, + { + "element": 1, + "is-folder": false, + "name": "dddd2", + "styles": [ + ], + "transform": { + "offset": { + "x": 55, + "y": 352 + }, + "rotation": 90, + "scale": { + "x": 1, + "y": 1 + } + } + }, + { + "element": 1, + "is-folder": false, + "name": "dddd3", + "styles": [ + ], + "transform": { + "offset": { + "x": -40, + "y": 220 + }, + "rotation": 180, + "scale": { + "x": 1, + "y": 1 + } + } + }, + { + "element": 1, + "is-folder": false, + "name": "dddd4", + "styles": [ + ], + "transform": { + "offset": { + "x": 0, + "y": 0 + }, + "rotation": 0, + "scale": { + "x": 1, + "y": 1 + } + } + }, + { + "element": 1, + "is-folder": false, + "name": "eeee1", + "styles": [ + ], + "transform": { + "offset": { + "x": 0, + "y": 0 + }, + "rotation": 0, + "scale": { + "x": 1, + "y": 1 + } + } + }, + { + "element": 1, + "is-folder": false, + "name": "eeee2", + "styles": [ + ], + "transform": { + "offset": { + "x": -149, + "y": 85 + }, + "rotation": 90, + "scale": { + "x": 1, + "y": 1 + } + } + }, + { + "element": 1, + "is-folder": false, + "name": "eeee3", + "styles": [ + ], + "transform": { + "offset": { + "x": 166, + "y": 482 + }, + "rotation": 180, + "scale": { + "x": 1, + "y": 1 + } + } + } + ], + "is-folder": true, + "name": "root", + "referenced-by": null, + "transform": { + "offset": { + "x": 8, + "y": 20 + }, + "rotation": 0, + "scale": { + "x": 1.7159367435419115, + "y": 1.7159367435419115 + } + } + }, + "width": 1080 +} diff --git a/ArchitectureColoredPainting/res/Shaders/painting.comp b/ArchitectureColoredPainting/res/Shaders/painting.comp index 6e166cf..324e093 100644 --- a/ArchitectureColoredPainting/res/Shaders/painting.comp +++ b/ArchitectureColoredPainting/res/Shaders/painting.comp @@ -1409,7 +1409,7 @@ void main() imageStore(gBaseColor, pixelLocation, vec4(color.rgb, 1)); imageStore(gMetallicRoughness, pixelLocation, vec4(metallicRoughness, 0, 1)); - //return; + return; if (/*color.a!=-1&&*/ debugBVH == vec3(0)) { // imageStore(gBaseColor, pixelLocation, vec4(vec3(1, 1, 0),1)); diff --git a/ArchitectureColoredPainting/src/Editor/util/PaintingUtil.cpp b/ArchitectureColoredPainting/src/Editor/util/PaintingUtil.cpp index aa23ce6..c6b7b55 100644 --- a/ArchitectureColoredPainting/src/Editor/util/PaintingUtil.cpp +++ b/ArchitectureColoredPainting/src/Editor/util/PaintingUtil.cpp @@ -14,8 +14,6 @@ using std::make_shared; using std::min; using std::queue; -const double PaintingUtil::pi = acos(-1); - struct LayerNode { LayerWrapper* nowLayer; QTransform transfrom; @@ -109,8 +107,9 @@ FolderLayerWrapper* PaintingUtil::handleLayerWrapper(LayerWrapper* nowLayer, QTr qDebug() << material->halfWidth; } QPainterPathStroker stroker; - stroker.setWidth(lineWidth); + stroker.setWidth(lineWidth * 2); stroker.setCapStyle(Qt::RoundCap); + stroker.setJoinStyle(Qt::RoundJoin); QPainterPath strokePath = stroker.createStroke(painterPath); auto rect = transform.map(strokePath).boundingRect(); elementTransform.bound = glm::vec4(rect.x(), rect.y(), rect.x() + rect.width(), rect.y() + rect.height()); diff --git a/ArchitectureColoredPainting/src/Editor/util/PaintingUtil.h b/ArchitectureColoredPainting/src/Editor/util/PaintingUtil.h index 850bfc0..332a0a4 100644 --- a/ArchitectureColoredPainting/src/Editor/util/PaintingUtil.h +++ b/ArchitectureColoredPainting/src/Editor/util/PaintingUtil.h @@ -5,7 +5,7 @@ class PaintingUtil { private: - static const double pi; + //static const double pi; static QJsonObject readJsonFile(QString jsonFilePath); static FolderLayerWrapper* handleLayerWrapper(LayerWrapper* nowLayer, QTransform& transform, Renderer::Painting& painting); //static double getMaxLineWidth(LayerWrapper* root); diff --git a/svg/4_L0-fill.svg b/svg/4_L0-fill.svg new file mode 100644 index 0000000..7248976 --- /dev/null +++ b/svg/4_L0-fill.svg @@ -0,0 +1,12 @@ + + + + + + diff --git a/test.json b/test.json index ce11428..c5158fb 100644 --- a/test.json +++ b/test.json @@ -59,9 +59,9 @@ "name": "Leaf2", "styles": [ { - "enableEachSideIndependent": true, + "enableEachSideIndependent": false, "left": "AAAAQAEAIZwAf////1UA/w==", - "right": "AADgQAAACJw=", + "right": "AADgQAEACJwAf///AFqe/w==", "type": "stroke" } ],