[TD]fix Svg hatch on export
This commit is contained in:
@@ -68,7 +68,8 @@ using namespace TechDrawGui;
|
||||
using namespace TechDraw;
|
||||
|
||||
QGIFace::QGIFace(int index) :
|
||||
projIndex(index)
|
||||
projIndex(index),
|
||||
m_hideSvgTiles(false)
|
||||
{
|
||||
m_segCount = 0;
|
||||
// setFillMode(NoFill);
|
||||
@@ -139,13 +140,16 @@ void QGIFace::draw()
|
||||
m_fillStyleCurrent = m_styleNormal;
|
||||
loadSvgHatch(m_fileSpec);
|
||||
buildSvgHatch();
|
||||
toggleSvg(true);
|
||||
if (m_hideSvgTiles) {
|
||||
m_rect->hide();
|
||||
} else {
|
||||
m_rect->show();
|
||||
}
|
||||
} else if ((ext.toUpper() == QString::fromUtf8("JPG")) ||
|
||||
(ext.toUpper() == QString::fromUtf8("PNG")) ||
|
||||
(ext.toUpper() == QString::fromUtf8("JPEG")) ||
|
||||
(ext.toUpper() == QString::fromUtf8("BMP")) ) {
|
||||
setFillMode(BitmapFill);
|
||||
toggleSvg(false);
|
||||
m_fillStyleCurrent = Qt::TexturePattern;
|
||||
m_texture = textureFromBitmap(m_fileSpec);
|
||||
m_brush.setTexture(m_texture);
|
||||
@@ -195,7 +199,7 @@ void QGIFace::setDrawEdges(bool b) {
|
||||
void QGIFace::setHatchFile(std::string fileSpec)
|
||||
{
|
||||
m_fileSpec = fileSpec;
|
||||
}
|
||||
}
|
||||
|
||||
void QGIFace::loadSvgHatch(std::string fileSpec)
|
||||
{
|
||||
@@ -546,7 +550,7 @@ void QGIFace::buildSvgHatch()
|
||||
|
||||
void QGIFace::clearSvg()
|
||||
{
|
||||
toggleSvg(false);
|
||||
hideSvg(true);
|
||||
}
|
||||
|
||||
//this isn't used currently
|
||||
@@ -578,14 +582,9 @@ void QGIFace::setHatchScale(double s)
|
||||
}
|
||||
|
||||
//QtSvg does not handle clipping, so we must be able to turn the hatching on/off
|
||||
void QGIFace::toggleSvg(bool b)
|
||||
void QGIFace::hideSvg(bool b)
|
||||
{
|
||||
if (b) {
|
||||
m_rect->show();
|
||||
} else {
|
||||
m_rect->hide();
|
||||
}
|
||||
update();
|
||||
m_hideSvgTiles = b;
|
||||
}
|
||||
|
||||
QPixmap QGIFace::textureFromBitmap(std::string fileSpec)
|
||||
|
||||
@@ -90,7 +90,7 @@ public:
|
||||
void setHatchFile(std::string fileSpec);
|
||||
void loadSvgHatch(std::string fileSpec);
|
||||
void buildSvgHatch(void);
|
||||
void toggleSvg(bool b);
|
||||
void hideSvg(bool b);
|
||||
void clearSvg(void);
|
||||
|
||||
//PAT fill parms & methods
|
||||
@@ -141,6 +141,8 @@ protected:
|
||||
long int m_maxSeg;
|
||||
long int m_maxTile;
|
||||
|
||||
bool m_hideSvgTiles;
|
||||
|
||||
|
||||
private:
|
||||
QPixmap m_texture; //
|
||||
|
||||
@@ -90,7 +90,8 @@ using namespace TechDrawGui;
|
||||
|
||||
const float lineScaleFactor = Rez::guiX(1.); // temp fiddle for devel
|
||||
|
||||
QGIViewPart::QGIViewPart()
|
||||
QGIViewPart::QGIViewPart() :
|
||||
m_isExporting(false)
|
||||
{
|
||||
setCacheMode(QGraphicsItem::NoCache);
|
||||
setHandlesChildEvents(false);
|
||||
@@ -508,17 +509,24 @@ void QGIViewPart::drawViewPart()
|
||||
}
|
||||
} else if (fHatch) {
|
||||
if (!fHatch->HatchPattern.isEmpty()) {
|
||||
newFace->isHatched(true);
|
||||
newFace->setFillMode(QGIFace::FromFile);
|
||||
newFace->setHatchFile(fHatch->HatchPattern.getValue());
|
||||
Gui::ViewProvider* gvp = QGIView::getViewProvider(fHatch);
|
||||
ViewProviderHatch* hatchVp = dynamic_cast<ViewProviderHatch*>(gvp);
|
||||
if (hatchVp != nullptr) {
|
||||
double hatchScale = hatchVp->HatchScale.getValue();
|
||||
if (hatchScale > 0.0) {
|
||||
newFace->setHatchScale(hatchVp->HatchScale.getValue());
|
||||
if (getExporting()) {
|
||||
newFace->hideSvg(true);
|
||||
newFace->isHatched(false);
|
||||
newFace->setFillMode(QGIFace::PlainFill);
|
||||
} else {
|
||||
newFace->hideSvg(false);
|
||||
newFace->isHatched(true);
|
||||
newFace->setFillMode(QGIFace::FromFile);
|
||||
newFace->setHatchFile(fHatch->HatchPattern.getValue());
|
||||
Gui::ViewProvider* gvp = QGIView::getViewProvider(fHatch);
|
||||
ViewProviderHatch* hatchVp = dynamic_cast<ViewProviderHatch*>(gvp);
|
||||
if (hatchVp != nullptr) {
|
||||
double hatchScale = hatchVp->HatchScale.getValue();
|
||||
if (hatchScale > 0.0) {
|
||||
newFace->setHatchScale(hatchVp->HatchScale.getValue());
|
||||
}
|
||||
newFace->setHatchColor(hatchVp->HatchColor.getValue());
|
||||
}
|
||||
newFace->setHatchColor(hatchVp->HatchColor.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,6 +90,8 @@ public:
|
||||
bool large_arc_flag, bool sweep_flag,
|
||||
double x, double y,
|
||||
double curx, double cury);
|
||||
void setExporting(bool b) { m_isExporting = b; }
|
||||
bool getExporting(void) { return m_isExporting; }
|
||||
|
||||
protected:
|
||||
QPainterPath drawPainterPath(TechDraw::BaseGeom *baseGeom) const;
|
||||
@@ -109,6 +111,8 @@ protected:
|
||||
bool formatGeomFromCosmetic(std::string cTag, QGIEdge* item);
|
||||
bool formatGeomFromCenterLine(std::string cTag, QGIEdge* item);
|
||||
|
||||
bool m_isExporting;
|
||||
|
||||
private:
|
||||
QList<QGraphicsItem*> deleteItems;
|
||||
};
|
||||
|
||||
@@ -743,8 +743,8 @@ void QGVPage::refreshViews(void)
|
||||
QList<QGraphicsItem*> qgiv;
|
||||
//find only QGIV's
|
||||
for (auto q: list) {
|
||||
QString tileFamily = QString::fromUtf8("QGIV");
|
||||
if (tileFamily == q->data(0).toString()) {
|
||||
QString viewFamily = QString::fromUtf8("QGIV");
|
||||
if (viewFamily == q->data(0).toString()) {
|
||||
qgiv.push_back(q);
|
||||
}
|
||||
}
|
||||
@@ -756,19 +756,14 @@ void QGVPage::refreshViews(void)
|
||||
}
|
||||
}
|
||||
|
||||
void QGVPage::toggleHatch(bool enable)
|
||||
void QGVPage::setExporting(bool enable)
|
||||
{
|
||||
// Base::Console().Message("QGVP::setExporting(%d)\n", enable);
|
||||
QList<QGraphicsItem*> sceneItems = scene()->items();
|
||||
for (auto& qgi:sceneItems) {
|
||||
QGIViewPart* qgiPart = dynamic_cast<QGIViewPart *>(qgi);
|
||||
if(qgiPart) {
|
||||
QList<QGraphicsItem*> partChildren = qgiPart->childItems();
|
||||
int faceItemType = QGraphicsItem::UserType + 104;
|
||||
for (auto& c:partChildren) {
|
||||
if (c->type() == faceItemType) {
|
||||
static_cast<QGIFace*>(c)->toggleSvg(enable);
|
||||
}
|
||||
}
|
||||
qgiPart->setExporting(enable);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -810,7 +805,7 @@ void QGVPage::saveSvg(QString filename)
|
||||
bool saveState = m_vpPage->getFrameState();
|
||||
m_vpPage->setFrameState(false);
|
||||
m_vpPage->setTemplateMarkers(false);
|
||||
toggleHatch(false);
|
||||
setExporting(true);
|
||||
|
||||
// Here we temporarily hide the page template, because Qt would otherwise convert the SVG template
|
||||
// texts into series of paths, making the later document edits practically unfeasible.
|
||||
@@ -839,7 +834,7 @@ void QGVPage::saveSvg(QString filename)
|
||||
|
||||
m_vpPage->setFrameState(saveState);
|
||||
m_vpPage->setTemplateMarkers(saveState);
|
||||
toggleHatch(true);
|
||||
setExporting(false);
|
||||
if (templateVisible) {
|
||||
svgTemplate->show();
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ public:
|
||||
|
||||
TechDraw::DrawPage * getDrawPage();
|
||||
|
||||
void toggleHatch(bool enable);
|
||||
void setExporting(bool enable);
|
||||
virtual void refreshViews(void);
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user