[TechDraw] Improve readability of DrawViewSection.cpp

This commit is contained in:
Benjamin Bræstrup Sayoc
2023-04-05 16:22:42 +02:00
committed by WandererFan
parent acca47ab6f
commit 2f193bbc0e

View File

@@ -542,13 +542,11 @@ void DrawViewSection::postHlrTasks(void)
DrawViewPart::postHlrTasks();
//second pass if required
if (ScaleType.isValue("Automatic")) {
if (!checkFit()) {
double newScale = autoScale();
Scale.setValue(newScale);
Scale.purgeTouched();
sectionExec(m_saveShape);
}
if (ScaleType.isValue("Automatic") && !checkFit()) {
double newScale = autoScale();
Scale.setValue(newScale);
Scale.purgeTouched();
sectionExec(m_saveShape);
}
overrideKeepUpdated(false);
@@ -891,30 +889,26 @@ bool DrawViewSection::isReallyInBox(const gp_Pnt p, const Bnd_Box& bb) const
Base::Vector3d DrawViewSection::getXDirection() const
{
// Base::Console().Message("DVS::getXDirection() - %s\n", Label.getValue());
Base::Vector3d result(1.0, 0.0, 0.0);//default X
App::Property* prop = getPropertyByName("XDirection");
if (prop) {
//we have an XDirection property
if (DrawUtil::fpCompare(XDirection.getValue().Length(), 0.0)) {
//but it has no value, so we make a value
if (BaseView.getValue()) {
gp_Ax2 cs = getCSFromBase(SectionDirection.getValueAsString());
gp_Dir gXDir = cs.XDirection();
result = Base::Vector3d(gXDir.X(), gXDir.Y(), gXDir.Z());
}
}
else {
//XDirection is good, so we use it
result = XDirection.getValue();
}
}
else {
//no XDirection property. can this happen?
if (!prop) {
// No XDirection property. can this happen?
gp_Ax2 cs = getCSFromBase(SectionDirection.getValueAsString());
gp_Dir gXDir = cs.XDirection();
result = Base::Vector3d(gXDir.X(), gXDir.Y(), gXDir.Z());
return Base::Vector3d(gXDir.X(), gXDir.Y(), gXDir.Z());
}
return result;
//we have an XDirection property
if (DrawUtil::fpCompare(XDirection.getValue().Length(), 0.0)) {
//but it has no value, so we make a value
if (BaseView.getValue()) {
gp_Ax2 cs = getCSFromBase(SectionDirection.getValueAsString());
gp_Dir gXDir = cs.XDirection();
return Base::Vector3d(gXDir.X(), gXDir.Y(), gXDir.Z());
}
}
//XDirection is good, so we use it
return XDirection.getValue();
}
void DrawViewSection::setCSFromBase(const std::string sectionName)
@@ -1053,33 +1047,29 @@ std::vector<LineSet> DrawViewSection::getDrawableLines(int i)
{
// Base::Console().Message("DVS::getDrawableLines(%d) - lineSets: %d\n", i, m_lineSets.size());
std::vector<LineSet> result;
result = DrawGeomHatch::getTrimmedLinesSection(this, m_lineSets, getSectionTopoDSFace(i),
HatchScale.getValue(), HatchRotation.getValue(),
HatchOffset.getValue());
return result;
return DrawGeomHatch::getTrimmedLinesSection(this, m_lineSets, getSectionTopoDSFace(i),
HatchScale.getValue(), HatchRotation.getValue(),
HatchOffset.getValue());
}
TopoDS_Face DrawViewSection::getSectionTopoDSFace(int i)
{
TopoDS_Face result;
TopExp_Explorer expl(m_sectionTopoDSFaces, TopAbs_FACE);
int count = 1;
for (; expl.More(); expl.Next(), count++) {
if (count == i + 1) {
result = TopoDS::Face(expl.Current());
return TopoDS::Face(expl.Current());
}
}
return result;
return TopoDS_Face();
}
TechDraw::DrawViewPart* DrawViewSection::getBaseDVP() const
{
TechDraw::DrawViewPart* baseDVP = nullptr;
App::DocumentObject* base = BaseView.getValue();
if (base) {
if (base->getTypeId().isDerivedFrom(TechDraw::DrawViewPart::getClassTypeId())) {
baseDVP = static_cast<TechDraw::DrawViewPart*>(base);
}
if (base && base->getTypeId().isDerivedFrom(TechDraw::DrawViewPart::getClassTypeId())) {
baseDVP = static_cast<TechDraw::DrawViewPart*>(base);
}
return baseDVP;
}
@@ -1088,10 +1078,8 @@ TechDraw::DrawProjGroupItem* DrawViewSection::getBaseDPGI() const
{
TechDraw::DrawProjGroupItem* baseDPGI = nullptr;
App::DocumentObject* base = BaseView.getValue();
if (base) {
if (base->getTypeId().isDerivedFrom(TechDraw::DrawProjGroupItem::getClassTypeId())) {
baseDPGI = static_cast<TechDraw::DrawProjGroupItem*>(base);
}
if (base && base->getTypeId().isDerivedFrom(TechDraw::DrawProjGroupItem::getClassTypeId())) {
baseDPGI = static_cast<TechDraw::DrawProjGroupItem*>(base);
}
return baseDPGI;
}
@@ -1141,8 +1129,8 @@ void DrawViewSection::makeLineSets(void)
return;
}
if ((ext == "pat") || (ext == "PAT")) {
if ((!fileSpec.empty()) && (!NameGeomPattern.isEmpty())) {
if (ext == "pat" || ext == "PAT") {
if (!fileSpec.empty() && !NameGeomPattern.isEmpty()) {
m_lineSets.clear();
m_lineSets = DrawGeomHatch::makeLineSets(fileSpec, NameGeomPattern.getValue());
}