<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hello,<div><br></div><div>I've never tried to do it before, but it made me curious. I got as far as being able to display the chart without the extra window popping up, but every effort to get the interactor to work gave me the extra window and a crash on exit. </div><div><br></div><div>This type of problem arises with the QVTKWidget when using vtkRenderView and vtkContextView descendants, but you can get around it by swapping the interactor and render window back and forth between the two like in EasyView.cxx, or in Python (without SIP bindings) with the QVTKRenderWindowInteractor I've gotten it to work by passing the render window from the vtkContextView to the constructor of the widget.</div><div><br></div><div>But, with the .NET bindings and the RenderWindowControl you can't set the render window or pass it one when you first create it, and all of the combinations I've tried with setting the vtkContextView's interactor or grabbing one from the render window haven't worked...</div><div><br></div><div>Here's my code in case it gets you a little further, but we'll have to hope that someone else out there has tried to get a vtkView into a window with the .NET bindings...</div><div><br></div><div>-Eric</div><div><br><div>
<span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; ">------------------------------------------------------<br>Eric E Monson<br>Duke Visualization Technology Group<br></span>
</div>
<div><br></div><div><br></div><div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 9.5px/normal Consolas; color: rgb(0, 142, 19); "><font class="Apple-style-span" color="#000000"><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 9.5px/normal Consolas; color: rgb(0, 142, 19); "><font class="Apple-style-span" color="#000000" face="Helvetica"><span class="Apple-style-span" style="font-size: medium;"><font class="Apple-style-span" face="Consolas" size="2"><span class="Apple-style-span" style="font-size: 10px;"><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 9.5px/normal Consolas; "> <span style="color: #223cfb">private</span> <span style="color: #223cfb">void</span> renderWindowControl1_Load(<span style="color: #223cfb">object</span> sender, <span style="color: #3da2bc">EventArgs</span> e)</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 9.5px/normal Consolas; "> {</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 9.5px/normal Consolas; color: rgb(0, 142, 19); "><span style="color: #000000"> </span>// Set up a 2D scene</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 9.5px/normal Consolas; color: rgb(61, 162, 188); "><span style="color: #000000"> </span>vtkContextView<span style="color: #000000"> view = </span>vtkContextView<span style="color: #000000">.New();</span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 9.5px/normal Consolas; min-height: 11px; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 9.5px/normal Consolas; color: rgb(0, 142, 19); "><span style="color: #000000"> </span>// Create components of the rendering subsystem</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 9.5px/normal Consolas; "> <span style="color: #008e13">//</span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 9.5px/normal Consolas; "> <span style="color: #3da2bc">vtkRenderWindow</span> renWin = renderWindowControl1.RenderWindow;</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 9.5px/normal Consolas; min-height: 11px; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 9.5px/normal Consolas; "> renderWindowControl1.RenderWindow.RemoveRenderer(renderWindowControl1.RenderWindow.GetRenderers().GetFirstRenderer());</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 9.5px/normal Consolas; "> renderWindowControl1.RenderWindow.AddRenderer(view.GetRenderer());</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 9.5px/normal Consolas; "> view.GetRenderer().SetBackground(1, 1, 1);</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 9.5px/normal Consolas; min-height: 11px; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 9.5px/normal Consolas; "> <span style="color: #3da2bc">vtkChartXY</span> chart = <span style="color: #3da2bc">vtkChartXY</span>.New();</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 9.5px/normal Consolas; "> view.GetScene().AddItem(chart);</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 9.5px/normal Consolas; min-height: 11px; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 9.5px/normal Consolas; "> <span style="color: #223cfb">int</span> numPoints = 40;</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 9.5px/normal Consolas; min-height: 11px; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 9.5px/normal Consolas; color: rgb(61, 162, 188); "><span style="color: #000000"> </span>vtkDoubleArray<span style="color: #000000"> arrX = </span>vtkDoubleArray<span style="color: #000000">.New();</span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 9.5px/normal Consolas; "> arrX.SetName(<span style="color: #b12621">"X Axis"</span>);</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 9.5px/normal Consolas; "> arrX.SetNumberOfComponents(1);</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 9.5px/normal Consolas; "> arrX.SetNumberOfValues(numPoints);</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 9.5px/normal Consolas; color: rgb(61, 162, 188); "><span style="color: #000000"> </span>vtkDoubleArray<span style="color: #000000"> arrC = </span>vtkDoubleArray<span style="color: #000000">.New();</span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 9.5px/normal Consolas; "> arrC.SetName(<span style="color: #b12621">"Cosine"</span>);</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 9.5px/normal Consolas; "> arrC.SetNumberOfComponents(1);</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 9.5px/normal Consolas; "> arrC.SetNumberOfValues(numPoints);</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 9.5px/normal Consolas; color: rgb(61, 162, 188); "><span style="color: #000000"> </span>vtkDoubleArray<span style="color: #000000"> arrS = </span>vtkDoubleArray<span style="color: #000000">.New();</span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 9.5px/normal Consolas; "> arrS.SetName(<span style="color: #b12621">"Sine"</span>);</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 9.5px/normal Consolas; "> arrS.SetNumberOfComponents(1);</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 9.5px/normal Consolas; "> arrS.SetNumberOfValues(numPoints);</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 9.5px/normal Consolas; min-height: 11px; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 9.5px/normal Consolas; color: rgb(0, 142, 19); "><span style="color: #000000"> </span>// Test charting with a few more points...</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 9.5px/normal Consolas; "> <span style="color: #223cfb">double</span> inc = 7.5 / (numPoints-1);</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 9.5px/normal Consolas; "> <span style="color: #223cfb">for</span> (<span style="color: #223cfb">long</span> i = 0; i < numPoints; ++i)</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 9.5px/normal Consolas; "> {</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 9.5px/normal Consolas; "> arrX.SetValue(i, i * inc);</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 9.5px/normal Consolas; "> arrC.SetValue(i, System.<span style="color: #3da2bc">Math</span>.Cos(i * inc) + 0.0);</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 9.5px/normal Consolas; "> arrS.SetValue(i, System.<span style="color: #3da2bc">Math</span>.Sin(i * inc) + 0.0);</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 9.5px/normal Consolas; "> }</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 9.5px/normal Consolas; min-height: 11px; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 9.5px/normal Consolas; "> <span style="color: #3da2bc">vtkTable</span> table = <span style="color: #3da2bc">vtkTable</span>.New();</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 9.5px/normal Consolas; "> table.AddColumn(arrX);</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 9.5px/normal Consolas; "> table.AddColumn(arrC);</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 9.5px/normal Consolas; "> table.AddColumn(arrS);</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 9.5px/normal Consolas; min-height: 11px; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 9.5px/normal Consolas; color: rgb(0, 142, 19); "><span style="color: #000000"> </span>// Add multiple line plots, setting the colors etc</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 9.5px/normal Consolas; "> <span style="color: #3da2bc">vtkPlot</span> points = chart.AddPlot(0);</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 9.5px/normal Consolas; "> points.SetInput(table, 0, 1);</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 9.5px/normal Consolas; "> points.SetColor(0, 0, 0, 255);</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 9.5px/normal Consolas; "> points.SetWidth((<span style="color: #223cfb">float</span>)1.0);</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 9.5px/normal Consolas; "> <span style="color: #3da2bc">vtkPlotLine</span>.SafeDownCast(points).SetMarkerStyle(4);</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 9.5px/normal Consolas; "> points = chart.AddPlot(1);</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 9.5px/normal Consolas; "> points.SetInput(table, 0, 2);</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 9.5px/normal Consolas; "> points.SetColor(150, 0, 0, 255);</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 9.5px/normal Consolas; "> points.SetWidth((<span style="color: #223cfb">float</span>)2.0);</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 9.5px/normal Consolas; "> <span style="color: #3da2bc">vtkPlotPoints</span>.SafeDownCast(points).SetMarkerStyle(3);</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 9.5px/normal Consolas; min-height: 11px; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 9.5px/normal Consolas; color: rgb(0, 142, 19); "><span style="color: #000000"> </span>// Add the actors to the renderer, set the window size</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 9.5px/normal Consolas; "> <span style="color: #008e13">//</span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 9.5px/normal Consolas; "> renWin.SetSize(250, 250);</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 9.5px/normal Consolas; "> renWin.Render();</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 9.5px/normal Consolas; "> }</div><div><br></div></span></font></span></font></div></font></div></div><div><div>On Feb 23, 2011, at 11:37 AM, dbenzhuser wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><span style="font-family:Verdana"><span style="font-size:12px"><span style="font-family: verdana;"><span style="font-size: 12px;">Hi everybody!<br>
<br>
I'm searching for a kind of Activiz - </span></span>RenderWindowControl <span style="font-family: verdana;"><span style="font-size: 12px;">- vtkChart "Hello World" example.<br>
<br>
I was able to "rewrite" the chart example here</span></span><br>
<a href="http://www.kitware.com/products/html/NewChartAPIInVTK.html">http://www.kitware.com/products/html/NewChartAPIInVTK.html</a><br>
using the Activiz 5.6.1 framework, but I don't see how I can render a chart inside the Kitware.VTK.RenderWindowControl.<br>
<br>
In the HalloVTKForm example provided with Activiz, a vtkActor is set with the AddViewProp() method, but I can't cast a ChartXY object to vtkProp (no wonder, they arent anywhere close in the object stucture).<br>
<br>
I tried to create a new vtkContextView and set its render window to the one provided by the control like this:<br>
<br>
vtkRenderWindow renwin = renderWindowControl1.RenderWindow;<br>
vtkContextView view = vtkContextView.New();<br>
(...)<br>
view.GetRenderer().SetRenderWindow(renwin);<br>
<br>
but it only opens a new window instead of drawing inside the control.<br>
<br>
Thanks for your help!</span></span>
_______________________________________________<br>Powered by <a href="http://www.kitware.com">www.kitware.com</a><br><br>Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html">http://www.kitware.com/opensource/opensource.html</a><br><br>Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ">http://www.vtk.org/Wiki/VTK_FAQ</a><br><br>Follow this link to subscribe/unsubscribe:<br><a href="http://www.vtk.org/mailman/listinfo/vtkusers">http://www.vtk.org/mailman/listinfo/vtkusers</a><br></blockquote></div><br></div></body></html>