Example #1
0
        private void FillPlot(BaseUtils.SortedListDoubleDuplicate <ISystem> csl, ISystem currentSystem)
        {
            SetControlText(string.Format("2D Plot of systems in range from {0} ".Tx(this, "2d"), currentSystem.Name));

            const int pointSize = 4;

            // initializing the plot
            var modelTop   = new PlotModel {
            };
            var modelFront = new PlotModel {
            };
            var modelSide  = new PlotModel {
            };

            this.plotViewTop.Model   = modelTop;
            this.plotViewFront.Model = modelFront;
            this.plotViewSide.Model  = modelSide;

            modelTop.Axes.Add(new LinearAxis {
                Position = AxisPosition.Bottom, TicklineColor = OxyColors.BlueViolet
            });
            modelTop.Axes.Add(new LinearAxis {
                Position = AxisPosition.Left, TicklineColor = OxyColors.BlueViolet, StartPosition = 1, EndPosition = -1
            });
            modelFront.Axes.Add(new LinearAxis {
                Position = AxisPosition.Bottom, TicklineColor = OxyColors.BlueViolet
            });
            modelFront.Axes.Add(new LinearAxis {
                Position = AxisPosition.Left, TicklineColor = OxyColors.BlueViolet
            });
            modelSide.Axes.Add(new LinearAxis {
                Position = AxisPosition.Bottom, TicklineColor = OxyColors.BlueViolet
            });
            modelSide.Axes.Add(new LinearAxis {
                Position = AxisPosition.Left, TicklineColor = OxyColors.BlueViolet
            });

            // Define defaults properties of the series for the Top view
            var currentSeriesTop = new ScatterSeries {
                MarkerType = MarkerType.Circle, MarkerSize = pointSize, MarkerFill = OxyColors.Red
            };
            var lastoneSeriesTop = new ScatterSeries {
                MarkerType = MarkerType.Circle, MarkerSize = pointSize, MarkerFill = OxyColors.Purple
            };
            var inrangeSeriesTop = new ScatterSeries {
                MarkerType = MarkerType.Circle, MarkerSize = pointSize, MarkerFill = OxyColors.Yellow
            };
            var visitedSeriesTop = new ScatterSeries {
                MarkerType = MarkerType.Circle, MarkerSize = pointSize, MarkerFill = OxyColors.Cyan
            };

            // Define defaults properties of the series for the Front view
            var currentSeriesFront = new ScatterSeries {
                MarkerType = MarkerType.Circle, MarkerSize = pointSize, MarkerFill = OxyColors.Red
            };
            var lastoneSeriesFront = new ScatterSeries {
                MarkerType = MarkerType.Circle, MarkerSize = pointSize, MarkerFill = OxyColors.Purple
            };
            var inrangeSeriesFront = new ScatterSeries {
                MarkerType = MarkerType.Circle, MarkerSize = pointSize, MarkerFill = OxyColors.Yellow
            };
            var visitedSeriesFront = new ScatterSeries {
                MarkerType = MarkerType.Circle, MarkerSize = pointSize, MarkerFill = OxyColors.Cyan
            };

            // Define defaults properties of the series for the Side view
            var currentSeriesSide = new ScatterSeries {
                MarkerType = MarkerType.Circle, MarkerSize = pointSize, MarkerFill = OxyColors.Red
            };
            var lastoneSeriesSide = new ScatterSeries {
                MarkerType = MarkerType.Circle, MarkerSize = pointSize, MarkerFill = OxyColors.Purple
            };
            var inrangeSeriesSide = new ScatterSeries {
                MarkerType = MarkerType.Circle, MarkerSize = pointSize, MarkerFill = OxyColors.Yellow
            };
            var visitedSeriesSide = new ScatterSeries {
                MarkerType = MarkerType.Circle, MarkerSize = pointSize, MarkerFill = OxyColors.Cyan
            };

            // Add the series
            modelTop.Series.Add(currentSeriesTop);
            modelTop.Series.Add(lastoneSeriesTop);
            modelTop.Series.Add(visitedSeriesTop);
            modelTop.Series.Add(inrangeSeriesTop);

            // Add the series
            modelFront.Series.Add(currentSeriesFront);
            modelFront.Series.Add(lastoneSeriesFront);
            modelFront.Series.Add(visitedSeriesFront);
            modelFront.Series.Add(inrangeSeriesFront);

            // Add the series
            modelSide.Series.Add(currentSeriesSide);
            modelSide.Series.Add(lastoneSeriesSide);
            modelSide.Series.Add(visitedSeriesSide);
            modelSide.Series.Add(inrangeSeriesSide);

            // titles
            modelTop.Title   = string.Format("Plot around {0}, viewed from the top".Tx(this, "PTOP"), currentSystemName);
            modelFront.Title = string.Format("Plot around {0}, viewed from the front".Tx(this, "PFRONT"), currentSystemName);
            modelSide.Title  = string.Format("Plot around {0}, viewed from the side".Tx(this, "PSIDE"), currentSystemName);

            // Title of the report
            reportView.Text += string.Format(("Systems around {0}, from {1} to {2}, Ly: {3}").Tx(this, "SysAROUND"), currentSystemName,
                                             textMinRadius.Value.ToString(), textMaxRadius.Value.ToString(), csl.Count.ToString());

            // Fill with some information for the report
            //reportView.AppendText("\nText " + currentSystem.some_value_interesting_to_report);
            reportView.Text += string.Format((Environment.NewLine + "    Visits: {0}").Tx(this, "Vs"), discoveryform.history.GetVisitsCount(currentSystem.Name, currentSystem.EDSMID));
            reportView.Text += string.Format((Environment.NewLine + "    Notes: {0}" + Environment.NewLine).Tx(this, "Nt"), currentSystem.SystemNote);

            // If the are any system inside the defined range...
            if (csl.Count() > 0)
            {
                // ...then iterate through each system in the list:
                foreach (KeyValuePair <double, ISystem> tvp in csl)
                {
                    // calculate the average distance;
                    var distFromCurrentSys = Math.Round(Math.Sqrt(tvp.Key), 2, MidpointRounding.AwayFromZero);

                    // count the total visits for each system;
                    int visits = discoveryform.history.GetVisitsCount(tvp.Value.Name, tvp.Value.EDSMID);

                    // Then, populate the Grid with the systems in range
                    if (distFromCurrentSys >= textMinRadius.Value && distFromCurrentSys <= textMaxRadius.Value && tvp.Value.Name != currentSystemName)
                    {
                        // get the coordinates of each system in range;
                        var sysX = tvp.Value.X;
                        var sysY = tvp.Value.Y;
                        var sysZ = tvp.Value.Z;

                        // print information on each member of the list;
                        reportView.Text += string.Format((Environment.NewLine + "{0} distance {1:N2} Ly").Tx(this, "D1"), tvp.Value.Name.ToString(), distFromCurrentSys);
                        reportView.Text += string.Format((Environment.NewLine + "    Visits: {0}").Tx(this, "D2"), visits.ToString());
                        reportView.Text += string.Format((Environment.NewLine + "    Coordinates: X:{0:N2}, Y:{1:N2}, Z:{2:N2}" + Environment.NewLine).Tx(this, "D3"), sysX, sysY, sysZ);

                        // Create the list, with each system's name, distances by x, y and z coordinates and number of visits
                        object[] value = { tvp.Value.Name, $"{sysX:0.00}", $"{sysY:0.00}", $"{sysZ:0.00}", $"{visits:n0}" };
                        var      i     = dataGridList.Rows.Add(value);
                        dataGridList.Rows[i].Tag = tvp.Value;

                        var seriesTop   = inrangeSeriesTop;
                        var seriesFront = inrangeSeriesFront;
                        var seriesSide  = inrangeSeriesSide;

                        // Assign each system to the correct color and series, depending of its state:
                        // visited; lastone; inrange (not visited).
                        if (visits > 0)
                        {
                            // is visited
                            if (tvp.Value.Name != previousSystemName)
                            {
                                seriesTop   = visitedSeriesTop;
                                seriesFront = visitedSeriesFront;
                                seriesSide  = visitedSeriesSide;
                            }
                            // is visited, and is the last visited system
                            else if (tvp.Value.Name == previousSystemName)
                            {
                                seriesTop   = lastoneSeriesTop;
                                seriesFront = lastoneSeriesFront;
                                seriesSide  = lastoneSeriesSide;
                            }
                        }
                        else
                        // is not visited yet
                        {
                            seriesTop   = inrangeSeriesTop;
                            seriesFront = inrangeSeriesFront;
                            seriesSide  = inrangeSeriesSide;
                        }
                        //

                        // Draw each point in the Plot
                        seriesTop.Points.Add(new ScatterPoint(Convert.ToDouble(value[1]), Convert.ToDouble(value[2]), pointSize, Convert.ToDouble(value[3]), value[0]));
                        seriesFront.Points.Add(new ScatterPoint(Convert.ToDouble(value[1]), Convert.ToDouble(value[3]), pointSize, Convert.ToDouble(value[2]), value[0]));
                        seriesSide.Points.Add(new ScatterPoint(Convert.ToDouble(value[2]), Convert.ToDouble(value[3]), pointSize, Convert.ToDouble(value[1]), value[0]));

                        // Create a tracker which shows the name of the system and its coordinates
                        const string trackerTop   = "{Tag}\n" + "X: {2:0.###}; Y: {4:0.###}; Z: {6:0.###}";
                        const string trackerFront = "{Tag}\n" + "X: {2:0.###}; Z: {4:0.###}; Y: {6:0.###}";
                        const string trackerSide  = "{Tag}\n" + "Y: {2:0.###}; Z: {4:0.###}; X: {6:0.###}";

                        seriesTop.TrackerFormatString   = trackerTop;
                        seriesFront.TrackerFormatString = trackerFront;
                        seriesSide.TrackerFormatString  = trackerSide;
                    }

                    currentSeriesTop.Points.Add(new ScatterPoint(currentSystem.X, currentSystem.Y, pointSize, currentSystem.Z, currentSystemName));
                    currentSeriesFront.Points.Add(new ScatterPoint(currentSystem.X, currentSystem.Z, pointSize, currentSystem.Y, currentSystemName));
                    currentSeriesSide.Points.Add(new ScatterPoint(currentSystem.Y, currentSystem.Z, pointSize, currentSystem.X, currentSystemName));

                    const string currentTrackerTop   = "{Tag}\n" + "X: {2:0.###}; Y: {4:0.###}; Z: {6:0.###}";
                    const string currentTrackerFront = "{Tag}\n" + "X: {2:0.###}; Z: {4:0.###}; Y: {6:0.###}";
                    const string currentTrackerSide  = "{Tag}\n" + "Y: {2:0.###}; Z: {4:0.###}; X: {6:0.###}";

                    currentSeriesTop.TrackerFormatString   = currentTrackerTop;
                    currentSeriesFront.TrackerFormatString = currentTrackerFront;
                    currentSeriesSide.TrackerFormatString  = currentTrackerSide;
                }

                // End of the Report
                reportView.Text += Environment.NewLine + Environment.NewLine + " @ " + DateTime.Now.ToString();
            }
        }
        private void FillPlot(BaseUtils.SortedListDoubleDuplicate <ISystem> csl, ISystem currentSystem)
        {
            SetControlText("2D Plot of systems in range from " + currentSystem.Name);

            var pointSize = 4;

            // initializing the plot
            var modelTop   = new PlotModel {
            };
            var modelFront = new PlotModel {
            };
            var modelSide  = new PlotModel {
            };

            this.plotViewTop.Model   = modelTop;
            this.plotViewFront.Model = modelFront;
            this.plotViewSide.Model  = modelSide;

            modelTop.Axes.Add(new LinearAxis {
                Position = AxisPosition.Bottom, TicklineColor = OxyColors.BlueViolet
            });
            modelTop.Axes.Add(new LinearAxis {
                Position = AxisPosition.Left, TicklineColor = OxyColors.BlueViolet
            });
            modelFront.Axes.Add(new LinearAxis {
                Position = AxisPosition.Bottom, TicklineColor = OxyColors.BlueViolet
            });
            modelFront.Axes.Add(new LinearAxis {
                Position = AxisPosition.Left, TicklineColor = OxyColors.BlueViolet
            });
            modelSide.Axes.Add(new LinearAxis {
                Position = AxisPosition.Bottom, TicklineColor = OxyColors.BlueViolet
            });
            modelSide.Axes.Add(new LinearAxis {
                Position = AxisPosition.Left, TicklineColor = OxyColors.BlueViolet
            });

            // Define defaults properties of the series for the Top view
            var currentSeriesTop = new ScatterSeries {
                MarkerType = MarkerType.Circle, MarkerSize = pointSize, MarkerFill = OxyColors.Red
            };
            var lastoneSeriesTop = new ScatterSeries {
                MarkerType = MarkerType.Circle, MarkerSize = pointSize, MarkerFill = OxyColors.Purple
            };
            var inrangeSeriesTop = new ScatterSeries {
                MarkerType = MarkerType.Circle, MarkerSize = pointSize, MarkerFill = OxyColors.Yellow
            };
            var visitedSeriesTop = new ScatterSeries {
                MarkerType = MarkerType.Circle, MarkerSize = pointSize, MarkerFill = OxyColors.Cyan
            };

            // Define defaults properties of the series for the Front view
            var currentSeriesFront = new ScatterSeries {
                MarkerType = MarkerType.Circle, MarkerSize = pointSize, MarkerFill = OxyColors.Red
            };
            var lastoneSeriesFront = new ScatterSeries {
                MarkerType = MarkerType.Circle, MarkerSize = pointSize, MarkerFill = OxyColors.Purple
            };
            var inrangeSeriesFront = new ScatterSeries {
                MarkerType = MarkerType.Circle, MarkerSize = pointSize, MarkerFill = OxyColors.Yellow
            };
            var visitedSeriesFront = new ScatterSeries {
                MarkerType = MarkerType.Circle, MarkerSize = pointSize, MarkerFill = OxyColors.Cyan
            };

            // Define defaults properties of the series for the Side view
            var currentSeriesSide = new ScatterSeries {
                MarkerType = MarkerType.Circle, MarkerSize = pointSize, MarkerFill = OxyColors.Red
            };
            var lastoneSeriesSide = new ScatterSeries {
                MarkerType = MarkerType.Circle, MarkerSize = pointSize, MarkerFill = OxyColors.Purple
            };
            var inrangeSeriesSide = new ScatterSeries {
                MarkerType = MarkerType.Circle, MarkerSize = pointSize, MarkerFill = OxyColors.Yellow
            };
            var visitedSeriesSide = new ScatterSeries {
                MarkerType = MarkerType.Circle, MarkerSize = pointSize, MarkerFill = OxyColors.Cyan
            };

            // Add the series
            modelTop.Series.Add(currentSeriesTop);
            modelTop.Series.Add(lastoneSeriesTop);
            modelTop.Series.Add(visitedSeriesTop);
            modelTop.Series.Add(inrangeSeriesTop);

            // Add the series
            modelFront.Series.Add(currentSeriesFront);
            modelFront.Series.Add(lastoneSeriesFront);
            modelFront.Series.Add(visitedSeriesFront);
            modelFront.Series.Add(inrangeSeriesFront);

            // Add the series
            modelSide.Series.Add(currentSeriesSide);
            modelSide.Series.Add(lastoneSeriesSide);
            modelSide.Series.Add(visitedSeriesSide);
            modelSide.Series.Add(inrangeSeriesSide);

            // titles
            modelTop.Title   = "Plot around " + currentSystemName + ", viewed from the top";
            modelFront.Title = "Plot around " + currentSystemName + ", viewed from the front";
            modelSide.Title  = "Plot around " + currentSystemName + ", viewed from the side";

            // Title of the report
            reportView.Text += ("\nSystems around " + currentSystemName + ", from " + textMinRadius.Value.ToString() + " to " + textMaxRadius.Value.ToString() + "Ly: " + csl.Count.ToString() + "\n");

            // Fill with some information for the report
            //reportView.AppendText("\nText " + currentSystem.some_value_interesting_to_report);
            reportView.Text += ("\nVisits: " + discoveryform.history.GetVisitsCount(currentSystem.Name, currentSystem.EDSMID));
            reportView.Text += ("\nNotes: " + currentSystem.SystemNote + "\n");

            // If the are any system inside the defined range...
            if (csl.Count() > 0)
            {
                // ...then iterate through each system in the list:
                foreach (KeyValuePair <double, ISystem> tvp in csl)
                {
                    // calculate the average distance;
                    var distFromCurrentSys = Math.Round(Math.Sqrt(tvp.Key), 2, MidpointRounding.AwayFromZero);

                    // count the total visits for each system;
                    int visits = discoveryform.history.GetVisitsCount(tvp.Value.Name, tvp.Value.EDSMID);

                    // Then, populate the Grid with the systems in range
                    if (distFromCurrentSys >= textMinRadius.Value && distFromCurrentSys <= textMaxRadius.Value && tvp.Value.Name != currentSystemName)
                    {
                        // get the coordinates of each system in range;
                        var sysX = tvp.Value.X;
                        var sysY = tvp.Value.Y;
                        var sysZ = tvp.Value.Z;

                        // print information on each member of the list;
                        reportView.Text += ("\n" + tvp.Value.Name.ToString() + ", distant " + distFromCurrentSys + "Ly ");
                        reportView.Text += ("\n" + "Visits: " + visits.ToString());
                        reportView.Text += ("\nCoordinates: " + "X:" + sysX + ", Y:" + sysY + ", Z:" + sysZ);

                        // Create the list, with each system's name, distances by x, y and z coordinates and number of visits
                        object[] plotobj  = { tvp.Value.Name, $"{sysX:0.00}", $"{sysY:0.00}", $"{sysZ:0.00}", $"{visits:n0}" };
                        int      rowindex = dataGridList.Rows.Add(plotobj);
                        dataGridList.Rows[rowindex].Tag = tvp.Value;

                        var seriesTop   = inrangeSeriesTop;
                        var seriesFront = inrangeSeriesFront;
                        var seriesSide  = inrangeSeriesSide;

                        // Assign each system to the correct color and series, depending of its state:
                        // visited; lastone; inrange (not visited).
                        if (visits > 0)
                        {
                            // is visited
                            if (tvp.Value.Name != previousSystemName)
                            {
                                seriesTop   = visitedSeriesTop;
                                seriesFront = visitedSeriesFront;
                                seriesSide  = visitedSeriesSide;
                            }
                            // is visited, and is the last visited system
                            else if (tvp.Value.Name == previousSystemName)
                            {
                                seriesTop   = lastoneSeriesTop;
                                seriesFront = lastoneSeriesFront;
                                seriesSide  = lastoneSeriesSide;
                            }
                        }
                        else
                        // is not visited yet
                        {
                            seriesTop   = inrangeSeriesTop;
                            seriesFront = inrangeSeriesFront;
                            seriesSide  = inrangeSeriesSide;
                        }
                        //

                        // Draw each point in the Plot
                        seriesTop.Points.Add(new ScatterPoint(Convert.ToDouble(plotobj[1]), Convert.ToDouble(plotobj[2]), pointSize, Convert.ToDouble(plotobj[3]), plotobj[0]));
                        seriesFront.Points.Add(new ScatterPoint(Convert.ToDouble(plotobj[1]), Convert.ToDouble(plotobj[3]), pointSize, Convert.ToDouble(plotobj[2]), plotobj[0]));
                        seriesSide.Points.Add(new ScatterPoint(Convert.ToDouble(plotobj[2]), Convert.ToDouble(plotobj[3]), pointSize, Convert.ToDouble(plotobj[1]), plotobj[0]));

                        // Create a tracker which shows the name of the system and its coordinates

                        string TrackerTop   = "{Tag}\n" + "X: {2:0.###}; Y: {4:0.###}; Z: {6:0.###}";
                        string TrackerFront = "{Tag}\n" + "X: {2:0.###}; Z: {4:0.###}; Y: {6:0.###}";
                        string TrackerSide  = "{Tag}\n" + "Y: {2:0.###}; Z: {4:0.###}; X: {6:0.###}";

                        seriesTop.TrackerFormatString   = TrackerTop;
                        seriesFront.TrackerFormatString = TrackerFront;
                        seriesSide.TrackerFormatString  = TrackerSide;
                    }

                    currentSeriesTop.Points.Add(new ScatterPoint(currentSystem.X, currentSystem.Y, pointSize, currentSystem.Z, currentSystemName));
                    currentSeriesFront.Points.Add(new ScatterPoint(currentSystem.X, currentSystem.Z, pointSize, currentSystem.Y, currentSystemName));
                    currentSeriesSide.Points.Add(new ScatterPoint(currentSystem.Y, currentSystem.Z, pointSize, currentSystem.X, currentSystemName));

                    string currentTracker = "{Tag}";

                    currentSeriesTop.TrackerFormatString   = currentTracker;
                    currentSeriesFront.TrackerFormatString = currentTracker;
                    currentSeriesSide.TrackerFormatString  = currentTracker;

                    // End of the systems list
                    reportView.Text += ("\n");
                }

                // End of the Report
                reportView.Text += ("\n\nReport created on " + DateTime.Now.ToString());
            }
        }
