Esempio n. 1
0
        public void DetermineNewFrequencyRange(int x, ref Int64 Low, ref Int64 High, ref int SampleCount)
        {
            Int64 nCentralFrequency;
            Int64 nPreviousBW;
            Int64 nNewStartFrequency;
            Int64 nNewEndFrequency;


            nCentralFrequency = GraphConfig.GetFrequencyFromXDisplay(x);
            nPreviousBW       = GraphConfig.nLastDrawingHighFrequency - GraphConfig.nLastDrawingLowFrequency;


            if (nPreviousBW < 100)
            {
                return;
            }

            nNewStartFrequency = nCentralFrequency - (Int64)(nPreviousBW * fZoomInRatio * 0.5f);
            nNewEndFrequency   = nCentralFrequency + (Int64)(nPreviousBW * fZoomInRatio * 0.5f);


            // now we correct the zoom to take acount of discrete frequency step
            SampleCount = Owner.GetSampleCount();


            Int64 nBW = (nNewEndFrequency - nNewStartFrequency);

            Int64 nRealStep;

            if (SampleCount > nBW)
            {
                SampleCount = (int)nBW;
                nRealStep   = 1;
            }
            else
            {
                nRealStep = ((nNewEndFrequency - nNewStartFrequency) + SampleCount / 2) / SampleCount;
            }

            nNewStartFrequency = nCentralFrequency - nRealStep * SampleCount / 2;
            nNewEndFrequency   = nNewStartFrequency + nRealStep * SampleCount;


            if (nNewEndFrequency > Owner.DeviceInterface.MaxFrequency)
            {
                nNewEndFrequency = Owner.DeviceInterface.MaxFrequency;
            }

            if (nNewStartFrequency < Owner.DeviceInterface.MinFrequency)
            {
                nNewStartFrequency = Owner.DeviceInterface.MinFrequency;
            }

            Low  = nNewStartFrequency;
            High = nNewEndFrequency;
        }
Esempio n. 2
0
        public void DisplayFrequencyAndLevelOnCorners(int nXMouse)
        {
            Int64 nFrequency = GraphConfig.GetFrequencyFromXDisplay(nXMouse);


            double dBLevel;

            String LevelText = null;

            if (CurvesList.Count > 0 && ActiveCurve != null && ActiveCurve.Visible == CCurve.YesNo.Yes)
            {
                dBLevel = Math.Round(ActiveCurve.GeDBLevelFromFrequency(nFrequency), 2);
                LevelDisplayLabel.ForeColor = ActiveCurve.Color_;
                LevelText = ActiveCurve.Name + " : ";
            }
            else
            {
                dBLevel = 0.0f;
                LevelDisplayLabel.ForeColor = Color.Black;
                LevelText = "Level : ";
            }


            double ImpedanceNorm = (100.0f / ((float)Math.Pow(10.0f, dBLevel / 20.0f)) - 100.0f) / 1.0f;

            FreqDisplayLabel.Text = "Frequency : " + Utility.GetStringWithSeparators(nFrequency, " ") + "Hz";


            if (GraphConfig.outputMode == OutputMode.dB)
            {
                if (ImpedanceNorm >= 0)
                {
                    LevelDisplayLabel.Text = LevelText + dBLevel.ToString() + "dB " + " |Z|=" + Math.Round(ImpedanceNorm, 0) + " Ohms";
                }
                else
                {
                    LevelDisplayLabel.Text = LevelText + dBLevel.ToString() + "dB ";
                }
            }
            else
            {
                LevelDisplayLabel.Text = LevelText + dBLevel.ToString();
            }

            GraphConfig.DrawTopBox(CurvesList, nFrequency);
        }
Esempio n. 3
0
        private void SpectrumPictureBoxClass_MouseClick(object sender, MouseEventArgs e)
        {
            if (Owner.DeviceInterface.GetDevice() == null)
            {
                return; // no device
            }
            MouseEventArgs Event = (MouseEventArgs)e;
            {
                Int64 nCentralFrequency;
                Int64 nPreviousBW;
                Int64 nNewStartFrequency;
                Int64 nNewEndFrequency;


                nCentralFrequency = GraphConfig.GetFrequencyFromXDisplay(Event.X);
                nPreviousBW       = GraphConfig.nLastDrawingHighFrequency - GraphConfig.nLastDrawingLowFrequency;


                if (Event.Button == MouseButtons.Left)
                {
                    if (nPreviousBW < 100)
                    {
                        return;
                    }

                    nNewStartFrequency = nCentralFrequency - (Int64)(nPreviousBW * fZoomInRatio * 0.5f);
                    nNewEndFrequency   = nCentralFrequency + (Int64)(nPreviousBW * fZoomInRatio * 0.5f);
                }
                else
                {
                    nNewStartFrequency = nCentralFrequency - nPreviousBW;
                    nNewEndFrequency   = nCentralFrequency + nPreviousBW;
                }

                // now we correct the zoom to take acount of discrete frequency step
                int nSampleCount = Owner.GetSampleCount();


                Int64 nBW = (nNewEndFrequency - nNewStartFrequency);

                Int64 nRealStep;
                if (nSampleCount > nBW)
                {
                    nSampleCount = (int)nBW;
                    Owner.SetSampleCount(nSampleCount);
                    nRealStep = 1;
                }
                else
                {
                    nRealStep = ((nNewEndFrequency - nNewStartFrequency) + nSampleCount / 2) / nSampleCount;
                }

                nNewStartFrequency = nCentralFrequency - nRealStep * nSampleCount / 2;
                nNewEndFrequency   = nNewStartFrequency + nRealStep * nSampleCount;


                if (nNewEndFrequency > Owner.DeviceInterface.MaxFrequency)
                {
                    nNewEndFrequency = Owner.DeviceInterface.MaxFrequency;
                }

                if (nNewStartFrequency < Owner.DeviceInterface.MinFrequency)
                {
                    nNewStartFrequency = Owner.DeviceInterface.MinFrequency;
                }


                GraphConfig.nLastDrawingLowFrequency  = nNewStartFrequency;
                GraphConfig.nLastDrawingHighFrequency = nNewEndFrequency;

                DrawCurveCollection(CurvesList);
                Owner.SetSweepStartFrequency(nNewStartFrequency);
                Owner.SetSweepEndFrequency(nNewEndFrequency);
            }
        }