Skip to content

Commit

Permalink
[TD]make geom hatch lines on property change
Browse files Browse the repository at this point in the history
  • Loading branch information
WandererFan committed Mar 20, 2020
1 parent 3c0d9d3 commit 072b6f1
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 27 deletions.
58 changes: 33 additions & 25 deletions src/Mod/TechDraw/App/DrawViewSection.cpp
Expand Up @@ -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) &&
Expand All @@ -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<PATLineSpec> 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<PATLineSpec> 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)
{
Expand Down Expand Up @@ -907,6 +914,7 @@ void DrawViewSection::onDocumentRestored()
if (PatIncluded.isEmpty()) {
setupPatIncluded();
}
makeLineSets();
}
}
DrawViewPart::onDocumentRestored();
Expand Down
1 change: 1 addition & 0 deletions src/Mod/TechDraw/App/DrawViewSection.h
Expand Up @@ -110,6 +110,7 @@ class TechDrawExport DrawViewSection : public DrawViewPart
TopoDS_Compound getSectionFaces() { return sectionFaces;};
std::vector<TopoDS_Wire> getSectionFaceWires(void) { return sectionFaceWires; }

void makeLineSets(void) ;
std::vector<LineSet> getDrawableLines(int i = 0);
std::vector<PATLineSpec> getDecodedSpecsFromFile(std::string fileSpec, std::string myPattern);

Expand Down
4 changes: 2 additions & 2 deletions src/Mod/TechDraw/Gui/QGIViewPart.cpp
Expand Up @@ -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<ViewProviderGeomHatch*>(gvp);
if (geomVp != nullptr) {
Expand All @@ -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<ViewProviderHatch*>(gvp);
if (hatchVp != nullptr) {
Expand Down

0 comments on commit 072b6f1

Please sign in to comment.