Example #3
0
        private void FillPlot(BaseUtils.SortedListDoubleDuplicate <ISystem> csl, ISystem currentSystem)
        {
            SetControlText("");

            if (csl.Count() > 0)
            {
                SetControlText("2D Plot of systems in range from " + currentSystem.Name);

                // position the current system in the center of the references coordinates
                chartBubble.Series[0].Points.AddXY(0, 0, 4);
                chartBubble.Series[0].ToolTip = currentSystem.Name;
                chartBubble.Series[3].Points.AddXY(0, 0, 4);
                chartBubble.Series[3].ToolTip = currentSystem.Name;
                chartBubble.Series[6].Points.AddXY(0, 0, 4);
                chartBubble.Series[6].ToolTip = currentSystem.Name;

                // create a point for each system in range
                foreach (KeyValuePair <double, ISystem> tvp in csl)
                {
                    var inRangeSystem = tvp.Value;

                    if (tvp.Value.Name != currentSystem.Name && tvp.Value.Name != previousSystemName)
                    {
                        // get the coordinates of each system in range
                        var sysX = inRangeSystem.X;
                        var sysY = inRangeSystem.Y;
                        var sysZ = inRangeSystem.Z;

                        // get the coordinates of the current system, to properly calculate the distance
                        var curX = currentSystem.X;
                        var curY = currentSystem.Y;
                        var curZ = currentSystem.Z;

                        // calculate the distance
                        var distFromCurrentSys = Math.Round(Math.Sqrt(tvp.Key), 2, MidpointRounding.AwayFromZero);

                        // reset charts axis
                        chartBubble.ChartAreas[0].AxisY.IsStartedFromZero = false;
                        chartBubble.ChartAreas[1].AxisY.IsStartedFromZero = false;
                        chartBubble.ChartAreas[2].AxisY.IsStartedFromZero = false;
                        chartBubble.ChartAreas[0].AxisX.IsStartedFromZero = false;
                        chartBubble.ChartAreas[1].AxisX.IsStartedFromZero = false;
                        chartBubble.ChartAreas[2].AxisX.IsStartedFromZero = false;

                        // for a spherical distribution, do not count distances bigger than the selected radius
                        if (distFromCurrentSys > textMinRadius.Value)
                        {
                            // count the total visits for each system
                            int visits = discoveryform.history.GetVisitsCount(tvp.Value.Name, tvp.Value.EDSMID);

                            // create the label for the tooltip
                            StringBuilder label = new StringBuilder();
                            label.Append(inRangeSystem.Name + " / " + visits + " visits" + "\n" + distFromCurrentSys);

                            // calculate the reference for each coordinate
                            double dx = curX - sysX;
                            double dy = curY - sysY;
                            double dz = curZ - sysZ;

                            // prepare the value to be displayed by the plot and fix the orientation
                            int px = Convert.ToInt32(dx) * -1;
                            int py = Convert.ToInt32(dy) * -1;
                            int pz = Convert.ToInt32(dz) * -1;

                            // visited systems go to series #1, #4 and #7; unvisited to series #2, #5 and #8.
                            // series #0, #3 and #6 is for the current system...

                            if (visits > 0)
                            {
                                // Top view
                                chartBubble.Series[1].Points.AddXY(px, py, pz);
                                chartBubble.Series[1].ToolTip = label.ToString();

                                // Front view
                                chartBubble.Series[4].Points.AddXY(px, pz, py);
                                chartBubble.Series[4].ToolTip = label.ToString();

                                // Side view
                                chartBubble.Series[7].Points.AddXY(py, pz, px);
                                chartBubble.Series[7].ToolTip = label.ToString();
                            }
                            else
                            {
                                // Top view
                                chartBubble.Series[2].Points.AddXY(px, py, pz);
                                chartBubble.Series[2].ToolTip = label.ToString();

                                // Front view
                                chartBubble.Series[5].Points.AddXY(px, pz, py);
                                chartBubble.Series[5].ToolTip = label.ToString();

                                // Side view
                                chartBubble.Series[8].Points.AddXY(py, pz, px);
                                chartBubble.Series[8].ToolTip = label.ToString();
                            }
                        }
                    }

                    if (tvp.Value.Name != currentSystem.Name && tvp.Value.Name == previousSystemName)
                    {
                        // Previous system coordinates, distances and label
                        int prevx = Convert.ToInt32(currentSystem.X - prevX) * -1;
                        int prevy = Convert.ToInt32(currentSystem.Y - prevY) * -1;
                        int prevz = Convert.ToInt32(currentSystem.Z - prevZ) * -1;

                        int visits             = discoveryform.history.GetVisitsCount(tvp.Value.Name, tvp.Value.EDSMID);
                        var distFromCurrentSys = Math.Round(Math.Sqrt(tvp.Key), 2, MidpointRounding.AwayFromZero);

                        StringBuilder label = new StringBuilder();
                        label.Append(previousSystemName + " / " + visits + " visits" + "\n" + distFromCurrentSys);

                        // Top view
                        chartBubble.Series[9].Points.AddXY(prevx, prevy, prevz);
                        chartBubble.Series[9].ToolTip = label.ToString();

                        // Front view
                        chartBubble.Series[10].Points.AddXY(prevx, prevz, prevy);
                        chartBubble.Series[10].ToolTip = label.ToString();

                        // Side view
                        chartBubble.Series[11].Points.AddXY(prevy, prevz, prevx);
                        chartBubble.Series[11].ToolTip = label.ToString();
                    }
                }
            }
        }
