made node edge changes undoable

This commit is contained in:
itsmattkc
2019-07-17 00:14:49 -04:00
parent a78cc3950a
commit 39256fd6f9
15 changed files with 318 additions and 12 deletions
+1
View File
@@ -15,6 +15,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
add_subdirectory(generator)
add_subdirectory(input)
add_subdirectory(output)
add_subdirectory(processor)
+1 -1
View File
@@ -34,9 +34,9 @@ NodeOutput *SolidGenerator::texture_output()
void SolidGenerator::Process(const rational &time)
{
// FIXME: Test code
Q_UNUSED(time)
// FIXME: Test code
if (texture_ == nullptr) {
QImage img(1920, 1080, QImage::Format_RGBA8888_Premultiplied);
img.fill(Qt::red);
+22
View File
@@ -0,0 +1,22 @@
# 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/>.
add_subdirectory(image)
set(OLIVE_SOURCES
${OLIVE_SOURCES}
PARENT_SCOPE
)
+22
View File
@@ -0,0 +1,22 @@
# 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/input/image/image.h
node/input/image/image.cpp
PARENT_SCOPE
)
+46
View File
@@ -0,0 +1,46 @@
#include "image.h"
ImageInput::ImageInput() :
texture_(nullptr)
{
texture_output_ = new NodeOutput();
texture_output_->set_data_type(NodeOutput::kTexture);
AddParameter(texture_output_);
}
QString ImageInput::Name()
{
return tr("Image");
}
QString ImageInput::Category()
{
return tr("Input");
}
QString ImageInput::Description()
{
return tr("Import an image file.");
}
NodeOutput *ImageInput::texture_output()
{
return texture_output_;
}
void ImageInput::Process(const rational &time)
{
// FIXME: Use OIIO and OCIO here
// FIXME: Test code
Q_UNUSED(time)
if (texture_ == nullptr) {
QImage img("/home/matt/Desktop/oof.png");
texture_ = new QOpenGLTexture(img);
}
texture_output_->set_value(texture_->textureId());
// End test code
}
+29
View File
@@ -0,0 +1,29 @@
#ifndef IMAGE_H
#define IMAGE_H
#include <QOpenGLTexture>
#include "node/node.h"
class ImageInput : public Node
{
Q_OBJECT
public:
ImageInput();
virtual QString Name() override;
virtual QString Category() override;
virtual QString Description() override;
NodeOutput* texture_output();
public slots:
virtual void Process(const rational &time) override;
private:
NodeOutput* texture_output_;
QOpenGLTexture* texture_;
};
#endif // IMAGE_H
+26 -3
View File
@@ -113,9 +113,7 @@ bool NodeParam::AreDataTypesCompatible(const DataType &output_type, const QList<
NodeEdgePtr NodeParam::ConnectEdge(NodeOutput *output, NodeInput *input)
{
// If the input can only accept one input (the default) and has one already, disconnect it
if (!input->edges_.isEmpty() && !input->can_accept_multiple_inputs()) {
DisconnectEdge(input->edges_.first());
}
FreeSpaceForEdgeFromInput(input);
// Make sure it's not a duplicate of an edge that already exists
foreach (NodeEdgePtr existing, input->edges()) {
@@ -146,6 +144,31 @@ void NodeParam::DisconnectEdge(NodeEdgePtr edge)
emit output->EdgeRemoved(edge);
}
void NodeParam::DisconnectEdge(NodeOutput *output, NodeInput *input)
{
for (int i=0;i<output->edges_.size();i++) {
NodeEdgePtr edge = output->edges_.at(i);
if (edge->input() == input) {
DisconnectEdge(edge);
break;
}
}
}
NodeEdgePtr NodeParam::FreeSpaceForEdgeFromInput(NodeInput *input)
{
// If the input can only accept one input (the default) and has one already, disconnect it
if (!input->edges_.isEmpty() && !input->can_accept_multiple_inputs()) {
NodeEdgePtr edge = input->edges_.first();
DisconnectEdge(edge);
return edge;
}
return nullptr;
}
QString NodeParam::GetDefaultDataTypeName(const DataType& type)
{
switch (type) {
+3
View File
@@ -72,6 +72,9 @@ public:
static NodeEdgePtr ConnectEdge(NodeOutput *output, NodeInput *input);
static void DisconnectEdge(NodeEdgePtr edge);
static void DisconnectEdge(NodeOutput* output, NodeInput* input);
static NodeEdgePtr FreeSpaceForEdgeFromInput(NodeInput* input);
static QString GetDefaultDataTypeName(const DataType &type);