]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Style fix
authordish <Dmitrii.SHVYDKOI@opencascade.com>
Fri, 22 Dec 2023 14:06:35 +0000 (14:06 +0000)
committerdish <dmitrii.shvydkoi@opencascade.com>
Wed, 5 Jun 2024 12:30:41 +0000 (12:30 +0000)
src/ModelAPI/ModelAPI_Tools.cpp
src/XGUI/XGUI_Workshop.cpp

index 2c076b288cbb1db49621b506b3684e739f266601..76af01b4853bbc1679bc55d6e69c527e9225ad91 100644 (file)
@@ -1199,10 +1199,9 @@ bool isShowEdgesDirection(std::shared_ptr<ModelAPI_Result> theResult)
 int getEdgeThickness(const std::shared_ptr<ModelAPI_Result>& 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<ModelAPI_Result>& 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);
-  }
 }
 
 //******************************************************
index 28975c9e5331c7f330cfca2f13dbc8eea07761d3..3932c53a1cd44fe7aa49e3029c983e58f68a2c05 100644 (file)
@@ -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<ModelAPI_Result>(anObj);
-    if (aResult.get() != NULL) {
-      ResultBodyPtr aBodyResult = std::dynamic_pointer_cast<ModelAPI_ResultBody>(aResult);
-      if (aBodyResult.get() != NULL) { // change property for all sub-solids
-        std::list<ResultPtr> allRes;
-        ModelAPI_Tools::allSubs(aBodyResult, allRes);
-        std::list<ResultPtr>::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<ModelAPI_Result>(obj);
+    if (result) {
+      ResultBodyPtr resultBody = std::dynamic_pointer_cast<ModelAPI_ResultBody>(result);
+      if (resultBody) {
+        std::list<ResultPtr> 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<ModelAPI_Result>(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<ModelAPI_Result>(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));
   }