Example #4
0
        private void FillRadar(BaseUtils.SortedListDoubleDuplicate <ISystem> csl, ISystem centerSystem)
        {
            SetControlText("");

            if (csl.Count() > 0)
            {
                SetControlText("2D Plot of systems in range from " + centerSystem.Name);

                chartBubble.Series[0].Points.AddXY(0, 0, 4);
                chartBubble.Series[0].ToolTip = centerSystem.Name;
                chartBubble.Series[3].Points.AddXY(0, 0, 4);
                chartBubble.Series[3].ToolTip = centerSystem.Name;
                chartBubble.Series[6].Points.AddXY(0, 0, 4);
                chartBubble.Series[6].ToolTip = centerSystem.Name;

                foreach (KeyValuePair <double, ISystem> tvp in csl)
                {
                    if (tvp.Value.Name != centerSystem.Name)
                    {
                        var theISystemInQuestion = tvp.Value;
                        var sysX = theISystemInQuestion.X;
                        var sysY = theISystemInQuestion.Y;
                        var sysZ = theISystemInQuestion.Z;
                        var distFromCurrentSys = Math.Round(Math.Sqrt(tvp.Key), 2, MidpointRounding.AwayFromZero);
                        var curX = centerSystem.X;
                        var curY = centerSystem.Y;
                        var curZ = centerSystem.Z;

                        // reset charts axis
                        chartBubble.ChartAreas[0].AxisY.IsStartedFromZero = false;
                        chartBubble.ChartAreas[1].AxisY.IsStartedFromZero = false;
                        chartBubble.ChartAreas[2].AxisY.IsStartedFromZero = false;

                        chartBubble.ChartAreas[0].AxisX.IsStartedFromZero = false;
                        chartBubble.ChartAreas[1].AxisX.IsStartedFromZero = false;
                        chartBubble.ChartAreas[2].AxisX.IsStartedFromZero = false;


                        if (distFromCurrentSys > textMinRadius.Value)
                        {
                            int visits = discoveryform.history.GetVisitsCount(tvp.Value.Name, tvp.Value.EDSMID);

                            StringBuilder label = new StringBuilder();
                            label.Append(theISystemInQuestion.Name + " / " + visits + " visits" + "\n" + distFromCurrentSys);

                            double dx = curX - sysX;
                            double dy = curY - sysY;
                            double dz = curZ - sysZ;

                            int px = Convert.ToInt32(dx) * -1;
                            int py = Convert.ToInt32(dy);
                            int pz = Convert.ToInt32(dz);

                            // visited systems go to series #1, #4 and #7; unvisited to series #2, #5 and #8.
                            // Serie #0, #3 and #6 is for the current system...

                            if (visits > 0)
                            {
                                chartBubble.Series[1].Points.AddXY(px, py, pz);
                                chartBubble.Series[1].ToolTip = label.ToString();

                                chartBubble.Series[4].Points.AddXY(px, pz, py);
                                chartBubble.Series[4].ToolTip = label.ToString();

                                chartBubble.Series[7].Points.AddXY(py, pz, px);
                                chartBubble.Series[7].ToolTip = label.ToString();
                            }
                            else
                            {
                                chartBubble.Series[2].Points.AddXY(px, py, pz);
                                chartBubble.Series[2].ToolTip = label.ToString();

                                chartBubble.Series[5].Points.AddXY(px, pz, py);
                                chartBubble.Series[5].ToolTip = label.ToString();

                                chartBubble.Series[8].Points.AddXY(py, pz, px);
                                chartBubble.Series[8].ToolTip = label.ToString();
                            }
                        }
                    }
                }
            }
        }