# Way to create permanent slice intersection

**URL:** <https://discourse.slicer.org/t/way-to-create-permanent-slice-intersection/13284>\
**Category:** Development\
**Created:** [September 1, 2020, 9:02pm UTC](https://discourse.slicer.org/t/way-to-create-permanent-slice-intersection/13284 "2020-09-01T21:02:58Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jakew](https://avatars.discourse-cdn.com/v4/letter/j/4af34b/32.png) [@Jakew](https://discourse.slicer.org/u/Jakew)\
**Post date:** [September 1, 2020, 9:02pm UTC](https://discourse.slicer.org/t/way-to-create-permanent-slice-intersection/13284/1 "2020-09-01T21:02:59Z")

</div>

when slice intersection is enabled, the user can see a line that indicates where the slice they are currently viewing is relative to the other views. I was wondering if there was a way to create a static line for a certain slice (i.e. create a line in the sagittal and coronal views indicating where the a specific axial slice is located, so it doesn’t change no matter what slice is currently in the axial view).

---

<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 1, 2020, 11:20pm UTC](https://discourse.slicer.org/t/way-to-create-permanent-slice-intersection/13284/2 "2020-09-01T23:20:07Z")

</div>

You can create a markups plane node (or a model node with a plane in it) at the desired position and enable 2D display to show its intersection line in slice views.

There are many other ways to do this, depending on what you would like to achieve. Can you write a bit more about your application?

---

<div class="post-metadata">

**Author:** ![Jakew](https://avatars.discourse-cdn.com/v4/letter/j/4af34b/32.png) [@Jakew](https://discourse.slicer.org/u/Jakew)\
**Post date:** [September 1, 2020, 11:26pm UTC](https://discourse.slicer.org/t/way-to-create-permanent-slice-intersection/13284/3 "2020-09-01T23:26:54Z")

</div>

This goal of this feature is basically so if the user has an axial and sagittal view open, the user can click a button with a specific slice open on the axial view and it would be “marked” on the sagittal view, i.e. if the user scrolls away from the that slice, they can tell exactly where the marked scan is by scrolling back to that line in the sagittal view.

---

<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 1, 2020, 11:35pm UTC](https://discourse.slicer.org/t/way-to-create-permanent-slice-intersection/13284/4 "2020-09-01T23:35:02Z")

</div>

To mark a point, you can also use markup fiducial points. It not just remembers a slice but a 3D position. You can jumpy to slice by clicking on the fiducial in the control point list (in Markups module) or in any views (you need to enable 2D projection to make the point show up in all slices).

Alternatively, you can choose view layouts with a couple of extra views (if you want to keep showing the reference planes to the user).

---

<div class="post-metadata">

**Author:** ![Jakew](https://avatars.discourse-cdn.com/v4/letter/j/4af34b/32.png) [@Jakew](https://discourse.slicer.org/u/Jakew)\
**Post date:** [September 2, 2020, 9:39pm UTC](https://discourse.slicer.org/t/way-to-create-permanent-slice-intersection/13284/5 "2020-09-02T21:39:12Z")

</div>

Is it possible to call functions in the vtkSlicerMarkupsLogic and vtkMRMLMarkupsLineNode classes in a different module? I’m not sure if my implementation is incorrect or something else is going wrong.

---

<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 2, 2020, 10:53pm UTC](https://discourse.slicer.org/t/way-to-create-permanent-slice-intersection/13284/6 "2020-09-02T22:53:55Z")

</div>

Yes, you can call methods of MRML nodes and module logic classes from any modules. If you write us the error messages that you get then we can tell what is missing.

---

<div class="post-metadata">

**Author:** ![Jakew](https://avatars.discourse-cdn.com/v4/letter/j/4af34b/32.png) [@Jakew](https://discourse.slicer.org/u/Jakew)\
**Post date:** [September 2, 2020, 11:04pm UTC](https://discourse.slicer.org/t/way-to-create-permanent-slice-intersection/13284/7 "2020-09-02T23:04:33Z")

</div>

Right now my issue is that despite including the vtkSlicerMarkupsLogic.h file in an #include line, I’m getting an “undefined reference to [function]” error whenever I try to use any of the functions in the class.

---

<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 3, 2020, 12:03am UTC](https://discourse.slicer.org/t/way-to-create-permanent-slice-intersection/13284/8 "2020-09-03T00:03:56Z")

</div>

Please provide the entire error message.

---

<div class="post-metadata">

**Author:** ![Jakew](https://avatars.discourse-cdn.com/v4/letter/j/4af34b/32.png) [@Jakew](https://discourse.slicer.org/u/Jakew)\
**Post date:** [September 3, 2020, 12:26am UTC](https://discourse.slicer.org/t/way-to-create-permanent-slice-intersection/13284/9 "2020-09-03T00:26:14Z")

</div>

This is what I’ve done:

```
vtkSlicerMarkupsLogic* markupLogic = vtkSlicerMarkupsLogic::SafeDownCast(qSlicerApplication::application()->applicationLogic());
vtkMRMLNode *markupsNode = qSlicerApplication::application()->mrmlScene()->AddNewNodeByClass("vtkMRMLMarkupsLineNode");
markupLogic->AddNewDisplayNodeForMarkupsNode(markupsNode);

```

The error I got was: “undefined reference to `vtkSlicerMarkupsLogic::AddNewDisplayNodeForMarkupsNode [abi:cxx11] (vtkMRMLNode\*) '”

---

<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 3, 2020, 2:40am UTC](https://discourse.slicer.org/t/way-to-create-permanent-slice-intersection/13284/10 "2020-09-03T02:40:01Z")

</div>

Adding `#include "vtkSlicerMarkupsLogic.h"` fixes undefined reference to `vtkSlicerMarkupsLogic::AddNewDisplayNodeForMarkupsNode`. If not, then most likely your compiler threw an error before that it could not find `vtkSlicerMarkupsLogic.h`. You always need to fix the very first error the compiler reports because subsequent errors may be result of previous ones.

There are several examples of using markups from C++ modules, for example in [SlicerIGT extension](https://github.com/SlicerIGT/SlicerIGT/).

---

<div class="post-metadata">

**Author:** ![Jakew](https://avatars.discourse-cdn.com/v4/letter/j/4af34b/32.png) [@Jakew](https://discourse.slicer.org/u/Jakew)\
**Post date:** [September 3, 2020, 5:08pm UTC](https://discourse.slicer.org/t/way-to-create-permanent-slice-intersection/13284/11 "2020-09-03T17:08:20Z")

</div>

That’s the strange part, I have the #include line and this error is the only error the compiler throws. I’ll keep investigating then, thanks!

---

<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 3, 2020, 5:52pm UTC](https://discourse.slicer.org/t/way-to-create-permanent-slice-intersection/13284/12 "2020-09-03T17:52:09Z")

</div>

If you send a link to your source code repository then I can take a look.

---

<div class="post-metadata">

**Author:** ![Suhaim](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/suhaim/32/81421_2.png) [@Suhaim](https://discourse.slicer.org/u/Suhaim)\
**Post date:** [July 16, 2025, 6:08am UTC](https://discourse.slicer.org/t/way-to-create-permanent-slice-intersection/13284/13 "2025-07-16T06:08:33Z")

</div>

Hi @Jakew , were you able to solve this issue?

---

<div class="post-metadata">

**Author:** ![Suhaim](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/suhaim/32/81421_2.png) [@Suhaim](https://discourse.slicer.org/u/Suhaim)\
**Post date:** [July 16, 2025, 7:04am UTC](https://discourse.slicer.org/t/way-to-create-permanent-slice-intersection/13284/14 "2025-07-16T07:04:40Z")

</div>

For me the error arised in the linking stage, the linker was not able to find the source code even though compilation worked due to the headers being found. I modified the CMakeLists.txt of the component that was looking for the logic component of the module in use(Markups in your case).

My module’s logic component needed vtkSlicerReformatModuleLogic, so adding it to the components to be linked(TARGET\_LIBRARIES) worked. Hope this helps, thanks!

```auto
project(vtkSlicer${MODULE_NAME}ModuleLogic)

set(KIT ${PROJECT_NAME})

set(${KIT}_EXPORT_DIRECTIVE "VTK_SLICER_${MODULE_NAME_UPPER}_MODULE_LOGIC_EXPORT")

set(${KIT}_INCLUDE_DIRECTORIES
  )

set(${KIT}_SRCS
  vtkSlicer${MODULE_NAME}Logic.cxx
  vtkSlicer${MODULE_NAME}Logic.h
  )

set(${KIT}_TARGET_LIBRARIES
  ${ITK_LIBRARIES}
  vtkSlicerReformatModuleLogic
)

#-----------------------------------------------------------------------------
SlicerMacroBuildModuleLogic(
  NAME ${KIT}
  EXPORT_DIRECTIVE ${${KIT}_EXPORT_DIRECTIVE}
  INCLUDE_DIRECTORIES ${${KIT}_INCLUDE_DIRECTORIES}
  SRCS ${${KIT}_SRCS}
  TARGET_LIBRARIES ${${KIT}_TARGET_LIBRARIES}
  )

```
