Пример #1
0
        private void Display(string text, HighlighType ht, int highlightStart, int highlighLen)
        {
            if (highlighLen == 0 || highlightStart >= text.Length)
            {
                Console.Write(text);
            }
            else
            {
                Console.Write(text.Substring(0, highlightStart));
                ConsoleColor fc = Console.ForegroundColor;
                ConsoleColor bc = Console.BackgroundColor;

                switch (ht)
                {
                case HighlighType.StatementLocation:
                    Console.ForegroundColor = ConsoleColor.Yellow;
                    break;

                case HighlighType.Error:
                    Console.ForegroundColor = ConsoleColor.Red;
                    break;

                default:
                    Debug.Assert(false);
                    throw new InvalidOperationException();
                }
                int l = highlightStart + highlighLen;
                if (l > text.Length)
                {
                    highlighLen = text.Length - highlightStart;
                }
                Console.Write(text.Substring(highlightStart, highlighLen));
                Console.ForegroundColor = fc;
                Console.BackgroundColor = bc;
                if (highlightStart + highlighLen < text.Length)
                {
                    Console.Write(text.Substring(highlightStart + highlighLen));
                }
            }
        }
Пример #2
0
 void Start()
 {
     highlightType = HighlighType.None;
 }
Пример #3
0
        private void Display(string text, HighlighType ht, int highlightStart, int highlighLen)
        {
            if (highlighLen == 0 || highlightStart >= text.Length)
            {
                Console.Write(text);
            }
            else
            {
                Console.Write(text.Substring(0, highlightStart));
                ConsoleColor fc = Console.ForegroundColor;
                ConsoleColor bc = Console.BackgroundColor;

                switch (ht)
                {
                    case HighlighType.StatementLocation:
                        Console.ForegroundColor = ConsoleColor.Yellow;
                        break;
                    case HighlighType.Error:
                        Console.ForegroundColor = ConsoleColor.Red;
                        break;
                    default:
                        Debug.Assert(false);
                        throw new InvalidOperationException();
                }
                int l = highlightStart + highlighLen;
                if (l > text.Length)
                {
                    highlighLen = text.Length - highlightStart;
                }
                Console.Write(text.Substring(highlightStart, highlighLen));
                Console.ForegroundColor = fc;
                Console.BackgroundColor = bc;
                if (highlightStart + highlighLen < text.Length)
                {
                    Console.Write(text.Substring(highlightStart + highlighLen));
                }
            }
        }
