Skip to content

Commit

Permalink
[TD]use shared renderer for svg tiles
Browse files Browse the repository at this point in the history
  • Loading branch information
WandererFan committed Jul 24, 2023
1 parent 20768ba commit be6484b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/Mod/TechDraw/Gui/QGIFace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ QGIFace::QGIFace(int index) :
setFillMode(PlainFill);
setFill(m_colDefFill, m_styleDef);
}

m_sharedRender = new QSvgRenderer();
}

QGIFace::~QGIFace()
Expand Down Expand Up @@ -540,16 +542,19 @@ void QGIFace::buildSvgHatch()
before = QString::fromStdString(SVGCOLPREFIX + SVGCOLDEFAULT).toUtf8();
after = QString::fromStdString(SVGCOLPREFIX + m_svgCol).toUtf8();
QByteArray colorXML = m_svgXML.replace(before, after);
if (!m_sharedRender->load(colorXML)) {
Base::Console().Message("QGIF::buildSvgHatch - failed to load svg string\n");
return;
}
long int tileCount = 0;
for (int iw = 0; iw < int(nw); iw++) {
for (int ih = 0; ih < int(nh); ih++) {
QGCustomSvg* tile = new QGCustomSvg();
tile->setScale(m_fillScale);
if (tile->load(&colorXML)) {
tile->setParentItem(m_svgHatchArea);
tile->setPos(iw*wTile + getHatchOffset().x,
-h + ih*hTile + getHatchOffset().y);
}
tile->setSharedRenderer(m_sharedRender);
tile->setParentItem(m_svgHatchArea);
tile->setPos(iw*wTile + getHatchOffset().x,
-h + ih*hTile + getHatchOffset().y);
tileCount++;
if (tileCount > m_maxTile) {
Base::Console().Warning("SVG tile count exceeded: %ld\n", tileCount);
Expand Down
3 changes: 3 additions & 0 deletions src/Mod/TechDraw/Gui/QGIFace.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

#include <QByteArray>
#include <QPixmap>
#include <QSvgRenderer>

#include <App/Material.h>

Expand Down Expand Up @@ -168,6 +169,8 @@ class QGIFace : public QGIPrimPath
double m_hatchRotation;
Base::Vector3d m_hatchOffset;

QSvgRenderer *m_sharedRender;

};

}
Expand Down

0 comments on commit be6484b

Please sign in to comment.