[vtkusers] Image tracer using Qt

Luis Roberto P. Paula luisrpp at gmail.com
Wed Jan 28 11:09:46 EST 2009


This is very close to what I did. But what if I wanna draw over the image
displayed in QVTKWidget using the left button of the mouse. If I use the
code you sent, I'll just control the window/level parameters.

On Wed, Jan 28, 2009 at 1:57 PM, Wagner Sales <wsales at gmail.com> wrote:

> Hi Arnaud,
>
> Yes, are possible to use how much QVTKWidgets you needs on a application.
> QVTKWidget will only provide one advantage: you can use VTK+Qt ( like
> ParaView ). This commented example may be helps you:
>
> // creates the QVTKWidget.
> QVTKWidget widget;
>   widget.resize(256,256); // resize
>
>   vtkPNGReader* reader = vtkPNGReader::New(); // a VTK reader like in and
> other example
>   char* fname = vtkTestUtilities::ExpandDataFileName(argc, argv,
> "Data/vtk.png"); // vtk stuff
>   reader->SetFileName(fname); // vtk stuff
>   delete [] fname;
>
>   vtkImageViewer* image_view = vtkImageViewer::New(); // an image viewer --
> vtk stuff
>   image_view->SetInputConnection(reader->GetOutputPort()); // vtk stuff
>
>   widget.SetRenderWindow(image_view->GetRenderWindow()); // Qt + vtk stuff
> ---> setting the Qt widget render window with the image_view render window
>   image_view->SetupInteractor(widget.GetRenderWindow()->GetInteractor());
> // Qt + vtk stuff ---> setup the interactor in image view
>
>   image_view->SetColorLevel(138.5); // vtk stuff
>   image_view->SetColorWindow(233); // vtk stuff
>
>   widget.show(); // qt stuff
>
> In this example, I think are clear that's the work thats are needed to put
> a image viewer in a Qt Widget are very simple. You can see that's are really
> very few lines to do this, without traps, and the other lines are the VTK
> stuff just like you have in any other VTK example.  In fact, if you remove
> the Qt lines ad creates the Interactor, with a Interactor->Start() and a
> RenderWindow->Render() you have all the example without Qt ( pure VTK).
>
> I hope this example are more clear and closely to a good answer.
>
> Regards,
>
> Wagner
>
>
> 2009/1/28 Luis Roberto P. Paula <luisrpp at gmail.com>
>
>> Hi Arnaud and Wagner,
>>
>> Thank's for the tips. Actually, I have already connected VTK and Qt. The
>> problem is that I need to draw a free line over an image being displayed in
>> the QVTKWidget, and by default, this widget controls the window/level
>> parameters when the left button of the mouse is pressed.
>>
>> Sorry for not being very clear, but my question is: How can I take the
>> advantages of vtkImageTracerWidget and still display the image in a Qt
>> window. Is it possible to use more than one widget at the same time?
>>
>> Thank's,
>> Luis
>>
>>
>> On Wed, Jan 28, 2009 at 10:36 AM, Wagner Sales <wsales at gmail.com> wrote:
>>
>>> Hi Luis,
>>>
>>> Basically, QVTKWidget provides you a vtkRenderWindow with an interactor (
>>> the last can be changed after ).
>>> The VTK/Qt events are managed by vtkEventQtSlotConnect. Of course, if you
>>> wants, you can use callbacks like in VTK. Then, if you are developing in
>>> C++, take a look at examples in VTK/Examples/GUI/Qt/VTK/Examples/GUI/Qt/.
>>> This examples will help you how to acces the vtkRenderWindow and how to
>>> connect VTK and Qt.
>>> Your task are easy to do, but I developed with Qt and VTK, and the best
>>> way to learn ( at least to me ) are by the examples.
>>>
>>>
>>> Regards,
>>>
>>> Wagner
>>>
>>> 2009/1/28 Luis Roberto P. Paula <luisrpp at gmail.com>
>>>
>>>> Hi All,
>>>>
>>>> I need to implement an image tracer, just like the one provided in
>>>> VTK/Examples/GUI/Python/ImageTracerWidget.py, but I need to do it using Qt
>>>> (QVTKWidget).
>>>>
>>>> Does anybody knows how can I do that?
>>>>
>>>> Thanks in advance,
>>>> Luis
>>>>
>>>> _______________________________________________
>>>> This is the private VTK discussion list.
>>>> Please keep messages on-topic. Check the FAQ at:
>>>> http://www.vtk.org/Wiki/VTK_FAQ
>>>> Follow this link to subscribe/unsubscribe:
>>>> http://www.vtk.org/mailman/listinfo/vtkusers
>>>>
>>>>
>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20090128/9f717312/attachment.htm>


More information about the vtkusers mailing list