# Changing Size and color of individual interaction handles of ROI

**URL:** <https://discourse.slicer.org/t/changing-size-and-color-of-individual-interaction-handles-of-roi/26360>\
**Category:** Development\
**Created:** [November 21, 2022, 8:30pm UTC](https://discourse.slicer.org/t/changing-size-and-color-of-individual-interaction-handles-of-roi/26360 "2022-11-21T20:30:40Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![maptekarev](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/maptekarev/32/14586_2.png) [@maptekarev](https://discourse.slicer.org/u/maptekarev)\
**Post date:** [November 21, 2022, 8:30pm UTC](https://discourse.slicer.org/t/changing-size-and-color-of-individual-interaction-handles-of-roi/26360/1 "2022-11-21T20:30:40Z")

</div>

To implement ROI I am using vtkMRMLMarkupsROINode class. There is SetInteractionHandleScale() method in this class, but it is changing size of all interaction handles.  
Is it possible to change size and color of one individual interaction handle of ROI?

---

<div class="post-metadata">

**Author:** ![pll\_llq](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pll_llq/32/9408_2.png) [@pll\_llq](https://discourse.slicer.org/u/pll_llq)\
**Post date:** [November 23, 2022, 11:04am UTC](https://discourse.slicer.org/t/changing-size-and-color-of-individual-interaction-handles-of-roi/26360/2 "2022-11-23T11:04:24Z")

</div>

@RafaelPalomar maybe you can give some insight here?

---

<div class="post-metadata">

**Author:** ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)\
**Post date:** [November 23, 2022, 12:08pm UTC](https://discourse.slicer.org/t/changing-size-and-color-of-individual-interaction-handles-of-roi/26360/3 "2022-11-23T12:08:30Z")

</div>

The handle sizes and colors are hard-coded, see

> <https://github.com/Slicer/Slicer/blob/3c592df27e3dccedbd8fcddf05979f59af484f2c/Modules/Loadable/Markups/VTKWidgets/vtkSlicerMarkupsWidgetRepresentation.cxx#L1081-L1083>

and

> <https://github.com/Slicer/Slicer/blob/3c592df27e3dccedbd8fcddf05979f59af484f2c/Modules/Loadable/Markups/VTKWidgets/vtkSlicerMarkupsWidgetRepresentation.cxx#L1322-L1331>

---

<div class="post-metadata">

**Author:** ![pll\_llq](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pll_llq/32/9408_2.png) [@pll\_llq](https://discourse.slicer.org/u/pll_llq)\
**Post date:** [November 23, 2022, 4:09pm UTC](https://discourse.slicer.org/t/changing-size-and-color-of-individual-interaction-handles-of-roi/26360/4 "2022-11-23T16:09:52Z")

</div>

Thanks for the insight @cpinter

---

<div class="post-metadata">

**Author:** ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)\
**Post date:** [November 24, 2022, 10:43am UTC](https://discourse.slicer.org/t/changing-size-and-color-of-individual-interaction-handles-of-roi/26360/5 "2022-11-24T10:43:48Z")

</div>

@maptekarev Can you tell us a bit about the motivation? I think the color can be made customizable relatively easily if you don’t need a GUI for that.

---

<div class="post-metadata">

**Author:** ![maptekarev](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/maptekarev/32/14586_2.png) [@maptekarev](https://discourse.slicer.org/u/maptekarev)\
**Post date:** [November 24, 2022, 11:36am UTC](https://discourse.slicer.org/t/changing-size-and-color-of-individual-interaction-handles-of-roi/26360/6 "2022-11-24T11:36:55Z")

</div>

@cpinter Ii want the green and red handle on roi to correspond with feet color of the human model, and also change size or opacity of white corner handles.

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/f/8/f89a53d3f53f705a4cde8b1364b125d50805c990.png)

---

<div class="post-metadata">

**Author:** ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)\
**Post date:** [November 24, 2022, 12:02pm UTC](https://discourse.slicer.org/t/changing-size-and-color-of-individual-interaction-handles-of-roi/26360/7 "2022-11-24T12:02:27Z")

</div>

Ah OK, so it’s about ROIs. It is different from what I was investigating. FYI this is what interaction handle means without the special context you just mentioned:

![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/5/b/5bfc91ac3a504a1629dbd0b2b46da35157401c4c.png)

The code is quite similar for ROIs though:

> <https://github.com/Slicer/Slicer/blob/3c592df27e3dccedbd8fcddf05979f59af484f2c/Modules/Loadable/Markups/VTKWidgets/vtkSlicerROIRepresentation3D.cxx#L532-L552>

I think customizing the color could be solved by adding members for the interaction handle colors to the markup display node (initialized with the hard-coded colors), and using these members in the two functions I have linked about colors. Note that in ROIs you have not three but six interaction colors, so this would need to be handled somehow if you want the left-right colors to be different (note the same red color setting for `L` and `R`). Maybe we could have `X`, `Y`, and `Z` interaction handle color getter/setters, with optional `AlternateX` or something similar for the inverse directions in the ROIs. @lassoan what do you think?

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [November 25, 2022, 5:41am UTC](https://discourse.slicer.org/t/changing-size-and-color-of-individual-interaction-handles-of-roi/26360/8 "2022-11-25T05:41:28Z")

</div>

ROI can be rotated, so there is no strict relationship between world coordinate system axis and ROI axis directions.

That said, the colors could be made customizable. If it is acceptable to provide only a low-level API (expose the color on the ROI representation class) then it is a very simple and small change. If we want to store it in MRML then it is a bigger change and I’m not sure if it is worth it (if it is an important use case or many users will ask for it then it is probaly worth the trouble implementing it).
