增加了originPath以便transform操作

dev-wuyize
yang.yongquan 2023-03-21 10:23:11 +08:00
parent a84c8cb752
commit 793402e3c5
4 changed files with 11 additions and 38 deletions

View File

@ -41,6 +41,7 @@ void PixelPath::addPath(const PixelPath& path)
QPainter painter(&pixmap); QPainter painter(&pixmap);
painter.drawPixmap(0, 0, path.getPixmap()); painter.drawPixmap(0, 0, path.getPixmap());
this->painterPath.addPath(path.getPainterPath()); this->painterPath.addPath(path.getPainterPath());
this->originPath.addPath(path.originPath);
boundingRect = boundingRect.united(path.getBoundingRect()); boundingRect = boundingRect.united(path.getBoundingRect());
} }
@ -52,6 +53,7 @@ void PixelPath::addPath(const QPainterPath& path)
painter.setPen(QPen(Qt::black,1)); painter.setPen(QPen(Qt::black,1));
painter.drawPath(path); painter.drawPath(path);
this->painterPath.addPath(path); this->painterPath.addPath(path);
this->originPath.addPath(path);
boundingRect = boundingRect.united(path.boundingRect()); boundingRect = boundingRect.united(path.boundingRect());
} }
@ -67,6 +69,7 @@ void PixelPath::clear()
pixmap.fill(Qt::transparent); pixmap.fill(Qt::transparent);
boundingRect = QRectF(0, 0, 0, 0); boundingRect = QRectF(0, 0, 0, 0);
painterPath.clear(); painterPath.clear();
originPath.clear();
} }
PixelPath PixelPath::trans(QTransform& mat)const PixelPath PixelPath::trans(QTransform& mat)const
@ -78,6 +81,7 @@ PixelPath PixelPath::trans(QTransform& mat)const
painter.setTransform(mat); painter.setTransform(mat);
painter.drawPixmap(0, 0, pixmap); painter.drawPixmap(0, 0, pixmap);
result.painterPath.addPath(this->painterPath); result.painterPath.addPath(this->painterPath);
result.originPath.addPath(this->painterPath);
result.painterPath = mat.map(result.painterPath); result.painterPath = mat.map(result.painterPath);
result.boundingRect = result.painterPath.boundingRect(); result.boundingRect = result.painterPath.boundingRect();
return result; return result;

View File

@ -10,7 +10,7 @@ class PixelPath
public: public:
QRectF boundingRect; QRectF boundingRect;
QPixmap pixmap; QPixmap pixmap;
QPainterPath painterPath; QPainterPath painterPath, originPath;
int w,h; int w,h;
public: public:
PixelPath(int w=16, int h= 16); PixelPath(int w=16, int h= 16);

View File

@ -79,7 +79,7 @@ FolderLayerWrapper* PaintingUtil::handleLayerWrapper(LayerWrapper* nowLayer, QTr
} }
PixelPath pixelPath = nowLayer->getCache(); PixelPath pixelPath = nowLayer->getCache();
QPainterPath painterPath = pixelPath.getPainterPath(); QPainterPath painterPath = pixelPath.originPath;
QRectF bound = painterPath.boundingRect(); QRectF bound = painterPath.boundingRect();
//qDebug() << leafLayer<<"------" << painterPath; //qDebug() << leafLayer<<"------" << painterPath;
// transform to -1£¬ 1 // transform to -1£¬ 1

View File

@ -3,7 +3,7 @@
"elements": [ "elements": [
{ {
"data": { "data": {
"include": "../svg/2.svg" "include": "/svg/2.svg"
}, },
"name": "ababa", "name": "ababa",
"type": "svg-file" "type": "svg-file"
@ -17,17 +17,10 @@
}, },
{ {
"data": { "data": {
"include": "../svg/0.svg" "include": "/svg/0.svg"
}, },
"name": "ababa2", "name": "ababa2",
"type": "svg-file" "type": "svg-file"
},
{
"data": {
"include": "D:/BigC2022/temp/ArchitectureColoredPainting/svg/3.svg"
},
"name": "3.svg",
"type": "svg-file"
} }
], ],
"height": 1080, "height": 1080,
@ -43,7 +36,7 @@
"styles": [ "styles": [
{ {
"enableEachSideIndependent": false, "enableEachSideIndependent": false,
"left": "AAAAQAEAIZwAf///qqr//w==", "left": "AACgQAEAIZwAf///AZ5X/w==",
"right": "AADgQAAACJw=", "right": "AADgQAAACJw=",
"type": "stroke" "type": "stroke"
} }
@ -67,8 +60,8 @@
"styles": [ "styles": [
{ {
"enableEachSideIndependent": false, "enableEachSideIndependent": false,
"left": "AAAAQAEAIZwAf////1UA/w==", "left": "AABAQAEAIZwAf///AFqe/w==",
"right": "AADgQAEACJwAf///AFqe/w==", "right": "AADgQAAACJw=",
"type": "stroke" "type": "stroke"
} }
], ],
@ -83,30 +76,6 @@
"y": 1.5 "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, "is-folder": true,