<span class="gmail_quote"></span>Hi Yumin,<br><br>Thanks for replying. I checked my code again. I don't think there is any problem with the VTK part in there. I can successfully read a dicom image and display it. Currently the file to be read is hard coded in the VTK code and I wanted to add this KWWidgets based filedialog to allow a user to choose the file to be displayed. 
<br>I also tried using the code that you sent me, to display the image in this example, but even that doesn't work.<br>I am attaching my complete code along with a single dicom file for testing(for that matter any jpeg file with appropriate code modifications would work for testing). It would be a great help if you or anyone in the list can help me figure out what's going wrong. I have just modified the MedicalImageViewer example and am using the same 
cmakelists.txt file also.<br><br>Thanks,<br>Ashish<br>-----------------------------------------------<br>file 1- vtkKWMyWindow.h---below<br>--------------------------------------------------<br>#ifndef __vtkKWMyWindow_h<br>

#define __vtkKWMyWindow_h<br><br>#include &quot;vtkKWWindow.h&quot;<br><br>class vtkKWRenderWidget;<br>class vtkImageViewer2;<br>class vtkKWScale;<br>class vtkKWWindowLevelPresetSelector;<br>class vtkKWSimpleAnimationWidget;
<br>class vtkKWLoadSaveButton;<br>class vtkDICOMImageReader;<br>class vtkImageData;<br><br>class vtkKWMyWindow : public vtkKWWindow<br>{<br>public:<br>&nbsp; static vtkKWMyWindow* New();<br>&nbsp; vtkTypeRevisionMacro(vtkKWMyWindow,vtkKWWindow);
<br>&nbsp; virtual void mycallback();<br><br>protected:<br>&nbsp; vtkKWMyWindow();<br>&nbsp; ~vtkKWMyWindow();<br><br>&nbsp; // Description:<br>&nbsp; // Create the widget.<br>&nbsp; virtual void CreateWidget();<br><br>&nbsp; vtkImageViewer2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; *ImageViewer; 
<br>&nbsp; vtkKWRenderWidget&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; *RenderWidget;<br>&nbsp; vtkKWLoadSaveButton&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;*myLoadSaveButton;<br>&nbsp; vtkDICOMImageReader&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;*mydicom;<br>&nbsp; vtkImageData&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;*img_data;<br><br>&nbsp;// virtual void UpdateSliceRanges();
<br><br>private:<br>&nbsp; vtkKWMyWindow(const vtkKWMyWindow&amp;);&nbsp;&nbsp; // Not implemented.<br>&nbsp; void operator=(const vtkKWMyWindow&amp;);&nbsp; // Not implemented.<br>};<br><br>#endif<br>------------------------------------------------------
<br>file 2- vtkKWMyWindow.cxx---below<br>-----------------------------------------------------<br>#include &quot;vtkKWMyWindow.h&quot;<br><br>#include &quot;vtkCornerAnnotation.h&quot;<br>#include &quot;vtkImageData.h&quot;
<br>#include &quot;vtkImageViewer2.h&quot;<br>#include &quot;vtkKWApplication.h&quot;<br>#include &quot;vtkKWFrame.h&quot;<br>#include &quot;vtkKWFrameWithLabel.h&quot;<br>#include &quot;vtkKWMenu.h&quot;<br>#include &quot;
vtkKWMenuButton.h&quot;<br>#include &quot;vtkKWMenuButtonWithSpinButtons.h&quot;<br>#include &quot;vtkKWMenuButtonWithSpinButtonsWithLabel.h&quot;<br>#include &quot;vtkKWNotebook.h&quot;<br>#include &quot;vtkKWRenderWidget.h

&quot;<br>#include &quot;vtkKWScale.h&quot;<br>#include &quot;vtkKWSimpleAnimationWidget.h&quot;<br>#include &quot;vtkKWWindow.h&quot;<br>#include &quot;vtkKWWindowLevelPresetSelector.h&quot;<br>#include &quot;vtkObjectFactory.h

&quot;<br>#include &quot;vtkRenderWindow.h&quot;<br>#include &quot;vtkRenderWindowInteractor.h&quot;<br>#include &quot;vtkXMLImageDataReader.h&quot;<br><br>#include &quot;vtkKWLoadSaveButton.h&quot;<br>#include &quot;vtkKWLoadSaveDialog.h

&quot;<br>#include &quot;vtkDICOMImageReader.h&quot;<br><br>#include &quot;vtkKWWidgetsPaths.h&quot;<br>#include &quot;vtkToolkits.h&quot;<br><br>#include &lt;vtksys/SystemTools.hxx&gt;<br><br>vtkStandardNewMacro( vtkKWMyWindow );
<br>vtkCxxRevisionMacro(vtkKWMyWindow, &quot;$Revision: 1.2 $&quot;);<br><br><br>vtkKWMyWindow::vtkKWMyWindow()<br>{<br>&nbsp; this-&gt;RenderWidget = NULL;<br>&nbsp; this-&gt;ImageViewer = NULL;<br>&nbsp; this-&gt;mydicom = NULL;<br>&nbsp; this-&gt;myLoadSaveButton = NULL;
<br>&nbsp; this-&gt;img_data = NULL;<br>}<br><br>vtkKWMyWindow::~vtkKWMyWindow()<br>{<br>&nbsp; if (this-&gt;ImageViewer)<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; this-&gt;ImageViewer-&gt;Delete();<br>&nbsp;&nbsp;&nbsp; }<br>&nbsp; if (this-&gt;RenderWidget)<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; this-&gt;RenderWidget-&gt;Delete();
<br>&nbsp;&nbsp;&nbsp; }<br>&nbsp; if(this-&gt;mydicom)<br>&nbsp;&nbsp;&nbsp; &nbsp; this-&gt;mydicom-&gt;Delete();<br>&nbsp; if(this-&gt;myLoadSaveButton)<br>&nbsp;&nbsp;&nbsp; &nbsp; this-&gt;myLoadSaveButton-&gt;Delete();<br>&nbsp; if(this-&gt;img_data)<br>&nbsp;&nbsp;&nbsp; &nbsp; this-&gt;img_data-&gt;Delete();
<br><br>}<br><br>void vtkKWMyWindow::CreateWidget()<br>{<br>&nbsp; // Check if already created<br><br>&nbsp; if (this-&gt;IsCreated())<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; vtkErrorMacro(&quot;class already created&quot;);<br>&nbsp;&nbsp;&nbsp; return;<br>&nbsp;&nbsp;&nbsp; }<br><br>

&nbsp; // Call the superclass to create the whole widget<br><br>&nbsp; this-&gt;Superclass::CreateWidget();<br><br>&nbsp; vtkKWApplication *app = this-&gt;GetApplication();<br><br>&nbsp; // Add a render widget, attach it to the view frame, and pack
<br><br>&nbsp; if (!this-&gt;RenderWidget)<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; this-&gt;RenderWidget = vtkKWRenderWidget::New();<br>&nbsp;&nbsp;&nbsp; }<br>&nbsp; this-&gt;RenderWidget-&gt;SetParent(this-&gt;GetViewFrame());<br>&nbsp; this-&gt;RenderWidget-&gt;Create();
<br>
&nbsp; this-&gt;RenderWidget-&gt;ResetCamera();<br>&nbsp; this-&gt;RenderWidget-&gt;CornerAnnotationVisibilityOn();<br><br>&nbsp; app-&gt;Script(&quot;pack %s -expand y -fill both -anchor c -expand y&quot;, <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this-&gt;RenderWidget-&gt;GetWidgetName());
<br><br>&nbsp; //create loadsavebutton<span class="q"><br>&nbsp; if(!this-&gt;myLoadSaveButton)<br>&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp; this-&gt;myLoadSaveButton = vtkKWLoadSaveButton::New();<br>&nbsp; }<br>&nbsp; this-&gt;myLoadSaveButton-&gt;SetParent(this-&gt;GetMainPanelFrame());
<br>&nbsp; this-&gt;myLoadSaveButton-&gt;Create();<br>&nbsp; this-&gt;myLoadSaveButton-&gt;SetText(&quot;Click to Pick a File&quot;);<br>&nbsp; this-&gt;myLoadSaveButton-&gt;GetLoadSaveDialog()-&gt;SaveDialogOff();<br>&nbsp; this-&gt;myLoadSaveButton-&gt;GetLoadSaveDialog()-&gt;SetFileTypes(&quot;{ {Dicom Document} {.dcm} }&quot;);
<br><br>&nbsp; this-&gt;myLoadSaveButton-&gt;SetCommand(this, &quot;mycallback&quot;);<br><br>&nbsp; app-&gt;Script(&quot;pack %s -side top -anchor nw -expand n -padx 2 -pady 2&quot;,this-&gt;myLoadSaveButton-&gt;GetWidgetName());
<br></span>
//&nbsp; this-&gt;RenderWidget-&gt;ResetCamera();<span class="q"><br><br>}<br><br>void vtkKWMyWindow::mycallback()<br>{<br>&nbsp;&nbsp;&nbsp; this-&gt;mydicom-&gt;SetFileName(this-&gt;myLoadSaveButton-&gt;GetLoadSaveDialog()-&gt;GetFileName());
<br>//&nbsp;&nbsp;&nbsp; this-&gt;mydicom-&gt;Update();
<br><br>&nbsp;&nbsp;&nbsp; /*if (!this-&gt;ImageViewer)<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; this-&gt;ImageViewer = vtkImageViewer2::New();<br>&nbsp;&nbsp;&nbsp; }*/<br>//&nbsp;&nbsp;&nbsp; this-&gt;ImageViewer-&gt;SetRenderWindow(this-&gt;RenderWidget-&gt;GetRenderWindow());<br></span>
//&nbsp;&nbsp;&nbsp; this-&gt;ImageViewer-&gt;SetInput(this-&gt;mydicom-&gt;GetOutput());
<span class="q"><br>//&nbsp;&nbsp;&nbsp; this-&gt;ImageViewer-&gt;SetupInteractor(this-&gt;RenderWidget-&gt;GetRenderWindow()-&gt;GetInteractor());<br>//&nbsp;&nbsp;&nbsp; this-&gt;ImageViewer-&gt;Render();<br><br></span>&nbsp;&nbsp;&nbsp; this-&gt;img_data = this-&gt;mydicom-&gt;GetOutput();
<br>&nbsp;&nbsp;&nbsp; double *range = this-&gt;img_data-&gt;GetScalarRange();<span class="q"><br>&nbsp;&nbsp;&nbsp; this-&gt;ImageViewer-&gt;SetColorWindow(range[1] - range[0]);<br>&nbsp;&nbsp;&nbsp; this-&gt;ImageViewer-&gt;SetColorLevel(0.5 * (range[1] + range[0]));
<br>&nbsp;&nbsp;&nbsp; this-&gt;ImageViewer-&gt;SetInput(img_data);
<br>&nbsp;&nbsp;&nbsp; this-&gt;ImageViewer-&gt;Render();<br><br>}<br></span>----------------------------------------------------------------------------<br>file 3-KWMedicalImageViewerExample.cxx---below<br>---------------------------------------------------------------------------
<br>#include &quot;vtkKWApplication.h&quot;<br>#include &quot;vtkKWMyWindow.h&quot;<br><br>#include &lt;vtksys/SystemTools.hxx&gt;<br>#include &lt;vtksys/CommandLineArguments.hxx&gt;<br><br>extern &quot;C&quot; int Kwmedicalimageviewerexamplelib_Init(Tcl_Interp *interp);
<br><br>int my_main(int argc, char *argv[])<br>{<br>&nbsp; // Initialize Tcl<br><br>&nbsp; Tcl_Interp *interp = vtkKWApplication::InitializeTcl(argc, argv, &amp;cerr);<br>&nbsp; if (!interp)<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; cerr &lt;&lt; &quot;Error: InitializeTcl failed&quot; &lt;&lt; endl ;
<br>&nbsp;&nbsp;&nbsp; return 1;<br>&nbsp;&nbsp;&nbsp; }<br><br>&nbsp; // Initialize our Tcl library (i.e. our classes wrapped in Tcl).<br>&nbsp; // This *is* required for the C++ methods to be used as callbacks.<br>&nbsp; // See comment at the top of this file.<br>

