nodes: revert to single output

This commit is contained in:
itsmattkc
2021-09-07 22:01:36 -07:00
parent 9843fd47f0
commit b07bccb7dc
89 changed files with 511 additions and 616 deletions
@@ -422,7 +422,7 @@ int NodeParamViewItemBody::GetElementY(NodeInput c) const
return lbl_center.y();
}
void NodeParamViewItemBody::EdgeChanged(const NodeOutput& output, const NodeInput& input)
void NodeParamViewItemBody::EdgeChanged(Node *output, const NodeInput& input)
{
Q_UNUSED(output)
+1 -1
View File
@@ -148,7 +148,7 @@ private:
static const int kWidgetStartColumn;
private slots:
void EdgeChanged(const NodeOutput &output, const NodeInput &input);
void EdgeChanged(Node *output, const NodeInput &input);
void ArrayCollapseBtnPressed(bool checked);
@@ -201,4 +201,15 @@ void NodeParamArrayAppendCommand::undo()
node_->InputArrayRemoveLast(input_, false);
}
void NodeSetValueHintCommand::redo()
{
old_hint_ = input_.node()->GetValueHintForInput(input_.input(), input_.element());
input_.node()->SetValueHintForInput(input_.input(), input_.element(), new_hint_);
}
void NodeSetValueHintCommand::undo()
{
input_.node()->SetValueHintForInput(input_.input(), input_.element(), old_hint_);
}
}
@@ -164,6 +164,38 @@ private:
};
class NodeSetValueHintCommand : public UndoCommand
{
public:
NodeSetValueHintCommand(const NodeInput &input, const Node::ValueHint &hint) :
input_(input),
new_hint_(hint)
{
}
NodeSetValueHintCommand(Node *node, const QString &input, int element, const Node::ValueHint &hint) :
NodeSetValueHintCommand(NodeInput(node, input, element), hint)
{
}
virtual Project* GetRelevantProject() const override
{
return input_.node()->project();
}
protected:
virtual void redo() override;
virtual void undo() override;
private:
NodeInput input_;
Node::ValueHint new_hint_;
Node::ValueHint old_hint_;
};
}
#endif // NODEPARAMVIEWUNDO_H
+4 -6
View File
@@ -43,7 +43,7 @@ void NodeTableView::SelectNodes(const QVector<Node *> &nodes)
{
foreach (Node* n, nodes) {
QTreeWidgetItem* top_item = new QTreeWidgetItem();
top_item->setText(0, n->Name());
top_item->setText(0, n->GetLabelAndName());
top_item->setFirstColumnSpanned(true);
this->addTopLevelItem(top_item);
top_level_item_map_.insert(n, top_item);
@@ -70,7 +70,7 @@ void NodeTableView::SetTime(const rational &time)
QTreeWidgetItem* item = i.value();
// Generate a value database for this node at this time
NodeValueDatabase db = traverser.GenerateDatabase(node, QString(), TimeRange(time, time));
NodeValueDatabase db = traverser.GenerateDatabase(node, TimeRange(time, time));
// Delete any children of this item that aren't in this database
for (int j=0; j<item->childCount(); j++) {
@@ -81,9 +81,7 @@ void NodeTableView::SetTime(const rational &time)
}
// Update all inputs
NodeValueDatabase::const_iterator l;
for (l=db.begin(); l!=db.end(); l++) {
for (auto l=db.begin(); l!=db.end(); l++) {
const NodeValueTable& table = l.value();
if (!node->HasInputWithID(l.key())) {
@@ -132,7 +130,7 @@ void NodeTableView::SetTime(const rational &time)
// Determine source
QString source_name;
if (value.source()) {
source_name = value.source()->Name();
source_name = value.source()->GetLabelAndName();
} else {
source_name = tr("(unknown)");
}
+17 -22
View File
@@ -20,7 +20,6 @@
#include "nodeview.h"
#include <cfloat>
#include <QInputDialog>
#include <QMouseEvent>
#include <QScrollBar>
@@ -460,8 +459,7 @@ void NodeView::mousePressEvent(QMouseEvent *event)
for (NodeViewEdge *edge_item : scene_.edges()) {
if (edge_item->arrow_bounding_rect().contains(scene_pt)) {
create_edge_src_ = scene_.NodeToUIObject(edge_item->output().node());
create_edge_src_output_ = edge_item->output().output();
create_edge_src_ = scene_.NodeToUIObject(edge_item->output());
create_edge_ = edge_item;
create_edge_already_exists_ = true;
return;
@@ -542,12 +540,10 @@ void NodeView::mouseMoveEvent(QMouseEvent *event)
NodeValue::Type drop_edge_data_type = NodeValue::kNone;
// Run the Node and guess what type it's actually returning
// Run the Node and determine what type is being used
NodeTraverser traverser;
NodeValueTable table = traverser.GenerateTable(new_drop_edge->output(), TimeRange(0, 0));
if (table.Count() > 0) {
drop_edge_data_type = table.at(table.Count() - 1).type();
}
NodeValue drop_edge_value = traverser.GenerateRow(new_drop_edge->output(), TimeRange(0, 0))[new_drop_edge->input().input()];
drop_edge_data_type = drop_edge_value.type();
// Iterate through the inputs of our dragging node and see if our node has any acceptable
// inputs to connect to for this type
@@ -633,7 +629,7 @@ void NodeView::mouseReleaseEvent(QMouseEvent *event)
if (creating_input.IsValid()) {
// Make connection
if (!reconnected_to_itself) {
NodeOutput creating_output(create_edge_src_->GetNode(), create_edge_src_output_);
Node *creating_output = create_edge_src_->GetNode();
if (creating_input.IsConnected()) {
Node::OutputConnection existing_edge_to_remove = {creating_input.GetConnectedOutput(), creating_input};
@@ -656,7 +652,7 @@ void NodeView::mouseReleaseEvent(QMouseEvent *event)
UpdateContextsFromEdgeRemove(command, removed_edges);
}
if (added_edge.first.IsValid()) {
if (added_edge.first) {
UpdateContextsFromEdgeAdd(command, added_edge, removed_edges);
}
@@ -994,9 +990,9 @@ void NodeView::RemoveNode(Node *node)
scene_.RemoveNode(node);
}
void NodeView::AddEdge(const NodeOutput &output, const NodeInput &input)
void NodeView::AddEdge(Node *output, const NodeInput &input)
{
Node *output_node = output.node();
Node *output_node = output;
Node *input_node = input.node();
if (scene_.item_map().contains(output_node) && scene_.item_map().contains(input_node)) {
@@ -1004,7 +1000,7 @@ void NodeView::AddEdge(const NodeOutput &output, const NodeInput &input)
}
}
void NodeView::RemoveEdge(const NodeOutput &output, const NodeInput &input)
void NodeView::RemoveEdge(Node *output, const NodeInput &input)
{
scene_.RemoveEdge(output, input);
}
@@ -1306,7 +1302,7 @@ void NodeView::UpdateContextsFromEdgeRemove(MultiUndoCommand *command, const Nod
{
// For each edge we remove, determine if we should remove the node from a context as well
for (const Node::OutputConnection &edge : remove_edges) {
Node *output_node = edge.first.node();
Node *output_node = edge.first;
QVector<Node *> contexts_to_remove_from;
int contexts_containing = 0;
@@ -1357,7 +1353,7 @@ void NodeView::RecursivelyRemoveFloatingNodeFromContext(MultiUndoCommand *comman
// Remove any dependency from the context that's also floating
for (auto it=node->input_connections().cbegin(); it!=node->input_connections().cend(); it++) {
Node *dependency = it->second.node();
Node *dependency = it->second;
// Determine if this node happens to output to anything else in the context (which may be
// another floating node that won't be removed by this operation)
@@ -1376,7 +1372,7 @@ void NodeView::RecursivelyAddNodeToContext(MultiUndoCommand *command, Node *node
// Add dependency
for (auto it=node->input_connections().cbegin(); it!=node->input_connections().cend(); it++) {
Node *dependency = it->second.node();
Node *dependency = it->second;
RecursivelyAddNodeToContext(command, dependency, context);
}
}
@@ -1386,7 +1382,7 @@ void NodeView::UpdateContextsFromEdgeAdd(MultiUndoCommand *command, const Node::
{
// Determine if node currently does NOT output to a context that it WILL after this operation
QVector<Node*> contexts_to_add_to;
Node *connecting_node = added_edge.first.node();
Node *connecting_node = added_edge.first;
Node *input_node = added_edge.second.node();
for (auto it=graph_->GetPositionMap().cbegin(); it!=graph_->GetPositionMap().cend(); it++) {
if (it.value().contains(input_node)) {
@@ -1441,7 +1437,6 @@ void NodeView::CreateNewEdge(NodeViewItem *output_item, const QPoint &mouse_pos)
{
create_edge_ = new NodeViewEdge();
create_edge_src_ = output_item;
create_edge_src_output_ = Node::kDefaultOutput;
create_edge_already_exists_ = false;
create_edge_->SetCurved(scene_.GetEdgesAreCurved());
@@ -1504,12 +1499,12 @@ void NodeView::PositionNewEdge(const QPoint &pos)
if (highlight_index >= 0) {
create_edge_dst_input_ = create_edge_dst_->GetInputAtIndex(highlight_index);
create_edge_->SetPoints(create_edge_src_->GetOutputPoint(Node::kDefaultOutput),
create_edge_->SetPoints(create_edge_src_->GetOutputPoint(),
create_edge_dst_->GetInputPoint(create_edge_dst_input_.input(), create_edge_dst_input_.element(), create_edge_src_->pos()),
true);
} else {
create_edge_dst_input_.Reset();
create_edge_->SetPoints(create_edge_src_->GetOutputPoint(Node::kDefaultOutput),
create_edge_->SetPoints(create_edge_src_->GetOutputPoint(),
scene_pt,
false);
}
@@ -1606,7 +1601,7 @@ NodeViewItem *NodeView::UpdateNodeItem(Node *node, bool ignore_own_context)
item = scene_.AddNode(node);
for (auto it=node->input_connections().cbegin(); it!=node->input_connections().cend(); it++) {
if (scene_.item_map().contains(it->second.node())) {
if (scene_.item_map().contains(it->second)) {
scene_.AddEdge(it->second, it->first);
}
}
@@ -1619,7 +1614,7 @@ NodeViewItem *NodeView::UpdateNodeItem(Node *node, bool ignore_own_context)
}
// Determine "view" position by averaging the Y value and "min"ing the X value of all contexts
QPointF item_pos(DBL_MAX, 0.0);
QPointF item_pos(std::numeric_limits<qreal>::max(), 0.0);
int average_count = 0;
for (Node *context : qAsConst(filter_nodes_)) {
if (context == node && ignore_own_context) {
+2 -3
View File
@@ -211,7 +211,6 @@ private:
NodeViewEdge* create_edge_;
NodeViewItem* create_edge_src_;
QString create_edge_src_output_;
NodeViewItem* create_edge_dst_;
NodeInput create_edge_dst_input_;
bool create_edge_dst_temp_expanded_;
@@ -281,8 +280,8 @@ private slots:
//void AddNode(Node *node);
void RemoveNode(Node *node);
void AddEdge(const NodeOutput& output, const NodeInput& input);
void RemoveEdge(const NodeOutput& output, const NodeInput& input);
void AddEdge(Node *output, const NodeInput& input);
void RemoveEdge(Node *output, const NodeInput& input);
void AddNodePosition(Node *node, Node *relative);
void RemoveNodePosition(Node *node, Node *relative);
+2 -2
View File
@@ -35,7 +35,7 @@ namespace olive {
#define super QGraphicsPathItem
NodeViewEdge::NodeViewEdge(const NodeOutput &output, const NodeInput &input,
NodeViewEdge::NodeViewEdge(Node *output, const NodeInput &input,
NodeViewItem* from_item, NodeViewItem* to_item,
QGraphicsItem* parent) :
super(parent),
@@ -59,7 +59,7 @@ NodeViewEdge::NodeViewEdge(QGraphicsItem *parent) :
void NodeViewEdge::Adjust()
{
// Draw a line between the two
SetPoints(from_item()->GetOutputPoint(output_.output()),
SetPoints(from_item()->GetOutputPoint(),
to_item()->GetInputPoint(input_.input(), input_.element(), from_item()->pos()),
to_item()->IsExpanded());
}
+3 -3
View File
@@ -39,13 +39,13 @@ class NodeViewItem;
class NodeViewEdge : public QGraphicsPathItem
{
public:
NodeViewEdge(const NodeOutput& output, const NodeInput& input,
NodeViewEdge(Node *output, const NodeInput& input,
NodeViewItem* from_item, NodeViewItem* to_item,
QGraphicsItem* parent = nullptr);
NodeViewEdge(QGraphicsItem* parent = nullptr);
const NodeOutput& output() const
Node *output() const
{
return output_;
}
@@ -124,7 +124,7 @@ private:
void UpdateCurve();
NodeOutput output_;
Node *output_;
NodeInput input_;
+1 -9
View File
@@ -301,14 +301,6 @@ void NodeViewItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *opti
QString node_label = node_->GetLabel();
QString node_shortname = node_->ShortName();
if (node_label.isEmpty()) {
// If this is a track and has no user-supplied label, generate an automatic one
Track* track_cast_test = dynamic_cast<Track*>(node_);
if (track_cast_test) {
node_label = Track::GetDefaultTrackName(track_cast_test->type(), track_cast_test->Index());
}
}
int icon_size = painter->fontMetrics().height()/2;
if (node_label.isEmpty()) {
@@ -511,7 +503,7 @@ QPointF NodeViewItem::GetInputPoint(const QString &input, int element, const QPo
return pos() + GetInputPointInternal(node_inputs_.indexOf(input), source_pos);
}
QPointF NodeViewItem::GetOutputPoint(const QString& output) const
QPointF NodeViewItem::GetOutputPoint() const
{
switch (flow_dir_) {
case NodeViewCommon::kLeftToRight:
+1 -1
View File
@@ -80,7 +80,7 @@ public:
*/
QPointF GetInputPoint(const QString& input, int element, const QPointF &source_pos) const;
QPointF GetOutputPoint(const QString &output) const;
QPointF GetOutputPoint() const;
/**
* @brief Sets the direction nodes are flowing
+5 -5
View File
@@ -98,7 +98,7 @@ NodeViewItem *NodeViewScene::NodeToUIObject(Node *n)
return item_map_.value(n);
}
NodeViewEdge *NodeViewScene::EdgeToUIObject(const NodeOutput& output, const NodeInput& input)
NodeViewEdge *NodeViewScene::EdgeToUIObject(Node *output, const NodeInput& input)
{
foreach (NodeViewEdge* edge, edges_) {
if (edge->output() == output && edge->input() == input) {
@@ -172,18 +172,18 @@ void NodeViewScene::RemoveNode(Node *node)
delete item_map_.take(node);
}
NodeViewEdge* NodeViewScene::AddEdge(const NodeOutput &output, const NodeInput &input)
NodeViewEdge* NodeViewScene::AddEdge(Node *output, const NodeInput &input)
{
NodeViewEdge *edge = EdgeToUIObject(output, input);
if (!edge) {
edge = AddEdgeInternal(output, input, NodeToUIObject(output.node()), NodeToUIObject(input.node()));
edge = AddEdgeInternal(output, input, NodeToUIObject(output), NodeToUIObject(input.node()));
}
return edge;
}
void NodeViewScene::RemoveEdge(const NodeOutput &output, const NodeInput &input)
void NodeViewScene::RemoveEdge(Node *output, const NodeInput &input)
{
NodeViewEdge* edge = EdgeToUIObject(output, input);
if (edge) {
@@ -209,7 +209,7 @@ int NodeViewScene::DetermineWeight(Node *n)
return qMax(1, weight);
}
NodeViewEdge* NodeViewScene::AddEdgeInternal(const NodeOutput& output, const NodeInput& input, NodeViewItem *from, NodeViewItem *to)
NodeViewEdge* NodeViewScene::AddEdgeInternal(Node *output, const NodeInput& input, NodeViewItem *from, NodeViewItem *to)
{
NodeViewEdge* edge_ui = new NodeViewEdge(output, input, from, to);
+4 -4
View File
@@ -53,7 +53,7 @@ public:
* in this view/scene), this function returns nullptr.
*/
NodeViewItem* NodeToUIObject(Node* n);
NodeViewEdge *EdgeToUIObject(const NodeOutput &output, const NodeInput &input);
NodeViewEdge *EdgeToUIObject(Node *output, const NodeInput &input);
QVector<Node *> GetSelectedNodes() const;
QVector<NodeViewItem*> GetSelectedItems() const;
@@ -96,8 +96,8 @@ public slots:
*/
void RemoveNode(Node* node);
NodeViewEdge *AddEdge(const NodeOutput& output, const NodeInput& input);
void RemoveEdge(const NodeOutput& output, const NodeInput& input);
NodeViewEdge *AddEdge(Node *output, const NodeInput& input);
void RemoveEdge(Node *output, const NodeInput& input);
/**
* @brief Set whether edges in this scene should be curved or not
@@ -107,7 +107,7 @@ public slots:
private:
static int DetermineWeight(Node* n);
NodeViewEdge* AddEdgeInternal(const NodeOutput &output, const NodeInput &input, NodeViewItem* from, NodeViewItem* to);
NodeViewEdge* AddEdgeInternal(Node *output, const NodeInput &input, NodeViewItem* from, NodeViewItem* to);
void ConnectNode(Node *n);
+4 -4
View File
@@ -24,7 +24,7 @@
namespace olive {
NodeEdgeAddCommand::NodeEdgeAddCommand(const NodeOutput &output, const NodeInput &input) :
NodeEdgeAddCommand::NodeEdgeAddCommand(Node *output, const NodeInput &input) :
output_(output),
input_(input),
remove_command_(nullptr)
@@ -60,10 +60,10 @@ void NodeEdgeAddCommand::undo()
Project *NodeEdgeAddCommand::GetRelevantProject() const
{
return output_.node()->project();
return output_->project();
}
NodeEdgeRemoveCommand::NodeEdgeRemoveCommand(const NodeOutput &output, const NodeInput &input) :
NodeEdgeRemoveCommand::NodeEdgeRemoveCommand(Node *output, const NodeInput &input) :
output_(output),
input_(input)
{
@@ -81,7 +81,7 @@ void NodeEdgeRemoveCommand::undo()
Project *NodeEdgeRemoveCommand::GetRelevantProject() const
{
return output_.node()->project();
return output_->project();
}
NodeAddCommand::NodeAddCommand(NodeGraph *graph, Node *node) :
+4 -4
View File
@@ -35,7 +35,7 @@ namespace olive {
*/
class NodeEdgeRemoveCommand : public UndoCommand {
public:
NodeEdgeRemoveCommand(const NodeOutput& output, const NodeInput& input);
NodeEdgeRemoveCommand(Node *output, const NodeInput& input);
virtual Project* GetRelevantProject() const override;
@@ -44,7 +44,7 @@ protected:
virtual void undo() override;
private:
NodeOutput output_;
Node *output_;
NodeInput input_;
};
@@ -56,7 +56,7 @@ private:
*/
class NodeEdgeAddCommand : public UndoCommand {
public:
NodeEdgeAddCommand(const NodeOutput& output, const NodeInput& input);
NodeEdgeAddCommand(Node *output, const NodeInput& input);
virtual ~NodeEdgeAddCommand() override;
@@ -67,7 +67,7 @@ protected:
virtual void undo() override;
private:
NodeOutput output_;
Node *output_;
NodeInput input_;
NodeEdgeRemoveCommand* remove_command_;
+7 -4
View File
@@ -34,6 +34,7 @@
#include "node/generator/matrix/matrix.h"
#include "node/math/math/math.h"
#include "node/project/sequence/sequence.h"
#include "widget/nodeparamview/nodeparamviewundo.h"
#include "widget/nodeview/nodeviewundo.h"
#include "widget/timelinewidget/undo/timelineundopointer.h"
#include "window/mainwindow/mainwindow.h"
@@ -385,8 +386,6 @@ void ImportTool::DropGhosts(bool insert)
TimelineViewGhostItem::AttachedFootage footage_stream = ghost->GetData(TimelineViewGhostItem::kAttachedFootage).value<TimelineViewGhostItem::AttachedFootage>();
NodeOutput corresponding_output(footage_stream.footage, footage_stream.output);
ClipBlock* clip = new ClipBlock();
clip->set_media_in(ghost->GetMediaIn());
clip->set_length_and_media_out(ghost->GetLength());
@@ -405,7 +404,9 @@ void ImportTool::DropGhosts(bool insert)
TransformDistortNode* transform = new TransformDistortNode();
command->add_child(new NodeAddCommand(dst_graph, transform));
command->add_child(new NodeEdgeAddCommand(corresponding_output, NodeInput(transform, TransformDistortNode::kTextureInput)));
command->add_child(new NodeSetValueHintCommand(transform, TransformDistortNode::kTextureInput, -1, {{NodeValue::kTexture}, -1, footage_stream.output}));
command->add_child(new NodeEdgeAddCommand(footage_stream.footage, NodeInput(transform, TransformDistortNode::kTextureInput)));
command->add_child(new NodeEdgeAddCommand(transform, NodeInput(clip, ClipBlock::kBufferIn)));
command->add_child(new NodeSetPositionCommand(transform, clip, QPointF(-1, 0), false));
break;
@@ -415,7 +416,9 @@ void ImportTool::DropGhosts(bool insert)
VolumeNode* volume_node = new VolumeNode();
command->add_child(new NodeAddCommand(dst_graph, volume_node));
command->add_child(new NodeEdgeAddCommand(corresponding_output, NodeInput(volume_node, VolumeNode::kSamplesInput)));
command->add_child(new NodeSetValueHintCommand(volume_node, VolumeNode::kSamplesInput, -1, {{NodeValue::kSamples}, -1, footage_stream.output}));
command->add_child(new NodeEdgeAddCommand(footage_stream.footage, NodeInput(volume_node, VolumeNode::kSamplesInput)));
command->add_child(new NodeEdgeAddCommand(volume_node, NodeInput(clip, ClipBlock::kBufferIn)));
command->add_child(new NodeSetPositionCommand(volume_node, clip, QPointF(-1, 0), false));
break;
@@ -111,11 +111,7 @@ void TrackViewItem::LineEditCancelled()
void TrackViewItem::UpdateLabel()
{
if (track_->GetLabel().isEmpty()) {
label_->setText(track_->GetDefaultTrackName(track_->type(), track_->Index()));
} else {
label_->setText(track_->GetLabel());
}
label_->setText(track_->GetLabelOrName());
}
}
+3 -3
View File
@@ -402,8 +402,8 @@ void ViewerWidget::DecodeCachedImage(RenderTicketPtr ticket, const QString &cach
bool ViewerWidget::ShouldForceWaveform() const
{
return GetConnectedNode()
&& !GetConnectedNode()->GetConnectedTextureOutput().IsValid()
&& GetConnectedNode()->GetConnectedSampleOutput().IsValid();
&& !GetConnectedNode()->GetConnectedTextureOutput()
&& GetConnectedNode()->GetConnectedSampleOutput();
}
void ViewerWidget::SetEmptyImage()
@@ -686,7 +686,7 @@ bool ViewerWidget::FrameExistsAtTime(const rational &time)
bool ViewerWidget::ViewerMightBeAStill()
{
return GetConnectedNode() && GetConnectedNode()->GetConnectedTextureOutput().IsValid() && GetConnectedNode()->GetVideoLength().isNull();
return GetConnectedNode() && GetConnectedNode()->GetConnectedTextureOutput() && GetConnectedNode()->GetVideoLength().isNull();
}
void ViewerWidget::SetDisplayImage(QVariant frame, bool main_only)
+1 -1
View File
@@ -401,7 +401,7 @@ void ViewerDisplayWidget::OnPaint()
gt.SetCacheVideoParams(gizmo_params_);
TimeRange range = GenerateGizmoTime();
gizmo_db_ = gt.GenerateRow(gizmos_, Node::kDefaultOutput, range);
gizmo_db_ = gt.GenerateRow(gizmos_, range);
QPainter p(inner_widget());
p.setWorldTransform(GenerateGizmoTransform());