<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Consolas;
panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
p.msonormal0, li.msonormal0, div.msonormal0
{mso-style-name:msonormal;
mso-margin-top-alt:auto;
margin-right:0cm;
mso-margin-bottom-alt:auto;
margin-left:0cm;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
span.EmailStyle20
{mso-style-type:personal-reply;
font-family:"Calibri",sans-serif;
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri",sans-serif;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal">Well I’m a dunce then aren’t I (I’m blaming this cold I have!).<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Yep – works great when in a local variable.<o:p></o:p></p>
<p class="MsoNormal">Definitely interested in that patch you’ve made too. <o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Thank you very much!<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Jesse<o:p></o:p></p>
<p class="MsoNormal">--<o:p></o:p></p>
<p class="MsoNormal">Jesse Kinross-Smith<o:p></o:p></p>
<p class="MsoNormal">Senior Software Engineer - BSW<o:p></o:p></p>
<p class="MsoNormal">Bentley Systems, Fremantle<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><b>From:</b> Todd [mailto:nztoddler@yahoo.com] <br>
<b>Sent:</b> Wednesday, 21 March 2018 5:44 AM<br>
<b>To:</b> Jesse Kinross-Smith <Jesse.Kinross-Smith@bentley.com><br>
<b>Cc:</b> vtkusers@vtk.org<br>
<b>Subject:</b> Re: [vtkusers] Exception when using vtkOrientationMarkerWidget in a vtkMFCWindow<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<p class="MsoNormal">What version of VTK are you using?<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">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. <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">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.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">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.<o:p></o:p></p>
</div>
<div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal">On 21 Mar 2018 3:33 a.m., Jesse Kinross-Smith <<a href="mailto:Jesse.Kinross-Smith@bentley.com">Jesse.Kinross-Smith@bentley.com</a>> wrote:<o:p></o:p></p>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm">
<div>
<div>
<p>Long shot, but wondering if anyone has any clue here.<o:p></o:p></p>
<p>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.<o:p></o:p></p>
<p> <o:p></o:p></p>
<p>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.<o:p></o:p></p>
<p> <o:p></o:p></p>
<p>This is the code I’m using, which is almost identical to the sample code at:<o:p></o:p></p>
<p> <a href="https://urldefense.proofpoint.com/v2/url?u=https-3A__www.vtk.org_Wiki_VTK_Examples_Cxx_Visualization_DisplayCoordinateAxes&d=DwMGaQ&c=hmGTLOph1qd_VnCqj81HzEWkDaxmYdIWRBdoFggzhj8&r=QPUyrnKdkaGJHD0OTha3x09u1N6qkcvUsRW8n2fg59E&m=Ca3A5kG2b470KvD_mbq3zjTxpojP65Ujht5NwFwmiB8&s=kkG8QsL17hAP6OZCTF-wqwHw_QxzqgLZqnvJAvmwCGY&e=">
https://www.vtk.org/Wiki/VTK/Examples/Cxx/Visualization/DisplayCoordinateAxes</a><o:p></o:p></p>
<p> <o:p></o:p></p>
<p><span style="font-size:9.5pt;font-family:Consolas;color:#2B91AF">vtkSmartPointer</span><span style="font-size:9.5pt;font-family:Consolas;color:black"><</span><span style="font-size:9.5pt;font-family:Consolas;color:#2B91AF">vtkAxesActor</span><span style="font-size:9.5pt;font-family:Consolas;color:black">>
axes = </span><span style="font-size:9.5pt;font-family:Consolas;color:#2B91AF">vtkSmartPointer</span><span style="font-size:9.5pt;font-family:Consolas;color:black"><</span><span style="font-size:9.5pt;font-family:Consolas;color:#2B91AF">vtkAxesActor</span><span style="font-size:9.5pt;font-family:Consolas;color:black">>::New();</span><o:p></o:p></p>
<p><span style="font-size:9.5pt;font-family:Consolas;color:#2B91AF">vtkSmartPointer</span><span style="font-size:9.5pt;font-family:Consolas;color:black"><</span><span style="font-size:9.5pt;font-family:Consolas;color:#2B91AF">vtkOrientationMarkerWidget</span><span style="font-size:9.5pt;font-family:Consolas;color:black">>
widget = </span><span style="font-size:9.5pt;font-family:Consolas;color:#2B91AF">vtkSmartPointer</span><span style="font-size:9.5pt;font-family:Consolas;color:black"><</span><span style="font-size:9.5pt;font-family:Consolas;color:#2B91AF">vtkOrientationMarkerWidget</span><span style="font-size:9.5pt;font-family:Consolas;color:black">>::New();</span><o:p></o:p></p>
<p><span style="font-size:9.5pt;font-family:Consolas;color:black">widget</span><span style="font-size:9.5pt;font-family:Consolas;color:teal">-></span><span style="font-size:9.5pt;font-family:Consolas;color:black">SetOutlineColor(0.9300, 0.5700, 0.1300);</span><o:p></o:p></p>
<p><span style="font-size:9.5pt;font-family:Consolas;color:black">widget</span><span style="font-size:9.5pt;font-family:Consolas;color:teal">-></span><span style="font-size:9.5pt;font-family:Consolas;color:black">SetOrientationMarker(axes);</span><o:p></o:p></p>
<p><span style="font-size:9.5pt;font-family:Consolas;color:black">widget</span><span style="font-size:9.5pt;font-family:Consolas;color:teal">-></span><span style="font-size:9.5pt;font-family:Consolas;color:black">SetCurrentRenderer(m_vtkRenderer);</span><o:p></o:p></p>
<p><span style="font-size:9.5pt;font-family:Consolas;color:black">widget</span><span style="font-size:9.5pt;font-family:Consolas;color:teal">-></span><span style="font-size:9.5pt;font-family:Consolas;color:black">SetInteractor(m_vtkRenderer->GetRenderWindow()->GetInteractor());</span><o:p></o:p></p>
<p><span style="font-size:9.5pt;font-family:Consolas;color:black">widget</span><span style="font-size:9.5pt;font-family:Consolas;color:teal">-></span><span style="font-size:9.5pt;font-family:Consolas;color:black">SetViewport(0.0, 0.0, 0.4, 0.4);</span><o:p></o:p></p>
<p><span style="font-size:9.5pt;font-family:Consolas;color:black">widget</span><span style="font-size:9.5pt;font-family:Consolas;color:teal">-></span><span style="font-size:9.5pt;font-family:Consolas;color:black">SetEnabled(1);</span><o:p></o:p></p>
<p><span style="font-size:9.5pt;font-family:Consolas;color:black">widget</span><span style="font-size:9.5pt;font-family:Consolas;color:teal">-></span><span style="font-size:9.5pt;font-family:Consolas;color:black">InteractiveOn();</span><o:p></o:p></p>
<p> <o:p></o:p></p>
<p>It actually displays both the model and the orientation axes briefly, then displays the following exception:<o:p></o:p></p>
<p> 0xC000041D: An unhandled exception was encountered during a user callback.<o:p></o:p></p>
<p> <o:p></o:p></p>
<p>Call Stack:<o:p></o:p></p>
<p>> vtkMFCWindow::OnPaint() Line 169 C++<o:p></o:p></p>
<p>CWnd::OnWndMsg(unsigned int message, unsigned __int64 wParam, __int64 lParam, __int64 * pResult) Line 2459 C++<o:p></o:p></p>
<p>CWnd::WindowProc(unsigned int message, unsigned __int64 wParam, __int64 lParam) Line 2093 C++<o:p></o:p></p>
<p>AfxCallWndProc(CWnd * pWnd, HWND__ * hWnd, unsigned int nMsg, unsigned __int64 wParam, __int64 lParam) Line 265 C++<o:p></o:p></p>
<p>AfxWndProc(HWND__ * hWnd, unsigned int nMsg, unsigned __int64 wParam, __int64 lParam) Line 418 C++<o:p></o:p></p>
<p> <o:p></o:p></p>
<p>Anyone got any ideas?<o:p></o:p></p>
<p> <o:p></o:p></p>
<p>--<o:p></o:p></p>
<p>Jesse Kinross-Smith<o:p></o:p></p>
<p>Senior Software Engineer - BSW<o:p></o:p></p>
<p>Bentley Systems, Fremantle<o:p></o:p></p>
<p> <o:p></o:p></p>
</div>
</div>
</blockquote>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</div>
</div>
</div>
</body>
</html>