diff --git a/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj b/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj
index 4f5655d..91c9f62 100644
--- a/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj
+++ b/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj
@@ -197,6 +197,7 @@
+
diff --git a/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj.filters b/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj.filters
index 90248ca..71f1e04 100644
--- a/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj.filters
+++ b/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj.filters
@@ -477,6 +477,9 @@
Header Files\Editor\Style
+
+ Header Files\Editor\util
+
diff --git a/ArchitectureColoredPainting/src/Editor/LayerStyle.cpp b/ArchitectureColoredPainting/src/Editor/LayerStyle.cpp
index 588ae94..9b65355 100644
--- a/ArchitectureColoredPainting/src/Editor/LayerStyle.cpp
+++ b/ArchitectureColoredPainting/src/Editor/LayerStyle.cpp
@@ -1,5 +1,6 @@
#include "LayerStyle.h"
#include "./EditorWidgetComponent/StrokeStyleWidget.h"
+#include "./util/JsonUtil.hpp"
#include
#include
#include
@@ -118,6 +119,16 @@ StrokeElementLayerStyle::StrokeElementLayerStyle(const StrokeElementLayerStyle&
enableEachSideIndependent = other.enableEachSideIndependent;
}
+QJsonObject StrokeElementLayerStyle::toJson() const
+{
+ QJsonObject json;
+ json.insert("type", "stroke");
+ json.insert("enableEachSideIndependent", enableEachSideIndependent);
+ json.insert("left", JsonUtil::toQJsonArray(strokePair.first->encoded()));
+ json.insert("right", JsonUtil::toQJsonArray(strokePair.second->encoded()));
+ return json;
+}
+
std::unique_ptr StrokeElementLayerStyle::clone() const
{
return std::make_unique(StrokeElementLayerStyle(*this));
@@ -161,7 +172,17 @@ FillElementLayerStyle::FillElementLayerStyle(const FillElementLayerStyle& other)
}
}
+QJsonObject FillElementLayerStyle::toJson() const
+{
+ return QJsonObject();
+}
+
std::unique_ptr FillElementLayerStyle::clone() const
{
return std::make_unique(FillElementLayerStyle(*this));
}
+
+std::unique_ptr LayerStyle::fromJson(const QJsonObject& json)
+{
+ return std::unique_ptr();
+}
diff --git a/ArchitectureColoredPainting/src/Editor/LayerStyle.h b/ArchitectureColoredPainting/src/Editor/LayerStyle.h
index 7d5fb25..6717299 100644
--- a/ArchitectureColoredPainting/src/Editor/LayerStyle.h
+++ b/ArchitectureColoredPainting/src/Editor/LayerStyle.h
@@ -5,6 +5,7 @@
#include
#include
#include
+#include
#include "../Renderer/Painting/ElementStyle.h"
#include "../Renderer/Painting/MaterialStyleStroke.h"
#include "../Renderer/Painting/MaterialStyleFill.h"
@@ -23,10 +24,13 @@ class LayerStyle : public Renderer::ElementStyle
{
public:
const static std::vector()>>> types;
+ static std::unique_ptr fromJson(const QJsonObject& json);
+
virtual QString getStyleName() const = 0;
virtual QWidget* getInputWidget() = 0;
virtual QWidget* getListDisplayWidget() const = 0;
virtual ~LayerStyle() {};
+ virtual QJsonObject toJson() const = 0;
virtual std::unique_ptr clone() const = 0;
};
@@ -43,6 +47,7 @@ public:
StrokeElementLayerStyle() = default;
StrokeElementLayerStyle(const StrokeElementLayerStyle& other);
~StrokeElementLayerStyle() = default;
+ QJsonObject toJson() const override;
std::unique_ptr clone() const override;
bool enableEachSideIndependent = false;
@@ -59,5 +64,6 @@ public:
FillElementLayerStyle(const FillElementLayerStyle& other);
~FillElementLayerStyle() = default;
std::vector> materialStyles;
+ QJsonObject toJson() const override;
std::unique_ptr clone() const override;
};
\ No newline at end of file
diff --git a/ArchitectureColoredPainting/src/Editor/LayerWrapper.cpp b/ArchitectureColoredPainting/src/Editor/LayerWrapper.cpp
index d5f28e7..960b547 100644
--- a/ArchitectureColoredPainting/src/Editor/LayerWrapper.cpp
+++ b/ArchitectureColoredPainting/src/Editor/LayerWrapper.cpp
@@ -240,6 +240,10 @@ QJsonObject LeafLayerWrapper::toJson() const
QJsonObject json = LayerWrapper::toJson();
json.insert("element", wrappedElement->index);
json.insert("is-folder", false);
+ QJsonArray stylesJson;
+ for (auto& style : styles)
+ stylesJson.push_back(style->toJson());
+ json.insert("styles", stylesJson);
return json;
}
diff --git a/ArchitectureColoredPainting/src/Editor/LayerWrapper.h b/ArchitectureColoredPainting/src/Editor/LayerWrapper.h
index 7df5d13..f753dcb 100644
--- a/ArchitectureColoredPainting/src/Editor/LayerWrapper.h
+++ b/ArchitectureColoredPainting/src/Editor/LayerWrapper.h
@@ -6,6 +6,7 @@
#include
#include
#include
+#include
#include
#include
#include