/// <summary>
        /// Reads new preset, updating color and opacity function from it.
        /// </summary>
        /// <param name="presetName">Name of choosen preset.</param>
        public void ChangeColorAndOpacityFunction(PresetInformation PresetInfo)
        {
            vtkColorTransferFunction ctf  = vtkColorTransferFunction.New();
            vtkPiecewiseFunction     spwf = vtkPiecewiseFunction.New();

            if (PresetInfo != null)
            {
                foreach (var pair in PresetInfo.Series[0].OpacityFunction)
                {
                    spwf.AddPoint(pair.Key, pair.Value);
                }

                foreach (var pair in PresetInfo.Series[0].ColorFuction)
                {
                    ctf.AddRGBSegment(pair.Key, pair.Value[0].R, pair.Value[0].G, pair.Value[0].B,
                                      pair.Key, pair.Value[1].R, pair.Value[1].G, pair.Value[1].B);
                }

                ctf.SetScaleToLinear();
                _volume.GetProperty().SetColor(ctf);
                _volume.GetProperty().SetScalarOpacity(spwf);

                _currentSerieNumber = 0;
                Update3DVisualization();
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Reads new preset, updating color and opacity function from it.
        /// </summary>
        /// <param name="presetName">Name of choosen preset.</param>
        public void ChangeColorAndOpacityFunction(string presetName)
        {
            vtkColorTransferFunction ctf  = vtkColorTransferFunction.New();
            vtkPiecewiseFunction     spwf = vtkPiecewiseFunction.New();

            PresetInfo = PresetReader.ReadXmlFile(presetName);
            _chart.Series["OpacityFunction"].Points.Clear();
            _chart.Series["OpacityFunctionSpline"].Points.Clear();

            foreach (var pair in PresetInfo.Series[0].OpacityFunction)
            {
                spwf.AddPoint(pair.Key, pair.Value);
                _chart.Series["OpacityFunction"].Points.AddXY(pair.Key, pair.Value);
                _chart.Series["OpacityFunctionSpline"].Points.AddXY(pair.Key, pair.Value);
            }

            foreach (var pair in PresetInfo.Series[0].ColorFuction)
            {
                ctf.AddRGBSegment(pair.Key, pair.Value[0].R, pair.Value[0].G, pair.Value[0].B,
                                  pair.Key, pair.Value[1].R, pair.Value[1].G, pair.Value[1].B);
                //Color colorRight = Color.FromArgb((int)pair.Value[1].R, (int)pair.Value[1].G, (int)pair.Value[1].B);
                //Color colorLeft = Color.FromArgb((int)pair.Value[0].R, (int)pair.Value[0].G, (int)pair.Value[0].B);
            }

            ctf.SetScaleToLinear();
            _volume.GetProperty().SetColor(ctf);
            _volume.GetProperty().SetScalarOpacity(spwf);

            _currentSerieNumber = 0;
        }