public:
/*!
* Constructor
- * \param theXmlFile - full path to the xml file which will be processed by the reader
*/
CONFIG_EXPORT Config_DataModelReader();
CONFIG_EXPORT virtual ~Config_DataModelReader();
};
-#endif
\ No newline at end of file
+#endif
std::string restoreAttribute(xmlNodePtr theNode, const char* theNodeAttribute);
/// Restores an attribute from internal map.
std::string restoreAttribute(const char* theNodeName, const char* theNodeAttribute);
+ /// Cleanups attribute from cache
bool cleanupAttribute(xmlNodePtr theNode, const char* theNodeAttribute);
+ /// Cleanups attribute from cache
bool cleanupAttribute(const char* theNodeName, const char* theNodeAttribute);
protected:
#include <map>
-/**\class ExchangePlugin_ExportFeature
+/**
+ * \class ExchangePlugin_ExportFeature
* \ingroup Plugins
* \brief Feature for export shapes to the external files in CAD formats.
*
class ExchangePlugin_ExportFeature : public ModelAPI_Feature
{
public:
+ /// Feature kind
inline static const std::string& ID()
{
static const std::string MY_EXPORT_ID("Export");
#include <map>
- /**\class ExchangePlugin_ImportFeature
+/**
+ * \class ExchangePlugin_ImportFeature
* \ingroup Plugins
* \brief Feature for import shapes from the external files in CAD formats.
*
class ExchangePlugin_ImportFeature : public ModelAPI_Feature
{
public:
- /// Extrusion kind
+ /// Feature kind
inline static const std::string& ID()
{
static const std::string MY_IMPORT_ID("Import");
#include <ModelAPI_Plugin.h>
#include <ModelAPI_Feature.h>
-/**\class ExchangePlugin_Plugin
+/**
+ * \class ExchangePlugin_Plugin
* \ingroup Plugins
* \brief The main class for management the import and export operations as plugin.
*/
#include <list>
#include <string>
-/**\class ExchangePlugin_Tools
+/**
+ * \class ExchangePlugin_Tools
* \ingroup Plugins
* \brief Internal tools for the plugin.
*/
#include "ExchangePlugin.h"
#include <ModelAPI_AttributeValidator.h>
-/**\class ExchangePlugin_ImportFormatValidator
+/**
+ * \class ExchangePlugin_FormatValidator
* \ingroup Validators
* \brief Validator for the imported formats checking
*
}
}
-void ParametersPlugin_EvalListener::renameInDependants(std::shared_ptr<ModelAPI_ResultParameter> theResultParameter,
+void ParametersPlugin_EvalListener::renameInDependents(std::shared_ptr<ModelAPI_ResultParameter> theResultParameter,
const std::string& theOldName,
const std::string& theNewName)
{
return;
}
- renameInDependants(aResultParameter, aMessage->oldName(), aMessage->newName());
+ renameInDependents(aResultParameter, aMessage->oldName(), aMessage->newName());
}
void ParametersPlugin_EvalListener::processReplaceParameterEvent(
double aRealValue = aResultParameter->data()->real(ModelAPI_ResultParameter::VALUE())->value();
std::string aValue = toStdString(aRealValue);
- renameInDependants(aResultParameter, aResultParameter->data()->name(), aValue);
+ renameInDependents(aResultParameter, aResultParameter->data()->name(), aValue);
}
class ParametersPlugin_Parameter;
class ParametersPlugin_PyInterp;
+/**
+ * \class ParametersPlugin_EvalListener
+ * \ingroup Plugins
+ * \brief Class which process the events from the event loop.
+ */
class ParametersPlugin_EvalListener : public Events_Listener
{
public:
PARAMETERSPLUGIN_EXPORT ParametersPlugin_EvalListener();
PARAMETERSPLUGIN_EXPORT virtual ~ParametersPlugin_EvalListener();
+ /// Reimplemented from Events_Listener::processEvent().
PARAMETERSPLUGIN_EXPORT virtual void processEvent(const std::shared_ptr<Events_Message>& theMessage);
protected:
+ /// Evaluates theExpression and returns its value.
double evaluate(const std::string& theExpression, std::string& theError,
const std::shared_ptr<ModelAPI_Document>& theDocument);
+ /// Processes Evaluation event.
void processEvaluationEvent(const std::shared_ptr<Events_Message>& theMessage);
+ /// Processes ObjectRenamed event.
void processObjectRenamedEvent(const std::shared_ptr<Events_Message>& theMessage);
+ /// Processes ReplaceParameter event.
void processReplaceParameterEvent(const std::shared_ptr<Events_Message>& theMessage);
+ /// Renames theOldName in theExpression by theNewName.
std::string renameInPythonExpression(const std::string& theExpression,
const std::string& theOldName,
const std::string& theNewName);
+ /// Renames theOldName in the expression attribute of theParameter by theNewName.
void renameInParameter(std::shared_ptr<ParametersPlugin_Parameter> theParameter,
const std::string& theOldName,
const std::string& theNewName);
+ /// Renames theOldName in the text fields of theAttribute by theNewName.
void renameInAttribute(std::shared_ptr<ModelAPI_Attribute> theAttribute,
const std::string& theOldName,
const std::string& theNewName);
- void renameInDependants(std::shared_ptr<ModelAPI_ResultParameter> theResultParameter,
+ /// Renames theOldName in all dependents of theResultParameter by theNewName.
+ void renameInDependents(std::shared_ptr<ModelAPI_ResultParameter> theResultParameter,
const std::string& theOldName,
const std::string& theNewName);
class ParametersPlugin_PyInterp;
+/**
+ * \class ParametersPlugin_Parameter
+ * \ingroup Plugins
+ * \brief Feature for parameter.
+ */
class ParametersPlugin_Parameter : public ModelAPI_Feature
{
public:
virtual ~ParametersPlugin_Parameter();
- /// Extrusion kind
+ /// Feature kind
inline static const std::string& ID()
{
static const std::string MY_PARAMETER_ID("Parameter");
return MY_PARAMETER_ID;
}
- /// attribute name of references sketch entities list, it should contain a sketch result or
- /// a pair a sketch result to sketch face
+ /// attribute of parameter name
inline static const std::string& VARIABLE_ID()
{
static const std::string MY_VARIABLE_ID("variable");
return MY_VARIABLE_ID;
}
-
- /// attribute name of extrusion size
+ /// attribute of parameter expression
inline static const std::string& EXPRESSION_ID()
{
static const std::string MY_EXPRESSION_ID("expression");
return MY_EXPRESSION_ID;
}
-
- /// attribute name of extrusion size
+ /// attribute of parameter expression error
inline static const std::string& EXPRESSION_ERROR_ID()
{
static const std::string MY_EXPRESSION_ERROR_ID("ExpressionError");
return MY_EXPRESSION_ERROR_ID;
}
-
/// list of references to the arguments of this expression
inline static const std::string& ARGUMENTS_ID()
{
ParametersPlugin_Parameter();
protected:
+ /// Evaluates theExpression and returns its value.
double evaluate(const std::string& theExpression, std::string& theError);
+ /// Update name of the parameter
void updateName();
+ /// Update expression of the parameter
void updateExpression();
private:
#include <ModelAPI_Plugin.h>
#include <ModelAPI_Feature.h>
-/**\class ParametersPlugin_Plugin
- * TODO: Add documentation
+/**
+ * \class ParametersPlugin_Plugin
+ * \ingroup Plugins
+ * \brief The main class for management of parameter evaluation operations as plugin.
*/
class ParametersPlugin_Plugin : public ModelAPI_Plugin
{
public:
ParametersPlugin_Plugin();
+ private:
std::shared_ptr<ParametersPlugin_EvalListener> myEvalListener;
};
// co_names should be tuple, but can be changed in modern versions of python (>2.7.3)
if(!PyTuple_Check(aCodeObj->co_names))
return aResult;
-
+
int params_size = PyTuple_Size(aCodeObj->co_names);
if (params_size > 0) {
for (int i = 0; i < params_size; i++) {
#include <string>
#include <utility>
+/**
+ * \class ParametersPlugin_PyInterp
+ * \ingroup Plugins
+ * \brief Helper class for using Python interpreter.
+ */
class PARAMETERSPLUGIN_EXPORT ParametersPlugin_PyInterp : public PyInterp_Interp
{
public:
ParametersPlugin_PyInterp();
virtual ~ParametersPlugin_PyInterp();
+ /// Returns a list of positions for theName in theExpression.
std::list<std::pair<int, int> > positions(const std::string& theExpression,
const std::string& theName);
- std::list<std::string> compile(const std::string&);
- void extendLocalContext(const std::list<std::string>&);
+ /// Compiles theExpression and returns a list of parameters from theExpression.
+ std::list<std::string> compile(const std::string& theExpression);
+ /// Extends local context with the list of parameters with values.
+ void extendLocalContext(const std::list<std::string>& theParameters);
+ /// Clears local context.
void clearLocalContext();
- double evaluate(const std::string&, std::string&);
+ /// Evaluates theExpression and returns its value.
+ double evaluate(const std::string& theExpression, std::string& theError);
protected:
+ /// Returns error message.
std::string errorMessage();
- // Overrides PyInterp_Interp
+ /// Overrides PyInterp_Interp.
virtual bool initContext();
+ /// Reimplemented from PyInterp_Interp::closeContext().
virtual void closeContext();
};
return true;
}
-bool ParametersPlugin_VariableValidator::isUnique(const AttributePtr& theAttribute,
+bool ParametersPlugin_VariableValidator::isUnique(const AttributePtr& theAttribute,
const std::string& theString) const
{
DocumentPtr aDocument = theAttribute->owner()->document();
#include <memory>
+/**
+ * \class ParametersPlugin_VariableValidator
+ * \ingroup Validators
+ * \brief Validator for the variable name of parameter.
+ */
class ParametersPlugin_VariableValidator : public ModelAPI_AttributeValidator
{
public:
//! returns true if attribute is valid
//! \param theAttribute the checked attribute
//! \param theArguments arguments of the attribute
+ //! \param theError the error string message if validation fails
PARAMETERSPLUGIN_EXPORT virtual bool isValid(const AttributePtr& theAttribute,
const std::list<std::string>& theArguments,
std::string& theError) const;
protected:
+ /// Returns true if theString is a variable name.
PARAMETERSPLUGIN_EXPORT bool isVariable(const std::string& theString) const;
- PARAMETERSPLUGIN_EXPORT bool isUnique(const AttributePtr& theAttribute,
+ /// Returns true if theString is unique parameter name for theAttribute context.
+ PARAMETERSPLUGIN_EXPORT bool isUnique(const AttributePtr& theAttribute,
const std::string& theString) const;
};
+/**
+ * \class ParametersPlugin_ExpressionValidator
+ * \ingroup Validators
+ * \brief Validator for the expression of parameter.
+ */
class ParametersPlugin_ExpressionValidator: public ModelAPI_AttributeValidator
{
public:
//! returns true if attribute is valid
//! \param theAttribute the checked attribute
//! \param theArguments arguments of the attribute
+ //! \param theError the error string message if validation fails
PARAMETERSPLUGIN_EXPORT virtual bool isValid(const AttributePtr& theAttribute,
const std::list<std::string>& theArguments,
std::string& theError) const;