[TechDraw] Improve readability of DrawHatch.cpp

This commit is contained in:
Benjamin Bræstrup Sayoc
2023-04-05 14:07:25 +02:00
committed by WandererFan
parent 32e56cfc9c
commit b57c7eab12

View File

@@ -97,38 +97,29 @@ PyObject *DrawHatch::getPyObject(void)
bool DrawHatch::faceIsHatched(int i, std::vector<TechDraw::DrawHatch*> hatchObjs)
{
bool result = false;
bool found = false;
for (auto& h:hatchObjs) {
const std::vector<std::string> &sourceNames = h->Source.getSubValues();
for (auto& s : sourceNames) {
int fdx = TechDraw::DrawUtil::getIndexFromName(s);
if (fdx == i) {
result = true;
found = true;
break;
return true; // Found something
}
}
if (found) {
break;
}
}
return result;
return false; // Found nothing
}
//does this hatch affect face i
bool DrawHatch::affectsFace(int i)
{
bool result = false;
const std::vector<std::string> &sourceNames = Source.getSubValues();
for (auto& s : sourceNames) {
int fdx = TechDraw::DrawUtil::getIndexFromName(s);
if (fdx == i) {
result = true;
break;
}
if (fdx == i) {
return true; // Found something
}
}
return result;
return false; // Found nothing
}
//remove a subElement(Face) from Source PropertyLinkSub
@@ -200,30 +191,28 @@ void DrawHatch::unsetupObject(void)
bool DrawHatch::isSvgHatch(void) const
{
bool result = false;
Base::FileInfo fi(HatchPattern.getValue());
if ((fi.extension() == "svg") ||
(fi.extension() == "SVG")) {
result = true;
if (fi.extension() == "svg" ||
fi.extension() == "SVG") {
return true;
}
return result;
return false;
}
bool DrawHatch::isBitmapHatch(void) const
{
bool result = false;
Base::FileInfo fi(HatchPattern.getValue());
if ((fi.extension() == "bmp") ||
(fi.extension() == "BMP") ||
(fi.extension() == "png") ||
(fi.extension() == "PNG") ||
(fi.extension() == "jpg") ||
(fi.extension() == "JPG") ||
(fi.extension() == "jpeg") ||
(fi.extension() == "JPEG") ) {
result = true;
if (fi.extension() == "bmp" ||
fi.extension() == "BMP" ||
fi.extension() == "png" ||
fi.extension() == "PNG" ||
fi.extension() == "jpg" ||
fi.extension() == "JPG" ||
fi.extension() == "jpeg" ||
fi.extension() == "JPEG" ) {
return true;
}
return result;
return false;
}
//standard preference getters