Esempio n. 1
0
 public OrbitSpec this[PlanetId id, OrbitInfoType kind]
 {
     get
     {
         return(Orbits[id, kind]);
     }
 }
Esempio n. 2
0
 private void NotifyPropertyChanged(OrbitInfoType info)
 {
     if (PropertyChanged != null)
     {
         PropertyChanged(Star, new PropertyChangedEventArgs(info.ToString()));
     }
 }
Esempio n. 3
0
 public void AddCurve(CurveItem curve)
 {
     if (!IsCurveAdded(curve.Label.Text))
     {
         PlanetId id = OwnerOf(curve.Label.Text[0]);
         int      i  = 0;
         for (; i < thePane.CurveList.Count; i++)
         {
             CurveItem     existed  = thePane.CurveList[i];
             PlanetId      starId   = OwnerOf(existed);
             OrbitInfoType starKind = KindOf(existed);
             if (starId > id)
             {
                 continue;
             }
             else if (starId < id)
             {
                 break;
             }
             //else if (starKind < kind)
             //    continue;
             //else if (starKind > kind)
             //    break;
         }
         thePane.CurveList.Insert(i, curve);
         Zed.Invalidate();
     }
 }
Esempio n. 4
0
        //public static Color ColorOf(PlanetId id)
        //{
        //    return (PlanetsColors.ContainsKey(id)) ? PlanetsColors[id] : Color.Black;
        //}

        public static Color ColorOf(PlanetId id, OrbitInfoType kind)
        {
            if (!PlanetsColors.ContainsKey(id))
            {
                return(ColorOf(PlanetId.SE_ECL_NUT, kind));
            }
            else
            {
                List <Color> colorSet = PlanetsColors[id];

                int index = (int)kind;
                if (index < colorSet.Count)
                {
                    return(colorSet[index]);
                }
                else if (index < colorSet.Count * 2)
                {
                    Color velocityColor = WeightedColor(colorSet[index % 3], 0.8f, false);
                    return(velocityColor);
                }
                else
                {
                    Color elseColor = WeightedColor(colorSet[index % 3], 1.0f, true);
                    return(elseColor);
                }
            }
        }
Esempio n. 5
0
        //public OrbitSpec(OrbitsCollection orbits, PlanetId id, OrbitInfoType kind)
        //{
        //    YList = orbits[id, kind];
        //    XList = (kind < OrbitInfoType.Ascending) ? orbits.DayByDay : orbits.MonthByMonth;
        //    if (Count != YList.Count)
        //        throw new Exception();

        //    Label = LableOf(id, kind);
        //    if (kind == OrbitInfoType.Longitude)
        //        DisplayColor = Planet.ColorOf(id);
        //    else if (kind.ToString().Contains("Distance") || kind.ToString().Contains("Velocities"))
        //    {
        //        DisplayColor = Color.DarkCyan;
        //    }
        //    else if (kind.ToString().Contains("Latitude"))
        //    {
        //        DisplayColor = Color.DarkGray;
        //    }
        //    else
        //    {
        //        Color baseColor = Planet.ColorOf(id);
        //        int g = (baseColor.G == 0) ? 0 : (int)(baseColor.G * (1 - (int)kind / 16.0));
        //        int b = (baseColor.B == 0) ? 0 : (int)(baseColor.B * (1 - (int)kind / 16.0));
        //        int r = (baseColor.R == 0) ? 0 : (int)(baseColor.R * (1 - (int)kind / 16.0));
        //        int a = (baseColor.A == 0) ? 0 : (int)(baseColor.A * (1 - (int)kind / 16.0));

        //        DisplayColor = Color.FromArgb(a, r, g, b);
        //    }

        //    Symbol = SymbolType.None;

        //    OriginalCurve  = new LineItem(Label, XList.ToArray(), YList.ToArray(), DisplayColor, Symbol);
        //}

        public OrbitSpec(PlanetId id, OrbitInfoType kind, List <double> xList, List <double> yList)
        {
            Id   = id;
            Kind = kind;

            XList = xList;

            if (kind == OrbitInfoType.Distance)
            {
                Double averageDistance = Planet.AverageDistances[id];
                YList = (from y in yList
                         select y - averageDistance).ToList();
            }
            else
            {
                YList = yList;
            }

            if (Count != YList.Count)
            {
                throw new Exception();
            }

            DisplayColor = Planet.ColorOf(id, kind);
            //if (kind == OrbitInfoType.Longitude || kind == OrbitInfoType.LongVelocityAndLatitude || kind == OrbitInfoType.LongitudeAcceleration)
            //{
            //    DisplayColor = Planet.ColorOf(id);
            //}
            //else if (kind.ToString().EndsWith("Latitude"))
            //{
            //    DisplayColor = WeightedColor(Planet.ColorOf(id), 0.9f, true);
            //}
            //else if (kind.ToString().EndsWith("Distance"))
            //{
            //    DisplayColor = WeightedColor(Planet.ColorOf(id), 0.5f, true);
            //}
            //else if (kind.ToString().EndsWith("Velocities"))
            //{
            //    DisplayColor = WeightedColor(Planet.ColorOf(id), 0.8f, false);
            //}
            //else
            //{
            //    Color baseColor = Planet.ColorOf(id);
            //    int g = (baseColor.G == 0) ? 0 : (int)(baseColor.G * (1 - (int)kind / 16.0));
            //    int b = (baseColor.B == 0) ? 0 : (int)(baseColor.B * (1 - (int)kind / 16.0));
            //    int r = (baseColor.R == 0) ? 0 : (int)(baseColor.R * (1 - (int)kind / 16.0));
            //    int a = (baseColor.A == 0) ? 0 : (int)(baseColor.A * (1 - (int)kind / 16.0));

            //    DisplayColor = Color.FromArgb(a, r, g, b);
            //}

            Symbol = SymbolType.None;

            OriginalCurve = new LineItem(Label, XList.ToArray(), YList.ToArray(), DisplayColor, Symbol);
        }
