From 728b2ec8411de99b17b3b84c8dcef003c18cf1f5 Mon Sep 17 00:00:00 2001 From: wandererfan Date: Fri, 8 Sep 2023 10:22:17 -0400 Subject: [PATCH] [Part]fix canScale logic - fix canScale logic - remove unused method - add more comments --- src/Mod/Part/Gui/DlgScale.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/Mod/Part/Gui/DlgScale.cpp b/src/Mod/Part/Gui/DlgScale.cpp index 03db951346..3666740351 100644 --- a/src/Mod/Part/Gui/DlgScale.cpp +++ b/src/Mod/Part/Gui/DlgScale.cpp @@ -108,15 +108,6 @@ void DlgScale::onUniformScaleToggled(bool state) } } -App::DocumentObject& DlgScale::getShapeToScale() const -{ -// Base::Console().Message("DS::getShapeToScale()\n"); - std::vector objs = this->getShapesToScale(); - if (objs.empty()) - throw Base::ValueError("No shapes selected"); - return *(objs[0]); -} - //! find all the scalable objects in the active document and load them into the //! list widget void DlgScale::findShapes() @@ -149,6 +140,7 @@ void DlgScale::findShapes() } } +//! return true if shape can be scaled. bool DlgScale::canScale(const TopoDS_Shape& shape) const { if (shape.IsNull()) { @@ -164,11 +156,13 @@ bool DlgScale::canScale(const TopoDS_Shape& shape) const if (type == TopAbs_COMPOUND || type == TopAbs_COMPSOLID) { TopExp_Explorer xp; - xp.Init(shape, TopAbs_SHAPE); + xp.Init(shape, TopAbs_EDGE); for ( ; xp.More() ; xp.Next()) { - // there is at least 1 sub shape inside the compound + // there is at least 1 edge inside the compound, so as long as it isn't null, + // we can scale this shape. We can stop looking as soon as we find a non-null + // edge. if (!xp.Current().IsNull()) { - // found a non-null shape + // found a non-null edge return true; } } @@ -194,6 +188,7 @@ void DlgScale::accept() }; } +// create a FeatureScale for each scalable object void DlgScale::apply() { // Base::Console().Message("DS::apply()\n"); @@ -272,6 +267,8 @@ void DlgScale::reject() QDialog::reject(); } +//! retrieve the document objects associated with the selected items in the list +//! widget std::vector DlgScale::getShapesToScale() const { // Base::Console().Message("DS::getShapesToScale()\n"); @@ -290,6 +287,8 @@ std::vector DlgScale::getShapesToScale() const return objects; } +//! return true if at least one item in the list widget corresponds to an +//! available document object in the document bool DlgScale::validate() { QList items = ui->treeWidget->selectedItems(); @@ -307,6 +306,7 @@ bool DlgScale::validate() return !objects.empty(); } +//! update a FeatureScale with the parameters from the UI void DlgScale::writeParametersToFeature(App::DocumentObject &feature, App::DocumentObject* base) const { // Base::Console().Message("DS::writeParametersToFeature()\n");