Пример #1
0
 /// <summary>
 /// Builder for zone selection operation
 /// </summary>
 /// <param name="diagramLayer">Layer of the Diagram of the GraphDrawing</param>
 /// <param name="tempLayer">Temporal layer of the GraphDrawing</param>
 /// <param name="initialPoint">Initial position where the operation was started</param>
 public SelectRectangle(GraphLayer diagramLayer, GraphLayer selectLayer, GraphLayer tempLayer, Point initMouseLocation)
 {
     this.diagramLayer        = diagramLayer;
     this.selectLayer         = selectLayer;
     this.selectLayer.Visible = true;
     this.tempLayer           = tempLayer;
     //Indicates that the temporary layer is visible but not updated (will be updated in the first MouseMove)
     this.tempLayer.Visible = true;
     this.initialPoint      = initMouseLocation;
     //The graphic selection rectangle is created and loaded to the temporary layer
     this.selectionRectangle = new SelectionRectangle();
     this.tempLayer.Add(this.selectionRectangle);
 }
Пример #2
0
        public Connect(Diagram diagram, GraphLayer diagramLayer, GraphLayer tempLayer)
        {
            this.diagram         = diagram;
            this.diagramLayer    = diagramLayer;
            this.tempLayer       = tempLayer;
            this.miPaste.Click  += new EventHandler(MiPaste_Click);
            this.miPaste.Enabled = !GraphManager.Clipboard.IsEmpty;
            this.miCancel.Click += new EventHandler(MiCancel_Click);
            this.menu            = new ContextMenu(new MenuItem[] { this.miPaste, this.miCancel });

            this.tempLayer.Visible = true;
            this.tempLayer.Add(this.tempGraphArrow);
        }
Пример #3
0
        private LayerListItem CreateItem(ref GraphLayer layer)
        {
//			string[] items = new string[6]{
//											  name,
//											  number.ToString(),
//											  visible.ToString(),
//											  locked.ToString(),
//											  usecolor.ToString(),
//											  opacity};
//			ListViewItem item = new ListViewItem(items);
            LayerListItem item = new LayerListItem(ref layer);

            return(item);
        }
Пример #4
0
 /// <summary>
 /// Builder for the Select operation
 /// </summary>
 /// <param name="diagramLayer">Diagram of the GraphDrawing layer</param>
 /// <param name="tempLayer">Temporal layer of the GraphDrawing</param>
 public Select(GraphLayer diagramLayer, GraphLayer selectLayer)
 {
     this.diagramLayer        = diagramLayer;
     this.selectLayer         = selectLayer;
     this.selectLayer.Visible = true;
     miSettings.Click        += new EventHandler(MiShowProperties_Click);
     miCopy.Click            += new EventHandler(MiCopy_Click);
     miCut.Click     += new EventHandler(MiCut_Click);
     miPaste.Enabled  = !GraphManager.Clipboard.IsEmpty;
     miPaste.Click   += new EventHandler(MiPaste_Click);
     miRemove.Click  += new EventHandler(MiRemove_Click);
     this.menu        = new ContextMenu(new MenuItem[] { miSettings, new MenuItem("-"), miCopy, miCut, miPaste, miRemove });
     this.menu.Popup += new EventHandler(Menu_Popup);
 }
Пример #5
0
 /// <summary>
 /// Builder for the operation do nothing "Nop"
 /// </summary>
 /// <param name="diagramLayer">Diagram of the GraphDrawing layer</param>
 /// <param name="tempLayer">Temporal layer of the GraphDrawing</param>
 public Nop(GraphLayer diagramLayer, GraphLayer tempLayer)
 {
     this.diagramLayer = diagramLayer;
     this.tempLayer    = tempLayer;
     try
     {
         this.miPaste.Enabled = !GraphManager.Clipboard.IsEmpty;
     }
     catch
     {
         this.miPaste.Enabled = false;
     }
     this.miPaste.Click += new EventHandler(MiPaste_Click);
     this.menu           = new ContextMenu(new MenuItem[] { miPaste });
 }
Пример #6
0
        /// <summary>
        /// Returns the first state found, which contains the mouse position
        /// </summary>
        /// <param name="graph"></param>
        /// <param name="layer"></param>
        /// <param name="mousePos"></param>
        /// <returns></returns>
        public static Node GetClickedNode(this Graph graph, GraphLayer layer, Vector2 mousePos)
        {
            IEnumerable <Node> reverse = graph.Nodes.Reverse <Node>();

            foreach (var node in reverse)
            {
                Rect transformedRect = layer.GetTransformedRect(node.Rect);

                if (transformedRect.Contains(mousePos))
                {
                    return(node);
                }
            }

            return(null);
        }
Пример #7
0
        /// <summary>
        /// Returns the collection of layers
        /// </summary>
        /// <returns></returns>
        public GraphLayerCollection GetLayers()
        {
            GraphLayer           layer;
            ListViewItem         item;
            GraphLayerCollection col = new GraphLayerCollection();

            for (int k = 0; k < listView.Items.Count; k++)
            {
                item  = listView.Items[k];
                layer = new GraphLayer();
                layer.SetNumber(k);
                layer.Name = item.SubItems[0].Text;
                col.Add(layer);
            }
            return(col);
        }
Пример #8
0
        public DragDrop(GraphLayer diagramLayer, GraphLayer selectLayer, GraphLayer tempLayer, Point initMouseLocation)
        {
            this.diagramLayer      = diagramLayer;
            this.selectLayer       = selectLayer; //The selection layer is already visible
            this.tempLayer         = tempLayer;   //Temporary layer passes to visible but not yet updated
            this.tempLayer.Visible = true;
            this.initMouseLocation = initMouseLocation;
            //Includes all those elements affected by the drag & drop in the temporal layer (the selected and the interspersed arrows)
            this.LoadTempLayer();

            //The initial positions of the items to be moved are saved
            foreach (GraphElement element in this.tempLayer.Elements)
            {
                this.initLocations.Add(element, element.Center);
            }
        }
Пример #9
0
 private void BlockShape_OnMouseUp(object sender, MouseEventArgs e)
 {
     if (LinkRectangle.Contains(e.Location))
     {
         if (m_linkedLayer != null)
         {
             Abstract.ActiveLayer(m_linkedLayer.Name);
         }
         else
         {
             m_linkedLayer = GenerateLayer(UID.ToString().Trim());
             Abstract.Layers.Add(m_linkedLayer);
             Abstract.ActiveLayer(m_linkedLayer.Name);
         }
         Site.Invalidate();
     }
 }
Пример #10
0
        private GraphLayer GenerateLayer(string layerName)
        {
            GraphLayer layer = null;

            if (Site != null)
            {
                layer = Site.Abstract.Layers[layerName];
            }

            if (layer == null)
            {
                layer          = new GraphLayer(layerName);
                layer.Visible  = false;
                layer.UseColor = false;
            }

            return(layer);
        }
Пример #11
0
 private void menu_goUpperLayer_Click(object sender, EventArgs e)
 {
     if (graphControl.Abstract.CurrentLayer != graphControl.Abstract.DefaultLayer)
     {
         foreach (Shape shape in graphControl.Shapes)
         {
             if (shape is BlockShape)
             {
                 GraphLayer layer = (shape as BlockShape).LinkedLayer;
                 if (layer != null && layer == graphControl.Abstract.CurrentLayer)
                 {
                     graphControl.Abstract.ActiveLayer(shape.Layer.Name);
                     return;
                 }
             }
         }
     }
 }
Пример #12
0
        internal void OpenLayer(Graph doc)
        {
            // Create new
            GraphLayer newLayer = new GraphLayer(this, doc);

            _StackedLayers.Add(newLayer);
            // Open for editing
            GraphGrid.Children.Clear();
            GraphGrid.Children.Add(newLayer);
            // Dim Prev if we are not the default one
            if (ActiveLayer != null)
            {
                ActiveLayer.Opacity = 0.3;
            }
            ActiveLayer = newLayer;
            // Update UI
            NotifyPropertyChanged("StackedLayerNames");
        }
