setSlice problem on QVTKWidget

classic Classic list List threaded Threaded
14 messages Options
Reply | Threaded
Open this post in threaded view
|

setSlice problem on QVTKWidget

massinissa bandou-2
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: setSlice problem on QVTKWidget

massinissa bandou-2
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: setSlice problem on QVTKWidget

David Doria-2-3
On Thu, Sep 6, 2012 at 3:52 PM, Massi <[hidden email]> wrote:
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.

David

_______________________________________________
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
Reply | Threaded
Open this post in threaded view
|

Re: setSlice problem on QVTKWidget

massinissa bandou-2
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: setSlice problem on QVTKWidget

David Doria-2-3
On Thu, Sep 6, 2012 at 4:42 PM, Massi <[hidden email]> wrote:
Hi David,
I replaced them all (reader, imageViewer and myInteractorStyle) in the cpp
file. According to this
example:http://www.vtk.org/Wiki/VTK/Examples/Cxx/IO/ReadDICOMSeries ,
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.

Please see: http://www.vtk.org/Wiki/VTK/MinimalExample

That code is not compilable (there are no includes), and there seems to be way more going on than is necessary to replicate the problem.

David

_______________________________________________
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
Reply | Threaded
Open this post in threaded view
|

Re: setSlice problem on QVTKWidget

massinissa bandou-2
In reply to this post by massinissa bandou-2
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: setSlice problem on QVTKWidget

massinissa bandou-2
In reply to this post by David Doria-2-3
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: setSlice problem on QVTKWidget

David Doria-2-3
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 :)

David
_______________________________________________
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
Reply | Threaded
Open this post in threaded view
|

Re: setSlice problem on QVTKWidget

massinissa bandou-2
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: setSlice problem on QVTKWidget

goodsit2
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.

iToVconnector->SetInput(reader->GetOutput());
       
    vtkSmartPointer<vtkImageViewer2> imageViewer =
          vtkSmartPointer<vtkImageViewer2>::New();
    imageViewer->SetInput(iToVconnector->GetOutput());

    vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor =
            vtkSmartPointer<vtkRenderWindowInteractor>::New();

    vtkSmartPointer<DicomInteractorStyleImage> myInteractor =
            vtkSmartPointer<DicomInteractorStyleImage>::New();

    myInteractor->SetImageViewer(imageViewer);
    myInteractor->SetStatusMapper(myLabel);
       
    imageViewer->SetupInteractor(renderWindowInteractor);


    myWindow->SetRenderWindow(renderWindowInteractor->GetRenderWindow());
        imageViewer->SetupInteractor(myWindow->GetRenderWindow()->GetInteractor());
        myWindow->GetRenderWindow()->GetInteractor()->SetInteractorStyle(myInteractor);
    imageViewer->Render();
    imageViewer->GetRenderer()->ResetCamera();
    imageViewer->Render();
    myWindow->update();

And since I saw Mass's interactor working, I thought I would try his method as seen below:

vtkImageViewer2 * imageViewer = vtkImageViewer2::New();
    imageViewer->SetInput(iToVconnector->GetOutput());

    DicomInteractorStyleImage * myInteractor = DicomInteractorStyleImage::New();

    // make imageviewer2 and dicomViewerLabel visible to our interactorstyle
    // to enable slice status message updates when scrolling through the slices
    myInteractor->SetImageViewer(imageViewer);
    myInteractor->SetStatusMapper(myLabel);
       
        myWindow->SetRenderWindow(imageViewer->GetRenderWindow());
        imageViewer->SetupInteractor(myWindow->GetRenderWindow()->GetInteractor());
        myWindow->GetRenderWindow()->GetInteractor()->SetInteractorStyle(myInteractor);
        myWindow->update();

Though the program crashed instantly when it ran through this section. I even tried his pointer theory, but still my program crashed. I narrowed it down to two lines of code. Those are:

myWindow->SetRenderWindow(imageViewer->GetRenderWindow());
imageViewer->SetupInteractor(myWindow->GetRenderWindow()->GetInteractor());

If either of these lines were in the code, it crashed the program. Any thoughts? Thanks for reading :)

Bests,

Jeremy
Reply | Threaded
Open this post in threaded view
|

Re: setSlice problem on QVTKWidget

massinissa bandou-2
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: setSlice problem on QVTKWidget

goodsit2
Hey Massi,

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?

Bests,

Jeremy
Reply | Threaded
Open this post in threaded view
|

Re: setSlice problem on QVTKWidget

massinissa bandou-2
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: setSlice problem on QVTKWidget

goodsit2
This post was updated on .
Massi,

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.)

Bests,

Jeremy