Пример #1
0
        public override void SortAndAssignNeighbours()
        {
            if (BeforeBuildingCurves != null)
            {
                BeforeBuildingCurves(this, null);
            }

            base.SortAndAssignNeighbours();

            Curves.Clear();

            if (Keyframes.Count > 0)
            {
                //first curve
                Curves.Add(new TLCurve("Start" + IDGenerator.NewID, null, Keyframes[0]));

                //between
                for (int i = 1; i < Keyframes.Count; i++)
                {
                    Curves.Add(new TLCurve(IDGenerator.NewID, Keyframes[i - 1], Keyframes[i]));
                }

                //last
                Curves.Add(new TLCurve("End" + IDGenerator.NewID, Keyframes[Keyframes.Count - 1], null));
            }

            if (AfterBuildingCurves != null)
            {
                AfterBuildingCurves(this, null);
            }
        }
Пример #2
0
        public CurveItem this[PlanetId id, PlanetEventFlag category]
        {
            get
            {
                if (!Curves.ContainsKey(id) || !Curves[id].ContainsKey((int)category))
                {
                    return(null);
                }
                return(Curves[id][(int)category]);
            }
            set
            {
                if (!Curves.ContainsKey(id))
                {
                    Curves.Add(id, new Dictionary <int, CurveItem>());
                }

                if (!Curves[id].ContainsKey((int)category))
                {
                    Curves[id].Add((int)category, null);
                }

                Curves[id][(int)category] = value;
            }
        }
        public void AddCurve()
        {
            var curveConfig = model.AddCurve(SelectedPickableCurve);
            var newModel    = factory().Init(curveConfig);

            Curves.Add(newModel);
            SelectedCurve = newModel;

            SelectedPickableCurve = null;
            UpdatePickableCurves();
        }
Пример #4
0
        public void AddNewCurve()
        {
            var curve = Curve.Create(MinSpeed, MaxSpeed);

            repository.Curves.Add(curve);

            var viewModel = factory().Init(Curves.Last().Id + 1, curve);

            Curves.Add(viewModel);
            SelectedCurve = viewModel;
            eventAggregator.PublishOnUIThread(new CurveAdded(curve));
        }
Пример #5
0
        public AnimatorEditorState(IAnimator animator)
        {
            Animator = animator;
            var propertyType = animator.Owner.GetType().GetProperty(animator.TargetProperty).PropertyType;

            if (propertyType == typeof(Vector2))
            {
                Curves.Add(new CurveEditorState("X"));
                Curves.Add(new CurveEditorState("Y"));
            }
            else if (propertyType == typeof(float))
            {
                Curves.Add(new CurveEditorState(null));
            }
        }
Пример #6
0
 public void Redo()
 {
     if (removedCurves.Any())
     {
         var curve = removedCurves[removedCurves.Count - 1];
         removedCurves.RemoveAt(removedCurves.Count - 1);
         hanldeCollectionChanges = false;
         try
         {
             Curves.Add(curve);
             addedCurves.Add(curve);
         }
         finally
         {
             hanldeCollectionChanges = true;
         }
     }
 }
Пример #7
0
        public void UpdatePropertiesFrom(IUpdatable source, ICloneManager cloneManager)
        {
            var sourceChartTemplate = source as CurveChartTemplate;

            if (sourceChartTemplate == null)
            {
                return;
            }

            FontAndSize.UpdatePropertiesFrom(sourceChartTemplate.FontAndSize, cloneManager);
            ChartSettings.UpdatePropertiesFrom(sourceChartTemplate.ChartSettings, cloneManager);
            Name = sourceChartTemplate.Name;
            _axes.Clear();
            Curves.Clear();
            sourceChartTemplate.Axes.Each(axis => AddAxis(axis.Clone()));
            sourceChartTemplate.Curves.Each(curve => Curves.Add(cloneManager.Clone(curve)));
            IsDefault       = sourceChartTemplate.IsDefault;
            PreviewSettings = sourceChartTemplate.PreviewSettings;
        }
