Salome HOME
updated copyright message
[modules/shaper.git] / src / ModuleBase / ModuleBase_Tools.cpp
index c4ae53fe11acc25e619a7506771e4ec8f709bb21..da130c0ac9a06b74b275ef34a64404568c5811c7 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2021  CEA/DEN, EDF R&D
+// Copyright (C) 2014-2023  CEA, EDF
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
@@ -56,6 +56,8 @@
 #include <ModelGeomAlgo_Point2D.h>
 #include <SUIT_ResourceMgr.h>
 
+#include <Basics_OCCTVersion.hxx>
+
 #ifdef HAVE_SALOME
 #include <SUIT_Application.h>
 #include <SUIT_Session.h>
@@ -446,7 +448,7 @@ int shapeType(const QString& theType)
 
 void checkObjects(const QObjectPtrList& theObjects, bool& hasResult, bool& hasFeature,
                   bool& hasParameter, bool& hasCompositeOwner, bool& hasResultInHistory,
-                  bool& hasFolder)
+                  bool& hasFolder, bool &hasGroupsOnly)
 {
   hasResult = false;
   hasFeature = false;
@@ -454,9 +456,11 @@ void checkObjects(const QObjectPtrList& theObjects, bool& hasResult, bool& hasFe
   hasCompositeOwner = false;
   hasResultInHistory = false;
   hasFolder = false;
+  bool hasNonGroup = false;
   foreach(ObjectPtr aObj, theObjects) {
     FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(aObj);
     ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(aObj);
+    ResultGroupPtr aGroup = std::dynamic_pointer_cast<ModelAPI_ResultGroup>(aObj);
     FolderPtr aFolder = std::dynamic_pointer_cast<ModelAPI_Folder>(aObj);
     ResultParameterPtr aConstruction = std::dynamic_pointer_cast<ModelAPI_ResultParameter>(aResult);
     FieldStepPtr aStep = std::dynamic_pointer_cast<ModelAPI_ResultField::ModelAPI_FieldStep>(aObj);
@@ -465,6 +469,7 @@ void checkObjects(const QObjectPtrList& theObjects, bool& hasResult, bool& hasFe
     hasFeature |= (aFeature.get() != NULL);
     hasFolder |= (aFolder.get() != NULL);
     hasParameter |= (aConstruction.get() != NULL);
+    hasNonGroup |= (aGroup.get() == NULL);
     if (hasFeature)
       hasCompositeOwner |= (ModelAPI_Tools::compositeOwner(aFeature) != NULL);
     else if (aResult.get())
@@ -475,41 +480,12 @@ void checkObjects(const QObjectPtrList& theObjects, bool& hasResult, bool& hasFe
       hasResultInHistory = aFeature.get() && aFeature->isInHistory();
     }
 
-    if (hasFeature && hasResult  && hasParameter && hasCompositeOwner)
+    if (hasFeature && hasResult && hasParameter && hasCompositeOwner && hasNonGroup)
       break;
   }
+  hasGroupsOnly = !hasNonGroup;
 }
 
-/*bool setDefaultDeviationCoefficient(std::shared_ptr<GeomAPI_Shape> theGeomShape)
-{
-  if (!theGeomShape.get())
-    return false;
-  // if the shape could not be exploded on faces, it contains only wires, edges, and vertices
-  // correction of deviation for them should not influence to the application performance
-  GeomAPI_ShapeExplorer anExp(theGeomShape, GeomAPI_Shape::FACE);
-  bool anEmpty = anExp.empty();
-  return !anExp.more();
-}*/
-
-/*void setDefaultDeviationCoefficient(const std::shared_ptr<ModelAPI_Result>& theResult,
-                                    const Handle(Prs3d_Drawer)& theDrawer)
-{
-  if (!theResult.get())
-    return;
-  bool aUseDeviation = false;
-
-  std::string aResultGroup = theResult->groupName();
-  if (aResultGroup == ModelAPI_ResultConstruction::group())
-    aUseDeviation = true;
-  else if (aResultGroup == ModelAPI_ResultBody::group()) {
-    GeomShapePtr aGeomShape = theResult->shape();
-    if (aGeomShape.get())
-      aUseDeviation = setDefaultDeviationCoefficient(aGeomShape);
-  }
-  if (aUseDeviation)
-    theDrawer->SetDeviationCoefficient(DEFAULT_DEVIATION_COEFFICIENT);
-}
-*/
 void setDefaultDeviationCoefficient(const TopoDS_Shape& theShape,
                                     const Handle(Prs3d_Drawer)& theDrawer)
 {
@@ -1104,10 +1080,7 @@ bool askToDelete(const std::set<FeaturePtr> theFeatures,
     aText += QString(QObject::tr(aMsg));
     aDetailedText += QString(QObject::tr(aMsgDetails))
                      .arg(aParamFeatureNames.join(aSep));
-#ifdef _DEBUG
-    QPushButton *aReplaceButton =
-#endif
-      aMessageBox.addButton(QObject::tr("Replace"), QMessageBox::ActionRole);
+    aMessageBox.addButton(QObject::tr("Replace"), QMessageBox::ActionRole);
   }
 
   if (!aText.isEmpty()) {
@@ -1264,11 +1237,19 @@ void setPointBallHighlighting(AIS_InteractiveObject* theAIS)
       anAspect = aPntAspect->Aspect();
       anAspect->SetType(Aspect_TOM_BALL);
     } else {
+#if OCC_VERSION_LARGE < 0x07070000
       if(aPixMap->Format() == Image_PixMap::ImgGray) {
         aPixMap->SetFormat (Image_PixMap::ImgAlpha);
       } else if(aPixMap->Format() == Image_PixMap::ImgGrayF) {
         aPixMap->SetFormat (Image_PixMap::ImgAlphaF);
       }
+#else
+      if(aPixMap->Format() == Image_Format_Gray) {
+        aPixMap->SetFormat (Image_Format_Alpha);
+      } else if(aPixMap->Format() == Image_Format_GrayF) {
+        aPixMap->SetFormat (Image_Format_AlphaF);
+      }
+#endif
       anAspect = new Graphic3d_AspectMarker3d(aPixMap);
       aPntAspect->SetAspect(anAspect);
     }