完善Element序列化
parent
3b87644e21
commit
fa91d80b70
|
@ -23,6 +23,7 @@ void SimpleElement::loadSvgFile(const QString& filePath)
|
||||||
SimpleElement::SimpleElement(QJsonObject jsonSource) : jsonSource(jsonSource)
|
SimpleElement::SimpleElement(QJsonObject jsonSource) : jsonSource(jsonSource)
|
||||||
{
|
{
|
||||||
painterPath.clear();
|
painterPath.clear();
|
||||||
|
filePath = jsonSource["data"].toObject()["include"].toString();
|
||||||
//loadSvgFile("D:\\Projects\\BigC\\svg\\3.svg");
|
//loadSvgFile("D:\\Projects\\BigC\\svg\\3.svg");
|
||||||
loadSvgFile("../"/*TODO: 改成json文件所在文件夹路径*/ + jsonSource.value("data").toObject().value("include").toString());
|
loadSvgFile("../"/*TODO: 改成json文件所在文件夹路径*/ + jsonSource.value("data").toObject().value("include").toString());
|
||||||
}
|
}
|
||||||
|
@ -95,10 +96,25 @@ PixelPath GroupElement::getPaintObject(std::vector<std::shared_ptr<LayerStyle>>*
|
||||||
// }
|
// }
|
||||||
//}
|
//}
|
||||||
//TODO : 添加细节
|
//TODO : 添加细节
|
||||||
QJsonObject GraphicElement::toJson() const
|
QJsonObject SimpleElement::toJson() const
|
||||||
{
|
{
|
||||||
QJsonObject result;
|
QJsonObject result;
|
||||||
result.insert("name", name);
|
QJsonObject data;
|
||||||
|
data["include"] = filePath;
|
||||||
|
result["type"] = "svg-file";
|
||||||
|
result["data"] = data;
|
||||||
|
result["name"] = name;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
QJsonObject GroupElement::toJson() const
|
||||||
|
{
|
||||||
|
QJsonObject result;
|
||||||
|
QJsonObject data;
|
||||||
|
data["reference-layer"] = "0.0";
|
||||||
|
result["type"] = "group";
|
||||||
|
result["data"] = data;
|
||||||
|
result["name"] = name;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ public:
|
||||||
QString name = "";
|
QString name = "";
|
||||||
int index;
|
int index;
|
||||||
// TODO: ¸ÄΪBitmapPath
|
// TODO: ¸ÄΪBitmapPath
|
||||||
virtual QJsonObject toJson() const;
|
virtual QJsonObject toJson() const = 0;
|
||||||
virtual PixelPath getPaintObject() const = 0;
|
virtual PixelPath getPaintObject() const = 0;
|
||||||
virtual PixelPath getPaintObject(std::vector<std::shared_ptr<LayerStyle>>*) const = 0;
|
virtual PixelPath getPaintObject(std::vector<std::shared_ptr<LayerStyle>>*) const = 0;
|
||||||
virtual void paint(QPainter* painter, QTransform transform, const std::vector<std::shared_ptr<LayerStyle>> &styles) = 0;
|
virtual void paint(QPainter* painter, QTransform transform, const std::vector<std::shared_ptr<LayerStyle>> &styles) = 0;
|
||||||
|
@ -37,9 +37,11 @@ public:
|
||||||
QJsonObject jsonSource;
|
QJsonObject jsonSource;
|
||||||
// TODO: ¸ÄΪComposedPainterPath
|
// TODO: ¸ÄΪComposedPainterPath
|
||||||
QPainterPath painterPath;
|
QPainterPath painterPath;
|
||||||
|
QString filePath;
|
||||||
void loadSvgFile(const QString& filePath);
|
void loadSvgFile(const QString& filePath);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
QJsonObject toJson() const override;
|
||||||
SimpleElement(QJsonObject jsonSource);
|
SimpleElement(QJsonObject jsonSource);
|
||||||
SimpleElement(QString filePath);
|
SimpleElement(QString filePath);
|
||||||
~SimpleElement() = default;
|
~SimpleElement() = default;
|
||||||
|
@ -54,6 +56,7 @@ public:
|
||||||
FolderLayerWrapper* sourceLayer;
|
FolderLayerWrapper* sourceLayer;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
QJsonObject toJson() const override;
|
||||||
GroupElement() = default;
|
GroupElement() = default;
|
||||||
GroupElement(FolderLayerWrapper* mSourceLayer);
|
GroupElement(FolderLayerWrapper* mSourceLayer);
|
||||||
~GroupElement() = default;
|
~GroupElement() = default;
|
||||||
|
|
Loading…
Reference in New Issue