Esempio n. 6
0
        private void loadNodeApsides(PlanetId star)
        {
            double[] xnasc    = new double[6];
            double[] xndsc    = new double[6];
            double[] xperi    = new double[6];
            double[] xaphe    = new double[6];
            String   errorMsg = "";

            Dictionary <OrbitInfoType, List <Double> > planetOrbits = AllOrbits[star];

            for (OrbitInfoType type = OrbitInfoType.Ascending; type <= OrbitInfoType.ApogeeVelocities; type++)
            {
                planetOrbits.Add(type, new List <double>());
            }

            double end = Utilities.ToJulianDay(End);

            for (double date = Utilities.ToJulianDay(Start); date <= end; date += SparsedInterval)
            {
                if (Utilities.swe_nod_aps_ut(date, star, SeFlg.SEFLG_SPEED | SeFlg.SEFLG_HELCTR, 0, xnasc, xndsc, xperi, xaphe, errorMsg) == SeFlg.ERR)
                {
                    throw new Exception();
                }
                else
                {
                    planetOrbits[OrbitInfoType.Ascending].Add(xnasc[0]);
                    planetOrbits[OrbitInfoType.AscendingLatitude].Add(xnasc[1]);
                    planetOrbits[OrbitInfoType.AscendingVelocities].Add(xnasc[3]);

                    planetOrbits[OrbitInfoType.Descending].Add(xndsc[0]);
                    planetOrbits[OrbitInfoType.DescendingLatitude].Add(xndsc[1]);
                    planetOrbits[OrbitInfoType.DescendingVelocities].Add(xndsc[3]);

                    planetOrbits[OrbitInfoType.Perigee].Add(xperi[0]);
                    planetOrbits[OrbitInfoType.PerigeeLatitude].Add(xperi[1]);
                    planetOrbits[OrbitInfoType.PerigeeVelocities].Add(xperi[3]);

                    planetOrbits[OrbitInfoType.Apogee].Add(xaphe[0]);
                    planetOrbits[OrbitInfoType.ApogeeLatitude].Add(xaphe[1]);
                    planetOrbits[OrbitInfoType.ApogeeVelocities].Add(xaphe[3]);
                }
            }
        }
