[vtkusers] How to get a vtkContextView into a QWidget?

da remywendy at gmail.com
Thu Apr 22 13:51:43 EDT 2010


Thanks Marcus.

The code I had somehow disabled mouse interactions - I wasn't able to zoom
or interact with the renderWindow that I created - however using your code
snippet it worked out. (instead of creating a new QVTKInteractor, use the
one from QVTKWidget). Not sure why though.

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

Good job man, its looking real pretty.

I'm running into an issue I can't figure out -
I have a table with { Index, X, Value } columns, I want to plot Value
against Index (Index on X-Axis), but instead of using Index as the tick
marks, I want to replace the tick marks in index with the corresponding X
values. (if i plot Value against X, it'll give me a different plot because X
goes from -3 -> 0 -> 3 while Index goes from 0 -> 500)
I tried using
(vtkPlot)->GetXAxis()->SetTickLabels()
but I don't think its doing what I expected it to do. Any ideas?

Thanks.



On Wed, Apr 21, 2010 at 4:36 PM, Marcus D. Hanwell <
marcus.hanwell at kitware.com> wrote:

> 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/20100422/b52d8eb0/attachment.htm>


More information about the vtkusers mailing list