/// <summary> /// Constructor creates a GraphDisplay with parent's choice of GraphType. /// </summary> /// <param name="DefaultGraphType">The GraphMode to use by default.</param> public GraphDisplay(GraphMode DefaultGraphType) { // This call is required by the Windows.Forms Form Designer. InitializeComponent(); this.GraphType = DefaultGraphType; }
private string GetConditionDetails(GraphMode mode, float altitude, float speed, float aoa, bool setAoA) { switch (mode) { case GraphMode.FlightEnvelope: EnvelopeSurf.EnvelopePoint conditionPtFE = new EnvelopeSurf.EnvelopePoint(this.vessel, this.body, altitude, speed, 0); if (setAoA) { this.AoA = conditionPtFE.AoA_level; } return(conditionPtFE.ToString()); case GraphMode.AoACurves: AoACurve.AoAPoint conditionPtAoA = new AoACurve.AoAPoint(this.vessel, this.body, altitude, speed, aoa); return(conditionPtAoA.ToString()); case GraphMode.VelocityCurves: VelCurve.VelPoint conditionPtVel = new VelCurve.VelPoint(this.vessel, this.body, altitude, speed); if (setAoA) { this.AoA = conditionPtVel.AoA_level; } return(conditionPtVel.ToString()); default: return(""); } }
/// <summary>根据画图模式和数据调整坐标显示 /// </summary> public void UpdateDisplayRect(DataRect initialRect, GraphMode graphStyle) { if (DataLists.HasData()) { if (graphStyle == GraphMode.GlobalMode) { DisplayRect.XMin = (DataLists.MinX < initialRect.XMin) ? DataLists.MinX : initialRect.XMin; DisplayRect.XMax = (DataLists.MaxX > initialRect.XMax) ? DataLists.MaxX : initialRect.XMax; DisplayRect.YMin = (DataLists.MinY < initialRect.YMin) ? DataLists.MinY : initialRect.YMin; DisplayRect.YMax = (DataLists.MaxY > initialRect.YMax) ? DataLists.MaxY : initialRect.YMax; } else if (graphStyle == GraphMode.FixMoveMode) { if (DataLists.MaxX > DisplayRect.XMax) { DisplayRect.XMin += DataLists.MaxX - DisplayRect.XMax; DisplayRect.XMax = DataLists.MaxX; } DisplayRect.YMin = (DataLists.MinY < DisplayRect.YMin) ? DataLists.MinY : DisplayRect.YMin; DisplayRect.YMax = (DataLists.MaxY > DisplayRect.YMax) ? DataLists.MaxY : DisplayRect.YMax; } } else { DisplayRect.UpdateRect(initialRect); } }
public IGraphHandle StartGraph(GraphMode graphMode, bool strict) { _graphMode = graphMode; if (_subGraphs.Count != 0) { throw new InvalidOperationException(); } string line = ""; if (strict) { line += "strict "; } line += graphMode == GraphMode.Graph ? "graph" : "digraph"; line += " \"\" {"; Line(line); GraphHandle g = new GraphHandle(this); _subGraphs.Push(g); return(g); }
private void DrawGraph(GraphMode graphMode) { if (graphDirty) { if (this.vessel == null) { this.vessel = VesselCache.SimulatedVessel.Borrow(EditorLogic.fetch.ship, VesselCache.SimCurves.Borrow(body)); } if (!graphRequested) { switch (graphMode) { case GraphMode.FlightEnvelope: EnvelopeSurfGenerator.Calculate(vessel, body, 0, maxSpeed, speedStep, 0, maxAltitude, altitudeStep); break; case GraphMode.AoACurves: AoACurveGenerator.Calculate(vessel, body, Altitude, Speed, -20f * Mathf.Deg2Rad, 20f * Mathf.Deg2Rad, 0.5f * Mathf.Deg2Rad); break; case GraphMode.VelocityCurves: VelCurveGenerator.Calculate(vessel, body, Altitude, 0, maxSpeed, speedStep); break; } graphRequested = true; } switch (GraphGenerator.Status) { case CalculationManager.RunStatus.PreStart: case CalculationManager.RunStatus.Cancelled: case CalculationManager.RunStatus.Running: DrawProgressBar(GraphGenerator.PercentComplete); break; case CalculationManager.RunStatus.Completed: grapher.SetCollection(GraphGenerator.Graphables); DrawGraph(); graphDirty = false; break; } if (selectedCrossHairVect.x >= 0 && selectedCrossHairVect.y >= 0) { selectedCrossHairVect = CrossHairsFromConditions(Altitude, Speed, AoA); SetConditionsFromGraph(selectedCrossHairVect); conditionDetails = GetConditionDetails(CurrentGraphMode, this.Altitude, this.Speed, CurrentGraphMode == GraphMode.AoACurves ? this.AoA : float.NaN, false); } else { conditionDetails = ""; } } else { DrawGraph(); } }
static Vector3 Sine2DFunction(float x, float z, float t) { _newMode = GraphMode.Mode2D; float y = Mathf.Sin(PI * (x + t)); y += Mathf.Sin(PI * (z + t)); y *= 0.5f; return(new Vector3(x, y, z)); }
public void SetMode(GraphMode mode, int sensitivity) { expPlotter.GraphMode = mode; if (mode == GraphMode.Polar) { expPlotter.PolarSensitivity = sensitivity; this.lblSensitivity.Text = "Polar sensitivity: " + expPlotter.PolarSensitivity; } }
static Vector3 Ripple(float x, float z, float t) { _newMode = GraphMode.Mode2D; float d = Mathf.Sqrt(x * x + z * z); // square root 平方根 float y = Mathf.Sin(PI * (4f * d - t)); y /= 1f + 10f * d; return(new Vector3(x, y, z)); }
//能用乘法就不要用除法, 乘法效率比除法高 static Vector3 MultiSineFunction(float x, float z, float t) { _newMode = GraphMode.Mode1D; float y = Mathf.Sin(PI * (x + t)); y += Mathf.Sin(2f * PI * (x + t)); y *= 0.5f; return(new Vector3(x, y, z)); }
static Vector3 MultiSine2DFunction(float x, float z, float t) { _newMode = GraphMode.Mode2D; float y = 4f * Mathf.Sin(PI * (x + z + t * 0.5f)); y += Mathf.Sin(PI * (x + t)); y += Mathf.Sin(2f * PI * (z + 2f * t)) * 0.5f; y *= 1f / 5.5f; return(new Vector3(x, y, z)); }
//Although the SineFunction and MultiSineFunction are part of Graph, //they are effectively self-contained. //Because static methods aren't associated with object instances, //the compiled code doesn't have to keep track of //which object you're invoking the method on. //This means that static method invocations are a bit faster, //but it's usually not significant enough to worry about. static Vector3 SineFunction(float x, float z, float t) { _newMode = GraphMode.Mode1D; Vector3 p; p.x = x; p.y = Mathf.Sin(PI * (x + t)); p.z = z; return(p); }
static Vector3 Cylinder(float u, float v, float t) { _newMode = GraphMode.Mode2D; float r = 0.8f + Mathf.Sin(PI * (6f * u + 2f * v + t)) * 0.2f; Vector3 p; p.x = r * Mathf.Sin(PI * u); p.y = v; p.z = r * Mathf.Cos(PI * u); return(p); }
static Vector3 Sphere(float u, float v, float t) { _newMode = GraphMode.Mode2D; Vector3 p; float r = Time.time % 5; float s = r * Mathf.Cos(PI * 0.5f * v); p.x = s * Mathf.Sin(PI * u); p.y = r * Mathf.Sin(PI * 0.5f * v); p.z = s * Mathf.Cos(PI * u); return(p); }
static Vector3 Torus(float u, float v, float t) { _newMode = GraphMode.Mode2D; Vector3 p; float r1 = 1f; float r2 = 0.5f; float s = r2 * Mathf.Cos(PI * v) + r1; p.x = s * Mathf.Sin(PI * u); p.y = r2 * Mathf.Sin(PI * v); p.z = s * Mathf.Cos(PI * u); return(p); }
private void CalculateGraphPoints(GraphMode mode, double X, double Y, double zoomFactor, Int64 timeStepMS) { _points.Clear(); Int64 totalTimeMS = 0; Int64 numSteps = FASTBuildMonitorControl.GetCurrentBuildTimeMS() / ((Int64)timeStepMS); Int64 remainder = FASTBuildMonitorControl.GetCurrentBuildTimeMS() % ((Int64)timeStepMS); numSteps += remainder > 0 ? 2 : 1; Int64 timeLimitMS = numSteps * (Int64)timeStepMS; float verticalPixPerUnit = cSystemGraphsHeight / Math.Max(_maxValue, 0.00001f); int samplesIndex = 0; while (totalTimeMS <= timeLimitMS && samplesIndex < _samples.Count) { int subStepSamplesCount = 0; float subStepAvgValue = 0.0f; while (samplesIndex < _samples.Count && _samples[samplesIndex]._time <= (totalTimeMS + timeStepMS)) { subStepAvgValue += _samples[samplesIndex]._value; samplesIndex++; subStepSamplesCount++; // validation code to make sure times are monotonic if (samplesIndex + 1 < _samples.Count) { Debug.Assert(_samples[samplesIndex + 1]._time >= _samples[samplesIndex]._time); } } if (subStepSamplesCount > 0) { subStepAvgValue = subStepAvgValue / (float)subStepSamplesCount; double x = X + zoomFactor * FASTBuildMonitorControl.pix_per_second * (totalTimeMS + timeStepMS) / 1000.0f; double y = cSystemGraphsHeight - (subStepAvgValue * verticalPixPerUnit); y = Math.Max(0.0f, y); _points.Add(new GraphPoint(new Point(x, y), subStepAvgValue)); } totalTimeMS += timeStepMS; } }
private void toolStripModeButton1_Click(object sender, EventArgs e) { if (mode == GraphMode.MODE_BY_EXPIRATION) { mode = GraphMode.MODE_BY_STRIKE; toolStripModeButton1.Text = "By Strike"; } else { mode = GraphMode.MODE_BY_EXPIRATION; toolStripModeButton1.Text = "By Expiration"; } // update graph based on new mode UpdatePutCallRatioGraphCurves(); }
private void comboBoxMode_SelectedIndexChanged(object sender, EventArgs e) { if (comboBoxMode.SelectedIndex == 0) { CurrentMode = GraphMode.Both; } if (comboBoxMode.SelectedIndex == 1) { CurrentMode = GraphMode.Auto; } if (comboBoxMode.SelectedIndex == 2) { CurrentMode = GraphMode.Tele; } PlotMatches(); }
bool IsGraphMode(GraphMode mode, params GraphMode[] modes) { if (m_graphMode == mode) { return(true); } for (int i = 0; i < modes.Length; i++) { if (modes[i] == m_graphMode) { return(true); } } return(false); }
public void ResetToVerify() { graphMode = GraphMode.Verify; speedSeries.Points.Clear(); progressOverlay.MaximumX = -1; currentMaximum = 100; yAxis.Maximum = currentMaximum; yAxis.MajorStep = currentMaximum / 5; speedLine.Text = ""; speedLine.Y = -10; speedSeries.Fill = OxyColor.FromRgb(176, 152, 0); speedSeries.Color = OxyColor.FromRgb(176, 152, 0); progressOverlay.Fill = OxyColor.FromArgb(96, 241, 220, 0); UpdateColorsInternal(); Model.InvalidatePlot(true); firsCall = true; }
public static void WriteXml(XmlWriter writer, Action writeNodes, Action writeEdges, GraphMode mode = GraphMode.Static, GraphDefaultEdgeType defaultEdgeType = GraphDefaultEdgeType.Directed) { writer.WriteStartElement(ElementName); writer.WriteAttributeString(ModeAttributeName, mode.ToString().ToLower()); writer.WriteAttributeString(DefaultEdgeTypeAttributeName, defaultEdgeType.ToString().ToLower()); writer.WriteStartElement(NodesElementName); writeNodes(); writer.WriteEndElement(); writer.WriteStartElement(EdgesElementName); writeEdges(); writer.WriteEndElement(); writer.WriteEndElement(); }
private void SpawnPoints() { if (_curXResolusion != resolusion || _curXRange != xRange || _curMode != _newMode) { _curMode = _newMode; _curZResolusion = _curMode == GraphMode.Mode1D ? 1 : resolusion; _curXResolusion = resolusion; _curXRange = xRange; foreach (var points in _points) { foreach (var point in points) { Destroy(point.gameObject); } } _points = new List <List <Transform> >(); Vector3 scale = Vector3.one * 0.2f; Vector3 position = Vector3.zero; for (int z = 0; z < _curZResolusion; z++) { var points = new List <Transform>(); //List.2 for (int x = 0; x < resolusion; x++) { Transform point = Instantiate(pointPrefab, transform); point.localScale = scale; points.Add(point); //List.3 //定义x轴 [0, resolution] -> [-xRange, xRange] position.x = ((x + 1.0f) * xRange * 2 / resolusion - xRange); position.z = ((z + 1.0f) * xRange * 2 / resolusion - xRange); point.localPosition = position; //var pos = position.x/(xRange*2)+0.5f; //point.GetComponent<MeshRenderer>().material.color = new Color(pos, pos, pos); } _points.Add(points); //List.4 } } }
/// <summary> /// Gets the points for the boss dps graph for a given player /// </summary> /// <param name="p">The player</param> /// <returns></returns> public static List <Point> getBossDPSGraph(ParsedLog log, AbstractPlayer p, int phase_index, GraphMode mode) { return(getDPSGraph(log, p, phase_index, log.getBossData().getInstid(), mode)); }
public void UpdateGraph(ZedGraphControl graph, int index, double x, double y, GraphMode mode, double paneWidth = 5.0) { GraphPane pane = graph.GraphPane; if (pane.CurveList.Count <= index) { return; } LineItem line = pane.CurveList[index] as LineItem; if (line == null) { return; } IPointListEdit point_list = line.Points as IPointListEdit; point_list.Add(x, y); Scale xScale = pane.XAxis.Scale; Scale yScale = pane.YAxis.Scale; switch (mode) { case GraphMode.Follow: if (x > xScale.Max - xScale.MajorStep) { xScale.Max = x + xScale.MajorStep; xScale.Min = xScale.Max - paneWidth; } if (y < yScale.Min + yScale.MajorStep) { yScale.Min = y - yScale.MajorStep; } if (y > yScale.Max - yScale.MajorStep) { yScale.Max = y + yScale.MajorStep; } DrawGraph(graph); break; case GraphMode.AutoScale: if (x < xScale.Min + xScale.MajorStep) { xScale.Min = x - xScale.MajorStep; } if (x > xScale.Max - xScale.MajorStep) { xScale.Max = x + xScale.MajorStep; } if (y < yScale.Min + yScale.MajorStep) { yScale.Min = y - yScale.MajorStep; } if (y > yScale.Max - yScale.MajorStep) { yScale.Max = y + yScale.MajorStep; } DrawGraph(graph); break; case GraphMode.Hold: break; } }
public void GraphModeChanged(GraphMode mode) { GraphMode = mode; NewEdge = new NewEdge(); StartAlgorithm = new StartAlgorithm(); }
private void SetGraphMode(GraphMode mode) { m_mode = mode; }
/// <summary> /// Load the given controller and create all necessary objects. /// </summary> void LoadControllerInternal(AIController newController, AIBehaviour newAIBehaviour = null, bool forceLoad = false) { if (!forceLoad) { if (controller == newController && aiBehaviour == newAIBehaviour) { return; } } controller = newController; aiBehaviour = newAIBehaviour; if (newController != null) { m_exposedParameterList = new ParameterList <ExposedParameter> (GetExposedParameters, m_canvas, Repaint); m_exposedParameterList.onParameterAddClicked += CreateExposedParameter; m_exposedParameterList.onParameterRemovedClicked += RemoveExposedParameter; m_exposedParameterList.onChangeParameterIndex += ChangeExposedParameterIndex; m_exposedParameterList.onChangeParameterName += ChangeExposedParameterName; m_nodeParameterList = new ParameterList <NodeParameter> (GetNodeParameters, m_canvas, Repaint); m_nodeParameterList.onParameterAddClicked += CreateNodeParameter; m_nodeParameterList.onParameterRemovedClicked += RemoveNodeParameter; m_nodeParameterList.onChangeParameterIndex += ChangeNodeParameterIndex; m_nodeParameterList.onChangeParameterName += ChangeNodeParameterName; if (controller.isCopy) { ShowNotification(new GUIContent("AIController changes will not be saved")); } #if GRAPH_DEBUG Debug.Log("[AI Graph]: Controller loaded (" + controller.name + ") AIBehaviour (" + aiBehaviour + ")"); #endif } else { aiBehaviour = null; controller = null; m_exposedParameterList = null; m_nodeParameterList = null; #if GRAPH_DEBUG Debug.Log("[AI Graph]: Controller loaded (null) AIBehaviour (null)"); #endif } onControllerChanged?.Invoke(newController, newAIBehaviour); GraphMode oldGraphMode = m_graphMode; if (controller == null) { m_graphMode = GraphMode.NoController; } else if (controller.isCopy) { if (aiBehaviour == null) { m_graphMode = GraphMode.RuntimeController; } else { m_graphMode = GraphMode.RuntimeControllerAndAiBehaviour; } } else { if (aiBehaviour == null) { m_graphMode = GraphMode.AssetController; } else { m_graphMode = GraphMode.AssetControllerAndAiBehaviour; } } if (m_graphMode != oldGraphMode) { onGraphModeChanged?.Invoke(m_graphMode); } }
/// <summary> /// Gets the points for the cleave dps graph for a given player /// </summary> /// <param name="log"></param> /// <param name="p"></param> /// <param name="phaseIndex"></param> /// <param name="phase"></param> /// <param name="mode"></param> /// <returns></returns> public static List <Point> GetCleaveDPSGraph(ParsedLog log, AbstractMasterPlayer p, int phaseIndex, PhaseData phase, GraphMode mode, Boss boss) { int askedId = (phaseIndex + "_" + (-1) + "_" + mode).GetHashCode(); if (p.GetDPSGraph(askedId).Count > 0) { return(p.GetDPSGraph(askedId)); } List <Point> totalPoints = GetTotalDPSGraph(log, p, phaseIndex, phase, mode); List <Point> bossPoints = GetBossDPSGraph(log, p, phaseIndex, phase, mode, boss); List <Point> cleavePoints = new List <Point>(); for (int i = 0; i < bossPoints.Count; i++) { cleavePoints.Add(new Point(bossPoints[i].X, totalPoints[i].Y - bossPoints[i].Y)); } p.DpsGraph[askedId] = cleavePoints; return(cleavePoints); }
private static List <Point> GetDPSGraph(ParsedLog log, AbstractMasterPlayer p, int phaseIndex, PhaseData phase, AbstractPlayer target, GraphMode mode) { ulong targetId = target != null ? target.Agent : 0; int askedId = (phaseIndex + "_" + targetId + "_" + mode).GetHashCode(); if (p.GetDPSGraph(askedId).Count > 0) { return(p.GetDPSGraph(askedId)); } List <Point> dmgList = new List <Point>(); List <Point> dmgList1s = new List <Point>(); List <Point> dmgList10s = new List <Point>(); List <Point> dmgList30s = new List <Point>(); List <DamageLog> damageLogs = p.GetDamageLogs(target, log, phase.Start, phase.End); // fill the graph, full precision List <double> dmgListFull = new List <double>(); for (int i = 0; i <= phase.GetDuration(); i++) { dmgListFull.Add(0.0); } int totalTime = 1; int totalDamage = 0; foreach (DamageLog dl in damageLogs) { int time = (int)(dl.Time - phase.Start); // fill for (; totalTime < time; totalTime++) { dmgListFull[totalTime] = totalDamage; } totalDamage += dl.Damage; dmgListFull[totalTime] = totalDamage; } // fill for (; totalTime <= phase.GetDuration(); totalTime++) { dmgListFull[totalTime] = totalDamage; } /*CombatReplay replay = p.Replay; * if (replay != null && dstid == 0 && phaseIndex == 0) * { * foreach (int i in replay.GetTimes()) * { * int limitId = 0; * replay.AddDPS((int)Math.Round(1000 * (dmgListFull[i] - dmgListFull[limitId]) / (i - limitId))); * if (Settings.Show10s) * { * limitId = Math.Max(i - 10000, 0); * replay.AddDPS10s((int)Math.Round(1000 * (dmgListFull[i] - dmgListFull[limitId]) / (i - limitId))); * } * if (Settings.Show30s) * { * limitId = Math.Max(i - 30000, 0); * replay.AddDPS30s((int)Math.Round(1000 * (dmgListFull[i] - dmgListFull[limitId]) / (i - limitId))); * } * } * }*/ dmgList.Add(new Point(0, 0)); dmgList1s.Add(new Point(0, 0)); dmgList10s.Add(new Point(0, 0)); dmgList30s.Add(new Point(0, 0)); for (int i = 1; i <= phase.GetDuration("s"); i++) { int limitId = 0; dmgList.Add(new Point(i, (int)Math.Round((dmgListFull[1000 * i] - dmgListFull[1000 * limitId]) / (i - limitId)))); limitId = i - 1; dmgList1s.Add(new Point(i, (int)Math.Round((dmgListFull[1000 * i] - dmgListFull[1000 * limitId]) / (i - limitId)))); if (Settings.Show10s) { limitId = Math.Max(i - 10, 0); dmgList10s.Add(new Point(i, (int)Math.Round((dmgListFull[1000 * i] - dmgListFull[1000 * limitId]) / (i - limitId)))); } if (Settings.Show30s) { limitId = Math.Max(i - 30, 0); dmgList30s.Add(new Point(i, (int)Math.Round((dmgListFull[1000 * i] - dmgListFull[1000 * limitId]) / (i - limitId)))); } } int id = (phaseIndex + "_" + targetId + "_" + GraphMode.Full).GetHashCode(); p.DpsGraph[id] = dmgList; id = (phaseIndex + "_" + targetId + "_" + GraphMode.S1).GetHashCode(); p.DpsGraph[id] = dmgList1s; if (Settings.Show10s) { id = (phaseIndex + "_" + targetId + "_" + GraphMode.S10).GetHashCode(); p.DpsGraph[id] = dmgList10s; } if (Settings.Show30s) { id = (phaseIndex + "_" + targetId + "_" + GraphMode.S30).GetHashCode(); p.DpsGraph[id] = dmgList30s; } return(p.GetDPSGraph(askedId)); }
/// <summary> /// Gets the points for the total dps graph for a given player /// </summary> /// <param name="log"></param> /// <param name="p"></param> /// <param name="phaseIndex"></param> /// <param name="phase"></param> /// <param name="mode"></param> /// <returns></returns> public static List <Point> GetTotalDPSGraph(ParsedLog log, AbstractMasterPlayer p, int phaseIndex, PhaseData phase, GraphMode mode) { return(GetDPSGraph(log, p, phaseIndex, phase, null, mode)); }
/// <summary> /// Gets the points for the boss dps graph for a given player /// </summary> /// <param name="log"></param> /// <param name="p"></param> /// <param name="phaseIndex"></param> /// <param name="phase"></param> /// <param name="mode"></param> /// <returns></returns> public static List <Point> GetBossDPSGraph(ParsedLog log, AbstractMasterPlayer p, int phaseIndex, PhaseData phase, GraphMode mode, Boss boss) { return(GetDPSGraph(log, p, phaseIndex, phase, boss, mode)); }
public void SetGraphMode(GraphMode mode) => Synchronize("setGraphMode", (int)mode);