From 4526b6a7ea6a5ca771012c795d4ad83f7f35c533 Mon Sep 17 00:00:00 2001 From: Seb James Date: Tue, 9 Dec 2025 10:45:30 +0000 Subject: [PATCH 1/2] Fixes a labels issue with updating coordarrows lengths. Also adds important example code in coordarrows.cpp --- examples/coordarrows.cpp | 14 +++++++++++--- mplot/VisualBase.h | 3 +++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/examples/coordarrows.cpp b/examples/coordarrows.cpp index a53ee0ff..9b5356c7 100644 --- a/examples/coordarrows.cpp +++ b/examples/coordarrows.cpp @@ -11,6 +11,12 @@ int main() mplot::Visual v(1024, 768, "Coordinate Arrows"); v.showCoordArrows (true); // Shows the 'scene' coordarrows, that you get in every mplot::Visual v.lightingEffects(true); + // You can update the coord arrows lengths and thickness scaling factor for the main CoordArrows + // if you want to. This updates to the defaults, and so is what you'd get if you left the call + // out: + v.updateCoordLengths ({ 0.1f, 0.1f, 0.1f }, 1.0f); + // This alternative makes the coordinate arrows longer: + // v.updateCoordLengths ({ 0.2f, 0.2f, 0.2f }, 1.0f); // An extra CoordArrows model, with defaults sm::vec offset = {}; @@ -19,9 +25,11 @@ int main() cavm->finalize(); v.addVisualModel (cavm); - sm::vec ux = {1,0,0}; - sm::vec uy = {0,1,0}; - sm::vec uz = {0,0,1}; + // I define unit vector here, because it makes the calls to CoordArrows::init easy to read, but + // you can also use sm::vec::ux(), etc to get static, constexpr unit vectors + constexpr sm::vec ux = {1,0,0}; + constexpr sm::vec uy = {0,1,0}; + constexpr sm::vec uz = {0,0,1}; // An CoordArrows model, with non-defaults offset[0] += 1.5f; diff --git a/mplot/VisualBase.h b/mplot/VisualBase.h index de7dff63..79e85206 100644 --- a/mplot/VisualBase.h +++ b/mplot/VisualBase.h @@ -397,10 +397,13 @@ namespace mplot this->coordArrows->reinit(); } + // Update the lengths of the CoordArrows that (usually) appear in the corner of the screen void updateCoordLengths (const sm::vec& _lengths, const float _thickness = 1.0f) { this->coordArrows->lengths = _lengths; this->coordArrows->thickness = _thickness; + this->coordArrows->clear(); + this->coordArrows->initAxisLabels(); this->coordArrows->reinit(); } From 6abe8f0046036954e527d53b7c4ff5eff28d0a42 Mon Sep 17 00:00:00 2001 From: Seb James Date: Tue, 9 Dec 2025 11:54:22 +0000 Subject: [PATCH 2/2] English/typos --- examples/coordarrows.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/coordarrows.cpp b/examples/coordarrows.cpp index 9b5356c7..393f49e3 100644 --- a/examples/coordarrows.cpp +++ b/examples/coordarrows.cpp @@ -25,8 +25,8 @@ int main() cavm->finalize(); v.addVisualModel (cavm); - // I define unit vector here, because it makes the calls to CoordArrows::init easy to read, but - // you can also use sm::vec::ux(), etc to get static, constexpr unit vectors + // I define some unit vectors here, because it makes the calls to CoordArrows::init easy to + // read, but you can also use sm::vec::ux(), etc to get static, constexpr unit vectors constexpr sm::vec ux = {1,0,0}; constexpr sm::vec uy = {0,1,0}; constexpr sm::vec uz = {0,0,1};