Example #1
0
        public void CheckReportCreation(bool showGraph, GraphElements graphElements, GraphSettings graphSettings, string path, string expected)
        {
            GraphEngine testObject = new GraphEngine(showGraph, graphElements, graphSettings, path);
            string      actual     = testObject.Create();

            Assert.Equal(expected, actual);
        }
Example #2
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            bool          showGraph     = false;
            GraphElements graphElements = null;
            GraphSettings graphSettings = null;
            string        path          = "";

            DA.GetData(0, ref showGraph);
            DA.GetData(1, ref graphElements);
            DA.GetData(2, ref graphSettings);
            DA.GetData(3, ref path);

            Graph graphObject = new Graph();

            graphObject.GraphData(showGraph, graphElements, graphSettings, path);
            if (showGraph)
            {
                graphObject.ShowDialog();
            }

            graphObject.Export();
            string reportPart = graphObject.Create();

            DA.SetData(0, reportPart);
        }
        public override void ExitGenericModel([NotNull] GenericModelContext context)
        {
            var list = new List <Models.IModelObject>();

            foreach (var item in context._smodels)
            {
                var sm = SingleModels.Get(item);
                list.Add(sm);
            }

            var TopLevelModel = new Models.SingleModel("@" + context.ID().GetText(), list)
            {
                Path = path.GetPath()
            };

            // check for doubles
            var existing = Collector.SingleModels.FirstOrDefault(p => p.Name == TopLevelModel.Name);

            if (existing != null)
            {
                existing.Value.AddRange(TopLevelModel.Value);
            }
            else
            {
                Collector.SingleModels.Add(TopLevelModel);
            }
            GraphElements.Add(TopLevelModel.Path, new GraphElement(TopLevelModel.Path, TopLevelModel));
            path.Pop();

            base.ExitGenericModel(context);
        }
        public override void ExitSinglemodel([NotNull] SinglemodelContext context)
        {
            var fullpath = path.GetPath();

            path.Pop();
            logger.Trace("Exit singlemodel {0}", fullpath);

            var obj = ObjProps.Get(context.obj());

            var model = new Models.SingleModel(context.ID().GetText(), obj);

            var orderby = ObjOrderByProps.Get(context.obj());

            model.Path = fullpath;
            model.OrderBy.AddRange(orderby);

            //model.Section = CurrentSection;
            if (context.inherits() != null)
            {
                model.Inherits     = true;
                model.InheritsFrom = context.inherits().ID().GetText();
            }
            string obs = "";

            logger.Trace("Single model = {0}{1}{2}",
                         model.Name,
                         context.inherits() != null ? " : " + model.InheritsFrom : "",
                         orderby.Any() ? " / " + orderby.Aggregate(obs, (f, run) => obs += run + ", ") : "");

            GraphElements.Add(model.Path, new GraphElement(model.Path, model));
            SingleModels.Put(context, model);
            base.ExitSinglemodel(context);
        }
        public void CorrectData(GraphData graphData, GraphLegend graphLegend, string toString)
        {
            GraphElements testObject = new GraphElements(graphData, graphLegend);

            Assert.Equal(graphData, testObject.Data);
            Assert.Equal(graphLegend, testObject.Legend);
            Assert.Equal(toString, testObject.ToString());
        }
Example #6
0
        public void CorrectData(bool showGraph, GraphElements graphElements, GraphSettings graphSettings, string path, string expected)
        {
            GraphEngine testObject = new GraphEngine(showGraph, graphElements, graphSettings, path);

            Assert.Equal(showGraph, testObject.ShowGraph);
            Assert.Equal(graphElements, testObject.Elements);
            Assert.Equal(graphSettings, testObject.Settings);
            Assert.Equal(path, testObject.Path);
        }
