change: change code style to Linux style except indent.
This commit is contained in:
+53
-52
@@ -20,7 +20,8 @@
|
||||
|
||||
#include "math.h"
|
||||
|
||||
namespace olive {
|
||||
namespace olive
|
||||
{
|
||||
|
||||
const QString MathNode::kMethodIn = QStringLiteral("method_in");
|
||||
const QString MathNode::kParamAIn = QStringLiteral("param_a_in");
|
||||
@@ -31,95 +32,95 @@ const QString MathNode::kParamCIn = QStringLiteral("param_c_in");
|
||||
|
||||
MathNode::MathNode()
|
||||
{
|
||||
AddInput(kMethodIn, NodeValue::kCombo, InputFlags(kInputFlagNotConnectable | kInputFlagNotKeyframable));
|
||||
AddInput(kMethodIn, NodeValue::kCombo,
|
||||
InputFlags(kInputFlagNotConnectable | kInputFlagNotKeyframable));
|
||||
|
||||
AddInput(kParamAIn, NodeValue::kFloat, 0.0);
|
||||
SetInputProperty(kParamAIn, QStringLiteral("decimalplaces"), 8);
|
||||
SetInputProperty(kParamAIn, QStringLiteral("autotrim"), true);
|
||||
AddInput(kParamAIn, NodeValue::kFloat, 0.0);
|
||||
SetInputProperty(kParamAIn, QStringLiteral("decimalplaces"), 8);
|
||||
SetInputProperty(kParamAIn, QStringLiteral("autotrim"), true);
|
||||
|
||||
AddInput(kParamBIn, NodeValue::kFloat, 0.0);
|
||||
SetInputProperty(kParamBIn, QStringLiteral("decimalplaces"), 8);
|
||||
SetInputProperty(kParamBIn, QStringLiteral("autotrim"), true);
|
||||
AddInput(kParamBIn, NodeValue::kFloat, 0.0);
|
||||
SetInputProperty(kParamBIn, QStringLiteral("decimalplaces"), 8);
|
||||
SetInputProperty(kParamBIn, QStringLiteral("autotrim"), true);
|
||||
}
|
||||
|
||||
QString MathNode::Name() const
|
||||
{
|
||||
// Default to naming after the operation
|
||||
if (parent()) {
|
||||
QString op_name = GetOperationName(GetOperation());
|
||||
if (!op_name.isEmpty()) {
|
||||
return op_name;
|
||||
}
|
||||
}
|
||||
// Default to naming after the operation
|
||||
if (parent()) {
|
||||
QString op_name = GetOperationName(GetOperation());
|
||||
if (!op_name.isEmpty()) {
|
||||
return op_name;
|
||||
}
|
||||
}
|
||||
|
||||
return tr("Math");
|
||||
return tr("Math");
|
||||
}
|
||||
|
||||
QString MathNode::id() const
|
||||
{
|
||||
return QStringLiteral("org.olivevideoeditor.Olive.math");
|
||||
return QStringLiteral("org.olivevideoeditor.Olive.math");
|
||||
}
|
||||
|
||||
QVector<Node::CategoryID> MathNode::Category() const
|
||||
{
|
||||
return {kCategoryMath};
|
||||
return { kCategoryMath };
|
||||
}
|
||||
|
||||
QString MathNode::Description() const
|
||||
{
|
||||
return tr("Perform a mathematical operation between two values.");
|
||||
return tr("Perform a mathematical operation between two values.");
|
||||
}
|
||||
|
||||
void MathNode::Retranslate()
|
||||
{
|
||||
super::Retranslate();
|
||||
super::Retranslate();
|
||||
|
||||
SetInputName(kMethodIn, tr("Method"));
|
||||
SetInputName(kParamAIn, tr("Value"));
|
||||
SetInputName(kParamBIn, tr("Value"));
|
||||
SetInputName(kMethodIn, tr("Method"));
|
||||
SetInputName(kParamAIn, tr("Value"));
|
||||
SetInputName(kParamBIn, tr("Value"));
|
||||
|
||||
QStringList operations = {GetOperationName(kOpAdd),
|
||||
GetOperationName(kOpSubtract),
|
||||
GetOperationName(kOpMultiply),
|
||||
GetOperationName(kOpDivide),
|
||||
QString(),
|
||||
GetOperationName(kOpPower)};
|
||||
QStringList operations = { GetOperationName(kOpAdd),
|
||||
GetOperationName(kOpSubtract),
|
||||
GetOperationName(kOpMultiply),
|
||||
GetOperationName(kOpDivide),
|
||||
QString(),
|
||||
GetOperationName(kOpPower) };
|
||||
|
||||
SetComboBoxStrings(kMethodIn, operations);
|
||||
SetComboBoxStrings(kMethodIn, operations);
|
||||
}
|
||||
|
||||
ShaderCode MathNode::GetShaderCode(const ShaderRequest &request) const
|
||||
{
|
||||
return GetShaderCodeInternal(request.id, kParamAIn, kParamBIn);
|
||||
return GetShaderCodeInternal(request.id, kParamAIn, kParamBIn);
|
||||
}
|
||||
|
||||
void MathNode::Value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const
|
||||
void MathNode::Value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
NodeValueTable *table) const
|
||||
{
|
||||
// Auto-detect what values to operate with
|
||||
// FIXME: Very inefficient
|
||||
NodeValueTable at, bt;
|
||||
at.Push(value[kParamAIn]);
|
||||
bt.Push(value[kParamBIn]);
|
||||
PairingCalculator calc(at, bt);
|
||||
// Auto-detect what values to operate with
|
||||
// FIXME: Very inefficient
|
||||
NodeValueTable at, bt;
|
||||
at.Push(value[kParamAIn]);
|
||||
bt.Push(value[kParamBIn]);
|
||||
PairingCalculator calc(at, bt);
|
||||
|
||||
// Do nothing if no pairing was found
|
||||
if (!calc.FoundMostLikelyPairing()) {
|
||||
return;
|
||||
}
|
||||
// Do nothing if no pairing was found
|
||||
if (!calc.FoundMostLikelyPairing()) {
|
||||
return;
|
||||
}
|
||||
|
||||
return ValueInternal(GetOperation(),
|
||||
calc.GetMostLikelyPairing(),
|
||||
kParamAIn,
|
||||
calc.GetMostLikelyValueA(),
|
||||
kParamBIn,
|
||||
calc.GetMostLikelyValueB(),
|
||||
globals,
|
||||
table);
|
||||
return ValueInternal(GetOperation(), calc.GetMostLikelyPairing(), kParamAIn,
|
||||
calc.GetMostLikelyValueA(), kParamBIn,
|
||||
calc.GetMostLikelyValueB(), globals, table);
|
||||
}
|
||||
|
||||
void MathNode::ProcessSamples(const NodeValueRow &values, const SampleBuffer &input, SampleBuffer &output, int index) const
|
||||
void MathNode::ProcessSamples(const NodeValueRow &values,
|
||||
const SampleBuffer &input, SampleBuffer &output,
|
||||
int index) const
|
||||
{
|
||||
return ProcessSamplesInternal(values, GetOperation(), kParamAIn, kParamBIn, input, output, index);
|
||||
return ProcessSamplesInternal(values, GetOperation(), kParamAIn, kParamBIn,
|
||||
input, output, index);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+30
-27
@@ -23,44 +23,47 @@
|
||||
|
||||
#include "mathbase.h"
|
||||
|
||||
namespace olive {
|
||||
|
||||
class MathNode : public MathNodeBase
|
||||
namespace olive
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
class MathNode : public MathNodeBase {
|
||||
Q_OBJECT
|
||||
public:
|
||||
MathNode();
|
||||
MathNode();
|
||||
|
||||
NODE_DEFAULT_FUNCTIONS(MathNode)
|
||||
NODE_DEFAULT_FUNCTIONS(MathNode)
|
||||
|
||||
virtual QString Name() const override;
|
||||
virtual QString id() const override;
|
||||
virtual QVector<CategoryID> Category() const override;
|
||||
virtual QString Description() const override;
|
||||
virtual QString Name() const override;
|
||||
virtual QString id() const override;
|
||||
virtual QVector<CategoryID> Category() const override;
|
||||
virtual QString Description() const override;
|
||||
|
||||
virtual void Retranslate() override;
|
||||
virtual void Retranslate() override;
|
||||
|
||||
virtual ShaderCode GetShaderCode(const ShaderRequest &request) const override;
|
||||
virtual ShaderCode
|
||||
GetShaderCode(const ShaderRequest &request) const override;
|
||||
|
||||
Operation GetOperation() const
|
||||
{
|
||||
return static_cast<Operation>(GetStandardValue(kMethodIn).toInt());
|
||||
}
|
||||
Operation GetOperation() const
|
||||
{
|
||||
return static_cast<Operation>(GetStandardValue(kMethodIn).toInt());
|
||||
}
|
||||
|
||||
void SetOperation(Operation o)
|
||||
{
|
||||
SetStandardValue(kMethodIn, o);
|
||||
}
|
||||
void SetOperation(Operation o)
|
||||
{
|
||||
SetStandardValue(kMethodIn, o);
|
||||
}
|
||||
|
||||
virtual void Value(const NodeValueRow& value, const NodeGlobals &globals, NodeValueTable *table) const override;
|
||||
virtual void Value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
NodeValueTable *table) const override;
|
||||
|
||||
virtual void ProcessSamples(const NodeValueRow &values, const SampleBuffer &input, SampleBuffer &output, int index) const override;
|
||||
|
||||
static const QString kMethodIn;
|
||||
static const QString kParamAIn;
|
||||
static const QString kParamBIn;
|
||||
static const QString kParamCIn;
|
||||
virtual void ProcessSamples(const NodeValueRow &values,
|
||||
const SampleBuffer &input, SampleBuffer &output,
|
||||
int index) const override;
|
||||
|
||||
static const QString kMethodIn;
|
||||
static const QString kParamAIn;
|
||||
static const QString kParamBIn;
|
||||
static const QString kParamCIn;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
+586
-503
File diff suppressed because it is too large
Load Diff
@@ -23,108 +23,116 @@
|
||||
|
||||
#include "node/node.h"
|
||||
|
||||
namespace olive {
|
||||
|
||||
class MathNodeBase : public Node
|
||||
namespace olive
|
||||
{
|
||||
|
||||
class MathNodeBase : public Node {
|
||||
public:
|
||||
MathNodeBase() = default;
|
||||
MathNodeBase() = default;
|
||||
|
||||
enum Operation {
|
||||
kOpAdd,
|
||||
kOpSubtract,
|
||||
kOpMultiply,
|
||||
kOpDivide,
|
||||
kOpPower
|
||||
};
|
||||
enum Operation { kOpAdd, kOpSubtract, kOpMultiply, kOpDivide, kOpPower };
|
||||
|
||||
static QString GetOperationName(Operation o);
|
||||
static QString GetOperationName(Operation o);
|
||||
|
||||
protected:
|
||||
enum Pairing {
|
||||
kPairNone = -1,
|
||||
enum Pairing {
|
||||
kPairNone = -1,
|
||||
|
||||
kPairNumberNumber,
|
||||
kPairVecVec,
|
||||
kPairMatrixMatrix,
|
||||
kPairColorColor,
|
||||
kPairTextureTexture,
|
||||
kPairNumberNumber,
|
||||
kPairVecVec,
|
||||
kPairMatrixMatrix,
|
||||
kPairColorColor,
|
||||
kPairTextureTexture,
|
||||
|
||||
kPairVecNumber,
|
||||
kPairMatrixVec,
|
||||
kPairNumberColor,
|
||||
kPairTextureNumber,
|
||||
kPairTextureColor,
|
||||
kPairTextureMatrix,
|
||||
kPairSampleSample,
|
||||
kPairSampleNumber,
|
||||
kPairVecNumber,
|
||||
kPairMatrixVec,
|
||||
kPairNumberColor,
|
||||
kPairTextureNumber,
|
||||
kPairTextureColor,
|
||||
kPairTextureMatrix,
|
||||
kPairSampleSample,
|
||||
kPairSampleNumber,
|
||||
|
||||
kPairCount
|
||||
};
|
||||
kPairCount
|
||||
};
|
||||
|
||||
class PairingCalculator {
|
||||
public:
|
||||
PairingCalculator(const NodeValueTable &table_a, const NodeValueTable &table_b);
|
||||
class PairingCalculator {
|
||||
public:
|
||||
PairingCalculator(const NodeValueTable &table_a,
|
||||
const NodeValueTable &table_b);
|
||||
|
||||
bool FoundMostLikelyPairing() const;
|
||||
Pairing GetMostLikelyPairing() const;
|
||||
bool FoundMostLikelyPairing() const;
|
||||
Pairing GetMostLikelyPairing() const;
|
||||
|
||||
const NodeValue& GetMostLikelyValueA() const;
|
||||
const NodeValue& GetMostLikelyValueB() const;
|
||||
const NodeValue &GetMostLikelyValueA() const;
|
||||
const NodeValue &GetMostLikelyValueB() const;
|
||||
|
||||
private:
|
||||
static QVector<int> GetPairLikelihood(const NodeValueTable& table);
|
||||
private:
|
||||
static QVector<int> GetPairLikelihood(const NodeValueTable &table);
|
||||
|
||||
Pairing most_likely_pairing_;
|
||||
Pairing most_likely_pairing_;
|
||||
|
||||
NodeValue most_likely_value_a_;
|
||||
NodeValue most_likely_value_a_;
|
||||
|
||||
NodeValue most_likely_value_b_;
|
||||
NodeValue most_likely_value_b_;
|
||||
};
|
||||
|
||||
};
|
||||
template <typename T, typename U>
|
||||
static T PerformAll(Operation operation, T a, U b);
|
||||
|
||||
template<typename T, typename U>
|
||||
static T PerformAll(Operation operation, T a, U b);
|
||||
template <typename T, typename U>
|
||||
static T PerformMultDiv(Operation operation, T a, U b);
|
||||
|
||||
template<typename T, typename U>
|
||||
static T PerformMultDiv(Operation operation, T a, U b);
|
||||
template <typename T, typename U>
|
||||
static T PerformAddSub(Operation operation, T a, U b);
|
||||
|
||||
template<typename T, typename U>
|
||||
static T PerformAddSub(Operation operation, T a, U b);
|
||||
template <typename T, typename U>
|
||||
static T PerformMult(Operation operation, T a, U b);
|
||||
|
||||
template<typename T, typename U>
|
||||
static T PerformMult(Operation operation, T a, U b);
|
||||
template <typename T, typename U>
|
||||
static T PerformAddSubMult(Operation operation, T a, U b);
|
||||
|
||||
template<typename T, typename U>
|
||||
static T PerformAddSubMult(Operation operation, T a, U b);
|
||||
template <typename T, typename U>
|
||||
static T PerformAddSubMultDiv(Operation operation, T a, U b);
|
||||
|
||||
template<typename T, typename U>
|
||||
static T PerformAddSubMultDiv(Operation operation, T a, U b);
|
||||
|
||||
static void PerformAllOnFloatBuffer(Operation operation, float *a, float b, int start, int end);
|
||||
static void PerformAllOnFloatBuffer(Operation operation, float *a, float b,
|
||||
int start, int end);
|
||||
|
||||
#if defined(Q_PROCESSOR_X86) || defined(Q_PROCESSOR_ARM)
|
||||
static void PerformAllOnFloatBufferSSE(Operation operation, float *a, float b, int start, int end);
|
||||
static void PerformAllOnFloatBufferSSE(Operation operation, float *a,
|
||||
float b, int start, int end);
|
||||
#endif
|
||||
|
||||
static QString GetShaderUniformType(const NodeValue::Type& type);
|
||||
static QString GetShaderUniformType(const NodeValue::Type &type);
|
||||
|
||||
static QString GetShaderVariableCall(const QString& input_id, const NodeValue::Type& type, const QString &coord_op = QString());
|
||||
static QString GetShaderVariableCall(const QString &input_id,
|
||||
const NodeValue::Type &type,
|
||||
const QString &coord_op = QString());
|
||||
|
||||
static QVector4D RetrieveVector(const NodeValue& val);
|
||||
static QVector4D RetrieveVector(const NodeValue &val);
|
||||
|
||||
static float RetrieveNumber(const NodeValue& val);
|
||||
static float RetrieveNumber(const NodeValue &val);
|
||||
|
||||
static bool NumberIsNoOp(const Operation& op, const float& number);
|
||||
static bool NumberIsNoOp(const Operation &op, const float &number);
|
||||
|
||||
ShaderCode GetShaderCodeInternal(const QString &shader_id, const QString ¶m_a_in, const QString ¶m_b_in) const;
|
||||
ShaderCode GetShaderCodeInternal(const QString &shader_id,
|
||||
const QString ¶m_a_in,
|
||||
const QString ¶m_b_in) const;
|
||||
|
||||
void PushVector(NodeValueTable* output, NodeValue::Type type, const QVector4D& vec) const;
|
||||
void PushVector(NodeValueTable *output, NodeValue::Type type,
|
||||
const QVector4D &vec) const;
|
||||
|
||||
void ValueInternal(Operation operation, Pairing pairing, const QString& param_a_in, const NodeValue &val_a, const QString& param_b_in, const NodeValue& val_b, const NodeGlobals &globals, NodeValueTable *output) const;
|
||||
|
||||
void ProcessSamplesInternal(const NodeValueRow &values, Operation operation, const QString& param_a_in, const QString& param_b_in, const SampleBuffer &input, SampleBuffer &output, int index) const;
|
||||
void ValueInternal(Operation operation, Pairing pairing,
|
||||
const QString ¶m_a_in, const NodeValue &val_a,
|
||||
const QString ¶m_b_in, const NodeValue &val_b,
|
||||
const NodeGlobals &globals,
|
||||
NodeValueTable *output) const;
|
||||
|
||||
void ProcessSamplesInternal(const NodeValueRow &values, Operation operation,
|
||||
const QString ¶m_a_in,
|
||||
const QString ¶m_b_in,
|
||||
const SampleBuffer &input, SampleBuffer &output,
|
||||
int index) const;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -22,7 +22,8 @@
|
||||
|
||||
#include "node/traverser.h"
|
||||
|
||||
namespace olive {
|
||||
namespace olive
|
||||
{
|
||||
|
||||
const QString MergeNode::kBaseIn = QStringLiteral("base_in");
|
||||
const QString MergeNode::kBlendIn = QStringLiteral("blend_in");
|
||||
@@ -31,66 +32,71 @@ const QString MergeNode::kBlendIn = QStringLiteral("blend_in");
|
||||
|
||||
MergeNode::MergeNode()
|
||||
{
|
||||
AddInput(kBaseIn, NodeValue::kTexture, InputFlags(kInputFlagNotKeyframable));
|
||||
AddInput(kBaseIn, NodeValue::kTexture,
|
||||
InputFlags(kInputFlagNotKeyframable));
|
||||
|
||||
AddInput(kBlendIn, NodeValue::kTexture, InputFlags(kInputFlagNotKeyframable));
|
||||
AddInput(kBlendIn, NodeValue::kTexture,
|
||||
InputFlags(kInputFlagNotKeyframable));
|
||||
|
||||
SetFlag(kDontShowInParamView);
|
||||
SetFlag(kDontShowInParamView);
|
||||
}
|
||||
|
||||
QString MergeNode::Name() const
|
||||
{
|
||||
return tr("Merge");
|
||||
return tr("Merge");
|
||||
}
|
||||
|
||||
QString MergeNode::id() const
|
||||
{
|
||||
return QStringLiteral("org.olivevideoeditor.Olive.merge");
|
||||
return QStringLiteral("org.olivevideoeditor.Olive.merge");
|
||||
}
|
||||
|
||||
QVector<Node::CategoryID> MergeNode::Category() const
|
||||
{
|
||||
return {kCategoryMath};
|
||||
return { kCategoryMath };
|
||||
}
|
||||
|
||||
QString MergeNode::Description() const
|
||||
{
|
||||
return tr("Merge two textures together.");
|
||||
return tr("Merge two textures together.");
|
||||
}
|
||||
|
||||
void MergeNode::Retranslate()
|
||||
{
|
||||
super::Retranslate();
|
||||
super::Retranslate();
|
||||
|
||||
SetInputName(kBaseIn, tr("Base"));
|
||||
SetInputName(kBaseIn, tr("Base"));
|
||||
|
||||
SetInputName(kBlendIn, tr("Blend"));
|
||||
SetInputName(kBlendIn, tr("Blend"));
|
||||
}
|
||||
|
||||
ShaderCode MergeNode::GetShaderCode(const ShaderRequest &request) const
|
||||
{
|
||||
Q_UNUSED(request)
|
||||
Q_UNUSED(request)
|
||||
|
||||
return ShaderCode(FileFunctions::ReadFileAsString(":/shaders/alphaover.frag"));
|
||||
return ShaderCode(
|
||||
FileFunctions::ReadFileAsString(":/shaders/alphaover.frag"));
|
||||
}
|
||||
|
||||
void MergeNode::Value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const
|
||||
void MergeNode::Value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
NodeValueTable *table) const
|
||||
{
|
||||
TexturePtr base_tex = value[kBaseIn].toTexture();
|
||||
TexturePtr blend_tex = value[kBlendIn].toTexture();
|
||||
|
||||
TexturePtr base_tex = value[kBaseIn].toTexture();
|
||||
TexturePtr blend_tex = value[kBlendIn].toTexture();
|
||||
|
||||
if (base_tex || blend_tex) {
|
||||
if (!base_tex || (blend_tex && blend_tex->channel_count() < VideoParams::kRGBAChannelCount)) {
|
||||
// We only have a blend texture or the blend texture is RGB only, no need to alpha over
|
||||
table->Push(value[kBlendIn]);
|
||||
} else if (!blend_tex) {
|
||||
// We only have a base texture, no need to alpha over
|
||||
table->Push(value[kBaseIn]);
|
||||
} else {
|
||||
table->Push(NodeValue::kTexture, base_tex->toJob(ShaderJob(value)), this);
|
||||
}
|
||||
}
|
||||
if (base_tex || blend_tex) {
|
||||
if (!base_tex || (blend_tex && blend_tex->channel_count() <
|
||||
VideoParams::kRGBAChannelCount)) {
|
||||
// We only have a blend texture or the blend texture is RGB only, no need to alpha over
|
||||
table->Push(value[kBlendIn]);
|
||||
} else if (!blend_tex) {
|
||||
// We only have a base texture, no need to alpha over
|
||||
table->Push(value[kBaseIn]);
|
||||
} else {
|
||||
table->Push(NodeValue::kTexture, base_tex->toJob(ShaderJob(value)),
|
||||
this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+19
-18
@@ -23,34 +23,35 @@
|
||||
|
||||
#include "node/node.h"
|
||||
|
||||
namespace olive {
|
||||
|
||||
class MergeNode : public Node
|
||||
namespace olive
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
class MergeNode : public Node {
|
||||
Q_OBJECT
|
||||
public:
|
||||
MergeNode();
|
||||
MergeNode();
|
||||
|
||||
NODE_DEFAULT_FUNCTIONS(MergeNode)
|
||||
NODE_DEFAULT_FUNCTIONS(MergeNode)
|
||||
|
||||
virtual QString Name() const override;
|
||||
virtual QString id() const override;
|
||||
virtual QVector<CategoryID> Category() const override;
|
||||
virtual QString Description() const override;
|
||||
virtual QString Name() const override;
|
||||
virtual QString id() const override;
|
||||
virtual QVector<CategoryID> Category() const override;
|
||||
virtual QString Description() const override;
|
||||
|
||||
virtual void Retranslate() override;
|
||||
virtual void Retranslate() override;
|
||||
|
||||
virtual ShaderCode GetShaderCode(const ShaderRequest &request) const override;
|
||||
virtual void Value(const NodeValueRow& value, const NodeGlobals &globals, NodeValueTable *table) const override;
|
||||
virtual ShaderCode
|
||||
GetShaderCode(const ShaderRequest &request) const override;
|
||||
virtual void Value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
NodeValueTable *table) const override;
|
||||
|
||||
static const QString kBaseIn;
|
||||
static const QString kBlendIn;
|
||||
static const QString kBaseIn;
|
||||
static const QString kBlendIn;
|
||||
|
||||
private:
|
||||
NodeInput* base_in_;
|
||||
|
||||
NodeInput* blend_in_;
|
||||
NodeInput *base_in_;
|
||||
|
||||
NodeInput *blend_in_;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -20,7 +20,8 @@
|
||||
|
||||
#include "trigonometry.h"
|
||||
|
||||
namespace olive {
|
||||
namespace olive
|
||||
{
|
||||
|
||||
const QString TrigonometryNode::kMethodIn = QStringLiteral("method_in");
|
||||
const QString TrigonometryNode::kXIn = QStringLiteral("x_in");
|
||||
@@ -29,89 +30,92 @@ const QString TrigonometryNode::kXIn = QStringLiteral("x_in");
|
||||
|
||||
TrigonometryNode::TrigonometryNode()
|
||||
{
|
||||
AddInput(kMethodIn, NodeValue::kCombo, InputFlags(kInputFlagNotConnectable | kInputFlagNotKeyframable));
|
||||
AddInput(kMethodIn, NodeValue::kCombo,
|
||||
InputFlags(kInputFlagNotConnectable | kInputFlagNotKeyframable));
|
||||
|
||||
AddInput(kXIn, NodeValue::kFloat, 0.0);
|
||||
AddInput(kXIn, NodeValue::kFloat, 0.0);
|
||||
}
|
||||
|
||||
QString TrigonometryNode::Name() const
|
||||
{
|
||||
return tr("Trigonometry");
|
||||
return tr("Trigonometry");
|
||||
}
|
||||
|
||||
QString TrigonometryNode::id() const
|
||||
{
|
||||
return QStringLiteral("org.olivevideoeditor.Olive.trigonometry");
|
||||
return QStringLiteral("org.olivevideoeditor.Olive.trigonometry");
|
||||
}
|
||||
|
||||
QVector<Node::CategoryID> TrigonometryNode::Category() const
|
||||
{
|
||||
return {kCategoryMath};
|
||||
return { kCategoryMath };
|
||||
}
|
||||
|
||||
QString TrigonometryNode::Description() const
|
||||
{
|
||||
return tr("Perform a trigonometry operation on a value.");
|
||||
return tr("Perform a trigonometry operation on a value.");
|
||||
}
|
||||
|
||||
void TrigonometryNode::Retranslate()
|
||||
{
|
||||
super::Retranslate();
|
||||
super::Retranslate();
|
||||
|
||||
QStringList strings = {tr("Sine"),
|
||||
tr("Cosine"),
|
||||
tr("Tangent"),
|
||||
QString(),
|
||||
tr("Inverse Sine"),
|
||||
tr("Inverse Cosine"),
|
||||
tr("Inverse Tangent"),
|
||||
QString(),
|
||||
tr("Hyperbolic Sine"),
|
||||
tr("Hyperbolic Cosine"),
|
||||
tr("Hyperbolic Tangent")};
|
||||
QStringList strings = { tr("Sine"),
|
||||
tr("Cosine"),
|
||||
tr("Tangent"),
|
||||
QString(),
|
||||
tr("Inverse Sine"),
|
||||
tr("Inverse Cosine"),
|
||||
tr("Inverse Tangent"),
|
||||
QString(),
|
||||
tr("Hyperbolic Sine"),
|
||||
tr("Hyperbolic Cosine"),
|
||||
tr("Hyperbolic Tangent") };
|
||||
|
||||
SetComboBoxStrings(kMethodIn, strings);
|
||||
SetComboBoxStrings(kMethodIn, strings);
|
||||
|
||||
SetInputName(kMethodIn, tr("Method"));
|
||||
SetInputName(kMethodIn, tr("Method"));
|
||||
|
||||
SetInputName(kXIn, tr("Value"));
|
||||
SetInputName(kXIn, tr("Value"));
|
||||
}
|
||||
|
||||
void TrigonometryNode::Value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const
|
||||
void TrigonometryNode::Value(const NodeValueRow &value,
|
||||
const NodeGlobals &globals,
|
||||
NodeValueTable *table) const
|
||||
{
|
||||
double x = value[kXIn].toDouble();
|
||||
double x = value[kXIn].toDouble();
|
||||
|
||||
switch (static_cast<Operation>(GetStandardValue(kMethodIn).toInt())) {
|
||||
case kOpSine:
|
||||
x = std::sin(x);
|
||||
break;
|
||||
case kOpCosine:
|
||||
x = std::cos(x);
|
||||
break;
|
||||
case kOpTangent:
|
||||
x = std::tan(x);
|
||||
break;
|
||||
case kOpArcSine:
|
||||
x = std::asin(x);
|
||||
break;
|
||||
case kOpArcCosine:
|
||||
x = std::acos(x);
|
||||
break;
|
||||
case kOpArcTangent:
|
||||
x = std::atan(x);
|
||||
break;
|
||||
case kOpHypSine:
|
||||
x = std::sinh(x);
|
||||
break;
|
||||
case kOpHypCosine:
|
||||
x = std::cosh(x);
|
||||
break;
|
||||
case kOpHypTangent:
|
||||
x = std::tanh(x);
|
||||
break;
|
||||
}
|
||||
switch (static_cast<Operation>(GetStandardValue(kMethodIn).toInt())) {
|
||||
case kOpSine:
|
||||
x = std::sin(x);
|
||||
break;
|
||||
case kOpCosine:
|
||||
x = std::cos(x);
|
||||
break;
|
||||
case kOpTangent:
|
||||
x = std::tan(x);
|
||||
break;
|
||||
case kOpArcSine:
|
||||
x = std::asin(x);
|
||||
break;
|
||||
case kOpArcCosine:
|
||||
x = std::acos(x);
|
||||
break;
|
||||
case kOpArcTangent:
|
||||
x = std::atan(x);
|
||||
break;
|
||||
case kOpHypSine:
|
||||
x = std::sinh(x);
|
||||
break;
|
||||
case kOpHypCosine:
|
||||
x = std::cosh(x);
|
||||
break;
|
||||
case kOpHypTangent:
|
||||
x = std::tanh(x);
|
||||
break;
|
||||
}
|
||||
|
||||
table->Push(NodeValue::kFloat, x, this);
|
||||
table->Push(NodeValue::kFloat, x, this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -23,41 +23,41 @@
|
||||
|
||||
#include "node/node.h"
|
||||
|
||||
namespace olive {
|
||||
|
||||
class TrigonometryNode : public Node
|
||||
namespace olive
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
class TrigonometryNode : public Node {
|
||||
Q_OBJECT
|
||||
public:
|
||||
TrigonometryNode();
|
||||
TrigonometryNode();
|
||||
|
||||
NODE_DEFAULT_FUNCTIONS(TrigonometryNode)
|
||||
NODE_DEFAULT_FUNCTIONS(TrigonometryNode)
|
||||
|
||||
virtual QString Name() const override;
|
||||
virtual QString id() const override;
|
||||
virtual QVector<CategoryID> Category() const override;
|
||||
virtual QString Description() const override;
|
||||
virtual QString Name() const override;
|
||||
virtual QString id() const override;
|
||||
virtual QVector<CategoryID> Category() const override;
|
||||
virtual QString Description() const override;
|
||||
|
||||
virtual void Retranslate() override;
|
||||
virtual void Retranslate() override;
|
||||
|
||||
virtual void Value(const NodeValueRow& value, const NodeGlobals &globals, NodeValueTable *table) const override;
|
||||
virtual void Value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
NodeValueTable *table) const override;
|
||||
|
||||
static const QString kMethodIn;
|
||||
static const QString kXIn;
|
||||
static const QString kMethodIn;
|
||||
static const QString kXIn;
|
||||
|
||||
private:
|
||||
enum Operation {
|
||||
kOpSine,
|
||||
kOpCosine,
|
||||
kOpTangent,
|
||||
kOpArcSine,
|
||||
kOpArcCosine,
|
||||
kOpArcTangent,
|
||||
kOpHypSine,
|
||||
kOpHypCosine,
|
||||
kOpHypTangent
|
||||
};
|
||||
|
||||
enum Operation {
|
||||
kOpSine,
|
||||
kOpCosine,
|
||||
kOpTangent,
|
||||
kOpArcSine,
|
||||
kOpArcCosine,
|
||||
kOpArcTangent,
|
||||
kOpHypSine,
|
||||
kOpHypCosine,
|
||||
kOpHypTangent
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user