I fixed the problem by replacing vtkSmartPointer by a real pointer and it
works Now. I still don't know what's wrong with the smartpointers.
Which smart pointers did you replace with normal pointers? reader, imageViewer, and myInteractorStyle?
If you could make a compilable example (in a single file) that reproduces the problem and has a commented block that we can switch with another block to replace the smart pointers, we might be able to tell you what is happening.
Powered by www.kitware.com
I replaced them all (reader, imageViewer and myInteractorStyle) in the cpp
file. According to this
I just want to display the series on a QVTKWidget but the program crashes
every time when I try to change the slice by pressing UP or Down. So I
decided to replace all the smartpointers by normal pointers and it works.
By the way, I'm using Netbeans IDE with Qt Designer integrated on it. I
tried to keep the same code, but I added some in bold.
On Thu, Sep 6, 2012 at 5:28 PM, Massi <[hidden email]> wrote:
> I'm sorry if you can't compile. I will try to reproduce the problem with
> VisualStrudio2010 and display it later.
That is way too much code to look at. The idea is to try to produce
the problem in as few lines of code as possible, and to avoid all
external dependencies. That is, instead of reading DICOM files, you
should just be able to create a dummy vtkImageData, right (the problem
is not data-specific)? And is Qt part of the problem? And is the
interaction part of the problem? Usually by reducing this to the
smallest possible test case, you will actually find where the problem
lies yourself :)
Powered by www.kitware.com
I hate to resurface this problem, but I have similar code and was able to reproduce the error. Before trying Massi's of getting the window to render in the widget, I kind of went in a loop as you will see right below, but myInteractor would not work in the widget. However, it does work if I try it in an external window (just not in the widget). Code below for non-working interactor.
// make imageviewer2 and dicomViewerLabel visible to our interactorstyle
// to enable slice status message updates when scrolling through the slices
Thanks for getting back to me so quickly! While trying your code, I realized I did something really foolish. I was letting my pointer go out of scope so of course it crashed. However, my interactor is still not working inside of the widget. I was reading that I might have to setup event connections manually for the widget? Do you have knowledge about this, or were you able to get your interactor functioning just by creating the class and setting the interactor style?
Interesting. Well, I'm using Qt to design the UI, but CMake/ VS to build. I can display on my widget. If I were to use a separate window and not the widget, the interactor works and the text label under the widget in the attached photo work as well. Though when I set the widget's interactor, it does not queue the interactor when I scroll over the widget or any other events that I have set up. Since I know my interactor works in a separate window, I can only assume the interactor is not being assigned to the widget properly. Thanks for all the help!
In this image, you will see the series that are available in the located the directory. You can update the widget by hitting the view dicoms button when a series in the list is highlighted. The load function will be to choose that set of dicoms and load them to my main UI.
Edit: I'm wondering if it has anything to do with my call order and a.exec();
So here is the outline of the program.
Main (initializes,shows fileloadwindow and calls a.exec();
fileloadwindow(has many buttons which have callbacks to class dicomLib)
dicomLib (takes the widget as an input as input, does not set the interactor until fileloadwindow has a callback on it from the "view dicoms" button. the function that is called by that button connects the myWindow to imageViewer and myInteractor.)