added full rational class

This commit is contained in:
itsmattkc
2019-05-17 19:59:26 +10:00
parent c616bc2b61
commit 00d3a4f105
6 changed files with 511 additions and 13 deletions
+10
View File
@@ -136,6 +136,11 @@ bool NodeIO::IsKeyframable()
return keyframable_;
}
QVariant NodeIO::GetValue()
{
return GetValueAt(0);
}
QVariant NodeIO::GetValueAt(double timecode)
{
if (FieldCount() == 0) {
@@ -147,6 +152,11 @@ QVariant NodeIO::GetValueAt(double timecode)
return Field(0)->GetValueAt(timecode);
}
void NodeIO::SetValue(const QVariant &value)
{
SetValueAt(0, value);
}
void NodeIO::SetValueAt(double timecode, const QVariant &value)
{
if (FieldCount() == 0) {
+20
View File
@@ -174,6 +174,16 @@ public:
*/
bool IsKeyframable();
/**
* @brief Get value
*
* A convenience value for a parameters that doesn't keyframe. Equivalent to GetValueAt(0) where the parameter
* doesn't keyframe so the 0 is ignored.
*
* @param value
*/
QVariant GetValue();
/**
* @brief Get value at a given timecode
*
@@ -193,6 +203,16 @@ public:
*/
virtual QVariant GetValueAt(double timecode);
/**
* @brief Set value
*
* A convenience value for a parameters that doesn't keyframe. Equivalent to SetValueAt(0, value) where the parameter
* doesn't keyframe so the 0 is ignored.
*
* @param value
*/
void SetValue(const QVariant& value);
/**
* @brief SetValueAt
*
+45 -2
View File
@@ -5,14 +5,42 @@ NodeBlock::NodeBlock(NodeGraph *graph) :
{
previous_block_ = new NodeIO(this, "prev_block", tr("Previous"), true, false);
previous_block_->AddAcceptedNodeInput(olive::nodes::kBlock);
previous_block_->SetValue(0);
AddParameter(previous_block_);
next_block_ = new NodeIO(this, "next_block", tr("Next"), true, false);
previous_block_->SetOutputDataType(olive::nodes::kBlock);
next_block_->SetOutputDataType(olive::nodes::kBlock);
next_block_->SetValue(0);
AddParameter(next_block_);
}
rational NodeBlock::track_in()
{
rational in_point;
NodeBlock* previous = previous_block();
while (previous != nullptr) {
in_point += previous->length();
}
return in_point;
}
rational NodeBlock::track_out()
{
return track_in() + length();
}
const rational &NodeBlock::length()
{
return length_;
}
void NodeBlock::set_length(const rational &l)
{
length_ = l;
}
QString NodeBlock::name()
{
return tr("Block");
@@ -25,5 +53,20 @@ QString NodeBlock::id()
NodeBlock *NodeBlock::previous_block()
{
return reinterpret_cast<NodeBlock*>(previous_block_->GetValue().value<quintptr>());
}
void NodeBlock::set_previous_block(NodeBlock *p)
{
previous_block_->SetValue(reinterpret_cast<quintptr>(p));
}
NodeBlock *NodeBlock::next_block()
{
return reinterpret_cast<NodeBlock*>(next_block_->GetValue().value<quintptr>());
}
void NodeBlock::set_next_block(NodeBlock *p)
{
next_block_->SetValue(reinterpret_cast<quintptr>(p));
}
+16 -5
View File
@@ -15,20 +15,31 @@ class NodeBlock : public Node
public:
NodeBlock(NodeGraph* graph);
const olive::rational& track_in();
const olive::rational& track_out();
rational track_in();
rational track_out();
const olive::rational& length();
void set_length(const olive::rational& l);
const rational& length();
void set_length(const rational& l);
virtual QString name() override;
virtual QString id() override;
/**
* @brief Retrieves the NodeBlock connected to the "Previous" parameter
*/
NodeBlock* previous_block();
void set_previous_block(NodeBlock* p);
/**
* @brief Retrieves the NodeBlock connected to the "Next" parameter
*/
NodeBlock* next_block();
void set_next_block(NodeBlock* p);
private:
olive::rational length_;
rational length_;
NodeIO* previous_block_;
NodeIO* next_block_;