* Example of the feature entry:\r
* <feature id="Part" text="New part" tooltip="Creates a new part" icon=":pictures/part_ico.png"/>\r
*/\r
-class CONFIG_EXPORT Config_FeatureMessage: public Event_Message\r
+class Config_FeatureMessage: public Event_Message\r
{\r
std::string myId; //Feature unique id\r
std::string myText; //Represents action's text\r
\r
public:\r
//const Event_ID theID, const void* theSender = 0\r
- Config_FeatureMessage(const Event_ID theId, const void* theParent = 0);\r
+ CONFIG_EXPORT Config_FeatureMessage(const Event_ID theId, const void* theParent = 0);\r
\r
//TODO(sbh): Implement static method to extract event id [SEID]\r
//static const char* eventId() { return ""; }\r
\r
//Auto-generated getters/setters\r
- const std::string& icon() const;\r
- const std::string& id() const;\r
- const std::string& keysequence() const;\r
- const std::string& text() const;\r
- const std::string& tooltip() const;\r
-\r
- const std::string& groupId() const;\r
- const std::string& workbenchId() const;\r
- const std::string& pluginLibrary() const;\r
-\r
- void setIcon(const std::string& icon);\r
- void setId(const std::string& id);\r
- void setKeysequence(const std::string& keysequence);\r
- void setText(const std::string& text);\r
- void setTooltip(const std::string& tooltip);\r
-\r
- void setGroupId(const std::string& groupId);\r
- void setWorkbenchId(const std::string& workbenchId);\r
- void setPluginLibrary(const std::string& thePluginLibrary);\r
+ CONFIG_EXPORT const std::string& icon() const;\r
+ CONFIG_EXPORT const std::string& id() const;\r
+ CONFIG_EXPORT const std::string& keysequence() const;\r
+ CONFIG_EXPORT const std::string& text() const;\r
+ CONFIG_EXPORT const std::string& tooltip() const;\r
+\r
+ CONFIG_EXPORT const std::string& groupId() const;\r
+ CONFIG_EXPORT const std::string& workbenchId() const;\r
+ CONFIG_EXPORT const std::string& pluginLibrary() const;\r
+\r
+ CONFIG_EXPORT void setIcon(const std::string& icon);\r
+ CONFIG_EXPORT void setId(const std::string& id);\r
+ CONFIG_EXPORT void setKeysequence(const std::string& keysequence);\r
+ CONFIG_EXPORT void setText(const std::string& text);\r
+ CONFIG_EXPORT void setTooltip(const std::string& tooltip);\r
+\r
+ CONFIG_EXPORT void setGroupId(const std::string& groupId);\r
+ CONFIG_EXPORT void setWorkbenchId(const std::string& workbenchId);\r
+ CONFIG_EXPORT void setPluginLibrary(const std::string& thePluginLibrary);\r
};\r
\r
#endif // CONFIG_MESSAGE_H
class Config_FeatureMessage;
-class CONFIG_EXPORT Config_FeatureReader: public Config_XMLReader
+class Config_FeatureReader: public Config_XMLReader
{
public:
Config_FeatureReader(const std::string& theXmlFile,
#include <string>
-class CONFIG_EXPORT Config_ModuleReader: public Config_XMLReader
+class Config_ModuleReader: public Config_XMLReader
{
public:
- Config_ModuleReader();
- virtual ~Config_ModuleReader();
+ CONFIG_EXPORT Config_ModuleReader();
+ CONFIG_EXPORT virtual ~Config_ModuleReader();
- void setAutoImport(bool enabled);
- const std::map<std::string, std::string>& plugins() const;
+ CONFIG_EXPORT void setAutoImport(bool enabled);
+ CONFIG_EXPORT const std::map<std::string, std::string>& plugins() const;
- std::string getModuleName();
+ CONFIG_EXPORT std::string getModuleName();
protected:
void processNode(xmlNodePtr aNode);
#include <string>
-class CONFIG_EXPORT Config_WidgetReader: public Config_XMLReader
+class Config_WidgetReader: public Config_XMLReader
{
public:
- Config_WidgetReader(const std::string& theXmlFile);
- virtual ~Config_WidgetReader();
+ CONFIG_EXPORT Config_WidgetReader(const std::string& theXmlFile);
+ CONFIG_EXPORT virtual ~Config_WidgetReader();
- std::string featureWidgetCfg(std::string theFeatureName);
+ CONFIG_EXPORT std::string featureWidgetCfg(std::string theFeatureName);
protected:
void processNode(xmlNodePtr theNode);
* for all xml operations.
*
*/
-class CONFIG_EXPORT Config_XMLReader
+class Config_XMLReader
{
public:
- Config_XMLReader(const std::string& theXmlFile);
- virtual ~Config_XMLReader();
+ CONFIG_EXPORT Config_XMLReader(const std::string& theXmlFile);
+ CONFIG_EXPORT virtual ~Config_XMLReader();
- void readAll();
+ CONFIG_EXPORT void readAll();
protected:
virtual void processNode(xmlNodePtr aNode);
Model_Application.h
Model_Document.h
Model_PluginManager.h
- Model_Object.h
+ Model_Data.h
Model_Iterator.h
Model_AttributeDouble.h
Model_AttributeDocRef.h
+ Model_Events.h
)
SET(PROJECT_SOURCES
Model_Application.cxx
Model_Document.cxx
Model_PluginManager.cxx
- Model_Object.cxx
+ Model_Data.cxx
Model_Iterator.cxx
Model_AttributeDouble.cxx
Model_AttributeDocRef.cxx
+ Model_Events.cxx
)
ADD_DEFINITIONS(-DMODEL_EXPORTS ${CAS_DEFINITIONS})
//function : getDocument
//purpose :
//=======================================================================
-std::shared_ptr<Model_Document> Model_Application::getDocument(string theDocID)
+const std::shared_ptr<Model_Document>& Model_Application::getDocument(string theDocID)
{
if (myDocs.find(theDocID) != myDocs.end())
return myDocs[theDocID];
std::shared_ptr<Model_Document> aNew(new Model_Document(theDocID));
myDocs[theDocID] = aNew;
- return aNew;
+ return myDocs[theDocID];
}
void Model_Application::deleteDocument(string theDocID)
//! Retuns the application: one per process
MODEL_EXPORT static Handle_Model_Application getApplication();
//! Returns the main document (on first call creates it) by the string identifier
- MODEL_EXPORT std::shared_ptr<Model_Document> getDocument(std::string theDocID);
+ MODEL_EXPORT const std::shared_ptr<Model_Document>& getDocument(std::string theDocID);
//! Deletes the document from the application
MODEL_EXPORT void deleteDocument(std::string theDocID);
* \brief Attribute that contains reference to another document.
*/
-class MODEL_EXPORT Model_AttributeDocRef : public ModelAPI_AttributeDocRef
+class Model_AttributeDocRef : public ModelAPI_AttributeDocRef
{
Handle_TDataStd_Comment myComment; ///< reference to document is identified as string-id
public:
/// Defines the document referenced from this attribute
- virtual void setValue(std::shared_ptr<ModelAPI_Document> theDoc);
+ MODEL_EXPORT virtual void setValue(std::shared_ptr<ModelAPI_Document> theDoc);
/// Returns document referenced from this attribute
- virtual std::shared_ptr<ModelAPI_Document> value();
+ MODEL_EXPORT virtual std::shared_ptr<ModelAPI_Document> value();
protected:
/// Initializes attibutes
Model_AttributeDocRef(TDF_Label& theLabel);
- friend class Model_Object;
+ friend class Model_Data;
};
#endif
* \brief Attribute that contains real value with double precision.
*/
-class MODEL_EXPORT Model_AttributeDouble : public ModelAPI_AttributeDouble
+class Model_AttributeDouble : public ModelAPI_AttributeDouble
{
Handle_TDataStd_Real myReal; ///< double is Real attribute
public:
/// Defines the double value
- virtual void setValue(const double theValue);
+ MODEL_EXPORT virtual void setValue(const double theValue);
/// Returns the double value
- virtual double value();
+ MODEL_EXPORT virtual double value();
protected:
/// Initializes attibutes
Model_AttributeDouble(TDF_Label& theLabel);
- friend class Model_Object;
+ friend class Model_Data;
};
#endif
--- /dev/null
+// File: Model_Data.hxx
+// Created: 21 Mar 2014
+// Author: Mikhail PONIKAROV
+
+#include <Model_Data.h>
+#include <Model_AttributeDocRef.h>
+#include <Model_AttributeDouble.h>
+#include <TDataStd_Name.hxx>
+
+using namespace std;
+
+Model_Data::Model_Data()
+{
+}
+
+void Model_Data::setLabel(TDF_Label& theLab)
+{
+ myLab = theLab;
+}
+
+string Model_Data::getName()
+{
+ Handle(TDataStd_Name) aName;
+ if (myLab.FindAttribute(TDataStd_Name::GetID(), aName))
+ return string(TCollection_AsciiString(aName->Get()).ToCString());
+ return ""; // not defined
+}
+
+void Model_Data::setName(string theName)
+{
+ TDataStd_Name::Set(myLab, theName.c_str());
+}
+
+void Model_Data::addAttribute(string theID, string theAttrType)
+{
+ TDF_Label anAttrLab = myLab.FindChild(myAttrs.size() + 1);
+ ModelAPI_Attribute* anAttr = 0;
+ if (theAttrType == ModelAPI_AttributeDocRef::type())
+ anAttr = new Model_AttributeDocRef(anAttrLab);
+ else if (theAttrType == ModelAPI_AttributeDouble::type())
+ anAttr = new Model_AttributeDouble(anAttrLab);
+
+ if (anAttr)
+ myAttrs[theID] = std::shared_ptr<ModelAPI_Attribute>(anAttr);
+ else
+ ; // TODO: generate error on unknown attribute request and/or add mechanism for customization
+}
+
+shared_ptr<ModelAPI_AttributeDocRef> Model_Data::docRef(const string theID)
+{
+ map<string, 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 std::shared_ptr<ModelAPI_AttributeDocRef>();
+ }
+ shared_ptr<ModelAPI_AttributeDocRef> aRes =
+ dynamic_pointer_cast<ModelAPI_AttributeDocRef>(aFound->second);
+ if (!aRes) {
+ // TODO: generate error on invalid attribute type request
+ }
+ return aRes;
+}
+
+shared_ptr<ModelAPI_AttributeDouble> Model_Data::real(const string theID)
+{
+ map<string, 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 std::shared_ptr<ModelAPI_AttributeDouble>();
+ }
+ shared_ptr<ModelAPI_AttributeDouble> aRes =
+ dynamic_pointer_cast<ModelAPI_AttributeDouble>(aFound->second);
+ if (!aRes) {
+ // TODO: generate error on invalid attribute type request
+ }
+ return aRes;
+}
--- /dev/null
+// File: Model_Data.hxx
+// Created: 21 Mar 2014
+// Author: Mikhail PONIKAROV
+
+#ifndef Model_Data_HeaderFile
+#define Model_Data_HeaderFile
+
+#include "Model.h"
+#include <ModelAPI_Object.h>
+#include <TDF_Label.hxx>
+
+#include <map>
+
+class ModelAPI_Attribute;
+
+/**\class Model_Data
+ * \ingroup DataModel
+ * \brief General object of the application that allows
+ * to get/set attributes from the document and compute result of an operation.
+ */
+
+class Model_Data: public ModelAPI_Object
+{
+ TDF_Label myLab; ///< label of the feature in the document
+ /// All attributes of the object identified by the attribute ID
+ std::map<std::string, std::shared_ptr<ModelAPI_Attribute> > myAttrs;
+
+ std::shared_ptr<ModelAPI_Document> myDoc; ///< document this feature belongs to
+
+ Model_Data();
+
+ TDF_Label label() {return myLab;}
+
+ friend class Model_Document;
+ friend class Model_Iterator;
+
+public:
+ /// Returns the name of the feature visible by the user in the object browser
+ MODEL_EXPORT virtual std::string getName();
+ /// Defines the name of the feature visible by the user in the object browser
+ MODEL_EXPORT virtual void setName(std::string theName);
+ /// Returns the attribute that references to another document
+ MODEL_EXPORT virtual std::shared_ptr<ModelAPI_AttributeDocRef> docRef(const std::string theID);
+ /// Returns the attribute that contains real value with double precision
+ MODEL_EXPORT virtual std::shared_ptr<ModelAPI_AttributeDouble> real(const std::string theID);
+
+ /// Initializes object by the attributes: must be called just after the object is created
+ /// for each attribute of the object
+ /// \param theID identifier of the attribute that can be referenced by this ID later
+ /// \param theAttrType type of the created attribute (received from the type method)
+ MODEL_EXPORT virtual void addAttribute(std::string theID, std::string theAttrType);
+
+ /// Returns the document of this data
+ MODEL_EXPORT virtual std::shared_ptr<ModelAPI_Document> document() {return myDoc;}
+
+ /// Puts feature to the document data sub-structure
+ MODEL_EXPORT void setLabel(TDF_Label& theLab);
+
+ /// Sets the document of this data
+ MODEL_EXPORT virtual void setDocument(const std::shared_ptr<ModelAPI_Document>& theDoc) {myDoc = theDoc;}
+};
+
+#endif
#include <Model_Document.h>
#include <ModelAPI_Feature.h>
-#include <Model_Object.h>
+#include <Model_Data.h>
#include <Model_Application.h>
#include <Model_PluginManager.h>
#include <Model_Iterator.h>
+#include <Model_Events.h>
#include <Event_Loop.h>
#include <TDataStd_Integer.hxx>
static const int UNDO_LIMIT = 10; // number of possible undo operations
static const int TAG_GENERAL = 1; // general properties tag
-static const int TAG_OBJECTS = 2; // tag of the objects sub-tree (Root for Model_ObjectsMgr)
+static const int TAG_OBJECTS = 2; // tag of the objects sub-tree (Root for Model_DatasMgr)
static const int TAG_HISTORY = 3; // tag of the history sub-tree (Root for Model_History)
using namespace std;
const std::string& aGroup = theFeature->getGroup();
TDF_Label aGroupLab = groupLabel(aGroup);
TDF_Label anObjLab = aGroupLab.NewChild();
- std::shared_ptr<Model_Object> aData(new Model_Object);
+ std::shared_ptr<Model_Data> aData(new Model_Data);
aData->setLabel(anObjLab);
aData->setDocument(Model_Application::getApplication()->getDocument(myID));
theFeature->setData(aData);
TDataStd_Integer::Set(anObjLab, myFeatures[aGroup].size());
myFeatures[aGroup].push_back(theFeature);
- // event: model is updated
- static Event_ID anEvent = Event_Loop::eventByName(EVENT_FEATURE_UPDATED);
- ModelAPI_FeatureUpdatedMessage aMsg(theFeature);
+ // event: feature is added
+ static Event_ID anEvent = Event_Loop::eventByName(EVENT_FEATURE_CREATED);
+ ModelAPI_FeatureUpdatedMessage aMsg(theFeature, anEvent);
Event_Loop::loop()->send(aMsg);
}
if (theFeature->data()->document().get() != this) {
return theFeature->data()->document()->featureIndex(theFeature);
}
- shared_ptr<Model_Object> aData = dynamic_pointer_cast<Model_Object>(theFeature->data());
+ shared_ptr<Model_Data> aData = dynamic_pointer_cast<Model_Data>(theFeature->data());
Handle(TDataStd_Integer) aFeatureIndex;
if (aData->label().FindAttribute(TDataStd_Integer::GetID(), aFeatureIndex)) {
return aFeatureIndex->Get();
static const int INFINITE_TAG = MAXINT; // no label means that it exists somwhere in infinite
int aFeatureTag = INFINITE_TAG;
if (aFIter != aFeatures.end()) { // existing tag for feature
- shared_ptr<Model_Object> aData = dynamic_pointer_cast<Model_Object>((*aFIter)->data());
+ shared_ptr<Model_Data> aData = dynamic_pointer_cast<Model_Data>((*aFIter)->data());
aFeatureTag = aData->label().Tag();
}
int aDSTag = INFINITE_TAG;
}
if (aDSTag > aFeatureTag) { // feature is removed
aFIter = aFeatures.erase(aFIter);
+ // event: model is updated
+ ModelAPI_FeatureDeletedMessage aMsg(
+ Model_Application::getApplication()->getDocument(myID), aGroupName);
+ Event_Loop::loop()->send(aMsg);
} else if (aDSTag < aFeatureTag) { // a new feature is inserted
// create a feature
shared_ptr<ModelAPI_Feature> aFeature = ModelAPI_PluginManager::get()->createFeature(
TCollection_AsciiString(Handle(TDataStd_Comment)::DownCast(
aFLabIter.Value())->Get()).ToCString());
- std::shared_ptr<Model_Object> aData(new Model_Object);
+ std::shared_ptr<Model_Data> aData(new Model_Data);
TDF_Label aLab = aFLabIter.Value()->Label();
aData->setLabel(aLab);
aData->setDocument(Model_Application::getApplication()->getDocument(myID));
aFeature->setData(aData);
aFeature->initAttributes();
// event: model is updated
- static Event_ID anEvent = Event_Loop::eventByName(EVENT_FEATURE_UPDATED);
- ModelAPI_FeatureUpdatedMessage aMsg(aFeature);
+ static Event_ID anEvent = Event_Loop::eventByName(EVENT_FEATURE_CREATED);
+ ModelAPI_FeatureUpdatedMessage aMsg(aFeature, anEvent);
Event_Loop::loop()->send(aMsg);
if (aFIter == aFeatures.end()) {
}
}
}
-
-ModelAPI_FeatureUpdatedMessage::ModelAPI_FeatureUpdatedMessage(
- shared_ptr<ModelAPI_Feature> theFeature)
- : Event_Message(messageId(), 0), myFeature(theFeature)
-{}
-
-const Event_ID ModelAPI_FeatureUpdatedMessage::messageId()
-{
- static Event_ID MY_ID = Event_Loop::eventByName("FeatureUpdated");
- return MY_ID;
-}
-
-shared_ptr<ModelAPI_Feature> ModelAPI_FeatureUpdatedMessage::feature()
-{
- return myFeature;
-}
#include <Model.h>
#include <ModelAPI_Document.h>
-#include <Event_Message.h>
#include <TDocStd_Document.hxx>
#include <map>
std::map<int, bool> myIsEmptyTr;
};
-/// Event ID that model is updated
-static const char * EVENT_FEATURE_UPDATED = "FeatureUpdated";
-
-/// Message that feature was changed (used for Object Browser update)
-class ModelAPI_FeatureUpdatedMessage : public Event_Message {
- std::shared_ptr<ModelAPI_Feature> myFeature; ///< which feature is changed
-public:
- /// sender is not important, all information is located in the feature
- ModelAPI_FeatureUpdatedMessage(std::shared_ptr<ModelAPI_Feature> theFeature);
-
- /// Returns the ID of this message
- static const Event_ID messageId();
-
- /// Returns the feature that has been updated
- std::shared_ptr<ModelAPI_Feature> feature();
-};
-
#endif
--- /dev/null
+// File: Model_Events.cxx
+// Created: 10 Apr 2014
+// Author: Mikhail PONIKAROV
+
+#include <Model_Events.h>
+#include <Event_Loop.h>
+
+ModelAPI_FeatureUpdatedMessage::ModelAPI_FeatureUpdatedMessage(
+ const std::shared_ptr<ModelAPI_Feature>& theFeature, const Event_ID& theEvent)
+ : Event_Message(theEvent, 0), myFeature(theFeature)
+{}
+
+ModelAPI_FeatureDeletedMessage::ModelAPI_FeatureDeletedMessage(
+ const std::shared_ptr<ModelAPI_Document>& theDoc, const std::string& theGroup)
+ : Event_Message(messageId(), 0), myDoc(theDoc), myGroup(theGroup)
+
+{
+}
+
+const Event_ID ModelAPI_FeatureDeletedMessage::messageId()
+{
+ static Event_ID MY_ID = Event_Loop::eventByName(EVENT_FEATURE_DELETED);
+ return MY_ID;
+}
--- /dev/null
+// File: Model_Events.h
+// Created: 10 Apr 2014
+// Author: Mikhail PONIKAROV
+
+#ifndef Model_Events_HeaderFile
+#define Model_Events_HeaderFile
+
+#include <Model.h>
+#include <Event_Message.h>
+#include <memory>
+#include <string>
+
+class ModelAPI_Feature;
+class ModelAPI_Document;
+
+/// Event ID that feature is created (comes with ModelAPI_FeatureUpdatedMessage)
+static const char * EVENT_FEATURE_CREATED = "FeatureCreated";
+/// Event ID that data of feature is updated (comes with ModelAPI_FeatureUpdatedMessage)
+static const char * EVENT_FEATURE_UPDATED = "FeatureUpdated";
+/// Event ID that data of feature is deleted (comes with ModelAPI_FeatureDeletedMessage)
+static const char * EVENT_FEATURE_DELETED = "FeatureDeleted";
+
+/// Message that feature was changed (used for Object Browser update)
+class ModelAPI_FeatureUpdatedMessage : public Event_Message {
+ std::shared_ptr<ModelAPI_Feature> myFeature; ///< which feature is changed
+public:
+ /// sender is not important, all information is located in the feature
+ ModelAPI_FeatureUpdatedMessage(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+ const Event_ID& theEvent);
+
+ /// Returns the feature that has been updated
+ std::shared_ptr<ModelAPI_Feature> feature() {return myFeature;}
+};
+
+/// Message that feature was deleted (used for Object Browser update)
+class ModelAPI_FeatureDeletedMessage : public Event_Message {
+ std::shared_ptr<ModelAPI_Document> myDoc; ///< document owner of the feature
+ std::string myGroup; ///< group identifier that contained the deleted feature
+public:
+ /// creates a message by initialization of fields
+ ModelAPI_FeatureDeletedMessage(const std::shared_ptr<ModelAPI_Document>& theDoc,
+ const std::string& theGroup);
+
+ /// Returns the ID of this message (EVENT_FEATURE_DELETED)
+ static const Event_ID messageId();
+
+ /// Returns the feature that has been updated
+ std::shared_ptr<ModelAPI_Document> document() {return myDoc;}
+
+ /// Returns the group where the feature was deleted
+ const std::string& group() {return myGroup;}
+};
+
+#endif
#include "Model_Iterator.h"
#include "Model_Document.h"
#include "ModelAPI_Feature.h"
-#include "Model_Object.h"
+#include "Model_Data.h"
#include <TDataStd_Comment.hxx>
#include <TDataStd_Name.hxx>
bool Model_Iterator::is(std::shared_ptr<ModelAPI_Feature> theFeature)
{
return (myIter.Value()->Label() ==
- dynamic_pointer_cast<Model_Object>(theFeature->data())->label()) == Standard_True;
+ dynamic_pointer_cast<Model_Data>(theFeature->data())->label()) == Standard_True;
}
+++ /dev/null
-// File: Model_Object.hxx
-// Created: 21 Mar 2014
-// Author: Mikhail PONIKAROV
-
-#include <Model_Object.h>
-#include <Model_AttributeDocRef.h>
-#include <Model_AttributeDouble.h>
-#include <TDataStd_Name.hxx>
-
-using namespace std;
-
-Model_Object::Model_Object()
-{
-}
-
-void Model_Object::setLabel(TDF_Label& theLab)
-{
- myLab = theLab;
-}
-
-string Model_Object::getName()
-{
- Handle(TDataStd_Name) aName;
- if (myLab.FindAttribute(TDataStd_Name::GetID(), aName))
- return string(TCollection_AsciiString(aName->Get()).ToCString());
- return ""; // not defined
-}
-
-void Model_Object::setName(string theName)
-{
- TDataStd_Name::Set(myLab, theName.c_str());
-}
-
-void Model_Object::addAttribute(string theID, string theAttrType)
-{
- TDF_Label anAttrLab = myLab.FindChild(myAttrs.size() + 1);
- ModelAPI_Attribute* anAttr = 0;
- if (theAttrType == ModelAPI_AttributeDocRef::type())
- anAttr = new Model_AttributeDocRef(anAttrLab);
- else if (theAttrType == ModelAPI_AttributeDouble::type())
- anAttr = new Model_AttributeDouble(anAttrLab);
-
- if (anAttr)
- myAttrs[theID] = std::shared_ptr<ModelAPI_Attribute>(anAttr);
- else
- ; // TODO: generate error on unknown attribute request and/or add mechanism for customization
-}
-
-shared_ptr<ModelAPI_AttributeDocRef> Model_Object::docRef(const string theID)
-{
- map<string, 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 std::shared_ptr<ModelAPI_AttributeDocRef>();
- }
- shared_ptr<ModelAPI_AttributeDocRef> aRes =
- dynamic_pointer_cast<ModelAPI_AttributeDocRef>(aFound->second);
- if (!aRes) {
- // TODO: generate error on invalid attribute type request
- }
- return aRes;
-}
-
-shared_ptr<ModelAPI_AttributeDouble> Model_Object::real(const string theID)
-{
- map<string, 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 std::shared_ptr<ModelAPI_AttributeDouble>();
- }
- shared_ptr<ModelAPI_AttributeDouble> aRes =
- dynamic_pointer_cast<ModelAPI_AttributeDouble>(aFound->second);
- if (!aRes) {
- // TODO: generate error on invalid attribute type request
- }
- return aRes;
-}
+++ /dev/null
-// File: Model_Object.hxx
-// Created: 21 Mar 2014
-// Author: Mikhail PONIKAROV
-
-#ifndef Model_Object_HeaderFile
-#define Model_Object_HeaderFile
-
-#include "Model.h"
-#include <ModelAPI_Object.h>
-#include <TDF_Label.hxx>
-
-#include <map>
-
-class ModelAPI_Attribute;
-
-/**\class Model_Object
- * \ingroup DataModel
- * \brief General object of the application that allows
- * to get/set attributes from the document and compute result of an operation.
- */
-
-class Model_Object: public ModelAPI_Object
-{
- TDF_Label myLab; ///< label of the feature in the document
- /// All attributes of the object identified by the attribute ID
- std::map<std::string, std::shared_ptr<ModelAPI_Attribute> > myAttrs;
-
- std::shared_ptr<ModelAPI_Document> myDoc; ///< document this feature belongs to
-
- Model_Object();
-
- TDF_Label label() {return myLab;}
-
- friend class Model_Document;
- friend class Model_Iterator;
-
-public:
- /// Returns the name of the feature visible by the user in the object browser
- MODEL_EXPORT virtual std::string getName();
- /// Defines the name of the feature visible by the user in the object browser
- MODEL_EXPORT virtual void setName(std::string theName);
- /// Returns the attribute that references to another document
- MODEL_EXPORT virtual std::shared_ptr<ModelAPI_AttributeDocRef> docRef(const std::string theID);
- /// Returns the attribute that contains real value with double precision
- MODEL_EXPORT virtual std::shared_ptr<ModelAPI_AttributeDouble> real(const std::string theID);
-
- /// Initializes object by the attributes: must be called just after the object is created
- /// for each attribute of the object
- /// \param theID identifier of the attribute that can be referenced by this ID later
- /// \param theAttrType type of the created attribute (received from the type method)
- MODEL_EXPORT virtual void addAttribute(std::string theID, std::string theAttrType);
-
- /// Returns the document of this data
- MODEL_EXPORT virtual std::shared_ptr<ModelAPI_Document> document() {return myDoc;}
-
- /// Puts feature to the document data sub-structure
- MODEL_EXPORT void setLabel(TDF_Label& theLab);
-
- /// Sets the document of this data
- MODEL_EXPORT virtual void setDocument(const std::shared_ptr<ModelAPI_Document>& theDoc) {myDoc = theDoc;}
-};
-
-#endif
#include <Model_PluginManager.h>
#include <ModelAPI_Feature.h>
#include <ModelAPI_Plugin.h>
-#include <Model_Object.h>
+#include <Model_Data.h>
#include <Model_Document.h>
#include <Model_Application.h>
#include <Event_Loop.h>
{
public:
/// Defines the double value
- virtual void setValue(double theValue) = 0;
+ virtual void setValue(const double theValue) = 0;
/// Returns the double value
virtual double value() = 0;
${QT_QTMAIN_LIBRARY}
${CAS_VIEWER}
${CAS_KERNEL}
- ${CAS_OCAF}
PyConsole
PyInterp
PyEvent
#include <ModelAPI_Document.h>
#include <ModelAPI_Feature.h>
#include <ModelAPI_Object.h>
-#include <Model_Document.h>
+#include <Model_Events.h>
#include <Event_Loop.h>
if (aMaxSide < Precision::Confusion())
return false;
- static float EPS = 5.0E-3;
+ static float EPS = (float)5.0E-3;
theSize = trihedron()->Size();
//theNewSize = aMaxSide*aSizeInPercents / 100.0;