From 97097fcc3abccdbd4230ec8553e5b952853eff47 Mon Sep 17 00:00:00 2001 From: karlis <2995621482@qq.com> Date: Tue, 14 Mar 2023 15:36:19 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=97=8B=E8=BD=AC=E5=88=A4?= =?UTF-8?q?=E5=AE=9A=EF=BC=8C=E6=B7=BB=E5=8A=A0style=E6=B8=B2=E6=9F=93?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/Editor/GraphicElement.cpp | 15 ++++++++++++--- .../src/Editor/PreviewWindow.cpp | 4 ++-- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/ArchitectureColoredPainting/src/Editor/GraphicElement.cpp b/ArchitectureColoredPainting/src/Editor/GraphicElement.cpp index d3dc67b..9602f2d 100644 --- a/ArchitectureColoredPainting/src/Editor/GraphicElement.cpp +++ b/ArchitectureColoredPainting/src/Editor/GraphicElement.cpp @@ -87,11 +87,20 @@ QJsonObject GraphicElement::toJson() const void SimpleElement::paint(QPainter* painter, QTransform transform, vector> styles) { - Renderer::ElementStyleStrokeDemo demo(2); - auto [img, mov] = renderer->drawElement(painterPath, demo, 1.0); painter->save(); painter->setTransform(transform); - painter->drawImage(mov, img); + if (styles.empty()) + { + painter->drawPath(painterPath); + } + else + { + // TODO:应用style + Renderer::ElementStyleStrokeDemo demo(2); + auto [img, mov] = renderer->drawElement(painterPath, demo, 1.0); + painter->drawImage(mov, img); + } + painter->restore(); } diff --git a/ArchitectureColoredPainting/src/Editor/PreviewWindow.cpp b/ArchitectureColoredPainting/src/Editor/PreviewWindow.cpp index d8199c7..485977d 100644 --- a/ArchitectureColoredPainting/src/Editor/PreviewWindow.cpp +++ b/ArchitectureColoredPainting/src/Editor/PreviewWindow.cpp @@ -88,9 +88,9 @@ void PreviewWindow::mouseMoveEvent(QMouseEvent* event) currentLayer->property.offset.setY(currentLayer->property.offset.y() + dy); qDebug() << dx << "----" << dy; } - else if (event->buttons() & Qt::RightButton) { + else if (event->buttons() & Qt::RightButton) { // 如果按下的是右键,那么旋转图形 - qreal angle = -sqrt(dx * dx + dy * dy) / 1.0; + qreal angle = dx; currentLayer->property.rotation += angle; } }