[vtkusers] QVTKWidget and depth peeling.

Bastian A. bastianra at gmail.com
Mon Dec 20 18:59:28 EST 2010


Hi,

I am unable to use depth peeling in a class derived from QVTKWidget,
using C++ and
VTK 5.6.0/QT 4.5.2. The test
Rendering/Testing/Cxx/TestTranslucentLUTDepthPeeling
successfully uses depth peeling. I found the discussion regarding the QVTKWidget
and depth peeling using python on this mailing list.
( http://public.kitware.com/pipermail/vtkusers/2010-August/111040.html )
Not having any better ideas, I patched GUIsuppout/Qt/QVTKWidget.* such that the
QVTKWidget derives from QGLWidget and is constructed as:

QVTKWidget::QVTKWidget(QWidget* p, Qt::WFlags f)
  : QGLWidget(QGLFormat(QGL::AlphaChannel),p,0, f | Qt::MSWindowsOwnDC),
    mRenWin(NULL), cachedImageCleanFlag(false),
    automaticImageCache(false), maxImageCacheRenderRate(1.0)

however this did not change that I am unable to use depth peeling in the
QVTKWidget.

After reverting my changes I tried using the
TestTranslucentLUTDepthPeeling within
my class derived from QVTKWidget removing only the interactor and exchanging
the vtkRenderWindow renWin with a call to GetRenderWindow() (for
details see below).
Depth peeling was not used.

Any help getting depth peeling to work would be greatly appreciated.

Cheers,
Bastian


In case this is relevant: I am using Kubuntu 9.10 and a Nvidia Quadro FX 4800
with the 190.53 driver.

VtkCellView::VtkCellView(QWidget *parent) :
	QVTKWidget(parent)
{
	  // vtkRenderWindowInteractor *iren=vtkRenderWindowInteractor::New();

	  GetRenderWindow()->SetMultiSamples(0);

	  GetRenderWindow()->SetAlphaBitPlanes(1);
	  //  iren->SetRenderWindow(GetRenderWindow());
	  //  renWin->Delete();

	  vtkRenderer *renderer = vtkRenderer::New();
	  GetRenderWindow()->AddRenderer(renderer);
	  renderer->Delete();
	  renderer->SetUseDepthPeeling(1);
	  renderer->SetMaximumNumberOfPeels(200);
	  renderer->SetOcclusionRatio(0.1);

	  vtkImageSinusoidSource *imageSource=vtkImageSinusoidSource::New();
	  imageSource->SetWholeExtent(0,9,0,9,0,9);
	  imageSource->SetPeriod(5);
	  imageSource->Update();

	  vtkImageData *image=imageSource->GetOutput();
	  double range[2];
	  image->GetScalarRange(range);

	  vtkDataSetSurfaceFilter *surface=vtkDataSetSurfaceFilter::New();

	  surface->SetInputConnection(imageSource->GetOutputPort());
	  imageSource->Delete();

	  vtkPolyDataMapper *mapper=vtkPolyDataMapper::New();
	  mapper->SetInputConnection(surface->GetOutputPort());
	  surface->Delete();

	  vtkLookupTable *lut=vtkLookupTable::New();
	  lut->SetTableRange(range);
	  lut->SetAlphaRange(0.5,0.5);
	  lut->SetHueRange(0.2,0.7);
	  lut->SetNumberOfTableValues(256);
	  lut->Build();

	  mapper->SetScalarVisibility(1);
	  mapper->SetLookupTable(lut);
	  lut->Delete();

	  vtkActor *actor=vtkActor::New();
	  renderer->AddActor(actor);
	  actor->Delete();
	  actor->SetMapper(mapper);
	  mapper->Delete();

	  renderer->SetBackground(0.1,0.3,0.0);


	  GetRenderWindow()->Render();
	  if(renderer->GetLastRenderingUsedDepthPeeling())
	  {
        cout<<"depth peeling was used"<<endl;
	  }
	  else
	  {
        cout<<"depth peeling was not used (alpha blending instead)"<<endl;
	  }

\\ snip



More information about the vtkusers mailing list