# Set and observe transform node to markups curve node: bug or feature?

**URL:** https://discourse.slicer.org/t/set-and-observe-transform-node-to-markups-curve-node-bug-or-feature/11599
**Category:** Support
**Tags:** transforms, markups
**Created:** [May 18, 2020, 11:31am UTC](https://discourse.slicer.org/t/set-and-observe-transform-node-to-markups-curve-node-bug-or-feature/11599 "2020-05-18T11:31:11Z")
**Posts on this page:** 15
**Page:** 1

<div class="post-metadata">

### Author: ![Mik](https://avatars.discourse-cdn.com/v4/letter/m/958977/32.png) [@Mik](https://discourse.slicer.org/u/Mik)
#### Post date: [May 18, 2020, 11:31am UTC](https://discourse.slicer.org/t/set-and-observe-transform-node-to-markups-curve-node-bug-or-feature/11599/1 "2020-05-18T11:31:11Z")

</div>

Greeting,

Transformation of vtkMRMLMarkupsClosedCurveNode looks like a little bit buggy. Points of the curve are transformed correctly, but not the curve itself.

There is no such problem with markups line node, where both line and points are transformed correctly.

Code `closedCurveNode->SetAndObserveTransformNodeID(transformNode->GetID());`

gives such results

 ![Screenshot_Markups1](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/7/2/7240caca3e2318ead746fe1294674800dd672a49.png)

 ![Screenshot_Markups2](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/a/f/af38361d09fe1970807ae575f5256e0c1ea1bdb6.png)

---

<div class="post-metadata">

### Author: ![Sunderlandkyl](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/sunderlandkyl/32/79987_2.png) [@Sunderlandkyl](https://discourse.slicer.org/u/Sunderlandkyl)
#### Post date: [May 18, 2020, 3:11pm UTC](https://discourse.slicer.org/t/set-and-observe-transform-node-to-markups-curve-node-bug-or-feature/11599/2 "2020-05-18T15:11:54Z")

</div>

Thanks for reporting this, I’ll take a look at it.

---

<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: [May 18, 2020, 5:12pm UTC](https://discourse.slicer.org/t/set-and-observe-transform-node-to-markups-curve-node-bug-or-feature/11599/3 "2020-05-18T17:12:04Z")

</div>

@mik Can you reproduce the problem with the latest Slicer Preview Release?

---

<div class="post-metadata">

### Author: ![Mik](https://avatars.discourse-cdn.com/v4/letter/m/958977/32.png) [@Mik](https://discourse.slicer.org/u/Mik)
#### Post date: [May 18, 2020, 7:54pm UTC](https://discourse.slicer.org/t/set-and-observe-transform-node-to-markups-curve-node-bug-or-feature/11599/4 "2020-05-18T19:54:01Z")

</div>

Build from the source, the problem remains.

Slicer 4.11.0-2020-05-14 r29057 / 0bc7cb1

curve node without transformation

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/d/2/d274fcf01af6ec73c270caf961186a35ad4eb097.png)

curve node with transformation (points and curve are separated)

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

---

<div class="post-metadata">

### Author: ![Sunderlandkyl](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/sunderlandkyl/32/79987_2.png) [@Sunderlandkyl](https://discourse.slicer.org/u/Sunderlandkyl)
#### Post date: [May 20, 2020, 2:19pm UTC](https://discourse.slicer.org/t/set-and-observe-transform-node-to-markups-curve-node-bug-or-feature/11599/5 "2020-05-20T14:19:27Z")

</div>

I’ve made a fix, could you try the latest version of Slicer?

---

<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: [May 20, 2020, 3:18pm UTC](https://discourse.slicer.org/t/set-and-observe-transform-node-to-markups-curve-node-bug-or-feature/11599/6 "2020-05-20T15:18:01Z")

</div>

The fix will be included in Slicer Preview Release that you download tomorrow or later.

---

<div class="post-metadata">

### Author: ![Mik](https://avatars.discourse-cdn.com/v4/letter/m/958977/32.png) [@Mik](https://discourse.slicer.org/u/Mik)
#### Post date: [May 20, 2020, 8:05pm UTC](https://discourse.slicer.org/t/set-and-observe-transform-node-to-markups-curve-node-bug-or-feature/11599/7 "2020-05-20T20:05:41Z")

</div>

Thank you, the major problem has been fixed.

I have one more minor issue with markups node. How to update markups data in loadable module correctly?

I have markups node with four points (rectangle). When i update markups control point position [the code](https://github.com/MichaelColonel/SlicerRT/blob/drr/PlmDrr/Logic/vtkSlicerPlmDrrLogic.cxx#L246-#L290) the point change it position, but not the curve.

The have found the solution by removing node and creating it with a new positions.

---

<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: [May 20, 2020, 8:33pm UTC](https://discourse.slicer.org/t/set-and-observe-transform-node-to-markups-curve-node-bug-or-feature/11599/8 "2020-05-20T20:33:22Z")

</div>

Can you send a link to the code lines where you set the control point positions?

---

<div class="post-metadata">

### Author: ![Mik](https://avatars.discourse-cdn.com/v4/letter/m/958977/32.png) [@Mik](https://discourse.slicer.org/u/Mik)
#### Post date: [May 21, 2020, 5:23am UTC](https://discourse.slicer.org/t/set-and-observe-transform-node-to-markups-curve-node-bug-or-feature/11599/9 "2020-05-21T05:23:03Z")

</div>

Here is a [method](https://github.com/MichaelColonel/SlicerRT/blob/drr/PlmDrr/Logic/vtkSlicerPlmDrrLogic.cxx#L435-#L486), which creates a curve node, other curve nodes use the same technique.

---

<div class="post-metadata">

### Author: ![Sunderlandkyl](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/sunderlandkyl/32/79987_2.png) [@Sunderlandkyl](https://discourse.slicer.org/u/Sunderlandkyl)
#### Post date: [May 21, 2020, 2:32pm UTC](https://discourse.slicer.org/t/set-and-observe-transform-node-to-markups-curve-node-bug-or-feature/11599/10 "2020-05-21T14:32:37Z")

</div>

I made the following snippet based on the code from the CreateImagerBoundary function, but it doesn’t seem to cause the issue:

```auto
c = slicer.vtkMRMLMarkupsClosedCurveNode()
slicer.mrmlScene.AddNode(c)
c.SetCurveTypeToLinear()
c.SetHideFromEditors(1)
c.AddControlPoint(vtk.vtkVector3d(0.0, 0.0, 0.0))
c.AddControlPoint(vtk.vtkVector3d(1.0, 0.0, 0.0))
c.AddControlPoint(vtk.vtkVector3d(1.0, 1.0, 0.0))
c.AddControlPoint(vtk.vtkVector3d(0.0, 1.0, 0.0))

```

---

<div class="post-metadata">

### Author: ![Mik](https://avatars.discourse-cdn.com/v4/letter/m/958977/32.png) [@Mik](https://discourse.slicer.org/u/Mik)
#### Post date: [May 21, 2020, 3:47pm UTC](https://discourse.slicer.org/t/set-and-observe-transform-node-to-markups-curve-node-bug-or-feature/11599/11 "2020-05-21T15:47:24Z")

</div>

What would happen if you modify a z coordinate of each point and try to update a curve node? Will the curve change it position as well, not just control points?

Static curve is not a problem anymore, thanks to your fix, but in GUI i have a slider which change z coordinates of the curve and only control points move.

---

<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: [May 24, 2020, 2:46pm UTC](https://discourse.slicer.org/t/set-and-observe-transform-node-to-markups-curve-node-bug-or-feature/11599/12 "2020-05-24T14:46:16Z")

</div>

Updating a control point position updates the curve correctly. For example, this code updates first point of curve “C” correctly (point and curve are both updated):

```python
c = getNode('C')
p = [0,0,0]
c.GetNthControlPointPosition(0, p)
p[2] = p[2] + 10
c.SetNthControlPointPosition(0, *p)

```

---

<div class="post-metadata">

### Author: ![Mik](https://avatars.discourse-cdn.com/v4/letter/m/958977/32.png) [@Mik](https://discourse.slicer.org/u/Mik)
#### Post date: [May 25, 2020, 2:52pm UTC](https://discourse.slicer.org/t/set-and-observe-transform-node-to-markups-curve-node-bug-or-feature/11599/13 "2020-05-25T14:52:31Z")

</div>

Thank you!

After some trials and errors, i have found the code

`double p[3];`  
`imagerMarkupsNode->GetNthControlPointPosition( 0, p);`  
`p[2] = value`  
`imagerMarkupsNode->Modified()`

didn’t work, but code

`double p[3];`  
`imagerMarkupsNode->GetNthControlPointPosition( 0, p);`  
`p[2] = value`  
`imagerMarkupsNode->SetNthControlPointPosition( 0, p[0], p[1], p[2]);`

works as it should.

The topic is closed.

---

<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: [May 25, 2020, 2:56pm UTC](https://discourse.slicer.org/t/set-and-observe-transform-node-to-markups-curve-node-bug-or-feature/11599/14 "2020-05-25T14:56:26Z")

</div>

> [@Mik](#):
>
> `double p[3];`  
> `imagerMarkupsNode->GetNthControlPointPosition( 0, p);`  
> `p[2] = value`  
> `imagerMarkupsNode->Modified()`

Would you recommend to make any changes to the documentation to clarify that no permanent synchronization mechanism is created between the input Python array and a markups node when you call GetNthControlPointPosition?

---

<div class="post-metadata">

### Author: ![Mik](https://avatars.discourse-cdn.com/v4/letter/m/958977/32.png) [@Mik](https://discourse.slicer.org/u/Mik)
#### Post date: [May 26, 2020, 4:09pm UTC](https://discourse.slicer.org/t/set-and-observe-transform-node-to-markups-curve-node-bug-or-feature/11599/15 "2020-05-26T16:09:20Z")

</div>

It will good to have a some kind of warning about such feature, and something like:

Warning: In order to update position of markups as well as a curve, one always must use `SetNthControlPointPosition` method.