Пример #4
0
    void WhenVoxelsAreUp()
    {
        if (voxelVis != lastVoxelVis) InspectorT.slicerForm.panel1.Invalidate();
        lastVoxelVis = voxelVis;
        voxelVis = GUILayout.HorizontalSlider(voxelVis, 0, 100, GUILayout.Width(220), GUILayout.Height(12));
        GUILayout.Label("Visibility: " + voxelVis.ToString("f2"), KeyStyle, GUILayout.Width(250));
        highlight = GUILayout.HorizontalSlider(highlight, 0, cSectionGCD.voxels.Count - 1, GUILayout.Width(220), GUILayout.Height(12));
        GUILayout.Label("Highlight: " + highlight.ToString("f0"), KeyStyle, GUILayout.Width(250));
        if (!cSectionGCD.voxels.ContainsKey(highlightVector)) return;
        var sloxList = cSectionGCD.layers[cSectionGCD.layerHeights[InspectorT.slicerForm.LayerTrackbar.Value]].Sloxels;
        var hSlox = sloxList[InspectorT.slicerForm.SloxelNumber.Value];
        var v = hSlox.Voxel;
        var str = "Voxel " + highlight.ToString("f0") + "\r\n";
        if (v.Voxel == null) return;
        str += "Position: " + v.Voxel.transform.position.ToString("f3") + "\r\n";
        str += "Temperature: " + "\r\n";
        str += "Position Error: " + "\r\n";
        GUILayout.Box(str, GUILayout.Width(220), GUILayout.Height(60));
        if (!voxelsFitted)
        {
            if (GUILayout.Button("Get Statistics"))
            {
                cSectionGCD.SetStatistics();
            }
            else
                return;
        }
        IntScrollPosition = GUILayout.BeginScrollView(IntScrollPosition, GUILayout.Width(225), GUILayout.Height(180));
        {
            var sloxVoxInfo = "<b>Voxel #: " + v.Id.ToString() + "\r\n";
            sloxVoxInfo += "Wall Thickness: " + v.WallThickness.ToString() + "\r\n";
            sloxVoxInfo += "Includes " + v.Sloxels.Count.ToString() + " Sloxels: \r\n</b>\r\n";
            foreach (var slox in v.Sloxels)
            {
                if (slox == hSlox)
                    sloxVoxInfo += "<color=red>";
                sloxVoxInfo += ("Layer: " + slox.Layer + ", " + "Sloxel #: " + slox.Id.ToString() + "\r\n");
                if (slox == hSlox)
                    sloxVoxInfo += "</color>";
            }
            GUILayout.Label(sloxVoxInfo, "i");
            var balls = "Contains " + v.CrazyBalls.Count.ToString() + " Data Points \r\n";
            if (v.CrazyBalls.Count >= 1)
            {
                var minError = 1000f;
                var maxError = 0f;
                var totalError = 0f;
                foreach (var ball in v.CrazyBalls)
                {
                    if (ball.ErrorDistance > minError)
                        minError = ball.ErrorDistance;
                    if (ball.ErrorDistance > maxError)
                        maxError = ball.ErrorDistance;
                    totalError += ball.ErrorDistance;
                    balls += "Point[" + ball.Id.ToString() + "] - Error: " + ball.ErrorDistance.ToString("f4") + "\r\n";
                }
                var averageError = totalError / v.CrazyBalls.Count;
                balls += "Average Error: " + averageError.ToString("f4");
            }
            GUILayout.Label(balls, "i2");
            var intersects = "Intersected By " + v.IntersectedByLines.Count.ToString() + " lines.\r\n";
            GUILayout.Label(intersects, "i2");

            GUILayout.Label("Median Line Number: " + v.MedianLineNumber.ToString("f0"), "i");
            GUILayout.Label("Line Number Std Dev: " + v.StandardDeviation.ToString("f3"), "i");
            if (v.MinDistance < 100)
                GUILayout.Label("Min Separation: " + v.MinDistance.ToString("f3"), "i");
            else
                GUILayout.Label("Min Separation: --", "i");
            if (v.MaxDistance > 0)
            {
                GUILayout.Label("Max Separation: " + v.MaxDistance.ToString("f3"), "i");
                GUILayout.Label("Mean Separation: " + v.MeanDistance.ToString("f3"), "i");
            }
            else
            {
                GUILayout.Label("Max Separation: --", "i");
                GUILayout.Label("Mean Separation: --", "i");
            }
            GUILayout.Space(8);
            foreach (var ints in v.IntersectedByLines)
            {
                var intersection = "[" + LoadFile.gcdLines.IndexOf(ints).ToString() + "]: " + "\r\n"
                    + "     P1: " + ints.p1.ToString("f3") + "," + "\r\n"
                    + "     P2: " + ints.p2.ToString("f3")
                    + "\r\n";
                GUILayout.Label(intersection, "i");
            }
            for (int q = 0; q <= 20; q++)
                GUILayout.Label("");
        }
        GUILayout.EndScrollView();
        highlightTypeIndex = GUILayout.Toolbar(highlightTypeIndex, pathToggleNames);
        switch (highlightTypeIndex)
        {
            case 0:
                highlightType = HighlighType.None;
                break;
            case 1:
                highlightType = HighlighType.PathDensity;
                minPathIntersects = GUILayout.HorizontalSlider(minPathIntersects, 0, maxPathIntersects);
                GUILayout.Label("Min #: " + minPathIntersects.ToString("f0"), KeyStyle, GUILayout.Width(220));
                maxPathIntersects = GUILayout.HorizontalSlider(maxPathIntersects, 1, PathFitter.maxPathsThrough);
                GUILayout.Label("Max #: " + maxPathIntersects.ToString("f0"), KeyStyle, GUILayout.Width(220));
                break;
            case 2:
                highlightType = HighlighType.PathSeparation;

                if (lastMaxSep != maxIntDist)
                    InspectorT.slicerForm.panel1.Invalidate();
                lastMaxSep = maxIntDist;
                if (lastMinSep != minIntDist)
                    InspectorT.slicerForm.panel1.Invalidate();
                lastMinSep = minIntDist;
                minIntDist = GUILayout.HorizontalSlider(minIntDist, 0, maxIntDist);
                GUILayout.Label("Min #: " + minIntDist.ToString("f4"), KeyStyle, GUILayout.Width(220));
                maxIntDist = GUILayout.HorizontalSlider(maxIntDist, 0, cSectionGCD.maxLineSepSloxels);
                GUILayout.Label("Max #: " + maxIntDist.ToString("f4"), KeyStyle, GUILayout.Width(220));
                break;
            case 3:
                highlightType = HighlighType.PathNumbers;
                break;
            default:
                break;
        }
        if (GUILayout.Button("Clear Voxels"))
        {
            ClearVoxels();
        }
    }