private void ClearEventHandler() { UserInputs[0].PointsList.Clear(); CurvesElements.Clear(); Model = new ArticulatedModel(); Render(); }
private void Render() { CanvasElements.Clear(); CanvasElements.AddRange(Model.GetDrawing()); //CanvasElements.AddRange(GeneratedAssembly.GetDrawing()); //AssembliesDrawable.ForEach(assembly => CanvasElements.AddRange(assembly.GetDrawing())); UserInputs.ForEach(curve => CanvasElements.AddRange(curve.GetDrawing())); CurvesElements.ForEach(curve => CanvasElements.Add(curve)); //// fixes y axis //for (int i = 0; i < CanvasElements.Count; i++) //{ // CanvasElements[i]. //} }
private void SolvedAssemblyEventHandler(AssemblySolver.CurveAssemblyAndAlignments obj) { //transform curve with 0 mean var mean = obj.c_a.Curve.Points.Aggregate(new Point(), (m, p) => { m.X += p.X; m.Y += p.Y; return(m); }); mean.X /= 72; mean.Y /= 72; double toflip = 1;//obj.ToFlip ? -1 : 1; var pts = obj.c_a.Curve.Points.Select(point => { var x = (point.X - mean.X); var y = (point.Y - mean.Y) * toflip; var rotatedX = (Math.Cos(-obj.RadRotation) * x - Math.Sin(-obj.RadRotation) * y) * obj.Scale; var rotatedY = (Math.Cos(-obj.RadRotation) * y + Math.Sin(-obj.RadRotation) * x) * obj.Scale; return(new Point(rotatedX + obj.MeanPoint.X, rotatedY + obj.MeanPoint.Y)); } ).ToList(); //plot CurvesElements.Clear(); CurvesElements.AddRange(pts.Select(point => { var tran2 = new TranslateTransform(point.X - 2, point.Y - 2); return(new Ellipse() { Width = 4, Height = 4, Fill = Brushes.Green, RenderTransform = tran2 }); })); Model = new ArticulatedModel(); Model.Load(obj); //load from JsonForAssemblies //add to canvas Render(); }