Compare commits
2 Commits
39602e091d
...
d4e52d4ab8
Author | SHA1 | Date |
---|---|---|
白封羽 | d4e52d4ab8 | |
白封羽 | 5b5465103a |
|
@ -4,6 +4,7 @@ EditorWidget::EditorWidget(QWidget *parent) : QWidget(parent)
|
|||
{
|
||||
ui.setupUi(this);
|
||||
previewWindow = ui.Preview;
|
||||
qDebug() << "123";
|
||||
// test
|
||||
QFile settingFile;
|
||||
settingFile.setFileName("../data.json");
|
||||
|
|
|
@ -21,8 +21,11 @@ QPainterPath SimpleElement::getPaintObject() const
|
|||
{
|
||||
return painterPath;
|
||||
}
|
||||
// TODO
|
||||
void SimpleElement::pathOperate(QJsonArray paths)
|
||||
{
|
||||
QRect r(100, 100, 100, 100);
|
||||
painterPath.addRect(r);
|
||||
}
|
||||
void SimpleElement::polygonOperate(QJsonArray points)
|
||||
{
|
||||
|
@ -37,9 +40,10 @@ void SimpleElement::roundOperate(QJsonObject json)
|
|||
{
|
||||
double xAxis = json.value("x-axis").toDouble();
|
||||
double yAxis = json.value("y-axis").toDouble();
|
||||
double origin = json.value("origin").toDouble();
|
||||
double angle = json.value("angle").toDouble();
|
||||
painterPath.arcMoveTo(xAxis * -0.5, yAxis * -0.5, xAxis, yAxis, 0);
|
||||
painterPath.arcTo(xAxis * -0.5, yAxis * -0.5, xAxis, yAxis, 0, angle);
|
||||
painterPath.arcMoveTo(xAxis * -0.5, yAxis * -0.5, xAxis, yAxis, origin);
|
||||
painterPath.arcTo(xAxis * -0.5, yAxis * -0.5, xAxis, yAxis, origin, angle);
|
||||
}
|
||||
SimpleElement::SimpleElement(QJsonObject jsonSource) : jsonSource(jsonSource)
|
||||
{
|
||||
|
|
|
@ -9,4 +9,5 @@ LayerManager::LayerManager(QJsonObject source, ElementManager *elementManager)
|
|||
}
|
||||
void LayerManager::paint(QPainter *painter) const
|
||||
{
|
||||
painter->drawPath(root->getCache());
|
||||
}
|
||||
|
|
|
@ -18,8 +18,9 @@ void FolderLayerWrapper::removeChild(LayerWrapper *child)
|
|||
}
|
||||
}
|
||||
|
||||
QPainterPath LayerWrapper::getCache() const
|
||||
QPainterPath LayerWrapper::getCache()
|
||||
{
|
||||
this->refresh();
|
||||
return cache;
|
||||
}
|
||||
// TODO: undone
|
||||
|
@ -49,7 +50,7 @@ FolderLayerWrapper::FolderLayerWrapper(QJsonObject json, ElementManager *element
|
|||
shared_ptr<LayerWrapper>(new LeafLayerWrapper(childJson.toObject(), elementManager, this)));
|
||||
}
|
||||
}
|
||||
#include <iostream>
|
||||
|
||||
LeafLayerWrapper::LeafLayerWrapper(QJsonObject json, ElementManager *elementManager, LayerWrapper *parent)
|
||||
: LayerWrapper(json, parent)
|
||||
{
|
||||
|
@ -57,3 +58,21 @@ LeafLayerWrapper::LeafLayerWrapper(QJsonObject json, ElementManager *elementMana
|
|||
int elementIndex = json.value("element").toInt();
|
||||
wrappedElement = elementManager->getElementById(elementIndex);
|
||||
}
|
||||
|
||||
void LayerWrapper::refresh()
|
||||
{
|
||||
}
|
||||
|
||||
void FolderLayerWrapper::refresh()
|
||||
{
|
||||
cache.clear();
|
||||
for (auto &child : children)
|
||||
cache.addPath(child.get()->getCache());
|
||||
}
|
||||
|
||||
void LeafLayerWrapper::refresh()
|
||||
{
|
||||
cache.clear();
|
||||
if (wrappedElement != nullptr)
|
||||
cache.addPath(wrappedElement->getPaintObject());
|
||||
}
|
||||
|
|
|
@ -26,7 +26,8 @@ class LayerWrapper
|
|||
QPainterPath cache;
|
||||
|
||||
public:
|
||||
QPainterPath getCache() const; // invoke by manager, then invoke parent's applyStyles
|
||||
virtual void refresh();
|
||||
QPainterPath getCache(); // invoke by manager, then invoke parent's applyStyles
|
||||
LayerWrapper(QJsonObject json, LayerWrapper *parent);
|
||||
LayerWrapper() = default;
|
||||
};
|
||||
|
@ -37,6 +38,7 @@ class FolderLayerWrapper : public LayerWrapper
|
|||
vector<shared_ptr<LayerWrapper>> children;
|
||||
|
||||
public:
|
||||
void refresh() override;
|
||||
FolderLayerWrapper() = default;
|
||||
FolderLayerWrapper(QJsonObject json, ElementManager *elementManager, LayerWrapper *parent);
|
||||
void addChild(LayerWrapper *child);
|
||||
|
@ -49,6 +51,7 @@ class LeafLayerWrapper : public LayerWrapper
|
|||
GraphicElement *wrappedElement;
|
||||
|
||||
public:
|
||||
void refresh() override;
|
||||
LeafLayerWrapper() = default;
|
||||
LeafLayerWrapper(QJsonObject json, ElementManager *elementManager, LayerWrapper *parent);
|
||||
};
|
||||
|
|
|
@ -1,16 +1,21 @@
|
|||
#include "MainWindow.h"
|
||||
#include <QtWidgets/QApplication>
|
||||
#include <QGuiApplication>
|
||||
#include "Renderer/Painting/CubicBezier.h"
|
||||
#include <QGuiApplication>
|
||||
#include <QtWidgets/QApplication>
|
||||
|
||||
using Renderer::CubicBezier;
|
||||
|
||||
extern "C" {
|
||||
extern "C"
|
||||
{
|
||||
_declspec(dllexport) unsigned long NvOptimusEnablement = 0x00000001;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
|
||||
return 0;
|
||||
QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
||||
QApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
|
||||
QApplication a(argc, argv);
|
||||
MainWindow w;
|
||||
w.show();
|
||||
return a.exec();
|
||||
}
|
||||
|
|
28
data.json
28
data.json
|
@ -92,24 +92,24 @@
|
|||
"data": {
|
||||
"points": [
|
||||
{
|
||||
"x": 10,
|
||||
"y": 20
|
||||
"x": 0,
|
||||
"y": 0
|
||||
},
|
||||
{
|
||||
"x": 10,
|
||||
"y": 20
|
||||
"x": 100,
|
||||
"y": 200
|
||||
},
|
||||
{
|
||||
"x": 10,
|
||||
"y": 20
|
||||
"x": 300,
|
||||
"y": 400
|
||||
},
|
||||
{
|
||||
"x": 10,
|
||||
"y": 20
|
||||
"x": 500,
|
||||
"y": 600
|
||||
},
|
||||
{
|
||||
"x": 10,
|
||||
"y": 20
|
||||
"x": 0,
|
||||
"y": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -117,8 +117,10 @@
|
|||
{
|
||||
"type": "round",
|
||||
"data": {
|
||||
"x-axis": 30,
|
||||
"y-axis": 40
|
||||
"x-axis": 300,
|
||||
"y-axis": 400,
|
||||
"origin": 270,
|
||||
"angle": 30
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -295,7 +297,7 @@
|
|||
],
|
||||
"effects": [],
|
||||
"is-folder": false,
|
||||
"element": 3
|
||||
"element": 2
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue