[TD]Simplify Section cut surface formatting
This commit is contained in:
@@ -85,12 +85,12 @@ void QGIViewSection::drawSectionFace()
|
||||
|
||||
auto sectionFaces( section->getFaceGeometry() );
|
||||
if (sectionFaces.empty()) {
|
||||
//Base::Console().Log("INFO - QGIViewSection::drawSectionFace - No sectionFaces available. Check Section plane.\n");
|
||||
Base::Console().
|
||||
Log("INFO - QGIViewSection::drawSectionFace - No sectionFaces available. Check Section plane.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector<TechDraw::Face *>::iterator fit = sectionFaces.begin();
|
||||
QColor faceColor = (sectionVp->CutSurfaceColor.getValue()).asValue<QColor>();
|
||||
int i = 0;
|
||||
for(; fit != sectionFaces.end(); fit++, i++) {
|
||||
QGIFace* newFace = drawFace(*fit,-1);
|
||||
@@ -102,39 +102,45 @@ void QGIViewSection::drawSectionFace()
|
||||
} else {
|
||||
newFace->setDrawEdges(false);
|
||||
}
|
||||
newFace->setFill(faceColor, Qt::SolidPattern);
|
||||
|
||||
if (sectionVp->HatchCutSurface.getValue()) {
|
||||
if (section->CutSurfaceDisplay.isValue("Hide")) {
|
||||
return;
|
||||
} else if (section->CutSurfaceDisplay.isValue("Color")) {
|
||||
newFace->isHatched(false);
|
||||
newFace->setFillMode(QGIFace::PlainFill);
|
||||
QColor faceColor = (sectionVp->CutSurfaceColor.getValue()).asValue<QColor>();
|
||||
newFace->setFillColor(faceColor);
|
||||
newFace->setFillStyle(Qt::SolidPattern);
|
||||
} else if (section->CutSurfaceDisplay.isValue("SvgHatch")) {
|
||||
newFace->isHatched(true);
|
||||
newFace->setFillMode(QGIFace::FromFile);
|
||||
newFace->setFillMode(QGIFace::SvgFill);
|
||||
newFace->setHatchColor(sectionVp->HatchColor.getValue());
|
||||
newFace->setHatchScale(section->HatchScale.getValue());
|
||||
|
||||
std::string hatchFile = section->FileHatchPattern.getValue();
|
||||
newFace->setHatchFile(hatchFile);
|
||||
std::string patternName = section->NameGeomPattern.getValue();
|
||||
QFileInfo hfi(QString::fromUtf8(hatchFile.data(),hatchFile.size()));
|
||||
if (hfi.isReadable()) {
|
||||
QString ext = hfi.suffix();
|
||||
if ((ext.toUpper() == QString::fromUtf8("PAT")) &&
|
||||
!patternName.empty() ) {
|
||||
newFace->setFillMode(QGIFace::GeomHatchFill);
|
||||
newFace->setLineWeight(sectionVp->WeightPattern.getValue());
|
||||
std::vector<LineSet> lineSets = section->getDrawableLines(i);
|
||||
if (!lineSets.empty()) {
|
||||
newFace->clearLineSets();
|
||||
for (auto& ls: lineSets) {
|
||||
// QPainterPath bigPath;
|
||||
// for (auto& g: ls.getGeoms()) {
|
||||
// QPainterPath smallPath = drawPainterPath(g);
|
||||
// bigPath.addPath(smallPath);
|
||||
// }
|
||||
newFace->addLineSet(ls);
|
||||
}
|
||||
std::string hatchSpec = section->FileHatchPattern.getValue();
|
||||
newFace->setHatchFile(hatchSpec);
|
||||
} else if (section->CutSurfaceDisplay.isValue("PatHatch")) {
|
||||
newFace->isHatched(true);
|
||||
newFace->setFillMode(QGIFace::GeomHatchFill);
|
||||
newFace->setHatchColor(sectionVp->HatchColor.getValue());
|
||||
newFace->setHatchScale(section->HatchScale.getValue());
|
||||
newFace->setLineWeight(sectionVp->WeightPattern.getValue());
|
||||
std::vector<LineSet> lineSets = section->getDrawableLines(i);
|
||||
if (!lineSets.empty()) {
|
||||
newFace->clearLineSets();
|
||||
for (auto& ls: lineSets) {
|
||||
QPainterPath bigPath;
|
||||
for (auto& g: ls.getGeoms()) {
|
||||
QPainterPath smallPath = drawPainterPath(g);
|
||||
bigPath.addPath(smallPath);
|
||||
}
|
||||
newFace->addLineSet(ls);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Base::Console().Warning("QGIVS::draw - unknown CutSurfaceDisplay: %d\n",
|
||||
section->CutSurfaceDisplay.getValue());
|
||||
}
|
||||
|
||||
newFace->draw();
|
||||
newFace->setPrettyNormal();
|
||||
newFace->setAcceptHoverEvents(false);
|
||||
@@ -150,16 +156,12 @@ void QGIViewSection::updateView(bool update)
|
||||
return;
|
||||
}
|
||||
|
||||
// if(update ||
|
||||
// viewPart->SectionNormal.isTouched() ||
|
||||
// viewPart->SectionOrigin.isTouched()) {
|
||||
//// QGIViewPart::updateView(true);
|
||||
//// drawSectionFace();
|
||||
// } else {
|
||||
//// QGIViewPart::updateView();
|
||||
//// drawSectionFace();
|
||||
// }
|
||||
std::string dbHatch = viewPart->FileHatchPattern.getValue();
|
||||
|
||||
draw();
|
||||
|
||||
QGIView::updateView(update);
|
||||
|
||||
}
|
||||
|
||||
void QGIViewSection::drawSectionLine(TechDraw::DrawViewSection* s, bool b)
|
||||
@@ -168,3 +170,4 @@ void QGIViewSection::drawSectionLine(TechDraw::DrawViewSection* s, bool b)
|
||||
Q_UNUSED(s);
|
||||
//override QGIVP::drawSectionLine
|
||||
}
|
||||
|
||||
|
||||
@@ -62,9 +62,11 @@ ViewProviderViewSection::ViewProviderViewSection()
|
||||
static const char *sgroup = "Cut Surface";
|
||||
static const char *hgroup = "Surface Hatch";
|
||||
sPixmap = "TechDraw_Tree_Section";
|
||||
ADD_PROPERTY_TYPE(ShowCutSurface ,(true),sgroup,App::Prop_None,"Show/hide the cut surface");
|
||||
//ShowCutSurface is obsolete - use CutSurfaceDisplay
|
||||
ADD_PROPERTY_TYPE(ShowCutSurface ,(true),sgroup,App::Prop_Hidden,"Show/hide the cut surface");
|
||||
ADD_PROPERTY_TYPE(CutSurfaceColor,(0.0,0.0,0.0),sgroup,App::Prop_None,"The color to shade the cut surface");
|
||||
ADD_PROPERTY_TYPE(HatchCutSurface ,(false),hgroup,App::Prop_None,"Hatch the cut surface");
|
||||
//HatchCutSurface is obsolete - use CutSurfaceDisplay
|
||||
ADD_PROPERTY_TYPE(HatchCutSurface ,(false),hgroup,App::Prop_Hidden,"Hatch the cut surface");
|
||||
ADD_PROPERTY_TYPE(HatchColor,(0.0,0.0,0.0),hgroup,App::Prop_None,"The color of the hatch pattern");
|
||||
ADD_PROPERTY_TYPE(WeightPattern,(0.1),hgroup,App::Prop_None,"GeomHatch pattern line thickness");
|
||||
|
||||
@@ -99,9 +101,9 @@ std::vector<std::string> ViewProviderViewSection::getDisplayModes(void) const
|
||||
void ViewProviderViewSection::onChanged(const App::Property* prop)
|
||||
{
|
||||
if (prop == &WeightPattern ||
|
||||
prop == &HatchCutSurface ||
|
||||
// prop == &HatchCutSurface ||
|
||||
prop == &HatchColor ||
|
||||
prop == &ShowCutSurface ||
|
||||
// prop == &ShowCutSurface ||
|
||||
prop == &CutSurfaceColor ) {
|
||||
updateGraphic();
|
||||
}
|
||||
@@ -113,6 +115,7 @@ void ViewProviderViewSection::onChanged(const App::Property* prop)
|
||||
void ViewProviderViewSection::updateData(const App::Property* prop)
|
||||
{
|
||||
if (prop == &(getViewObject()->FileHatchPattern) ||
|
||||
prop == &(getViewObject()->CutSurfaceDisplay) ||
|
||||
prop == &(getViewObject()->NameGeomPattern) ||
|
||||
prop == &(getViewObject()->HatchScale) ) {
|
||||
updateGraphic();
|
||||
|
||||
@@ -44,9 +44,9 @@ public:
|
||||
/// destructor
|
||||
virtual ~ViewProviderViewSection();
|
||||
|
||||
App::PropertyBool ShowCutSurface;
|
||||
App::PropertyBool ShowCutSurface; //obsolete - use CutSurfaceDisplay
|
||||
App::PropertyColor CutSurfaceColor;
|
||||
App::PropertyBool HatchCutSurface;
|
||||
App::PropertyBool HatchCutSurface; //obsolete - use CutSurfaceDisplay
|
||||
App::PropertyColor HatchColor;
|
||||
App::PropertyFloat WeightPattern;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user