Element mapper using QtScript to return a value for an element.
#include <Mesh/DataStructures/elementscriptmapper.h>
|
| ElementScriptMapper () |
|
| ElementScriptMapper (const ElementScriptMapper &mapper) |
|
| ~ElementScriptMapper () override |
|
ElementScriptMapper * | clone () const override |
|
Application::Memento::Data * | createMementoData (const MeshModelInterface &model, const ElementType::List &supportedElementTypes={ &ElementType::Tri::getInstance(), &ElementType::Quad::getInstance(), &ElementType::Tetrahedron::getInstance(), &ElementType::Hexahedron::getInstance() }) const override |
|
const QString & | getFunctionName () const |
|
const QString & | getScript () const |
|
double | getValue (const ElementType::Type &elementType, const ElementHandle &element, Application::Memento::Data &mementoData) const override |
|
ElementScriptMapper & | operator= (const ElementScriptMapper &mapper) |
|
void | setFunctionName (const QString &functionName) |
|
void | setScript (const QString &script) |
|
bool | canSerialize () const override |
|
ElementMapper * | clone () const override=0 |
|
virtual Application::Memento::Data * | createMementoData (const MeshModelInterface &model, const ElementType::List &supportedElementTypes={&ElementType::Tri::getInstance(), &ElementType::Quad::getInstance(), &ElementType::Tetrahedron::getInstance(), &ElementType::Hexahedron::getInstance()}) const =0 |
|
virtual double | getValue (const ElementType::Type &elementType, const ElementHandle &element, Application::Memento::Data &mementoData) const =0 |
|
virtual bool | getValueDataObject (const ElementType::Type &, const ElementHandle &, Application::Memento::Data &, DataExecution::DataObject *) const |
|
bool | load (const DataExecution::SerializedItem &item) override |
|
void | logText (const QString &msg) const |
|
bool | save (DataExecution::SerializedItem &item) const override |
|
virtual | ~Clonable ()=default |
|
virtual Clonable * | clone () const =0 |
|
virtual | ~Serialize ()=default |
|
virtual bool | canSerialize () const =0 |
|
virtual bool | load (const SerializedItem &item)=0 |
|
virtual bool | save (SerializedItem &item) const =0 |
|
◆ ElementScriptMapper() [1/2]
◆ ElementScriptMapper() [2/2]
◆ ~ElementScriptMapper()
◆ clone()
- Returns
- A clone of this object.
- Note
- Subclasses would normally return their own type rather than the Clonable type. The C++ language rules allow a more derived type to be returned from a virtual function and the compiler will still treat it as a valid override.
Implements ElementMapper.
◆ createMementoData()
◆ getFunctionName()
const QString & getFunctionName |
( |
| ) |
const |
- Returns
- The name of the function that will be called to map each node to a value.
The default function name is an empty string, however the convention is to use mapToValue
as the function name. The default is empty because it allows the script contents to be as trivial as possible. See setFunctionName() for more details on this issue.
- See also
- setFunctionName()
◆ getScript()
const QString & getScript |
( |
| ) |
const |
- Returns
- The script being used by the mapper.
- See also
- setScript()
◆ getValue()
- Parameters
-
elementType | The element type to be mapped to a value. |
element | The element to be mapped to a value. |
mementoData | The data from the memento created by a previous call to createMementoData(). It is used internally by this function to work out what value needs to be returned. |
- Returns
- The mapped value for the element. If mementoData is invalid, this function returns 0.
Implements ElementMapper.
◆ operator=()
◆ setFunctionName()
void setFunctionName |
( |
const QString & |
functionName | ) |
|
- Parameters
-
functionName | The name of the function to call to map each element to a value. |
The functionName should refer to a valid function defined in the script provided to the mapper. If it does not, an error will occur and the mapper will fail (and therefore return 0 for all values). The one exception to this is if functionName is empty. In this case, the contents of the script are assumed to be just the body of a function and the mapper should wrap it in its own function. This is not as clear, since the script still needs to have return statements but the script itself won't show what is being returned from. Still, some users may find this "feature" useful if their script contents are more or less trivial.
- See also
- getFunctionName()
◆ setScript()
void setScript |
( |
const QString & |
script | ) |
|
- Parameters
-
script | The script to use for the mapper. |
- See also
- getScript()