MODEL_EXPORT virtual AttributePtr attribute(const int theIndex) const;
/// Removes the last element in the list.
- MODEL_EXPORT virtual void removeLast() = 0;
+ MODEL_EXPORT virtual void removeLast();
/// Removes the elements from the list.
/// \param theIndices a list of indices of elements to be removed
#include <Model_AttributeReference.h>
#include <Model_AttributeRefAttr.h>
#include <Model_AttributeRefList.h>
+#include <Model_AttributeRefAttrList.h>
#include <Model_AttributeBoolean.h>
#include <Model_AttributeString.h>
#include <Model_AttributeSelection.h>
anAttr = new Model_AttributeRefAttr(anAttrLab);
} else if (theAttrType == ModelAPI_AttributeRefList::typeId()) {
anAttr = new Model_AttributeRefList(anAttrLab);
+ } else if (theAttrType == ModelAPI_AttributeRefAttrList::typeId()) {
+ anAttr = new Model_AttributeRefAttrList(anAttrLab);
} else if (theAttrType == ModelAPI_AttributeIntArray::typeId()) {
anAttr = new Model_AttributeIntArray(anAttrLab);
}
GET_ATTRIBUTE_BY_ID(ModelAPI_AttributeSelectionList, selectionList);
GET_ATTRIBUTE_BY_ID(ModelAPI_AttributeRefAttr, refattr);
GET_ATTRIBUTE_BY_ID(ModelAPI_AttributeRefList, reflist);
+GET_ATTRIBUTE_BY_ID(ModelAPI_AttributeRefAttrList, refattrlist);
GET_ATTRIBUTE_BY_ID(ModelAPI_AttributeIntArray, intArray);
std::shared_ptr<ModelAPI_Attribute> Model_Data::attribute(const std::string& theID)
for(int a = aRef->size() - 1; a >= 0; a--) {
aReferenced.push_back(aRef->value(a)->context());
}
+ } else if (aType == ModelAPI_AttributeRefAttrList::typeId()) {
+ std::shared_ptr<ModelAPI_AttributeRefAttrList> aRefAttr = std::dynamic_pointer_cast<
+ ModelAPI_AttributeRefAttrList>(anAttr->second);
+ std::list<std::pair<ObjectPtr, AttributePtr> > aRefs = aRefAttr->list();
+ std::list<std::pair<ObjectPtr, AttributePtr> >::const_iterator anIt = aRefs.begin(),
+ aLast = aRefs.end();
+ for (; anIt != aLast; anIt++) {
+ aReferenced.push_back(anIt->first);
+ }
} else if (aType == ModelAPI_AttributeInteger::typeId()) { // integer attribute
AttributeIntegerPtr anAttribute =
std::dynamic_pointer_cast<ModelAPI_AttributeInteger>(anAttr->second);
#include <ModelAPI_AttributeRefAttr.h>
#include <ModelAPI_AttributeReference.h>
#include <ModelAPI_AttributeRefList.h>
+#include <ModelAPI_AttributeRefAttrList.h>
#include <ModelAPI_AttributeString.h>
#include <ModelAPI_AttributeIntArray.h>
#include <ModelAPI_Data.h>
/// Returns the attribute that contains list of references to features
MODEL_EXPORT virtual std::shared_ptr<ModelAPI_AttributeRefList>
reflist(const std::string& theID);
+ /// Returns the attribute that contains list of references to features
+ /// or reference to an attribute of a feature
+ MODEL_EXPORT virtual std::shared_ptr<ModelAPI_AttributeRefAttrList>
+ refattrlist(const std::string& theID);
/// Returns the attribute that contains boolean value
MODEL_EXPORT virtual std::shared_ptr<ModelAPI_AttributeBoolean>
boolean(const std::string& theID);
virtual void clear() = 0;
/// Returns number of features in the list
- ///\param theWithEmpty if it is false, returns the number of not-empty referenced objects
- virtual int size(const bool theWithEmpty = true) const = 0;
+ virtual int size() const = 0;
/// Returns the list of features and attributes (if it is reference to the attribute)
virtual std::list<std::pair<ObjectPtr, AttributePtr> > list() = 0;
class ModelAPI_AttributeReference;
class ModelAPI_AttributeRefAttr;
class ModelAPI_AttributeRefList;
+class ModelAPI_AttributeRefAttrList;
class ModelAPI_AttributeBoolean;
class ModelAPI_AttributeString;
class ModelAPI_Document;
virtual std::shared_ptr<ModelAPI_AttributeRefAttr> refattr(const std::string& theID) = 0;
/// Returns the attribute that contains list of references to features
virtual std::shared_ptr<ModelAPI_AttributeRefList> reflist(const std::string& theID) = 0;
+ /// Returns the attribute that contains list of references to features or reference to
+ /// an attribute of a feature
+ virtual std::shared_ptr<ModelAPI_AttributeRefAttrList> refattrlist(const std::string& theID) = 0;
/// Returns the attribute that contains boolean value
virtual std::shared_ptr<ModelAPI_AttributeBoolean> boolean(const std::string& theID) = 0;
/// Returns the attribute that contains boolean value
AttributePtr anAttribute = myFeature->data()->attribute(attributeID());
std::string aType = anAttribute->attributeType();
if (aType == ModelAPI_AttributeRefAttrList::typeId()) {
- AttributeRefAttrListPtr aRefAttrListAttr =
+ AttributeRefAttrListPtr aRefAttrListAttr =
std::dynamic_pointer_cast<ModelAPI_AttributeRefAttrList>(anAttribute);
-
bool isDone = false;
if (!thePrs.shape().IsNull()) {
GeomShapePtr aGeomShape = std::shared_ptr<GeomAPI_Shape>(new GeomAPI_Shape);
isDone = true;
}
}
- if (!isDone)
- ModuleBase_WidgetSelector::setSelectionCustom(thePrs);
+ if (!isDone) {
+ //ModuleBase_WidgetSelector::setSelectionCustom(thePrs);
+ ObjectPtr anObject;
+ GeomShapePtr aShape;
+ getGeomSelection(thePrs, anObject, aShape);
+ setObject(anObject, aShape);
+ }
}
else {
- ModuleBase_WidgetSelector::setSelectionCustom(thePrs);
- /*ObjectPtr anObject;
+ //ModuleBase_WidgetSelector::setSelectionCustom(thePrs);
+
+ ObjectPtr anObject;
GeomShapePtr aShape;
getGeomSelection(thePrs, anObject, aShape);
- setObject(anObject, aShape);*/
+ setObject(anObject, aShape);
}
return true;
}
return aValid;
}
-//********************************************************************
-bool ModuleBase_WidgetSelector::setSelectionCustom(const ModuleBase_ViewerPrs& thePrs)
-{
- ObjectPtr anObject;
- GeomShapePtr aShape;
- getGeomSelection(thePrs, anObject, aShape);
-
- setObject(anObject, aShape);
- return true;
-}
-
//********************************************************************
void ModuleBase_WidgetSelector::deactivate()
{
/// \return a boolean value
virtual bool isValidSelectionCustom(const ModuleBase_ViewerPrs& thePrs);
- /// Fills the attribute with the value of the selected owner
- /// \param thePrs a selected owner
- virtual bool setSelectionCustom(const ModuleBase_ViewerPrs& thePrs);
-
/// The methiod called when widget is deactivated
virtual void deactivate();
GeomShapePtr theShape)
{
DataPtr aData = myFeature->data();
- AttributeReferencePtr aRef = aData->reference(attributeID());
- if (aRef) {
+ std::string aType = aData->attribute(attributeID())->attributeType();
+ if (aType == ModelAPI_AttributeReference::typeId()) {
+ AttributeReferencePtr aRef = aData->reference(attributeID());
ObjectPtr aObject = aRef->value();
if (!(aObject && aObject->isSame(theSelectedObject))) {
aRef->setValue(theSelectedObject);
}
- } else {
+ } else if (aType == ModelAPI_AttributeRefAttr::typeId()) {
AttributeRefAttrPtr aRefAttr = aData->refattr(attributeID());
- if (aRefAttr) {
- ObjectPtr aObject = aRefAttr->object();
- if (!(aObject && aObject->isSame(theSelectedObject))) {
- aRefAttr->setObject(theSelectedObject);
- }
- } else {
- AttributeSelectionPtr aSelectAttr = aData->selection(attributeID());
- ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(theSelectedObject);
- if (aSelectAttr.get() != NULL) {
- aSelectAttr->setValue(aResult, theShape);
- }
+ ObjectPtr aObject = aRefAttr->object();
+ if (!(aObject && aObject->isSame(theSelectedObject))) {
+ aRefAttr->setObject(theSelectedObject);
+ }
+ } else if (aType == ModelAPI_AttributeSelection::typeId()) {
+ AttributeSelectionPtr aSelectAttr = aData->selection(attributeID());
+ ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(theSelectedObject);
+ if (aSelectAttr.get() != NULL) {
+ aSelectAttr->setValue(aResult, theShape);
}
}
}
aRefAttr->setAttr(myRefAttribute);
}
}
+
+//********************************************************************
+bool ModuleBase_WidgetShapeSelector::setSelectionCustom(const ModuleBase_ViewerPrs& thePrs)
+{
+ ObjectPtr anObject;
+ GeomShapePtr aShape;
+ getGeomSelection(thePrs, anObject, aShape);
+
+ setObject(anObject, aShape);
+ return true;
+}
/// \return a list of shapes
virtual QIntList getShapeTypes() const;
+ /// Fills the attribute with the value of the selected owner
+ /// \param thePrs a selected owner
+ virtual bool setSelectionCustom(const ModuleBase_ViewerPrs& thePrs);
+
/// Store the values to the model attribute of the widget. It casts this attribute to
/// the specific type and set the given values
/// \param theSelectedObject an object