I have a custom Paraview application that is used to display astronomical data. As part of it, I display multiple 2D images in the same renderview (an instance of pqRenderView*
). The images are all instantiated and loaded separately, to make sure that arbitrary numbers of images can be loaded.
The images are created as follows:
imageRep = builder->createDataRepresentation(this->imageSource->getOutputPort(0), viewImage);
imageProxy = imageRep->getProxy();
vtkSMPropertyHelper(imageProxy, "Representation").Set("Slice");
auto separateProperty = vtkSMPVRepresentationProxy::SafeDownCast(imageProxy)->GetProperty("UseSeparateColorMap");
vtkSMPropertyHelper(separateProperty).Set(1);
vtkSMPVRepresentationProxy::SetScalarColoring(imageProxy, "FITSImage", vtkDataObject::POINT);
imageProxy->UpdateVTKObjects();
The colour map for each image is initialised by the following:
// Set up colour map controls
vtkNew<vtkSMTransferFunctionManager> mgr;
lutProxy = vtkSMTransferFunctionProxy::SafeDownCast(mgr->GetColorTransferFunction("FITSImage", imageProxy->GetSessionProxyManager()));
When the user changes the colour map, this is what I use to change the colour map:
if (vtkSMProperty *lutProperty = imageProxy->GetProperty("LookupTable")) {
auto presets = vtkSMTransferFunctionPresets::GetInstance();
lutProxy->ApplyPreset(presets->GetFirstPresetWithName(name.toStdString().c_str()));
vtkSMPropertyHelper(lutProperty).Set(lutProxy);
lutProxy->UpdateVTKObjects();
vtkSMPVRepresentationProxy::RescaleTransferFunctionToDataRange(imageProxy, false, false);
vtkSMPVRepresentationProxy::SetScalarBarVisibility(imageProxy, viewImage->getProxy(), true);
imageProxy->UpdateVTKObjects();
this->colourMap = name;
return 1;
}
If the user chooses to select log scale, that is changed by this snippet:
if (auto logProperty = lutProxy->GetProperty("UseLogScale"))
{
double range[2];
vtkSMTransferFunctionProxy::GetRange(lutProxy, range);
vtkSMCoreUtilities::AdjustRangeForLog(range);
this->logScale = true;
vtkSMTransferFunctionProxy::RescaleTransferFunction(lutProxy, range);
vtkSMPropertyHelper(logProperty).Set(1);
changeColorMap(this->getColourMap());
lutProxy->UpdateVTKObjects();
imageProxy->UpdateVTKObjects();
return 1;
}
For some reason, if I just change the log scaling property, the actual colour map resets to the default, which is why I change the colour map again after setting the scaling property.
Each image is initialised separately and added to the pqRenderView
. However, despite setting the “UseSeparateColorMap” property to true on initialising the image, all the images in the renderview has their colour maps synchronised. If any of the images have their colour maps changed, all the others will follow suit.
What am I missing here?