[Paraview] Forcing update on view

Andrzej Peczak apeczak at ara.co.uk
Fri Jun 17 04:11:22 EDT 2016


Thanks Utkarsh, this was exactly what I was looking for!

Andrzej

-----Original Message-----
From: Utkarsh Ayachit [mailto:utkarsh.ayachit at kitware.com] 
Sent: 14 June 2016 20:22
To: Andrzej Peczak
Cc: paraview at paraview.org
Subject: Re: [Paraview] Forcing update on view

I am not sure I follow what you're doing, but here are a few things to note.

1. vtkSMProxy::UpdateVTKObjects() is called to push changes done to a property. Thus, only needs to be called on the proxy whose properties you're changing. Thus, if you are chaning "CompositeDataSetIIndex"
property on the chartRepresentationProxy, you only need to call
UpdateVTKObjects() on it.
2. pqView::forceRender() cancels pending renders, so you don't have to do that explicitly.
3. When CompositeDataSetIndex property is changed and successfully pushed, vtkChartRepresentation::AddCompositeDataSetIndex() should be called. Try putting a breakpoint there to ensure it's getting called when you're expecting it to happen.

Hope that helps,
Utkarsh

On Tue, Jun 14, 2016 at 5:35 AM, Andrzej Peczak <apeczak at ara.co.uk> wrote:
> I missed the question regarding the problem I describe. Is there a way to programmatically display the content of CompositeDataSetIndex property depending on status of the checkbox widgets I change through vector properties?
>
> Andrzej
>
> Hi,
>
> I have a snippet code which I wrote to allow me to save multiple plot images to files. I do it by changing property checkboxes of Composite Data Set Index property. I can change their status programmatically but the view is not being updated. When I change them manually in the UI the view knows about their status change and plots only the content I select. I tried to force the update with UpdateVTkObjects() of available properties plus explicitly calling render()/forceRender() of the view but with no success.  Every file I create has multiple plot curves in it instead of one.
>
> Andrzej
>
>         pqDataRepresentation *repr = source->getRepresentation( view );
>         auto chartRepresentationProxy = repr->getProxy();
>
>         vtkSMProperty *property = chartRepresentationProxy->GetProperty( "CompositeDataSetIndex" );
>         if ( property ) {
>
>                 auto VectorProperty = vtkSMIntVectorProperty::SafeDownCast( property );
>                 if ( VectorProperty ) {
>
>                         const auto numElements = VectorProperty->GetNumberOfElements();
>                         int elements[ numElements ];
>                         std::copy( VectorProperty->GetElements(), VectorProperty->GetElements() + numElements, elements );
>                         for ( auto i = 0 ; i != numElements ; ++i ) {
>                                 VectorProperty->SetElement( elements[ i ], 0 );
>                         }
>
>                         for ( auto i = 0 ; i != numElements ; ++i ) {
>                                 VectorProperty->SetElement( elements[ 
> i ], 1 );
>
>                                 source->getSourceProxy()->UpdateVTKObjects();
>                                 view->getViewProxy()->UpdateVTKObjects();
>                                 view->getViewProxy()->Update();
>                                 repr = source->getRepresentation( view );
>                                 repr->getProxy()->UpdateVTKObjects();
>                                 repr->renderView( true );
>                                 property->GetParent()->UpdateVTKObjects();
>                                 view->cancelPendingRenders();
>                                 view->forceRender();
>
>                                 std::stringstream ssFileName;
>                                 std::string ext , newName2;
>                                 std::string::size_type dot_pos = newName.rfind( '.' );
>                                 if ( dot_pos != std::string::npos ) {
>                                         ext = newName.substr( dot_pos );
>                                         newName2 = newName.substr( 0, dot_pos );
>                                 }
>                                 ssFileName << newName2 << "_" << i + 1 << ext;
>                                 view->writeImage( ssFileName.str().c_str(), size, quality );
>                                 VectorProperty->SetElement( elements[ i ], 0 );
>                         }
>
>                         VectorProperty->SetElements( elements );
>                 }
>         }
>
> **********************************************************************
> Please consider the environment. Only print this email if absolutely necessary.
>
> This email contains information that is private and confidential and is intended only for the addressee.
> If you are not the intended recipient please delete it and notify us immediately by e-mailing the sender.
> Note: All email sent to or from this address may be accessed by 
> someone other than the recipient, for system management and security reasons.
> Aircraft Research Association Ltd.  Registered in England, Registration No 503668 Registered Office:
> Manton Lane, Bedford MK41 7PF England VAT No GB 196351245
>
> **********************************************************************
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at 
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the ParaView Wiki at: 
> http://paraview.org/Wiki/ParaView
>
> Search the list archives at: http://markmail.org/search/?q=ParaView
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/paraview

**********************************************************************
Please consider the environment. Only print this email if absolutely necessary.

This email contains information that is private and confidential and is intended only for the addressee.
If you are not the intended recipient please delete it and notify us immediately by e-mailing the sender.
Note: All email sent to or from this address may be accessed by someone other than the recipient, for
system management and security reasons.
Aircraft Research Association Ltd.  Registered in England, Registration No 503668 Registered Office:
Manton Lane, Bedford MK41 7PF England VAT No GB 196351245

**********************************************************************


More information about the ParaView mailing list