<html><head><meta charset="GB2312"><style>body { line-height: 1.5; }body { font-size: 10.5pt; font-family: Î¢ÈíÑźÚ; color: rgb(0, 0, 0); line-height: 1.5; }</style></head><body>
<div><span></span><div style="font-family: Î¢ÈíÑźÚ, Tahoma;"><font size="3">Hey Guys,</font></div><div style="font-family: Î¢ÈíÑźÚ, Tahoma;">    I want to display vtkChartXYZ in a QVTKWidget,  how could I accomplish that ? I tried the following code, but I get some errors, but the 3D graph could be shown.</div><div style="font-family: Î¢ÈíÑźÚ, Tahoma;"><br></div><div style="font-family: Î¢ÈíÑźÚ, Tahoma;">// Code:</div><div style="font-family: Î¢ÈíÑźÚ, Tahoma;"><pre style="margin-top: 0px; margin-bottom: 0px;"><span style="color: rgb(128, 128, 0);">int</span><span style="color: rgb(192, 192, 192);"> </span>TestLinePlot3D(<span style="color: rgb(128, 128, 0);">int</span><span style="color: rgb(192, 192, 192);"> </span>argc,<span style="color: rgb(192, 192, 192);"> </span><span style="color: rgb(128, 128, 0);">char</span><span style="color: rgb(192, 192, 192);"> </span>*<span style="color: rgb(192, 192, 192);"> </span>argv[])</pre><pre style="margin-top: 0px; margin-bottom: 0px;">{</pre><pre style="margin-top: 0px; margin-bottom: 0px;"><span style="color: rgb(192, 192, 192);">    </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(192, 192, 192);"> </span><span style="color: rgb(0, 128, 0);">Create</span><span style="color: rgb(192, 192, 192);"> </span><span style="color: rgb(0, 128, 0);">the</span><span style="color: rgb(192, 192, 192);"> </span><span style="color: rgb(0, 128, 0);">data.</span></pre><pre style="margin-top: 0px; margin-bottom: 0px;"><span style="color: rgb(192, 192, 192);">    </span><span style="color: rgb(128, 0, 128);">QApplication</span><span style="color: rgb(192, 192, 192);"> </span>app(argc,<span style="color: rgb(192, 192, 192);"> </span>argv);</pre><pre style="margin-top: 0px; margin-bottom: 0px;"><span style="color: rgb(192, 192, 192);">    </span><span style="color: rgb(128, 0, 128);">QVTKWidget</span>*<span style="color: rgb(192, 192, 192);"> </span>widget<span style="color: rgb(192, 192, 192);"> </span>=<span style="color: rgb(192, 192, 192);"> </span><span style="color: rgb(128, 128, 0);">new</span><span style="color: rgb(192, 192, 192);"> </span><span style="color: rgb(128, 0, 128);">QVTKWidget</span>;</pre><pre style="margin-top: 0px; margin-bottom: 0px;"><span style="color: rgb(192, 192, 192);">    </span><span style="color: rgb(128, 0, 128);">vtkNew</span><<span style="color: rgb(128, 0, 128);">vtkTable</span>><span style="color: rgb(192, 192, 192);"> </span>varXSolution;</pre><pre style="margin-top: 0px; margin-bottom: 0px;"><span style="color: rgb(192, 192, 192);">    </span><span style="color: rgb(128, 0, 128);">vtkNew</span><<span style="color: rgb(128, 0, 128);">vtkFloatArray</span>><span style="color: rgb(192, 192, 192);"> </span>arrX0;</pre><pre style="margin-top: 0px; margin-bottom: 0px;"><span style="color: rgb(192, 192, 192);">    </span>arrX0-><span style="font-style: italic;">SetName</span>(<span style="color: rgb(0, 128, 0);">"X"</span>);</pre><pre style="margin-top: 0px; margin-bottom: 0px;"><span style="color: rgb(192, 192, 192);">    </span>varXSolution->AddColumn(arrX0.GetPointer());</pre><pre style="margin-top: 0px; margin-bottom: 0px;"><span style="color: rgb(192, 192, 192);">    </span><span style="color: rgb(128, 0, 128);">vtkNew</span><<span style="color: rgb(128, 0, 128);">vtkFloatArray</span>><span style="color: rgb(192, 192, 192);"> </span>arrX1;</pre><pre style="margin-top: 0px; margin-bottom: 0px;"><span style="color: rgb(192, 192, 192);">    </span>arrX1-><span style="font-style: italic;">SetName</span>(<span style="color: rgb(0, 128, 0);">"Y"</span>);</pre><pre style="margin-top: 0px; margin-bottom: 0px;"><span style="color: rgb(192, 192, 192);">    </span>varXSolution->AddColumn(arrX1.GetPointer());</pre><pre style="margin-top: 0px; margin-bottom: 0px;"><span style="color: rgb(192, 192, 192);">    </span><span style="color: rgb(128, 0, 128);">vtkNew</span><<span style="color: rgb(128, 0, 128);">vtkFloatArray</span>><span style="color: rgb(192, 192, 192);"> </span>arrX2;</pre><pre style="margin-top: 0px; margin-bottom: 0px;"><span style="color: rgb(192, 192, 192);">    </span>arrX2-><span style="font-style: italic;">SetName</span>(<span style="color: rgb(0, 128, 0);">"Z"</span>);</pre><pre style="margin-top: 0px; margin-bottom: 0px;"><span style="color: rgb(192, 192, 192);">    </span>varXSolution->AddColumn(arrX2.GetPointer());</pre><pre style="margin-top: 0px; margin-bottom: 0px;"><span style="color: rgb(192, 192, 192);">    </span><span style="color: rgb(128, 128, 0);">const</span><span style="color: rgb(192, 192, 192);"> </span><span style="color: rgb(128, 128, 0);">unsigned</span><span style="color: rgb(192, 192, 192);"> </span><span style="color: rgb(128, 128, 0);">int</span><span style="color: rgb(192, 192, 192);"> </span>numberOfTimePoints<span style="color: rgb(192, 192, 192);"> </span>=<span style="color: rgb(192, 192, 192);"> </span><span style="color: rgb(0, 0, 128);">1000</span>;</pre><pre style="margin-top: 0px; margin-bottom: 0px;"><span style="color: rgb(192, 192, 192);">    </span>varXSolution->SetNumberOfRows(numberOfTimePoints);</pre><pre style="margin-top: 0px; margin-bottom: 0px;"><span style="color: rgb(192, 192, 192);">    </span><span style="color: rgb(128, 128, 0);">float</span><span style="color: rgb(192, 192, 192);"> </span>varX[<span style="color: rgb(0, 0, 128);">3</span>];</pre><pre style="margin-top: 0px; margin-bottom: 0px;"><span style="color: rgb(192, 192, 192);">    </span>varX[<span style="color: rgb(0, 0, 128);">0</span>]<span style="color: rgb(192, 192, 192);"> </span>=<span style="color: rgb(192, 192, 192);"> </span><span style="color: rgb(0, 0, 128);">0.0f</span>;</pre><pre style="margin-top: 0px; margin-bottom: 0px;"><span style="color: rgb(192, 192, 192);">    </span>varX[<span style="color: rgb(0, 0, 128);">1</span>]<span style="color: rgb(192, 192, 192);"> </span>=<span style="color: rgb(192, 192, 192);"> </span><span style="color: rgb(0, 0, 128);">1.0f</span>;</pre><pre style="margin-top: 0px; margin-bottom: 0px;"><span style="color: rgb(192, 192, 192);">    </span>varX[<span style="color: rgb(0, 0, 128);">2</span>]<span style="color: rgb(192, 192, 192);"> </span>=<span style="color: rgb(192, 192, 192);"> </span><span style="color: rgb(0, 0, 128);">1.05f</span>;</pre><pre style="margin-top: 0px; margin-bottom: 0px;"><span style="color: rgb(192, 192, 192);">    </span><span style="color: rgb(128, 128, 0);">float</span><span style="color: rgb(192, 192, 192);"> </span>varXDerivative[<span style="color: rgb(0, 0, 128);">3</span>];</pre><pre style="margin-top: 0px; margin-bottom: 0px;"><span style="color: rgb(192, 192, 192);">    </span><span style="color: rgb(128, 128, 0);">const</span><span style="color: rgb(192, 192, 192);"> </span><span style="color: rgb(128, 128, 0);">float</span><span style="color: rgb(192, 192, 192);"> </span>deltaT<span style="color: rgb(192, 192, 192);"> </span>=<span style="color: rgb(192, 192, 192);"> </span><span style="color: rgb(0, 0, 128);">0.01f</span>;</pre><pre style="margin-top: 0px; margin-bottom: 0px;"><span style="color: rgb(192, 192, 192);">    </span><span style="color: rgb(128, 128, 0);">for</span><span style="color: rgb(192, 192, 192);"> </span>(<span style="color: rgb(128, 128, 0);">unsigned</span><span style="color: rgb(192, 192, 192);"> </span><span style="color: rgb(128, 128, 0);">int</span><span style="color: rgb(192, 192, 192);"> </span>ii<span style="color: rgb(192, 192, 192);"> </span>=<span style="color: rgb(192, 192, 192);"> </span><span style="color: rgb(0, 0, 128);">0</span>;<span style="color: rgb(192, 192, 192);"> </span>ii<span style="color: rgb(192, 192, 192);"> </span><<span style="color: rgb(192, 192, 192);"> </span>numberOfTimePoints;<span style="color: rgb(192, 192, 192);"> </span>++ii)</pre><pre style="margin-top: 0px; margin-bottom: 0px;"><span style="color: rgb(192, 192, 192);">    </span>{</pre><pre style="margin-top: 0px; margin-bottom: 0px;"><span style="color: rgb(192, 192, 192);">        </span>varXSolution->SetValue(ii,<span style="color: rgb(192, 192, 192);"> </span><span style="color: rgb(0, 0, 128);">0</span>,<span style="color: rgb(192, 192, 192);"> </span>varX[<span style="color: rgb(0, 0, 128);">0</span>]);</pre><pre style="margin-top: 0px; margin-bottom: 0px;"><span style="color: rgb(192, 192, 192);">        </span>varXSolution->SetValue(ii,<span style="color: rgb(192, 192, 192);"> </span><span style="color: rgb(0, 0, 128);">1</span>,<span style="color: rgb(192, 192, 192);"> </span>varX[<span style="color: rgb(0, 0, 128);">1</span>]);</pre><pre style="margin-top: 0px; margin-bottom: 0px;"><span style="color: rgb(192, 192, 192);">        </span>varXSolution->SetValue(ii,<span style="color: rgb(192, 192, 192);"> </span><span style="color: rgb(0, 0, 128);">2</span>,<span style="color: rgb(192, 192, 192);"> </span>varX[<span style="color: rgb(0, 0, 128);">2</span>]);</pre><pre style="margin-top: 0px; margin-bottom: 0px;"><span style="color: rgb(192, 192, 192);">        </span>lorenz(varX,<span style="color: rgb(192, 192, 192);"> </span>varXDerivative);</pre><pre style="margin-top: 0px; margin-bottom: 0px;"><span style="color: rgb(192, 192, 192);">        </span>varX[<span style="color: rgb(0, 0, 128);">0</span>]<span style="color: rgb(192, 192, 192);"> </span>+=<span style="color: rgb(192, 192, 192);"> </span>varXDerivative[<span style="color: rgb(0, 0, 128);">0</span>]<span style="color: rgb(192, 192, 192);"> </span>*<span style="color: rgb(192, 192, 192);"> </span>deltaT;</pre><pre style="margin-top: 0px; margin-bottom: 0px;"><span style="color: rgb(192, 192, 192);">        </span>varX[<span style="color: rgb(0, 0, 128);">1</span>]<span style="color: rgb(192, 192, 192);"> </span>+=<span style="color: rgb(192, 192, 192);"> </span>varXDerivative[<span style="color: rgb(0, 0, 128);">1</span>]<span style="color: rgb(192, 192, 192);"> </span>*<span style="color: rgb(192, 192, 192);"> </span>deltaT;</pre><pre style="margin-top: 0px; margin-bottom: 0px;"><span style="color: rgb(192, 192, 192);">        </span>varX[<span style="color: rgb(0, 0, 128);">2</span>]<span style="color: rgb(192, 192, 192);"> </span>+=<span style="color: rgb(192, 192, 192);"> </span>varXDerivative[<span style="color: rgb(0, 0, 128);">2</span>]<span style="color: rgb(192, 192, 192);"> </span>*<span style="color: rgb(192, 192, 192);"> </span>deltaT;</pre><pre style="margin-top: 0px; margin-bottom: 0px;"><span style="color: rgb(192, 192, 192);">    </span>}</pre><pre style="margin-top: 0px; margin-bottom: 0px;"><br></pre><pre style="margin-top: 0px; margin-bottom: 0px;"><span style="color: rgb(192, 192, 192);">    </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(192, 192, 192);"> </span><span style="color: rgb(0, 128, 0);">Set</span><span style="color: rgb(192, 192, 192);"> </span><span style="color: rgb(0, 128, 0);">up</span><span style="color: rgb(192, 192, 192);"> </span><span style="color: rgb(0, 128, 0);">a</span><span style="color: rgb(192, 192, 192);"> </span><span style="color: rgb(0, 128, 0);">3D</span><span style="color: rgb(192, 192, 192);"> </span><span style="color: rgb(0, 128, 0);">scene</span><span style="color: rgb(192, 192, 192);"> </span><span style="color: rgb(0, 128, 0);">and</span><span style="color: rgb(192, 192, 192);"> </span><span style="color: rgb(0, 128, 0);">add</span><span style="color: rgb(192, 192, 192);"> </span><span style="color: rgb(0, 128, 0);">an</span><span style="color: rgb(192, 192, 192);"> </span><span style="color: rgb(0, 128, 0);">XYZ</span><span style="color: rgb(192, 192, 192);"> </span><span style="color: rgb(0, 128, 0);">chart</span><span style="color: rgb(192, 192, 192);"> </span><span style="color: rgb(0, 128, 0);">to</span><span style="color: rgb(192, 192, 192);"> </span><span style="color: rgb(0, 128, 0);">it.</span></pre><pre style="margin-top: 0px; margin-bottom: 0px;"><span style="color: rgb(192, 192, 192);">    </span><span style="color: rgb(128, 0, 128);">vtkNew</span><<span style="color: rgb(128, 0, 128);">vtkContextView</span>><span style="color: rgb(192, 192, 192);"> </span>view;</pre><pre style="margin-top: 0px; margin-bottom: 0px;"><span style="color: rgb(192, 192, 192);">    </span>view-><span style="font-style: italic;">GetRenderWindow</span>()-><span style="font-style: italic;">SetSize</span>(<span style="color: rgb(0, 0, 128);">400</span>,<span style="color: rgb(192, 192, 192);"> </span><span style="color: rgb(0, 0, 128);">300</span>);</pre><pre style="margin-top: 0px; margin-bottom: 0px;"><span style="color: rgb(192, 192, 192);">    </span><span style="color: rgb(128, 0, 128);">vtkNew</span><<span style="color: rgb(128, 0, 128);">vtkChartXYZ</span>><span style="color: rgb(192, 192, 192);"> </span>chart;</pre><pre style="margin-top: 0px; margin-bottom: 0px;"><span style="color: rgb(192, 192, 192);">    </span>chart->SetGeometry(<span style="color: rgb(128, 0, 128);">vtkRectf</span>(<span style="color: rgb(0, 0, 128);">10.0</span>,<span style="color: rgb(192, 192, 192);"> </span><span style="color: rgb(0, 0, 128);">20.0</span>,<span style="color: rgb(192, 192, 192);"> </span><span style="color: rgb(0, 0, 128);">250</span>,<span style="color: rgb(192, 192, 192);"> </span><span style="color: rgb(0, 0, 128);">260</span>));</pre><pre style="margin-top: 0px; margin-bottom: 0px;"><span style="color: rgb(192, 192, 192);">    </span>view-><span style="font-style: italic;">GetScene</span>()->AddItem(chart.GetPointer());</pre><pre style="margin-top: 0px; margin-bottom: 0px;"><br></pre><pre style="margin-top: 0px; margin-bottom: 0px;"><span style="color: rgb(192, 192, 192);">    </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(192, 192, 192);"> </span><span style="color: rgb(0, 128, 0);">Add</span><span style="color: rgb(192, 192, 192);"> </span><span style="color: rgb(0, 128, 0);">a</span><span style="color: rgb(192, 192, 192);"> </span><span style="color: rgb(0, 128, 0);">line</span><span style="color: rgb(192, 192, 192);"> </span><span style="color: rgb(0, 128, 0);">plot.</span></pre><pre style="margin-top: 0px; margin-bottom: 0px;"><span style="color: rgb(192, 192, 192);">    </span><span style="color: rgb(128, 0, 128);">vtkNew</span><<span style="color: rgb(128, 0, 128);">vtkPlotLine3D</span>><span style="color: rgb(192, 192, 192);"> </span>plot;</pre><pre style="margin-top: 0px; margin-bottom: 0px;"><span style="color: rgb(192, 192, 192);">    </span>plot-><span style="font-style: italic;">SetInputData</span>(varXSolution.GetPointer());</pre><pre style="margin-top: 0px; margin-bottom: 0px;"><span style="color: rgb(192, 192, 192);">    </span>plot->GetPen()->SetColorF(<span style="color: rgb(0, 0, 128);">0.1</span>,<span style="color: rgb(192, 192, 192);"> </span><span style="color: rgb(0, 0, 128);">0.2</span>,<span style="color: rgb(192, 192, 192);"> </span><span style="color: rgb(0, 0, 128);">0.8</span>,<span style="color: rgb(192, 192, 192);"> </span><span style="color: rgb(0, 0, 128);">1.0</span>);</pre><pre style="margin-top: 0px; margin-bottom: 0px;"><span style="color: rgb(192, 192, 192);">    </span>chart-><span style="font-style: italic;">AddPlot</span>(plot.GetPointer());</pre><pre style="margin-top: 0px; margin-bottom: 0px;"><br></pre><pre style="margin-top: 0px; margin-bottom: 0px;"><span style="color: rgb(192, 192, 192);">    </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(192, 192, 192);"> </span><span style="color: rgb(0, 128, 0);">Finally</span><span style="color: rgb(192, 192, 192);"> </span><span style="color: rgb(0, 128, 0);">render</span><span style="color: rgb(192, 192, 192);"> </span><span style="color: rgb(0, 128, 0);">the</span><span style="color: rgb(192, 192, 192);"> </span><span style="color: rgb(0, 128, 0);">scene</span><span style="color: rgb(192, 192, 192);"> </span><span style="color: rgb(0, 128, 0);">and</span><span style="color: rgb(192, 192, 192);"> </span><span style="color: rgb(0, 128, 0);">compare</span><span style="color: rgb(192, 192, 192);"> </span><span style="color: rgb(0, 128, 0);">the</span><span style="color: rgb(192, 192, 192);"> </span><span style="color: rgb(0, 128, 0);">image</span><span style="color: rgb(192, 192, 192);"> </span><span style="color: rgb(0, 128, 0);">to</span><span style="color: rgb(192, 192, 192);"> </span><span style="color: rgb(0, 128, 0);">a</span><span style="color: rgb(192, 192, 192);"> </span><span style="color: rgb(0, 128, 0);">reference</span><span style="color: rgb(192, 192, 192);"> </span><span style="color: rgb(0, 128, 0);">image.</span></pre><pre style="margin-top: 0px; margin-bottom: 0px;"><span style="color: rgb(192, 192, 192);">    </span>view-><span style="font-style: italic;">GetRenderWindow</span>()-><span style="font-style: italic;">SetMultiSamples</span>(<span style="color: rgb(0, 0, 128);">0</span>);</pre><pre style="margin-top: 0px; margin-bottom: 0px;"><span style="color: rgb(192, 192, 192);">    </span>view-><span style="font-style: italic;">GetRenderer</span>()-><span style="font-style: italic;">SetBackground</span>(<span style="color: rgb(0, 0, 128);">0</span>,<span style="color: rgb(192, 192, 192);"> </span><span style="color: rgb(0, 0, 128);">110</span>,<span style="color: rgb(192, 192, 192);"> </span><span style="color: rgb(0, 0, 128);">0</span>);</pre><pre style="margin-top: 0px; margin-bottom: 0px;"><span style="color: rgb(192, 192, 192);">    </span>chart->SetFitToScene(<span style="color: rgb(128, 128, 0);">true</span>);</pre><pre style="margin-top: 0px; margin-bottom: 0px;"><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(192, 192, 192);">    </span><span style="color: rgb(0, 128, 0);">widget->SetRenderWindow(view->GetRenderWindow());</span></pre><pre style="margin-top: 0px; margin-bottom: 0px;"><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(192, 192, 192);">    </span><span style="color: rgb(0, 128, 0);">view->SetInteractor(widget->GetInteractor());</span></pre><pre style="margin-top: 0px; margin-bottom: 0px;"><span style="color: rgb(192, 192, 192);">    </span>view-><span style="font-style: italic;">GetInteractor</span>()-><span style="font-style: italic;">Initialize</span>();</pre><pre style="margin-top: 0px; margin-bottom: 0px;"><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(192, 192, 192);">    </span><span style="color: rgb(0, 128, 0);">view->GetInteractor()->Start(); // shouldn't be calling this </span></pre><pre style="margin-top: 0px; margin-bottom: 0px;"><br></pre><pre style="margin-top: 0px; margin-bottom: 0px;"><span style="color: rgb(192, 192, 192);">    </span>view-><span style="font-style: italic;">SetRenderWindow</span>(widget-><span style="font-style: italic;">GetRenderWindow</span>());</pre><pre style="margin-top: 0px; margin-bottom: 0px;"><span style="color: rgb(192, 192, 192);">    </span>widget->show();</pre><pre style="margin-top: 0px; margin-bottom: 0px;"><span style="color: rgb(192, 192, 192);">    </span><span style="color: rgb(128, 128, 0);">return</span><span style="color: rgb(192, 192, 192);"> </span>app.exec();</pre><pre style="margin-top: 0px; margin-bottom: 0px;">}</pre><pre style="margin-top: 0px; margin-bottom: 0px;"><br></pre><pre style="margin-top: 0px; margin-bottom: 0px;">// Errors:</pre><pre style="margin-top: 0px; margin-bottom: 0px;">ERROR: In E:\open\vtk\vtkvc32\VTK-6.1.0\Rendering\Context2D\vtkOpenGLContextDevice2D.cxx, line 1244
<br>vtkOpenGL2ContextDevice2D (074DB1B8): failed after PopMatrix 1 OpenGL errors detected
<br>  0 : (1284) Stack underflow
<br>ERROR: In E:\open\vtk\vtkvc32\VTK-6.1.0\Rendering\Context2D\vtkOpenGLContextDevice2D.cxx, line 177
<br>vtkOpenGL2ContextDevice2D (074DB1B8): failed after End 1 OpenGL errors detected
<br>  0 : (1284) Stack underflow</pre></div><div style="font-family: Î¢ÈíÑźÚ, Tahoma;"><br></div><div style="font-family: Î¢ÈíÑźÚ, Tahoma;">Any help would be appreciated.</div><div style="font-family: Î¢ÈíÑźÚ, Tahoma;"><br></div><div style="font-family: Î¢ÈíÑźÚ, Tahoma;">P.S. I am using Qt5.4.0 & VTK 6.1.0</div><div style="font-family: Î¢ÈíÑźÚ, Tahoma;"><br></div><div style="font-family: Î¢ÈíÑźÚ, Tahoma;">Thanks.</div><div style="font-family: Î¢ÈíÑźÚ, Tahoma;">Jason Zhang.</div></div>
</body></html>