Esempio n. 7
0
        public void AddCurve(PlanetId id, OrbitInfoType kind)
        {
            if (!IsCurveAdded(id, kind))
            {
                OrbitSpec spec = this[id, kind];

                CurveItem curve = null;

                if (kind == OrbitInfoType.Longitude || (kind >= OrbitInfoType.Ascending && kind <= OrbitInfoType.Apogee))
                {
                    curve = Frame.CurveOf(spec);
                }
                else if (kind.ToString().EndsWith("Latitude"))
                {
                    curve                    = spec.OriginalCurve;
                    curve.IsY2Axis           = true;
                    thePane.Y2Axis.IsVisible = true;

                    Double max = Math.Max(Math.Abs(spec.MaxY), Math.Abs(spec.MinY));
                    if (max > thePane.Y2Axis.Scale.Max)
                    {
                        SetY2Scale(max);
                    }
                }
                else
                {
                    thePane.Y2AxisList[1].IsVisible = true;

                    curve            = spec.OriginalCurve;
                    curve.IsY2Axis   = true;
                    curve.YAxisIndex = 1;

                    Double max = Math.Max(Math.Abs(spec.MaxY), Math.Abs(spec.MinY));
                    if (max > thePane.Y2AxisList[1].Scale.Max)
                    {
                        SetY3Scale(max);
                    }
                }

                AddCurve(curve);
            }
        }
Esempio n. 8
0
        public bool this[OrbitInfoType type]
        {
            get
            {
                switch (type)
                {
                //case OrbitInfoType.All: return IsPlanetShown;
                case OrbitInfoType.Longitude: return(LatitudeShown);

                case OrbitInfoType.Latitude: return(LatitudeShown);

                case OrbitInfoType.Distance: return(DistanceShown);

                case OrbitInfoType.LongitudeVelocities: return(LongitudeVelocitiesShown);

                case OrbitInfoType.LatitudeVelocities: return(LatitudeVelocitiesShown);

                case OrbitInfoType.DistanceVelocities: return(DistanceVelocitiesShown);

                case OrbitInfoType.Ascending: return(AscendingShown);

                case OrbitInfoType.Descending: return(DescendingShown);

                case OrbitInfoType.Perigee: return(PerigeeShown);

                case OrbitInfoType.Apogee: return(ApogeeShown);

                case OrbitInfoType.AscendingLatitude: return(AscendingLatitudeShown);

                case OrbitInfoType.DescendingLatitude: return(DescendingLatitudeShown);

                case OrbitInfoType.PerigeeLatitude: return(PerigeeLatitudeShown);

                case OrbitInfoType.ApogeeLatitude: return(ApogeeLatitudeShown);

                case OrbitInfoType.AscendingVelocities: return(AscendingVelocitiesShown);

                case OrbitInfoType.DescendingVelocities: return(DescendingVelocitiesShown);

                case OrbitInfoType.PerigeeVelocities: return(PerigeeVelocitiesShown);

                case OrbitInfoType.ApogeeVelocities: return(ApogeeVelocitiesShown);

                default: throw new NotImplementedException();
                }
            }
            set
            {
                switch (type)
                {
                //case OrbitInfoType.All: IsPlanetShown = value; break;
                case OrbitInfoType.Longitude: LatitudeShown = value; break;

                case OrbitInfoType.Latitude: LatitudeShown = value; break;

                case OrbitInfoType.Distance: DistanceShown = value; break;

                case OrbitInfoType.LongitudeVelocities: LongitudeVelocitiesShown = value; break;

                case OrbitInfoType.LatitudeVelocities: LatitudeVelocitiesShown = value; break;

                case OrbitInfoType.DistanceVelocities: DistanceVelocitiesShown = value; break;

                case OrbitInfoType.Ascending: AscendingShown = value; break;

                case OrbitInfoType.Descending: DescendingShown = value; break;

                case OrbitInfoType.Perigee: PerigeeShown = value; break;

                case OrbitInfoType.Apogee: ApogeeShown = value; break;

                case OrbitInfoType.AscendingLatitude: AscendingLatitudeShown = value; break;

                case OrbitInfoType.DescendingLatitude: DescendingLatitudeShown = value; break;

                case OrbitInfoType.PerigeeLatitude: PerigeeLatitudeShown = value; break;

                case OrbitInfoType.ApogeeLatitude: ApogeeLatitudeShown = value; break;

                case OrbitInfoType.AscendingVelocities: AscendingVelocitiesShown = value; break;

                case OrbitInfoType.DescendingVelocities: DescendingVelocitiesShown = value; break;

                case OrbitInfoType.PerigeeVelocities: PerigeeVelocitiesShown = value; break;

                case OrbitInfoType.ApogeeVelocities: ApogeeVelocitiesShown = value; break;

                default: throw new NotImplementedException();
                }
            }
        }
