polygon node: early crude implementation
This commit is contained in:
@@ -31,6 +31,7 @@ add_subdirectory(nodecopypaste)
|
||||
add_subdirectory(nodeview)
|
||||
add_subdirectory(nodeparamview)
|
||||
add_subdirectory(panel)
|
||||
add_subdirectory(pixelsampler)
|
||||
add_subdirectory(playbackcontrols)
|
||||
add_subdirectory(projectexplorer)
|
||||
add_subdirectory(projecttoolbar)
|
||||
@@ -41,6 +42,7 @@ add_subdirectory(taskview)
|
||||
add_subdirectory(timebased)
|
||||
add_subdirectory(timelinewidget)
|
||||
add_subdirectory(timeruler)
|
||||
add_subdirectory(timetarget)
|
||||
add_subdirectory(toolbar)
|
||||
add_subdirectory(viewer)
|
||||
|
||||
|
||||
@@ -24,7 +24,5 @@ set(OLIVE_SOURCES
|
||||
widget/keyframeview/keyframeviewitem.cpp
|
||||
widget/keyframeview/keyframeviewundo.h
|
||||
widget/keyframeview/keyframeviewundo.cpp
|
||||
widget/keyframeview/timetargetobject.h
|
||||
widget/keyframeview/timetargetobject.cpp
|
||||
PARENT_SCOPE
|
||||
)
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
#include "keyframeviewitem.h"
|
||||
#include "node/keyframe.h"
|
||||
#include "timetargetobject.h"
|
||||
#include "widget/timetarget/timetarget.h"
|
||||
#include "widget/curvewidget/beziercontrolpointitem.h"
|
||||
#include "widget/timelinewidget/view/timelineviewbase.h"
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
#include <QGraphicsRectItem>
|
||||
|
||||
#include "node/keyframe.h"
|
||||
#include "timetargetobject.h"
|
||||
#include "widget/timetarget/timetarget.h"
|
||||
|
||||
OLIVE_NAMESPACE_ENTER
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
#include <QWidget>
|
||||
|
||||
#include "node/input.h"
|
||||
#include "widget/keyframeview/timetargetobject.h"
|
||||
#include "widget/timetarget/timetarget.h"
|
||||
|
||||
OLIVE_NAMESPACE_ENTER
|
||||
|
||||
|
||||
@@ -24,8 +24,8 @@
|
||||
#include <QObject>
|
||||
|
||||
#include "node/input.h"
|
||||
#include "widget/keyframeview/timetargetobject.h"
|
||||
#include "widget/slider/sliderbase.h"
|
||||
#include "widget/timetarget/timetarget.h"
|
||||
|
||||
OLIVE_NAMESPACE_ENTER
|
||||
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
# Olive - Non-Linear Video Editor
|
||||
# Copyright (C) 2019 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/>.
|
||||
|
||||
set(OLIVE_SOURCES
|
||||
${OLIVE_SOURCES}
|
||||
widget/pixelsampler/pixelsampler.h
|
||||
widget/pixelsampler/pixelsampler.cpp
|
||||
PARENT_SCOPE
|
||||
)
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
***/
|
||||
|
||||
#include "pixelsamplerwidget.h"
|
||||
#include "pixelsampler.h"
|
||||
|
||||
#include <QVBoxLayout>
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
# Olive - Non-Linear Video Editor
|
||||
# Copyright (C) 2019 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/>.
|
||||
|
||||
set(OLIVE_SOURCES
|
||||
${OLIVE_SOURCES}
|
||||
widget/timetarget/timetarget.h
|
||||
widget/timetarget/timetarget.cpp
|
||||
PARENT_SCOPE
|
||||
)
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
***/
|
||||
|
||||
#include "timetargetobject.h"
|
||||
#include "timetarget.h"
|
||||
|
||||
OLIVE_NAMESPACE_ENTER
|
||||
|
||||
@@ -20,8 +20,8 @@ set(OLIVE_SOURCES
|
||||
widget/viewer/audiowaveformview.cpp
|
||||
widget/viewer/footageviewer.h
|
||||
widget/viewer/footageviewer.cpp
|
||||
widget/viewer/pixelsamplerwidget.h
|
||||
widget/viewer/pixelsamplerwidget.cpp
|
||||
widget/viewer/gizmotraverser.h
|
||||
widget/viewer/gizmotraverser.cpp
|
||||
widget/viewer/viewer.h
|
||||
widget/viewer/viewer.cpp
|
||||
widget/viewer/viewerdisplay.h
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
/***
|
||||
|
||||
Olive - Non-Linear Video Editor
|
||||
Copyright (C) 2019 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"
|
||||
|
||||
OLIVE_NAMESPACE_ENTER
|
||||
|
||||
void GizmoTraverser::FootageProcessingEvent(StreamPtr stream, const TimeRange &/*input_time*/, NodeValueTable *table)
|
||||
{
|
||||
if (stream->type() == Stream::kVideo || stream->type() == Stream::kAudio) {
|
||||
|
||||
ImageStreamPtr image_stream = std::static_pointer_cast<ImageStream>(stream);
|
||||
|
||||
table->Push(NodeParam::kTexture, QSize(image_stream->width(),
|
||||
image_stream->height()));
|
||||
|
||||
} else if (stream->type() == Stream::kAudio) {
|
||||
// FIXME: Get samples
|
||||
}
|
||||
}
|
||||
|
||||
OLIVE_NAMESPACE_EXIT
|
||||
@@ -0,0 +1,40 @@
|
||||
/***
|
||||
|
||||
Olive - Non-Linear Video Editor
|
||||
Copyright (C) 2019 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"
|
||||
|
||||
OLIVE_NAMESPACE_ENTER
|
||||
|
||||
class GizmoTraverser : public NodeTraverser
|
||||
{
|
||||
public:
|
||||
GizmoTraverser() = default;
|
||||
|
||||
protected:
|
||||
virtual void FootageProcessingEvent(StreamPtr stream, const TimeRange &input_time, NodeValueTable* table) override;
|
||||
|
||||
};
|
||||
|
||||
OLIVE_NAMESPACE_EXIT
|
||||
|
||||
#endif // GIZMOTRAVERSER_H
|
||||
@@ -130,6 +130,8 @@ void ViewerWidget::TimeChangedEvent(const int64_t &i)
|
||||
UpdateTextureFromNode(time_set);
|
||||
|
||||
PushScrubbedAudio();
|
||||
|
||||
main_gl_widget()->SetTime(time_set);
|
||||
}
|
||||
|
||||
last_time_ = i;
|
||||
@@ -335,6 +337,7 @@ ColorManager *ViewerWidget::color_manager() const
|
||||
|
||||
void ViewerWidget::SetGizmos(Node *node)
|
||||
{
|
||||
main_gl_widget()->SetTimeTarget(GetConnectedNode());
|
||||
main_gl_widget()->SetGizmos(node);
|
||||
}
|
||||
|
||||
@@ -537,6 +540,8 @@ void ViewerWidget::UpdateRendererParameters()
|
||||
video_renderer_->InvalidateCache(TimeRange(0, GetConnectedNode()->Length()), nullptr);
|
||||
}
|
||||
|
||||
main_gl_widget()->SetVideoParams(vparam);
|
||||
|
||||
AudioRenderingParams aparam(GetConnectedNode()->audio_params(),
|
||||
SampleFormat::kInternalFormat);
|
||||
|
||||
|
||||
@@ -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()
|
||||
{
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#include "render/colormanager.h"
|
||||
#include "viewersafemargininfo.h"
|
||||
#include "widget/manageddisplay/manageddisplay.h"
|
||||
#include "widget/timetarget/timetarget.h"
|
||||
|
||||
OLIVE_NAMESPACE_ENTER
|
||||
|
||||
@@ -50,7 +51,7 @@ OLIVE_NAMESPACE_ENTER
|
||||
* the same texture object, use SetTexture() since it will nearly always be faster to just set it than to check *and*
|
||||
* set it.
|
||||
*/
|
||||
class ViewerDisplayWidget : public ManagedDisplayWidget
|
||||
class ViewerDisplayWidget : public ManagedDisplayWidget, public TimeTargetObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
@@ -78,6 +79,8 @@ public:
|
||||
void SetSafeMargins(const ViewerSafeMarginInfo& safe_margin);
|
||||
|
||||
void SetGizmos(Node* node);
|
||||
void SetVideoParams(const VideoRenderingParams& params);
|
||||
void SetTime(const rational& time);
|
||||
|
||||
public slots:
|
||||
/**
|
||||
@@ -126,15 +129,20 @@ signals:
|
||||
|
||||
protected:
|
||||
/**
|
||||
* @brief Override the mouse press event simply to emit the DragStarted() signal
|
||||
* @brief Override the mouse press event for the DragStarted() signal and gizmos
|
||||
*/
|
||||
virtual void mousePressEvent(QMouseEvent* event) override;
|
||||
|
||||
/**
|
||||
* @brief Override mouse move to provide functionality for
|
||||
* @brief Override mouse move to signal for the pixel sampler and gizmos
|
||||
*/
|
||||
virtual void mouseMoveEvent(QMouseEvent* event) override;
|
||||
|
||||
/**
|
||||
* @brief Override mouse release event for gizmos
|
||||
*/
|
||||
virtual void mouseReleaseEvent(QMouseEvent* event) override;
|
||||
|
||||
/**
|
||||
* @brief Initialize function to set up the OpenGL context upon its construction
|
||||
*
|
||||
@@ -150,6 +158,10 @@ protected:
|
||||
virtual void paintGL() override;
|
||||
|
||||
private:
|
||||
QPointF GetTexturePosition(const QPoint& screen_pos);
|
||||
QPointF GetTexturePosition(const QSize& size);
|
||||
QPointF GetTexturePosition(const double& x, const double& y);
|
||||
|
||||
/**
|
||||
* @brief Internal reference to the OpenGL texture to draw. Set in SetTexture() and used in paintGL().
|
||||
*/
|
||||
@@ -177,6 +189,12 @@ private:
|
||||
|
||||
Node* gizmos_;
|
||||
|
||||
VideoRenderingParams gizmo_params_;
|
||||
|
||||
bool gizmo_click_;
|
||||
|
||||
rational time_;
|
||||
|
||||
private slots:
|
||||
/**
|
||||
* @brief Slot to connect just before the OpenGL context is destroyed to clean up resources
|
||||
|
||||
Reference in New Issue
Block a user