Пример #13
0
        protected BlockShape(SerializationInfo info, StreamingContext context) : base(info, context)
        {
            m_leftConnector           = (Connector)info.GetValue("m_leftConnector", typeof(Connector));
            m_leftConnector.BelongsTo = this;
            Connectors.Add(m_leftConnector);

            try
            {
                //this.URL = string.Empty;
                //this.URL = info.GetString("m_linkedLayer");
                m_linkedLayer = (GraphLayer)info.GetValue("m_linkedLayer", typeof(GraphLayer));
            }
            catch (Exception)
            {
            }

            BindingEventHandler();
        }
Пример #14
0
        private void BlockShape_OnMouseUp(object sender, MouseEventArgs e)
        {
            PointF p = new PointF(e.X - Site.AutoScrollPosition.X, e.Y - Site.AutoScrollPosition.Y);

            if (LinkRectangle.Contains(p))
            {
                if (m_linkedLayer != null)
                {
                    Abstract.ActiveLayer(m_linkedLayer.Name);
                }
                else
                {
                    m_linkedLayer = GenerateLayer(UID.ToString().Trim());
                    Abstract.Layers.Add(m_linkedLayer);
                    Abstract.ActiveLayer(m_linkedLayer.Name);
                }
                Site.Invalidate();
            }
        }
Пример #15
0
        internal GraphNodeControl(GraphNodeView view, GraphLayer manager)
        {
            View             = view; // The visual element of the view is this
            Node             = view.Node;
            _OwnerGraphLayer = manager;
            InitializeComponent();

            // Initialize resources
            if (bResourceInitialized == false)
            {
                JumperImageStyle         = NodeImage.FindResource("JumperStyleImage") as Style;
                TextNodeStyle            = this.FindResource("TextNode") as Style;
                TextNodeHighLightStyle   = this.FindResource("TextNodeHighlight") as Style;
                ImageNodeStyle           = this.FindResource("ImageNode") as Style;
                ImageNodeHighLightStyle  = this.FindResource("ImageNodeHighlight") as Style;
                JumperNodeStyle          = this.FindResource("JumperNode") as Style;
                JumperNodeHighlightStyle = this.FindResource("JumperNodeHighlight") as Style;
                bResourceInitialized     = true;
            }

            // Switch Style
            switch (Node.Type)
            {
            case NodeType.SimpleText:
                // Do nothing more setup, default assumed
                // Show
                NodeTextExpander.Visibility = Visibility.Visible;
                break;

            case NodeType.Link:
                SetupInterfaceForLink();
                break;

            case NodeType.RichFlowText:
                SetupInterfaceForFlowText();
                break;

            case NodeType.Jumper:
                SetupInterfaceForJumper();
                break;
            }
        }
