/// <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 int M = 0; IGH_Goo X = null; IGH_Goo Y = null; int P = 50; // Access the input parameters if (!DA.GetData(0, ref M)) { return; } if (!DA.GetData(1, ref X)) { return; } if (!DA.GetData(2, ref Y)) { return; } if (!DA.GetData(3, ref P)) { return; } Bitmap A = null; Bitmap B = null; if (X != null) { X.CastTo(out A); } if (Y != null) { Y.CastTo(out B); } Bitmap C = new Bitmap(A); if ((A.Width != B.Width) || (A.Height != B.Height)) { mMatchBitmaps BitmapPair = new mMatchBitmaps(A, B, MatchType, MatchSizing); A = new Bitmap(BitmapPair.BottomImage); B = new Bitmap(BitmapPair.TopImage); } switch (M) { case 0: C = new mDifferenceThreshold(A, B, P).ModifiedBitmap; break; case 1: C = new mDifferenceEuclidean(A, B, P).ModifiedBitmap; break; } DA.SetData(0, C); }
/// <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 Z = null; Color C = Color.Black; Interval Rc = new Interval(0, 255); Interval Gc = new Interval(100, 255); Interval Bc = new Interval(100, 255); // Access the input parameters if (!DA.GetData(0, ref Z)) { return; } if (!DA.GetData(1, ref C)) { return; } if (!DA.GetData(2, ref Rc)) { return; } if (!DA.GetData(3, ref Gc)) { return; } if (!DA.GetData(4, ref Bc)) { return; } Bitmap A = new Bitmap(10, 10); if (Z != null) { Z.CastTo(out A); } mFilter Filter = new mFilter(); switch (ModeIndex) { case 0: Filter = new mFilterARGBChannel(new wDomain(Rc.T0, Rc.T1), new wDomain(Gc.T0, Gc.T1), new wDomain(Bc.T0, Bc.T1), ModeInOut); break; case 1: Filter = new mFilterARGBColor(new wDomain(Rc.T0, Rc.T1), new wDomain(Gc.T0, Gc.T1), new wDomain(Bc.T0, Bc.T1), ModeInOut, C); break; case 2: Filter = new mFilterHSL(new wDomain(Rc.T0, Rc.T1), new wDomain(Gc.T0, Gc.T1), new wDomain(Bc.T0, Bc.T1), ModeInOut, C); break; case 3: Filter = new mFilterYCbCrColor(new wDomain(Rc.T0, Rc.T1), new wDomain(Gc.T0, Gc.T1), new wDomain(Bc.T0, Bc.T1), ModeInOut, C); break; } Bitmap B = new mApply(A, Filter).ModifiedBitmap; wObject W = new wObject(Filter, "Macaw", Filter.Type); DA.SetData(0, B); DA.SetData(1, 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) { IGH_Goo Element = null; int X = 0; int Y = 0; int Z = 0; bool D = false; if (!DA.GetData(0, ref Element)) { return; } if (!DA.GetData(1, ref X)) { return; } if (!DA.GetData(2, ref Y)) { return; } if (!DA.GetData(3, ref Z)) { return; } wObject W; Element.CastTo(out W); D = !((X == 0) & (Y == 0) & (Z == 0)); p3D V = new p3D(X, Y, Z, D, (p3D.LightingMode)ModeLighting); switch (W.Type) { case "Pollen": switch (W.SubType) { case "DataSet": DataSetCollection tDataSet = (DataSetCollection)W.Element; tDataSet.SetThreeDView(D, V); W.Element = tDataSet; break; case "PointChart": pElement E = (pElement)W.Element; pChart C = (pChart)E.PollenControl; C.View = V; C.SetThreeDView(); E.PollenControl = C; W.Element = E; break; } 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) { IGH_Goo trailData = null; IGH_Goo colorData = null; bool texture = new bool(); object displayMode = null; VisualData visualData = new VisualData(); if (!DA.GetData(0, ref trailData) || trailData == null) { AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "No Trail Data Detected, please connect Trail Data to enable the component"); return; } DA.GetData(1, ref colorData); string dataType = trailData.GetType().Name.ToString(); if (trailData.ToString() == "Culebra_GH.Data_Structures.TrailData") { TrailData td; bool worked = trailData.CastTo(out td); if (worked) { visualData.trailData = td; } else { AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Could not convert trail data, ensure you have the correct inputs"); return; } } else { AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Please input Trail Data Output value for Trail Data not a " + dataType); return; } if (colorData != null) { string colorType = colorData.GetType().Name.ToString(); if (colorData.ToString() == "Culebra_GH.Data_Structures.ColorData") { ColorData cd; bool worked = colorData.CastTo(out cd); if (worked) { visualData.colorData = cd; } else { AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Could not convert color data, ensure you have the correct inputs"); return; } } else { AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Please input Trail Data Output value for Trail Data not a " + colorType); return; } } else { ColorData color = new ColorData(); color.colorDataType = "Base"; visualData.colorData = color; } if (!DA.GetData(2, ref texture)) { return; } if (texture) { AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "WARNING USING TEXTURE CAN MAKE THE SIMULATION VERY UNSTABLE AND MAY CRASH WITHOUT WARNING, I RECOMMEND USING THE GH BUILT IN CLOUD DISPLAY FOR THE CREEPERS OUTPUT"); } visualData.useTexture = texture; if (!DA.GetData(3, ref displayMode)) { return; } string type2 = displayMode.GetType().Name.ToString(); if (displayMode.GetType() != typeof(GH_Integer) && displayMode.GetType() != typeof(GH_Number)) { AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Please input a integer/float value for Display Mode not a " + type2); return; } else { if (displayMode.GetType() == typeof(GH_Integer)) { GH_Integer ghInt = (GH_Integer)displayMode; visualData.displayMode = ghInt.Value; } else { GH_Number ghNum = (GH_Number)displayMode; visualData.displayMode = Convert.ToInt32(ghNum.Value); } } IGH_VisualData igh_Viz = new IGH_VisualData(visualData); DA.SetData(0, igh_Viz); }
/// <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; bool P = false; double R0 = 5; if (!DA.GetData(0, ref Element)) { return; } if (!DA.GetData(1, ref P)) { return; } if (!DA.GetData(2, ref R0)) { return; } wObject W = new wObject(); if (Element != null) { Element.CastTo(out W); } wGraphic G = W.Graphics; G.PadRadius = P; G.Radius[0] = R0; G.Radius[1] = R0; G.Radius[2] = R0; G.Radius[3] = R0; W.Graphics = G; if (P) { W.Graphics.SetPaddingFromCorners(); } else { W.Graphics.SetUniformPadding(0); } switch (W.Type) { case "Parrot": pElement E = (pElement)W.Element; pControl C = (pControl)E.ParrotControl; C.Graphics = G; C.SetCorners(); break; case "Pollen": switch (W.SubType) { case "DataPoint": DataPt tDataPt = (DataPt)W.Element; tDataPt.Graphics.Radius = G.Radius; W.Element = tDataPt; break; case "DataSet": DataSetCollection tDataSet = (DataSetCollection)W.Element; tDataSet.Graphics.Radius = G.Radius; W.Element = tDataSet; break; } break; case "Hoopoe": 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) { 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 pControl = new pRadialChart(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; pControl = (pRadialChart)Element.PollenControl; } } else { Elements.Add(C, WindObject); } //Set Unique Control Properties IGH_Goo D = null; double R = 0; if (!DA.GetData(0, ref D)) { return; } if (!DA.GetData(1, ref R)) { return; } wObject W = new wObject(); D.CastTo(out W); DataSetCollection DC = (DataSetCollection)W.Element; if (DC.TotalCustomFill == 0) { DC.SetDefaultPallet(Wind.Presets.wGradients.Metro, false, false); } if (DC.TotalCustomStroke == 0) { DC.SetDefaultStrokes(wStrokes.StrokeTypes.OffWhiteSolid); } if (DC.TotalCustomFont == 0) { DC.SetDefaultFonts(wFonts.ChartPoint); } if (DC.TotalCustomMarker == 0) { DC.SetDefaultMarkers(wGradients.Metro, wMarker.MarkerType.Circle, false, DC.Sets.Count > 1); } if (DC.TotalCustomLabel == 0) { DC.SetDefaultLabels(new wLabel(wLabel.LabelPosition.Center, wLabel.LabelAlignment.Center, new wGraphic(wColors.Transparent))); } if (DC.TotalCustomTitles == 0) { DC.Graphics.FontObject = wFonts.AxisLabel; } List <pRadialSeries> RadialSeriesList = new List <pRadialSeries>(); pControl.SetProperties(DC, R); pControl.SetPollenSeries(name); pControl.ForceRefresh(); /* * for (int i = 0; i < DC.Sets.Count; i++) * { * pRadialSeries pSeriesSet = new pRadialSeries(Convert.ToString(name + i)); * pSeriesSet.SetRadialSeries(DC.Sets[i]); * RadialSeriesList.Add(pSeriesSet); * } */ //pControl.SetSeries(RadialSeriesList); //pControl.SetAxisAppearance(); //Set Parrot Element and Wind Object properties if (!Active) { Element = new pElement(pControl.Element, pControl, pControl.Type); } WindObject = new wObject(Element, "Pollen", Element.Type); WindObject.GUID = this.InstanceGuid; WindObject.Instance = C; Elements[this.RunCount] = WindObject; 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) { // Declare variables IGH_Goo X = null; int M = 0; List <Vector3d> V = new List <Vector3d>(); // Access the input parameters if (!DA.GetData(0, ref X)) { return; } if (!DA.GetData(1, ref M)) { return; } if (!DA.GetDataList(2, V)) { return; } Bitmap A = new Bitmap(10, 10); if (X != null) { X.CastTo(out A); } if (M != ModeIndex) { ModeIndex = M; UpdateMessage(); } mGetChannel C = null; List <double> i = new List <double>(); List <double> j = new List <double>(); for (int k = 0; k < V.Count; k++) { i.Add(V[k].X); j.Add(1.0 - V[k].Y); } switch (M) { default: C = new mGetRGBColor(A, i, j); break; case 1: C = new mGetAlpha(A, i, j, unitize); break; case 2: C = new mGetRed(A, i, j, unitize); break; case 3: C = new mGetGreen(A, i, j, unitize); break; case 4: C = new mGetBlue(A, i, j, unitize); break; case 5: C = new mGetHue(A, i, j, unitize); break; case 6: C = new mGetSaturation(A, i, j); break; case 7: C = new mGetBrightness(A, i, j); break; } if (M == 0) { DA.SetDataList(0, C.Colors); } else { DA.SetDataList(0, C.Values); } }
/// <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) { this.UpdateMessage(); // Declare variables IGH_Goo V = null; double T = 0.90; double X = 1.00; int S = 2; // Access the input parameters if (!DA.GetData(0, ref V)) { return; } if (!DA.GetData(1, ref T)) { return; } if (!DA.GetData(2, ref X)) { return; } if (!DA.GetData(3, ref S)) { return; } Bitmap A = null; if (V != null) { V.CastTo(out A); } Bitmap B = new Bitmap(A); List <List <wPoint[]> > PointArr = new List <List <wPoint[]> >(); PointArr.Clear(); mAnalyzePotrace Scorner = new mAnalyzePotrace(A, T, X, 0.2, S, OptimizeCurve, FilterMode); PointArr = Scorner.VectorizedPointArray; List <Polyline> CL = new List <Polyline>(); foreach (var ptArrList in PointArr) { List <Point3d> Points = new List <Point3d>(); PointCloud PtCld = new PointCloud(); foreach (var ptArr in ptArrList) { Points.Add(new Point3d(ptArr[0].X, ptArr[0].Y, 0)); } Points.Add(new Point3d(ptArrList[ptArrList.Count - 1][1].X, ptArrList[ptArrList.Count - 1][1].Y, 0)); Polyline Pline = new Polyline(Points.ToArray()); if (!Pline.IsClosed) { Pline.Add(new Point3d(ptArrList[0][0].X, ptArrList[0][0].Y, 0)); } CL.Add(Pline); } DA.SetData(0, B); DA.SetDataList(1, CL); }
/// <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 pMeshViewer(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 = (pMeshViewer)Element.ParrotControl; } } else { pCtrl.SetProperties(); Elements.Add(C, WindObject); } //Set Unique Control Properties List <IGH_Goo> X = new List <IGH_Goo>(); List <IGH_Goo> Y = new List <IGH_Goo>(); IGH_Goo U = null; if (Params.Input[1].VolatileDataCount < 1) { UpdateLightInput(1); } //if (Params.Input[2].VolatileDataCount < 1) { UpdateCameraInput(2); } if (!DA.GetDataList(0, X)) { return; } if (!DA.GetDataList(1, Y)) { return; } if (!DA.GetData(2, ref U)) { return; } wCamera V = new wCamera(); U.CastTo(out V); List <wMesh> Meshes = new List <wMesh>(); foreach (IGH_Goo Obj in X) { wMesh M = new wMesh(); Obj.CastTo(out M); Meshes.Add(M); } pCtrl.SetMeshes(Meshes); List <wLight> Lights = new List <wLight>(); foreach (IGH_Goo Obj in Y) { wLight L = new wLight(); Obj.CastTo(out L); Lights.Add(L); } pCtrl.SetLights(Lights); pCtrl.BuildScene(); pCtrl.SetCamera(V); pCtrl.SetNavigation(HasNavigation); pCtrl.SetGizmo(HasGizmo); pCtrl.SetCoordinateSystem(HasCoordinates); //if (V.IsPreset) { pCtrl.ZoomExtents(1.0); } if (ZoomExtents) { pCtrl.ZoomExtents(1.0); ZoomExtents = false; } //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); }
/// <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); }
/// <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; 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) { 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) { // Declare variables IGH_Goo Z = null; Interval Ra = new Interval(0, 255); Interval Ga = new Interval(0, 255); Interval Ba = new Interval(0, 255); Interval Xa = new Interval(0, 255); Interval Rb = new Interval(0, 255); Interval Gb = new Interval(0, 255); Interval Bb = new Interval(0, 255); Interval Xb = new Interval(0, 255); // Access the input parameters if (!DA.GetData(0, ref Z)) { return; } if (!DA.GetData(1, ref Ra)) { return; } if (!DA.GetData(2, ref Rb)) { return; } Bitmap A = new Bitmap(10, 10); if (Z != null) { Z.CastTo(out A); } mFilter Filter = new mFilter(); switch (ModeIndex) { case 0: if (TypeIndex == 0) { Filter = new mAdjustLevels(new wDomain(Ra.T0, Ra.T1), new wDomain(Rb.T0, Rb.T1), new wDomain(Ra.T0, Ra.T1), new wDomain(Rb.T0, Rb.T1), new wDomain(Ra.T0, Ra.T1), new wDomain(Rb.T0, Rb.T1)); } else { Filter = new mAdjustLevels16bpp(new wDomain(Ra.T0, Ra.T1), new wDomain(Rb.T0, Rb.T1), new wDomain(Ra.T0, Ra.T1), new wDomain(Rb.T0, Rb.T1), new wDomain(Ra.T0, Ra.T1), new wDomain(Rb.T0, Rb.T1)); } break; case 1: if (TypeIndex == 0) { Filter = new mAdjustLevels(new wDomain(Ra.T0, Ra.T1), new wDomain(Rb.T0, Rb.T1)); } else { Filter = new mAdjustLevels16bpp(new wDomain(Ra.T0, Ra.T1), new wDomain(Rb.T0, Rb.T1)); } break; case 2: if (!DA.GetData(3, ref Ga)) { return; } if (!DA.GetData(4, ref Gb)) { return; } if (!DA.GetData(5, ref Ba)) { return; } if (!DA.GetData(6, ref Bb)) { return; } if (TypeIndex == 0) { Filter = new mAdjustLevels(new wDomain(Ra.T0, Ra.T1), new wDomain(Rb.T0, Rb.T1), new wDomain(Ga.T0, Ga.T1), new wDomain(Gb.T0, Gb.T1), new wDomain(Ba.T0, Ba.T1), new wDomain(Bb.T0, Bb.T1)); } else { Filter = new mAdjustLevels16bpp(new wDomain(Ra.T0, Ra.T1), new wDomain(Rb.T0, Rb.T1), new wDomain(Ga.T0, Ga.T1), new wDomain(Gb.T0, Gb.T1), new wDomain(Ba.T0, Ba.T1), new wDomain(Bb.T0, Bb.T1)); } break; case 3: if (!DA.GetData(3, ref Ga)) { return; } if (!DA.GetData(4, ref Gb)) { return; } if (!DA.GetData(5, ref Ba)) { return; } if (!DA.GetData(6, ref Bb)) { return; } if (!DA.GetData(7, ref Xa)) { return; } if (!DA.GetData(8, ref Xb)) { return; } if (TypeIndex == 0) { Filter = new mAdjustLevels(new wDomain(Ra.T0, Ra.T1), new wDomain(Rb.T0, Rb.T1), new wDomain(Ga.T0, Ga.T1), new wDomain(Gb.T0, Gb.T1), new wDomain(Ba.T0, Ba.T1), new wDomain(Bb.T0, Bb.T1), new wDomain(Xa.T0, Xa.T1), new wDomain(Xb.T0, Xb.T1)); } else { Filter = new mAdjustLevels16bpp(new wDomain(Ra.T0, Ra.T1), new wDomain(Rb.T0, Rb.T1), new wDomain(Ga.T0, Ga.T1), new wDomain(Gb.T0, Gb.T1), new wDomain(Ba.T0, Ba.T1), new wDomain(Bb.T0, Bb.T1), new wDomain(Xa.T0, Xa.T1), new wDomain(Xb.T0, Xb.T1)); } break; } Bitmap B = new mApply(A, Filter).ModifiedBitmap; wObject W = new wObject(Filter, "Macaw", Filter.Type); DA.SetData(0, B); DA.SetData(1, 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) { 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 pControl = new pCartesianChart(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; pControl = (pCartesianChart)Element.PollenControl; } } else { Elements.Add(C, WindObject); } //Set Unique Control Properties IGH_Goo D = null; int M = 0; if (!DA.GetData(0, ref D)) { return; } if (!DA.GetData(1, ref M)) { return; } wObject W = new wObject(); D.CastTo(out W); DataSetCollection DC = (DataSetCollection)W.Element; if (DC.TotalCustomFill == 0) { DC.SetDefaultPallet(wGradients.Metro, false, DC.Sets.Count > 1); } if (DC.TotalCustomStroke == 0) { DC.SetDefaultStrokes(wStrokes.StrokeTypes.Transparent); } if (DC.TotalCustomFont == 0) { DC.SetDefaultFonts(wFonts.ChartPoint); } if (DC.TotalCustomMarker == 0) { DC.SetDefaultMarkers(wGradients.SolidTransparent, wMarker.MarkerType.None, false, DC.Sets.Count > 1); } if (DC.TotalCustomLabel == 0) { if ((M == 0) || (M == 3)) { DC.SetDefaultLabels(new wLabel(wLabel.LabelPosition.Center, wLabel.LabelAlignment.Center, new wGraphic(wColors.Transparent))); } else { DC.SetDefaultLabels(new wLabel(wLabel.LabelPosition.Top, wLabel.LabelAlignment.Perp, new wGraphic(wColors.Transparent))); } } List <pCartesianSeries> PointSeriesList = new List <pCartesianSeries>(); pControl.SetProperties(DC); switch (M) { case 0: pControl.SetAdjacentBarChart(); break; case 1: pControl.SetStackBarChart(false); break; case 2: pControl.SetStackBarChart(true); break; case 3: pControl.SetAdjacentColumnChart(); break; case 4: pControl.SetStackColumnChart(false); break; case 5: pControl.SetStackColumnChart(true); break; } pControl.ForceRefresh(); pControl.SetAxisAppearance(); //Set Parrot Element and Wind Object properties if (!Active) { Element = new pElement(pControl.Element, pControl, pControl.Type); } WindObject = new wObject(Element, "Pollen", Element.Type); WindObject.GUID = this.InstanceGuid; WindObject.Instance = C; Elements[this.RunCount] = WindObject; 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; 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) { // Declare variables int M = 0; IGH_Goo Z = null; double R = 0; double D = 1; int X = 600; int Y = 600; // Access the input parameters if (!DA.GetData(0, ref Z)) { return; } if (!DA.GetData(1, ref M)) { return; } if (!DA.GetData(2, ref R)) { return; } if (!DA.GetData(3, ref D)) { return; } if (!DA.GetData(4, ref X)) { return; } if (!DA.GetData(5, ref Y)) { return; } Bitmap A = new Bitmap(10, 10); if (Z != null) { Z.CastTo(out A); } mFilter Filter = new mFilter(); if (M != ModeIndex) { ModeIndex = M; UpdateMessage(); } switch (M) { case 0: Filter = new mPolarToPolar(R, D, X, Y); break; case 1: Filter = new mPolarToRect(R, D, X, Y); break; } Bitmap B = new mApply(A, Filter).ModifiedBitmap; wObject W = new wObject(Filter, "Macaw", Filter.Type); DA.SetData(0, B); DA.SetData(1, 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) { 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 pControl = new pPointChart(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; pControl = (pPointChart)Element.PollenControl; } } else { Elements.Add(C, WindObject); } //Set Unique Control Properties IGH_Goo D = null; int M = 0; if (!DA.GetData(0, ref D)) { return; } if (!DA.GetData(1, ref M)) { return; } wObject W = new wObject(); D.CastTo(out W); DataSetCollection DC = (DataSetCollection)W.Element; if (DC.TotalCustomFill == 0) { DC.SetDefaultPallet(wGradients.Metro, false, DC.Sets.Count > 1); } if (DC.TotalCustomStroke == 0) { if (M == 1) { DC.SetDefaultStrokes(wStrokes.StrokeTypes.Transparent); } else { DC.SetDefaultStrokes(wStrokes.StrokeTypes.LineChart, wGradients.Metro, false, true); } } if (DC.TotalCustomMarker == 0) { if (M == 0) { DC.SetDefaultMarkers(wGradients.Metro, wMarker.MarkerType.Circle, false, DC.Sets.Count > 1); } else { DC.SetDefaultMarkers(wGradients.SolidTransparent, wMarker.MarkerType.None, false, DC.Sets.Count > 1); } } if (DC.TotalCustomFont == 0) { DC.SetDefaultFonts(wFonts.ChartPointDark); } if (DC.TotalCustomLabel == 0) { DC.SetDefaultLabels(new wLabel(wLabel.LabelPosition.Center, wLabel.LabelAlignment.None, new wGraphic(wColors.Transparent))); } if (DC.TotalCustomTitles == 0) { DC.Graphics.FontObject = wFonts.AxisLabel; } List <pPointSeries> PointSeriesList = new List <pPointSeries>(); int T = 0; double X = DC.Sets.Count; double Y = 99.0 / X; if (!DC.Axes.Enabled) { DC.Axes.AxisX.Enabled = true; DC.Axes.AxisX.HasLabel = false; DC.Axes.AxisY.Enabled = true; DC.Axes.AxisY.HasLabel = false; } pControl.SetProperties(DC); for (int i = 0; i < DC.Sets.Count; i++) { pPointSeries pSeriesSet = new pPointSeries(DC.Sets[i].Title); pSeriesSet.SetProperties(DC.Sets[i]); pSeriesSet.SetRadialChartType(M); pSeriesSet.SetChartLabels(DC.Label); pSeriesSet.SetNumericData(4); PointSeriesList.Add(pSeriesSet); } pControl.SetSeries(PointSeriesList); pControl.SetAxisScale(); pControl.SetAxisAppearance(); if (M == 0) { pControl.SetXaxis(new wDomain(0, PointSeriesList[0].DataList.Count - 1)); } //Set Parrot Element and Wind Object properties if (!Active) { Element = new pElement(pControl.Element, pControl, pControl.Type); } WindObject = new wObject(Element, "Pollen", Element.Type); WindObject.GUID = this.InstanceGuid; WindObject.Instance = C; Elements[this.RunCount] = WindObject; 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; double T0 = 1; if (!DA.GetData(0, ref Element)) { return; } if (!DA.GetData(1, ref T0)) { return; } wObject W = new wObject(); if (Element != null) { Element.CastTo(out W); } wGraphic G = W.Graphics; G.Margin[0] = T0; G.Margin[1] = T0; G.Margin[2] = T0; G.Margin[3] = T0; W.Graphics = G; switch (W.Type) { case "Parrot": pElement E = (pElement)W.Element; pControl C = (pControl)E.ParrotControl; C.Graphics = G; C.SetMargin(); 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.SetMargin(); pE.PollenControl = pC; W.Element = pE; break; } break; case "Hoopoe": 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) { // Declare variables IGH_Goo X = null; List <int> M = new List <int>(); List <double> V = new List <double>(); List <Color> C = new List <Color>(); // Access the input parameters if (!DA.GetData(0, ref X)) { return; } if (!DA.GetDataList(1, M)) { return; } if (!DA.GetDataList(2, V)) { return; } if (!DA.GetDataList(3, C)) { return; } int total = M.Count; if (V.Count > total) { total = V.Count; } if (C.Count > total) { total = C.Count; } int i = 0; int j = M.Count; for (i = j; i < total; i++) { M.Add(M[j - 1]); } j = V.Count; for (i = j; i < total; i++) { V.Add(V[j - 1]); } j = C.Count; for (i = j; i < total; i++) { C.Add(C[j - 1]); } wObject Z = new wObject(); if (X != null) { X.CastTo(out Z); } mLayer L = new mLayer((mLayer)Z.Element); List <mModifier> modifiers = new List <mModifier>(); foreach (mModifier mm in L.Modifiers) { modifiers.Add(mm); } int[] Ma = M.ToArray(); string tID = String.Join("~", Ma); if (tID != ID) { Array.Sort(Ma); Array.Reverse(Ma); int Mi = Ma[0]; ModeIndex = Ma; UpdateMessage(); if (Mi < 4) { Params.Input[2].NickName = "-"; } else { Params.Input[2].NickName = "V"; } if (Mi < 9) { Params.Input[3].NickName = "-"; } else { Params.Input[3].NickName = "C"; } if (Mi < 9) { Params.Input[3].Description = "Not used by this filter"; } else { Params.Input[3].Description = "Color"; } } //L.Modifiers.Clear(); for (i = 0; i < M.Count; i++) { mModifier modifier = null; switch (M[i]) { case 0: //Invert modifier = new mModifyInvert(); break; case 1: //Solarize modifier = new mModifySolarize(); break; case 2: //Grayscale modifier = new mModifyGrayscale(); break; case 3: //Vignette modifier = new mModifyVignette(); break; case 4: //Emboss modifier = new mModifyEmboss((float)V[i]); break; case 5: //Brightness modifier = new mModifyBrightness((int)V[i]); break; case 6: //Contrast modifier = new mModifyContrast((int)V[i]); break; case 7: //Feather modifier = new mModifyFeather((int)V[i]); break; case 8: //Gaussian modifier = new mModifyGaussian(1 + (int)V[i]); break; case 9: //Border modifier = new mModifyGaussian((int)V[i]); break; case 10: //Tint modifier = new mModifyColorTint(new Wind.Types.wColor(C[i].A, C[i].R, C[i].G, C[i].B), (int)V[i]); break; } modifiers.Add(modifier); } L.Modifiers = modifiers; wObject W = new wObject(L, "Macaw", L.Type); DA.SetData(0, W); DA.SetData(1, L.Modifiers.Count); }
/// <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 Z = null; int M = 0; double P = -1; // Access the input parameters if (!DA.GetData(0, ref Z)) { return; } if (!DA.GetData(1, ref M)) { return; } if (!DA.GetData(2, ref P)) { return; } if (M != ModeIndex) { ModeIndex = M; UpdateMessage(); if (M > 1) { SetParameter(2, "Threshold", "T", "" + V[M] + ""); } else { SetParameter(2, "Not Used", "-", "Not used by this filter"); } } Bitmap A = new Bitmap(10, 10); if (Z != null) { Z.CastTo(out A); } mFilter Filter = new mFilter(); switch (ModeIndex) { case 0: Filter = new mDitherBayer(); break; case 1: Filter = new mDitherOrdered(); break; case 2: if (P < 0) { P = 32; } Filter = new mDitherBurkes((byte)P); break; case 3: if (P < 0) { P = 16; } Filter = new mDitherFloydSteinberg((byte)P); break; case 4: if (P < 0) { P = 48; } Filter = new mDitherJarvisJudiceNinke((byte)P); break; case 5: if (P < 0) { P = 32; } Filter = new mDitherSierra((byte)P); break; case 6: if (P < 0) { P = 42; } Filter = new mDitherStucki((byte)P); break; case 7: if (P < 0) { P = 50; } Filter = new mDitherThresholdCarry((byte)P); break; } Bitmap B = new mApply(A, Filter).ModifiedBitmap; wObject W = new wObject(Filter, "Macaw", Filter.Type); DA.SetData(0, B); DA.SetData(1, 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) { IGH_Goo Element = null; int X = 0; int P = 0; double A = 0; bool L = true; System.Drawing.Color C = System.Drawing.Color.Transparent; System.Drawing.Color F = System.Drawing.Color.Transparent; double T = 0; if (!DA.GetData(0, ref Element)) { return; } if (!DA.GetData(1, ref X)) { return; } if (!DA.GetData(2, ref P)) { return; } if (!DA.GetData(3, ref A)) { return; } if (!DA.GetData(4, ref C)) { return; } if (!DA.GetData(5, ref F)) { return; } if (!DA.GetData(6, ref T)) { return; } wObject W; Element.CastTo(out W); wLabel CustomLabel = new wLabel(); wGraphic G = CustomLabel.Graphics; if (P == 0) { L = false; } CustomLabel.HasLeader = L; CustomLabel.Graphics = new wGraphic(new wColor(C), G.Foreground, new wColor(F), T); CustomLabel.Position = (wLabel.LabelPosition)P; CustomLabel.Alignment = (wLabel.LabelAlignment)X; CustomLabel.Graphics = G; switch (W.Type) { case "Pollen": switch (W.SubType) { case "DataPoint": DataPt Pt = (DataPt)W.Element; Pt.Graphics.FontObject.Angle = A; Pt.Label.HasLeader = L; Pt.Label.Graphics = new wGraphic(new wColor(C), G.Foreground, new wColor(F), T); Pt.Label.Position = (wLabel.LabelPosition)P; Pt.Label.Alignment = (wLabel.LabelAlignment)X; Pt.CustomLabels += 1; W.Element = Pt; break; case "DataSet": DataSetCollection St = (DataSetCollection)W.Element; St.SetUniformLabel(CustomLabel, A); St.Graphics.FontObject.Angle = A; St.Label.HasLeader = L; St.Label.Graphics = new wGraphic(new wColor(C), G.Foreground, new wColor(F), T); St.Label.Position = (wLabel.LabelPosition)P; St.Label.Alignment = (wLabel.LabelAlignment)X; W.Element = St; break; } break; } DA.SetData(0, W); DA.SetData(1, CustomLabel); }
/// <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 M = 0; int R = 10; System.Drawing.Color F = System.Drawing.Color.DarkGray; System.Drawing.Color S = System.Drawing.Color.Transparent; double T = 0; if (!DA.GetData(0, ref Element)) { return; } if (!DA.GetData(1, ref M)) { return; } if (!DA.GetData(2, ref R)) { return; } if (!DA.GetData(3, ref F)) { return; } if (!DA.GetData(4, ref S)) { return; } if (!DA.GetData(5, ref T)) { return; } wObject W; Element.CastTo(out W); wGraphic G = new wGraphic(); G.Background = new wColor(F); G.StrokeColor = new wColor(S); G.SetUniformStrokeWeight(T); wMarker CustomMarker = new wMarker((wMarker.MarkerType)M, (int)R, G); switch (W.Type) { case "Pollen": switch (W.SubType) { case "DataPoint": DataPt Pt = (DataPt)W.Element; Pt.SetMarker(CustomMarker); W.Element = Pt; break; case "DataSet": DataSetCollection St = (DataSetCollection)W.Element; St.SetUniformMarkers(CustomMarker); W.Element = St; break; } break; } DA.SetData(0, W); DA.SetData(1, CustomMarker); }
/// <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 Z = null; // Access the input parameters if (!DA.GetData(0, ref Z)) { return; } Bitmap A = new Bitmap(10, 10); if (Z != null) { Z.CastTo(out A); } mFilter Filter = new mFilter(); switch (ModeIndex) { case 0: //Blur Filter = new mBlur(); break; case 1: //Jitter int R3 = 10; if (!DA.GetData(1, ref R3)) { return; } Filter = new mEffectJitter(R3); break; case 2: //Daube int R4 = 10; if (!DA.GetData(1, ref R4)) { return; } Filter = new mEffectDaube(R4); break; case 3: //Kuwahara int R7 = 5; if (!DA.GetData(1, ref R7)) { return; } Filter = new mEffectKuwahara(R7); break; case 4: //Additive int R5 = 5; if (!DA.GetData(1, ref R5)) { return; } Filter = new mNoiseAdditive(new Wind.Types.wDomain(0, R5)); break; case 5: //Salt&Pepper int R6 = 5; if (!DA.GetData(1, ref R6)) { return; } Filter = new mNoiseSandP(R6); break; case 6: //Box Blur int H1 = 3; int V1 = 3; if (!DA.GetData(1, ref H1)) { return; } if (!DA.GetData(2, ref V1)) { return; } Filter = new mBlurBox((byte)H1, (byte)V1); break; case 7: //Gaussian Blur double S2 = 4.0; int K2 = 11; if (!DA.GetData(1, ref S2)) { return; } if (!DA.GetData(2, ref K2)) { return; } Filter = new mBlurGaussian(S2, K2); break; case 8: //Pixelate int H8 = 3; int W8 = 3; if (!DA.GetData(1, ref H8)) { return; } if (!DA.GetData(2, ref W8)) { return; } Filter = new mEffectPixelate(H8, W8); break; case 9: //Posterization int D9 = 5; int M9 = 0; if (!DA.GetData(1, ref D9)) { return; } if (!DA.GetData(2, ref M9)) { return; } Filter = new mEffectPosterization((byte)D9, M9); break; case 10: //Ripple int X10 = 10; int Y10 = 5; int H10 = 5; int W10 = 5; if (!DA.GetData(1, ref X10)) { return; } if (!DA.GetData(2, ref Y10)) { return; } if (!DA.GetData(3, ref H10)) { return; } if (!DA.GetData(4, ref W10)) { return; } Filter = new mEffectRipple(X10, Y10, H10, W10); break; } Bitmap B = new mApply(A, Filter).ModifiedBitmap; wObject W = new wObject(Filter, "Macaw", Filter.Type); DA.SetData(0, B); DA.SetData(1, 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) { 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 pDataGrid(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 = (pDataGrid)Element.PollenControl; } } else { Elements.Add(C, WindObject); } //Set Unique Control Properties IGH_Goo D = null; if (!DA.GetData(0, ref D)) { return; } wObject W = new wObject(); D.CastTo(out W); DataSetCollection DC = (DataSetCollection)W.Element; if (DC.TotalCustomFill == 0) { DC.SetDefaultPallet(wGradients.SolidLightGray, false, DC.Sets.Count > 1); } if (DC.TotalCustomFont == 0) { DC.SetDefaultFonts(wFonts.DataGrid); } if (DC.TotalCustomStroke == 0) { DC.SetDefaultStrokes(wStrokes.StrokeTypes.OffWhiteSolid); } if (DC.TotalCustomTitles == 0) { DC.Graphics.FontObject = wFonts.DataGridTitle; } pCtrl.SetProperties(DC, HasTitle); //Set Parrot Element and Wind Object properties if (!Active) { Element = new pElement(pCtrl.Element, pCtrl, pCtrl.Type); } WindObject = new wObject(Element, "Pollen", Element.Type); WindObject.GUID = this.InstanceGuid; WindObject.Instance = C; Elements[this.RunCount] = WindObject; 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; 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) { 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 pControl = new pGaugeChartSeries(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; pControl = (pGaugeChartSeries)Element.PollenControl; } } else { Elements.Add(C, WindObject); } //Set Unique Control Properties IGH_Goo D = null; int M = 0; bool B = true; int S = 100; if (!DA.GetData(0, ref D)) { return; } if (!DA.GetData(1, ref M)) { return; } if (!DA.GetData(2, ref B)) { return; } if (!DA.GetData(3, ref S)) { return; } wObject W = new wObject(); D.CastTo(out W); DataSetCollection DC = (DataSetCollection)W.Element; if (DC.TotalCustomFill == 0) { DC.SetDefaultPallet(wGradients.Metro, false, false); } if (DC.TotalCustomStroke == 0) { DC.SetDefaultStrokes(wStrokes.StrokeTypes.Transparent); } if (DC.TotalCustomFont == 0) { DC.SetDefaultFonts(wFonts.ChartGauge); } if (DC.TotalCustomMarker == 0) { DC.SetDefaultMarkers(wGradients.SolidTransparent, wMarker.MarkerType.None, false, false); } if (DC.TotalCustomLabel == 0) { DC.SetDefaultLabels(new wLabel(wLabel.LabelPosition.Center, wLabel.LabelAlignment.Center, new wGraphic(wColors.Transparent))); } pControl.SetProperties(DC, B, 0); pControl.SetCharts(S, M, modeStatus); if (DC.TotalCustomFont > 0) { pControl.SetFont(); } //Set Parrot Element and Wind Object properties if (!Active) { Element = new pElement(pControl.Element, pControl, pControl.Type); } WindObject = new wObject(Element, "Pollen", Element.Type); WindObject.GUID = this.InstanceGuid; WindObject.Instance = C; Elements[this.RunCount] = WindObject; DA.SetData(0, WindObject); }
protected void SolveInstanceHelper(IGH_DataAccess data, int startIndex) { if (!ActivateGlContext()) { return; } if (!_model.CompileProgram()) { foreach (var err in _model.AllCompileErrors()) { AddRuntimeMessage(GH_RuntimeMessageLevel.Error, err.ToString()); } } _model.ClearData(); for (int i = startIndex; i < Params.Input.Count; i++) { string varname = Params.Input[i].NickName; string datatype; if (_model.TryGetUniformType(varname, out datatype)) { IGH_Goo destination = null; if (Params.Input[i].Access == GH_ParamAccess.item) { data.GetData(i, ref destination); } else { List <IGH_Goo> list = new List <IGH_Goo>(); data.GetDataList(i, list); destination = list[0]; } switch (datatype) { case "int": { int value; if (!destination.CastTo(out value)) { double dvalue; if (destination.CastTo(out dvalue)) { value = (int)dvalue; } else { bool bvalue; if (destination.CastTo(out bvalue)) { value = bvalue ? 1 : 0; } } } _model.AddUniform(varname, value); break; } case "float": { double value; destination.CastTo(out value); if (!destination.CastTo(out value)) { int ival; if (destination.CastTo(out ival)) { value = ival; } } _model.AddUniform(varname, (float)value); break; } case "vec3": { Point3d point; if (destination.CastTo(out point)) { float x = (float)point.X; float y = (float)point.Y; float z = (float)point.Z; _model.AddUniform(varname, new Point3f(x, y, z)); } break; } case "vec4": { if (destination.TypeName == "Colour") { System.Drawing.Color color; if (destination.CastTo(out color)) { Vec4 v4 = new Vec4(color.R / 255.0f, color.G / 255.0f, color.B / 255.0f, color.A / 255.0f); _model.AddUniform(varname, v4); } } break; } case "bool": { bool value; if (!destination.CastTo(out value)) { int ivalue; if (destination.CastTo(out ivalue)) { value = ivalue != 0; } } _model.AddUniform(varname, value ? 1 : 0); break; } case "sampler2D": { //Try casting to a string first. This will be interpreted as a path to an image file string path; if (destination.CastTo(out path)) { _model.AddSampler2DUniform(varname, path); } break; } } continue; } int location; if (_model.TryGetAttributeType(varname, out datatype, out location)) { if (datatype == "int" || datatype == "float") { List <double> destination = new List <double>(); if (data.GetDataList(i, destination)) { int[] ints = datatype == "int" ? new int[destination.Count] : null; float[] floats = ints == null ? new float[destination.Count] : null; for (int index = 0; index < destination.Count; index++) { if (ints != null) { ints[index] = (int)destination[index]; } if (floats != null) { floats[index] = (float)destination[index]; } } if (ints != null && ints.Length > 0) { _model.AddAttribute(varname, location, ints); } if (floats != null && floats.Length > 0) { _model.AddAttribute(varname, location, floats); } } if (destination.Count < 1 && datatype == "int") { List <int> int_destination = new List <int>(); if (data.GetDataList(i, int_destination) && int_destination.Count > 0) { int[] ints = int_destination.ToArray(); if (ints != null && ints.Length > 0) { _model.AddAttribute(varname, location, ints); } } } } if (datatype == "vec3") { //vec3 -> point3d List <Point3d> destination = new List <Point3d>(); if (data.GetDataList(i, destination)) { Point3f[] vec3_array = new Point3f[destination.Count]; for (int index = 0; index < destination.Count; index++) { float x = (float)destination[index].X; float y = (float)destination[index].Y; float z = (float)destination[index].Z; vec3_array[index] = new Point3f(x, y, z); } _model.AddAttribute(varname, location, vec3_array); } } if (datatype == "vec4") { List <System.Drawing.Color> destination = new List <System.Drawing.Color>(); if (data.GetDataList(i, destination)) { Vec4[] vec4_array = new Vec4[destination.Count]; for (int index = 0; index < destination.Count; index++) { Color4f color = new Color4f(destination[index]); vec4_array[index] = new Vec4(color.R, color.G, color.B, color.A); } _model.AddAttribute(varname, location, vec4_array); } } } } }
/// <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 X = null; int L = 0; int H = 0; int S = 1; bool Z = false; // Access the input parameters if (!DA.GetData(0, ref X)) { return; } Bitmap A = new Bitmap(10, 10); if (X != null) { X.CastTo(out A); } mFilter Filter = new mFilter(); switch (ModeIndex) { case 0: Filter = new mEdgeDifference(); break; case 1: Filter = new mEdgeHomogenity(); break; case 2: if (!DA.GetData(1, ref Z)) { return; } Filter = new mEdgeSobel(Z); break; case 3: if (!DA.GetData(1, ref S)) { return; } if (!DA.GetData(2, ref L)) { return; } if (!DA.GetData(3, ref Z)) { return; } Filter = new mEdgeSimple(L, S, Z); break; case 4: if (!DA.GetData(1, ref S)) { return; } if (!DA.GetData(2, ref L)) { return; } if (!DA.GetData(3, ref H)) { return; } Filter = new mEdgeCanny(L, H, S); break; } Bitmap B = new mApply(A, Filter).ModifiedBitmap; wObject W = new wObject(Filter, "Macaw", Filter.Type); DA.SetData(0, B); DA.SetData(1, W); }