Пример #1
0
        protected override void RenderCursor()
        {
            uint colorCursor    = (uint)ColorCursor.ToArgb();
            uint colorCursorBox = (uint)CursorBoxColor.ToArgb();

            float stubLength = (float)DirectXHeight / 10.0f;
            float xPos       = (float)LastMousePos.X;
            float yPos       = (float)LastMousePos.Y;
            float unit       = (float)(SampleFromYPos(yPos) * ScaleUnitFactor);

            if (UpdateCursor)
            {
                UpdateCursor = false;

                /* draw vertical cursor line */
                if (xPos > DirectXWidth / 2)
                {
                    CursorVertexesVert[0].PositionRhw.X = xPos - 30;
                }
                else
                {
                    CursorVertexesVert[0].PositionRhw.X = xPos + 30;
                }
                CursorVertexesVert[1].PositionRhw.X = xPos;
                CursorVertexesVert[2].PositionRhw.X = xPos;
                CursorVertexesVert[3].PositionRhw.X = xPos;

                /* horizontal line */
                CursorVertexesHor[0].PositionRhw.X = xPos - 30;
                CursorVertexesHor[0].PositionRhw.Y = yPos;

                CursorVertexesHor[1].PositionRhw.X = xPos;
                CursorVertexesHor[1].PositionRhw.Y = yPos;

                CursorVertexesHor[2].PositionRhw.X = xPos + 30;
                CursorVertexesHor[2].PositionRhw.Y = yPos;


                /* recalc lines (this is needed just once btw.) */
                CursorVertexesVert[0].PositionRhw.Y = 20;
                CursorVertexesVert[0].PositionRhw.Z = 0.5f;
                CursorVertexesVert[0].PositionRhw.W = 1;
                CursorVertexesVert[0].Color         = colorCursor & 0x00FFFFFF;

                CursorVertexesVert[1].PositionRhw.Y = 20 + stubLength;
                CursorVertexesVert[1].PositionRhw.Z = 0.5f;
                CursorVertexesVert[1].PositionRhw.W = 1;
                CursorVertexesVert[1].Color         = colorCursor;

                CursorVertexesVert[2].PositionRhw.Y = DirectXHeight - stubLength;
                CursorVertexesVert[2].PositionRhw.Z = 0.5f;
                CursorVertexesVert[2].PositionRhw.W = 1;
                CursorVertexesVert[2].Color         = colorCursor;

                CursorVertexesVert[3].PositionRhw.Y = DirectXHeight;
                CursorVertexesVert[3].PositionRhw.Z = 0.5f;
                CursorVertexesVert[3].PositionRhw.W = 1;
                CursorVertexesVert[3].Color         = colorCursor;

                CursorVertexesHor[0].PositionRhw.Z = 0.5f;
                CursorVertexesHor[0].PositionRhw.W = 1;
                CursorVertexesHor[0].Color         = colorCursor & 0x00FFFFFF;

                CursorVertexesHor[1].PositionRhw.Z = 0.5f;
                CursorVertexesHor[1].PositionRhw.W = 1;
                CursorVertexesHor[1].Color         = colorCursor;

                CursorVertexesHor[2].PositionRhw.Z = 0.5f;
                CursorVertexesHor[2].PositionRhw.W = 1;
                CursorVertexesHor[2].Color         = colorCursor & 0x00FFFFFF;
            }

            if (MouseHovering || ShowVerticalCursor)
            {
                string signalPower = unit + " " + ScaleUnit;
                string positionLabel;
                if (OverviewMode)
                {
                    positionLabel = XLabelFromSampleNum(xPos);
                }
                else
                {
                    positionLabel = XLabelFromCursorPos(xPos);
                }

                int signalPowerWidth    = SmallFont.MeasureString(null, signalPower, DrawTextFormat.Center).Width;
                int positionLabelWidth  = SmallFont.MeasureString(null, positionLabel, DrawTextFormat.Center).Width;
                int signalPowerHeight   = SmallFont.MeasureString(null, signalPower, DrawTextFormat.Center).Height;
                int positionLabelHeight = SmallFont.MeasureString(null, positionLabel, DrawTextFormat.Center).Height;

                int boxWidth  = 10 + Math.Max(signalPowerWidth, positionLabelWidth);
                int boxHeight = 10 + signalPowerHeight + positionLabelHeight;
                int boxY      = 20;
                int boxX      = (int)xPos;

                if (xPos > DirectXWidth / 2)
                {
                    boxX -= boxWidth + 25;
                }
                else
                {
                    boxX += 25;
                }

                BuildStripRectangle(CursorRectVertexes, colorCursorBox & 0x3FFFFFFF, boxX, boxX + boxWidth, boxY + boxHeight, boxY);

                Device.DrawUserPrimitives(PrimitiveType.TriangleStrip, 2, CursorRectVertexes);
                Device.DrawUserPrimitives(PrimitiveType.LineStrip, 3, CursorVertexesVert);

                if (MouseHovering)
                {
                    /* draw the strength into box */
                    SmallFont.DrawString(null, signalPower, boxX + 5, boxY + 5, ColorFG.ToArgb());
                    Device.DrawUserPrimitives(PrimitiveType.LineStrip, 2, CursorVertexesHor);
                }

                /* draw the horizontal into box */
                SmallFont.DrawString(null, positionLabel, boxX + 5, boxY + 5 + signalPowerHeight, ColorFG.ToArgb());
            }
        }
