增加了QPainterPath转为vector<>
parent
9e1ec3f848
commit
2af2464745
|
@ -110,6 +110,7 @@
|
||||||
<ClCompile Include="src\Editor\RightBar\LayerTreeWidget.cpp" />
|
<ClCompile Include="src\Editor\RightBar\LayerTreeWidget.cpp" />
|
||||||
<ClCompile Include="src\Editor\ThirdPartyLib\qquick\qquicksvgparser.cpp" />
|
<ClCompile Include="src\Editor\ThirdPartyLib\qquick\qquicksvgparser.cpp" />
|
||||||
<ClCompile Include="src\Editor\ThirdPartyLib\SvgHelper.cpp" />
|
<ClCompile Include="src\Editor\ThirdPartyLib\SvgHelper.cpp" />
|
||||||
|
<ClCompile Include="src\Editor\util\PainterPathUtil.cpp" />
|
||||||
<ClCompile Include="src\Editor\util\SvgFileLoader.cpp" />
|
<ClCompile Include="src\Editor\util\SvgFileLoader.cpp" />
|
||||||
<ClCompile Include="src\IconWidget.cpp" />
|
<ClCompile Include="src\IconWidget.cpp" />
|
||||||
<ClCompile Include="src\main.cpp" />
|
<ClCompile Include="src\main.cpp" />
|
||||||
|
@ -180,6 +181,7 @@
|
||||||
<ClInclude Include="src\Editor\ThirdPartyLib\qquick\qtquickglobal.h" />
|
<ClInclude Include="src\Editor\ThirdPartyLib\qquick\qtquickglobal.h" />
|
||||||
<ClInclude Include="src\Editor\ThirdPartyLib\qquick\qtquickglobal_p.h" />
|
<ClInclude Include="src\Editor\ThirdPartyLib\qquick\qtquickglobal_p.h" />
|
||||||
<ClInclude Include="src\Editor\ThirdPartyLib\SvgHelper.h" />
|
<ClInclude Include="src\Editor\ThirdPartyLib\SvgHelper.h" />
|
||||||
|
<ClInclude Include="src\Editor\util\PainterPathUtil.h" />
|
||||||
<ClInclude Include="src\Editor\util\SvgFileLoader.h" />
|
<ClInclude Include="src\Editor\util\SvgFileLoader.h" />
|
||||||
<ClInclude Include="src\Renderer\Painting\CubicBezierSignedDistance.h" />
|
<ClInclude Include="src\Renderer\Painting\CubicBezierSignedDistance.h" />
|
||||||
<ClInclude Include="src\Renderer\Painting\Element.h" />
|
<ClInclude Include="src\Renderer\Painting\Element.h" />
|
||||||
|
|
|
@ -192,6 +192,9 @@
|
||||||
<ClCompile Include="src\Editor\util\SvgFileLoader.cpp">
|
<ClCompile Include="src\Editor\util\SvgFileLoader.cpp">
|
||||||
<Filter>Source Files\Editor\util</Filter>
|
<Filter>Source Files\Editor\util</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="src\Editor\util\PainterPathUtil.cpp">
|
||||||
|
<Filter>Source Files\Editor\util</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<QtMoc Include="src\Renderer\RendererGLWidget.h">
|
<QtMoc Include="src\Renderer\RendererGLWidget.h">
|
||||||
|
@ -360,9 +363,6 @@
|
||||||
<ClInclude Include="src\Renderer\Painting\CubicBezierSignedDistance.h">
|
<ClInclude Include="src\Renderer\Painting\CubicBezierSignedDistance.h">
|
||||||
<Filter>Header Files\Renderer\Painting</Filter>
|
<Filter>Header Files\Renderer\Painting</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="src\Editor\third-party modules\util\SvgFileLoader.h">
|
|
||||||
<Filter>Header Files\Editor\util</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="src\Renderer\Painting\ElementStyle.h">
|
<ClInclude Include="src\Renderer\Painting\ElementStyle.h">
|
||||||
<Filter>Header Files\Renderer\Painting</Filter>
|
<Filter>Header Files\Renderer\Painting</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
@ -387,12 +387,12 @@
|
||||||
<ClInclude Include="src\Renderer\Painting\MaterialStyleFill.h">
|
<ClInclude Include="src\Renderer\Painting\MaterialStyleFill.h">
|
||||||
<Filter>Header Files\Renderer\Painting</Filter>
|
<Filter>Header Files\Renderer\Painting</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="src\Renderer\Painting\BaseStyle.h">
|
|
||||||
<Filter>Header Files\Renderer\Painting</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="src\Renderer\Painting\MaterialStyleStroke.h">
|
<ClInclude Include="src\Renderer\Painting\MaterialStyleStroke.h">
|
||||||
<Filter>Header Files\Renderer\Painting</Filter>
|
<Filter>Header Files\Renderer\Painting</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="src\Editor\util\PainterPathUtil.h">
|
||||||
|
<Filter>Header Files\Editor\util</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<QtRcc Include="MainWindow.qrc">
|
<QtRcc Include="MainWindow.qrc">
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#include "GraphicElement.h"
|
#include "GraphicElement.h"
|
||||||
#include "third-party modules/util/SvgFileLoader.h"
|
#include <util/SvgFileLoader.h>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
QPainterPath SimpleElement::getPaintObject() const
|
QPainterPath SimpleElement::getPaintObject() const
|
||||||
{
|
{
|
||||||
|
|
|
@ -0,0 +1,41 @@
|
||||||
|
#include "PainterPathUtil.h"
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
|
using Renderer::Point;
|
||||||
|
using std::vector;
|
||||||
|
|
||||||
|
vector<vector<Point> > PainterPathUtil::transformToLines(QPainterPath& painterPath) {
|
||||||
|
vector<Point> line; line.clear();
|
||||||
|
vector<vector<Point> > lines; lines.clear();
|
||||||
|
QPointF startPoint(0, 0);
|
||||||
|
Point point(0, 0);
|
||||||
|
for (int elementIndex = 0; elementIndex < painterPath.elementCount(); elementIndex++) {
|
||||||
|
auto element = painterPath.elementAt(elementIndex);
|
||||||
|
point = element;
|
||||||
|
qDebug() << element;
|
||||||
|
if (element.isMoveTo()) {
|
||||||
|
if (line.size() >= 2) {
|
||||||
|
lines.push_back(line);
|
||||||
|
}
|
||||||
|
line.clear();
|
||||||
|
line.push_back(point);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
line.push_back(point);
|
||||||
|
if (element.isLineTo()) {
|
||||||
|
lines.push_back(line);
|
||||||
|
}
|
||||||
|
if (element.isCurveTo()) {
|
||||||
|
point = painterPath.elementAt(++elementIndex);
|
||||||
|
line.push_back(point);
|
||||||
|
point = painterPath.elementAt(++elementIndex);
|
||||||
|
line.push_back(point);
|
||||||
|
lines.push_back(line);
|
||||||
|
}
|
||||||
|
line.clear();
|
||||||
|
line.push_back(point);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
line.clear();
|
||||||
|
return lines;
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
#pragma once
|
||||||
|
#include <vector>
|
||||||
|
#include <QPainterPath>
|
||||||
|
#include "../Renderer/Painting/Line.h"
|
||||||
|
|
||||||
|
using Renderer::Point;
|
||||||
|
|
||||||
|
class PainterPathUtil
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static std::vector<std::vector<Point> > transformToLines(QPainterPath& painterPath);
|
||||||
|
};
|
||||||
|
|
|
@ -151,7 +151,8 @@ void SvgFileLoader::handleLabelCircle(QPainterPath& painterPath) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
qDebug() << labelStyle;
|
qDebug() << labelStyle;
|
||||||
addEllipse(cx, cy, r, r, painterPath);
|
//addEllipse(cx, cy, r, r, painterPath);
|
||||||
|
painterPath.addEllipse(cx, cy, r, r);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SvgFileLoader::handleLabelEllipse(QPainterPath& painterPath) {
|
void SvgFileLoader::handleLabelEllipse(QPainterPath& painterPath) {
|
||||||
|
@ -174,7 +175,8 @@ void SvgFileLoader::handleLabelEllipse(QPainterPath& painterPath) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
qDebug() << labelStyle;
|
qDebug() << labelStyle;
|
||||||
addEllipse(cx, cy, rx, ry, painterPath);
|
//addEllipse(cx, cy, rx, ry, painterPath);
|
||||||
|
painterPath.addEllipse(cx, cy, rx, ry);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SvgFileLoader::handleLabelPolyline(QPainterPath& painterPath) {
|
void SvgFileLoader::handleLabelPolyline(QPainterPath& painterPath) {
|
||||||
|
|
|
@ -23,4 +23,5 @@ private:
|
||||||
void handleLabelEllipse(QPainterPath& painterPath);
|
void handleLabelEllipse(QPainterPath& painterPath);
|
||||||
void handleLabelPolyline(QPainterPath& painterPath);
|
void handleLabelPolyline(QPainterPath& painterPath);
|
||||||
void handleLabelPolygon(QPainterPath& painterPath);
|
void handleLabelPolygon(QPainterPath& painterPath);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -25,6 +25,11 @@ namespace Renderer
|
||||||
bool operator< (const Point& a) const {
|
bool operator< (const Point& a) const {
|
||||||
return fabs(x - a.x) <= eps ? y < a.y : x < a.x;
|
return fabs(x - a.x) <= eps ? y < a.y : x < a.x;
|
||||||
}
|
}
|
||||||
|
Point& operator= (const QPointF p){
|
||||||
|
x = p.x();
|
||||||
|
y = p.y();
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
operator glm::dvec2() {
|
operator glm::dvec2() {
|
||||||
return glm::dvec2(x, y);
|
return glm::dvec2(x, y);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue