fvitello
(Fabio Vitello)
#1
Dear all,
In my c++ custom application I want to set the color map of my slice representation.
I have created the representation and settled the scalar to use with this code:
drepSliceCube = builder->createDataRepresentation(fitsSource->getOutputPort(0), viewCube);
auto reprProxySliceCube = drepSliceCube->getProxy();
vtkSMPropertyHelper(reprProxySliceCube, "Representation").Set("Slice");
vtkSMPVRepresentationProxy::SetScalarColoring(reprProxySliceCube, "FITSImage", vtkDataObject::POINT);
How can I set one of the predefined color map e.g. XRay?
Thanks
fvitello
(Fabio Vitello)
#2
I was able to solve, here the code that might be useful for someone else
vtkNew<vtkSMTransferFunctionManager> mgr;
if (vtkSMProperty* lutProperty = reprProxySliceCube->GetProperty("LookupTable"))
{
vtkSMTransferFunctionProxy* lutProxy = vtkSMTransferFunctionProxy::SafeDownCast(
mgr->GetColorTransferFunction(arrayName, reprProxySliceCube->GetSessionProxyManager()));
int rescaleMode =
vtkSMPropertyHelper(lutProxy, "AutomaticRescaleRangeMode", true).GetAsInt();
auto presets = vtkSMTransferFunctionPresets::GetInstance();
//qDebug()<<presets->HasPreset("X Ray");
lutProxy->ApplyPreset(presets->GetFirstPresetWithName("X Ray"), (bool)rescaleMode);
vtkSMPropertyHelper(lutProperty).Set(lutProxy);
bool extend = rescaleMode == vtkSMTransferFunctionManager::GROW_ON_APPLY;
bool force = false;
vtkSMPVRepresentationProxy::RescaleTransferFunctionToDataRange(reprProxySliceCube, extend, force);
reprProxySliceCube->UpdateVTKObjects();
}
Now I would like to be able to use a custom vtkLookupTable, how can I do?