Compare commits
No commits in common. "d4e52d4ab8a9147301a4f997b9c80e05531b5415" and "39602e091d66e08f348629c26a9b2608ea128d2b" have entirely different histories.
d4e52d4ab8
...
39602e091d
|
@ -4,18 +4,17 @@ EditorWidget::EditorWidget(QWidget *parent) : QWidget(parent)
|
||||||
{
|
{
|
||||||
ui.setupUi(this);
|
ui.setupUi(this);
|
||||||
previewWindow = ui.Preview;
|
previewWindow = ui.Preview;
|
||||||
qDebug() << "123";
|
|
||||||
// test
|
// test
|
||||||
QFile settingFile;
|
QFile settingFile;
|
||||||
settingFile.setFileName("../data.json");
|
settingFile.setFileName("../data.json");
|
||||||
settingFile.open(QFile::ReadOnly);
|
settingFile.open(QFile::ReadOnly);
|
||||||
QByteArray setting = settingFile.readAll().trimmed();
|
QByteArray setting = settingFile.readAll().trimmed();
|
||||||
QJsonParseError jError;
|
QJsonParseError jError;
|
||||||
QJsonDocument jsonDoc(QJsonDocument::fromJson(setting, &jError));
|
QJsonDocument jsonDoc(QJsonDocument::fromJson(setting,&jError));
|
||||||
qDebug() << jsonDoc.object().value("height").toDouble();
|
qDebug() << jsonDoc.object().value("height").toDouble();
|
||||||
qDebug() << jError.errorString();
|
qDebug() << jError.errorString();
|
||||||
// end test
|
// end test
|
||||||
QJsonObject source = jsonDoc.object();
|
QJsonObject source=jsonDoc.object();
|
||||||
elementManager = new ElementManager(source);
|
elementManager = new ElementManager(source);
|
||||||
layerManager = new LayerManager(source, elementManager);
|
layerManager = new LayerManager(source, elementManager);
|
||||||
previewWindow->initialize(layerManager);
|
previewWindow->initialize(layerManager);
|
||||||
|
|
|
@ -21,11 +21,8 @@ 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)
|
||||||
{
|
{
|
||||||
|
@ -40,10 +37,9 @@ 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, origin);
|
painterPath.arcMoveTo(xAxis * -0.5, yAxis * -0.5, xAxis, yAxis, 0);
|
||||||
painterPath.arcTo(xAxis * -0.5, yAxis * -0.5, xAxis, yAxis, origin, angle);
|
painterPath.arcTo(xAxis * -0.5, yAxis * -0.5, xAxis, yAxis, 0, angle);
|
||||||
}
|
}
|
||||||
SimpleElement::SimpleElement(QJsonObject jsonSource) : jsonSource(jsonSource)
|
SimpleElement::SimpleElement(QJsonObject jsonSource) : jsonSource(jsonSource)
|
||||||
{
|
{
|
||||||
|
|
|
@ -9,5 +9,4 @@ LayerManager::LayerManager(QJsonObject source, ElementManager *elementManager)
|
||||||
}
|
}
|
||||||
void LayerManager::paint(QPainter *painter) const
|
void LayerManager::paint(QPainter *painter) const
|
||||||
{
|
{
|
||||||
painter->drawPath(root->getCache());
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,9 +18,8 @@ void FolderLayerWrapper::removeChild(LayerWrapper *child)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QPainterPath LayerWrapper::getCache()
|
QPainterPath LayerWrapper::getCache() const
|
||||||
{
|
{
|
||||||
this->refresh();
|
|
||||||
return cache;
|
return cache;
|
||||||
}
|
}
|
||||||
// TODO: undone
|
// TODO: undone
|
||||||
|
@ -50,7 +49,7 @@ FolderLayerWrapper::FolderLayerWrapper(QJsonObject json, ElementManager *element
|
||||||
shared_ptr<LayerWrapper>(new LeafLayerWrapper(childJson.toObject(), elementManager, this)));
|
shared_ptr<LayerWrapper>(new LeafLayerWrapper(childJson.toObject(), elementManager, this)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#include <iostream>
|
||||||
LeafLayerWrapper::LeafLayerWrapper(QJsonObject json, ElementManager *elementManager, LayerWrapper *parent)
|
LeafLayerWrapper::LeafLayerWrapper(QJsonObject json, ElementManager *elementManager, LayerWrapper *parent)
|
||||||
: LayerWrapper(json, parent)
|
: LayerWrapper(json, parent)
|
||||||
{
|
{
|
||||||
|
@ -58,21 +57,3 @@ LeafLayerWrapper::LeafLayerWrapper(QJsonObject json, ElementManager *elementMana
|
||||||
int elementIndex = json.value("element").toInt();
|
int elementIndex = json.value("element").toInt();
|
||||||
wrappedElement = elementManager->getElementById(elementIndex);
|
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,8 +26,7 @@ class LayerWrapper
|
||||||
QPainterPath cache;
|
QPainterPath cache;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual void refresh();
|
QPainterPath getCache() const; // invoke by manager, then invoke parent's applyStyles
|
||||||
QPainterPath getCache(); // invoke by manager, then invoke parent's applyStyles
|
|
||||||
LayerWrapper(QJsonObject json, LayerWrapper *parent);
|
LayerWrapper(QJsonObject json, LayerWrapper *parent);
|
||||||
LayerWrapper() = default;
|
LayerWrapper() = default;
|
||||||
};
|
};
|
||||||
|
@ -38,7 +37,6 @@ class FolderLayerWrapper : public LayerWrapper
|
||||||
vector<shared_ptr<LayerWrapper>> children;
|
vector<shared_ptr<LayerWrapper>> children;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void refresh() override;
|
|
||||||
FolderLayerWrapper() = default;
|
FolderLayerWrapper() = default;
|
||||||
FolderLayerWrapper(QJsonObject json, ElementManager *elementManager, LayerWrapper *parent);
|
FolderLayerWrapper(QJsonObject json, ElementManager *elementManager, LayerWrapper *parent);
|
||||||
void addChild(LayerWrapper *child);
|
void addChild(LayerWrapper *child);
|
||||||
|
@ -51,7 +49,6 @@ class LeafLayerWrapper : public LayerWrapper
|
||||||
GraphicElement *wrappedElement;
|
GraphicElement *wrappedElement;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void refresh() override;
|
|
||||||
LeafLayerWrapper() = default;
|
LeafLayerWrapper() = default;
|
||||||
LeafLayerWrapper(QJsonObject json, ElementManager *elementManager, LayerWrapper *parent);
|
LeafLayerWrapper(QJsonObject json, ElementManager *elementManager, LayerWrapper *parent);
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,21 +1,16 @@
|
||||||
#include "MainWindow.h"
|
#include "MainWindow.h"
|
||||||
#include "Renderer/Painting/CubicBezier.h"
|
|
||||||
#include <QGuiApplication>
|
|
||||||
#include <QtWidgets/QApplication>
|
#include <QtWidgets/QApplication>
|
||||||
|
#include <QGuiApplication>
|
||||||
|
#include "Renderer/Painting/CubicBezier.h"
|
||||||
|
|
||||||
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);
|
|
||||||
QApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
|
return 0;
|
||||||
QApplication a(argc, argv);
|
|
||||||
MainWindow w;
|
|
||||||
w.show();
|
|
||||||
return a.exec();
|
|
||||||
}
|
}
|
||||||
|
|
28
data.json
28
data.json
|
@ -92,24 +92,24 @@
|
||||||
"data": {
|
"data": {
|
||||||
"points": [
|
"points": [
|
||||||
{
|
{
|
||||||
"x": 0,
|
"x": 10,
|
||||||
"y": 0
|
"y": 20
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"x": 100,
|
"x": 10,
|
||||||
"y": 200
|
"y": 20
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"x": 300,
|
"x": 10,
|
||||||
"y": 400
|
"y": 20
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"x": 500,
|
"x": 10,
|
||||||
"y": 600
|
"y": 20
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"x": 0,
|
"x": 10,
|
||||||
"y": 0
|
"y": 20
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -117,10 +117,8 @@
|
||||||
{
|
{
|
||||||
"type": "round",
|
"type": "round",
|
||||||
"data": {
|
"data": {
|
||||||
"x-axis": 300,
|
"x-axis": 30,
|
||||||
"y-axis": 400,
|
"y-axis": 40
|
||||||
"origin": 270,
|
|
||||||
"angle": 30
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -297,7 +295,7 @@
|
||||||
],
|
],
|
||||||
"effects": [],
|
"effects": [],
|
||||||
"is-folder": false,
|
"is-folder": false,
|
||||||
"element": 2
|
"element": 3
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue