[TD]Simplify Section cut surface formatting
This commit is contained in:
@@ -96,6 +96,11 @@ const char* DrawViewSection::SectionDirEnums[]= {"Right",
|
||||
"Down",
|
||||
NULL};
|
||||
|
||||
const char* DrawViewSection::CutSurfaceEnums[]= {"Hide",
|
||||
"Color",
|
||||
"SvgHatch",
|
||||
"PatHatch",
|
||||
NULL};
|
||||
|
||||
|
||||
//===========================================================================
|
||||
@@ -118,15 +123,19 @@ DrawViewSection::DrawViewSection()
|
||||
ADD_PROPERTY_TYPE(SectionDirection,((long)0),sgroup, App::Prop_None, "Direction in Base View for this Section");
|
||||
ADD_PROPERTY_TYPE(FuseBeforeCut ,(false),sgroup,App::Prop_None,"Merge Source(s) into a single shape before cutting");
|
||||
|
||||
CutSurfaceDisplay.setEnums(CutSurfaceEnums);
|
||||
ADD_PROPERTY_TYPE(CutSurfaceDisplay,((long)2),fgroup, App::Prop_None, "Appearance of Cut Surface");
|
||||
ADD_PROPERTY_TYPE(FileHatchPattern ,(""),fgroup,App::Prop_None,"The hatch pattern file for the cut surface");
|
||||
ADD_PROPERTY_TYPE(FileGeomPattern ,(""),fgroup,App::Prop_None,"The PAT pattern file for geometric hatching");
|
||||
ADD_PROPERTY_TYPE(NameGeomPattern ,(""),fgroup,App::Prop_None,"The pattern name for geometric hatching");
|
||||
ADD_PROPERTY_TYPE(HatchScale,(1.0),fgroup,App::Prop_None,"Hatch pattern size adjustment");
|
||||
|
||||
getParameters();
|
||||
|
||||
std::string hatchFilter("Svg files (*.svg *.SVG);;PAT files (*.pat *.PAT);;All files (*)");
|
||||
std::string hatchFilter("Svg files (*.svg *.SVG);;All files (*)");
|
||||
FileHatchPattern.setFilter(hatchFilter);
|
||||
|
||||
hatchFilter = ("PAT files (*.pat *.PAT);;All files (*)");
|
||||
FileGeomPattern.setFilter(hatchFilter);
|
||||
}
|
||||
|
||||
DrawViewSection::~DrawViewSection()
|
||||
@@ -158,26 +167,28 @@ void DrawViewSection::onChanged(const App::Property* prop)
|
||||
" - " +
|
||||
std::string(SectionSymbol.getValue());
|
||||
Label.setValue(lblText);
|
||||
}
|
||||
if (prop == &SectionOrigin) {
|
||||
} else if (prop == &SectionOrigin) {
|
||||
App::DocumentObject* base = BaseView.getValue();
|
||||
TechDraw::DrawView* dv = dynamic_cast<TechDraw::DrawView*>(base);
|
||||
if (dv != nullptr) {
|
||||
dv->requestPaint();
|
||||
}
|
||||
} else if (prop == &CutSurfaceDisplay) {
|
||||
// Base::Console().Message("DVS::onChanged(%s)\n",prop->getName());
|
||||
}
|
||||
}
|
||||
if (prop == &FileHatchPattern ||
|
||||
if (prop == &FileGeomPattern ||
|
||||
prop == &NameGeomPattern ) {
|
||||
std::string fileSpec = FileHatchPattern.getValue();
|
||||
std::string fileSpec = FileGeomPattern.getValue();
|
||||
Base::FileInfo fi(fileSpec);
|
||||
std::string ext = fi.extension();
|
||||
if ( (ext == "pat") ||
|
||||
(ext == "PAT") ) {
|
||||
if ((!FileHatchPattern.isEmpty()) &&
|
||||
if ((!FileGeomPattern.isEmpty()) &&
|
||||
(!NameGeomPattern.isEmpty())) {
|
||||
std::vector<PATLineSpec> specs =
|
||||
DrawGeomHatch::getDecodedSpecsFromFile(FileHatchPattern.getValue(),NameGeomPattern.getValue());
|
||||
DrawGeomHatch::getDecodedSpecsFromFile(FileGeomPattern.getValue(),
|
||||
NameGeomPattern.getValue());
|
||||
m_lineSets.clear();
|
||||
for (auto& hl: specs) {
|
||||
//hl.dump("hl from section");
|
||||
@@ -759,6 +770,14 @@ void DrawViewSection::getParameters()
|
||||
FileHatchPattern.setValue(patternFileName);
|
||||
}
|
||||
|
||||
defaultDir = App::Application::getResourceDir() + "Mod/TechDraw/PAT/";
|
||||
defaultFileName = defaultDir + "FCPAT.pat";
|
||||
patternFileName = hGrp->GetASCII("FilePattern",defaultFileName.c_str());
|
||||
Base::FileInfo tfi2(patternFileName);
|
||||
if (tfi2.isReadable()) {
|
||||
FileGeomPattern.setValue(patternFileName);
|
||||
}
|
||||
|
||||
std::string patternName = hGrp->GetASCII("PatternName","Diamond");
|
||||
NameGeomPattern.setValue(patternName);
|
||||
|
||||
|
||||
@@ -66,9 +66,13 @@ public:
|
||||
App::PropertyVector SectionNormal;
|
||||
App::PropertyVector SectionOrigin;
|
||||
App::PropertyEnumeration SectionDirection;
|
||||
|
||||
App::PropertyEnumeration CutSurfaceDisplay; //new v019
|
||||
App::PropertyFile FileHatchPattern;
|
||||
App::PropertyFile FileGeomPattern; //new v019
|
||||
App::PropertyString NameGeomPattern;
|
||||
App::PropertyFloat HatchScale;
|
||||
|
||||
App::PropertyString SectionSymbol;
|
||||
App::PropertyBool FuseBeforeCut;
|
||||
|
||||
@@ -110,6 +114,7 @@ public:
|
||||
TopoDS_Shape getCutShape(void) {return m_cutShape;}
|
||||
|
||||
static const char* SectionDirEnums[];
|
||||
static const char* CutSurfaceEnums[];
|
||||
|
||||
protected:
|
||||
TopoDS_Compound sectionFaces;
|
||||
|
||||
@@ -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