Пример #2
0
        protected override void CreateVertexBufferForPoints(Point[] points, int numPoints)
        {
            if (points == null)
            {
                return;
            }

            try
            {
                uint colorFG = ((uint)ColorFG.ToArgb()) & 0xFFFFFF;

                if (numPoints > 0)
                {
                    double xDist = 1;

                    if (RenderAsLines)
                    {
                        if (PlotVerts == null || numPoints > PlotVerts.Length)
                        {
                            PlotVerts = new Vertex[numPoints];
                        }
                        if (numPoints > PlotVertsOverview.Length)
                        {
                            PlotVertsOverview = new Vertex[numPoints];
                        }
                        PlotVertsEntries = numPoints - 1;
                        xDist            = DirectXWidth / ((double)PlotVertsEntries);
                    }
                    else
                    {
                        if (numPoints * 2 > PlotVerts.Length)
                        {
                            PlotVerts         = new Vertex[numPoints * 2];
                            PlotVertsOverview = new Vertex[numPoints * 2];
                        }
                        PlotVertsEntries = 2 * numPoints - 1;
                        xDist            = DirectXWidth / ((double)PlotVertsEntries / 2.0f);
                    }


                    int outPos = 0;
                    for (int pos = 0; pos < numPoints; pos++)
                    {
                        double yVal = points[pos].Y;
                        double xPos = (double)points[pos].X * xDist;

                        PlotVerts[outPos].PositionRhw.X = (float)Math.Min(DirectXWidth, Math.Max(0, ((XAxisSampleOffset + xPos) * XZoomFactor - DisplayXOffset)));
                        PlotVerts[outPos].PositionRhw.Y = (float)Math.Min(DirectXHeight, Math.Max(0, yVal));
                        PlotVerts[outPos].PositionRhw.Z = 0.5f;
                        PlotVerts[outPos].PositionRhw.W = 1;
                        PlotVerts[outPos].Color         = 0x9F000000 | colorFG;

                        if (OverviewModeEnabled)
                        {
                            PlotVertsOverview[pos].PositionRhw.X = (float)Math.Min(DirectXWidth, Math.Max(0, (XAxisSampleOffset + xPos)));
                            PlotVertsOverview[pos].PositionRhw.Y = PlotVerts[pos].PositionRhw.Y;
                            PlotVertsOverview[pos].PositionRhw.Z = PlotVerts[pos].PositionRhw.Z;
                            PlotVertsOverview[pos].PositionRhw.W = PlotVerts[pos].PositionRhw.W;
                            PlotVertsOverview[pos].Color         = PlotVerts[pos].Color;
                        }

                        outPos++;

                        if (!RenderAsLines)
                        {
                            PlotVerts[outPos] = PlotVerts[outPos - 1];
                            PlotVerts[outPos].PositionRhw.Z += 0.1f;
                            outPos++;
                        }
                    }

                    try
                    {
                        foreach (DirectXDrawable drawable in Drawables)
                        {
                            if (drawable is PlotVertsSink)
                            {
                                ((PlotVertsSink)drawable).ProcessPlotVerts(PlotVerts, PlotVertsEntries);
                            }
                        }
                    }
                    catch (Exception e)
                    {
                    }
                }
            }
            catch (Exception e)
            {
                return;
            }
        }