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:
@@ -27,43 +27,43 @@
|
||||
namespace olive
|
||||
{
|
||||
|
||||
const QString PolygonGenerator::kPointsInput = QStringLiteral("points_in");
|
||||
const QString PolygonGenerator::kColorInput = QStringLiteral("color_in");
|
||||
const QString PolygonGenerator::k_points_input = QStringLiteral("points_in");
|
||||
const QString PolygonGenerator::k_color_input = QStringLiteral("color_in");
|
||||
|
||||
#define super GeneratorWithMerge
|
||||
|
||||
PolygonGenerator::PolygonGenerator()
|
||||
{
|
||||
AddInput(kPointsInput, NodeValue::kBezier, QVector2D(0, 0),
|
||||
InputFlags(kInputFlagArray));
|
||||
add_input(k_points_input, NodeValue::k_bezier, QVector2D(0, 0),
|
||||
InputFlags(k_input_flag_array));
|
||||
|
||||
AddInput(kColorInput, NodeValue::kColor,
|
||||
add_input(k_color_input, NodeValue::k_color,
|
||||
QVariant::fromValue(Color(1.0, 1.0, 1.0)));
|
||||
|
||||
const int kMiddleX = 135;
|
||||
const int kMiddleY = 45;
|
||||
const int kBottomX = 90;
|
||||
const int kBottomY = 120;
|
||||
const int kTopY = 135;
|
||||
const int k_middle_x = 135;
|
||||
const int k_middle_y = 45;
|
||||
const int k_bottom_x = 90;
|
||||
const int k_bottom_y = 120;
|
||||
const int k_top_y = 135;
|
||||
|
||||
// The Default Pentagon(tm)
|
||||
InputArrayResize(kPointsInput, 5);
|
||||
SetSplitStandardValueOnTrack(kPointsInput, 0, 0, 0);
|
||||
SetSplitStandardValueOnTrack(kPointsInput, 1, -kTopY, 0);
|
||||
SetSplitStandardValueOnTrack(kPointsInput, 0, kMiddleX, 1);
|
||||
SetSplitStandardValueOnTrack(kPointsInput, 1, -kMiddleY, 1);
|
||||
SetSplitStandardValueOnTrack(kPointsInput, 0, kBottomX, 2);
|
||||
SetSplitStandardValueOnTrack(kPointsInput, 1, kBottomY, 2);
|
||||
SetSplitStandardValueOnTrack(kPointsInput, 0, -kBottomX, 3);
|
||||
SetSplitStandardValueOnTrack(kPointsInput, 1, kBottomY, 3);
|
||||
SetSplitStandardValueOnTrack(kPointsInput, 0, -kMiddleX, 4);
|
||||
SetSplitStandardValueOnTrack(kPointsInput, 1, -kMiddleY, 4);
|
||||
input_array_resize(k_points_input, 5);
|
||||
set_split_standard_value_on_track(k_points_input, 0, 0, 0);
|
||||
set_split_standard_value_on_track(k_points_input, 1, -k_top_y, 0);
|
||||
set_split_standard_value_on_track(k_points_input, 0, k_middle_x, 1);
|
||||
set_split_standard_value_on_track(k_points_input, 1, -k_middle_y, 1);
|
||||
set_split_standard_value_on_track(k_points_input, 0, k_bottom_x, 2);
|
||||
set_split_standard_value_on_track(k_points_input, 1, k_bottom_y, 2);
|
||||
set_split_standard_value_on_track(k_points_input, 0, -k_bottom_x, 3);
|
||||
set_split_standard_value_on_track(k_points_input, 1, k_bottom_y, 3);
|
||||
set_split_standard_value_on_track(k_points_input, 0, -k_middle_x, 4);
|
||||
set_split_standard_value_on_track(k_points_input, 1, -k_middle_y, 4);
|
||||
|
||||
// Initiate gizmos
|
||||
poly_gizmo_ = new PathGizmo(this);
|
||||
}
|
||||
|
||||
QString PolygonGenerator::Name() const
|
||||
QString PolygonGenerator::name() const
|
||||
{
|
||||
return tr("Polygon");
|
||||
}
|
||||
@@ -73,52 +73,52 @@ QString PolygonGenerator::id() const
|
||||
return QStringLiteral("org.olivevideoeditor.Olive.polygon");
|
||||
}
|
||||
|
||||
QVector<Node::CategoryID> PolygonGenerator::Category() const
|
||||
QVector<Node::CategoryID> PolygonGenerator::category() const
|
||||
{
|
||||
return { kCategoryGenerator };
|
||||
return { k_category_generator };
|
||||
}
|
||||
|
||||
QString PolygonGenerator::Description() const
|
||||
QString PolygonGenerator::description() const
|
||||
{
|
||||
return tr("Generate a 2D polygon of any amount of points.");
|
||||
}
|
||||
|
||||
void PolygonGenerator::Retranslate()
|
||||
void PolygonGenerator::retranslate()
|
||||
{
|
||||
super::Retranslate();
|
||||
super::retranslate();
|
||||
|
||||
SetInputName(kPointsInput, tr("Points"));
|
||||
SetInputName(kColorInput, tr("Color"));
|
||||
set_input_name(k_points_input, tr("Points"));
|
||||
set_input_name(k_color_input, tr("Color"));
|
||||
}
|
||||
|
||||
ShaderJob PolygonGenerator::GetGenerateJob(const NodeValueRow &value,
|
||||
ShaderJob PolygonGenerator::get_generate_job(const NodeValueRow &value,
|
||||
const VideoParams ¶ms) const
|
||||
{
|
||||
VideoParams p = params;
|
||||
p.set_format(PixelFormat::U8);
|
||||
auto job = Texture::Job(p, GenerateJob(value));
|
||||
p.set_format(PixelFormat::u8);
|
||||
auto job = Texture::job(p, GenerateJob(value));
|
||||
|
||||
// Conversion to RGB
|
||||
ShaderJob rgb;
|
||||
rgb.SetShaderID(QStringLiteral("rgb"));
|
||||
rgb.Insert(QStringLiteral("texture_in"),
|
||||
NodeValue(NodeValue::kTexture, job, this));
|
||||
rgb.Insert(QStringLiteral("color_in"), value[kColorInput]);
|
||||
rgb.set_shader_id(QStringLiteral("rgb"));
|
||||
rgb.insert(QStringLiteral("texture_in"),
|
||||
NodeValue(NodeValue::k_texture, job, this));
|
||||
rgb.insert(QStringLiteral("color_in"), value[k_color_input]);
|
||||
|
||||
return rgb;
|
||||
}
|
||||
|
||||
void PolygonGenerator::Value(const NodeValueRow &value,
|
||||
void PolygonGenerator::value(const NodeValueRow &value,
|
||||
const NodeGlobals &globals,
|
||||
NodeValueTable *table) const
|
||||
{
|
||||
PushMergableJob(value,
|
||||
Texture::Job(globals.vparams(),
|
||||
GetGenerateJob(value, globals.vparams())),
|
||||
push_mergable_job(value,
|
||||
Texture::job(globals.vparams(),
|
||||
get_generate_job(value, globals.vparams())),
|
||||
table);
|
||||
}
|
||||
|
||||
void PolygonGenerator::GenerateFrame(FramePtr frame,
|
||||
void PolygonGenerator::generate_frame(FramePtr frame,
|
||||
const GenerateJob &job) const
|
||||
{
|
||||
// This could probably be more optimized, but for now we use Qt to draw to a QImage.
|
||||
@@ -129,12 +129,12 @@ void PolygonGenerator::GenerateFrame(FramePtr frame,
|
||||
frame->linesize_bytes(), QImage::Format_RGBA8888_Premultiplied);
|
||||
img.fill(Qt::transparent);
|
||||
|
||||
auto points = job.Get(kPointsInput).toArray();
|
||||
auto points = job.get(k_points_input).to_array();
|
||||
|
||||
QPainterPath path = GeneratePath(points, InputArraySize(kPointsInput));
|
||||
QPainterPath path = generate_path(points, input_array_size(k_points_input));
|
||||
|
||||
QPainter p(&img);
|
||||
double par = frame->video_params().pixel_aspect_ratio().toDouble();
|
||||
double par = frame->video_params().pixel_aspect_ratio().to_double();
|
||||
p.scale(1.0 / frame->video_params().divider() / par,
|
||||
1.0 / frame->video_params().divider());
|
||||
p.translate(frame->video_params().width() / 2 * par,
|
||||
@@ -145,18 +145,18 @@ void PolygonGenerator::GenerateFrame(FramePtr frame,
|
||||
p.drawPath(path);
|
||||
}
|
||||
|
||||
template <typename T> NodeGizmo *PolygonGenerator::CreateAppropriateGizmo()
|
||||
template <typename T> NodeGizmo *PolygonGenerator::create_appropriate_gizmo()
|
||||
{
|
||||
return new T(this);
|
||||
}
|
||||
|
||||
template <> NodeGizmo *PolygonGenerator::CreateAppropriateGizmo<PointGizmo>()
|
||||
template <> NodeGizmo *PolygonGenerator::create_appropriate_gizmo<PointGizmo>()
|
||||
{
|
||||
return AddDraggableGizmo<PointGizmo>();
|
||||
return add_draggable_gizmo<PointGizmo>();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void PolygonGenerator::ValidateGizmoVectorSize(QVector<T *> &vec, int new_sz)
|
||||
void PolygonGenerator::validate_gizmo_vector_size(QVector<T *> &vec, int new_sz)
|
||||
{
|
||||
int old_sz = vec.size();
|
||||
|
||||
@@ -171,17 +171,17 @@ void PolygonGenerator::ValidateGizmoVectorSize(QVector<T *> &vec, int new_sz)
|
||||
|
||||
if (old_sz < new_sz) {
|
||||
for (int i = old_sz; i < new_sz; i++) {
|
||||
vec[i] = static_cast<T *>(CreateAppropriateGizmo<T>());
|
||||
vec[i] = static_cast<T *>(create_appropriate_gizmo<T>());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void PolygonGenerator::UpdateGizmoPositions(const NodeValueRow &row,
|
||||
void PolygonGenerator::update_gizmo_positions(const NodeValueRow &row,
|
||||
const NodeGlobals &globals)
|
||||
{
|
||||
QVector2D res;
|
||||
if (TexturePtr tex = row[kBaseInput].toTexture()) {
|
||||
if (TexturePtr tex = row[k_base_input].to_texture()) {
|
||||
res = tex->virtual_resolution();
|
||||
} else {
|
||||
res = globals.square_resolution();
|
||||
@@ -189,72 +189,72 @@ void PolygonGenerator::UpdateGizmoPositions(const NodeValueRow &row,
|
||||
|
||||
Imath::V2d half_res(res.x() / 2, res.y() / 2);
|
||||
|
||||
auto points = row[kPointsInput].toArray();
|
||||
auto points = row[k_points_input].to_array();
|
||||
|
||||
int current_pos_sz = gizmo_position_handles_.size();
|
||||
|
||||
ValidateGizmoVectorSize(gizmo_position_handles_, points.size());
|
||||
ValidateGizmoVectorSize(gizmo_bezier_handles_, points.size() * 2);
|
||||
ValidateGizmoVectorSize(gizmo_bezier_lines_, points.size() * 2);
|
||||
validate_gizmo_vector_size(gizmo_position_handles_, points.size());
|
||||
validate_gizmo_vector_size(gizmo_bezier_handles_, points.size() * 2);
|
||||
validate_gizmo_vector_size(gizmo_bezier_lines_, points.size() * 2);
|
||||
|
||||
for (int i = current_pos_sz; i < gizmo_position_handles_.size(); i++) {
|
||||
gizmo_position_handles_.at(i)->AddInput(
|
||||
NodeKeyframeTrackReference(NodeInput(this, kPointsInput, i), 0));
|
||||
gizmo_position_handles_.at(i)->AddInput(
|
||||
NodeKeyframeTrackReference(NodeInput(this, kPointsInput, i), 1));
|
||||
gizmo_position_handles_.at(i)->add_input(
|
||||
NodeKeyframeTrackReference(NodeInput(this, k_points_input, i), 0));
|
||||
gizmo_position_handles_.at(i)->add_input(
|
||||
NodeKeyframeTrackReference(NodeInput(this, k_points_input, i), 1));
|
||||
|
||||
PointGizmo *bez_gizmo1 = gizmo_bezier_handles_.at(i * 2 + 0);
|
||||
bez_gizmo1->AddInput(
|
||||
NodeKeyframeTrackReference(NodeInput(this, kPointsInput, i), 2));
|
||||
bez_gizmo1->AddInput(
|
||||
NodeKeyframeTrackReference(NodeInput(this, kPointsInput, i), 3));
|
||||
bez_gizmo1->SetShape(PointGizmo::kCircle);
|
||||
bez_gizmo1->SetSmaller(true);
|
||||
bez_gizmo1->add_input(
|
||||
NodeKeyframeTrackReference(NodeInput(this, k_points_input, i), 2));
|
||||
bez_gizmo1->add_input(
|
||||
NodeKeyframeTrackReference(NodeInput(this, k_points_input, i), 3));
|
||||
bez_gizmo1->set_shape(PointGizmo::k_circle);
|
||||
bez_gizmo1->set_smaller(true);
|
||||
|
||||
PointGizmo *bez_gizmo2 = gizmo_bezier_handles_.at(i * 2 + 1);
|
||||
bez_gizmo2->AddInput(
|
||||
NodeKeyframeTrackReference(NodeInput(this, kPointsInput, i), 4));
|
||||
bez_gizmo2->AddInput(
|
||||
NodeKeyframeTrackReference(NodeInput(this, kPointsInput, i), 5));
|
||||
bez_gizmo2->SetShape(PointGizmo::kCircle);
|
||||
bez_gizmo2->SetSmaller(true);
|
||||
bez_gizmo2->add_input(
|
||||
NodeKeyframeTrackReference(NodeInput(this, k_points_input, i), 4));
|
||||
bez_gizmo2->add_input(
|
||||
NodeKeyframeTrackReference(NodeInput(this, k_points_input, i), 5));
|
||||
bez_gizmo2->set_shape(PointGizmo::k_circle);
|
||||
bez_gizmo2->set_smaller(true);
|
||||
}
|
||||
|
||||
int pts_sz = InputArraySize(kPointsInput);
|
||||
int pts_sz = input_array_size(k_points_input);
|
||||
if (!points.empty()) {
|
||||
for (int i = 0; i < pts_sz; i++) {
|
||||
const Bezier &pt = points.at(i).toBezier();
|
||||
const Bezier &pt = points.at(i).to_bezier();
|
||||
|
||||
Imath::V2d main = pt.to_vec() + half_res;
|
||||
Imath::V2d cp1 = main + pt.control_point_1_to_vec();
|
||||
Imath::V2d cp2 = main + pt.control_point_2_to_vec();
|
||||
|
||||
gizmo_position_handles_[i]->SetPoint(QPointF(main.x, main.y));
|
||||
gizmo_position_handles_[i]->set_point(QPointF(main.x, main.y));
|
||||
|
||||
gizmo_bezier_handles_[i * 2]->SetPoint(QPointF(cp1.x, cp1.y));
|
||||
gizmo_bezier_lines_[i * 2]->SetLine(
|
||||
gizmo_bezier_handles_[i * 2]->set_point(QPointF(cp1.x, cp1.y));
|
||||
gizmo_bezier_lines_[i * 2]->set_line(
|
||||
QLineF(QPointF(main.x, main.y), QPointF(cp1.x, cp1.y)));
|
||||
gizmo_bezier_handles_[i * 2 + 1]->SetPoint(QPointF(cp2.x, cp2.y));
|
||||
gizmo_bezier_lines_[i * 2 + 1]->SetLine(
|
||||
gizmo_bezier_handles_[i * 2 + 1]->set_point(QPointF(cp2.x, cp2.y));
|
||||
gizmo_bezier_lines_[i * 2 + 1]->set_line(
|
||||
QLineF(QPointF(main.x, main.y), QPointF(cp2.x, cp2.y)));
|
||||
}
|
||||
}
|
||||
|
||||
poly_gizmo_->SetPath(GeneratePath(points, pts_sz)
|
||||
poly_gizmo_->set_path(generate_path(points, pts_sz)
|
||||
.translated(QPointF(half_res.x, half_res.y)));
|
||||
}
|
||||
|
||||
ShaderCode PolygonGenerator::GetShaderCode(const ShaderRequest &request) const
|
||||
ShaderCode PolygonGenerator::get_shader_code(const ShaderRequest &request) const
|
||||
{
|
||||
if (request.id == QStringLiteral("rgb")) {
|
||||
return ShaderCode(
|
||||
FileFunctions::ReadFileAsString(":/shaders/rgb.frag"));
|
||||
FileFunctions::read_file_as_string(":/shaders/rgb.frag"));
|
||||
} else {
|
||||
return super::GetShaderCode(request);
|
||||
return super::get_shader_code(request);
|
||||
}
|
||||
}
|
||||
|
||||
void PolygonGenerator::GizmoDragMove(double x, double y,
|
||||
void PolygonGenerator::gizmo_drag_move(double x, double y,
|
||||
const Qt::KeyboardModifiers &modifiers)
|
||||
{
|
||||
DraggableGizmo *gizmo = static_cast<DraggableGizmo *>(sender());
|
||||
@@ -262,14 +262,14 @@ void PolygonGenerator::GizmoDragMove(double x, double y,
|
||||
if (gizmo == poly_gizmo_) {
|
||||
// FIXME: Drag all points
|
||||
} else {
|
||||
NodeInputDragger &x_drag = gizmo->GetDraggers()[0];
|
||||
NodeInputDragger &y_drag = gizmo->GetDraggers()[1];
|
||||
x_drag.Drag(x_drag.GetStartValue().toDouble() + x);
|
||||
y_drag.Drag(y_drag.GetStartValue().toDouble() + y);
|
||||
NodeInputDragger &x_drag = gizmo->get_draggers()[0];
|
||||
NodeInputDragger &y_drag = gizmo->get_draggers()[1];
|
||||
x_drag.drag(x_drag.get_start_value().toDouble() + x);
|
||||
y_drag.drag(y_drag.get_start_value().toDouble() + y);
|
||||
}
|
||||
}
|
||||
|
||||
void PolygonGenerator::AddPointToPath(QPainterPath *path, const Bezier &before,
|
||||
void PolygonGenerator::add_point_to_path(QPainterPath *path, const Bezier &before,
|
||||
const Bezier &after)
|
||||
{
|
||||
Imath::V2d a = before.to_vec() + before.control_point_2_to_vec();
|
||||
@@ -279,22 +279,22 @@ void PolygonGenerator::AddPointToPath(QPainterPath *path, const Bezier &before,
|
||||
path->cubicTo(QPointF(a.x, a.y), QPointF(b.x, b.y), QPointF(c.x, c.y));
|
||||
}
|
||||
|
||||
QPainterPath PolygonGenerator::GeneratePath(const NodeValueArray &points,
|
||||
QPainterPath PolygonGenerator::generate_path(const NodeValueArray &points,
|
||||
int size)
|
||||
{
|
||||
QPainterPath path;
|
||||
|
||||
if (!points.empty()) {
|
||||
const Bezier &first_pt = points.at(0).toBezier();
|
||||
const Bezier &first_pt = points.at(0).to_bezier();
|
||||
Imath::V2d v = first_pt.to_vec();
|
||||
path.moveTo(QPointF(v.x, v.y));
|
||||
|
||||
for (int i = 1; i < size; i++) {
|
||||
AddPointToPath(&path, points.at(i - 1).toBezier(),
|
||||
points.at(i).toBezier());
|
||||
add_point_to_path(&path, points.at(i - 1).to_bezier(),
|
||||
points.at(i).to_bezier());
|
||||
}
|
||||
|
||||
AddPointToPath(&path, points.at(size - 1).toBezier(), first_pt);
|
||||
add_point_to_path(&path, points.at(size - 1).to_bezier(), first_pt);
|
||||
}
|
||||
|
||||
return path;
|
||||
|
||||
Reference in New Issue
Block a user