class Events_MessageGroup;
-/**\class Events_Lopp
+/**\class Events_Loop
* \ingroup EventsLoop
* \brief Base class that manages the receiving and sending of all
* not Qt-events in the application.
#include <Events_Message.h>
#include <memory>
-/**\class Events_Message
+/**\class Events_MessageGroup
* \ingroup EventsLoop
* \brief Message that allows to group messages and send them later as a group of messages.
*
ADD_DEFINITIONS(-DMODEL_EXPORTS ${CAS_DEFINITIONS})
-ADD_LIBRARY(Model MODULE ${PROJECT_SOURCES} ${PROJECT_HEADERS})
+ADD_LIBRARY(Model SHARED ${PROJECT_SOURCES} ${PROJECT_HEADERS})
TARGET_LINK_LIBRARIES(Model ${PROJECT_LIBRARIES})
INCLUDE_DIRECTORIES(
/**\class Model_Application
* \ingroup DataModel
* \brief Realization of Open CASCADE application abstraction. Class for internal use only.
+ *
* Application supports the formats and document management. It is uses OCAF-lke
* architecture and just implements specific features of the module.
*/
class Model_Application : public TDocStd_Application
{
- public:
+public:
// useful methods inside of the module
// CASCADE RTTI
- DEFINE_STANDARD_RTTI(Model_Application)
- ;
+ /// Definition of "Handles" usage
+ /// \param Model_Application is the class name that is covered by the OCCT Handle
+ DEFINE_STANDARD_RTTI(Model_Application);
//! Retuns the application: one per process
MODEL_EXPORT static Handle_Model_Application getApplication();
if (aContext->groupName() == ModelAPI_ResultBody::group()) {
// body: just a named shape, use selection mechanism from OCCT
TNaming_Selector aSelector(aSelLab);
- bool aResult = aSelector.Solve(scope()) == Standard_True;
+ bool aResult = true;//aSelector.Solve(scope()) == Standard_True;
owner()->data()->sendAttributeUpdated(this);
return aResult;
} else if (aContext->groupName() == ModelAPI_ResultConstruction::group()) {
/// Returns the number ofselection attributes in the list
MODEL_EXPORT virtual int size();
+ /// The type of all elements selection
+ /// \returns the index of the OCCT enumeration of the type of shape
MODEL_EXPORT virtual int selectionType();
- MODEL_EXPORT virtual void setSelectionType(int);
+ /// Sets the type of all elements selection
+ /// \param theType the index of the OCCT enumeration of the type of shape
+ MODEL_EXPORT virtual void setSelectionType(int theType);
/// Returns the attribute selection by the index (zero based)
MODEL_EXPORT virtual std::shared_ptr<ModelAPI_AttributeSelection> value(const int theIndex);
/// Returns the identifier of feature-owner, unique in this document
MODEL_EXPORT virtual int featureId() const;
- // returns all objects referenced to this
+ /// returns all objects referenced to this
MODEL_EXPORT virtual const std::set<AttributePtr>& refsToMe() {return myRefsToMe;}
- // returns all references by attributes of this data
- // \param theRefs returned list of pairs: id of referenced attribute and list of referenced objects
+ /// returns all references by attributes of this data
+ /// \param theRefs returned list of pairs: id of referenced attribute and list of referenced objects
MODEL_EXPORT virtual void referencesToObjects(
std::list<std::pair<std::string, std::list<ObjectPtr> > >& theRefs);
private:
- // removes all information about back references
+ /// removes all information about back references
void eraseBackReferences();
// adds a back reference (with identifier which attribute references to this object
void addBackReference(FeaturePtr theFeature, std::string theAttrID);
//! Loads the OCAF document from the file.
//! \param theFileName full name of the file to load
- //! \param theStudyID identifier of the SALOME study to associate with loaded file
//! \returns true if file was loaded successfully
MODEL_EXPORT virtual bool load(const char* theFileName);
MODEL_EXPORT virtual void redo();
//! Adds to the document the new feature of the given feature id
- //! \param creates feature and puts it in the document
+ //! \param theID creates feature and puts it in the document
MODEL_EXPORT virtual FeaturePtr addFeature(std::string theID);
//! Removes the feature from the document (with result)
+ //! \param theFeature the feature to be removed
//! \param theCheck if it is false, do not check the references
MODEL_EXPORT virtual void removeFeature(FeaturePtr theFeature, const bool theCheck = true);
//! Returns the feature in the group by the index (started from zero)
//! \param theGroupID group that contains a feature
//! \param theIndex zero-based index of feature in the group
- //! \param isOperation if it is true, returns feature (not Object)
//! \param theHidden if it is true, it counts also the features that are not in tree
MODEL_EXPORT virtual ObjectPtr object(const std::string& theGroupID, const int theIndex,
const bool theHidden = false);
//! Creates new document with binary file format
Model_Document(const std::string theID, const std::string theKind);
+ //! Returns the internal OCCT document of this interface
Handle_TDocStd_Document document()
{
return myDoc;
return myGroups;
}
+ /// Returns the new empty message of this type
virtual std::shared_ptr<Events_MessageGroup> newEmpty();
+ /// Returns the identifier of this message
virtual const Events_ID messageId();
+ /// Appends to this message the given one
virtual void Join(const std::shared_ptr<Events_MessageGroup>& theJoined);
};
#include <set>
#include <map>
+/**\class Model_FeatureValidator
+ * \ingroup DataModel
+ * \brief The geneneric validator for the whole feature.
+ *
+ * Can be redefined for some specific feature, but by default for each feature this validator is
+ * used: it checks each argument of the feature and if one of it is not valid (and obligatory),
+ * the hole feature is invalid.
+ */
class Model_FeatureValidator : public ModelAPI_FeatureValidator
{
// not obligatory attributes, not checked for initialization
std::map<std::string, std::set<std::string> > myNotObligatory;
- public:
+public:
/// Returns true if feature and/or attributes are valid
/// \param theFeature the validated feature
+ /// \param theArguments the arguments in the configuration file for this validator
+ /// \returns true if feature is valid
MODEL_EXPORT virtual bool isValid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
const std::list<std::string>& theArguments) const;
- // sets not obligatory attributes, not checked for initialization
+ /// sets not obligatory attributes, not checked for initialization
virtual void registerNotObligatory(std::string theFeature, std::string theAttribute);
/// Returns true if the attribute in feature is not obligatory for the feature execution
class TNaming_Builder;
-/**\class ModelAPI_ResultBody
+/**\class Model_ResultBody
* \ingroup DataModel
* \brief The body (shape) result of a feature.
*
#include "Model.h"
#include <ModelAPI_ResultConstruction.h>
-/**\class ModelAPI_ResultConstruction
+/**\class Model_ResultConstruction
* \ingroup DataModel
* \brief The construction element result of a feature.
*
#include "Model.h"
#include <ModelAPI_ResultGroup.h>
-/**\class ModelAPI_ResultGroup
+/**\class Model_ResultGroup
* \ingroup DataModel
* \brief The groups result.
*
#include "Model.h"
#include <ModelAPI_ResultPart.h>
-/**\class ModelAPI_ResultPart
+/**\class Model_ResultPart
* \ingroup DataModel
* \brief The Part document, result of a creation of new part feature.
*
//! Loads the OCAF document from the file.
//! \param theFileName full name of the file to load
- //! \param theStudyID identifier of the SALOME study to associate with loaded file
//! \returns true if file was loaded successfully
MODEL_EXPORT virtual bool load(const char* theFileName);
/// Returns the validators factory: the only one instance per application
MODEL_EXPORT virtual ModelAPI_ValidatorsFactory* validators();
+ /// Sets the flag to check modifications outside the transaction or not
void setCheckTransactions(const bool theCheck)
{
myCheckTransactions = theCheck;
virtual bool isConcealed(std::string theFeature, std::string theAttribute);
protected:
+ /// Adds the defualt validators that are usefull for all features.
void addDefaultValidators(std::list<ModelAPI_Validator*>& theValidators,
std::list<std::list<std::string> >& theArguments) const;
/// Get instance from Session
/// Returns the number ofselection attributes in the list
virtual int size() = 0;
+ /// The type of all elements selection
+ /// \returns the index of the enumeration of the type of shape
virtual int selectionType() = 0;
- virtual void setSelectionType(int) = 0;
+ /// Sets the type of all elements selection
+ /// \param theType the index of the enumeration of the type of shape
+ virtual void setSelectionType(int theType) = 0;
/// Returns the attribute selection by the index (zero based)
virtual std::shared_ptr<ModelAPI_AttributeSelection> value(const int theIndex) = 0;
/// Returns the identifier of feature-owner, unique in this document
virtual int featureId() const = 0;
- // returns all objects referenced to this
+ /// returns all objects referenced to this
virtual const std::set<std::shared_ptr<ModelAPI_Attribute> >& refsToMe() = 0;
- // returns all references by attributes of this data
- // \param theRefs returned list of pairs: id of referenced attribute and list of referenced objects
+ /// returns all references by attributes of this data
+ /// \param theRefs returned list of pairs: id of referenced attribute and list of referenced objects
virtual void referencesToObjects(
std::list<std::pair<std::string, std::list<std::shared_ptr<ModelAPI_Object> > > >& theRefs) = 0;
protected:
class ModelAPI_ResultGroup;
class ModelAPI_Data;
-/**\class Model_Document
+/**\class ModelAPI_Document
* \ingroup DataModel
* \brief Document for internal data structure of any object storage.
* Document contains all data that must be stored/retrived in the file.
virtual void close(const bool theForever = false) = 0;
//! Adds to the document the new feature of the given feature id
- //! \param creates feature and puts it in the document (if it is not action)
+ //! \param theID creates feature and puts it in the document (if it is not action)
virtual std::shared_ptr<ModelAPI_Feature> addFeature(std::string theID) = 0;
//! Removes the feature from the document
class MODELAPI_EXPORT ModelAPI_ObjectUpdatedMessage : public Events_MessageGroup
{
protected:
+ /// Creates an empty message
ModelAPI_ObjectUpdatedMessage(const Events_ID theID, const void* theSender = 0);
+ /// The virtual destructor
virtual ~ModelAPI_ObjectUpdatedMessage();
public:
/// Message that feature was deleted (used for Object Browser update)
class MODELAPI_EXPORT ModelAPI_ObjectDeletedMessage : public Events_MessageGroup
{
- protected:
+protected:
+ /// Creates an empty message
ModelAPI_ObjectDeletedMessage(const Events_ID theID, const void* theSender = 0);
+ /// The virtual destructor
virtual ~ModelAPI_ObjectDeletedMessage();
- public:
+public:
/// Returns the feature that has been updated
virtual std::shared_ptr<ModelAPI_Document> document() const = 0;
/// Returns the group where the feature was deleted
virtual const std::set<std::string>& groups() const = 0;
+ /// Creates the new empty message of this kind
virtual std::shared_ptr<Events_MessageGroup> newEmpty() = 0;
+ /// Returns the identifier of the kind of a message
virtual const Events_ID messageId() = 0;
+ /// Appenad to this message the given one.
virtual void Join(const std::shared_ptr<Events_MessageGroup>& theJoined) = 0;
};
/// Allows to create ModelAPI messages
class MODELAPI_EXPORT ModelAPI_EventCreator
{
- public:
+public:
/// creates created, updated or moved messages and sends to the loop
virtual void sendUpdated(const ObjectPtr& theObject, const Events_ID& theEvent,
const bool isGroupped = true) const = 0;
};
// TODO(sbh): Move this message into a separate package, like "GuiAPI"
+/// Contains the state information about the feature: is it enabled or disabled.
class ModelAPI_FeatureStateMessage : public Events_Message
{
- public:
+public:
+ /// Creates an empty message
MODELAPI_EXPORT ModelAPI_FeatureStateMessage(const Events_ID theID, const void* theSender = 0);
+ /// The virtual destructor
MODELAPI_EXPORT virtual ~ModelAPI_FeatureStateMessage();
- // For request
+ /// Returns the feature this message is related to
MODELAPI_EXPORT std::shared_ptr<ModelAPI_Feature> feature() const;
+ /// Stores the feature this message is related to
MODELAPI_EXPORT void setFeature(std::shared_ptr<ModelAPI_Feature>& theFeature);
// For response
+ /// Returns true if feature has specific state
MODELAPI_EXPORT bool hasState(const std::string& theFeatureId) const;
+ /// Returns true if feature is enabled
MODELAPI_EXPORT bool state(const std::string& theFeatureId, bool theDefault = false) const;
+ /// Stores the feature state
MODELAPI_EXPORT void setState(const std::string& theFeatureId, bool theValue);
+ /// Returns all feature IDs with states
MODELAPI_EXPORT std::list<std::string> features() const;
private:
- // For Request
+ /// For Request
std::shared_ptr<ModelAPI_Feature> myCurrentFeature;
- // For response
+ /// For response
std::map<std::string, bool> myFeatureState;
};
/// To virtually destroy the fields of successors
MODELAPI_EXPORT virtual ~ModelAPI_Feature();
+ /// Returns the feature by the object (result).
MODELAPI_EXPORT static std::shared_ptr<ModelAPI_Feature> feature(ObjectPtr theObject);
//
// Helper methods, aliases for data()->method()
// -----------------------------------------------------------------------------------------------
+ /// Returns the name stored in the attribute
inline std::string name()
{
return data()->name();
}
-
+ /// Returns the Boolean attribute by the identifier
inline std::shared_ptr<ModelAPI_AttributeBoolean> boolean(const std::string& theID)
{
return data()->boolean(theID);
}
-
+ /// Returns the document reference attribute
inline std::shared_ptr<ModelAPI_AttributeDocRef> document(const std::string& theID)
{
return data()->document(theID);
}
-
+ /// Returns the real attribute by the identifier
inline std::shared_ptr<ModelAPI_AttributeDouble> real(const std::string& theID)
{
return data()->real(theID);
}
-
+ /// Returns the integer attribute by the identifier
inline std::shared_ptr<ModelAPI_AttributeInteger> integer(const std::string& theID)
{
return data()->integer(theID);
}
-
+ /// Returns the reference attribute by the identifier
inline std::shared_ptr<ModelAPI_AttributeRefAttr> refattr(const std::string& theID)
{
return data()->refattr(theID);
}
-
+ /// Returns the reference attribute by the identifier
inline std::shared_ptr<ModelAPI_AttributeReference> reference(const std::string& theID)
{
return data()->reference(theID);
}
-
+ /// Returns the list of references attribute by the identifier
inline std::shared_ptr<ModelAPI_AttributeRefList> reflist(const std::string& theID)
{
return data()->reflist(theID);
}
-
+ /// Returns the shape selection attribute by the identifier
inline std::shared_ptr<ModelAPI_AttributeSelection> selection(const std::string& theID)
{
return data()->selection(theID);
}
-
+ /// Returns the list of shape selections attribute by the identifier
inline std::shared_ptr<ModelAPI_AttributeSelectionList> selectionList(const std::string& theID)
{
return data()->selectionList(theID);
}
-
+ /// Returns the string attribute by the identifier
inline std::shared_ptr<ModelAPI_AttributeString> string(const std::string& theID)
{
return data()->string(theID);
}
-
+ /// Returns the attribute by the identifier
inline std::shared_ptr<ModelAPI_Attribute> attribute(const std::string& theID)
{
return data()->attribute(theID);
#include "ModelAPI.h"
#include "ModelAPI_Validator.h"
+/**\class ModelAPI_FeatureValidator
+ * \ingroup DataModel
+ * \brief The geneneric validator for the whole feature.
+ *
+ * Can be redefined for some specific feature, but by default for each feature this validator is
+ * used: it checks each argument of the feature and if one of it is not valid (and obligatory),
+ * the hole feature is invalid.
+ */
class ModelAPI_FeatureValidator : public ModelAPI_Validator
{
public:
/// Returns true if feature and/or attributes are valid
/// \param theFeature the validated feature
- /// \param theAttr the validated attribute ID, empty string of feature is validated
/// \param theArguments list of string, feature attribute names: dependent attributes
virtual bool isValid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
const std::list<std::string>& theArguments) const = 0;
* \ingroup DataModel
* \brief Interface common for any plugin: allows to use plugin by the plugins manager.
*/
-
class MODELAPI_EXPORT ModelAPI_Plugin
{
public:
#include <ModelAPI_Attribute.h>
#include <ModelAPI_AttributeValidator.h>
-/*
+/**\class ModelAPI_RefAttrValidator
+ * \ingroup DataModel
* Used for filtering out the object that can be used for reference attribute value
*/
class ModelAPI_RefAttrValidator : public ModelAPI_AttributeValidator
#include "ModelAPI_Validator.h"
#include "ModelAPI_Object.h"
+/**\class ModelAPI_ResultValidator
+ * \ingroup DataModel
+ * \brief The base class for selection filter for results of features.
+ *
+ * The referenced arguments of feature is normally results displayed in the viewer or by the
+ * selection attribute. This filter allows to filter out the results not usable as this argument.
+ */
class ModelAPI_ResultValidator : public ModelAPI_Validator
{
- public:
+public:
+ /// The abstract method for implementation in the specific validator.
+ /// \param theObject the checked object as an argument
+ /// \returns true if object is OK for this filter
virtual bool isValid(const ObjectPtr theObject) const = 0;
};
//! Loads the OCAF document from the file.
//! \param theFileName full name of the file to load
- //! \param theStudyID identifier of the SALOME study to associate with loaded file
//! \returns true if file was loaded successfully
virtual bool load(const char* theFileName) = 0;
protected:
/// Creates the feature object using plugins functionality
virtual std::shared_ptr<ModelAPI_Feature> createFeature(std::string theFeatureID) = 0;
-
+ /// Sets the session interface implementation (once per application launch)
static void setSession(std::shared_ptr<ModelAPI_Session> theManager);
friend class Model_Document;
#include <ModelAPI_Feature.h>
#include <ModelAPI_Events.h>
+/**\class SketchPlugin_Plugin
+ * \ingroup DataModel
+ * \brief Interface common for any plugin: allows to use plugin by the plugins manager.
+ */
class SKETCHPLUGIN_EXPORT SketchPlugin_Plugin : public ModelAPI_Plugin, public Events_Listener
{
- public:
+public:
/// Creates the feature object of this plugin by the feature string ID
virtual FeaturePtr createFeature(std::string theFeatureID);
SketchPlugin_Plugin();
//! Redefinition of Events_Listener method
virtual void processEvent(const std::shared_ptr<Events_Message>& theMessage);
- protected:
+protected:
+ //! Returns the state of the feature in the WorkBench: enabled or disabled for the moment.
std::shared_ptr<ModelAPI_FeatureStateMessage> getFeaturesState(
const std::shared_ptr<ModelAPI_Feature>& theFeature) const;
};
* \param[in] theEntity attribute of the constraint
*/
void updateRelatedConstraints(std::shared_ptr<ModelAPI_Attribute> theEntity) const;
+ /** \brief Searches the constraints built on the entity and emit the signal to update them
+ * \param[in] theFeature feature of the constraint
+ */
void updateRelatedConstraintsFeature(std::shared_ptr<ModelAPI_Feature> theFeature) const;
/** \brief Adds or updates an entity in the group