Пример #16
0
        void PlotFullDATXY(FullDATField xval, FullDATField yval, string strGrName, AxisType xAxis = AxisType.Linear, AxisType yAxis = AxisType.Linear, string plotType = "Scatter", FullDATField yval2 = FullDATField.Luminance)
        {
            activeGraphLayer1 = originApp.FindGraphLayer(strGrName);
            if (activeGraphLayer1 == null)
            {
                strGrName = (String)originApp.CreatePage((int)Origin.PAGETYPES.OPT_GRAPH, strGrName, plotType, 2);
            }
            activeGraphLayer1 = (GraphLayer)originApp.GraphPages[strGrName].Layers[0];
            DataRange dr1 = activeSheet.NewDataRange();

            dr1.Add("X", activeSheet, 0, (int)xval, -1, (int)xval);//add data for X column
            dr1.Add("Y", activeSheet, 0, (int)yval, -1, (int)yval);
            String strPlotName = string.Concat(strGrName, "_plot");

            activeDataPlot = activeGraphLayer1.DataPlots[strPlotName];
            activeDataPlot = activeGraphLayer1.DataPlots.Add(dr1, PLOTTYPES.IDM_PLOT_LINESYMB);
            activeGraphLayer1.Execute(string.Concat("set ", activeDataPlot.Name, " -c color(", plotColors[colorCounter], ")"));
            if (xAxis == AxisType.Logarithmic)
            {
                activeGraphLayer1.Execute("layer.x.type = 2");
            }
            if (yAxis == AxisType.Logarithmic)
            {
                activeGraphLayer1.Execute("layer.y.type = 2");
            }
            activeGraphLayer1.Execute("Rescale");
            activeGraphLayer1.Execute("layer.y.rescale()");
            activeGraphLayer1.Execute("legendupdate dest:=layer update:=reconstruct mode:=comment");
            if (plotType == "DoubleY")
            {
                activeGraphLayer2 = (GraphLayer)originApp.GraphPages[strGrName].Layers[1];
                DataRange dr2 = activeSheet.NewDataRange();
                dr2.Add("X", activeSheet, 0, (int)xval, -1, (int)xval);//add data for X column
                dr2.Add("Y", activeSheet, 0, (int)yval2, -1, (int)yval2);
                activeDataPlot = activeGraphLayer2.DataPlots.Add(dr2, PLOTTYPES.IDM_PLOT_LINESYMB);
                activeGraphLayer2.Execute(string.Concat("set ", activeDataPlot.Name, " -c color(", plotColors[colorCounter], ")"));
                activeGraphLayer2.Execute(string.Concat("set ", activeDataPlot.Name, " -k 4"));//change symbol for luminance to triangle
                activeGraphLayer2.Execute("legendupdate dest:=layer update:=reconstruct mode:=comment");
                activeGraphLayer2.Execute("Rescale");
            }
            FormatXYGraph();
        }
Пример #17
0
        private void CloseLayer(GraphLayer layer)
        {
            // Restrict it to be only the last one
            if (_StackedLayers.Last() != layer)
            {
                throw new IndexOutOfRangeException("Specified layer isn't opened or is not the most recent one in current editor.");
            }

            _StackedLayers.Remove(layer);
            GraphGrid.Children.Remove(layer);
            // Commit change
            layer.SaveGraphData();
            // Return active
            ActiveLayer         = _StackedLayers.Last();
            ActiveLayer.Opacity = 1;
            // Show prev one
            GraphGrid.Children.Add(ActiveLayer);
            // Update UI
            NotifyPropertyChanged("StackedLayerNames");
        }
Пример #18
0
        /// <summary>
        /// Default ctor
        /// </summary>
        /// <param name="layer">ref-ed GraphLayer from the graphcontrol</param>
        public LayerListItem(ref GraphLayer layer)
        {
            mLayer          = layer;
            this.Locked     = layer.Locked;
            this.Name       = layer.Name;
            this.Number     = layer.Number;
            this.Opacity    = layer.Opacity;
            this.UseColor   = layer.UseColor;
            this.Visible    = layer.Visible;
            this.LayerColor = layer.LayerColor;
            this.Text       = Name;
            this.SubItems.Add(Number.ToString());
            if (Visible)
            {
                this.SubItems.Add(constChecked, Color.Black, Color.Empty, new Font("Wingdings", 11f));
            }
            else
            {
                this.SubItems.Add(constUnchecked, Color.Black, Color.Empty, new Font("Wingdings", 11f));
            }

            if (Locked)
            {
                this.SubItems.Add(constChecked, Color.Black, Color.Empty, new Font("Wingdings", 11f));
            }
            else
            {
                this.SubItems.Add(constUnchecked, Color.Black, Color.Empty, new Font("Wingdings", 11f));
            }

            if (UseColor)
            {
                this.SubItems.Add(constChecked, Color.Black, Color.Empty, new Font("Wingdings", 11f));
            }
            else
            {
                this.SubItems.Add(constUnchecked, Color.Black, Color.Empty, new Font("Wingdings", 11f));
            }

            UseItemStyleForSubItems = false;
        }
