示例#1
0
        public void AddLine(string lineName, double[] xValues, double[] yValues, Color lineColor, int lineThickness, bool display)
        {
            if (allLines.ContainsKey(lineName))
            {
                MonoBehaviour.print("Error: A Line with that name already exists");
                return;
            }
            if (xValues.Length != yValues.Length)
            {
                MonoBehaviour.print("Error: X and Y value arrays are different lengths");
                return;
            }

            KerbalGraphLine newLine = new KerbalGraphLine((int)drawRect.width, (int)drawRect.height);

            newLine.InputData(xValues, yValues);
            newLine.SetBoundaries(bounds);
            newLine.lineColor       = lineColor;
            newLine.lineThickness   = lineThickness;
            newLine.backgroundColor = backgroundColor;
            newLine.displayInLegend = display;

            allLines.Add(lineName, newLine);
            Update();
        }
示例#2
0
        public void AddLine(string lineName)
        {
            if (allLines.ContainsKey(lineName))
            {
                MonoBehaviour.print("Error: A Line with that name already exists");
                return;
            }
            KerbalGraphLine newLine = new KerbalGraphLine((int)drawRect.width, (int)drawRect.height);

            newLine.SetBoundaries(bounds);
            allLines.Add(lineName, newLine);
            Update();
        }
示例#3
0
        public void RemoveLine(string lineName)
        {
            if (!allLines.ContainsKey(lineName))
            {
                MonoBehaviour.print("Error: No line with that name exists");
                return;
            }

            KerbalGraphLine line = allLines[lineName];

            allLines.Remove(lineName);

            line.ClearTextures();
            Update();
        }
示例#4
0
        /// <summary>
        /// Dumps a set number of lines to a file at a specific path
        /// </summary>
        /// <param name="pathName">The file path; must end with a slash: ex: GameData/KerbalGraph/</param>
        /// <param name="fileName">The file name; must include file type: ex: KerbalGraphStuff.csv</param>
        /// <param name="linesToDump">A list of the lines to dump; is case-sensitive</param>
        public void DumpDataToCSV(string pathName, string fileName, List <string> linesToDump)
        {
            List <string>          columnHeadings = new List <string>();
            List <KerbalGraphLine> linesToPrint   = new List <KerbalGraphLine>();

            for (int i = 0; i < linesToDump.Count; i++)
            {
                string lineName = linesToDump[i];
                linesToPrint.Add(allLines[lineName]);
                columnHeadings.Add(horizontalLabel);
                columnHeadings.Add(lineName);
            }

            int maxNumElements = 0;

            for (int i = 0; i < linesToDump.Count; i++)
            {
                KerbalGraphLine line = linesToPrint[i];
                maxNumElements = Math.Max(maxNumElements, line.GetNumDataPoints());
            }

            double[,] dataArray = new double[2 * linesToPrint.Count, maxNumElements];

            int colIndex = 0;

            for (int i = 0; i < linesToDump.Count; i++)
            {
                KerbalGraphLine line = linesToPrint[i];
                double[]        rawX = line.GetRawDataX();
                double[]        rawY = line.GetRawDataY();

                for (int j = 0; j < rawX.Length; j++)
                {
                    dataArray[colIndex, j]     = rawX[j];
                    dataArray[colIndex + 1, j] = rawY[j];
                }
                colIndex += 2;
            }

            string fileNameAndPath = pathName + fileName;

            KerbalGraphIO.WriteToFile(fileNameAndPath, columnHeadings, dataArray);
        }
示例#5
0
 public void AddLine(string lineName)
 {
     if (allLines.ContainsKey(lineName))
     {
         MonoBehaviour.print("Error: A Line with that name already exists");
         return;
     }
     KerbalGraphLine newLine = new KerbalGraphLine((int)drawRect.width, (int)drawRect.height);
     newLine.SetBoundaries(bounds);
     allLines.Add(lineName, newLine);
     Update();
 }
示例#6
0
        public void AddLine(string lineName, double[] xValues, double[] yValues, Color lineColor, int lineThickness, bool display)
        {
            if (allLines.ContainsKey(lineName))
            {
                MonoBehaviour.print("Error: A Line with that name already exists");
                return;
            }
            if (xValues.Length != yValues.Length)
            {
                MonoBehaviour.print("Error: X and Y value arrays are different lengths");
                return;
            }

            KerbalGraphLine newLine = new KerbalGraphLine((int)drawRect.width, (int)drawRect.height);
            newLine.InputData(xValues, yValues);
            newLine.SetBoundaries(bounds);
            newLine.lineColor = lineColor;
            newLine.lineThickness = lineThickness;
            newLine.backgroundColor = backgroundColor;
            newLine.displayInLegend = display;

            allLines.Add(lineName, newLine);
            Update();
        }