/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param> protected override void SolveInstance(IGH_DataAccess DA) { string T = ""; Plane P = Plane.WorldXY; if (!DA.GetData(0, ref T)) { return; } if (!DA.GetData(1, ref P)) { return; } wPlane Pln = new wPlane(new wPoint(P.Origin.X, P.Origin.Y, P.Origin.Z), new wVector(P.XAxis.X, P.XAxis.Y, P.XAxis.Z), new wVector(P.YAxis.X, P.YAxis.Y, P.YAxis.Z)); wText Txt = new wText(T); wTextObject TxtObj = new wTextObject(Txt, Pln); TxtObj.Angle = (Vector3d.VectorAngle(Vector3d.YAxis, P.YAxis, Plane.WorldXY) / Math.PI * 180); wShape Shape = new wShape(TxtObj); wShapeCollection Shapes = new wShapeCollection(Shape); Shapes.Type = "Text"; Shapes.Graphics = new wGraphic().BlackFill(); Shapes.Effects = new wEffects(); wObject WindObject = new wObject(Shapes, "Hoopoe", Shapes.Type); DA.SetData(0, WindObject); }
public wFillSwatch(wShapeCollection ShapeSet, double Scale, int TilingMode, double X, double Y, double PanelWidth, double PanelHeight) { foreach (wShape Shp in ShapeSet.Shapes) { GeometryDrawing dwgG = new GeometryDrawing(new SolidColorBrush(Shp.Graphic.Foreground.ToMediaColor()), new Pen(new SolidColorBrush(Shp.Graphic.StrokeColor.ToMediaColor()), Shp.Graphic.StrokeWeight[0]), Shp.GeometrySet); dwgG.Pen.DashStyle = new DashStyle(Shp.Graphic.StrokePattern, 0); dwgG.Pen.DashCap = PenLineCap.Flat; dwgG.Pen.StartLineCap = (PenLineCap)Shp.Graphic.StrokeCap; dwgG.Pen.EndLineCap = (PenLineCap)Shp.Graphic.StrokeCap; DwgGroup.Children.Add(dwgG); } DwgGroup.ClipGeometry = new RectangleGeometry(new System.Windows.Rect(X, Y, PanelWidth, PanelHeight)); DwgBrush.Drawing = DwgGroup; DwgBrush.Viewbox = new System.Windows.Rect(0, 0, 1, 1); DwgBrush.Viewport = new System.Windows.Rect(0, 0, Scale, Scale); DwgBrush.TileMode = TileMode.Tile; DwgBrush.Stretch = Stretch.UniformToFill; DwgBrush.AlignmentX = AlignmentX.Center; DwgBrush.AlignmentY = AlignmentY.Center; FillBrush = DwgBrush; }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param> protected override void SolveInstance(IGH_DataAccess DA) { Point3d P = new Point3d(0, 0, 0); double R = 1.0; if (!DA.GetData(0, ref P)) { return; } if (!DA.GetData(1, ref R)) { return; } wPoint O = new wPoint(P.X, P.Y, P.Z); wCurve Crv = new wCircle(O, R); wShape Shape = new wShape(Crv); wShapeCollection Shapes = new wShapeCollection(Shape); wPlane Pln = new wPlane().XYPlane(); Pln.Origin = O; Shapes.Boundary = new wRectangle(Pln, R, R); Shapes.Type = Crv.GetCurveType; Shapes.Graphics = new wGraphic().BlackFill(); Shapes.Effects = new wEffects(); wObject WindObject = new wObject(Shapes, "Hoopoe", Shapes.Type); DA.SetData(0, WindObject); }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param> protected override void SolveInstance(IGH_DataAccess DA) { IGH_Goo Element = null; string LayerName = "Layer 01"; if (!DA.GetData(0, ref Element)) { return; } if (!DA.GetData(1, ref LayerName)) { return; } wObject W = new wObject(); if (Element != null) { Element.CastTo(out W); } wGraphic G = W.Graphics; G.Layer = LayerName; W.Graphics = G; switch (W.Type) { case "Parrot": pElement E = (pElement)W.Element; pControl C = (pControl)E.ParrotControl; C.Graphics = G; break; case "Pollen": switch (W.SubType) { } break; case "Hoopoe": wShapeCollection Shapes = (wShapeCollection)W.Element; Shapes.Group = LayerName; Shapes.Graphics.Layer = LayerName; W.Element = Shapes; break; } DA.SetData(0, W); DA.SetData(1, G); }
private void GroupCheck(wShapeCollection shapes) { string Name = shapes.Group; if (!PathSet.ContainsKey(Name)) { PathSet.Add(Name, new StringBuilder()); Frames.AddFrame(shapes.Frame); FrameCount += Convert.ToInt32(shapes.Frame.Active); } }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param> protected override void SolveInstance(IGH_DataAccess DA) { IGH_Goo Z = null; Rectangle3d R = new Rectangle3d(Plane.WorldXY, 150, 150); if (!DA.GetData(0, ref Z)) { return; } if (!DA.GetData(0, ref R)) { return; } Bitmap A = null; if (Z != null) { Z.CastTo(out A); } // Check if is pline Curve C = R.ToNurbsCurve(); BoundingBox B = C.GetBoundingBox(true); wPoint O = new wPoint(B.Center.X, B.Center.Y, B.Center.Z); wShape Shape = new wShape(new wRectangle()); wShapeCollection Shapes = new wShapeCollection(Shape); wPlane Pln = new wPlane().XYPlane(); Pln.Origin = O; Shapes.Boundary = new wRectangle(Pln, B.Diagonal.X, B.Diagonal.Y); //Shapes.Type = Crv.GetCurveType; if (C.IsClosed) { Shapes.Graphics = new wGraphic().BlackFill(); } else { Shapes.Graphics = new wGraphic().BlackOutline(); } Shapes.Effects = new wEffects(); wObject WindObject = new wObject(Shapes, "Hoopoe", Shapes.Type); DA.SetData(0, WindObject); }
public Path WpfCompoundPolyline(wShapeCollection Shapes) { Path X = new Path(); PathFigureCollection Fc = new PathFigureCollection(); PathGeometry G = new PathGeometry(); Fc.Clear(); foreach (wShape Shp in Shapes.Shapes) { PathSegmentCollection Sc = new PathSegmentCollection(); PathFigure Pf = new PathFigure(); wCurve Crv = Shp.Curve; wPoint StartPoint = Crv.Points[0]; Pf.StartPoint = new System.Windows.Point(StartPoint.X * Scale, StartPoint.Y * Scale); PathGeometry Geo = (PathGeometry)WpfPolyline(Crv, Shapes.Graphics, Shapes.Effects).Data; PathFigureCollection Fig = (PathFigureCollection)Geo.Figures; PathFigure PFig = (PathFigure)(Fig[0]); PathSegmentCollection Seg = (PathSegmentCollection)PFig.Segments; PolyLineSegment Pl = (PolyLineSegment)Seg[0]; PolyLineSegment S = new PolyLineSegment(Pl.Points, true); Pf.IsClosed = true; Sc.Add(S); Pf.Segments = Sc; Fc.Add(Pf); } G.Figures = Fc; X.Data = G; X.RenderTransform = Xform; wGraphic Graphics = Shapes.Graphics; wEffects ShapeEffects = Shapes.Effects; X = SetPathFill(X, Graphics); X = SetPathStroke(X, Graphics); X = SetPathEffects(X, ShapeEffects); group.Shapes.Add(new wShape(G, Graphics)); return(X); }
public wPattern(double OriginX, double OriginY, double CropWidth, double CropHeight, wShapeCollection ShapeGraphic) { X = OriginX; Y = OriginY; W = CropWidth; H = CropHeight; Shp = ShapeGraphic; Shp.X = X; Shp.Y = Y; Shp.Width = W; Shp.Height = H; }
public Path WpfCompoundSpline(wShapeCollection Shapes) { Path X = new Path(); PathFigureCollection Fc = new PathFigureCollection(); PathGeometry G = new PathGeometry(); Fc.Clear(); foreach (wShape Shp in Shapes.Shapes) { PathSegmentCollection Sc = new PathSegmentCollection(); PathFigure Pf = new PathFigure(); wBezierSpline C = (wBezierSpline)Shp.Curve; wPoint StartPoint = C.Points[0]; PolyBezierSegment S = new PolyBezierSegment(); Pf.StartPoint = new System.Windows.Point(C.Points[0].X * Scale, C.Points[0].Y * Scale); for (int i = 1; i < C.Points.Count; i++) { wPoint P = C.Points[i]; S.Points.Add(new System.Windows.Point(P.X * Scale, P.Y * Scale)); } Sc.Add(S); Pf.Segments = Sc; //Pf.IsClosed = true; Fc.Add(Pf); } G.Figures = Fc; X.Data = G; X.RenderTransform = Xform; wGraphic Graphics = Shapes.Graphics; wEffects ShapeEffects = Shapes.Effects; X = SetPathStroke(X, Graphics); X = SetPathFill(X, Graphics); X = SetPathEffects(X, ShapeEffects); group.Shapes.Add(new wShape(G, Graphics)); return(X); }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param> protected override void SolveInstance(IGH_DataAccess DA) { IGH_Goo Element = null; double R = 10.0; if (!DA.GetData(0, ref Element)) { return; } if (!DA.GetData(1, ref R)) { return; } wObject W = new wObject(); if (Element != null) { Element.CastTo(out W); } switch (W.Type) { case "Parrot": pElement E = (pElement)W.Element; break; case "Pollen": break; case "Hoopoe": wShapeCollection Shapes = (wShapeCollection)W.Element; Shapes.Effects.Blur = new wBlur(R); Shapes.Effects.SetEffect(Shapes.Effects.Blur.ShapeEffect); Shapes.Effects.HasEffect = true; W.Element = Shapes; break; } DA.SetData(0, W); }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param> protected override void SolveInstance(IGH_DataAccess DA) { Brep B = new Brep(); double D = 0; double K = 0; if (!DA.GetData(0, ref B)) { return; } if (!DA.GetData(1, ref D)) { return; } if (!DA.GetData(2, ref K)) { return; } Curve[] C = B.DuplicateNakedEdgeCurves(true, true); C = Curve.JoinCurves(C); wShapeCollection Shapes = new wShapeCollection(); foreach (Curve Crv in C) { Shapes.Shapes.Add(new wShape(new RhCrvToWindCrv().ToPiecewiseBezier(Crv, D, K))); } BoundingBox X = B.GetBoundingBox(true); wPoint O = new wPoint(X.Center.X, X.Center.Y, X.Center.Z); wPlane Pln = new wPlane().XYPlane(); Pln.Origin = O; Shapes.Boundary = new wRectangle(Pln, X.Diagonal.X, X.Diagonal.Y); Shapes.Type = "PolyCurveGroup"; Shapes.Graphics = new wGraphic().BlackFill(); wObject WindObject = new wObject(Shapes, "Hoopoe", Shapes.Type); DA.SetData(0, WindObject); }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param> protected override void SolveInstance(IGH_DataAccess DA) { Mesh M = new Mesh(); if (!DA.GetData(0, ref M)) { return; } Polyline[] P = M.GetNakedEdges(); List <wShape> Shape = new List <wShape>(); foreach (Polyline Pline in P) { List <wPoint> Pts = new List <wPoint>(); for (int i = 0; i < Pline.Count; i++) { Pts.Add(new wPoint(Pline[i].X, Pline[i].Y, Pline[i].Z)); } wCurve Crv = new wPolyline(Pts, true); Shape.Add(new wShape(Crv)); } wShapeCollection Shapes = new wShapeCollection(Shape); BoundingBox B = M.GetBoundingBox(true); wPoint O = new wPoint(B.Center.X, B.Center.Y, B.Center.Z); wPlane Pln = new wPlane().XYPlane(); Pln.Origin = O; Shapes.Boundary = new wRectangle(Pln, B.Diagonal.X, B.Diagonal.Y); Shapes.Type = "PolylineGroup"; Shapes.Graphics = new wGraphic().BlackFill(); wObject WindObject = new wObject(Shapes, "Hoopoe", Shapes.Type); DA.SetData(0, WindObject); }
public void AddShape(wShapeCollection Shapes) { switch (Shapes.Type) { case "Arc": Element.Children.Add(WpfArc(Shapes.Shapes[0].Curve, Shapes.Graphics, Shapes.Effects)); break; case "Circle": Element.Children.Add(WpfCircle(Shapes.Shapes[0].Curve, Shapes.Graphics, Shapes.Effects)); break; case "Ellipse": Element.Children.Add(WpfEllipse(Shapes.Shapes[0].Curve, Shapes.Graphics, Shapes.Effects)); break; case "Line": Element.Children.Add(WpfLine(Shapes.Shapes[0].Curve, Shapes.Graphics, Shapes.Effects)); break; case "Polyline": Element.Children.Add(WpfPolyline(Shapes.Shapes[0].Curve, Shapes.Graphics, Shapes.Effects)); break; case "BezierSpline": Element.Children.Add(WpfSpline(Shapes.Shapes[0].Curve, Shapes.Graphics, Shapes.Effects)); break; case "Text": Element.Children.Add(WpfText(Shapes.Shapes[0].Curve, Shapes.Graphics, Shapes.Effects)); break; default: break; } }
public void SetShapeType(wShapeCollection HoopoeShapes, int ShapeIndex) { Index = ShapeIndex; Shapes = HoopoeShapes; switch (Shapes.Type) { case "PolyCurveGroup": CompoundCurve(); break; case "PolylineGroup": CompoundPolyline(); break; case "Text": AddText(); break; default: AddShape(); break; } }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param> protected override void SolveInstance(IGH_DataAccess DA) { IGH_Goo Element = null; System.Drawing.Color B = System.Drawing.Color.Black; double T = 1; List <double> P = new List <double>(); if (!DA.GetData(0, ref Element)) { return; } if (!DA.GetData(1, ref B)) { return; } if (!DA.GetData(2, ref T)) { return; } if (!DA.GetDataList(3, P)) { return; } wObject W = new wObject(); if (Element != null) { Element.CastTo(out W); } wGraphic G = W.Graphics; G.StrokeColor = new wColor(B); G.SetUniformStrokeWeight(T); G.StrokeCap = (wGraphic.StrokeCaps)CapMode; G.StrokeCorner = (wGraphic.StrokeCorners)CornerMode; switch (PatternMode) { case 0: if ((P.Count == 1) && (P[0] == 0)) { P = new List <double> { 1, 0 }; } break; case 1: P = new List <double> { 2, 3 }; break; case 2: P = new List <double> { 5 }; break; case 3: P = new List <double> { 15, 10 }; break; case 4: P = new List <double> { 0.5, 2 }; break; case 5: P = new List <double> { 30, 5, 10, 5, }; break; } List <double> SP = new List <double>(); foreach (double PV in P) { SP.Add(PV / T); } G.StrokePattern = SP.ToArray(); G.CustomStrokes += 1; W.Graphics = G; switch (W.Type) { case "Parrot": pElement E = (pElement)W.Element; pControl C = (pControl)E.ParrotControl; C.Graphics = G; C.SetStroke(); break; case "Pollen": switch (W.SubType) { case "DataPoint": DataPt tDataPt = (DataPt)W.Element; tDataPt.Graphics = G; W.Element = tDataPt; break; case "DataSet": DataSetCollection tDataSet = (DataSetCollection)W.Element; tDataSet.Graphics = G; W.Element = tDataSet; break; case "Chart": case "Table": pElement pE = (pElement)W.Element; pChart pC = pE.PollenControl; pC.Graphics = G; pC.SetStroke(); pE.PollenControl = pC; W.Element = pE; break; } break; case "Hoopoe": wShapeCollection Shapes = (wShapeCollection)W.Element; Shapes.Graphics.StrokeColor = G.StrokeColor; Shapes.Graphics.StrokeWeight = G.StrokeWeight; Shapes.Graphics.StrokePattern = G.StrokePattern; Shapes.Graphics.StrokeCap = G.StrokeCap; Shapes.Graphics.StrokeCorner = G.StrokeCorner; W.Element = Shapes; break; } DA.SetData(0, W); DA.SetData(1, G); }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param> protected override void SolveInstance(IGH_DataAccess DA) { Curve C = new Circle(new Point3d(0, 0, 0), 1).ToNurbsCurve(); double D = 0; double K = 0; if (!DA.GetData(0, ref C)) { return; } if (!DA.GetData(1, ref D)) { return; } if (!DA.GetData(2, ref K)) { return; } wCurve Crv = new wCircle(new wPoint(), 1); Curve[] Segments = C.DuplicateSegments(); // Check if is pline if (Segments.Count() > 1) { Polyline P = new Polyline(); if (C.TryGetPolyline(out P)) { List <wPoint> Pts = new List <wPoint>(); for (int i = 0; i < P.Count; i++) { Pts.Add(new wPoint(P[i].X, P[i].Y, P[i].Z)); } Crv = new wPolyline(Pts, P.IsClosed); } else { Crv = new RhCrvToWindCrv().ToPiecewiseBezier(C, D, K); } } else { Crv = new RhCrvToWindCrv(C).WindCurve; } BoundingBox B = C.GetBoundingBox(true); wPoint O = new wPoint(B.Center.X, B.Center.Y, B.Center.Z); wShape Shape = new wShape(Crv); wShapeCollection Shapes = new wShapeCollection(Shape); wPlane Pln = new wPlane().XYPlane(); Pln.Origin = O; Shapes.Boundary = new wRectangle(Pln, B.Diagonal.X, B.Diagonal.Y); Shapes.Type = Crv.GetCurveType; if (C.IsClosed) { Shapes.Graphics = new wGraphic().BlackFill(); } else { Shapes.Graphics = new wGraphic().BlackOutline(); } Shapes.Effects = new wEffects(); wObject WindObject = new wObject(Shapes, "Hoopoe", Shapes.Type); DA.SetData(0, WindObject); }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param> protected override void SolveInstance(IGH_DataAccess DA) { IGH_Goo Element = null; string N = "Arial"; double S = 8; System.Drawing.Color X = System.Drawing.Color.Black; int J = 0; bool B = false; bool I = false; bool U = false; if (!DA.GetData(0, ref Element)) { return; } if (!DA.GetData(1, ref N)) { return; } if (!DA.GetData(2, ref S)) { return; } if (!DA.GetData(3, ref X)) { return; } if (!DA.GetData(4, ref J)) { return; } if (!DA.GetData(5, ref B)) { return; } if (!DA.GetData(6, ref I)) { return; } if (!DA.GetData(7, ref U)) { return; } wObject W = new wObject(); if (Element != null) { Element.CastTo(out W); } wGraphic G = W.Graphics; wFont F = new wFont(N, S, new wColor(X), (wFontBase.Justification)J, B, I, U, false); G.FontObject = F; W.Graphics = G; switch (W.Type) { case "Parrot": pElement E = (pElement)W.Element; pControl C = (pControl)E.ParrotControl; C.Graphics = G; C.SetFont(); break; case "Pollen": switch (W.SubType) { case "DataPoint": DataPt tDataPt = (DataPt)W.Element; tDataPt.Graphics = G; W.Element = tDataPt; break; case "DataSet": DataSetCollection tDataSet = (DataSetCollection)W.Element; tDataSet.Graphics = G; tDataSet.TotalCustomTitles += 1; W.Element = tDataSet; break; case "Chart": case "Table": pElement pE = (pElement)W.Element; pChart pC = pE.PollenControl; pC.Graphics = G; pC.SetFont(); pE.PollenControl = pC; W.Element = pE; break; } break; case "Hoopoe": wShapeCollection Shapes = (wShapeCollection)W.Element; Shapes.Fonts = F; W.Element = Shapes; break; } DA.SetData(0, W); DA.SetData(1, G.FontObject); DA.SetData(2, G); }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param> protected override void SolveInstance(IGH_DataAccess DA) { //Set Unique Control Properties List <IGH_Goo> Shps = new List <IGH_Goo>(); Rectangle3d B = new Rectangle3d(Plane.WorldXY, 0, 0); Interval Fx = new Interval(600, 600); bool D = true; if (!DA.GetDataList(0, Shps)) { return; } if (!DA.GetData(1, ref B)) { return; } if (!DA.GetData(2, ref Fx)) { return; } if (!DA.GetData(3, ref D)) { return; } List <wShapeCollection> Shapes = new List <wShapeCollection>(); Rectangle3d F = new Rectangle3d(Plane.WorldXY, Fx.T0, Fx.T1); wObject Wx = new wObject(); wShapeCollection Sx = new wShapeCollection(); Shps[0].CastTo(out Wx); Sx = (wShapeCollection)Wx.Element; BoundingBox bBox = new BoundingBox(); if (D) { SavedBox = new BoundingBox(); } else { bBox = SavedBox; } bBox.Union(new BoundingBox(Sx.Boundary.CornerPoints[0].X, Sx.Boundary.CornerPoints[0].Y, 0, Sx.Boundary.CornerPoints[2].X, Sx.Boundary.CornerPoints[2].Y, 0)); SavedBox = bBox; foreach (IGH_Goo Obj in Shps) { wObject W = new wObject(); wShapeCollection S = new wShapeCollection(); Obj.CastTo(out W); S = (wShapeCollection)W.Element; Shapes.Add(S); wPoint PtA = S.Boundary.CornerPoints[0]; wPoint PtB = S.Boundary.CornerPoints[2]; bBox.Union(new Point3d(PtA.X, PtA.Y, PtA.Z)); bBox.Union(new Point3d(PtB.X, PtB.Y, PtB.Z)); } if ((B.Width == 0.0) & (B.Height == 0.0)) { Plane pln = Plane.WorldXY; pln.Origin = bBox.Center; B = new Rectangle3d(pln, new Interval(-bBox.Diagonal.X / 2.0, bBox.Diagonal.X / 2.0), new Interval(-bBox.Diagonal.Y / 2.0, bBox.Diagonal.Y / 2.0)); } wPlane PlnB = new wPlane( new wPoint(B.Center.X, B.Center.Y, B.Center.Z), new wVector(B.Plane.XAxis.X, B.Plane.XAxis.Y, B.Plane.XAxis.Z), new wVector(B.Plane.YAxis.X, B.Plane.YAxis.Y, B.Plane.YAxis.Z)); wPlane PlnF = new wPlane( new wPoint(F.Center.X, F.Center.Y, F.Center.Z), new wVector(F.Plane.XAxis.X, F.Plane.XAxis.Y, F.Plane.XAxis.Z), new wVector(F.Plane.YAxis.X, F.Plane.YAxis.Y, F.Plane.YAxis.Z)); CompileSVG SVGobject = new CompileSVG(); double X = F.Width / B.Width; double Y = F.Height / B.Height; double Z = 1.0; if (X < Y) { Z = X; } else { Z = Y; } SVGobject.SetSize((int)F.Width, (int)F.Height, new wRectangle(PlnB, B.Width, B.Height), Z); SVGobject.SetQuality(QualityType); if (D) { SavedPathSets.Clear(); } else { SVGobject.LoadPaths(SavedPathSets); } int i = 0; foreach (wShapeCollection S in Shapes) { SVGobject.SetShapeType(S, i); i += 1; } SavedPathSets = SVGobject.PathSet; if (SVGobject.FrameCount > 0) { SVGobject.SetFrames(); } else { SVGobject.SetGroups(); } SVGobject.Build(); DA.SetData(0, SVGobject); }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param> protected override void SolveInstance(IGH_DataAccess DA) { string ID = this.Attributes.InstanceGuid.ToString(); string name = new GUIDtoAlpha(Convert.ToString(ID + Convert.ToString(this.RunCount)), false).Text; int C = this.RunCount; wObject WindObject = new wObject(); pElement Element = new pElement(); bool Active = Elements.ContainsKey(C); var pCtrl = new pDrawing(name); if (Elements.ContainsKey(C)) { Active = true; } //Check if control already exists if (Active) { if (Elements[C] != null) { WindObject = Elements[C]; Element = (pElement)WindObject.Element; pCtrl = (pDrawing)Element.ParrotControl; } } else { pCtrl.SetProperties(); Elements.Add(C, WindObject); } //Set Unique Control Properties List <IGH_Goo> Shps = new List <IGH_Goo>(); Rectangle3d B = new Rectangle3d(Plane.WorldXY, 0, 0); Interval Fx = new Interval(600, 600); bool D = true; if (!DA.GetDataList(0, Shps)) { return; } if (!DA.GetData(1, ref B)) { return; } if (!DA.GetData(2, ref Fx)) { return; } if (!DA.GetData(3, ref D)) { return; } List <wShapeCollection> Shapes = new List <wShapeCollection>(); Rectangle3d F = new Rectangle3d(Plane.WorldXY, Fx.T0, Fx.T1); wObject Wx = new wObject(); wShapeCollection Sx = new wShapeCollection(); Shps[0].CastTo(out Wx); Sx = (wShapeCollection)Wx.Element; BoundingBox Box = new BoundingBox(Sx.Boundary.CornerPoints[0].X, Sx.Boundary.CornerPoints[0].Y, 0, Sx.Boundary.CornerPoints[2].X, Sx.Boundary.CornerPoints[2].Y, 0); foreach (IGH_Goo Obj in Shps) { wObject W = new wObject(); wShapeCollection S = new wShapeCollection(); Obj.CastTo(out W); S = (wShapeCollection)W.Element; Shapes.Add(S); wPoint PtA = S.Boundary.CornerPoints[0]; wPoint PtB = S.Boundary.CornerPoints[2]; Box.Union(new Point3d(PtA.X, PtA.Y, PtA.Z)); Box.Union(new Point3d(PtB.X, PtB.Y, PtB.Z)); } if ((B.Width == 0.0) & (B.Height == 0.0)) { Plane pln = Plane.WorldXY; pln.Origin = Box.Center; B = new Rectangle3d(pln, new Interval(-Box.Diagonal.X / 2.0, Box.Diagonal.X / 2.0), new Interval(-Box.Diagonal.Y / 2.0, Box.Diagonal.Y / 2.0)); } wPlane PlnB = new wPlane( new wPoint(B.Center.X, B.Center.Y, B.Center.Z), new wVector(B.Plane.XAxis.X, B.Plane.XAxis.Y, B.Plane.XAxis.Z), new wVector(B.Plane.YAxis.X, B.Plane.YAxis.Y, B.Plane.YAxis.Z)); wPlane PlnF = new wPlane( new wPoint(F.Center.X, F.Center.Y, F.Center.Z), new wVector(F.Plane.XAxis.X, F.Plane.XAxis.Y, F.Plane.XAxis.Z), new wVector(F.Plane.YAxis.X, F.Plane.YAxis.Y, F.Plane.YAxis.Z)); pCtrl.SetCanvasSize(new wRectangle(PlnF, F.Width, F.Height), new wRectangle(PlnB, B.Width, B.Height)); pCtrl.Graphics.Width = F.Width; pCtrl.Graphics.Height = F.Height; pCtrl.group.X = B.Center.X * pCtrl.Scale - B.Width / 2.0 * pCtrl.Scale; pCtrl.group.Y = B.Center.Y * pCtrl.Scale - B.Height / 2.0 * pCtrl.Scale; pCtrl.group.Width = F.Width; pCtrl.group.Height = F.Height; pCtrl.SetSize(); pCtrl.SetScale(); if (D) { pCtrl.ClearDrawing(); } foreach (wShapeCollection S in Shapes) { switch (S.Type) { case "PolyCurveGroup": pCtrl.AddPolySpline(S); break; case "PolylineGroup": pCtrl.AddPolyFigure(S); break; default: pCtrl.AddShape(S); break; } } pCtrl.SetCanvas(); //Set Parrot Element and Wind Object properties if (!Active) { Element = new pElement(pCtrl.Element, pCtrl, pCtrl.Type); } WindObject = new wObject(Element, "Parrot", Element.Type); WindObject.GUID = this.InstanceGuid; WindObject.Instance = C; Elements[this.RunCount] = WindObject; DA.SetData(0, WindObject); DA.SetData(1, pCtrl.group); DA.SetData(2, pCtrl.GetBitmap()); }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param> protected override void SolveInstance(IGH_DataAccess DA) { IGH_Goo Element = null; List <System.Drawing.Color> Colors = new List <System.Drawing.Color>(); List <double> Parameters = new List <double>(); double GradientAngle = 0; if (!DA.GetData(0, ref Element)) { return; } if (!DA.GetDataList(1, Colors)) { return; } if (!DA.GetDataList(2, Parameters)) { return; } if (!DA.GetData(3, ref GradientAngle)) { return; } wObject W = new wObject(); if (Element != null) { Element.CastTo(out W); } wGraphic G = W.Graphics; G.FillType = wGraphic.FillTypes.LinearGradient; G.CustomFills += 1; if (Parameters.Count < 1) { G.Gradient = new wGradient(Colors); } else { if (Parameters.Count < Colors.Count) { for (int i = Parameters.Count; i < Colors.Count; i++) { Parameters.Add(Parameters[Parameters.Count - 1]); } } G.Gradient = new wGradient(Colors, Parameters, GradientAngle, (wGradient.GradientSpace)GradientSpace); } G.WpfFill = new wFillGradient(G.Gradient, GradientType).GrdBrush; W.Graphics = G; if (Element != null) { switch (W.Type) { case "Parrot": pElement E = (pElement)W.Element; pControl C = (pControl)E.ParrotControl; C.SetFill(); C.Graphics = G; break; case "Pollen": switch (W.SubType) { case "DataPoint": DataPt tDataPt = (DataPt)W.Element; tDataPt.Graphics = G; tDataPt.Graphics.WpfFill = G.WpfFill; tDataPt.Graphics.WpfPattern = G.WpfPattern; W.Element = tDataPt; break; case "DataSet": DataSetCollection tDataSet = (DataSetCollection)W.Element; tDataSet.Graphics = G; tDataSet.Graphics.WpfFill = G.WpfFill; tDataSet.Graphics.WpfPattern = G.WpfPattern; W.Element = tDataSet; break; case "Chart": case "Table": pElement pE = (pElement)W.Element; pChart pC = pE.PollenControl; pC.Graphics = G; pC.Graphics.WpfFill = G.WpfFill; pC.Graphics.WpfPattern = G.WpfPattern; pC.SetGradientFill(); pE.PollenControl = pC; W.Element = pE; break; } break; case "Hoopoe": wShapeCollection Shapes = (wShapeCollection)W.Element; Shapes.Graphics.FillType = wGraphic.FillTypes.LinearGradient; wGradient GRD = new wGradient(); if (Parameters.Count < 1) { GRD = new wGradient(Colors, GradientAngle, (wGradient.GradientSpace)GradientSpace); } else { GRD = new wGradient(Colors, Parameters, GradientAngle, (wGradient.GradientSpace)GradientSpace); } Shapes.Graphics.Gradient = GRD; Shapes.Graphics.WpfFill = new wFillGradient(G.Gradient, GradientType).GrdBrush; W.Element = Shapes; break; } } DA.SetData(0, W); DA.SetData(1, G); }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param> protected override void SolveInstance(IGH_DataAccess DA) { IGH_Goo Element = null; int J = vJustify * 3 + hJustify; if (!DA.GetData(0, ref Element)) { return; } wObject W = new wObject(); if (Element != null) { Element.CastTo(out W); } wGraphic G = W.Graphics; GetFont.Font = new wFont(fName, fSize, new wColor(DrawColor), (wFontBase.Justification)J, IsBold, IsItalic, IsUnder, false).ToDrawingFont().FontObject; GetFont.Color = DrawColor; if (toggle) { GetFont.ShowDialog(); fName = GetFont.Font.Name; fSize = GetFont.Font.Size; IsBold = GetFont.Font.Bold; IsItalic = GetFont.Font.Italic; IsUnder = GetFont.Font.Underline; DrawColor = GetFont.Color; toggle = false; } wFont F = new wFont(fName, fSize, new wColor(DrawColor), (wFontBase.Justification)J, IsBold, IsItalic, IsUnder, false); G.FontObject = F; G.CustomFonts += 1; W.Graphics = G; switch (W.Type) { case "Parrot": pElement E = (pElement)W.Element; pControl C = (pControl)E.ParrotControl; C.Graphics = G; C.SetFont(); break; case "Pollen": switch (W.SubType) { case "DataPoint": DataPt tDataPt = (DataPt)W.Element; tDataPt.Graphics = G; W.Element = tDataPt; break; case "DataSet": DataSetCollection tDataSet = (DataSetCollection)W.Element; tDataSet.Graphics = G; tDataSet.TotalCustomTitles += 1; W.Element = tDataSet; break; case "Chart": case "Table": pElement pE = (pElement)W.Element; pChart pC = pE.PollenControl; pC.Graphics = G; pC.SetFont(); pE.PollenControl = pC; W.Element = pE; break; } break; case "Hoopoe": wShapeCollection Shapes = (wShapeCollection)W.Element; Shapes.Fonts = F; W.Element = Shapes; break; } DA.SetData(0, W); DA.SetData(1, G.FontObject); DA.SetData(2, G); }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param> protected override void SolveInstance(IGH_DataAccess DA) { IGH_Goo Element = null; double D = 5.0; double A = 315.0; double R = 2.0; System.Drawing.Color X = new System.Drawing.Color(); if (!DA.GetData(0, ref Element)) { return; } if (!DA.GetData(1, ref D)) { return; } if (!DA.GetData(2, ref A)) { return; } if (!DA.GetData(3, ref R)) { return; } if (!DA.GetData(4, ref X)) { return; } wColor C = new wColor(X); wObject W = new wObject(); if (Element != null) { Element.CastTo(out W); } switch (W.Type) { case "Parrot": pElement E = (pElement)W.Element; break; case "Pollen": switch (W.SubType) { } break; case "Hoopoe": wShapeCollection Shapes = (wShapeCollection)W.Element; Shapes.Effects.DropShadow = new wDropShadow(C, A, D, R, (255.0 / C.A)); Shapes.Effects.SetEffect(Shapes.Effects.DropShadow.ShapeEffect); Shapes.Effects.HasEffect = true; W.Element = Shapes; break; } DA.SetData(0, W); }
public void AddPolySpline(wShapeCollection Shapes) { Element.Children.Add(WpfCompoundSpline(Shapes)); }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param> protected override void SolveInstance(IGH_DataAccess DA) { // Declare variables IGH_Goo Element = null; IGH_Goo Z = null; int A = 6; int T = 4; int F = 1; double R = 0; // Access the input parameters if (!DA.GetData(0, ref Element)) { return; } if (!DA.GetData(1, ref Z)) { return; } if (!DA.GetData(2, ref A)) { return; } if (!DA.GetData(3, ref F)) { return; } if (!DA.GetData(4, ref T)) { return; } if (!DA.GetData(5, ref R)) { return; } wObject W = new wObject(); if (Element != null) { Element.CastTo(out W); } wGraphic G = W.Graphics; Bitmap B = null; if (Z != null) { Z.CastTo(out B); } G.FillType = wGraphic.FillTypes.Bitmap; G.FillBitmap = new wImage(B, (wImage.FillSpace)FillSpace, IsEmbedded, (wImage.AlignMode)A, (wImage.FitMode)F, R); G.WpfFill = new wFillBitmap(B, A, F, T, R, ScaleFactor).FillBrush; G.CustomFills += 1; W.Graphics = G; if (Element != null) { switch (W.Type) { case "Parrot": pElement E = (pElement)W.Element; pControl C = (pControl)E.ParrotControl; C.SetFill(); C.Graphics = G; break; case "Pollen": switch (W.SubType) { case "DataPoint": DataPt tDataPt = (DataPt)W.Element; tDataPt.Graphics = G; tDataPt.Graphics.WpfFill = G.WpfFill; tDataPt.Graphics.WpfPattern = G.WpfPattern; W.Element = tDataPt; break; case "DataSet": DataSetCollection tDataSet = (DataSetCollection)W.Element; tDataSet.Graphics = G; tDataSet.Graphics.WpfFill = G.WpfFill; tDataSet.Graphics.WpfPattern = G.WpfPattern; W.Element = tDataSet; break; } break; case "Hoopoe": wShapeCollection Shapes = (wShapeCollection)W.Element; Shapes.Graphics.FillType = wGraphic.FillTypes.Bitmap; Shapes.Graphics.WpfFill = G.WpfFill; Shapes.Graphics.FillBitmap = new wImage(B, (wImage.FillSpace)FillSpace, IsEmbedded, (wImage.AlignMode)A, (wImage.FitMode)F, R); W.Element = Shapes; break; } } DA.SetData(0, W); DA.SetData(1, G); }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param> protected override void SolveInstance(IGH_DataAccess DA) { IGH_Goo Element = null; IGH_Goo Shps = null; double Scale = 1.0; if (!DA.GetData(0, ref Element)) { return; } if (!DA.GetData(1, ref Shps)) { return; } if (!DA.GetData(2, ref Scale)) { return; } wObject W = new wObject(); if (Element != null) { Element.CastTo(out W); } wGraphic G = W.Graphics; wShapeCollection S = new wShapeCollection(); if (Shps != null) { Shps.CastTo(out S); } wFillSwatch Swatch = new wFillSwatch(S, Scale, TilingMode, S.X, S.Y, S.Width, S.Height); G.FillType = wGraphic.FillTypes.Pattern; G.WpfPattern = Swatch.DwgBrush; G.WpfFill = Swatch.DwgBrush; G.CustomFills += 1; W.Graphics = G; switch (W.Type) { case "Parrot": pElement E = (pElement)W.Element; pControl C = (pControl)E.ParrotControl; C.Graphics = G; C.SetFill(); break; case "Pollen": switch (W.SubType) { case "DataPoint": DataPt tDataPt = (DataPt)W.Element; tDataPt.Graphics = G; tDataPt.Graphics.WpfFill = G.WpfFill; tDataPt.Graphics.WpfPattern = G.WpfPattern; W.Element = tDataPt; break; case "DataSet": DataSetCollection tDataSet = (DataSetCollection)W.Element; tDataSet.Graphics = G; tDataSet.Graphics.WpfFill = G.WpfFill; tDataSet.Graphics.WpfPattern = G.WpfPattern; W.Element = tDataSet; break; case "Chart": case "Table": pElement pE = (pElement)W.Element; pChart pC = pE.PollenControl; pC.Graphics = G; pC.Graphics.WpfFill = G.WpfFill; pC.Graphics.WpfPattern = G.WpfPattern; pC.SetPatternFill(); pE.PollenControl = pC; W.Element = pE; break; } break; case "Hoopoe": wShapeCollection Shapes = (wShapeCollection)W.Element; Shapes.Graphics.FillType = wGraphic.FillTypes.Pattern; Shapes.Graphics.WpfFill = G.WpfFill; Shapes.Graphics.WpfPattern = G.WpfPattern; W.Element = Shapes; break; } DA.SetData(0, W); DA.SetData(1, G); }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param> protected override void SolveInstance(IGH_DataAccess DA) { IGH_Goo Element = null; System.Drawing.Color Background = wColors.VeryLightGray.ToDrawingColor(); if (!DA.GetData(0, ref Element)) { return; } if (!DA.GetData(1, ref Background)) { return; } wObject W = new wObject(); if (Element != null) { Element.CastTo(out W); } wGraphic G = W.Graphics; G.FillType = wGraphic.FillTypes.Solid; G.Background = new wColor(Background); G.Foreground = new wColor(Background); G.WpfFill = new wFillSolid(G.Background).FillBrush; G.CustomFills += 1; W.Graphics = G; switch (W.Type) { case "Parrot": pElement E = (pElement)W.Element; pControl C = (pControl)E.ParrotControl; C.Graphics = G; C.SetFill(); break; case "Pollen": switch (W.SubType) { case "DataPoint": DataPt tDataPt = (DataPt)W.Element; tDataPt.Graphics = G; tDataPt.Graphics.WpfFill = G.WpfFill; tDataPt.Graphics.WpfPattern = G.WpfPattern; W.Element = tDataPt; break; case "DataSet": DataSetCollection tDataSet = (DataSetCollection)W.Element; tDataSet.Graphics = G; tDataSet.Graphics.WpfFill = G.WpfFill; tDataSet.Graphics.WpfPattern = G.WpfPattern; W.Element = tDataSet; break; case "Chart": case "Table": pElement pE = (pElement)W.Element; pChart pC = pE.PollenControl; pC.Graphics = G; pC.SetSolidFill(); pE.PollenControl = pC; W.Element = pE; break; } break; case "Hoopoe": wShapeCollection Shapes = (wShapeCollection)W.Element; Shapes.Graphics.FillType = wGraphic.FillTypes.Solid; Shapes.Graphics.WpfFill = G.WpfFill; Shapes.Graphics.Background = new wColor(Background); Shapes.Graphics.Foreground = new wColor(Background); W.Element = Shapes; break; } DA.SetData(0, W); DA.SetData(1, G); }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param> protected override void SolveInstance(IGH_DataAccess DA) { IGH_Goo Element = null; int FrameIndex = 0; double FrameDuration = 0.333; if (!DA.GetData(0, ref Element)) { return; } if (!DA.GetData(1, ref FrameIndex)) { return; } if (!DA.GetData(2, ref FrameDuration)) { return; } wObject W = new wObject(); if (Element != null) { Element.CastTo(out W); } wGraphic G = W.Graphics; string LayerName = FrameIndex.ToString(); G.Layer = LayerName; W.Graphics = G; switch (W.Type) { case "Parrot": pElement E = (pElement)W.Element; pControl C = (pControl)E.ParrotControl; C.Graphics = G; break; case "Pollen": switch (W.SubType) { } break; case "Hoopoe": wShapeCollection Shapes = (wShapeCollection)W.Element; Shapes.Group = LayerName; Shapes.Graphics.Layer = LayerName; Shapes.Frame = new wFrames(FrameIndex, FrameDuration, CompositeMode); W.Element = Shapes; break; } DA.SetData(0, W); DA.SetData(1, G); }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param> protected override void SolveInstance(IGH_DataAccess DA) { IGH_Goo Element = null; int Pattern = 0; double Scale = 1; System.Drawing.Color Background = wColors.VeryLightGray.ToDrawingColor(); System.Drawing.Color ForeGround = wColors.LightGray.ToDrawingColor(); if (!DA.GetData(0, ref Element)) { return; } if (!DA.GetData(1, ref Pattern)) { return; } if (!DA.GetData(2, ref Scale)) { return; } if (!DA.GetData(3, ref ForeGround)) { return; } if (!DA.GetData(4, ref Background)) { return; } wObject W = new wObject(); if (Element != null) { Element.CastTo(out W); } wGraphic G = W.Graphics; G.FillType = wGraphic.FillTypes.Pattern; G.CustomFills += 1; G.Background = new wColor(Background); G.Foreground = new wColor(ForeGround); G.StrokeColor = new wColor(ForeGround); G.SetUniformStrokeWeight(PatternWeight); wShapeCollection S = new wShapeCollection(); S.Graphics = G; wPattern P = new wPattern(0, 0, 9, 9, S); if ((PatternModeStatus < 5) && (PatternModeStatus != 0)) { P.SetStroke(Pattern); } else { P.SetStroke(0); } S = P.SetPattern(PatternModeStatus, Pattern, SpacingMode); G = S.Graphics; wFillSwatch Swatch = new wFillSwatch(S, Scale, 4, S.X, S.Y, S.Width, S.Height); G.WpfPattern = Swatch.DwgBrush; G.WpfFill = Swatch.DwgBrush; W.Graphics = G; switch (W.Type) { case "Parrot": pElement E = (pElement)W.Element; pControl C = (pControl)E.ParrotControl; C.Graphics = G; C.SetFill(); break; case "Pollen": switch (W.SubType) { case "DataPoint": DataPt tDataPt = (DataPt)W.Element; tDataPt.Graphics = G; tDataPt.Graphics.WpfFill = G.WpfFill; tDataPt.Graphics.WpfPattern = G.WpfPattern; W.Element = tDataPt; break; case "DataSet": DataSetCollection tDataSet = (DataSetCollection)W.Element; tDataSet.Graphics = G; tDataSet.Graphics.WpfFill = G.WpfFill; tDataSet.Graphics.WpfPattern = G.WpfPattern; W.Element = tDataSet; break; case "Chart": case "Table": pElement pE = (pElement)W.Element; pChart pC = pE.PollenControl; pC.Graphics = G; pC.Graphics.WpfFill = G.WpfFill; pC.Graphics.WpfPattern = G.WpfPattern; pC.SetPatternFill(); pE.PollenControl = pC; W.Element = pE; break; } break; case "Hoopoe": wShapeCollection Shapes = (wShapeCollection)W.Element; Shapes.Graphics.FillType = wGraphic.FillTypes.Pattern; Shapes.Graphics.WpfFill = G.WpfFill; Shapes.Graphics.WpfPattern = G.WpfPattern; W.Element = Shapes; break; } DA.SetData(0, W); DA.SetData(1, G); }