Example #1
0
        public static void SetVChart()
        {
            if (VZArray == null || VArray == null)
            {
                MessageBox.Show("array is null");
                return;
            }

            VTable = vtkTable.New();
            VTable.AddColumn(VZArray);
            VTable.AddColumn(VArray);

            VChart = vtkChartXY.New();
            var line = VChart.AddPlot(0);

            line.SetInput(VTable, 0, 1);

            VView = vtkContextView.New();
            VView.GetScene().AddItem(VChart);

            RenWinControlVertical.RenderWindow.GetRenderers().GetFirstRenderer().RemoveAllViewProps();

            VView.SetRenderWindow(RenWinControlVertical.RenderWindow);
            RenWinControlVertical.RenderWindow.Render();
        }
Example #2
0
        public static void SetHChart()
        {
            if (HArray == null || HZArray == null)
            {
                MessageBox.Show("array is null");
                return;
            }

            HTable = vtkTable.New();
            HTable.AddColumn(HArray);
            HTable.AddColumn(HZArray);

            HChart = vtkChartXY.New();
            var line = HChart.AddPlot(0);

            line.SetInput(HTable, 0, 1);

            HView = vtkContextView.New();
            HView.GetScene().AddItem(HChart);

            RenWinControlHorizontal.RenderWindow.GetRenderers().GetFirstRenderer().RemoveAllViewProps();

            HView.SetRenderWindow(RenWinControlHorizontal.RenderWindow);
            RenWinControlHorizontal.RenderWindow.Render();
        }
Example #3
0
        protected virtual void SetXArray(vtkDoubleArray array, VtkPlotPointsModel plot)
        {
            VtkChartXyModel model = this.Model as VtkChartXyModel;

            if (model == null)
            {
                return;
            }

            vtkTable table = plot.Table;

            if (table.GetNumberOfColumns() <= 1)
            {
                table.Initialize();
                table.AddColumn(array);
            }
            else
            {
                vtkDoubleArray arrY = table.GetColumn(1) as vtkDoubleArray;
                if (arrY == null)
                {
                    this.Log.Error("SetXArray(): Could not cast table data to vtkDoubleArray");
                    return;
                }

                table.Initialize();
                table.AddColumn(array);
                table.AddColumn(arrY);

                vtkPlotPoints vtkPlot = plot.PlotItem as vtkPlotPoints;
                if (vtkPlot == null)
                {
                    this.Log.Error("SetXArray(): Could not cast plot item to vtkPlotPoints");
                    return;
                }

                vtkPlot.SetInputData(table, 0, 1);
            }
        }
        public static void LinePlotTest()
        {
            vtkTable table = vtkTable.New();

            vtkFloatArray arrX = vtkFloatArray.New();

            table.AddColumn(arrX);

            vtkFloatArray arrSine = vtkFloatArray.New();

            table.AddColumn(arrSine);

            int numPoints = 100;

            table.SetNumberOfRows(100);

            for (int i = 0; i < numPoints; i++)
            {
                arrSine.SetValue(i, (float)Math.Cos(i));
            }

            table.Update();

            vtkContextView view = vtkContextView.New();

            view.GetRenderer().SetBackground(0, 0, 0);


            vtkChartXY chart = vtkChartXY.New();

            view.GetScene().AddItem(chart);


            chart.AddPlot(0).SetInput(table);

            view.GetInteractor().Initialize();
            view.GetInteractor().Start();
        }
Example #5
0
        protected virtual void SetYArray(vtkDoubleArray array, VtkPlotPointsModel plot)
        {
            VtkChartXyModel model = this.Model as VtkChartXyModel;

            if (model == null)
            {
                return;
            }

            vtkTable table = plot.Table;

            if (table.GetNumberOfColumns() == 0)
            {
                this.Log.Error("SetYArray(): No XArray data");
                return;
            }

            if (table.GetNumberOfColumns() == 1)
            {
                table.AddColumn(array);
            }
            else
            {
                table.RemoveColumn(1);
                table.AddColumn(array);
            }

            vtkPlotPoints vtkPlot = plot.PlotItem as vtkPlotPoints;

            if (vtkPlot == null)
            {
                this.Log.Error("SetYArray(): Could not cast plot item to vtkPlotPoints");
                return;
            }

            vtkPlot.SetInputData(table, 0, 1);
        }
Example #6
0
 public VtkPlotPointsModel()
 {
     Create();
     _table = new vtkTable();
 }