/// <summary> /// This method marks the point specified in the parameters /// </summary> /// <param name="g">Graphics context to use</param> /// <param name="typeVar">The type of point to plot</param> /// <param name="startPoint">The start point of the value to plot</param> /// <param name="valueToPlot">The offset of the value to plot</param> /// <param name="sliceCount"></param> /// <param name="organToPlot"></param> private static void MarkPoint(Graphics g, PlotPoint plotPoint) { // Create the rectangle that marks the point g.FillRectangle(plotPoint.Brush, new Rectangle(plotPoint.Point.X - (SQUARE_SIZE / 2), plotPoint.Point.Y - (SQUARE_SIZE / 2), SQUARE_SIZE, SQUARE_SIZE)); var organSystemFont = new Font(FontFamily.GenericSansSerif, 8, FontStyle.Regular); if (plotPoint.OrganText != null) { g.DrawLine(Pens.LightGray, plotPoint.StartPoint, plotPoint.TextPoint); var sizeContainer = g.MeasureString(plotPoint.OrganText, organSystemFont); g.DrawString(plotPoint.OrganText, organSystemFont, Brushes.Black, plotPoint.TextPoint.X - (sizeContainer.Width / 2), plotPoint.TextPoint.Y - (sizeContainer.Height / 2)); } var plotValueSizeContainer = g.MeasureString(plotPoint.Value.ToString("F2"), organSystemFont); if (plotPoint.Brush.Color == UnFilteredColor) { g.DrawString(plotPoint.Value.ToString("F2"), organSystemFont, plotPoint.Brush, plotPoint.TextPoint.X - (plotValueSizeContainer.Width / 2), plotPoint.TextPoint.Y - (plotValueSizeContainer.Height / 2) - plotValueSizeContainer.Height); } else { g.DrawString(plotPoint.Value.ToString("F2"), organSystemFont, plotPoint.Brush, plotPoint.TextPoint.X - (plotValueSizeContainer.Width / 2), plotPoint.TextPoint.Y + (plotValueSizeContainer.Height / 2)); } organSystemFont.Dispose(); }
private List <Parcel> get_list_containing(Parcel p) { List <Parcel> parcels; if (Session.Project.TreasureParcels.Contains(p)) { return(Session.Project.TreasureParcels); } List <PlotPoint> .Enumerator enumerator = Session.Project.AllPlotPoints.GetEnumerator(); try { while (enumerator.MoveNext()) { PlotPoint current = enumerator.Current; if (!current.Parcels.Contains(p)) { continue; } parcels = current.Parcels; return(parcels); } return(null); } finally { ((IDisposable)enumerator).Dispose(); } }
public void ShowPlotPoint(PlotPoint pp) { string str = HTML.Text(pp.ReadAloud, false, false, PlayerViewForm.DisplaySize); this.set_html(str); base.Show(); }
public static int GetPartyLevel(PlotPoint pp) { int total_xp = GetTotalXP(pp); int xp_per_player = total_xp / Session.Project.Party.Size; return(Experience.GetHeroLevel(xp_per_player)); }
void autobuild_delve(bool advanced) { AutoBuildData data = null; if (advanced) { AutoBuildForm dlg = new AutoBuildForm(AutoBuildForm.Mode.Delve); if (dlg.ShowDialog() == DialogResult.OK) { data = dlg.Data; } else { return; } } else { data = new AutoBuildData(); } PlotPoint pp = DelveBuilder.AutoBuild(SelectedMap, data); Session.Project.Plot.Points.Add(pp); Session.Modified = true; Close(); }
public static int GetTotalXP(PlotPoint pp) { int xP = Session.Project.Party.XP * Session.Project.Party.Size; do { Plot plot = Session.Project.FindParent(pp); if (plot == null) { break; } foreach (List <PlotPoint> plotPoints in Workspace.FindLayers(plot)) { bool flag = false; foreach (PlotPoint plotPoint in plotPoints) { if (plotPoint.ID != pp.ID) { continue; } flag = true; break; } if (flag) { break; } xP += Workspace.GetLayerXP(plotPoints); } pp = Session.Project.FindParent(plot); }while (pp != null); return(xP); }
public static int GetPartyLevel(PlotPoint pp) { int totalXP = Workspace.GetTotalXP(pp); int size = totalXP / Session.Project.Party.Size; return(Experience.GetHeroLevel(size)); }
private TimeSeriesGraph CreateSineGraph() { TimeSeriesGraph graph = new TimeSeriesGraph(); string sineString = SineData.ToString(); DataParser parser = new DataParser(sineString); List <float> x1 = parser.GetListFromColumn(0); List <float> y1 = parser.GetListFromColumn(1); List <float> z1 = parser.GetListFromColumn(2); List <float> x2 = parser.GetListFromColumn(3); List <float> y2 = parser.GetListFromColumn(4); List <float> z2 = parser.GetListFromColumn(5); List <float> x3 = parser.GetListFromColumn(6); List <float> y3 = parser.GetListFromColumn(7); List <float> z3 = parser.GetListFromColumn(8); PlotPoint new_point = new PlotPoint(x1, y1, z1); graph.AddPlotPoint(new_point); new_point = new PlotPoint(x2, y2, z2); graph.AddPlotPoint(new_point); new_point = new PlotPoint(x3, y3, z3); graph.AddPlotPoint(new_point); return(graph); }
/* * Temporary method to use CSV parsing when creating graph */ private void CreateTimeSeriesGraphUsingCSV() { var csvString = DataFile1.ToString(); // Convert CSV to String for easier use DataParser parser = new DataParser(csvString); // Create PlotPoint object using data from CSV List <float> x_values = parser.GetListFromColumn(0); // Grab values from first column List <float> y_values = parser.GetListFromColumn(1); List <float> z_values = parser.GetListFromColumn(2); PlotPoint new_point = new PlotPoint(x_values, y_values, z_values); // Create empty Graph object and give it plot points Graph = new TimeSeriesGraph(); Graph.AddPlotPoint(new_point); csvString = DataFile2.ToString(); parser = new DataParser(csvString); x_values = parser.GetListFromColumn(0); y_values = parser.GetListFromColumn(1); z_values = parser.GetListFromColumn(2); new_point = new PlotPoint(x_values, y_values, z_values); // Create empty Graph object and give it plot points Graph.AddPlotPoint(new_point); }
private void UpdatePoint(Transform point, int index) { Vector3 updated_position; PlotPoint pointFromGraph = Graph.PlotPoints[index]; int currentIndex = pointFromGraph.currentPointIndex; // Get bounds of BoxCollider to help with normalizing plot point Vector3 max_range = GraphRadius; Vector3 min_range = -GraphRadius; //Debug.Log("max range: " + max_range + " min range: " + min_range); if (currentIndex < pointFromGraph.XPoints.Count) { updated_position.x = NormalizeToRange(min_range.x, max_range.x, pointFromGraph.XPoints[currentIndex], GraphXMax, GraphXMin); updated_position.y = NormalizeToRange(min_range.y, max_range.y, pointFromGraph.YPoints[currentIndex], GraphYMax, GraphYMin); updated_position.z = NormalizeToRange(min_range.z, max_range.z, pointFromGraph.ZPoints[currentIndex], GraphZMax, GraphZMin); Debug.Log(updated_position.ToString("F4")); point.localPosition = updated_position; if (Graph.isTimeGraph()) { UpdateTime(currentIndex); } pointFromGraph.currentPointIndex++; } else { pointFromGraph.currentPointIndex = 0; } }
public void AddPlotPoint(PlotPoint point) { PlotPoints.Add(point); CalculateMaxPoints(); CalculateMinPoints(); CalculateMidPoints(); }
public void ShowPlotPoint(PlotPoint pp) { string html = HTML.Text(pp.ReadAloud, false, false, Session.Preferences.PlayerViewTextSize); set_html(html); Show(); }
public void GenerateVisualiserFromSamples(FrequencyBand[] frequencyBands, float _songTime) { for (int i = 0; i < 4; i++) { FrequencyBandVisualisers[i].seperator.gameObject.SetActive(i < frequencyBands.Length); } for (int b = 0; b < frequencyBands.Length; b++) { FrequencyBand band = frequencyBands[b]; FrequencyBandVisualisers[b].parent.position = new Vector3(0f, 0f, 0f); previousPlotTransform = null; foreach (Transform child in FrequencyBandVisualisers[b].parent) { GameObject.Destroy(child.gameObject); } for (int i = 0; i < band.spectralFluxSamples.Count; i++) { SpectralFluxData sample = band.spectralFluxSamples[i]; PlotPoint spectralPoint = Instantiate(plotPoint, new Vector2(i * spacingBetweenSamples, sample.spectralFlux * FrequencyBandVisualisers[b].heightMultiplier), Quaternion.identity, FrequencyBandVisualisers[b].parent); spectralPoint.spriteRenderer.color = sample.isOnset ? peakColor : plotColor; if (previousPlotTransform != null) { spectralPoint.connectingPlotTransform = previousPlotTransform; } previousPlotTransform = spectralPoint.transform; } float screenHeight = 12.6f; float distanceBetweenBands = screenHeight / frequencyBands.Length; float offsetSpace = distanceBetweenBands * bandOffsetMultiplier; float initialOffset = (screenHeight / 2) - distanceBetweenBands + offsetSpace; FrequencyBandVisualisers[b].parent.position = new Vector3(0f, initialOffset - (distanceBetweenBands * b), 0f); Vector2 anchorMin = FrequencyBandVisualisers[b].seperator.anchorMin; Vector2 anchorMax = FrequencyBandVisualisers[b].seperator.anchorMax; anchorMin.Set(anchorMin.x, (b) * (1f / frequencyBands.Length)); anchorMax.Set(anchorMax.x, (b + 1f) * (1f / frequencyBands.Length)); FrequencyBandVisualisers[b].seperator.anchorMin = anchorMin; FrequencyBandVisualisers[b].seperator.anchorMax = anchorMax; } levelLength = (frequencyBands[0].spectralFluxSamples.Count * spacingBetweenSamples); songTime = _songTime; }
public void PlotMVF(SRMData data, double tmax = 1.5) { if (data != null) { mvf = srm.MvfData(PlotPoint.MakeSeq(0, data.TotalTime * tmax)); } else { mvf = null; } }
/// <summary> /// Queries the average rate of change of the graph. /// </summary> /// <returns>The average rate of change.</returns> /// <param name="window">Window.</param> /// <param name="timeUnit">The unit of time for this rate of change.</param> public ScalarSpan GetPrimaryAverageRateOfChange() { TrimRoc(); var p = new PlotPoint[rocBuffer.count]; var su = sensor.unit.standardUnit; var cnt = rocBuffer.ToArray(p); if (cnt <= 2) { return(su.OfSpan(0)); } return(CalculateExponetialWeightedMovingAverage(p)); }
public void Stream(int[] data) { // We add the new values for (int i = 0; i < data.Length; ++i) { if (data[i] < _resolution.y) // cheap high-pass filter { _rawData.Add(data[i]); } } // smoothing signal by averaging int diff = (_rawData.Count - _lastProcessed) - _averageWindowSize / 2; for (int j = 0; j < diff; ++j) { float total = 0; for (int i = -_averageWindowSize / 2; i < _averageWindowSize / 2; ++i) { total += _rawData[_lastProcessed + i]; } _lastProcessed++; PlotPoint p = new PlotPoint(); p.point = total / _averageWindowSize; p.peak = 1; _data.Add(p); } // We delete values outside the window int extraElements = _data.Count - (int)_resolution.x; if (extraElements > 0) { _data.RemoveRange(0, extraElements); _lastIndex -= extraElements; _lastPeak -= extraElements; } extraElements = _rawData.Count - (int)_resolution.x; if (extraElements > 0) { _rawData.RemoveRange(0, extraElements); _lastProcessed -= extraElements; } _redraw = true; }
public PlotPointForm(PlotPoint pp, Plot p, bool start_at_element_page) { InitializeComponent(); Application.Idle += new EventHandler(Application_Idle); ParcelList_SizeChanged(null, null); LinkList_SizeChanged(null, null); EncBrowser.DocumentText = ""; fPoint = pp.Copy(); fPlot = p; fStartAtElement = start_at_element_page; NameBox.Text = fPoint.Name; DetailsBox.Text = fPoint.Details; ReadAloudBox.Text = fPoint.ReadAloud; XPBox.Value = fPoint.AdditionalXP; if (fPlot.FindPoint(fPoint.ID) != null) { StartXPLbl.Text = "Start at: " + Workspace.GetTotalXP(fPoint) + " XP"; } else { StartXPLbl.Visible = false; XPSeparator.Visible = false; } update_element(); update_parcels(); update_encyclopedia_entries(); update_links(); if (Session.Project.Encyclopedia.Entries.Count == 0) { Pages.TabPages.Remove(EncyclopediaPage); } else { EncyclopediaList_SelectedIndexChanged(null, null); } if (start_at_element_page) { Pages.SelectedTab = RPGPage; } }
private int add_nodes(TreeNodeCollection tnc, Plot p) { int num = 1; PlotPoint plotPoint = Session.Project.FindParent(p); TreeNode treeNode = tnc.Add((plotPoint != null ? plotPoint.Name : Session.Project.Name)); treeNode.Tag = p; foreach (PlotPoint point in p.Points) { if (point.Subplot.Points.Count == 0) { continue; } num += this.add_nodes(treeNode.Nodes, point.Subplot); } return(num); }
// Process Data to detect Breaths using raw or smoothed data private void ProcessData() { int diff = (_data.Count - _lastIndex) - _averageWindowSize / 2; while (diff > 0) { diff--; // Improvement: look at derivate sign // simple Gaussian peak detection // can be optimized by reusing sums using a queue/list if (_lastIndex - _lastPeak > _peakDistance) { float prev = 0; float post = 0; for (int j = 0; j + 1 < _averageWindowSize / 2; ++j) { prev += (_data[_lastIndex - j].point - _data[_lastIndex - j - 1].point); post += (_data[_lastIndex + j + 1].point - _data[_lastIndex + j].point); } if (prev > 0 && post < 0) { PlotPoint point = _data[_lastIndex]; point.peak = 0; _data[_lastIndex] = point; _lastPeak = _lastIndex; _numPeaks++; if (listener != null) { listener(); } Debug.Log("UPPER PEAK"); } else if (prev < 0 && post > 0) { PlotPoint point = _data[_lastIndex]; point.peak = 100; _lastPeak = _lastIndex; _data[_lastIndex] = point; Debug.Log("DOWN PEAK"); } } _lastIndex++; } }
public static int GetTotalXP(PlotPoint pp) { int xp = Session.Project.Party.XP * Session.Project.Party.Size; while (true) { // Add the XP value for all previous plot points in this plot Plot plot = Session.Project.FindParent(pp); if (plot == null) { break; } List <List <PlotPoint> > layers = FindLayers(plot); foreach (List <PlotPoint> layer in layers) { bool in_layer = false; foreach (PlotPoint point in layer) { if (point.ID == pp.ID) { in_layer = true; break; } } if (in_layer) { break; } int layer_xp = GetLayerXP(layer); xp += layer_xp; } pp = Session.Project.FindParent(plot); if (pp == null) { break; } } return(xp); }
private static void add_points(Plot plot, List <Goal> goals, Dictionary <Guid, Pair <PlotPoint, PlotPoint> > map) { foreach (Goal goal in goals) { PlotPoint plotPoint = new PlotPoint(string.Concat("Discover: ", goal.Name)) { Details = goal.Details }; PlotPoint plotPoint1 = new PlotPoint(string.Concat("Complete: ", goal.Name)) { Details = goal.Details }; plot.Points.Add(plotPoint); plot.Points.Add(plotPoint1); map[goal.ID] = new Pair <PlotPoint, PlotPoint>(plotPoint, plotPoint1); GoalBuilder.add_points(plot, goal.Prerequisites, map); } }
private TimeSeriesGraph CreateDroneGraph() { TimeSeriesGraph graph = new TimeSeriesGraph(); string droneString = DroneData.ToString(); DataParser parser = new DataParser(droneString); List <float> x_values = parser.GetListFromColumn(4); // lat List <float> y_values = parser.GetListFromColumn(2); // alt List <float> z_values = parser.GetListFromColumn(3); // long List <string> time_values = parser.GetTimePoints(1); // time PlotPoint new_point = new PlotPoint(x_values, y_values, z_values); graph.AddPlotPoint(new_point); graph.AddTimePoints(time_values); return(graph); }
void update_links() { LinkList.Items.Clear(); // Links to this item foreach (PlotPoint pp in fPlot.Points) { if (pp.Links.Contains(fPoint.ID)) { ListViewItem lvi = LinkList.Items.Add(pp.Name); lvi.SubItems.Add((pp.Details != "") ? pp.Details : "(no details)"); lvi.Tag = pp; lvi.Group = LinkList.Groups[0]; } } // Links from this item foreach (Guid id in fPoint.Links) { PlotPoint pp = fPlot.FindPoint(id); if (pp != null) { ListViewItem lvi = LinkList.Items.Add(pp.Name); lvi.SubItems.Add((pp.Details != "") ? pp.Details : "(no details)"); lvi.Tag = pp; lvi.Group = LinkList.Groups[1]; } } foreach (ListViewGroup lvg in LinkList.Groups) { if (lvg.Items.Count == 0) { ListViewItem lvi = LinkList.Items.Add("(none)"); lvi.ForeColor = SystemColors.GrayText; lvi.Group = lvg; } } }
int add_nodes(TreeNodeCollection tnc, Plot p) { int nodes = 1; PlotPoint pp = Session.Project.FindParent(p); string plot_name = (pp != null) ? pp.Name : Session.Project.Name; TreeNode tn = tnc.Add(plot_name); tn.Tag = p; foreach (PlotPoint child in p.Points) { if (child.Subplot.Points.Count != 0) { nodes += add_nodes(tn.Nodes, child.Subplot); } } return(nodes); }
private void DelveDeck_Click(object sender, EventArgs e) { EncounterDeck encounterDeck = new EncounterDeck() { Name = string.Concat(this.SelectedMap, " Deck") }; DeckBuilderForm deckBuilderForm = new DeckBuilderForm(encounterDeck); if (deckBuilderForm.ShowDialog() == System.Windows.Forms.DialogResult.OK) { encounterDeck = deckBuilderForm.Deck; PlotPoint plotPoint = new PlotPoint(string.Concat(this.SelectedMap.Name, " Delve")) { Element = new MapElement(this.SelectedMap.ID, Guid.Empty) }; encounterDeck.DrawDelve(plotPoint, this.SelectedMap); Session.Project.Plot.Points.Add(plotPoint); Session.Modified = true; base.Close(); } }
private void add_navigation_node(PlotPoint pp, TreeNode parent) { try { string str = (pp != null ? pp.Name : Session.Project.Name); TreeNode treeNode = ((parent != null ? parent.Nodes : this.PlotTree.Nodes)).Add(str); treeNode.Tag = (pp != null ? pp.Subplot : Session.Project.Plot); foreach (PlotPoint plotPoint in (pp != null ? pp.Subplot.Points : Session.Project.Plot.Points)) { if (plotPoint.Subplot.Points.Count == 0) { continue; } this.add_navigation_node(plotPoint, treeNode); } } catch (Exception exception) { LogSystem.Trace(exception); } }
public static void Build(Plot plot) { foreach (FiveByFiveColumn column in plot.FiveByFive.Columns) { PlotPoint plotPoint = null; foreach (FiveByFiveItem item in column.Items) { PlotPoint plotPoint1 = new PlotPoint(item.Details) { Details = item.Details, Colour = column.Colour }; plot.Points.Add(plotPoint1); if (plotPoint != null) { plotPoint.Links.Add(plotPoint1.ID); } plotPoint = plotPoint1; } } }
public GameObject OpenPointPanel(PlotPoint point) { CloseAllPanels(); //get an unused point panel, lock it on and play anim GameObject go = Dequeue(pointPanelPool); go.SetActive(true); go.GetComponent <SimpleLockOnto>().referenceTransform = point.transform; go.GetComponent <SimpleBillboardDampened>().referenceTransform = cameraAnchor; //set initial pos/rot go.transform.position = point.transform.position; go.GetComponent <SimpleBillboardDampened>().SnapToDesiredRotation(); go.transform.GetChild(0).GetComponent <Animation>().Play("StockWorldCanvasOpen"); go.transform.Find("CANVAS/MASK/NAME").GetComponent <Text>().text = Dataset.GetName(point.symbol); pointPanelsInUse.Add(point, go); return(go); }
static void Main(string[] args) { Graph graph = new Graph(1000, 1000); graph.SetBounds(-10f, 10f, -10f, 10f); float deviation = 1f; PlotPoint[] g1 = GlobalRandom.BuildRandom(-2, deviation, 1, deviation, 0, 500); PlotPoint[] g2 = GlobalRandom.BuildRandom(2, deviation, -1, deviation, 0, 500); Neuron neuron = new Neuron(); for (int i = 0; i < g1.Length; i++) { graph.DrawPlotBackground(); graph.Plot(g1, 4, Color.Red, GraphPlotType.Points); graph.Plot(g2, 4, Color.Blue, GraphPlotType.Points); PlotPoint[] line = new PlotPoint[] { neuron.GetPoint(-5), neuron.GetPoint(5) }; graph.Plot(line, 2, Color.Yellow, GraphPlotType.Line); graph.PlotCircle(g1[i].X, g1[i].Y, 8, Color.Green); graph.PlotCircle(g2[i].X, g2[i].Y, 8, Color.Green); graph.ShowGraph(); Console.WriteLine(i); System.Threading.Thread.Sleep(250); neuron.Train(g1[i].X, g1[i].Y, 0); neuron.Train(g2[i].X, g2[i].Y, 1); } Console.ReadLine(); }
private static IEnumerable <Point> GetValue(IEnumerable <AnalysisResultEntity> orderedGroup, Graphics g, double mean, double deviation, double increment) { var organs = new LinqMetaData().Organ; var sliceCount = 0; // add group to image foreach (var result in orderedGroup) { ++sliceCount; // Calculate the radius of the point var pointValue = (result.JsInteger - mean) / deviation; var deltaValue = Convert.ToInt32(Math.Round((pointValue * HALF_BAR_HEIGHT), 0)); var centerPoint = result.FingerDesc.Contains("L") ? LeftCenterPoint : RightCenterPoint; var plotPoint = new PlotPoint { Point = CalcDisplayPoint(centerPoint, BASE_RADIUS + deltaValue, sliceCount * increment), TextPoint = CalcDisplayPoint(centerPoint, TEXT_RADIUS, sliceCount * increment), Value = pointValue, StartPoint = centerPoint, Brush = result.IsFiltered ? new SolidBrush(FilteredColor) : new SolidBrush(UnFilteredColor) }; if (!result.IsFiltered) { var isLeft = result.FingerDesc.Contains("L"); var organ = isLeft ? organs.First(x => x.LComp == result.FingerDesc) : organs.First(x => x.RComp == result.FingerDesc); plotPoint.OrganText = organ.Description.Replace(" - Right", "").Replace(" - Left", ""); } MarkPoint(g, plotPoint); yield return(plotPoint.Point); } }