Compare commits
No commits in common. "7ff8fd90c0e399b63f70ee61aac3f06e492d762b" and "744ae58743b0c045795c0805a399e6774fa33a3f" have entirely different histories.
7ff8fd90c0
...
744ae58743
|
@ -104,7 +104,6 @@
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="src\Editor\EditorWidgetComponent\ColorPicker.cpp" />
|
|
||||||
<ClCompile Include="src\Editor\EditorWidgetComponent\LayerCreateWidget.cpp" />
|
<ClCompile Include="src\Editor\EditorWidgetComponent\LayerCreateWidget.cpp" />
|
||||||
<ClCompile Include="src\Editor\EditorWidgetComponent\LayerStyleDialog.cpp" />
|
<ClCompile Include="src\Editor\EditorWidgetComponent\LayerStyleDialog.cpp" />
|
||||||
<ClCompile Include="src\Editor\EditorWidget.cpp" />
|
<ClCompile Include="src\Editor\EditorWidget.cpp" />
|
||||||
|
@ -146,14 +145,12 @@
|
||||||
<ClCompile Include="src\Renderer\Painting\MaterialStyleStroke.cpp" />
|
<ClCompile Include="src\Renderer\Painting\MaterialStyleStroke.cpp" />
|
||||||
<ClCompile Include="src\Renderer\Painting\Painting.cpp" />
|
<ClCompile Include="src\Renderer\Painting\Painting.cpp" />
|
||||||
<ClCompile Include="src\Renderer\PaintingMesh.cpp" />
|
<ClCompile Include="src\Renderer\PaintingMesh.cpp" />
|
||||||
<ClCompile Include="src\Renderer\Preview\ElementRenderer.cpp" />
|
|
||||||
<ClCompile Include="src\Renderer\RendererGLWidget.cpp" />
|
<ClCompile Include="src\Renderer\RendererGLWidget.cpp" />
|
||||||
<ClCompile Include="src\Renderer\RendererWidget.cpp" />
|
<ClCompile Include="src\Renderer\RendererWidget.cpp" />
|
||||||
<ClCompile Include="src\Renderer\Painting\ShortCutTree.cpp" />
|
<ClCompile Include="src\Renderer\Painting\ShortCutTree.cpp" />
|
||||||
<ClCompile Include="src\Renderer\Painting\StraightLine.cpp" />
|
<ClCompile Include="src\Renderer\Painting\StraightLine.cpp" />
|
||||||
<ClCompile Include="src\Renderer\VirtualTextureManager.cpp" />
|
<ClCompile Include="src\Renderer\VirtualTextureManager.cpp" />
|
||||||
<ClCompile Include="src\SvgParser.cpp" />
|
<ClCompile Include="src\SvgParser.cpp" />
|
||||||
<ClCompile Include="src\Editor\EditorWidgetComponent\StrokeStyleListView.cpp" />
|
|
||||||
<QtUic Include="EditorWidget.ui" />
|
<QtUic Include="EditorWidget.ui" />
|
||||||
<QtUic Include="EditorWidgetItem.ui" />
|
<QtUic Include="EditorWidgetItem.ui" />
|
||||||
<QtUic Include="MainWindow.ui" />
|
<QtUic Include="MainWindow.ui" />
|
||||||
|
@ -189,14 +186,12 @@
|
||||||
<None Include="res\Shaders\ssgi.comp" />
|
<None Include="res\Shaders\ssgi.comp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<QtMoc Include="src\Editor\EditorWidgetComponent\StrokeStyleListView.h" />
|
|
||||||
<QtMoc Include="src\Editor\RightBar\LayerTreeWidget.h" />
|
<QtMoc Include="src\Editor\RightBar\LayerTreeWidget.h" />
|
||||||
<QtMoc Include="src\Editor\RightBar\InfoDisplayWidget.h" />
|
<QtMoc Include="src\Editor\RightBar\InfoDisplayWidget.h" />
|
||||||
<QtMoc Include="src\MainWindow.h" />
|
<QtMoc Include="src\MainWindow.h" />
|
||||||
<QtMoc Include="src\Editor\EditorWidget.h" />
|
<QtMoc Include="src\Editor\EditorWidget.h" />
|
||||||
<QtMoc Include="src\Editor\EditorWidgetComponent\LayerCreateWidget.h" />
|
<QtMoc Include="src\Editor\EditorWidgetComponent\LayerCreateWidget.h" />
|
||||||
<QtMoc Include="src\Editor\EditorWidgetComponent\LayerStyleDialog.h" />
|
<QtMoc Include="src\Editor\EditorWidgetComponent\LayerStyleDialog.h" />
|
||||||
<QtMoc Include="src\Editor\EditorWidgetComponent\ColorPicker.h" />
|
|
||||||
<ClInclude Include="src\Editor\ElementManager.h" />
|
<ClInclude Include="src\Editor\ElementManager.h" />
|
||||||
<QtMoc Include="src\Editor\ElementPoolWidget.h" />
|
<QtMoc Include="src\Editor\ElementPoolWidget.h" />
|
||||||
<ClInclude Include="src\Editor\GraphicElement.h" />
|
<ClInclude Include="src\Editor\GraphicElement.h" />
|
||||||
|
|
|
@ -59,18 +59,9 @@
|
||||||
<Filter Include="Source Files\Editor\util">
|
<Filter Include="Source Files\Editor\util">
|
||||||
<UniqueIdentifier>{96f98afe-4250-44cb-a505-682a1d5932c3}</UniqueIdentifier>
|
<UniqueIdentifier>{96f98afe-4250-44cb-a505-682a1d5932c3}</UniqueIdentifier>
|
||||||
</Filter>
|
</Filter>
|
||||||
<Filter Include="Source Files\Renderer\Preview">
|
|
||||||
<UniqueIdentifier>{2a8e109f-7791-46ad-8c86-fe22a651cbe7}</UniqueIdentifier>
|
|
||||||
</Filter>
|
|
||||||
<Filter Include="Header Files\Renderer\Preview">
|
<Filter Include="Header Files\Renderer\Preview">
|
||||||
<UniqueIdentifier>{7ead1a66-586a-4584-ae80-9e7a4e667364}</UniqueIdentifier>
|
<UniqueIdentifier>{7ead1a66-586a-4584-ae80-9e7a4e667364}</UniqueIdentifier>
|
||||||
</Filter>
|
</Filter>
|
||||||
<Filter Include="Header Files\Editor\Style">
|
|
||||||
<UniqueIdentifier>{be3f4585-c8ba-410f-8619-2adcd4349f02}</UniqueIdentifier>
|
|
||||||
</Filter>
|
|
||||||
<Filter Include="Source Files\Editor\Style">
|
|
||||||
<UniqueIdentifier>{b9732a33-aa2e-4f8d-886f-1b1730c66519}</UniqueIdentifier>
|
|
||||||
</Filter>
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<QtUic Include="MainWindow.ui">
|
<QtUic Include="MainWindow.ui">
|
||||||
|
@ -117,6 +108,9 @@
|
||||||
<ClCompile Include="src\Renderer\RendererWidget.cpp">
|
<ClCompile Include="src\Renderer\RendererWidget.cpp">
|
||||||
<Filter>Source Files\Renderer</Filter>
|
<Filter>Source Files\Renderer</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="src\NavigationBarWidget.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
<ClCompile Include="src\Renderer\Painting\BvhTree.cpp">
|
<ClCompile Include="src\Renderer\Painting\BvhTree.cpp">
|
||||||
<Filter>Source Files\Renderer\Painting</Filter>
|
<Filter>Source Files\Renderer\Painting</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
@ -159,6 +153,12 @@
|
||||||
<ClCompile Include="src\Renderer\Painting\CubicBezierSignedDistance.cpp">
|
<ClCompile Include="src\Renderer\Painting\CubicBezierSignedDistance.cpp">
|
||||||
<Filter>Source Files\Renderer\Painting</Filter>
|
<Filter>Source Files\Renderer\Painting</Filter>
|
||||||
</ClCompile>
|
</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">
|
<ClCompile Include="src\Renderer\Painting\ElementStyle.cpp">
|
||||||
<Filter>Source Files\Renderer\Painting</Filter>
|
<Filter>Source Files\Renderer\Painting</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
@ -183,8 +183,8 @@
|
||||||
<ClCompile Include="src\Editor\util\PainterPathUtil.cpp">
|
<ClCompile Include="src\Editor\util\PainterPathUtil.cpp">
|
||||||
<Filter>Source Files\Editor\util</Filter>
|
<Filter>Source Files\Editor\util</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="src\Renderer\Preview\ElementRenderer.cpp">
|
<ClCompile Include="src\Editor\LayerStyle.cpp">
|
||||||
<Filter>Source Files\Renderer\Preview</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="src\Renderer\IblUtils.cpp">
|
<ClCompile Include="src\Renderer\IblUtils.cpp">
|
||||||
<Filter>Source Files\Renderer</Filter>
|
<Filter>Source Files\Renderer</Filter>
|
||||||
|
@ -210,29 +210,11 @@
|
||||||
<ClCompile Include="src\Editor\util\PaintingUtil.cpp">
|
<ClCompile Include="src\Editor\util\PaintingUtil.cpp">
|
||||||
<Filter>Source Files\Editor\util</Filter>
|
<Filter>Source Files\Editor\util</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="src\Editor\LayerStyle.cpp">
|
<ClCompile Include="src\Editor\EditorWidgetComponent\LayerCreateWidget.cpp">
|
||||||
<Filter>Source Files\Editor\Style</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="src\Editor\EditorWidgetComponent\LayerStyleDialog.cpp">
|
<ClCompile Include="src\Editor\EditorWidgetComponent\LayerStyleDialog.cpp">
|
||||||
<Filter>Source Files\Editor\Style</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="src\Editor\EditorWidgetComponent\StrokeStyleListView.cpp">
|
|
||||||
<Filter>Source Files\Editor\Style</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="src\Editor\RightBar\InfoDisplayWidget.cpp">
|
|
||||||
<Filter>Source Files\Editor</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="src\Editor\EditorWidgetComponent\LayerCreateWidget.cpp">
|
|
||||||
<Filter>Source Files\Editor</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="src\Editor\RightBar\LayerTreeWidget.cpp">
|
|
||||||
<Filter>Source Files\Editor</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="src\NavigationBarWidget.cpp">
|
|
||||||
<Filter>Source Files\Editor</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="src\Editor\EditorWidgetComponent\ColorPicker.cpp">
|
|
||||||
<Filter>Source Files\Editor</Filter>
|
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -245,41 +227,35 @@
|
||||||
<QtMoc Include="src\Renderer\RendererWidget.h">
|
<QtMoc Include="src\Renderer\RendererWidget.h">
|
||||||
<Filter>Header Files\Renderer</Filter>
|
<Filter>Header Files\Renderer</Filter>
|
||||||
</QtMoc>
|
</QtMoc>
|
||||||
|
<QtMoc Include="src\NavigationBarWidget.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</QtMoc>
|
||||||
|
<QtMoc Include="src\MainWindow.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</QtMoc>
|
||||||
<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>
|
||||||
|
<QtMoc Include="src\Editor\EditorWidget.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</QtMoc>
|
||||||
<QtMoc Include="src\Editor\ElementPoolWidget.h">
|
<QtMoc Include="src\Editor\ElementPoolWidget.h">
|
||||||
<Filter>Header Files\Editor</Filter>
|
<Filter>Header Files\Editor</Filter>
|
||||||
</QtMoc>
|
</QtMoc>
|
||||||
<QtMoc Include="src\FluentMenu.h">
|
<QtMoc Include="src\FluentMenu.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</QtMoc>
|
</QtMoc>
|
||||||
<QtMoc Include="src\Editor\EditorWidgetComponent\StrokeStyleListView.h">
|
<QtMoc Include="src\Editor\EditorWidgetComponent\LayerCreateWidget.h">
|
||||||
<Filter>Header Files\Editor\Style</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</QtMoc>
|
</QtMoc>
|
||||||
<QtMoc Include="src\Editor\EditorWidgetComponent\LayerStyleDialog.h">
|
<QtMoc Include="src\Editor\EditorWidgetComponent\LayerStyleDialog.h">
|
||||||
<Filter>Header Files\Editor\Style</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</QtMoc>
|
|
||||||
<QtMoc Include="src\Editor\RightBar\InfoDisplayWidget.h">
|
|
||||||
<Filter>Header Files\Editor</Filter>
|
|
||||||
</QtMoc>
|
|
||||||
<QtMoc Include="src\Editor\EditorWidgetComponent\LayerCreateWidget.h">
|
|
||||||
<Filter>Header Files\Editor</Filter>
|
|
||||||
</QtMoc>
|
|
||||||
<QtMoc Include="src\Editor\EditorWidget.h">
|
|
||||||
<Filter>Header Files\Editor</Filter>
|
|
||||||
</QtMoc>
|
|
||||||
<QtMoc Include="src\Editor\RightBar\LayerTreeWidget.h">
|
|
||||||
<Filter>Header Files\Editor</Filter>
|
|
||||||
</QtMoc>
|
|
||||||
<QtMoc Include="src\MainWindow.h">
|
|
||||||
<Filter>Header Files\Editor</Filter>
|
|
||||||
</QtMoc>
|
|
||||||
<QtMoc Include="src\NavigationBarWidget.h">
|
|
||||||
<Filter>Header Files\Editor</Filter>
|
|
||||||
</QtMoc>
|
|
||||||
<QtMoc Include="src\Editor\EditorWidgetComponent\ColorPicker.h">
|
|
||||||
<Filter>Header Files\Editor</Filter>
|
|
||||||
</QtMoc>
|
</QtMoc>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -475,7 +451,7 @@
|
||||||
<Filter>Header Files\Editor\util</Filter>
|
<Filter>Header Files\Editor\util</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="src\Editor\LayerStyle.h">
|
<ClInclude Include="src\Editor\LayerStyle.h">
|
||||||
<Filter>Header Files\Editor\Style</Filter>
|
<Filter>Header Files\Editor</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>1473</width>
|
<width>1124</width>
|
||||||
<height>1103</height>
|
<height>1010</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
|
@ -56,20 +56,7 @@
|
||||||
<widget class="QWidget" name="LeftBar" native="true"/>
|
<widget class="QWidget" name="LeftBar" native="true"/>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="PreviewWindow" name="Preview">
|
<widget class="PreviewWindow" name="Preview"/>
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>1080</width>
|
|
||||||
<height>1080</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="maximumSize">
|
|
||||||
<size>
|
|
||||||
<width>1080</width>
|
|
||||||
<height>1080</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QWidget" name="RightBar" native="true">
|
<widget class="QWidget" name="RightBar" native="true">
|
||||||
|
|
|
@ -1190,7 +1190,7 @@ void main()
|
||||||
//imageStore(gBaseColor, pixelLocation, vec4(uv,1,1));
|
//imageStore(gBaseColor, pixelLocation, vec4(uv,1,1));
|
||||||
//imageStore(gMetallicRoughness, pixelLocation, vec4(uv,1,1));
|
//imageStore(gMetallicRoughness, pixelLocation, vec4(uv,1,1));
|
||||||
//return;
|
//return;
|
||||||
uv = uv*2-vec2(1);
|
uv = vec2(1)-uv*2;
|
||||||
//vec2 uv = imageLoad(gPaintingTexCoord, pixelLocation).rg;
|
//vec2 uv = imageLoad(gPaintingTexCoord, pixelLocation).rg;
|
||||||
|
|
||||||
vec3 debugBVH = vec3(0);
|
vec3 debugBVH = vec3(0);
|
||||||
|
|
|
@ -1,38 +0,0 @@
|
||||||
#include "ColorPicker.h"
|
|
||||||
#include <QColorDialog>
|
|
||||||
|
|
||||||
QString getStyleSheet(const QColor& color)
|
|
||||||
{
|
|
||||||
return
|
|
||||||
"QPushButton#colorPicker {"
|
|
||||||
" border-style: solid;"
|
|
||||||
" border-width: 1px;"
|
|
||||||
" border-color: black;"
|
|
||||||
" background-color: " + color.name() + ";"
|
|
||||||
"}";
|
|
||||||
}
|
|
||||||
|
|
||||||
ColorPicker::ColorPicker(const QColor& color, QWidget* parent) : QPushButton(parent), color(color)
|
|
||||||
{
|
|
||||||
this->setObjectName("colorPicker");
|
|
||||||
this->setStyleSheet(getStyleSheet(color));
|
|
||||||
connect(this, &QPushButton::clicked, this, &ColorPicker::onClicked);
|
|
||||||
}
|
|
||||||
|
|
||||||
QColor ColorPicker::getColor() const
|
|
||||||
{
|
|
||||||
return color;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ColorPicker::onClicked()
|
|
||||||
{
|
|
||||||
QColorDialog dialog(this->color, this);
|
|
||||||
dialog.exec();
|
|
||||||
QColor newColor = dialog.selectedColor();
|
|
||||||
if (newColor.isValid() && this->color != newColor)
|
|
||||||
{
|
|
||||||
this->color = newColor;
|
|
||||||
this->setStyleSheet(getStyleSheet(newColor));
|
|
||||||
emit colorChanged(newColor);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,16 +0,0 @@
|
||||||
#pragma once
|
|
||||||
#include <QPushButton>
|
|
||||||
class ColorPicker : public QPushButton
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
private:
|
|
||||||
QColor color;
|
|
||||||
public:
|
|
||||||
ColorPicker(const QColor& color, QWidget* parent = nullptr);
|
|
||||||
QColor getColor() const;
|
|
||||||
public slots:
|
|
||||||
void onClicked();
|
|
||||||
signals:
|
|
||||||
void colorChanged(QColor newColor);
|
|
||||||
};
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ LayerStyleDialog::LayerStyleDialog(
|
||||||
|
|
||||||
if (existedStyle)
|
if (existedStyle)
|
||||||
{
|
{
|
||||||
this->modifyingStyle = existedStyle->clone();
|
this->modifyingStyle = existedStyle->clonePtr();
|
||||||
|
|
||||||
this->styleContainer = nullptr;
|
this->styleContainer = nullptr;
|
||||||
this->styleWidget = modifyingStyle->getInputWidget();
|
this->styleWidget = modifyingStyle->getInputWidget();
|
||||||
|
|
|
@ -1,95 +0,0 @@
|
||||||
#include "StrokeStyleListView.h"
|
|
||||||
#include "ColorPicker.h"
|
|
||||||
|
|
||||||
constexpr int COLUMN_WIDTH = 0;
|
|
||||||
constexpr int COLUMN_COLOR = 1;
|
|
||||||
constexpr int COLUMN_METALLIC = 2;
|
|
||||||
constexpr int COLUMN_ROUGHNESS = 3;
|
|
||||||
|
|
||||||
StrokeStyleListView::StrokeStyleListView(
|
|
||||||
std::shared_ptr<Renderer::StrokeRadialGradient> stroke,
|
|
||||||
QWidget* parent
|
|
||||||
) : QTableWidget(parent), stroke(stroke)
|
|
||||||
{
|
|
||||||
this->setSizeAdjustPolicy(QAbstractScrollArea::AdjustToContentsOnFirstShow);
|
|
||||||
this->setColumnCount(4);
|
|
||||||
this->setRowCount(stroke->materialMap.size());
|
|
||||||
QStringList headers;
|
|
||||||
headers.append(QStringLiteral("×ÜÏß¿íÕ¼±È"));
|
|
||||||
headers.append(QStringLiteral("ÑÕÉ«"));
|
|
||||||
headers.append(QStringLiteral("½ðÊô¶È"));
|
|
||||||
headers.append(QStringLiteral("´Ö²Ú¶È"));
|
|
||||||
this->setHorizontalHeaderLabels(headers);
|
|
||||||
for (int row = 0; auto& strokePair : stroke->materialMap)
|
|
||||||
{
|
|
||||||
QTableWidgetItem* widthItem = new QTableWidgetItem;
|
|
||||||
widthItem->setData(Qt::EditRole, strokePair.first);
|
|
||||||
this->setItem(row, COLUMN_WIDTH, widthItem);
|
|
||||||
|
|
||||||
QColor* colorPtr = &(strokePair.second.color);
|
|
||||||
QTableWidgetItem* colorItem = new QTableWidgetItem;
|
|
||||||
colorItem->setData(Qt::DisplayRole, *colorPtr);
|
|
||||||
this->setItem(row, COLUMN_COLOR, colorItem);
|
|
||||||
ColorPicker* colorPicker = new ColorPicker(*colorPtr, this);
|
|
||||||
this->setCellWidget(row, COLUMN_COLOR, colorPicker);
|
|
||||||
connect(colorPicker, &ColorPicker::colorChanged, [this, colorPtr](QColor color) {
|
|
||||||
*colorPtr = color;
|
|
||||||
this->update();
|
|
||||||
});
|
|
||||||
|
|
||||||
QTableWidgetItem* metallicItem = new QTableWidgetItem;
|
|
||||||
metallicItem->setData(Qt::EditRole, strokePair.second.metallic);
|
|
||||||
this->setItem(row, COLUMN_METALLIC, metallicItem);
|
|
||||||
|
|
||||||
QTableWidgetItem* roughnessItem = new QTableWidgetItem;
|
|
||||||
roughnessItem->setData(Qt::EditRole, strokePair.second.roughness);
|
|
||||||
this->setItem(row, COLUMN_ROUGHNESS, roughnessItem);
|
|
||||||
|
|
||||||
row++;
|
|
||||||
}
|
|
||||||
connect(this, &StrokeStyleListView::currentItemChanged, this, &StrokeStyleListView::onCurrentItemChanged);
|
|
||||||
connect(this, &StrokeStyleListView::cellChanged, this, &StrokeStyleListView::onCellChanged);
|
|
||||||
this->adjustSize();
|
|
||||||
}
|
|
||||||
|
|
||||||
void StrokeStyleListView::onCurrentItemChanged(QTableWidgetItem* current, QTableWidgetItem* previous)
|
|
||||||
{
|
|
||||||
int column = current->column();
|
|
||||||
if (column != COLUMN_COLOR)
|
|
||||||
{
|
|
||||||
this->currentItemValue = current->text();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void StrokeStyleListView::onCellChanged(int row, int column)
|
|
||||||
{
|
|
||||||
auto changedItem = this->item(row, column);
|
|
||||||
auto changedItemValue = changedItem->text().toFloat();
|
|
||||||
if (changedItemValue < 0 || 1 < changedItemValue)
|
|
||||||
{
|
|
||||||
changedItem->setData(Qt::EditRole, this->currentItemValue.toFloat());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
auto changedWidth = this->item(row, COLUMN_WIDTH)->text().toFloat();
|
|
||||||
switch (row)
|
|
||||||
{
|
|
||||||
case COLUMN_WIDTH:
|
|
||||||
{
|
|
||||||
float oldWidth = this->currentItemValue.toFloat();
|
|
||||||
auto node = stroke->materialMap.extract(oldWidth);
|
|
||||||
node.key() = changedWidth;
|
|
||||||
stroke->materialMap.insert(std::move(node));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case COLUMN_METALLIC:
|
|
||||||
{
|
|
||||||
stroke->materialMap[changedWidth].metallic = changedItemValue;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case COLUMN_ROUGHNESS:
|
|
||||||
{
|
|
||||||
stroke->materialMap[changedWidth].roughness = changedItemValue;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,21 +0,0 @@
|
||||||
#pragma once
|
|
||||||
#include "LayerStyle.h"
|
|
||||||
#include "../Renderer/Painting/MaterialStyleStroke.h"
|
|
||||||
#include <QListView>
|
|
||||||
#include <QListWidget>
|
|
||||||
#include <QTableWidget>
|
|
||||||
class StrokeStyleListView : public QTableWidget
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
private:
|
|
||||||
QString currentItemValue;
|
|
||||||
|
|
||||||
public:
|
|
||||||
StrokeStyleListView(std::shared_ptr<Renderer::StrokeRadialGradient> stroke, QWidget* parent = nullptr);
|
|
||||||
std::shared_ptr<Renderer::StrokeRadialGradient> stroke;
|
|
||||||
|
|
||||||
protected slots:
|
|
||||||
void onCurrentItemChanged(QTableWidgetItem* current, QTableWidgetItem* previous);
|
|
||||||
void onCellChanged(int row, int column);
|
|
||||||
};
|
|
||||||
|
|
|
@ -14,8 +14,6 @@ EditorWidgetItem::EditorWidgetItem(QString filePath,QWidget *parent) : QWidget(p
|
||||||
elementInfoDisplayWidget = dynamic_cast<ElementPoolWidget *>(tabWidget->widget(1));
|
elementInfoDisplayWidget = dynamic_cast<ElementPoolWidget *>(tabWidget->widget(1));
|
||||||
qDebug() << layerInfoDisplayWidget;
|
qDebug() << layerInfoDisplayWidget;
|
||||||
qDebug() << elementInfoDisplayWidget;
|
qDebug() << elementInfoDisplayWidget;
|
||||||
connect(previewWindow, &PreviewWindow::layerInfoChanged, layerInfoDisplayWidget, &InfoDisplayWidget::triggerSelfRefresh);
|
|
||||||
connect(treeWidget, &LayerTreeWidget::displayLayerChange, previewWindow, &PreviewWindow::currentLayerChanged);
|
|
||||||
connect(treeWidget, &LayerTreeWidget::requireRefreshElementWidget, elementInfoDisplayWidget, &ElementPoolWidget::refresh);
|
connect(treeWidget, &LayerTreeWidget::requireRefreshElementWidget, elementInfoDisplayWidget, &ElementPoolWidget::refresh);
|
||||||
connect(layerInfoDisplayWidget, &InfoDisplayWidget::requireRefreshElementWidget, elementInfoDisplayWidget, &ElementPoolWidget::refresh);
|
connect(layerInfoDisplayWidget, &InfoDisplayWidget::requireRefreshElementWidget, elementInfoDisplayWidget, &ElementPoolWidget::refresh);
|
||||||
connect(treeWidget, &LayerTreeWidget::displayLayerChange, this, &EditorWidgetItem::onLayerChange);
|
connect(treeWidget, &LayerTreeWidget::displayLayerChange, this, &EditorWidgetItem::onLayerChange);
|
||||||
|
@ -59,11 +57,7 @@ EditorWidgetItem::~EditorWidgetItem()
|
||||||
|
|
||||||
void EditorWidgetItem::paintEvent(QPaintEvent *event)
|
void EditorWidgetItem::paintEvent(QPaintEvent *event)
|
||||||
{
|
{
|
||||||
QPainter painter(this);
|
|
||||||
|
|
||||||
// 设置画刷的颜色为灰色,并填充整个窗口区域
|
|
||||||
painter.setBrush(Qt::gray);
|
|
||||||
painter.drawRect(this->rect());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorWidgetItem::onLayerChange(LayerWrapper *layer)
|
void EditorWidgetItem::onLayerChange(LayerWrapper *layer)
|
||||||
|
|
|
@ -11,7 +11,7 @@ PixelPath SimpleElement::getPaintObject() const
|
||||||
|
|
||||||
void SimpleElement::loadSvgFile(const QString& filePath)
|
void SimpleElement::loadSvgFile(const QString& filePath)
|
||||||
{
|
{
|
||||||
// TODO <EFBFBD><EFBFBD>ʽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
// TODO 样式问题
|
||||||
SvgFileLoader loader;
|
SvgFileLoader loader;
|
||||||
loader.loadSvgFile(filePath, painterPath);
|
loader.loadSvgFile(filePath, painterPath);
|
||||||
qDebug() << "load svg file success " << painterPath.elementCount();
|
qDebug() << "load svg file success " << painterPath.elementCount();
|
||||||
|
@ -21,7 +21,7 @@ SimpleElement::SimpleElement(QJsonObject jsonSource) : jsonSource(jsonSource)
|
||||||
{
|
{
|
||||||
painterPath.clear();
|
painterPath.clear();
|
||||||
//loadSvgFile("D:\\Projects\\BigC\\svg\\3.svg");
|
//loadSvgFile("D:\\Projects\\BigC\\svg\\3.svg");
|
||||||
loadSvgFile("../"/*TODO: <EFBFBD>ij<EFBFBD>json<EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><EFBFBD>*/ + jsonSource.value("data").toObject().value("include").toString());
|
loadSvgFile("../"/*TODO: 改成json文件所在文件夹路径*/ + jsonSource.value("data").toObject().value("include").toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
GroupElement::GroupElement(FolderLayerWrapper* sourceLayer)
|
GroupElement::GroupElement(FolderLayerWrapper* sourceLayer)
|
||||||
|
@ -54,12 +54,9 @@ PixelPath SimpleElement::getPaintObject(std::vector<std::shared_ptr<LayerStyle>>
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
style = (*styles)[0];
|
style = (*styles)[0];
|
||||||
/*qDebug() << std::dynamic_pointer_cast<Renderer::StrokePlain>(
|
qDebug() << std::dynamic_pointer_cast<Renderer::StrokePlain>(
|
||||||
std::dynamic_pointer_cast<StrokeElementLayerStyle>(style)->materialStyles[0]->materialStroke
|
std::dynamic_pointer_cast<StrokeElementLayerStyle>(style)->materialStyles[0]->materialStroke
|
||||||
)->material.color.name();*/
|
)->material.color.name();
|
||||||
/*qDebug() << std::dynamic_pointer_cast<Renderer::StrokeRadialGradient>(
|
|
||||||
std::dynamic_pointer_cast<StrokeElementLayerStyle>(style)->materialStyles[0]->materialStroke
|
|
||||||
)->materialMap[1.0].color;*/
|
|
||||||
}
|
}
|
||||||
auto [img, mov] = renderer->drawElement(painterPath, *style, 1.0);
|
auto [img, mov] = renderer->drawElement(painterPath, *style, 1.0);
|
||||||
//qDebug() << img << " ------";
|
//qDebug() << img << " ------";
|
||||||
|
@ -91,34 +88,10 @@ PixelPath GroupElement::getPaintObject(std::vector<std::shared_ptr<LayerStyle>>*
|
||||||
// rawPath.addPath(path);
|
// rawPath.addPath(path);
|
||||||
// }
|
// }
|
||||||
//}
|
//}
|
||||||
//TODO : <EFBFBD><EFBFBD><EFBFBD>ϸ<EFBFBD><EFBFBD>
|
//TODO : 添加细节
|
||||||
QJsonObject GraphicElement::toJson() const
|
QJsonObject GraphicElement::toJson() const
|
||||||
{
|
{
|
||||||
QJsonObject result;
|
QJsonObject result;
|
||||||
result.insert("name", name);
|
result.insert("name", name);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SimpleElement::paint(QPainter* painter, QTransform transform, vector<std::shared_ptr<LayerStyle>> styles)
|
|
||||||
{
|
|
||||||
painter->save();
|
|
||||||
painter->setTransform(transform);
|
|
||||||
if (styles.empty())
|
|
||||||
{
|
|
||||||
painter->drawPath(painterPath);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// TODO:Ӧ<><D3A6>style
|
|
||||||
Renderer::ElementStyleStrokeDemo demo(2);
|
|
||||||
auto [img, mov] = renderer->drawElement(painterPath, demo, 1.0);
|
|
||||||
painter->drawImage(mov, img);
|
|
||||||
}
|
|
||||||
|
|
||||||
painter->restore();
|
|
||||||
}
|
|
||||||
|
|
||||||
void GroupElement::paint(QPainter* painter, QTransform transform, vector<std::shared_ptr<LayerStyle>> styles)
|
|
||||||
{
|
|
||||||
sourceLayer->paint(painter, transform);
|
|
||||||
}
|
|
|
@ -28,7 +28,6 @@ public:
|
||||||
virtual QJsonObject toJson() const;
|
virtual QJsonObject toJson() const;
|
||||||
virtual PixelPath getPaintObject() const = 0;
|
virtual PixelPath getPaintObject() const = 0;
|
||||||
virtual PixelPath getPaintObject(std::vector<std::shared_ptr<LayerStyle>>*) const = 0;
|
virtual PixelPath getPaintObject(std::vector<std::shared_ptr<LayerStyle>>*) const = 0;
|
||||||
virtual void paint(QPainter* painter, QTransform transform, std::vector<std::shared_ptr<LayerStyle>> styles) = 0;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class SimpleElement : public GraphicElement
|
class SimpleElement : public GraphicElement
|
||||||
|
@ -45,7 +44,6 @@ public:
|
||||||
~SimpleElement() = default;
|
~SimpleElement() = default;
|
||||||
PixelPath getPaintObject() const override;
|
PixelPath getPaintObject() const override;
|
||||||
PixelPath getPaintObject(std::vector<std::shared_ptr<LayerStyle>>*) const override;
|
PixelPath getPaintObject(std::vector<std::shared_ptr<LayerStyle>>*) const override;
|
||||||
void paint(QPainter* painter, QTransform transform, std::vector<std::shared_ptr<LayerStyle>> styles) override;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class GroupElement : public GraphicElement
|
class GroupElement : public GraphicElement
|
||||||
|
@ -60,7 +58,6 @@ public:
|
||||||
PixelPath getPaintObject() const override;
|
PixelPath getPaintObject() const override;
|
||||||
PixelPath getPaintObject(std::vector<std::shared_ptr<LayerStyle>>*) const override;
|
PixelPath getPaintObject(std::vector<std::shared_ptr<LayerStyle>>*) const override;
|
||||||
void setSourceLayer(FolderLayerWrapper* sourceLayer);
|
void setSourceLayer(FolderLayerWrapper* sourceLayer);
|
||||||
void paint(QPainter* painter, QTransform transform, std::vector<std::shared_ptr<LayerStyle>> styles) override;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
//******************************** BitmapPath ********************************//
|
//******************************** BitmapPath ********************************//
|
||||||
|
|
|
@ -11,10 +11,10 @@ LayerWrapper *LayerManager::getRoot() const
|
||||||
{
|
{
|
||||||
return root;
|
return root;
|
||||||
}
|
}
|
||||||
void LayerManager::paint(QPainter *painter, QSize size,LayerWrapper* selecetedLayer) const
|
void LayerManager::paint(QPainter *painter, QSize size) const
|
||||||
{
|
{
|
||||||
root->getCache();
|
auto p = root->getCache().resizedPixel(size);
|
||||||
root->paint(painter);
|
painter->drawPixmap(0, 0, p);
|
||||||
}
|
}
|
||||||
bool LayerManager::singleSelectedCheck() const
|
bool LayerManager::singleSelectedCheck() const
|
||||||
{
|
{
|
||||||
|
|
|
@ -32,7 +32,7 @@ class LayerManager
|
||||||
LayerManager() = default;
|
LayerManager() = default;
|
||||||
LayerManager(QJsonObject source, ElementManager* elementManager);
|
LayerManager(QJsonObject source, ElementManager* elementManager);
|
||||||
QJsonObject toJson() const;
|
QJsonObject toJson() const;
|
||||||
void paint(QPainter *painter, QSize size, LayerWrapper* selecetedLayer=nullptr) const;
|
void paint(QPainter *painter, QSize size) const;
|
||||||
bool rename(QString newName) const;
|
bool rename(QString newName) const;
|
||||||
bool combine() const;
|
bool combine() const;
|
||||||
// bool seperate() const;
|
// bool seperate() const;
|
||||||
|
|
|
@ -1,13 +1,10 @@
|
||||||
#include "LayerStyle.h"
|
#include "LayerStyle.h"
|
||||||
#include "./EditorWidgetComponent/StrokeStyleListView.h"
|
|
||||||
#include <qtmaterialcheckbox.h>
|
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
#include <QDialogButtonBox>
|
#include <QDialogButtonBox>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QDebug>
|
|
||||||
|
|
||||||
const std::vector<std::pair<QString, std::function<std::unique_ptr<LayerStyle>()>>> LayerStyle::types = {
|
const std::vector<std::pair<QString, std::function<std::unique_ptr<LayerStyle>()>>> LayerStyle::types = {
|
||||||
{
|
{
|
||||||
|
@ -23,24 +20,10 @@ const std::vector<std::pair<QString, std::function<std::unique_ptr<LayerStyle>()
|
||||||
std::vector<Renderer::BaseStyle> StrokeElementLayerStyle::toBaseStyles() const
|
std::vector<Renderer::BaseStyle> StrokeElementLayerStyle::toBaseStyles() const
|
||||||
{
|
{
|
||||||
std::vector<Renderer::BaseStyle> baseStyles;
|
std::vector<Renderer::BaseStyle> baseStyles;
|
||||||
/*for (auto materialStyle : materialStyles)
|
for (auto materialStyle : materialStyles)
|
||||||
{
|
{
|
||||||
baseStyles.push_back(Renderer::BaseStyle(std::make_shared<Renderer::TransformStyle>(),
|
baseStyles.push_back(Renderer::BaseStyle(std::make_shared<Renderer::TransformStyle>(),
|
||||||
materialStyle));
|
materialStyle));
|
||||||
}*/
|
|
||||||
if (enableEachSideIndependent)
|
|
||||||
{
|
|
||||||
baseStyles.push_back(Renderer::BaseStyle(std::make_shared<Renderer::TransformStyle>(),
|
|
||||||
strokePair.first));
|
|
||||||
baseStyles.push_back(Renderer::BaseStyle(std::make_shared<Renderer::TransformStyle>(),
|
|
||||||
strokePair.second));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
strokePair.first->strokeType = Renderer::StrokeType::kBothSides;
|
|
||||||
baseStyles.push_back(Renderer::BaseStyle(std::make_shared<Renderer::TransformStyle>(),
|
|
||||||
strokePair.first));
|
|
||||||
strokePair.first->strokeType = Renderer::StrokeType::kLeftSide;
|
|
||||||
}
|
}
|
||||||
return baseStyles;
|
return baseStyles;
|
||||||
}
|
}
|
||||||
|
@ -52,61 +35,34 @@ QString StrokeElementLayerStyle::getStyleName() const
|
||||||
|
|
||||||
QWidget* StrokeElementLayerStyle::getInputWidget()
|
QWidget* StrokeElementLayerStyle::getInputWidget()
|
||||||
{
|
{
|
||||||
if (this->strokePair.first == nullptr)
|
// TODO
|
||||||
|
if (this->materialStyles.empty())
|
||||||
{
|
{
|
||||||
auto materialMap = std::map<float, Renderer::Material>();
|
/*auto materialMap = std::map<float, Renderer::Material>();
|
||||||
materialMap[0.3] = Renderer::Material{ QColor(0,255,255), 0.f, .8f };
|
materialMap[1.0] = Renderer::Material{ QColor(0,255,255), 1.0f, 1.0f };
|
||||||
materialMap[1.0] = Renderer::Material{ QColor(80,25,255), 0.f, .8f };
|
this->materialStyles.push_back(std::shared_ptr<Renderer::MaterialStyleStroke>(new Renderer::MaterialStyleStroke(
|
||||||
this->strokePair.first = std::shared_ptr<Renderer::MaterialStyleStroke>(new Renderer::MaterialStyleStroke(
|
0,
|
||||||
15,
|
Renderer::StrokeType::kBothSides, Renderer::StrokeEndType::kFlat,
|
||||||
Renderer::StrokeType::kLeftSide, Renderer::StrokeEndType::kFlat,
|
|
||||||
std::shared_ptr<Renderer::MaterialStroke>(new Renderer::StrokeRadialGradient(
|
|
||||||
materialMap, false
|
|
||||||
))
|
|
||||||
));
|
|
||||||
}
|
|
||||||
if (this->strokePair.second == nullptr)
|
|
||||||
{
|
|
||||||
auto materialMap = std::map<float, Renderer::Material>();
|
|
||||||
materialMap[0.3] = Renderer::Material{ QColor(0,255,255), 0.f, .8f };
|
|
||||||
materialMap[1.0] = Renderer::Material{ QColor(80,25,255), 0.f, .8f };
|
|
||||||
this->strokePair.second = std::shared_ptr<Renderer::MaterialStyleStroke>(new Renderer::MaterialStyleStroke(
|
|
||||||
15,
|
|
||||||
Renderer::StrokeType::kRightSide, Renderer::StrokeEndType::kFlat,
|
|
||||||
std::shared_ptr<Renderer::MaterialStroke>(new Renderer::StrokeRadialGradient(
|
std::shared_ptr<Renderer::MaterialStroke>(new Renderer::StrokeRadialGradient(
|
||||||
materialMap, false
|
materialMap, false
|
||||||
))
|
))
|
||||||
|
)));*/
|
||||||
|
this->materialStyles.push_back(std::make_shared<Renderer::MaterialStyleStroke>(
|
||||||
|
0,
|
||||||
|
Renderer::StrokeType::kBothSides, Renderer::StrokeEndType::kFlat,
|
||||||
|
std::make_shared<Renderer::StrokePlain>(QColor::fromRgb(50, 50, 50), 0, 0.8)
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
QWidget* w = new QWidget;
|
QWidget* w = new QWidget;
|
||||||
QListView* materialList = new QListView;
|
|
||||||
|
|
||||||
QVBoxLayout* layout = new QVBoxLayout(w);
|
QVBoxLayout* layout = new QVBoxLayout(w);
|
||||||
layout->setMargin(0);
|
layout->setMargin(0);
|
||||||
|
QLineEdit* r = new QLineEdit(w), * g = new QLineEdit(w), * b = new QLineEdit(w);
|
||||||
StrokeStyleListView* leftStrokeView = new StrokeStyleListView(
|
layout->addWidget(r);
|
||||||
std::dynamic_pointer_cast<Renderer::StrokeRadialGradient>(this->strokePair.first->materialStroke), w
|
layout->addWidget(g);
|
||||||
);
|
layout->addWidget(b);
|
||||||
layout->addWidget(leftStrokeView);
|
|
||||||
|
|
||||||
QtMaterialCheckBox* checkEachSideIndependent = new QtMaterialCheckBox(w);
|
|
||||||
checkEachSideIndependent->setText(QStringLiteral("ÆôÓÃÁ½²à¶ÀÁ¢Ãè±ß"));
|
|
||||||
checkEachSideIndependent->setChecked(enableEachSideIndependent);
|
|
||||||
layout->addWidget(checkEachSideIndependent);
|
|
||||||
|
|
||||||
StrokeStyleListView* rightStrokeView = new StrokeStyleListView(
|
|
||||||
std::dynamic_pointer_cast<Renderer::StrokeRadialGradient>(this->strokePair.second->materialStroke), w
|
|
||||||
);
|
|
||||||
layout->addWidget(rightStrokeView);
|
|
||||||
rightStrokeView->setDisabled(!this->enableEachSideIndependent);
|
|
||||||
|
|
||||||
QObject::connect(checkEachSideIndependent, &QtMaterialCheckBox::toggled, [this, rightStrokeView](bool toggled) {
|
|
||||||
this->enableEachSideIndependent = toggled;
|
|
||||||
rightStrokeView->setDisabled(!toggled);
|
|
||||||
});
|
|
||||||
//auto stroke = std::dynamic_pointer_cast<Renderer::StrokeRadialGradient>(this->materialStyles[0]->materialStroke);
|
//auto stroke = std::dynamic_pointer_cast<Renderer::StrokeRadialGradient>(this->materialStyles[0]->materialStroke);
|
||||||
//QColor* color = &(stroke->materialMap[1.0].color);
|
//QColor* color = &(stroke->materialMap[1.0].color);
|
||||||
/*auto stroke = std::dynamic_pointer_cast<Renderer::StrokePlain>(this->materialStyles[0]->materialStroke);
|
auto stroke = std::dynamic_pointer_cast<Renderer::StrokePlain>(this->materialStyles[0]->materialStroke);
|
||||||
QColor* color = &(stroke->material.color);
|
QColor* color = &(stroke->material.color);
|
||||||
r->setText(QString::number(color->red()));
|
r->setText(QString::number(color->red()));
|
||||||
g->setText(QString::number(color->green()));
|
g->setText(QString::number(color->green()));
|
||||||
|
@ -128,7 +84,7 @@ QWidget* StrokeElementLayerStyle::getInputWidget()
|
||||||
{
|
{
|
||||||
color->setBlue(content.toInt());
|
color->setBlue(content.toInt());
|
||||||
}
|
}
|
||||||
});*/
|
});
|
||||||
return w;
|
return w;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -145,16 +101,16 @@ QWidget* StrokeElementLayerStyle::getListDisplayWidget() const
|
||||||
|
|
||||||
StrokeElementLayerStyle::StrokeElementLayerStyle(const StrokeElementLayerStyle& other)
|
StrokeElementLayerStyle::StrokeElementLayerStyle(const StrokeElementLayerStyle& other)
|
||||||
{
|
{
|
||||||
strokePair.first = std::dynamic_pointer_cast<MaterialStyleStroke>(
|
materialStyles = std::vector<std::shared_ptr<Renderer::MaterialStyleStroke>>(other.materialStyles.size());
|
||||||
std::shared_ptr<Renderer::MaterialStyle>(std::move(other.strokePair.first->clone()))
|
for (size_t i = 0; i < other.materialStyles.size(); i++)
|
||||||
|
{
|
||||||
|
materialStyles[i] = std::dynamic_pointer_cast<Renderer::MaterialStyleStroke>(
|
||||||
|
std::shared_ptr<Renderer::MaterialStyle>(std::move(other.materialStyles[i]->clone()))
|
||||||
);
|
);
|
||||||
strokePair.second = std::dynamic_pointer_cast<MaterialStyleStroke>(
|
}
|
||||||
std::shared_ptr<Renderer::MaterialStyle>(std::move(other.strokePair.second->clone()))
|
|
||||||
);
|
|
||||||
enableEachSideIndependent = other.enableEachSideIndependent;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<LayerStyle> StrokeElementLayerStyle::clone() const
|
std::unique_ptr<LayerStyle> StrokeElementLayerStyle::clonePtr() const
|
||||||
{
|
{
|
||||||
return std::make_unique<StrokeElementLayerStyle>(StrokeElementLayerStyle(*this));
|
return std::make_unique<StrokeElementLayerStyle>(StrokeElementLayerStyle(*this));
|
||||||
}
|
}
|
||||||
|
@ -197,7 +153,7 @@ FillElementLayerStyle::FillElementLayerStyle(const FillElementLayerStyle& other)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<LayerStyle> FillElementLayerStyle::clone() const
|
std::unique_ptr<LayerStyle> FillElementLayerStyle::clonePtr() const
|
||||||
{
|
{
|
||||||
return std::make_unique<FillElementLayerStyle>(FillElementLayerStyle(*this));
|
return std::make_unique<FillElementLayerStyle>(FillElementLayerStyle(*this));
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,8 +9,6 @@
|
||||||
#include "../Renderer/Painting/MaterialStyleStroke.h"
|
#include "../Renderer/Painting/MaterialStyleStroke.h"
|
||||||
#include "../Renderer/Painting/MaterialStyleFill.h"
|
#include "../Renderer/Painting/MaterialStyleFill.h"
|
||||||
|
|
||||||
using Renderer::MaterialStyleStroke;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 在进行Style的添加时,首先创建空对象,然后直接调用getInputWidget()方法
|
* 在进行Style的添加时,首先创建空对象,然后直接调用getInputWidget()方法
|
||||||
* 在进行Style的修改时,直接调用getInputWidget()方法
|
* 在进行Style的修改时,直接调用getInputWidget()方法
|
||||||
|
@ -26,14 +24,11 @@ public:
|
||||||
virtual QWidget* getInputWidget() = 0;
|
virtual QWidget* getInputWidget() = 0;
|
||||||
virtual QWidget* getListDisplayWidget() const = 0;
|
virtual QWidget* getListDisplayWidget() const = 0;
|
||||||
virtual ~LayerStyle() {};
|
virtual ~LayerStyle() {};
|
||||||
virtual std::unique_ptr<LayerStyle> clone() const = 0;
|
virtual std::unique_ptr<LayerStyle> clonePtr() const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class StrokeElementLayerStyle : public LayerStyle
|
class StrokeElementLayerStyle : public LayerStyle
|
||||||
{
|
{
|
||||||
private:
|
|
||||||
std::pair<std::shared_ptr<MaterialStyleStroke>, std::shared_ptr<MaterialStyleStroke>> strokePair;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
std::vector<Renderer::BaseStyle> toBaseStyles() const override;
|
std::vector<Renderer::BaseStyle> toBaseStyles() const override;
|
||||||
QString getStyleName() const override;
|
QString getStyleName() const override;
|
||||||
|
@ -42,9 +37,8 @@ public:
|
||||||
StrokeElementLayerStyle() = default;
|
StrokeElementLayerStyle() = default;
|
||||||
StrokeElementLayerStyle(const StrokeElementLayerStyle& other);
|
StrokeElementLayerStyle(const StrokeElementLayerStyle& other);
|
||||||
~StrokeElementLayerStyle() = default;
|
~StrokeElementLayerStyle() = default;
|
||||||
std::unique_ptr<LayerStyle> clone() const override;
|
std::vector<std::shared_ptr<Renderer::MaterialStyleStroke>> materialStyles;
|
||||||
|
std::unique_ptr<LayerStyle> clonePtr() const override;
|
||||||
bool enableEachSideIndependent = false;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class FillElementLayerStyle : public LayerStyle
|
class FillElementLayerStyle : public LayerStyle
|
||||||
|
@ -58,5 +52,5 @@ public:
|
||||||
FillElementLayerStyle(const FillElementLayerStyle& other);
|
FillElementLayerStyle(const FillElementLayerStyle& other);
|
||||||
~FillElementLayerStyle() = default;
|
~FillElementLayerStyle() = default;
|
||||||
std::vector<std::shared_ptr<Renderer::MaterialStyleFill>> materialStyles;
|
std::vector<std::shared_ptr<Renderer::MaterialStyleFill>> materialStyles;
|
||||||
std::unique_ptr<LayerStyle> clone() const override;
|
std::unique_ptr<LayerStyle> clonePtr() const override;
|
||||||
};
|
};
|
|
@ -23,13 +23,9 @@ FolderLayerWrapper*LayerWrapper::getParent() const
|
||||||
return this == nullptr ? nullptr : this->parent;
|
return this == nullptr ? nullptr : this->parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
PixelPath LayerWrapper::getCache(LayerWrapper* selectedLayer)
|
PixelPath LayerWrapper::getCache()
|
||||||
{
|
{
|
||||||
this->refresh(selectedLayer);
|
this->refresh();
|
||||||
if (selectedLayer == this)
|
|
||||||
{
|
|
||||||
this->cache.highLight();
|
|
||||||
}
|
|
||||||
return cache;
|
return cache;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,7 +42,6 @@ LayerWrapper::LayerWrapper(QJsonObject json, FolderLayerWrapper*parent, ElementM
|
||||||
property.scale = {transformJson.value("scale").toObject().value("x").toDouble(),
|
property.scale = {transformJson.value("scale").toObject().value("x").toDouble(),
|
||||||
transformJson.value("scale").toObject().value("y").toDouble()};
|
transformJson.value("scale").toObject().value("y").toDouble()};
|
||||||
property.rotation = {transformJson.value("rotation").toDouble()};
|
property.rotation = {transformJson.value("rotation").toDouble()};
|
||||||
selected = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FolderLayerWrapper::FolderLayerWrapper(QJsonObject json, ElementManager *elementManager, FolderLayerWrapper*parent)
|
FolderLayerWrapper::FolderLayerWrapper(QJsonObject json, ElementManager *elementManager, FolderLayerWrapper*parent)
|
||||||
|
@ -80,52 +75,35 @@ LeafLayerWrapper::LeafLayerWrapper(QJsonObject json, ElementManager *elementMana
|
||||||
int elementIndex = json.value("element").toInt();
|
int elementIndex = json.value("element").toInt();
|
||||||
wrappedElement = elementManager->getElementById(elementIndex);
|
wrappedElement = elementManager->getElementById(elementIndex);
|
||||||
}
|
}
|
||||||
|
void LayerWrapper::SimpleProperty::apply(PixelPath&cache) const
|
||||||
void LayerWrapper::SimpleProperty::apply(PixelPath&cache)
|
|
||||||
{
|
|
||||||
transform.reset();
|
|
||||||
double centerX = cache.getBoundingRect().center().x();
|
|
||||||
double centerY = cache.getBoundingRect().center().y();
|
|
||||||
//qDebug() << name << " " << cache.boundingRect().center();
|
|
||||||
//qDebug() << name << " " << cache.boundingRect();
|
|
||||||
transform.translate(centerX, centerY);
|
|
||||||
transform.translate(offset.x(), offset.y());
|
|
||||||
transform.rotate(rotation);
|
|
||||||
transform.scale(scale.x(), scale.y());
|
|
||||||
transform.translate(-centerX, -centerY);
|
|
||||||
cache = cache.trans(transform);
|
|
||||||
}
|
|
||||||
|
|
||||||
QTransform LayerWrapper::getTransform()
|
|
||||||
{
|
{
|
||||||
QTransform trans;
|
QTransform trans;
|
||||||
double centerX = cache.getBoundingRect().center().x();
|
double centerX = cache.getBoundingRect().center().x();
|
||||||
double centerY = cache.getBoundingRect().center().y();
|
double centerY = cache.getBoundingRect().center().y();
|
||||||
//qDebug() << name << " " << cache.boundingRect().center();
|
//qDebug() << name << " " << cache.boundingRect().center();
|
||||||
//qDebug() << name << " " << cache.boundingRect();
|
//qDebug() << name << " " << cache.boundingRect();
|
||||||
trans.translate(centerX, centerY);
|
trans.translate(offset.x(), offset.y());
|
||||||
trans.translate(property.offset.x(), property.offset.y());
|
|
||||||
trans.rotate(property.rotation);
|
|
||||||
trans.scale(property.scale.x(), property.scale.y());
|
|
||||||
trans.translate(-centerX, -centerY);
|
trans.translate(-centerX, -centerY);
|
||||||
return trans;
|
trans.rotate(rotation);
|
||||||
|
trans.scale(scale.x(), scale.y());
|
||||||
|
trans.translate(centerX, centerY);
|
||||||
|
cache = cache.trans(trans);
|
||||||
}
|
}
|
||||||
|
void LayerWrapper::refresh()
|
||||||
void LayerWrapper::refresh(LayerWrapper* layer)
|
|
||||||
{
|
{
|
||||||
property.apply(cache);
|
property.apply(cache);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FolderLayerWrapper::refresh(LayerWrapper* layer)
|
void FolderLayerWrapper::refresh()
|
||||||
{
|
{
|
||||||
cache.clear();
|
cache.clear();
|
||||||
for (auto& child : children) {
|
for (auto& child : children) {
|
||||||
cache.addPath(child.get()->getCache(layer));
|
cache.addPath(child.get()->getCache());
|
||||||
}
|
}
|
||||||
LayerWrapper::refresh();
|
LayerWrapper::refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
void LeafLayerWrapper::refresh(LayerWrapper* layer)
|
void LeafLayerWrapper::refresh()
|
||||||
{
|
{
|
||||||
cache.clear();
|
cache.clear();
|
||||||
if (wrappedElement != nullptr)
|
if (wrappedElement != nullptr)
|
||||||
|
@ -250,36 +228,3 @@ int FolderLayerWrapper::getReferencedBy()const
|
||||||
else
|
else
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LayerWrapper::paint(QPainter* painter, QTransform transform)
|
|
||||||
{
|
|
||||||
if (this->selected)
|
|
||||||
{
|
|
||||||
painter->save();
|
|
||||||
painter->setTransform(transform);
|
|
||||||
painter->setPen(QPen(Qt::gray, 2));
|
|
||||||
painter->setPen(Qt::DashLine);
|
|
||||||
painter->drawRect(cache.getBoundingRect());
|
|
||||||
painter->restore();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void FolderLayerWrapper::paint(QPainter* painter, QTransform transform)
|
|
||||||
{
|
|
||||||
LayerWrapper::paint(painter, transform);
|
|
||||||
transform = property.transform * transform;
|
|
||||||
qDebug() << transform;
|
|
||||||
for (auto& child : children)
|
|
||||||
child->paint(painter, transform);
|
|
||||||
}
|
|
||||||
|
|
||||||
void LeafLayerWrapper::paint(QPainter* painter, QTransform transform)
|
|
||||||
{
|
|
||||||
LayerWrapper::paint(painter, transform);
|
|
||||||
transform = property.transform * transform;
|
|
||||||
qDebug() << transform;
|
|
||||||
if (wrappedElement != nullptr)
|
|
||||||
{
|
|
||||||
wrappedElement->paint(painter, transform, styles);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -35,7 +35,6 @@ class LayerWrapper
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QTreeWidgetItem* qTreeWidgetItem;
|
QTreeWidgetItem* qTreeWidgetItem;
|
||||||
bool selected;
|
|
||||||
struct SimpleProperty
|
struct SimpleProperty
|
||||||
{
|
{
|
||||||
QString name = "";
|
QString name = "";
|
||||||
|
@ -44,20 +43,17 @@ class LayerWrapper
|
||||||
double rotation = 0;
|
double rotation = 0;
|
||||||
bool flipHorizontally = 0;
|
bool flipHorizontally = 0;
|
||||||
bool flipVertically = 0;
|
bool flipVertically = 0;
|
||||||
QTransform transform;
|
|
||||||
// TODO: 将QPainterPath改为BitmapPath
|
// TODO: 将QPainterPath改为BitmapPath
|
||||||
void apply(PixelPath&cache);
|
void apply(PixelPath&cache) const;
|
||||||
} property;
|
} property;
|
||||||
virtual void setParent(FolderLayerWrapper*newParent);
|
virtual void setParent(FolderLayerWrapper*newParent);
|
||||||
virtual void refresh(LayerWrapper* layer = nullptr);
|
virtual void refresh();
|
||||||
virtual QTreeWidgetItem* getQTreeItem();
|
virtual QTreeWidgetItem* getQTreeItem();
|
||||||
// TODO: 将QPainterPath改为BitmapPath/QImage,或者直接将其删除,绘制时直接使用BitmapPath的paint方法
|
// TODO: 将QPainterPath改为BitmapPath/QImage,或者直接将其删除,绘制时直接使用BitmapPath的paint方法
|
||||||
virtual PixelPath getCache(LayerWrapper* selectedLayer=nullptr);
|
virtual PixelPath getCache();
|
||||||
QTransform getTransform();
|
|
||||||
FolderLayerWrapper*getParent() const; // invoke by manager, then invoke parent's applyStyles
|
FolderLayerWrapper*getParent() const; // invoke by manager, then invoke parent's applyStyles
|
||||||
LayerWrapper(QJsonObject json, FolderLayerWrapper*parent, ElementManager* elementManager=nullptr);
|
LayerWrapper(QJsonObject json, FolderLayerWrapper*parent, ElementManager* elementManager=nullptr);
|
||||||
LayerWrapper() = default;
|
LayerWrapper() = default;
|
||||||
virtual void paint(QPainter* painter, QTransform transform=QTransform());
|
|
||||||
// TODO : export Function
|
// TODO : export Function
|
||||||
// virtual LayerWrapper *addChild() = 0; // Leaf Child Only
|
// virtual LayerWrapper *addChild() = 0; // Leaf Child Only
|
||||||
// virtual LayerWrapper *addParent() = 0; // Folder Parent Only
|
// virtual LayerWrapper *addParent() = 0; // Folder Parent Only
|
||||||
|
@ -79,7 +75,7 @@ class FolderLayerWrapper : public LayerWrapper
|
||||||
public:
|
public:
|
||||||
|
|
||||||
~FolderLayerWrapper() = default;
|
~FolderLayerWrapper() = default;
|
||||||
void refresh(LayerWrapper* layer=nullptr) override;
|
void refresh() override;
|
||||||
FolderLayerWrapper() = default;
|
FolderLayerWrapper() = default;
|
||||||
FolderLayerWrapper(QJsonObject json, ElementManager *elementManager, FolderLayerWrapper*parent);
|
FolderLayerWrapper(QJsonObject json, ElementManager *elementManager, FolderLayerWrapper*parent);
|
||||||
void addChild(shared_ptr<LayerWrapper> child);
|
void addChild(shared_ptr<LayerWrapper> child);
|
||||||
|
@ -90,7 +86,6 @@ class FolderLayerWrapper : public LayerWrapper
|
||||||
QTreeWidgetItem* getQTreeItem() override;
|
QTreeWidgetItem* getQTreeItem() override;
|
||||||
QJsonObject toJson() const override;
|
QJsonObject toJson() const override;
|
||||||
int getReferencedBy()const;
|
int getReferencedBy()const;
|
||||||
void paint(QPainter* painter, QTransform transform = QTransform()) override;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class LeafLayerWrapper : public LayerWrapper
|
class LeafLayerWrapper : public LayerWrapper
|
||||||
|
@ -102,11 +97,10 @@ class LeafLayerWrapper : public LayerWrapper
|
||||||
|
|
||||||
public:
|
public:
|
||||||
~LeafLayerWrapper() = default;
|
~LeafLayerWrapper() = default;
|
||||||
void refresh(LayerWrapper* layer = nullptr) override;
|
void refresh() override;
|
||||||
LeafLayerWrapper() = default;
|
LeafLayerWrapper() = default;
|
||||||
LeafLayerWrapper(QJsonObject json, ElementManager *elementManager, FolderLayerWrapper*parent);
|
LeafLayerWrapper(QJsonObject json, ElementManager *elementManager, FolderLayerWrapper*parent);
|
||||||
QJsonObject toJson() const override;
|
QJsonObject toJson() const override;
|
||||||
void paint(QPainter* painter, QTransform transform = QTransform()) override;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(LayerWrapper *)
|
Q_DECLARE_METATYPE(LayerWrapper *)
|
||||||
|
|
|
@ -103,18 +103,3 @@ QPixmap PixelPath::getDetail()const
|
||||||
result = pixmap.copy(rect);
|
result = pixmap.copy(rect);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PixelPath::highLight()
|
|
||||||
{
|
|
||||||
// 创建一个QPainter对象,关联到QPixmap对象
|
|
||||||
QPainter painter(&pixmap);
|
|
||||||
|
|
||||||
// 设置画笔的颜色、宽度和样式
|
|
||||||
painter.setPen(QPen(Qt::black, 1, Qt::DashLine));
|
|
||||||
|
|
||||||
// 绘制一个矩形,指定左上角和右下角的坐标
|
|
||||||
painter.drawRect(boundingRect);
|
|
||||||
|
|
||||||
// 结束绘制
|
|
||||||
painter.end();
|
|
||||||
}
|
|
|
@ -26,5 +26,4 @@ public:
|
||||||
PixelPath trans(QTransform& mat)const;
|
PixelPath trans(QTransform& mat)const;
|
||||||
QPixmap resizedPixel(QSize size)const;
|
QPixmap resizedPixel(QSize size)const;
|
||||||
QPixmap getDetail()const;
|
QPixmap getDetail()const;
|
||||||
void highLight();
|
|
||||||
};
|
};
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
PreviewWindow::PreviewWindow(QWidget *parent) : QOpenGLWidget(parent)
|
PreviewWindow::PreviewWindow(QWidget *parent) : QOpenGLWidget(parent)
|
||||||
{
|
{
|
||||||
this->setFixedSize(QSize(1080, 1080));
|
|
||||||
this->renderer = Renderer::ElementRenderer::instance();
|
this->renderer = Renderer::ElementRenderer::instance();
|
||||||
QSurfaceFormat surfaceFormat;
|
QSurfaceFormat surfaceFormat;
|
||||||
surfaceFormat.setSamples(16);
|
surfaceFormat.setSamples(16);
|
||||||
|
@ -11,7 +10,6 @@ PreviewWindow::PreviewWindow(QWidget *parent) : QOpenGLWidget(parent)
|
||||||
painter->setRenderHint(QPainter::SmoothPixmapTransform);
|
painter->setRenderHint(QPainter::SmoothPixmapTransform);
|
||||||
painter->setRenderHint(QPainter::HighQualityAntialiasing);
|
painter->setRenderHint(QPainter::HighQualityAntialiasing);
|
||||||
layerManager = nullptr;
|
layerManager = nullptr;
|
||||||
currentLayer = nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PreviewWindow::initialize(LayerManager *layerManager,QSize windowSize)
|
void PreviewWindow::initialize(LayerManager *layerManager,QSize windowSize)
|
||||||
|
@ -48,7 +46,7 @@ void PreviewWindow::paintGL()
|
||||||
painter->begin(this);
|
painter->begin(this);
|
||||||
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());
|
||||||
painter->end();
|
painter->end();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,47 +57,3 @@ void PreviewWindow::resizeGL(int w, int h)
|
||||||
Renderer::ElementRenderer* const PreviewWindow::getRenderer()const {
|
Renderer::ElementRenderer* const PreviewWindow::getRenderer()const {
|
||||||
return this->renderer;
|
return this->renderer;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PreviewWindow::currentLayerChanged(LayerWrapper* layer)
|
|
||||||
{
|
|
||||||
this->currentLayer = layer;
|
|
||||||
}
|
|
||||||
|
|
||||||
void PreviewWindow::refresh()
|
|
||||||
{
|
|
||||||
this->repaint();
|
|
||||||
}
|
|
||||||
|
|
||||||
void PreviewWindow::mousePressEvent(QMouseEvent* event)
|
|
||||||
{
|
|
||||||
// 当鼠标按下时,记录当前的位置
|
|
||||||
m_lastPos = event->pos();
|
|
||||||
}
|
|
||||||
|
|
||||||
void PreviewWindow::mouseMoveEvent(QMouseEvent* event)
|
|
||||||
{
|
|
||||||
// 当鼠标移动时,计算移动的距离,并根据需要更新图形的状态
|
|
||||||
int dx = event->x() - m_lastPos.x();
|
|
||||||
int dy = event->y() - m_lastPos.y();
|
|
||||||
if (currentLayer != nullptr) {
|
|
||||||
if (event->buttons() & Qt::LeftButton) {
|
|
||||||
// 如果按下的是左键,那么平移图形
|
|
||||||
currentLayer->property.offset.setX(currentLayer->property.offset.x() + dx);
|
|
||||||
currentLayer->property.offset.setY(currentLayer->property.offset.y() + dy);
|
|
||||||
qDebug() << dx << "----" << dy;
|
|
||||||
}
|
|
||||||
else if (event->buttons() & Qt::RightButton) {
|
|
||||||
// 如果按下的是右键,那么旋转图形
|
|
||||||
qreal angle = dx;
|
|
||||||
currentLayer->property.rotation += angle;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 更新上一次的位置
|
|
||||||
m_lastPos = event->pos();
|
|
||||||
this->repaint();
|
|
||||||
}
|
|
||||||
|
|
||||||
void PreviewWindow::mouseReleaseEvent(QMouseEvent* event)
|
|
||||||
{
|
|
||||||
emit layerInfoChanged();
|
|
||||||
}
|
|
|
@ -7,7 +7,6 @@
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
#include <QJsonValue>
|
#include <QJsonValue>
|
||||||
#include <QOpenGLFunctions>
|
#include <QOpenGLFunctions>
|
||||||
#include <QMouseEvent>
|
|
||||||
#include <QOpenGLWidget>
|
#include <QOpenGLWidget>
|
||||||
#include "../Renderer/Preview/ElementRenderer.h"
|
#include "../Renderer/Preview/ElementRenderer.h"
|
||||||
|
|
||||||
|
@ -20,12 +19,6 @@ class PreviewWindow : public QOpenGLWidget, protected QOpenGLFunctions
|
||||||
LayerManager *layerManager;
|
LayerManager *layerManager;
|
||||||
Renderer::ElementRenderer* renderer;
|
Renderer::ElementRenderer* renderer;
|
||||||
QSize logicalSize;
|
QSize logicalSize;
|
||||||
QRectF viewportRect;
|
|
||||||
LayerWrapper* currentLayer;
|
|
||||||
QPointF m_lastPos;
|
|
||||||
void mousePressEvent(QMouseEvent* event) override;
|
|
||||||
void mouseMoveEvent(QMouseEvent* event) override;
|
|
||||||
void mouseReleaseEvent(QMouseEvent* event) override;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PreviewWindow(QWidget *parent = nullptr);
|
PreviewWindow(QWidget *parent = nullptr);
|
||||||
|
@ -35,11 +28,4 @@ class PreviewWindow : public QOpenGLWidget, protected QOpenGLFunctions
|
||||||
void paintGL() override;
|
void paintGL() override;
|
||||||
void resizeGL(int w, int h) override;
|
void resizeGL(int w, int h) override;
|
||||||
Renderer::ElementRenderer* const getRenderer()const;
|
Renderer::ElementRenderer* const getRenderer()const;
|
||||||
|
|
||||||
public slots:
|
|
||||||
void currentLayerChanged(LayerWrapper*);
|
|
||||||
void refresh();
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void layerInfoChanged();
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -12,19 +12,11 @@ LayerTreeWidget::LayerTreeWidget(QWidget *parent)
|
||||||
this->setHeaderLabel("Layer Content");
|
this->setHeaderLabel("Layer Content");
|
||||||
connect(this, &QTreeWidget::customContextMenuRequested, this, &LayerTreeWidget::popMenu);
|
connect(this, &QTreeWidget::customContextMenuRequested, this, &LayerTreeWidget::popMenu);
|
||||||
connect(this, &QTreeWidget::currentItemChanged, [=](QTreeWidgetItem *currentItem) {
|
connect(this, &QTreeWidget::currentItemChanged, [=](QTreeWidgetItem *currentItem) {
|
||||||
if (this->selectedItem != nullptr) {
|
|
||||||
this->selectedItem->data(0, Qt::UserRole).value<LayerWrapper*>()->selected = false;
|
|
||||||
}
|
|
||||||
this->selectedItem = currentItem;
|
this->selectedItem = currentItem;
|
||||||
if (this->selectedItem != nullptr) {
|
if(this->selectedItem !=nullptr)
|
||||||
auto layer = this->selectedItem->data(0, Qt::UserRole).value<LayerWrapper*>();
|
emit displayLayerChange(this->selectedItem->data(0, Qt::UserRole).value<LayerWrapper *>());
|
||||||
layer->selected = true;
|
else
|
||||||
emit displayLayerChange(layer);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
emit displayLayerChange(nullptr);
|
emit displayLayerChange(nullptr);
|
||||||
}
|
|
||||||
emit requireRefreshPreview();
|
|
||||||
});
|
});
|
||||||
// connect(this, &QTreeWidget::itemDoubleClicked, this, &LayerTreeWidget::onItemDoubleClicked);
|
// connect(this, &QTreeWidget::itemDoubleClicked, this, &LayerTreeWidget::onItemDoubleClicked);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,22 +2,23 @@
|
||||||
#include <QOpenGLFunctions_4_5_Core>
|
#include <QOpenGLFunctions_4_5_Core>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <QVector2D>
|
||||||
|
#include <QVector3D>
|
||||||
#include <QOpenGLShaderProgram>
|
#include <QOpenGLShaderProgram>
|
||||||
#include <QOpenGLBuffer>
|
#include <QOpenGLBuffer>
|
||||||
#include <QOpenGLVertexArrayObject>
|
#include <QOpenGLVertexArrayObject>
|
||||||
#include <QOpenGLTexture>
|
#include <QOpenGLTexture>
|
||||||
#include <QOpenGLWidget>
|
#include <QOpenGLWidget>
|
||||||
#include <assimp/vector3.h>
|
#include <assimp/vector3.h>
|
||||||
#include <glm/glm.hpp>
|
|
||||||
#include "Drawable.h"
|
#include "Drawable.h"
|
||||||
|
|
||||||
namespace Renderer
|
namespace Renderer
|
||||||
{
|
{
|
||||||
struct Vertex
|
struct Vertex
|
||||||
{
|
{
|
||||||
glm::vec3 Position;
|
QVector3D Position;
|
||||||
glm::vec3 Normal;
|
QVector3D Normal;
|
||||||
glm::vec2 TexCoords;
|
QVector2D TexCoords;
|
||||||
Vertex(const aiVector3D& position, const aiVector3D& Normal, const aiVector3D& TexCoords);
|
Vertex(const aiVector3D& position, const aiVector3D& Normal, const aiVector3D& TexCoords);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,7 @@ void Renderer::Model::loadModel(QString path)
|
||||||
directory = modelFile.dir();
|
directory = modelFile.dir();
|
||||||
|
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene* scene = importer.ReadFile(modelFile.absoluteFilePath().toUtf8(), aiProcess_Triangulate /*| aiProcess_FlipUVs*/);
|
const aiScene* scene = importer.ReadFile(modelFile.absoluteFilePath().toUtf8(), aiProcess_Triangulate | aiProcess_FlipUVs);
|
||||||
if (!scene || scene->mFlags & AI_SCENE_FLAGS_INCOMPLETE || !scene->mRootNode)
|
if (!scene || scene->mFlags & AI_SCENE_FLAGS_INCOMPLETE || !scene->mRootNode)
|
||||||
{
|
{
|
||||||
qCritical() << "ERROR::ASSIMP::" << importer.GetErrorString() << endl;
|
qCritical() << "ERROR::ASSIMP::" << importer.GetErrorString() << endl;
|
||||||
|
@ -117,8 +117,12 @@ void Model::processNode(aiNode* node, const aiScene* scene, aiMatrix4x4 mat4)
|
||||||
|
|
||||||
std::unique_ptr<Drawable> Model::processMesh(aiMesh* mesh, const aiScene* scene, aiMatrix4x4 model)
|
std::unique_ptr<Drawable> Model::processMesh(aiMesh* mesh, const aiScene* scene, aiMatrix4x4 model)
|
||||||
{
|
{
|
||||||
|
aiMaterial* material = scene->mMaterials[mesh->mMaterialIndex];
|
||||||
QMatrix4x4 modelQ((float*)&model);
|
QMatrix4x4 modelQ((float*)&model);
|
||||||
|
|
||||||
|
aiString str;
|
||||||
|
material->GetTexture(aiTextureType_BASE_COLOR, 0, &str);
|
||||||
|
|
||||||
std::vector<Vertex> vertices;
|
std::vector<Vertex> vertices;
|
||||||
for (unsigned int i = 0; i < mesh->mNumVertices; i++)
|
for (unsigned int i = 0; i < mesh->mNumVertices; i++)
|
||||||
{
|
{
|
||||||
|
@ -135,59 +139,45 @@ std::unique_ptr<Drawable> Model::processMesh(aiMesh* mesh, const aiScene* scene,
|
||||||
maxZ = std::max(maxZ, worldPos.z);
|
maxZ = std::max(maxZ, worldPos.z);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<unsigned int> indices;
|
std::vector<unsigned int> indices;
|
||||||
for (auto face = mesh->mFaces; face < mesh->mFaces + mesh->mNumFaces; face++)
|
for (auto face = mesh->mFaces; face < mesh->mFaces + mesh->mNumFaces; face++)
|
||||||
indices.insert(indices.end(), face->mIndices, face->mIndices + face->mNumIndices);
|
indices.insert(indices.end(), face->mIndices, face->mIndices + face->mNumIndices);
|
||||||
|
|
||||||
aiMaterial* material = scene->mMaterials[mesh->mMaterialIndex];
|
|
||||||
|
|
||||||
if (auto iter = paintingMap.find([&] {
|
if (auto iter = paintingMap.find(std::string(str.C_Str())); paintingProgram != nullptr && iter != paintingMap.end())
|
||||||
aiString str;
|
|
||||||
material->GetTexture(aiTextureType_BASE_COLOR, 0, &str);
|
|
||||||
return std::string(str.C_Str());
|
|
||||||
}()); paintingProgram != nullptr && iter != paintingMap.end())
|
|
||||||
{
|
{
|
||||||
qDebug() << iter->first.c_str() << "Replaced";
|
|
||||||
|
|
||||||
auto mesh = std::make_unique<PaintingMesh>(glFunc, paintingProgram, shadowProgram, modelQ);
|
|
||||||
|
|
||||||
auto& [paintingPath, leftBottom, rightTop] = iter->second;
|
auto& [paintingPath, leftBottom, rightTop] = iter->second;
|
||||||
|
qDebug() << str.C_Str() << "Replaced";
|
||||||
|
|
||||||
for (auto& v : vertices)
|
auto m_mesh = std::make_unique<PaintingMesh>(glFunc, paintingProgram, shadowProgram, modelQ);
|
||||||
{
|
m_mesh->vertices = vertices;
|
||||||
//qDebug() << v.TexCoords.x << v.TexCoords.y;
|
m_mesh->indices = indices;
|
||||||
v.TexCoords = (v.TexCoords - leftBottom) / (rightTop - leftBottom);
|
|
||||||
qDebug() << v.TexCoords.x << v.TexCoords.y;
|
|
||||||
}
|
|
||||||
|
|
||||||
mesh->vertices = vertices;
|
m_mesh->paintingId = loadPainting(paintingPath);
|
||||||
mesh->indices = indices;
|
auto& handle = vtManager->getPaintingHandle(m_mesh->paintingId);
|
||||||
|
m_mesh->textureBasecolor = handle.baseColor;
|
||||||
mesh->paintingId = loadPainting(paintingPath);
|
m_mesh->textureMetallicRoughness = handle.metallicRoughness;
|
||||||
auto& handle = vtManager->getPaintingHandle(mesh->paintingId);
|
m_mesh->setupMesh();
|
||||||
mesh->textureBasecolor = handle.baseColor;
|
return m_mesh;
|
||||||
mesh->textureMetallicRoughness = handle.metallicRoughness;
|
|
||||||
mesh->setupMesh();
|
|
||||||
return mesh;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
auto mesh = std::make_unique<Mesh>(glFunc, shaderProgram, shadowProgram, modelQ);
|
auto m_mesh = std::make_unique<Mesh>(glFunc, shaderProgram, shadowProgram, modelQ);
|
||||||
mesh->vertices = vertices;
|
m_mesh->vertices = vertices;
|
||||||
mesh->indices = indices;
|
m_mesh->indices = indices;
|
||||||
|
|
||||||
if (!(mesh->textureBasecolor = loadMaterialTextures(material, aiTextureType_BASE_COLOR)))
|
// ´¦Àí²ÄÖÊ
|
||||||
|
if (!(m_mesh->textureBasecolor = loadMaterialTextures(material, aiTextureType_BASE_COLOR)))
|
||||||
qWarning() << "Basecolor Texture Loading Failed!";
|
qWarning() << "Basecolor Texture Loading Failed!";
|
||||||
if (!(mesh->textureMetallicRoughness = loadMaterialTextures(material, aiTextureType_METALNESS)))
|
if (!(m_mesh->textureMetallicRoughness = loadMaterialTextures(material, aiTextureType_METALNESS)))
|
||||||
qWarning() << "MetallicRoughness Texture Loading Failed!";
|
qWarning() << "MetallicRoughness Texture Loading Failed!";
|
||||||
if (!(mesh->textureNormal = loadMaterialTextures(material, aiTextureType_NORMALS)))
|
if (!(m_mesh->textureNormal = loadMaterialTextures(material, aiTextureType_NORMALS)))
|
||||||
qWarning() << "Normal Texture Loading Failed!";
|
qWarning() << "Normal Texture Loading Failed!";
|
||||||
|
|
||||||
if (mesh->textureBasecolor && mesh->textureMetallicRoughness && mesh->textureNormal)
|
if (m_mesh->textureBasecolor && m_mesh->textureMetallicRoughness && m_mesh->textureNormal)
|
||||||
{
|
{
|
||||||
mesh->setupMesh();
|
m_mesh->setupMesh();
|
||||||
return mesh;
|
return m_mesh;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -218,7 +208,7 @@ GLuint Model::loadMaterialTextures(aiMaterial* mat, aiTextureType type)
|
||||||
texture.setWrapMode(QOpenGLTexture::DirectionS, QOpenGLTexture::Repeat);
|
texture.setWrapMode(QOpenGLTexture::DirectionS, QOpenGLTexture::Repeat);
|
||||||
texture.setWrapMode(QOpenGLTexture::DirectionT, QOpenGLTexture::Repeat);
|
texture.setWrapMode(QOpenGLTexture::DirectionT, QOpenGLTexture::Repeat);
|
||||||
texture.setMinMagFilters(QOpenGLTexture::LinearMipMapLinear, QOpenGLTexture::Linear);
|
texture.setMinMagFilters(QOpenGLTexture::LinearMipMapLinear, QOpenGLTexture::Linear);
|
||||||
texture.setData(data.mirrored());
|
texture.setData(data);
|
||||||
return texture.textureId();
|
return texture.textureId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,10 +24,6 @@ namespace Renderer
|
||||||
QOpenGLShaderProgram* shadowProgram = nullptr;
|
QOpenGLShaderProgram* shadowProgram = nullptr;
|
||||||
VirtualTextureManager* vtManager = nullptr;
|
VirtualTextureManager* vtManager = nullptr;
|
||||||
|
|
||||||
/**
|
|
||||||
* @param key BaseColor路径
|
|
||||||
* @param value json路径, 纹理坐标
|
|
||||||
*/
|
|
||||||
std::unordered_map<std::string, std::tuple<std::string, glm::vec2, glm::vec2>> paintingMap;
|
std::unordered_map<std::string, std::tuple<std::string, glm::vec2, glm::vec2>> paintingMap;
|
||||||
std::unordered_map<std::string, GLuint> paintingLoaded;
|
std::unordered_map<std::string, GLuint> paintingLoaded;
|
||||||
std::unordered_map<std::string, QOpenGLTexture> texturesLoaded;
|
std::unordered_map<std::string, QOpenGLTexture> texturesLoaded;
|
||||||
|
|
Loading…
Reference in New Issue