Thanks Clint. I am resending this message because the previous message didn't get posted to the list.<br><br>vtkRenderWindow::Render() opens up the image in a
new window and not in QVTKWidget. QVTKWidget::update() from OnLoad()
works fine.<br><br>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.<br>
<br><div>
Do you know what may be the cause of these? How do I fix these errors?<br><br>Thanks,<br><font color="#888888">Ashish</font></div><br>------------<br>ERROR: In ..\..\vtk-5.2.1sources\Rendering\vtkImageActor.cxx, line 267<br>
vtkOpenGLImageActor (05E9B1C0): This filter requires unsigned char scalars as input<br><br>ERROR: In ..\..\vtk-5.2.1sources\Filtering\vtkDemandDrivenPipeline.cxx, line 725<br>vtkStreamingDemandDrivenPipeline (05E9C998): Input port 0 of algorithm vtkImageMapToWindowLevelColors(05E9B7F8) has 0 connections but is not optional.<br>
<br>ERROR: In ..\..\vtk-5.2.1sources\Filtering\vtkDemandDrivenPipeline.cxx, line 725<br>vtkStreamingDemandDrivenPipeline (05E9C998): Input port 0 of algorithm vtkImageMapToWindowLevelColors(05E9B7F8) has 0 connections but is not optional.<br>
<br>ERROR: In ..\..\vtk-5.2.1sources\Filtering\vtkDemandDrivenPipeline.cxx, line 725<br>vtkStreamingDemandDrivenPipeline (05E9C998): Input port 0 of algorithm vtkImageMapToWindowLevelColors(05E9B7F8) has 0 connections but is not optional.<br>
<br>ERROR: In ..\..\vtk-5.2.1sources\Filtering\vtkDemandDrivenPipeline.cxx, line 725<br>vtkStreamingDemandDrivenPipeline (05E9C998): Input port 0 of algorithm vtkImageMapToWindowLevelColors(05E9B7F8) has 0 connections but is not optional.<br>
<br>ERROR: In ..\..\vtk-5.2.1sources\Rendering\vtkImageActor.cxx, line 267<br>vtkOpenGLImageActor (05E9B1C0): This filter requires unsigned char scalars as input<br><br>ERROR: In ..\..\vtk-5.2.1sources\Filtering\vtkDemandDrivenPipeline.cxx, line 725<br>
vtkStreamingDemandDrivenPipeline (05E9C998): Input port 0 of algorithm vtkImageMapToWindowLevelColors(05E9B7F8) has 0 connections but is not optional.<br><br>ERROR: In ..\..\vtk-5.2.1sources\Filtering\vtkDemandDrivenPipeline.cxx, line 725<br>
vtkStreamingDemandDrivenPipeline (05E9C998): Input port 0 of algorithm vtkImageMapToWindowLevelColors(05E9B7F8) has 0 connections but is not optional.<br><br>ERROR: In ..\..\vtk-5.2.1sources\Filtering\vtkDemandDrivenPipeline.cxx, line 725<br>
vtkStreamingDemandDrivenPipeline (05E9C998): Input port 0 of algorithm vtkImageMapToWindowLevelColors(05E9B7F8) has 0 connections but is not optional.<br><br>ERROR: In ..\..\vtk-5.2.1sources\Filtering\vtkDemandDrivenPipeline.cxx, line 725<br>
vtkStreamingDemandDrivenPipeline (05E9C998): Input port 0 of algorithm vtkImageMapToWindowLevelColors(05E9B7F8) has 0 connections but is not optional.<br><br>ERROR: In ..\..\vtk-5.2.1sources\Rendering\vtkImageActor.cxx, line 267<br>
vtkOpenGLImageActor (05E9B1C0): This filter requires unsigned char scalars as input<br><br>ERROR: In ..\..\vtk-5.2.1sources\Filtering\vtkDemandDrivenPipeline.cxx, line 725<br>vtkStreamingDemandDrivenPipeline (05E9C998): Input port 0 of algorithm vtkImageMapToWindowLevelColors(05E9B7F8) has 0 connections but is not optional.<br>
------------------<br><br><div class="gmail_quote">On Fri, Mar 13, 2009 at 3:57 PM, Clinton Stimpson <span dir="ltr"><<a href="mailto:clinton@elemtech.com" target="_blank">clinton@elemtech.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
You need to update the view when you change the data.<br>
You can add a call to vtkRenderWindow::Render() or preferably a call to QVTKWidget::update() in your OnLoad().<br>
<br>
Clint<br>
<br>
Ashish Singh wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div><div></div><div>
Hi,<br>
<br>
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?<br>
<br>
I am working on a Windows system and using VTK version 5.2.1 with Visual Studio 2005 and Qt 4.5<br>
<br>
Thanks,<br>
Ashish<br>
<br>
Here's my code:<br>
------header file----<br>
#include <QObject><br>
#include <QPushButton><br>
#include <QLabel><br>
#include <QHBoxLayout><br>
#include <QVBoxLayout><br>
#include <QMainWindow><br>
#include <QVTKWidget.h><br>
#include <QWidget><br>
#include <QString><br>
#include <QFileDialog><br>
#include <QDir><br>
#include <qapplication.h><br>
#include <qobject.h><br>
#include <QtGui><br>
<br>
#include <vtkDICOMImageReader.h><br>
#include <vtkImageViewer2.h><br>
#include <vtkRenderWindow.h><br>
#include "vtkRenderer.h"<br>
<br>
using namespace std;<br>
<br>
class test : public QObject<br>
{<br>
Q_OBJECT<br>
<br>
public:<br>
string dirname;<br>
vtkDICOMImageReader *reader;<br>
vtkImageViewer2 *imgview;<br>
<br>
QMainWindow *mymainwindow;<br>
QWidget *centralwidget;<br>
QLabel *mylabel;<br>
QPushButton *mypbutton;<br>
QPushButton *myloadbutton;<br>
QVTKWidget *vtkwidget;<br>
QHBoxLayout *myhlayout;<br>
QVBoxLayout *myvlayout;<br>
test(QObject* parent = 0);<br>
~test();<br>
<br>
<br>
public slots:<br>
void OnLoad();<br>
void OnBrowse();<br>
<br>
};<br>
------cpp file------<br>
#include "test.h"<br>
test::test(QObject * parent):QObject(parent)<br>
{<br>
reader = vtkDICOMImageReader::New();<br>
imgview = vtkImageViewer2::New();<br>
<br>
mymainwindow = new QMainWindow();<br>
centralwidget = new QWidget(mymainwindow);<br>
<br>
mylabel = new QLabel(centralwidget);<br>
mypbutton = new QPushButton(centralwidget);<br>
myloadbutton = new QPushButton(centralwidget);<br>
<br>
vtkwidget = new QVTKWidget(centralwidget);<br>
vtkwidget->GetRenderWindow()->AddRenderer(imgview->GetRenderer());<br>
vtkwidget->setFixedSize(512,512);<br>
<br>
myhlayout = new QHBoxLayout();<br>
myvlayout = new QVBoxLayout();<br>
<br>
//setup UI<br>
mylabel->setText("Select Dicom Dir");<br>
mypbutton->setText("Browse");<br>
this->connect(this->mypbutton,SIGNAL(clicked()),this, SLOT(OnBrowse()));<br>
<br>
myloadbutton->setText("Load");<br>
this->connect(this->mypbutton,SIGNAL(clicked()),this, SLOT(OnLoad()));<br>
<br>
myhlayout->addWidget(mylabel);<br>
myhlayout->addWidget(mypbutton);<br>
myhlayout->addWidget(myloadbutton);<br>
<br>
myvlayout->addLayout(myhlayout);<br>
myvlayout->addWidget(vtkwidget);<br>
<br>
centralwidget->setLayout(myvlayout);<br>
mymainwindow->setCentralWidget(centralwidget);<br>
mymainwindow->show();<br>
}<br>
<br>
test::~test()<br>
{<br>
reader->Delete();<br>
imgview->Delete();<br>
}<br>
<br>
void test::OnLoad()<br>
{<br>
reader->SetDirectoryName("D:\\testimages\\dicomset\\test");<br>
reader->Update();<br>
<br>
imgview->SetInput(reader->GetOutput());<br>
imgview->GetRenderer()->ResetCamera();<br>
<br>
}<br>
<br>
void test::OnBrowse()<br>
{<br>
QString indirectory = QFileDialog::getExistingDirectory(this->centralwidget,tr("Select Input Directory"), QDir::currentPath());<br>
dirname = indirectory.toStdString();<br>
<br>
}<br>
------main.cpp---------<br>
#include "test.h"<br>
void main(int argc, char *argv[])<br>
{<br>
QApplication app(argc, argv);<br>
test *mywin = new test;<br>
app.exec();<br>
<br>
}<br></div></div>
------------------------------------------------------------------------<br>
<br>
_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
<br>
</blockquote>
<br>
</blockquote></div><br>