[TechDraw] Return logic simplification (#16504)
* [TechDraw] AppTechDrawPy.cpp return logic simplification * [TechDraw] CosmeticExtension.cpp return logic simplification * [TechDraw] DrawBrokenView.cpp return logic simplification * [TechDraw] HatchLine.cpp return logic simplification * [TechDraw] LineGenerator.cpp return logic simplification * [TechDraw] Preferences.cpp return logic simplification * [TechDraw] ShapeExtractor.cpp return logic simplification * [TechDraw] MDIViewPage.cpp return logic simplification * [TechDraw] QGILeaderLine.cpp return logic simplification * [TechDraw] QGIRichAnno.cpp return logic simplification * [TechDraw] QGTracker.cpp return logic simplification
This commit is contained in:
committed by
GitHub
parent
00acfd5b2a
commit
52fe0eec53
@@ -835,8 +835,7 @@ private:
|
||||
const TopoDS_Shape& shape = pShape->getTopoShapePtr()->getShape();
|
||||
Base::Vector3d dir = static_cast<Base::VectorPy*>(pcObjDir)->value();
|
||||
Base::Vector3d centroid = ShapeUtils::findCentroidVec(shape, dir);
|
||||
PyObject* result = nullptr;
|
||||
result = new Base::VectorPy(new Base::Vector3d(centroid));
|
||||
PyObject* result = new Base::VectorPy(new Base::Vector3d(centroid));
|
||||
return Py::asObject(result);
|
||||
}
|
||||
|
||||
|
||||
@@ -205,8 +205,7 @@ std::string CosmeticExtension::addCosmeticVertex(const Base::Vector3d& pos, bool
|
||||
TechDraw::CosmeticVertex* cv = new TechDraw::CosmeticVertex(tempPos);
|
||||
verts.push_back(cv);
|
||||
CosmeticVertexes.setValues(verts);
|
||||
std::string result = cv->getTagAsString();
|
||||
return result;
|
||||
return cv->getTagAsString();
|
||||
}
|
||||
|
||||
/// retrieve a cosmetic vertex by unique id
|
||||
|
||||
@@ -240,11 +240,8 @@ TopoDS_Shape DrawBrokenView::apply1Break(const App::DocumentObject& breakObj, co
|
||||
TopoDS_Shape DrawBrokenView::compressShape(const TopoDS_Shape& shapeToCompress) const
|
||||
{
|
||||
// Base::Console().Message("DBV::compressShape()\n");
|
||||
TopoDS_Shape result;
|
||||
TopoDS_Shape compressed = compressHorizontal(shapeToCompress);
|
||||
result = compressVertical(compressed);
|
||||
|
||||
return result;
|
||||
return compressVertical(compressed);
|
||||
}
|
||||
|
||||
//! move the broken pieces in the input shape "right" to close up the removed areas.
|
||||
|
||||
@@ -79,21 +79,19 @@ bool LineSet::isDashed()
|
||||
//! calculates the apparent start point (ie start of overlay line) for dashed lines
|
||||
Base::Vector3d LineSet::calcApparentStart(TechDraw::BaseGeomPtr g)
|
||||
{
|
||||
Base::Vector3d result;
|
||||
Base::Vector3d start(g->getStartPoint().x, g->getStartPoint().y, 0.0);
|
||||
double angle = getPATLineSpec().getAngle();
|
||||
if (angle == 0.0) { //horizontal
|
||||
result = Base::Vector3d(getMinX(), start.y, 0.0);
|
||||
return Base::Vector3d(getMinX(), start.y, 0.0);
|
||||
} else if ((angle == 90.0) ||
|
||||
(angle == -90.0)) { //vertical
|
||||
result = Base::Vector3d(start.x, getMinY(), 0.0);
|
||||
return Base::Vector3d(start.x, getMinY(), 0.0);
|
||||
} else {
|
||||
double slope = getPATLineSpec().getSlope();
|
||||
double y = getMinY();
|
||||
double x = ((y - start.y) / slope) + start.x;
|
||||
result = Base::Vector3d(x, y,0);
|
||||
return Base::Vector3d(x, y,0);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
Base::Vector3d LineSet::getUnitDir()
|
||||
@@ -132,20 +130,18 @@ Base::Vector3d LineSet::getUnitOrtho()
|
||||
|
||||
Base::Vector3d LineSet::findAtomStart()
|
||||
{
|
||||
Base::Vector3d result;
|
||||
Base::Vector3d origin = getOrigin();
|
||||
double angle = getAngle();
|
||||
if (angle == 0.0) {
|
||||
result = Base::Vector3d(getMinX(), origin.y, 0.0);
|
||||
return Base::Vector3d(getMinX(), origin.y, 0.0);
|
||||
} else if ( (angle == 90.0) ||
|
||||
(angle == -90.0) ) {
|
||||
result = Base::Vector3d(origin.x, getMinY(), 0.0);
|
||||
return Base::Vector3d(origin.x, getMinY(), 0.0);
|
||||
} else {
|
||||
double minY = getMinY();
|
||||
double x = origin.x - (origin.y - minY)/getSlope();
|
||||
result = Base::Vector3d(x, minY, 0.0);
|
||||
return Base::Vector3d(x, minY, 0.0);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
Base::Vector3d LineSet::getPatternStartPoint(TechDraw::BaseGeomPtr g, double &offset, double scale)
|
||||
|
||||
@@ -177,7 +177,6 @@ int LineGenerator::fromQtStyle(Qt::PenStyle style)
|
||||
{
|
||||
// Base::Console().Message("DLG::fromQtStyle(%d)\n", style);
|
||||
|
||||
int result { 0 };
|
||||
// the 4 standard Qt::PenStyles and ISO128 equivalents
|
||||
int dashed = 2;
|
||||
int dotted = 7;
|
||||
@@ -199,29 +198,22 @@ int LineGenerator::fromQtStyle(Qt::PenStyle style)
|
||||
switch (style) {
|
||||
case Qt::NoPen:
|
||||
case Qt::SolidLine:
|
||||
result = 1;
|
||||
break;
|
||||
return 1;
|
||||
case Qt::DashLine:
|
||||
result = dashed;
|
||||
break;
|
||||
return dashed;
|
||||
case Qt::DotLine:
|
||||
result = dotted;
|
||||
break;
|
||||
return dotted;
|
||||
case Qt::DashDotLine:
|
||||
result = dashDot;
|
||||
break;
|
||||
return dashDot;
|
||||
case Qt::DashDotDotLine:
|
||||
result = dashDotDot;
|
||||
break;
|
||||
return dashDotDot;
|
||||
case Qt::CustomDashLine:
|
||||
// not sure what to do here. we would have to match the custom pattern
|
||||
// to the patterns of the ISO lines and set the dash pattern accordingly.
|
||||
result = 2;
|
||||
break;
|
||||
return 2;
|
||||
default:
|
||||
result = 0;
|
||||
return 0;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -549,21 +549,16 @@ std::string Preferences::currentElementDefFile()
|
||||
int Preferences::LineCapStyle()
|
||||
{
|
||||
int currentIndex = LineCapIndex();
|
||||
int result{0x20};
|
||||
switch (currentIndex) {
|
||||
switch (currentIndex) {
|
||||
case 0:
|
||||
result = static_cast<Qt::PenCapStyle>(0x20); //round;
|
||||
break;
|
||||
return static_cast<Qt::PenCapStyle>(0x20); //round;
|
||||
case 1:
|
||||
result = static_cast<Qt::PenCapStyle>(0x10); //square;
|
||||
break;
|
||||
return static_cast<Qt::PenCapStyle>(0x10); //square;
|
||||
case 2:
|
||||
result = static_cast<Qt::PenCapStyle>(0x00); //flat
|
||||
break;
|
||||
return static_cast<Qt::PenCapStyle>(0x00); //flat
|
||||
default:
|
||||
result = static_cast<Qt::PenCapStyle>(0x20);
|
||||
return static_cast<Qt::PenCapStyle>(0x20);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
//! returns the line cap index without conversion to a Qt::PenCapStyle
|
||||
|
||||
@@ -421,18 +421,17 @@ bool ShapeExtractor::is2dObject(const App::DocumentObject* obj)
|
||||
// just these for now
|
||||
bool ShapeExtractor::isEdgeType(const App::DocumentObject* obj)
|
||||
{
|
||||
bool result = false;
|
||||
Base::Type t = obj->getTypeId();
|
||||
if (t.isDerivedFrom(Part::Line::getClassTypeId()) ) {
|
||||
result = true;
|
||||
return true;
|
||||
} else if (t.isDerivedFrom(Part::Circle::getClassTypeId())) {
|
||||
result = true;
|
||||
return true;
|
||||
} else if (t.isDerivedFrom(Part::Ellipse::getClassTypeId())) {
|
||||
result = true;
|
||||
return true;
|
||||
} else if (t.isDerivedFrom(Part::RegularPolygon::getClassTypeId())) {
|
||||
result = true;
|
||||
return true;
|
||||
}
|
||||
return result;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ShapeExtractor::isPointType(const App::DocumentObject* obj)
|
||||
|
||||
@@ -1061,8 +1061,6 @@ void MDIViewPage::removeUnselectedTreeSelection(QList<QGraphicsItem*> sceneSelec
|
||||
bool MDIViewPage::compareSelections(std::vector<Gui::SelectionObject> treeSel,
|
||||
QList<QGraphicsItem*> sceneSel)
|
||||
{
|
||||
bool result = true;
|
||||
|
||||
if (treeSel.empty() && sceneSel.empty()) {
|
||||
return true;
|
||||
}
|
||||
@@ -1141,7 +1139,7 @@ bool MDIViewPage::compareSelections(std::vector<Gui::SelectionObject> treeSel,
|
||||
return false;
|
||||
}
|
||||
|
||||
return result;
|
||||
return true;
|
||||
}
|
||||
|
||||
///////////////////end Selection Routines //////////////////////
|
||||
|
||||
@@ -596,8 +596,7 @@ double QGILeaderLine::getLineWidth()
|
||||
|
||||
TechDraw::DrawLeaderLine* QGILeaderLine::getLeaderFeature()
|
||||
{
|
||||
TechDraw::DrawLeaderLine* result = static_cast<TechDraw::DrawLeaderLine*>(getViewObject());
|
||||
return result;
|
||||
return static_cast<TechDraw::DrawLeaderLine*>(getViewObject());
|
||||
}
|
||||
|
||||
double QGILeaderLine::getEdgeFuzz() const
|
||||
@@ -637,12 +636,11 @@ void QGILeaderLine::paint(QPainter* painter, const QStyleOptionGraphicsItem* opt
|
||||
|
||||
bool QGILeaderLine::useOldCoords() const
|
||||
{
|
||||
bool result = false;
|
||||
auto vp = dynamic_cast<ViewProviderLeader*>(getViewProvider(getViewObject()));
|
||||
if (vp) {
|
||||
result = vp->UseOldCoords.getValue();
|
||||
return vp->UseOldCoords.getValue();
|
||||
}
|
||||
return result;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -279,9 +279,7 @@ QString QGIRichAnno::convertTextSizes(const QString& inHtml) const
|
||||
|
||||
TechDraw::DrawRichAnno* QGIRichAnno::getFeature()
|
||||
{
|
||||
TechDraw::DrawRichAnno* result =
|
||||
static_cast<TechDraw::DrawRichAnno*>(getViewObject());
|
||||
return result;
|
||||
return static_cast<TechDraw::DrawRichAnno*>(getViewObject());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -483,10 +483,7 @@ QColor QGTracker::getTrackerColor()
|
||||
|
||||
double QGTracker::getTrackerWeight()
|
||||
{
|
||||
double result = 1.0;
|
||||
result = Preferences::getPreferenceGroup("Tracker")->GetFloat("TrackerWeight", 4.0);
|
||||
|
||||
return result;
|
||||
return Preferences::getPreferenceGroup("Tracker")->GetFloat("TrackerWeight", 4.0);
|
||||
}
|
||||
|
||||
#include <Mod/TechDraw/Gui/moc_QGTracker.cpp>
|
||||
|
||||
Reference in New Issue
Block a user