File: WaterfallCanvas.h

package info (click to toggle)
cubicsdr 0.2.7%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 5,560 kB
  • sloc: cpp: 32,850; sh: 60; makefile: 6
file content (102 lines) | stat: -rw-r--r-- 2,772 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
// Copyright (c) Charles J. Cliffe
// SPDX-License-Identifier: GPL-2.0+

#pragma once

#include "wx/glcanvas.h"
#include "wx/timer.h"

#include <vector>
#include <queue>
#include <memory>
#include "InteractiveCanvas.h"
#include "MouseTracker.h"
#include "SpectrumCanvas.h"
#include "WaterfallPanel.h"
#include "Timer.h"

class WaterfallCanvas: public InteractiveCanvas {
public:
    enum DragState {
        WF_DRAG_NONE, WF_DRAG_BANDWIDTH_LEFT, WF_DRAG_BANDWIDTH_RIGHT, WF_DRAG_FREQUENCY, WF_DRAG_RANGE
    };

    WaterfallCanvas(wxWindow *parent, std::vector<int> dispAttrs);
    void setup(unsigned int fft_size_in, int waterfall_lines_in);
    void setFFTSize(unsigned int fft_size_in);
    ~WaterfallCanvas() override;

    DragState getDragState();
    DragState getNextDragState();
    
    void attachSpectrumCanvas(SpectrumCanvas *canvas_in);
    void processInputQueue();
    SpectrumVisualDataQueuePtr getVisualDataQueue();

    void setLinesPerSecond(int lps);
    void setMinBandwidth(int min);

    //This is public because it is indeed forwarded from
    //AppFrame::OnGlobalKeyDown, because global key handler intercepts 
    //calls in all windows.
    void OnKeyDown(wxKeyEvent& event);

    //This is public because it is indeed forwarded from
    //AppFrame::OnGlobalKeyUp, because global key handler intercepts 
    //calls in all windows.
    void OnKeyUp(wxKeyEvent& event);

    //public because called by SpectrumCanvas.
    void OnMouseWheelMoved(wxMouseEvent& event);
    
    
    
private:
    void OnPaint(wxPaintEvent& event);
    void OnIdle(wxIdleEvent &event);

    void updateHoverState();
    
    void OnMouseMoved(wxMouseEvent& event);
    void OnMouseDown(wxMouseEvent& event);
    void OnMouseReleased(wxMouseEvent& event);
    void OnMouseRightDown(wxMouseEvent& event);
    void OnMouseRightReleased(wxMouseEvent& event);
    void OnMouseEnterWindow(wxMouseEvent& event);
    void OnMouseLeftWindow(wxMouseEvent& event);

    void updateCenterFrequency(long long freq);
    
    std::vector<float> spectrum_points;

    SpectrumCanvas *spectrumCanvas = nullptr;
    PrimaryGLContext *glContext = nullptr;
    WaterfallPanel waterfallPanel;

    DragState dragState;
    DragState nextDragState;

    unsigned int fft_size, new_fft_size;
    int waterfall_lines;
    int dragOfs;

    float mouseZoom, zoom;
    bool freqMoving;
    long double freqMove;
    float hoverAlpha;
    int linesPerSecond;
    float scaleMove;
    int dragBW;
    
    SpectrumVisualDataQueuePtr visualDataQueue = std::make_shared<SpectrumVisualDataQueue>();

    Timer gTimer;
    double lpsIndex;
    bool preBuf;
    std::mutex tex_update;
    int minBandwidth;
    std::atomic_bool fft_size_changed;
    // event table
wxDECLARE_EVENT_TABLE();
};