From 072b6f11b18fbc2e4d072aad0a4ce932a4ecc5a8 Mon Sep 17 00:00:00 2001 From: wandererfan Date: Tue, 17 Mar 2020 19:51:29 -0400 Subject: [PATCH] [TD]make geom hatch lines on property change --- src/Mod/TechDraw/App/DrawViewSection.cpp | 58 ++++++++++++++---------- src/Mod/TechDraw/App/DrawViewSection.h | 1 + src/Mod/TechDraw/Gui/QGIViewPart.cpp | 4 +- 3 files changed, 36 insertions(+), 27 deletions(-) diff --git a/src/Mod/TechDraw/App/DrawViewSection.cpp b/src/Mod/TechDraw/App/DrawViewSection.cpp index 286ae99af1..897a15fbf1 100644 --- a/src/Mod/TechDraw/App/DrawViewSection.cpp +++ b/src/Mod/TechDraw/App/DrawViewSection.cpp @@ -193,7 +193,9 @@ void DrawViewSection::onChanged(const App::Property* prop) dv->requestPaint(); } } else if (prop == &CutSurfaceDisplay) { -// Base::Console().Message("DVS::onChanged(%s)\n",prop->getName()); + if (CutSurfaceDisplay.isValue("PatHatch")) { + makeLineSets(); + } } if ((prop == &FileHatchPattern) && @@ -219,37 +221,42 @@ void DrawViewSection::onChanged(const App::Property* prop) if (prop == &FileGeomPattern || prop == &NameGeomPattern ) { - if (!FileGeomPattern.isEmpty()) { - std::string fileSpec = FileGeomPattern.getValue(); - Base::FileInfo fi(fileSpec); - std::string ext = fi.extension(); - if (!fi.isReadable()) { - Base::Console().Message("%s can not read hatch file: %s\n", getNameInDocument(), fileSpec.c_str()); - Base::Console().Message("%s using included hatch file.\n", getNameInDocument()); - } else { - if ( (ext == "pat") || - (ext == "PAT") ) { - if ((!fileSpec.empty()) && - (!NameGeomPattern.isEmpty())) { - std::vector specs = - DrawGeomHatch::getDecodedSpecsFromFile(fileSpec, - NameGeomPattern.getValue()); - m_lineSets.clear(); - for (auto& hl: specs) { - //hl.dump("hl from section"); - LineSet ls; - ls.setPATLineSpec(hl); - m_lineSets.push_back(ls); - } + makeLineSets(); + } + DrawView::onChanged(prop); +} + +void DrawViewSection::makeLineSets(void) +{ +// Base::Console().Message("DVS::makeLineSets()\n"); + if (!FileGeomPattern.isEmpty()) { + std::string fileSpec = FileGeomPattern.getValue(); + Base::FileInfo fi(fileSpec); + std::string ext = fi.extension(); + if (!fi.isReadable()) { + Base::Console().Message("%s can not read hatch file: %s\n", getNameInDocument(), fileSpec.c_str()); + Base::Console().Message("%s using included hatch file.\n", getNameInDocument()); + } else { + if ( (ext == "pat") || + (ext == "PAT") ) { + if ((!fileSpec.empty()) && + (!NameGeomPattern.isEmpty())) { + std::vector specs = + DrawGeomHatch::getDecodedSpecsFromFile(fileSpec, + NameGeomPattern.getValue()); + m_lineSets.clear(); + for (auto& hl: specs) { + //hl.dump("hl from section"); + LineSet ls; + ls.setPATLineSpec(hl); + m_lineSets.push_back(ls); } } } } } - DrawView::onChanged(prop); } - //this could probably always use FileHatchPattern as input? void DrawViewSection::replaceSvgIncluded(std::string newSvgFile) { @@ -907,6 +914,7 @@ void DrawViewSection::onDocumentRestored() if (PatIncluded.isEmpty()) { setupPatIncluded(); } + makeLineSets(); } } DrawViewPart::onDocumentRestored(); diff --git a/src/Mod/TechDraw/App/DrawViewSection.h b/src/Mod/TechDraw/App/DrawViewSection.h index d459b47019..b999c0bf44 100644 --- a/src/Mod/TechDraw/App/DrawViewSection.h +++ b/src/Mod/TechDraw/App/DrawViewSection.h @@ -110,6 +110,7 @@ public: TopoDS_Compound getSectionFaces() { return sectionFaces;}; std::vector getSectionFaceWires(void) { return sectionFaceWires; } + void makeLineSets(void) ; std::vector getDrawableLines(int i = 0); std::vector getDecodedSpecsFromFile(std::string fileSpec, std::string myPattern); diff --git a/src/Mod/TechDraw/Gui/QGIViewPart.cpp b/src/Mod/TechDraw/Gui/QGIViewPart.cpp index 16e4de8c24..91d5cd9840 100644 --- a/src/Mod/TechDraw/Gui/QGIViewPart.cpp +++ b/src/Mod/TechDraw/Gui/QGIViewPart.cpp @@ -498,7 +498,7 @@ void QGIViewPart::drawViewPart() if (hatchScale > 0.0) { newFace->setHatchScale(fGeom->ScalePattern.getValue()); } - newFace->setHatchFile(fGeom->FilePattern.getValue()); + newFace->setHatchFile(fGeom->PatIncluded.getValue()); Gui::ViewProvider* gvp = QGIView::getViewProvider(fGeom); ViewProviderGeomHatch* geomVp = dynamic_cast(gvp); if (geomVp != nullptr) { @@ -517,7 +517,7 @@ void QGIViewPart::drawViewPart() newFace->hideSvg(false); newFace->isHatched(true); newFace->setFillMode(QGIFace::FromFile); - newFace->setHatchFile(fHatch->HatchPattern.getValue()); + newFace->setHatchFile(fHatch->SvgIncluded.getValue()); Gui::ViewProvider* gvp = QGIView::getViewProvider(fHatch); ViewProviderHatch* hatchVp = dynamic_cast(gvp); if (hatchVp != nullptr) {