void QGIViewSection::drawSectionFace()
{
    if(getViewObject() == 0 || !getViewObject()->isDerivedFrom(TechDraw::DrawViewSection::getClassTypeId()))
        return;

    TechDraw::DrawViewSection *section = dynamic_cast<TechDraw::DrawViewSection *>(getViewObject());
    if (!section->hasGeometry()) {
        return;
    }

    if (!section->ShowCutSurface.getValue()) {
        return;
    }

    std::vector<TechDrawGeometry::Face*> sectionFaces;
    sectionFaces = section->getFaceGeometry();
    if (sectionFaces.empty()) {
        Base::Console().Log("INFO - QGIViewSection::drawSectionFace - No sectionFaces available. Check Section plane.\n");
        return;
    }
    std::vector<TechDrawGeometry::Face *>::iterator fit = sectionFaces.begin();
    QColor faceColor = section->CutSurfaceColor.getValue().asValue<QColor>();
    for(; fit != sectionFaces.end(); fit++) {
        QGIFace* newFace = drawFace(*fit,-1);  //TODO: do we need to know which sectionFace this QGIFace came from?
        newFace->setZValue(ZVALUE::SECTIONFACE);
        newFace->setFill(faceColor, Qt::SolidPattern);
        newFace->setPrettyNormal();
        newFace->setAcceptHoverEvents(false);
        newFace->setFlag(QGraphicsItem::ItemIsSelectable, false);
    }
}
Ejemplo n.º 2
0
void QGIViewSection::drawSectionFace()
{
    auto section( dynamic_cast<TechDraw::DrawViewSection *>(getViewObject()) );
    if( section == nullptr ) {
        return;
    }

    if ( !section->hasGeometry()) {
        return;
    }
    Gui::ViewProvider* gvp = QGIView::getViewProvider(section);
    ViewProviderViewSection* sectionVp = dynamic_cast<ViewProviderViewSection*>(gvp);
    if ((sectionVp == nullptr)  ||
        (!sectionVp->ShowCutSurface.getValue())) {
        return;
    }

    auto sectionFaces( section->getFaceGeometry() );
    if (sectionFaces.empty()) {
        //Base::Console().Log("INFO - QGIViewSection::drawSectionFace - No sectionFaces available. Check Section plane.\n");
        return;
    }

    std::vector<TechDrawGeometry::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);
        newFace->setZValue(ZVALUE::SECTIONFACE);
        if (section->showSectionEdges()) {
            newFace->setDrawEdges(true);
        } else {
            newFace->setDrawEdges(false);
        }
        newFace->setFill(faceColor, Qt::SolidPattern);

        if (sectionVp->HatchCutSurface.getValue()) {
            newFace->isHatched(true);
            newFace->setFillMode(QGIFace::FromFile);
            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);
                        }
                    }
                }
            }
        }
        newFace->draw();
        newFace->setPrettyNormal();
        newFace->setAcceptHoverEvents(false);
        newFace->setFlag(QGraphicsItem::ItemIsSelectable, false);
    }
}