From 60b04f98b4bf3e68ae4abe12c477f7461acfca54 Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Wed, 10 Jul 2019 03:00:35 -0500 Subject: [PATCH] began new node infrastructure --- app/CMakeLists.txt | 1 + app/node/CMakeLists.txt | 30 +++++++++++++ app/node/graph.cpp | 26 ++++++++++++ app/node/graph.h | 34 +++++++++++++++ app/node/input.cpp | 41 ++++++++++++++++++ app/node/input.h | 41 ++++++++++++++++++ app/node/node.cpp | 26 ++++++++++++ app/node/node.h | 32 ++++++++++++++ app/node/output.cpp | 42 +++++++++++++++++++ app/node/output.h | 40 ++++++++++++++++++ app/node/param.cpp | 62 +++++++++++++++++++++++++++ app/node/param.h | 63 ++++++++++++++++++++++++++++ app/project/item/sequence/sequence.h | 3 +- 13 files changed, 440 insertions(+), 1 deletion(-) create mode 100644 app/node/CMakeLists.txt create mode 100644 app/node/graph.cpp create mode 100644 app/node/graph.h create mode 100644 app/node/input.cpp create mode 100644 app/node/input.h create mode 100644 app/node/node.cpp create mode 100644 app/node/node.h create mode 100644 app/node/output.cpp create mode 100644 app/node/output.h create mode 100644 app/node/param.cpp create mode 100644 app/node/param.h diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index bd74573ed..132c58a78 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -24,6 +24,7 @@ set(OLIVE_SOURCES ) add_subdirectory(decoder) +add_subdirectory(node) add_subdirectory(panel) add_subdirectory(project) add_subdirectory(render) diff --git a/app/node/CMakeLists.txt b/app/node/CMakeLists.txt new file mode 100644 index 000000000..eb4d9bcb7 --- /dev/null +++ b/app/node/CMakeLists.txt @@ -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 . + +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 +) diff --git a/app/node/graph.cpp b/app/node/graph.cpp new file mode 100644 index 000000000..eebd60340 --- /dev/null +++ b/app/node/graph.cpp @@ -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 . + +***/ + +#include "graph.h" + +NodeGraph::NodeGraph() +{ + +} diff --git a/app/node/graph.h b/app/node/graph.h new file mode 100644 index 000000000..b70026317 --- /dev/null +++ b/app/node/graph.h @@ -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 . + +***/ + +#ifndef NODEGRAPH_H +#define NODEGRAPH_H + +#include + +class NodeGraph : public QObject +{ +public: + NodeGraph(); + +private: +}; + +#endif // NODEGRAPH_H diff --git a/app/node/input.cpp b/app/node/input.cpp new file mode 100644 index 000000000..570e2c44d --- /dev/null +++ b/app/node/input.cpp @@ -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 . + +***/ + +#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_); +} diff --git a/app/node/input.h b/app/node/input.h new file mode 100644 index 000000000..73add2a23 --- /dev/null +++ b/app/node/input.h @@ -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 . + +***/ + +#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 inputs_; +}; + +#endif // NODEINPUT_H diff --git a/app/node/node.cpp b/app/node/node.cpp new file mode 100644 index 000000000..23080ce1a --- /dev/null +++ b/app/node/node.cpp @@ -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 . + +***/ + +#include "node.h" + +Node::Node(QObject *parent) : + QObject(parent) +{ +} diff --git a/app/node/node.h b/app/node/node.h new file mode 100644 index 000000000..b1276a406 --- /dev/null +++ b/app/node/node.h @@ -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 . + +***/ + +#ifndef NODE_H +#define NODE_H + +#include + +class Node : public QObject +{ +public: + Node(QObject* parent = nullptr); +}; + +#endif // NODE_H diff --git a/app/node/output.cpp b/app/node/output.cpp new file mode 100644 index 000000000..309890f92 --- /dev/null +++ b/app/node/output.cpp @@ -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 . + +***/ + +#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; +} diff --git a/app/node/output.h b/app/node/output.h new file mode 100644 index 000000000..248990d47 --- /dev/null +++ b/app/node/output.h @@ -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 . + +***/ + +#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 diff --git a/app/node/param.cpp b/app/node/param.cpp new file mode 100644 index 000000000..0c871e291 --- /dev/null +++ b/app/node/param.cpp @@ -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 . + +***/ + +#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& input_types) +{ + for (int i=0;i. + +***/ + +#ifndef NODEPARAM_H +#define NODEPARAM_H + +#include + +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& input_types); + +private: + +}; + +#endif // NODEPARAM_H diff --git a/app/project/item/sequence/sequence.h b/app/project/item/sequence/sequence.h index 76b420d90..64e1197b8 100644 --- a/app/project/item/sequence/sequence.h +++ b/app/project/item/sequence/sequence.h @@ -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();