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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user