diff --git a/src/Mod/TechDraw/Gui/QGIFace.cpp b/src/Mod/TechDraw/Gui/QGIFace.cpp index 91f5ef9093..b8174c958e 100644 --- a/src/Mod/TechDraw/Gui/QGIFace.cpp +++ b/src/Mod/TechDraw/Gui/QGIFace.cpp @@ -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) diff --git a/src/Mod/TechDraw/Gui/QGIFace.h b/src/Mod/TechDraw/Gui/QGIFace.h index 38e00803f0..0e1ffdf7b1 100644 --- a/src/Mod/TechDraw/Gui/QGIFace.h +++ b/src/Mod/TechDraw/Gui/QGIFace.h @@ -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; // diff --git a/src/Mod/TechDraw/Gui/QGIViewPart.cpp b/src/Mod/TechDraw/Gui/QGIViewPart.cpp index 2555e23061..7ff8728f90 100644 --- a/src/Mod/TechDraw/Gui/QGIViewPart.cpp +++ b/src/Mod/TechDraw/Gui/QGIViewPart.cpp @@ -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(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(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()); } } } diff --git a/src/Mod/TechDraw/Gui/QGIViewPart.h b/src/Mod/TechDraw/Gui/QGIViewPart.h index 6ec25fabb2..f9a6a1d8cf 100644 --- a/src/Mod/TechDraw/Gui/QGIViewPart.h +++ b/src/Mod/TechDraw/Gui/QGIViewPart.h @@ -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 deleteItems; }; diff --git a/src/Mod/TechDraw/Gui/QGVPage.cpp b/src/Mod/TechDraw/Gui/QGVPage.cpp index 7afa054883..f2165aca39 100644 --- a/src/Mod/TechDraw/Gui/QGVPage.cpp +++ b/src/Mod/TechDraw/Gui/QGVPage.cpp @@ -743,8 +743,8 @@ void QGVPage::refreshViews(void) QList 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 sceneItems = scene()->items(); for (auto& qgi:sceneItems) { QGIViewPart* qgiPart = dynamic_cast(qgi); if(qgiPart) { - QList partChildren = qgiPart->childItems(); - int faceItemType = QGraphicsItem::UserType + 104; - for (auto& c:partChildren) { - if (c->type() == faceItemType) { - static_cast(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(); } diff --git a/src/Mod/TechDraw/Gui/QGVPage.h b/src/Mod/TechDraw/Gui/QGVPage.h index fbddd2f3c4..52bbde1583 100644 --- a/src/Mod/TechDraw/Gui/QGVPage.h +++ b/src/Mod/TechDraw/Gui/QGVPage.h @@ -110,7 +110,7 @@ public: TechDraw::DrawPage * getDrawPage(); - void toggleHatch(bool enable); + void setExporting(bool enable); virtual void refreshViews(void);