Пример #19
0
        private void PlotCEJ(string plotName)
        {
            String strGrName = string.Concat(plotName, "CEJ");

            activeGraphLayer1 = originApp.FindGraphLayer(strGrName);
            if (activeGraphLayer1 == null)
            {
                strGrName = (String)originApp.CreatePage((int)Origin.PAGETYPES.OPT_GRAPH, strGrName, "Scatter", 2);
            }
            activeGraphLayer1 = (GraphLayer)originApp.GraphPages[strGrName].Layers[0];
            DataRange cejdr = activeSheet.NewDataRange();

            cejdr.Add("X", activeSheet, 0, 1, -1, 1); //2nd column (J)
            cejdr.Add("Y", activeSheet, 0, 4, -1, 4); //5th column (CE)
            String strPlotName = string.Concat(plotName, "CEJ_Scatter");

            activeDataPlot = activeGraphLayer1.DataPlots[strPlotName];
            activeDataPlot = activeGraphLayer1.DataPlots.Add(cejdr, PLOTTYPES.IDM_PLOT_LINESYMB);
            activeGraphLayer1.Execute(string.Concat("set ", activeDataPlot.Name, " -c color(", plotColors[colorCounter], ")"));
            FormatXYGraph();
        }
Пример #20
0
        private void SetForm()
        {
            chrtUren.Enabled    = grpTotalen.Enabled = grpOverzicht.Enabled = Data.IsConnected && !Data.DbEmpty;
            grpKlokken.Enabled  = Data.IsConnected;
            btnClockIn.Enabled  = !Data.IsLoggedIn();
            btnClockOut.Enabled = !btnClockIn.Enabled;

            var reg = Data.Last();

            if (reg == null)
            {
                return;
            }
            SetBtnGenerate();
            ucWeek.Init();
            lblOnline.Text        = StringLayer.GetLblOnlineString(reg);
            lblUrenWeek.Text      = Registratie.TotalDuration(Data.GetRegsForWeek(DateTime.Now)) + "/" + Contract.Uren;
            lblUrenTotaal.Text    = Registratie.TotalDuration(Data.All());
            lblUrenDiff.Text      = Registratie.Difference(Data.All());
            lblUrenDiff.ForeColor = lblUrenDiff.Text.StartsWith("-") ? Color.Red : Color.Green;
            chrtUren.Series[0]    = GraphLayer.GetSeries(GraphLayer.WorkedHours);
        }
Пример #21
0
        public void OnGraphLoaded(Node root, List <Vertex> vertices)
        {
            Action <Node, List <Vertex> > action = (x, y) =>
            {
                var layer = new GraphLayer(y)
                {
                    Name = "graph"
                };
                map.Layers.Add(layer);

                BuildTree(x);
            };

            if (InvokeRequired)
            {
                Invoke(action, root, vertices);
            }
            else
            {
                action(root, vertices);
            }
        }
        public override void Run()
        {
            //some shapes randomly placed on the canvas
            Shape shape1 = mediator.GraphControl.AddBasicShape("Item 1"); SetShape(shape1);
            Shape shape2 = mediator.GraphControl.AddBasicShape("Item 2"); SetShape(shape2);
            Shape shape3 = mediator.GraphControl.AddBasicShape("Item 3"); SetShape(shape3);
            Shape shape4 = mediator.GraphControl.AddBasicShape("Item 4"); SetShape(shape4);
            Shape shape5 = mediator.GraphControl.AddBasicShape("Item 5"); SetShape(shape5);
            Shape shape6 = mediator.GraphControl.AddBasicShape("Item 6"); SetShape(shape6);
            Shape shape7 = mediator.GraphControl.AddBasicShape("Item 7"); SetShape(shape7);
            Shape shape8 = mediator.GraphControl.AddBasicShape("Item 8"); SetShape(shape8);

            GraphLayer redlayer = new GraphLayer("Red layer", Color.WhiteSmoke, 26);

            redlayer.UseColor = true;
            mediator.GraphControl.Layers.Add(redlayer);

            GraphLayer bluelayer = new GraphLayer("Blue layer", Color.DarkBlue, 46);

            bluelayer.UseColor = true;
            mediator.GraphControl.Layers.Add(bluelayer);

            shape1.SetLayer(1);
            shape2.SetLayer(1);
            shape7.SetLayer(2);

            //some connections
            Connection cn = Connect(shape1, shape2);

            cn.SetLayer(1);
            Connect(shape2, shape3);
            Connect(shape2, shape4);
            Connect(shape4, shape5);
            Connect(shape4, shape6);
            Connect(shape2, shape7);
            Connect(shape3, shape8);
            Connect(shape7, shape8);
        }