<br>&nbsp; Kwmedicalimageviewerexamplelib_Init(interp);<br><br>&nbsp; // Process some command-line arguments<br>&nbsp; // The --test option here is used to run this example as a non-interactive <br>&nbsp; // test for software quality purposes. You can ignore it.
<br><br>&nbsp; int option_test = 0;<br>&nbsp; vtksys::CommandLineArguments args;<br>&nbsp; args.Initialize(argc, argv);<br>&nbsp; args.AddArgument(<br>&nbsp;&nbsp;&nbsp; &quot;--test&quot;, vtksys::CommandLineArguments::NO_ARGUMENT, &amp;option_test, &quot;&quot;);
<br>&nbsp; args.Parse();<br>&nbsp; <br>&nbsp; // Create the application<br>&nbsp; // If --test was provided, ignore all registry settings, and exit silently<br>&nbsp; // Restore the settings that have been saved to the registry, like<br>&nbsp; // the geometry of the user interface so far.
<br><br>&nbsp; vtkKWApplication *app = vtkKWApplication::New();<br>&nbsp; app-&gt;SetName(&quot;KWMedicalImageViewerExample&quot;);<br>&nbsp; if (option_test)<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; app-&gt;SetRegistryLevel(0);<br>&nbsp;&nbsp;&nbsp; app-&gt;PromptBeforeExitOff();
<br>&nbsp;&nbsp;&nbsp; }<br>&nbsp; app-&gt;RestoreApplicationSettingsFromRegistry();<br><br>&nbsp; // Set a help link. Can be a remote link (URL), or a local file<br><br>&nbsp; app-&gt;SetHelpDialogStartingPage(&quot;<a href="http://www.kwwidgets.org" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">