Пример #8
0
        protected virtual void Create(CarriageWay carriageWay, RoadCentreLine centreLine)
        {
            var db               = Application.DocumentManager.MdiActiveDocument.Database;
            var acTrans          = TransactionFactory.CreateFromTop();
            var blockTable       = (BlockTable)acTrans.GetObject(db.BlockTableId, OpenMode.ForRead);
            var blockTableRecord = (BlockTableRecord)acTrans.GetObject(blockTable[BlockTableRecord.ModelSpace], OpenMode.ForWrite);
            var offsetDist       = DistanceFromCarriageWay(carriageWay);

            foreach (ObjectId obj in carriageWay.Curves.Collection)
            {
                var entity = acTrans.GetObject(obj, OpenMode.ForRead) as Entity;
                if (entity is Curve curve)
                {
                    var curveOffset = curve.CreateOffset(Side, offsetDist);
                    if (curveOffset != null)
                    {
                        curveOffset.Layer = Constants.LAYER_DEF_POINTS;

                        Curves.Add(blockTableRecord.AppendEntity(curveOffset));
                        acTrans.AddNewlyCreatedDBObject(curveOffset, true);
                    }
                }
            }
        }
Пример #9
0
        private void MarkSections(Simulator simulator, List <TrackVectorSection> SectionList, float Len)
        {
            if (null == simulator)
            {
                throw new ArgumentNullException(nameof(simulator));
            }

            if (Len < simulator.Settings.SuperElevationMinLen || SectionList.Count == 0)
            {
                return;//too short a curve or the list is empty
            }
            TrackSections tSection    = simulator.TSectionDat.TrackSections;
            TrackSection  sectionData = tSection.Get(SectionList[0].SectionIndex);

            if (sectionData == null)
            {
                return;
            }
            //loop all section to determine the max elevation for the whole track
            double Curvature = sectionData.Angle * SectionList.Count * 33 / Len;                                           //average radius in degree/100feet
            float  Max       = (float)(Math.Pow(simulator.Route.SpeedLimit * 2.25, 2) * 0.0007 * Math.Abs(Curvature) - 3); //in inch

            Max *= 2.5f;                                                                                                   //change to cm
            Max  = (float)Math.Round(Max * 2, MidpointRounding.AwayFromZero) / 200f;                                       //closest to 5 mm increase;
            if (Max < 0.01f)
            {
                return;
            }
            if (Max > MaximumAllowedM)
            {
                Max = MaximumAllowedM;                              //max
            }
            Max = (float)Math.Atan(Max / 1.44f);                    //now change to rotation in radius by quick estimation as the angle is small

            Curves.Add(new List <TrackVectorSection>(SectionList)); //add the curve
            MapWFiles2Sections(SectionList);                        //map these sections to tiles, so we can compute it quicker later
            if (SectionList.Count == 1)                             //only one section in the curve
            {
                SectionList[0].StartElev = SectionList[0].EndElev = 0f; SectionList[0].MaxElev = Max;
            }
            else//more than one section in the curve
            {
                int count = 0;

                foreach (TrackVectorSection section in SectionList)
                {
                    if (count == 0)
                    {
                        section.StartElev = 0f;
                        section.MaxElev   = Max;
                        section.EndElev   = Max;
                    }
                    else if (count == SectionList.Count - 1)
                    {
                        section.StartElev = Max;
                        section.MaxElev   = Max;
                        section.EndElev   = 0f;
                    }
                    else
                    {
                        section.StartElev = section.EndElev = section.MaxElev = Max;
                    }
                    count++;
                }
            }
        }
