# Change axis labels of slice view and 3D view

**URL:** <https://discourse.slicer.org/t/change-axis-labels-of-slice-view-and-3d-view/19608>\
**Category:** Development\
**Created:** [September 10, 2021, 3:15pm UTC](https://discourse.slicer.org/t/change-axis-labels-of-slice-view-and-3d-view/19608 "2021-09-10T15:15:08Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![keri](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/keri/32/11618_2.png) [@keri](https://discourse.slicer.org/u/keri)\
**Post date:** [September 10, 2021, 3:15pm UTC](https://discourse.slicer.org/t/change-axis-labels-of-slice-view-and-3d-view/19608/1 "2021-09-10T15:15:08Z")

</div>

Hi,

I’m trying to rename axis labels from medical `I, P, A etc ` to `XYZ`. I’ve tried to do that in `qMyAppMainWindow`:

```cpp
  std::vector<std::string> axesNames({"-X", "X", "-Y", "Y", "-Z", "Z"});

  for (int j = 0; j < this->LayoutManager->threeDViewCount(); j++)
    for (int i = 0; i < axesNames.size(); i++)
      this->LayoutManager->threeDWidget(j)->mrmlViewNode()->SetAxisLabel(
          i, axesNames[i].c_str());

  for (const QString& sliceViewName : this->LayoutManager->sliceViewNames())
    for (int i = 0; i < axesNames.size(); i++)
      this->LayoutManager->sliceWidget(sliceViewName)
          ->mrmlSliceNode()
          ->SetAxisLabel(i, axesNames[i].c_str());

```

and in my custom module but apparently after I have set labels some other module reset it to default values by calling `vtkMRMLAbstractViewNode::CopyContent()`

I think I need to make a decision either to put the code above to `vtkSlicerModuleLogic::OnMRMLSceneNodeAdded(...)` of my module or to control the module loading order (though I don’t know how to do that yet).

In `vtkSlicerModuleLogic::OnMRMLSceneNodeAdded(vtkMRMLNode* node)` I process the newly added `node` and if it is a slice or 3D view then I change its labels. But I think that changing labels of already existind nodes every time new node is added is not the best way.

Probably someone has a better solution?

---

<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:** [September 10, 2021, 11:57pm UTC](https://discourse.slicer.org/t/change-axis-labels-of-slice-view-and-3d-view/19608/2 "2021-09-10T23:57:41Z")

</div>

Probably you also need to change the axes names in the default view node, similarly to how it is done [here](https://slicer.readthedocs.io/en/latest/developer_guide/script_repository.html#change-default-slice-view-orientation).

---

<div class="post-metadata">

**Author:** ![keri](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/keri/32/11618_2.png) [@keri](https://discourse.slicer.org/u/keri)\
**Post date:** [September 11, 2021, 1:05am UTC](https://discourse.slicer.org/t/change-axis-labels-of-slice-view-and-3d-view/19608/3 "2021-09-11T01:05:44Z")

</div>

Thank you for the useful info!

---

<div class="post-metadata">

**Author:** ![keri](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/keri/32/11618_2.png) [@keri](https://discourse.slicer.org/u/keri)\
**Post date:** [September 11, 2021, 1:37am UTC](https://discourse.slicer.org/t/change-axis-labels-of-slice-view-and-3d-view/19608/4 "2021-09-11T01:37:01Z")

</div>

I have found that disabling `DataProbe` module (` --disable-modules DataProbe`) solves my problem with resetting axes labels.

@lassoan in the link you gave there is a comment:  
**# Replace orientation presets in all existing slice nodes and in the default slice node**

It is the second time I encounter **default node** and I can’t understand what it is and what it is aimed to? Especially why **default** nodes are some kind of a separate nodes as in the example we append them to the list:

```python
sliceNodes = slicer.util.getNodesByClass("vtkMRMLSliceNode")
sliceNodes.append(slicer.mrmlScene.GetDefaultNodeByClass("vtkMRMLSliceNode"))

```

Thus `slicer.util.getNodesByClass("vtkMRMLSliceNode")` doesn’t include defaul nodes…

---

<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:** [September 11, 2021, 1:53am UTC](https://discourse.slicer.org/t/change-axis-labels-of-slice-view-and-3d-view/19608/5 "2021-09-11T01:53:45Z")

</div>

The MRML scene can store an instance of each MRML class, the _default node_. When you create a new node or reset a node then the default node will be used to set its properties. See some more information in the [API documentation](http://apidocs.slicer.org/master/classvtkMRMLScene.html#ae302c5ed4aabb2910bc35dcc9aa2513f).

---

<div class="post-metadata">

**Author:** ![keri](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/keri/32/11618_2.png) [@keri](https://discourse.slicer.org/u/keri)\
**Post date:** [September 11, 2021, 2:05am UTC](https://discourse.slicer.org/t/change-axis-labels-of-slice-view-and-3d-view/19608/6 "2021-09-11T02:05:33Z")

</div>

As I understood the default node serves as some kind of a template and the scene may create new nodes of that class with the properties set from that template?

One more thing:  
let’s suppose that slicer was launched with the dault layout (single 3D view and three slices). Will that default `vtkMRMLSliceNode` be one of that three slices or it will be the forth slice node and it is hidden?

---

<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:** [September 11, 2021, 3:24am UTC](https://discourse.slicer.org/t/change-axis-labels-of-slice-view-and-3d-view/19608/7 "2021-09-11T03:24:52Z")

</div>

The default slice node is used to initialize all slice nodes. The values are also used when the nodes are reset (e.g., when the scene is closed).
