[vtkusers] vtkXYPlotActor : RemoveAllInputs

REGAT-BARREL Aurélien arbvtk at yahoo.fr
Mon May 17 03:30:06 EDT 2004


Hi,
I am using a vtkXYPlotActor in order to draw curves from scratch.  To do this, I build a vtkDataObject that I add to my vtkXYPlotActor by calling AddDataObjectInput.
It works well, the first time. When I want to change the values viewed, I call
    XYplot->RemoveAllInputs()
and do the same thing, and it crashes. I found that this is because RemoveAllInputs() does not apply on vtkXYplotActor::DataObjectInputList.
Instead I call
    XYplot->GetDataObjectInputList()->RemoveAllItems();
and it works well.
Is it a normal behaviour ?
 
Here is the interesting code :
 
    vtkFloatArray * Xarray = vtkFloatArray::New();
    vtkFloatArray * Yarray = vtkFloatArray::New();
    // fill the arays
    for ( size_t i = 0; i < R.size(); ++i )
    {
        Xarray->InsertNextValue( i );
        Yarray->InsertNextValue( R.at( i ) );
    }
    // create the data object
    vtkFieldData * FieldValues = vtkFieldData::New();
    FieldValues->AllocateArrays( 2 );
    FieldValues->AddArray( Xarray );
    FieldValues->AddArray( Yarray );
    vtkDataObject * Data = vtkDataObject::New();
    Data->SetFieldData( FieldValues );
    // add input
    this->XYplot->AddDataObjectInput( Data );
    int num = this->XYplot->GetDataObjectInputList()->GetNumberOfItems()- 1;
    this->XYplot->SetDataObjectYComponent( num, 1 );
    this->XYplot->SetPlotColor( num, vtkXYPlot::GetPlotColors( num ) );

Is there a better way to do the same thing ? (in particular for the 3 last lines).
Thanks.



Aurélien REGAT-BARREL
		
---------------------------------
Yahoo! Mail : votre e-mail personnel et gratuit qui vous suit partout !
Créez votre Yahoo! Mail

Dialoguez en direct avec vos amis grâce à Yahoo! Messenger !
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20040517/ede72591/attachment.htm>


More information about the vtkusers mailing list