[vtkusers] Integrating Qt (Carsten Kuebler) and VTK
Erica Sullivan
cardsfan1995 at hotmail.com
Mon Jul 11 11:11:08 EDT 2005
I am using Carsten Kuebler's package to integrate Qt (v3.2) w/ VTK (v4.2).
I know that the following line has to be included in the main function -
vtkQtObjectFactory::RegisterObjectFactory(). Is it possible, though, to
include the pipeline in another function? I have included main.cpp and the
function in MainGUI.cpp that contains the pipeline.
If I comment out all of Kuebler's code in the function, the pipeline works
correctly (i.e. a vtkImage Viewer object is created that displays the file
selected). If I try to use Kuebler's code nothing happens after I select
the file to open. I am guessing that this has something to do with the fact
that the pipeline is in a seperate function from RegisterObjectFactory.
Thanks, Erica
#include <qapplication.h>
#include <vtkQtObjectFactory.h>
#include "MainGUI.h"
int main(int argc, char *argv[])
{
vtkQtObjectFactory::RegisterObjectFactory();
QApplication app(argc, argv);
//Basics for the QT-Event loop
app.setMainWidget(dialog);
dialog->show();
return app.exec();
return 0;
}
This is the function call in MainGUI.cpp. This function is tied to the slot
for a QtPushButton.
void MainGUI::open()
{
QString fileFilters = tr("JPEG (*.jpg)\n" "Bitmap (*.bmp)\n" "GIF
(*.gif)\n" "TIFF (*.tif)\n" "PNG (*.png)" );
filename = QFileDialog:: getOpenFileName(".", fileFilters, this);
typedef unsigned char PixelType;
const unsigned int Dimension = 2;
typedef itk::Image< PixelType, Dimension > ImageType;
typedef itk::ImageFileReader< ImageType > ReaderType;
typedef itk::ImageToVTKImageFilter<ImageType> ConnectorType;
ReaderType::Pointer reader = ReaderType::New();
ConnectorType::Pointer connector = ConnectorType::New();
reader->SetFileName((const char*)filename);
connector->SetInput(reader->GetOutput());
vtkImageViewer *viewer = vtkImageViewer::New();
vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
viewer->SetupInteractor(iren);
viewer->SetInput(connector->GetOutput());
viewer->SetColorWindow(255);
viewer->SetColorLevel(128);
vtkQtObjectFactory::SetQtBase(filSV->viewport(), NULL);
viewer->GetRenderWindow()->Start();
QWidget *tmpWidget =
vtkQtObjectFactory::QtWidget(viewer->GetRenderWindow());
if (tmpWidget != NULL)
{
// Works as well without the vtkqt object factory support
filSV->addChild(tmpWidget);
}
viewer->GetRenderWindow()->SetSize(512,512);
//This starts the event loop and as a side effect causes an initial render.
if (tmpWidget == NULL)
{
viewer->Render();
iren->Start();
}
_________________________________________________________________
Dont just search. Find. Check out the new MSN Search!
http://search.msn.click-url.com/go/onm00200636ave/direct/01/
More information about the vtkusers
mailing list