From a9b66a4e1287a7228e93c03740fb766b12231764 Mon Sep 17 00:00:00 2001 From: AndreaRigoni Date: Wed, 18 Mar 2026 21:44:29 +0000 Subject: [PATCH] add grid annotation --- src/Vtk/vtkViewport.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/Vtk/vtkViewport.cpp b/src/Vtk/vtkViewport.cpp index ccb1bf7..10e2fea 100644 --- a/src/Vtk/vtkViewport.cpp +++ b/src/Vtk/vtkViewport.cpp @@ -55,9 +55,12 @@ void Viewport::SetupPipeline(vtkRenderWindowInteractor* iren) m_Annotation->GetTextProperty()->SetFontFamilyToArial(); m_Annotation->GetTextProperty()->SetOpacity(0.5); m_Annotation->SetMaximumFontSize(10); - m_Annotation->SetText(0, "uLib VTK Viewer - OpenCMT all right reserved."); + m_Annotation->SetText(0, "uLib VTK Viewer - OpenCMT viewer."); m_Renderer->AddViewProp(m_Annotation); + // right corner annotation + m_Annotation->SetText(1, "Grid: -"); + // Orientation axes marker (bottom-left corner) vtkNew axes; m_Marker->SetInteractor(iren); @@ -376,6 +379,17 @@ void Viewport::UpdateGrid() if (m_OriginAxes) { m_OriginAxes->SetScaleFactor(spacing); } + + // Update annotation for grid size + char gridLabel[32]; + if (spacing >= 1000.0) { + sprintf(gridLabel, "Grid: %.0f m", spacing / 1000.0); + } else if (spacing >= 10.0) { + sprintf(gridLabel, "Grid: %.0f cm", spacing / 10.0); + } else { + sprintf(gridLabel, "Grid: %.0f mm", spacing); + } + m_Annotation->SetText(1, gridLabel); }