http://www.kwwidgets.org</a>&quot;);<br><br>&nbsp; // Add our window<br>&nbsp; // Set 'SupportHelp' to automatically add a menu entry for the help link<br><br>&nbsp; vtkKWMyWindow *win = vtkKWMyWindow::New();<br>&nbsp; win-&gt;SupportHelpOn();
<br>&nbsp; app-&gt;AddWindow(win);<br>&nbsp; win-&gt;Create();<br>&nbsp; //win-&gt;SecondaryPanelVisibilityOff();<br>&nbsp;&nbsp;&nbsp; std::cout&lt;&lt;&quot;hi&quot;&lt;&lt;&quot;\n&quot;;<br><br>&nbsp; // Start the application<br>&nbsp; // If --test was provided, do not enter the event loop and run this example
<br>&nbsp; // as a non-interactive test for software quality purposes.<br><br>&nbsp; int ret = 0;<br>&nbsp; win-&gt;Display();<br>&nbsp; if (!option_test)<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; app-&gt;Start(argc, argv);<br>&nbsp;&nbsp;&nbsp; ret = app-&gt;GetExitStatus();<br>&nbsp;&nbsp;&nbsp; }
<br>&nbsp; win-&gt;Close();<br><br>&nbsp; // Deallocate and exit<br><br>&nbsp; win-&gt;Delete();<br>&nbsp; app-&gt;Delete();<br>&nbsp; <br>&nbsp; return ret;<br>}<br><br>#if defined(_WIN32) &amp;&amp; !defined(__CYGWIN__)<br>#include &lt;windows.h&gt;
<br>int __stdcall WinMain(HINSTANCE, HINSTANCE, LPSTR lpCmdLine, int)<br>{<br>&nbsp; int argc;<br>&nbsp; char **argv;<br>&nbsp; vtksys::SystemTools::ConvertWindowsCommandLineToUnixArguments(<br>&nbsp;&nbsp;&nbsp; lpCmdLine, &amp;argc, &amp;argv);<br>
&nbsp; int ret = my_main(argc, argv);
<br>&nbsp; for (int i = 0; i &lt; argc; i++) { delete [] argv[i]; }<br>&nbsp; delete [] argv;<br>&nbsp; return ret;<br>}<br>#else<br>int main(int argc, char *argv[])<br>{<br>&nbsp; return my_main(argc, argv);<br>}<br>#endif<br>--------------------------
<div><span class="e" id="q_10f77f8ad4f6ffbb_9"><br><br><div><span class="gmail_quote">On 12/11/06, <b class="gmail_sendername">Yumin Yuan</b> &lt;<a href="mailto:yumin.yuan@kitware.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
yumin.yuan@kitware.com</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi Ashish,<br><br>Since I do not have the DICOM files you are using, here are a couple thoughts:<br><br>1. Tell us on which line of code it is crashing.<br><br>2. Make sure the vtkDICOMImageReader can read your files.<br>

