Commit 5f053eb6 authored by sblekout's avatar sblekout
Browse files

update of array scalar operator modifier node

parent f7824903
......@@ -147,7 +147,27 @@ dtkComposerFactory::dtkComposerFactory(void) : d(new dtkComposerFactoryPrivate)
d->descriptions["Scalar Array Insert"] = "<p>Description not yet filled!</p>";
d->tags["Scalar Array Insert"] = QStringList() << "container" << "array" << "scalar" << "insert" ;
d->types["Scalar Array Insert"] = "array_scalar_insert";
d->nodes << "Scalar Array Sum";
d->descriptions["Scalar Array Sum"] = "<p>Description not yet filled!</p>";
d->tags["Scalar Array Sum"] = QStringList() << "container" << "array" << "scalar" << "sum" ;
d->types["Scalar Array Sum"] = "array_scalar_sum";
d->nodes << "Scalar Array Substract";
d->descriptions["Scalar Array Substract"] = "<p>Description not yet filled!</p>";
d->tags["Scalar Array Substract"] = QStringList() << "container" << "array" << "scalar" << "substract" ;
d->types["Scalar Array Substract"] = "array_scalar_substract";
d->nodes << "Scalar Array Mult";
d->descriptions["Scalar Array Mult"] = "<p>Description not yet filled!</p>";
d->tags["Scalar Array Mult"] = QStringList() << "container" << "array" << "scalar" << "mult" ;
d->types["Scalar Array Mult"] = "array_scalar_mult" ;
d->nodes << "Scalar Array Divide";
d->descriptions["Scalar Array Divide"] = "<p>Description not yet filled!</p>";
d->tags["Scalar Array Divide"] = QStringList() << "container" << "array" << "scalar" << "divide" ;
d->types["Scalar Array Divide"] = "array_scalar_divide" ;
// Algebraic nodes
d->nodes << "Vector3D";
......@@ -671,6 +691,18 @@ dtkComposerNode *dtkComposerFactory::create(const QString& type)
if(type == "array_scalar_insert")
return new dtkComposerNodeArrayScalarOperatorInsert;
if(type == "array_scalar_sum")
return new dtkComposerNodeArrayScalarOperatorSum;
if(type == "array_scalar_substract")
return new dtkComposerNodeArrayScalarOperatorSubstract;
if(type == "array_scalar_mult")
return new dtkComposerNodeArrayScalarOperatorMult;
if(type == "array_scalar_divide")
return new dtkComposerNodeArrayScalarOperatorDivide;
// algebraic nodes
if(type == "vector3D")
......
......@@ -17,14 +17,12 @@
*
*/
#include "dtkComposerNodeArrayScalarOperatorModifier.h"
#include "dtkComposerTransmitterEmitter.h"
#include "dtkComposerTransmitterReceiver.h"
#include "dtkComposerNodeArrayScalarOperatorModifier.h"
#include <dtkCore/dtkContainerVector.h>
// /////////////////////////////////////////////////////////////////
// dtkComposerNodearrayScalarOperatorBinary
// /////////////////////////////////////////////////////////////////
......@@ -57,10 +55,10 @@ dtkComposerNodeArrayScalarOperatorModifier::~dtkComposerNodeArrayScalarOperatorM
d = NULL;
}
// /////////////////////////////////////////////////////////////////
// dtkComposerNodeArrayScalarOperator - Insert
// dtkComposerNodeArrayScalarOperator - INSERT
// /////////////////////////////////////////////////////////////////
void dtkComposerNodeArrayScalarOperatorInsert::run(void)
{
dtkContainerVectorReal array;
......@@ -70,7 +68,90 @@ void dtkComposerNodeArrayScalarOperatorInsert::run(void)
array.vector().insert(d->receiver_index.data(), d->receiver_value.data());
}
d->emitter_array.setVector(array);
}
// /////////////////////////////////////////////////////////////////
// dtkComposerNodeArrayScalarOperator - SUM
// /////////////////////////////////////////////////////////////////
void dtkComposerNodeArrayScalarOperatorSum::run(void)
{
dtkContainerVectorReal array;
if (!d->receiver_array.isEmpty()) {
array = d->receiver_array.vector();
array.vector()[d->receiver_index.data()] += d->receiver_value.data();
}
d->emitter_array.setVector(array);
}
// /////////////////////////////////////////////////////////////////
// dtkComposerNodeArrayScalarOperator - Substract
// /////////////////////////////////////////////////////////////////
void dtkComposerNodeArrayScalarOperatorSubstract::run(void)
{
dtkContainerVectorReal array;
if (!d->receiver_array.isEmpty()) {
array = d->receiver_array.vector();
array.vector()[d->receiver_index.data()] -= d->receiver_value.data();
}
d->emitter_array.setVector(array);
// dtkContainerVectorReal temp = d->emitter_array.vector();
//qDebug() << temp.vector();
}
// /////////////////////////////////////////////////////////////////
// dtkComposerNodeArrayScalarOperator - Mult
// /////////////////////////////////////////////////////////////////
void dtkComposerNodeArrayScalarOperatorMult::run(void)
{
dtkContainerVectorReal array;
if (!d->receiver_array.isEmpty()) {
array = d->receiver_array.vector();
array.vector()[d->receiver_index.data()] *= d->receiver_value.data();
}
d->emitter_array.setVector(array);
}
// /////////////////////////////////////////////////////////////////
// dtkComposerNodeArrayScalarOperator - Divide
// /////////////////////////////////////////////////////////////////
void dtkComposerNodeArrayScalarOperatorDivide::run(void)
{
dtkContainerVectorReal array;
if (!d->receiver_array.isEmpty()) {
array = d->receiver_array.vector();
array.vector()[d->receiver_index.data()] /= d->receiver_value.data();
}
d->emitter_array.setVector(array);
}
......@@ -28,13 +28,12 @@
// dtkComposerNodeArrayScalarOperatorModifier interface
// /////////////////////////////////////////////////////////////////
class dtkComposerNodeArrayScalarOperatorModifierPrivate;
class DTKCOMPOSER_EXPORT dtkComposerNodeArrayScalarOperatorModifier : public dtkComposerNodeLeaf
{
public:
dtkComposerNodeArrayScalarOperatorModifier(void);
dtkComposerNodeArrayScalarOperatorModifier(void);
~dtkComposerNodeArrayScalarOperatorModifier(void);
public:
......@@ -55,10 +54,8 @@ protected:
dtkComposerNodeArrayScalarOperatorModifierPrivate *d;
};
// /////////////////////////////////////////////////////////////////
// dtkComposerNodeArrayScalarOperator - insert
// dtkComposerNodeArrayScalarOperator - INSERT
// /////////////////////////////////////////////////////////////////
class DTKCOMPOSER_EXPORT dtkComposerNodeArrayScalarOperatorInsert : public dtkComposerNodeArrayScalarOperatorModifier
......@@ -76,5 +73,80 @@ public:
}
};
// /////////////////////////////////////////////////////////////////
// dtkComposerNodeArrayScalarOperator - SUM
// /////////////////////////////////////////////////////////////////
class DTKCOMPOSER_EXPORT dtkComposerNodeArrayScalarOperatorSum : public dtkComposerNodeArrayScalarOperatorModifier
{
public:
void run(void);
public:
inline QString type(void) {
return "array_scalar_sum";
}
inline QString titleHint(void) {
return "Scalar array sum";
}
};
// /////////////////////////////////////////////////////////////////
// dtkComposerNodeArrayScalarOperator - Substract
// /////////////////////////////////////////////////////////////////
class DTKCOMPOSER_EXPORT dtkComposerNodeArrayScalarOperatorSubstract : public dtkComposerNodeArrayScalarOperatorModifier
{
public:
void run(void);
public:
inline QString type(void) {
return "array_scalar_substract";
}
inline QString titleHint(void) {
return "Scalar array substract";
}
};
// /////////////////////////////////////////////////////////////////
// dtkComposerNodeArrayScalarOperator - Mult
// /////////////////////////////////////////////////////////////////
class DTKCOMPOSER_EXPORT dtkComposerNodeArrayScalarOperatorMult : public dtkComposerNodeArrayScalarOperatorModifier
{
public:
void run(void);
public:
inline QString type(void) {
return "array_scalar_mult";
}
inline QString titleHint(void) {
return "Scalar array mult";
}
};
// /////////////////////////////////////////////////////////////////
// dtkComposerNodeArrayScalarOperator - Divide
// /////////////////////////////////////////////////////////////////
class DTKCOMPOSER_EXPORT dtkComposerNodeArrayScalarOperatorDivide : public dtkComposerNodeArrayScalarOperatorModifier
{
public:
void run(void);
public:
inline QString type(void) {
return "array_scalar_divide";
}
inline QString titleHint(void) {
return "Scalar array divide";
}
};
#endif
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment