Пример #1
0
        void SingleCurveDisplay(Int64 nFrequencyBase, Int64 nStep, float [] data)
        {
            int    Count = data.Length;
            CCurve Curve = (CCurve)SweepModeCurvesList[0];

            Curve.Color_ = Color.DeepPink;

            /*
             * CGraph Graph = SpectrumPictureBox.GetGraphConfig();
             * Graph.nLastDrawingLowFrequency = nFrequencyBase;
             * Graph.nLastDrawingHighFrequency = nFrequencyBase + nStep * Count;
             * Graph.fLastDrawingLevelLow = -90;
             * Graph.fLastDrawingLevelHigh = 0;
             *
             * SpectrumPictureBox.GetGraphConfig().DrawBackGround();
             */
            Curve.SpectrumValues         = data;
            Curve.nSpectrumLowFrequency  = nFrequencyBase;
            Curve.nSpectrumHighFrequency = nFrequencyBase + nStep * Count;
            Curve.Name = "Crystal";
            Curve.DetermineMinMaxLevels();

            SpectrumPictureBox.DrawCurveCollection(SweepModeCurvesList);
            //SpectrumPictureBox.DrawSingleCurve(Curve);
        }
Пример #2
0
        private void LoadCurveButton_Click(object sender, EventArgs e)
        {
            OpenFileDialog dialog = new OpenFileDialog();

            dialog.Filter           = "Curves files (*.xml)|*.xml|all files (*.*)|*.*";
            dialog.InitialDirectory = Program.CurvesPath;
            dialog.RestoreDirectory = true;


            if (dialog.ShowDialog() == DialogResult.OK)
            {
                XmlSerializer xs = new XmlSerializer(typeof(CCurve));
                using (StreamReader wr = new StreamReader(dialog.FileName))
                {
                    try
                    {
                        CCurve CurveToLoad = xs.Deserialize(wr) as CCurve;
                        CurveToLoad.ComputeCaracteristicsParams();

                        SweepModeCurvesList.Add(CurveToLoad);
                        UpdateCurveComboBoxFromCurveList();

                        SpectrumPictureBox.DrawCurveCollection(SweepModeCurvesList);
                        CurveListComboBox.SelectedIndex = SweepModeCurvesList.Count - 1;
                    }
                    catch (Exception)
                    {
                        LOGError("sorry, your curve file format is incompatible with this software version");
                    }

                    Program.CurvesPath = System.IO.Path.GetDirectoryName(dialog.FileName);
                }
            }
        }
Пример #3
0
        public void ProcessSweepModeDisplayAcquisition(NWTDevice.RunSweepModeParam AcquisitionParams)
        {
            CGraph Graph       = SpectrumPictureBox.GetGraphConfig();
            CCurve CurveConfig = (CCurve)CurveConfigPropertyGrid.SelectedObject;

            SpectrumPictureBox.SetActiveCurve(CurveConfig);

            CurveConfig.nSpectrumLowFrequency  = AcquisitionParams.nBaseFrequency;
            CurveConfig.nSpectrumHighFrequency = AcquisitionParams.nBaseFrequency + AcquisitionParams.nFrequencyStep * AcquisitionParams.nCount;
            CurveConfig.nFrequencyStep         = AcquisitionParams.nFrequencyStep;

            if (AcquisitionParams.ResultDatas != null)
            {
                Utility.FilterArray(AcquisitionParams.ResultDatas, (int)((FilterMode)FilterComboBox.SelectedItem));
                CurveConfig.SpectrumValues = AcquisitionParams.ResultDatas;
                CurveConfig.DetermineMinMaxLevels();
                CurveConfig.ComputeCaracteristicsParams();
                if (bLoop == false)
                {
                    LOGDraw(""); // new line
                    LOGDraw("*** ----- RESULTS----- ***");
                    LOGDraw(CurveConfig.GetCurveDescription());
                }
            }

            Graph.nLastDrawingLowFrequency  = nFrequencyDetectionStart;
            Graph.nLastDrawingHighFrequency = nFrequencyDetectionEnd;
            SpectrumPictureBox.DrawCurveCollection(SweepModeCurvesList, bLoop);
        }
Пример #4
0
        public void DrawTopBox(ArrayList curveList = null, Int64 CursorFrequency = -1)
        {
            Graphics g = Graphics.FromImage(BitmapWhereDraw);

            g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
            int   nWidth           = BitmapWhereDraw.Size.Width - LeftBorder - RightBorder;
            int   nHeight          = BitmapWhereDraw.Size.Height - UpBorder - LowBorder;
            float nFontSize        = 12.0f;
            float nFontVerticalPos = UpBorder / 2 - 8;

            SolidBrush ClearBrush = new SolidBrush(Color.White);

            g.FillRectangle(ClearBrush, new Rectangle(LeftBorder, 0, BitmapWhereDraw.Size.Width, UpBorder - 15));
            // display curve name
            System.Drawing.Font CurveFont = new Font("Verdana", nFontSize);


            if (curveList != null)
            {
                int nVisibleCurveCount = 0;
                foreach (CCurve Curve in curveList)
                {
                    if (Curve.Visible == CCurve.YesNo.Yes)
                    {
                        nVisibleCurveCount++;
                    }
                }

                int HCurveGranularity = BitmapWhereDraw.Size.Width / (1 + nVisibleCurveCount);

                int nXStart = HCurveGranularity;

                for (int nCurve = 0; nCurve < curveList.Count; nCurve++)
                {
                    CCurve Curve = (CCurve)curveList[nCurve];

                    if (Curve.Visible == CCurve.YesNo.Yes)
                    {
                        SolidBrush CurveBrush = new SolidBrush(Curve.Color_);
                        Pen        mypen      = new Pen(Curve.Color_, Curve.LineWidth + 1);
                        //mypen.DashStyle = Curve._Style;

                        String TextToDraw = Curve.Name;
                        if (CursorFrequency >= 0)
                        {
                            double dBLevel = Math.Round(Curve.GeDBLevelFromFrequency(CursorFrequency), 2);
                            TextToDraw += ":" + dBLevel.ToString() + "dB";
                        }

                        g.DrawLine(mypen, nXStart - 15, nFontVerticalPos + 10, nXStart, nFontVerticalPos + 10);
                        g.DrawString(TextToDraw, CurveFont, CurveBrush, new PointF(nXStart + 2, nFontVerticalPos));
                        nXStart += HCurveGranularity;
                    }
                }
            }
            g.Dispose();
        }
Пример #5
0
        private void ForceRangeButton_Click(object sender, EventArgs e)
        {
            CCurve ActiveCurve = (CCurve)CurveConfigPropertyGrid.SelectedObject;

            if (ActiveCurve != null && ActiveCurve.SpectrumValues != null)
            {
                SetSweepFrequencies(ActiveCurve.nSpectrumLowFrequency, ActiveCurve.nSpectrumHighFrequency);
            }
        }
Пример #6
0
        private void CurveConfigPropertyGrid_PropertyValueChanged(object s, System.Windows.Forms.PropertyValueChangedEventArgs e)
        {
            CCurve Curve = (CCurve)CurveConfigPropertyGrid.SelectedObject;

            Curve.ComputeCaracteristicsParams();
            SpectrumPictureBox.Redraw();
            UpdateCurveComboBoxFromCurveList();
            CurveListComboBox.SelectedItem = CurveConfigPropertyGrid.SelectedObject;
        }
Пример #7
0
        private void AddNewCurveButton_Click(object sender, EventArgs e)
        {
            CCurve NewCurve = new CCurve();

            NewCurve.Name   = "Curve_" + SweepModeCurvesList.Count;
            NewCurve.Color_ = GetDefaultCurveColor(SweepModeCurvesList.Count);
            SweepModeCurvesList.Add(NewCurve);
            CurveListComboBox.DataSource   = null;
            CurveListComboBox.DataSource   = SweepModeCurvesList;
            CurveListComboBox.SelectedItem = NewCurve;
            SpectrumPictureBox.DrawCurveCollection(SweepModeCurvesList);
            CurveConfigPropertyGrid.SelectedObject = NewCurve;
        }
Пример #8
0
 private void CurveListComboBox_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (CurveListComboBox.SelectedIndex != -1)
     {
         CurveConfigPropertyGrid.SelectedObject = SweepModeCurvesList[CurveListComboBox.SelectedIndex];
         SpectrumPictureBox.SetActiveCurve((CCurve)SweepModeCurvesList[CurveListComboBox.SelectedIndex]);
         SpectrumPictureBox.Redraw();
         CCurve Curve = (CCurve)SweepModeCurvesList[CurveListComboBox.SelectedIndex];
         if (Curve.SpectrumValues != null && Curve.SpectrumValues.Length > 0)
         {
             LOGDraw("***------ SELECTED CURVE ----------***");
             LOGDraw(Curve.GetCurveDescription());
         }
     }
 }
Пример #9
0
 public void GraphicDisplay(ArrayList curveList, CCurve ActiveCurve, Bitmap PictureBoxBitmap)
 {
     BitmapWhereDraw = PictureBoxBitmap;
     DrawBackGround(curveList);
     if (curveList != null)
     {
         for (int i = 0; i < curveList.Count; i++)
         {
             if (curveList[i] != null)
             {
                 bool IsActive = (curveList[i] == ActiveCurve);
                 ((CCurve)curveList[i]).Draw(this, IsActive);
             }
         }
     }
 }
Пример #10
0
        public void DrawSingleCurve(CCurve _curve)
        {
            if (Size.Width == 0 || Size.Height == 0)
            {
                return;
            }

            if (_curve.SpectrumValues != null)
            {
                _curve.DetermineMinMaxLevels();
            }

            CurvesList.Clear();
            CurvesList.Add(_curve);
            ActiveCurve = _curve;
            DrawCurveCollection(CurvesList);
        }
Пример #11
0
        private void SaveCurveButton_Click(object sender, EventArgs e)
        {
            SaveFileDialog dialog = new SaveFileDialog();

            dialog.Filter = "Curves files (*.xml)|*.xml|all files (*.*)|*.*";
            CCurve CurveToSave = (CCurve)CurveConfigPropertyGrid.SelectedObject;

            dialog.InitialDirectory = Program.CurvesPath;
            dialog.FileName         = CurveToSave.ToString() + ".xml";


            if (dialog.ShowDialog() == DialogResult.OK)
            {
                XmlSerializer xs = new XmlSerializer(typeof(CCurve));
                using (StreamWriter wr = new StreamWriter(dialog.FileName))
                {
                    xs.Serialize(wr, CurveToSave);
                }
            }
        }
Пример #12
0
 public void SetActiveCurve(CCurve Active)
 {
     ActiveCurve = Active;
 }