diff --git a/src/esp/bindings/AttributesBindings.cpp b/src/esp/bindings/AttributesBindings.cpp index d8ca44cc3f..218d55a1f4 100644 --- a/src/esp/bindings/AttributesBindings.cpp +++ b/src/esp/bindings/AttributesBindings.cpp @@ -246,7 +246,9 @@ void initAttributesBindings(py::module& m) { .def(py::init(&MarkerSet::create<>)); py::class_(m, "MarkerSets") - .def(py::init(&MarkerSets::create<>)); + .def(py::init(&MarkerSets::create<>)) + .def_property_readonly("num_marker_sets", &MarkerSets::getNumMarkerSets, + R"(The current number of Markersets present.)"); // ==== ArticulatedObjectAttributes ==== py::class_loadOneConfigFromJson( numConfigSettings, subKey, jsonObj[i]); } @@ -453,7 +453,7 @@ int Configuration::loadOneConfigFromJson(int numConfigSettings, for (size_t i = 0; i < jsonObj.Size(); ++i) { const std::string subKey = - Cr::Utility::formatString("{}_{:.02d}", key, i); + Cr::Utility::formatString("{}_{:.03d}", key, i); numConfigSettings += subGroupPtr->loadOneConfigFromJson( numConfigSettings, subKey, jsonObj[i]); } diff --git a/src/esp/metadata/attributes/MarkerSets.h b/src/esp/metadata/attributes/MarkerSets.h index db680c4743..f57f1ebf03 100644 --- a/src/esp/metadata/attributes/MarkerSets.h +++ b/src/esp/metadata/attributes/MarkerSets.h @@ -30,49 +30,14 @@ class LinkMarkerSubset : public esp::core::config::Configuration { return getSubconfigView("markers")->getNumValues(); } - /** - * @brief whether the given @p markerName exists as a marker in - * this LinkMarkerSubset. - * - * @param markerName The desired marker set's name. - * @return whether the name is found as a marker value. - */ - bool hasNamedMarker(const std::string& markerName) const { - return getSubconfigView("markers")->hasValue(markerName); - } - - /** - * @brief Retrieve the marker point specified by the given @p markerName - */ - Mn::Vector3 getNamedMarker(const std::string& markerName) const { - return getSubconfigView("markers")->get(markerName); - } - - /** - * @brief Adds passed marker. Uses naming convention from load - key for this - * marker will be "markers_{numCurrentMarkers}" - */ - void addMarker(const Magnum::Vector3& marker) { - auto markersPtr = editSubconfig("markers"); - const std::string markerKey = Cr::Utility::formatString( - "markers_{:.02d}", markersPtr->getNumValues()); - markersPtr->set(markerKey, marker); - } - - /** - * @brief Retrieve a listing of all the marker handles in this - * LinkMarkerSubset. - */ - std::vector getAllMarkerNames() const { - return getSubconfigView("markers")->getKeys(); - } - /** * @brief Returns a list of all markers in this LinkMarkerSubset */ - std::vector getAllMarkers() const { + std::vector getMarkers() const { const auto markersPtr = getSubconfigView("markers"); std::vector markerTags = markersPtr->getKeys(); + // Sort the keys + std::sort(markerTags.begin(), markerTags.end()); std::vector res; res.reserve(markerTags.size()); for (const auto& tag : markerTags) { @@ -82,11 +47,14 @@ class LinkMarkerSubset : public esp::core::config::Configuration { } /** - * @brief Remove a named marker. + * @brief Set the list of marker points */ - Mn::Vector3 removeMarker(const std::string& markerKey) { - return editSubconfig("markers")->remove( - markerKey); + void setMarkers(const std::vector& markers) { + auto markersPtr = editSubconfig("markers"); + for (std::size_t i = 0; i < markers.size(); ++i) { + const std::string key = Cr::Utility::formatString("{:.03d}", i); + markersPtr->set(key, markers[i]); + } } ESP_SMART_POINTERS(LinkMarkerSubset) diff --git a/src/tests/AttributesConfigsTest.cpp b/src/tests/AttributesConfigsTest.cpp index 1657fb7fb0..0d79730a3f 100644 --- a/src/tests/AttributesConfigsTest.cpp +++ b/src/tests/AttributesConfigsTest.cpp @@ -1350,10 +1350,10 @@ void AttributesConfigsTest::testStageAttrVals( // Test marker sets MarkersTestMap subset_id_000_stage_name( - {{"markers_03", Mn::Vector3{4.1, 5.2, 6.3}}, - {"markers_02", Mn::Vector3{3.1, 4.2, 5.3}}, - {"markers_01", Mn::Vector3{2.1, 3.2, 4.3}}, - {"markers_00", Mn::Vector3{1.1, 2.2, 3.3}}}); + {{"markers_003", Mn::Vector3{4.1, 5.2, 6.3}}, + {"markers_002", Mn::Vector3{3.1, 4.2, 5.3}}, + {"markers_001", Mn::Vector3{2.1, 3.2, 4.3}}, + {"markers_000", Mn::Vector3{1.1, 2.2, 3.3}}}); MarkersTestMap subset_id_001_stage_name( {{"3", Mn::Vector3{4.2, 5.3, 6.4}}, @@ -1369,10 +1369,10 @@ void AttributesConfigsTest::testStageAttrVals( {{"link_id_00_stage_name", link_id_00_stage_name}}}; MarkersTestMap subset_id_100_stage_name( - {{"markers_03", Mn::Vector3{14.1, 15.2, 16.3}}, - {"markers_02", Mn::Vector3{13.1, 14.2, 15.3}}, - {"markers_01", Mn::Vector3{12.1, 13.2, 14.3}}, - {"markers_00", Mn::Vector3{11.1, 12.2, 13.3}}}); + {{"markers_003", Mn::Vector3{14.1, 15.2, 16.3}}, + {"markers_002", Mn::Vector3{13.1, 14.2, 15.3}}, + {"markers_001", Mn::Vector3{12.1, 13.2, 14.3}}, + {"markers_000", Mn::Vector3{11.1, 12.2, 13.3}}}); MarkersTestMap subset_id_101_stage_name( {{"3", Mn::Vector3{14.2, 15.3, 16.4}}, @@ -1398,10 +1398,10 @@ void AttributesConfigsTest::testStageAttrVals( {"0", Mn::Vector3{11.3, 12.4, 13.5}}}); MarkersTestMap subset_id_111_stage_name( - {{"markers_03", Mn::Vector3{14.4, 15.5, 16.6}}, - {"markers_02", Mn::Vector3{13.4, 14.5, 15.6}}, - {"markers_01", Mn::Vector3{12.4, 13.5, 14.6}}, - {"markers_00", Mn::Vector3{11.4, 12.5, 13.6}}}); + {{"markers_003", Mn::Vector3{14.4, 15.5, 16.6}}, + {"markers_002", Mn::Vector3{13.4, 14.5, 15.6}}, + {"markers_001", Mn::Vector3{12.4, 13.5, 14.6}}, + {"markers_000", Mn::Vector3{11.4, 12.5, 13.6}}}); SubsetTestMap link_id_11_stage_name( {{"subset_id_110_stage_name", subset_id_110_stage_name}, @@ -1620,10 +1620,10 @@ void AttributesConfigsTest::testObjectAttrVals( // Test marker sets MarkersTestMap subset_id_000_obj_name( - {{"markers_03", Mn::Vector3{4.1, 5.2, 6.3}}, - {"markers_02", Mn::Vector3{3.1, 4.2, 5.3}}, - {"markers_01", Mn::Vector3{2.1, 3.2, 4.3}}, - {"markers_00", Mn::Vector3{1.1, 2.2, 3.3}}}); + {{"markers_003", Mn::Vector3{4.1, 5.2, 6.3}}, + {"markers_002", Mn::Vector3{3.1, 4.2, 5.3}}, + {"markers_001", Mn::Vector3{2.1, 3.2, 4.3}}, + {"markers_000", Mn::Vector3{1.1, 2.2, 3.3}}}); MarkersTestMap subset_id_001_obj_name({{"3", Mn::Vector3{4.2, 5.3, 6.4}}, {"2", Mn::Vector3{3.2, 4.3, 5.4}}, @@ -1640,10 +1640,10 @@ void AttributesConfigsTest::testObjectAttrVals( {"0", Mn::Vector3{1.3, 2.4, 3.5}}}); MarkersTestMap subset_id_011_obj_name( - {{"markers_03", Mn::Vector3{4.4, 5.5, 6.6}}, - {"markers_02", Mn::Vector3{3.4, 4.5, 5.6}}, - {"markers_01", Mn::Vector3{2.4, 3.5, 4.6}}, - {"markers_00", Mn::Vector3{1.4, 2.5, 3.6}}}); + {{"markers_003", Mn::Vector3{4.4, 5.5, 6.6}}, + {"markers_002", Mn::Vector3{3.4, 4.5, 5.6}}, + {"markers_001", Mn::Vector3{2.4, 3.5, 4.6}}, + {"markers_000", Mn::Vector3{1.4, 2.5, 3.6}}}); SubsetTestMap link_id_01_obj_name( {{"subset_id_010_obj_name", subset_id_010_obj_name}, @@ -1654,10 +1654,10 @@ void AttributesConfigsTest::testObjectAttrVals( {"link_id_01_obj_name", link_id_01_obj_name}}}; MarkersTestMap subset_id_100_obj_name( - {{"markers_03", Mn::Vector3{14.1, 15.2, 16.3}}, - {"markers_02", Mn::Vector3{13.1, 14.2, 15.3}}, - {"markers_01", Mn::Vector3{12.1, 13.2, 14.3}}, - {"markers_00", Mn::Vector3{11.1, 12.2, 13.3}}}); + {{"markers_003", Mn::Vector3{14.1, 15.2, 16.3}}, + {"markers_002", Mn::Vector3{13.1, 14.2, 15.3}}, + {"markers_001", Mn::Vector3{12.1, 13.2, 14.3}}, + {"markers_000", Mn::Vector3{11.1, 12.2, 13.3}}}); MarkersTestMap subset_id_101_obj_name( {{"3", Mn::Vector3{14.2, 15.3, 16.4}}, @@ -1676,10 +1676,10 @@ void AttributesConfigsTest::testObjectAttrVals( {"0", Mn::Vector3{11.3, 12.4, 13.5}}}); MarkersTestMap subset_id_111_obj_name( - {{"markers_03", Mn::Vector3{14.4, 15.5, 16.6}}, - {"markers_02", Mn::Vector3{13.4, 14.5, 15.6}}, - {"markers_01", Mn::Vector3{12.4, 13.5, 14.6}}, - {"markers_00", Mn::Vector3{11.4, 12.5, 13.6}}}); + {{"markers_003", Mn::Vector3{14.4, 15.5, 16.6}}, + {"markers_002", Mn::Vector3{13.4, 14.5, 15.6}}, + {"markers_001", Mn::Vector3{12.4, 13.5, 14.6}}, + {"markers_000", Mn::Vector3{11.4, 12.5, 13.6}}}); SubsetTestMap link_id_11_obj_name( {{"subset_id_110_obj_name", subset_id_110_obj_name}, @@ -1906,10 +1906,10 @@ void AttributesConfigsTest::testArticulatedObjectAttrVals( // Test marker sets MarkersTestMap subset_id_000_ao_name( - {{"markers_03", Mn::Vector3{14.1, 5.2, 6.3}}, - {"markers_02", Mn::Vector3{13.1, 4.2, 5.3}}, - {"markers_01", Mn::Vector3{12.1, 3.2, 4.3}}, - {"markers_00", Mn::Vector3{11.1, 2.2, 3.3}}}); + {{"markers_003", Mn::Vector3{14.1, 5.2, 6.3}}, + {"markers_002", Mn::Vector3{13.1, 4.2, 5.3}}, + {"markers_001", Mn::Vector3{12.1, 3.2, 4.3}}, + {"markers_000", Mn::Vector3{11.1, 2.2, 3.3}}}); MarkersTestMap subset_id_001_ao_name({{"3", Mn::Vector3{14.2, 5.3, 6.4}}, {"2", Mn::Vector3{13.2, 4.3, 5.4}}, @@ -1926,10 +1926,10 @@ void AttributesConfigsTest::testArticulatedObjectAttrVals( {"0", Mn::Vector3{11.3, 2.4, 3.5}}}); MarkersTestMap subset_id_011_ao_name( - {{"markers_03", Mn::Vector3{14.4, 5.5, 6.6}}, - {"markers_02", Mn::Vector3{13.4, 4.5, 5.6}}, - {"markers_01", Mn::Vector3{12.4, 3.5, 4.6}}, - {"markers_00", Mn::Vector3{11.4, 2.5, 3.6}}}); + {{"markers_003", Mn::Vector3{14.4, 5.5, 6.6}}, + {"markers_002", Mn::Vector3{13.4, 4.5, 5.6}}, + {"markers_001", Mn::Vector3{12.4, 3.5, 4.6}}, + {"markers_000", Mn::Vector3{11.4, 2.5, 3.6}}}); SubsetTestMap link_id_01_ao_name( {{"subset_id_010_ao_name", subset_id_010_ao_name}, @@ -1941,16 +1941,16 @@ void AttributesConfigsTest::testArticulatedObjectAttrVals( {"0", Mn::Vector3{21.3, 2.4, 3.5}}}); MarkersTestMap subset_id_021_ao_name( - {{"markers_03", Mn::Vector3{24.4, 5.5, 6.6}}, - {"markers_02", Mn::Vector3{23.4, 4.5, 5.6}}, - {"markers_01", Mn::Vector3{22.4, 3.5, 4.6}}, - {"markers_00", Mn::Vector3{21.4, 2.5, 3.6}}}); + {{"markers_003", Mn::Vector3{24.4, 5.5, 6.6}}, + {"markers_002", Mn::Vector3{23.4, 4.5, 5.6}}, + {"markers_001", Mn::Vector3{22.4, 3.5, 4.6}}, + {"markers_000", Mn::Vector3{21.4, 2.5, 3.6}}}); MarkersTestMap subset_id_022_ao_name( - {{"markers_03", Mn::Vector3{224.4, 5.5, 6.6}}, - {"markers_02", Mn::Vector3{223.4, 4.5, 5.6}}, - {"markers_01", Mn::Vector3{222.4, 3.5, 4.6}}, - {"markers_00", Mn::Vector3{221.4, 2.5, 3.6}}}); + {{"markers_003", Mn::Vector3{224.4, 5.5, 6.6}}, + {"markers_002", Mn::Vector3{223.4, 4.5, 5.6}}, + {"markers_001", Mn::Vector3{222.4, 3.5, 4.6}}, + {"markers_000", Mn::Vector3{221.4, 2.5, 3.6}}}); SubsetTestMap link_id_02_ao_name( {{"subset_id_020_ao_name", subset_id_020_ao_name}, @@ -1963,10 +1963,10 @@ void AttributesConfigsTest::testArticulatedObjectAttrVals( {"link_id_02_ao_name", link_id_02_ao_name}}}; MarkersTestMap subset_id_100_ao_name( - {{"markers_03", Mn::Vector3{114.1, 15.2, 16.3}}, - {"markers_02", Mn::Vector3{113.1, 14.2, 15.3}}, - {"markers_01", Mn::Vector3{112.1, 13.2, 14.3}}, - {"markers_00", Mn::Vector3{111.1, 12.2, 13.3}}}); + {{"markers_003", Mn::Vector3{114.1, 15.2, 16.3}}, + {"markers_002", Mn::Vector3{113.1, 14.2, 15.3}}, + {"markers_001", Mn::Vector3{112.1, 13.2, 14.3}}, + {"markers_000", Mn::Vector3{111.1, 12.2, 13.3}}}); MarkersTestMap subset_id_101_ao_name( {{"3", Mn::Vector3{114.2, 15.3, 16.4}}, @@ -1985,10 +1985,10 @@ void AttributesConfigsTest::testArticulatedObjectAttrVals( {"0", Mn::Vector3{111.3, 12.4, 13.5}}}); MarkersTestMap subset_id_111_ao_name( - {{"markers_03", Mn::Vector3{114.4, 15.5, 16.6}}, - {"markers_02", Mn::Vector3{113.4, 14.5, 15.6}}, - {"markers_01", Mn::Vector3{112.4, 13.5, 14.6}}, - {"markers_00", Mn::Vector3{111.4, 12.5, 13.6}}}); + {{"markers_003", Mn::Vector3{114.4, 15.5, 16.6}}, + {"markers_002", Mn::Vector3{113.4, 14.5, 15.6}}, + {"markers_001", Mn::Vector3{112.4, 13.5, 14.6}}, + {"markers_000", Mn::Vector3{111.4, 12.5, 13.6}}}); SubsetTestMap link_id_11_ao_name( {{"subset_id_110_ao_name", subset_id_110_ao_name},