-// Copyright (C) 2014-2017 CEA/DEN, EDF R&D
+// Copyright (C) 2014-2021 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
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// See http://www.salome-platform.org/ or
-// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#include "ModelHighAPI_Selection.h"
#include <ModelAPI_AttributeSelectionList.h>
#include <ModelAPI_Feature.h>
#include <ModelAPI_ResultBody.h>
-
+#include <ModelAPI_Tools.h>
#include <GeomAPI_Pnt.h>
//--------------------------------------------------------------------------------------
}
ModelHighAPI_Selection::ModelHighAPI_Selection(const std::string& theType,
- const std::string& theSubShapeName)
+ const std::wstring& theSubShapeName)
: myVariantType(VT_TypeSubShapeNamePair)
, myTypeSubShapeNamePair(theType, theSubShapeName)
{
}
ModelHighAPI_Selection::ModelHighAPI_Selection(const std::string& theType,
- const std::string& theContextName, const int theIndex)
- : myVariantType(VT_WeakNamingPair)
- , myWeakNamingPair(theType, std::pair<std::string, int>(theContextName, theIndex))
+ const std::wstring& theContextName, const int theIndex)
+ : myVariantType(VT_WeakNamingPair),
+ myWeakNamingPair(theType, std::pair<std::wstring, int>(theContextName, theIndex))
{
}
theAttribute->selectSubShape(
myWeakNamingPair.first, myWeakNamingPair.second.first, myWeakNamingPair.second.second);
break;
+ case VT_Filtering:
+ break; // do nothing [to avoid compilation warning]
}
if (theAttribute->isInvalid()) {
theAttribute->append(
myWeakNamingPair.first, myWeakNamingPair.second.first, myWeakNamingPair.second.second);
return;
+ case VT_Filtering:
+ theAttribute->setFilters(myFilterFeature);
+ return;
}
}
return myTypeInnerPointPair;
}
+//==================================================================================================
+TypeWeakNamingPair ModelHighAPI_Selection::typeWeakNamingPair() const
+{
+ return myWeakNamingPair;
+}
+
//==================================================================================================
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<ModelAPI_Result> aResult = myResultSubShapePair.first;
}
}
-std::string ModelHighAPI_Selection::name() const
+std::wstring ModelHighAPI_Selection::name() const
{
if (myVariantType == VT_ResultSubShapePair) {
std::shared_ptr<ModelAPI_Result> 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;
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<int> 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)
aDeflectionAttr->setValue(theValue);
}
+// LCOV_EXCL_START
void ModelHighAPI_Selection::setTransparency(double theValue)
{
if (myVariantType != VT_ResultSubShapePair)
aTransparencyAttr->setValue(theValue);
}
+// LCOV_EXCL_STOP
int ModelHighAPI_Selection::numberOfSubs() const
{