[vtkusers] Exception when using vtkOrientationMarkerWidget in a vtkMFCWindow

Todd Martin nztoddler at yahoo.com
Tue Mar 20 21:02:35 EDT 2018


 Hi Jesse
No problem. I made a similar mistake using c# wrappers.Here's the MR. Looking at the gitlab site, it is not obvious to me whether it got in before the 8.1 release or not, but it is definitely in the master branch.
Remove OrientationMarkerWidget from render window on destruction (!3546) · Merge Requests · VTK / VTK


| 
| 
| 
|  |  |

 |

 |
| 
|  | 
Remove OrientationMarkerWidget from render window on destruction (!3546)...

The orientation marker widget adds its own visual elements and an observer to the display window and also hooks ...
 |

 |

 |


    On Wednesday, March 21, 2018, 12:41:22 PM GMT+13, Jesse Kinross-Smith <Jesse.Kinross-Smith at bentley.com> wrote:  
 
 
Well I’m a dunce then aren’t I (I’m blaming this cold I have!).
 
  

 
Yep – works great when in a local variable.
 
Definitely interested in that patch you’ve made too. 
 
  
 
Thank you very much!
 
  
 
Jesse
 
--
 
Jesse Kinross-Smith
 
Senior Software Engineer - BSW
 
Bentley Systems, Fremantle
 
  
 
From: Todd [mailto:nztoddler at yahoo.com] 
Sent: Wednesday, 21 March 2018 5:44 AM
To: Jesse Kinross-Smith <Jesse.Kinross-Smith at bentley.com>
Cc: vtkusers at vtk.org
Subject: Re: [vtkusers] Exception when using vtkOrientationMarkerWidget in a vtkMFCWindow
 
  
 
What version of VTK are you using?
 
  
 
You're using a local variable for the marker widget with a smart pointer. As soon as it goes out of scope, it will be destroyed. 
 
  
 
To make matters worse the marker widget does not properly unhook itself from render window events upon destruction, so you get these nasty callbacks to a dead object. However I pushed a patch for this which was merged, as I recall, just after the official release of VTK8.1. I'll see if I can find the merge request number.
 
  
 
I would suggest creating a class member to hold onto the marker widget until you're finished with the render window; i.e. keep it alive.
 
  
 
On 21 Mar 2018 3:33 a.m., Jesse Kinross-Smith <Jesse.Kinross-Smith at bentley.com> wrote:
 

Long shot, but wondering if anyone has any clue here.
 
I’ve got a whole lot of rendering working nicely in a vtkMFCWindow and thought I’d try adding an orientation widget to show axes.
 
 
 
I found some sample code which does this with a vtkOrientationMarkerWidget, but I tried it with our vtkMFCWindow and it’s causing an exception almost straight away.
 
 
 
This is the code I’m using, which is almost identical to the sample code at:
 
  https://www.vtk.org/Wiki/VTK/Examples/Cxx/Visualization/DisplayCoordinateAxes
 
 
 
vtkSmartPointer<vtkAxesActor> axes = vtkSmartPointer<vtkAxesActor>::New();
 
vtkSmartPointer<vtkOrientationMarkerWidget> widget = vtkSmartPointer<vtkOrientationMarkerWidget>::New();
 
widget->SetOutlineColor(0.9300, 0.5700, 0.1300);
 
widget->SetOrientationMarker(axes);
 
widget->SetCurrentRenderer(m_vtkRenderer);
 
widget->SetInteractor(m_vtkRenderer->GetRenderWindow()->GetInteractor());
 
widget->SetViewport(0.0, 0.0, 0.4, 0.4);
 
widget->SetEnabled(1);
 
widget->InteractiveOn();
 
 
 
It actually displays both the model and the orientation axes briefly, then displays the following exception:
 
  0xC000041D: An unhandled exception was encountered during a user callback.
 
 
 
Call Stack:
 
> vtkMFCWindow::OnPaint() Line 169     C++
 
CWnd::OnWndMsg(unsigned int message, unsigned __int64 wParam, __int64 lParam, __int64 * pResult) Line 2459        C++
 
CWnd::WindowProc(unsigned int message, unsigned __int64 wParam, __int64 lParam) Line 2093      C++
 
AfxCallWndProc(CWnd * pWnd, HWND__ * hWnd, unsigned int nMsg, unsigned __int64 wParam, __int64 lParam) Line 265           C++
 
AfxWndProc(HWND__ * hWnd, unsigned int nMsg, unsigned __int64 wParam, __int64 lParam) Line 418              C++
 
 
 
Anyone got any ideas?
 
 
 
--
 
Jesse Kinross-Smith
 
Senior Software Engineer - BSW
 
Bentley Systems, Fremantle
 
 
 

  
   
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://vtk.org/pipermail/vtkusers/attachments/20180321/48b053b1/attachment.html>


More information about the vtkusers mailing list