From d8eea1d83997ad7da34b19e06a6eea9db2d1c543 Mon Sep 17 00:00:00 2001 From: Nicolas RECHATIN Date: Wed, 28 Jul 2021 13:52:51 +0200 Subject: [PATCH] WIP addVolume with body --- src/OperaPlugin/OperaPlugin_Volume.cpp | 31 ++++++++------------------ src/OperaPlugin/addvolume_widget.xml | 3 ++- src/OperaPlugin/plugin-Opera.xml | 7 +++++- 3 files changed, 17 insertions(+), 24 deletions(-) diff --git a/src/OperaPlugin/OperaPlugin_Volume.cpp b/src/OperaPlugin/OperaPlugin_Volume.cpp index 709364328..8ed676a78 100644 --- a/src/OperaPlugin/OperaPlugin_Volume.cpp +++ b/src/OperaPlugin/OperaPlugin_Volume.cpp @@ -82,24 +82,16 @@ void OperaPlugin_Volume::execute() return; } - AttributeSelectionListPtr aList = selectionList(VOLUME_LIST_ID()); int aResultIndex = 0; - std::set 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 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 aResult = aSel->context(); - std::wstring aBaseName = aSel->context() ? aSel->context()->data()->name() : - aSel->contextFeature()->firstResult()->data()->name(); + std::set 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 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); } diff --git a/src/OperaPlugin/addvolume_widget.xml b/src/OperaPlugin/addvolume_widget.xml index 042e18492..8f18a004d 100644 --- a/src/OperaPlugin/addvolume_widget.xml +++ b/src/OperaPlugin/addvolume_widget.xml @@ -6,7 +6,8 @@ + shape_types="solids" + concealment="true"> diff --git a/src/OperaPlugin/plugin-Opera.xml b/src/OperaPlugin/plugin-Opera.xml index 97914e06a..3fe8fce5e 100644 --- a/src/OperaPlugin/plugin-Opera.xml +++ b/src/OperaPlugin/plugin-Opera.xml @@ -1,7 +1,12 @@ - -- 2.39.2