began new node infrastructure

This commit is contained in:
itsmattkc
2019-07-10 03:00:35 -05:00
parent cf267440d7
commit 60b04f98b4
13 changed files with 440 additions and 1 deletions
+1
View File
@@ -24,6 +24,7 @@ set(OLIVE_SOURCES
)
add_subdirectory(decoder)
add_subdirectory(node)
add_subdirectory(panel)
add_subdirectory(project)
add_subdirectory(render)
+30
View File
@@ -0,0 +1,30 @@
# Olive - Non-Linear Video Editor
# Copyright (C) 2019 Olive Team
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
set(OLIVE_SOURCES
${OLIVE_SOURCES}
node/node.h
node/node.cpp
node/graph.h
node/graph.cpp
node/input.h
node/input.cpp
node/output.h
node/output.cpp
node/param.h
node/param.cpp
PARENT_SCOPE
)
+26
View File
@@ -0,0 +1,26 @@
/***
Olive - Non-Linear Video Editor
Copyright (C) 2019 Olive Team
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
***/
#include "graph.h"
NodeGraph::NodeGraph()
{
}
+34
View File
@@ -0,0 +1,34 @@
/***
Olive - Non-Linear Video Editor
Copyright (C) 2019 Olive Team
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
***/
#ifndef NODEGRAPH_H
#define NODEGRAPH_H
#include <QObject>
class NodeGraph : public QObject
{
public:
NodeGraph();
private:
};
#endif // NODEGRAPH_H
+41
View File
@@ -0,0 +1,41 @@
/***
Olive - Non-Linear Video Editor
Copyright (C) 2019 Olive Team
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
***/
#include "input.h"
NodeInput::NodeInput(Node* parent) :
NodeParam(parent)
{
}
NodeParam::Type NodeInput::type()
{
return kInput;
}
void NodeInput::add_data_input(const NodeParam::DataType &data_type)
{
inputs_.append(data_type);
}
bool NodeInput::can_accept_type(const NodeParam::DataType &data_type)
{
return AreDataTypesCompatible(data_type, inputs_);
}
+41
View File
@@ -0,0 +1,41 @@
/***
Olive - Non-Linear Video Editor
Copyright (C) 2019 Olive Team
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
***/
#ifndef NODEINPUT_H
#define NODEINPUT_H
#include "param.h"
class NodeInput : public NodeParam
{
public:
NodeInput(Node *parent);
virtual Type type() override;
void add_data_input(const DataType& data_type);
bool can_accept_type(const DataType& data_type);
private:
QList<DataType> inputs_;
};
#endif // NODEINPUT_H
+26
View File
@@ -0,0 +1,26 @@
/***
Olive - Non-Linear Video Editor
Copyright (C) 2019 Olive Team
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
***/
#include "node.h"
Node::Node(QObject *parent) :
QObject(parent)
{
}
+32
View File
@@ -0,0 +1,32 @@
/***
Olive - Non-Linear Video Editor
Copyright (C) 2019 Olive Team
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
***/
#ifndef NODE_H
#define NODE_H
#include <QObject>
class Node : public QObject
{
public:
Node(QObject* parent = nullptr);
};
#endif // NODE_H
+42
View File
@@ -0,0 +1,42 @@
/***
Olive - Non-Linear Video Editor
Copyright (C) 2019 Olive Team
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
***/
#include "output.h"
NodeOutput::NodeOutput(Node *parent) :
NodeParam(parent)
{
}
NodeParam::Type NodeOutput::type()
{
return kOutput;
}
const NodeParam::DataType &NodeOutput::data_type()
{
return data_type_;
}
void NodeOutput::set_data_type(const NodeParam::DataType &type)
{
data_type_ = type;
}
+40
View File
@@ -0,0 +1,40 @@
/***
Olive - Non-Linear Video Editor
Copyright (C) 2019 Olive Team
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
***/
#ifndef NODEOUTPUT_H
#define NODEOUTPUT_H
#include "param.h"
class NodeOutput : public NodeParam
{
public:
NodeOutput(Node* parent);
virtual Type type() override;
const DataType& data_type();
void set_data_type(const DataType& type);
private:
DataType data_type_;
};
#endif // NODEOUTPUT_H
+62
View File
@@ -0,0 +1,62 @@
/***
Olive - Non-Linear Video Editor
Copyright (C) 2019 Olive Team
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
***/
#include "param.h"
#include "node.h"
NodeParam::NodeParam(Node *parent) :
QObject(parent)
{
}
bool NodeParam::AreDataTypesCompatible(const NodeParam::DataType &output_type, const NodeParam::DataType &input_type)
{
if (input_type == output_type) {
return true;
}
if (input_type == kNone) {
return false;
}
if (input_type == kAny) {
return true;
}
// Allow for up-converting integers to floats (but not the other way around)
if (output_type == kInt && input_type == kFloat) {
return true;
}
return false;
}
bool NodeParam::AreDataTypesCompatible(const DataType &output_type, const QList<DataType>& input_types)
{
for (int i=0;i<input_types.size();i++) {
if (AreDataTypesCompatible(output_type, input_types.at(i))) {
return true;
}
}
return false;
}
+63
View File
@@ -0,0 +1,63 @@
/***
Olive - Non-Linear Video Editor
Copyright (C) 2019 Olive Team
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
***/
#ifndef NODEPARAM_H
#define NODEPARAM_H
#include <QObject>
class Node;
class NodeParam : public QObject
{
public:
enum Type {
kInput,
kOutput,
kPassthrough
};
enum DataType {
kNone,
kInt,
kFloat,
kColor,
kString,
kBoolean,
kFont,
kFile,
kTexture,
kMatrix,
kBlock,
kAny
};
NodeParam(Node* parent);
virtual Type type() = 0;
static bool AreDataTypesCompatible(const DataType& output_type, const DataType& input_type);
static bool AreDataTypesCompatible(const DataType& output_type, const QList<DataType>& input_types);
private:
};
#endif // NODEPARAM_H
+2 -1
View File
@@ -21,9 +21,10 @@
#ifndef SEQUENCE_H
#define SEQUENCE_H
#include "node/graph.h"
#include "project/item/item.h"
class Sequence : public Item
class Sequence : public Item, public NodeGraph
{
public:
Sequence();