Ejemplo n.º 1
0
        void _drawFFTVerticalGridLines(CustomGraphics g)
        {
            /* Draw x-grid lines and label the frequencies in the FFT that they point to. */
            int    prevEnd      = 0;
            int    divs         = 20;
            double maxFrequency = 1 / (ControlPanel.TimeStep * Speed * divs * 2);

            g.LineColor = Color.FromArgb(0x88, 0x00, 0x00);
            for (int i = 0; i < divs; i++)
            {
                int x = BoundingBox.Width * i / divs;
                if (x < prevEnd)
                {
                    continue;
                }
                string s      = ((int)Math.Round(i * maxFrequency)) + "Hz";
                int    sWidth = (int)Math.Ceiling(g.GetTextSize(s).Width);
                prevEnd = x + sWidth + 4;
                if (i > 0)
                {
                    g.DrawLine(x, 0, x, BoundingBox.Height);
                }
                g.DrawLeftText(s, x + 2, BoundingBox.Height - 12);
            }
        }
Ejemplo n.º 2
0
 void _drawInfoText(CustomGraphics g, string text)
 {
     if (BoundingBox.Y + BoundingBox.Height <= mTextY + 5)
     {
         return;
     }
     g.DrawLeftText(text, 0, mTextY);
     mTextY += 15;
 }
Ejemplo n.º 3
0
        void _drawInfoTexts(CustomGraphics g)
        {
            mTextY = 10;
            var plot = mVisiblePlots[0];

            if (ShowScale)
            {
                string vScaleText = "";
                if (mGridStepY != 0 && (!ShowV))
                {
                    vScaleText = " V=" + plot.GetUnitText(mGridStepY) + "/div";
                }
                _drawInfoText(g, "H=" + Utils.UnitText(mGridStepX, "s") + "/div" + vScaleText);
            }
            if (ShowMax)
            {
                _drawInfoText(g, plot.GetUnitText(mMaxValue));
            }
            if (ShowMin)
            {
                int ym = BoundingBox.Height - 5;
                g.DrawLeftText(plot.GetUnitText(mMinValue), 0, ym);
            }
            if (ShowRMS)
            {
                _drawRMS(g);
            }
            string t = Text;

            if (t == null)
            {
                t = mScopeText;
            }
            if (t != null)
            {
                _drawInfoText(g, t);
            }
            if (ShowFreq)
            {
                _drawFrequency(g);
            }
        }
Ejemplo n.º 4
0
        void _drawCrosshairs(CustomGraphics g)
        {
            if (CirSim.Sim.DialogIsShowing())
            {
                return;
            }
            if (!BoundingBox.Contains(CirSim.Sim.MouseCursorX, CirSim.Sim.MouseCursorY))
            {
                return;
            }
            if (SelectedPlot < 0 && !ShowFFT)
            {
                return;
            }
            var info = new string[4];
            int ipa  = mPlots[0].StartIndex(BoundingBox.Width);
            int ip   = (CirSim.Sim.MouseCursorX - BoundingBox.X + ipa) & (mScopePointCount - 1);
            int ct   = 0;
            int maxy = (BoundingBox.Height - 1) / 2;
            int y    = maxy;

            if (SelectedPlot >= 0)
            {
                var plot = mVisiblePlots[SelectedPlot];
                info[ct++] = plot.GetUnitText(plot.MaxValues[ip]);
                int maxvy = (int)(mMainGridMult * (plot.MaxValues[ip] - mMainGridMid));
                g.LineColor = plot.Color;
                g.FillCircle(CirSim.Sim.MouseCursorX, BoundingBox.Y + y - maxvy, 2.5f);
            }
            if (ShowFFT)
            {
                double maxFrequency = 1 / (ControlPanel.TimeStep * Speed * 2);
                info[ct++] = Utils.UnitText(maxFrequency * (CirSim.Sim.MouseCursorX - BoundingBox.X) / BoundingBox.Width, "Hz");
            }
            if (mVisiblePlots.Count > 0)
            {
                double t = CirSim.Sim.Time - ControlPanel.TimeStep * Speed * (BoundingBox.X + BoundingBox.Width - CirSim.Sim.MouseCursorX);
                info[ct++] = Utils.TimeText(t);
            }

            int szw = 0, szh = 15 * ct;

            for (int i = 0; i != ct; i++)
            {
                int w = (int)g.GetTextSize(info[i]).Width;
                if (w > szw)
                {
                    szw = w;
                }
            }

            g.LineColor = CustomGraphics.WhiteColor;
            g.DrawLine(CirSim.Sim.MouseCursorX, BoundingBox.Y, CirSim.Sim.MouseCursorX, BoundingBox.Y + BoundingBox.Height);

            int bx = CirSim.Sim.MouseCursorX;

            if (bx < szw / 2)
            {
                bx = szw / 2;
            }

            g.LineColor = ControlPanel.ChkPrintable.Checked ? Color.White : Color.Black;
            g.FillRectangle(bx - szw / 2, BoundingBox.Y - szh, szw, szh);

            for (int i = 0; i != ct; i++)
            {
                int w = (int)g.GetTextSize(info[i]).Width;
                g.DrawLeftText(info[i], bx - w / 2, BoundingBox.Y - 2 - (ct - 1 - i) * 15);
            }
        }