public PhaseDisplayAdapter([NotNull] CanvasView wavefromView, HorizontalAxisView horizontalAxisView, VerticalAxisView verticalAxisView, TextBox tbXCoordinate, TextBox tbDistance, int dispPointNum, double samplingRate, int startFreqInMHz, int endFreqInMHz) : base( wavefromView, horizontalAxisView, verticalAxisView, tbXCoordinate, tbDistance, dispPointNum, samplingRate, startFreqInMHz, endFreqInMHz) { _instantDispValues = new double[DispPointsCnt]; _instantPts = new PointCollection(DispPointsCnt); _dummyAxis = Axis.DummyAxis(_instantDispValues); }
public SpectrumDisplayAdapter([NotNull] CanvasView wavefromView, HorizontalAxisView horizontalAxisView, VerticalAxisView verticalAxisView, TextBox tbXCoordinate, TextBox tbDistance, int dispPointNum, double samplingRate, int startFreqInMHz, int endFreqInMHz, double?lockDipFreq, double lockDipScanRadius) : base( wavefromView, horizontalAxisView, verticalAxisView, tbXCoordinate, tbDistance, dispPointNum, samplingRate, startFreqInMHz, endFreqInMHz) { _lockDipFreq = lockDipFreq; _lockDipScanRadius = lockDipScanRadius; _instantDispValues = new double[DispPointsCnt]; _accDispValues = new double[DispPointsCnt]; _instantPts = new PointCollection(DispPointsCnt); _accPts = new PointCollection(DispPointsCnt); _dummyAxis = Axis.DummyAxis(_instantDispValues); Min = 0; if (lockDipFreq.HasValue) { WavefromView.Canvas.Children.Add(_ellipse); WavefromView.Canvas.Children.Add(_innerEllipse); } }
public DisplayAdapterV2([NotNull] CanvasView wavefromView, HorizontalAxisView horizontalAxisView, VerticalAxisView verticalAxisView, TextBox tbXCoordinate, TextBox tbDistance, int dispPointNum, double samplingRate, int startFreqInMHz, int endFreqInMHz) { WavefromView = wavefromView; WavefromView.Reload(); // todo move out, and use a event DispPointsCnt = dispPointNum; Axis = new AxisBuilder(WavefromView); _horizontalAxisView = horizontalAxisView; VerticalAxisView = verticalAxisView; SampleRateInMHz = samplingRate / 1e6; StartFreqInMHz = startFreqInMHz; EndFreqInMHz = endFreqInMHz; var eventLayer = EventLayer.Setup(wavefromView.Canvas); eventLayer.ZoomEvent += (start, end, valid) => { if (valid) { var zoomCommand = new ZoomCommand(start, end, WavefromView, this); _cmdStack.Push(zoomCommand); zoomCommand.Invoke(); ResetXYScales(); } else { WavefromView.ClearLine(); } }; TextBlock pop = null; eventLayer.FollowTraceEvent += (last, curr, mouseDown) => { var xOnAxis = GetXValueByPointPosition(curr.X); tbXCoordinate.Text = xOnAxis.ToString("F5"); if (pop == null) { pop = WavefromView.DrawText(curr.X + 4, curr.Y - 12, xOnAxis.ToString("F3")); } else { Canvas.SetTop(pop, curr.Y - 12); Canvas.SetLeft(pop, curr.X + 4); pop.Text = xOnAxis.ToString("F3"); } if (mouseDown) { var xStart = GetXValueByPointPosition(eventLayer.MouseDownStart); var xDelta = xOnAxis - xStart; tbDistance.Text = xDelta.ToString("F5"); } if (mouseDown) { WavefromView.InvokeAsync(() => { var pointCollection = new PointCollection(2) { last, curr }; WavefromView.DrawLine(pointCollection, Colors.Yellow); }); } }; eventLayer.AdjustYAxisEvent += ResetXYScales; eventLayer.UndoEvent += () => { if (_cmdStack.IsEmpty()) { StartFreqInMHz = startFreqInMHz; EndFreqInMHz = endFreqInMHz; // todo hard coded } else { var zoomCommand = _cmdStack.Pop(); zoomCommand.Undo(); } ResetXYScales(); }; WavefromView.DrawGrid(); }