Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        protected override Func <double, double> GetYScaler([NotNull] double[] yAxis)
        {
            Max = yAxis.Max();
            VerticalAxisView.Canvas.Dispatcher.InvokeAsync(() => { VerticalAxisView.DrawRuler(Min, Max, false); });
            // todo: store height as const or invoke getter to adapt
            //            const int margin = 10;
            const int margin         = 0;
            var       dispAreaHeight = ScreenHeight - 2 * margin;

            return(y => dispAreaHeight - dispAreaHeight / Max * y + margin);
            //     const int margin = 0;
            //            var dispAreaHeight = ScreenHeight - 2*margin;
            //            return y => dispAreaHeight - dispAreaHeight/(max - min)*(y - min) + margin;
        }
Ejemplo n.º 3
0
        protected override Func <double, double> GetYScaler([NotNull] double[] yAxis)
        {
            double min, max;

            Functions.FindMinMax(yAxis, out min, out max);
            Min = min;
            Max = max;
            VerticalAxisView.Canvas.Dispatcher.InvokeAsync(() => { VerticalAxisView.DrawRuler(min, max, true); });
            // todo: store height as const or invoke getter to adapt
            //            const int margin = 10;
            const int margin         = 0;
            var       dispAreaHeight = ScreenHeight - 2 * margin;

            return(y => dispAreaHeight - dispAreaHeight / (max - min) * (y - min) + margin);
            //     const int margin = 0;
            //            var dispAreaHeight = ScreenHeight - 2*margin;
            //            return y => dispAreaHeight - dispAreaHeight/(max - min)*(y - min) + margin;
        }
Ejemplo n.º 4
0
        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);
            }
        }
Ejemplo n.º 5
0
        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();
        }