Esempio n. 9
0
        public OrbitSpec this[PlanetId star, OrbitInfoType type]
        {
            get
            {
                List <double> yList, xList;

                if (!AllOrbits.ContainsKey(star))
                {
                    throw new Exception();
                }

                Dictionary <OrbitInfoType, List <double> > planetsOrbits = AllOrbits[star];

                if (type >= OrbitInfoType.Longitude && type <= OrbitInfoType.DistanceVelocities)
                {
                    if (planetsOrbits.ContainsKey(type))
                    {
                        yList = planetsOrbits[type];
                        xList = DayByDay;
                        return(new OrbitSpec(star, type, xList, yList));
                    }
                    else
                    {
                        throw new Exception();
                    }
                }
                else if (type == OrbitInfoType.LongitudeAcceleration)
                {
                    yList = new List <double>();
                    yList.Add(0);

                    List <double> longVelocities = planetsOrbits[OrbitInfoType.LongitudeVelocities];
                    //double lvRange = longVelocities.Max() - longVelocities.Min();

                    for (int i = 1; i < longVelocities.Count; i++)
                    {
                        yList.Add(100 * (longVelocities[i] - longVelocities[i - 1]));
                    }
                    xList = DayByDay;
                    return(new OrbitSpec(star, type, xList, yList));
                }
                else if (type == OrbitInfoType.LongVelocityAndLatitude)
                {
                    yList = new List <double>();
                    List <double> latitudes      = planetsOrbits[OrbitInfoType.Latitude];
                    List <double> longVelocities = planetsOrbits[OrbitInfoType.LongitudeVelocities];

                    double latRange  = latitudes.Max() - latitudes.Min();
                    double lvRange   = longVelocities.Max() - longVelocities.Min();
                    double latFactor = lvRange / latRange;

                    for (int i = 0; i < latitudes.Count; i++)
                    {
                        //yList.Add(latitudes[i] + longVelocities[i]);
                        yList.Add(latitudes[i] * latFactor + longVelocities[i]);
                    }
                    xList = DayByDay;
                    return(new OrbitSpec(star, type, xList, yList));
                }
                else if (type >= OrbitInfoType.Ascending && type <= OrbitInfoType.ApogeeVelocities)
                {
                    if (!planetsOrbits.ContainsKey(type))
                    {
                        loadNodeApsides(star);
                    }

                    yList = planetsOrbits[type];
                    xList = MonthByMonth;

                    if (xList.Count != yList.Count || yList.Count == 0)
                    {
                        return(null);
                    }

                    return(new OrbitSpec(star, type, xList, yList));
                }
                else
                {
                    throw new Exception();
                }


                //Dictionary<PlanetId, List<Double>> collection = null;

                //switch(type)
                //{
                //    //case OrbitInfoType.All:
                //    case OrbitInfoType.Longitude:
                //        collection = Longitudes;
                //        break;
                //    case OrbitInfoType.Latitude:
                //        collection = Latitudes;
                //        break;
                //    case OrbitInfoType.Distance:
                //        collection = Distances;
                //        break;
                //    case OrbitInfoType.LongitudeVelocities:
                //        collection = LongitudeVelocities;
                //        break;
                //    case OrbitInfoType.LatitudeVelocities:
                //        collection = LatitudeVelocities;
                //        break;
                //    case OrbitInfoType.DistanceVelocities:
                //        collection = DistanceVelocities;
                //        break;
                //    case OrbitInfoType.Ascending:
                //        collection = ascendingOrbits;
                //        break;
                //    case OrbitInfoType.Descending:
                //        collection = descendingOrbits;
                //        break;
                //    case OrbitInfoType.Perigee:
                //        collection = perigeeOrbits;
                //        break;
                //    case OrbitInfoType.Apogee:
                //        collection = apogeeOrbits;
                //        break;
                //    case OrbitInfoType.AscendingLatitude:
                //        collection = ascendingHeights;
                //        break;
                //    case OrbitInfoType.DescendingLatitude:
                //        collection = descendingHeights;
                //        break;
                //    case OrbitInfoType.PerigeeLatitude:
                //        collection = perigeeHeights;
                //        break;
                //    case OrbitInfoType.ApogeeLatitude:
                //        collection = apogeeHeights;
                //        break;
                //    case OrbitInfoType.AscendingVelocities:
                //        collection = ascendingVelocities;
                //        break;
                //    case OrbitInfoType.DescendingVelocities:
                //        collection = descendingVelocities;
                //        break;
                //    case OrbitInfoType.PerigeeVelocities:
                //        collection = perigeeVelocities;
                //        break;
                //    case OrbitInfoType.ApogeeVelocities:
                //        collection = apogeeVelocities;
                //        break;
                //    default:
                //        throw new NotImplementedException();
                //}

                //if (type >= OrbitInfoType.Ascending && !collection.ContainsKey(star))
                //{
                //    loadNodeApsides(star);
                //}

                //if (collection.ContainsKey(star))
                //    return collection[star];
                //else
                //    throw new Exception();
            }
        }
