gizmos: implemented pathway for node to draw on the viewer

This commit is contained in:
itsmattkc
2020-04-27 04:34:36 +10:00
parent ac3f49a845
commit 1cca9de7c5
15 changed files with 78 additions and 3 deletions
+11
View File
@@ -110,6 +110,17 @@ NodeValueTable MatrixGenerator::Value(NodeValueDatabase &value) const
return output;
}
bool MatrixGenerator::HasGizmos() const
{
return true;
}
void MatrixGenerator::DrawGizmos(QPainter *p, const QRect& viewport) const
{
p->setPen(Qt::white);
p->drawEllipse(viewport);
}
void MatrixGenerator::UniformScaleChanged()
{
scale_input_->set_property("disabley", uniform_scale_input_->get_standard_value().toBool());
+3
View File
@@ -42,6 +42,9 @@ public:
virtual NodeValueTable Value(NodeValueDatabase& value) const override;
virtual bool HasGizmos() const override;
virtual void DrawGizmos(QPainter *p, const QRect &viewport) const override;
private:
NodeInput* position_input_;
+9
View File
@@ -268,6 +268,15 @@ QList<NodeOutput *> Node::GetOutputs() const
return {output_};
}
bool Node::HasGizmos() const
{
return false;
}
void Node::DrawGizmos(QPainter *, const QRect &) const
{
}
void Node::CopyInputs(Node *source, Node *destination, bool include_connections)
{
Q_ASSERT(source->id() == destination->id());
+5
View File
@@ -23,6 +23,7 @@
#include <QCryptographicHash>
#include <QObject>
#include <QPainter>
#include <QPointF>
#include <QXmlStreamWriter>
@@ -352,6 +353,10 @@ public:
QList<NodeOutput*> GetOutputs() const;
virtual bool HasGizmos() const;
virtual void DrawGizmos(QPainter* p, const QRect &viewport) const;
protected:
void AddInput(NodeInput* input);
+1
View File
@@ -33,6 +33,7 @@ ParamPanel::ParamPanel(QWidget* parent) :
connect(view, &NodeParamView::RequestSelectNode, this, &ParamPanel::RequestSelectNode);
connect(view, &NodeParamView::OpenedNode, this, &ParamPanel::OpeningNode);
connect(view, &NodeParamView::ClosedNode, this, &ParamPanel::ClosingNode);
connect(view, &NodeParamView::FoundGizmos, this, &ParamPanel::FoundGizmos);
SetTimeBasedWidget(view);
Retranslate();
+2
View File
@@ -43,6 +43,8 @@ signals:
void RequestSelectNode(const QList<Node*>& target);
void FoundGizmos(Node* node);
protected:
virtual void Retranslate() override;
+5
View File
@@ -91,6 +91,11 @@ void ViewerPanelBase::SetFullScreen(QScreen *screen)
static_cast<ViewerWidget*>(GetTimeBasedWidget())->SetFullScreen(screen);
}
void ViewerPanelBase::SetGizmos(Node *node)
{
static_cast<ViewerWidget*>(GetTimeBasedWidget())->SetGizmos(node);
}
void ViewerPanelBase::CreateScopePanel(ScopePanel::Type type)
{
ViewerWidget* vw = static_cast<ViewerWidget*>(GetTimeBasedWidget());
+3
View File
@@ -56,6 +56,9 @@ public:
*/
void SetFullScreen(QScreen* screen = nullptr);
public slots:
void SetGizmos(Node* node);
protected:
void CreateScopePanel(ScopePanel::Type type);
+9 -2
View File
@@ -127,7 +127,7 @@ void NodeParamView::SetNodes(QList<Node *> nodes)
// If we already have item widgets, delete them all now
foreach (NodeParamViewItem* item, items_) {
emit ClosedNode(item->GetNode());
emit FoundGizmos(nullptr);
delete item;
}
items_.clear();
@@ -142,6 +142,8 @@ void NodeParamView::SetNodes(QList<Node *> nodes)
if (!nodes_.isEmpty()) {
// For each node, create a widget
bool found_gizmos = false;
foreach (Node* node, nodes_) {
NodeParamViewItem* item = new NodeParamViewItem(node);
@@ -156,9 +158,14 @@ void NodeParamView::SetNodes(QList<Node *> nodes)
items_.append(item);
QTimer::singleShot(1, item, &NodeParamViewItem::SignalAllKeyframes);
QMetaObject::invokeMethod(item, "SignalAllKeyframes", Qt::QueuedConnection);
emit OpenedNode(node);
if (!found_gizmos && node->HasGizmos()) {
emit FoundGizmos(node);
found_gizmos = true;
}
}
ViewerOutput* viewer = nodes_.first()->FindOutputNode<ViewerOutput>();
+2
View File
@@ -51,6 +51,8 @@ signals:
void ClosedNode(Node* n);
void FoundGizmos(Node* n);
protected:
virtual void resizeEvent(QResizeEvent *event) override;
+5
View File
@@ -335,6 +335,11 @@ ColorManager *ViewerWidget::color_manager() const
return main_gl_widget()->color_manager();
}
void ViewerWidget::SetGizmos(Node *node)
{
main_gl_widget()->SetGizmos(node);
}
void ViewerWidget::UpdateTextureFromNode(const rational& time)
{
if (!GetConnectedNode() || time >= GetConnectedNode()->Length()) {
+2
View File
@@ -87,6 +87,8 @@ public:
ColorManager* color_manager() const;
void SetGizmos(Node* node);
public slots:
void Play(bool in_to_out_only);
+15 -1
View File
@@ -45,7 +45,8 @@ ViewerDisplayWidget::ViewerDisplayWidget(QWidget *parent) :
managed_copy_pipeline_(nullptr),
has_image_(false),
signal_cursor_color_(false),
enable_display_referred_signal_(false)
enable_display_referred_signal_(false),
gizmos_(nullptr)
{
}
@@ -177,6 +178,13 @@ void ViewerDisplayWidget::SetSafeMargins(const ViewerSafeMarginInfo &safe_margin
update();
}
void ViewerDisplayWidget::SetGizmos(Node *node)
{
gizmos_ = node;
update();
}
void ViewerDisplayWidget::mousePressEvent(QMouseEvent *event)
{
QOpenGLWidget::mousePressEvent(event);
@@ -299,6 +307,12 @@ void ViewerDisplayWidget::paintGL()
}
}
// Draw gizmos if we have any
if (gizmos_) {
QPainter p(this);
gizmos_->DrawGizmos(&p, rect());
}
// Draw action/title safe areas
if (safe_margin_.is_enabled()) {
QPainter p(this);
+5
View File
@@ -23,6 +23,7 @@
#include <QOpenGLWidget>
#include "node/node.h"
#include "render/backend/opengl/openglcolorprocessor.h"
#include "render/backend/opengl/openglframebuffer.h"
#include "render/backend/opengl/openglshader.h"
@@ -76,6 +77,8 @@ public:
const ViewerSafeMarginInfo& GetSafeMargin() const;
void SetSafeMargins(const ViewerSafeMarginInfo& safe_margin);
void SetGizmos(Node* node);
public slots:
/**
* @brief Set the transformation matrix to draw with
@@ -212,6 +215,8 @@ private:
bool enable_display_referred_signal_;
Node* gizmos_;
private slots:
/**
* @brief Slot to connect just before the OpenGL context is destroyed to clean up resources
+1
View File
@@ -81,6 +81,7 @@ MainWindow::MainWindow(QWidget *parent) :
connect(param_panel_, &ParamPanel::RequestSelectNode, node_panel_, &NodePanel::Select);
connect(sequence_viewer_panel_, &SequenceViewerPanel::TimeChanged, param_panel_, &ParamPanel::SetTimestamp);
connect(param_panel_, &ParamPanel::TimeChanged, sequence_viewer_panel_, &SequenceViewerPanel::SetTimestamp);
connect(param_panel_, &ParamPanel::FoundGizmos, sequence_viewer_panel_, &SequenceViewerPanel::SetGizmos);
connect(PanelManager::instance(), &PanelManager::FocusedPanelChanged, this, &MainWindow::FocusedPanelChanged);
sequence_viewer_panel_->ConnectTimeBasedPanel(param_panel_);