<br>
Hi Xiaopeng,<br><br>Please post some of the error messages <br>to the mailing list.<br><br>We can't help you much if we can't see the <br>error messages...<br><br><br> Thanks<br><br><br> Luis<br><br><br>
-----------------------------------------------------------<br><div class="gmail_quote">2010/7/12 Xiaopeng Yang <span dir="ltr"><<a href="mailto:yxp233@postech.ac.kr">yxp233@postech.ac.kr</a>></span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div link="blue" vlink="purple" lang="EN-US">
<div>
<p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);">Hi Luis,</span></p>
<p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);"> </span></p>
<p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);">Thanks very much for your help. I tried again according to your
suggestion, but I met many errors. Attached is my header file of SimpleView,
where shall I modify? And at the main code, what I need to do is that just
changing them to </span></p><div class="im">
<p class="MsoNormal"><span style="font-size: 10pt; font-family: DotumChe;"> this->reader =
ReaderType::New();</span></p>
<p class="MsoNormal" style="text-indent: 10.5pt;"><span style="font-size: 10pt; font-family: DotumChe;">this->connector
= FilterType::New();</span><span style="font-size: 10pt; font-family: DotumChe;"></span></p>
</div><p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);">Is there anything else I shall modify in the main code?</span></p>
<p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);"> </span></p>
<p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);"> </span></p>
<p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);">Attached is the header file:</span></p>
<p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);"> </span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New"; color: blue;">#ifndef</span><span style="font-size: 10pt; font-family: "Courier New";"> SimpleView_H</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New"; color: blue;">#define</span><span style="font-size: 10pt; font-family: "Courier New";"> SimpleView_H</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";"> </span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New"; color: blue;">#include</span><span style="font-size: 10pt; font-family: "Courier New";"> <span style="color: rgb(163, 21, 21);">"vtkSmartPointer.h"</span>
<span style="color: green;">// Required for smart pointer internal ivars.</span></span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New"; color: blue;">#include</span><span style="font-size: 10pt; font-family: "Courier New";"> <span style="color: rgb(163, 21, 21);"><QMainWindow></span></span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New"; color: rgb(163, 21, 21);"> </span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";">QT_BEGIN_NAMESPACE</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New"; color: blue;">class</span><span style="font-size: 10pt; font-family: "Courier New";"> QAction;</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New"; color: blue;">class</span><span style="font-size: 10pt; font-family: "Courier New";"> QLabel;</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New"; color: blue;">class</span><span style="font-size: 10pt; font-family: "Courier New";"> QMenu;</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New"; color: blue;">class</span><span style="font-size: 10pt; font-family: "Courier New";"> QScrollArea;</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New"; color: blue;">class</span><span style="font-size: 10pt; font-family: "Courier New";"> QScrollBar;</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";"> </span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";">QT_END_NAMESPACE</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";"> </span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New"; color: green;">// Forward Qt class declarations</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New"; color: blue;">class</span><span style="font-size: 10pt; font-family: "Courier New";"> Ui_SimpleView;</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";"> </span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New"; color: green;">// Forward VTK class declarations</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New"; color: blue;">class</span><span style="font-size: 10pt; font-family: "Courier New";"> vtkQtTableView;</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";"> </span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";"> </span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New"; color: blue;">class</span><span style="font-size: 10pt; font-family: "Courier New";"> SimpleView : <span style="color: blue;">public</span>
QMainWindow</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";">{</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";"> Q_OBJECT</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";"> </span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New"; color: blue;">public</span><span style="font-size: 10pt; font-family: "Courier New";">:</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";"> </span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";"> <span style="color: green;">//
Constructor/Destructor</span></span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";"> SimpleView(); </span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";"> ~SimpleView();</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";"> </span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New"; color: blue;">public</span><span style="font-size: 10pt; font-family: "Courier New";"> slots:</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";"> </span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";"> <span style="color: blue;">virtual</span> <span style="color: blue;">void</span> slotOpenFile();</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";"> <span style="color: blue;">virtual</span> <span style="color: blue;">void</span> slotExit();</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";"> </span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New"; color: blue;">protected</span><span style="font-size: 10pt; font-family: "Courier New";">:</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";"> </span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";"> </span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New"; color: blue;">protected</span><span style="font-size: 10pt; font-family: "Courier New";"> slots:</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";"> </span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New"; color: blue;">private</span><span style="font-size: 10pt; font-family: "Courier New";">:</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";"> </span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";">
vtkSmartPointer<vtkQtTableView>
TableView;</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";"> </span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";"> <span style="color: green;">// Designer form</span></span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";"> Ui_SimpleView *ui;</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";">};</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";"> </span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: "Courier New"; color: blue;">#endif</span><span style="font-size: 10pt; font-family: "Courier New";">
<span style="color: green;">// SimpleView_H</span></span><span style="font-size: 10pt; font-family: "Courier New"; color: green;"></span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: "Courier New"; color: green;"> </span></p>
<p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);"> </span></p>
<p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);"> </span></p>
<div style="border-style: solid none none; border-color: rgb(181, 196, 223) -moz-use-text-color -moz-use-text-color; border-width: 1pt medium medium; padding: 3pt 0in 0in;">
<p class="MsoNormal"><b><span style="font-size: 10pt;" lang="ZH-CN">发件人</span></b><b><span style="font-size: 10pt;">:</span></b><span style="font-size: 10pt;"> Luis Ibanez
[mailto:<a href="mailto:luis.ibanez@kitware.com" target="_blank">luis.ibanez@kitware.com</a>] <br>
<b><span lang="ZH-CN">发送时间</span>:</b> Thursday, June 17, 2010 11:53 PM<br>
<b><span lang="ZH-CN">收件人</span>:</b> Xiaopeng Yang<br>
<b><span lang="ZH-CN">抄送</span>:</b> <a href="mailto:vtkusers@vtk.org" target="_blank">vtkusers@vtk.org</a>; itk<br>
<b><span lang="ZH-CN">主题</span>:</b> Re: [vtkusers] About DICOM loading with VTK,
ITK and QT</span></p>
</div><div><div></div><div class="h5">
<p class="MsoNormal"> </p>
<p class="MsoNormal" style="margin-bottom: 12pt;"><br>
Hi Xiaopeng,<br>
<br>
It is likely that the source of the error is that<br>
you are instantiating ITK objects inside your<br>
constructor, but not associating them to <br>
member variables of the "SimpleView" class.<br>
<br>
Therefore, these ITK objects will be destroyed<br>
by the time you get to the closing bracket of<br>
your class constructor (the end of scope).<br>
<br>
<br>
The typical solution here,<br>
is that you should make:</p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: DotumChe;"> ReaderType::Pointer
reader;</span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: DotumChe;"> FilterType::Pointer
connector;</span></p>
<p class="MsoNormal"> </p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: DotumChe;">to be member variables of your
class (move them to </span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: DotumChe;">declaration of the SimpleView
class in your header file)</span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: DotumChe;">and instantiate them in the
constructor as</span></p>
<p class="MsoNormal"> </p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: DotumChe;"> this->reader =
ReaderType::New();</span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: DotumChe;"> this->connector =
FilterType::New();</span></p>
<p class="MsoNormal"><br>
<br>
In this way, they will stay alive for the lifetime<br>
of the SimpleView class.<br>
<br>
<br>
<br>
Regards,<br>
<br>
<br>
Luis<br>
<br>
<br>
-----------------------------------------------------------------</p>
<div>
<p class="MsoNormal">On Tue, Jun 15, 2010 at 10:06 AM, Xiaopeng Yang <<a href="mailto:yxp233@postech.ac.kr" target="_blank">yxp233@postech.ac.kr</a>> wrote:</p>
<div>
<div>
<div>
<div>
<p class="MsoNormal">Dear
VTK users,</p>
<p class="MsoNormal"> </p>
<p class="MsoNormal"> I
made a simple UI with QT for loading a DICOM image by ITK and visualize it by
VTK. Even I successfully debugged the code, but when I ran the executable file,
errors occurred: “An unhandled win32 exception occurred in SimpleView.exe
[448]”. Could you help me to check whether there is any problem in my code?</p>
<p class="MsoNormal"> </p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: DotumChe;">SimpleView::SimpleView() </span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: DotumChe;">{</span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: DotumChe;"> <span style="color: blue;">this</span>->ui
= <span style="color: blue;">new</span> Ui_SimpleView;</span></p>
<p class="MsoNormal" style="text-indent: 10.5pt;"><span style="font-size: 10pt; font-family: DotumChe; color: blue;">this</span><span style="font-size: 10pt; font-family: DotumChe;">->ui->setupUi(<span style="color: blue;">this</span>);</span></p>
<p class="MsoNormal" style="text-indent: 10.5pt;"> </p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: DotumChe; color: green;">//Define ITK DICOM
loader</span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: DotumChe;"> <span style="color: blue;">typedef</span>
itk::Image <<span style="color: blue;">unsigned</span> <span style="color: blue;">short</span>, 2> ImageType;</span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: DotumChe;"> <span style="color: blue;">typedef</span>
itk::ImageFileReader<ImageType>ReaderType;</span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: DotumChe;"> </span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: DotumChe;"> <span style="color: green;">//Connect
ITK to VTK</span></span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: DotumChe;"> <span style="color: blue;">typedef</span>
itk::ImageToVTKImageFilter<ImageType>FilterType;</span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: DotumChe;"> </span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: DotumChe;"> ReaderType::Pointer reader
= ReaderType::New();</span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: DotumChe;"> FilterType::Pointer
connector = FilterType::New();</span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: DotumChe;"> reader->SetFileName(<span style="color: rgb(163, 21, 21);">"C:/Documents and Settings/edt/Desktop/QT
Test3/ImageViewer/DICOM/portal47.dcm"</span>);</span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: DotumChe;">
connector->SetInput(reader->GetOutput());</span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: DotumChe;"> </span></p>
<p class="MsoNormal" style="text-indent: 10.5pt;"><span style="font-size: 10pt; font-family: DotumChe;">vtkImageViewer
*viewer = vtkImageViewer::New();</span></p>
<p class="MsoNormal" style="text-indent: 10.5pt;"><span style="font-size: 10pt; font-family: DotumChe;"> </span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: DotumChe; color: green;"> </span><span style="font-size: 10pt; font-family: DotumChe; color: blue;">this</span><span style="font-size: 10pt; font-family: DotumChe;">->ui->qvtkWidget_2->SetRenderWindow(viewer->GetRenderWindow());</span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: DotumChe;">
viewer->SetupInteractor(<span style="color: blue;">this</span>->ui->qvtkWidget_2->GetRenderWindow()->GetInteractor());</span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: DotumChe;">
viewer->SetInput(connector->GetOutput());</span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: DotumChe;"> viewer->Render();</span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: DotumChe;">
viewer->SetColorLevel(255);</span></p>
<p class="MsoNormal" style="text-indent: 10.5pt;"><span style="font-size: 10pt; font-family: DotumChe;">viewer->SetColorWindow(128);</span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: DotumChe;"> </span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: DotumChe;"> connect(<span style="color: blue;">this</span>->ui->actionOpenFile, SIGNAL(triggered()), <span style="color: blue;">this</span>, SLOT(slotOpenFile()));</span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: DotumChe;"> connect(<span style="color: blue;">this</span>->ui->actionExit, SIGNAL(triggered()), <span style="color: blue;">this</span>, SLOT(slotExit()));</span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: DotumChe;">};</span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: DotumChe;"> </span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: DotumChe;"> </span></p>
<p class="MsoNormal"><span style="font-size: 10pt;">Thanks.</span></p>
<p class="MsoNormal"><span style="font-size: 10pt;"> </span></p>
<p class="MsoNormal"><span style="font-size: 10pt;">Xiaopeng</span></p>
</div>
</div>
</div>
</div>
<p class="MsoNormal" style="margin-bottom: 12pt;"><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></p>
</div>
<p class="MsoNormal"> </p>
</div></div></div>
</div>
</blockquote></div><br>