回滚到e19aac0dd2
parent
4eba93a4f7
commit
685df86863
|
@ -105,8 +105,6 @@
|
|||
<ClCompile Include="src\Editor\LayerManager.cpp" />
|
||||
<ClCompile Include="src\Editor\LayerWrapper.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\util\SvgFileLoader.cpp" />
|
||||
<ClCompile Include="src\IconWidget.cpp" />
|
||||
|
@ -164,8 +162,6 @@
|
|||
<None Include="Shaders\ssgi.comp" />
|
||||
</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_p.h" />
|
||||
<ClInclude Include="src\Editor\third-party modules\qquick\qquicksvgparser_p.h" />
|
||||
|
|
|
@ -173,13 +173,6 @@
|
|||
</ClCompile>
|
||||
<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>
|
||||
</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 Include="src\Renderer\Painting\ElementStyle.cpp">
|
||||
<Filter>Source Files\Renderer\Painting</Filter>
|
||||
|
@ -213,12 +206,6 @@
|
|||
<QtMoc Include="src\Editor\PreviewWindow.h">
|
||||
<Filter>Header Files\Editor</Filter>
|
||||
</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>
|
||||
<None Include="Shaders\shader.frag">
|
||||
|
@ -346,6 +333,9 @@
|
|||
<ClInclude Include="src\Editor\ElementManager.h">
|
||||
<Filter>Header Files\Editor</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\Editor\LayerWrapper.h">
|
||||
<Filter>Header Files\Editor</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\Renderer\Painting\LineTree.h">
|
||||
<Filter>Header Files\Renderer\Painting</Filter>
|
||||
</ClInclude>
|
||||
|
@ -370,13 +360,6 @@
|
|||
<ClInclude Include="src\Renderer\Painting\ElementStyle.h">
|
||||
<Filter>Header Files\Renderer\Painting</Filter>
|
||||
</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>
|
||||
<QtRcc Include="MainWindow.qrc">
|
||||
|
|
|
@ -27,60 +27,18 @@
|
|||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QWidget" name="MainWindow" native="true">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2" stretch="1,30">
|
||||
<item>
|
||||
<widget class="QLabel" name="Title">
|
||||
<property name="text">
|
||||
<string>纹理编辑</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout" stretch="1,18,5">
|
||||
<item>
|
||||
<widget class="QWidget" name="LeftBar" native="true"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="PreviewWindow" name="Preview"/>
|
||||
</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>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3" stretch="1,30">
|
||||
<item>
|
||||
<widget class="QLabel" name="title">
|
||||
<property name="text">
|
||||
<string>纹理编辑</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="PreviewWindow" name="Preview"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
|
@ -91,17 +49,6 @@
|
|||
<extends>QOpenGLWidget</extends>
|
||||
<header>PreviewWindow.h</header>
|
||||
</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>
|
||||
<resources/>
|
||||
<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 hitElement = false;
|
||||
|
|
|
@ -2,19 +2,10 @@
|
|||
|
||||
EditorWidget::EditorWidget(QWidget *parent) : QWidget(parent)
|
||||
{
|
||||
displayLayer = nullptr;
|
||||
displayElement = nullptr;
|
||||
ui.setupUi(this);
|
||||
previewWindow = ui.Preview;
|
||||
treeWidget = ui.LayerTree;
|
||||
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
|
||||
qDebug() << "123";
|
||||
// test
|
||||
QFile settingFile;
|
||||
settingFile.setFileName("../data.json");
|
||||
settingFile.open(QFile::ReadOnly);
|
||||
|
@ -28,10 +19,6 @@ EditorWidget::EditorWidget(QWidget *parent) : QWidget(parent)
|
|||
elementManager = new ElementManager(source);
|
||||
layerManager = new LayerManager(source, elementManager);
|
||||
previewWindow->initialize(layerManager);
|
||||
if (layerManager->getRoot() != nullptr)
|
||||
{
|
||||
treeWidget->addTopLevelItem(layerManager->getRoot()->qTreeItem);
|
||||
}
|
||||
}
|
||||
|
||||
EditorWidget::~EditorWidget()
|
||||
|
@ -41,16 +28,3 @@ EditorWidget::~EditorWidget()
|
|||
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
|
||||
|
||||
#include "ElementManager.h"
|
||||
#include "InfoDisplayWidget.h"
|
||||
#include "LayerManager.h"
|
||||
#include "LayerTreeWidget.h"
|
||||
#include "PreviewWindow.h"
|
||||
#include "ui_EditorWidget.h"
|
||||
#include <QPainter>
|
||||
#include <QTreeWidget>
|
||||
#include <QWidget>
|
||||
|
||||
class EditorWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private:
|
||||
// DATA PART
|
||||
Ui::EditorWidgetClass ui;
|
||||
PreviewWindow *previewWindow;
|
||||
ElementManager *elementManager;
|
||||
LayerManager *layerManager;
|
||||
// QT GUI PART
|
||||
Ui::EditorWidgetClass ui;
|
||||
LayerTreeWidget *treeWidget;
|
||||
QTabWidget *tabWidget;
|
||||
InfoDisplayWidget *layerInfoDisplayWidget, *elementInfoDisplayWidget;
|
||||
// QT DATA PART
|
||||
LayerWrapper *displayLayer;
|
||||
GraphicElement *displayElement;
|
||||
|
||||
public:
|
||||
EditorWidget(QWidget *parent = nullptr);
|
||||
~EditorWidget();
|
||||
void paintEvent(QPaintEvent *event) override;
|
||||
|
||||
private slots:
|
||||
void onLayerChange(LayerWrapper *layer);
|
||||
void triggerRefreshPreview();
|
||||
};
|
||||
|
|
|
@ -11,14 +11,12 @@ void SimpleElement::loadSvgFile(const QString& filePath)
|
|||
// TODO ÑùʽÎÊÌâ
|
||||
SvgFileLoader loader;
|
||||
loader.loadSvgFile(filePath, painterPath);
|
||||
qDebug() << "load svg file success "<<painterPath.elementCount();
|
||||
}
|
||||
|
||||
SimpleElement::SimpleElement(QJsonObject jsonSource) : jsonSource(jsonSource)
|
||||
{
|
||||
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)
|
||||
|
|
|
@ -7,10 +7,6 @@ LayerManager::LayerManager(QJsonObject source, ElementManager *elementManager)
|
|||
else
|
||||
root = new LeafLayerWrapper(rootJson, elementManager, nullptr);
|
||||
}
|
||||
LayerWrapper *LayerManager::getRoot() const
|
||||
{
|
||||
return root;
|
||||
}
|
||||
void LayerManager::paint(QPainter *painter) const
|
||||
{
|
||||
painter->drawPath(root->getCache());
|
||||
|
@ -61,11 +57,3 @@ bool LayerManager::changeParent(FolderLayerWrapper *newParent) const
|
|||
selectedLayers[0]->setParent(newParent);
|
||||
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 <QJsonArray>
|
||||
#include <QPainter>
|
||||
#include <set>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
using std::pair;
|
||||
using std::set;
|
||||
using std::vector;
|
||||
class ElementManager;
|
||||
class LayerWrapper;
|
||||
|
@ -23,13 +21,8 @@ class LayerManager
|
|||
LayerPtrs involvedLeafLayersCache;
|
||||
bool singleSelectedCheck() const;
|
||||
bool multipleSelectedCheck() const;
|
||||
set<LayerWrapper *> layerSet;
|
||||
|
||||
public:
|
||||
void addLayer(LayerWrapper *layer);
|
||||
void removeLayer(LayerWrapper *layer);
|
||||
LayerWrapper *getRoot() const;
|
||||
LayerManager() = default;
|
||||
LayerManager(QJsonObject source, ElementManager *elementManager);
|
||||
void paint(QPainter *painter) const;
|
||||
bool rename(QString newName) const;
|
||||
|
|
|
@ -33,23 +33,15 @@ LayerWrapper::LayerWrapper(QJsonObject json, LayerWrapper *parent)
|
|||
{
|
||||
this->parent = shared_ptr<LayerWrapper>(parent);
|
||||
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.scale = {transformJson.value("scale").toObject().value("x").toDouble(),
|
||||
transformJson.value("scale").toObject().value("y").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));
|
||||
property.offset = { transformJson.value("offset").toObject().value("x").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()};
|
||||
}
|
||||
|
||||
FolderLayerWrapper::FolderLayerWrapper(QJsonObject json, ElementManager *elementManager, LayerWrapper *parent)
|
||||
: LayerWrapper(json, parent)
|
||||
{
|
||||
qDebug() << json.value("name").toString() << " " << this;
|
||||
qDebug() << json.value("name").toString()<<" "<<this;
|
||||
QJsonArray childrenJson = json.value("children").toArray();
|
||||
QJsonValue referencedJson = json.value("referenced-by");
|
||||
if (!referencedJson.isNull())
|
||||
|
@ -79,16 +71,16 @@ LeafLayerWrapper::LeafLayerWrapper(QJsonObject json, ElementManager *elementMana
|
|||
void LayerWrapper::SimpleProperty::apply(QPainterPath &cache) const
|
||||
{
|
||||
QTransform trans;
|
||||
double centerX = cache.boundingRect().center().x();
|
||||
double centerY = cache.boundingRect().center().y();
|
||||
qDebug() << name << " " << cache.boundingRect().center();
|
||||
qDebug() << name << " " << cache.boundingRect();
|
||||
trans.translate(centerX, centerY);
|
||||
double delX = cache.boundingRect().width();
|
||||
double delY = cache.boundingRect().height();
|
||||
trans.translate(-delX,-delY);
|
||||
trans.scale(scale.x(), scale.y());
|
||||
trans.rotate(rotation);
|
||||
trans.translate(-centerX, -centerY);
|
||||
trans.translate(offset.x(), offset.y());
|
||||
cache = trans.map(cache);
|
||||
trans.reset();
|
||||
trans.translate(delX+offset.x(), delY+offset.y());
|
||||
cache = trans.map(cache);
|
||||
// cache.translate(offset);
|
||||
}
|
||||
void LayerWrapper::refresh()
|
||||
{
|
||||
|
@ -106,8 +98,7 @@ void FolderLayerWrapper::refresh()
|
|||
void LeafLayerWrapper::refresh()
|
||||
{
|
||||
cache.clear();
|
||||
if (wrappedElement != nullptr)
|
||||
{
|
||||
if (wrappedElement != nullptr) {
|
||||
cache.addPath(wrappedElement->getPaintObject());
|
||||
}
|
||||
LayerWrapper::refresh();
|
||||
|
@ -122,12 +113,3 @@ void FolderLayerWrapper::removeAllChild()
|
|||
{
|
||||
children.clear();
|
||||
}
|
||||
|
||||
namespace LayerEvent
|
||||
{
|
||||
|
||||
static void onDoubleClick(QTreeWidgetItem *qItem, LayerWrapper *layerWrapper)
|
||||
{
|
||||
}
|
||||
|
||||
} // namespace LayerEvent
|
||||
|
|
|
@ -7,9 +7,7 @@
|
|||
#include <QGraphicsScene>
|
||||
#include <QJSonObject>
|
||||
#include <QLine>
|
||||
#include <QObject>
|
||||
#include <QPoint>
|
||||
#include <QTreeWidget>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
using std::shared_ptr;
|
||||
|
@ -21,7 +19,6 @@ class ElementManager;
|
|||
|
||||
class LayerWrapper
|
||||
{
|
||||
|
||||
protected:
|
||||
shared_ptr<LayerWrapper> parent;
|
||||
QPointF referencePoint;
|
||||
|
@ -29,7 +26,6 @@ class LayerWrapper
|
|||
QPainterPath cache;
|
||||
|
||||
public:
|
||||
QTreeWidgetItem *qTreeItem;
|
||||
struct SimpleProperty
|
||||
{
|
||||
QString name = "";
|
||||
|
@ -46,11 +42,6 @@ class LayerWrapper
|
|||
LayerWrapper *getParent() const; // invoke by manager, then invoke parent's applyStyles
|
||||
LayerWrapper(QJsonObject json, LayerWrapper *parent);
|
||||
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
|
||||
|
@ -77,5 +68,3 @@ class LeafLayerWrapper : public LayerWrapper
|
|||
LeafLayerWrapper() = default;
|
||||
LeafLayerWrapper(QJsonObject json, ElementManager *elementManager, LayerWrapper *parent);
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE(LayerWrapper *)
|
||||
|
|
Loading…
Reference in New Issue