]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
WIP addVolume with body
authorNicolas RECHATIN <nicolas.rechatin@cea.fr>
Wed, 28 Jul 2021 11:52:51 +0000 (13:52 +0200)
committerNicolas RECHATIN <nicolas.rechatin@cea.fr>
Wed, 28 Jul 2021 11:52:51 +0000 (13:52 +0200)
src/OperaPlugin/OperaPlugin_Volume.cpp
src/OperaPlugin/addvolume_widget.xml
src/OperaPlugin/plugin-Opera.xml

index 709364328c08375b63c6f09c433922923dd061ad..8ed676a7847ebb6e5acef87f9093e397f670fa17 100644 (file)
@@ -82,24 +82,16 @@ void OperaPlugin_Volume::execute()
     return;
   }
 
-  AttributeSelectionListPtr aList = selectionList(VOLUME_LIST_ID());
   int aResultIndex = 0;
-  std::set<std::wstring> anExistingNames; // to avoid names duplication
+
+  AttributeSelectionListPtr aList = selectionList(VOLUME_LIST_ID());
+
   for (int aSelIndex = 0; aSelIndex < aList->size(); aSelIndex++) {
     AttributeSelectionPtr aSel = aList->value(aSelIndex);
-    GeomShapePtr aResult = shapeOfSelection(aSel);
-    if (!aResult.get())
-      continue;
-    // std::shared_ptr<GeomAlgoAPI_Copy> aCopyBuilder(new GeomAlgoAPI_Copy(aShape, false, false));
-    // std::string anError;
-    // if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aCopyBuilder, getKind(), anError)) {
-    //   setError(anError);
-    //   return;
-    // }
-    // GeomShapePtr aResult = aCopyBuilder->shape();
+    std::shared_ptr<ModelAPI_Result> aResult = aSel->context();
 
-    std::wstring aBaseName = aSel->context() ? aSel->context()->data()->name() :
-      aSel->contextFeature()->firstResult()->data()->name();
+    std::set<std::wstring> anExistingNames;
+    std::wstring aBaseName = aResult->data()->name();
     std::wstring aName;
     int anInd = 0;
     do {
@@ -110,15 +102,10 @@ void OperaPlugin_Volume::execute()
     } while (anExistingNames.count(aName));
     anExistingNames.insert(aName);
 
-    std::shared_ptr<ModelAPI_ResultBody> aResultBody = document()->createBody(data(), aResultIndex);
+    ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex);
     aResultBody->data()->setName(aName);
-    // to make sub-results also names with a similar name temporarily rename the feature
-    // std::wstring anOrigName = name();
-    // data()->setName(aBaseName);
-    aResultBody->store(aResult);
-    // data()->setName(anOrigName);
-    // aResultBody->loadFirstLevel(aResult, "Copy");
+    aResultBody->store(aResult->shape());
     setResult(aResultBody, aResultIndex++);
+    aResult->setDisabled(aResult, true);
   }
-  removeResults(aResultIndex);
 }
index 042e18492548fc32dba5bfe9ccdd0948fef1d212..8f18a004d74adfe6fda13f3366594f9dcddfc8bd 100644 (file)
@@ -6,7 +6,8 @@
   <multi_selector id="volume_list"
                   label="Select solids"
                   tooltip="Select solid objects"
-                  shape_types="solids">
+                  shape_types="solids"
+                  concealment="true">
     <validator id="GeomValidators_ShapeType" parameters="solid"/>
   </multi_selector>
 </source>
index 97914e06ab6a188ce0dbba6ec6c1aa8243acfb6a..3fe8fce5ea631c0e48a78f39079ba25c266384ff 100644 (file)
@@ -1,7 +1,12 @@
 <plugin>
   <workbench id="Opera" document="Part">
     <group id="Opera">
-      <feature id="addVolume" title="addVolume" tooltip="Create a volume" icon="icons/Opera/addVolume.png"
+      <feature
+               id="addVolume"
+               title="addVolume"
+               tooltip="Create a volume"
+               icon="icons/Opera/addVolume.png"
+               auto_preview="true"
                helpfile="addvolumeFeature.html">
         <source path="addvolume_widget.xml"/>
       </feature>