If it is crashing on &quot;img2-&gt;Update()&quot;, or<br>&quot;this-&gt;ImageViewer-&gt;SetInput(img_data);&quot;<br>or&nbsp;&nbsp;&quot;this-&gt;ImageViewer-&gt;Render();&quot;<br><br>your problem is more appropriate on the VTK users mailing list:
<br><br><a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://www.vtk.org/mailman/listinfo/vtkusers</a><br><br>3. Here are the documentation for vtkImageViewer2 (for displaying 2D
<br>image) and vtkDICOMImageReader
<br><a href="http://www.vtk.org/doc/nightly/html/classvtkDICOMImageReader.html" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://www.vtk.org/doc/nightly/html/classvtkDICOMImageReader.html</a>
<br><a href="http://www.vtk.org/doc/nightly/html/classvtkImageViewer2.html" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
http://www.vtk.org/doc/nightly/html/classvtkImageViewer2.html</a><br><br>4. Use the following code to display the image:<br><br>&nbsp;&nbsp;vtkImageData *img_data = img2-&gt;GetOutput();<br>&nbsp;&nbsp; double *range = img_data-&gt;GetScalarRange();
<br>&nbsp;&nbsp; this-&gt;ImageViewer-&gt;SetColorWindow(range[1] - range[0]);<br>&nbsp;&nbsp; this-&gt;ImageViewer-&gt;SetColorLevel(0.5 * (range[1] + range[0]));<br>&nbsp;&nbsp; this-&gt;ImageViewer-&gt;SetInput(img_data);<br> this-&gt;ImageViewer-&gt;Render();
<br><br>5. If you could be more specific on your problem, such as which line<br>of code is crashing, it will save us a great deal of time to find a<br>solution.<br><br>Hope this helps,<br><br>-Yumin<br>-----------------------------
<br>Yumin Yuan<br>R&amp;D Engineer<br>Kitware Inc.<br><br><br>On 12/11/06, Ashish Singh &lt;<a href="mailto:mrasingh@gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">mrasingh@gmail.com</a>
&gt; wrote:<br>&gt; Hi,<br>&gt;<br>&gt; Can someone please tell me how to resolve this problem? I am stuck here and
<br>&gt; can't figure out what's going wrong.<br>&gt;<br>&gt; Thanks,<br>&gt; Ashish<br>&gt;<br>&gt;<br>&gt; On 12/8/06, Ashish Singh &lt;<a href="mailto:mrasingh@gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
mrasingh@gmail.com</a>&gt; wrote:<br>&gt; &gt; Thanks Yumin.
<br>&gt; &gt; I tried creating a callback function. On running the code, I get the<br>&gt; loadsave button but after selecting a file, the program crashes. I can't<br>&gt; figure out what's wrong. Here is my code. Can you please tell me where I am
<br>&gt; going wrong and how to get it to work?<br>&gt; &gt;<br>&gt; &gt; ---part of my code----<br>&gt; &gt; .<br>&gt; &gt; .<br>&gt; &gt; .<br>&gt; &gt;<br>&gt; &gt;&nbsp;&nbsp;if(!this-&gt;myLoadSaveButton)<br>&gt; &gt;&nbsp;&nbsp; {<br>
&gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this-&gt;myLoadSaveButton = vtkKWLoadSaveButton::New();
<br>&gt; &gt;&nbsp;&nbsp; }<br>&gt; &gt;<br>&gt; this-&gt;myLoadSaveButton-&gt;SetParent(this-&gt;GetMainPanelFrame());<br>&gt; &gt;&nbsp;&nbsp; this-&gt;myLoadSaveButton-&gt;Create();<br>&gt; &gt;&nbsp;&nbsp; this-&gt;myLoadSaveButton-&gt;SetText(&quot;Click to Pick a
<br>&gt; File&quot;);<br>&gt; &gt;<br>&gt; this-&gt;myLoadSaveButton-&gt;GetLoadSaveDialog()-&gt;SaveDialogOff();<br>&gt; &gt;<br>&gt; this-&gt;myLoadSaveButton-&gt;GetLoadSaveDialog()-&gt;SetFileTypes(&quot;{<br>&gt; {Dicom Document} {.dcm} }&quot;);
<br>&gt; &gt;&nbsp;&nbsp; this-&gt;myLoadSaveButton-&gt;SetCommand(this,&quot;mycallback&quot;);<br>&gt; &gt;<br>&gt; &gt;&nbsp;&nbsp; app-&gt;Script(&quot;pack %s -side top -anchor nw -expand n -padx 2 -pady<br>&gt; 2&quot;,this-&gt;myLoadSaveButton-&gt;GetWidgetName());
<br>&gt; &gt; .<br>&gt; &gt; .<br>&gt; &gt; void vtkKWMyWindow::mycallback()<br>&gt; &gt; {<br>&gt; &gt;<br>&gt; this-&gt;mydicom-&gt;SetFileName(this-&gt;myLoadSaveButton-&gt;GetLoadSaveDialog()-&gt;GetFileName());<br>&gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp; this-&gt;mydicom-&gt;Update();
<br>&gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp; if (!this-&gt;ImageViewer)<br>&gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this-&gt;ImageViewer = vtkImageViewer2::New();<br>&gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&gt; &gt;<br>&gt; this-&gt;ImageViewer-&gt;SetRenderWindow(this-&gt;RenderWidget-&gt;GetRenderWindow());
<br>&gt; &gt;<br>&gt; this-&gt;ImageViewer-&gt;SetRenderer(this-&gt;RenderWidget-&gt;GetRenderer());<br>&gt; &gt;<br>&gt; this-&gt;ImageViewer-&gt;SetInput(this-&gt;mydicom-&gt;GetOutput());<br>&gt; &gt;<br>&gt; this-&gt;ImageViewer-&gt;SetupInteractor(this-&gt;RenderWidget-&gt;GetRenderWindow()-&gt;GetInteractor());
<br>&gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp; this-&gt;ImageViewer-&gt;Render();<br>&gt; &gt;<br>&gt; &gt; }<br>&gt; &gt;<br>&gt; &gt; Thanks,<br>&gt; &gt; Ashish<br>&gt; &gt; ---------<br>&gt; &gt;<br>&gt; &gt;<br>&gt; &gt;<br>&gt; &gt; On 12/6/06, Yumin Yuan &lt;
<a href="mailto:yumin.yuan@kitware.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">yumin.yuan@kitware.com</a> &gt; wrote:<br>&gt; &gt; &gt; Hi Ashish,<br>&gt; &gt; &gt;<br>&gt; &gt; &gt; The problem is the
<br>&gt; &quot;load_button1-&gt;GetLoadSaveDialog()-&gt;GetFileName()&quot;
<br>&gt; &gt; &gt; returns NULL in your code.<br>&gt; &gt; &gt;<br>&gt; &gt; &gt; Two options here:<br>&gt; &gt; &gt;<br>&gt; &gt; &gt; 1. Use vtkKWLoadSaveDialog directly, instead of the<br>&gt; &gt; &gt; vtkKWLoadSaveButton, and call Invoke() on the dialog before
<br>&gt; &gt; &gt; GetFileName().<br>&gt; &gt; &gt; Also, check dialog status &quot;GetStatus() == vtkKWDialog::StatusOK&quot;<br>&gt; &gt; &gt;<br>&gt; &gt; &gt;<br>&gt; &gt; &gt; 2. If you want to use vtkKWLoadSaveButton, try to add a callback to the
<br>&gt; button:<br>&gt; &gt; &gt;<br>&gt; &gt; &gt; for example:<br>&gt; &gt; &gt;<br>&gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;this-&gt;load_button1-&gt;SetCommand( this, &quot;SelectFileCallback&quot;);<br>&gt; &gt; &gt;<br>&gt; &gt; &gt; before packing statement.
<br>&gt; &gt; &gt;<br>&gt; &gt; &gt; &gt;&nbsp;&nbsp; app-&gt;Script(&quot;pack %s -side top -anchor nw -expand n -padx 2 -pady<br>&gt; &gt; &gt; &gt; 2&quot;,load_button1-&gt;GetWidgetName());<br>&gt; &gt; &gt;<br>&gt; &gt; &gt; Then, put your file loading code in the callback function
<br>&gt; &gt; &gt;<br>&gt; &gt; &gt; void yourclass::SelectFileCallback()<br>&gt; &gt; &gt; {<br>&gt; &gt; &gt;<br>&gt; &gt; &gt; //Check dialog status &quot;GetStatus() == vtkKWDialog::StatusOK&quot;<br>&gt; &gt; &gt;<br>

&gt; &gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;vtkDICOMImageReader<br>&gt; *img2=vtkDICOMImageReader::New();<br>&gt; &gt; &gt; &gt;<br>&gt; &gt; &gt; &gt;<br>&gt; img2-&gt;SetFileName(load_button1-&gt;GetLoadSaveDialog()-&gt;GetFileName());<br>
&gt; &gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;img2-&gt;Update();
<br>&gt; &gt; &gt; &gt;<br>&gt; &gt; &gt; &gt;&nbsp;&nbsp; vtkImageViewer2 * myviewer=vtkImageViewer2::New();<br>&gt; &gt; &gt; &gt;&nbsp;&nbsp; myviewer-&gt;SetInput(img2-&gt;GetOutput());<br>&gt; &gt; &gt; &gt;&nbsp;&nbsp; myviewer-&gt;SetColorWindow(2000);
<br>&gt; &gt; &gt; &gt;&nbsp;&nbsp; myviewer-&gt;SetColorLevel(1500);<br>&gt; &gt; &gt; &gt;&nbsp;&nbsp; myviewer-&gt;Render();<br>&gt; &gt; &gt;<br>&gt; &gt; &gt; }<br>&gt; &gt; &gt;<br>&gt; &gt; &gt;<br>&gt; &gt; &gt; -Yumin<br>&gt; &gt; &gt;
<br>&gt; &gt; &gt; On 12/6/06, Ashish Singh &lt;<a href="mailto:mrasingh@gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">mrasingh@gmail.com</a> &gt; wrote:<br>&gt; &gt; &gt; &gt; Hi,<br>
&gt; &gt; &gt; &gt;<br>&gt; &gt; &gt; &gt; I have a vtk application to display a dicom 
image.I am trying to<br>&gt; create a<br>&gt; &gt; &gt; &gt; button on main panel which when clicked opens up the directory tree<br>&gt; and we<br>&gt; &gt; &gt; &gt; can choose the dicom image files to be displayed in this application.
<br>&gt; I am<br>&gt; &gt; &gt; &gt; using vtkkwloadsavebutton for this. When I run the application, I get<br>&gt; an<br>&gt; &gt; &gt; &gt; error in the vtkoutput window saying that-'filename was not specified<br>&gt; or
<br>&gt; &gt; &gt; &gt; directory doesn't contain dicom images'. I also get the button in the<br>&gt; main<br>&gt; &gt; &gt; &gt; panel which when clicked lets me choose the file that I want to load,<br>&gt; but<br>&gt; &gt; &gt; &gt; nothing happens after I choose the file.
<br>&gt; &gt; &gt; &gt;<br>&gt; &gt; &gt; &gt; I am pasting a part of my code(this is not the complete code) to do<br>&gt; this,<br>&gt; &gt; &gt; &gt; below. Can anyone please tell me how to fix this so that I can choose
<br>&gt; the<br>&gt; &gt; &gt; &gt; file using the dialog and get it displayed?<br>&gt; &gt; &gt; &gt;<br>&gt; &gt; &gt; &gt; Thanks,<br>&gt; &gt; &gt; &gt; Ashish<br>&gt; &gt; &gt; &gt;<br>&gt; &gt; &gt; &gt; --------<br>

