添加data.json

dev-VirtualTexture
wuyize 2022-11-19 17:27:06 +08:00 committed by 白封羽
parent 4b97ece85d
commit d6a3d3555d
8 changed files with 53 additions and 21 deletions

View File

@ -130,16 +130,16 @@
<Filter>Source Files\Editor</Filter> <Filter>Source Files\Editor</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="src\Editor\ElementManager.cpp"> <ClCompile Include="src\Editor\ElementManager.cpp">
<Filter>Source Files</Filter> <Filter>Source Files\Editor</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="src\Editor\LayerManager.cpp"> <ClCompile Include="src\Editor\LayerManager.cpp">
<Filter>Source Files</Filter> <Filter>Source Files\Editor</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="src\Editor\LayerWrapper.cpp"> <ClCompile Include="src\Editor\LayerWrapper.cpp">
<Filter>Source Files</Filter> <Filter>Source Files\Editor</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="src\Editor\PreviewWindow.cpp"> <ClCompile Include="src\Editor\PreviewWindow.cpp">
<Filter>Source Files</Filter> <Filter>Source Files\Editor</Filter>
</ClCompile> </ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
@ -168,7 +168,7 @@
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</QtMoc> </QtMoc>
<QtMoc Include="src\Editor\PreviewWindow.h"> <QtMoc Include="src\Editor\PreviewWindow.h">
<Filter>Header Files</Filter> <Filter>Header Files\Editor</Filter>
</QtMoc> </QtMoc>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
@ -287,17 +287,17 @@
<ClInclude Include="src\Editor\GraphicElement.h"> <ClInclude Include="src\Editor\GraphicElement.h">
<Filter>Header Files\Editor</Filter> <Filter>Header Files\Editor</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="src\Editor\ElementManager.h"> <ClInclude Include="src\Editor\LayerStyle.h">
<Filter>Header Files</Filter> <Filter>Header Files\Editor</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="src\Editor\LayerManager.h"> <ClInclude Include="src\Editor\LayerManager.h">
<Filter>Header Files</Filter> <Filter>Header Files\Editor</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="src\Editor\LayerStyle.h"> <ClInclude Include="src\Editor\ElementManager.h">
<Filter>Header Files</Filter> <Filter>Header Files\Editor</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="src\Editor\LayerWrapper.h"> <ClInclude Include="src\Editor\LayerWrapper.h">
<Filter>Header Files</Filter> <Filter>Header Files\Editor</Filter>
</ClInclude> </ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@ -1,5 +1,8 @@
#include "LayerManager.h" #include "LayerManager.h"
LayerManager::LayerManager(QObject *parent)
void LayerManager::paint(QPainter *painter) const {
scene = new QGraphicsScene(parent);
}
void LayerManager::paint(QGraphicsView *view) const
{ {
} }

View File

@ -1,6 +1,6 @@
#pragma once #pragma once
#include "LayerWrapper.h" #include "LayerWrapper.h"
#include <QPainter> #include <QGraphicsView>
#include <utility> #include <utility>
#include <vector> #include <vector>
using std::pair; using std::pair;
@ -9,10 +9,12 @@ class LayerManager
{ {
private: private:
using LayerPtrs = vector<LayerWrapper *>; using LayerPtrs = vector<LayerWrapper *>;
LayerWrapper root; LayerWrapper *root;
LayerPtrs selectedLayers; LayerPtrs selectedLayers;
LayerPtrs involvedLeafLayersCache; LayerPtrs involvedLeafLayersCache;
QGraphicsScene *scene;
public: public:
void paint(QPainter *painter) const; LayerManager(QObject *parent = 0);
void paint(QGraphicsView *view) const;
}; };

View File

@ -1,8 +1,5 @@
#include "LayerWrapper.h" #include "LayerWrapper.h"
void LayerWrapper::applyStyles(SimpleElement &element)
{
}
void FolderLayerWrapper::addChild(LayerWrapper *child) void FolderLayerWrapper::addChild(LayerWrapper *child)
{ {
} }

View File

@ -1,6 +1,9 @@
#pragma once #pragma once
#include "GraphicElement.h" #include "GraphicElement.h"
#include "LayerStyle.h" #include "LayerStyle.h"
#include <QGraphicsItem>
#include <QGraphicsItemGroup>
#include <QGraphicsScene>
#include <QLine> #include <QLine>
#include <QPoint> #include <QPoint>
#include <memory> #include <memory>
@ -16,7 +19,7 @@ class LayerWrapper
QPainterPath cache; QPainterPath cache;
public: public:
void applyStyles(SimpleElement &element); // invoke by manager, then invoke parent's applyStyles virtual void draw(QGraphicsScene *scene) = 0; // invoke by manager, then invoke parent's applyStyles
// todo: provide atomic operations for Events // todo: provide atomic operations for Events
}; };

View File

@ -10,7 +10,7 @@ void PreviewWindow::show()
{ {
mainScene->clear(); mainScene->clear();
QFile settingFile; QFile settingFile;
settingFile.setFileName("C:/Users/Karlis/Desktop/data.json"); settingFile.setFileName("../data.json");
settingFile.open(QFile::ReadOnly); settingFile.open(QFile::ReadOnly);
QByteArray setting = settingFile.readAll().trimmed(); QByteArray setting = settingFile.readAll().trimmed();
QJsonDocument jsonDoc(QJsonDocument::fromJson(setting)); QJsonDocument jsonDoc(QJsonDocument::fromJson(setting));

View File

@ -1,5 +1,6 @@
#pragma once #pragma once
#include "GraphicElement.h" #include "GraphicElement.h"
#include "LayerManager.h"
#include "QGraphicsItem.h" #include "QGraphicsItem.h"
#include "QGraphicsView.h" #include "QGraphicsView.h"
#include <QFile> #include <QFile>

26
data.json Normal file
View File

@ -0,0 +1,26 @@
{
"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
}
}
]
}