From 793402e3c5c6ecd643fbc9f29f020d8cce43b625 Mon Sep 17 00:00:00 2001 From: "yang.yongquan" <3395816735@qq.com> Date: Tue, 21 Mar 2023 10:23:11 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BA=86originPath=E4=BB=A5?= =?UTF-8?q?=E4=BE=BFtransform=E6=93=8D=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/Editor/PixelPath.cpp | 4 ++ .../src/Editor/PixelPath.h | 2 +- .../src/Editor/util/PaintingUtil.cpp | 2 +- test.json | 41 +++---------------- 4 files changed, 11 insertions(+), 38 deletions(-) diff --git a/ArchitectureColoredPainting/src/Editor/PixelPath.cpp b/ArchitectureColoredPainting/src/Editor/PixelPath.cpp index e673504..7eaf51d 100644 --- a/ArchitectureColoredPainting/src/Editor/PixelPath.cpp +++ b/ArchitectureColoredPainting/src/Editor/PixelPath.cpp @@ -41,6 +41,7 @@ void PixelPath::addPath(const PixelPath& path) QPainter painter(&pixmap); painter.drawPixmap(0, 0, path.getPixmap()); this->painterPath.addPath(path.getPainterPath()); + this->originPath.addPath(path.originPath); boundingRect = boundingRect.united(path.getBoundingRect()); } @@ -52,6 +53,7 @@ void PixelPath::addPath(const QPainterPath& path) painter.setPen(QPen(Qt::black,1)); painter.drawPath(path); this->painterPath.addPath(path); + this->originPath.addPath(path); boundingRect = boundingRect.united(path.boundingRect()); } @@ -67,6 +69,7 @@ void PixelPath::clear() pixmap.fill(Qt::transparent); boundingRect = QRectF(0, 0, 0, 0); painterPath.clear(); + originPath.clear(); } PixelPath PixelPath::trans(QTransform& mat)const @@ -78,6 +81,7 @@ PixelPath PixelPath::trans(QTransform& mat)const painter.setTransform(mat); painter.drawPixmap(0, 0, pixmap); result.painterPath.addPath(this->painterPath); + result.originPath.addPath(this->painterPath); result.painterPath = mat.map(result.painterPath); result.boundingRect = result.painterPath.boundingRect(); return result; diff --git a/ArchitectureColoredPainting/src/Editor/PixelPath.h b/ArchitectureColoredPainting/src/Editor/PixelPath.h index c3dc704..894ac63 100644 --- a/ArchitectureColoredPainting/src/Editor/PixelPath.h +++ b/ArchitectureColoredPainting/src/Editor/PixelPath.h @@ -10,7 +10,7 @@ class PixelPath public: QRectF boundingRect; QPixmap pixmap; - QPainterPath painterPath; + QPainterPath painterPath, originPath; int w,h; public: PixelPath(int w=16, int h= 16); diff --git a/ArchitectureColoredPainting/src/Editor/util/PaintingUtil.cpp b/ArchitectureColoredPainting/src/Editor/util/PaintingUtil.cpp index 0b84c07..1d5dd71 100644 --- a/ArchitectureColoredPainting/src/Editor/util/PaintingUtil.cpp +++ b/ArchitectureColoredPainting/src/Editor/util/PaintingUtil.cpp @@ -79,7 +79,7 @@ FolderLayerWrapper* PaintingUtil::handleLayerWrapper(LayerWrapper* nowLayer, QTr } PixelPath pixelPath = nowLayer->getCache(); - QPainterPath painterPath = pixelPath.getPainterPath(); + QPainterPath painterPath = pixelPath.originPath; QRectF bound = painterPath.boundingRect(); //qDebug() << leafLayer<<"------" << painterPath; // transform to -1£¬ 1 diff --git a/test.json b/test.json index d369f0c..777aeec 100644 --- a/test.json +++ b/test.json @@ -3,7 +3,7 @@ "elements": [ { "data": { - "include": "../svg/2.svg" + "include": "/svg/2.svg" }, "name": "ababa", "type": "svg-file" @@ -17,17 +17,10 @@ }, { "data": { - "include": "../svg/0.svg" + "include": "/svg/0.svg" }, "name": "ababa2", "type": "svg-file" - }, - { - "data": { - "include": "D:/BigC2022/temp/ArchitectureColoredPainting/svg/3.svg" - }, - "name": "3.svg", - "type": "svg-file" } ], "height": 1080, @@ -43,7 +36,7 @@ "styles": [ { "enableEachSideIndependent": false, - "left": "AAAAQAEAIZwAf///qqr//w==", + "left": "AACgQAEAIZwAf///AZ5X/w==", "right": "AADgQAAACJw=", "type": "stroke" } @@ -67,8 +60,8 @@ "styles": [ { "enableEachSideIndependent": false, - "left": "AAAAQAEAIZwAf////1UA/w==", - "right": "AADgQAEACJwAf///AFqe/w==", + "left": "AABAQAEAIZwAf///AFqe/w==", + "right": "AADgQAAACJw=", "type": "stroke" } ], @@ -83,30 +76,6 @@ "y": 1.5 } } - }, - { - "element": -842150451, - "is-folder": false, - "name": "å­å›¾å±‚-3", - "styles": [ - { - "enableEachSideIndependent": false, - "left": "AAAAQAEAIZwAf///AP8A/w==", - "right": "AADgQAAACJw=", - "type": "stroke" - } - ], - "transform": { - "offset": { - "x": 0, - "y": 0 - }, - "rotation": 0, - "scale": { - "x": 1, - "y": 1 - } - } } ], "is-folder": true,