add grid annotation

This commit is contained in:
AndreaRigoni
2026-03-18 21:44:29 +00:00
parent cca29ef837
commit a9b66a4e12

View File

@@ -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<vtkAxesActor> 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);
}