[vtkusers] Activiz and vtkChartXY

Eric E. Monson emonson at cs.duke.edu
Thu Feb 24 09:16:39 EST 2011


Hey Matthias,

Really? When I make that change to the interactor I get the second (vtkContextView) window popping up, and when I interact with the main render window the interaction only affects the second window...

I have a feeling that the RenderWindowControl will have to be modified to allow setting the render window, but I still haven't tried building the .NET wrappers from source, so I can't play around yet. (I also may not be experienced enough in C# to play intelligently...)

Let me know if you make a breakthrough, and hopefully one of the original developers will chime in. 

Thanks,
-Eric


On Feb 24, 2011, at 3:22 AM, Matthias Binninger wrote:

> Thanks a lot!
> 
> I got a little further with it, but not as far as I hoped ...
> 
> renwin.GetInteractor().Disable();
> renwin.SetInteractor(view.GetInteractor());
> 
> ... does the trick and makes it possible to use the chart inside the control, but only if
> 
> * I don't use the load event handler but start the chart with a button afterwards
> * I don't do anything crazy like ...
> * * draging some other window over it and switch back to the chart
> * * or moving the chart window to my second screen.
> 
> else the chart-only window appears and the original window gets messed up.
> 
> My code:
> 
> private void Start()
> {
>     const int NUM_POINTS = 100;
>     const float INC = 7.5f / (NUM_POINTS - 1);
> 
>     vtkContextView view = vtkContextView.New();
> 
>     vtkRenderWindow renwin = renderWindowControl1.RenderWindow;
> 
>     renwin.RemoveRenderer(renwin.GetRenderers().GetFirstRenderer());
>     renwin.AddRenderer(view.GetRenderer());
> 
>     renwin.GetInteractor().Disable();
>     renwin.SetInteractor(view.GetInteractor());
>     
>     view.GetRenderer().SetBackground(1.0, 1.0, 1.0);
> 
>     vtkChartXY chart = vtkChartXY.New();
>     chart.SetTitle("MyChart");
>     chart.SetShowLegend(true);
>     chart.GetAxis(0).SetTitle("Y");
>     chart.GetAxis(1).SetTitle("X");
> 
>     view.GetScene().AddItem(chart);
> 
>     vtkTable table = vtkTable.New();
> 
>     vtkFloatArray arrX = vtkFloatArray.New();
>     arrX.SetName("X");
>     table.AddColumn(arrX);
> 
>     vtkFloatArray arrS = vtkFloatArray.New();
>     arrS.SetName("Sine");
>     table.AddColumn(arrS);
> 
>     vtkFloatArray arrC = vtkFloatArray.New();
>     arrC.SetName("Cosine");
>     table.AddColumn(arrC);
> 
>     table.SetNumberOfRows(NUM_POINTS);
> 
>     for (int i = 0; i < NUM_POINTS; i++)
>     {
>         arrX.SetValue(i, i * INC);
>         arrS.SetValue(i, (float)Math.Sin(i * INC));
>         arrC.SetValue(i, (float)Math.Cos(i * INC));
>     }
> 
>     vtkPlotLine l_oPlot1 = (vtkPlotLine)chart.AddPlot((int)vtkChart.BAR_WrapperEnum.LINE);
>     l_oPlot1.SetInput(table, 0, 1);
>     l_oPlot1.SetColor(255, 0, 0, 255);
> 
>     vtkPlotLine l_oPlot2 = (vtkPlotLine)chart.AddPlot((int)vtkChart.BAR_WrapperEnum.LINE);
>     l_oPlot2.SetInput(table, 0, 2);
>     l_oPlot2.SetColor(0, 127, 127, 255);
> 
>     renwin.Render();
> }
>  
> 
>   _______________________________________________
> Powered by www.kitware.com
> 
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
> 
> Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
> 
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20110224/e6efdbcf/attachment.htm>


More information about the vtkusers mailing list