Пример #10
0
        /// <summary>
        /// Initialize data
        /// </summary>
        /// <param name="userManager"></param>
        /// <param name="roleManager"></param>
        /// <param name="token"></param>
        /// <returns></returns>
        public async Task InitializeDatabaseAsync(
            UserManager <User> userManager,
            RoleManager <UserRole> roleManager,
            CancellationToken token = default)
        {
            await Database.EnsureCreatedAsync();

            if (await roleManager.FindByNameAsync("ROOT") == null)
            {
                await roleManager.CreateAsync(new UserRole { Name = "ROOT", NormalizedName = "ROOT" });
            }
            if (await roleManager.FindByNameAsync("COMMONUSER") == null)
            {
                await roleManager.CreateAsync(new UserRole { Name = "COMMONUSER", NormalizedName = "COMMONUSER" });
            }

            if (await userManager.FindByNameAsync("root") == null)
            {
                var user = new User {
                    UserName = "******"
                };
                await userManager.CreateAsync(user, "123456");

                await userManager.AddToRoleAsync(user, "ROOT");
            }
            for (var i = 1; i <= 10; i++)
            {
                var userName = "******" + i;
                if (await userManager.FindByNameAsync(userName) == null)
                {
                    var user = new User {
                        UserName = userName
                    };
                    await userManager.CreateAsync(user, "123456");

                    await userManager.AddToRoleAsync(user, "COMMONUSER");
                }
            }

            if (!await Curves.AnyAsync(x => x.Id == "bancor", token))
            {
                Curves.Add(new Curve
                {
                    Id = "bancor",
                    PriceSupplyFunction   = "${supply} * (pow((1 + (x - ${balance}) / ${balance}),${cw}) - 1) + ${supply}",
                    BalanceSupplyFunction = "x / ((${supply} * (pow((1 + (x - ${balance}) / ${balance}),${cw}) - 1) + ${supply}) * ${cw})",
                    Description           = "",
                    Arguments             = JsonConvert.SerializeObject(new List <CurveArgument>
                    {
                        new CurveArgument {
                            Id = "supply", ControlType = CurveArgumentControlType.Input, Name = "Initial Supply (Token)"
                        },
                        new CurveArgument {
                            Id = "balance", ControlType = CurveArgumentControlType.Input, Name = "Initial Balance (EOS)"
                        },
                        new CurveArgument {
                            Id = "cw", ControlType = CurveArgumentControlType.Slider, Name = "Reserve Ratio"
                        }
                    })
                });

                await SaveChangesAsync();
            }

            if (!await Curves.AnyAsync(x => x.Id == "daibo", token))
            {
                Curves.Add(new Curve
                {
                    Id = "daibo",
                    PriceSupplyFunction   = "${k} * x",
                    BalanceSupplyFunction = "${k}/2 * x^2",
                    SupplyBalanceFunction = "(2/${k})^(0.5) * x^(0.5)",
                    PriceBalanceFunction  = "((2/${k})^(0.5) * x^(0.5)) * ${k}",
                    Description           = "",
                    Arguments             = JsonConvert.SerializeObject(new List <CurveArgument>
                    {
                        new CurveArgument {
                            Id = "k", ControlType = CurveArgumentControlType.Slider, Name = "Increase Ratio"
                        }
                    })
                });

                await SaveChangesAsync();
            }

            if (!await Constants.AnyAsync(x => x.Id == "action_pos", token))
            {
                Constants.Add(new Constant
                {
                    Id    = "action_pos",
                    Value = "-1"
                });

                await SaveChangesAsync();
            }
        }
