增加了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);
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;

View File

@ -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);

View File

@ -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

View File

@ -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,