[vtkusers] Clearing vtkPlot object

Maarten Beek beekmaarten at yahoo.com
Fri Dec 19 11:17:00 EST 2014


In the debugger, I followed the call
m_pChart->GetPlot(0)->SetInputData(0);
all the way into vtkContextMapper2D::SetInputConnection()  and it seems to invoke the calls inputs->SetNumberOfInformationObjects(0); and this->Modified().
So although Modified() is called when the input is removed, I think the scene is not re-rendered (I don't get a warning re. a mapper w/o input either (what other mappers do)).
Turning the visibility on/off using SetVisible() works fine. But I find it weird that the data is still dangling.(I don't want to remove the plot, because that would mean I'll have to keep track of all the plot ids.)
So I think my problem is gone, as long as I don't try to understand what is going on. ;-)
Maarten

 

     On Friday, December 19, 2014 10:48 AM, Marcus D. Hanwell <marcus.hanwell at kitware.com> wrote:
   

 On Fri, Dec 19, 2014 at 10:12 AM, Maarten Beek via vtkusers
<vtkusers at vtk.org> wrote:
> Hi all,
>
> Yesterday I started exploring the options to draw 2d graphs in VTK.
>
> Why does
>
> m_pChart->GetPlot(0)->SetInputData(0);
>
> not remove the graph from my chart?
>
That isn't how the API was designed, you can call remove for a plot,
or clear all plots.
>
> I am currently using
> vtkTable* table = m_pChart->GetPlot(0)->GetInput();
> if( 0 != table )
> {
>    while( 0  < table->GetNumberOfRows() )
>    {
>        table->RemoveRow(0);
>    }
> }
>
> m_pChart->GetPlot(0)->GetData()->Modified(); // <- required!
>
Unless the data is marked as modified then the plot is cached, and it
would be slow to rebuild on every render. This is pretty common in the
VTK API, if an object is not marked as modified it is not surprising.
I guess you might expect SetInputData on the plot to mark that as
modified, which could be a bug in that method.

Hope that makes it clearer, it has been a while since I went through
all of this logic, and it is possible we still have one or two bugs
lurking in there.

Marcus


   
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20141219/bdcd33f1/attachment.html>


More information about the vtkusers mailing list