Compare commits
6 Commits
adb28a67e8
...
64c4646783
Author | SHA1 | Date |
---|---|---|
ArgonarioD | 64c4646783 | |
ArgonarioD | 64e1c4a4e9 | |
ArgonarioD | 66cde802ec | |
ArgonarioD | 4c95d6e362 | |
wuyize | 12b62bf039 | |
ArgonarioD | 0e62672b58 |
|
@ -202,6 +202,7 @@
|
||||||
<QtMoc Include="src\Editor\EditorWidgetComponent\ColorPicker.h" />
|
<QtMoc Include="src\Editor\EditorWidgetComponent\ColorPicker.h" />
|
||||||
<QtMoc Include="src\Editor\RightBar\EditorSettingWidget.h" />
|
<QtMoc Include="src\Editor\RightBar\EditorSettingWidget.h" />
|
||||||
<QtMoc Include="src\Editor\EditorWidgetComponent\FillStyleWidget.h" />
|
<QtMoc Include="src\Editor\EditorWidgetComponent\FillStyleWidget.h" />
|
||||||
|
<ClInclude Include="src\Editor\LayerWrapper.h" />
|
||||||
<ClInclude Include="src\Editor\util\EncodeUtil.hpp" />
|
<ClInclude Include="src\Editor\util\EncodeUtil.hpp" />
|
||||||
<ClInclude Include="src\Editor\util\JsonUtil.hpp" />
|
<ClInclude Include="src\Editor\util\JsonUtil.hpp" />
|
||||||
<ClInclude Include="src\Editor\ElementManager.h" />
|
<ClInclude Include="src\Editor\ElementManager.h" />
|
||||||
|
|
|
@ -71,6 +71,18 @@
|
||||||
<Filter Include="Source Files\Editor\Style">
|
<Filter Include="Source Files\Editor\Style">
|
||||||
<UniqueIdentifier>{b9732a33-aa2e-4f8d-886f-1b1730c66519}</UniqueIdentifier>
|
<UniqueIdentifier>{b9732a33-aa2e-4f8d-886f-1b1730c66519}</UniqueIdentifier>
|
||||||
</Filter>
|
</Filter>
|
||||||
|
<Filter Include="Header Files\Editor\Element">
|
||||||
|
<UniqueIdentifier>{8d846557-8fd5-47d5-8edf-eb3eb77c226b}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="Source Files\Editor\Element">
|
||||||
|
<UniqueIdentifier>{22d7f3ef-8185-476e-8fe1-aea24c4faacc}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="Header Files\Editor\Layer">
|
||||||
|
<UniqueIdentifier>{6fc32493-d5a2-44c3-a283-d2d3181330fb}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="Source Files\Editor\Layer">
|
||||||
|
<UniqueIdentifier>{e6de889e-8313-4846-8bdf-125b766eef59}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<QtUic Include="MainWindow.ui">
|
<QtUic Include="MainWindow.ui">
|
||||||
|
@ -141,18 +153,6 @@
|
||||||
<ClCompile Include="src\Renderer\Painting\Element.cpp">
|
<ClCompile Include="src\Renderer\Painting\Element.cpp">
|
||||||
<Filter>Source Files\Renderer\Painting</Filter>
|
<Filter>Source Files\Renderer\Painting</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="src\Editor\GraphicElement.cpp">
|
|
||||||
<Filter>Source Files\Editor</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="src\Editor\ElementManager.cpp">
|
|
||||||
<Filter>Source Files\Editor</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="src\Editor\LayerManager.cpp">
|
|
||||||
<Filter>Source Files\Editor</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="src\Editor\LayerWrapper.cpp">
|
|
||||||
<Filter>Source Files\Editor</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="src\Editor\PreviewWindow.cpp">
|
<ClCompile Include="src\Editor\PreviewWindow.cpp">
|
||||||
<Filter>Source Files\Editor</Filter>
|
<Filter>Source Files\Editor</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
@ -201,12 +201,6 @@
|
||||||
<ClCompile Include="src\Editor\PixelPath.cpp">
|
<ClCompile Include="src\Editor\PixelPath.cpp">
|
||||||
<Filter>Source Files\Editor</Filter>
|
<Filter>Source Files\Editor</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="src\Editor\EditorWidget.cpp">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="src\Editor\ElementPoolWidget.cpp">
|
|
||||||
<Filter>Source Files\Editor</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="src\FluentMenu.cpp">
|
<ClCompile Include="src\FluentMenu.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
@ -225,20 +219,41 @@
|
||||||
<ClCompile Include="src\Editor\RightBar\InfoDisplayWidget.cpp">
|
<ClCompile Include="src\Editor\RightBar\InfoDisplayWidget.cpp">
|
||||||
<Filter>Source Files\Editor</Filter>
|
<Filter>Source Files\Editor</Filter>
|
||||||
</ClCompile>
|
</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">
|
<ClCompile Include="src\NavigationBarWidget.cpp">
|
||||||
<Filter>Source Files\Editor</Filter>
|
<Filter>Source Files\Editor</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="src\Editor\EditorWidgetComponent\ColorPicker.cpp">
|
<ClCompile Include="src\Editor\EditorWidgetComponent\ColorPicker.cpp">
|
||||||
<Filter>Source Files\Editor</Filter>
|
<Filter>Source Files\Editor</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="src\Editor\EditorWidget.cpp">
|
||||||
|
<Filter>Source Files\Editor</Filter>
|
||||||
|
</ClCompile>
|
||||||
<ClCompile Include="src\Editor\RightBar\EditorSettingWidget.cpp">
|
<ClCompile Include="src\Editor\RightBar\EditorSettingWidget.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files\Editor</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="src\Editor\EditorWidgetComponent\FillStyleWidget.cpp">
|
||||||
|
<Filter>Source Files\Editor\Style</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="src\Editor\ElementManager.cpp">
|
||||||
|
<Filter>Source Files\Editor\Element</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="src\Editor\ElementPoolWidget.cpp">
|
||||||
|
<Filter>Source Files\Editor\Element</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="src\Editor\GraphicElement.cpp">
|
||||||
|
<Filter>Source Files\Editor\Element</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="src\Editor\LayerManager.cpp">
|
||||||
|
<Filter>Source Files\Editor\Layer</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="src\Editor\RightBar\LayerTreeWidget.cpp">
|
||||||
|
<Filter>Source Files\Editor\Layer</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="src\Editor\EditorWidgetComponent\LayerCreateWidget.cpp">
|
||||||
|
<Filter>Source Files\Editor\Layer</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="src\Editor\LayerWrapper.cpp">
|
||||||
|
<Filter>Source Files\Editor\Layer</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="src\Editor\EditorWidgetComponent\FillStyleWidget.cpp">
|
<ClCompile Include="src\Editor\EditorWidgetComponent\FillStyleWidget.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
|
@ -257,9 +272,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\ElementPoolWidget.h">
|
|
||||||
<Filter>Header Files\Editor</Filter>
|
|
||||||
</QtMoc>
|
|
||||||
<QtMoc Include="src\FluentMenu.h">
|
<QtMoc Include="src\FluentMenu.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</QtMoc>
|
</QtMoc>
|
||||||
|
@ -272,15 +284,9 @@
|
||||||
<QtMoc Include="src\Editor\RightBar\InfoDisplayWidget.h">
|
<QtMoc Include="src\Editor\RightBar\InfoDisplayWidget.h">
|
||||||
<Filter>Header Files\Editor</Filter>
|
<Filter>Header Files\Editor</Filter>
|
||||||
</QtMoc>
|
</QtMoc>
|
||||||
<QtMoc Include="src\Editor\EditorWidgetComponent\LayerCreateWidget.h">
|
|
||||||
<Filter>Header Files\Editor</Filter>
|
|
||||||
</QtMoc>
|
|
||||||
<QtMoc Include="src\Editor\EditorWidget.h">
|
<QtMoc Include="src\Editor\EditorWidget.h">
|
||||||
<Filter>Header Files\Editor</Filter>
|
<Filter>Header Files\Editor</Filter>
|
||||||
</QtMoc>
|
</QtMoc>
|
||||||
<QtMoc Include="src\Editor\RightBar\LayerTreeWidget.h">
|
|
||||||
<Filter>Header Files\Editor</Filter>
|
|
||||||
</QtMoc>
|
|
||||||
<QtMoc Include="src\MainWindow.h">
|
<QtMoc Include="src\MainWindow.h">
|
||||||
<Filter>Header Files\Editor</Filter>
|
<Filter>Header Files\Editor</Filter>
|
||||||
</QtMoc>
|
</QtMoc>
|
||||||
|
@ -291,7 +297,19 @@
|
||||||
<Filter>Header Files\Editor</Filter>
|
<Filter>Header Files\Editor</Filter>
|
||||||
</QtMoc>
|
</QtMoc>
|
||||||
<QtMoc Include="src\Editor\RightBar\EditorSettingWidget.h">
|
<QtMoc Include="src\Editor\RightBar\EditorSettingWidget.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files\Editor</Filter>
|
||||||
|
</QtMoc>
|
||||||
|
<QtMoc Include="src\Editor\EditorWidgetComponent\FillStyleWidget.h">
|
||||||
|
<Filter>Header Files\Editor\Style</Filter>
|
||||||
|
</QtMoc>
|
||||||
|
<QtMoc Include="src\Editor\ElementPoolWidget.h">
|
||||||
|
<Filter>Header Files\Editor\Element</Filter>
|
||||||
|
</QtMoc>
|
||||||
|
<QtMoc Include="src\Editor\EditorWidgetComponent\LayerCreateWidget.h">
|
||||||
|
<Filter>Header Files\Editor\Layer</Filter>
|
||||||
|
</QtMoc>
|
||||||
|
<QtMoc Include="src\Editor\RightBar\LayerTreeWidget.h">
|
||||||
|
<Filter>Header Files\Editor\Layer</Filter>
|
||||||
</QtMoc>
|
</QtMoc>
|
||||||
<QtMoc Include="src\Editor\EditorWidgetComponent\FillStyleWidget.h">
|
<QtMoc Include="src\Editor\EditorWidgetComponent\FillStyleWidget.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
|
@ -426,15 +444,6 @@
|
||||||
<ClInclude Include="src\Renderer\Painting\Element.h">
|
<ClInclude Include="src\Renderer\Painting\Element.h">
|
||||||
<Filter>Header Files\Renderer\Painting</Filter>
|
<Filter>Header Files\Renderer\Painting</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="src\Editor\GraphicElement.h">
|
|
||||||
<Filter>Header Files\Editor</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="src\Editor\LayerManager.h">
|
|
||||||
<Filter>Header Files\Editor</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="src\Editor\ElementManager.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>
|
||||||
|
@ -474,9 +483,6 @@
|
||||||
<ClInclude Include="src\Renderer\Preview\ElementRenderer.h">
|
<ClInclude Include="src\Renderer\Preview\ElementRenderer.h">
|
||||||
<Filter>Header Files\Renderer\Preview</Filter>
|
<Filter>Header Files\Renderer\Preview</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="src\Editor\PixelPath.h">
|
|
||||||
<Filter>Header Files</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="src\Renderer\IblUtils.h">
|
<ClInclude Include="src\Renderer\IblUtils.h">
|
||||||
<Filter>Header Files\Renderer</Filter>
|
<Filter>Header Files\Renderer</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
@ -498,6 +504,21 @@
|
||||||
<ClInclude Include="src\Editor\util\EncodeUtil.hpp">
|
<ClInclude Include="src\Editor\util\EncodeUtil.hpp">
|
||||||
<Filter>Header Files\Editor\util</Filter>
|
<Filter>Header Files\Editor\util</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="src\Editor\ElementManager.h">
|
||||||
|
<Filter>Header Files\Editor\Element</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="src\Editor\GraphicElement.h">
|
||||||
|
<Filter>Header Files\Editor\Element</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="src\Editor\LayerManager.h">
|
||||||
|
<Filter>Header Files\Editor\Layer</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="src\Editor\PixelPath.h">
|
||||||
|
<Filter>Header Files\Editor</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="src\Editor\LayerWrapper.h">
|
||||||
|
<Filter>Header Files\Editor\Layer</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<QtRcc Include="res\MainWindow.qrc">
|
<QtRcc Include="res\MainWindow.qrc">
|
||||||
|
|
|
@ -1071,16 +1071,16 @@ void main()
|
||||||
if (num_its % 2 == 1)
|
if (num_its % 2 == 1)
|
||||||
{
|
{
|
||||||
hitElement = true;
|
hitElement = true;
|
||||||
elementColor = vec4(1, 1, 0, 0);
|
|
||||||
|
|
||||||
vec4 head = unpackUnorm4x8(floatBitsToUint(style[styleIndex]));
|
vec4 head = unpackUnorm4x8(floatBitsToUint(style[styleIndex]));
|
||||||
if (head.z == 0)
|
if (head.z == 0)
|
||||||
{
|
{
|
||||||
elementColor = vec4(unpackUnorm4x8(floatBitsToUint(style[++styleIndex])).rgb, 1);
|
elementColor = vec4(unpackUnorm4x8(floatBitsToUint(style[styleIndex+1])).rgb, 1);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
styleIndex += 2;
|
||||||
|
}
|
||||||
else // Stroke
|
else // Stroke
|
||||||
{
|
{
|
||||||
float minDistance = 1e38;
|
float minDistance = 1e38;
|
||||||
|
|
|
@ -17,7 +17,10 @@ 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();
|
auto startPoint = static_cast<QPointF>(painterPath.elementAt(0));
|
||||||
|
auto endPoint = static_cast<QPointF>(painterPath.elementAt(painterPath.elementCount() - 1));
|
||||||
|
this->closed = startPoint == endPoint;
|
||||||
|
qDebug() << "load svg file success " << painterPath.elementCount() << (isClosed() ? "is" : "not") << "closed";
|
||||||
}
|
}
|
||||||
|
|
||||||
SimpleElement::SimpleElement(QJsonObject jsonSource) : jsonSource(jsonSource)
|
SimpleElement::SimpleElement(QJsonObject jsonSource) : jsonSource(jsonSource)
|
||||||
|
@ -117,11 +120,21 @@ void SimpleElement::paint(QPainter* painter, QTransform transform, const LayerSt
|
||||||
painter->restore();
|
painter->restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SimpleElement::isClosed() const
|
||||||
|
{
|
||||||
|
return closed;
|
||||||
|
}
|
||||||
|
|
||||||
void GroupElement::paint(QPainter* painter, QTransform transform, const LayerStyleContainer& styles)
|
void GroupElement::paint(QPainter* painter, QTransform transform, const LayerStyleContainer& styles)
|
||||||
{
|
{
|
||||||
sourceLayer->paint(painter, transform);
|
sourceLayer->paint(painter, transform);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool GroupElement::isClosed() const
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
QPixmap SimpleElement::getPreview(QSize size)
|
QPixmap SimpleElement::getPreview(QSize size)
|
||||||
{
|
{
|
||||||
|
|
|
@ -28,11 +28,14 @@ public:
|
||||||
virtual PixelPath getPaintObject() const = 0;
|
virtual PixelPath getPaintObject() const = 0;
|
||||||
virtual PixelPath getPaintObject(const LayerStyleContainer& styles) const = 0;
|
virtual PixelPath getPaintObject(const LayerStyleContainer& styles) const = 0;
|
||||||
virtual void paint(QPainter* painter, QTransform transform, const LayerStyleContainer& styles) = 0;
|
virtual void paint(QPainter* painter, QTransform transform, const LayerStyleContainer& styles) = 0;
|
||||||
|
virtual bool isClosed() const = 0;
|
||||||
virtual QPixmap getPreview(QSize size) = 0;
|
virtual QPixmap getPreview(QSize size) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class SimpleElement : public GraphicElement
|
class SimpleElement : public GraphicElement
|
||||||
{
|
{
|
||||||
|
private:
|
||||||
|
bool closed;
|
||||||
public:
|
public:
|
||||||
QJsonObject jsonSource;
|
QJsonObject jsonSource;
|
||||||
// TODO: ¸ÄΪComposedPainterPath
|
// TODO: ¸ÄΪComposedPainterPath
|
||||||
|
@ -48,6 +51,7 @@ public:
|
||||||
PixelPath getPaintObject() const override;
|
PixelPath getPaintObject() const override;
|
||||||
PixelPath getPaintObject(const LayerStyleContainer& styles) const override;
|
PixelPath getPaintObject(const LayerStyleContainer& styles) const override;
|
||||||
void paint(QPainter* painter, QTransform transform, const LayerStyleContainer& styles) override;
|
void paint(QPainter* painter, QTransform transform, const LayerStyleContainer& styles) override;
|
||||||
|
bool isClosed() const override;
|
||||||
QPixmap getPreview(QSize size) override;
|
QPixmap getPreview(QSize size) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -65,6 +69,7 @@ public:
|
||||||
PixelPath getPaintObject(const LayerStyleContainer& styles) const override;
|
PixelPath getPaintObject(const LayerStyleContainer& styles) const override;
|
||||||
void setSourceLayer(FolderLayerWrapper* sourceLayer);
|
void setSourceLayer(FolderLayerWrapper* sourceLayer);
|
||||||
void paint(QPainter* painter, QTransform transform, const LayerStyleContainer& styles) override;
|
void paint(QPainter* painter, QTransform transform, const LayerStyleContainer& styles) override;
|
||||||
|
bool isClosed() const override;
|
||||||
QPixmap getPreview(QSize size) override;
|
QPixmap getPreview(QSize size) override;
|
||||||
void collectReachable(std::set<LayerWrapper*>& set) const;
|
void collectReachable(std::set<LayerWrapper*>& set) const;
|
||||||
};
|
};
|
||||||
|
|
|
@ -90,9 +90,9 @@ void LayerStyleContainer::computeNewHash()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LayerStyleContainer LayerStyleContainer::fromJson(const QJsonArray& jsonArray)
|
LayerStyleContainer LayerStyleContainer::fromJson(bool isClosedElement, const QJsonArray& jsonArray)
|
||||||
{
|
{
|
||||||
LayerStyleContainer container;
|
LayerStyleContainer container(isClosedElement);
|
||||||
for (const auto& style : jsonArray)
|
for (const auto& style : jsonArray)
|
||||||
{
|
{
|
||||||
container.useStyle(LayerStyle::fromJson(style.toObject()));
|
container.useStyle(LayerStyle::fromJson(style.toObject()));
|
||||||
|
@ -100,16 +100,26 @@ LayerStyleContainer LayerStyleContainer::fromJson(const QJsonArray& jsonArray)
|
||||||
return container;
|
return container;
|
||||||
}
|
}
|
||||||
|
|
||||||
LayerStyleContainer::LayerStyleContainer() : hash(0)
|
LayerStyleContainer::LayerStyleContainer(bool isClosedElement) : hash(0)
|
||||||
{
|
{
|
||||||
unusedStyles = { {
|
for (const auto& style : commonStyles)
|
||||||
StrokeElementLayerStyle::displayName(),
|
|
||||||
[] { return std::make_unique<StrokeElementLayerStyle>(); }
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
FillElementLayerStyle::displayName(),
|
unusedStyles.insert(style);
|
||||||
[] { return std::make_unique<FillElementLayerStyle>(); }
|
}
|
||||||
} };
|
if (isClosedElement)
|
||||||
|
{
|
||||||
|
for (const auto& style : closedOnlyStyles)
|
||||||
|
{
|
||||||
|
unusedStyles.insert(style);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (const auto& style : unclosedOnlyStyles)
|
||||||
|
{
|
||||||
|
unusedStyles.insert(style);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<Renderer::BaseStyle> LayerStyleContainer::toBaseStyles() const
|
std::vector<Renderer::BaseStyle> LayerStyleContainer::toBaseStyles() const
|
||||||
|
|
|
@ -38,42 +38,6 @@ public:
|
||||||
virtual std::unique_ptr<LayerStyle> clone() const = 0;
|
virtual std::unique_ptr<LayerStyle> clone() const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* LayerStyle的容器,在每次数据变更时需要手动调用computeNewHash()方法,否则哈希值不会更新
|
|
||||||
*/
|
|
||||||
class LayerStyleContainer : public Renderer::ElementStyle
|
|
||||||
{
|
|
||||||
using DisplayNameWithSupplier = std::map<QString, std::function<std::unique_ptr<LayerStyle>()>>;
|
|
||||||
private:
|
|
||||||
DisplayNameWithSupplier unusedStyles;
|
|
||||||
DisplayNameWithSupplier usedStyles;
|
|
||||||
std::map<QString, std::shared_ptr<LayerStyle>> styles;
|
|
||||||
size_t hash;
|
|
||||||
public:
|
|
||||||
static LayerStyleContainer fromJson(const QJsonArray& jsonArray);
|
|
||||||
|
|
||||||
LayerStyleContainer();
|
|
||||||
std::vector<Renderer::BaseStyle> toBaseStyles() const override;
|
|
||||||
QJsonArray toJson() const;
|
|
||||||
|
|
||||||
bool empty() const;
|
|
||||||
bool full() const;
|
|
||||||
std::map<QString, std::shared_ptr<LayerStyle>>::iterator begin();
|
|
||||||
std::map<QString, std::shared_ptr<LayerStyle>>::iterator end();
|
|
||||||
|
|
||||||
QStringList unusedStyleNames() const;
|
|
||||||
std::unique_ptr<LayerStyle> makeUnusedStyle(const QString& styleName) const;
|
|
||||||
bool useStyle(const std::shared_ptr<LayerStyle>& style);
|
|
||||||
bool dropStyle(const QString& styleName);
|
|
||||||
float boundingBoxAffectValue() const;
|
|
||||||
size_t getHash() const;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 需要在每次更改后手动调用
|
|
||||||
*/
|
|
||||||
void computeNewHash();
|
|
||||||
};
|
|
||||||
|
|
||||||
class StrokeElementLayerStyle : public LayerStyle
|
class StrokeElementLayerStyle : public LayerStyle
|
||||||
{
|
{
|
||||||
using PMaterialStyleStroke = std::shared_ptr<MaterialStyleStroke>;
|
using PMaterialStyleStroke = std::shared_ptr<MaterialStyleStroke>;
|
||||||
|
@ -117,3 +81,50 @@ public:
|
||||||
|
|
||||||
PMaterialStyleFill fillMaterialStyle;
|
PMaterialStyleFill fillMaterialStyle;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LayerStyle的容器,在每次数据变更时需要手动调用computeNewHash()方法,否则哈希值不会更新
|
||||||
|
*/
|
||||||
|
class LayerStyleContainer : public Renderer::ElementStyle
|
||||||
|
{
|
||||||
|
using DisplayNameWithSupplier = std::map<QString, std::function<std::unique_ptr<LayerStyle>()>>;
|
||||||
|
private:
|
||||||
|
|
||||||
|
inline const static DisplayNameWithSupplier commonStyles = { {
|
||||||
|
StrokeElementLayerStyle::displayName(),
|
||||||
|
[] { return std::make_unique<StrokeElementLayerStyle>(); }
|
||||||
|
} };
|
||||||
|
inline const static DisplayNameWithSupplier closedOnlyStyles = { {
|
||||||
|
FillElementLayerStyle::displayName(),
|
||||||
|
[] { return std::make_unique<FillElementLayerStyle>(); }
|
||||||
|
} };
|
||||||
|
inline const static DisplayNameWithSupplier unclosedOnlyStyles = { };
|
||||||
|
|
||||||
|
DisplayNameWithSupplier unusedStyles;
|
||||||
|
DisplayNameWithSupplier usedStyles;
|
||||||
|
std::map<QString, std::shared_ptr<LayerStyle>> styles;
|
||||||
|
size_t hash;
|
||||||
|
public:
|
||||||
|
static LayerStyleContainer fromJson(bool isClosedElement, const QJsonArray& jsonArray);
|
||||||
|
|
||||||
|
LayerStyleContainer(bool isClosedElement);
|
||||||
|
std::vector<Renderer::BaseStyle> toBaseStyles() const override;
|
||||||
|
QJsonArray toJson() const;
|
||||||
|
|
||||||
|
bool empty() const;
|
||||||
|
bool full() const;
|
||||||
|
std::map<QString, std::shared_ptr<LayerStyle>>::iterator begin();
|
||||||
|
std::map<QString, std::shared_ptr<LayerStyle>>::iterator end();
|
||||||
|
|
||||||
|
QStringList unusedStyleNames() const;
|
||||||
|
std::unique_ptr<LayerStyle> makeUnusedStyle(const QString& styleName) const;
|
||||||
|
bool useStyle(const std::shared_ptr<LayerStyle>& style);
|
||||||
|
bool dropStyle(const QString& styleName);
|
||||||
|
float boundingBoxAffectValue() const;
|
||||||
|
size_t getHash() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 需要在每次更改后手动调用
|
||||||
|
*/
|
||||||
|
void computeNewHash();
|
||||||
|
};
|
|
@ -73,14 +73,12 @@ FolderLayerWrapper::FolderLayerWrapper(QJsonObject json, ElementManager *element
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LeafLayerWrapper::LeafLayerWrapper(QJsonObject json, ElementManager *elementManager, FolderLayerWrapper*parent)
|
LeafLayerWrapper::LeafLayerWrapper(QJsonObject json, ElementManager* elementManager, FolderLayerWrapper* parent)
|
||||||
: LayerWrapper(json, parent)
|
: LayerWrapper(json, parent),
|
||||||
|
wrappedElement(elementManager->getElementById(json.value("element").toInt())),
|
||||||
|
styles(LayerStyleContainer::fromJson(wrappedElement->isClosed(), json.value("styles").toArray()))
|
||||||
{
|
{
|
||||||
qDebug() << json.value("name").toString() << " " << this;
|
qDebug() << json.value("name").toString() << " " << this;
|
||||||
int elementIndex = json.value("element").toInt();
|
|
||||||
wrappedElement = elementManager->getElementById(elementIndex);
|
|
||||||
QJsonArray stylesArray = json.value("styles").toArray();
|
|
||||||
styles = LayerStyleContainer::fromJson(stylesArray);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LayerWrapper::SimpleProperty::apply(PixelPath&cache)
|
void LayerWrapper::SimpleProperty::apply(PixelPath&cache)
|
||||||
|
|
|
@ -107,7 +107,6 @@ class LeafLayerWrapper : public LayerWrapper
|
||||||
public:
|
public:
|
||||||
~LeafLayerWrapper() = default;
|
~LeafLayerWrapper() = default;
|
||||||
void refresh(LayerWrapper* layer = nullptr) override;
|
void refresh(LayerWrapper* layer = nullptr) override;
|
||||||
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(), bool ignoreSelected = false) override;
|
void paint(QPainter* painter, QTransform transform = QTransform(), bool ignoreSelected = false) override;
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
#include <QtWidgets/QApplication>
|
#include <QtWidgets/QApplication>
|
||||||
#include "ElementRendererTest.h"
|
#include "ElementRendererTest.h"
|
||||||
#include "Renderer/Painting/ElementStyle.h"
|
#include "Renderer/Painting/ElementStyle.h"
|
||||||
|
#include "Renderer/Painting/MaterialStyleFill.h"
|
||||||
|
|
||||||
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
|
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
|
||||||
using namespace Renderer;
|
using namespace Renderer;
|
||||||
|
@ -12,13 +12,63 @@ namespace UnitTest
|
||||||
{
|
{
|
||||||
void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString& msg);
|
void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString& msg);
|
||||||
|
|
||||||
|
TEST_CLASS(ElementRendererFillTest)
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
char* argv[1];
|
||||||
|
int argc;
|
||||||
|
QPainterPath path;
|
||||||
|
public:
|
||||||
|
ElementRendererFillTest() :argv{ (char*)"" }, argc(1)
|
||||||
|
{
|
||||||
|
QQuickSvgParser::parsePathDataFast("M100,100C-.5,100,0,100.5,0,0L40,.07C40,59.5,39.5,60,100,60Z",
|
||||||
|
path);
|
||||||
|
QTransform transform;
|
||||||
|
//transform.scale(10, 10);
|
||||||
|
path = transform.map(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_METHOD_INITIALIZE(initialize)
|
||||||
|
{
|
||||||
|
qInstallMessageHandler(messageHandler);
|
||||||
|
QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
||||||
|
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
|
||||||
|
QApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
|
||||||
|
}
|
||||||
|
TEST_METHOD(TestFillPlain)
|
||||||
|
{
|
||||||
|
QApplication a(argc, argv);
|
||||||
|
class Style : public Renderer::ElementStyle
|
||||||
|
{
|
||||||
|
virtual std::vector<Renderer::BaseStyle> toBaseStyles() const override
|
||||||
|
{
|
||||||
|
|
||||||
|
return { BaseStyle(std::make_shared<TransformStyle>(),
|
||||||
|
std::make_shared<MaterialStyleFill>(
|
||||||
|
std::make_shared<FillPlain>(Material(QColor(255,255,0))))) };
|
||||||
|
}
|
||||||
|
} style;
|
||||||
|
TestGLWidget w(style, path);
|
||||||
|
w.show();
|
||||||
|
a.exec();
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
TEST_CLASS(ElementRendererStokeTypeTest)
|
TEST_CLASS(ElementRendererStokeTypeTest)
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
char* argv[1];
|
char* argv[1];
|
||||||
int argc;
|
int argc;
|
||||||
|
QPainterPath path;
|
||||||
public:
|
public:
|
||||||
ElementRendererStokeTypeTest() :argv{ (char*)"" }, argc(1) {}
|
ElementRendererStokeTypeTest() :argv{ (char*)"" }, argc(1)
|
||||||
|
{
|
||||||
|
QQuickSvgParser::parsePathDataFast("M292.82,107.78s0,0,0,0,0,3.59,0,7.62c0,3.85,0,5.78.06,6.43a19.94,19.94,0,0,0,2.87,7.58,15.85,15.85,0,0,0,6.61,6.23A14.75,14.75,0,0,0,310,137a11.69,11.69,0,0,0,7.59-2.92,11,11,0,0,0,3.2-6.84c.15-1.27.58-4.84-1.79-7.64a8.54,8.54,0,0,0-3.56-2.44c-1.32-.52-3.32-1.31-5.06-.33a5.41,5.41,0,0,0-2.14,3,3.48,3.48,0,0,0-.16,2.71c.78,1.86,3.36,2.14,3.47,2.15", path);
|
||||||
|
QTransform transform;
|
||||||
|
transform.scale(10, 10);
|
||||||
|
path = transform.map(path);
|
||||||
|
}
|
||||||
|
|
||||||
TEST_METHOD_INITIALIZE(initialize)
|
TEST_METHOD_INITIALIZE(initialize)
|
||||||
{
|
{
|
||||||
|
@ -44,7 +94,7 @@ namespace UnitTest
|
||||||
std::make_shared<StrokeRadialGradient>(materialMap, false))) };
|
std::make_shared<StrokeRadialGradient>(materialMap, false))) };
|
||||||
}
|
}
|
||||||
} style;
|
} style;
|
||||||
TestGLWidget w(style);
|
TestGLWidget w(style, path);
|
||||||
w.show();
|
w.show();
|
||||||
a.exec();
|
a.exec();
|
||||||
}
|
}
|
||||||
|
@ -65,7 +115,7 @@ namespace UnitTest
|
||||||
std::make_shared<StrokeRadialGradient>(materialMap, false))) };
|
std::make_shared<StrokeRadialGradient>(materialMap, false))) };
|
||||||
}
|
}
|
||||||
} style;
|
} style;
|
||||||
TestGLWidget w(style);
|
TestGLWidget w(style, path);
|
||||||
w.show();
|
w.show();
|
||||||
a.exec();
|
a.exec();
|
||||||
}
|
}
|
||||||
|
@ -86,7 +136,7 @@ namespace UnitTest
|
||||||
std::make_shared<StrokeRadialGradient>(materialMap, false))) };
|
std::make_shared<StrokeRadialGradient>(materialMap, false))) };
|
||||||
}
|
}
|
||||||
} style;
|
} style;
|
||||||
TestGLWidget w(style);
|
TestGLWidget w(style, path);
|
||||||
w.show();
|
w.show();
|
||||||
a.exec();
|
a.exec();
|
||||||
}
|
}
|
||||||
|
@ -107,7 +157,7 @@ namespace UnitTest
|
||||||
std::make_shared<StrokeRadialGradient>(materialMap, false))) };
|
std::make_shared<StrokeRadialGradient>(materialMap, false))) };
|
||||||
}
|
}
|
||||||
} style;
|
} style;
|
||||||
TestGLWidget w(style);
|
TestGLWidget w(style, path);
|
||||||
w.show();
|
w.show();
|
||||||
a.exec();
|
a.exec();
|
||||||
}
|
}
|
||||||
|
@ -128,7 +178,7 @@ namespace UnitTest
|
||||||
std::make_shared<StrokeRadialGradient>(materialMap, false))) };
|
std::make_shared<StrokeRadialGradient>(materialMap, false))) };
|
||||||
}
|
}
|
||||||
} style;
|
} style;
|
||||||
TestGLWidget w(style);
|
TestGLWidget w(style, path);
|
||||||
w.show();
|
w.show();
|
||||||
a.exec();
|
a.exec();
|
||||||
}
|
}
|
||||||
|
@ -139,8 +189,15 @@ namespace UnitTest
|
||||||
private:
|
private:
|
||||||
char* argv[1];
|
char* argv[1];
|
||||||
int argc;
|
int argc;
|
||||||
|
QPainterPath path;
|
||||||
public:
|
public:
|
||||||
ElementRendererStokeMaterialTest() :argv{ (char*)"" }, argc(1) {}
|
ElementRendererStokeMaterialTest() :argv{ (char*)"" }, argc(1)
|
||||||
|
{
|
||||||
|
QQuickSvgParser::parsePathDataFast("M292.82,107.78s0,0,0,0,0,3.59,0,7.62c0,3.85,0,5.78.06,6.43a19.94,19.94,0,0,0,2.87,7.58,15.85,15.85,0,0,0,6.61,6.23A14.75,14.75,0,0,0,310,137a11.69,11.69,0,0,0,7.59-2.92,11,11,0,0,0,3.2-6.84c.15-1.27.58-4.84-1.79-7.64a8.54,8.54,0,0,0-3.56-2.44c-1.32-.52-3.32-1.31-5.06-.33a5.41,5.41,0,0,0-2.14,3,3.48,3.48,0,0,0-.16,2.71c.78,1.86,3.36,2.14,3.47,2.15", path);
|
||||||
|
QTransform transform;
|
||||||
|
transform.scale(10, 10);
|
||||||
|
path = transform.map(path);
|
||||||
|
}
|
||||||
TEST_METHOD(TestStrokePlain)
|
TEST_METHOD(TestStrokePlain)
|
||||||
{
|
{
|
||||||
QApplication a(argc, argv);
|
QApplication a(argc, argv);
|
||||||
|
@ -153,7 +210,7 @@ namespace UnitTest
|
||||||
std::make_shared<StrokePlain>(QColor(255,255,255),1,1))) };
|
std::make_shared<StrokePlain>(QColor(255,255,255),1,1))) };
|
||||||
}
|
}
|
||||||
} style;
|
} style;
|
||||||
TestGLWidget w(style);
|
TestGLWidget w(style, path);
|
||||||
w.show();
|
w.show();
|
||||||
a.exec();
|
a.exec();
|
||||||
}
|
}
|
||||||
|
@ -174,7 +231,7 @@ namespace UnitTest
|
||||||
std::make_shared<StrokeRadialGradient>(materialMap, false))) };
|
std::make_shared<StrokeRadialGradient>(materialMap, false))) };
|
||||||
}
|
}
|
||||||
} style;
|
} style;
|
||||||
TestGLWidget w(style);
|
TestGLWidget w(style, path);
|
||||||
w.show();
|
w.show();
|
||||||
a.exec();
|
a.exec();
|
||||||
}
|
}
|
||||||
|
@ -195,7 +252,7 @@ namespace UnitTest
|
||||||
std::make_shared<StrokeRadialGradient>(materialMap, true))) };
|
std::make_shared<StrokeRadialGradient>(materialMap, true))) };
|
||||||
}
|
}
|
||||||
} style;
|
} style;
|
||||||
TestGLWidget w(style);
|
TestGLWidget w(style, path);
|
||||||
w.show();
|
w.show();
|
||||||
a.exec();
|
a.exec();
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,29 +16,25 @@ namespace UnitTest
|
||||||
private:
|
private:
|
||||||
Renderer::ElementRenderer& renderer;
|
Renderer::ElementRenderer& renderer;
|
||||||
Renderer::ElementStyle& style;
|
Renderer::ElementStyle& style;
|
||||||
|
QPainterPath& path;
|
||||||
public:
|
public:
|
||||||
TestGLWidget(Renderer::ElementStyle& style, QWidget* parent = nullptr)
|
TestGLWidget(Renderer::ElementStyle& style, QPainterPath& path, QWidget* parent = nullptr)
|
||||||
: QOpenGLWidget(parent), renderer(*Renderer::ElementRenderer::instance()), style(style) {};
|
: QOpenGLWidget(parent), renderer(*Renderer::ElementRenderer::instance()), style(style), path(path) {};
|
||||||
void initializeGL() override
|
void initializeGL() override
|
||||||
{
|
{
|
||||||
initializeOpenGLFunctions();
|
initializeOpenGLFunctions();
|
||||||
};
|
};
|
||||||
void paintGL() override
|
void paintGL() override
|
||||||
{
|
{
|
||||||
glClearColor(219/255., 78/255., 32/255., 1.0);
|
glClearColor(219 / 255., 78 / 255., 32 / 255., 1.0);
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
QPainterPath path;
|
|
||||||
QQuickSvgParser::parsePathDataFast("M292.82,107.78s0,0,0,0,0,3.59,0,7.62c0,3.85,0,5.78.06,6.43a19.94,19.94,0,0,0,2.87,7.58,15.85,15.85,0,0,0,6.61,6.23A14.75,14.75,0,0,0,310,137a11.69,11.69,0,0,0,7.59-2.92,11,11,0,0,0,3.2-6.84c.15-1.27.58-4.84-1.79-7.64a8.54,8.54,0,0,0-3.56-2.44c-1.32-.52-3.32-1.31-5.06-.33a5.41,5.41,0,0,0-2.14,3,3.48,3.48,0,0,0-.16,2.71c.78,1.86,3.36,2.14,3.47,2.15", path);
|
|
||||||
path = PainterPathUtil::monotonization(path);
|
|
||||||
QTransform transform;
|
|
||||||
transform.scale(10, 10);
|
|
||||||
path = transform.map(path);
|
|
||||||
float pixelRatio = devicePixelRatioF();
|
float pixelRatio = devicePixelRatioF();
|
||||||
auto [img, pos] = renderer.drawElement(path, style, pixelRatio);
|
auto [img, pos] = renderer.drawElement(path, style, pixelRatio);
|
||||||
QPainter painter(this);
|
QPainter painter(this);
|
||||||
painter.setRenderHint(QPainter::SmoothPixmapTransform);
|
painter.setRenderHint(QPainter::SmoothPixmapTransform);
|
||||||
painter.setRenderHint(QPainter::HighQualityAntialiasing);
|
painter.setRenderHint(QPainter::HighQualityAntialiasing);
|
||||||
painter.drawImage(QRectF(QPointF(0, 0), img.size()/pixelRatio), img);
|
painter.drawImage(QRectF(QPointF(0, 0), img.size() / pixelRatio), img);
|
||||||
};
|
};
|
||||||
void resizeGL(int w, int h) override {};
|
void resizeGL(int w, int h) override {};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue