# Trigger rendering on Modified

**URL:** <https://discourse.slicer.org/t/trigger-rendering-on-modified/1598>\
**Category:** Development\
**Created:** [December 5, 2017, 7:09pm UTC](https://discourse.slicer.org/t/trigger-rendering-on-modified/1598 "2017-12-05T19:09:35Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![thaenel](https://avatars.discourse-cdn.com/v4/letter/t/9fc348/32.png) [@thaenel](https://discourse.slicer.org/u/thaenel)\
**Post date:** [December 5, 2017, 7:09pm UTC](https://discourse.slicer.org/t/trigger-rendering-on-modified/1598/1 "2017-12-05T19:09:35Z")

</div>

Hello everyone,

I’m currently developing a module that streams 2D images based on custom OpenIGTLink messages. The streaming works good, concurrency is no issue (I use `vtkSlicerApplicationLogic::RequestModified` from the receiving thread), images are received and the module clones their content continously into the `vtkImageData` of a `vtkMRMLVectorVolumeNode`. This `vtkImageData` object was initialy added with `vtkMRMLVolumeNode::SetAndObserveImageData`. After each cloning operation `vtkObject::Modified()` is called on the `vtkImageData` object.  
Here is the problem: the views are only updated/rerenderd when I interact with them.

What do I need to do (besides the `Modified()` call on the `vtkImageData` of the `vtkMRMLVectorVolumeNode`), that all views are updated/rerendered based on the current state of the MRML scene (including the modified node)?

Thanks in advance

---

<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:** [December 5, 2017, 8:45pm UTC](https://discourse.slicer.org/t/trigger-rendering-on-modified/1598/2 "2017-12-05T20:45:46Z")

</div>

What was the reason you had to reimplement receiving of images through OpenIGTLink? OpenIGTLinkIF module was developed exactly for this purpose.

Image update works well if you use OpenIGTLinkIF by doing this:

> <https://github.com/openigtlink/OpenIGTLinkIF/blob/98019cf0cac06b3e15eb43a6b2b99428295504e7/MRML/vtkIGTLToMRMLImage.cxx#L562-L565>

You may attach a debugger and see better what exact series of steps are performed there.

---

<div class="post-metadata">

**Author:** ![thaenel](https://avatars.discourse-cdn.com/v4/letter/t/9fc348/32.png) [@thaenel](https://discourse.slicer.org/u/thaenel)\
**Post date:** [December 5, 2017, 10:15pm UTC](https://discourse.slicer.org/t/trigger-rendering-on-modified/1598/3 "2017-12-05T22:15:04Z")

</div>

I thought that you would mention OpenIGTLinkIF. Unfortunately I’m bound to a non-standard extension of the Protocol (an extension of the IMAGE Message). That’s why had to implement the streaming by myself.

Adding the Modified Call() to the volume node did the trick. I thought this was done automatically as the class has a custom `ImageDataModifiedEvent`. Thanks for the quick and helpful response 👍

---

<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:** [December 5, 2017, 11:07pm UTC](https://discourse.slicer.org/t/trigger-rendering-on-modified/1598/4 "2017-12-05T23:07:42Z")

</div>

For future reference, OpenIGTLinkIF was designed to be extensible. To add support for a new OpenIGTLink node or message type, tou just need to create a simple converter class in your module and register it using a single method call. Small amount of code also means smaller maintenance and bugfixing efforts and you also get new features for free, such as OpenIGTLink 3 compatibility, image compression (available soon), etc. OpenIGTLink3 allows attaching arbitrary metadata (as key:value pairs) to messages, so you need custom messages less often.

---

<div class="post-metadata">

**Author:** ![thaenel](https://avatars.discourse-cdn.com/v4/letter/t/9fc348/32.png) [@thaenel](https://discourse.slicer.org/u/thaenel)\
**Post date:** [December 6, 2017, 2:05pm UTC](https://discourse.slicer.org/t/trigger-rendering-on-modified/1598/5 "2017-12-06T14:05:03Z")

</div>

I didn’t know OpenIGTLinkIF was that extensible. Now that I think about it, it is somehow related to VTK. Of course it is extensible 😁 …

I implemeted my own Converter and added a dependecy to OpenIGTLinkIF and the work I did before in 5 days was done in 2 hours (and most likely better done).

---

<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:** [December 6, 2017, 2:38pm UTC](https://discourse.slicer.org/t/trigger-rendering-on-modified/1598/6 "2017-12-06T14:38:40Z")

</div>

> I implemeted my own Converter and added a dependecy to OpenIGTLinkIF and the work I did before in 5 days was done in 2 hours (and most likely better done)

Nice work!

Can you share with us what your project is about?

---

<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:** [December 7, 2017, 3:35pm UTC](https://discourse.slicer.org/t/trigger-rendering-on-modified/1598/7 "2017-12-07T15:35:19Z")

</div>

A post was split to a new topic: [Showing real-time thermography images as overlay](https://discourse.slicer.org/t/showing-real-time-thermography-images-as-overlay/1610)
