From: dish Date: Fri, 22 Dec 2023 14:06:35 +0000 (+0000) Subject: Style fix X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=01d7f2fc1b1045a1905af1d156daaf19d400155d;p=modules%2Fshaper.git Style fix --- diff --git a/src/ModelAPI/ModelAPI_Tools.cpp b/src/ModelAPI/ModelAPI_Tools.cpp index 2c076b288..76af01b48 100644 --- a/src/ModelAPI/ModelAPI_Tools.cpp +++ b/src/ModelAPI/ModelAPI_Tools.cpp @@ -1199,10 +1199,9 @@ bool isShowEdgesDirection(std::shared_ptr theResult) int getEdgeThickness(const std::shared_ptr& theResult) { int aThickness = -1; - if (theResult.get() != NULL && - theResult->data()->attribute(ModelAPI_Result::EDGE_THICKNESS_ID()).get() != NULL) { + if (theResult && theResult->data()->attribute(ModelAPI_Result::EDGE_THICKNESS_ID())) { AttributeIntegerPtr aIntAttr = theResult->data()->integer(ModelAPI_Result::EDGE_THICKNESS_ID()); - if (aIntAttr.get() && aIntAttr->isInitialized()) { + if (aIntAttr && aIntAttr->isInitialized()) { aThickness = aIntAttr->value(); } } @@ -1211,13 +1210,12 @@ int getEdgeThickness(const std::shared_ptr& theResult) void setEdgeThickness(ResultPtr theResult, int theEdgeThickness) { - if (!theResult.get()) + if (!theResult) return; AttributeIntegerPtr anAttribute = theResult->data()->integer(ModelAPI_Result::EDGE_THICKNESS_ID()); - if (anAttribute.get() != NULL) { + if (anAttribute) anAttribute->setValue(theEdgeThickness); - } } //****************************************************** diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index 28975c9e5..3932c53a1 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -2520,7 +2520,7 @@ bool XGUI_Workshop::canChangeProperty(const QString& theActionName) const { if (theActionName == "COLOR_CMD" || theActionName == "DEFLECTION_CMD" || - theActionName == "TRANSPARENCY_CMD" || + theActionName == "TRANSPARENCY_CMD" || theActionName == "EDGE_THICKNESS_CMD") { QObjectPtrList anObjects = mySelector->selection()->selectedObjects(); @@ -2881,19 +2881,18 @@ int getDefaultEdgeThickness() //************************************************************** void setEdgeThickness(int theThickness, const QObjectPtrList& theObjects) { - foreach(ObjectPtr anObj, theObjects) { - ResultPtr aResult = std::dynamic_pointer_cast(anObj); - if (aResult.get() != NULL) { - ResultBodyPtr aBodyResult = std::dynamic_pointer_cast(aResult); - if (aBodyResult.get() != NULL) { // change property for all sub-solids - std::list allRes; - ModelAPI_Tools::allSubs(aBodyResult, allRes); - std::list::iterator aRes; - for(aRes = allRes.begin(); aRes != allRes.end(); aRes++) { - ModelAPI_Tools::setEdgeThickness(*aRes, theThickness); + foreach(ObjectPtr obj, theObjects) { + ResultPtr result = std::dynamic_pointer_cast(obj); + if (result) { + ResultBodyPtr resultBody = std::dynamic_pointer_cast(result); + if (resultBody) { + std::list subResults; + ModelAPI_Tools::allSubs(resultBody, subResults); + for(auto itSubResult = subResults.begin(); itSubResult != subResults.end(); itSubResult++) { + ModelAPI_Tools::setEdgeThickness(*itSubResult, theThickness); } } - ModelAPI_Tools::setEdgeThickness(aResult, theThickness); + ModelAPI_Tools::setEdgeThickness(result, theThickness); } } } @@ -2901,45 +2900,46 @@ void setEdgeThickness(int theThickness, const QObjectPtrList& theObjects) //************************************************************** void XGUI_Workshop::changeEdgeThickness(const QObjectPtrList& theObjects) { - AttributeIntegerPtr aDoubleAttr; // 1. Get current value. - int aCurrentValue = -1; - foreach(ObjectPtr anObject, theObjects) { - ResultPtr aResult = std::dynamic_pointer_cast(anObject); - if (aResult.get()) { - aCurrentValue = ModelAPI_Tools::getEdgeThickness(aResult); - if (aCurrentValue < 0) - aCurrentValue = getDefaultEdgeThickness(); - } - if (aCurrentValue > 0) + int currentValue = -1; + foreach(ObjectPtr object, theObjects) { + ResultPtr result = std::dynamic_pointer_cast(object); + if (!result) + continue; + + currentValue = ModelAPI_Tools::getEdgeThickness(result); + if (currentValue < 0) + currentValue = getDefaultEdgeThickness(); + + if (currentValue > 0) break; } - if (aCurrentValue < 0) + if (currentValue < 0) return; if (!abortAllOperations()) return; // 2. Show the dialog. - XGUI_PropertyDialog* aDlg = new XGUI_PropertyDialog(desktop()); - aDlg->setWindowTitle(tr("Edge Thickness")); - XGUI_EdgeThicknessWidget* aEdgeThicknessWidget = new XGUI_EdgeThicknessWidget(aDlg); - connect(aEdgeThicknessWidget, SIGNAL(thicknessValueChanged()), this, SLOT(onEdgeThicknessValueChanged())); - aDlg->setContent(aEdgeThicknessWidget); - aEdgeThicknessWidget->setValue(aCurrentValue); + const auto dialog = new XGUI_PropertyDialog(desktop()); + dialog->setWindowTitle(tr("Edge Thickness")); + XGUI_EdgeThicknessWidget* edgeThicknessWidget = new XGUI_EdgeThicknessWidget(dialog); + connect(edgeThicknessWidget, SIGNAL(thicknessValueChanged()), this, SLOT(onEdgeThicknessValueChanged())); + dialog->setContent(edgeThicknessWidget); + aEdgeThicknessWidget->setValue(currentValue); // 3. Abort the previous operation and start a new one. - SessionPtr aMgr = ModelAPI_Session::get(); - QString aDescription = contextMenuMgr()->action("EDGE_THICKNESS_CMD")->text(); - aMgr->startOperation(aDescription.toStdString()); + SessionPtr session = ModelAPI_Session::get(); + QString description = contextMenuMgr()->action("EDGE_THICKNESS_CMD")->text(); + session->startOperation(description.toStdString()); - if (aDlg->exec() == QDialog::Accepted) { + if (dialog->exec() == QDialog::Accepted) { // 4. Set the value to all results. - aCurrentValue = aEdgeThicknessWidget->getValue(); - setEdgeThickness(aCurrentValue, theObjects); - aMgr->finishOperation(); + currentValue = edgeThicknessWidget->getValue(); + setEdgeThickness(currentValue, theObjects); + session->finishOperation(); } else { - aMgr->abortOperation(); + session->abortOperation(); Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY)); }