From 955af2fa8d7db1692ccfbe20bee5556e9b2a2ea9 Mon Sep 17 00:00:00 2001 From: Uwe Date: Mon, 29 Nov 2021 12:05:10 +0100 Subject: [PATCH] [PD] use existing definition for PI in Helix - also a lot of style fixes kindly done by MSVC --- src/Mod/PartDesign/App/FeatureHelix.cpp | 96 ++++++----- src/Mod/PartDesign/App/FeatureHelix.h | 2 +- .../PartDesign/Gui/TaskHelixParameters.cpp | 163 +++++++++--------- src/Mod/PartDesign/Gui/TaskHelixParameters.h | 10 +- 4 files changed, 144 insertions(+), 127 deletions(-) diff --git a/src/Mod/PartDesign/App/FeatureHelix.cpp b/src/Mod/PartDesign/App/FeatureHelix.cpp index 11de1bf859..1ab173895c 100644 --- a/src/Mod/PartDesign/App/FeatureHelix.cpp +++ b/src/Mod/PartDesign/App/FeatureHelix.cpp @@ -63,11 +63,9 @@ # include "FeatureHelix.h" -const double PI = 3.14159265359; - using namespace PartDesign; -const char* Helix::ModeEnums[] = {"pitch-height-angle", "pitch-turns-angle", "height-turns-angle", "height-turns-growth", NULL}; +const char* Helix::ModeEnums[] = { "pitch-height-angle", "pitch-turns-angle", "height-turns-angle", "height-turns-growth", NULL }; PROPERTY_SOURCE(PartDesign::Helix, PartDesign::ProfileBased) @@ -108,43 +106,48 @@ short Helix::mustExecute() const return ProfileBased::mustExecute(); } -App::DocumentObjectExecReturn *Helix::execute(void) +App::DocumentObjectExecReturn* Helix::execute(void) { - // Validate and normalize parameters + // Validate and normalize parameters HelixMode mode = static_cast(Mode.getValue()); if (mode == HelixMode::pitch_height_angle) { if (Pitch.getValue() < Precision::Confusion()) return new App::DocumentObjectExecReturn("Error: Pitch too small"); if (Height.getValue() < Precision::Confusion()) return new App::DocumentObjectExecReturn("Error: height too small!"); - Turns.setValue(Height.getValue()/Pitch.getValue()); - } else if (mode == HelixMode::pitch_turns_angle) { + Turns.setValue(Height.getValue() / Pitch.getValue()); + } + else if (mode == HelixMode::pitch_turns_angle) { if (Pitch.getValue() < Precision::Confusion()) return new App::DocumentObjectExecReturn("Error: pitch too small!"); if (Turns.getValue() < Precision::Confusion()) return new App::DocumentObjectExecReturn("Error: turns too small!"); - Height.setValue(Turns.getValue()*Pitch.getValue()); - } else if (mode == HelixMode::height_turns_angle) { + Height.setValue(Turns.getValue() * Pitch.getValue()); + } + else if (mode == HelixMode::height_turns_angle) { if (Height.getValue() < Precision::Confusion()) return new App::DocumentObjectExecReturn("Error: height too small!"); if (Turns.getValue() < Precision::Confusion()) return new App::DocumentObjectExecReturn("Error: turns too small!"); - Pitch.setValue(Height.getValue()/Turns.getValue()); - } else if (mode == HelixMode::height_turns_growth) { + Pitch.setValue(Height.getValue() / Turns.getValue()); + } + else if (mode == HelixMode::height_turns_growth) { if (Turns.getValue() < Precision::Confusion()) return new App::DocumentObjectExecReturn("Error: turns too small!"); if ((Height.getValue() < Precision::Confusion()) && (abs(Growth.getValue()) < Precision::Confusion())) return new App::DocumentObjectExecReturn("Error: either height or growth must not be zero!"); - Pitch.setValue(Height.getValue()/Turns.getValue()); - } else { + Pitch.setValue(Height.getValue() / Turns.getValue()); + } + else { return new App::DocumentObjectExecReturn("Error: unsupported mode"); } TopoDS_Shape sketchshape; try { sketchshape = getVerifiedFace(); - } catch (const Base::Exception& e) { + } + catch (const Base::Exception& e) { return new App::DocumentObjectExecReturn(e.what()); } @@ -165,7 +168,8 @@ App::DocumentObjectExecReturn *Helix::execute(void) TopoDS_Shape base; try { base = getBaseShape(); - } catch (const Base::Exception&) { + } + catch (const Base::Exception&) { // fall back to support (for legacy features) base = TopoDS_Shape(); } @@ -173,7 +177,8 @@ App::DocumentObjectExecReturn *Helix::execute(void) // update Axis from ReferenceAxis try { updateAxis(); - } catch (const Base::Exception& e) { + } + catch (const Base::Exception& e) { return new App::DocumentObjectExecReturn(e.what()); } @@ -189,18 +194,19 @@ App::DocumentObjectExecReturn *Helix::execute(void) std::vector wires; try { wires = getProfileWires(); - } catch (const Base::Exception& e) { + } + catch (const Base::Exception& e) { return new App::DocumentObjectExecReturn(e.what()); } std::vector> wiresections; - for(TopoDS_Wire& wire : wires) + for (TopoDS_Wire& wire : wires) wiresections.emplace_back(1, wire); //build all shells std::vector shells; std::vector frontwires, backwires; - for(std::vector& wires : wiresections) { + for (std::vector& wires : wiresections) { BRepOffsetAPI_MakePipeShell mkPS(TopoDS::Wire(path)); @@ -208,7 +214,7 @@ App::DocumentObjectExecReturn *Helix::execute(void) mkPS.SetTransitionMode(BRepBuilderAPI_Transformed); mkPS.SetMode(true); //This is for frenet - for(TopoDS_Wire& wire : wires) { + for (TopoDS_Wire& wire : wires) { wire.Move(invObjLoc); mkPS.Add(wire); } @@ -233,19 +239,20 @@ App::DocumentObjectExecReturn *Helix::execute(void) if (!frontwires.empty()) { // build the end faces, sew the shell and build the final solid TopoDS_Shape front = Part::FaceMakerCheese::makeFace(frontwires); - TopoDS_Shape back = Part::FaceMakerCheese::makeFace(backwires); + TopoDS_Shape back = Part::FaceMakerCheese::makeFace(backwires); BRepBuilderAPI_Sewing sewer; sewer.SetTolerance(Precision::Confusion()); sewer.Add(front); sewer.Add(back); - for(TopoDS_Shape& s : shells) + for (TopoDS_Shape& s : shells) sewer.Add(s); sewer.Perform(); mkSolid.Add(TopoDS::Shell(sewer.SewedShape())); - } else { + } + else { // shells are already closed - add them directly for (TopoDS_Shape& s : shells) { mkSolid.Add(TopoDS::Shell(s)); @@ -307,7 +314,8 @@ App::DocumentObjectExecReturn *Helix::execute(void) return new App::DocumentObjectExecReturn("Error: Intersecting the helix failed"); boolOp = this->getSolid(mkCom.Shape()); - } else { + } + else { BRepAlgoAPI_Cut mkCut(base, result); if (!mkCut.IsDone()) return new App::DocumentObjectExecReturn("Error: Subtracting the helix failed"); @@ -343,14 +351,14 @@ App::DocumentObjectExecReturn *Helix::execute(void) void Helix::updateAxis(void) { - App::DocumentObject *pcReferenceAxis = ReferenceAxis.getValue(); - const std::vector &subReferenceAxis = ReferenceAxis.getSubValues(); + App::DocumentObject* pcReferenceAxis = ReferenceAxis.getValue(); + const std::vector& subReferenceAxis = ReferenceAxis.getSubValues(); Base::Vector3d base; Base::Vector3d dir; getAxis(pcReferenceAxis, subReferenceAxis, base, dir, false); - Base.setValue(base.x,base.y,base.z); - Axis.setValue(dir.x,dir.y,dir.z); + Base.setValue(base.x, base.y, base.z); + Axis.setValue(dir.x, dir.y, dir.z); } TopoDS_Shape Helix::generateHelixPath(void) @@ -367,9 +375,9 @@ TopoDS_Shape Helix::generateHelixPath(void) // get revolve axis Base::Vector3d b = Base.getValue(); - gp_Pnt pnt(b.x,b.y,b.z); + gp_Pnt pnt(b.x, b.y, b.z); Base::Vector3d v = Axis.getValue(); - gp_Dir dir(v.x,v.y,v.z); + gp_Dir dir(v.x, v.y, v.z); Base::Vector3d normal = getProfileNormal(); Base::Vector3d start = v.Cross(normal); // pointing towards the desired helix start point. @@ -391,14 +399,14 @@ TopoDS_Shape Helix::generateHelixPath(void) // Find out in what quadrant relative to the axis the profile is located, and the exact position. Base::Vector3d profileCenter = getProfileCenterPoint(); - double axisOffset = profileCenter*start - b*start; - double startOffset = profileCenter*v - b*v; + double axisOffset = profileCenter * start - b * start; + double startOffset = profileCenter * v - b * v; double radius = std::fabs(axisOffset); bool turned = axisOffset < 0; - if (radius < Precision::Confusion()) { + if (radius < Precision::Confusion()) { // in this case ensure that axis is not in the sketch plane - if (std::fabs(v*normal) < Precision::Confusion()) + if (std::fabs(v * normal) < Precision::Confusion()) throw Base::ValueError("Error: Result is self intersecting"); radius = 1.0; //fallback to radius 1 } @@ -430,19 +438,19 @@ TopoDS_Shape Helix::generateHelixPath(void) if (reversed) { - mov.SetRotation(gp_Ax1(origo, dir_axis2), PI); + mov.SetRotation(gp_Ax1(origo, dir_axis2), M_PI); TopLoc_Location loc(mov); path.Move(loc); } if (abs(startOffset) > 0) { // translate the helix so that the starting point aligns with the profile - mov.SetTranslation(startOffset*gp_Vec(dir_axis1)); + mov.SetTranslation(startOffset * gp_Vec(dir_axis1)); TopLoc_Location loc(mov); path.Move(loc); } if (turned) { // turn the helix so that the starting point aligns with the profile - mov.SetRotation(gp_Ax1(origo, dir_axis1), PI); + mov.SetRotation(gp_Ax1(origo, dir_axis1), M_PI); TopLoc_Location loc(mov); path.Move(loc); } @@ -472,7 +480,7 @@ double Helix::safePitch() // Below is an approximation. It is possible to do the general way by solving for the pitch // where the helix is self intersecting. - double angle = Angle.getValue()/180.0*PI; + double angle = Angle.getValue() / 180.0 * M_PI; TopoDS_Shape sketchshape = getVerifiedFace(); Bnd_Box bb; @@ -483,15 +491,15 @@ double Helix::safePitch() double X = Xmax - Xmin, Y = Ymax - Ymin, Z = Zmax - Zmin; - gp_Dir dir(v.x,v.y,v.z); + gp_Dir dir(v.x, v.y, v.z); gp_Vec bbvec(X, Y, Z); - double p0 = bbvec*dir; // safe pitch if angle=0 + double p0 = bbvec * dir; // safe pitch if angle=0 gp_Dir dir_s(s.x, s.y, s.z); - if (tan(abs(angle))*p0 > abs(bbvec*dir_s)) - return abs(bbvec*dir_s)/tan(abs(angle)); + if (tan(abs(angle)) * p0 > abs(bbvec * dir_s)) + return abs(bbvec * dir_s) / tan(abs(angle)); else return p0; } @@ -507,7 +515,7 @@ void Helix::proposeParameters(bool force) double pitch = 1.1 * sqrt(bb.SquareExtent()); Pitch.setValue(pitch); - Height.setValue(pitch*3.0); + Height.setValue(pitch * 3.0); HasBeenEdited.setValue(1); } } @@ -521,7 +529,7 @@ Base::Vector3d Helix::getProfileCenterPoint() box.SetGap(0.0); double xmin, ymin, zmin, xmax, ymax, zmax; box.Get(xmin, ymin, zmin, xmax, ymax, zmax); - return Base::Vector3d(0.5*(xmin+xmax), 0.5*(ymin+ymax), 0.5*(zmin+zmax)); + return Base::Vector3d(0.5 * (xmin + xmax), 0.5 * (ymin + ymax), 0.5 * (zmin + zmax)); } void Helix::handleChangedPropertyType(Base::XMLReader& reader, const char* TypeName, App::Property* prop) diff --git a/src/Mod/PartDesign/App/FeatureHelix.h b/src/Mod/PartDesign/App/FeatureHelix.h index f834f08be0..904caf96cc 100644 --- a/src/Mod/PartDesign/App/FeatureHelix.h +++ b/src/Mod/PartDesign/App/FeatureHelix.h @@ -64,7 +64,7 @@ public: /** @name methods override feature */ //@{ - App::DocumentObjectExecReturn *execute(void); + App::DocumentObjectExecReturn* execute(void); short mustExecute() const; /// returns the type name of the view provider const char* getViewProviderName(void) const { diff --git a/src/Mod/PartDesign/Gui/TaskHelixParameters.cpp b/src/Mod/PartDesign/Gui/TaskHelixParameters.cpp index 85df9c4c39..bc9e878ce6 100644 --- a/src/Mod/PartDesign/Gui/TaskHelixParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskHelixParameters.cpp @@ -61,9 +61,9 @@ using namespace Gui; /* TRANSLATOR PartDesignGui::TaskHelixParameters */ -TaskHelixParameters::TaskHelixParameters(PartDesignGui::ViewProviderHelix *HelixView, QWidget *parent) +TaskHelixParameters::TaskHelixParameters(PartDesignGui::ViewProviderHelix* HelixView, QWidget* parent) : TaskSketchBasedParameters(HelixView, parent, "PartDesign_AdditiveHelix", tr("Helix parameters")), - ui (new Ui_TaskHelixParameters) + ui(new Ui_TaskHelixParameters) { // we need a separate container widget to add all controls to proxy = new QWidget(this); @@ -71,27 +71,27 @@ TaskHelixParameters::TaskHelixParameters(PartDesignGui::ViewProviderHelix *Helix QMetaObject::connectSlotsByName(this); connect(ui->pitch, SIGNAL(valueChanged(double)), - this, SLOT(onPitchChanged(double))); + this, SLOT(onPitchChanged(double))); connect(ui->height, SIGNAL(valueChanged(double)), - this, SLOT(onHeightChanged(double))); + this, SLOT(onHeightChanged(double))); connect(ui->turns, SIGNAL(valueChanged(double)), - this, SLOT(onTurnsChanged(double))); + this, SLOT(onTurnsChanged(double))); connect(ui->coneAngle, SIGNAL(valueChanged(double)), - this, SLOT(onAngleChanged(double))); + this, SLOT(onAngleChanged(double))); connect(ui->growth, SIGNAL(valueChanged(double)), - this, SLOT(onGrowthChanged(double))); + this, SLOT(onGrowthChanged(double))); connect(ui->axis, SIGNAL(activated(int)), - this, SLOT(onAxisChanged(int))); + this, SLOT(onAxisChanged(int))); connect(ui->checkBoxLeftHanded, SIGNAL(toggled(bool)), - this, SLOT(onLeftHandedChanged(bool))); + this, SLOT(onLeftHandedChanged(bool))); connect(ui->checkBoxReversed, SIGNAL(toggled(bool)), - this, SLOT(onReversedChanged(bool))); + this, SLOT(onReversedChanged(bool))); connect(ui->checkBoxUpdateView, SIGNAL(toggled(bool)), - this, SLOT(onUpdateView(bool))); + this, SLOT(onUpdateView(bool))); connect(ui->inputMode, SIGNAL(activated(int)), - this, SLOT(onModeChanged(int))); + this, SLOT(onModeChanged(int))); connect(ui->checkBoxOutside, SIGNAL(toggled(bool)), - this, SLOT(onOutsideChanged(bool))); + this, SLOT(onOutsideChanged(bool))); this->groupLayout()->addWidget(proxy); @@ -153,11 +153,11 @@ TaskHelixParameters::TaskHelixParameters(PartDesignGui::ViewProviderHelix *Helix updateUI(); // enable use of parametric expressions for the numerical fields - ui->pitch->bind(static_cast(pcFeat)->Pitch); - ui->height->bind(static_cast(pcFeat)->Height); - ui->turns->bind(static_cast(pcFeat)->Turns); - ui->coneAngle->bind(static_cast(pcFeat)->Angle); - ui->growth->bind(static_cast(pcFeat)->Growth); + ui->pitch->bind(static_cast(pcFeat)->Pitch); + ui->height->bind(static_cast(pcFeat)->Height); + ui->turns->bind(static_cast(pcFeat)->Turns); + ui->coneAngle->bind(static_cast(pcFeat)->Angle); + ui->growth->bind(static_cast(pcFeat)->Growth); ui->axis->blockSignals(false); ui->pitch->blockSignals(false); @@ -169,20 +169,21 @@ TaskHelixParameters::TaskHelixParameters(PartDesignGui::ViewProviderHelix *Helix ui->checkBoxReversed->blockSignals(false); ui->checkBoxOutside->blockSignals(false); - setFocus (); + setFocus(); //show the parts coordinate system axis for selection - PartDesign::Body * body = PartDesign::Body::findBodyOf ( vp->getObject () ); - if(body) { + PartDesign::Body* body = PartDesign::Body::findBodyOf(vp->getObject()); + if (body) { try { - App::Origin *origin = body->getOrigin(); + App::Origin* origin = body->getOrigin(); ViewProviderOrigin* vpOrigin; vpOrigin = static_cast(Gui::Application::Instance->getViewProvider(origin)); vpOrigin->setTemporaryVisibility(true, false); - } catch (const Base::Exception &ex) { + } + catch (const Base::Exception& ex) { ex.ReportException(); } - } + } } void TaskHelixParameters::fillAxisCombo(bool forceRefill) @@ -193,7 +194,7 @@ void TaskHelixParameters::fillAxisCombo(bool forceRefill) if (axesInList.empty()) forceRefill = true;//not filled yet, full refill - if (forceRefill){ + if (forceRefill) { ui->axis->clear(); this->axesInList.clear(); @@ -201,53 +202,54 @@ void TaskHelixParameters::fillAxisCombo(bool forceRefill) //add sketch axes PartDesign::ProfileBased* pcFeat = static_cast(vp->getObject()); Part::Part2DObject* pcSketch = dynamic_cast(pcFeat->Profile.getValue()); - if (pcSketch){ - addAxisToCombo(pcSketch,"N_Axis",QObject::tr("Normal sketch axis")); - addAxisToCombo(pcSketch,"V_Axis",QObject::tr("Vertical sketch axis")); - addAxisToCombo(pcSketch,"H_Axis",QObject::tr("Horizontal sketch axis")); - for (int i=0; i < pcSketch->getAxisCount(); i++) { - QString itemText = QObject::tr("Construction line %1").arg(i+1); + if (pcSketch) { + addAxisToCombo(pcSketch, "N_Axis", QObject::tr("Normal sketch axis")); + addAxisToCombo(pcSketch, "V_Axis", QObject::tr("Vertical sketch axis")); + addAxisToCombo(pcSketch, "H_Axis", QObject::tr("Horizontal sketch axis")); + for (int i = 0; i < pcSketch->getAxisCount(); i++) { + QString itemText = QObject::tr("Construction line %1").arg(i + 1); std::stringstream sub; sub << "Axis" << i; - addAxisToCombo(pcSketch,sub.str(),itemText); + addAxisToCombo(pcSketch, sub.str(), itemText); } } //add part axes - PartDesign::Body * body = PartDesign::Body::findBodyOf ( pcFeat ); + PartDesign::Body* body = PartDesign::Body::findBodyOf(pcFeat); if (body) { try { App::Origin* orig = body->getOrigin(); - addAxisToCombo(orig->getX(),"",tr("Base X axis")); - addAxisToCombo(orig->getY(),"",tr("Base Y axis")); - addAxisToCombo(orig->getZ(),"",tr("Base Z axis")); - } catch (const Base::Exception &ex) { + addAxisToCombo(orig->getX(), "", tr("Base X axis")); + addAxisToCombo(orig->getY(), "", tr("Base Y axis")); + addAxisToCombo(orig->getZ(), "", tr("Base Z axis")); + } + catch (const Base::Exception& ex) { ex.ReportException(); } } //add "Select reference" - addAxisToCombo(0,std::string(),tr("Select reference...")); + addAxisToCombo(0, std::string(), tr("Select reference...")); }//endif forceRefill //add current link, if not in list //first, figure out the item number for current axis int indexOfCurrent = -1; App::DocumentObject* ax = propReferenceAxis->getValue(); - const std::vector &subList = propReferenceAxis->getSubValues(); + const std::vector& subList = propReferenceAxis->getSubValues(); for (size_t i = 0; i < axesInList.size(); i++) { if (ax == axesInList[i]->getValue() && subList == axesInList[i]->getSubValues()) { indexOfCurrent = i; break; } } - if (indexOfCurrent == -1 && ax) { + if (indexOfCurrent == -1 && ax) { assert(subList.size() <= 1); std::string sub; if (!subList.empty()) sub = subList[0]; addAxisToCombo(ax, sub, getRefStr(ax, subList)); - indexOfCurrent = axesInList.size()-1; + indexOfCurrent = axesInList.size() - 1; } //highlight current. @@ -258,13 +260,13 @@ void TaskHelixParameters::fillAxisCombo(bool forceRefill) } void TaskHelixParameters::addAxisToCombo(App::DocumentObject* linkObj, - std::string linkSubname, - QString itemText) + std::string linkSubname, + QString itemText) { this->ui->axis->addItem(itemText); this->axesInList.emplace_back(new App::PropertyLinkSub); - App::PropertyLinkSub &lnk = *(axesInList.back()); - lnk.setValue(linkObj,std::vector(1,linkSubname)); + App::PropertyLinkSub& lnk = *(axesInList.back()); + lnk.setValue(linkObj, std::vector(1, linkSubname)); } void TaskHelixParameters::updateUI() @@ -273,7 +275,7 @@ void TaskHelixParameters::updateUI() auto pcHelix = static_cast(vp->getObject()); auto status = std::string(pcHelix->getStatusString()); - if (status.compare("Valid")==0 || status.compare("Touched")==0) { + if (status.compare("Valid") == 0 || status.compare("Touched") == 0) { if (pcHelix->safePitch() > propPitch->getValue()) status = "Warning: helix might be self intersecting"; else @@ -281,14 +283,14 @@ void TaskHelixParameters::updateUI() } ui->labelMessage->setText(QString::fromUtf8(status.c_str())); - bool isPitchVisible = false; + bool isPitchVisible = false; bool isHeightVisible = false; - bool isTurnsVisible = false; + bool isTurnsVisible = false; bool isOutsideVisible = false; bool isAngleVisible = false; bool isGrowthVisible = false; - if(pcHelix->getAddSubType() == PartDesign::FeatureAddSub::Subtractive) + if (pcHelix->getAddSubType() == PartDesign::FeatureAddSub::Subtractive) isOutsideVisible = true; HelixMode mode = static_cast(propMode->getValue()); @@ -296,19 +298,23 @@ void TaskHelixParameters::updateUI() isPitchVisible = true; isHeightVisible = true; isAngleVisible = true; - } else if (mode == HelixMode::pitch_turns_angle) { + } + else if (mode == HelixMode::pitch_turns_angle) { isPitchVisible = true; isTurnsVisible = true; isAngleVisible = true; - } else if (mode == HelixMode::height_turns_angle) { + } + else if (mode == HelixMode::height_turns_angle) { isHeightVisible = true; isTurnsVisible = true; isAngleVisible = true; - } else if (mode == HelixMode::height_turns_growth) { + } + else if (mode == HelixMode::height_turns_growth) { isHeightVisible = true; isTurnsVisible = true; isGrowthVisible = true; - } else { + } + else { status = "Error: unsupported mode"; ui->labelMessage->setText(QString::fromUtf8(status.c_str())); } @@ -389,19 +395,20 @@ void TaskHelixParameters::onAxisChanged(int num) if (axesInList.empty()) return; - App::DocumentObject *oldRefAxis = propReferenceAxis->getValue(); + App::DocumentObject* oldRefAxis = propReferenceAxis->getValue(); std::vector oldSubRefAxis = propReferenceAxis->getSubValues(); std::string oldRefName; if (!oldSubRefAxis.empty()) oldRefName = oldSubRefAxis.front(); - App::PropertyLinkSub &lnk = *(axesInList[num]); + App::PropertyLinkSub& lnk = *(axesInList[num]); if (lnk.getValue() == 0) { // enter reference selection mode TaskSketchBasedParameters::onSelectReference(true, true, false, true, true); return; - } else { - if (!pcHelix->getDocument()->isIn(lnk.getValue())){ + } + else { + if (!pcHelix->getDocument()->isIn(lnk.getValue())) { Base::Console().Error("Object was deleted\n"); return; } @@ -412,8 +419,8 @@ void TaskHelixParameters::onAxisChanged(int num) } try { - App::DocumentObject *newRefAxis = propReferenceAxis->getValue(); - const std::vector &newSubRefAxis = propReferenceAxis->getSubValues(); + App::DocumentObject* newRefAxis = propReferenceAxis->getValue(); + const std::vector& newSubRefAxis = propReferenceAxis->getSubValues(); std::string newRefName; if (!newSubRefAxis.empty()) newRefName = newSubRefAxis.front(); @@ -444,7 +451,7 @@ void TaskHelixParameters::onModeChanged(int index) ui->pitch->setValue(propPitch->getValue()); ui->height->setValue(propHeight->getValue()); - ui->turns->setValue((propHeight->getValue())/(propPitch->getValue())); + ui->turns->setValue((propHeight->getValue()) / (propPitch->getValue())); recomputeFeature(); updateUI(); @@ -475,20 +482,21 @@ TaskHelixParameters::~TaskHelixParameters() { try { //hide the parts coordinate system axis for selection - PartDesign::Body * body = vp ? PartDesign::Body::findBodyOf(vp->getObject()) : 0; + PartDesign::Body* body = vp ? PartDesign::Body::findBodyOf(vp->getObject()) : 0; if (body) { - App::Origin *origin = body->getOrigin(); + App::Origin* origin = body->getOrigin(); ViewProviderOrigin* vpOrigin; vpOrigin = static_cast(Gui::Application::Instance->getViewProvider(origin)); vpOrigin->resetTemporaryVisibility(); } - } catch (const Base::Exception &ex) { + } + catch (const Base::Exception& ex) { ex.ReportException(); } } -void TaskHelixParameters::changeEvent(QEvent *e) +void TaskHelixParameters::changeEvent(QEvent* e) { TaskBox::changeEvent(e); if (e->type() == QEvent::LanguageChange) { @@ -502,12 +510,13 @@ void TaskHelixParameters::getReferenceAxis(App::DocumentObject*& obj, std::vecto throw Base::RuntimeError("Not initialized!"); int num = ui->axis->currentIndex(); - const App::PropertyLinkSub &lnk = *(axesInList[num]); + const App::PropertyLinkSub& lnk = *(axesInList[num]); if (lnk.getValue() == 0) { throw Base::RuntimeError("Still in reference selection mode; reference wasn't selected yet"); - } else { + } + else { PartDesign::ProfileBased* pcRevolution = static_cast(vp->getObject()); - if (!pcRevolution->getDocument()->isIn(lnk.getValue())){ + if (!pcRevolution->getDocument()->isIn(lnk.getValue())) { throw Base::RuntimeError("Object was deleted"); } @@ -563,15 +572,15 @@ void TaskHelixParameters::apply() getReferenceAxis(obj, sub); std::string axis = buildLinkSingleSubPythonStr(obj, sub); auto tobj = vp->getObject(); - FCMD_OBJ_CMD(tobj,"ReferenceAxis = " << axis); - FCMD_OBJ_CMD(tobj,"Mode = " << propMode->getValue()); - FCMD_OBJ_CMD(tobj,"Pitch = " << propPitch->getValue()); - FCMD_OBJ_CMD(tobj,"Height = " << propHeight->getValue()); - FCMD_OBJ_CMD(tobj,"Turns = " << propTurns->getValue()); - FCMD_OBJ_CMD(tobj,"Angle = " << propAngle->getValue()); - FCMD_OBJ_CMD(tobj,"Growth = " << propGrowth->getValue()); - FCMD_OBJ_CMD(tobj,"LeftHanded = " << (propLeftHanded->getValue() ? 1 : 0)); - FCMD_OBJ_CMD(tobj,"Reversed = " << (propReversed->getValue() ? 1 : 0)); + FCMD_OBJ_CMD(tobj, "ReferenceAxis = " << axis); + FCMD_OBJ_CMD(tobj, "Mode = " << propMode->getValue()); + FCMD_OBJ_CMD(tobj, "Pitch = " << propPitch->getValue()); + FCMD_OBJ_CMD(tobj, "Height = " << propHeight->getValue()); + FCMD_OBJ_CMD(tobj, "Turns = " << propTurns->getValue()); + FCMD_OBJ_CMD(tobj, "Angle = " << propAngle->getValue()); + FCMD_OBJ_CMD(tobj, "Growth = " << propGrowth->getValue()); + FCMD_OBJ_CMD(tobj, "LeftHanded = " << (propLeftHanded->getValue() ? 1 : 0)); + FCMD_OBJ_CMD(tobj, "Reversed = " << (propReversed->getValue() ? 1 : 0)); } @@ -579,7 +588,7 @@ void TaskHelixParameters::apply() //************************************************************************** // TaskDialog //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -TaskDlgHelixParameters::TaskDlgHelixParameters(ViewProviderHelix *HelixView) +TaskDlgHelixParameters::TaskDlgHelixParameters(ViewProviderHelix* HelixView) : TaskDlgSketchBasedParameters(HelixView) { assert(HelixView); diff --git a/src/Mod/PartDesign/Gui/TaskHelixParameters.h b/src/Mod/PartDesign/Gui/TaskHelixParameters.h index 110cad5444..e45847afb9 100644 --- a/src/Mod/PartDesign/Gui/TaskHelixParameters.h +++ b/src/Mod/PartDesign/Gui/TaskHelixParameters.h @@ -49,7 +49,7 @@ class TaskHelixParameters : public TaskSketchBasedParameters Q_OBJECT public: - TaskHelixParameters(ViewProviderHelix *HelixView,QWidget *parent = 0); + TaskHelixParameters(ViewProviderHelix* HelixView, QWidget* parent = 0); ~TaskHelixParameters(); virtual void apply() override; @@ -64,7 +64,7 @@ public: * list (if necessary), and selected. If the list is empty, it will be refilled anyway. */ void fillAxisCombo(bool forceRefill = false); - void addAxisToCombo(App::DocumentObject *linkObj, std::string linkSubname, QString itemText); + void addAxisToCombo(App::DocumentObject* linkObj, std::string linkSubname, QString itemText); private Q_SLOTS: void onPitchChanged(double); @@ -81,9 +81,9 @@ private Q_SLOTS: protected: void onSelectionChanged(const Gui::SelectionChanges& msg) override; - void changeEvent(QEvent *e) override; + void changeEvent(QEvent* e) override; bool updateView() const; - void getReferenceAxis(App::DocumentObject *&obj, std::vector &sub) const; + void getReferenceAxis(App::DocumentObject*& obj, std::vector& sub) const; void startReferenceSelection(App::DocumentObject* profile, App::DocumentObject* base) override; void finishReferenceSelection(App::DocumentObject* profile, App::DocumentObject* base) override; @@ -124,7 +124,7 @@ class TaskDlgHelixParameters : public TaskDlgSketchBasedParameters Q_OBJECT public: - TaskDlgHelixParameters(ViewProviderHelix *HelixView); + TaskDlgHelixParameters(ViewProviderHelix* HelixView); ViewProviderHelix* getHelixView() const { return static_cast(vp); }