Пример #23
0
 /// <summary>
 /// Builder for the delete operation
 /// </summary>
 /// <param name="diagram">Diagram of the GraphDrawing</param>
 /// <param name="diagramLayer">GraphDrawing diagram Layer</param>
 /// <param name="tempLayer">Temporal layer of the GraphDrawing</param>
 public Delete(Diagram diagram, GraphLayer diagramLayer, GraphLayer selectLayer)
 {
     this.diagram      = diagram;
     this.diagramLayer = diagramLayer;
     this.selectLayer  = selectLayer;
 }
Пример #24
0
 /// <summary>
 /// Builder
 /// </summary>
 /// <param name="selectLayer">Graphic Diagram Selection layer</param>
 public Copy(GraphLayer selectLayer)
 {
     this.selectLayer = selectLayer;
 }
Пример #25
0
        /// <summary>
        ///
        /// </summary>
        public override void Initialize()
        {
            debugFont = Game.Content.Load <DiscTexture>("conchars");

            var bounds = Game.RenderSystem.DisplayBounds;

            masterView = Game.RenderSystem.RenderWorld;


            Game.RenderSystem.RemoveLayer(masterView);

            viewLayer = new RenderLayer(Game);
            Game.RenderSystem.AddLayer(viewLayer);

            Game.RenderSystem.DisplayBoundsChanged += (s, e) =>
            {
                masterView.Resize(Game.RenderSystem.DisplayBounds.Width, Game.RenderSystem.DisplayBounds.Height);
            };

            viewLayer.SpriteLayers.Add(console.ConsoleSpriteLayer);


            Game.Keyboard.KeyDown += Keyboard_KeyDown;

            LoadContent();

            Game.Reloading += (s, e) => LoadContent();


            Game.Touch.Tap          += args => System.Console.WriteLine("You just perform tap gesture at point: " + args.Position);
            Game.Touch.DoubleTap    += args => System.Console.WriteLine("You just perform double tap gesture at point: " + args.Position);
            Game.Touch.SecondaryTap += args => System.Console.WriteLine("You just perform secondary tap gesture at point: " + args.Position);
            Game.Touch.Manipulate   += args => System.Console.WriteLine("You just perform touch manipulation: " + args.Position + "	" + args.ScaleDelta + "	" + args.RotationDelta + " " + args.IsEventBegin + " " + args.IsEventEnd);


            graph        = new GraphLayer(Game);
            graph.Camera = new GreatCircleCamera();

            Game.Mouse.Scroll += (sender, args) =>
            {
                graph.Camera.Zoom(args.WheelDelta > 0 ? -0.1f : 0.1f);
            };

            Game.Mouse.Move += (sender, args) =>
            {
                if (Game.Keyboard.IsKeyDown(Keys.LeftButton))
                {
                    graph.Camera.RotateCamera(mouseDelta);
                }
                if (Game.Keyboard.IsKeyDown(Keys.MiddleButton))
                {
                    graph.Camera.MoveCamera(mouseDelta);
                }
            };

            var g = new Graph();
            // Здесь должно быть чтение из файла и запись в узлы
            string path = @"Data/Hela_sonic_LMNA_interactions_diploid_10071362_iter_final.csv";
            Dictionary <int, Graph.Vertice> allVertices = new Dictionary <int, Graph.Vertice>();
            List <Graph.Link> allEdges = new List <Graph.Link>();
            var zone       = -1;
            var currentChr = "";
            var zoneIndex  = -1;
            var lines      = File.ReadAllLines(path);
            var index      = 0;

            foreach (var line in lines)
            {
                var info = line.Split(',');
                int id   = index++;
                Log.Message(info[0] + ' ' + id);

                var chr = info[0].Split(':')[0];
                if (!chr.Equals(currentChr))
                {
                    zoneIndex++;
                    currentChr = chr;
                    Log.Message("zone" + zoneIndex);
                }

                if (!allVertices.ContainsKey(id))
                {
                    if (zone == zoneIndex && id != 0)
                    {
                        try
                        {
                            var type = 1;
                            // var id = i;
                            var stock = id - 1;


                            Graph.Link link = new Graph.Link()
                            {
                                SourceID      = id,
                                StockID       = stock,
                                Length        = 10,
                                Force         = 0,
                                Orientation   = Vector3.Zero,
                                Weight        = graph.cfg.MaxLinkWidth,
                                LinkType      = type + 1,
                                Color         = paletteByZone.ElementAt(zone).ToVector4(),
                                Width         = 10,
                                LifeTime      = 0,
                                TotalLifeTime = 0,
                            };
                            allEdges.Add(link);
                        }

                        catch (Exception e)
                        {
                            Log.Message(e.StackTrace);
                        }
                    }
                    else
                    {
                        zone = zoneIndex;
                    }
                    Graph.Vertice node = new Graph.Vertice()
                    {
                        Position     = new Vector3(float.Parse(info[1]), float.Parse(info[2]), float.Parse(info[3])) * 1000, //gcConfig.LinkSize,
                        Velocity     = Vector3.Zero,
                        Color        = paletteByZone.ElementAt(zone).ToVector4(),                                            //to bechange
                        Size         = float.Parse(info[4]) * 1000,
                        Acceleration = Vector3.Zero,
                        Mass         = 0,
                        Information  = 1,
                        Id           = id,
                        Group        = zone,
                        Charge       = 1,
                        Cluster      = 0,
                        ColorType    = zone * 100 + graph.cfg.MinParticleRadius * 5,
                    };

                    allVertices.Add(id, node);
                }
            }
            //try
            //{
            //    for (int i = 0; i < lines.Count() - 1; i++)
            //    {
            //        var type = 1;
            //        var id = i;
            //        var stock = i + 1;


            //        Graph.Link link = new Graph.Link()
            //        {
            //            SourceID = id,
            //            StockID = stock,
            //            Length = 10,
            //            Force = 0,
            //            Orientation = Vector3.Zero,
            //            Weight = graph.cfg.MaxLinkWidth,
            //            LinkType = type + 1,
            //            Color = ColorConstant.paletteWhite.ElementAt(type + 1).ToVector4(),
            //            Width = 10,
            //            LifeTime = 0,
            //            TotalLifeTime = 0,
            //        };
            //        allEdges.Add(link);
            //    }
            //}
            //catch (Exception e)
            //{
            //    Log.Message(e.StackTrace);
            //}

            foreach (var pair in allVertices)
            {
                var node = pair.Value;
                //node.ColorType = 0;
                g.nodes.Add(node);
            }
            g.NodesCount = g.nodes.Count;
            g.links      = allEdges;

            graph.SetGraph(g);
            graph.cfg.GraphLayout = @"Graph/Signaling";
            graph.Initialize();
            graph.staticMode = true;
            graph.Pause();
            graph.AddMaxParticles();



            viewLayer.GraphLayers.Add(graph);
        }
