代码
#include <vtkScalarBarWidget.h>
#include <vtkScalarBarActor.h>
#include <vtkLookupTable.h>
vtkSmartPointer<vtkLookupTable> hueLut
= vtkSmartPointer<vtkLookupTable>::New();
vtkSmartPointer<vtkScalarBarActor> sBarActor
= vtkSmartPointer<vtkScalarBarActor>::New();
vtkSmartPointer<vtkScalarBarWidget> scalarBarWidget
= vtkSmartPointer<vtkScalarBarWidget>::New();
vtkSmartPointer<vtkRenderWindow> renWin
= vtkSmartPointer<vtkRenderWindow>::New();
......
sBarActor->SetLookupTable(ugridMapper->GetLookupTable());
sBarActor->SetNumberOfLabels(8);
sBarActor->SetTitle("height");
/*
sBarActor->GetPositionCoordinate()->SetCoordinateSystemToNormalizedViewport();
sBarActor->GetPositionCoordinate()->SetValue(0.1,0.1);
sBarActor->SetWidth(0.8);
sBarActor->SetHeight(0.2);
*/
sBarActor->SetOrientationToHorizontal();
scalarBarWidget->SetInteractor(iren);
scalarBarWidget->SetScalarBarActor(sBarActor);
scalarBarWidget->On();
scalarBarWidget->SetEnabled(1);
iren->SetRenderWindow(renWin);
renWin->Render();
iren->Start();