Model_AttributeString.h
Model_AttributeInteger.h
Model_AttributeSelection.h
+ Model_AttributeSelectionList.h
Model_Events.h
Model_Update.h
Model_Validator.h
Model_AttributeString.cpp
Model_AttributeInteger.cpp
Model_AttributeSelection.cpp
+ Model_AttributeSelectionList.cpp
Model_Events.cpp
Model_Update.cpp
Model_Validator.cpp
/// Returns the context of the selection (the whole shape owner)
MODEL_EXPORT virtual ResultPtr context();
+ /// Sets the feature object
MODEL_EXPORT virtual void setObject(const boost::shared_ptr<ModelAPI_Object>& theObject);
protected:
const ResultPtr& theContext, const boost::shared_ptr<GeomAPI_Shape>& theSubShape);
friend class Model_Data;
+ friend class Model_AttributeSelectionList;
};
#endif
--- /dev/null
+// File: Model_AttributeSelectionList.h
+// Created: 22 Oct 2014
+// Author: Mikhail PONIKAROV
+
+#include "Model_AttributeSelectionList.h"
+#include "Model_AttributeSelection.h"
+#include "Model_Application.h"
+#include "Model_Events.h"
+#include "Model_Data.h"
+
+#include <TDF_ChildIterator.hxx>
+
+using namespace std;
+
+void Model_AttributeSelectionList::append(
+ const ResultPtr& theContext, const boost::shared_ptr<GeomAPI_Shape>& theSubShape)
+{
+ int aNewTag = mySize->Get() + 1;
+ TDF_Label aNewLab = mySize->Label().FindChild(aNewTag);
+ mySubs.push_back(boost::shared_ptr<Model_AttributeSelection>(
+ new Model_AttributeSelection(aNewLab)));
+ mySize->Set(aNewTag);
+}
+
+int Model_AttributeSelectionList::size()
+{
+ return mySize->Get();
+}
+
+boost::shared_ptr<ModelAPI_AttributeSelection>
+ Model_AttributeSelectionList::value(const int theIndex)
+{
+ return mySubs[theIndex];
+}
+
+void Model_AttributeSelectionList::clear()
+{
+ mySubs.clear();
+ TDF_ChildIterator aSubIter(mySize->Label());
+ for(; aSubIter.More(); aSubIter.Next()) {
+ aSubIter.Value().ForgetAllAttributes(Standard_True);
+ }
+}
+
+Model_AttributeSelectionList::Model_AttributeSelectionList(TDF_Label& theLabel)
+{
+ myIsInitialized = theLabel.FindAttribute(TDataStd_Integer::GetID(), mySize) == Standard_True;
+ if (!myIsInitialized) {
+ mySize = TDataStd_Integer::Set(theLabel, 0);
+ } else { // recollect mySubs
+ int aNum = mySize->Get();
+ TDF_ChildIterator aSubIter(theLabel);
+ for(; aSubIter.More(), aNum != 0; aSubIter.Next(), aNum--) {
+ TDF_Label aChildLab = aSubIter.Value();
+ boost::shared_ptr<Model_AttributeSelection> aNewAttr =
+ boost::shared_ptr<Model_AttributeSelection>(new Model_AttributeSelection(aChildLab));
+ if (owner())
+ aNewAttr->setObject(owner());
+ mySubs.push_back(aNewAttr);
+ }
+ }
+}
+
+void Model_AttributeSelectionList::setObject(const boost::shared_ptr<ModelAPI_Object>& theObject)
+{
+ ModelAPI_AttributeSelectionList::setObject(theObject);
+ std::vector<boost::shared_ptr<Model_AttributeSelection> >::iterator aSubIter = mySubs.begin();
+ for(; aSubIter != mySubs.end(); aSubIter++) {
+ (*aSubIter)->setObject(theObject);
+ }
+}
--- /dev/null
+// File: Model_AttributeSelectionList.h
+// Created: 22 Oct 2014
+// Author: Mikhail PONIKAROV
+
+#ifndef Model_AttributeSelectionList_H_
+#define Model_AttributeSelectionList_H_
+
+#include "Model.h"
+#include "Model_AttributeSelection.h"
+#include <ModelAPI_AttributeSelectionList.h>
+#include <TDataStd_Integer.hxx>
+#include <vector>
+
+/**\class Model_AttributeSelectionList
+ * \ingroup DataModel
+ * \brief Attribute that contains list of references to the sub-shapes with
+ * possibility to manage them.
+ */
+
+class Model_AttributeSelectionList : public ModelAPI_AttributeSelectionList
+{
+ Handle(TDataStd_Integer) mySize; ///< Contains size of this list
+ std::vector<boost::shared_ptr<Model_AttributeSelection> > mySubs; /// the selection attributes
+public:
+ /// Adds the new reference to the end of the list
+ MODEL_EXPORT virtual void append(
+ const ResultPtr& theContext, const boost::shared_ptr<GeomAPI_Shape>& theSubShape);
+
+ /// Returns the number ofselection attributes in the list
+ MODEL_EXPORT virtual int size();
+
+ /// Returns the attribute selection by the index (zero based)
+ MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_AttributeSelection> value(const int theIndex);
+
+ /// Returns all attributes
+ MODEL_EXPORT virtual void clear();
+
+ /// Sets the feature object
+ MODEL_EXPORT virtual void setObject(const boost::shared_ptr<ModelAPI_Object>& theObject);
+
+protected:
+ /// Objects are created for features automatically
+ MODEL_EXPORT Model_AttributeSelectionList(TDF_Label& theLabel);
+ /// Performs the selection for the body result (TNaming Selection)
+
+ friend class Model_Data;
+};
+
+#endif
#include <Model_AttributeBoolean.h>
#include <Model_AttributeString.h>
#include <Model_AttributeSelection.h>
+#include <Model_AttributeSelectionList.h>
#include <Model_Events.h>
#include <ModelAPI_Feature.h>
#include <ModelAPI_Result.h>
anAttr = new Model_AttributeReference(anAttrLab);
} else if (theAttrType == ModelAPI_AttributeSelection::type()) {
anAttr = new Model_AttributeSelection(anAttrLab);
+ } else if (theAttrType == ModelAPI_AttributeSelectionList::type()) {
+ anAttr = new Model_AttributeSelectionList(anAttrLab);
} else if (theAttrType == ModelAPI_AttributeRefAttr::type()) {
anAttr = new Model_AttributeRefAttr(anAttrLab);
} else if (theAttrType == ModelAPI_AttributeRefList::type()) {
boost::shared_ptr<ModelAPI_AttributeDocRef> Model_Data::document(const std::string& theID)
{
- std::map<std::string, boost::shared_ptr<ModelAPI_Attribute> >::iterator aFound = myAttrs.find(theID);
+ std::map<std::string, boost::shared_ptr<ModelAPI_Attribute> >::iterator aFound =
+ myAttrs.find(theID);
if (aFound == myAttrs.end()) {
// TODO: generate error on unknown attribute request and/or add mechanism for customization
return boost::shared_ptr<ModelAPI_AttributeDocRef>();
boost::shared_ptr<ModelAPI_AttributeDouble> Model_Data::real(const std::string& theID)
{
- std::map<std::string, boost::shared_ptr<ModelAPI_Attribute> >::iterator aFound = myAttrs.find(theID);
+ std::map<std::string, boost::shared_ptr<ModelAPI_Attribute> >::iterator aFound =
+ myAttrs.find(theID);
if (aFound == myAttrs.end()) {
// TODO: generate error on unknown attribute request and/or add mechanism for customization
return boost::shared_ptr<ModelAPI_AttributeDouble>();
boost::shared_ptr<ModelAPI_AttributeInteger> Model_Data::integer(const std::string& theID)
{
- std::map<std::string, boost::shared_ptr<ModelAPI_Attribute> >::iterator aFound = myAttrs.find(theID);
+ std::map<std::string, boost::shared_ptr<ModelAPI_Attribute> >::iterator aFound =
+ myAttrs.find(theID);
if (aFound == myAttrs.end()) {
// TODO: generate error on unknown attribute request and/or add mechanism for customization
return boost::shared_ptr<ModelAPI_AttributeInteger>();
boost::shared_ptr<ModelAPI_AttributeBoolean> Model_Data::boolean(const std::string& theID)
{
- std::map<std::string, boost::shared_ptr<ModelAPI_Attribute> >::iterator aFound = myAttrs.find(theID);
+ std::map<std::string, boost::shared_ptr<ModelAPI_Attribute> >::iterator aFound =
+ myAttrs.find(theID);
if (aFound == myAttrs.end()) {
// TODO: generate error on unknown attribute request and/or add mechanism for customization
return boost::shared_ptr<ModelAPI_AttributeBoolean>();
boost::shared_ptr<ModelAPI_AttributeString> Model_Data::string(const std::string& theID)
{
- std::map<std::string, boost::shared_ptr<ModelAPI_Attribute> >::iterator aFound = myAttrs.find(theID);
+ std::map<std::string, boost::shared_ptr<ModelAPI_Attribute> >::iterator aFound =
+ myAttrs.find(theID);
if (aFound == myAttrs.end()) {
// TODO: generate error on unknown attribute request and/or add mechanism for customization
return boost::shared_ptr<ModelAPI_AttributeString>();
boost::shared_ptr<ModelAPI_AttributeReference> Model_Data::reference(const std::string& theID)
{
- std::map<std::string, boost::shared_ptr<ModelAPI_Attribute> >::iterator aFound = myAttrs.find(theID);
+ std::map<std::string, boost::shared_ptr<ModelAPI_Attribute> >::iterator aFound =
+ myAttrs.find(theID);
if (aFound == myAttrs.end()) {
// TODO: generate error on unknown attribute request and/or add mechanism for customization
return boost::shared_ptr<ModelAPI_AttributeReference>();
boost::shared_ptr<ModelAPI_AttributeSelection> Model_Data::selection(const std::string& theID)
{
- std::map<std::string, boost::shared_ptr<ModelAPI_Attribute> >::iterator aFound = myAttrs.find(theID);
+ std::map<std::string, boost::shared_ptr<ModelAPI_Attribute> >::iterator aFound =
+ myAttrs.find(theID);
if (aFound == myAttrs.end()) {
// TODO: generate error on unknown attribute request and/or add mechanism for customization
return boost::shared_ptr<ModelAPI_AttributeSelection>();
return aRes;
}
+boost::shared_ptr<ModelAPI_AttributeSelectionList>
+ Model_Data::selectionList(const std::string& theID)
+{
+ std::map<std::string, boost::shared_ptr<ModelAPI_Attribute> >::iterator aFound =
+ myAttrs.find(theID);
+ if (aFound == myAttrs.end()) {
+ // TODO: generate error on unknown attribute request and/or add mechanism for customization
+ return boost::shared_ptr<ModelAPI_AttributeSelectionList>();
+ }
+ boost::shared_ptr<ModelAPI_AttributeSelectionList> aRes =
+ boost::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(aFound->second);
+ if (!aRes) {
+ // TODO: generate error on invalid attribute type request
+ }
+ return aRes;
+}
+
boost::shared_ptr<ModelAPI_AttributeRefAttr> Model_Data::refattr(const std::string& theID)
{
- std::map<std::string, boost::shared_ptr<ModelAPI_Attribute> >::iterator aFound = myAttrs.find(theID);
+ std::map<std::string, boost::shared_ptr<ModelAPI_Attribute> >::iterator aFound =
+ myAttrs.find(theID);
if (aFound == myAttrs.end()) {
// TODO: generate error on unknown attribute request and/or add mechanism for customization
return boost::shared_ptr<ModelAPI_AttributeRefAttr>();
boost::shared_ptr<ModelAPI_AttributeRefList> Model_Data::reflist(const std::string& theID)
{
- std::map<std::string, boost::shared_ptr<ModelAPI_Attribute> >::iterator aFound = myAttrs.find(theID);
+ std::map<std::string, boost::shared_ptr<ModelAPI_Attribute> >::iterator aFound =
+ myAttrs.find(theID);
if (aFound == myAttrs.end()) {
// TODO: generate error on unknown attribute request and/or add mechanism for customization
return boost::shared_ptr<ModelAPI_AttributeRefList>();
const std::string& Model_Data::id(const boost::shared_ptr<ModelAPI_Attribute>& theAttr)
{
- std::map<std::string, boost::shared_ptr<ModelAPI_Attribute> >::iterator anAttr = myAttrs.begin();
+ std::map<std::string, boost::shared_ptr<ModelAPI_Attribute> >::iterator anAttr =
+ myAttrs.begin();
for (; anAttr != myAttrs.end(); anAttr++) {
if (anAttr->second == theAttr)
return anAttr->first;
/// Returns the attribute that contains selection to a shape
MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_AttributeSelection>
selection(const std::string& theID);
+ /// Returns the attribute that contains selection to a shape
+ MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_AttributeSelectionList>
+ selectionList(const std::string& theID);
/// Returns the attribute that contains reference to an attribute of a feature
MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_AttributeRefAttr>
refattr(const std::string& theID);
ModelAPI_AttributeBoolean.h
ModelAPI_AttributeString.h
ModelAPI_AttributeSelection.h
+ ModelAPI_AttributeSelectionList.h
ModelAPI_Events.h
ModelAPI_Validator.h
ModelAPI_FeatureValidator.h
#include "ModelAPI_AttributeReference.h"
#include "ModelAPI_AttributeRefAttr.h"
#include "ModelAPI_AttributeSelection.h"
+ #include "ModelAPI_AttributeSelectionList.h"
#include "ModelAPI_Validator.h"
#include "ModelAPI_AttributeRefList.h"
#include "ModelAPI_AttributeBoolean.h"
%shared_ptr(ModelAPI_AttributeRefList)
%shared_ptr(ModelAPI_AttributeBoolean)
%shared_ptr(ModelAPI_AttributeSelection)
+%shared_ptr(ModelAPI_AttributeSelectionList)
%shared_ptr(ModelAPI_Result)
%shared_ptr(ModelAPI_ResultConstruction)
%shared_ptr(ModelAPI_ResultBody)
%include "ModelAPI_AttributeRefAttr.h"
%include "ModelAPI_AttributeBoolean.h"
%include "ModelAPI_AttributeSelection.h"
+%include "ModelAPI_AttributeSelectionList.h"
%include "ModelAPI_AttributeRefList.h"
%include "ModelAPI_Validator.h"
%include "ModelAPI_Result.h"
--- /dev/null
+// File: ModelAPI_AttributeSelectionList.h
+// Created: 22 Oct 2014
+// Author: Mikhail PONIKAROV
+
+#ifndef ModelAPI_AttributeSelectionList_H_
+#define ModelAPI_AttributeSelectionList_H_
+
+#include "ModelAPI_AttributeSelection.h"
+#include <ModelAPI_Result.h>
+
+/**\class ModelAPI_AttributeSelectionList
+ * \ingroup DataModel
+ * \brief Attribute that contains list of references to the sub-shapes with
+ * possibility to manage them.
+ */
+
+class ModelAPI_AttributeSelectionList : public ModelAPI_Attribute
+{
+ public:
+ /// Adds the new reference to the end of the list
+ virtual void append(
+ const ResultPtr& theContext, const boost::shared_ptr<GeomAPI_Shape>& theSubShape) = 0;
+
+ /// Returns the number ofselection attributes in the list
+ virtual int size() = 0;
+
+ /// Returns the attribute selection by the index (zero based)
+ virtual boost::shared_ptr<ModelAPI_AttributeSelection> value(const int theIndex) = 0;
+
+ /// Returns all attributes
+ virtual void clear() = 0;
+
+ /// Returns the type of this class of attributes
+ static std::string type()
+ {
+ return "SelectionList";
+ }
+
+ /// Returns the type of this class of attributes, not static method
+ virtual std::string attributeType()
+ {
+ return type();
+ }
+
+ /// To virtually destroy the fields of successors
+ virtual ~ModelAPI_AttributeSelectionList()
+ {
+ }
+
+ protected:
+ /// Objects are created for features automatically
+ MODELAPI_EXPORT ModelAPI_AttributeSelectionList()
+ {
+ }
+};
+
+#endif
class ModelAPI_Attribute;
class ModelAPI_Feature;
class ModelAPI_AttributeSelection;
+class ModelAPI_AttributeSelectionList;
class GeomAPI_Shape;
/**\class ModelAPI_Data
virtual boost::shared_ptr<ModelAPI_AttributeReference> reference(const std::string& theID) = 0;
/// Returns the attribute that contains selection to a shape
virtual boost::shared_ptr<ModelAPI_AttributeSelection> selection(const std::string& theID) = 0;
+ /// Returns the attribute that contains selection to a shape
+ virtual boost::shared_ptr<ModelAPI_AttributeSelectionList>
+ selectionList(const std::string& theID) = 0;
/// Returns the attribute that contains reference to an attribute of a feature
virtual boost::shared_ptr<ModelAPI_AttributeRefAttr> refattr(const std::string& theID) = 0;
/// Returns the attribute that contains list of references to features
#include <ModelAPI_AttributeRefList.h>
#include <ModelAPI_AttributeBoolean.h>
#include <ModelAPI_AttributeSelection.h>
+#include <ModelAPI_AttributeSelectionList.h>
#include <ModelAPI_Events.h>
#include <ModelAPI_Validator.h>