&gt; &gt; &gt; &gt;<br>&gt; &gt; &gt; &gt;&nbsp;&nbsp;vtkKWLoadSaveButton *load_button1 = vtkKWLoadSaveButton::New();<br>&gt; &gt; &gt; &gt;&nbsp;&nbsp; load_button1-&gt;SetParent(win-&gt;GetMainPanelFrame());<br>&gt; &gt; &gt; &gt;&nbsp;&nbsp; load_button1-&gt;Create();
<br>&gt; &gt; &gt; &gt;&nbsp;&nbsp; load_button1-&gt;SetText(&quot;Click to Pick a File&quot;);<br>&gt; &gt; &gt; &gt;&nbsp;&nbsp; load_button1-&gt;GetLoadSaveDialog()-&gt;SaveDialogOff();<br>&gt; //<br>&gt; &gt; &gt; &gt; load mode<br>&gt; &gt; &gt; &gt;&nbsp;&nbsp; load_button1-&gt;GetLoadSaveDialog()-&gt;SetFileTypes(&quot;{
<br>&gt; {Dicom<br>&gt; &gt; &gt; &gt; Document} {.dcm} }&quot;);<br>&gt; &gt; &gt; &gt;&nbsp;&nbsp; app-&gt;Script(&quot;pack %s -side top -anchor nw -expand n -padx 2 -pady<br>&gt; &gt; &gt; &gt; 2&quot;,load_button1-&gt;GetWidgetName());
<br>&gt; &gt; &gt; &gt;<br>&gt; &gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;vtkDICOMImageReader<br>&gt; *img2=vtkDICOMImageReader::New();<br>&gt; &gt; &gt; &gt;<br>&gt; &gt; &gt; &gt;<br>&gt; img2-&gt;SetFileName(load_button1-&gt;GetLoadSaveDialog()-&gt;GetFileName());
<br>&gt; &gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;img2-&gt;Update();<br>&gt; &gt; &gt; &gt;<br>&gt; &gt; &gt; &gt;&nbsp;&nbsp; vtkImageViewer2 * myviewer=vtkImageViewer2::New();<br>&gt; &gt; &gt; &gt;&nbsp;&nbsp; myviewer-&gt;SetInput(img2-&gt;GetOutput());<br>&gt; &gt; &gt; &gt;&nbsp;&nbsp; myviewer-&gt;SetColorWindow(2000);
<br>&gt; &gt; &gt; &gt;&nbsp;&nbsp; myviewer-&gt;SetColorLevel(1500);<br>&gt; &gt; &gt; &gt;&nbsp;&nbsp; myviewer-&gt;Render();<br>&gt; &gt; &gt; &gt; -------<br>&gt; &gt; &gt; &gt;<br>&gt; &gt; &gt; &gt; _______________________________________________
<br>&gt; &gt; &gt; &gt; KWWidgets mailing list<br>&gt; &gt; &gt; &gt; <a href="mailto:KWWidgets@kwwidgets.org" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">KWWidgets@kwwidgets.org</a><br>&gt; &gt; &gt; &gt;
<br>&gt; <a href="http://public.kitware.com/cgi-bin/mailman/listinfo/kwwidgets" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
http://public.kitware.com/cgi-bin/mailman/listinfo/kwwidgets</a><br>&gt; &gt; &gt; &gt;<br>&gt; &gt; &gt; &gt;<br>&gt; &gt; &gt;<br>&gt; &gt;<br>&gt; &gt;<br>&gt;<br>&gt;<br></blockquote></div><br>

</span></div><br clear="all">