X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModelHighAPI%2FModelHighAPI_Selection.cpp;h=5c8bf3e4cb1095463d4255dfaa21990f2cf6e2fe;hb=fc72d43b677baa05ae7fd317346fd8b723b799ed;hp=cb74050bce40a957fa16dba8abc967a06f830736;hpb=6e421e939851e0de46554ae45a3ca0e1f67cd91d;p=modules%2Fshaper.git diff --git a/src/ModelHighAPI/ModelHighAPI_Selection.cpp b/src/ModelHighAPI/ModelHighAPI_Selection.cpp index cb74050bc..5c8bf3e4c 100644 --- a/src/ModelHighAPI/ModelHighAPI_Selection.cpp +++ b/src/ModelHighAPI/ModelHighAPI_Selection.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2019 CEA/DEN, EDF R&D +// Copyright (C) 2014-2023 CEA/DEN, EDF R&D // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -25,7 +25,7 @@ #include #include #include - +#include #include //-------------------------------------------------------------------------------------- @@ -44,7 +44,7 @@ ModelHighAPI_Selection::ModelHighAPI_Selection(const std::shared_ptr(theContextName, theIndex)) + const std::wstring& theContextName, const int theIndex) + : myVariantType(VT_WeakNamingPair), + myWeakNamingPair(theType, std::pair(theContextName, theIndex)) { } @@ -102,6 +102,8 @@ void ModelHighAPI_Selection::fillAttribute( theAttribute->selectSubShape( myWeakNamingPair.first, myWeakNamingPair.second.first, myWeakNamingPair.second.second); break; + case VT_Filtering: + break; // do nothing [to avoid compilation warning] } if (theAttribute->isInvalid()) { @@ -133,6 +135,9 @@ void ModelHighAPI_Selection::appendToList( theAttribute->append( myWeakNamingPair.first, myWeakNamingPair.second.first, myWeakNamingPair.second.second); return; + case VT_Filtering: + theAttribute->setFilters(myFilterFeature); + return; } } @@ -175,13 +180,15 @@ std::string ModelHighAPI_Selection::shapeType() const myResultSubShapePair.first->shape()->shapeTypeStr(); case VT_TypeSubShapeNamePair: return myTypeSubShapeNamePair.first; case VT_TypeInnerPointPair: return myTypeInnerPointPair.first; + default: + break; // do nothing [to avoid compilation warning] } return "SHAPE"; } //================================================================================================== -void ModelHighAPI_Selection::setName(const std::string& theName) +void ModelHighAPI_Selection::setName(const std::wstring& theName) { if (myVariantType == VT_ResultSubShapePair) { std::shared_ptr aResult = myResultSubShapePair.first; @@ -192,17 +199,17 @@ void ModelHighAPI_Selection::setName(const std::string& theName) } } -std::string ModelHighAPI_Selection::name() const +std::wstring ModelHighAPI_Selection::name() const { if (myVariantType == VT_ResultSubShapePair) { std::shared_ptr aResult = myResultSubShapePair.first; if (aResult.get()) return aResult->data()->name(); } - return std::string(); + return std::wstring(); } -void ModelHighAPI_Selection::setColor(int theRed, int theGreen, int theBlue) +void ModelHighAPI_Selection::setColor(int theRed, int theGreen, int theBlue, bool random) { if (myVariantType != VT_ResultSubShapePair || !myResultSubShapePair.first.get()) return; @@ -210,14 +217,25 @@ void ModelHighAPI_Selection::setColor(int theRed, int theGreen, int theBlue) AttributeIntArrayPtr aColor = myResultSubShapePair.first->data()->intArray(ModelAPI_Result::COLOR_ID()); aColor->setSize(3); - aColor->setValue(0, theRed); - aColor->setValue(1, theGreen); - aColor->setValue(2, theBlue); + + if (random) + { + std::vector aValues; + ModelAPI_Tools::findRandomColor(aValues); + for (int anIndex = 0; anIndex < 3; ++anIndex) + aColor->setValue(anIndex, aValues[anIndex]); + } + else + { + aColor->setValue(0, theRed); + aColor->setValue(1, theGreen); + aColor->setValue(2, theBlue); + } } void ModelHighAPI_Selection::setDeflection(double theValue) { - if (myVariantType != VT_ResultSubShapePair) + if (myVariantType != VT_ResultSubShapePair || !myResultSubShapePair.first.get()) return; AttributeDoublePtr aDeflectionAttr = @@ -229,7 +247,7 @@ void ModelHighAPI_Selection::setDeflection(double theValue) // LCOV_EXCL_START void ModelHighAPI_Selection::setTransparency(double theValue) { - if (myVariantType != VT_ResultSubShapePair) + if (myVariantType != VT_ResultSubShapePair || !myResultSubShapePair.first.get()) return; AttributeDoublePtr aTransparencyAttr =