修改了一些Bug
parent
3efb7973b0
commit
e19aac0dd2
|
@ -62,14 +62,20 @@ QMap<QString, QString> SvgFileLoader::transformStyle(QString style) {
|
||||||
return resStyleMap;
|
return resStyleMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
QVector<QPointF> SvgFileLoader::transformPoints(QString points) {
|
QPolygonF SvgFileLoader::transformPoints(QString points) {
|
||||||
QVector<QPointF> resPointVector;
|
QPolygonF resPointVector;
|
||||||
QPointF pointBegin(0, 0);
|
QPointF point(0, 0);
|
||||||
|
bool isX = true;
|
||||||
for (auto& onePoint : points.split(' ')) {
|
for (auto& onePoint : points.split(' ')) {
|
||||||
QString x = *(onePoint.split(',').begin());
|
for (auto& value : onePoint.split(',')) {
|
||||||
QString y = *(onePoint.split(',').rbegin());
|
if (value.trimmed().isEmpty()) continue;
|
||||||
resPointVector.push_back(QPointF(x.toDouble(), y.toDouble()));
|
if (isX) point.setX(value.toDouble());
|
||||||
|
else {
|
||||||
|
point.setY(value.toDouble());
|
||||||
|
resPointVector.push_back(point);
|
||||||
|
}
|
||||||
|
isX = !isX;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return resPointVector;
|
return resPointVector;
|
||||||
}
|
}
|
||||||
|
@ -79,6 +85,9 @@ void SvgFileLoader::handleLabelG(QPainterPath& painterPath) {
|
||||||
if (attr.name().toString() == QLatin1String("style")) {
|
if (attr.name().toString() == QLatin1String("style")) {
|
||||||
styleMap = transformStyle(attr.value().toLatin1());
|
styleMap = transformStyle(attr.value().toLatin1());
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
styleMap.insert(attr.name().toLatin1(), attr.value().toLatin1());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
existFatherLabelG = true;
|
existFatherLabelG = true;
|
||||||
qDebug() << styleMap;
|
qDebug() << styleMap;
|
||||||
|
@ -90,9 +99,12 @@ void SvgFileLoader::handleLabelPath(QPainterPath& painterPath) {
|
||||||
if (attr.name().toString() == QLatin1String("d")) {
|
if (attr.name().toString() == QLatin1String("d")) {
|
||||||
QQuickSvgParser::parsePathDataFast(attr.value().toLatin1(), painterPath);
|
QQuickSvgParser::parsePathDataFast(attr.value().toLatin1(), painterPath);
|
||||||
}
|
}
|
||||||
if (attr.name().toString() == QLatin1String("style")) {
|
else if (attr.name().toString() == QLatin1String("style")) {
|
||||||
labelStyle = transformStyle(attr.value().toLatin1());
|
labelStyle = transformStyle(attr.value().toLatin1());
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
labelStyle.insert(attr.name().toLatin1(), attr.value().toLatin1());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,20 +114,21 @@ void SvgFileLoader::handleLabelRect(QPainterPath& painterPath) {
|
||||||
for (auto& attr : xmlReader->attributes()) {
|
for (auto& attr : xmlReader->attributes()) {
|
||||||
if (attr.name().toString() == QLatin1String("x")) {
|
if (attr.name().toString() == QLatin1String("x")) {
|
||||||
xBegin = attr.value().toDouble();
|
xBegin = attr.value().toDouble();
|
||||||
}
|
} else if (attr.name().toString() == QLatin1String("y")) {
|
||||||
if (attr.name().toString() == QLatin1String("y")) {
|
|
||||||
yBegin = attr.value().toDouble();
|
yBegin = attr.value().toDouble();
|
||||||
}
|
} else if (attr.name().toString() == QLatin1String("width")) {
|
||||||
if (attr.name().toString() == QLatin1String("width")) {
|
|
||||||
width = attr.value().toDouble();
|
width = attr.value().toDouble();
|
||||||
}
|
} else if (attr.name().toString() == QLatin1String("height")) {
|
||||||
if (attr.name().toString() == QLatin1String("height")) {
|
|
||||||
height = attr.value().toDouble();
|
height = attr.value().toDouble();
|
||||||
}
|
}
|
||||||
if (attr.name().toString() == QLatin1String("style")) {
|
else if (attr.name().toString() == QLatin1String("style")) {
|
||||||
labelStyle = transformStyle(attr.value().toLatin1());
|
labelStyle = transformStyle(attr.value().toLatin1());
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
labelStyle.insert(attr.name().toLatin1(), attr.value().toLatin1());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
qDebug() << labelStyle;
|
||||||
painterPath.addRect(xBegin, yBegin, xBegin + width, yBegin + height);
|
painterPath.addRect(xBegin, yBegin, xBegin + width, yBegin + height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,17 +138,19 @@ void SvgFileLoader::handleLabelCircle(QPainterPath& painterPath) {
|
||||||
for (auto& attr : xmlReader->attributes()) {
|
for (auto& attr : xmlReader->attributes()) {
|
||||||
if (attr.name().toString() == QLatin1String("cx")) {
|
if (attr.name().toString() == QLatin1String("cx")) {
|
||||||
cx = attr.value().toDouble();
|
cx = attr.value().toDouble();
|
||||||
}
|
} else if (attr.name().toString() == QLatin1String("cy")) {
|
||||||
if (attr.name().toString() == QLatin1String("cy")) {
|
|
||||||
cy = attr.value().toDouble();
|
cy = attr.value().toDouble();
|
||||||
}
|
} else if (attr.name().toString() == QLatin1String("r")) {
|
||||||
if (attr.name().toString() == QLatin1String("r")) {
|
|
||||||
r = attr.value().toDouble();
|
r = attr.value().toDouble();
|
||||||
}
|
}
|
||||||
if (attr.name().toString() == QLatin1String("style")) {
|
else if (attr.name().toString() == QLatin1String("style")) {
|
||||||
labelStyle = transformStyle(attr.value().toLatin1());
|
labelStyle = transformStyle(attr.value().toLatin1());
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
labelStyle.insert(attr.name().toLatin1(), attr.value().toLatin1());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
qDebug() << labelStyle;
|
||||||
painterPath.addEllipse(cx, cy, r, r);
|
painterPath.addEllipse(cx, cy, r, r);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -145,20 +160,20 @@ void SvgFileLoader::handleLabelEllipse(QPainterPath& painterPath) {
|
||||||
for (auto& attr : xmlReader->attributes()) {
|
for (auto& attr : xmlReader->attributes()) {
|
||||||
if (attr.name().toString() == QLatin1String("cx")) {
|
if (attr.name().toString() == QLatin1String("cx")) {
|
||||||
cx = attr.value().toDouble();
|
cx = attr.value().toDouble();
|
||||||
}
|
} else if (attr.name().toString() == QLatin1String("cy")) {
|
||||||
if (attr.name().toString() == QLatin1String("cy")) {
|
|
||||||
cy = attr.value().toDouble();
|
cy = attr.value().toDouble();
|
||||||
}
|
} else if (attr.name().toString() == QLatin1String("rx")) {
|
||||||
if (attr.name().toString() == QLatin1String("rx")) {
|
|
||||||
rx = attr.value().toDouble();
|
rx = attr.value().toDouble();
|
||||||
}
|
} else if (attr.name().toString() == QLatin1String("ry")) {
|
||||||
if (attr.name().toString() == QLatin1String("ry")) {
|
|
||||||
rx = attr.value().toDouble();
|
rx = attr.value().toDouble();
|
||||||
}
|
} else if (attr.name().toString() == QLatin1String("style")) {
|
||||||
if (attr.name().toString() == QLatin1String("style")) {
|
|
||||||
labelStyle = transformStyle(attr.value().toLatin1());
|
labelStyle = transformStyle(attr.value().toLatin1());
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
labelStyle.insert(attr.name().toLatin1(), attr.value().toLatin1());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
qDebug() << labelStyle;
|
||||||
painterPath.addEllipse(cx, cy, rx, ry);
|
painterPath.addEllipse(cx, cy, rx, ry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -169,10 +184,14 @@ void SvgFileLoader::handleLabelPolyline(QPainterPath& painterPath) {
|
||||||
QPolygonF points = transformPoints(attr.value().toLatin1());
|
QPolygonF points = transformPoints(attr.value().toLatin1());
|
||||||
painterPath.addPolygon(points);
|
painterPath.addPolygon(points);
|
||||||
}
|
}
|
||||||
if (attr.name().toString() == QLatin1String("style")) {
|
else if (attr.name().toString() == QLatin1String("style")) {
|
||||||
labelStyle = transformStyle(attr.value().toLatin1());
|
labelStyle = transformStyle(attr.value().toLatin1());
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
labelStyle.insert(attr.name().toLatin1(), attr.value().toLatin1());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
qDebug() << labelStyle;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SvgFileLoader::handleLabelPolygon(QPainterPath & painterPath) {
|
void SvgFileLoader::handleLabelPolygon(QPainterPath & painterPath) {
|
||||||
|
@ -182,9 +201,13 @@ void SvgFileLoader::handleLabelPolygon(QPainterPath & painterPath) {
|
||||||
QPolygonF points = transformPoints(attr.value().toLatin1());
|
QPolygonF points = transformPoints(attr.value().toLatin1());
|
||||||
points.push_back(*points.begin());
|
points.push_back(*points.begin());
|
||||||
painterPath.addPolygon(points);
|
painterPath.addPolygon(points);
|
||||||
}
|
}
|
||||||
if (attr.name().toString() == QLatin1String("style")) {
|
else if (attr.name().toString() == QLatin1String("style")) {
|
||||||
labelStyle = transformStyle(attr.value().toLatin1());
|
labelStyle = transformStyle(attr.value().toLatin1());
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
labelStyle.insert(attr.name().toLatin1(), attr.value().toLatin1());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
qDebug() << labelStyle;
|
||||||
}
|
}
|
|
@ -13,7 +13,7 @@ private:
|
||||||
bool existFatherLabelG;
|
bool existFatherLabelG;
|
||||||
QMap<QString, QString> styleMap;
|
QMap<QString, QString> styleMap;
|
||||||
std::shared_ptr<QXmlStreamReader> xmlReader;
|
std::shared_ptr<QXmlStreamReader> xmlReader;
|
||||||
QVector<QPointF> transformPoints(QString points);
|
QPolygonF transformPoints(QString points);
|
||||||
QMap<QString, QString> transformStyle(QString style);
|
QMap<QString, QString> transformStyle(QString style);
|
||||||
void handleLabelG(QPainterPath& painterPath);
|
void handleLabelG(QPainterPath& painterPath);
|
||||||
void handleLabelPath(QPainterPath& painterPath);
|
void handleLabelPath(QPainterPath& painterPath);
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
#include "Renderer/Painting/CubicBezier.h"
|
#include "Renderer/Painting/CubicBezier.h"
|
||||||
#include <QGuiApplication>
|
#include <QGuiApplication>
|
||||||
#include <QtWidgets/QApplication>
|
#include <QtWidgets/QApplication>
|
||||||
#include "Editor/third-party modules/util/SvgFileLoader.h"
|
|
||||||
|
|
||||||
using Renderer::CubicBezier;
|
using Renderer::CubicBezier;
|
||||||
|
|
||||||
|
@ -11,11 +10,12 @@ extern "C"
|
||||||
_declspec(dllexport) unsigned long NvOptimusEnablement = 0x00000001;
|
_declspec(dllexport) unsigned long NvOptimusEnablement = 0x00000001;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
SvgFileLoader svgLoader;
|
QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
||||||
QPainterPath painterPath;
|
QApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
|
||||||
svgLoader.loadSvgFile("D:/login.svg", painterPath);
|
QApplication a(argc, argv);
|
||||||
qDebug() << painterPath;
|
MainWindow w;
|
||||||
return 0;
|
w.show();
|
||||||
|
return a.exec();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue