ListOfShape::const_iterator anIt = aFaces.cbegin();
for(; anIt != aFaces.cend(); ++anIt) {
GeomShapePtr aFacePtr = *anIt;
- aFacesListAttr->append(aCompSolidAttr->context(), aFacePtr);
+ if (!(aFacesListAttr->isInList(aCompSolidAttr->context(), aFacePtr))) {
+ aFacesListAttr->append(aCompSolidAttr->context(), aFacePtr);
+ }
}
- std::stringstream alabel;
- alabel << aFacesListAttr->size();
+ std::stringstream aLabel;
+ aLabel << aFacesListAttr->size();
AttributeStringPtr aNumberFacesAttr =
std::dynamic_pointer_cast<ModelAPI_AttributeString>(attributNumberFaces());
- aNumberFacesAttr->setValue(alabel.str());
+ aNumberFacesAttr->setValue(aLabel.str());
}
}
}
//=================================================================================================
-void FeaturesPlugin_CommonSharedFaces::setFacesGroup(const std::wstring& theName )
+void FeaturesPlugin_CommonSharedFaces::setFacesGroup(const std::wstring& theName)
{
std::vector<int> aColor;
ResultGroupPtr aGroup = document()->createGroup(data());
#include <Locale_Convert.h>
+#include <sstream>
+
//=================================================================================================
FeaturesPlugin_GroupSharedFaces::FeaturesPlugin_GroupSharedFaces()
{
//=================================================================================================
void FeaturesPlugin_GroupSharedFaces::initAttributes()
{
- // attribute for object selected
data()->addAttribute(OBJECT_ID(), ModelAPI_AttributeSelection::typeId());
- AttributeSelectionListPtr aList = std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(
- data()->addAttribute(LIST_FACES_ID(), ModelAPI_AttributeSelectionList::typeId()));
-
+ data()->addAttribute(LIST_FACES_ID(), ModelAPI_AttributeSelectionList::typeId());
data()->addAttribute(NUMBER_FACES_ID(), ModelAPI_AttributeString::typeId());
data()->addAttribute(TRANSPARENCY_ID(), ModelAPI_AttributeInteger::typeId());
data()->addAttribute(GROUP_NAME_ID(), ModelAPI_AttributeString::typeId());
ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), TRANSPARENCY_ID());
ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), COMPUTE_ID());
ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), NUMBER_FACES_ID());
+ ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), LIST_FACES_ID());
+
data()->boolean(COMPUTE_ID())->setValue(true);
}
{
if (selectionList(LIST_FACES_ID())->isInitialized()
&& string(GROUP_NAME_ID())->value() != "") {
- AttributeStringPtr aNameAtt = string( GROUP_NAME_ID() ) ;
+ AttributeStringPtr aNameAtt = string(GROUP_NAME_ID()) ;
std::wstring aNameFace = aNameAtt->isUValue() ?
Locale::Convert::toWString(aNameAtt->valueU()) :
Locale::Convert::toWString(aNameAtt->value());
ModelAPI_Tools::setTransparency(*aRes, aTranparency);
}
}
+
+ // Update the number of shared faces
+ AttributeSelectionListPtr aFacesListAttr =
+ std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList> (attributListFaces());
+ AttributeStringPtr aNumberFacesAttr =
+ std::dynamic_pointer_cast<ModelAPI_AttributeString> (attributNumberFaces());
+ std::stringstream aLabel;
+ aLabel << aFacesListAttr->size();
+ aNumberFacesAttr->setValue(aLabel.str());
}
//=================================================================================================
void FeaturesPlugin_GroupSharedFaces::attributeChanged(const std::string& theID)
{
- if (theID == OBJECT_ID())
+ if (theID == OBJECT_ID() || theID == LIST_FACES_ID())
updateFaces();
}
#include <ModelAPI_Tools.h>
#include <ModelAPI_Validator.h>
+#include <sstream>
+
//=================================================================================================
FeaturesPlugin_SharedFaces::FeaturesPlugin_SharedFaces()
{
//=================================================================================================
void FeaturesPlugin_SharedFaces::initAttributes()
{
- // attribute for object selected
data()->addAttribute(OBJECT_ID(), ModelAPI_AttributeSelection::typeId());
- AttributeSelectionListPtr aList = std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(
- data()->addAttribute(LIST_FACES_ID(), ModelAPI_AttributeSelectionList::typeId()));
+ data()->addAttribute(LIST_FACES_ID(), ModelAPI_AttributeSelectionList::typeId());
data()->addAttribute(NUMBER_FACES_ID(), ModelAPI_AttributeString::typeId());
data()->addAttribute(TRANSPARENCY_ID(), ModelAPI_AttributeInteger::typeId());
ModelAPI_Tools::setTransparency(*aRes, aTranparency);
}
}
+
+ // Update the number of shared faces
+ AttributeSelectionListPtr aFacesListAttr =
+ std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList> (attributListFaces());
+ AttributeStringPtr aNumberFacesAttr =
+ std::dynamic_pointer_cast<ModelAPI_AttributeString> (attributNumberFaces());
+ std::stringstream aLabel;
+ aLabel << aFacesListAttr->size();
+ aNumberFacesAttr->setValue(aLabel.str());
}
//=================================================================================================
void FeaturesPlugin_SharedFaces::attributeChanged(const std::string& theID)
{
if (theID == OBJECT_ID()) {
-
updateFaces();
if (myCreateGroupFeature.get())
updateGroup();
{
myCreateGroupFeature->boolean(FeaturesPlugin_GroupSharedFaces::COMPUTE_ID())->setValue(false);
myCreateGroupFeature->string(FeaturesPlugin_GroupSharedFaces::GROUP_NAME_ID())
- ->setValue( string(GROUP_NAME_ID())->value());
+ ->setValue(string(GROUP_NAME_ID())->value());
myCreateGroupFeature->selection(FeaturesPlugin_GroupSharedFaces::OBJECT_ID())
- ->setValue( selection(OBJECT_ID())->context() ,
- selection(OBJECT_ID())->value() );
+ ->setValue(selection(OBJECT_ID())->context(), selection(OBJECT_ID())->value());
AttributeSelectionListPtr aFacesFeatures =
std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>
(myCreateGroupFeature->attribute(LIST_FACES_ID()));