Пример #11
0
        private void setDuration(ZedGraphControl zed, DateTimeOffset since, DateTimeOffset until)
        {
            double min = zed.GraphPane.XAxis.Scale.Min = since.DateTime.ToOADate();
            double max = zed.GraphPane.XAxis.Scale.Max = until.DateTime.ToOADate();

            List <SeFlg> centricFlags = new List <SeFlg> {
                SeFlg.GEOCENTRIC, SeFlg.HELIOCENTRIC
            };
            List <double> xValues = new List <double>();

            for (double x = min; x <= max; x++)
            {
                xValues.Add(x);
            }

            for (int i = zed.GraphPane.CurveList.Count - 1; i >= 0; i--)
            {
                CurveItem curve = zed.GraphPane.CurveList[i];
                removeCurve(zedLongTerm, curve);
            }

            foreach (SeFlg flag in centricFlags)
            {
                CentricFlag = flag;

                #region Get the longitude curves
                OrbitsDict     = CurrentEphemeris.AllOrbitsCollectionDuring(since, until);
                TheAspectarian = CurrentEphemeris.AspectarianDuring(since, until, defaultAspectImportance);
                //populateAspectarian(TheAspectarian);

                //Special treatment of average longDif by replacing them with the smoothed version without gap generated when a planet enters Aries
                for (int i = CurrentEphemeris.Luminaries.IndexOf(PlanetId.Five_Average); i < CurrentEphemeris.Luminaries.Count; i++)
                {
                    PlanetId      id          = CurrentEphemeris.Luminaries[i];
                    List <double> beforeShift = OrbitsDict[PositionValueIndex.Longitude][id];
                    List <double> afterShift  = Ephemeris.SmoothingOfAverage(beforeShift);
                    OrbitsDict[PositionValueIndex.Longitude].Remove(id);
                    OrbitsDict[PositionValueIndex.Longitude].Add(id, afterShift);
                }
                #endregion

                Curves.Clear();

                foreach (KeyValuePair <PlanetId, List <double> > kvp in OrbitsDict[PositionValueIndex.Longitude])
                {
                    String   name  = Planet.Glyphs[kvp.Key].ToString();
                    Color    color = Planet.PlanetsColors.ContainsKey(kvp.Key) ? Planet.PlanetsColors[kvp.Key].First() : Color.Gray;
                    LineItem line  = null;

                    List <IPlanetEvent> signChanges = CurrentEphemeris[since, until, PlanetEventFlag.SignChangedCategory, kvp.Key];

                    if (signChanges != null && signChanges.Count != 0)
                    {
                        List <double> finalYs = new List <double>(kvp.Value);
                        List <double> finalXs = new List <double>(xValues);

                        for (int i = signChanges.Count - 1; i >= 0; i--)
                        {
                            SignEntrance change = signChanges[i] as SignEntrance;

                            double x = (change.When - since).TotalDays;
                            double y = Math.Round(change.Where.Longitude);

                            int insertPos = (int)x + 1;

                            if (y != 0 && y != 360)
                            {
                                finalXs.Insert(insertPos, x + min);
                                finalYs.Insert(insertPos, y);
                            }
                            else
                            {
                                finalXs.Insert(insertPos, x + min);
                                finalXs.Insert(insertPos, x + min);
                                finalYs.Insert(insertPos, change.IsRetrograde ? 360 : 0);
                                finalYs.Insert(insertPos, change.IsRetrograde ? 0 : 360);
                            }
                        }

                        line = new LineItem(name, finalXs.ToArray(), finalYs.ToArray(), color, SymbolType.None);
                    }
                    else
                    {
                        line = new LineItem(name, xValues.ToArray(), kvp.Value.ToArray(), color, SymbolType.None);
                    }

                    Curves.Add(kvp.Key, new Dictionary <int, CurveItem> {
                        { 0, line }
                    });
                }
                getEventCurves();
            }
        }
Пример #12
0
        public Animation(FBXFile file, List <string> bones)
        {
            var rawNodes  = file.GetAnimationCurveNodes();
            var rawCurves = file.GetAnimationCurves();

            // first: expand AnimationCurveNode into curve nodes
            var curveNodes = new List <FBXAnimCurveNode>();

            foreach (var tempNode in rawNodes)
            {
                var fileNode = file.FindChild(tempNode.Id);

                curveNodes.Add(new FBXAnimCurveNode(fileNode, file, bones));
            }

            // second: gen dict, mapped by internalId
            var tmp = new Dictionary <long, FBXAnimCurveNode>();

            for (var i = 0; i < curveNodes.Count; ++i)
            {
                tmp.Add(curveNodes[i].Id, curveNodes[i]);
            }

            // third: insert curves into the dict
            var ac  = new List <FBXAnimCurve>();
            var max = 0f;

            foreach (var curve in rawCurves)
            {
                ac.Add(curve);

                max = curve.Length > max ? curve.Length : max;

                var parentId = file.Connections.Where(a => a.Src == curve.Id).FirstOrDefault().Dst;
                var axis     = file.GetConnectionType(curve.Id, parentId);

                if (axis.Contains("X"))
                {
                    axis = "x";
                }
                if (axis.Contains("Y"))
                {
                    axis = "y";
                }
                if (axis.Contains("Z"))
                {
                    axis = "z";
                }

                tmp[parentId].Curves.Add(axis, curve);
            }

            // forth:
            foreach (var t in tmp)
            {
                var id = t.Value.ContainerBoneId;

                if (!Curves.ContainsKey(id))
                {
                    Curves.Add(id, new Dictionary <string, FBXAnimCurveNode>());
                }

                if (Curves[id].ContainsKey(t.Value.Attr))
                {
                    Curves[id][t.Value.Attr] = t.Value;
                }
                else
                {
                    Curves[id].Add(t.Value.Attr, t.Value);
                }
            }

            Length = max;
            Frames = Length * FPS;
        }
