bool ModuleBase_WidgetShapeSelector::setSelection(ModuleBase_ViewerPrs theValue)
{
ObjectPtr aObject = theValue.object();
- ObjectPtr aCurrentObject = getObject();
+ ObjectPtr aCurrentObject = getObject(myFeature->attribute(attributeID()));
if ((!aCurrentObject) && (!aObject))
return false;
return false;
}
-//********************************************************************
-ObjectPtr ModuleBase_WidgetShapeSelector::getObject() const
+ObjectPtr ModuleBase_WidgetShapeSelector::getObject(const AttributePtr& theAttribute)
{
ObjectPtr anObject;
-
- DataPtr aData = myFeature->data();
- if (aData.get() == NULL)
- return anObject;
-
- AttributeSelectionPtr aSelect = aData->selection(attributeID());
- if (aSelect) {
- anObject = aSelect->context();
- } else {
- AttributeRefAttrPtr aRefAttr = aData->refattr(attributeID());
- if (aRefAttr) {
- anObject = aRefAttr->object();
- } else {
- AttributeReferencePtr aRef = aData->reference(attributeID());
- if (aRef) {
- anObject = aRef->value();
- }
- }
+ std::string anAttrType = theAttribute->attributeType();
+ if (anAttrType == ModelAPI_AttributeRefAttr::type()) {
+ AttributeRefAttrPtr anAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theAttribute);
+ if (anAttr != NULL && anAttr->isObject())
+ anObject = anAttr->object();
+ }
+ if (anAttrType == ModelAPI_AttributeSelection::type()) {
+ AttributeSelectionPtr anAttr = std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(theAttribute);
+ if (anAttr != NULL && anAttr->isInitialized())
+ anObject = anAttr->context();
+ }
+ if (anAttrType == ModelAPI_AttributeReference::type()) {
+ AttributeReferencePtr anAttr = std::dynamic_pointer_cast<ModelAPI_AttributeReference>(theAttribute);
+ if (anAttr.get() != NULL && anAttr->isInitialized())
+ anObject = anAttr->value();
}
return anObject;
}
+
//********************************************************************
GeomShapePtr ModuleBase_WidgetShapeSelector::getShape() const
{
}
}
if (!isNameUpdated) {
- ObjectPtr anObject = getObject();
+ ObjectPtr anObject = getObject(myFeature->attribute(attributeID()));
if (anObject.get() != NULL) {
std::string aName = anObject->data()->name();
myTextLine->setText(QString::fromStdString(aName));
aFactory->validators(parentID(), attributeID(), aValidators, anArguments);
DataPtr aData = myFeature->data();
- //AttributePtr aAttr = aData->attribute(attributeID());
AttributeRefAttrPtr aRefAttr = aData->refattr(attributeID());
if (aRefAttr) {
// 1. saves the previous attribute values
#include <GeomAdaptor_Curve.hxx>
#include <GeomAbs_CurveType.hxx>
#include <ModuleBase_ISelection.h>
+#include <ModuleBase_WidgetShapeSelector.h>
#include <ModelAPI_AttributeRefAttr.h>
#include <ModelAPI_AttributeSelection.h>
// 1. check whether the object of the attribute is not among the feature attributes
// find the attribute's object
- ObjectPtr anObject = getObject(theAttribute);
+ ObjectPtr anObject = ModuleBase_WidgetShapeSelector::getObject(theAttribute);
// check whether the object is not among other feature attributes
if (anObject.get() != NULL) {
// the function parameter attribute should be skipped
if (anAttr.get() == NULL || anAttr->id() == theAttribute->id())
continue;
- ObjectPtr aCurObject = getObject(anAttr);
+ ObjectPtr aCurObject = ModuleBase_WidgetShapeSelector::getObject(anAttr);
if (aCurObject && aCurObject == anObject)
return false;
}
return true;
}
-ObjectPtr PartSet_DifferentObjectsValidator::getObject(const AttributePtr& theAttribute) const
-{
- ObjectPtr anObject;
- std::string anAttrType = theAttribute->attributeType();
- if (anAttrType == ModelAPI_AttributeRefAttr::type()) {
- AttributeRefAttrPtr anAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theAttribute);
- if (anAttr != NULL && anAttr->isObject())
- anObject = anAttr->object();
- }
- if (anAttrType == ModelAPI_AttributeSelection::type()) {
- AttributeSelectionPtr anAttr = std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(theAttribute);
- if (anAttr != NULL && anAttr->isInitialized())
- anObject = anAttr->context();
- }
- if (anAttrType == ModelAPI_AttributeReference::type()) {
- AttributeReferencePtr anAttr = std::dynamic_pointer_cast<ModelAPI_AttributeReference>(theAttribute);
- if (anAttr.get() != NULL && anAttr->isInitialized())
- anObject = anAttr->value();
- }
- return anObject;
-}
-
bool PartSet_SketchValidator::isValid(const ObjectPtr theObject) const
{
FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);