修正了样例;修复了main函数

dev-VirtualTexture
白封羽 2022-12-21 15:24:53 +08:00
parent 5b5465103a
commit d4e52d4ab8
5 changed files with 35 additions and 22 deletions

View File

@ -21,8 +21,11 @@ QPainterPath SimpleElement::getPaintObject() const
{ {
return painterPath; return painterPath;
} }
// TODO
void SimpleElement::pathOperate(QJsonArray paths) void SimpleElement::pathOperate(QJsonArray paths)
{ {
QRect r(100, 100, 100, 100);
painterPath.addRect(r);
} }
void SimpleElement::polygonOperate(QJsonArray points) void SimpleElement::polygonOperate(QJsonArray points)
{ {
@ -37,9 +40,10 @@ void SimpleElement::roundOperate(QJsonObject json)
{ {
double xAxis = json.value("x-axis").toDouble(); double xAxis = json.value("x-axis").toDouble();
double yAxis = json.value("y-axis").toDouble(); double yAxis = json.value("y-axis").toDouble();
double origin = json.value("origin").toDouble();
double angle = json.value("angle").toDouble(); double angle = json.value("angle").toDouble();
painterPath.arcMoveTo(xAxis * -0.5, yAxis * -0.5, xAxis, yAxis, 0); painterPath.arcMoveTo(xAxis * -0.5, yAxis * -0.5, xAxis, yAxis, origin);
painterPath.arcTo(xAxis * -0.5, yAxis * -0.5, xAxis, yAxis, 0, angle); painterPath.arcTo(xAxis * -0.5, yAxis * -0.5, xAxis, yAxis, origin, angle);
} }
SimpleElement::SimpleElement(QJsonObject jsonSource) : jsonSource(jsonSource) SimpleElement::SimpleElement(QJsonObject jsonSource) : jsonSource(jsonSource)
{ {

View File

@ -9,4 +9,5 @@ LayerManager::LayerManager(QJsonObject source, ElementManager *elementManager)
} }
void LayerManager::paint(QPainter *painter) const void LayerManager::paint(QPainter *painter) const
{ {
painter->drawPath(root->getCache());
} }

View File

@ -54,6 +54,7 @@ FolderLayerWrapper::FolderLayerWrapper(QJsonObject json, ElementManager *element
LeafLayerWrapper::LeafLayerWrapper(QJsonObject json, ElementManager *elementManager, LayerWrapper *parent) LeafLayerWrapper::LeafLayerWrapper(QJsonObject json, ElementManager *elementManager, LayerWrapper *parent)
: LayerWrapper(json, parent) : LayerWrapper(json, parent)
{ {
qDebug() << json.value("name").toString();
int elementIndex = json.value("element").toInt(); int elementIndex = json.value("element").toInt();
wrappedElement = elementManager->getElementById(elementIndex); wrappedElement = elementManager->getElementById(elementIndex);
} }
@ -66,12 +67,12 @@ void FolderLayerWrapper::refresh()
{ {
cache.clear(); cache.clear();
for (auto &child : children) for (auto &child : children)
cache += child.get()->getCache(); cache.addPath(child.get()->getCache());
} }
void LeafLayerWrapper::refresh() void LeafLayerWrapper::refresh()
{ {
cache.clear(); cache.clear();
if (wrappedElement != nullptr) if (wrappedElement != nullptr)
cache += wrappedElement->getPaintObject(); cache.addPath(wrappedElement->getPaintObject());
} }

View File

@ -1,16 +1,21 @@
#include "MainWindow.h" #include "MainWindow.h"
#include <QtWidgets/QApplication>
#include <QGuiApplication>
#include "Renderer/Painting/CubicBezier.h" #include "Renderer/Painting/CubicBezier.h"
#include <QGuiApplication>
#include <QtWidgets/QApplication>
using Renderer::CubicBezier; using Renderer::CubicBezier;
extern "C" { extern "C"
{
_declspec(dllexport) unsigned long NvOptimusEnablement = 0x00000001; _declspec(dllexport) unsigned long NvOptimusEnablement = 0x00000001;
} }
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
return 0; QApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
QApplication a(argc, argv);
MainWindow w;
w.show();
return a.exec();
} }

View File

@ -92,24 +92,24 @@
"data": { "data": {
"points": [ "points": [
{ {
"x": 10, "x": 0,
"y": 20 "y": 0
}, },
{ {
"x": 10, "x": 100,
"y": 20 "y": 200
}, },
{ {
"x": 10, "x": 300,
"y": 20 "y": 400
}, },
{ {
"x": 10, "x": 500,
"y": 20 "y": 600
}, },
{ {
"x": 10, "x": 0,
"y": 20 "y": 0
} }
] ]
} }
@ -117,8 +117,10 @@
{ {
"type": "round", "type": "round",
"data": { "data": {
"x-axis": 30, "x-axis": 300,
"y-axis": 40 "y-axis": 400,
"origin": 270,
"angle": 30
} }
}, },
{ {
@ -295,7 +297,7 @@
], ],
"effects": [], "effects": [],
"is-folder": false, "is-folder": false,
"element": 3 "element": 2
} }
] ]
} }