From e98a4237b6200f632da7b5c1d6ceb21dfe134f5c Mon Sep 17 00:00:00 2001 From: Seb James Date: Wed, 8 Jan 2025 12:35:40 +0000 Subject: [PATCH] One more function to modernize to make CoordArrows usable as a normal VisualModel --- morph/CoordArrows.h | 7 ++++--- morph/Visual.h | 6 ++++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/morph/CoordArrows.h b/morph/CoordArrows.h index 2655435a..177503df 100644 --- a/morph/CoordArrows.h +++ b/morph/CoordArrows.h @@ -43,7 +43,7 @@ namespace morph { this->initAxisLabels(); } - //! Make sure coord arrow colours are ok on the given background colour + //! Make sure coord arrow colours are ok on the given background colour. Call this *after* finalize. void setColourForBackground (const std::array& bgcolour) { // For now, only worry about the centresphere: @@ -52,16 +52,17 @@ namespace morph { 1.0f-bgcolour[2]}; if (cscol != this->centresphere_col) { this->centresphere_col = cscol; - this->initializeVertices(); - this->postVertexInit(); + this->reinit(); // sets context, does not release it } // Give the text labels a suitable, visible colour + if (this->setContext != nullptr) { this->setContext (this->parentVis); } auto ti = this->texts.begin(); while (ti != this->texts.end()) { (*ti)->setVisibleOn (bgcolour); ti++; } + if (this->releaseContext != nullptr) { this->releaseContext (this->parentVis); } } void initAxisLabels() diff --git a/morph/Visual.h b/morph/Visual.h index 594d7b8a..e1aef508 100644 --- a/morph/Visual.h +++ b/morph/Visual.h @@ -570,8 +570,10 @@ namespace morph { if ((this->ptype == perspective_type::orthographic || this->ptype == perspective_type::perspective) && this->showCoordArrows == true) { // Ensure coordarrows centre sphere will be visible on BG: - this->coordArrows->setColourForBackground (this->bgcolour); - + this->coordArrows->setColourForBackground (this->bgcolour); // releases context... +#ifndef OWNED_MODE + this->setContext(); // ...so re-acquire +#endif if (this->coordArrowsInScene == true) { this->coordArrows->setSceneMatrix (sceneview); } else {