コード例 #1
0
        private void NewStarListComputed(ISystem sys, BaseUtils.SortedListDoubleDuplicate <ISystem> list)      // In UI thread
        {
            System.Diagnostics.Debug.Assert(System.Windows.Forms.Application.MessageLoop);
            int i = 1;

            foreach (var s in list)
            {
                string p = ret_prefix + (i++).ToStringInvariant() + "_";
                ActionVars.SystemVars(apr.variables, s.Value, p);
                ActionVars.SystemVarsFurtherInfo(apr, (apr.ActionController as ActionController).HistoryList, s.Value, p);
                apr[p + "Dist"] = Math.Sqrt(s.Key).ToStringInvariant("0.##");
            }

            apr[ret_prefix + "Count"] = list.Count.ToStringInvariant();

            apr.ResumeAfterPause();
        }
コード例 #2
0
        private void FillPlot(BaseUtils.SortedListDoubleDuplicate <ISystem> csl, ISystem currentSystem)
        {
            SetControlText(string.Format("2D Plot of systems in range from {0} ".T(EDTx.UserControlPlot_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".T(EDTx.UserControlPlot_PTOP), currentSystemName);
            modelFront.Title = string.Format("Plot around {0}, viewed from the front".T(EDTx.UserControlPlot_PFRONT), currentSystemName);
            modelSide.Title  = string.Format("Plot around {0}, viewed from the side".T(EDTx.UserControlPlot_PSIDE), currentSystemName);

            // Title of the report
            reportView.Text += string.Format(("Systems around {0}, from {1} to {2}, Ly: {3}").T(EDTx.UserControlPlot_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}").T(EDTx.UserControlPlot_Vs), discoveryform.history.GetVisitsCount(currentSystem.Name));
            //removed - system does not have a note. reportView.Text += string.Format((Environment.NewLine + "    Notes: {0}" + Environment.NewLine).T(EDTx.UserControlPlot_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);

                    // 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").T(EDTx.UserControlPlot_D1), tvp.Value.Name.ToString(), distFromCurrentSys);
                        reportView.Text += string.Format((Environment.NewLine + "    Visits: {0}").T(EDTx.UserControlPlot_D2), visits.ToString());
                        reportView.Text += string.Format((Environment.NewLine + "    Coordinates: X:{0:N2}, Y:{1:N2}, Z:{2:N2}" + Environment.NewLine).T(EDTx.UserControlPlot_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();
            }
        }
コード例 #3
0
 private void NewStarListComputed(ISystem sys, BaseUtils.SortedListDoubleDuplicate <ISystem> list) // In UI
 {
     System.Diagnostics.Debug.Assert(Application.MessageLoop);                                     // check!
     discoveryform.history.CalculateSqDistances(list, sys.X, sys.Y, sys.Z, maxitems, textMinRadius.Value, textMaxRadius.Value, true);
     FillPlot(list, sys);
 }