public override void UpdateGraph(bool selectionChanged) { GraphObjList.Clear(); CurveList.Clear(); Legend.IsVisible = false; if (!DetectionPlotData.GetDataCache().TryGet( GraphSummary.DocumentUIContainer.DocumentUI, Settings.QValueCutoff, this.DataCallback, out _detectionData)) { return; } AddLabels(); BarSettings.Type = BarType.SortedOverlay; BarSettings.MinClusterGap = 0.3f; //draw bars var countPoints = new PointPairList(Enumerable.Range(0, _detectionData.ReplicateCount) .Select(i => new PointPair(i, TargetData.Histogram[i] / YScale)).ToList()); CurveList.Insert(0, MakeBarItem(countPoints, Color.FromArgb(180, 220, 255))); //axes formatting XAxis.Scale.Max = _detectionData.ReplicateCount + 1; YAxis.Scale.Max = TargetData.Histogram.Max() / YScale * 1.15; }
//Worker thread method private void CacheData(DataRequest request, int index) { try { if (!_document.IsLoaded) { SetCacheStatus(CacheStatus.idle, Resources.DetectionPlotData_WaitingForDocumentLoad_Label); return; } lock (_statusLock) { //first make sure it hasn't been retrieved already //and calculate the queue size var currentSize = 0; DetectionPlotData res = null; foreach (var dat in _datas) { currentSize += dat.ReplicateCount; if (dat.IsValidFor(_document, request.qValue)) { res = dat; } } if (res != null) { return; } SetCacheStatus(CacheStatus.processing, string.Empty); res = new DetectionPlotData(_document, request.qValue); var statusMessage = res.Init(_tokenSource.Token, ReportProgress); SetCacheStatus(CacheStatus.idle, string.Empty); if (res.IsValid) { SetCacheStatus(CacheStatus.idle, Resources.DetectionPlotData_DataRetrieved_Label); if (currentSize + res.ReplicateCount >= CACHE_CAPACITY) { _datas.TryDequeue(out _); } _datas.Enqueue(res); _callback.Invoke(res); } else { SetCacheStatus(CacheStatus.error, statusMessage); } } } catch (Exception e) { SetCacheStatus(CacheStatus.idle, e.Message); throw; } }
protected DetectionsPlotPane(GraphSummary graphSummary) : base(graphSummary) { MaxRepCount = graphSummary.DocumentUIContainer.DocumentUI.MeasuredResults.Chromatograms.Count; Settings.RepCount = MaxRepCount / 2; if (GraphSummary.Toolbar is DetectionsToolbar toolbar) { toolbar.UpdateUI(); } XAxis.Scale.Min = YAxis.Scale.Min = 0; XAxis.Scale.MinAuto = XAxis.Scale.MaxAuto = YAxis.Scale.MinAuto = YAxis.Scale.MaxAuto = false; ToolTip = new ToolTipImplementation(this); DetectionPlotData.GetDataCache().ReportProgress += UpdateProgressHandler; DetectionPlotData.GetDataCache().StatusChange += UpdateStatusHandler; }
public override void UpdateUI() { IntLabeledValue.PopulateCombo(cbLevel, Settings.TargetType); if (!_graphSummary.TryGetGraphPane(out DetectionsPlotPane pane)) { return; } if (pane.CurrentData.IsValid && DetectionPlotData.GetDataCache().Status != DetectionPlotData.DetectionDataCache.CacheStatus.error) { EnableControls(true); IntLabeledValue.PopulateCombo(cbLevel, Settings.TargetType); toolStripAtLeastN.NumericUpDownControl.Minimum = 0; toolStripAtLeastN.NumericUpDownControl.Maximum = _graphSummary.DocumentUIContainer.DocumentUI.MeasuredResults.Chromatograms.Count; toolStripAtLeastN.NumericUpDownControl.Value = Settings.RepCount; toolStripAtLeastN.NumericUpDownControl.ValueChanged += toolStripAtLeastN_ValueChanged; } else { toolStripAtLeastN.NumericUpDownControl.Value = 0; EnableControls(false); } }
public override void OnClose(EventArgs e) { DetectionPlotData.GetDataCache().ReportProgress -= UpdateProgressHandler; DetectionPlotData.GetDataCache().StatusChange -= UpdateStatusHandler; Dispose(); }
public override void UpdateGraph(bool selectionChanged) { GraphObjList.Clear(); CurveList.Clear(); Legend.IsVisible = false; if (!DetectionPlotData.GetDataCache().TryGet( GraphSummary.DocumentUIContainer.DocumentUI, Settings.QValueCutoff, this.DataCallback, out _detectionData)) { return; } AddLabels(); BarSettings.Type = BarType.SortedOverlay; BarSettings.MinClusterGap = 0.3f; Legend.IsVisible = Settings.ShowLegend; var emptySymbol = new Symbol(SymbolType.None, Color.Transparent); //draw bars var counts = TargetData.TargetsCount; var countPoints = new PointPairList(Enumerable.Range(0, _detectionData.ReplicateCount) .Select(i => new PointPair(i, counts[i] / YScale)).ToList()); CurveList.Insert(0, MakeBarItem(countPoints, Color.FromArgb(180, 220, 255))); //draw cumulative curve counts = TargetData.TargetsCumulative; var cumulativePoints = new PointPairList(Enumerable.Range(0, _detectionData.ReplicateCount) .Select(i => new PointPair(i, counts[i] / YScale)).ToList()); CurveList.Insert(1, new LineItem(Resources.DetectionPlotPane_CumulativeLine_Name) { Points = cumulativePoints, Symbol = emptySymbol, Line = new Line() { Color = Color.Coral, Width = 2 } }); //draw inclusive curve counts = TargetData.TargetsAll; var allPoints = new PointPairList(Enumerable.Range(0, _detectionData.ReplicateCount) .Select(i => new PointPair(i, counts[i] / YScale)).ToList()); CurveList.Insert(2, new LineItem(Resources.DetectionPlotPane_AllRunsLine_Name) { Symbol = emptySymbol, Points = allPoints, Line = new Line() { Color = Color.Black, Width = 2 } }); //axes formatting XAxis.Scale.Max = _detectionData.ReplicateCount + 1; YAxis.Scale.Max = _detectionData.GetTargetData(Settings.TargetType).MaxCount / YScale * 1.15; if (Settings.ShowAtLeastN) { double lineY = TargetData.getCountForMinReplicates(Settings.RepCount); var atLeastLine = new Line() { Width = 1, Color = Color.Blue, Style = DashStyle.Dash }; var dummyPoints = new PointPairList(new[] { new PointPair(0, 0) }); var line = new LineObj(Color.Blue, 0, lineY / YScale, XAxis.Scale.Max, lineY / YScale) { IsClippedToChartRect = true, Line = atLeastLine }; GraphObjList.Add(line); //This is a placeholder to make sure the line shows in the legend. CurveList.Insert(3, new LineItem(String.Format(CultureInfo.CurrentCulture, Resources.DetectionPlotPane_AtLeastLine_Name, Settings.RepCount, _detectionData.ReplicateCount, lineY)) { Symbol = emptySymbol, Points = dummyPoints, Line = atLeastLine }); } if (Settings.ShowSelection) { var selectedIndex = GraphSummary.StateProvider.SelectedResultsIndex; var lineLength = TargetData.TargetsCount[selectedIndex] / YScale + YAxis.Scale.Max * 0.05; GraphObjList.Add( new LineObj(Color.Black, selectedIndex + 1, 0, selectedIndex + 1, lineLength) { IsClippedToChartRect = true, Line = new Line() { Width = 1, Color = Color.Black, Style = DashStyle.Dash } }); } if (Settings.ShowMean) { var stats = new Statistics(TargetData.TargetsCount.Select((x) => (double)x)); var labelText = String.Format(CultureInfo.CurrentCulture, TextUtil.LineSeparate(new[] { Resources.DetectionPlotPane_Label_Mean, Resources.DetectionPlotPane_Label_Stddev } ), stats.Mean(), stats.StdDev()); GraphObjList.Add(new TextObj(labelText, 0.1, YAxis.Scale.Max, CoordType.AxisXYScale, AlignH.Left, AlignV.Top) { IsClippedToChartRect = true, ZOrder = ZOrder.E_BehindCurves, FontSpec = GraphSummary.CreateFontSpec(Color.Black), }); } }
public bool TryGet(SrmDocument doc, float qValue, Action <DetectionPlotData> callback, out DetectionPlotData data) { data = INVALID; if (IsDisposed) { return(false); } var request = new DataRequest() { qValue = qValue }; _callback = callback; if (ReferenceEquals(doc, _document)) { data = Get(request) ?? INVALID; if (data.IsValid) { return(true); } _stackWorker.Add(request); } else { _document = doc; new Task(() => CancelWorker(request, false)).Start(); } return(false); }