From: mpv Date: Thu, 10 Apr 2014 13:37:17 +0000 (+0400) Subject: Updated events for Model and minor other changes X-Git-Tag: V_0.1~23^2~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=34c92803a174324249d12ae0eb45143e0d8a9c23;p=modules%2Fshaper.git Updated events for Model and minor other changes --- diff --git a/src/Config/Config_FeatureMessage.h b/src/Config/Config_FeatureMessage.h index 8fce1b173..4185b4b96 100644 --- a/src/Config/Config_FeatureMessage.h +++ b/src/Config/Config_FeatureMessage.h @@ -11,7 +11,7 @@ * Example of the feature entry: * */ -class CONFIG_EXPORT Config_FeatureMessage: public Event_Message +class Config_FeatureMessage: public Event_Message { std::string myId; //Feature unique id std::string myText; //Represents action's text @@ -25,31 +25,31 @@ class CONFIG_EXPORT Config_FeatureMessage: public Event_Message public: //const Event_ID theID, const void* theSender = 0 - Config_FeatureMessage(const Event_ID theId, const void* theParent = 0); + CONFIG_EXPORT Config_FeatureMessage(const Event_ID theId, const void* theParent = 0); //TODO(sbh): Implement static method to extract event id [SEID] //static const char* eventId() { return ""; } //Auto-generated getters/setters - const std::string& icon() const; - const std::string& id() const; - const std::string& keysequence() const; - const std::string& text() const; - const std::string& tooltip() const; - - const std::string& groupId() const; - const std::string& workbenchId() const; - const std::string& pluginLibrary() const; - - void setIcon(const std::string& icon); - void setId(const std::string& id); - void setKeysequence(const std::string& keysequence); - void setText(const std::string& text); - void setTooltip(const std::string& tooltip); - - void setGroupId(const std::string& groupId); - void setWorkbenchId(const std::string& workbenchId); - void setPluginLibrary(const std::string& thePluginLibrary); + CONFIG_EXPORT const std::string& icon() const; + CONFIG_EXPORT const std::string& id() const; + CONFIG_EXPORT const std::string& keysequence() const; + CONFIG_EXPORT const std::string& text() const; + CONFIG_EXPORT const std::string& tooltip() const; + + CONFIG_EXPORT const std::string& groupId() const; + CONFIG_EXPORT const std::string& workbenchId() const; + CONFIG_EXPORT const std::string& pluginLibrary() const; + + CONFIG_EXPORT void setIcon(const std::string& icon); + CONFIG_EXPORT void setId(const std::string& id); + CONFIG_EXPORT void setKeysequence(const std::string& keysequence); + CONFIG_EXPORT void setText(const std::string& text); + CONFIG_EXPORT void setTooltip(const std::string& tooltip); + + CONFIG_EXPORT void setGroupId(const std::string& groupId); + CONFIG_EXPORT void setWorkbenchId(const std::string& workbenchId); + CONFIG_EXPORT void setPluginLibrary(const std::string& thePluginLibrary); }; #endif // CONFIG_MESSAGE_H diff --git a/src/Config/Config_FeatureReader.h b/src/Config/Config_FeatureReader.h index 117e8bd6c..da5fa77fe 100644 --- a/src/Config/Config_FeatureReader.h +++ b/src/Config/Config_FeatureReader.h @@ -16,7 +16,7 @@ class Config_FeatureMessage; -class CONFIG_EXPORT Config_FeatureReader: public Config_XMLReader +class Config_FeatureReader: public Config_XMLReader { public: Config_FeatureReader(const std::string& theXmlFile, diff --git a/src/Config/Config_ModuleReader.h b/src/Config/Config_ModuleReader.h index 5a19c24c0..33567bdd2 100644 --- a/src/Config/Config_ModuleReader.h +++ b/src/Config/Config_ModuleReader.h @@ -15,17 +15,17 @@ #include -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& plugins() const; + CONFIG_EXPORT void setAutoImport(bool enabled); + CONFIG_EXPORT const std::map& plugins() const; - std::string getModuleName(); + CONFIG_EXPORT std::string getModuleName(); protected: void processNode(xmlNodePtr aNode); diff --git a/src/Config/Config_WidgetReader.h b/src/Config/Config_WidgetReader.h index 58fd904b0..7b5aa86f4 100644 --- a/src/Config/Config_WidgetReader.h +++ b/src/Config/Config_WidgetReader.h @@ -15,13 +15,13 @@ #include -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); diff --git a/src/Config/Config_XMLReader.h b/src/Config/Config_XMLReader.h index 331de4b6b..95d3ea651 100644 --- a/src/Config/Config_XMLReader.h +++ b/src/Config/Config_XMLReader.h @@ -30,13 +30,13 @@ struct _xmlDoc; * 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); diff --git a/src/Model/CMakeLists.txt b/src/Model/CMakeLists.txt index eca79ac1a..48a70e9ac 100644 --- a/src/Model/CMakeLists.txt +++ b/src/Model/CMakeLists.txt @@ -8,20 +8,22 @@ SET(PROJECT_HEADERS 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}) diff --git a/src/Model/Model_Application.cxx b/src/Model/Model_Application.cxx index 260db7d44..a8c8966b3 100644 --- a/src/Model/Model_Application.cxx +++ b/src/Model/Model_Application.cxx @@ -25,14 +25,14 @@ Handle(Model_Application) Model_Application::getApplication() //function : getDocument //purpose : //======================================================================= -std::shared_ptr Model_Application::getDocument(string theDocID) +const std::shared_ptr& Model_Application::getDocument(string theDocID) { if (myDocs.find(theDocID) != myDocs.end()) return myDocs[theDocID]; std::shared_ptr aNew(new Model_Document(theDocID)); myDocs[theDocID] = aNew; - return aNew; + return myDocs[theDocID]; } void Model_Application::deleteDocument(string theDocID) diff --git a/src/Model/Model_Application.h b/src/Model/Model_Application.h index 998aba08b..c4f578f04 100644 --- a/src/Model/Model_Application.h +++ b/src/Model/Model_Application.h @@ -30,7 +30,7 @@ public: //! 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 getDocument(std::string theDocID); + MODEL_EXPORT const std::shared_ptr& getDocument(std::string theDocID); //! Deletes the document from the application MODEL_EXPORT void deleteDocument(std::string theDocID); diff --git a/src/Model/Model_AttributeDocRef.h b/src/Model/Model_AttributeDocRef.h index 221855724..778ed316b 100644 --- a/src/Model/Model_AttributeDocRef.h +++ b/src/Model/Model_AttributeDocRef.h @@ -15,21 +15,21 @@ * \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 theDoc); + MODEL_EXPORT virtual void setValue(std::shared_ptr theDoc); /// Returns document referenced from this attribute - virtual std::shared_ptr value(); + MODEL_EXPORT virtual std::shared_ptr value(); protected: /// Initializes attibutes Model_AttributeDocRef(TDF_Label& theLabel); - friend class Model_Object; + friend class Model_Data; }; #endif diff --git a/src/Model/Model_AttributeDouble.h b/src/Model/Model_AttributeDouble.h index d498bc42b..0079b639c 100644 --- a/src/Model/Model_AttributeDouble.h +++ b/src/Model/Model_AttributeDouble.h @@ -15,21 +15,21 @@ * \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 diff --git a/src/Model/Model_Data.cxx b/src/Model/Model_Data.cxx new file mode 100644 index 000000000..a9ac29bf0 --- /dev/null +++ b/src/Model/Model_Data.cxx @@ -0,0 +1,77 @@ +// File: Model_Data.hxx +// Created: 21 Mar 2014 +// Author: Mikhail PONIKAROV + +#include +#include +#include +#include + +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(anAttr); + else + ; // TODO: generate error on unknown attribute request and/or add mechanism for customization +} + +shared_ptr Model_Data::docRef(const string theID) +{ + map >::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(); + } + shared_ptr aRes = + dynamic_pointer_cast(aFound->second); + if (!aRes) { + // TODO: generate error on invalid attribute type request + } + return aRes; +} + +shared_ptr Model_Data::real(const string theID) +{ + map >::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(); + } + shared_ptr aRes = + dynamic_pointer_cast(aFound->second); + if (!aRes) { + // TODO: generate error on invalid attribute type request + } + return aRes; +} diff --git a/src/Model/Model_Data.h b/src/Model/Model_Data.h new file mode 100644 index 000000000..b634d935a --- /dev/null +++ b/src/Model/Model_Data.h @@ -0,0 +1,63 @@ +// File: Model_Data.hxx +// Created: 21 Mar 2014 +// Author: Mikhail PONIKAROV + +#ifndef Model_Data_HeaderFile +#define Model_Data_HeaderFile + +#include "Model.h" +#include +#include + +#include + +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 > myAttrs; + + std::shared_ptr 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 docRef(const std::string theID); + /// Returns the attribute that contains real value with double precision + MODEL_EXPORT virtual std::shared_ptr 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 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& theDoc) {myDoc = theDoc;} +}; + +#endif diff --git a/src/Model/Model_Document.cxx b/src/Model/Model_Document.cxx index 9eebe15d1..0e976420c 100644 --- a/src/Model/Model_Document.cxx +++ b/src/Model/Model_Document.cxx @@ -4,10 +4,11 @@ #include #include -#include +#include #include #include #include +#include #include #include @@ -17,7 +18,7 @@ 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; @@ -219,7 +220,7 @@ void Model_Document::addFeature(const std::shared_ptr theFeatu const std::string& aGroup = theFeature->getGroup(); TDF_Label aGroupLab = groupLabel(aGroup); TDF_Label anObjLab = aGroupLab.NewChild(); - std::shared_ptr aData(new Model_Object); + std::shared_ptr aData(new Model_Data); aData->setLabel(anObjLab); aData->setDocument(Model_Application::getApplication()->getDocument(myID)); theFeature->setData(aData); @@ -231,9 +232,9 @@ void Model_Document::addFeature(const std::shared_ptr theFeatu 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); } @@ -255,7 +256,7 @@ int Model_Document::featureIndex(shared_ptr theFeature) if (theFeature->data()->document().get() != this) { return theFeature->data()->document()->featureIndex(theFeature); } - shared_ptr aData = dynamic_pointer_cast(theFeature->data()); + shared_ptr aData = dynamic_pointer_cast(theFeature->data()); Handle(TDataStd_Integer) aFeatureIndex; if (aData->label().FindAttribute(TDataStd_Integer::GetID(), aFeatureIndex)) { return aFeatureIndex->Get(); @@ -389,7 +390,7 @@ void Model_Document::synchronizeFeatures() 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 aData = dynamic_pointer_cast((*aFIter)->data()); + shared_ptr aData = dynamic_pointer_cast((*aFIter)->data()); aFeatureTag = aData->label().Tag(); } int aDSTag = INFINITE_TAG; @@ -398,21 +399,25 @@ void Model_Document::synchronizeFeatures() } 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 aFeature = ModelAPI_PluginManager::get()->createFeature( TCollection_AsciiString(Handle(TDataStd_Comment)::DownCast( aFLabIter.Value())->Get()).ToCString()); - std::shared_ptr aData(new Model_Object); + std::shared_ptr 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()) { @@ -431,19 +436,3 @@ void Model_Document::synchronizeFeatures() } } } - -ModelAPI_FeatureUpdatedMessage::ModelAPI_FeatureUpdatedMessage( - shared_ptr 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_FeatureUpdatedMessage::feature() -{ - return myFeature; -} diff --git a/src/Model/Model_Document.h b/src/Model/Model_Document.h index ec5de4b9f..678a3f83d 100644 --- a/src/Model/Model_Document.h +++ b/src/Model/Model_Document.h @@ -7,7 +7,6 @@ #include #include -#include #include #include @@ -126,21 +125,4 @@ private: std::map 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 myFeature; ///< which feature is changed -public: - /// sender is not important, all information is located in the feature - ModelAPI_FeatureUpdatedMessage(std::shared_ptr theFeature); - - /// Returns the ID of this message - static const Event_ID messageId(); - - /// Returns the feature that has been updated - std::shared_ptr feature(); -}; - #endif diff --git a/src/Model/Model_Events.cxx b/src/Model/Model_Events.cxx new file mode 100644 index 000000000..f9ddb0f11 --- /dev/null +++ b/src/Model/Model_Events.cxx @@ -0,0 +1,24 @@ +// File: Model_Events.cxx +// Created: 10 Apr 2014 +// Author: Mikhail PONIKAROV + +#include +#include + +ModelAPI_FeatureUpdatedMessage::ModelAPI_FeatureUpdatedMessage( + const std::shared_ptr& theFeature, const Event_ID& theEvent) + : Event_Message(theEvent, 0), myFeature(theFeature) +{} + +ModelAPI_FeatureDeletedMessage::ModelAPI_FeatureDeletedMessage( + const std::shared_ptr& 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; +} diff --git a/src/Model/Model_Events.h b/src/Model/Model_Events.h new file mode 100644 index 000000000..e969458d6 --- /dev/null +++ b/src/Model/Model_Events.h @@ -0,0 +1,54 @@ +// File: Model_Events.h +// Created: 10 Apr 2014 +// Author: Mikhail PONIKAROV + +#ifndef Model_Events_HeaderFile +#define Model_Events_HeaderFile + +#include +#include +#include +#include + +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 myFeature; ///< which feature is changed +public: + /// sender is not important, all information is located in the feature + ModelAPI_FeatureUpdatedMessage(const std::shared_ptr& theFeature, + const Event_ID& theEvent); + + /// Returns the feature that has been updated + std::shared_ptr feature() {return myFeature;} +}; + +/// Message that feature was deleted (used for Object Browser update) +class ModelAPI_FeatureDeletedMessage : public Event_Message { + std::shared_ptr 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& 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 document() {return myDoc;} + + /// Returns the group where the feature was deleted + const std::string& group() {return myGroup;} +}; + +#endif diff --git a/src/Model/Model_Iterator.cxx b/src/Model/Model_Iterator.cxx index 42ed7309f..b8a765d91 100644 --- a/src/Model/Model_Iterator.cxx +++ b/src/Model/Model_Iterator.cxx @@ -5,7 +5,7 @@ #include "Model_Iterator.h" #include "Model_Document.h" #include "ModelAPI_Feature.h" -#include "Model_Object.h" +#include "Model_Data.h" #include #include @@ -54,7 +54,7 @@ int Model_Iterator::numIterationsLeft() bool Model_Iterator::is(std::shared_ptr theFeature) { return (myIter.Value()->Label() == - dynamic_pointer_cast(theFeature->data())->label()) == Standard_True; + dynamic_pointer_cast(theFeature->data())->label()) == Standard_True; } diff --git a/src/Model/Model_Object.cxx b/src/Model/Model_Object.cxx deleted file mode 100644 index 0312a0c12..000000000 --- a/src/Model/Model_Object.cxx +++ /dev/null @@ -1,77 +0,0 @@ -// File: Model_Object.hxx -// Created: 21 Mar 2014 -// Author: Mikhail PONIKAROV - -#include -#include -#include -#include - -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(anAttr); - else - ; // TODO: generate error on unknown attribute request and/or add mechanism for customization -} - -shared_ptr Model_Object::docRef(const string theID) -{ - map >::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(); - } - shared_ptr aRes = - dynamic_pointer_cast(aFound->second); - if (!aRes) { - // TODO: generate error on invalid attribute type request - } - return aRes; -} - -shared_ptr Model_Object::real(const string theID) -{ - map >::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(); - } - shared_ptr aRes = - dynamic_pointer_cast(aFound->second); - if (!aRes) { - // TODO: generate error on invalid attribute type request - } - return aRes; -} diff --git a/src/Model/Model_Object.h b/src/Model/Model_Object.h deleted file mode 100644 index 9a778c99d..000000000 --- a/src/Model/Model_Object.h +++ /dev/null @@ -1,63 +0,0 @@ -// File: Model_Object.hxx -// Created: 21 Mar 2014 -// Author: Mikhail PONIKAROV - -#ifndef Model_Object_HeaderFile -#define Model_Object_HeaderFile - -#include "Model.h" -#include -#include - -#include - -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 > myAttrs; - - std::shared_ptr 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 docRef(const std::string theID); - /// Returns the attribute that contains real value with double precision - MODEL_EXPORT virtual std::shared_ptr 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 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& theDoc) {myDoc = theDoc;} -}; - -#endif diff --git a/src/Model/Model_PluginManager.cxx b/src/Model/Model_PluginManager.cxx index cca7b72fd..ea0b826a6 100644 --- a/src/Model/Model_PluginManager.cxx +++ b/src/Model/Model_PluginManager.cxx @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/ModelAPI/ModelAPI_AttributeDouble.h b/src/ModelAPI/ModelAPI_AttributeDouble.h index 7dfb882c3..cc6a2dd26 100644 --- a/src/ModelAPI/ModelAPI_AttributeDouble.h +++ b/src/ModelAPI/ModelAPI_AttributeDouble.h @@ -16,7 +16,7 @@ class MODELAPI_EXPORT ModelAPI_AttributeDouble : public ModelAPI_Attribute { 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; diff --git a/src/XGUI/CMakeLists.txt b/src/XGUI/CMakeLists.txt index 33d7a9765..f428942ff 100644 --- a/src/XGUI/CMakeLists.txt +++ b/src/XGUI/CMakeLists.txt @@ -67,7 +67,6 @@ SET(PROJECT_LIBRARIES ${QT_QTMAIN_LIBRARY} ${CAS_VIEWER} ${CAS_KERNEL} - ${CAS_OCAF} PyConsole PyInterp PyEvent diff --git a/src/XGUI/XGUI_DocumentDataModel.cpp b/src/XGUI/XGUI_DocumentDataModel.cpp index 0cb623369..c3f8a437b 100644 --- a/src/XGUI/XGUI_DocumentDataModel.cpp +++ b/src/XGUI/XGUI_DocumentDataModel.cpp @@ -6,7 +6,7 @@ #include #include #include -#include +#include #include diff --git a/src/XGUI/XGUI_Viewer.cpp b/src/XGUI/XGUI_Viewer.cpp index 6bec77168..ed02e33b1 100644 --- a/src/XGUI/XGUI_Viewer.cpp +++ b/src/XGUI/XGUI_Viewer.cpp @@ -324,7 +324,7 @@ bool XGUI_Viewer::computeTrihedronSize(double& theNewSize, double& theSize) 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;