Пример #13
0
 public void Add(CurveBase curve)
 {
     Curves.Add(curve);
 }
Пример #14
0
 public void AddNewCurve()
 {
     Curves.Add(Curve.Create());
     Curves = new List <Curve>(Curves.OrderBy(c => c.Name));
 }
Пример #15
0
        public virtual void Create(RoadCentreLine centreLine)
        {
            var keepList    = new List <Curve>();
            var wasteList   = new List <Curve>();
            var offsetCurve = centreLine.GetCurve().CreateOffset(Side, DistanceFromCentre);

            if (Intersections.Count == 0 & Ignore)
            {
                return;
            }
            keepList.Add(offsetCurve);

            foreach (var intersection in Intersections)
            {
                var hasIntersected = false;

                foreach (var r in keepList.ToList())
                {
                    var splitSets = r.TrySplit(intersection.Point);
                    if (splitSets == null)
                    {
                        continue;
                    }

                    hasIntersected = true;
                    keepList.Remove(r);

                    var beforeCurve = splitSets[0] as Curve;
                    var afterCurve  = splitSets[1] as Curve;

                    if (intersection.Before)
                    {
                        if (beforeCurve != null)
                        {
                            keepList.Add(beforeCurve);
                        }
                        if (afterCurve != null)
                        {
                            wasteList.Add(afterCurve);
                        }
                    }
                    else
                    {
                        if (beforeCurve != null)
                        {
                            wasteList.Add(beforeCurve);
                        }
                        if (afterCurve != null)
                        {
                            keepList.Add(afterCurve);
                        }
                    }
                }

                if (hasIntersected)
                {
                    continue;
                }

                foreach (var w in wasteList.ToList())
                {
                    var splitSets = w.TrySplit(intersection.Point);
                    if (splitSets == null)
                    {
                        continue;
                    }

                    wasteList.Remove(w);

                    var beforeCurve = splitSets[0] as Curve;
                    var afterCurve  = splitSets[1] as Curve;
                    if (intersection.Before)
                    {
                        if (beforeCurve != null)
                        {
                            keepList.Add(beforeCurve);
                        }
                        if (afterCurve != null)
                        {
                            wasteList.Add(afterCurve);
                        }
                    }
                    else
                    {
                        if (beforeCurve != null)
                        {
                            wasteList.Add(beforeCurve);
                        }
                        if (afterCurve != null)
                        {
                            keepList.Add(afterCurve);
                        }
                    }
                }
            }

            var db               = Application.DocumentManager.MdiActiveDocument.Database;
            var acTrans          = TransactionFactory.CreateFromTop();
            var blockTable       = (BlockTable)acTrans.GetObject(db.BlockTableId, OpenMode.ForRead);
            var blockTableRecord = (BlockTableRecord)acTrans.GetObject(blockTable[BlockTableRecord.ModelSpace], OpenMode.ForWrite);

            foreach (var curve in keepList)
            {
                curve.Layer = Constants.LAYER_DEF_POINTS;

                Curves.Add(blockTableRecord.AppendEntity(curve));
                acTrans.AddNewlyCreatedDBObject(curve, true);
            }
        }
Пример #16
0
 public void AddNewCurve(Curve curve)
 {
     Curves.Add(curve);
     Curves = new List <Curve>(Curves.OrderBy(c => c.Name));
 }