# Slice Representation Lookup table

**URL:** https://discourse.paraview.org/t/slice-representation-lookup-table/9703
**Category:** Development
**Created:** [May 28, 2022, 2:39pm UTC](https://discourse.paraview.org/t/slice-representation-lookup-table/9703 "2022-05-28T14:39:37Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![fvitello](https://discourse.paraview.org/user_avatar/discourse.paraview.org/fvitello/32/8783_2.png) [@fvitello](https://discourse.paraview.org/u/fvitello)
#### Post date: [May 28, 2022, 2:39pm UTC](https://discourse.paraview.org/t/slice-representation-lookup-table/9703/1 "2022-05-28T14:39:37Z")

</div>

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:

```auto
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

---

<div class="post-metadata">

### Author: ![fvitello](https://discourse.paraview.org/user_avatar/discourse.paraview.org/fvitello/32/8783_2.png) [@fvitello](https://discourse.paraview.org/u/fvitello)
#### Post date: [May 29, 2022, 7:48am UTC](https://discourse.paraview.org/t/slice-representation-lookup-table/9703/2 "2022-05-29T07:48:30Z")

</div>

I was able to solve, here the code that might be useful for someone else

```auto
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?

---

<div class="post-metadata">

### Author: ![fvitello](https://discourse.paraview.org/user_avatar/discourse.paraview.org/fvitello/32/8783_2.png) [@fvitello](https://discourse.paraview.org/u/fvitello)
#### Post date: [July 13, 2023, 7:02am UTC](https://discourse.paraview.org/t/slice-representation-lookup-table/9703/3 "2023-07-13T07:02:50Z")

</div>

Dear All,

can you help me setting log scale when mapping data to colors in In my c++ custom application?

Thanks

---

<div class="post-metadata">

### Author: ![utkarsh.ayachit](https://discourse.paraview.org/user_avatar/discourse.paraview.org/utkarsh.ayachit/32/39_2.png) [@utkarsh.ayachit](https://discourse.paraview.org/u/utkarsh.ayachit)
#### Post date: [July 13, 2023, 2:09pm UTC](https://discourse.paraview.org/t/slice-representation-lookup-table/9703/4 "2023-07-13T14:09:20Z")

</div>

Look at code in `pqColorOpacityEditorWidget::useLogScaleClicked(...)`, it pretty much goes through the steps needed to enable/disable log scaling.

ref: [https://gitlab.kitware.com/paraview/paraview/-/blob/master/Qt/ApplicationComponents/pqColorOpacityEditorWidget.cxx#L910](https://gitlab.kitware.com/paraview/paraview/-/blob/master/Qt/ApplicationComponents/pqColorOpacityEditorWidget.cxx#L910)

---

<div class="post-metadata">

### Author: ![fvitello](https://discourse.paraview.org/user_avatar/discourse.paraview.org/fvitello/32/8783_2.png) [@fvitello](https://discourse.paraview.org/u/fvitello)
#### Post date: [July 13, 2023, 4:10pm UTC](https://discourse.paraview.org/t/slice-representation-lookup-table/9703/5 "2023-07-13T16:10:46Z")

</div>

Thanks, I realized that is quite easy to enable the log scaling:

```auto
        vtkSMPropertyHelper(lutProxy, "UseLogScale").Set(1);

```
