Skip to content

Commit

Permalink
One more function to modernize to make CoordArrows usable as a normal…
Browse files Browse the repository at this point in the history
… VisualModel
  • Loading branch information
sebjameswml committed Jan 8, 2025
1 parent c8c7e22 commit e98a423
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
7 changes: 4 additions & 3 deletions morph/CoordArrows.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<float, 4>& bgcolour)
{
// For now, only worry about the centresphere:
Expand All @@ -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()
Expand Down
6 changes: 4 additions & 2 deletions morph/Visual.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit e98a423

Please sign in to comment.