[Paraview] Forcing update on view

Andrzej Peczak apeczak at ara.co.uk
Mon Jun 13 07:20:53 EDT 2016


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();
	vtkSMPropertyHelper helper( repr->getProxy(), "CompositeDataSetIndex" );

	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

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


More information about the ParaView mailing list