回滚到e19aac0dd2
parent
4eba93a4f7
commit
685df86863
|
@ -105,8 +105,6 @@
|
||||||
<ClCompile Include="src\Editor\LayerManager.cpp" />
|
<ClCompile Include="src\Editor\LayerManager.cpp" />
|
||||||
<ClCompile Include="src\Editor\LayerWrapper.cpp" />
|
<ClCompile Include="src\Editor\LayerWrapper.cpp" />
|
||||||
<ClCompile Include="src\Editor\PreviewWindow.cpp" />
|
<ClCompile Include="src\Editor\PreviewWindow.cpp" />
|
||||||
<ClCompile Include="src\Editor\RightBar\InfoDisplayWidget.cpp" />
|
|
||||||
<ClCompile Include="src\Editor\RightBar\LayerTreeWidget.cpp" />
|
|
||||||
<ClCompile Include="src\Editor\third-party modules\qquick\qquicksvgparser.cpp" />
|
<ClCompile Include="src\Editor\third-party modules\qquick\qquicksvgparser.cpp" />
|
||||||
<ClCompile Include="src\Editor\third-party modules\util\SvgFileLoader.cpp" />
|
<ClCompile Include="src\Editor\third-party modules\util\SvgFileLoader.cpp" />
|
||||||
<ClCompile Include="src\IconWidget.cpp" />
|
<ClCompile Include="src\IconWidget.cpp" />
|
||||||
|
@ -164,8 +162,6 @@
|
||||||
<None Include="Shaders\ssgi.comp" />
|
<None Include="Shaders\ssgi.comp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<QtMoc Include="src\Editor\RightBar\LayerTreeWidget.h" />
|
|
||||||
<QtMoc Include="src\Editor\RightBar\InfoDisplayWidget.h" />
|
|
||||||
<ClInclude Include="src\Editor\third-party modules\qquick\qtquickglobal.h" />
|
<ClInclude Include="src\Editor\third-party modules\qquick\qtquickglobal.h" />
|
||||||
<ClInclude Include="src\Editor\third-party modules\qquick\qtquickglobal_p.h" />
|
<ClInclude Include="src\Editor\third-party modules\qquick\qtquickglobal_p.h" />
|
||||||
<ClInclude Include="src\Editor\third-party modules\qquick\qquicksvgparser_p.h" />
|
<ClInclude Include="src\Editor\third-party modules\qquick\qquicksvgparser_p.h" />
|
||||||
|
|
|
@ -173,13 +173,6 @@
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="src\Editor\third-party modules\SvgHelper.cpp">
|
<ClCompile Include="src\Editor\third-party modules\SvgHelper.cpp">
|
||||||
<Filter>Source Files\Editor\third-party modules</Filter>
|
<Filter>Source Files\Editor\third-party modules</Filter>
|
||||||
<Filter>Source Files\Editor\third-party modules</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="src\Editor\RightBar\LayerTreeWidget.cpp">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="src\Editor\RightBar\InfoDisplayWidget.cpp">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="src\Renderer\Painting\ElementStyle.cpp">
|
<ClCompile Include="src\Renderer\Painting\ElementStyle.cpp">
|
||||||
<Filter>Source Files\Renderer\Painting</Filter>
|
<Filter>Source Files\Renderer\Painting</Filter>
|
||||||
|
@ -213,12 +206,6 @@
|
||||||
<QtMoc Include="src\Editor\PreviewWindow.h">
|
<QtMoc Include="src\Editor\PreviewWindow.h">
|
||||||
<Filter>Header Files\Editor</Filter>
|
<Filter>Header Files\Editor</Filter>
|
||||||
</QtMoc>
|
</QtMoc>
|
||||||
<QtMoc Include="src\Editor\RightBar\LayerTreeWidget.h">
|
|
||||||
<Filter>Header Files</Filter>
|
|
||||||
</QtMoc>
|
|
||||||
<QtMoc Include="src\Editor\RightBar\InfoDisplayWidget.h">
|
|
||||||
<Filter>Header Files</Filter>
|
|
||||||
</QtMoc>
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="Shaders\shader.frag">
|
<None Include="Shaders\shader.frag">
|
||||||
|
@ -346,6 +333,9 @@
|
||||||
<ClInclude Include="src\Editor\ElementManager.h">
|
<ClInclude Include="src\Editor\ElementManager.h">
|
||||||
<Filter>Header Files\Editor</Filter>
|
<Filter>Header Files\Editor</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="src\Editor\LayerWrapper.h">
|
||||||
|
<Filter>Header Files\Editor</Filter>
|
||||||
|
</ClInclude>
|
||||||
<ClInclude Include="src\Renderer\Painting\LineTree.h">
|
<ClInclude Include="src\Renderer\Painting\LineTree.h">
|
||||||
<Filter>Header Files\Renderer\Painting</Filter>
|
<Filter>Header Files\Renderer\Painting</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
@ -370,13 +360,6 @@
|
||||||
<ClInclude Include="src\Renderer\Painting\ElementStyle.h">
|
<ClInclude Include="src\Renderer\Painting\ElementStyle.h">
|
||||||
<Filter>Header Files\Renderer\Painting</Filter>
|
<Filter>Header Files\Renderer\Painting</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="src\Editor\LayerWrapper.h">
|
|
||||||
<Filter>Header Files\Editor</Filter>
|
|
||||||
<Filter>Header Files\Editor\third-party modules\qquick</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="src\Editor\third-party modules\util\SvgFileLoader.h">
|
|
||||||
<Filter>Header Files\Editor\util</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<QtRcc Include="MainWindow.qrc">
|
<QtRcc Include="MainWindow.qrc">
|
||||||
|
|
|
@ -27,60 +27,18 @@
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QWidget" name="MainWindow" native="true">
|
<layout class="QVBoxLayout" name="verticalLayout_3" stretch="1,30">
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_2" stretch="1,30">
|
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="Title">
|
<widget class="QLabel" name="title">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>纹理编辑</string>
|
<string>纹理编辑</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="alignment">
|
|
||||||
<set>Qt::AlignCenter</set>
|
|
||||||
</property>
|
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout" stretch="1,18,5">
|
|
||||||
<item>
|
|
||||||
<widget class="QWidget" name="LeftBar" native="true"/>
|
|
||||||
</item>
|
|
||||||
<item>
|
<item>
|
||||||
<widget class="PreviewWindow" name="Preview"/>
|
<widget class="PreviewWindow" name="Preview"/>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
|
||||||
<widget class="QWidget" name="RightBar" native="true">
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_4" stretch="1,2">
|
|
||||||
<item>
|
|
||||||
<widget class="QTabWidget" name="DisplayTab">
|
|
||||||
<property name="currentIndex">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<widget class="InfoDisplayWidget" name="LayerDisplay">
|
|
||||||
<attribute name="title">
|
|
||||||
<string>Layer</string>
|
|
||||||
</attribute>
|
|
||||||
</widget>
|
|
||||||
<widget class="QWidget" name="ElementDisplay">
|
|
||||||
<attribute name="title">
|
|
||||||
<string>Element</string>
|
|
||||||
</attribute>
|
|
||||||
</widget>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="LayerTreeWidget" name="LayerTree">
|
|
||||||
<property name="contextMenuPolicy">
|
|
||||||
<enum>Qt::CustomContextMenu</enum>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
@ -91,17 +49,6 @@
|
||||||
<extends>QOpenGLWidget</extends>
|
<extends>QOpenGLWidget</extends>
|
||||||
<header>PreviewWindow.h</header>
|
<header>PreviewWindow.h</header>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
<customwidget>
|
|
||||||
<class>LayerTreeWidget</class>
|
|
||||||
<extends>QTreeWidget</extends>
|
|
||||||
<header location="global">LayerTreeWidget.h</header>
|
|
||||||
</customwidget>
|
|
||||||
<customwidget>
|
|
||||||
<class>InfoDisplayWidget</class>
|
|
||||||
<extends>QWidget</extends>
|
|
||||||
<header location="global">InfoDisplayWidget.h</header>
|
|
||||||
<container>1</container>
|
|
||||||
</customwidget>
|
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections/>
|
<connections/>
|
||||||
|
|
|
@ -876,49 +876,6 @@ void drawLine(in float d, in uint styleIndex, out vec4 elementColor, out vec2 me
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawLine(in float d, in uint styleIndex, out vec4 elementColor, out vec2 metallicRoughness)
|
|
||||||
{
|
|
||||||
elementColor = vec4(1);
|
|
||||||
metallicRoughness = vec2(0.8);
|
|
||||||
switch(int(elementData[styleIndex+3]))
|
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
{
|
|
||||||
elementColor = vec4(elementData[styleIndex+7],elementData[styleIndex+8],elementData[styleIndex+9],1);
|
|
||||||
metallicRoughness = vec2(elementData[styleIndex+10],elementData[styleIndex+11]);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 1:
|
|
||||||
{
|
|
||||||
elementColor = vec4(mix(vec3(0), vec3(1), d), 1);
|
|
||||||
metallicRoughness = vec2(0,0.8);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 2:
|
|
||||||
{
|
|
||||||
float levels[] = {0.25,0.5,0.75};
|
|
||||||
vec3 colors[] = {vec3(1,0,0), vec3(0,1,0), vec3(0,0,1), vec3(1,1,0)};
|
|
||||||
int i = 0;
|
|
||||||
while(i<3)
|
|
||||||
{
|
|
||||||
if(d<levels[i])
|
|
||||||
{
|
|
||||||
elementColor = vec4(colors[i], 1);
|
|
||||||
metallicRoughness = vec2(0,0.8);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
if(i==3)
|
|
||||||
{
|
|
||||||
elementColor = vec4(colors[i], 1);
|
|
||||||
metallicRoughness = vec2(0,0.8);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool drawElement(uint elementIndex, vec2 localUV, out vec3 color, out vec2 metallicRoughness, inout vec3 debugBVH = vec3(0))
|
bool drawElement(uint elementIndex, vec2 localUV, out vec3 color, out vec2 metallicRoughness, inout vec3 debugBVH = vec3(0))
|
||||||
{
|
{
|
||||||
bool hitElement = false;
|
bool hitElement = false;
|
||||||
|
|
|
@ -2,18 +2,9 @@
|
||||||
|
|
||||||
EditorWidget::EditorWidget(QWidget *parent) : QWidget(parent)
|
EditorWidget::EditorWidget(QWidget *parent) : QWidget(parent)
|
||||||
{
|
{
|
||||||
displayLayer = nullptr;
|
|
||||||
displayElement = nullptr;
|
|
||||||
ui.setupUi(this);
|
ui.setupUi(this);
|
||||||
previewWindow = ui.Preview;
|
previewWindow = ui.Preview;
|
||||||
treeWidget = ui.LayerTree;
|
qDebug() << "123";
|
||||||
tabWidget = ui.DisplayTab;
|
|
||||||
layerInfoDisplayWidget = dynamic_cast<InfoDisplayWidget *>(tabWidget->widget(0));
|
|
||||||
elementInfoDisplayWidget = dynamic_cast<InfoDisplayWidget *>(tabWidget->widget(1));
|
|
||||||
connect(treeWidget, &LayerTreeWidget::displayLayerChange, this, &EditorWidget::onLayerChange);
|
|
||||||
connect(layerInfoDisplayWidget, &InfoDisplayWidget::requireRefreshPreview, this,
|
|
||||||
&EditorWidget::triggerRefreshPreview);
|
|
||||||
// &EditorWidget::triggerRefreshPreview);
|
|
||||||
// test
|
// test
|
||||||
QFile settingFile;
|
QFile settingFile;
|
||||||
settingFile.setFileName("../data.json");
|
settingFile.setFileName("../data.json");
|
||||||
|
@ -28,10 +19,6 @@ EditorWidget::EditorWidget(QWidget *parent) : QWidget(parent)
|
||||||
elementManager = new ElementManager(source);
|
elementManager = new ElementManager(source);
|
||||||
layerManager = new LayerManager(source, elementManager);
|
layerManager = new LayerManager(source, elementManager);
|
||||||
previewWindow->initialize(layerManager);
|
previewWindow->initialize(layerManager);
|
||||||
if (layerManager->getRoot() != nullptr)
|
|
||||||
{
|
|
||||||
treeWidget->addTopLevelItem(layerManager->getRoot()->qTreeItem);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
EditorWidget::~EditorWidget()
|
EditorWidget::~EditorWidget()
|
||||||
|
@ -41,16 +28,3 @@ EditorWidget::~EditorWidget()
|
||||||
void EditorWidget::paintEvent(QPaintEvent *event)
|
void EditorWidget::paintEvent(QPaintEvent *event)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorWidget::onLayerChange(LayerWrapper *layer)
|
|
||||||
{
|
|
||||||
displayLayer = layer;
|
|
||||||
// TODO : notify InfoDisplayWidget and update
|
|
||||||
dynamic_cast<InfoDisplayWidget *>(tabWidget->widget(0))->setLayer(layer);
|
|
||||||
this->update();
|
|
||||||
}
|
|
||||||
|
|
||||||
void EditorWidget::triggerRefreshPreview()
|
|
||||||
{
|
|
||||||
previewWindow->update();
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,38 +1,24 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "ElementManager.h"
|
#include "ElementManager.h"
|
||||||
#include "InfoDisplayWidget.h"
|
|
||||||
#include "LayerManager.h"
|
#include "LayerManager.h"
|
||||||
#include "LayerTreeWidget.h"
|
|
||||||
#include "PreviewWindow.h"
|
#include "PreviewWindow.h"
|
||||||
#include "ui_EditorWidget.h"
|
#include "ui_EditorWidget.h"
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QTreeWidget>
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
class EditorWidget : public QWidget
|
class EditorWidget : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// DATA PART
|
Ui::EditorWidgetClass ui;
|
||||||
PreviewWindow *previewWindow;
|
PreviewWindow *previewWindow;
|
||||||
ElementManager *elementManager;
|
ElementManager *elementManager;
|
||||||
LayerManager *layerManager;
|
LayerManager *layerManager;
|
||||||
// QT GUI PART
|
|
||||||
Ui::EditorWidgetClass ui;
|
|
||||||
LayerTreeWidget *treeWidget;
|
|
||||||
QTabWidget *tabWidget;
|
|
||||||
InfoDisplayWidget *layerInfoDisplayWidget, *elementInfoDisplayWidget;
|
|
||||||
// QT DATA PART
|
|
||||||
LayerWrapper *displayLayer;
|
|
||||||
GraphicElement *displayElement;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
EditorWidget(QWidget *parent = nullptr);
|
EditorWidget(QWidget *parent = nullptr);
|
||||||
~EditorWidget();
|
~EditorWidget();
|
||||||
void paintEvent(QPaintEvent *event) override;
|
void paintEvent(QPaintEvent *event) override;
|
||||||
|
|
||||||
private slots:
|
|
||||||
void onLayerChange(LayerWrapper *layer);
|
|
||||||
void triggerRefreshPreview();
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -11,14 +11,12 @@ void SimpleElement::loadSvgFile(const QString& filePath)
|
||||||
// TODO ÑùʽÎÊÌâ
|
// TODO ÑùʽÎÊÌâ
|
||||||
SvgFileLoader loader;
|
SvgFileLoader loader;
|
||||||
loader.loadSvgFile(filePath, painterPath);
|
loader.loadSvgFile(filePath, painterPath);
|
||||||
qDebug() << "load svg file success "<<painterPath.elementCount();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SimpleElement::SimpleElement(QJsonObject jsonSource) : jsonSource(jsonSource)
|
SimpleElement::SimpleElement(QJsonObject jsonSource) : jsonSource(jsonSource)
|
||||||
{
|
{
|
||||||
painterPath.clear();
|
painterPath.clear();
|
||||||
loadSvgFile("D:\\Projects\\BigC\\svg\\3.svg");
|
loadSvgFile(jsonSource.value("data").toObject().value("include").toString());
|
||||||
//loadSvgFile(jsonSource.value("data").toObject().value("include").toString());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GroupElement::GroupElement(FolderLayerWrapper *sourceLayer)
|
GroupElement::GroupElement(FolderLayerWrapper *sourceLayer)
|
||||||
|
|
|
@ -7,10 +7,6 @@ LayerManager::LayerManager(QJsonObject source, ElementManager *elementManager)
|
||||||
else
|
else
|
||||||
root = new LeafLayerWrapper(rootJson, elementManager, nullptr);
|
root = new LeafLayerWrapper(rootJson, elementManager, nullptr);
|
||||||
}
|
}
|
||||||
LayerWrapper *LayerManager::getRoot() const
|
|
||||||
{
|
|
||||||
return root;
|
|
||||||
}
|
|
||||||
void LayerManager::paint(QPainter *painter) const
|
void LayerManager::paint(QPainter *painter) const
|
||||||
{
|
{
|
||||||
painter->drawPath(root->getCache());
|
painter->drawPath(root->getCache());
|
||||||
|
@ -61,11 +57,3 @@ bool LayerManager::changeParent(FolderLayerWrapper *newParent) const
|
||||||
selectedLayers[0]->setParent(newParent);
|
selectedLayers[0]->setParent(newParent);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
void LayerManager::addLayer(LayerWrapper *layer)
|
|
||||||
{
|
|
||||||
layerSet.insert(layer);
|
|
||||||
}
|
|
||||||
void LayerManager::removeLayer(LayerWrapper *layer)
|
|
||||||
{
|
|
||||||
layerSet.erase(layer);
|
|
||||||
}
|
|
||||||
|
|
|
@ -3,11 +3,9 @@
|
||||||
#include "LayerWrapper.h"
|
#include "LayerWrapper.h"
|
||||||
#include <QJsonArray>
|
#include <QJsonArray>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <set>
|
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
using std::pair;
|
using std::pair;
|
||||||
using std::set;
|
|
||||||
using std::vector;
|
using std::vector;
|
||||||
class ElementManager;
|
class ElementManager;
|
||||||
class LayerWrapper;
|
class LayerWrapper;
|
||||||
|
@ -23,13 +21,8 @@ class LayerManager
|
||||||
LayerPtrs involvedLeafLayersCache;
|
LayerPtrs involvedLeafLayersCache;
|
||||||
bool singleSelectedCheck() const;
|
bool singleSelectedCheck() const;
|
||||||
bool multipleSelectedCheck() const;
|
bool multipleSelectedCheck() const;
|
||||||
set<LayerWrapper *> layerSet;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void addLayer(LayerWrapper *layer);
|
|
||||||
void removeLayer(LayerWrapper *layer);
|
|
||||||
LayerWrapper *getRoot() const;
|
|
||||||
LayerManager() = default;
|
|
||||||
LayerManager(QJsonObject source, ElementManager *elementManager);
|
LayerManager(QJsonObject source, ElementManager *elementManager);
|
||||||
void paint(QPainter *painter) const;
|
void paint(QPainter *painter) const;
|
||||||
bool rename(QString newName) const;
|
bool rename(QString newName) const;
|
||||||
|
|
|
@ -33,17 +33,9 @@ LayerWrapper::LayerWrapper(QJsonObject json, LayerWrapper *parent)
|
||||||
{
|
{
|
||||||
this->parent = shared_ptr<LayerWrapper>(parent);
|
this->parent = shared_ptr<LayerWrapper>(parent);
|
||||||
auto transformJson = json.value("transform").toObject();
|
auto transformJson = json.value("transform").toObject();
|
||||||
property.name = json.value("name").toString();
|
property.offset = { transformJson.value("offset").toObject().value("x").toDouble(), transformJson.value("offset").toObject().value("y").toDouble() };
|
||||||
property.offset = {transformJson.value("offset").toObject().value("x").toDouble(),
|
property.scale = { transformJson.value("scale").toObject().value("x").toDouble(), transformJson.value("scale").toObject().value("y").toDouble() };
|
||||||
transformJson.value("offset").toObject().value("y").toDouble()};
|
|
||||||
property.scale = {transformJson.value("scale").toObject().value("x").toDouble(),
|
|
||||||
transformJson.value("scale").toObject().value("y").toDouble()};
|
|
||||||
property.rotation = { transformJson.value("rotation").toDouble()};
|
property.rotation = { transformJson.value("rotation").toDouble()};
|
||||||
qTreeItem = new QTreeWidgetItem();
|
|
||||||
qTreeItem->setText(0, property.name);
|
|
||||||
if (parent != nullptr)
|
|
||||||
parent->qTreeItem->addChild(qTreeItem);
|
|
||||||
qTreeItem->setData(0, Qt::UserRole, QVariant::fromValue(this));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FolderLayerWrapper::FolderLayerWrapper(QJsonObject json, ElementManager *elementManager, LayerWrapper *parent)
|
FolderLayerWrapper::FolderLayerWrapper(QJsonObject json, ElementManager *elementManager, LayerWrapper *parent)
|
||||||
|
@ -79,16 +71,16 @@ LeafLayerWrapper::LeafLayerWrapper(QJsonObject json, ElementManager *elementMana
|
||||||
void LayerWrapper::SimpleProperty::apply(QPainterPath &cache) const
|
void LayerWrapper::SimpleProperty::apply(QPainterPath &cache) const
|
||||||
{
|
{
|
||||||
QTransform trans;
|
QTransform trans;
|
||||||
double centerX = cache.boundingRect().center().x();
|
double delX = cache.boundingRect().width();
|
||||||
double centerY = cache.boundingRect().center().y();
|
double delY = cache.boundingRect().height();
|
||||||
qDebug() << name << " " << cache.boundingRect().center();
|
trans.translate(-delX,-delY);
|
||||||
qDebug() << name << " " << cache.boundingRect();
|
|
||||||
trans.translate(centerX, centerY);
|
|
||||||
trans.scale(scale.x(), scale.y());
|
trans.scale(scale.x(), scale.y());
|
||||||
trans.rotate(rotation);
|
trans.rotate(rotation);
|
||||||
trans.translate(-centerX, -centerY);
|
|
||||||
trans.translate(offset.x(), offset.y());
|
|
||||||
cache = trans.map(cache);
|
cache = trans.map(cache);
|
||||||
|
trans.reset();
|
||||||
|
trans.translate(delX+offset.x(), delY+offset.y());
|
||||||
|
cache = trans.map(cache);
|
||||||
|
// cache.translate(offset);
|
||||||
}
|
}
|
||||||
void LayerWrapper::refresh()
|
void LayerWrapper::refresh()
|
||||||
{
|
{
|
||||||
|
@ -106,8 +98,7 @@ void FolderLayerWrapper::refresh()
|
||||||
void LeafLayerWrapper::refresh()
|
void LeafLayerWrapper::refresh()
|
||||||
{
|
{
|
||||||
cache.clear();
|
cache.clear();
|
||||||
if (wrappedElement != nullptr)
|
if (wrappedElement != nullptr) {
|
||||||
{
|
|
||||||
cache.addPath(wrappedElement->getPaintObject());
|
cache.addPath(wrappedElement->getPaintObject());
|
||||||
}
|
}
|
||||||
LayerWrapper::refresh();
|
LayerWrapper::refresh();
|
||||||
|
@ -122,12 +113,3 @@ void FolderLayerWrapper::removeAllChild()
|
||||||
{
|
{
|
||||||
children.clear();
|
children.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace LayerEvent
|
|
||||||
{
|
|
||||||
|
|
||||||
static void onDoubleClick(QTreeWidgetItem *qItem, LayerWrapper *layerWrapper)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace LayerEvent
|
|
||||||
|
|
|
@ -7,9 +7,7 @@
|
||||||
#include <QGraphicsScene>
|
#include <QGraphicsScene>
|
||||||
#include <QJSonObject>
|
#include <QJSonObject>
|
||||||
#include <QLine>
|
#include <QLine>
|
||||||
#include <QObject>
|
|
||||||
#include <QPoint>
|
#include <QPoint>
|
||||||
#include <QTreeWidget>
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
using std::shared_ptr;
|
using std::shared_ptr;
|
||||||
|
@ -21,7 +19,6 @@ class ElementManager;
|
||||||
|
|
||||||
class LayerWrapper
|
class LayerWrapper
|
||||||
{
|
{
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
shared_ptr<LayerWrapper> parent;
|
shared_ptr<LayerWrapper> parent;
|
||||||
QPointF referencePoint;
|
QPointF referencePoint;
|
||||||
|
@ -29,7 +26,6 @@ class LayerWrapper
|
||||||
QPainterPath cache;
|
QPainterPath cache;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QTreeWidgetItem *qTreeItem;
|
|
||||||
struct SimpleProperty
|
struct SimpleProperty
|
||||||
{
|
{
|
||||||
QString name = "";
|
QString name = "";
|
||||||
|
@ -46,11 +42,6 @@ class LayerWrapper
|
||||||
LayerWrapper *getParent() const; // invoke by manager, then invoke parent's applyStyles
|
LayerWrapper *getParent() const; // invoke by manager, then invoke parent's applyStyles
|
||||||
LayerWrapper(QJsonObject json, LayerWrapper *parent);
|
LayerWrapper(QJsonObject json, LayerWrapper *parent);
|
||||||
LayerWrapper() = default;
|
LayerWrapper() = default;
|
||||||
// TODO : export Function
|
|
||||||
// virtual LayerWrapper *addChild() = 0; // Leaf Child Only
|
|
||||||
// virtual LayerWrapper *addParent() = 0; // Folder Parent Only
|
|
||||||
// virtual void deleteSelf() const = 0;
|
|
||||||
// virtual void deleteAll() const = 0;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class FolderLayerWrapper : public LayerWrapper
|
class FolderLayerWrapper : public LayerWrapper
|
||||||
|
@ -77,5 +68,3 @@ class LeafLayerWrapper : public LayerWrapper
|
||||||
LeafLayerWrapper() = default;
|
LeafLayerWrapper() = default;
|
||||||
LeafLayerWrapper(QJsonObject json, ElementManager *elementManager, LayerWrapper *parent);
|
LeafLayerWrapper(QJsonObject json, ElementManager *elementManager, LayerWrapper *parent);
|
||||||
};
|
};
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(LayerWrapper *)
|
|
||||||
|
|
Loading…
Reference in New Issue