[TD]make geom hatch lines on property change

This commit is contained in:
wandererfan
2020-03-17 19:51:29 -04:00
committed by WandererFan
parent 3c0d9d3d98
commit 072b6f11b1
3 changed files with 36 additions and 27 deletions

View File

@@ -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<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)
{
@@ -907,6 +914,7 @@ void DrawViewSection::onDocumentRestored()
if (PatIncluded.isEmpty()) {
setupPatIncluded();
}
makeLineSets();
}
}
DrawViewPart::onDocumentRestored();

View File

@@ -110,6 +110,7 @@ public:
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);

View File

@@ -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) {
@@ -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) {