// Analysis disable once UnusedParameter public bool RenderGraphs(RenderTexture screen, float cameraAspect) { if (!startupComplete) { return(false); } if (backgroundTexture != null) { Graphics.Blit(backgroundTexture, screen); } GL.Clear(true, (backgroundTexture == null), backgroundColorValue); GL.PushMatrix(); // This way 0,0 is in bottom left corner, which is what we want this time. GL.LoadPixelMatrix(0, screen.width, 0, screen.height); double time = Planetarium.GetUniversalTime(); foreach (GraphLine graph in graphs) { graph.Draw(graphSpace, time); } if (borders > 0) { GraphLine.DrawVector(borderVertices, borderColorValue); } GL.PopMatrix(); return(true); }
public void RefreshWillRemoveLines() { GraphLine line = CreateLineWithTwoPoints(); line.AddValue(0.4f, 4.0f); line.lines.Add(new Line2D(Vector2D.Zero, Vector2D.One, Color.Purple)); line.Refresh(); }
public void RenderTwoRandomLinesWithKey() { GraphLine line2 = graph.CreateLine("Two", Color.Red); graph.Add(new List <GraphLine> { line, line2 }); graph.Start <AddTwoRandomValuesEverySecond>(); }
public void HiddenGraphDisplaysNothing() { graph.NumberOfPercentiles = 5; GraphLine line = graph.CreateLine("", LineColor); line.AddPoint(new Vector2D(-1.0f, -1.0f)); line.AddPoint(new Vector2D(0.1f, 0.5f)); graph.IsVisible = false; }
static float PlotY(GraphLine line, int pointIndex, float heightTrue) { return(Utf.Ale.AlchemyEasing.Ease(Utf.Ale.EasingTypes.Linear, line.Points[pointIndex], line.ValMin, line.ValMax, 0, heightTrue)); }
public void AddValueAddsToTheEnd() { GraphLine line = CreateLineWithTwoPoints(); line.AddValue(0.4f, 4.0f); Assert.AreEqual(new Vector2D(1.0f, 4.0f), line.points[2]); line.AddValue(3.0f); Assert.AreEqual(new Vector2D(2.0f, 3.0f), line.points[3]); }
public void RefreshUpdatesLinesIfViewportChanged() { GraphLine line = CreateLineWithTwoPoints(); line.graph.Viewport = Rectangle.FromCenter(0.4f, 0.4f, 0.8f, 0.8f); line.Refresh(); Assert.IsTrue(line.lines[0].StartPoint.IsNearlyEqual(new Vector2D(0.5f, 0.4762f))); Assert.IsTrue(line.lines[0].EndPoint.IsNearlyEqual(new Vector2D(0.5952f, 0.4286f))); }
private Rect GetLineBounds(GraphLine line) { float center = position.center.y - position.y; float top = center - (LineThickness / 2); float width = position.width - (HorizontalMargin + NodeWidth / 2) * 2; float left = (HorizontalMargin + NodeWidth / 2) + line.Position * width; return(new Rect(left, top, line.Length * width, LineThickness)); }
public void RefreshDoesNothingIfViewportDidntChange() { GraphLine line = CreateLineWithTwoPoints(); Vector2D start = line.lines[0].StartPoint; Vector2D end = line.lines[0].EndPoint; line.Refresh(); Assert.AreEqual(start, line.lines[0].StartPoint); Assert.AreEqual(end, line.lines[0].EndPoint); }
public void ClearRemovesAllLinesAndClearsAllPoints() { GraphLine line = CreateLineWithTwoPoints(); Line2D line2D = line.lines[0]; Assert.IsTrue(line2D.IsActive); line.Clear(); Assert.AreEqual(0, line.lines.Count); Assert.AreEqual(0, line.points.Count); }
public void RemoveLastPoint() { GraphLine line = CreateLineWithThreePoints(); line.RemoveAt(2); Assert.AreEqual(2, line.points.Count); Assert.AreEqual(1, line.lines.Count); Assert.IsTrue(line.lines[0].StartPoint.IsNearlyEqual(new Vector2D(0.462f, 0.5f))); Assert.IsTrue(line.lines[0].EndPoint.IsNearlyEqual(new Vector2D(0.538f, 0.462f))); }
public override void Begin() { if (IsContinue == true) { TempPrims.Clear(); Temp = new GraphLine(); TempPrims.Add(Temp); Step = 0; } }
private void PopulateGraphFromDocument(bool centre) { Dictionary <Guid, GraphNode> idToNode = new Dictionary <Guid, GraphNode>(); List <GraphNode> linkedNodes = new List <GraphNode>(); _populatingControl = true; netEditor.SuspendLayout(); netEditor.ClearGraph(); netEditor.DocumentWidth = NetGraphDocument.DEFAULT_DOCUMENT_WIDTH; netEditor.DocumentHeight = NetGraphDocument.DEFAULT_DOCUMENT_HEIGHT; foreach (var n in _document.Nodes) { idToNode[n.Id] = AddNode(n, new PointF(n.X, n.Y), n.Z); ILinkedNodeConfig linkedConfig = n as ILinkedNodeConfig; if ((linkedConfig != null) && (linkedConfig.LinkedNode != null)) { linkedNodes.Add(idToNode[n.Id]); } } foreach (GraphNode n in linkedNodes) { ILinkedNodeConfig config = n.Tag as ILinkedNodeConfig; if (idToNode.ContainsKey(config.LinkedNode.Id)) { AddLinkLine(n, idToNode[config.LinkedNode.Id]); } } foreach (LineConfig l in _document.Lines) { if ((idToNode.ContainsKey(l.SourceNode.Id) && (idToNode.ContainsKey(l.DestNode.Id)))) { GraphLine newLine = netEditor.AddLine(idToNode[l.SourceNode.Id], idToNode[l.DestNode.Id]); newLine.BiDirection = l.BiDirection; newLine.Label = l.PathName; newLine.Tag = l.WeakPath; newLine.LineDashStyle = l.WeakPath ? DashStyle.Dot : DashStyle.Solid; } } netEditor.SelectedObject = null; if (centre) { netEditor.CenterViewOfGraph(); } netEditor.ResumeLayout(); _populatingControl = false; }
public void AddThirdPointAtTheEnd() { GraphLine line = CreateLineWithTwoPoints(); line.AddPoint(new Vector2D(0.8f, 0.5f)); Assert.AreEqual(3, line.points.Count); Assert.AreEqual(2, line.lines.Count); Line2D line2D = line.lines[1]; Assert.IsTrue(line2D.StartPoint.IsNearlyEqual(new Vector2D(0.538f, 0.462f))); Assert.IsTrue(line2D.EndPoint.IsNearlyEqual(new Vector2D(0.6143f, 0.5f))); }
/// <summary> /// Define a new graph line /// </summary> /// <param name="color"></param> /// <returns></returns> public int NewGraphLine(Color color, double scale, double offset) { GraphLine line = new GraphLine(); line.color = color; line.scale = scale; line.offset = offset; line.gameObject = Instantiate(trailPrefab); line.gameObject.transform.SetParent(this.transform); graphLines.Add(line); return(graphLines.Count - 1); }
public void Draw(SKSurface surface, List <IGraphItem> graphItems) { SKCanvas canvas = surface.Canvas; foreach (var item in graphItems) { string type = item.GetType().ToString(); int pos = type.LastIndexOf('.'); type = type.Substring(pos + 1); switch (type) { case "GraphClear": GraphClear graphClear = item as GraphClear; canvas.Clear(graphClear.Color); break; case "GraphLine": GraphLine graphLine = item as GraphLine; canvas.DrawLine(graphLine.XPosStart, graphLine.YPosStart, graphLine.XPosEnd, graphLine.YPosEnd, GetLineBrush(graphLine)); break; case "GraphRectangle": GraphRectangle graphRectangle = item as GraphRectangle; var rect = SKRect.Create(graphRectangle.XPos, graphRectangle.YPos, graphRectangle.Width, graphRectangle.Height); canvas.DrawRect(rect, GetRectangleBrush(graphRectangle)); break; case "GraphText": GraphText graphText = item as GraphText; if (graphText.Rotation == 0) { canvas.DrawText(graphText.Text, graphText.XPos, graphText.YPos, GetTextBrush(graphText)); } else { using (new SKAutoCanvasRestore(canvas)) // https://stackoverflow.com/questions/41908497/draw-rotated-text-in-skiasharp { // do any transformations canvas.RotateDegrees(graphText.Rotation, graphText.XPos, graphText.YPos); // do serious work canvas.DrawText(graphText.Text, graphText.XPos, graphText.YPos, GetTextBrush(graphText)); // auto restore, even on exceptions or errors } } break; case "GraphCircle": GraphCircle graphCircle = item as GraphCircle; canvas.DrawCircle(graphCircle.XPos, graphCircle.YPos, graphCircle.Radius, GetCircleBrush(graphCircle)); break; } } }
private void DrawLineGUI(GraphLine line) { var data = target as GraphObjectObserver; line.Graph = data.Flow; EditorGUILayout.LabelField("Line Segment", EditorStyles.boldLabel); EditorUtil.DrawObjectList <DungeonArchetype>("Dungeon Archetypes", line.DungeonArchetypes, GameObjectSelectionTypes.Prefab); EditorGUILayout.Space(); DrawKeys(line.Graph.KeyManager, line.Keys, line.Locks, false); }
public void RemovingGraphLineRemovesItsLines() { GraphLine line = graph.CreateLine("", LineColor); line.AddPoint(new Vector2D(-1.0f, -1.0f)); line.AddPoint(new Vector2D(0.1f, 0.5f)); Assert.AreEqual(1, graph.Lines.Count); Assert.AreEqual(1, line.lines.Count); graph.RemoveLine(line); Assert.AreEqual(0, graph.Lines.Count); Assert.AreEqual(0, line.lines.Count); }
public void RemoveMiddlePoint() { GraphLine line = CreateLineWithThreePoints(); line.RemoveAt(1); Assert.AreEqual(2, line.points.Count); Assert.AreEqual(1, line.lines.Count); Assert.AreEqual(new Vector2D(0.4f, 0.5f), line.points[0]); Assert.AreEqual(new Vector2D(0.8f, 0.4f), line.points[1]); Assert.IsTrue(line.lines[0].StartPoint.IsNearlyEqual(new Vector2D(0.462f, 0.5f))); Assert.IsTrue(line.lines[0].EndPoint.IsNearlyEqual(new Vector2D(0.6143f, 0.519f))); }
public void TwoPointsDrawALine() { GraphLine line = CreateLineWithTwoPoints(); Assert.AreEqual(2, line.points.Count); Assert.AreEqual(1, line.lines.Count); Line2D line2D = line.lines[0]; Assert.IsTrue(line2D.StartPoint.IsNearlyEqual(new Vector2D(0.462f, 0.5f))); Assert.IsTrue(line2D.EndPoint.IsNearlyEqual(new Vector2D(0.538f, 0.462f))); Assert.AreEqual(LineColor, line.Color); }
public void RenderFpsWithFivePercentiles() { graph.Viewport = new Rectangle(0.0f, 0.0f, 10.0f, 60.0f); graph.NumberOfPercentiles = 5; graph.PercentileSuffix = "%"; GraphLine line = graph.CreateLine("", LineColor); var fps = new FontText(Font.Default, "", new Rectangle(0.5f, 0.7f, 1.0f, 0.1f)); graph.Add(line); graph.Add(fps); graph.Start <AddValueEveryFrame>(); }
public override void End() { var p = Temp.EndPoint; Temp.Effective = true; Primitive.CurrentGraphics.Add(Temp); TempPrims.Clear(); Temp = new GraphLine(); TempPrims.Add(Temp); Temp.StartPoint.X = p.X; Temp.StartPoint.Y = p.Y; Step = 1; }
private void HandleNodeContextMenu(GraphNode node) { contextMenuNode = node; contextMenuLine = null; var menu = new GenericMenu(); if (node.NodeType == NodeType.Normal) { menu.AddItem(new GUIContent("Delete " + (string.IsNullOrEmpty(node.Label) ? "Node" : node.Label)), false, NodeContextMenuCallback, GraphContextCommand.Delete); } menu.ShowAsContext(); }
private void CreateGraphWithFourLines() { new FilledRect(Rectangle.One, Color.Gray) { RenderLayer = int.MinValue }; GraphLine line = graph.CreateLine("", LineColor); line.AddPoint(new Vector2D(-1.0f, -1.0f)); line.AddPoint(new Vector2D(0.1f, 0.5f)); line.AddPoint(new Vector2D(0.5f, 0.2f)); line.AddPoint(new Vector2D(0.9f, 1.0f)); line.AddPoint(new Vector2D(1.5f, -2.0f)); }
public void AddThirdPointInTheMiddle() { GraphLine line = CreateLineWithTwoPoints(); line.AddPoint(new Vector2D(0.5f, 0.4f)); Assert.AreEqual(3, line.points.Count); Assert.AreEqual(2, line.lines.Count); Line2D line0 = line.lines[0]; Assert.IsTrue(line0.StartPoint.IsNearlyEqual(new Vector2D(0.462f, 0.5f))); Assert.IsTrue(line0.EndPoint.IsNearlyEqual(new Vector2D(0.5f, 0.519f))); Line2D line1 = line.lines[1]; Assert.IsTrue(line1.StartPoint.IsNearlyEqual(new Vector2D(0.5f, 0.519f))); Assert.IsTrue(line1.EndPoint.IsNearlyEqual(new Vector2D(0.538f, 0.462f))); }
private void HandleLineContextMenu(GraphLine line) { contextMenuLine = line; contextMenuNode = null; var menu = new GenericMenu(); menu.AddItem(new GUIContent("Add Node Here"), false, LineContextMenuCallback, GraphContextCommand.AddNode); menu.AddItem(new GUIContent("Split Segment"), false, LineContextMenuCallback, GraphContextCommand.SplitLine); if (Flow.Lines.Count > 1) { menu.AddItem(new GUIContent("Delete Segment"), false, LineContextMenuCallback, GraphContextCommand.Delete); } menu.ShowAsContext(); }
//========================================= // addNewGraphLine //========================================= public void addNewGraphLine(uint handle, string name, Color col) { for (int i = 0; i < mGraphLines.Count; i++) { if (mGraphLines[i].mHandle == handle) { return; } } GraphLine hl = new GraphLine(); hl.mHandle = handle; hl.mName = name; hl.mColor = col; mGraphLines.Add(hl); }
private void PopulateGraphFromDocument() { Dictionary <Guid, GraphNode> idToNode = new Dictionary <Guid, GraphNode>(); List <GraphNode> linkedNodes = new List <GraphNode>(); netEditor.SuspendLayout(); netEditor.ClearGraph(); foreach (var n in _document.Nodes) { idToNode[n.Id] = AddNode(n, new PointF(n.X, n.Y), n.Z); ILinkedNodeConfig linkedConfig = n as ILinkedNodeConfig; if ((linkedConfig != null) && (linkedConfig.LinkedNode != null)) { linkedNodes.Add(idToNode[n.Id]); } } foreach (GraphNode n in linkedNodes) { ILinkedNodeConfig config = n.Tag as ILinkedNodeConfig; if (idToNode.ContainsKey(config.LinkedNode.Id)) { AddLinkLine(n, idToNode[config.LinkedNode.Id]); } } foreach (LineConfig l in _document.Lines) { if ((idToNode.ContainsKey(l.SourceNode.Id) && (idToNode.ContainsKey(l.DestNode.Id)))) { GraphLine newLine = netEditor.AddLine(idToNode[l.SourceNode.Id], idToNode[l.DestNode.Id]); newLine.BiDirection = l.BiDirection; newLine.Label = l.PathName; newLine.Tag = l.WeakPath; newLine.LineDashStyle = l.WeakPath ? DashStyle.Dot : DashStyle.Solid; } } netEditor.SelectedObject = null; netEditor.ResumeLayout(); }
private void RefreshLineSelection(Point point) { var selectedLine = FindLineByPoint(MasterArrayOfGraphLines, point); if (selectedLine != this.SelectedLine) { this.SelectedLine = selectedLine; this.Invalidate(); } if (Moving != null) { this.Invalidate(); } this.Cursor = Moving != null ? Cursors.Hand : SelectedLine != null ? Cursors.SizeAll : Cursors.Default; }
/// <summary> /// Creates the graph traces and calls the graph draw method to display the strategies on a graph /// </summary> /// <param name="showAllOnGraph">Represents whether all traces on the graph will be shown after the update</param> /// <param name="changeNormalised">Represents whether the normalised driver should be set to the fastest driver, /// or maintained as the current driver</param> void DrawGraph(bool showAllOnGraph, bool changeNormalised) { //create traces. DataPoint tempPoint; GraphLine pointList; Strategy thisStrategy; int lapsThroughRace = 0; float cumulativeTime = 0; Traces.Clear(); for (int driverIndex = 0; driverIndex < Data.NumberOfDrivers; driverIndex++) { pointList = new GraphLine(driverIndex, true, Data.Drivers[driverIndex].LineColour); lapsThroughRace = 0; cumulativeTime = 0; thisStrategy = strategyViewerData.GetStrategy(driverIndex); //Add the starting point tempPoint.index = driverIndex; tempPoint.X = 0; tempPoint.Y = 0; tempPoint.isCycled = false; pointList.DataPoints.Add(tempPoint); //The points are now defined as the state at the end of a lap foreach (float lap in thisStrategy.LapTimes) { cumulativeTime += lap; tempPoint.index = driverIndex; tempPoint.X = ++lapsThroughRace; tempPoint.Y = cumulativeTime; tempPoint.isCycled = false; pointList.DataPoints.Add(tempPoint); } Traces.Add(pointList); } graph.DrawGraph(Traces, showAllOnGraph, changeNormalised); }
private void DetermineRange(GraphLine _line, float _min, float _max) { _line.Maxrange = _max * 1.05F; _line.Minrange = _min * 1.05F; switch (_line.ChannelName) { case "DisplProt.LambdaScanner": // AFR through wideband? case "Lambda.LambdaInt": // AFR through narrowband? _line.Minrange = 0.5F; _line.Maxrange = 1.5F; break; case "ActualIn.n_Engine": _line.Minrange = 0; _line.Maxrange = 7000; break; case "In.v_Vehicle": _line.Minrange = 0; _line.Maxrange = 300; break; case "In.p_AirInlet": _line.Minrange = -1; _line.Maxrange = 2; break; case "ActualIn.T_AirInlet": _line.Minrange = -30; _line.Maxrange = 120; break; case "ActualIn.T_Engine": _line.Minrange = -30; _line.Maxrange = 120; break; case "Out.fi_Ignition": _line.Minrange = -10; _line.Maxrange = 50; break; case "Out.PWM_BoostCntrl": case "REG_KON_APC": _line.Minrange = 0; _line.Maxrange = 100; break; case "Out.X_AccPedal": _line.Minrange = 0; _line.Maxrange = 100; break; } }
public bool Contains(GraphLine value) { // If value is not of type Int16, this will return false. return (List.Contains(value)); }
public int Add(GraphLine value) { return (List.Add(value)); }
public void Remove(GraphLine value) { List.Remove(value); }
public void Insert(int index, GraphLine value) { List.Insert(index, value); }
public int IndexOf(GraphLine value) { return (List.IndexOf(value)); }
public GraphData(GraphNode[] nodes, GraphLine[] lines) { _nodes = nodes; _lines = lines; }
public void AddMeasurement(string Graphname, string SymbolName, DateTime Timestamp, float value, float minrange, float maxrange, Color linecolor) { bool _linefound = false; foreach (GraphLine line in _lines) { if (line.Symbol == SymbolName) { _linefound = true; // if (value < minrange) minrange = value - 5; // if (value > maxrange) maxrange = value + 5; line.AddPoint(value, Timestamp, minrange, maxrange, linecolor); break; } } if (!_linefound) { GraphLine _newline = new GraphLine(); _newline.Symbol = SymbolName; _newline.NumberOfDecimals = GetChannelResolution(SymbolName); _newline.ChannelName = Graphname; _newline.Clear(); _lines.Add(_newline); // if (value < minrange) minrange = value; // if (value > maxrange) maxrange = value; _newline.AddPoint(value, Timestamp, minrange, maxrange, linecolor); // set visible or invisible according to registry setting _newline.LineVisible = GetRegistryValue(Graphname); if (_newline.ChannelName == "KnockInfo") _newline.LineVisible = false; if (_newline.ChannelName == "Idle") _newline.LineVisible = false; if (_newline.ChannelName == "ClosedLoop") _newline.LineVisible = false; if (_newline.ChannelName == "Warmup") _newline.LineVisible = false; } }
public void AddMeasurementToCollection(GraphLineCollection coll, string Graphname, string SymbolName, DateTime Timestamp, float value, float minrange, float maxrange, Color linecolor) { bool _linefound = false; foreach (GraphLine line in coll) { if (line.Symbol == SymbolName) { _linefound = true; // if (value < minrange) minrange = value - 5; // if (value > maxrange) maxrange = value + 5; line.AddPoint(value, Timestamp, minrange, maxrange, linecolor); break; } } if (!_linefound) { GraphLine _newline = new GraphLine(); _newline.Symbol = SymbolName; _newline.NumberOfDecimals = GetChannelResolution(SymbolName); _newline.ChannelName = Graphname; _newline.Clear(); coll.Add(_newline); _newline.AddPoint(value, Timestamp, minrange, maxrange, linecolor); _newline.LineVisible = GetRegistryValue(Graphname); } }
private void DetermineRange(GraphLine _line, float _min, float _max) { _line.Maxrange = _max * 1.05F; _line.Minrange = _min * 1.05F; switch (_line.Symbol.ToUpper()) { case "RPM": _line.Minrange = 0; _line.Maxrange = 7000; break; case "BIL_HAST": _line.Minrange = 0; _line.Maxrange = 300; break; case "P_MANIFOLD": case "P_MANIFOLD10": case "REGL_TRYCK": case "MAX_TRYCK": _line.Minrange = -1; _line.Maxrange = 2; break; case "LUFTTEMP": _line.Minrange = -30; _line.Maxrange = 120; break; case "KYL_TEMP": _line.Minrange = -30; _line.Maxrange = 120; break; case "INSPTID_MS10": _line.Minrange = 0; _line.Maxrange = 50; break; case "GEAR": _line.Minrange = -1; _line.Maxrange = 5; break; case "APC_DECRESE": case "APC_DECREASE": _line.Minrange = 0; _line.Maxrange = 200; break; case "IGN_ANGLE": _line.Minrange = -10; _line.Maxrange = 50; break; case "PWM_UT10": case "REG_KON_APC": _line.Minrange = 0; _line.Maxrange = 100; break; case "MODELTROT": case "TROT_MIN": _line.Minrange = 0; _line.Maxrange = 255; break; } }