polygon node: early crude implementation
This commit is contained in:
@@ -30,6 +30,7 @@
|
||||
#include <QPainter>
|
||||
|
||||
#include "common/define.h"
|
||||
#include "gizmotraverser.h"
|
||||
#include "render/backend/opengl/openglrenderfunctions.h"
|
||||
#include "render/backend/opengl/openglshader.h"
|
||||
#include "render/pixelformat.h"
|
||||
@@ -44,7 +45,8 @@ ViewerDisplayWidget::ViewerDisplayWidget(QWidget *parent) :
|
||||
ManagedDisplayWidget(parent),
|
||||
has_image_(false),
|
||||
signal_cursor_color_(false),
|
||||
gizmos_(nullptr)
|
||||
gizmos_(nullptr),
|
||||
gizmo_click_(false)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -169,8 +171,33 @@ void ViewerDisplayWidget::SetGizmos(Node *node)
|
||||
update();
|
||||
}
|
||||
|
||||
void ViewerDisplayWidget::SetVideoParams(const VideoRenderingParams ¶ms)
|
||||
{
|
||||
gizmo_params_ = params;
|
||||
|
||||
if (gizmos_) {
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
void ViewerDisplayWidget::SetTime(const rational &time)
|
||||
{
|
||||
time_ = time;
|
||||
|
||||
if (gizmos_) {
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
void ViewerDisplayWidget::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
if (gizmos_) {
|
||||
if (gizmos_->GizmoPress(GetTexturePosition(event->pos()))) {
|
||||
gizmo_click_ = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
QOpenGLWidget::mousePressEvent(event);
|
||||
|
||||
emit DragStarted();
|
||||
@@ -178,6 +205,11 @@ void ViewerDisplayWidget::mousePressEvent(QMouseEvent *event)
|
||||
|
||||
void ViewerDisplayWidget::mouseMoveEvent(QMouseEvent *event)
|
||||
{
|
||||
if (gizmo_click_) {
|
||||
gizmos_->GizmoMove(GetTexturePosition(event->pos()));
|
||||
return;
|
||||
}
|
||||
|
||||
QOpenGLWidget::mouseMoveEvent(event);
|
||||
|
||||
if (signal_cursor_color_) {
|
||||
@@ -201,6 +233,18 @@ void ViewerDisplayWidget::mouseMoveEvent(QMouseEvent *event)
|
||||
}
|
||||
}
|
||||
|
||||
void ViewerDisplayWidget::mouseReleaseEvent(QMouseEvent *event)
|
||||
{
|
||||
if (gizmo_click_) {
|
||||
gizmos_->GizmoRelease(GetTexturePosition(event->pos()));
|
||||
gizmo_click_ = false;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
QOpenGLWidget::mouseReleaseEvent(event);
|
||||
}
|
||||
|
||||
void ViewerDisplayWidget::initializeGL()
|
||||
{
|
||||
ManagedDisplayWidget::initializeGL();
|
||||
@@ -233,7 +277,7 @@ void ViewerDisplayWidget::paintGL()
|
||||
f->glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
// We only draw if we have a pipeline
|
||||
if (has_image_ && color_service() && texture_.IsCreated()) {
|
||||
if (has_image_ && color_service()) {
|
||||
|
||||
// Bind retrieved texture
|
||||
f->glBindTexture(GL_TEXTURE_2D, texture_.texture());
|
||||
@@ -248,8 +292,19 @@ void ViewerDisplayWidget::paintGL()
|
||||
|
||||
// Draw gizmos if we have any
|
||||
if (gizmos_) {
|
||||
GizmoTraverser gt;
|
||||
|
||||
rational node_time = GetAdjustedTime(GetTimeTarget(), gizmos_, time_, NodeParam::kInput);
|
||||
|
||||
NodeValueDatabase db = gt.GenerateDatabase(gizmos_, TimeRange(node_time, node_time));
|
||||
|
||||
QPainter p(this);
|
||||
gizmos_->DrawGizmos(&p, rect());
|
||||
|
||||
// Scale so that gizmos can just draw on the buffer
|
||||
QPointF tex_point = GetTexturePosition(size());
|
||||
p.scale(tex_point.x(), tex_point.y());
|
||||
|
||||
gizmos_->DrawGizmos(db, &p);
|
||||
}
|
||||
|
||||
// Draw action/title safe areas
|
||||
@@ -285,6 +340,22 @@ void ViewerDisplayWidget::paintGL()
|
||||
}
|
||||
}
|
||||
|
||||
QPointF ViewerDisplayWidget::GetTexturePosition(const QPoint &screen_pos)
|
||||
{
|
||||
return GetTexturePosition(screen_pos.x(), screen_pos.y());
|
||||
}
|
||||
|
||||
QPointF ViewerDisplayWidget::GetTexturePosition(const QSize &size)
|
||||
{
|
||||
return GetTexturePosition(size.width(), size.height());
|
||||
}
|
||||
|
||||
QPointF ViewerDisplayWidget::GetTexturePosition(const double &x, const double &y)
|
||||
{
|
||||
return QPointF(x / gizmo_params_.width(),
|
||||
y / gizmo_params_.height());
|
||||
}
|
||||
|
||||
#ifdef Q_OS_LINUX
|
||||
void ViewerDisplayWidget::ShowNouveauWarning()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user