nodes: merged gizmotraverser and nodetabletraverser into nodetraverser

No real reason for these other derivatives that did virtually
the same thing.
This commit is contained in:
itsmattkc
2021-04-22 12:52:10 +10:00
parent 65a1922ed4
commit 97b9bcc79f
15 changed files with 65 additions and 336 deletions
+2 -4
View File
@@ -16,11 +16,9 @@
set(OLIVE_SOURCES
${OLIVE_SOURCES}
widget/nodetableview/nodetabletraverser.h
widget/nodetableview/nodetabletraverser.cpp
widget/nodetableview/nodetableview.h
widget/nodetableview/nodetableview.cpp
widget/nodetableview/nodetablewidget.h
widget/nodetableview/nodetableview.h
widget/nodetableview/nodetablewidget.cpp
widget/nodetableview/nodetablewidget.h
PARENT_SCOPE
)
@@ -1,35 +0,0 @@
/***
Olive - Non-Linear Video Editor
Copyright (C) 2021 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 "nodetabletraverser.h"
namespace olive {
QVariant NodeTableTraverser::ProcessVideoFootage(const FootageJob &video_stream, const rational &input_time)
{
return QVariant::fromValue(video_stream.video_params());
}
QVariant NodeTableTraverser::ProcessAudioFootage(const FootageJob &audio_stream, const TimeRange &input_time)
{
return QVariant::fromValue(audio_stream.audio_params());
}
}
@@ -1,42 +0,0 @@
/***
Olive - Non-Linear Video Editor
Copyright (C) 2021 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 NODETABLETRAVERSER_H
#define NODETABLETRAVERSER_H
#include "node/traverser.h"
namespace olive {
class NodeTableTraverser : public NodeTraverser
{
public:
NodeTableTraverser() = default;
protected:
virtual QVariant ProcessVideoFootage(const FootageJob &video_stream, const rational &input_time);
virtual QVariant ProcessAudioFootage(const FootageJob &audio_stream, const TimeRange &input_time);
};
}
#endif // NODETABLETRAVERSER_H
+4 -102
View File
@@ -23,7 +23,7 @@
#include <QCheckBox>
#include <QHeaderView>
#include "nodetabletraverser.h"
#include "node/traverser.h"
namespace olive {
@@ -63,10 +63,9 @@ void NodeTableView::SetTime(const rational &time)
{
last_time_ = time;
NodeTableTraverser traverser;
NodeTraverser traverser;
QMap<Node*, QTreeWidgetItem*>::const_iterator i;
for (i=top_level_item_map_.constBegin(); i!=top_level_item_map_.constEnd(); i++) {
for (auto i=top_level_item_map_.constBegin(); i!=top_level_item_map_.constEnd(); i++) {
Node* node = i.key();
QTreeWidgetItem* item = i.value();
@@ -150,7 +149,7 @@ void NodeTableView::SetTime(const rational &time)
break;
case NodeValue::kTexture:
{
// NodeTableTraverser puts video params in here
// NodeTraverser puts video params in here
for (int k=0;k<VideoParams::kRGBAChannelCount;k++) {
this->setItemWidget(sub_item, 2 + k, new QCheckBox());
}
@@ -169,101 +168,4 @@ void NodeTableView::SetTime(const rational &time)
}
}
/*
void NodeTableView::SetNode(Node *n, const rational &time)
{
NodeTableTraverser traverser;
NodeValueDatabase db = traverser.GenerateDatabase(n, TimeRange(time, time));
// Remove top items if necessary
for (int i=0;i<this->topLevelItemCount();i++) {
if (!db.contains(this->topLevelItem(i)->data(0, Qt::UserRole).toString())) {
delete this->takeTopLevelItem(i);
i--;
}
}
NodeValueDatabase::const_iterator i;
for (i=db.begin(); i!=db.end(); i++) {
const NodeValueTable& table = i.value();
NodeInput* input = n->GetInputWithID(i.key());
if (!input) {
// Filters out table entries that aren't inputs (like "global")
continue;
}
QTreeWidgetItem* top_item = nullptr;
for (int j=0;j<this->topLevelItemCount();j++) {
QTreeWidgetItem* compare = this->topLevelItem(j);
if (compare->data(0, Qt::UserRole).toString() == input->id()) {
top_item = compare;
break;
}
}
if (!top_item) {
top_item = new QTreeWidgetItem();
top_item->setText(0, input->name());
top_item->setData(0, Qt::UserRole, input->id());
top_item->setFirstColumnSpanned(true);
this->addTopLevelItem(top_item);
}
// Create children if necessary
while (top_item->childCount() < table.Count()) {
top_item->addChild(new QTreeWidgetItem());
}
// Remove children if necessary
while (top_item->childCount() > table.Count()) {
delete top_item->takeChild(top_item->childCount() - 1);
}
for (int j=0;j<table.Count();j++) {
const NodeValue& value = table.at(table.Count() - 1 - j);
// Create item
QTreeWidgetItem* sub_item = top_item->child(j);
// Set data type name
sub_item->setText(0, NodeParam::GetPrettyDataTypeName(value.type()));
// Determine source
QString source_name;
if (value.source()) {
source_name = value.source()->Name();
} else {
source_name = tr("(unknown)");
}
sub_item->setText(1, source_name);
switch (value.type()) {
case NodeParam::kTexture:
{
// NodeTableTraverser puts video params in here
VideoParams p = value.data().value<VideoParams>();
int channel_count = PixelFormat::ChannelCount(p.format());
for (int k=0;k<channel_count;k++) {
this->setItemWidget(sub_item, 2 + k, new QCheckBox());
}
break;
}
default:
{
QVector<QVariant> split_values = input->split_normal_value_into_track_values(value.data());
for (int k=0;k<split_values.size();k++) {
sub_item->setText(2 + k, NodeInput::ValueToString(value.type(), split_values.at(k)));
}
}
}
}
}
}
*/
}
+7 -9
View File
@@ -16,23 +16,21 @@
set(OLIVE_SOURCES
${OLIVE_SOURCES}
widget/viewer/audiowaveformview.h
widget/viewer/audiowaveformview.cpp
widget/viewer/footageviewer.h
widget/viewer/audiowaveformview.h
widget/viewer/footageviewer.cpp
widget/viewer/gizmotraverser.h
widget/viewer/gizmotraverser.cpp
widget/viewer/viewer.h
widget/viewer/footageviewer.h
widget/viewer/viewer.cpp
widget/viewer/viewerdisplay.h
widget/viewer/viewer.h
widget/viewer/viewerdisplay.cpp
widget/viewer/viewerplaybacktimer.h
widget/viewer/viewerdisplay.h
widget/viewer/viewerplaybacktimer.cpp
widget/viewer/viewerplaybacktimer.h
widget/viewer/viewerqueue.h
widget/viewer/viewersafemargininfo.h
widget/viewer/viewersizer.h
widget/viewer/viewersizer.cpp
widget/viewer/viewerwindow.h
widget/viewer/viewersizer.h
widget/viewer/viewerwindow.cpp
widget/viewer/viewerwindow.h
PARENT_SCOPE
)
-51
View File
@@ -1,51 +0,0 @@
/***
Olive - Non-Linear Video Editor
Copyright (C) 2021 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 "gizmotraverser.h"
namespace olive {
QVariant GizmoTraverser::ProcessVideoFootage(const FootageJob &ref, const rational &input_time)
{
Q_UNUSED(input_time)
VideoParams stream = ref.video_params();
return QVector2D(stream.width() * stream.pixel_aspect_ratio().toDouble(),
stream.height());
}
QVariant GizmoTraverser::ProcessShader(const Node *node, const TimeRange &range, const ShaderJob &job)
{
Q_UNUSED(node)
Q_UNUSED(range)
Q_UNUSED(job)
return GenerateResolution();
}
QVariant GizmoTraverser::ProcessFrameGeneration(const Node *node, const GenerateJob &job)
{
Q_UNUSED(node)
Q_UNUSED(job)
return GenerateResolution();
}
}
-57
View File
@@ -1,57 +0,0 @@
/***
Olive - Non-Linear Video Editor
Copyright (C) 2021 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 GIZMOTRAVERSER_H
#define GIZMOTRAVERSER_H
#include "node/traverser.h"
namespace olive {
class GizmoTraverser : public NodeTraverser
{
public:
GizmoTraverser(const QVector2D& sequence_resolution) :
size_(sequence_resolution)
{
}
protected:
virtual QVariant ProcessVideoFootage(const FootageJob& stream, const rational &input_time) override;
virtual QVariant ProcessShader(const Node *node, const TimeRange &range, const ShaderJob& job) override;
virtual QVector2D GenerateResolution() const override
{
return size_;
}
virtual QVariant ProcessFrameGeneration(const Node *node, const GenerateJob& job) override;
// FIXME: Do something about audio?
private:
QVector2D size_;
};
}
#endif // GIZMOTRAVERSER_H
+3 -3
View File
@@ -33,7 +33,7 @@
#include "common/functiontimer.h"
#include "config/config.h"
#include "core.h"
#include "gizmotraverser.h"
#include "node/traverser.h"
namespace olive {
@@ -339,8 +339,8 @@ void ViewerDisplayWidget::OnPaint()
// Draw gizmos if we have any
if (gizmos_) {
GizmoTraverser gt(QVector2D(gizmo_params_.width() * gizmo_params_.pixel_aspect_ratio().toDouble(),
gizmo_params_.height()));
NodeTraverser gt;
gt.SetCacheVideoParams(gizmo_params_);
rational node_time = GetGizmoTime();