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
+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_;