Esempio n. 10
0
        public bool RemoveCurveOf(PlanetId id, OrbitInfoType kind)
        {
            String label = OrbitSpec.LableOf(id, kind);

            return(RemoveCurveOf(label));
        }
Esempio n. 11
0
        public void AddCurve(String name)
        {
            if (IsCurveAdded(name))
            {
                RemoveCurveOf(name);
            }

            switch (name[0])
            {
            case 'A':
                if (Clock != null)
                {
                    LineItem clockLine = Frame.CurveOf(Clock, Orbits.Start, Orbits.End);

                    if (clockLine != null)
                    {
                        AddCurve(clockLine);
                    }
                }
                break;

            case '$':
                if (PriceTranslator != null)
                {
                    LineItem priceLine;

                    if (PriceTranslator.Rule != PriceMappingRules.Filled)
                    {
                        priceLine = Frame.CurveOf(PriceTranslator, History.CurrentOutline.PivotDates, History.CurrentOutline.PivotValues, CycleMapper, true);
                    }
                    else
                    {
                        priceLine = Frame.CurveOf(PriceTranslator, History.Dates, History.OutlineValues, CycleMapper, true);
                    }

                    if (priceLine != null)
                    {
                        AddCurve(priceLine);
                    }
                }
                break;

            case '+':
                if (Shift != null)
                {
                    LineItem shiftLine = Frame.CurveOf("+", timeScope, new List <double> {
                        Shift.Degrees, Shift.Degrees
                    }, Color.DarkCyan, SymbolType.None);
                    AddCurve(shiftLine);
                }
                break;

            case '*':
                if (Shift == null)
                {
                    break;
                }
                else if (MinusOrbits.Count != 0 || PlusOrbits.Count != 0)
                {
                    List <Double> xList = getCombinedDateValues();

                    if (xList != null)
                    {
                        CurveItem curve = combinedCurveOf(xList);
                        AddCurve(curve);
                    }
                    else
                    {
                        throw new Exception();
                    }
                }
                break;

            default:
                PlanetId      id   = OwnerOf(name[0]);
                OrbitInfoType kind = kindOf(name.Substring(1, name.Length - 1));
                AddCurve(id, kind);
                break;
            }
            Zed.Invalidate();
        }
Esempio n. 12
0
        public bool IsCurveAdded(PlanetId id, OrbitInfoType kind)
        {
            String label = OrbitSpec.LableOf(id, kind);

            return(IsCurveAdded(label));
        }
Esempio n. 13
0
 public static string LableOf(PlanetId id, OrbitInfoType kind)
 {
     return(String.Format("{0}{1}", Planet.SymbolOf(id), OrbitTypeAbbrv[kind]));
 }