Fix: PreviewWindow显示不完整 | #26

dev-wuyize
wuyize 2023-03-22 14:51:37 +08:00
parent 7e0e07292f
commit 60c7695545
5 changed files with 19 additions and 37 deletions

View File

@ -66,11 +66,11 @@
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents">
<widget class="PreviewWindow" name="Preview">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<y>-17</y>
<width>1024</width>
<height>1024</height>
</rect>
@ -88,35 +88,11 @@
</size>
</property>
<property name="maximumSize">
<size>
<width>10241024</width>
<height>10241024</height>
</size>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="PreviewWindow" name="Preview">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>1024</width>
<height>1024</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>1024</width>
<height>1024</height>
</size>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>

View File

@ -1402,7 +1402,7 @@ void main()
if (elementZIndex <= zIndex)
{
uint transformIndex = leftChild - 0x80000000;
uint elementIndex = bvhChildren[index].y - elementZIndex;
uint elementIndex = bvhChildren[index].y & 0x3FFFF;
mat3x2 transform = elementTranform[transformIndex];
vec2 localUV =
(mat3(vec3(transform[0], 0), vec3(transform[1], 0), vec3(transform[2], 1)) * vec3(uv, 1))

View File

@ -91,7 +91,7 @@ void PaintingUtil::handleLayerWrapper(LayerWrapper* nowLayer, QTransform transfo
QTransform trans;
double maxLen = std::max(bound.width(), bound.height()) * 1.00001;
//qDebug() << maxLen << bound;
trans.scale(1 / maxLen, 1 / maxLen);
trans.scale(2 / maxLen, 2 / maxLen);
trans.translate(-bound.center().x(), -bound.center().y());
//std::shared_ptr<LayerWrapper> keyLayerPtr(nowLayer);
@ -116,6 +116,7 @@ void PaintingUtil::handleLayerWrapper(LayerWrapper* nowLayer, QTransform transfo
for (auto& baseStyle : baseStyles) {
double lineWidth = 0;
QPainterPath path;
std::shared_ptr<MaterialStyle> material;
@ -124,15 +125,19 @@ void PaintingUtil::handleLayerWrapper(LayerWrapper* nowLayer, QTransform transfo
std::static_pointer_cast<MaterialStyleStroke>(copy)->halfWidth /= maxLen;
lineWidth = std::static_pointer_cast<MaterialStyleStroke>(copy)->halfWidth;
material = copy;
}
else
material = baseStyle.material;
QPainterPathStroker stroker;
stroker.setWidth(lineWidth * 2);
stroker.setCapStyle(Qt::RoundCap);
stroker.setJoinStyle(Qt::RoundJoin);
QPainterPath strokePath = stroker.createStroke(painterPath);
auto rect = leafTransform.map(strokePath).boundingRect();
path = stroker.createStroke(painterPath);
}
else
{
material = baseStyle.material;
path = painterPath;
}
auto rect = leafTransform.map(path).boundingRect();
elementTransform.bound = glm::vec4(rect.x(), rect.y(), rect.x() + rect.width(), rect.y() + rect.height());
//qDebug() << elementTransform.bound.x << elementTransform.bound.y << elementTransform.bound.z << elementTransform.bound.z;
elementTransform.transform = glm::mat3x2(

View File

@ -351,7 +351,7 @@ GLuint Renderer::Model::loadPainting(std::string path)
trans.m13(), trans.m23(), trans.m33()).c_str();
//painting.addElement(*element[0], ElementTransform{ glm::vec4(-1,-1,1,1), mat, 0});
painting.addElement(*element[1], ElementTransform{ glm::vec4(-1,-1,0,1), mat, 0 });
painting.addElement(*element[1], ElementTransform{ glm::vec4(-1,-1,0,1), mat, 1 });
painting.addElement(*element[2], ElementTransform{ glm::vec4(0,-1,1,1), mat2, 0 });
//painting.addElement(*element[0], ElementTransform{ glm::vec2(-0.45,0.45), glm::vec2(0.25), 0, glm::bvec2(false), 0 });
//painting.addElement(*element[1], ElementTransform{ glm::vec2(-0.535,0.33), glm::vec2(0.15), 0, glm::bvec2(false), 0 });

1
svg/正方形.svg Normal file
View File

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 116.45 116.45"><defs><style>.cls-1{fill:#fff;stroke:#231815;stroke-miterlimit:10;}</style></defs><g id="图层_2" data-name="图层 2"><g id="图层_1-2" data-name="图层 1"><rect class="cls-1" x="0.5" y="0.5" width="115.45" height="115.45"/></g></g></svg>

After

Width:  |  Height:  |  Size: 310 B