From f8a9739dafa2da4372e88351e2c8072fe71c0a3e Mon Sep 17 00:00:00 2001 From: Markus Bullmann Date: Tue, 1 Oct 2019 14:45:52 +0200 Subject: [PATCH] Fixed drawing of distance circles --- code/Plotty.h | 16 ++++++++++++++-- code/main.cpp | 6 ++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/code/Plotty.h b/code/Plotty.h index e2ef07c..0df0f3c 100644 --- a/code/Plotty.h +++ b/code/Plotty.h @@ -108,6 +108,7 @@ public: K::GnuplotSplotElementEmpty emptyElem; + std::vector distanceCircles; K::GnuplotSplotElementPM3D pm3doutline; @@ -186,7 +187,7 @@ public: } - void addCircle(int id, const Point2& center, float radius, const K::GnuplotColor& strokeColor) + void addDistanceCircle(const Point2& center, float radius, const K::GnuplotColor& strokeColor) { auto c = K::GnuplotCoordinate2(center.x, center.y, K::GnuplotCoordinateSystem::FIRST); auto r = K::GnuplotCoordinate1(radius, K::GnuplotCoordinateSystem::FIRST); @@ -196,8 +197,19 @@ public: K::GnuplotObjectCircle* obj = new K::GnuplotObjectCircle(c, r, fill, stroke); - splot.getObjects().set(id, obj); + splot.getObjects().add(obj); + distanceCircles.push_back(obj->getID()); + } + + void clearDistanceCircles() + { + for (int oldID : distanceCircles) + { + splot.getObjects().remove(oldID); + } + + distanceCircles.clear(); } void addBBoxes(const BBoxes3& boxes, const K::GnuplotColor& c) { diff --git a/code/main.cpp b/code/main.cpp index d52f944..2b93956 100644 --- a/code/main.cpp +++ b/code/main.cpp @@ -187,7 +187,7 @@ static CombinedStats run(Settings::DataSetup setup, int walkIdx, std::str std::string currDir = std::filesystem::current_path().string(); Floorplan::IndoorMap* map = Floorplan::Reader::readFromFile(setup.map); - Offline::FileReader fr(setup.training[walkIdx], setup.NanoSecondTimestamps); + Offline::FileReader fr(setup.training[walkIdx], setup.HasNanoSecondTimestamps); // ground truth std::vector gtPath = setup.gtPath; @@ -334,6 +334,8 @@ static CombinedStats run(Settings::DataSetup setup, int walkIdx, std::str errorStats.ftm.add(distErrorFtm); // draw wifi ranges + plot.clearDistanceCircles(); + for (size_t i = 0; i < obs.ftm.size(); i++) { WiFiMeasurement wifi2 = obs.ftm[i]; @@ -349,7 +351,7 @@ static CombinedStats run(Settings::DataSetup setup, int walkIdx, std::str default: color = K::GnuplotColor::fromRGB(255, 0, 0); break; } - plot.addCircle(1000 + i, apPos.xy(), wifi2.getFtmDist(), color); + plot.addDistanceCircle(apPos.xy(), wifi2.getFtmDist(), color); } obs.wifi.clear();