[vtkusers] Problem with ScalarBar

Lledo Museros Cabedo lledo.museros at itc.uji.es
Thu Sep 13 13:32:09 EDT 2007


Hi,
 
I am implementing a code in C++ using VTK (version 5.0) and MFC (using
MS Visual Studio .NET 2003).
I have implemented several scalarBarActors using only VTK (with C++),
but now that I am using also MFC I have next problem:
I add the scalarBarActor to the render and when the render window
appears the scalarbar appears correctly placed, with the correct colors,
but the title, and labels appears always in the left-down corner of the
window, moreover each letter, and number appears one over the previous
one. 
 
The code is this one:
 
vtkLookupTable *lut=vtkLookupTable::New();
lut->SetHueRange(0.67, 0.0);

vtkScalarBarActor *scalarBar=vtkScalarBarActor::New();
scalarBar->SetLookupTable(lut);
scalarBar->SetTitle("Depth");
scalarBar->GetTitleTextProperty()->SetColor(0,0,0);
scalarBar->GetPositionCoordinate()->SetCoordinateSystemToNormalizedViewp
ort();
scalarBar->GetPositionCoordinate()->SetValue(0.0,0.1);
scalarBar->SetOrientationToVertical();
scalarBar->SetHeight(0.8);
scalarBar->SetWidth(0.05);
scalarBar->SetLabelFormat("%2.1f");
scalarBar->GetLabelTextProperty()->SetFontSize(12);
scalarBar->GetLabelTextProperty()->SetColor(0,0,0);
scalarBar->GetLabelTextProperty()->BoldOn();

//.... Some code lines more and then:

vtkPolyDataMapper *cubeMapper = vtkPolyDataMapper::New();
cubeMapper->SetInput(cube);
cubeMapper->SetScalarRange(min_depth,max_depth);
cubeMapper->SetLookupTable(lut);

vtkActor *cubeActor = vtkActor::New();
cubeActor->SetMapper(cubeMapper);

vtkRenderer *renderer = vtkRenderer::New();
vtkRenderWindow *renWin = vtkRenderWindow::New();
renWin->AddRenderer(renderer);
vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
iren->SetRenderWindow(renWin);
iren->SetPicker(picker);

renderer->AddActor(scalarBar);
renderer->AddActor(cubeActor);
renderer->SetActiveCamera(camera);
renderer->ResetCamera();

renderer->SetBackground(1,1,1);

renWin->SetSize(600,600);
iren->Initialize();
renWin->Render();
iren->Start();

Can anyone help me?
 
Best regards,
LLEDO



More information about the vtkusers mailing list