[vtkusers] Bug in vtkScalarBarActor
David.Pont at ForestResearch.co.nz
David.Pont at ForestResearch.co.nz
Thu Dec 18 15:52:43 EST 2003
Andreas,
I cant help you, but I too have noticed strange coloring of a scalar bar
actor. In my case this occurs if there is an actor with a texture map. The
colors change unpredictably during rendering. My feeling was some error in
OpenGL calls during rendering. Your problem sounds like it could be another
symptom of the same underlying problem? Perhaps you should log a formal bug
report as you seem to have a nice simple test case.
Dave P
|---------+---------------------------->
| | "Andreas Kuhn" |
| | <kuhnan at ee.ethz.c|
| | h> |
| | Sent by: |
| | vtkusers-admin at vt|
| | k.org |
| | |
| | |
| | 19/12/2003 06:11 |
| | |
|---------+---------------------------->
>--------------------------------------------------------------------------------------------------------------------------------|
| |
| To: <vtkusers at vtk.org> |
| cc: |
| Subject: [vtkusers] Bug in vtkScalarBarActor |
>--------------------------------------------------------------------------------------------------------------------------------|
Hi,
I have a problem with vtkScalarBarActor:
Whenever I use the vtkScalarBarActor in combination with a transparent
actor, the scalar bar is completely grey on startup of the window. When
I resize the window the scalar bar gets colored.
I've posted an example code below which shows the problem. If you
comment out the line "aSphere->GetProperty()->SetOpacity(0.5);" the
scalar bar works fine. Otherwise the scalar bar is grey on startup.
Does someone know a solution to this problem?
Thanks a lot,
Andreas
#include "vtkSphereSource.h"
#include "vtkPolyDataMapper.h"
#include "vtkActor.h"
#include "vtkRenderWindow.h"
#include "vtkRenderer.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkProperty.h"
#include "vtkScalarBarActor.h"
#include "vtkLookupTable.h"
#include "vtkFloatArray.h"
#include "vtkPolyData.h"
#include "vtkPointData.h"
int main( int argc, char *argv[] )
{
vtkIntArray *scalars = vtkIntArray::New();
// create sphere geometry
vtkSphereSource *sphere = vtkSphereSource::New();
sphere->SetRadius(1.0);
sphere->SetThetaResolution(18);
sphere->SetPhiResolution(18);
sphere->Update();
for (int i=0; i<sphere->GetOutput()->GetNumberOfPoints(); i++){
scalars->InsertNextTuple1(i);
}
sphere->GetOutput()->GetPointData()->SetScalars(scalars);
// create a lookup table
vtkLookupTable *looktable = vtkLookupTable::New();
looktable->SetTableRange (0,
sphere->GetOutput()->GetNumberOfPoints());
looktable->SetHueRange (0, 0.55);
// map to graphics library
vtkPolyDataMapper *map = vtkPolyDataMapper::New();
map->SetLookupTable(looktable);
map->ScalarVisibilityOn();
map->SetScalarModeToUsePointData();
map->UseLookupTableScalarRangeOn();
map->SetColorModeToMapScalars();
map->SetInput(sphere->GetOutput());
//create ScalarBar
vtkScalarBarActor *scalarBar = vtkScalarBarActor::New();
scalarBar->SetLookupTable(map->GetLookupTable());
// actor coordinates geometry, properties, transformation
vtkActor *aSphere = vtkActor::New();
aSphere->SetMapper(map);
////////////////////////////////////////////////////////////////////
//if you comment next line out scalarBar is working fine
aSphere->GetProperty()->SetOpacity(0.5);
////////////////////////////////////////////////////////////////////
// a renderer and render window
vtkRenderer *ren1 = vtkRenderer::New();
vtkRenderWindow *renWin = vtkRenderWindow::New();
renWin->AddRenderer(ren1);
// an interactor
vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
iren->SetRenderWindow(renWin);
// add the actor to the scene
ren1->AddActor(aSphere);
ren1->AddActor2D(scalarBar);
ren1->SetBackground(1,1,1); // Background color white
// render an image (lights and cameras are created automatically)
renWin->Render();
// begin mouse interaction
iren->Start();
return 1;
}
_______________________________________________
This is the private VTK discussion list.
Please keep messages on-topic. Check the FAQ at: <
http://public.kitware.com/cgi-bin/vtkfaq>
Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers
More information about the vtkusers
mailing list