rewrote node data types as or flags

The data types can now be or'd to match broader data types.
This commit is contained in:
itsmattkc
2019-12-04 20:26:43 +11:00
parent bae448fc32
commit 88c3bd44a5
9 changed files with 180 additions and 110 deletions
+8 -31
View File
@@ -45,7 +45,7 @@ NodeParam::~NodeParam()
}
}
const QString NodeParam::id()
const QString NodeParam::id() const
{
return id_;
}
@@ -184,40 +184,13 @@ NodeEdgePtr NodeParam::DisconnectForNewOutput(NodeInput *input)
return nullptr;
}
QString NodeParam::GetDefaultDataTypeName(const DataType& type)
{
switch (type) {
case kNone: return tr("None");
case kInt: return tr("Integer");
case kFloat: return tr("Float");
case kColor: return tr("Color");
case kString: return tr("String");
case kBoolean: return tr("Boolean");
case kFont: return tr("Font");
case kFile: return tr("File");
case kTexture: return tr("Texture");
case kMatrix: return tr("Matrix");
case kBlock: return tr("Block");
case kFootage: return tr("Footage");
case kTrack: return tr("Track");
case kRational: return tr("Rational");
case kVec2: return tr("Vector2D");
case kVec3: return tr("Vector3D");
case kVec4: return tr("Vector4D");
case kSamples: return tr("Samples");
case kAny: return tr("Any");
}
return QString();
}
QByteArray NodeParam::ValueToBytes(const NodeParam::DataType &type, const QVariant &value)
{
switch (type) {
case kInt: return ValueToBytesInternal<int>(value);
case kFloat: return ValueToBytesInternal<float>(value);
case kColor: return ValueToBytesInternal<QColor>(value);
case kString: return ValueToBytesInternal<QString>(value);
case kText: return ValueToBytesInternal<QString>(value);
case kBoolean: return ValueToBytesInternal<bool>(value);
case kFont: return ValueToBytesInternal<QString>(value); // FIXME: This should probably be a QFont?
case kFile: return ValueToBytesInternal<QString>(value);
@@ -231,9 +204,13 @@ QByteArray NodeParam::ValueToBytes(const NodeParam::DataType &type, const QVaria
case kNone:
case kFootage:
case kTexture:
case kBlock:
case kTrack:
case kSamples:
case kDecimal:
case kWholeNumber:
case kNumber:
case kString:
case kBuffer:
case kVector:
case kAny:
break;
}
+148 -37
View File
@@ -55,60 +55,171 @@ public:
* @brief The types of data that can be passed between Nodes
*/
enum DataType {
kNone,
kNone = 0x0,
/// Resolves to `int`
kInt,
/**
****************************** SPECIFIC IDENTIFIERS ******************************
*/
/// Resolves to `double`
kFloat,
/**
* Integer type
*
* Resolves to `int` (may resolve to `long` in the future).
*/
kInt = 0x1,
/// Resolves to TBA
kColor,
/**
* Decimal (floating-point) type
*
* Resolves to `double`.
*/
kFloat = 0x2,
/// Resolves to `QString`
kString,
/**
* Decimal (rational) type
*
* Resolves to `double`.
*/
kRational = 0x4,
/// Resolves to `bool`
kBoolean,
/**
* Boolean type
*
* Resolves to `bool`.
*/
kBoolean = 0x8,
/// Resolves to TBA
kFont,
/**
* Floating-point type
*
* Resolves to `QRgba64`.
*
* Colors passed around the nodes should always be in reference space and preferably use
*/
kColor = 0x10,
/// Resolves to `QString` filename
kFile,
/**
* Matrix type
*
* Resolves to `QMatrix4x4`.
*/
kMatrix = 0x20,
/// Resolves to `RenderTexturePtr`
kTexture,
/**
* Text type
*
* Resolves to `QString`.
*/
kText = 0x40,
/// Resolves to `QMatrix4x4`
kMatrix,
/**
* Font type
*
* Resolves to `QFont`.
*/
kFont = 0x80,
/// Resolves to `Block*`
kBlock,
/**
* File type
*
* Resolves to a `QString` containing an absolute file path.
*/
kFile = 0x100,
/// Resolves to `Footage*`
kFootage,
/**
* Image buffer type
*
* True value type depends on the render engine used.
*/
kTexture = 0x200,
/// Resolves to `TrackOutput*`
kTrack,
/**
* Audio samples type
*
* Resolves to `QVector4D`.
*/
kSamples = 0x400,
/// Resolves to `rational`
kRational,
/**
* Footage stream identifier type
*
* Resolves to `StreamPtr`.
*/
kFootage = 0x800,
/// Resolves to `QVector2D`
kVec2,
/**
* Two-dimensional vector (XY) type
*
* Resolves to `QVector2D`.
*/
kVec2 = 0x1000,
/// Resolves to `QVector3D`
kVec3,
/**
* Three-dimensional vector (XYZ) type
*
* Resolves to `QVector3D`.
*/
kVec3 = 0x2000,
/// Resolves to `QVector4D`
kVec4,
/**
* Four-dimensional vector (XYZW) type
*
* Resolves to `QVector4D`.
*/
kVec4 = 0x4000,
/// Resolves to `QByteArray`
kSamples,
/**
****************************** BROAD IDENTIFIERS ******************************
*/
kAny
/**
* Identifier for type that contains a decimal number
*
* Includes kFloat and kRational.
*/
kDecimal = 0x6,
/**
* Identifier for type that contains a whole number
*
* Includes kInt and kBoolean.
*/
kWholeNumber = 0x9,
/**
* Identifier for type that contains a number of any kind (whole or decimal)
*
* Includes kInt, kFloat, kRational, and kBoolean.
*/
kNumber = 0xF,
/**
* Identifier for type that contains a text string of any kind.
*
* Includes kText and kFile.
*/
kString = 0x140,
/**
* Identifier for type that contains a either an image or audio buffer
*
* Includes kTexture and kSamples.
*/
kBuffer = 0x600,
/**
* Identifier for type that contains a vector (two- to four-dimensional)
*
* Includes kVec2, kVec3, kVec4, and kColor.
*/
kVector = 0x7010,
/**
* Identifier for any type
*
* Matches with all types except for kNone
*/
kAny = 0xFFFFFFFF
};
/**
@@ -121,7 +232,7 @@ public:
/**
* @brief Return ID of this parameter
*/
const QString id();
const QString id() const;
/**
* @brief The type of node paramter this is