diff --git a/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj b/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj index 493a418..775940a 100644 --- a/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj +++ b/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj @@ -137,6 +137,7 @@ + diff --git a/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj.filters b/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj.filters index 4bbf375..9bc98d8 100644 --- a/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj.filters +++ b/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj.filters @@ -232,6 +232,7 @@ Resource Files + diff --git a/ArchitectureColoredPainting/src/Editor/EditorWidget.cpp b/ArchitectureColoredPainting/src/Editor/EditorWidget.cpp index 60be82e..6d836ca 100644 --- a/ArchitectureColoredPainting/src/Editor/EditorWidget.cpp +++ b/ArchitectureColoredPainting/src/Editor/EditorWidget.cpp @@ -4,7 +4,17 @@ EditorWidget::EditorWidget(QWidget *parent) : QWidget(parent) { ui.setupUi(this); previewWindow = ui.Preview; - QJsonObject source; + // test + QFile settingFile; + settingFile.setFileName("../data.json"); + settingFile.open(QFile::ReadOnly); + QByteArray setting = settingFile.readAll().trimmed(); + QJsonParseError jError; + QJsonDocument jsonDoc(QJsonDocument::fromJson(setting,&jError)); + qDebug() << jsonDoc.object().value("height").toDouble(); + qDebug() << jError.errorString(); + // end test + QJsonObject source=jsonDoc.object(); elementManager = new ElementManager(source); layerManager = new LayerManager(source, elementManager); previewWindow->initialize(layerManager); diff --git a/ArchitectureColoredPainting/src/Editor/ElementManager.cpp b/ArchitectureColoredPainting/src/Editor/ElementManager.cpp index aeaaa1a..ef5cfdc 100644 --- a/ArchitectureColoredPainting/src/Editor/ElementManager.cpp +++ b/ArchitectureColoredPainting/src/Editor/ElementManager.cpp @@ -2,6 +2,7 @@ ElementManager::ElementManager(QJsonObject source) { auto elementsJson = source.value("elements").toArray(); + qDebug() << elementsJson.size(); for (auto elementJson : elementsJson) { if (elementJson.toObject().value("type") == "group") diff --git a/ArchitectureColoredPainting/src/Editor/LayerWrapper.cpp b/ArchitectureColoredPainting/src/Editor/LayerWrapper.cpp index 631f8cd..5d60a59 100644 --- a/ArchitectureColoredPainting/src/Editor/LayerWrapper.cpp +++ b/ArchitectureColoredPainting/src/Editor/LayerWrapper.cpp @@ -30,6 +30,7 @@ LayerWrapper::LayerWrapper(QJsonObject json, LayerWrapper *parent) FolderLayerWrapper::FolderLayerWrapper(QJsonObject json, ElementManager *elementManager, LayerWrapper *parent) : LayerWrapper(json, parent) { + qDebug() << json.value("name").toString(); QJsonArray childrenJson = json.value("children").toArray(); QJsonValue referencedJson = json.value("referenced-by"); if (!referencedJson.isNull()) @@ -52,6 +53,7 @@ FolderLayerWrapper::FolderLayerWrapper(QJsonObject json, ElementManager *element LeafLayerWrapper::LeafLayerWrapper(QJsonObject json, ElementManager *elementManager, LayerWrapper *parent) : LayerWrapper(json, parent) { + qDebug() << json.value("name").toString(); int elementIndex = json.value("element").toInt(); wrappedElement = elementManager->getElementById(elementIndex); } diff --git a/ArchitectureColoredPainting/src/Editor/data.json b/ArchitectureColoredPainting/src/Editor/data.json deleted file mode 100644 index e9053a7..0000000 --- a/ArchitectureColoredPainting/src/Editor/data.json +++ /dev/null @@ -1,26 +0,0 @@ -{ -"elements":[ - { - "type":"polygon", - "data":{ - "points":[{"x":20,"y":30},{"x":20,"y":50},{"x":50,"y":100},{"x":20,"y":30}] - } - }, - { - "type":"polygon", - "data":{ - "points":[{"x":100,"y":100},{"x":100,"y":500},{"x":500,"y":500},{"x":100,"y":100}] - } - }, - { - "type":"round", - "data":{ - "x-axis":500, - "y-axis":500, - "angle":360 - } - } -] - - -} \ No newline at end of file diff --git a/data.json b/data.json index e9053a7..9f33a0f 100644 --- a/data.json +++ b/data.json @@ -1,26 +1,302 @@ { -"elements":[ - { - "type":"polygon", - "data":{ - "points":[{"x":20,"y":30},{"x":20,"y":50},{"x":50,"y":100},{"x":20,"y":30}] - } - }, - { - "type":"polygon", - "data":{ - "points":[{"x":100,"y":100},{"x":100,"y":500},{"x":500,"y":500},{"x":100,"y":100}] - } - }, - { - "type":"round", - "data":{ - "x-axis":500, - "y-axis":500, - "angle":360 + "height": 1080, + "width": 1080, + "elements": [ + { + "type": "path", + "data": { + "operations": [ + { + "type": "line", + "data": { + "target": { + "x": 15, + "y": 20 + } + } + }, + { + "type": "cubic", + "data": { + "target": { + "x": 18, + "y": 21 + }, + "control": { + "start": { + "x": 17, + "y": 22 + }, + "end": { + "x": 20, + "y": 23 + } + } + } + }, + { + "type": "cubic-smooth", + "data": { + "target": { + "x": 18, + "y": 21 + }, + "control": { + "x": 18, + "y": 21 + } + } + }, + { + "type": "quadratic", + "data": { + "target": { + "x": 18, + "y": 21 + }, + "control": { + "x": 18, + "y": 21 + } + } + }, + { + "type": "quadratic-smooth", + "data": { + "target": { + "x": 18, + "y": 21 + } + } + }, + { + "type": "arc", + "data": { + "center": { + "x": 18, + "y": 21 + }, + "x-axis": 40, + "y-axis": 50, + "angle": 60 + } + }, + { + "type": "zeal" + } + ] + } + }, + { + "type": "polygon", + "data": { + "points": [ + { + "x": 10, + "y": 20 + }, + { + "x": 10, + "y": 20 + }, + { + "x": 10, + "y": 20 + }, + { + "x": 10, + "y": 20 + }, + { + "x": 10, + "y": 20 + } + ] + } + }, + { + "type": "round", + "data": { + "x-axis": 30, + "y-axis": 40 + } + }, + { + "type": "group", + "data": { + "reference-layer": "0.0" + } } + ], + "root-layer": { + "name": "root", + "offset": { + "x": 0, + "y": 0 + }, + "transformation": [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "effects": [], + "is-folder": true, + "referenced-by": null, + "children": [ + { + "name": "GroupFolderExample", + "offset": { + "x": 5, + "y": 10 + }, + "transformation": [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "effects": [ + { + "type": "iterate", + "data": { + "time": 5, + "operations": [ + { + "type": "move", + "data": { + "offset": { + "x": 5, + "y": 6 + } + } + }, + { + "type": "rotate", + "data": { + "center-offset": { + "x": 0, + "y": 0 + }, + "angle": 60 + } + }, + { + "type": "zoom", + "data": { + "zoom": 1.5 + } + }, + { + "type": "flip", + "data": { + "k": 1.2, + "b": 3 + } + } + ] + } + } + ], + "is-folder": true, + "referenced-by": 3, + "children": [ + { + "name": "GroupedLayer1", + "offset": { + "x": 10, + "y": 20 + }, + "transformation": [ + 5, + 0, + 0, + 0, + 6, + 0, + 0, + 0, + 0 + ], + "effects": [], + "is-folder": false, + "element": 0 + }, + { + "name": "GroupedLayer2", + "offset": { + "x": 15, + "y": 25 + }, + "transformation": [ + 5, + 0, + 0, + 0, + 6, + 0, + 0, + 0, + 0 + ], + "effects": [], + "is-folder": false, + "element": 1 + } + ] + }, + { + "name": "ReferencingGroupLayer", + "offset": { + "x": 10, + "y": 20 + }, + "transformation": [ + 5, + 0, + 0, + 0, + 6, + 0, + 0, + 0, + 0 + ], + "effects": [], + "is-folder": false, + "element": 3 + }, + { + "name": "Layer1", + "offset": { + "x": 10, + "y": 20 + }, + "transformation": [ + 5, + 0, + 0, + 0, + 6, + 0, + 0, + 0, + 0 + ], + "effects": [], + "is-folder": false, + "element": 3 + } + ] } -] - - } \ No newline at end of file