Add a representation to a view

Hello,

I’m adding a feature to an application based on ParaView 5.4.
This feature basically consists of showing errors that occurred during the execution of a filter.

By “showing errors”, I mean adding a wireframe representation of the filter’s output overlaying its own representation and this is where i’m struggling.
The representation I wish to add is quite similar to the one showed when using “Find Data” feature on cell data but I didn’t find how it is done in the sources.

I implemented a “behavior” based on the example .\Examples\Plugins\RepresentationBehavior to handle the logic. I managed to add an actor to the active view representing what I want but I don’t think this is the right way to do it.

Any ideas on how to add such a representation ?

By “showing errors”, I mean adding a wireframe representation of the filter’s output overlaying its own representation

I guess I’m not clear on what you are looking for. Is it sufficient to select the standard Wireframe representation for the filter’s output and show the filter’s input as a surface? Or do you want to display just some part of the output where the error is high?

1 Like

I will keep this idea as a backup plan. The reason why I chose to add an overlaying representation instead of changing the object representation was to keep it simple as I would need to store the previous representation in case an error was cleared.

As a first iteration, I want all the object to be overlayed with a red wireframe. But in the future, I will look for a solution using point/cell data to give more informations about the error.

The reason why I chose to add an overlaying representation instead of changing the object representation was to keep it simple as I would need to store the previous representation in case an error was cleared.

I’m sorry, but I’m still not clear about what you mean about storing the previous representation. You have the input A. A can be represented as a surface. Your produces an output, call it B. B can be represented by a wireframe without changing the representation of A. A can still be a surface, so you are in effect storing the previous representation. You can color the wireframe for B red entirely independently of what happens to B.

It would look something like this:

Here, my filter output B is in a red wireframe and the original surface A is still represented by a surface.

That’s how ParaView works: every output of every filter in the pipeline can be represented differently, or not be represented at all if you turn the visibility off.

If I’m totally understanding your goal wrong, could you mock up what your visualization will look like and explain which parts come from the input vs. filter output?

1 Like

Sorry, I should have started from the beginning.
I might not be using the right term with “representation”. I didn’t mean to add a new representation type in the “Display” drop down list. What I meant is to add an actor on the views.

I have:

  • A mechanism which allows a vtkAlgorithm to raise/clear an error (it invokes events Error ON/OFF)
  • A “behavior” listening to this type of events using vtkCallbackCommand

All fine but I would need:

  • Event Error ON: My behavior to add a red wireframe overlaying the output
  • Event Error OFF: My behavior to remove the red wireframe overlaying the output

Let’s build a scenario:

  • I implemented a new vtkAlgorithm called vtkCustomSphereSource
  • if the radius of a vtkCustomSphereSource is lower than 1mm, it toggles an error
  • When an error is active, my output should look like this:

Following my question, I found something that might be interesting, which is pqObjectBuilder::createDataRepresentation(
pqOutputPort*, pqView*, const QString&)

I used this method as follows:

pqDataRepresentation* aUpdateNotificationBehavior::CreateRepresentation(pqPipelineSource* source, pqView* view)
{
	pqDataRepresentation* repr =
		pqApplicationCore::instance()->getObjectBuilder()->createDataRepresentation(source->getOutputPort(0), view);

	vtkSMProxy* reprProxy = repr->getProxy();

	if ( reprProxy ) {
		vtkSMPropertyHelper(reprProxy, "Representation").Set("Wireframe");
		vtkSMPropertyHelper(reprProxy, "LineWidth").Set(2);

		double red[3] = { 1.0, 0.0, 0.0 };
		vtkSMPropertyHelper(reprProxy, "AmbientColor").Set(red, 3);

		reprProxy->UpdateVTKObjects();
		repr->renderViewEventually();
	}

	return repr;
}

The result is not quite what I expected, I get 2 scenarios:

  • if createDataRepresentation() called on first apply (no representation yet), the object takes the red wireframe representation as its default representation
  • if createDataRepresentation() called after first apply, I have to hide and show my source to get the desired representation (surface + red wireframe overlay) and I get errors:
    ERROR: In paraview\paraviewcore\clientservercore\rendering\vtkpvdatadeliverymanager.cxx, line 404
    vtkPVDataDeliveryManager (000001D662363E90): Invalid arguments."

I’m wondering if it is possible to create multiple representations for pipeline source that way?