CTL
0.6.1
Computed Tomography Library
|
The AbstractDataModel2D class is the base class for two-dimensional data models. More...
#include <abstractdatamodel2d.h>
Public Types | |
enum | { Type = 1000 } |
![]() | |
enum | { Type = -1, UserType = 65536 } |
Public Member Functions | |
int | type () const override |
virtual float | valueAt (float x, float y) const =0 |
virtual AbstractDataModel2D * | clone () const =0 |
virtual QVariant | parameter () const |
virtual void | setParameter (const QVariant ¶meter) |
void | setParameter (const QString &name, const QVariant &value) |
void | fromVariant (const QVariant &variant) override |
QVariant | toVariant () const override |
QString | name () const |
void | setName (const QString &name) |
Chunk2D< float > | sampleChunk (const SamplingRange &xRange, const SamplingRange &yRange, uint nbSamplesX, uint nbSamplesY) const |
![]() | |
virtual | ~SerializationInterface ()=default |
Protected Member Functions | |
AbstractDataModel2D (const AbstractDataModel2D &)=default | |
AbstractDataModel2D (AbstractDataModel2D &&)=default | |
AbstractDataModel2D & | operator= (const AbstractDataModel2D &)=default |
AbstractDataModel2D & | operator= (AbstractDataModel2D &&)=default |
![]() | |
SerializationInterface ()=default | |
SerializationInterface (const SerializationInterface &)=default | |
SerializationInterface (SerializationInterface &&)=default | |
SerializationInterface & | operator= (const SerializationInterface &)=default |
SerializationInterface & | operator= (SerializationInterface &&)=default |
Private Attributes | |
QString | _name |
Friends | |
template<class > | |
struct | SerializationHelper::RegisterWithSerializationHelper |
Related Functions | |
(Note that these are not member functions.) | |
std::shared_ptr< AbstractDataModel2D > | operator+ (std::shared_ptr< AbstractDataModel2D > lhs, std::shared_ptr< AbstractDataModel2D > rhs) |
std::shared_ptr< AbstractDataModel2D > | operator- (std::shared_ptr< AbstractDataModel2D > lhs, std::shared_ptr< AbstractDataModel2D > rhs) |
std::shared_ptr< AbstractDataModel2D > | operator * (std::shared_ptr< AbstractDataModel2D > lhs, std::shared_ptr< AbstractDataModel2D > rhs) |
std::shared_ptr< AbstractDataModel2D > | operator/ (std::shared_ptr< AbstractDataModel2D > lhs, std::shared_ptr< AbstractDataModel2D > rhs) |
std::shared_ptr< AbstractDataModel2D > & | operator+= (std::shared_ptr< AbstractDataModel2D > &lhs, const std::shared_ptr< AbstractDataModel2D > &rhs) |
std::shared_ptr< AbstractDataModel2D > & | operator-= (std::shared_ptr< AbstractDataModel2D > &lhs, const std::shared_ptr< AbstractDataModel2D > &rhs) |
std::shared_ptr< AbstractDataModel2D > & | operator *= (std::shared_ptr< AbstractDataModel2D > &lhs, const std::shared_ptr< AbstractDataModel2D > &rhs) |
std::shared_ptr< AbstractDataModel2D > & | operator/= (std::shared_ptr< AbstractDataModel2D > &lhs, const std::shared_ptr< AbstractDataModel2D > &rhs) |
The AbstractDataModel2D class is the base class for two-dimensional data models.
A two-dimensional data model represents data on a 2D grid, i.e. given a tuple of x and y coordinates, it provides a well-defined value. Sub-classes must implement the method to sample a value at a given position (valueAt()), as well as a clone() method.
Data from the model can also be sampled in a structured pattern using sampleChunk(), which samples values on an equidistantly-spaced 2D grid and returns data as a Chunk2D.
Models can have parameters specifying their specific properties. Parameters can be set by passing a QVariant that contains all necessary information. Re-implement the setParameter() method to parse the QVariant into your required format (i.e. extract relevant information) within sub-classes of AbstractDataModel2D.
To enable de-/serialization of sub-class objects, also reimplement the parameter() method such that it stores all parameters of the model in a QVariant. The resulting QVariant should be fully compatible with setParameter() in the sense that setParameter(parameter()) does not change the objects properties. Additionally, call the macro DECLARE_SERIALIZABLE_TYPE(YourNewClassName) within the .cpp file of your new class (substitute "YourNewClassName" with the actual class name). Objects of the new class can then be de-/serialized with any of the serializer classes (see also AbstractSerializer).
Alternatively, the de-/serialization interface methods toVariant() and fromVariant() can be reimplemented directly. This might be required in some specific situations (usually when polymorphic class members are in use). For the majority of cases, using the parameter() / setParameter() approach should be sufficient and is recommended.
|
overridevirtual |
Interface to read all member variables from the QVariant variant.
Reimplement this method such that it reads all newly introduced content when sub-classing. A typical reimplementation in sub-classes might look like this:
Reimplemented from CTL::SerializationInterface.
|
virtual |
Returns the parameters of this model as a QVariant.
Default implementation returns an empty QVariant. Override in custom classes to encode all relevant information from the class' members. The returned QVariant must contain all information to fully specify the objects state. In particular, calling setParameter(parameter()) should not change the state of an object.
Reimplemented in CTL::AbstractDataModel2DOperation, CTL::SeparableProductModel, CTL::RectModel2D, CTL::GaussianModel2D, and CTL::ConstantModel2D.
Chunk2D< float > CTL::AbstractDataModel2D::sampleChunk | ( | const SamplingRange & | xRange, |
const SamplingRange & | yRange, | ||
uint | nbSamplesX, | ||
uint | nbSamplesY | ||
) | const |
Samples values from this model on an equidistantly-spaced 2D grid and returns data as a Chunk2D. The grid will cover the range specified by xRange and yRange with nbSamplesX and nbSamplesY sampling points, respectively.
|
virtual |
Sets the parameters of this model based on data held in parameter.
Default implementation does nothing. Override in custom classes to extract all relevant information from parameter and set class members accordingly. A call to this method (given an appropriate input parameter) should prepare the full state of the object. In particular, calling setParameter(parameter()) should not change the state of an object.
Reimplemented in CTL::AbstractDataModel2DOperation, CTL::SeparableProductModel, CTL::RectModel2D, CTL::GaussianModel2D, and CTL::ConstantModel2D.
void CTL::AbstractDataModel2D::setParameter | ( | const QString & | name, |
const QVariant & | value | ||
) |
Sets the parameter with tag name to value, by passing a QVariantMap containing only the name, value pair as its sole entry to setParameter(const QVariant&).
This method is only useful if setParameter(const QVariant&) is implemented in a way that it allows for individual parameters to be set if the QVariant passed to it does only contain a selection of parameters. When overriding setParameter(const QVariant&) in custom classes, this method will be shadowed. In case you implemented setParameter(const QVariant&) in the way described above (i.e. such that setting individual parameters is possible), re-enable this method in the sub-class via
.
|
overridevirtual |
Interface to store all member variables in a QVariant.
Stores the object's type-id.
Reimplement this method such that it stores all newly introduced object data when sub-classing. This needs to cover everything that is necessary to fully determine the state of an object. Best practice is to invoke the base class version of this method to take care of all content originating from underlying base classes.
A typical reimplementation in sub-classes might look like this:
Reimplemented from CTL::SerializationInterface.
Reimplemented in CTL::SeparableProductModel, CTL::RectModel2D, CTL::GaussianModel2D, and CTL::ConstantModel2D.
|
inlineoverridevirtual |
Returns the type-id of the serializable object. Used in deserialization to determine the proper object type.
Add derived classes to the enumeration using the CTL_TYPE_ID macro.
Reimplemented from CTL::SerializationInterface.
Reimplemented in CTL::DataModel2DDiv, CTL::DataModel2DMul, CTL::DataModel2DSub, CTL::DataModel2DAdd, CTL::SeparableProductModel, CTL::RectModel2D, CTL::GaussianModel2D, and CTL::ConstantModel2D.
|
related |
Creates a data model that represents the product of lhs and rhs in the sense that, when requesting a value from the resulting model at position (x, y), the returned value will be the product of the individually sampled values of each model, i.e.:
.
Note that you will no longer be able to modify the parameters of any of the two input models based on the returned 'product'-model.
|
related |
Replaces lhs by a 'product'-model of lhs * rhs.
See CTL::operator*(std::shared_ptr<AbstractDataModel2D>, std::shared_ptr<AbstractDataModel2D>) for more details.
|
related |
Creates a data model that represents the sum of lhs and rhs in the sense that, when requesting a value from the resulting model at position (x, y), the returned value will be the sum of the individually sampled values of each model, i.e.:
.
Note that you will no longer be able to modify the parameters of any of the two input models based on the returned 'sum'-model.
|
related |
Replaces lhs by a 'sum'-model of lhs + rhs.
See CTL::operator+(std::shared_ptr<AbstractDataModel2D>, std::shared_ptr<AbstractDataModel2D>) for more details.
|
related |
Creates a data model that represents the difference of lhs and rhs in the sense that, when requesting a value from the resulting model at position (x, y), the returned value will be the difference of the individually sampled values of each model, i.e.:
.
Note that you will no longer be able to modify the parameters of any of the two input models based on the returned 'difference'-model.
|
related |
Replaces lhs by a 'difference'-model of lhs - rhs.
See CTL::operator-(std::shared_ptr<AbstractDataModel2D>, std::shared_ptr<AbstractDataModel2D>) for more details.
|
related |
Creates a data model that represents the quotient of lhs and rhs in the sense that, when requesting a value from the resulting model at position (x, y), the returned value will be the quotient of the individually sampled values of each model, i.e.:
.
Note that you will no longer be able to modify the parameters of any of the two input models based on the returned 'quotient'-model.
|
related |
Replaces lhs by a 'quotient'-model of lhs / rhs.
See CTL::operator/(std::shared_ptr<AbstractDataModel2D>, std::shared_ptr<AbstractDataModel2D>) for more details.