# How to output the image to slicer view?

**URL:** https://discourse.slicer.org/t/how-to-output-the-image-to-slicer-view/11517
**Category:** Development
**Created:** [May 13, 2020, 10:51am UTC](https://discourse.slicer.org/t/how-to-output-the-image-to-slicer-view/11517 "2020-05-13T10:51:19Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![sunshine\_boycn](https://avatars.discourse-cdn.com/v4/letter/s/ed8c4c/32.png) [@sunshine\_boycn](https://discourse.slicer.org/u/sunshine_boycn)
#### Post date: [May 13, 2020, 10:51am UTC](https://discourse.slicer.org/t/how-to-output-the-image-to-slicer-view/11517/1 "2020-05-13T10:51:19Z")

</div>

Dear everybody:

I am following the tutorials on “Programming in Slicer4” implementing the demo “Implemen:ng the  
Laplace\* Operator”. Everything is fine. The problems come out when I tried to modify the program using C++. Currently I have difficulties in converting the following lines into C++. I can’t find the corresponding class and method in C++.

```
# make the output volume appear in all the slice views
slicer.util.setSliceViewerLayers(background=self.outputSelector.currentNode())

```

Would any body help me out?

Thankyou very much

---

<div class="post-metadata">

### Author: ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)
#### Post date: [May 13, 2020, 12:48pm UTC](https://discourse.slicer.org/t/how-to-output-the-image-to-slicer-view/11517/2 "2020-05-13T12:48:50Z")

</div>

Hi - In general it can help to use the `git grep` command in the source directory to search for the definition and uses of methods. Or you can search the repository at the github page.

In this case, the method is define here:

> <https://github.com/Slicer/Slicer/blob/master/Base/Python/slicer/util.py#L336-L377>

---

<div class="post-metadata">

### Author: ![sunshine\_boycn](https://avatars.discourse-cdn.com/v4/letter/s/ed8c4c/32.png) [@sunshine\_boycn](https://discourse.slicer.org/u/sunshine_boycn)
#### Post date: [May 13, 2020, 1:20pm UTC](https://discourse.slicer.org/t/how-to-output-the-image-to-slicer-view/11517/3 "2020-05-13T13:20:26Z")

</div>

> [@pieper](#):
>
> setSliceViewerLayers

Thank you very much!

I have solve this problem and have my C++ version of this “Implementing the Laplace\* Operator” demo. 🙂

You have introduced a good way of using “git grep”. That’s nice. Before your recommendation, I have tried to use grep in Ubuntu and “findstr” in Windows. I failed to get the correct answer because I searched in a wrong directory. I thought the function “setSliceViewerLayers” was a member function of some MRML classes.

Thank you. And I think it would be better to have the c++ version of this tutorial later on.
