public SpectrumEditorTabPage(Spectrum spec)
        {
            InitializeComponent();

            init();

            Spectrum = spec;
        }
        public SpectrumEditorControl(Spectrum spectrum_)
        {
            InitializeComponent();

            init();

            SetSpectrum(spectrum_);
        }
        public SpectrumEditorTabPage(SpectrumLibrary specLib_, Spectrum spec)
        {
            InitializeComponent();

            init();

            SetSpectrumLibrary(specLib_);
            Spectrum = spec;
        }
        public SpectrumEditorControl()
        {
            InitializeComponent();
            
            init();

            Spectrum spectrum_ = new Spectrum(ESpectrumTemplate.ExtendedVisible);
            spectrum_.AddSpectralPoint(580, 0);

            SetSpectrum(spectrum_);
        }
 void specEdControl_OnSpectrumEditorSave(Spectrum spec)
 {
     CallSpectrumModified();
 }
Example #6
0
        public Spectrum(Spectrum sp)
        {
            //properties kopieren
            name = sp.Name;
            category = sp.Category;
            specInt = sp.Interpolation;
            points = new SpectralPointCollection(sp.Points);
            baseIntensity = sp.BaseIntensity;
            imageIndex = sp.ImageIndex;
            lambdaMin = sp.LambdaMin;
            lambdaMax = sp.LambdaMax;

            CallSpectrumChanged();
        }
 void sl_OnCategorySpectrumAdded(int idx, Spectrum spec, string category)
 {
     InvalidateSpectrumLibrary();
 }
 private void AddImages(int idx, Spectrum spec)
 {
     if (idx != imagesSmall.Images.Count)
         InvalidateImages();
     else
     {
         imagesSmall.Images.Add(specDrawer.GetBitmap(spec, true, imageSizeSmall));
         imagesLarge.Images.Add(specDrawer.GetBitmap(spec, true, imageSizeLarge));
         spec.ImageIndex = idx;
     }
 }
 public int GetIndex(Spectrum spec)
 {
     return spectra.GetIndex(spec);
 }
        public void DoViewSpectrum(Spectrum spec)
        {
            if (OnViewSpectrum != null)
            {
                int idx = GetIndex(spec);
                if (idx > -1)
                {
                    String category = GetCategory(spec);

                    OnViewSpectrum(idx, spec, category);
                }
            }
        }
        public void ChangeCategory(Spectrum spec, String categoryOld, String categoryNew)
        {
            // TODO edit spectrum also
            int idx = spectra.GetIndex(spec);
            RemoveCategory(idx, categoryOld);
            SetCategory(idx, categoryNew);

            if (OnSpectrumCategoryChanged != null)
                OnSpectrumCategoryChanged(idx, spec, categoryOld, categoryNew);
        }
 private void overwriteToolStripMenuItem_Click(object sender, EventArgs e)
 {
     backup = new Spectrum(Spectrum);
 }
        private void SetSpectrum(Spectrum spectrum_)
        {
            specPanel.Spectrum = spectrum_;
            backup = new Spectrum(spectrum_);

            InternalUpdate();
        }
        private void ParseImage()
        {
            if ((imProp.Image != null) && (imProp.StartPoint != new Point(-1, -1)) && (imProp.EndPoint != new Point(-1, -1)))
            {
                CreateBackBuffer();

                spectrum = new Spectrum();

                int x_len = imProp.EndPoint.X - imProp.StartPoint.X;
                int y_len = imProp.EndPoint.Y - imProp.StartPoint.Y;

                double dLambda = (imProp.EndLambda - imProp.StartLambda) / (double)x_len;
                double dIntensity = (imProp.MaxIntensity - imProp.MinIntensity) / (double)y_len;

                double lambda = imProp.StartLambda;

                for (int xx = 0; xx <= Math.Abs(x_len); xx++)
                {
                    double intensity = imProp.MinIntensity;
                    for (int yy = 0; yy <= Math.Abs(y_len); yy++)
                    {
                        int x = Math.Sign(x_len) * xx + imProp.StartPoint.X;
                        int y = Math.Sign(y_len) * yy + imProp.StartPoint.Y;
                        if (backBufferBMP.GetPixel(x, y) == imProp.GraphColor)
                        {
                            intensity = imProp.MinIntensity + yy * Math.Abs(dIntensity);
                        }

                    }
                    spectrum.AddSpectralPoint(lambda, intensity);
                    lambda += dLambda;
                }
            }
        }
 void specLib_OnEditSpectrum(int idx, Spectrum spec, string category)
 {
     Spectrum = spec;
     ((TabControl) this.Parent).SelectTab(this);
 }
        public void AddSpectrum(Spectrum spec, String category)
        {
            int idx = spectra.Add(spec);

            AddImages(idx, spec);
            spec.Category = category;

            SetCategory(idx, category);
            if (OnCategorySpectrumAdded != null)
                OnCategorySpectrumAdded(idx, spec, category);
        }
        public void AddSpectrum(Spectrum spec)
        {
            int idx = spectra.Add(spec);

            AddImages(idx, spec);

            if (spec.Category == "")
                spec.Category = "[blank]";

            SetCategory(idx, spec.Category);
            if (OnCategorySpectrumAdded != null)
                OnCategorySpectrumAdded(idx, spec, spec.Category);
        }
 private void SetSpectrum(Spectrum spec)
 {
     spectrum = spec;
     if (spectrum != null)
     {
         spectrum.OnSpectrumChanged += new Spectrum.SpectrumChanged(spectrum_OnSpectrumChanged);
         DrawSpectrum();
     }
 }
        public void DoSpectrumModified(Spectrum spec)
        {
            if (OnSpectrumModified != null)
            {
                int idx = GetIndex(spec);
                if (idx > -1)
                {
                    String category = GetCategory(spec);

                    UpdateImage(idx, spec);

                    OnSpectrumModified(idx, spec, category);
                }
            }
        }
        private void AddSpectrumItem(Spectrum spec)
        {
            SmallImageList.Images.Add(specPainter.GetBitmap(spec, true, SmallImageList.ImageSize));
            LargeImageList.Images.Add(specPainter.GetBitmap(spec, true, LargeImageList.ImageSize));
            int idx = SmallImageList.Images.Count - 1;

            ListViewItem lvi = SpectrumGUIHelper.CreateListViewItem(spec);
            lvi.ImageIndex = idx;

            Items.Add(lvi);
        }
 public String GetCategory(Spectrum spec)
 {
     if (categories.ContainsKey(spec.Category))
         return spec.Category;
     else
     {
         int idx = GetIndex(spec);
         if (idx > -1)
             foreach (String category in categories.Keys)
                 if (((ArrayList)categories[category]).Contains(idx))
                     return category;
         return "";
     }
 }
 void collection_OnSpectrumAdded(int idx, Spectrum spec)
 {
     InvalidateCollection();
 }
        public void RemoveSpectrum(Spectrum spec)
        {
            int idx = spectra.GetIndex(spec);

            if (OnPreSpectrumRemoved != null)
                OnPreSpectrumRemoved(idx);

            // TODO can be done via spectrum
            foreach (String category in categories.Keys)
            {
                if (((ArrayList)categories[category]).Contains(idx))
                {
                    ((ArrayList)categories[category]).Remove(idx);
                    if (OnSpectrumRemoved != null)
                        OnSpectrumRemoved(idx, category);
                }

            }
            spectra.Remove(spec);
            imagesSmall.Images.RemoveAt(idx);
            imagesLarge.Images.RemoveAt(idx);
        }
 public void AddToCollection(Spectrum spec)
 {
     Collection.Add(new Spectrum(spec));
 }
 private void UpdateImage(int idx, Spectrum spec)
 {
     if (Helper.InRange(idx, 0, imagesSmall.Images.Count - 1))
     {
         imagesSmall.Images[idx] = specDrawer.GetBitmap(spec, true, imageSizeSmall);
         imagesLarge.Images[idx] = specDrawer.GetBitmap(spec, true, imageSizeLarge);
     }
 }
 void specLib_OnSpectrumModified(int idx, Spectrum spec, string category)
 {
     this.Invalidate();
 }
 void sl_OnSpectrumModified(int idx, Spectrum spec, string category)
 {
     if (category == this.category)
     {
         for (int i = 0; i < Items.Count; i++)
             if (Items[i].ImageIndex == idx)
                 SpectrumGUIHelper.UpdateListViewItem(Items[i], spec);
     }
 }
 public void Redo(Spectrum spec)
 {
     switch (action)
     {
         case EAction.Moved:
             spec.SetSpectralPoint(actionAfter, actionBefore);
             break;
         case EAction.Added:
             spec.AddSpectralPoint(actionAfter);
             break;
         case EAction.Deleted:
             spec.DeleteSpectralPoint(actionBefore);
             break;
         case EAction.None:
         default:
             break;
     }
 }
Example #29
0
        public void Clone(Spectrum spec)
        {
            category = spec.Category;
            name = spec.Name;
            specInt = spec.Interpolation;
            lambdaMin = spec.LambdaMin;
            lambdaMax = spec.LambdaMax;
            imageIndex = spec.ImageIndex;
            baseIntensity = spec.BaseIntensity;

            points.Clear();
            foreach (SpectralPoint sp in spec.Points)
                points.Add(new SpectralPoint(sp));

            CallSpectrumChanged();
        }
 private void SetSpectrum(Spectrum spec)
 {
     CallSpectrumModified();
     externalSpectrum = true;
     specEdControl.Spectrum = spec;
     SetAppropriateName(true);
 }