Merge branch 'main' of http://101.34.228.45:3000/BigC/ArchitectureColoredPainting
commit
e39eb15f03
|
@ -0,0 +1,424 @@
|
||||||
|
{
|
||||||
|
"background-color": "#b7a386",
|
||||||
|
"elements": [
|
||||||
|
{
|
||||||
|
"data": {
|
||||||
|
"include": "../svg/2.svg"
|
||||||
|
},
|
||||||
|
"name": "ababa",
|
||||||
|
"type": "svg-file"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"data": {
|
||||||
|
"reference-layer": "0.0"
|
||||||
|
},
|
||||||
|
"name": "ababa-group",
|
||||||
|
"type": "group"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"data": {
|
||||||
|
"include": "../svg/0.svg"
|
||||||
|
},
|
||||||
|
"name": "ababa2",
|
||||||
|
"type": "svg-file"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"data": {
|
||||||
|
"include": "D:/BigC2022/temp/ArchitectureColoredPainting/svg/4_L0-fill.svg"
|
||||||
|
},
|
||||||
|
"name": "4_L0-fill.svg",
|
||||||
|
"type": "svg-file"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"height": 1080,
|
||||||
|
"project-name": "样例1",
|
||||||
|
"root-layer": {
|
||||||
|
"children": [
|
||||||
|
{
|
||||||
|
"children": [
|
||||||
|
{
|
||||||
|
"element": 3,
|
||||||
|
"is-folder": false,
|
||||||
|
"name": "4_L0",
|
||||||
|
"styles": [
|
||||||
|
{
|
||||||
|
"material": "AH8A/2pkiv8=",
|
||||||
|
"type": "fill"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"enableEachSideIndependent": true,
|
||||||
|
"left": "AADAQAEAJJwAf///9dKG/w==",
|
||||||
|
"right": "AADgQAAACpw=",
|
||||||
|
"type": "stroke"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"transform": {
|
||||||
|
"offset": {
|
||||||
|
"x": -230,
|
||||||
|
"y": -533
|
||||||
|
},
|
||||||
|
"rotation": 0,
|
||||||
|
"scale": {
|
||||||
|
"x": 0.32341007644113307,
|
||||||
|
"y": 0.32341007644113307
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"is-folder": true,
|
||||||
|
"name": "GroupFolderExample",
|
||||||
|
"referenced-by": 1,
|
||||||
|
"transform": {
|
||||||
|
"offset": {
|
||||||
|
"x": 50,
|
||||||
|
"y": 50
|
||||||
|
},
|
||||||
|
"rotation": 0,
|
||||||
|
"scale": {
|
||||||
|
"x": 1,
|
||||||
|
"y": 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"element": 1,
|
||||||
|
"is-folder": false,
|
||||||
|
"name": "aaaa2",
|
||||||
|
"styles": [
|
||||||
|
],
|
||||||
|
"transform": {
|
||||||
|
"offset": {
|
||||||
|
"x": 127,
|
||||||
|
"y": -109
|
||||||
|
},
|
||||||
|
"rotation": 90,
|
||||||
|
"scale": {
|
||||||
|
"x": 1,
|
||||||
|
"y": 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"element": 1,
|
||||||
|
"is-folder": false,
|
||||||
|
"name": "aaaa3",
|
||||||
|
"styles": [
|
||||||
|
],
|
||||||
|
"transform": {
|
||||||
|
"offset": {
|
||||||
|
"x": 232,
|
||||||
|
"y": 17
|
||||||
|
},
|
||||||
|
"rotation": 180,
|
||||||
|
"scale": {
|
||||||
|
"x": 1,
|
||||||
|
"y": 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"element": 1,
|
||||||
|
"is-folder": false,
|
||||||
|
"name": "aaaa4",
|
||||||
|
"styles": [
|
||||||
|
],
|
||||||
|
"transform": {
|
||||||
|
"offset": {
|
||||||
|
"x": 103,
|
||||||
|
"y": 130
|
||||||
|
},
|
||||||
|
"rotation": 270,
|
||||||
|
"scale": {
|
||||||
|
"x": 1,
|
||||||
|
"y": 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"element": 1,
|
||||||
|
"is-folder": false,
|
||||||
|
"name": "bbbb1",
|
||||||
|
"styles": [
|
||||||
|
],
|
||||||
|
"transform": {
|
||||||
|
"offset": {
|
||||||
|
"x": 197,
|
||||||
|
"y": 265
|
||||||
|
},
|
||||||
|
"rotation": 0,
|
||||||
|
"scale": {
|
||||||
|
"x": 1,
|
||||||
|
"y": 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"element": 1,
|
||||||
|
"is-folder": false,
|
||||||
|
"name": "bbbb2",
|
||||||
|
"styles": [
|
||||||
|
],
|
||||||
|
"transform": {
|
||||||
|
"offset": {
|
||||||
|
"x": 323,
|
||||||
|
"y": 156
|
||||||
|
},
|
||||||
|
"rotation": 90,
|
||||||
|
"scale": {
|
||||||
|
"x": 1,
|
||||||
|
"y": 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"element": 1,
|
||||||
|
"is-folder": false,
|
||||||
|
"name": "bbbb3",
|
||||||
|
"styles": [
|
||||||
|
],
|
||||||
|
"transform": {
|
||||||
|
"offset": {
|
||||||
|
"x": 432,
|
||||||
|
"y": 285
|
||||||
|
},
|
||||||
|
"rotation": 180,
|
||||||
|
"scale": {
|
||||||
|
"x": 1,
|
||||||
|
"y": 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"element": 1,
|
||||||
|
"is-folder": false,
|
||||||
|
"name": "bbbb4",
|
||||||
|
"styles": [
|
||||||
|
],
|
||||||
|
"transform": {
|
||||||
|
"offset": {
|
||||||
|
"x": 302,
|
||||||
|
"y": 399
|
||||||
|
},
|
||||||
|
"rotation": 270,
|
||||||
|
"scale": {
|
||||||
|
"x": 1,
|
||||||
|
"y": 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"element": 1,
|
||||||
|
"is-folder": false,
|
||||||
|
"name": "cccc1",
|
||||||
|
"styles": [
|
||||||
|
],
|
||||||
|
"transform": {
|
||||||
|
"offset": {
|
||||||
|
"x": 467,
|
||||||
|
"y": 71
|
||||||
|
},
|
||||||
|
"rotation": 0,
|
||||||
|
"scale": {
|
||||||
|
"x": 1,
|
||||||
|
"y": 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"element": 1,
|
||||||
|
"is-folder": false,
|
||||||
|
"name": "cccc2",
|
||||||
|
"styles": [
|
||||||
|
],
|
||||||
|
"transform": {
|
||||||
|
"offset": {
|
||||||
|
"x": 361,
|
||||||
|
"y": -70
|
||||||
|
},
|
||||||
|
"rotation": 90,
|
||||||
|
"scale": {
|
||||||
|
"x": 1,
|
||||||
|
"y": 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"element": 1,
|
||||||
|
"is-folder": false,
|
||||||
|
"name": "cccc3",
|
||||||
|
"styles": [
|
||||||
|
],
|
||||||
|
"transform": {
|
||||||
|
"offset": {
|
||||||
|
"x": 273,
|
||||||
|
"y": -211
|
||||||
|
},
|
||||||
|
"rotation": 180,
|
||||||
|
"scale": {
|
||||||
|
"x": 1,
|
||||||
|
"y": 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"element": 1,
|
||||||
|
"is-folder": false,
|
||||||
|
"name": "cccc4",
|
||||||
|
"styles": [
|
||||||
|
],
|
||||||
|
"transform": {
|
||||||
|
"offset": {
|
||||||
|
"x": 574,
|
||||||
|
"y": 198
|
||||||
|
},
|
||||||
|
"rotation": 270,
|
||||||
|
"scale": {
|
||||||
|
"x": 1,
|
||||||
|
"y": 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"element": 1,
|
||||||
|
"is-folder": false,
|
||||||
|
"name": "dddd1",
|
||||||
|
"styles": [
|
||||||
|
],
|
||||||
|
"transform": {
|
||||||
|
"offset": {
|
||||||
|
"x": 33,
|
||||||
|
"y": -231
|
||||||
|
},
|
||||||
|
"rotation": 0,
|
||||||
|
"scale": {
|
||||||
|
"x": 1,
|
||||||
|
"y": 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"element": 1,
|
||||||
|
"is-folder": false,
|
||||||
|
"name": "dddd2",
|
||||||
|
"styles": [
|
||||||
|
],
|
||||||
|
"transform": {
|
||||||
|
"offset": {
|
||||||
|
"x": 55,
|
||||||
|
"y": 352
|
||||||
|
},
|
||||||
|
"rotation": 90,
|
||||||
|
"scale": {
|
||||||
|
"x": 1,
|
||||||
|
"y": 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"element": 1,
|
||||||
|
"is-folder": false,
|
||||||
|
"name": "dddd3",
|
||||||
|
"styles": [
|
||||||
|
],
|
||||||
|
"transform": {
|
||||||
|
"offset": {
|
||||||
|
"x": -40,
|
||||||
|
"y": 220
|
||||||
|
},
|
||||||
|
"rotation": 180,
|
||||||
|
"scale": {
|
||||||
|
"x": 1,
|
||||||
|
"y": 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"element": 1,
|
||||||
|
"is-folder": false,
|
||||||
|
"name": "dddd4",
|
||||||
|
"styles": [
|
||||||
|
],
|
||||||
|
"transform": {
|
||||||
|
"offset": {
|
||||||
|
"x": 0,
|
||||||
|
"y": 0
|
||||||
|
},
|
||||||
|
"rotation": 0,
|
||||||
|
"scale": {
|
||||||
|
"x": 1,
|
||||||
|
"y": 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"element": 1,
|
||||||
|
"is-folder": false,
|
||||||
|
"name": "eeee1",
|
||||||
|
"styles": [
|
||||||
|
],
|
||||||
|
"transform": {
|
||||||
|
"offset": {
|
||||||
|
"x": 0,
|
||||||
|
"y": 0
|
||||||
|
},
|
||||||
|
"rotation": 0,
|
||||||
|
"scale": {
|
||||||
|
"x": 1,
|
||||||
|
"y": 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"element": 1,
|
||||||
|
"is-folder": false,
|
||||||
|
"name": "eeee2",
|
||||||
|
"styles": [
|
||||||
|
],
|
||||||
|
"transform": {
|
||||||
|
"offset": {
|
||||||
|
"x": -149,
|
||||||
|
"y": 85
|
||||||
|
},
|
||||||
|
"rotation": 90,
|
||||||
|
"scale": {
|
||||||
|
"x": 1,
|
||||||
|
"y": 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"element": 1,
|
||||||
|
"is-folder": false,
|
||||||
|
"name": "eeee3",
|
||||||
|
"styles": [
|
||||||
|
],
|
||||||
|
"transform": {
|
||||||
|
"offset": {
|
||||||
|
"x": 166,
|
||||||
|
"y": 482
|
||||||
|
},
|
||||||
|
"rotation": 180,
|
||||||
|
"scale": {
|
||||||
|
"x": 1,
|
||||||
|
"y": 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"is-folder": true,
|
||||||
|
"name": "root",
|
||||||
|
"referenced-by": null,
|
||||||
|
"transform": {
|
||||||
|
"offset": {
|
||||||
|
"x": 8,
|
||||||
|
"y": 20
|
||||||
|
},
|
||||||
|
"rotation": 0,
|
||||||
|
"scale": {
|
||||||
|
"x": 1.7159367435419115,
|
||||||
|
"y": 1.7159367435419115
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"width": 1080
|
||||||
|
}
|
|
@ -104,6 +104,7 @@
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ClCompile Include="src\Editor\DataManager\ProjectDataManager.cpp" />
|
||||||
<ClCompile Include="src\Editor\EditorWidgetComponent\FillStyleWidget.cpp" />
|
<ClCompile Include="src\Editor\EditorWidgetComponent\FillStyleWidget.cpp" />
|
||||||
<ClCompile Include="src\Editor\RightBar\EditorSettingWidget.cpp" />
|
<ClCompile Include="src\Editor\RightBar\EditorSettingWidget.cpp" />
|
||||||
<ClCompile Include="src\Editor\EditorWidgetComponent\ColorPicker.cpp" />
|
<ClCompile Include="src\Editor\EditorWidgetComponent\ColorPicker.cpp" />
|
||||||
|
@ -203,6 +204,7 @@
|
||||||
<QtMoc Include="src\Editor\EditorWidgetComponent\ColorPicker.h" />
|
<QtMoc Include="src\Editor\EditorWidgetComponent\ColorPicker.h" />
|
||||||
<QtMoc Include="src\Editor\RightBar\EditorSettingWidget.h" />
|
<QtMoc Include="src\Editor\RightBar\EditorSettingWidget.h" />
|
||||||
<QtMoc Include="src\Editor\EditorWidgetComponent\FillStyleWidget.h" />
|
<QtMoc Include="src\Editor\EditorWidgetComponent\FillStyleWidget.h" />
|
||||||
|
<ClInclude Include="src\Editor\DataManager\ProjectDataManager.h" />
|
||||||
<ClInclude Include="src\ColorHelper.hpp" />
|
<ClInclude Include="src\ColorHelper.hpp" />
|
||||||
<ClInclude Include="src\Editor\LayerWrapper.h" />
|
<ClInclude Include="src\Editor\LayerWrapper.h" />
|
||||||
<ClInclude Include="src\Editor\util\EncodeUtil.hpp" />
|
<ClInclude Include="src\Editor\util\EncodeUtil.hpp" />
|
||||||
|
|
|
@ -261,6 +261,9 @@
|
||||||
<ClCompile Include="src\Editor\EditorWidgetComponent\FillStyleWidget.cpp">
|
<ClCompile Include="src\Editor\EditorWidgetComponent\FillStyleWidget.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="src\Editor\DataManager\ProjectDataManager.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<QtMoc Include="src\Renderer\RendererGLWidget.h">
|
<QtMoc Include="src\Renderer\RendererGLWidget.h">
|
||||||
|
@ -525,6 +528,9 @@
|
||||||
<ClInclude Include="src\ColorHelper.hpp">
|
<ClInclude Include="src\ColorHelper.hpp">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="src\Editor\DataManager\ProjectDataManager.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<QtRcc Include="res\MainWindow.qrc">
|
<QtRcc Include="res\MainWindow.qrc">
|
||||||
|
|
|
@ -1409,7 +1409,7 @@ void main()
|
||||||
|
|
||||||
imageStore(gBaseColor, pixelLocation, vec4(color.rgb, 1));
|
imageStore(gBaseColor, pixelLocation, vec4(color.rgb, 1));
|
||||||
imageStore(gMetallicRoughness, pixelLocation, vec4(metallicRoughness, 0, 1));
|
imageStore(gMetallicRoughness, pixelLocation, vec4(metallicRoughness, 0, 1));
|
||||||
//return;
|
return;
|
||||||
if (/*color.a!=-1&&*/ debugBVH == vec3(0))
|
if (/*color.a!=-1&&*/ debugBVH == vec3(0))
|
||||||
{
|
{
|
||||||
// imageStore(gBaseColor, pixelLocation, vec4(vec3(1, 1, 0),1));
|
// imageStore(gBaseColor, pixelLocation, vec4(vec3(1, 1, 0),1));
|
||||||
|
|
|
@ -0,0 +1,38 @@
|
||||||
|
#include "ProjectDataManager.h"
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
ProjectDataManager* ProjectDataManager::instance = nullptr;
|
||||||
|
|
||||||
|
ProjectDataManager* ProjectDataManager::Instance()
|
||||||
|
{
|
||||||
|
if (instance == nullptr)
|
||||||
|
instance = new ProjectDataManager();
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ProjectDataManager::addProjectData(ProjectData data)
|
||||||
|
{
|
||||||
|
projectDataList.push_back(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ProjectDataManager::setZoom(double x, double y, EditorWidgetItem* item)
|
||||||
|
{
|
||||||
|
for (auto& data : projectDataList) {
|
||||||
|
if (data.item == item) {
|
||||||
|
data.zoomX = x;
|
||||||
|
data.zoomY = y;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QPointF ProjectDataManager::getZoomByPainterDeivce(QPaintDevice* device)
|
||||||
|
{
|
||||||
|
for (auto& data : projectDataList) {
|
||||||
|
if (data.item->previewWindow == device) {
|
||||||
|
return QPointF(data.zoomX, data.zoomY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return QPointF(1, 1);
|
||||||
|
}
|
|
@ -0,0 +1,30 @@
|
||||||
|
#pragma once
|
||||||
|
#include <map>
|
||||||
|
#include <QPaintDevice>
|
||||||
|
#include <QFile>
|
||||||
|
#include <vector>
|
||||||
|
#include "EditorWidgetItem.h"
|
||||||
|
|
||||||
|
struct ProjectData
|
||||||
|
{
|
||||||
|
int width, height;
|
||||||
|
double zoomX, zoomY;
|
||||||
|
QString fileHome;
|
||||||
|
EditorWidgetItem* item;
|
||||||
|
};
|
||||||
|
|
||||||
|
class ProjectDataManager
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
std::vector<ProjectData> projectDataList;
|
||||||
|
ProjectDataManager() = default;
|
||||||
|
~ProjectDataManager() = default;
|
||||||
|
static ProjectDataManager* instance;
|
||||||
|
|
||||||
|
public:
|
||||||
|
static ProjectDataManager* Instance();
|
||||||
|
void addProjectData(ProjectData data);
|
||||||
|
void setZoom(double x, double y, EditorWidgetItem* item);
|
||||||
|
QPointF getZoomByPainterDeivce(QPaintDevice* device);
|
||||||
|
};
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
#include "EditorWidgetItem.h"
|
#include "EditorWidgetItem.h"
|
||||||
#include "EditorWidget.h"
|
#include "EditorWidget.h"
|
||||||
|
#include "DataManager/ProjectDataManager.h"
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
#include <QFileInfo>
|
||||||
|
#include <QFile>
|
||||||
|
#include <QDir>
|
||||||
|
|
||||||
EditorWidgetItem::EditorWidgetItem(QString filePath,QWidget *parent) : QWidget(parent)
|
EditorWidgetItem::EditorWidgetItem(QString filePath,QWidget *parent) : QWidget(parent)
|
||||||
{
|
{
|
||||||
|
@ -54,9 +58,17 @@ EditorWidgetItem::EditorWidgetItem(QString filePath,QWidget *parent) : QWidget(p
|
||||||
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();
|
||||||
|
ProjectData data;
|
||||||
|
data.fileHome = QFileInfo(filePath).absolutePath();
|
||||||
|
data.width = jsonDoc.object().value("height").toInt();
|
||||||
|
data.height = jsonDoc.object().value("width").toInt();
|
||||||
|
data.zoomX = 1.0;
|
||||||
|
data.zoomY = 1.0;
|
||||||
|
data.item = this;
|
||||||
|
ProjectDataManager::Instance()->addProjectData(data);
|
||||||
// end test
|
// end test
|
||||||
QJsonObject source = jsonDoc.object();
|
QJsonObject source = jsonDoc.object();
|
||||||
elementManager = new ElementManager(source,Renderer::ElementRenderer::instance());
|
elementManager = new ElementManager(source, QFileInfo(filePath).absolutePath());
|
||||||
layerManager = new LayerManager(source, elementManager);
|
layerManager = new LayerManager(source, elementManager);
|
||||||
elementInfoDisplayWidget->setElementManager(elementManager);
|
elementInfoDisplayWidget->setElementManager(elementManager);
|
||||||
treeWidget->elementManager = elementManager;
|
treeWidget->elementManager = elementManager;
|
||||||
|
@ -79,7 +91,6 @@ EditorWidgetItem::EditorWidgetItem(QString filePath,QWidget *parent) : QWidget(p
|
||||||
handleProjectNameChange(this->projectName);
|
handleProjectNameChange(this->projectName);
|
||||||
centralRefresh();
|
centralRefresh();
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
EditorWidgetItem::~EditorWidgetItem()
|
EditorWidgetItem::~EditorWidgetItem()
|
||||||
|
@ -116,6 +127,23 @@ void EditorWidgetItem::save() const
|
||||||
void EditorWidgetItem::saveAs(QString filePath) const
|
void EditorWidgetItem::saveAs(QString filePath) const
|
||||||
{
|
{
|
||||||
saveImpl(filePath);
|
saveImpl(filePath);
|
||||||
|
QString srcHome = QFileInfo(this->filePath).absolutePath();
|
||||||
|
if (!QDir(QFileInfo(filePath).absolutePath() + "/svg").exists())
|
||||||
|
{
|
||||||
|
QDir().mkdir(QFileInfo(filePath).absolutePath() + "/svg");
|
||||||
|
}
|
||||||
|
for (auto& ele : elementManager->elements)
|
||||||
|
{
|
||||||
|
auto e = dynamic_cast<SimpleElement*>(ele);
|
||||||
|
if (e != nullptr)
|
||||||
|
{
|
||||||
|
QString fileName = e->jsonSource["data"].toObject()["include"].toString();
|
||||||
|
QString src = srcHome + fileName;
|
||||||
|
QString dst = QFileInfo(filePath).absolutePath() + fileName;
|
||||||
|
QFile::copy(src, dst);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorWidgetItem::saveImpl(QString filePath) const
|
void EditorWidgetItem::saveImpl(QString filePath) const
|
||||||
|
|
|
@ -16,7 +16,7 @@ class EditorWidgetItem : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
private:
|
public:
|
||||||
// DATA PART
|
// DATA PART
|
||||||
PreviewWindow *previewWindow;
|
PreviewWindow *previewWindow;
|
||||||
ElementManager *elementManager;
|
ElementManager *elementManager;
|
||||||
|
|
|
@ -1,16 +1,20 @@
|
||||||
#include "ElementManager.h"
|
#include "ElementManager.h"
|
||||||
ElementManager::ElementManager(QJsonObject source,Renderer::ElementRenderer* renderer)
|
#include <QFileInfo>
|
||||||
|
#include <QDir>
|
||||||
|
#include <QFile>
|
||||||
|
|
||||||
|
ElementManager::ElementManager(QJsonObject source, QString fileHome)
|
||||||
{
|
{
|
||||||
auto elementsJson = source.value("elements").toArray();
|
auto elementsJson = source.value("elements").toArray();
|
||||||
|
this->fileHome = fileHome;
|
||||||
int index = 0;
|
int index = 0;
|
||||||
for (auto elementJson : elementsJson)
|
for (auto elementJson : elementsJson)
|
||||||
{
|
{
|
||||||
if (elementJson.toObject().value("type").toString() == "group")
|
if (elementJson.toObject().value("type").toString() == "group")
|
||||||
elements.push_back(new GroupElement());
|
elements.push_back(new GroupElement());
|
||||||
else
|
else
|
||||||
elements.push_back(new SimpleElement(elementJson.toObject()));
|
elements.push_back(new SimpleElement(elementJson.toObject(), fileHome));
|
||||||
(*elements.rbegin())->name = elementJson.toObject().value("name").toString();
|
(*elements.rbegin())->name = elementJson.toObject().value("name").toString();
|
||||||
(*elements.rbegin())->renderer = renderer;
|
|
||||||
}
|
}
|
||||||
for (auto element : elements)
|
for (auto element : elements)
|
||||||
element->index = index++;
|
element->index = index++;
|
||||||
|
@ -90,9 +94,11 @@ void ElementManager::createGroupElement(QString name, FolderLayerWrapper* source
|
||||||
void ElementManager::createSimpleElement(QString name, QString filePath) {
|
void ElementManager::createSimpleElement(QString name, QString filePath) {
|
||||||
QJsonObject json;
|
QJsonObject json;
|
||||||
QJsonObject data;
|
QJsonObject data;
|
||||||
data.insert("include", filePath);
|
QFile fileSrc(filePath);
|
||||||
|
QFile::copy(filePath, QDir::cleanPath(fileHome + "/svg/" + QFileInfo(filePath).fileName()));
|
||||||
|
data.insert("include", "/svg/"+QFileInfo(filePath).fileName());
|
||||||
json.insert("data", data);
|
json.insert("data", data);
|
||||||
auto element = new SimpleElement(json);
|
auto element = new SimpleElement(json, fileHome);
|
||||||
element->name = name;
|
element->name = name;
|
||||||
addElement(element);
|
addElement(element);
|
||||||
}
|
}
|
|
@ -14,9 +14,10 @@ class ElementManager
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
vector<GraphicElement *> elements;
|
vector<GraphicElement *> elements;
|
||||||
|
QString fileHome;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ElementManager(QJsonObject source,Renderer::ElementRenderer *renderer);
|
ElementManager(QJsonObject source, QString fileHome);
|
||||||
~ElementManager();
|
~ElementManager();
|
||||||
void addElement(GraphicElement *element);
|
void addElement(GraphicElement *element);
|
||||||
void removeElement(GraphicElement *pElement);
|
void removeElement(GraphicElement *pElement);
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
#include "util/SvgFileLoader.h"
|
#include "util/SvgFileLoader.h"
|
||||||
#include <QGuiApplication>
|
#include <QGuiApplication>
|
||||||
#include <QScreen>
|
#include <QScreen>
|
||||||
|
#include <QDir>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
PixelPath SimpleElement::getPaintObject() const
|
PixelPath SimpleElement::getPaintObject() const
|
||||||
|
@ -23,13 +25,13 @@ void SimpleElement::loadSvgFile(const QString& filePath)
|
||||||
qDebug() << "load svg file success " << painterPath.elementCount() << (isClosed() ? "is" : "not") << "closed";
|
qDebug() << "load svg file success " << painterPath.elementCount() << (isClosed() ? "is" : "not") << "closed";
|
||||||
}
|
}
|
||||||
|
|
||||||
SimpleElement::SimpleElement(QJsonObject jsonSource) : jsonSource(jsonSource)
|
SimpleElement::SimpleElement(QJsonObject jsonSource, QString fileHome) : jsonSource(jsonSource)
|
||||||
{
|
{
|
||||||
painterPath.clear();
|
painterPath.clear();
|
||||||
filePath = jsonSource["data"].toObject()["include"].toString();
|
filePath = jsonSource["data"].toObject()["include"].toString();
|
||||||
//loadSvgFile("D:\\Projects\\BigC\\svg\\3.svg");
|
//loadSvgFile("D:\\Projects\\BigC\\svg\\3.svg");
|
||||||
QFileInfo info(filePath);
|
QFileInfo info(QDir::cleanPath(fileHome + "/" + filePath));
|
||||||
loadSvgFile(filePath);
|
loadSvgFile(info.absoluteFilePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
GroupElement::GroupElement(FolderLayerWrapper* sourceLayer)
|
GroupElement::GroupElement(FolderLayerWrapper* sourceLayer)
|
||||||
|
|
|
@ -46,7 +46,7 @@ public:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QJsonObject toJson() const override;
|
QJsonObject toJson() const override;
|
||||||
SimpleElement(QJsonObject jsonSource);
|
SimpleElement(QJsonObject jsonSource, QString fileHome);
|
||||||
SimpleElement(QString filePath);
|
SimpleElement(QString filePath);
|
||||||
~SimpleElement() = default;
|
~SimpleElement() = default;
|
||||||
PixelPath getPaintObject() const override;
|
PixelPath getPaintObject() const override;
|
||||||
|
|
|
@ -75,7 +75,7 @@ FolderLayerWrapper::FolderLayerWrapper(QJsonObject json, ElementManager *element
|
||||||
}
|
}
|
||||||
|
|
||||||
LeafLayerWrapper::LeafLayerWrapper(QJsonObject json, ElementManager* elementManager, FolderLayerWrapper* parent)
|
LeafLayerWrapper::LeafLayerWrapper(QJsonObject json, ElementManager* elementManager, FolderLayerWrapper* parent)
|
||||||
: LayerWrapper(json, parent),
|
: LayerWrapper(json, parent, elementManager),
|
||||||
wrappedElement(elementManager->getElementById(json.value("element").toInt())),
|
wrappedElement(elementManager->getElementById(json.value("element").toInt())),
|
||||||
styles(LayerStyleContainer::fromJson(wrappedElement->isClosed(), json.value("styles").toArray()))
|
styles(LayerStyleContainer::fromJson(wrappedElement->isClosed(), json.value("styles").toArray()))
|
||||||
{
|
{
|
||||||
|
@ -255,7 +255,8 @@ QJsonObject FolderLayerWrapper::toJson() const
|
||||||
QJsonObject json = LayerWrapper::toJson();
|
QJsonObject json = LayerWrapper::toJson();
|
||||||
QJsonArray childrenJson;
|
QJsonArray childrenJson;
|
||||||
for (auto& child : children)
|
for (auto& child : children)
|
||||||
childrenJson.push_back(child->toJson());
|
if(child != nullptr)
|
||||||
|
childrenJson.push_back(child->toJson());
|
||||||
json.insert("children", childrenJson);
|
json.insert("children", childrenJson);
|
||||||
json.insert("is-folder", true);
|
json.insert("is-folder", true);
|
||||||
if(this->getReferencedBy() != -1)
|
if(this->getReferencedBy() != -1)
|
||||||
|
@ -268,7 +269,7 @@ QJsonObject FolderLayerWrapper::toJson() const
|
||||||
QJsonObject LeafLayerWrapper::toJson() const
|
QJsonObject LeafLayerWrapper::toJson() const
|
||||||
{
|
{
|
||||||
QJsonObject json = LayerWrapper::toJson();
|
QJsonObject json = LayerWrapper::toJson();
|
||||||
json.insert("element", wrappedElement->index);
|
json.insert("element", elementManager->getElementIndex(wrappedElement));
|
||||||
json.insert("is-folder", false);
|
json.insert("is-folder", false);
|
||||||
json.insert("styles", styles.toJson());
|
json.insert("styles", styles.toJson());
|
||||||
return json;
|
return json;
|
||||||
|
|
|
@ -14,6 +14,7 @@ PreviewWindow::PreviewWindow(QWidget *parent) : QOpenGLWidget(parent)
|
||||||
painter->setRenderHint(QPainter::HighQualityAntialiasing);
|
painter->setRenderHint(QPainter::HighQualityAntialiasing);
|
||||||
layerManager = nullptr;
|
layerManager = nullptr;
|
||||||
currentLayer = nullptr;
|
currentLayer = nullptr;
|
||||||
|
zoomStep = 0;
|
||||||
backgroundColor = QColor(255, 255, 255, 255);
|
backgroundColor = QColor(255, 255, 255, 255);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,6 +22,7 @@ void PreviewWindow::initialize(LayerManager *layerManager,QSize windowSize)
|
||||||
{
|
{
|
||||||
this->logicalSize = windowSize;
|
this->logicalSize = windowSize;
|
||||||
this->layerManager = layerManager;
|
this->layerManager = layerManager;
|
||||||
|
this->setFixedSize(windowSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PreviewWindow::show()
|
void PreviewWindow::show()
|
||||||
|
@ -49,6 +51,7 @@ void PreviewWindow::paintGL()
|
||||||
glClearColor(backgroundColor.redF(), backgroundColor.greenF(), backgroundColor.blueF(), backgroundColor.alphaF());
|
glClearColor(backgroundColor.redF(), backgroundColor.greenF(), backgroundColor.blueF(), backgroundColor.alphaF());
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
painter->begin(this);
|
painter->begin(this);
|
||||||
|
painter->setWindow(0, 0, logicalSize.width(), logicalSize.height());
|
||||||
painter->setRenderHint(QPainter::Antialiasing);
|
painter->setRenderHint(QPainter::Antialiasing);
|
||||||
painter->setRenderHint(QPainter::HighQualityAntialiasing);
|
painter->setRenderHint(QPainter::HighQualityAntialiasing);
|
||||||
layerManager->paint(painter,this->size(),currentLayer);
|
layerManager->paint(painter,this->size(),currentLayer);
|
||||||
|
@ -130,3 +133,21 @@ void PreviewWindow::setBackgroundColor(QColor color)
|
||||||
this->backgroundColor = color;
|
this->backgroundColor = color;
|
||||||
this->repaint();
|
this->repaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PreviewWindow::wheelEvent(QWheelEvent* event)
|
||||||
|
{
|
||||||
|
if (QApplication::keyboardModifiers() == Qt::ControlModifier)
|
||||||
|
{
|
||||||
|
if (event->delta() > 0 && zoomStep < ZOOM_STEP_MAX)
|
||||||
|
{
|
||||||
|
zoomStep++;
|
||||||
|
this->setFixedSize(logicalSize * (1 + zoomStep * ZOOM_RATE));
|
||||||
|
}
|
||||||
|
else if(event->delta() < 0 && zoomStep > ZOOM_STEP_MIN)
|
||||||
|
{
|
||||||
|
zoomStep--;
|
||||||
|
this->setFixedSize(logicalSize * (1 + zoomStep * ZOOM_RATE));
|
||||||
|
}
|
||||||
|
this->repaint();
|
||||||
|
}
|
||||||
|
}
|
|
@ -16,6 +16,14 @@ class PreviewWindow : public QOpenGLWidget, protected QOpenGLFunctions
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
constexpr static double ZOOM_RATE = 0.25;
|
||||||
|
constexpr static double ZOOM_DEFAULT = 1.0;
|
||||||
|
constexpr static int ZOOM_STEP_MIN = -2;
|
||||||
|
constexpr static int ZOOM_STEP_MAX = 4;
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
int zoomStep;
|
||||||
QPainter *painter;
|
QPainter *painter;
|
||||||
LayerManager *layerManager;
|
LayerManager *layerManager;
|
||||||
Renderer::ElementRenderer* renderer;
|
Renderer::ElementRenderer* renderer;
|
||||||
|
@ -27,6 +35,7 @@ class PreviewWindow : public QOpenGLWidget, protected QOpenGLFunctions
|
||||||
void mousePressEvent(QMouseEvent* event) override;
|
void mousePressEvent(QMouseEvent* event) override;
|
||||||
void mouseMoveEvent(QMouseEvent* event) override;
|
void mouseMoveEvent(QMouseEvent* event) override;
|
||||||
void mouseReleaseEvent(QMouseEvent* event) override;
|
void mouseReleaseEvent(QMouseEvent* event) override;
|
||||||
|
void wheelEvent(QWheelEvent* event) override;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PreviewWindow(QWidget *parent = nullptr);
|
PreviewWindow(QWidget *parent = nullptr);
|
||||||
|
|
|
@ -59,6 +59,7 @@ void LayerTreeWidget::popMenu(const QPoint &pos)
|
||||||
connect(dialog, &LayerCreateWidget::LayerInfoReturned, this, [this, layer](QJsonObject jsonObj) {
|
connect(dialog, &LayerCreateWidget::LayerInfoReturned, this, [this, layer](QJsonObject jsonObj) {
|
||||||
auto folderLayer = dynamic_cast<FolderLayerWrapper*>(layer);
|
auto folderLayer = dynamic_cast<FolderLayerWrapper*>(layer);
|
||||||
LayerWrapper* newLayer;
|
LayerWrapper* newLayer;
|
||||||
|
qDebug() << this->elementManager;
|
||||||
if(jsonObj.value("is-folder").toBool())
|
if(jsonObj.value("is-folder").toBool())
|
||||||
newLayer = new FolderLayerWrapper(jsonObj, this->elementManager, folderLayer);
|
newLayer = new FolderLayerWrapper(jsonObj, this->elementManager, folderLayer);
|
||||||
else
|
else
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#include <QJsondocument>
|
#include <QJsondocument>
|
||||||
#include "PainterPathUtil.h"
|
#include "PainterPathUtil.h"
|
||||||
#include <queue>
|
#include <queue>
|
||||||
|
#include <QFileInfo>
|
||||||
|
|
||||||
using Renderer::Painting;
|
using Renderer::Painting;
|
||||||
using Renderer::BaseElement;
|
using Renderer::BaseElement;
|
||||||
|
@ -14,8 +15,6 @@ using std::make_shared;
|
||||||
using std::min;
|
using std::min;
|
||||||
using std::queue;
|
using std::queue;
|
||||||
|
|
||||||
const double PaintingUtil::pi = acos(-1);
|
|
||||||
|
|
||||||
struct LayerNode {
|
struct LayerNode {
|
||||||
LayerWrapper* nowLayer;
|
LayerWrapper* nowLayer;
|
||||||
QTransform transfrom;
|
QTransform transfrom;
|
||||||
|
@ -37,7 +36,7 @@ Painting PaintingUtil::transfromToPainting(QString jsonFilePath) {
|
||||||
glm::bvec2 flip(0, 0);
|
glm::bvec2 flip(0, 0);
|
||||||
QJsonObject jsonObj = readJsonFile(jsonFilePath);
|
QJsonObject jsonObj = readJsonFile(jsonFilePath);
|
||||||
qDebug() << jsonObj;
|
qDebug() << jsonObj;
|
||||||
shared_ptr<ElementManager> elementManager = make_shared<ElementManager>(jsonObj, Renderer::ElementRenderer::instance());
|
shared_ptr<ElementManager> elementManager = make_shared<ElementManager>(jsonObj, QFileInfo(jsonFilePath).absolutePath());
|
||||||
shared_ptr<LayerManager> layerManager = make_shared<LayerManager>(jsonObj, elementManager.get());
|
shared_ptr<LayerManager> layerManager = make_shared<LayerManager>(jsonObj, elementManager.get());
|
||||||
//qDebug() << elementManager->toJson();
|
//qDebug() << elementManager->toJson();
|
||||||
//qDebug() << layerManager->toJson();
|
//qDebug() << layerManager->toJson();
|
||||||
|
@ -109,8 +108,9 @@ FolderLayerWrapper* PaintingUtil::handleLayerWrapper(LayerWrapper* nowLayer, QTr
|
||||||
qDebug() << material->halfWidth;
|
qDebug() << material->halfWidth;
|
||||||
}
|
}
|
||||||
QPainterPathStroker stroker;
|
QPainterPathStroker stroker;
|
||||||
stroker.setWidth(lineWidth);
|
stroker.setWidth(lineWidth * 2);
|
||||||
stroker.setCapStyle(Qt::RoundCap);
|
stroker.setCapStyle(Qt::RoundCap);
|
||||||
|
stroker.setJoinStyle(Qt::RoundJoin);
|
||||||
QPainterPath strokePath = stroker.createStroke(painterPath);
|
QPainterPath strokePath = stroker.createStroke(painterPath);
|
||||||
auto rect = transform.map(strokePath).boundingRect();
|
auto rect = transform.map(strokePath).boundingRect();
|
||||||
elementTransform.bound = glm::vec4(rect.x(), rect.y(), rect.x() + rect.width(), rect.y() + rect.height());
|
elementTransform.bound = glm::vec4(rect.x(), rect.y(), rect.x() + rect.width(), rect.y() + rect.height());
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
class PaintingUtil
|
class PaintingUtil
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
static const double pi;
|
//static const double pi;
|
||||||
static QJsonObject readJsonFile(QString jsonFilePath);
|
static QJsonObject readJsonFile(QString jsonFilePath);
|
||||||
static FolderLayerWrapper* handleLayerWrapper(LayerWrapper* nowLayer, QTransform& transform, Renderer::Painting& painting);
|
static FolderLayerWrapper* handleLayerWrapper(LayerWrapper* nowLayer, QTransform& transform, Renderer::Painting& painting);
|
||||||
//static double getMaxLineWidth(LayerWrapper* root);
|
//static double getMaxLineWidth(LayerWrapper* root);
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
"name": "ababa",
|
"name": "ababa",
|
||||||
"type": "svg-file",
|
"type": "svg-file",
|
||||||
"data": {
|
"data": {
|
||||||
"include": "../svg/2.svg"
|
"include": "/svg/2.svg"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -22,7 +22,7 @@
|
||||||
"name": "ababa2",
|
"name": "ababa2",
|
||||||
"type": "svg-file",
|
"type": "svg-file",
|
||||||
"data": {
|
"data": {
|
||||||
"include": "../svg/0.svg"
|
"include": "/svg/0.svg"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- Generator: Adobe Illustrator 25.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||||
|
<svg version="1.1" id="图层_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||||
|
viewBox="0 0 1735.4 1712.3" style="enable-background:new 0 0 1735.4 1712.3;" xml:space="preserve">
|
||||||
|
<style type="text/css">
|
||||||
|
.st0{stroke:#000000;stroke-miterlimit:10;}
|
||||||
|
</style>
|
||||||
|
<polygon class="st0" points="932.3,945.5 1007,887.6 1034.9,922.2 512.7,1320.5 488.7,1287.4 592.2,1208.1 546.2,1145.1
|
||||||
|
579.5,1120.1 627.3,1181.8 747.8,1088.8 278.2,440.8 158.8,520.8 199.7,578.8 163.3,604.9 120.1,546.9 28,608.3 0.7,569.7
|
||||||
|
497.7,234.2 526.1,272.9 463.5,316.1 507.9,379.8 477.2,402.5 430.6,337.7 303.9,424.4 778.3,1064.7 892.1,977.2 826.2,888
|
||||||
|
865.7,857.4 "/>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 822 B |
|
@ -59,9 +59,9 @@
|
||||||
"name": "Leaf2",
|
"name": "Leaf2",
|
||||||
"styles": [
|
"styles": [
|
||||||
{
|
{
|
||||||
"enableEachSideIndependent": true,
|
"enableEachSideIndependent": false,
|
||||||
"left": "AAAAQAEAIZwAf////1UA/w==",
|
"left": "AAAAQAEAIZwAf////1UA/w==",
|
||||||
"right": "AADgQAAACJw=",
|
"right": "AADgQAEACJwAf///AFqe/w==",
|
||||||
"type": "stroke"
|
"type": "stroke"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
Loading…
Reference in New Issue