merge
commit
f175e50b7b
|
@ -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>
|
||||
|
@ -89,34 +89,10 @@
|
|||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>10241024</width>
|
||||
<height>10241024</height>
|
||||
<width>1024</width>
|
||||
<height>1024</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>
|
||||
|
|
|
@ -1376,7 +1376,7 @@ void main()
|
|||
// vec4 color = vec4(0.76, 0.33, 0.15, -1);
|
||||
vec4 color = vec4(backgroundRed, backgroundGreen, backgroundBlue, -1);
|
||||
vec2 metallicRoughness = vec2(backgroundMetallic, backgroundRoughness);
|
||||
int zIndex = 1<<15;
|
||||
uint zIndex = 1 << 15;
|
||||
// vec4 color = vec4(0.72f, 0.66f, 0.55f, -1);
|
||||
// vec2 metallicRoughness = vec2(0,0.5);
|
||||
stack.top = 0;
|
||||
|
@ -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))
|
||||
|
@ -1412,6 +1412,7 @@ void main()
|
|||
vec2 elementMetallicRoughness;
|
||||
if (drawElement(elementIndex, localUV, elementColor, elementMetallicRoughness, debugBVH))
|
||||
{
|
||||
zIndex = elementZIndex;
|
||||
color = vec4(elementColor, elementZIndex);
|
||||
metallicRoughness = elementMetallicRoughness;
|
||||
}
|
||||
|
|
|
@ -92,6 +92,15 @@ LeafLayerWrapper::~LeafLayerWrapper()
|
|||
wrappedElement->referencedCount--;
|
||||
}
|
||||
|
||||
void LayerWrapper::SimpleProperty::setRotation(double newRotation)
|
||||
{
|
||||
if (newRotation <= -360 || 360 <= newRotation)
|
||||
{
|
||||
newRotation -= static_cast<int>(std::round(newRotation)) / 360 * 360;
|
||||
}
|
||||
rotation = newRotation;
|
||||
}
|
||||
|
||||
void LayerWrapper::SimpleProperty::apply(PixelPath&cache)
|
||||
{
|
||||
transform.reset();
|
||||
|
|
|
@ -49,6 +49,7 @@ class LayerWrapper
|
|||
bool flipY = 0;
|
||||
QTransform transform;
|
||||
// TODO: 将QPainterPath改为BitmapPath
|
||||
void setRotation(double newRotation);
|
||||
void apply(PixelPath&cache);
|
||||
} property;
|
||||
virtual void setParent(FolderLayerWrapper*newParent);
|
||||
|
|
|
@ -106,7 +106,7 @@ void PreviewWindow::mouseMoveEvent(QMouseEvent* event)
|
|||
else if (event->buttons() & Qt::RightButton) {
|
||||
// 如果按下的是右键,那么旋转图形
|
||||
qreal angle = dx;
|
||||
currentLayer->property.rotation += angle;
|
||||
currentLayer->property.setRotation(currentLayer->property.rotation + angle);
|
||||
}
|
||||
auto layer = currentLayer;
|
||||
while (layer != nullptr)
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include <QJsondocument>
|
||||
#include "PainterPathUtil.h"
|
||||
#include <queue>
|
||||
#include <ranges>
|
||||
#include <QFileInfo>
|
||||
|
||||
using Renderer::Painting;
|
||||
|
@ -52,7 +53,7 @@ Painting PaintingUtil::transfromToPainting(QString jsonFilePath) {
|
|||
//qDebug() << ((SimpleElement*)((LeafLayerWrapper*)((FolderLayerWrapper*)((FolderLayerWrapper*)layerManager->getRoot())->children[0].get())->children[0].get())->wrappedElement)->painterPath;
|
||||
//qDebug() << ((LeafLayerWrapper*)((FolderLayerWrapper*)((FolderLayerWrapper*)layerManager->getRoot())->children[0].get())->children[0].get())->getCache().painterPath;
|
||||
//queue<LayerNode> layerQueue;
|
||||
|
||||
|
||||
//double maxLineWidth = getMaxLineWidth(root);
|
||||
//layerQueue.push({ root, QTransform()});
|
||||
/*while (!layerQueue.empty()) {
|
||||
|
@ -66,7 +67,7 @@ Painting PaintingUtil::transfromToPainting(QString jsonFilePath) {
|
|||
}
|
||||
}*/
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
void PaintingUtil::handleLayerWrapper(LayerWrapper* nowLayer, QTransform transform, Painting& painting, std::unordered_map<LayerWrapper*, Contour>& contourMap) {
|
||||
|
@ -93,7 +94,7 @@ void PaintingUtil::handleLayerWrapper(LayerWrapper* nowLayer, QTransform transfo
|
|||
//qDebug() << maxLen << bound;
|
||||
trans.scale(1 / maxLen, 1 / maxLen);
|
||||
trans.translate(-bound.center().x(), -bound.center().y());
|
||||
|
||||
painterPath = trans.map(painterPath);
|
||||
//std::shared_ptr<LayerWrapper> keyLayerPtr(nowLayer);
|
||||
auto iterContour = contourMap.find(nowLayer);
|
||||
PaintingUtil::Contour contour = nullptr;
|
||||
|
@ -101,45 +102,53 @@ void PaintingUtil::handleLayerWrapper(LayerWrapper* nowLayer, QTransform transfo
|
|||
contour = iterContour->second;
|
||||
}
|
||||
else {
|
||||
painterPath = trans.map(painterPath);
|
||||
contour = std::make_shared<vector<vector<Renderer::Point> >>(PainterPathUtil::transformToLines(painterPath));
|
||||
contourMap.insert({ nowLayer, contour });
|
||||
; }
|
||||
;
|
||||
}
|
||||
QSize screenSize = QSize(1080, 1080);
|
||||
|
||||
ElementTransform elementTransform;
|
||||
QTransform leafTransform = trans.inverted() * transform * QTransform::fromScale(2. / screenSize.width(), 2. / screenSize.height()) * QTransform::fromTranslate(-1, -1) * QTransform::fromScale(1, -1);
|
||||
QTransform transformInverted = leafTransform.inverted();
|
||||
|
||||
++zIndexCount;
|
||||
//++zIndexCount;
|
||||
auto baseStyles = leafLayer->styles.toBaseStyles();
|
||||
|
||||
for (auto& baseStyle : baseStyles) {
|
||||
qDebug() << baseStyles.size();
|
||||
for (auto& baseStyle : std::views::reverse(baseStyles)) {
|
||||
double lineWidth = 0;
|
||||
QPainterPath path;
|
||||
|
||||
std::shared_ptr<MaterialStyle> material;
|
||||
|
||||
if (baseStyle.material->type() == Renderer::MaterialStyleType::kStroke) {
|
||||
qDebug() << "MaterialStyleType::kStroke";
|
||||
std::shared_ptr copy = baseStyle.material->clone();
|
||||
std::static_pointer_cast<MaterialStyleStroke>(copy)->halfWidth /= maxLen;
|
||||
lineWidth = std::static_pointer_cast<MaterialStyleStroke>(copy)->halfWidth;
|
||||
material = copy;
|
||||
|
||||
QPainterPathStroker stroker;
|
||||
stroker.setWidth(lineWidth * 2);
|
||||
stroker.setCapStyle(Qt::RoundCap);
|
||||
stroker.setJoinStyle(Qt::RoundJoin);
|
||||
path = stroker.createStroke(painterPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug() << "MaterialStyleType::kFill";
|
||||
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 = painterPath;
|
||||
}
|
||||
auto rect = leafTransform.map(path).boundingRect();
|
||||
elementTransform.bound = glm::vec4(rect.x(), rect.y(), rect.x() + rect.width(), rect.y() + rect.height());
|
||||
//elementTransform.bound = glm::vec4(-1,-1,1,1);
|
||||
//qDebug() << elementTransform.bound.x << elementTransform.bound.y << elementTransform.bound.z << elementTransform.bound.z;
|
||||
elementTransform.transform = glm::mat3x2(
|
||||
transformInverted.m11(), transformInverted.m12(), transformInverted.m21(),
|
||||
transformInverted.m22(), transformInverted.m31(), transformInverted.m32()
|
||||
);
|
||||
elementTransform.zIndex = zIndexCount;
|
||||
elementTransform.zIndex = ++zIndexCount;
|
||||
painting.addElement(BaseElement{ contour, material }, elementTransform);
|
||||
}
|
||||
|
||||
|
|
|
@ -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 });
|
||||
|
|
|
@ -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 |
Loading…
Reference in New Issue