private void InitFractal() { if (fractalPlotter != null) { Xmin = (decimal)fractalPlotter.XMini; Xmax = (decimal)fractalPlotter.XMaxi; Ymin = (decimal)fractalPlotter.YMini; Ymax = (decimal)fractalPlotter.YMaxi; fractalPlotter.MAX_MAG_SQUARED = max_MAG_SQUARED.ToString(); fractalPlotter.SmoozeType = SmoozeType; fractalPlotter.Reset(); PlotForm.Params2Form(); if (fractalPlotter.ThisType == FractalType.LinePlot) { fractalPlotter.DoCalculation(); if (PlotForm != null) { PlotForm.FormImage = PointsImage.Bitmap; } } else { SimulateTask(); } } }
public void SetPoints() { if (Constants.Initalising) { return; } PlotForm.SetEnabled(false); PlotFunction(); if (doFillXvalues) { List <decimal> furcationPoints = new List <decimal>(); foreach (DiagramSet p in CurrentFunction.furcationPoints) { furcationPoints.Add(p.X); } List <PointD> setpoints = CurrentFunction.furcationPoints[CurrentFunction.furcationPoints.Count - 1].setPoints; if (setpoints.Count > 1) { for (int i = setpoints.Count - 1; i >= 0; i--) { PointD p = setpoints[i]; furcationPoints.Add(p.X); } } PlotForm.FillXValues(furcationPoints); } PlotForm.SetEnabled(true); }
public void RescanExampleParallelAsync(bool colorChanged) { tasks.Clear(); foreach (BasePlotter p in examplePlottersGeneral) { p.SmoozeType = smoozeType; if (colorChanged) { p.Map.CalculatedTypes.Clear(); } tasks.Add(Task.Run(() => p.DoCalculation())); } foreach (BasePlotter p in examplePlottersJulia) { p.SmoozeType = smoozeType; if (colorChanged) { p.Map.CalculatedTypes.Clear(); } tasks.Add(Task.Run(() => p.DoCalculation())); } foreach (BasePlotter p in examplePlottersMira) { p.SmoozeType = smoozeType; if (colorChanged) { p.Map.CalculatedTypes.Clear(); } tasks.Add(Task.Run(() => p.DoCalculation())); } foreach (MiraLinePlotter m in miraLineplotExamples) { tasks.Add(Task.Run(() => m.setFavorite(m.ExampleNumber))); } var results = Task.WhenAll(tasks); for (int i = 0; i < examplePlottersGeneral.Count; i++) { PlotForm.AddExampleImage(i, examplePlottersGeneral[i].map.Bitmap, examplePlottersGeneral[i].Title, ExampleGroups.General); } for (int i = 0; i < examplePlottersJulia.Count; i++) { PlotForm.AddExampleImage(i, examplePlottersJulia[i].map.Bitmap, examplePlottersJulia[i].Title, ExampleGroups.Julia); } for (int i = 0; i < examplePlottersMira.Count; i++) { PlotForm.AddExampleImage(i, examplePlottersMira[i].map.Bitmap, examplePlottersMira[i].Title, ExampleGroups.Line); } foreach (MiraLinePlotter miraLineplot in miraLineplotExamples) { PlotForm.AddExampleImage(miraLineplot.ExampleNumber, miraLineplot.map.Bitmap, miraLineplot.StartPoint.X.ToString("00.0") + " - " + miraLineplot.StartPoint.Y.ToString("00.0") + Environment.NewLine + miraLineplot.Parameters[0].ToString("0.00") + " - " + miraLineplot.Parameters[6].ToString("0.00"), ExampleGroups.MiraLine); } PlotForm.RescanExamples(); }
public virtual async void SimulateTask() { PlotForm.SetProgressBar(pictBoxSize.Width); PlotForm.SetEnabled(false); InitTaskHandles(); await Task.Run(() => { doTaskWork(); }); PlotForm.SetEnabled(true); PlotForm.EndGenerate(); }
private void PlotScatterNamed(IEnumerable <object> XValues, IEnumerable <object> YValues, string XName, string YName, string PlotName) { try { PlotForm.RunPlot(XValues.Select(Convert.ToDouble).ToList(), YValues.Select(Convert.ToDouble).ToList(), true, XName, YName, PlotName); } catch (Exception e) { Console.WriteLine(e.Message); } }
private void PlotXY(IEnumerable <object> XValues, IEnumerable <object> YValues) { try { PlotForm.RunPlot(XValues.Select(m => Convert.ToDouble(m, CultureInfo.InvariantCulture)).ToList(), YValues.Select(Convert.ToDouble).ToList()); } catch (Exception e) { Console.WriteLine(e.Message); } }
private void Plot(IEnumerable <object> YValues1, IEnumerable <object> YValues2, IEnumerable <object> YValues3, double Step, double InitX) { try { PlotForm.RunPlot(YValues1.Select(Convert.ToDouble).ToList(), YValues2.Select(Convert.ToDouble).ToList(), YValues3.Select(Convert.ToDouble).ToList(), Step, InitX); } catch (Exception e) { Console.WriteLine(e.Message); } }
private void FractalCompletedGIF() { fractalPlotter.CreateGif = false; gifCreater.Create(1, gifFilename); xMin = currXmin; xMax = currXmax; yMin = currYmin; yMax = currYmax; PlotForm.SetEnabled(true); PlotForm.EndGenerate(); Reset();//includes SimulateTask(); }
public async void CreateGif(PointD current, string numGif, string fName) { m_StartX = (float)current.X; m_StartY = (float)current.Y; gifFilename = fractalPlotter.Title + fName + numGif; Int32.TryParse(numGif, out nGif); gifFilename = string.Concat(gifFilename.Split(Path.GetInvalidFileNameChars())); gifFilename = gifFilename.Replace("^", ""); gifFilename = gifFilename.Replace("/", ""); currXmin = xMin; currXmax = xMax; currYmin = yMin; currYmax = yMax; fractalPlotter.CreateGif = true; gifCreater.images.Clear(); //zoom in to the largest square around current x,y if (Math.Abs(m_StartY) < 0.05) { m_StartY = 0; } if (Math.Abs(m_StartX) < 0.05) { m_StartX = 0; } double minX = Math.Min(Math.Abs((float)xMax - m_StartX), Math.Abs((float)xMin - m_StartX)); double minY = Math.Min(Math.Abs((float)yMax - m_StartY), Math.Abs((float)yMin - m_StartY)); double delta = Math.Min(minX, minY); xMin = (decimal)(m_StartX - delta); xMax = (decimal)(m_StartX + delta); yMin = (decimal)(m_StartY - delta); yMax = (decimal)(m_StartY + delta); centerX = xMin + (xMax - xMin) / 2; centerY = yMin + (yMax - yMin) / 2; dx = (xMax - xMin) / (2 * nGif); dy = (yMax - yMin) / (2 * nGif); xMax -= dx * (nGif - 1); xMin += dx * (nGif - 1); yMax -= dy * (nGif - 1); yMin += dy * (nGif - 1); plotForm.Params2Form(); PlotForm.SetProgressBar(pictBoxSize.Width); PlotForm.SetEnabled(false); InitTaskHandlesGif(); await Task.Run(() => { DoGif(); }); FractalCompletedGIF(); }
private void dataPlotToolStripMenuItem_Click(object sender, EventArgs e) { if (graphFrom_ == null || graphFrom_.IsDisposed) { ChartManager.Inst.Reset(); graphFrom_ = new PlotForm(); graphFrom_.Show(); } else { graphFrom_.Show(); graphFrom_.Focus(); } }
private void CalcSimPar() { doFillXvalues = false; decimal t = CurrentFunction.Parameter; decimal start = t; if (t > CurrentFunction.DiagramStop) { start = CurrentFunction.DiagramStop; } int m = MaxFunctionIterations; gifCreater.images.Clear(); decimal range2Fill = Math.Abs(CurrentFunction.DiagramStop - t); int numSteps = 50; decimal delta = range2Fill / numSteps; int max = (int)(Math.Abs(CurrentFunction.DiagramStop - t) * 100); PlotForm.SetProgressBar(numSteps + 1); try { for (decimal i = 0; i < numSteps; i++) { report.PercentageComplete = (int)i; if (progressHandler is IProgress <ProgressReportModel> progress) { progress.Report(report); } if (token.IsCancellationRequested) { break; } CurrentFunction.Parameter = start + i * delta; PlotFunction(); if (CreateGIF) { gifCreater.images.Add(functionDrawer.Copy4GIF); } Thread.Sleep(5); } } catch { } gifCreater.Create(1, FunctionGifFileName); CurrentFunction.Parameter = t; PlotFunction(); MaxFunctionIterations = m; doFillXvalues = true; }
public Control4FunctionsView(IView f, Control4AllViews cav) : base(f, cav) { Constants constants = new Constants(); Constants.SettingsFromXML(); PlotForm = (IFunctionsView)f; // BSize = 2000; done in base!!!!!! CurrentFunction = new BaseFunction(); functionDrawer = new FunctionDrawer(PlotForm, this, createGIF); henonFunction = new HenonFunction(PlotForm); mandelbrotFunction = new MandelbrotFunction(PlotForm); CurrFunctionType = Constants.currentFunctionType; Constants.Initalising = false; PlotForm.Control4FunctionsView = this; PlotForm.Params2Form(); }
public void DiagramParamShoice(int x, Size size) { if (diagramPoints.Count > 0) { decimal dx = 1.0M * x / size.Width; int index = (int)(dx * DestRect.Width); decimal start = DiagramStartParameter; decimal stop = DiagramStopParameter; if (stop < start) { stop = DiagramStartParameter; start = DiagramStopParameter; } decimal Par = start + (decimal)((stop - start) * dx); if (index >= 0 && index < BSize && index < diagramPoints.Count) { PlotForm.ShowNumber(index, Par, diagramPoints); } ParamChoice2Form(Par); } }
private void InitialUI_Load(object sender, EventArgs e) { m_worldModel = new WorldModel(m_data, SimCountryData.LoadFrom(@"../../../Data/CountryData.dat")); m_mapControl.AssignWorldModel(m_worldModel); PlotForm dc1 = new PlotForm("Mortality"); dc1.Bind(m_worldModel, new[] { GetTotal(n => n.Killed), GetTotal(n => n.Dead) }, new[] { "Killed", "Dead" }); PlotForm dc2 = new PlotForm("Disease Stages"); dc2.Bind(m_worldModel, new[] { GetTotal(n => n.ContagiousAsymptomatic), GetTotal(n => n.ContagiousSymptomatic), GetTotal(n => n.NonContagiousInfected), GetTotal(n => n.Immune), }, new[] { "ContagiousAsymptomatic", "ContagiousSymptomatic", "NonContagiousInfected", "Immune" }); m_mapControl.Show(); dc1.Show(); dc2.Show(); /*PlotForm m_plotWindow1 = new PlotForm("Killed"); * m_plotWindow1.Bind(m_worldModel, GetTotal(n => n.Killed)); * m_plotWindow1.Show(); * * PlotForm m_plotWindow2 = new PlotForm("Immune"); * m_plotWindow2.Bind(m_worldModel, GetTotal(n => n.Immune)); * m_plotWindow2.Show(); * * PlotForm m_plotWindow3 = new PlotForm("Total Population"); * m_plotWindow3.Bind(m_worldModel, GetTotal(n => n.Population)); * m_plotWindow3.Show(); * * PlotForm m_plotWindow4 = new PlotForm("Immunization Effort"); * m_plotWindow4.Bind(m_worldModel, GetTotal(n => n.Flows[2](n))); * m_plotWindow4.Show();*/ m_mapControl.MouseMove += (o, args) => { double lat, lon; int x, y; GraphicalUtilities.GraphicsCoordsToMapCoords(panel1.Size, m_worldModel.Size, args.X, args.Y, out x, out y); m_data.DataXYToLatLon(x, y, out lat, out lon); string where = ReverseGeocodeService.CountryNameForLatAndLong(lat, lon + 2) ?? "Unknown"; DiseaseNode n = m_worldModel.NodeAt(x, y); toolStripStatusLabel1.Text = $"data[{x},{y}] is {where}, Lat {lat:f2}/Lon {lon:f2} {n:d4}"; Console.WriteLine(toolStripStatusLabel1.Text); }; toolStripStatusLabel1.TextChanged += (o, args) => Console.WriteLine(((ToolStripStatusLabel)o).Text); }
private void CloseWindows() { PlotForm.ClosePlotWindows(); }
private void CalcDiagram() { gifCreater.images.Clear(); int startIter = maxGIFIterations - 1; if (diagramDrawer.CreateGif) { startIter = 1; } int s = 2; int d = MaxFunctionIterations / maxGIFIterations; if (maxGIFIterations > 2) { d = MaxFunctionIterations / (maxGIFIterations - 2); } for (int m = startIter; m < maxGIFIterations; m++) { decimal start = DiagramStartParameter; decimal stop = DiagramStopParameter; if (DiagramStartParameter > DiagramStopParameter) { start = DiagramStopParameter; stop = DiagramStartParameter; } int tempMax = CurrentFunction.MaxIterations; decimal tempP = CurrentFunction.Parameter; decimal delta = 1.0M * (stop - start) / BSize; diagramPoints.Clear(); try { for (int i = 0; i < BSize; i++) { report.PercentageComplete = i; if (progressHandler is IProgress <ProgressReportModel> progress) { progress.Report(report); } if (token.IsCancellationRequested) { break; } decimal p = start + i * delta; BaseFunction diagramFunction = CurrentFunction; diagramFunction.Parameter = p; if (diagramDrawer.CreateGif) { diagramFunction.MaxIterations = s; } else { diagramFunction.MaxIterations = MaxFunctionIterations; } diagramFunction.SetFurcationPoints(); if (diagramFunction.furcationPoints.Count > 0) { if (CurrentFunction is HenonFunction) { for (int dp = diagramFunction.furcationPoints.Count - 1; dp > diagramFunction.furcationPoints.Count - 250 && dp >= 0; dp--) { DiagramSet ds = diagramFunction.furcationPoints[dp]; diagramPoints.Add(new DiagramSet(i, ds)); } } else { int last = diagramFunction.furcationPoints.Count - 1; diagramPoints.Add(new DiagramSet(i, diagramFunction.furcationPoints[last])); } } else { diagramPoints.Add(new DiagramSet(i, 2)); } } CurrentFunction.MaxIterations = tempMax; CurrentFunction.Parameter = tempP; PlotDiagram(); if (diagramDrawer.CreateGif) { gifCreater.images.Add(diagramDrawer.Copy4GIF); Thread.Sleep(1); } PlotForm.SetCurrentIteration(m); if (s < 100) { s += 10; } else if (s < 1000) { s += 100; } else { s += d; } } catch {} } int mSec = 40 / maxGIFIterations; if (mSec == 0) { mSec = 1; } if (diagramDrawer.CreateGif) { gifCreater.Create(mSec, DiagramGifFileName); } ParamChoice2Form(DiagramStopParameter); diagramDrawer.CreateGif = false; }
private async void rbtnPlotList_Click(object sender, RibbonControlEventArgs e) { var frm = new PlotForm(); await Task.Run(() => frm.ShowDialog()); }
public override void SimulateTask() { SetPoints(); PlotForm.Params2Form(); }
public override void SimulateTask() { PlotForm.Params2Form(); CreateDiagram(false); }
public static void Main(string[] args) { Plot generatedDataPlot = new Plot(); Spawner spawner = new Spawner(STD_DEV); List <PointF> allPoints = new List <PointF>(); for (int i = 0; i < CLUSTER_COUNT; ++i) { spawner.ResetCenter(MIN_CENTER_DISTANCE, MAX_CENTER_DISTANCE); PointF[] points = spawner.Spawn(POINT_COUNT); allPoints.AddRange(points); Color color = generatedDataPlot.GetNextColor(); generatedDataPlot.AddScatterPoints(points, color, label: $"Points {i + 1}"); generatedDataPlot.AddPoint(spawner.Center.X, spawner.Center.Y, color, 25); } generatedDataPlot.Legend(); PlotForm generatedDataPlotForm = new PlotForm(generatedDataPlot, "source_data"); generatedDataPlotForm.ShowDialog(); Plot grayDataPlot = new Plot(); grayDataPlot.AddScatterPoints(allPoints.ToArray(), label: "Gray points"); grayDataPlot.Legend(); PlotForm grayDataPlotForm = new PlotForm(grayDataPlot, "gray_data"); grayDataPlotForm.ShowDialog(); KMeansClusterizer clusterizer = new KMeansClusterizer(); List <Dictionary <PointF, List <PointF> > > clusterizingHistory = clusterizer.Clusterize(allPoints, CLUSTER_COUNT); PlotForm resultPlotForm = new PlotForm(CreateClusterizingPlot(clusterizingHistory.Last()), "crusterized"); resultPlotForm.ShowDialog(); PlotForm historyForm = new PlotForm(clusterizingHistory.Select(c => CreateClusterizingPlot(c)).ToList(), "history_"); historyForm.ShowDialog(); CentroidLinkage <DataPoint> linkage = new CentroidLinkage <DataPoint>( new DissimilarityMetric(), cluster => new DataPoint( cluster.Average(p => p.X), cluster.Average(p => p.Y) ) ); AgglomerativeClusteringAlgorithm <DataPoint> algorithm = new AgglomerativeClusteringAlgorithm <DataPoint>(linkage); HashSet <DataPoint> dataPoints = allPoints.Select(p => new DataPoint(p)).ToHashSet(); ClusteringResult <DataPoint> clusteringResult = algorithm.GetClustering(dataPoints); ClusterSet <DataPoint> result = clusteringResult[clusteringResult.Count - 3]; Plot aglomeraPlot = new Plot(); foreach (Cluster <DataPoint> resultCluster in result) { Color color = aglomeraPlot.GetNextColor(); aglomeraPlot.AddScatterPoints( resultCluster.Select(p => (double)p.X).ToArray(), resultCluster.Select(p => (double)p.Y).ToArray(), color ); aglomeraPlot.AddPoint( resultCluster.Select(p => p.X).Average(), resultCluster.Select(p => p.Y).Average(), color, 25 ); } PlotForm aglomeraForm = new PlotForm(aglomeraPlot, "aglomera"); aglomeraForm.ShowDialog(); clusteringResult.SaveD3DendrogramFile(Environment.CurrentDirectory + "/dendro.json"); Console.ReadLine(); }
public void ShowPlotDialog() { var plotForm = new PlotForm(this); plotForm.Show(); }