style: unify identifier naming per updated conventions
Automated with clang-tidy readability-identifier-naming (config added to .clang-tidy) plus scripted passes, per the updated rules now documented in CONTRIBUTING.md: - types (class/struct/enum/alias/template params): PascalCase - functions, variables, members: snake_case (incl. rational -> Rational) - private/protected members: trailing underscore; static member variables likewise (instance_, available_themes_) - constants and enum values: snake_case (kLinear -> k_linear, F32P -> f32p); ALL_CAPS reserved for macros - macros: OAK_ prefix (OLIVE_ADD_TEST/OLIVE_ASSERT/OLIVE_CONFIG -> OAK_ADD_TEST/OAK_ASSERT/OAK_CONFIG, GL_PREAMBLE -> OAK_GL_PREAMBLE, include guards -> OAK_*) - file names: all lowercase (Current/Plugin/OliveHost/OliveClip/ OlivePluginInstance -> current/plugin/olivehost/oliveclip/ oliveplugininstance) - getters share the member name sans underscore, setters set_foo() - Qt and third-party (OpenFX) virtual overrides and framework callbacks keep their original names (exempt in .clang-tidy) Manual follow-ups required where automation could not reach: - string-based QMetaObject/SIGNAL/SLOT references updated to renamed methods (AddTask, CreatedFile, DeleteSpecificFile, moveSelectionUp, ...) - macro bodies referencing renamed methods (OLIVE_CONFIG, NODE_DEFAULT_DESTRUCTOR, MANAGEDDISPLAYWIDGET_*) - self-shadowing locals renamed where signals/methods became same-named (size_changed, worker_count, selected_items, import param, filters) - third_party OFX member/namespace usages restored (OFX::Host::*, _created, _clipPrefsDirty, createInstance, clearPersistentMessage) - STL protocol aliases restored (const_iterator) with .clang-tidy ignore rules; qHash overloads restored Full build and test suite pass: ctest 4/4, ~1960 gtest cases green.
This commit is contained in:
@@ -28,95 +28,95 @@
|
||||
namespace olive
|
||||
{
|
||||
|
||||
const QString CornerPinDistortNode::kTextureInput = QStringLiteral("tex_in");
|
||||
const QString CornerPinDistortNode::kTopLeftInput =
|
||||
const QString CornerPinDistortNode::k_texture_input = QStringLiteral("tex_in");
|
||||
const QString CornerPinDistortNode::k_top_left_input =
|
||||
QStringLiteral("top_left_in");
|
||||
const QString CornerPinDistortNode::kTopRightInput =
|
||||
const QString CornerPinDistortNode::k_top_right_input =
|
||||
QStringLiteral("top_right_in");
|
||||
const QString CornerPinDistortNode::kBottomRightInput =
|
||||
const QString CornerPinDistortNode::k_bottom_right_input =
|
||||
QStringLiteral("bottom_right_in");
|
||||
const QString CornerPinDistortNode::kBottomLeftInput =
|
||||
const QString CornerPinDistortNode::k_bottom_left_input =
|
||||
QStringLiteral("bottom_left_in");
|
||||
const QString CornerPinDistortNode::kPerspectiveInput =
|
||||
const QString CornerPinDistortNode::k_perspective_input =
|
||||
QStringLiteral("perspective_in");
|
||||
|
||||
#define super Node
|
||||
|
||||
CornerPinDistortNode::CornerPinDistortNode()
|
||||
{
|
||||
AddInput(kTextureInput, NodeValue::kTexture,
|
||||
InputFlags(kInputFlagNotKeyframable));
|
||||
AddInput(kPerspectiveInput, NodeValue::kBoolean, true);
|
||||
AddInput(kTopLeftInput, NodeValue::kVec2, QVector2D(0.0, 0.0));
|
||||
AddInput(kTopRightInput, NodeValue::kVec2, QVector2D(0.0, 0.0));
|
||||
AddInput(kBottomRightInput, NodeValue::kVec2, QVector2D(0.0, 0.0));
|
||||
AddInput(kBottomLeftInput, NodeValue::kVec2, QVector2D(0.0, 0.0));
|
||||
add_input(k_texture_input, NodeValue::k_texture,
|
||||
InputFlags(k_input_flag_not_keyframable));
|
||||
add_input(k_perspective_input, NodeValue::k_boolean, true);
|
||||
add_input(k_top_left_input, NodeValue::k_vec2, QVector2D(0.0, 0.0));
|
||||
add_input(k_top_right_input, NodeValue::k_vec2, QVector2D(0.0, 0.0));
|
||||
add_input(k_bottom_right_input, NodeValue::k_vec2, QVector2D(0.0, 0.0));
|
||||
add_input(k_bottom_left_input, NodeValue::k_vec2, QVector2D(0.0, 0.0));
|
||||
|
||||
// Initiate gizmos
|
||||
gizmo_whole_rect_ = AddDraggableGizmo<PolygonGizmo>();
|
||||
gizmo_resize_handle_[0] = AddDraggableGizmo<PointGizmo>(
|
||||
{ NodeKeyframeTrackReference(NodeInput(this, kTopLeftInput), 0),
|
||||
NodeKeyframeTrackReference(NodeInput(this, kTopLeftInput), 1) });
|
||||
gizmo_resize_handle_[1] = AddDraggableGizmo<PointGizmo>(
|
||||
{ NodeKeyframeTrackReference(NodeInput(this, kTopRightInput), 0),
|
||||
NodeKeyframeTrackReference(NodeInput(this, kTopRightInput), 1) });
|
||||
gizmo_resize_handle_[2] = AddDraggableGizmo<PointGizmo>(
|
||||
{ NodeKeyframeTrackReference(NodeInput(this, kBottomRightInput), 0),
|
||||
NodeKeyframeTrackReference(NodeInput(this, kBottomRightInput), 1) });
|
||||
gizmo_resize_handle_[3] = AddDraggableGizmo<PointGizmo>(
|
||||
{ NodeKeyframeTrackReference(NodeInput(this, kBottomLeftInput), 0),
|
||||
NodeKeyframeTrackReference(NodeInput(this, kBottomLeftInput), 1) });
|
||||
gizmo_whole_rect_ = add_draggable_gizmo<PolygonGizmo>();
|
||||
gizmo_resize_handle_[0] = add_draggable_gizmo<PointGizmo>(
|
||||
{ NodeKeyframeTrackReference(NodeInput(this, k_top_left_input), 0),
|
||||
NodeKeyframeTrackReference(NodeInput(this, k_top_left_input), 1) });
|
||||
gizmo_resize_handle_[1] = add_draggable_gizmo<PointGizmo>(
|
||||
{ NodeKeyframeTrackReference(NodeInput(this, k_top_right_input), 0),
|
||||
NodeKeyframeTrackReference(NodeInput(this, k_top_right_input), 1) });
|
||||
gizmo_resize_handle_[2] = add_draggable_gizmo<PointGizmo>(
|
||||
{ NodeKeyframeTrackReference(NodeInput(this, k_bottom_right_input), 0),
|
||||
NodeKeyframeTrackReference(NodeInput(this, k_bottom_right_input), 1) });
|
||||
gizmo_resize_handle_[3] = add_draggable_gizmo<PointGizmo>(
|
||||
{ NodeKeyframeTrackReference(NodeInput(this, k_bottom_left_input), 0),
|
||||
NodeKeyframeTrackReference(NodeInput(this, k_bottom_left_input), 1) });
|
||||
|
||||
SetFlag(kVideoEffect);
|
||||
SetEffectInput(kTextureInput);
|
||||
set_flag(k_video_effect);
|
||||
set_effect_input(k_texture_input);
|
||||
}
|
||||
|
||||
void CornerPinDistortNode::Retranslate()
|
||||
void CornerPinDistortNode::retranslate()
|
||||
{
|
||||
super::Retranslate();
|
||||
super::retranslate();
|
||||
|
||||
SetInputName(kTextureInput, tr("Texture"));
|
||||
SetInputName(kPerspectiveInput, tr("Perspective"));
|
||||
SetInputName(kTopLeftInput, tr("Top Left"));
|
||||
SetInputName(kTopRightInput, tr("Top Right"));
|
||||
SetInputName(kBottomRightInput, tr("Bottom Right"));
|
||||
SetInputName(kBottomLeftInput, tr("Bottom Left"));
|
||||
set_input_name(k_texture_input, tr("Texture"));
|
||||
set_input_name(k_perspective_input, tr("Perspective"));
|
||||
set_input_name(k_top_left_input, tr("Top Left"));
|
||||
set_input_name(k_top_right_input, tr("Top Right"));
|
||||
set_input_name(k_bottom_right_input, tr("Bottom Right"));
|
||||
set_input_name(k_bottom_left_input, tr("Bottom Left"));
|
||||
}
|
||||
|
||||
void CornerPinDistortNode::Value(const NodeValueRow &value,
|
||||
void CornerPinDistortNode::value(const NodeValueRow &value,
|
||||
const NodeGlobals &globals,
|
||||
NodeValueTable *table) const
|
||||
{
|
||||
// If no texture do nothing
|
||||
if (TexturePtr tex = value[kTextureInput].toTexture()) {
|
||||
if (TexturePtr tex = value[k_texture_input].to_texture()) {
|
||||
// In the special case that all sliders are in their default position just
|
||||
// push the texture.
|
||||
if (!(value[kTopLeftInput].toVec2().isNull() &&
|
||||
value[kTopRightInput].toVec2().isNull() &&
|
||||
value[kBottomRightInput].toVec2().isNull() &&
|
||||
value[kBottomLeftInput].toVec2().isNull())) {
|
||||
if (!(value[k_top_left_input].to_vec2().isNull() &&
|
||||
value[k_top_right_input].to_vec2().isNull() &&
|
||||
value[k_bottom_right_input].to_vec2().isNull() &&
|
||||
value[k_bottom_left_input].to_vec2().isNull())) {
|
||||
ShaderJob job(value);
|
||||
job.Insert(QStringLiteral("resolution_in"),
|
||||
NodeValue(NodeValue::kVec2, tex->virtual_resolution(),
|
||||
job.insert(QStringLiteral("resolution_in"),
|
||||
NodeValue(NodeValue::k_vec2, tex->virtual_resolution(),
|
||||
this));
|
||||
|
||||
// Convert slider values to their pixel values and then convert to clip space (-1.0 ... 1.0) for overriding the
|
||||
// vertex coordinates.
|
||||
const QVector2D &resolution = tex->virtual_resolution();
|
||||
QVector2D half_resolution = resolution * 0.5;
|
||||
QVector2D top_left = QVector2D(ValueToPixel(0, value, resolution)) /
|
||||
QVector2D top_left = QVector2D(value_to_pixel(0, value, resolution)) /
|
||||
half_resolution -
|
||||
QVector2D(1.0, 1.0);
|
||||
QVector2D top_right =
|
||||
QVector2D(ValueToPixel(1, value, resolution)) /
|
||||
QVector2D(value_to_pixel(1, value, resolution)) /
|
||||
half_resolution -
|
||||
QVector2D(1.0, 1.0);
|
||||
QVector2D bottom_right =
|
||||
QVector2D(ValueToPixel(2, value, resolution)) /
|
||||
QVector2D(value_to_pixel(2, value, resolution)) /
|
||||
half_resolution -
|
||||
QVector2D(1.0, 1.0);
|
||||
QVector2D bottom_left =
|
||||
QVector2D(ValueToPixel(3, value, resolution)) /
|
||||
QVector2D(value_to_pixel(3, value, resolution)) /
|
||||
half_resolution -
|
||||
QVector2D(1.0, 1.0);
|
||||
|
||||
@@ -130,27 +130,27 @@ void CornerPinDistortNode::Value(const NodeValueRow &value,
|
||||
bottom_left.x(), bottom_left.y(), 0.0f,
|
||||
bottom_right.x(), bottom_right.y(), 0.0f
|
||||
};
|
||||
job.SetVertexCoordinates(adjusted_vertices);
|
||||
job.set_vertex_coordinates(adjusted_vertices);
|
||||
|
||||
table->Push(NodeValue::kTexture, tex->toJob(job), this);
|
||||
table->push(NodeValue::k_texture, tex->to_job(job), this);
|
||||
} else {
|
||||
table->Push(value[kTextureInput]);
|
||||
table->push(value[k_texture_input]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ShaderCode
|
||||
CornerPinDistortNode::GetShaderCode(const ShaderRequest &request) const
|
||||
CornerPinDistortNode::get_shader_code(const ShaderRequest &request) const
|
||||
{
|
||||
Q_UNUSED(request)
|
||||
|
||||
return ShaderCode(FileFunctions::ReadFileAsString(
|
||||
return ShaderCode(FileFunctions::read_file_as_string(
|
||||
QStringLiteral(":/shaders/cornerpin.frag")),
|
||||
FileFunctions::ReadFileAsString(
|
||||
FileFunctions::read_file_as_string(
|
||||
QStringLiteral(":/shaders/cornerpin.vert")));
|
||||
}
|
||||
|
||||
QPointF CornerPinDistortNode::ValueToPixel(int value, const NodeValueRow &row,
|
||||
QPointF CornerPinDistortNode::value_to_pixel(int value, const NodeValueRow &row,
|
||||
const QVector2D &resolution) const
|
||||
{
|
||||
Q_ASSERT(value >= 0 && value <= 3);
|
||||
@@ -159,65 +159,65 @@ QPointF CornerPinDistortNode::ValueToPixel(int value, const NodeValueRow &row,
|
||||
|
||||
switch (value) {
|
||||
case 0: // Top left
|
||||
v = row[kTopLeftInput].toVec2();
|
||||
v = row[k_top_left_input].to_vec2();
|
||||
return QPointF(v.x(), v.y());
|
||||
case 1: // Top right
|
||||
v = row[kTopRightInput].toVec2();
|
||||
v = row[k_top_right_input].to_vec2();
|
||||
return QPointF(resolution.x() + v.x(), v.y());
|
||||
case 2: // Bottom right
|
||||
v = row[kBottomRightInput].toVec2();
|
||||
v = row[k_bottom_right_input].to_vec2();
|
||||
return QPointF(resolution.x() + v.x(), resolution.y() + v.y());
|
||||
case 3: //Bottom left
|
||||
v = row[kBottomLeftInput].toVec2();
|
||||
v = row[k_bottom_left_input].to_vec2();
|
||||
return QPointF(v.x(), v.y() + resolution.y());
|
||||
default: // We should never get here
|
||||
return QPointF();
|
||||
}
|
||||
}
|
||||
|
||||
void CornerPinDistortNode::GizmoDragMove(double x, double y,
|
||||
void CornerPinDistortNode::gizmo_drag_move(double x, double y,
|
||||
const Qt::KeyboardModifiers &modifiers)
|
||||
{
|
||||
DraggableGizmo *gizmo = static_cast<DraggableGizmo *>(sender());
|
||||
|
||||
if (gizmo != gizmo_whole_rect_) {
|
||||
gizmo->GetDraggers()[0].Drag(
|
||||
gizmo->GetDraggers()[0].GetStartValue().toDouble() + x);
|
||||
gizmo->GetDraggers()[1].Drag(
|
||||
gizmo->GetDraggers()[1].GetStartValue().toDouble() + y);
|
||||
gizmo->get_draggers()[0].drag(
|
||||
gizmo->get_draggers()[0].get_start_value().toDouble() + x);
|
||||
gizmo->get_draggers()[1].drag(
|
||||
gizmo->get_draggers()[1].get_start_value().toDouble() + y);
|
||||
}
|
||||
}
|
||||
|
||||
void CornerPinDistortNode::UpdateGizmoPositions(const NodeValueRow &row,
|
||||
void CornerPinDistortNode::update_gizmo_positions(const NodeValueRow &row,
|
||||
const NodeGlobals &globals)
|
||||
{
|
||||
if (TexturePtr tex = row[kTextureInput].toTexture()) {
|
||||
if (TexturePtr tex = row[k_texture_input].to_texture()) {
|
||||
const QVector2D &resolution = tex->virtual_resolution();
|
||||
|
||||
QPointF top_left = ValueToPixel(0, row, resolution);
|
||||
QPointF top_right = ValueToPixel(1, row, resolution);
|
||||
QPointF bottom_right = ValueToPixel(2, row, resolution);
|
||||
QPointF bottom_left = ValueToPixel(3, row, resolution);
|
||||
QPointF top_left = value_to_pixel(0, row, resolution);
|
||||
QPointF top_right = value_to_pixel(1, row, resolution);
|
||||
QPointF bottom_right = value_to_pixel(2, row, resolution);
|
||||
QPointF bottom_left = value_to_pixel(3, row, resolution);
|
||||
|
||||
// Add the correct offset to each slider
|
||||
SetInputProperty(kTopLeftInput, QStringLiteral("offset"),
|
||||
set_input_property(k_top_left_input, QStringLiteral("offset"),
|
||||
QVector2D(0.0, 0.0));
|
||||
SetInputProperty(kTopRightInput, QStringLiteral("offset"),
|
||||
set_input_property(k_top_right_input, QStringLiteral("offset"),
|
||||
QVector2D(resolution.x(), 0.0));
|
||||
SetInputProperty(kBottomRightInput, QStringLiteral("offset"),
|
||||
set_input_property(k_bottom_right_input, QStringLiteral("offset"),
|
||||
resolution);
|
||||
SetInputProperty(kBottomLeftInput, QStringLiteral("offset"),
|
||||
set_input_property(k_bottom_left_input, QStringLiteral("offset"),
|
||||
QVector2D(0.0, resolution.y()));
|
||||
|
||||
// Draw bounding box
|
||||
gizmo_whole_rect_->SetPolygon(QPolygonF(
|
||||
gizmo_whole_rect_->set_polygon(QPolygonF(
|
||||
{ top_left, top_right, bottom_right, bottom_left, top_left }));
|
||||
|
||||
// Create handles
|
||||
gizmo_resize_handle_[0]->SetPoint(top_left);
|
||||
gizmo_resize_handle_[1]->SetPoint(top_right);
|
||||
gizmo_resize_handle_[2]->SetPoint(bottom_right);
|
||||
gizmo_resize_handle_[3]->SetPoint(bottom_left);
|
||||
gizmo_resize_handle_[0]->set_point(top_left);
|
||||
gizmo_resize_handle_[1]->set_point(top_right);
|
||||
gizmo_resize_handle_[2]->set_point(bottom_right);
|
||||
gizmo_resize_handle_[3]->set_point(bottom_left);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef CORNERPINDISTORTNODE_H
|
||||
#define CORNERPINDISTORTNODE_H
|
||||
#ifndef OAK_CORNERPINDISTORTNODE_H
|
||||
#define OAK_CORNERPINDISTORTNODE_H
|
||||
|
||||
#include <QVector2D>
|
||||
|
||||
@@ -38,7 +38,7 @@ public:
|
||||
|
||||
NODE_DEFAULT_FUNCTIONS(CornerPinDistortNode)
|
||||
|
||||
virtual QString Name() const override
|
||||
virtual QString name() const override
|
||||
{
|
||||
return tr("Corner Pin");
|
||||
}
|
||||
@@ -48,52 +48,52 @@ public:
|
||||
return QStringLiteral("org.olivevideoeditor.Olive.cornerpin");
|
||||
}
|
||||
|
||||
virtual QVector<CategoryID> Category() const override
|
||||
virtual QVector<CategoryID> category() const override
|
||||
{
|
||||
return { kCategoryDistort };
|
||||
return { k_category_distort };
|
||||
}
|
||||
|
||||
virtual QString Description() const override
|
||||
virtual QString description() const override
|
||||
{
|
||||
return tr("Distort the image by dragging the corners.");
|
||||
}
|
||||
|
||||
virtual void Retranslate() override;
|
||||
virtual void retranslate() override;
|
||||
|
||||
virtual void Value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
virtual void value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
NodeValueTable *table) const override;
|
||||
|
||||
virtual ShaderCode
|
||||
GetShaderCode(const ShaderRequest &request) const override;
|
||||
get_shader_code(const ShaderRequest &request) const override;
|
||||
|
||||
virtual void UpdateGizmoPositions(const NodeValueRow &row,
|
||||
virtual void update_gizmo_positions(const NodeValueRow &row,
|
||||
const NodeGlobals &globals) override;
|
||||
|
||||
/**
|
||||
* @brief Convenience function - converts the 2D slider values from being
|
||||
* an offset to the actual pixel value.
|
||||
*/
|
||||
QPointF ValueToPixel(int value, const NodeValueRow &row,
|
||||
QPointF value_to_pixel(int value, const NodeValueRow &row,
|
||||
const QVector2D &resolution) const;
|
||||
|
||||
static const QString kTextureInput;
|
||||
static const QString kPerspectiveInput;
|
||||
static const QString kTopLeftInput;
|
||||
static const QString kTopRightInput;
|
||||
static const QString kBottomRightInput;
|
||||
static const QString kBottomLeftInput;
|
||||
static const QString k_texture_input;
|
||||
static const QString k_perspective_input;
|
||||
static const QString k_top_left_input;
|
||||
static const QString k_top_right_input;
|
||||
static const QString k_bottom_right_input;
|
||||
static const QString k_bottom_left_input;
|
||||
|
||||
protected slots:
|
||||
virtual void GizmoDragMove(double x, double y,
|
||||
virtual void gizmo_drag_move(double x, double y,
|
||||
const Qt::KeyboardModifiers &modifiers) override;
|
||||
|
||||
private:
|
||||
// Gizmo variables
|
||||
static const int kGizmoCornerCount = 4;
|
||||
PointGizmo *gizmo_resize_handle_[kGizmoCornerCount];
|
||||
static const int k_gizmo_corner_count = 4;
|
||||
PointGizmo *gizmo_resize_handle_[k_gizmo_corner_count];
|
||||
PolygonGizmo *gizmo_whole_rect_;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // CORNERPINDISTORTNODE_H
|
||||
#endif // OAK_CORNERPINDISTORTNODE_H
|
||||
|
||||
@@ -28,133 +28,133 @@
|
||||
namespace olive
|
||||
{
|
||||
|
||||
const QString CropDistortNode::kTextureInput = QStringLiteral("tex_in");
|
||||
const QString CropDistortNode::kLeftInput = QStringLiteral("left_in");
|
||||
const QString CropDistortNode::kTopInput = QStringLiteral("top_in");
|
||||
const QString CropDistortNode::kRightInput = QStringLiteral("right_in");
|
||||
const QString CropDistortNode::kBottomInput = QStringLiteral("bottom_in");
|
||||
const QString CropDistortNode::kFeatherInput = QStringLiteral("feather_in");
|
||||
const QString CropDistortNode::k_texture_input = QStringLiteral("tex_in");
|
||||
const QString CropDistortNode::k_left_input = QStringLiteral("left_in");
|
||||
const QString CropDistortNode::k_top_input = QStringLiteral("top_in");
|
||||
const QString CropDistortNode::k_right_input = QStringLiteral("right_in");
|
||||
const QString CropDistortNode::k_bottom_input = QStringLiteral("bottom_in");
|
||||
const QString CropDistortNode::k_feather_input = QStringLiteral("feather_in");
|
||||
|
||||
#define super Node
|
||||
|
||||
CropDistortNode::CropDistortNode()
|
||||
{
|
||||
AddInput(kTextureInput, NodeValue::kTexture,
|
||||
InputFlags(kInputFlagNotKeyframable));
|
||||
add_input(k_texture_input, NodeValue::k_texture,
|
||||
InputFlags(k_input_flag_not_keyframable));
|
||||
|
||||
CreateCropSideInput(kLeftInput);
|
||||
CreateCropSideInput(kTopInput);
|
||||
CreateCropSideInput(kRightInput);
|
||||
CreateCropSideInput(kBottomInput);
|
||||
create_crop_side_input(k_left_input);
|
||||
create_crop_side_input(k_top_input);
|
||||
create_crop_side_input(k_right_input);
|
||||
create_crop_side_input(k_bottom_input);
|
||||
|
||||
AddInput(kFeatherInput, NodeValue::kFloat, 0.0);
|
||||
SetInputProperty(kFeatherInput, QStringLiteral("min"), 0.0);
|
||||
add_input(k_feather_input, NodeValue::k_float, 0.0);
|
||||
set_input_property(k_feather_input, QStringLiteral("min"), 0.0);
|
||||
|
||||
// Initiate gizmos
|
||||
poly_gizmo_ = AddDraggableGizmo<PolygonGizmo>(
|
||||
{ kLeftInput, kTopInput, kRightInput, kBottomInput });
|
||||
poly_gizmo_ = add_draggable_gizmo<PolygonGizmo>(
|
||||
{ k_left_input, k_top_input, k_right_input, k_bottom_input });
|
||||
|
||||
point_gizmo_[kGizmoScaleTopLeft] =
|
||||
AddDraggableGizmo<PointGizmo>({ kLeftInput, kTopInput });
|
||||
point_gizmo_[kGizmoScaleTopCenter] =
|
||||
AddDraggableGizmo<PointGizmo>({ kTopInput });
|
||||
point_gizmo_[kGizmoScaleTopRight] =
|
||||
AddDraggableGizmo<PointGizmo>({ kRightInput, kTopInput });
|
||||
point_gizmo_[kGizmoScaleBottomLeft] =
|
||||
AddDraggableGizmo<PointGizmo>({ kLeftInput, kBottomInput });
|
||||
point_gizmo_[kGizmoScaleBottomCenter] =
|
||||
AddDraggableGizmo<PointGizmo>({ kBottomInput });
|
||||
point_gizmo_[kGizmoScaleBottomRight] =
|
||||
AddDraggableGizmo<PointGizmo>({ kRightInput, kBottomInput });
|
||||
point_gizmo_[kGizmoScaleCenterLeft] =
|
||||
AddDraggableGizmo<PointGizmo>({ kLeftInput });
|
||||
point_gizmo_[kGizmoScaleCenterRight] =
|
||||
AddDraggableGizmo<PointGizmo>({ kRightInput });
|
||||
point_gizmo_[k_gizmo_scale_top_left] =
|
||||
add_draggable_gizmo<PointGizmo>({ k_left_input, k_top_input });
|
||||
point_gizmo_[k_gizmo_scale_top_center] =
|
||||
add_draggable_gizmo<PointGizmo>({ k_top_input });
|
||||
point_gizmo_[k_gizmo_scale_top_right] =
|
||||
add_draggable_gizmo<PointGizmo>({ k_right_input, k_top_input });
|
||||
point_gizmo_[k_gizmo_scale_bottom_left] =
|
||||
add_draggable_gizmo<PointGizmo>({ k_left_input, k_bottom_input });
|
||||
point_gizmo_[k_gizmo_scale_bottom_center] =
|
||||
add_draggable_gizmo<PointGizmo>({ k_bottom_input });
|
||||
point_gizmo_[k_gizmo_scale_bottom_right] =
|
||||
add_draggable_gizmo<PointGizmo>({ k_right_input, k_bottom_input });
|
||||
point_gizmo_[k_gizmo_scale_center_left] =
|
||||
add_draggable_gizmo<PointGizmo>({ k_left_input });
|
||||
point_gizmo_[k_gizmo_scale_center_right] =
|
||||
add_draggable_gizmo<PointGizmo>({ k_right_input });
|
||||
|
||||
SetFlag(kVideoEffect);
|
||||
SetEffectInput(kTextureInput);
|
||||
set_flag(k_video_effect);
|
||||
set_effect_input(k_texture_input);
|
||||
}
|
||||
|
||||
void CropDistortNode::Retranslate()
|
||||
void CropDistortNode::retranslate()
|
||||
{
|
||||
super::Retranslate();
|
||||
super::retranslate();
|
||||
|
||||
SetInputName(kTextureInput, tr("Texture"));
|
||||
SetInputName(kLeftInput, tr("Left"));
|
||||
SetInputName(kTopInput, tr("Top"));
|
||||
SetInputName(kRightInput, tr("Right"));
|
||||
SetInputName(kBottomInput, tr("Bottom"));
|
||||
SetInputName(kFeatherInput, tr("Feather"));
|
||||
set_input_name(k_texture_input, tr("Texture"));
|
||||
set_input_name(k_left_input, tr("Left"));
|
||||
set_input_name(k_top_input, tr("Top"));
|
||||
set_input_name(k_right_input, tr("Right"));
|
||||
set_input_name(k_bottom_input, tr("Bottom"));
|
||||
set_input_name(k_feather_input, tr("Feather"));
|
||||
}
|
||||
|
||||
void CropDistortNode::Value(const NodeValueRow &value,
|
||||
void CropDistortNode::value(const NodeValueRow &value,
|
||||
const NodeGlobals &globals,
|
||||
NodeValueTable *table) const
|
||||
{
|
||||
ShaderJob job;
|
||||
job.Insert(value);
|
||||
job.insert(value);
|
||||
|
||||
if (TexturePtr texture = job.Get(kTextureInput).toTexture()) {
|
||||
job.Insert(QStringLiteral("resolution_in"),
|
||||
NodeValue(NodeValue::kVec2,
|
||||
if (TexturePtr texture = job.get(k_texture_input).to_texture()) {
|
||||
job.insert(QStringLiteral("resolution_in"),
|
||||
NodeValue(NodeValue::k_vec2,
|
||||
QVector2D(texture->params().width(),
|
||||
texture->params().height()),
|
||||
this));
|
||||
|
||||
if (!qIsNull(job.Get(kLeftInput).toDouble()) ||
|
||||
!qIsNull(job.Get(kRightInput).toDouble()) ||
|
||||
!qIsNull(job.Get(kTopInput).toDouble()) ||
|
||||
!qIsNull(job.Get(kBottomInput).toDouble())) {
|
||||
table->Push(NodeValue::kTexture, texture->toJob(job), this);
|
||||
if (!qIsNull(job.get(k_left_input).to_double()) ||
|
||||
!qIsNull(job.get(k_right_input).to_double()) ||
|
||||
!qIsNull(job.get(k_top_input).to_double()) ||
|
||||
!qIsNull(job.get(k_bottom_input).to_double())) {
|
||||
table->push(NodeValue::k_texture, texture->to_job(job), this);
|
||||
} else {
|
||||
table->Push(job.Get(kTextureInput));
|
||||
table->push(job.get(k_texture_input));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ShaderCode CropDistortNode::GetShaderCode(const ShaderRequest &request) const
|
||||
ShaderCode CropDistortNode::get_shader_code(const ShaderRequest &request) const
|
||||
{
|
||||
Q_UNUSED(request)
|
||||
return ShaderCode(
|
||||
FileFunctions::ReadFileAsString(QStringLiteral(":/shaders/crop.frag")));
|
||||
FileFunctions::read_file_as_string(QStringLiteral(":/shaders/crop.frag")));
|
||||
}
|
||||
|
||||
void CropDistortNode::UpdateGizmoPositions(const NodeValueRow &row,
|
||||
void CropDistortNode::update_gizmo_positions(const NodeValueRow &row,
|
||||
const NodeGlobals &globals)
|
||||
{
|
||||
if (TexturePtr tex = row[kTextureInput].toTexture()) {
|
||||
if (TexturePtr tex = row[k_texture_input].to_texture()) {
|
||||
const QVector2D &resolution = tex->virtual_resolution();
|
||||
temp_resolution_ = resolution;
|
||||
|
||||
double left_pt = resolution.x() * row[kLeftInput].toDouble();
|
||||
double top_pt = resolution.y() * row[kTopInput].toDouble();
|
||||
double right_pt = resolution.x() * (1.0 - row[kRightInput].toDouble());
|
||||
double left_pt = resolution.x() * row[k_left_input].to_double();
|
||||
double top_pt = resolution.y() * row[k_top_input].to_double();
|
||||
double right_pt = resolution.x() * (1.0 - row[k_right_input].to_double());
|
||||
double bottom_pt =
|
||||
resolution.y() * (1.0 - row[kBottomInput].toDouble());
|
||||
resolution.y() * (1.0 - row[k_bottom_input].to_double());
|
||||
double center_x_pt = mid(left_pt, right_pt);
|
||||
double center_y_pt = mid(top_pt, bottom_pt);
|
||||
|
||||
point_gizmo_[kGizmoScaleTopLeft]->SetPoint(QPointF(left_pt, top_pt));
|
||||
point_gizmo_[kGizmoScaleTopCenter]->SetPoint(
|
||||
point_gizmo_[k_gizmo_scale_top_left]->set_point(QPointF(left_pt, top_pt));
|
||||
point_gizmo_[k_gizmo_scale_top_center]->set_point(
|
||||
QPointF(center_x_pt, top_pt));
|
||||
point_gizmo_[kGizmoScaleTopRight]->SetPoint(QPointF(right_pt, top_pt));
|
||||
point_gizmo_[kGizmoScaleBottomLeft]->SetPoint(
|
||||
point_gizmo_[k_gizmo_scale_top_right]->set_point(QPointF(right_pt, top_pt));
|
||||
point_gizmo_[k_gizmo_scale_bottom_left]->set_point(
|
||||
QPointF(left_pt, bottom_pt));
|
||||
point_gizmo_[kGizmoScaleBottomCenter]->SetPoint(
|
||||
point_gizmo_[k_gizmo_scale_bottom_center]->set_point(
|
||||
QPointF(center_x_pt, bottom_pt));
|
||||
point_gizmo_[kGizmoScaleBottomRight]->SetPoint(
|
||||
point_gizmo_[k_gizmo_scale_bottom_right]->set_point(
|
||||
QPointF(right_pt, bottom_pt));
|
||||
point_gizmo_[kGizmoScaleCenterLeft]->SetPoint(
|
||||
point_gizmo_[k_gizmo_scale_center_left]->set_point(
|
||||
QPointF(left_pt, center_y_pt));
|
||||
point_gizmo_[kGizmoScaleCenterRight]->SetPoint(
|
||||
point_gizmo_[k_gizmo_scale_center_right]->set_point(
|
||||
QPointF(right_pt, center_y_pt));
|
||||
|
||||
poly_gizmo_->SetPolygon(
|
||||
poly_gizmo_->set_polygon(
|
||||
QRectF(left_pt, top_pt, right_pt - left_pt, bottom_pt - top_pt));
|
||||
}
|
||||
}
|
||||
|
||||
void CropDistortNode::GizmoDragMove(double x_diff, double y_diff,
|
||||
void CropDistortNode::gizmo_drag_move(double x_diff, double y_diff,
|
||||
const Qt::KeyboardModifiers &modifiers)
|
||||
{
|
||||
DraggableGizmo *gizmo = static_cast<DraggableGizmo *>(sender());
|
||||
@@ -163,27 +163,27 @@ void CropDistortNode::GizmoDragMove(double x_diff, double y_diff,
|
||||
x_diff /= res.x();
|
||||
y_diff /= res.y();
|
||||
|
||||
for (int j = 0; j < gizmo->GetDraggers().size(); j++) {
|
||||
NodeInputDragger &i = gizmo->GetDraggers()[j];
|
||||
double s = i.GetStartValue().toDouble();
|
||||
if (i.GetInput().input().input() == kLeftInput) {
|
||||
i.Drag(s + x_diff);
|
||||
} else if (i.GetInput().input().input() == kTopInput) {
|
||||
i.Drag(s + y_diff);
|
||||
} else if (i.GetInput().input().input() == kRightInput) {
|
||||
i.Drag(s - x_diff);
|
||||
} else if (i.GetInput().input().input() == kBottomInput) {
|
||||
i.Drag(s - y_diff);
|
||||
for (int j = 0; j < gizmo->get_draggers().size(); j++) {
|
||||
NodeInputDragger &i = gizmo->get_draggers()[j];
|
||||
double s = i.get_start_value().toDouble();
|
||||
if (i.get_input().input().input() == k_left_input) {
|
||||
i.drag(s + x_diff);
|
||||
} else if (i.get_input().input().input() == k_top_input) {
|
||||
i.drag(s + y_diff);
|
||||
} else if (i.get_input().input().input() == k_right_input) {
|
||||
i.drag(s - x_diff);
|
||||
} else if (i.get_input().input().input() == k_bottom_input) {
|
||||
i.drag(s - y_diff);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CropDistortNode::CreateCropSideInput(const QString &id)
|
||||
void CropDistortNode::create_crop_side_input(const QString &id)
|
||||
{
|
||||
AddInput(id, NodeValue::kFloat, 0.0);
|
||||
SetInputProperty(id, QStringLiteral("min"), 0.0);
|
||||
SetInputProperty(id, QStringLiteral("max"), 1.0);
|
||||
SetInputProperty(id, QStringLiteral("view"), FloatSlider::kPercentage);
|
||||
add_input(id, NodeValue::k_float, 0.0);
|
||||
set_input_property(id, QStringLiteral("min"), 0.0);
|
||||
set_input_property(id, QStringLiteral("max"), 1.0);
|
||||
set_input_property(id, QStringLiteral("view"), FloatSlider::k_percentage);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef CROPDISTORTNODE_H
|
||||
#define CROPDISTORTNODE_H
|
||||
#ifndef OAK_CROPDISTORTNODE_H
|
||||
#define OAK_CROPDISTORTNODE_H
|
||||
|
||||
#include <QVector2D>
|
||||
|
||||
@@ -39,7 +39,7 @@ public:
|
||||
|
||||
NODE_DEFAULT_FUNCTIONS(CropDistortNode)
|
||||
|
||||
virtual QString Name() const override
|
||||
virtual QString name() const override
|
||||
{
|
||||
return tr("Crop");
|
||||
}
|
||||
@@ -49,47 +49,47 @@ public:
|
||||
return QStringLiteral("org.olivevideoeditor.Olive.crop");
|
||||
}
|
||||
|
||||
virtual QVector<CategoryID> Category() const override
|
||||
virtual QVector<CategoryID> category() const override
|
||||
{
|
||||
return { kCategoryDistort };
|
||||
return { k_category_distort };
|
||||
}
|
||||
|
||||
virtual QString Description() const override
|
||||
virtual QString description() const override
|
||||
{
|
||||
return tr("Crop the edges of an image.");
|
||||
}
|
||||
|
||||
virtual void Retranslate() override;
|
||||
virtual void retranslate() override;
|
||||
|
||||
virtual void Value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
virtual void value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
NodeValueTable *table) const override;
|
||||
|
||||
virtual ShaderCode
|
||||
GetShaderCode(const ShaderRequest &request) const override;
|
||||
get_shader_code(const ShaderRequest &request) const override;
|
||||
|
||||
virtual void UpdateGizmoPositions(const NodeValueRow &row,
|
||||
virtual void update_gizmo_positions(const NodeValueRow &row,
|
||||
const NodeGlobals &globals) override;
|
||||
|
||||
static const QString kTextureInput;
|
||||
static const QString kLeftInput;
|
||||
static const QString kTopInput;
|
||||
static const QString kRightInput;
|
||||
static const QString kBottomInput;
|
||||
static const QString kFeatherInput;
|
||||
static const QString k_texture_input;
|
||||
static const QString k_left_input;
|
||||
static const QString k_top_input;
|
||||
static const QString k_right_input;
|
||||
static const QString k_bottom_input;
|
||||
static const QString k_feather_input;
|
||||
|
||||
protected slots:
|
||||
virtual void GizmoDragMove(double delta_x, double delta_y,
|
||||
virtual void gizmo_drag_move(double delta_x, double delta_y,
|
||||
const Qt::KeyboardModifiers &modifiers) override;
|
||||
|
||||
private:
|
||||
void CreateCropSideInput(const QString &id);
|
||||
void create_crop_side_input(const QString &id);
|
||||
|
||||
// Gizmo variables
|
||||
PointGizmo *point_gizmo_[kGizmoScaleCount];
|
||||
PointGizmo *point_gizmo_[k_gizmo_scale_count];
|
||||
PolygonGizmo *poly_gizmo_;
|
||||
QVector2D temp_resolution_;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // CROPDISTORTNODE_H
|
||||
#endif // OAK_CROPDISTORTNODE_H
|
||||
|
||||
@@ -24,26 +24,26 @@
|
||||
namespace olive
|
||||
{
|
||||
|
||||
const QString FlipDistortNode::kTextureInput = QStringLiteral("tex_in");
|
||||
const QString FlipDistortNode::kHorizontalInput = QStringLiteral("horiz_in");
|
||||
const QString FlipDistortNode::kVerticalInput = QStringLiteral("vert_in");
|
||||
const QString FlipDistortNode::k_texture_input = QStringLiteral("tex_in");
|
||||
const QString FlipDistortNode::k_horizontal_input = QStringLiteral("horiz_in");
|
||||
const QString FlipDistortNode::k_vertical_input = QStringLiteral("vert_in");
|
||||
|
||||
#define super Node
|
||||
|
||||
FlipDistortNode::FlipDistortNode()
|
||||
{
|
||||
AddInput(kTextureInput, NodeValue::kTexture,
|
||||
InputFlags(kInputFlagNotKeyframable));
|
||||
add_input(k_texture_input, NodeValue::k_texture,
|
||||
InputFlags(k_input_flag_not_keyframable));
|
||||
|
||||
AddInput(kHorizontalInput, NodeValue::kBoolean, false);
|
||||
add_input(k_horizontal_input, NodeValue::k_boolean, false);
|
||||
|
||||
AddInput(kVerticalInput, NodeValue::kBoolean, false);
|
||||
add_input(k_vertical_input, NodeValue::k_boolean, false);
|
||||
|
||||
SetFlag(kVideoEffect);
|
||||
SetEffectInput(kTextureInput);
|
||||
set_flag(k_video_effect);
|
||||
set_effect_input(k_texture_input);
|
||||
}
|
||||
|
||||
QString FlipDistortNode::Name() const
|
||||
QString FlipDistortNode::name() const
|
||||
{
|
||||
return tr("Flip");
|
||||
}
|
||||
@@ -53,45 +53,45 @@ QString FlipDistortNode::id() const
|
||||
return QStringLiteral("org.olivevideoeditor.Olive.flip");
|
||||
}
|
||||
|
||||
QVector<Node::CategoryID> FlipDistortNode::Category() const
|
||||
QVector<Node::CategoryID> FlipDistortNode::category() const
|
||||
{
|
||||
return { kCategoryDistort };
|
||||
return { k_category_distort };
|
||||
}
|
||||
|
||||
QString FlipDistortNode::Description() const
|
||||
QString FlipDistortNode::description() const
|
||||
{
|
||||
return tr("Flips an image horizontally or vertically");
|
||||
}
|
||||
|
||||
void FlipDistortNode::Retranslate()
|
||||
void FlipDistortNode::retranslate()
|
||||
{
|
||||
super::Retranslate();
|
||||
super::retranslate();
|
||||
|
||||
SetInputName(kTextureInput, tr("Input"));
|
||||
SetInputName(kHorizontalInput, tr("Horizontal"));
|
||||
SetInputName(kVerticalInput, tr("Vertical"));
|
||||
set_input_name(k_texture_input, tr("Input"));
|
||||
set_input_name(k_horizontal_input, tr("Horizontal"));
|
||||
set_input_name(k_vertical_input, tr("Vertical"));
|
||||
}
|
||||
|
||||
ShaderCode FlipDistortNode::GetShaderCode(const ShaderRequest &request) const
|
||||
ShaderCode FlipDistortNode::get_shader_code(const ShaderRequest &request) const
|
||||
{
|
||||
Q_UNUSED(request)
|
||||
return ShaderCode(FileFunctions::ReadFileAsString(":/shaders/flip.frag"));
|
||||
return ShaderCode(FileFunctions::read_file_as_string(":/shaders/flip.frag"));
|
||||
}
|
||||
|
||||
void FlipDistortNode::Value(const NodeValueRow &value,
|
||||
void FlipDistortNode::value(const NodeValueRow &value,
|
||||
const NodeGlobals &globals,
|
||||
NodeValueTable *table) const
|
||||
{
|
||||
// If there's no texture, no need to run an operation
|
||||
if (TexturePtr tex = value[kTextureInput].toTexture()) {
|
||||
if (TexturePtr tex = value[k_texture_input].to_texture()) {
|
||||
// Only run shader if at least one of flip or flop are selected
|
||||
if (value[kHorizontalInput].toBool() ||
|
||||
value[kVerticalInput].toBool()) {
|
||||
table->Push(NodeValue::kTexture, tex->toJob(ShaderJob(value)),
|
||||
if (value[k_horizontal_input].to_bool() ||
|
||||
value[k_vertical_input].to_bool()) {
|
||||
table->push(NodeValue::k_texture, tex->to_job(ShaderJob(value)),
|
||||
this);
|
||||
} else {
|
||||
// If we're not flipping or flopping just push the texture
|
||||
table->Push(value[kTextureInput]);
|
||||
table->push(value[k_texture_input]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef FLIPDISTORTNODE_H
|
||||
#define FLIPDISTORTNODE_H
|
||||
#ifndef OAK_FLIPDISTORTNODE_H
|
||||
#define OAK_FLIPDISTORTNODE_H
|
||||
|
||||
#include "node/node.h"
|
||||
|
||||
@@ -34,23 +34,23 @@ public:
|
||||
|
||||
NODE_DEFAULT_FUNCTIONS(FlipDistortNode)
|
||||
|
||||
virtual QString Name() const override;
|
||||
virtual QString name() const override;
|
||||
virtual QString id() const override;
|
||||
virtual QVector<CategoryID> Category() const override;
|
||||
virtual QString Description() const override;
|
||||
virtual QVector<CategoryID> category() const override;
|
||||
virtual QString description() const override;
|
||||
|
||||
virtual void Retranslate() override;
|
||||
virtual void retranslate() override;
|
||||
|
||||
virtual ShaderCode
|
||||
GetShaderCode(const ShaderRequest &request) const override;
|
||||
virtual void Value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
get_shader_code(const ShaderRequest &request) const override;
|
||||
virtual void value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
NodeValueTable *table) const override;
|
||||
|
||||
static const QString kTextureInput;
|
||||
static const QString kHorizontalInput;
|
||||
static const QString kVerticalInput;
|
||||
static const QString k_texture_input;
|
||||
static const QString k_horizontal_input;
|
||||
static const QString k_vertical_input;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // FLIPDISTORTNODE_H
|
||||
#endif // OAK_FLIPDISTORTNODE_H
|
||||
|
||||
@@ -28,105 +28,105 @@ namespace olive
|
||||
|
||||
#define super PolygonGenerator
|
||||
|
||||
const QString MaskDistortNode::kFeatherInput = QStringLiteral("feather_in");
|
||||
const QString MaskDistortNode::kInvertInput = QStringLiteral("invert_in");
|
||||
const QString MaskDistortNode::k_feather_input = QStringLiteral("feather_in");
|
||||
const QString MaskDistortNode::k_invert_input = QStringLiteral("invert_in");
|
||||
|
||||
MaskDistortNode::MaskDistortNode()
|
||||
{
|
||||
// Mask should always be (1.0, 1.0, 1.0) for multiply to work correctly
|
||||
SetInputFlag(kColorInput, kInputFlagHidden);
|
||||
set_input_flag(k_color_input, k_input_flag_hidden);
|
||||
|
||||
AddInput(kInvertInput, NodeValue::kBoolean, false);
|
||||
add_input(k_invert_input, NodeValue::k_boolean, false);
|
||||
|
||||
AddInput(kFeatherInput, NodeValue::kFloat, 0.0);
|
||||
SetInputProperty(kFeatherInput, QStringLiteral("min"), 0.0);
|
||||
add_input(k_feather_input, NodeValue::k_float, 0.0);
|
||||
set_input_property(k_feather_input, QStringLiteral("min"), 0.0);
|
||||
}
|
||||
|
||||
ShaderCode MaskDistortNode::GetShaderCode(const ShaderRequest &request) const
|
||||
ShaderCode MaskDistortNode::get_shader_code(const ShaderRequest &request) const
|
||||
{
|
||||
if (request.id == QStringLiteral("mrg")) {
|
||||
return ShaderCode(FileFunctions::ReadFileAsString(
|
||||
return ShaderCode(FileFunctions::read_file_as_string(
|
||||
QStringLiteral(":/shaders/multiply.frag")));
|
||||
} else if (request.id == QStringLiteral("feather")) {
|
||||
return ShaderCode(FileFunctions::ReadFileAsString(
|
||||
return ShaderCode(FileFunctions::read_file_as_string(
|
||||
QStringLiteral(":/shaders/blur.frag")));
|
||||
} else if (request.id == QStringLiteral("invert")) {
|
||||
return ShaderCode(FileFunctions::ReadFileAsString(
|
||||
return ShaderCode(FileFunctions::read_file_as_string(
|
||||
QStringLiteral(":/shaders/invertrgba.frag")));
|
||||
} else {
|
||||
return super::GetShaderCode(request);
|
||||
return super::get_shader_code(request);
|
||||
}
|
||||
}
|
||||
|
||||
void MaskDistortNode::Retranslate()
|
||||
void MaskDistortNode::retranslate()
|
||||
{
|
||||
super::Retranslate();
|
||||
super::retranslate();
|
||||
|
||||
SetInputName(kBaseInput, tr("Texture"));
|
||||
SetInputName(kInvertInput, tr("Invert"));
|
||||
SetInputName(kFeatherInput, tr("Feather"));
|
||||
set_input_name(k_base_input, tr("Texture"));
|
||||
set_input_name(k_invert_input, tr("Invert"));
|
||||
set_input_name(k_feather_input, tr("Feather"));
|
||||
}
|
||||
|
||||
void MaskDistortNode::Value(const NodeValueRow &value,
|
||||
void MaskDistortNode::value(const NodeValueRow &value,
|
||||
const NodeGlobals &globals,
|
||||
NodeValueTable *table) const
|
||||
{
|
||||
TexturePtr texture = value[kBaseInput].toTexture();
|
||||
TexturePtr texture = value[k_base_input].to_texture();
|
||||
|
||||
VideoParams job_params = texture ? texture->params() : globals.vparams();
|
||||
NodeValue job(NodeValue::kTexture,
|
||||
Texture::Job(job_params, GetGenerateJob(value, job_params)),
|
||||
NodeValue job(NodeValue::k_texture,
|
||||
Texture::job(job_params, get_generate_job(value, job_params)),
|
||||
this);
|
||||
|
||||
if (value[kInvertInput].toBool()) {
|
||||
if (value[k_invert_input].to_bool()) {
|
||||
ShaderJob invert;
|
||||
invert.SetShaderID(QStringLiteral("invert"));
|
||||
invert.Insert(QStringLiteral("tex_in"), job);
|
||||
job.set_value(Texture::Job(job_params, invert));
|
||||
invert.set_shader_id(QStringLiteral("invert"));
|
||||
invert.insert(QStringLiteral("tex_in"), job);
|
||||
job.set_value(Texture::job(job_params, invert));
|
||||
}
|
||||
|
||||
if (texture) {
|
||||
// Push as merge node
|
||||
ShaderJob merge;
|
||||
|
||||
merge.SetShaderID(QStringLiteral("mrg"));
|
||||
merge.Insert(QStringLiteral("tex_a"), value[kBaseInput]);
|
||||
merge.set_shader_id(QStringLiteral("mrg"));
|
||||
merge.insert(QStringLiteral("tex_a"), value[k_base_input]);
|
||||
|
||||
if (value[kFeatherInput].toDouble() > 0.0) {
|
||||
if (value[k_feather_input].to_double() > 0.0) {
|
||||
// Nest a blur shader in there too
|
||||
ShaderJob feather;
|
||||
|
||||
feather.SetShaderID(QStringLiteral("feather"));
|
||||
feather.Insert(BlurFilterNode::kTextureInput, job);
|
||||
feather.Insert(BlurFilterNode::kMethodInput,
|
||||
NodeValue(NodeValue::kInt,
|
||||
int(BlurFilterNode::kGaussian), this));
|
||||
feather.Insert(BlurFilterNode::kHorizInput,
|
||||
NodeValue(NodeValue::kBoolean, true, this));
|
||||
feather.Insert(BlurFilterNode::kVertInput,
|
||||
NodeValue(NodeValue::kBoolean, true, this));
|
||||
feather.Insert(BlurFilterNode::kRepeatEdgePixelsInput,
|
||||
NodeValue(NodeValue::kBoolean, true, this));
|
||||
feather.Insert(BlurFilterNode::kRadiusInput,
|
||||
NodeValue(NodeValue::kFloat,
|
||||
value[kFeatherInput].toDouble(), this));
|
||||
feather.SetIterations(2, BlurFilterNode::kTextureInput);
|
||||
feather.Insert(QStringLiteral("resolution_in"),
|
||||
NodeValue(NodeValue::kVec2,
|
||||
feather.set_shader_id(QStringLiteral("feather"));
|
||||
feather.insert(BlurFilterNode::k_texture_input, job);
|
||||
feather.insert(BlurFilterNode::k_method_input,
|
||||
NodeValue(NodeValue::k_int,
|
||||
int(BlurFilterNode::k_gaussian), this));
|
||||
feather.insert(BlurFilterNode::k_horiz_input,
|
||||
NodeValue(NodeValue::k_boolean, true, this));
|
||||
feather.insert(BlurFilterNode::k_vert_input,
|
||||
NodeValue(NodeValue::k_boolean, true, this));
|
||||
feather.insert(BlurFilterNode::k_repeat_edge_pixels_input,
|
||||
NodeValue(NodeValue::k_boolean, true, this));
|
||||
feather.insert(BlurFilterNode::k_radius_input,
|
||||
NodeValue(NodeValue::k_float,
|
||||
value[k_feather_input].to_double(), this));
|
||||
feather.set_iterations(2, BlurFilterNode::k_texture_input);
|
||||
feather.insert(QStringLiteral("resolution_in"),
|
||||
NodeValue(NodeValue::k_vec2,
|
||||
texture ? texture->virtual_resolution() :
|
||||
globals.square_resolution(),
|
||||
this));
|
||||
|
||||
merge.Insert(QStringLiteral("tex_b"),
|
||||
NodeValue(NodeValue::kTexture,
|
||||
Texture::Job(job_params, feather), this));
|
||||
merge.insert(QStringLiteral("tex_b"),
|
||||
NodeValue(NodeValue::k_texture,
|
||||
Texture::job(job_params, feather), this));
|
||||
} else {
|
||||
merge.Insert(QStringLiteral("tex_b"), job);
|
||||
merge.insert(QStringLiteral("tex_b"), job);
|
||||
}
|
||||
|
||||
table->Push(NodeValue::kTexture, Texture::Job(job_params, merge), this);
|
||||
table->push(NodeValue::k_texture, Texture::job(job_params, merge), this);
|
||||
} else {
|
||||
table->Push(job);
|
||||
table->push(job);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef MASKDISTORTNODE_H
|
||||
#define MASKDISTORTNODE_H
|
||||
#ifndef OAK_MASKDISTORTNODE_H
|
||||
#define OAK_MASKDISTORTNODE_H
|
||||
|
||||
#include "node/generator/polygon/polygon.h"
|
||||
|
||||
@@ -34,7 +34,7 @@ public:
|
||||
|
||||
NODE_DEFAULT_FUNCTIONS(MaskDistortNode)
|
||||
|
||||
virtual QString Name() const override
|
||||
virtual QString name() const override
|
||||
{
|
||||
return tr("Mask");
|
||||
}
|
||||
@@ -44,28 +44,28 @@ public:
|
||||
return QStringLiteral("org.olivevideoeditor.Olive.mask");
|
||||
}
|
||||
|
||||
virtual QVector<CategoryID> Category() const override
|
||||
virtual QVector<CategoryID> category() const override
|
||||
{
|
||||
return { kCategoryDistort };
|
||||
return { k_category_distort };
|
||||
}
|
||||
|
||||
virtual QString Description() const override
|
||||
virtual QString description() const override
|
||||
{
|
||||
return tr("Apply a polygonal mask.");
|
||||
}
|
||||
|
||||
virtual ShaderCode
|
||||
GetShaderCode(const ShaderRequest &request) const override;
|
||||
get_shader_code(const ShaderRequest &request) const override;
|
||||
|
||||
virtual void Retranslate() override;
|
||||
virtual void retranslate() override;
|
||||
|
||||
virtual void Value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
virtual void value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
NodeValueTable *table) const override;
|
||||
|
||||
static const QString kInvertInput;
|
||||
static const QString kFeatherInput;
|
||||
static const QString k_invert_input;
|
||||
static const QString k_feather_input;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // MASKDISTORTNODE_H
|
||||
#endif // OAK_MASKDISTORTNODE_H
|
||||
|
||||
@@ -24,43 +24,43 @@
|
||||
namespace olive
|
||||
{
|
||||
|
||||
const QString RippleDistortNode::kTextureInput = QStringLiteral("tex_in");
|
||||
const QString RippleDistortNode::kEvolutionInput =
|
||||
const QString RippleDistortNode::k_texture_input = QStringLiteral("tex_in");
|
||||
const QString RippleDistortNode::k_evolution_input =
|
||||
QStringLiteral("evolution_in");
|
||||
const QString RippleDistortNode::kIntensityInput =
|
||||
const QString RippleDistortNode::k_intensity_input =
|
||||
QStringLiteral("intensity_in");
|
||||
const QString RippleDistortNode::kFrequencyInput =
|
||||
const QString RippleDistortNode::k_frequency_input =
|
||||
QStringLiteral("frequency_in");
|
||||
const QString RippleDistortNode::kPositionInput = QStringLiteral("position_in");
|
||||
const QString RippleDistortNode::kStretchInput = QStringLiteral("stretch_in");
|
||||
const QString RippleDistortNode::k_position_input = QStringLiteral("position_in");
|
||||
const QString RippleDistortNode::k_stretch_input = QStringLiteral("stretch_in");
|
||||
|
||||
#define super Node
|
||||
|
||||
RippleDistortNode::RippleDistortNode()
|
||||
{
|
||||
AddInput(kTextureInput, NodeValue::kTexture,
|
||||
InputFlags(kInputFlagNotKeyframable));
|
||||
add_input(k_texture_input, NodeValue::k_texture,
|
||||
InputFlags(k_input_flag_not_keyframable));
|
||||
|
||||
AddInput(kEvolutionInput, NodeValue::kFloat, 0);
|
||||
AddInput(kIntensityInput, NodeValue::kFloat, 100);
|
||||
add_input(k_evolution_input, NodeValue::k_float, 0);
|
||||
add_input(k_intensity_input, NodeValue::k_float, 100);
|
||||
|
||||
AddInput(kFrequencyInput, NodeValue::kFloat, 1);
|
||||
SetInputProperty(kFrequencyInput, QStringLiteral("base"), 0.01);
|
||||
add_input(k_frequency_input, NodeValue::k_float, 1);
|
||||
set_input_property(k_frequency_input, QStringLiteral("base"), 0.01);
|
||||
|
||||
AddInput(kPositionInput, NodeValue::kVec2, QVector2D(0, 0));
|
||||
AddInput(kStretchInput, NodeValue::kBoolean, false);
|
||||
add_input(k_position_input, NodeValue::k_vec2, QVector2D(0, 0));
|
||||
add_input(k_stretch_input, NodeValue::k_boolean, false);
|
||||
|
||||
SetFlag(kVideoEffect);
|
||||
SetEffectInput(kTextureInput);
|
||||
set_flag(k_video_effect);
|
||||
set_effect_input(k_texture_input);
|
||||
|
||||
gizmo_ = AddDraggableGizmo<PointGizmo>({
|
||||
NodeKeyframeTrackReference(NodeInput(this, kPositionInput), 0),
|
||||
NodeKeyframeTrackReference(NodeInput(this, kPositionInput), 1),
|
||||
gizmo_ = add_draggable_gizmo<PointGizmo>({
|
||||
NodeKeyframeTrackReference(NodeInput(this, k_position_input), 0),
|
||||
NodeKeyframeTrackReference(NodeInput(this, k_position_input), 1),
|
||||
});
|
||||
gizmo_->SetShape(PointGizmo::kAnchorPoint);
|
||||
gizmo_->set_shape(PointGizmo::k_anchor_point);
|
||||
}
|
||||
|
||||
QString RippleDistortNode::Name() const
|
||||
QString RippleDistortNode::name() const
|
||||
{
|
||||
return tr("Ripple");
|
||||
}
|
||||
@@ -70,72 +70,72 @@ QString RippleDistortNode::id() const
|
||||
return QStringLiteral("org.olivevideoeditor.Olive.ripple");
|
||||
}
|
||||
|
||||
QVector<Node::CategoryID> RippleDistortNode::Category() const
|
||||
QVector<Node::CategoryID> RippleDistortNode::category() const
|
||||
{
|
||||
return { kCategoryDistort };
|
||||
return { k_category_distort };
|
||||
}
|
||||
|
||||
QString RippleDistortNode::Description() const
|
||||
QString RippleDistortNode::description() const
|
||||
{
|
||||
return tr("Distorts an image with a ripple effect.");
|
||||
}
|
||||
|
||||
void RippleDistortNode::Retranslate()
|
||||
void RippleDistortNode::retranslate()
|
||||
{
|
||||
super::Retranslate();
|
||||
super::retranslate();
|
||||
|
||||
SetInputName(kTextureInput, tr("Input"));
|
||||
SetInputName(kFrequencyInput, tr("Frequency"));
|
||||
SetInputName(kIntensityInput, tr("Intensity"));
|
||||
SetInputName(kEvolutionInput, tr("Evolution"));
|
||||
SetInputName(kPositionInput, tr("Position"));
|
||||
SetInputName(kStretchInput, tr("Stretch"));
|
||||
set_input_name(k_texture_input, tr("Input"));
|
||||
set_input_name(k_frequency_input, tr("Frequency"));
|
||||
set_input_name(k_intensity_input, tr("Intensity"));
|
||||
set_input_name(k_evolution_input, tr("Evolution"));
|
||||
set_input_name(k_position_input, tr("Position"));
|
||||
set_input_name(k_stretch_input, tr("Stretch"));
|
||||
}
|
||||
|
||||
ShaderCode RippleDistortNode::GetShaderCode(const ShaderRequest &request) const
|
||||
ShaderCode RippleDistortNode::get_shader_code(const ShaderRequest &request) const
|
||||
{
|
||||
Q_UNUSED(request)
|
||||
return ShaderCode(FileFunctions::ReadFileAsString(":/shaders/ripple.frag"));
|
||||
return ShaderCode(FileFunctions::read_file_as_string(":/shaders/ripple.frag"));
|
||||
}
|
||||
|
||||
void RippleDistortNode::Value(const NodeValueRow &value,
|
||||
void RippleDistortNode::value(const NodeValueRow &value,
|
||||
const NodeGlobals &globals,
|
||||
NodeValueTable *table) const
|
||||
{
|
||||
// If there's no texture, no need to run an operation
|
||||
if (TexturePtr tex = value[kTextureInput].toTexture()) {
|
||||
if (TexturePtr tex = value[k_texture_input].to_texture()) {
|
||||
// Only run shader if at least one of flip or flop are selected
|
||||
if (!qIsNull(value[kIntensityInput].toDouble())) {
|
||||
if (!qIsNull(value[k_intensity_input].to_double())) {
|
||||
ShaderJob job(value);
|
||||
job.Insert(QStringLiteral("resolution_in"),
|
||||
NodeValue(NodeValue::kVec2, tex->virtual_resolution(),
|
||||
job.insert(QStringLiteral("resolution_in"),
|
||||
NodeValue(NodeValue::k_vec2, tex->virtual_resolution(),
|
||||
this));
|
||||
table->Push(NodeValue::kTexture, tex->toJob(job), this);
|
||||
table->push(NodeValue::k_texture, tex->to_job(job), this);
|
||||
} else {
|
||||
// If we're not flipping or flopping just push the texture
|
||||
table->Push(value[kTextureInput]);
|
||||
table->push(value[k_texture_input]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RippleDistortNode::UpdateGizmoPositions(const NodeValueRow &row,
|
||||
void RippleDistortNode::update_gizmo_positions(const NodeValueRow &row,
|
||||
const NodeGlobals &globals)
|
||||
{
|
||||
if (TexturePtr tex = row[kTextureInput].toTexture()) {
|
||||
if (TexturePtr tex = row[k_texture_input].to_texture()) {
|
||||
QPointF half_res(tex->virtual_resolution().x() / 2,
|
||||
tex->virtual_resolution().y() / 2);
|
||||
gizmo_->SetPoint(half_res + row[kPositionInput].toVec2().toPointF());
|
||||
gizmo_->set_point(half_res + row[k_position_input].to_vec2().toPointF());
|
||||
}
|
||||
}
|
||||
|
||||
void RippleDistortNode::GizmoDragMove(double x, double y,
|
||||
void RippleDistortNode::gizmo_drag_move(double x, double y,
|
||||
const Qt::KeyboardModifiers &modifiers)
|
||||
{
|
||||
NodeInputDragger &x_drag = gizmo_->GetDraggers()[0];
|
||||
NodeInputDragger &y_drag = gizmo_->GetDraggers()[1];
|
||||
NodeInputDragger &x_drag = gizmo_->get_draggers()[0];
|
||||
NodeInputDragger &y_drag = gizmo_->get_draggers()[1];
|
||||
|
||||
x_drag.Drag(x_drag.GetStartValue().toDouble() + x);
|
||||
y_drag.Drag(y_drag.GetStartValue().toDouble() + y);
|
||||
x_drag.drag(x_drag.get_start_value().toDouble() + x);
|
||||
y_drag.drag(y_drag.get_start_value().toDouble() + y);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef RIPPLEDISTORTNODE_H
|
||||
#define RIPPLEDISTORTNODE_H
|
||||
#ifndef OAK_RIPPLEDISTORTNODE_H
|
||||
#define OAK_RIPPLEDISTORTNODE_H
|
||||
|
||||
#include "node/gizmo/point.h"
|
||||
#include "node/node.h"
|
||||
@@ -35,30 +35,30 @@ public:
|
||||
|
||||
NODE_DEFAULT_FUNCTIONS(RippleDistortNode)
|
||||
|
||||
virtual QString Name() const override;
|
||||
virtual QString name() const override;
|
||||
virtual QString id() const override;
|
||||
virtual QVector<CategoryID> Category() const override;
|
||||
virtual QString Description() const override;
|
||||
virtual QVector<CategoryID> category() const override;
|
||||
virtual QString description() const override;
|
||||
|
||||
virtual void Retranslate() override;
|
||||
virtual void retranslate() override;
|
||||
|
||||
virtual ShaderCode
|
||||
GetShaderCode(const ShaderRequest &request) const override;
|
||||
virtual void Value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
get_shader_code(const ShaderRequest &request) const override;
|
||||
virtual void value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
NodeValueTable *table) const override;
|
||||
|
||||
virtual void UpdateGizmoPositions(const NodeValueRow &row,
|
||||
virtual void update_gizmo_positions(const NodeValueRow &row,
|
||||
const NodeGlobals &globals) override;
|
||||
|
||||
static const QString kTextureInput;
|
||||
static const QString kEvolutionInput;
|
||||
static const QString kIntensityInput;
|
||||
static const QString kFrequencyInput;
|
||||
static const QString kPositionInput;
|
||||
static const QString kStretchInput;
|
||||
static const QString k_texture_input;
|
||||
static const QString k_evolution_input;
|
||||
static const QString k_intensity_input;
|
||||
static const QString k_frequency_input;
|
||||
static const QString k_position_input;
|
||||
static const QString k_stretch_input;
|
||||
|
||||
protected slots:
|
||||
virtual void GizmoDragMove(double x, double y,
|
||||
virtual void gizmo_drag_move(double x, double y,
|
||||
const Qt::KeyboardModifiers &modifiers) override;
|
||||
|
||||
private:
|
||||
@@ -67,4 +67,4 @@ private:
|
||||
|
||||
}
|
||||
|
||||
#endif // RIPPLEDISTORTNODE_H
|
||||
#endif // OAK_RIPPLEDISTORTNODE_H
|
||||
|
||||
@@ -24,37 +24,37 @@
|
||||
namespace olive
|
||||
{
|
||||
|
||||
const QString SwirlDistortNode::kTextureInput = QStringLiteral("tex_in");
|
||||
const QString SwirlDistortNode::kRadiusInput = QStringLiteral("radius_in");
|
||||
const QString SwirlDistortNode::kAngleInput = QStringLiteral("angle_in");
|
||||
const QString SwirlDistortNode::kPositionInput = QStringLiteral("pos_in");
|
||||
const QString SwirlDistortNode::k_texture_input = QStringLiteral("tex_in");
|
||||
const QString SwirlDistortNode::k_radius_input = QStringLiteral("radius_in");
|
||||
const QString SwirlDistortNode::k_angle_input = QStringLiteral("angle_in");
|
||||
const QString SwirlDistortNode::k_position_input = QStringLiteral("pos_in");
|
||||
|
||||
#define super Node
|
||||
|
||||
SwirlDistortNode::SwirlDistortNode()
|
||||
{
|
||||
AddInput(kTextureInput, NodeValue::kTexture,
|
||||
InputFlags(kInputFlagNotKeyframable));
|
||||
add_input(k_texture_input, NodeValue::k_texture,
|
||||
InputFlags(k_input_flag_not_keyframable));
|
||||
|
||||
AddInput(kRadiusInput, NodeValue::kFloat, 200);
|
||||
SetInputProperty(kRadiusInput, QStringLiteral("min"), 0);
|
||||
add_input(k_radius_input, NodeValue::k_float, 200);
|
||||
set_input_property(k_radius_input, QStringLiteral("min"), 0);
|
||||
|
||||
AddInput(kAngleInput, NodeValue::kFloat, 10);
|
||||
SetInputProperty(kAngleInput, QStringLiteral("base"), 0.1);
|
||||
add_input(k_angle_input, NodeValue::k_float, 10);
|
||||
set_input_property(k_angle_input, QStringLiteral("base"), 0.1);
|
||||
|
||||
AddInput(kPositionInput, NodeValue::kVec2, QVector2D(0, 0));
|
||||
add_input(k_position_input, NodeValue::k_vec2, QVector2D(0, 0));
|
||||
|
||||
SetFlag(kVideoEffect);
|
||||
SetEffectInput(kTextureInput);
|
||||
set_flag(k_video_effect);
|
||||
set_effect_input(k_texture_input);
|
||||
|
||||
gizmo_ = AddDraggableGizmo<PointGizmo>({
|
||||
NodeKeyframeTrackReference(NodeInput(this, kPositionInput), 0),
|
||||
NodeKeyframeTrackReference(NodeInput(this, kPositionInput), 1),
|
||||
gizmo_ = add_draggable_gizmo<PointGizmo>({
|
||||
NodeKeyframeTrackReference(NodeInput(this, k_position_input), 0),
|
||||
NodeKeyframeTrackReference(NodeInput(this, k_position_input), 1),
|
||||
});
|
||||
gizmo_->SetShape(PointGizmo::kAnchorPoint);
|
||||
gizmo_->set_shape(PointGizmo::k_anchor_point);
|
||||
}
|
||||
|
||||
QString SwirlDistortNode::Name() const
|
||||
QString SwirlDistortNode::name() const
|
||||
{
|
||||
return tr("Swirl");
|
||||
}
|
||||
@@ -64,70 +64,70 @@ QString SwirlDistortNode::id() const
|
||||
return QStringLiteral("org.olivevideoeditor.Olive.swirl");
|
||||
}
|
||||
|
||||
QVector<Node::CategoryID> SwirlDistortNode::Category() const
|
||||
QVector<Node::CategoryID> SwirlDistortNode::category() const
|
||||
{
|
||||
return { kCategoryDistort };
|
||||
return { k_category_distort };
|
||||
}
|
||||
|
||||
QString SwirlDistortNode::Description() const
|
||||
QString SwirlDistortNode::description() const
|
||||
{
|
||||
return tr("Distorts an image by swirling it around a center point.");
|
||||
}
|
||||
|
||||
void SwirlDistortNode::Retranslate()
|
||||
void SwirlDistortNode::retranslate()
|
||||
{
|
||||
super::Retranslate();
|
||||
super::retranslate();
|
||||
|
||||
SetInputName(kTextureInput, tr("Input"));
|
||||
SetInputName(kRadiusInput, tr("Radius"));
|
||||
SetInputName(kAngleInput, tr("Angle"));
|
||||
SetInputName(kPositionInput, tr("Position"));
|
||||
set_input_name(k_texture_input, tr("Input"));
|
||||
set_input_name(k_radius_input, tr("Radius"));
|
||||
set_input_name(k_angle_input, tr("Angle"));
|
||||
set_input_name(k_position_input, tr("Position"));
|
||||
}
|
||||
|
||||
ShaderCode SwirlDistortNode::GetShaderCode(const ShaderRequest &request) const
|
||||
ShaderCode SwirlDistortNode::get_shader_code(const ShaderRequest &request) const
|
||||
{
|
||||
Q_UNUSED(request)
|
||||
return ShaderCode(FileFunctions::ReadFileAsString(":/shaders/swirl.frag"));
|
||||
return ShaderCode(FileFunctions::read_file_as_string(":/shaders/swirl.frag"));
|
||||
}
|
||||
|
||||
void SwirlDistortNode::Value(const NodeValueRow &value,
|
||||
void SwirlDistortNode::value(const NodeValueRow &value,
|
||||
const NodeGlobals &globals,
|
||||
NodeValueTable *table) const
|
||||
{
|
||||
// If there's no texture, no need to run an operation
|
||||
if (TexturePtr tex = value[kTextureInput].toTexture()) {
|
||||
if (TexturePtr tex = value[k_texture_input].to_texture()) {
|
||||
// Only run shader if at least one of flip or flop are selected
|
||||
if (!qIsNull(value[kAngleInput].toDouble()) &&
|
||||
!qIsNull(value[kRadiusInput].toDouble())) {
|
||||
if (!qIsNull(value[k_angle_input].to_double()) &&
|
||||
!qIsNull(value[k_radius_input].to_double())) {
|
||||
ShaderJob job(value);
|
||||
job.Insert(QStringLiteral("resolution_in"),
|
||||
NodeValue(NodeValue::kVec2, tex->virtual_resolution(),
|
||||
job.insert(QStringLiteral("resolution_in"),
|
||||
NodeValue(NodeValue::k_vec2, tex->virtual_resolution(),
|
||||
this));
|
||||
table->Push(NodeValue::kTexture, tex->toJob(job), this);
|
||||
table->push(NodeValue::k_texture, tex->to_job(job), this);
|
||||
} else {
|
||||
// If we're not flipping or flopping just push the texture
|
||||
table->Push(value[kTextureInput]);
|
||||
table->push(value[k_texture_input]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SwirlDistortNode::UpdateGizmoPositions(const NodeValueRow &row,
|
||||
void SwirlDistortNode::update_gizmo_positions(const NodeValueRow &row,
|
||||
const NodeGlobals &globals)
|
||||
{
|
||||
QPointF half_res(globals.square_resolution().x() / 2,
|
||||
globals.square_resolution().y() / 2);
|
||||
|
||||
gizmo_->SetPoint(half_res + row[kPositionInput].toVec2().toPointF());
|
||||
gizmo_->set_point(half_res + row[k_position_input].to_vec2().toPointF());
|
||||
}
|
||||
|
||||
void SwirlDistortNode::GizmoDragMove(double x, double y,
|
||||
void SwirlDistortNode::gizmo_drag_move(double x, double y,
|
||||
const Qt::KeyboardModifiers &modifiers)
|
||||
{
|
||||
NodeInputDragger &x_drag = gizmo_->GetDraggers()[0];
|
||||
NodeInputDragger &y_drag = gizmo_->GetDraggers()[1];
|
||||
NodeInputDragger &x_drag = gizmo_->get_draggers()[0];
|
||||
NodeInputDragger &y_drag = gizmo_->get_draggers()[1];
|
||||
|
||||
x_drag.Drag(x_drag.GetStartValue().toDouble() + x);
|
||||
y_drag.Drag(y_drag.GetStartValue().toDouble() + y);
|
||||
x_drag.drag(x_drag.get_start_value().toDouble() + x);
|
||||
y_drag.drag(y_drag.get_start_value().toDouble() + y);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef SWIRLDISTORTNODE_H
|
||||
#define SWIRLDISTORTNODE_H
|
||||
#ifndef OAK_SWIRLDISTORTNODE_H
|
||||
#define OAK_SWIRLDISTORTNODE_H
|
||||
|
||||
#include "node/gizmo/point.h"
|
||||
#include "node/node.h"
|
||||
@@ -35,28 +35,28 @@ public:
|
||||
|
||||
NODE_DEFAULT_FUNCTIONS(SwirlDistortNode)
|
||||
|
||||
virtual QString Name() const override;
|
||||
virtual QString name() const override;
|
||||
virtual QString id() const override;
|
||||
virtual QVector<CategoryID> Category() const override;
|
||||
virtual QString Description() const override;
|
||||
virtual QVector<CategoryID> category() const override;
|
||||
virtual QString description() const override;
|
||||
|
||||
virtual void Retranslate() override;
|
||||
virtual void retranslate() override;
|
||||
|
||||
virtual ShaderCode
|
||||
GetShaderCode(const ShaderRequest &request) const override;
|
||||
virtual void Value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
get_shader_code(const ShaderRequest &request) const override;
|
||||
virtual void value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
NodeValueTable *table) const override;
|
||||
|
||||
virtual void UpdateGizmoPositions(const NodeValueRow &row,
|
||||
virtual void update_gizmo_positions(const NodeValueRow &row,
|
||||
const NodeGlobals &globals) override;
|
||||
|
||||
static const QString kTextureInput;
|
||||
static const QString kRadiusInput;
|
||||
static const QString kAngleInput;
|
||||
static const QString kPositionInput;
|
||||
static const QString k_texture_input;
|
||||
static const QString k_radius_input;
|
||||
static const QString k_angle_input;
|
||||
static const QString k_position_input;
|
||||
|
||||
protected slots:
|
||||
virtual void GizmoDragMove(double x, double y,
|
||||
virtual void gizmo_drag_move(double x, double y,
|
||||
const Qt::KeyboardModifiers &modifiers) override;
|
||||
|
||||
private:
|
||||
@@ -65,4 +65,4 @@ private:
|
||||
|
||||
}
|
||||
|
||||
#endif // SWIRLDISTORTNODE_H
|
||||
#endif // OAK_SWIRLDISTORTNODE_H
|
||||
|
||||
@@ -26,43 +26,43 @@
|
||||
namespace olive
|
||||
{
|
||||
|
||||
const QString TileDistortNode::kTextureInput = QStringLiteral("tex_in");
|
||||
const QString TileDistortNode::kScaleInput = QStringLiteral("scale_in");
|
||||
const QString TileDistortNode::kPositionInput = QStringLiteral("position_in");
|
||||
const QString TileDistortNode::kAnchorInput = QStringLiteral("anchor_in");
|
||||
const QString TileDistortNode::kMirrorXInput = QStringLiteral("mirrorx_in");
|
||||
const QString TileDistortNode::kMirrorYInput = QStringLiteral("mirrory_in");
|
||||
const QString TileDistortNode::k_texture_input = QStringLiteral("tex_in");
|
||||
const QString TileDistortNode::k_scale_input = QStringLiteral("scale_in");
|
||||
const QString TileDistortNode::k_position_input = QStringLiteral("position_in");
|
||||
const QString TileDistortNode::k_anchor_input = QStringLiteral("anchor_in");
|
||||
const QString TileDistortNode::k_mirror_x_input = QStringLiteral("mirrorx_in");
|
||||
const QString TileDistortNode::k_mirror_y_input = QStringLiteral("mirrory_in");
|
||||
|
||||
#define super Node
|
||||
|
||||
TileDistortNode::TileDistortNode()
|
||||
{
|
||||
AddInput(kTextureInput, NodeValue::kTexture,
|
||||
InputFlags(kInputFlagNotKeyframable));
|
||||
add_input(k_texture_input, NodeValue::k_texture,
|
||||
InputFlags(k_input_flag_not_keyframable));
|
||||
|
||||
AddInput(kScaleInput, NodeValue::kFloat, 0.5);
|
||||
SetInputProperty(kScaleInput, QStringLiteral("min"), 0);
|
||||
SetInputProperty(kScaleInput, QStringLiteral("view"),
|
||||
FloatSlider::kPercentage);
|
||||
add_input(k_scale_input, NodeValue::k_float, 0.5);
|
||||
set_input_property(k_scale_input, QStringLiteral("min"), 0);
|
||||
set_input_property(k_scale_input, QStringLiteral("view"),
|
||||
FloatSlider::k_percentage);
|
||||
|
||||
AddInput(kPositionInput, NodeValue::kVec2, QVector2D(0, 0));
|
||||
add_input(k_position_input, NodeValue::k_vec2, QVector2D(0, 0));
|
||||
|
||||
AddInput(kAnchorInput, NodeValue::kCombo, kMiddleCenter);
|
||||
add_input(k_anchor_input, NodeValue::k_combo, k_middle_center);
|
||||
|
||||
AddInput(kMirrorXInput, NodeValue::kBoolean, false);
|
||||
AddInput(kMirrorYInput, NodeValue::kBoolean, false);
|
||||
add_input(k_mirror_x_input, NodeValue::k_boolean, false);
|
||||
add_input(k_mirror_y_input, NodeValue::k_boolean, false);
|
||||
|
||||
SetFlag(kVideoEffect);
|
||||
SetEffectInput(kTextureInput);
|
||||
set_flag(k_video_effect);
|
||||
set_effect_input(k_texture_input);
|
||||
|
||||
gizmo_ = AddDraggableGizmo<PointGizmo>({
|
||||
NodeKeyframeTrackReference(NodeInput(this, kPositionInput), 0),
|
||||
NodeKeyframeTrackReference(NodeInput(this, kPositionInput), 1),
|
||||
gizmo_ = add_draggable_gizmo<PointGizmo>({
|
||||
NodeKeyframeTrackReference(NodeInput(this, k_position_input), 0),
|
||||
NodeKeyframeTrackReference(NodeInput(this, k_position_input), 1),
|
||||
});
|
||||
gizmo_->SetShape(PointGizmo::kAnchorPoint);
|
||||
gizmo_->set_shape(PointGizmo::k_anchor_point);
|
||||
}
|
||||
|
||||
QString TileDistortNode::Name() const
|
||||
QString TileDistortNode::name() const
|
||||
{
|
||||
return tr("Tile");
|
||||
}
|
||||
@@ -72,28 +72,28 @@ QString TileDistortNode::id() const
|
||||
return QStringLiteral("org.olivevideoeditor.Olive.tile");
|
||||
}
|
||||
|
||||
QVector<Node::CategoryID> TileDistortNode::Category() const
|
||||
QVector<Node::CategoryID> TileDistortNode::category() const
|
||||
{
|
||||
return { kCategoryDistort };
|
||||
return { k_category_distort };
|
||||
}
|
||||
|
||||
QString TileDistortNode::Description() const
|
||||
QString TileDistortNode::description() const
|
||||
{
|
||||
return tr("Infinitely tile an image horizontally and vertically.");
|
||||
}
|
||||
|
||||
void TileDistortNode::Retranslate()
|
||||
void TileDistortNode::retranslate()
|
||||
{
|
||||
super::Retranslate();
|
||||
super::retranslate();
|
||||
|
||||
SetInputName(kTextureInput, tr("Input"));
|
||||
SetInputName(kScaleInput, tr("Scale"));
|
||||
SetInputName(kPositionInput, tr("Position"));
|
||||
SetInputName(kMirrorXInput, tr("Mirror Horizontally"));
|
||||
SetInputName(kMirrorYInput, tr("Mirror Vertically"));
|
||||
set_input_name(k_texture_input, tr("Input"));
|
||||
set_input_name(k_scale_input, tr("Scale"));
|
||||
set_input_name(k_position_input, tr("Position"));
|
||||
set_input_name(k_mirror_x_input, tr("Mirror Horizontally"));
|
||||
set_input_name(k_mirror_y_input, tr("Mirror Vertically"));
|
||||
|
||||
SetInputName(kAnchorInput, tr("Anchor"));
|
||||
SetComboBoxStrings(kAnchorInput, {
|
||||
set_input_name(k_anchor_input, tr("Anchor"));
|
||||
set_combo_box_strings(k_anchor_input, {
|
||||
tr("Top-Left"),
|
||||
tr("Top-Center"),
|
||||
tr("Top-Right"),
|
||||
@@ -106,72 +106,72 @@ void TileDistortNode::Retranslate()
|
||||
});
|
||||
}
|
||||
|
||||
ShaderCode TileDistortNode::GetShaderCode(const ShaderRequest &request) const
|
||||
ShaderCode TileDistortNode::get_shader_code(const ShaderRequest &request) const
|
||||
{
|
||||
Q_UNUSED(request)
|
||||
return ShaderCode(FileFunctions::ReadFileAsString(":/shaders/tile.frag"));
|
||||
return ShaderCode(FileFunctions::read_file_as_string(":/shaders/tile.frag"));
|
||||
}
|
||||
|
||||
void TileDistortNode::Value(const NodeValueRow &value,
|
||||
void TileDistortNode::value(const NodeValueRow &value,
|
||||
const NodeGlobals &globals,
|
||||
NodeValueTable *table) const
|
||||
{
|
||||
// If there's no texture, no need to run an operation
|
||||
if (TexturePtr tex = value[kTextureInput].toTexture()) {
|
||||
if (TexturePtr tex = value[k_texture_input].to_texture()) {
|
||||
// Only run shader if at least one of flip or flop are selected
|
||||
if (!qFuzzyCompare(value[kScaleInput].toDouble(), 1.0)) {
|
||||
if (!qFuzzyCompare(value[k_scale_input].to_double(), 1.0)) {
|
||||
ShaderJob job(value);
|
||||
job.Insert(QStringLiteral("resolution_in"),
|
||||
NodeValue(NodeValue::kVec2, tex->virtual_resolution(),
|
||||
job.insert(QStringLiteral("resolution_in"),
|
||||
NodeValue(NodeValue::k_vec2, tex->virtual_resolution(),
|
||||
this));
|
||||
table->Push(NodeValue::kTexture, tex->toJob(job), this);
|
||||
table->push(NodeValue::k_texture, tex->to_job(job), this);
|
||||
} else {
|
||||
// If we're not flipping or flopping just push the texture
|
||||
table->Push(value[kTextureInput]);
|
||||
table->push(value[k_texture_input]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TileDistortNode::UpdateGizmoPositions(const NodeValueRow &row,
|
||||
void TileDistortNode::update_gizmo_positions(const NodeValueRow &row,
|
||||
const NodeGlobals &globals)
|
||||
{
|
||||
if (TexturePtr tex = row[kTextureInput].toTexture()) {
|
||||
if (TexturePtr tex = row[k_texture_input].to_texture()) {
|
||||
QPointF res = tex->virtual_resolution().toPointF();
|
||||
QPointF pos = row[kPositionInput].toVec2().toPointF();
|
||||
QPointF pos = row[k_position_input].to_vec2().toPointF();
|
||||
qreal x = pos.x();
|
||||
qreal y = pos.y();
|
||||
|
||||
Anchor a = static_cast<Anchor>(row[kAnchorInput].toInt());
|
||||
if (a == kTopLeft || a == kTopCenter || a == kTopRight) {
|
||||
Anchor a = static_cast<Anchor>(row[k_anchor_input].to_int());
|
||||
if (a == k_top_left || a == k_top_center || a == k_top_right) {
|
||||
// Do nothing
|
||||
} else if (a == kMiddleLeft || a == kMiddleCenter ||
|
||||
a == kMiddleRight) {
|
||||
} else if (a == k_middle_left || a == k_middle_center ||
|
||||
a == k_middle_right) {
|
||||
y += res.y() / 2;
|
||||
} else if (a == kBottomLeft || a == kBottomCenter ||
|
||||
a == kBottomRight) {
|
||||
} else if (a == k_bottom_left || a == k_bottom_center ||
|
||||
a == k_bottom_right) {
|
||||
y += res.y();
|
||||
}
|
||||
if (a == kTopLeft || a == kMiddleLeft || a == kBottomLeft) {
|
||||
if (a == k_top_left || a == k_middle_left || a == k_bottom_left) {
|
||||
// Do nothing
|
||||
} else if (a == kTopCenter || a == kMiddleCenter ||
|
||||
a == kBottomCenter) {
|
||||
} else if (a == k_top_center || a == k_middle_center ||
|
||||
a == k_bottom_center) {
|
||||
x += res.x() / 2;
|
||||
} else if (a == kTopRight || a == kMiddleRight || a == kBottomRight) {
|
||||
} else if (a == k_top_right || a == k_middle_right || a == k_bottom_right) {
|
||||
x += res.x();
|
||||
}
|
||||
|
||||
gizmo_->SetPoint(QPointF(x, y));
|
||||
gizmo_->set_point(QPointF(x, y));
|
||||
}
|
||||
}
|
||||
|
||||
void TileDistortNode::GizmoDragMove(double x, double y,
|
||||
void TileDistortNode::gizmo_drag_move(double x, double y,
|
||||
const Qt::KeyboardModifiers &modifiers)
|
||||
{
|
||||
NodeInputDragger &x_drag = gizmo_->GetDraggers()[0];
|
||||
NodeInputDragger &y_drag = gizmo_->GetDraggers()[1];
|
||||
NodeInputDragger &x_drag = gizmo_->get_draggers()[0];
|
||||
NodeInputDragger &y_drag = gizmo_->get_draggers()[1];
|
||||
|
||||
x_drag.Drag(x_drag.GetStartValue().toDouble() + x);
|
||||
y_drag.Drag(y_drag.GetStartValue().toDouble() + y);
|
||||
x_drag.drag(x_drag.get_start_value().toDouble() + x);
|
||||
y_drag.drag(y_drag.get_start_value().toDouble() + y);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef TILEDISTORTNODE_H
|
||||
#define TILEDISTORTNODE_H
|
||||
#ifndef OAK_TILEDISTORTNODE_H
|
||||
#define OAK_TILEDISTORTNODE_H
|
||||
|
||||
#include "node/gizmo/point.h"
|
||||
#include "node/node.h"
|
||||
@@ -35,43 +35,43 @@ public:
|
||||
|
||||
NODE_DEFAULT_FUNCTIONS(TileDistortNode)
|
||||
|
||||
virtual QString Name() const override;
|
||||
virtual QString name() const override;
|
||||
virtual QString id() const override;
|
||||
virtual QVector<CategoryID> Category() const override;
|
||||
virtual QString Description() const override;
|
||||
virtual QVector<CategoryID> category() const override;
|
||||
virtual QString description() const override;
|
||||
|
||||
virtual void Retranslate() override;
|
||||
virtual void retranslate() override;
|
||||
|
||||
virtual ShaderCode
|
||||
GetShaderCode(const ShaderRequest &request) const override;
|
||||
virtual void Value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
get_shader_code(const ShaderRequest &request) const override;
|
||||
virtual void value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
NodeValueTable *table) const override;
|
||||
|
||||
virtual void UpdateGizmoPositions(const NodeValueRow &row,
|
||||
virtual void update_gizmo_positions(const NodeValueRow &row,
|
||||
const NodeGlobals &globals) override;
|
||||
|
||||
static const QString kTextureInput;
|
||||
static const QString kScaleInput;
|
||||
static const QString kPositionInput;
|
||||
static const QString kAnchorInput;
|
||||
static const QString kMirrorXInput;
|
||||
static const QString kMirrorYInput;
|
||||
static const QString k_texture_input;
|
||||
static const QString k_scale_input;
|
||||
static const QString k_position_input;
|
||||
static const QString k_anchor_input;
|
||||
static const QString k_mirror_x_input;
|
||||
static const QString k_mirror_y_input;
|
||||
|
||||
protected slots:
|
||||
virtual void GizmoDragMove(double x, double y,
|
||||
virtual void gizmo_drag_move(double x, double y,
|
||||
const Qt::KeyboardModifiers &modifiers) override;
|
||||
|
||||
private:
|
||||
enum Anchor {
|
||||
kTopLeft,
|
||||
kTopCenter,
|
||||
kTopRight,
|
||||
kMiddleLeft,
|
||||
kMiddleCenter,
|
||||
kMiddleRight,
|
||||
kBottomLeft,
|
||||
kBottomCenter,
|
||||
kBottomRight
|
||||
k_top_left,
|
||||
k_top_center,
|
||||
k_top_right,
|
||||
k_middle_left,
|
||||
k_middle_center,
|
||||
k_middle_right,
|
||||
k_bottom_left,
|
||||
k_bottom_center,
|
||||
k_bottom_right
|
||||
};
|
||||
|
||||
PointGizmo *gizmo_;
|
||||
@@ -79,4 +79,4 @@ private:
|
||||
|
||||
}
|
||||
|
||||
#endif // TILEDISTORTNODE_H
|
||||
#endif // OAK_TILEDISTORTNODE_H
|
||||
|
||||
@@ -26,124 +26,124 @@
|
||||
namespace olive
|
||||
{
|
||||
|
||||
const QString TransformDistortNode::kParentInput = QStringLiteral("parent_in");
|
||||
const QString TransformDistortNode::kTextureInput = QStringLiteral("tex_in");
|
||||
const QString TransformDistortNode::kAutoscaleInput =
|
||||
const QString TransformDistortNode::k_parent_input = QStringLiteral("parent_in");
|
||||
const QString TransformDistortNode::k_texture_input = QStringLiteral("tex_in");
|
||||
const QString TransformDistortNode::k_autoscale_input =
|
||||
QStringLiteral("autoscale_in");
|
||||
const QString TransformDistortNode::kInterpolationInput =
|
||||
const QString TransformDistortNode::k_interpolation_input =
|
||||
QStringLiteral("interpolation_in");
|
||||
|
||||
#define super MatrixGenerator
|
||||
|
||||
TransformDistortNode::TransformDistortNode()
|
||||
{
|
||||
AddInput(kParentInput, NodeValue::kMatrix);
|
||||
add_input(k_parent_input, NodeValue::k_matrix);
|
||||
|
||||
AddInput(kAutoscaleInput, NodeValue::kCombo, 0);
|
||||
add_input(k_autoscale_input, NodeValue::k_combo, 0);
|
||||
|
||||
AddInput(kInterpolationInput, NodeValue::kCombo, 2);
|
||||
add_input(k_interpolation_input, NodeValue::k_combo, 2);
|
||||
|
||||
PrependInput(kTextureInput, NodeValue::kTexture,
|
||||
InputFlags(kInputFlagNotKeyframable));
|
||||
prepend_input(k_texture_input, NodeValue::k_texture,
|
||||
InputFlags(k_input_flag_not_keyframable));
|
||||
|
||||
// Initiate gizmos
|
||||
rotation_gizmo_ = AddDraggableGizmo<ScreenGizmo>();
|
||||
rotation_gizmo_->AddInput(NodeInput(this, kRotationInput));
|
||||
rotation_gizmo_->SetDragValueBehavior(ScreenGizmo::kAbsolute);
|
||||
rotation_gizmo_ = add_draggable_gizmo<ScreenGizmo>();
|
||||
rotation_gizmo_->add_input(NodeInput(this, k_rotation_input));
|
||||
rotation_gizmo_->set_drag_value_behavior(ScreenGizmo::k_absolute);
|
||||
|
||||
poly_gizmo_ = AddDraggableGizmo<PolygonGizmo>();
|
||||
poly_gizmo_->AddInput(
|
||||
NodeKeyframeTrackReference(NodeInput(this, kPositionInput), 0));
|
||||
poly_gizmo_->AddInput(
|
||||
NodeKeyframeTrackReference(NodeInput(this, kPositionInput), 1));
|
||||
poly_gizmo_ = add_draggable_gizmo<PolygonGizmo>();
|
||||
poly_gizmo_->add_input(
|
||||
NodeKeyframeTrackReference(NodeInput(this, k_position_input), 0));
|
||||
poly_gizmo_->add_input(
|
||||
NodeKeyframeTrackReference(NodeInput(this, k_position_input), 1));
|
||||
|
||||
anchor_gizmo_ = AddDraggableGizmo<PointGizmo>();
|
||||
anchor_gizmo_->SetShape(PointGizmo::kAnchorPoint);
|
||||
anchor_gizmo_->AddInput(
|
||||
NodeKeyframeTrackReference(NodeInput(this, kAnchorInput), 0));
|
||||
anchor_gizmo_->AddInput(
|
||||
NodeKeyframeTrackReference(NodeInput(this, kAnchorInput), 1));
|
||||
anchor_gizmo_->AddInput(
|
||||
NodeKeyframeTrackReference(NodeInput(this, kPositionInput), 0));
|
||||
anchor_gizmo_->AddInput(
|
||||
NodeKeyframeTrackReference(NodeInput(this, kPositionInput), 1));
|
||||
anchor_gizmo_ = add_draggable_gizmo<PointGizmo>();
|
||||
anchor_gizmo_->set_shape(PointGizmo::k_anchor_point);
|
||||
anchor_gizmo_->add_input(
|
||||
NodeKeyframeTrackReference(NodeInput(this, k_anchor_input), 0));
|
||||
anchor_gizmo_->add_input(
|
||||
NodeKeyframeTrackReference(NodeInput(this, k_anchor_input), 1));
|
||||
anchor_gizmo_->add_input(
|
||||
NodeKeyframeTrackReference(NodeInput(this, k_position_input), 0));
|
||||
anchor_gizmo_->add_input(
|
||||
NodeKeyframeTrackReference(NodeInput(this, k_position_input), 1));
|
||||
|
||||
for (int i = 0; i < kGizmoScaleCount; i++) {
|
||||
point_gizmo_[i] = AddDraggableGizmo<PointGizmo>();
|
||||
point_gizmo_[i]->AddInput(
|
||||
NodeKeyframeTrackReference(NodeInput(this, kScaleInput), 0));
|
||||
point_gizmo_[i]->AddInput(
|
||||
NodeKeyframeTrackReference(NodeInput(this, kScaleInput), 1));
|
||||
point_gizmo_[i]->SetDragValueBehavior(PointGizmo::kAbsolute);
|
||||
for (int i = 0; i < k_gizmo_scale_count; i++) {
|
||||
point_gizmo_[i] = add_draggable_gizmo<PointGizmo>();
|
||||
point_gizmo_[i]->add_input(
|
||||
NodeKeyframeTrackReference(NodeInput(this, k_scale_input), 0));
|
||||
point_gizmo_[i]->add_input(
|
||||
NodeKeyframeTrackReference(NodeInput(this, k_scale_input), 1));
|
||||
point_gizmo_[i]->set_drag_value_behavior(PointGizmo::k_absolute);
|
||||
}
|
||||
|
||||
SetFlag(kVideoEffect);
|
||||
SetEffectInput(kTextureInput);
|
||||
set_flag(k_video_effect);
|
||||
set_effect_input(k_texture_input);
|
||||
}
|
||||
|
||||
void TransformDistortNode::Retranslate()
|
||||
void TransformDistortNode::retranslate()
|
||||
{
|
||||
super::Retranslate();
|
||||
super::retranslate();
|
||||
|
||||
SetInputName(kParentInput, tr("Parent"));
|
||||
SetInputName(kAutoscaleInput, tr("Auto-Scale"));
|
||||
SetInputName(kTextureInput, tr("Texture"));
|
||||
SetInputName(kInterpolationInput, tr("Interpolation"));
|
||||
set_input_name(k_parent_input, tr("Parent"));
|
||||
set_input_name(k_autoscale_input, tr("Auto-Scale"));
|
||||
set_input_name(k_texture_input, tr("Texture"));
|
||||
set_input_name(k_interpolation_input, tr("Interpolation"));
|
||||
|
||||
SetComboBoxStrings(kAutoscaleInput,
|
||||
set_combo_box_strings(k_autoscale_input,
|
||||
{ tr("None"), tr("Fit"), tr("Fill"), tr("Stretch") });
|
||||
SetComboBoxStrings(kInterpolationInput,
|
||||
set_combo_box_strings(k_interpolation_input,
|
||||
{ tr("Nearest Neighbor"), tr("Bilinear"),
|
||||
tr("Mipmapped Bilinear") });
|
||||
}
|
||||
|
||||
void TransformDistortNode::Value(const NodeValueRow &value,
|
||||
void TransformDistortNode::value(const NodeValueRow &value,
|
||||
const NodeGlobals &globals,
|
||||
NodeValueTable *table) const
|
||||
{
|
||||
// Generate matrix
|
||||
QMatrix4x4 generated_matrix = GenerateMatrix(
|
||||
value, false, false, false, value[kParentInput].toMatrix());
|
||||
QMatrix4x4 generated_matrix = generate_matrix(
|
||||
value, false, false, false, value[k_parent_input].to_matrix());
|
||||
|
||||
// Pop texture
|
||||
NodeValue texture_meta = value[kTextureInput];
|
||||
NodeValue texture_meta = value[k_texture_input];
|
||||
|
||||
TexturePtr job_to_push = nullptr;
|
||||
|
||||
// If we have a texture, generate a matrix and make it happen
|
||||
if (TexturePtr texture = texture_meta.toTexture()) {
|
||||
if (TexturePtr texture = texture_meta.to_texture()) {
|
||||
// Adjust our matrix by the resolutions involved
|
||||
QMatrix4x4 real_matrix = GenerateAutoScaledMatrix(
|
||||
QMatrix4x4 real_matrix = generate_auto_scaled_matrix(
|
||||
generated_matrix, value, globals, texture->params());
|
||||
|
||||
if (!real_matrix.isIdentity()) {
|
||||
// The matrix will transform things
|
||||
ShaderJob job;
|
||||
job.Insert(QStringLiteral("ove_maintex"), texture_meta);
|
||||
job.Insert(QStringLiteral("ove_mvpmat"),
|
||||
NodeValue(NodeValue::kMatrix, real_matrix, this));
|
||||
job.SetInterpolation(QStringLiteral("ove_maintex"),
|
||||
job.insert(QStringLiteral("ove_maintex"), texture_meta);
|
||||
job.insert(QStringLiteral("ove_mvpmat"),
|
||||
NodeValue(NodeValue::k_matrix, real_matrix, this));
|
||||
job.set_interpolation(QStringLiteral("ove_maintex"),
|
||||
static_cast<Texture::Interpolation>(
|
||||
value[kInterpolationInput].toInt()));
|
||||
value[k_interpolation_input].to_int()));
|
||||
|
||||
// Use global resolution rather than texture resolution because this may result in a size change
|
||||
job_to_push = Texture::Job(globals.vparams(), job);
|
||||
job_to_push = Texture::job(globals.vparams(), job);
|
||||
}
|
||||
}
|
||||
|
||||
table->Push(NodeValue::kMatrix, QVariant::fromValue(generated_matrix),
|
||||
table->push(NodeValue::k_matrix, QVariant::fromValue(generated_matrix),
|
||||
this);
|
||||
|
||||
if (!job_to_push) {
|
||||
// Re-push whatever value we received
|
||||
table->Push(texture_meta);
|
||||
table->push(texture_meta);
|
||||
} else {
|
||||
table->Push(NodeValue::kTexture, job_to_push, this);
|
||||
table->push(NodeValue::k_texture, job_to_push, this);
|
||||
}
|
||||
}
|
||||
|
||||
ShaderCode
|
||||
TransformDistortNode::GetShaderCode(const ShaderRequest &request) const
|
||||
TransformDistortNode::get_shader_code(const ShaderRequest &request) const
|
||||
{
|
||||
Q_UNUSED(request);
|
||||
|
||||
@@ -151,70 +151,70 @@ TransformDistortNode::GetShaderCode(const ShaderRequest &request) const
|
||||
return ShaderCode();
|
||||
}
|
||||
|
||||
void TransformDistortNode::GizmoDragStart(const NodeValueRow &row, double x,
|
||||
double y, const rational &time)
|
||||
void TransformDistortNode::gizmo_drag_start(const NodeValueRow &row, double x,
|
||||
double y, const Rational &time)
|
||||
{
|
||||
DraggableGizmo *gizmo = static_cast<DraggableGizmo *>(sender());
|
||||
|
||||
if (gizmo == anchor_gizmo_) {
|
||||
gizmo_inverted_transform_ =
|
||||
GenerateMatrix(row, true, true, false, row[kParentInput].toMatrix())
|
||||
generate_matrix(row, true, true, false, row[k_parent_input].to_matrix())
|
||||
.toTransform()
|
||||
.inverted();
|
||||
|
||||
} else if (IsAScaleGizmo(gizmo)) {
|
||||
} else if (is_a_scale_gizmo(gizmo)) {
|
||||
// Dragging scale handle
|
||||
TexturePtr tex = row[kTextureInput].toTexture();
|
||||
TexturePtr tex = row[k_texture_input].to_texture();
|
||||
if (!tex) {
|
||||
return;
|
||||
}
|
||||
|
||||
gizmo_scale_uniform_ = row[kUniformScaleInput].toBool();
|
||||
gizmo_anchor_pt_ = (row[kAnchorInput].toVec2() +
|
||||
gizmo->GetGlobals().nonsquare_resolution() / 2)
|
||||
gizmo_scale_uniform_ = row[k_uniform_scale_input].to_bool();
|
||||
gizmo_anchor_pt_ = (row[k_anchor_input].to_vec2() +
|
||||
gizmo->get_globals().nonsquare_resolution() / 2)
|
||||
.toPointF();
|
||||
|
||||
if (gizmo == point_gizmo_[kGizmoScaleTopLeft] ||
|
||||
gizmo == point_gizmo_[kGizmoScaleTopRight] ||
|
||||
gizmo == point_gizmo_[kGizmoScaleBottomLeft] ||
|
||||
gizmo == point_gizmo_[kGizmoScaleBottomRight]) {
|
||||
gizmo_scale_axes_ = kGizmoScaleBoth;
|
||||
} else if (gizmo == point_gizmo_[kGizmoScaleCenterLeft] ||
|
||||
gizmo == point_gizmo_[kGizmoScaleCenterRight]) {
|
||||
gizmo_scale_axes_ = kGizmoScaleXOnly;
|
||||
if (gizmo == point_gizmo_[k_gizmo_scale_top_left] ||
|
||||
gizmo == point_gizmo_[k_gizmo_scale_top_right] ||
|
||||
gizmo == point_gizmo_[k_gizmo_scale_bottom_left] ||
|
||||
gizmo == point_gizmo_[k_gizmo_scale_bottom_right]) {
|
||||
gizmo_scale_axes_ = k_gizmo_scale_both;
|
||||
} else if (gizmo == point_gizmo_[k_gizmo_scale_center_left] ||
|
||||
gizmo == point_gizmo_[k_gizmo_scale_center_right]) {
|
||||
gizmo_scale_axes_ = k_gizmo_scale_x_only;
|
||||
} else {
|
||||
gizmo_scale_axes_ = kGizmoScaleYOnly;
|
||||
gizmo_scale_axes_ = k_gizmo_scale_y_only;
|
||||
}
|
||||
|
||||
// Store texture size
|
||||
VideoParams texture_params = tex->params();
|
||||
QVector2D texture_sz(texture_params.square_pixel_width(),
|
||||
texture_params.height());
|
||||
gizmo_scale_anchor_ = row[kAnchorInput].toVec2() + texture_sz / 2;
|
||||
gizmo_scale_anchor_ = row[k_anchor_input].to_vec2() + texture_sz / 2;
|
||||
|
||||
if (gizmo == point_gizmo_[kGizmoScaleTopRight] ||
|
||||
gizmo == point_gizmo_[kGizmoScaleBottomRight] ||
|
||||
gizmo == point_gizmo_[kGizmoScaleCenterRight]) {
|
||||
if (gizmo == point_gizmo_[k_gizmo_scale_top_right] ||
|
||||
gizmo == point_gizmo_[k_gizmo_scale_bottom_right] ||
|
||||
gizmo == point_gizmo_[k_gizmo_scale_center_right]) {
|
||||
// Right handles, flip X axis
|
||||
gizmo_scale_anchor_.setX(texture_sz.x() - gizmo_scale_anchor_.x());
|
||||
}
|
||||
|
||||
if (gizmo == point_gizmo_[kGizmoScaleBottomLeft] ||
|
||||
gizmo == point_gizmo_[kGizmoScaleBottomRight] ||
|
||||
gizmo == point_gizmo_[kGizmoScaleBottomCenter]) {
|
||||
if (gizmo == point_gizmo_[k_gizmo_scale_bottom_left] ||
|
||||
gizmo == point_gizmo_[k_gizmo_scale_bottom_right] ||
|
||||
gizmo == point_gizmo_[k_gizmo_scale_bottom_center]) {
|
||||
// Bottom handles, flip Y axis
|
||||
gizmo_scale_anchor_.setY(texture_sz.y() - gizmo_scale_anchor_.y());
|
||||
}
|
||||
|
||||
// Store current matrix
|
||||
gizmo_inverted_transform_ =
|
||||
GenerateMatrix(row, true, true, true, row[kParentInput].toMatrix())
|
||||
generate_matrix(row, true, true, true, row[k_parent_input].to_matrix())
|
||||
.toTransform()
|
||||
.inverted();
|
||||
|
||||
} else if (gizmo == rotation_gizmo_) {
|
||||
gizmo_anchor_pt_ = (row[kAnchorInput].toVec2() +
|
||||
gizmo->GetGlobals().nonsquare_resolution() / 2)
|
||||
gizmo_anchor_pt_ = (row[k_anchor_input].to_vec2() +
|
||||
gizmo->get_globals().nonsquare_resolution() / 2)
|
||||
.toPointF();
|
||||
gizmo_start_angle_ =
|
||||
std::atan2(y - gizmo_anchor_pt_.y(), x - gizmo_anchor_pt_.x());
|
||||
@@ -222,36 +222,36 @@ void TransformDistortNode::GizmoDragStart(const NodeValueRow &row, double x,
|
||||
gizmo_last_alt_angle_ =
|
||||
std::atan2(x - gizmo_anchor_pt_.x(), y - gizmo_anchor_pt_.y());
|
||||
gizmo_rotate_wrap_ = 0;
|
||||
gizmo_rotate_last_dir_ = kDirectionNone;
|
||||
gizmo_rotate_last_dir_ = k_direction_none;
|
||||
}
|
||||
}
|
||||
|
||||
void TransformDistortNode::GizmoDragMove(double x, double y,
|
||||
void TransformDistortNode::gizmo_drag_move(double x, double y,
|
||||
const Qt::KeyboardModifiers &modifiers)
|
||||
{
|
||||
DraggableGizmo *gizmo = static_cast<DraggableGizmo *>(sender());
|
||||
|
||||
if (gizmo == poly_gizmo_) {
|
||||
NodeInputDragger &x_drag = gizmo->GetDraggers()[0];
|
||||
NodeInputDragger &y_drag = gizmo->GetDraggers()[1];
|
||||
NodeInputDragger &x_drag = gizmo->get_draggers()[0];
|
||||
NodeInputDragger &y_drag = gizmo->get_draggers()[1];
|
||||
|
||||
x_drag.Drag(x_drag.GetStartValue().toDouble() + x);
|
||||
y_drag.Drag(y_drag.GetStartValue().toDouble() + y);
|
||||
x_drag.drag(x_drag.get_start_value().toDouble() + x);
|
||||
y_drag.drag(y_drag.get_start_value().toDouble() + y);
|
||||
|
||||
} else if (gizmo == anchor_gizmo_) {
|
||||
NodeInputDragger &x_anchor_drag = gizmo->GetDraggers()[0];
|
||||
NodeInputDragger &y_anchor_drag = gizmo->GetDraggers()[1];
|
||||
NodeInputDragger &x_pos_drag = gizmo->GetDraggers()[2];
|
||||
NodeInputDragger &y_pos_drag = gizmo->GetDraggers()[3];
|
||||
NodeInputDragger &x_anchor_drag = gizmo->get_draggers()[0];
|
||||
NodeInputDragger &y_anchor_drag = gizmo->get_draggers()[1];
|
||||
NodeInputDragger &x_pos_drag = gizmo->get_draggers()[2];
|
||||
NodeInputDragger &y_pos_drag = gizmo->get_draggers()[3];
|
||||
|
||||
QPointF inverted_movement(gizmo_inverted_transform_.map(QPointF(x, y)));
|
||||
|
||||
x_anchor_drag.Drag(x_anchor_drag.GetStartValue().toDouble() +
|
||||
x_anchor_drag.drag(x_anchor_drag.get_start_value().toDouble() +
|
||||
inverted_movement.x());
|
||||
y_anchor_drag.Drag(y_anchor_drag.GetStartValue().toDouble() +
|
||||
y_anchor_drag.drag(y_anchor_drag.get_start_value().toDouble() +
|
||||
inverted_movement.y());
|
||||
x_pos_drag.Drag(x_pos_drag.GetStartValue().toDouble() + x);
|
||||
y_pos_drag.Drag(y_pos_drag.GetStartValue().toDouble() + y);
|
||||
x_pos_drag.drag(x_pos_drag.get_start_value().toDouble() + x);
|
||||
y_pos_drag.drag(y_pos_drag.get_start_value().toDouble() + y);
|
||||
|
||||
} else if (gizmo == rotation_gizmo_) {
|
||||
double raw_angle =
|
||||
@@ -263,11 +263,11 @@ void TransformDistortNode::GizmoDragMove(double x, double y,
|
||||
|
||||
// Detect rotation wrap around
|
||||
RotationDirection this_dir =
|
||||
GetDirectionFromAngles(gizmo_last_angle_, raw_angle);
|
||||
get_direction_from_angles(gizmo_last_angle_, raw_angle);
|
||||
RotationDirection alt_dir =
|
||||
GetDirectionFromAngles(gizmo_last_alt_angle_, alt_angle);
|
||||
get_direction_from_angles(gizmo_last_alt_angle_, alt_angle);
|
||||
|
||||
if (gizmo_rotate_last_dir_ != kDirectionNone &&
|
||||
if (gizmo_rotate_last_dir_ != k_direction_none &&
|
||||
this_dir != gizmo_rotate_last_dir_) {
|
||||
if (alt_dir == gizmo_rotate_last_alt_dir_) {
|
||||
if ((raw_angle - gizmo_last_angle_) < 0) {
|
||||
@@ -292,10 +292,10 @@ void TransformDistortNode::GizmoDragMove(double x, double y,
|
||||
double rotation_difference =
|
||||
(current_angle - gizmo_start_angle_) * 57.2958;
|
||||
|
||||
NodeInputDragger &d = gizmo->GetDraggers()[0];
|
||||
d.Drag(d.GetStartValue().toDouble() + rotation_difference);
|
||||
NodeInputDragger &d = gizmo->get_draggers()[0];
|
||||
d.drag(d.get_start_value().toDouble() + rotation_difference);
|
||||
|
||||
} else if (IsAScaleGizmo(gizmo)) {
|
||||
} else if (is_a_scale_gizmo(gizmo)) {
|
||||
QPointF mouse_relative =
|
||||
gizmo_inverted_transform_.map(QPointF(x, y) - gizmo_anchor_pt_);
|
||||
|
||||
@@ -304,38 +304,38 @@ void TransformDistortNode::GizmoDragMove(double x, double y,
|
||||
double y_scaled_movement =
|
||||
qAbs(mouse_relative.y() / gizmo_scale_anchor_.y());
|
||||
|
||||
NodeInputDragger &x_drag = gizmo->GetDraggers()[0];
|
||||
NodeInputDragger &y_drag = gizmo->GetDraggers()[1];
|
||||
NodeInputDragger &x_drag = gizmo->get_draggers()[0];
|
||||
NodeInputDragger &y_drag = gizmo->get_draggers()[1];
|
||||
|
||||
switch (gizmo_scale_axes_) {
|
||||
case kGizmoScaleXOnly:
|
||||
x_drag.Drag(x_scaled_movement);
|
||||
case k_gizmo_scale_x_only:
|
||||
x_drag.drag(x_scaled_movement);
|
||||
break;
|
||||
case kGizmoScaleYOnly:
|
||||
case k_gizmo_scale_y_only:
|
||||
if (gizmo_scale_uniform_) {
|
||||
x_drag.Drag(y_scaled_movement);
|
||||
x_drag.drag(y_scaled_movement);
|
||||
} else {
|
||||
y_drag.Drag(y_scaled_movement);
|
||||
y_drag.drag(y_scaled_movement);
|
||||
}
|
||||
break;
|
||||
case kGizmoScaleBoth:
|
||||
case k_gizmo_scale_both:
|
||||
if (gizmo_scale_uniform_) {
|
||||
double distance =
|
||||
std::hypot(mouse_relative.x(), mouse_relative.y());
|
||||
double texture_diag = std::hypot(gizmo_scale_anchor_.x(),
|
||||
gizmo_scale_anchor_.y());
|
||||
|
||||
x_drag.Drag(qAbs(distance / texture_diag));
|
||||
x_drag.drag(qAbs(distance / texture_diag));
|
||||
} else {
|
||||
x_drag.Drag(x_scaled_movement);
|
||||
y_drag.Drag(y_scaled_movement);
|
||||
x_drag.drag(x_scaled_movement);
|
||||
y_drag.drag(y_scaled_movement);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QMatrix4x4 TransformDistortNode::AdjustMatrixByResolutions(
|
||||
QMatrix4x4 TransformDistortNode::adjust_matrix_by_resolutions(
|
||||
const QMatrix4x4 &mat, const QVector2D &sequence_res,
|
||||
const QVector2D &texture_res, const QVector2D &offset,
|
||||
AutoScaleType autoscale_type)
|
||||
@@ -356,8 +356,8 @@ QMatrix4x4 TransformDistortNode::AdjustMatrixByResolutions(
|
||||
adjusted_matrix.scale(texture_res.x() * 0.5, texture_res.y() * 0.5, 1.0);
|
||||
|
||||
// If auto-scale is enabled, fit the texture to the sequence (without cropping)
|
||||
if (autoscale_type != kAutoScaleNone) {
|
||||
if (autoscale_type == kAutoScaleStretch) {
|
||||
if (autoscale_type != k_auto_scale_none) {
|
||||
if (autoscale_type == k_auto_scale_stretch) {
|
||||
adjusted_matrix.scale(sequence_res.x() / texture_res.x(),
|
||||
sequence_res.y() / texture_res.y(), 1.0);
|
||||
} else {
|
||||
@@ -368,7 +368,7 @@ QMatrix4x4 TransformDistortNode::AdjustMatrixByResolutions(
|
||||
double scale_by_y = sequence_res.y() / texture_res.y();
|
||||
double autoscale_val;
|
||||
|
||||
if ((autoscale_type == kAutoScaleFit) ==
|
||||
if ((autoscale_type == k_auto_scale_fit) ==
|
||||
(sequence_real_ar > footage_real_ar)) {
|
||||
// Scale by height. Either the sequence is wider than the footage or we're using fill and
|
||||
// cutting off the sides
|
||||
@@ -386,10 +386,10 @@ QMatrix4x4 TransformDistortNode::AdjustMatrixByResolutions(
|
||||
return adjusted_matrix;
|
||||
}
|
||||
|
||||
void TransformDistortNode::UpdateGizmoPositions(const NodeValueRow &row,
|
||||
void TransformDistortNode::update_gizmo_positions(const NodeValueRow &row,
|
||||
const NodeGlobals &globals)
|
||||
{
|
||||
TexturePtr tex = row[kTextureInput].toTexture();
|
||||
TexturePtr tex = row[k_texture_input].to_texture();
|
||||
if (!tex) {
|
||||
return;
|
||||
}
|
||||
@@ -406,13 +406,13 @@ void TransformDistortNode::UpdateGizmoPositions(const NodeValueRow &row,
|
||||
|
||||
// Retrieve autoscale value
|
||||
AutoScaleType autoscale =
|
||||
static_cast<AutoScaleType>(row[kAutoscaleInput].toInt());
|
||||
static_cast<AutoScaleType>(row[k_autoscale_input].to_int());
|
||||
|
||||
// Fold values into a matrix for the rectangle
|
||||
QMatrix4x4 rectangle_matrix;
|
||||
rectangle_matrix.scale(sequence_half_res.x(), sequence_half_res.y());
|
||||
rectangle_matrix *= AdjustMatrixByResolutions(
|
||||
GenerateMatrix(row, false, false, false, row[kParentInput].toMatrix()),
|
||||
rectangle_matrix *= adjust_matrix_by_resolutions(
|
||||
generate_matrix(row, false, false, false, row[k_parent_input].to_matrix()),
|
||||
sequence_res, tex_sz, tex_offset, autoscale);
|
||||
|
||||
// Create rect and transform it
|
||||
@@ -422,63 +422,63 @@ void TransformDistortNode::UpdateGizmoPositions(const NodeValueRow &row,
|
||||
QTransform rectangle_transform = rectangle_matrix.toTransform();
|
||||
QPolygonF r = rectangle_transform.map(points);
|
||||
r.translate(sequence_half_res_pt);
|
||||
poly_gizmo_->SetPolygon(r);
|
||||
poly_gizmo_->set_polygon(r);
|
||||
|
||||
// Draw anchor point
|
||||
QMatrix4x4 anchor_matrix;
|
||||
anchor_matrix.scale(sequence_half_res.x(), sequence_half_res.y());
|
||||
anchor_matrix *= AdjustMatrixByResolutions(
|
||||
GenerateMatrix(row, true, false, false, row[kParentInput].toMatrix()),
|
||||
anchor_matrix *= adjust_matrix_by_resolutions(
|
||||
generate_matrix(row, true, false, false, row[k_parent_input].to_matrix()),
|
||||
sequence_res, tex_sz, tex_offset, autoscale);
|
||||
anchor_gizmo_->SetPoint(anchor_matrix.toTransform().map(QPointF(0, 0)) +
|
||||
anchor_gizmo_->set_point(anchor_matrix.toTransform().map(QPointF(0, 0)) +
|
||||
sequence_half_res_pt);
|
||||
|
||||
// Draw scale handles
|
||||
point_gizmo_[kGizmoScaleTopLeft]->SetPoint(
|
||||
CreateScalePoint(-1, -1, sequence_half_res_pt, rectangle_matrix));
|
||||
point_gizmo_[kGizmoScaleTopCenter]->SetPoint(
|
||||
CreateScalePoint(0, -1, sequence_half_res_pt, rectangle_matrix));
|
||||
point_gizmo_[kGizmoScaleTopRight]->SetPoint(
|
||||
CreateScalePoint(1, -1, sequence_half_res_pt, rectangle_matrix));
|
||||
point_gizmo_[kGizmoScaleBottomLeft]->SetPoint(
|
||||
CreateScalePoint(-1, 1, sequence_half_res_pt, rectangle_matrix));
|
||||
point_gizmo_[kGizmoScaleBottomCenter]->SetPoint(
|
||||
CreateScalePoint(0, 1, sequence_half_res_pt, rectangle_matrix));
|
||||
point_gizmo_[kGizmoScaleBottomRight]->SetPoint(
|
||||
CreateScalePoint(1, 1, sequence_half_res_pt, rectangle_matrix));
|
||||
point_gizmo_[kGizmoScaleCenterLeft]->SetPoint(
|
||||
CreateScalePoint(-1, 0, sequence_half_res_pt, rectangle_matrix));
|
||||
point_gizmo_[kGizmoScaleCenterRight]->SetPoint(
|
||||
CreateScalePoint(1, 0, sequence_half_res_pt, rectangle_matrix));
|
||||
point_gizmo_[k_gizmo_scale_top_left]->set_point(
|
||||
create_scale_point(-1, -1, sequence_half_res_pt, rectangle_matrix));
|
||||
point_gizmo_[k_gizmo_scale_top_center]->set_point(
|
||||
create_scale_point(0, -1, sequence_half_res_pt, rectangle_matrix));
|
||||
point_gizmo_[k_gizmo_scale_top_right]->set_point(
|
||||
create_scale_point(1, -1, sequence_half_res_pt, rectangle_matrix));
|
||||
point_gizmo_[k_gizmo_scale_bottom_left]->set_point(
|
||||
create_scale_point(-1, 1, sequence_half_res_pt, rectangle_matrix));
|
||||
point_gizmo_[k_gizmo_scale_bottom_center]->set_point(
|
||||
create_scale_point(0, 1, sequence_half_res_pt, rectangle_matrix));
|
||||
point_gizmo_[k_gizmo_scale_bottom_right]->set_point(
|
||||
create_scale_point(1, 1, sequence_half_res_pt, rectangle_matrix));
|
||||
point_gizmo_[k_gizmo_scale_center_left]->set_point(
|
||||
create_scale_point(-1, 0, sequence_half_res_pt, rectangle_matrix));
|
||||
point_gizmo_[k_gizmo_scale_center_right]->set_point(
|
||||
create_scale_point(1, 0, sequence_half_res_pt, rectangle_matrix));
|
||||
|
||||
// Use offsets to make the appearance of values that start in the top left, even though we
|
||||
// really anchor around the center
|
||||
SetInputProperty(kPositionInput, QStringLiteral("offset"),
|
||||
set_input_property(k_position_input, QStringLiteral("offset"),
|
||||
sequence_half_res + tex_offset);
|
||||
SetInputProperty(kAnchorInput, QStringLiteral("offset"), tex_sz * 0.5);
|
||||
set_input_property(k_anchor_input, QStringLiteral("offset"), tex_sz * 0.5);
|
||||
}
|
||||
|
||||
QTransform
|
||||
TransformDistortNode::GizmoTransformation(const NodeValueRow &row,
|
||||
TransformDistortNode::gizmo_transformation(const NodeValueRow &row,
|
||||
const NodeGlobals &globals) const
|
||||
{
|
||||
if (TexturePtr texture = row[kTextureInput].toTexture()) {
|
||||
if (TexturePtr texture = row[k_texture_input].to_texture()) {
|
||||
//auto m = GenerateMatrix(row, false, false, false, row[kParentInput].toMatrix());
|
||||
auto m = GenerateMatrix(row, false, false, false, QMatrix4x4());
|
||||
return GenerateAutoScaledMatrix(m, row, globals, texture->params())
|
||||
auto m = generate_matrix(row, false, false, false, QMatrix4x4());
|
||||
return generate_auto_scaled_matrix(m, row, globals, texture->params())
|
||||
.toTransform();
|
||||
}
|
||||
return super::GizmoTransformation(row, globals);
|
||||
return super::gizmo_transformation(row, globals);
|
||||
}
|
||||
|
||||
QPointF TransformDistortNode::CreateScalePoint(double x, double y,
|
||||
QPointF TransformDistortNode::create_scale_point(double x, double y,
|
||||
const QPointF &half_res,
|
||||
const QMatrix4x4 &mat)
|
||||
{
|
||||
return mat.map(QPointF(x, y)) + half_res;
|
||||
}
|
||||
|
||||
QMatrix4x4 TransformDistortNode::GenerateAutoScaledMatrix(
|
||||
QMatrix4x4 TransformDistortNode::generate_auto_scaled_matrix(
|
||||
const QMatrix4x4 &generated_matrix, const NodeValueRow &value,
|
||||
const NodeGlobals &globals, const VideoParams &texture_params) const
|
||||
{
|
||||
@@ -486,16 +486,16 @@ QMatrix4x4 TransformDistortNode::GenerateAutoScaledMatrix(
|
||||
QVector2D texture_res(texture_params.square_pixel_width(),
|
||||
texture_params.height());
|
||||
AutoScaleType autoscale =
|
||||
static_cast<AutoScaleType>(value[kAutoscaleInput].toInt());
|
||||
static_cast<AutoScaleType>(value[k_autoscale_input].to_int());
|
||||
|
||||
return AdjustMatrixByResolutions(generated_matrix, sequence_res,
|
||||
return adjust_matrix_by_resolutions(generated_matrix, sequence_res,
|
||||
texture_res, texture_params.offset(),
|
||||
autoscale);
|
||||
}
|
||||
|
||||
bool TransformDistortNode::IsAScaleGizmo(NodeGizmo *g) const
|
||||
bool TransformDistortNode::is_a_scale_gizmo(NodeGizmo *g) const
|
||||
{
|
||||
for (int i = 0; i < kGizmoScaleCount; i++) {
|
||||
for (int i = 0; i < k_gizmo_scale_count; i++) {
|
||||
if (point_gizmo_[i] == g) {
|
||||
return true;
|
||||
}
|
||||
@@ -505,9 +505,9 @@ bool TransformDistortNode::IsAScaleGizmo(NodeGizmo *g) const
|
||||
}
|
||||
|
||||
TransformDistortNode::RotationDirection
|
||||
TransformDistortNode::GetDirectionFromAngles(double last, double current)
|
||||
TransformDistortNode::get_direction_from_angles(double last, double current)
|
||||
{
|
||||
return (current > last) ? kDirectionPositive : kDirectionNegative;
|
||||
return (current > last) ? k_direction_positive : k_direction_negative;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef TRANSFORMDISTORTNODE_H
|
||||
#define TRANSFORMDISTORTNODE_H
|
||||
#ifndef OAK_TRANSFORMDISTORTNODE_H
|
||||
#define OAK_TRANSFORMDISTORTNODE_H
|
||||
|
||||
#include "node/generator/matrix/matrix.h"
|
||||
#include "node/gizmo/point.h"
|
||||
@@ -37,15 +37,15 @@ public:
|
||||
|
||||
NODE_DEFAULT_FUNCTIONS(TransformDistortNode)
|
||||
|
||||
virtual QString Name() const override
|
||||
virtual QString name() const override
|
||||
{
|
||||
return tr("Transform");
|
||||
}
|
||||
|
||||
virtual QString ShortName() const override
|
||||
virtual QString short_name() const override
|
||||
{
|
||||
// Override MatrixGenerator's short name "Ortho"
|
||||
return Name();
|
||||
return name();
|
||||
}
|
||||
|
||||
virtual QString id() const override
|
||||
@@ -53,65 +53,65 @@ public:
|
||||
return QStringLiteral("org.olivevideoeditor.Olive.transform");
|
||||
}
|
||||
|
||||
virtual QVector<CategoryID> Category() const override
|
||||
virtual QVector<CategoryID> category() const override
|
||||
{
|
||||
return { kCategoryDistort };
|
||||
return { k_category_distort };
|
||||
}
|
||||
|
||||
virtual QString Description() const override
|
||||
virtual QString description() const override
|
||||
{
|
||||
return tr(
|
||||
"Transform an image in 2D space. Equivalent to multiplying by an orthographic matrix.");
|
||||
}
|
||||
|
||||
virtual void Retranslate() override;
|
||||
virtual void retranslate() override;
|
||||
|
||||
virtual void Value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
virtual void value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
NodeValueTable *table) const override;
|
||||
|
||||
virtual ShaderCode
|
||||
GetShaderCode(const ShaderRequest &request) const override;
|
||||
get_shader_code(const ShaderRequest &request) const override;
|
||||
|
||||
enum AutoScaleType {
|
||||
kAutoScaleNone,
|
||||
kAutoScaleFit,
|
||||
kAutoScaleFill,
|
||||
kAutoScaleStretch
|
||||
k_auto_scale_none,
|
||||
k_auto_scale_fit,
|
||||
k_auto_scale_fill,
|
||||
k_auto_scale_stretch
|
||||
};
|
||||
|
||||
static QMatrix4x4 AdjustMatrixByResolutions(
|
||||
static QMatrix4x4 adjust_matrix_by_resolutions(
|
||||
const QMatrix4x4 &mat, const QVector2D &sequence_res,
|
||||
const QVector2D &texture_res, const QVector2D &offset,
|
||||
AutoScaleType autoscale_type = kAutoScaleNone);
|
||||
AutoScaleType autoscale_type = k_auto_scale_none);
|
||||
|
||||
virtual void UpdateGizmoPositions(const NodeValueRow &row,
|
||||
virtual void update_gizmo_positions(const NodeValueRow &row,
|
||||
const NodeGlobals &globals) override;
|
||||
virtual QTransform
|
||||
GizmoTransformation(const NodeValueRow &row,
|
||||
gizmo_transformation(const NodeValueRow &row,
|
||||
const NodeGlobals &globals) const override;
|
||||
|
||||
static const QString kParentInput;
|
||||
static const QString kTextureInput;
|
||||
static const QString kAutoscaleInput;
|
||||
static const QString kInterpolationInput;
|
||||
static const QString k_parent_input;
|
||||
static const QString k_texture_input;
|
||||
static const QString k_autoscale_input;
|
||||
static const QString k_interpolation_input;
|
||||
|
||||
protected slots:
|
||||
virtual void GizmoDragStart(const olive::NodeValueRow &row, double x,
|
||||
double y, const olive::rational &time) override;
|
||||
virtual void gizmo_drag_start(const olive::NodeValueRow &row, double x,
|
||||
double y, const olive::Rational &time) override;
|
||||
|
||||
virtual void GizmoDragMove(double x, double y,
|
||||
virtual void gizmo_drag_move(double x, double y,
|
||||
const Qt::KeyboardModifiers &modifiers) override;
|
||||
|
||||
private:
|
||||
static QPointF CreateScalePoint(double x, double y, const QPointF &half_res,
|
||||
static QPointF create_scale_point(double x, double y, const QPointF &half_res,
|
||||
const QMatrix4x4 &mat);
|
||||
|
||||
QMatrix4x4
|
||||
GenerateAutoScaledMatrix(const QMatrix4x4 &generated_matrix,
|
||||
generate_auto_scaled_matrix(const QMatrix4x4 &generated_matrix,
|
||||
const NodeValueRow &db, const NodeGlobals &globals,
|
||||
const VideoParams &texture_params) const;
|
||||
|
||||
bool IsAScaleGizmo(NodeGizmo *g) const;
|
||||
bool is_a_scale_gizmo(NodeGizmo *g) const;
|
||||
|
||||
// Gizmo variables
|
||||
double gizmo_start_angle_;
|
||||
@@ -123,23 +123,23 @@ private:
|
||||
int gizmo_rotate_wrap_;
|
||||
|
||||
enum RotationDirection {
|
||||
kDirectionNone,
|
||||
kDirectionPositive, // Clockwise
|
||||
kDirectionNegative // Counter-clockwise
|
||||
k_direction_none,
|
||||
k_direction_positive, // Clockwise
|
||||
k_direction_negative // Counter-clockwise
|
||||
};
|
||||
|
||||
static RotationDirection GetDirectionFromAngles(double last,
|
||||
static RotationDirection get_direction_from_angles(double last,
|
||||
double current);
|
||||
RotationDirection gizmo_rotate_last_dir_;
|
||||
RotationDirection gizmo_rotate_last_alt_dir_;
|
||||
|
||||
enum GizmoScaleType { kGizmoScaleXOnly, kGizmoScaleYOnly, kGizmoScaleBoth };
|
||||
enum GizmoScaleType { k_gizmo_scale_x_only, k_gizmo_scale_y_only, k_gizmo_scale_both };
|
||||
|
||||
GizmoScaleType gizmo_scale_axes_;
|
||||
QVector2D gizmo_scale_anchor_;
|
||||
|
||||
// Gizmo on screen object storage
|
||||
PointGizmo *point_gizmo_[kGizmoScaleCount];
|
||||
PointGizmo *point_gizmo_[k_gizmo_scale_count];
|
||||
PointGizmo *anchor_gizmo_;
|
||||
PolygonGizmo *poly_gizmo_;
|
||||
ScreenGizmo *rotation_gizmo_;
|
||||
@@ -147,4 +147,4 @@ private:
|
||||
|
||||
}
|
||||
|
||||
#endif // TRANSFORMDISTORTNODE_H
|
||||
#endif // OAK_TRANSFORMDISTORTNODE_H
|
||||
|
||||
@@ -24,30 +24,30 @@
|
||||
namespace olive
|
||||
{
|
||||
|
||||
const QString WaveDistortNode::kTextureInput = QStringLiteral("tex_in");
|
||||
const QString WaveDistortNode::kFrequencyInput = QStringLiteral("frequency_in");
|
||||
const QString WaveDistortNode::kIntensityInput = QStringLiteral("intensity_in");
|
||||
const QString WaveDistortNode::kEvolutionInput = QStringLiteral("evolution_in");
|
||||
const QString WaveDistortNode::kVerticalInput = QStringLiteral("vertical_in");
|
||||
const QString WaveDistortNode::k_texture_input = QStringLiteral("tex_in");
|
||||
const QString WaveDistortNode::k_frequency_input = QStringLiteral("frequency_in");
|
||||
const QString WaveDistortNode::k_intensity_input = QStringLiteral("intensity_in");
|
||||
const QString WaveDistortNode::k_evolution_input = QStringLiteral("evolution_in");
|
||||
const QString WaveDistortNode::k_vertical_input = QStringLiteral("vertical_in");
|
||||
|
||||
#define super Node
|
||||
|
||||
WaveDistortNode::WaveDistortNode()
|
||||
{
|
||||
AddInput(kTextureInput, NodeValue::kTexture,
|
||||
InputFlags(kInputFlagNotKeyframable));
|
||||
add_input(k_texture_input, NodeValue::k_texture,
|
||||
InputFlags(k_input_flag_not_keyframable));
|
||||
|
||||
AddInput(kFrequencyInput, NodeValue::kFloat, 10);
|
||||
AddInput(kIntensityInput, NodeValue::kFloat, 10);
|
||||
AddInput(kEvolutionInput, NodeValue::kFloat, 0);
|
||||
add_input(k_frequency_input, NodeValue::k_float, 10);
|
||||
add_input(k_intensity_input, NodeValue::k_float, 10);
|
||||
add_input(k_evolution_input, NodeValue::k_float, 0);
|
||||
|
||||
AddInput(kVerticalInput, NodeValue::kCombo, false);
|
||||
add_input(k_vertical_input, NodeValue::k_combo, false);
|
||||
|
||||
SetFlag(kVideoEffect);
|
||||
SetEffectInput(kTextureInput);
|
||||
set_flag(k_video_effect);
|
||||
set_effect_input(k_texture_input);
|
||||
}
|
||||
|
||||
QString WaveDistortNode::Name() const
|
||||
QString WaveDistortNode::name() const
|
||||
{
|
||||
return tr("Wave");
|
||||
}
|
||||
@@ -57,48 +57,48 @@ QString WaveDistortNode::id() const
|
||||
return QStringLiteral("org.olivevideoeditor.Olive.wave");
|
||||
}
|
||||
|
||||
QVector<Node::CategoryID> WaveDistortNode::Category() const
|
||||
QVector<Node::CategoryID> WaveDistortNode::category() const
|
||||
{
|
||||
return { kCategoryDistort };
|
||||
return { k_category_distort };
|
||||
}
|
||||
|
||||
QString WaveDistortNode::Description() const
|
||||
QString WaveDistortNode::description() const
|
||||
{
|
||||
return tr("Distorts an image along a sine wave.");
|
||||
}
|
||||
|
||||
void WaveDistortNode::Retranslate()
|
||||
void WaveDistortNode::retranslate()
|
||||
{
|
||||
super::Retranslate();
|
||||
super::retranslate();
|
||||
|
||||
SetInputName(kTextureInput, tr("Input"));
|
||||
SetInputName(kFrequencyInput, tr("Frequency"));
|
||||
SetInputName(kIntensityInput, tr("Intensity"));
|
||||
SetInputName(kEvolutionInput, tr("Evolution"));
|
||||
SetInputName(kVerticalInput, tr("Direction"));
|
||||
SetComboBoxStrings(kVerticalInput, { tr("Horizontal"), tr("Vertical") });
|
||||
set_input_name(k_texture_input, tr("Input"));
|
||||
set_input_name(k_frequency_input, tr("Frequency"));
|
||||
set_input_name(k_intensity_input, tr("Intensity"));
|
||||
set_input_name(k_evolution_input, tr("Evolution"));
|
||||
set_input_name(k_vertical_input, tr("Direction"));
|
||||
set_combo_box_strings(k_vertical_input, { tr("Horizontal"), tr("Vertical") });
|
||||
}
|
||||
|
||||
ShaderCode WaveDistortNode::GetShaderCode(const ShaderRequest &request) const
|
||||
ShaderCode WaveDistortNode::get_shader_code(const ShaderRequest &request) const
|
||||
{
|
||||
Q_UNUSED(request)
|
||||
return ShaderCode(FileFunctions::ReadFileAsString(":/shaders/wave.frag"));
|
||||
return ShaderCode(FileFunctions::read_file_as_string(":/shaders/wave.frag"));
|
||||
}
|
||||
|
||||
void WaveDistortNode::Value(const NodeValueRow &value,
|
||||
void WaveDistortNode::value(const NodeValueRow &value,
|
||||
const NodeGlobals &globals,
|
||||
NodeValueTable *table) const
|
||||
{
|
||||
// If there's no texture, no need to run an operation
|
||||
if (TexturePtr texture = value[kTextureInput].toTexture()) {
|
||||
if (TexturePtr texture = value[k_texture_input].to_texture()) {
|
||||
// Only run shader if at least one of flip or flop are selected
|
||||
if (!qIsNull(value[kIntensityInput].toDouble())) {
|
||||
table->Push(NodeValue::kTexture,
|
||||
Texture::Job(texture->params(), ShaderJob(value)),
|
||||
if (!qIsNull(value[k_intensity_input].to_double())) {
|
||||
table->push(NodeValue::k_texture,
|
||||
Texture::job(texture->params(), ShaderJob(value)),
|
||||
this);
|
||||
} else {
|
||||
// If we're not flipping or flopping just push the texture
|
||||
table->Push(value[kTextureInput]);
|
||||
table->push(value[k_texture_input]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef WAVEDISTORTNODE_H
|
||||
#define WAVEDISTORTNODE_H
|
||||
#ifndef OAK_WAVEDISTORTNODE_H
|
||||
#define OAK_WAVEDISTORTNODE_H
|
||||
|
||||
#include "node/node.h"
|
||||
|
||||
@@ -34,25 +34,25 @@ public:
|
||||
|
||||
NODE_DEFAULT_FUNCTIONS(WaveDistortNode)
|
||||
|
||||
virtual QString Name() const override;
|
||||
virtual QString name() const override;
|
||||
virtual QString id() const override;
|
||||
virtual QVector<CategoryID> Category() const override;
|
||||
virtual QString Description() const override;
|
||||
virtual QVector<CategoryID> category() const override;
|
||||
virtual QString description() const override;
|
||||
|
||||
virtual void Retranslate() override;
|
||||
virtual void retranslate() override;
|
||||
|
||||
virtual ShaderCode
|
||||
GetShaderCode(const ShaderRequest &request) const override;
|
||||
virtual void Value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
get_shader_code(const ShaderRequest &request) const override;
|
||||
virtual void value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
NodeValueTable *table) const override;
|
||||
|
||||
static const QString kTextureInput;
|
||||
static const QString kFrequencyInput;
|
||||
static const QString kIntensityInput;
|
||||
static const QString kEvolutionInput;
|
||||
static const QString kVerticalInput;
|
||||
static const QString k_texture_input;
|
||||
static const QString k_frequency_input;
|
||||
static const QString k_intensity_input;
|
||||
static const QString k_evolution_input;
|
||||
static const QString k_vertical_input;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // WAVEDISTORTNODE_H
|
||||
#endif // OAK_WAVEDISTORTNODE_H
|
||||
|
||||
Reference in New Issue
Block a user