[vtkusers] How to get a vtkContextView into a QWidget?
Marcus D. Hanwell
marcus.hanwell at kitware.com
Wed Apr 21 19:36:28 EDT 2010
On Wed, Apr 21, 2010 at 6:19 PM, da <remywendy at gmail.com> wrote:
> Thanks Eric.
>
> I ended up doing something like this
>
> vtkSmartPointer<QVTKInteractor> renderWindowInteractor =
> vtkSmartPointer<QVTKInteractor>::New();
> renderWindowInteractor->SetRenderWindow(*(vtkContextView)*
> ->GetRenderWindow());
> renderWindowInteractor->Initialize();
>
> *(QVTKWidget)*->SetRenderWindow(*(vtkContextView)*->GetRenderWindow());
>
> The following should work, but I should add an example to VTK to
demonstrate this (and test that it continues to compile),
QVTKWidget* widget = new QVTKWidget;
vtkContextView* view = vtkContextView::New();
view->SetInteractor(widget->GetInteractor());
widget->SetRenderWindow(view->GetRenderWindow());
It follows the normal vtkRenderView issues around creating a QVTKWidget that
properly contains a render view. This is the basic approach used in ParaView
(hidden in a few proxies).
since QVTKWidget requires a QVTKInteractor as the Interactor. I created a
> new QVTKInteractor, attached it as vtkContextView's interactor, and then
> just set the renderwindow from context view into the qvtkwidget.
>
I may refactor the context view to be a little more lightweight (the render
view it currently derives from contains quite a few things that are not used
by the context view).
>
> (BTW, thanks to the guys developing the new chart classes, they look very
> nice! Especially in Paraview!)
>
> Thanks - I have been working really hard on getting all the pieces in place
for the release. There are quite a few things I would like to do, but think
that the 2D API coupled with the 2D scene, chart API and mark API should
give VTK a powerful suite of tools for rendering 2D views.
Sandia and the Titan project have played a key role in funding and steering
the development of the new 2D APIs and charts in VTK/ParaView. We will
continue collaborating with them as we move forward with this work.
Thanks,
Marcus
>
> On Wed, Apr 21, 2010 at 12:11 PM, Eric E. Monson <emonson at cs.duke.edu>wrote:
>
>> Hello,
>>
>> As long as you are programming in C++ I think you can follow the examples
>> in [vtksource]/Examples/Infovis/Cxx -- there they have things like EasyView
>> that put a vtkGraphLayoutView into a QVTKWidget. I haven't tried this with
>> the Charts specifically, but since vtkContextView is also a vtkRenderView,
>> hopefully you can do the same thing:
>>
>> // Graph View needs to get my render window
>>
>> this->GraphView->SetInteractor(this->ui->vtkGraphViewWidget->GetInteractor());
>>
>> this->ui->vtkGraphViewWidget->SetRenderWindow(this->GraphView->GetRenderWindow());
>>
>> (The reason I say that hopefully you're using C++ is that I can't get this
>> to work with the Python wrappers and PyQt4...)
>>
>> -Eric
>>
>> ------------------------------------------------------
>> Eric E Monson
>> Duke Visualization Technology Group
>>
>>
>> On Apr 21, 2010, at 12:28 PM, da wrote:
>>
>> > Hey everyone,
>> >
>> > I've been playing around with the plotting functionality: first the
>> older vtkQt* classes and now I'm looking at VTK/Charts classes. It seems
>> that vtkContextView is an entire "view" in itself. How would I get this
>> embedded into a QWidget? I've been using QVTKWidget previously but I don't
>> think I can just put the renderer from the context view into the qvtkwidget?
>> >
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100421/828a0664/attachment.htm>
More information about the vtkusers
mailing list