Skip to content

Commit

Permalink
Changed None to empty string, corrected dynamic pointers
Browse files Browse the repository at this point in the history
  • Loading branch information
BrennoCaldato committed Apr 13, 2021
1 parent a7cefa4 commit 2cf2c55
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 23 deletions.
10 changes: 5 additions & 5 deletions src/Clip.cpp
Expand Up @@ -749,7 +749,7 @@ std::string Clip::PropertiesJSON(int64_t requested_frame) const {
if (!parentObjectId.empty()) {
root["parentObjectId"] = add_property_json("Parent", 0.0, "string", parentObjectId, NULL, -1, -1, false, requested_frame);
} else {
root["parentObjectId"] = add_property_json("Parent", 0.0, "string", "None", NULL, -1, -1, false, requested_frame);
root["parentObjectId"] = add_property_json("Parent", 0.0, "string", "", NULL, -1, -1, false, requested_frame);
}
// Add gravity choices (dropdown style)
root["gravity"]["choices"].append(add_property_choice_json("Top Left", GRAVITY_TOP_LEFT, gravity));
Expand All @@ -766,16 +766,16 @@ std::string Clip::PropertiesJSON(int64_t requested_frame) const {
root["scale"]["choices"].append(add_property_choice_json("Crop", SCALE_CROP, scale));
root["scale"]["choices"].append(add_property_choice_json("Best Fit", SCALE_FIT, scale));
root["scale"]["choices"].append(add_property_choice_json("Stretch", SCALE_STRETCH, scale));
root["scale"]["choices"].append(add_property_choice_json("None", SCALE_NONE, scale));
root["scale"]["choices"].append(add_property_choice_json("", SCALE_NONE, scale));

// Add frame number display choices (dropdown style)
root["display"]["choices"].append(add_property_choice_json("None", FRAME_DISPLAY_NONE, display));
root["display"]["choices"].append(add_property_choice_json("", FRAME_DISPLAY_NONE, display));
root["display"]["choices"].append(add_property_choice_json("Clip", FRAME_DISPLAY_CLIP, display));
root["display"]["choices"].append(add_property_choice_json("Timeline", FRAME_DISPLAY_TIMELINE, display));
root["display"]["choices"].append(add_property_choice_json("Both", FRAME_DISPLAY_BOTH, display));

// Add volume mixing choices (dropdown style)
root["mixing"]["choices"].append(add_property_choice_json("None", VOLUME_MIX_NONE, mixing));
root["mixing"]["choices"].append(add_property_choice_json("", VOLUME_MIX_NONE, mixing));
root["mixing"]["choices"].append(add_property_choice_json("Average", VOLUME_MIX_AVERAGE, mixing));
root["mixing"]["choices"].append(add_property_choice_json("Reduce", VOLUME_MIX_REDUCE, mixing));

Expand Down Expand Up @@ -962,7 +962,7 @@ void Clip::SetJsonValue(const Json::Value root) {
// Set data from Json (if key is found)
if (!root["parentObjectId"].isNull()){
parentObjectId = root["parentObjectId"].asString();
if (parentObjectId.size() > 0 && parentObjectId != "None"){
if (parentObjectId.size() > 0 && parentObjectId != ""){
AttachToObject(parentObjectId);
} else{
parentTrackedObject = nullptr;
Expand Down
4 changes: 2 additions & 2 deletions src/EffectBase.cpp
Expand Up @@ -52,7 +52,7 @@ void EffectBase::InitEffectInfo()
info.has_tracked_object = false;
info.name = "";
info.description = "";
info.parent_effect_id = "None";
info.parent_effect_id = "";
}

// Display file information
Expand Down Expand Up @@ -160,7 +160,7 @@ void EffectBase::SetJsonValue(Json::Value root) {

if (!root["parent_effect_id"].isNull()){
info.parent_effect_id = root["parent_effect_id"].asString();
if (info.parent_effect_id.size() > 0 && info.parent_effect_id != "None" && parentEffect == NULL)
if (info.parent_effect_id.size() > 0 && info.parent_effect_id != "" && parentEffect == NULL)
SetParentEffect(info.parent_effect_id);
else
parentEffect = NULL;
Expand Down
7 changes: 3 additions & 4 deletions src/KeyFrame.cpp
Expand Up @@ -34,9 +34,9 @@
#include <algorithm>
#include <functional>
#include <utility>
#include <cassert> // For assert()
#include <iostream> // For std::cout
#include <iomanip> // For std::setprecision
#include <cassert> // For assert()
#include <iostream> // For std::cout
#include <iomanip> // For std::setprecision

using namespace std;
using namespace openshot;
Expand Down Expand Up @@ -92,7 +92,6 @@ namespace openshot{
t_step /= 2;
} while (true);
}

// Interpolate two points using the right Point's interpolation method
double InterpolateBetween(Point const & left, Point const & right, double target, double allowed_error) {
assert(left.co.X < target);
Expand Down
4 changes: 2 additions & 2 deletions src/TrackedObjectBBox.cpp
Expand Up @@ -370,7 +370,7 @@ void TrackedObjectBBox::SetJsonValue(const Json::Value root)
{

// Set the Id by the given JSON object
if (!root["box_id"].isNull() && root["box_id"].asString() != "None")
if (!root["box_id"].isNull() && root["box_id"].asString() != "")
Id(root["box_id"].asString());

// Set the BaseFps by the given JSON object
Expand All @@ -395,7 +395,7 @@ void TrackedObjectBBox::SetJsonValue(const Json::Value root)

// Set the id of the child clip
// Does not allow to link to the parent clip
if (!root["child_clip_id"].isNull() && root["box_id"].asString() != "None"){
if (!root["child_clip_id"].isNull() && root["box_id"].asString() != ""){
Clip* parentClip = (Clip *) ParentClip();

if(parentClip && (root["child_clip_id"].asString() != parentClip->Id())){
Expand Down
8 changes: 4 additions & 4 deletions src/TrackedObjectBase.cpp
Expand Up @@ -39,16 +39,16 @@ namespace openshot
// Blank constructor
TrackedObjectBase::TrackedObjectBase() : visible(1.0), draw_box(1)
{
// Initializes the id as "None"
id = "None";
childClipId = "None";
// Initializes the id as ""
id = "";
childClipId = "";
}

// Default constructor
TrackedObjectBase::TrackedObjectBase(std::string _id) : visible(1.0)
{
Id(_id);
childClipId = "None";
childClipId = "";
}

Json::Value TrackedObjectBase::add_property_choice_json(std::string name, int value, int selected_value) const
Expand Down
2 changes: 1 addition & 1 deletion src/effects/Tracker.cpp
Expand Up @@ -132,7 +132,7 @@ std::shared_ptr<Frame> Tracker::GetFrame(std::shared_ptr<Frame> frame, int64_t f
}

// Get the image of the Tracked Object' child clip
if (trackedData->ChildClipId() != "None"){
if (trackedData->ChildClipId() != ""){
// Cast the parent timeline of this effect
Timeline* parentTimeline = (Timeline *) ParentTimeline();
if (parentTimeline){
Expand Down
10 changes: 6 additions & 4 deletions tests/KeyFrame.cpp
Expand Up @@ -693,8 +693,9 @@ TEST_CASE( "AttachToObject", "[libopenshot][keyframe]" )
auto trackedDataJson = trackedData->JsonValue();

// Get and cast the trakcedObject
auto trackedObject_base = t.GetTrackedObject("None");
std::shared_ptr<TrackedObjectBBox> trackedObject = std::static_pointer_cast<TrackedObjectBBox>(trackedObject_base);
auto trackedObject_base = t.GetTrackedObject("");
auto trackedObject = std::make_shared<TrackedObjectBBox>();
trackedObject = std::dynamic_pointer_cast<TrackedObjectBBox>(trackedObject_base);
CHECK(trackedObject == trackedData);

// Set trackedObject Json Value
Expand All @@ -705,7 +706,8 @@ TEST_CASE( "AttachToObject", "[libopenshot][keyframe]" )
childClip.Open();
childClip.AttachToObject(tracked_id);

std::shared_ptr<TrackedObjectBBox> trackedTest = std::static_pointer_cast<TrackedObjectBBox>(childClip.GetAttachedObject());
auto trackedTest = std::make_shared<TrackedObjectBBox>();
trackedTest = std::dynamic_pointer_cast<TrackedObjectBBox>(childClip.GetAttachedObject());

CHECK(trackedData->scale_x.GetValue(1) == trackedTest->scale_x.GetValue(1));

Expand All @@ -719,7 +721,7 @@ TEST_CASE( "GetBoxValues", "[libopenshot][keyframe]" )
TrackedObjectBBox trackedDataObject;
trackedDataObject.AddBox(1, 10.0, 10.0, 20.0, 20.0, 30.0);

std::shared_ptr<TrackedObjectBase> trackedData = std::make_shared<TrackedObjectBBox>(trackedDataObject);
auto trackedData = std::make_shared<TrackedObjectBBox>(trackedDataObject);

auto boxValues = trackedData->GetBoxValues(1);

Expand Down
2 changes: 1 addition & 1 deletion tests/KeyFrame_Tests.cpp
Expand Up @@ -670,7 +670,7 @@ TEST(Attach_test){
auto trackedDataJson = trackedData->JsonValue();

// Get and cast the trakcedObject
auto trackedObject_base = t.GetTrackedObject("None");
auto trackedObject_base = t.GetTrackedObject("");
std::shared_ptr<TrackedObjectBBox> trackedObject = std::static_pointer_cast<TrackedObjectBBox>(trackedObject_base);
CHECK_EQUAL(trackedData, trackedObject);

Expand Down

0 comments on commit 2cf2c55

Please sign in to comment.