コード例 #1
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;
        }
コード例 #2
0
ファイル: ExportForm.cs プロジェクト: tomvoros/lets-tag
        void ReloadPresets(string defaultPresetName)
        {
            presetComboBox.Items.Clear();
            presetComboBox.Items.Add(blankPreset);

            Preset defaultPreset = blankPreset;

            defaultPresetName = defaultPresetName.ToLower();
            string[] presetFiles = PresetManager.GetPresetFiles();
            foreach (string presetFile in presetFiles)
            {
                try
                {
                    Preset preset = PresetReader.LoadPreset(presetFile);
                    presetComboBox.Items.Add(preset);

                    if (preset.Name.ToLower() == defaultPresetName)
                    {
                        defaultPreset = preset;
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(string.Format("{0} is not a valid preset file:\n{1}", presetFile, ex.Message), null, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }

            presetComboBox.SelectedItem = defaultPreset;
        }
コード例 #3
0
 static Preset GetPreset(IDictionary <string, string> options)
 {
     try
     {
         string presetName = "Default.xml";
         if (options.ContainsKey("preset"))
         {
             presetName = options["preset"];
             if (string.IsNullOrEmpty(Path.GetExtension(presetName)))
             {
                 presetName = string.Format("{0}.xml", presetName);
             }
         }
         return(PresetReader.LoadPreset(presetName));
     }
     catch (Exception ex)
     {
         throw new LetsTagException("Could not load preset", ex);
     }
 }