Пример #26
0
        private void PopulateCompareStatsSheetThenPlotXY(StatsDATField xval, StatsDATField yval, string sheetName, AxisType xAxis = AxisType.Linear, AxisType yAxis = AxisType.Linear)
        {
            //create worksheet
            activeSheet = originApp.FindWorksheet(sheetName);
            if (activeSheet == null)
            {
                sheetName = (String)originApp.CreatePage((int)Origin.PAGETYPES.OPT_WORKSHEET, sheetName, "Origin", 2);
            }
            activeSheet = (Worksheet)originApp.WorksheetPages[sheetName].Layers[0];
            //count columns to create from # of scans
            int colsCounter = 0;

            foreach (Device d in dbvm.TheDeviceBatch.Devices)
            {
                foreach (DeviceLJVScanSummary ss in d.DeviceLJVScanSummaries)
                {
                    if (ss.TestCondition == activeTestCondition)
                    {
                        foreach (LJVScan scan in ss.LJVScans)
                        {
                            colsCounter++;
                        }
                    }
                }
            }
            activeSheet.Cols = colsCounter * 3;//xval (mean),yval(mean),yerror (no xerror because messy)
            colsCounter      = 0;
            //create graph layer
            String strGrName = string.Concat("graph_", sheetName);

            activeGraphLayer1 = originApp.FindGraphLayer(strGrName);
            if (activeGraphLayer1 == null)
            {
                strGrName = (String)originApp.CreatePage((int)Origin.PAGETYPES.OPT_GRAPH, strGrName, "Scatter", 2);
            }
            activeGraphLayer1 = (GraphLayer)originApp.GraphPages[strGrName].Layers[0];
            String strPlotName = string.Concat(strGrName, "_line");

            activeDataPlot   = activeGraphLayer1.DataPlots[strPlotName];
            colorCounter     = 0;
            lineStyleCounter = 0;
            if (activeSheet.Cols > 0)
            {
                //populate columns with data then add DataPlots to GraphLayer
                foreach (Device d in dbvm.TheDeviceBatch.Devices)
                {
                    Debug.WriteLine("Plotting " + sheetName + " for " + d.Label);
                    foreach (DeviceLJVScanSummary ss in d.DeviceLJVScanSummaries)
                    {
                        if (ss.TestCondition == activeTestCondition)
                        {
                            lineStyleCounter = 0;
                            LJVScanSummaryVM vm = new LJVScanSummaryVM(ss);
                            var array           = vm.StatsDatArray();
                            activeSheet.Columns[colsCounter].LongName = StatsDATLongNames[xval];
                            activeSheet.Columns[colsCounter].Type     = COLTYPES.COLTYPE_X;
                            activeSheet.Columns[colsCounter].Units    = StatsDATUnits[xval];
                            activeSheet.SetData(array.GetCol((int)xval), 0, colsCounter);
                            activeSheet.Columns[colsCounter + 1].LongName = StatsDATLongNames[yval];
                            activeSheet.Columns[colsCounter + 1].Type     = COLTYPES.COLTYPE_Y;
                            activeSheet.Columns[colsCounter + 1].Units    = StatsDATUnits[yval];
                            activeSheet.Columns[colsCounter + 1].Comments = d.Label;
                            activeSheet.SetData(array.GetCol((int)yval), 0, colsCounter + 1);
                            activeSheet.Columns[colsCounter + 2].Type = COLTYPES.COLTYPE_ERROR;//set y error stuff
                            activeSheet.SetData(array.GetCol((int)yval + 1), 0, colsCounter + 2);
                            DataRange dr = activeSheet.NewDataRange();
                            dr.Add("X", activeSheet, 0, colsCounter, -1, colsCounter);          //add data for X column
                            dr.Add("Y", activeSheet, 0, colsCounter + 1, -1, colsCounter + 1);
                            dr.Add("ED", activeSheet, 0, colsCounter + 2, -1, colsCounter + 2); //ED==origin name for Yerror type XDDDD
                            activeDataPlot = activeGraphLayer1.DataPlots.Add(dr, PLOTTYPES.IDM_PLOT_LINE);
                            activeGraphLayer1.Execute(string.Concat("set ", activeDataPlot.Name, " -c color(", plotColors[colorCounter], ")"));
                            activeGraphLayer1.Execute(string.Concat("set ", activeDataPlot.Name, " -d ", lineStyleCounter));
                            colsCounter += 3;
                            lineStyleCounter++;
                        }
                    }
                    colorCounter++;//do this to use same line color for each device
                }
                if (xAxis == AxisType.Logarithmic)
                {
                    activeGraphLayer1.Execute("layer.x.type = 2");
                }
                if (yAxis == AxisType.Logarithmic)
                {
                    activeGraphLayer1.Execute("layer.y.type = 2");
                }
                FormatXYGraph();
            }
        }