[vtkusers] QVTKwidget issue
Ashish Singh
mrasingh at gmail.com
Fri Mar 13 17:36:31 EDT 2009
Thanks Clint. I am resending this message because the previous message
didn't get posted to the list.
vtkRenderWindow::Render() opens up the image in a new window and not in
QVTKWidget. QVTKWidget::update() from OnLoad() works fine.
There is one more issue with the same code. Even before I select the
directory containing CT images, I get a vtkOutputWindow with many errors as
below.
Do you know what may be the cause of these? How do I fix these errors?
Thanks,
Ashish
------------
ERROR: In ..\..\vtk-5.2.1sources\Rendering\vtkImageActor.cxx, line 267
vtkOpenGLImageActor (05E9B1C0): This filter requires unsigned char scalars
as input
ERROR: In ..\..\vtk-5.2.1sources\Filtering\vtkDemandDrivenPipeline.cxx, line
725
vtkStreamingDemandDrivenPipeline (05E9C998): Input port 0 of algorithm
vtkImageMapToWindowLevelColors(05E9B7F8) has 0 connections but is not
optional.
ERROR: In ..\..\vtk-5.2.1sources\Filtering\vtkDemandDrivenPipeline.cxx, line
725
vtkStreamingDemandDrivenPipeline (05E9C998): Input port 0 of algorithm
vtkImageMapToWindowLevelColors(05E9B7F8) has 0 connections but is not
optional.
ERROR: In ..\..\vtk-5.2.1sources\Filtering\vtkDemandDrivenPipeline.cxx, line
725
vtkStreamingDemandDrivenPipeline (05E9C998): Input port 0 of algorithm
vtkImageMapToWindowLevelColors(05E9B7F8) has 0 connections but is not
optional.
ERROR: In ..\..\vtk-5.2.1sources\Filtering\vtkDemandDrivenPipeline.cxx, line
725
vtkStreamingDemandDrivenPipeline (05E9C998): Input port 0 of algorithm
vtkImageMapToWindowLevelColors(05E9B7F8) has 0 connections but is not
optional.
ERROR: In ..\..\vtk-5.2.1sources\Rendering\vtkImageActor.cxx, line 267
vtkOpenGLImageActor (05E9B1C0): This filter requires unsigned char scalars
as input
ERROR: In ..\..\vtk-5.2.1sources\Filtering\vtkDemandDrivenPipeline.cxx, line
725
vtkStreamingDemandDrivenPipeline (05E9C998): Input port 0 of algorithm
vtkImageMapToWindowLevelColors(05E9B7F8) has 0 connections but is not
optional.
ERROR: In ..\..\vtk-5.2.1sources\Filtering\vtkDemandDrivenPipeline.cxx, line
725
vtkStreamingDemandDrivenPipeline (05E9C998): Input port 0 of algorithm
vtkImageMapToWindowLevelColors(05E9B7F8) has 0 connections but is not
optional.
ERROR: In ..\..\vtk-5.2.1sources\Filtering\vtkDemandDrivenPipeline.cxx, line
725
vtkStreamingDemandDrivenPipeline (05E9C998): Input port 0 of algorithm
vtkImageMapToWindowLevelColors(05E9B7F8) has 0 connections but is not
optional.
ERROR: In ..\..\vtk-5.2.1sources\Filtering\vtkDemandDrivenPipeline.cxx, line
725
vtkStreamingDemandDrivenPipeline (05E9C998): Input port 0 of algorithm
vtkImageMapToWindowLevelColors(05E9B7F8) has 0 connections but is not
optional.
ERROR: In ..\..\vtk-5.2.1sources\Rendering\vtkImageActor.cxx, line 267
vtkOpenGLImageActor (05E9B1C0): This filter requires unsigned char scalars
as input
ERROR: In ..\..\vtk-5.2.1sources\Filtering\vtkDemandDrivenPipeline.cxx, line
725
vtkStreamingDemandDrivenPipeline (05E9C998): Input port 0 of algorithm
vtkImageMapToWindowLevelColors(05E9B7F8) has 0 connections but is not
optional.
------------------
On Fri, Mar 13, 2009 at 3:57 PM, Clinton Stimpson <clinton at elemtech.com>wrote:
>
> You need to update the view when you change the data.
> You can add a call to vtkRenderWindow::Render() or preferably a call to
> QVTKWidget::update() in your OnLoad().
>
> Clint
>
> Ashish Singh wrote:
>
>> Hi,
>>
>> I am trying to display each slice from a series of CT scans in a
>> QVTKwidget. The QVTKWidget itself is in a QMainWindow with 2 other widgets
>> to browse and load the data. I want to be able to display the data in
>> QVTKwidget as soon as I hit the load button. I can read the data fine, but
>> it doesn't display in QVTKwidget until I click or interact with QVTKwidget
>> using mouse. Can anyone please tell me what am I missing here?
>>
>> I am working on a Windows system and using VTK version 5.2.1 with Visual
>> Studio 2005 and Qt 4.5
>>
>> Thanks,
>> Ashish
>>
>> Here's my code:
>> ------header file----
>> #include <QObject>
>> #include <QPushButton>
>> #include <QLabel>
>> #include <QHBoxLayout>
>> #include <QVBoxLayout>
>> #include <QMainWindow>
>> #include <QVTKWidget.h>
>> #include <QWidget>
>> #include <QString>
>> #include <QFileDialog>
>> #include <QDir>
>> #include <qapplication.h>
>> #include <qobject.h>
>> #include <QtGui>
>>
>> #include <vtkDICOMImageReader.h>
>> #include <vtkImageViewer2.h>
>> #include <vtkRenderWindow.h>
>> #include "vtkRenderer.h"
>>
>> using namespace std;
>>
>> class test : public QObject
>> {
>> Q_OBJECT
>>
>> public:
>> string dirname;
>> vtkDICOMImageReader *reader;
>> vtkImageViewer2 *imgview;
>>
>> QMainWindow *mymainwindow;
>> QWidget *centralwidget;
>> QLabel *mylabel;
>> QPushButton *mypbutton;
>> QPushButton *myloadbutton;
>> QVTKWidget *vtkwidget;
>> QHBoxLayout *myhlayout;
>> QVBoxLayout *myvlayout;
>> test(QObject* parent = 0);
>> ~test();
>>
>>
>> public slots:
>> void OnLoad();
>> void OnBrowse();
>>
>> };
>> ------cpp file------
>> #include "test.h"
>> test::test(QObject * parent):QObject(parent)
>> {
>> reader = vtkDICOMImageReader::New();
>> imgview = vtkImageViewer2::New();
>>
>> mymainwindow = new QMainWindow();
>> centralwidget = new QWidget(mymainwindow);
>>
>> mylabel = new QLabel(centralwidget);
>> mypbutton = new QPushButton(centralwidget);
>> myloadbutton = new QPushButton(centralwidget);
>>
>> vtkwidget = new QVTKWidget(centralwidget);
>> vtkwidget->GetRenderWindow()->AddRenderer(imgview->GetRenderer());
>> vtkwidget->setFixedSize(512,512);
>>
>> myhlayout = new QHBoxLayout();
>> myvlayout = new QVBoxLayout();
>>
>> //setup UI
>> mylabel->setText("Select Dicom Dir");
>> mypbutton->setText("Browse");
>> this->connect(this->mypbutton,SIGNAL(clicked()),this,
>> SLOT(OnBrowse()));
>>
>> myloadbutton->setText("Load");
>> this->connect(this->mypbutton,SIGNAL(clicked()),this, SLOT(OnLoad()));
>>
>> myhlayout->addWidget(mylabel);
>> myhlayout->addWidget(mypbutton);
>> myhlayout->addWidget(myloadbutton);
>>
>> myvlayout->addLayout(myhlayout);
>> myvlayout->addWidget(vtkwidget);
>>
>> centralwidget->setLayout(myvlayout);
>> mymainwindow->setCentralWidget(centralwidget);
>> mymainwindow->show();
>> }
>>
>> test::~test()
>> {
>> reader->Delete();
>> imgview->Delete();
>> }
>>
>> void test::OnLoad()
>> {
>> reader->SetDirectoryName("D:\\testimages\\dicomset\\test");
>> reader->Update();
>>
>> imgview->SetInput(reader->GetOutput());
>> imgview->GetRenderer()->ResetCamera();
>>
>> }
>>
>> void test::OnBrowse()
>> {
>> QString indirectory =
>> QFileDialog::getExistingDirectory(this->centralwidget,tr("Select Input
>> Directory"), QDir::currentPath());
>> dirname = indirectory.toStdString();
>>
>> }
>> ------main.cpp---------
>> #include "test.h"
>> void main(int argc, char *argv[])
>> {
>> QApplication app(argc, argv);
>> test *mywin = new test;
>> app.exec();
>>
>> }
>> ------------------------------------------------------------------------
>>
>> _______________________________________________
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Please keep messages on-topic and check the VTK FAQ at:
>> http://www.vtk.org/Wiki/VTK_FAQ
>>
>> Follow this link to subscribe/unsubscribe:
>> http://www.vtk.org/mailman/listinfo/vtkusers
>>
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20090313/38163670/attachment.htm>
More information about the vtkusers
mailing list