Example #7
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            GraphData   graphData   = null;
            GraphLegend graphLegend = null;

            DA.GetData(0, ref graphData);
            DA.GetData(1, ref graphLegend);

            GraphElements graphElements = new GraphElements(graphData, graphLegend);

            DA.SetData(0, graphElements);
        }
        public override void ExitIncludeStatement([NotNull] IncludeStatementContext context)
        {
            base.ExitIncludeStatement(context);

            var mp = new ModelParser();

            mp.ParseInputFile(context.GetText().Substring(1));

            foreach (var item in mp.ModelCollector.ParameterModels)
            {
                var exists = Collector.ParameterModels.FirstOrDefault(m => m.Name == item.Name);
                if (exists != null)
                {
                    exists.Value.AddRange(item.Value);
                }
                else
                {
                    Collector.ParameterModels.Add(item);
                }
            }
            foreach (var item in mp.ModelCollector.SingleModels)
            {
                var exists = Collector.SingleModels.FirstOrDefault(m => m.Name == item.Name);
                if (exists != null)
                {
                    exists.Value.AddRange(item.Value);
                }
                else
                {
                    Collector.SingleModels.Add(item);
                }
            }
            // get GraphElements from included
            foreach (var item in mp.GraphElements)
            {
                if (!GraphElements.ContainsKey(item.Key))
                {
                    GraphElements.Add(item.Key, item.Value);
                }
            }
        }
        public override void ExitPair([NotNull] PairContext context)
        {
            var fullpath = path.GetPath();

            path.Pop();
            logger.Trace("Exit pair {0}", fullpath);

            Models.IModelObject pair = null;
            if (context.pairvalue()?.value() != null)
            {
                pair = ValueProps.Get(context.pairvalue().value());
            }
            if (pair == null)
            {
                var value = new List <Models.IModelObject>();
                pair = new Models.ModelCompositeObject
                {
                    Value = value
                };
            }
            pair.Name = context.ID().GetText();

            pair.Path = fullpath;

            PairProps.Put(context, pair);
            if (context.pairvalue()?.inherits() != null)
            {
                pair.Inherits     = true;
                pair.InheritsFrom = context.pairvalue().inherits().ID().GetText();
            }
            if (context.modifier != null)
            {
                pair.Modified = true;
                pair.Modifier = context.modifier.Text;
            }
            GraphElements.Add(pair.Path, new GraphElement(pair.Path, pair));

            logger.Trace("Pair: {0}{1} = {2}{3}", pair.Modifier, pair.Name, pair.GetText() ?? "unknown", context.pairvalue()?.inherits() != null ? " : " + pair.InheritsFrom : "");

            base.ExitPair(context);
        }
Example #10
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            GraphElements graphElements = null;
            GraphSettings graphSettings = null;

            DA.GetData(0, ref graphElements);
            DA.GetData(1, ref graphSettings);

            Graph graphObject = new Graph();

            dialogImage = graphObject;
            PterodactylGrasshopperBitmapGoo GH_bmp = new PterodactylGrasshopperBitmapGoo();

            graphObject.GraphData(true, graphElements, graphSettings, GH_bmp.ReferenceTag);
            using (Bitmap b = graphObject.ExportBitmap())
            {
                GH_bmp.Value      = b.Clone(new Rectangle(0, 0, b.Width, b.Height), b.PixelFormat);
                GH_bmp.ReportPart = graphObject.Create();
                DA.SetData(0, GH_bmp);
            }
        }
Example #11
0
        public FlowStepElement(double x, double y, string label = null, string color = "Black", double stepSize = 10, float textSize = 12, string textFamily = "Consolas")
        {
            Step = new RectangleElement(x, y, x + stepSize, y + stepSize, new RectangleElementViewModel {
                Color = color
            });
            GraphElements.Add(Step);
            LeftConnectorIn = new Connector {
                Direction = ConnectorDirectionEnum.Right, Position = new Point(Step.Left - 10, Step.Top + stepSize / 2)
            };
            RightConnectorIn = new Connector {
                Direction = ConnectorDirectionEnum.Left, Position = new Point(Step.Right + 10, Step.Top + stepSize / 2)
            };
            TopConnectorIn = new Connector {
                Direction = ConnectorDirectionEnum.Down, Position = new Point(Step.Left + stepSize / 2, Step.Top - 10)
            };
            BottomConnectorIn = new Connector {
                Direction = ConnectorDirectionEnum.Up, Position = new Point(Step.Left + stepSize / 2, Step.Bottom + 10)
            };
            LeftConnectorOut = new Connector {
                Direction = ConnectorDirectionEnum.Left, Position = new Point(Step.Left - 10, Step.Top + stepSize / 2)
            };
            RightConnectorOut = new Connector {
                Direction = ConnectorDirectionEnum.Right, Position = new Point(Step.Right + 10, Step.Top + stepSize / 2)
            };
            TopConnectorOut = new Connector {
                Direction = ConnectorDirectionEnum.Up, Position = new Point(Step.Left + stepSize / 2, Step.Top - 10)
            };
            BottomConnectorOut = new Connector {
                Direction = ConnectorDirectionEnum.Down, Position = new Point(Step.Left + stepSize / 2, Step.Bottom + 10)
            };

            if (!string.IsNullOrEmpty(label))
            {
                Label = new TextElement(label, x, y, new TextElementViewModel {
                    TextSize = textSize, Color = color, TextFamily = textFamily
                });
                Label.Move(stepSize / 2, -Label.Height - 3);
                GraphElements.Add(Label);
            }
        }
 private void Connect(FlowStepElement elementSrc, FlowStepElement elementDest, ConnectionElement connection)
 {
     elementSrc.ConnectionsOut.Add(connection);
     elementDest.ConnectionsIn.Add(connection);
     GraphElements.Add(connection);
 }
 public FlowStepElement AddElement(FlowStepElement element)
 {
     GraphElements.Add(element);
     return(element);
 }