Ejemplo n.º 1
0
        /// <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);
        }
Ejemplo n.º 2
0
        /// <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);
        }
Ejemplo n.º 3
0
        /// <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);
        }
Ejemplo n.º 4
0
        //#########################################################################


        private void SetDefault()
        {
            Graphic.StrokeColor = wColors.Black;
            Graphic.SetUniformStrokeWeight(1);
        }