SoDaRadio-5.0.3-master:8901fb5
freqlabel.hpp
Go to the documentation of this file.
1 /*
2  Copyright (c) 2017 Matthew H. Reilly (kb1vc)
3  All rights reserved.
4 
5  Redistribution and use in source and binary forms, with or without
6  modification, are permitted provided that the following conditions are
7  met:
8 
9  Redistributions of source code must retain the above copyright
10  notice, this list of conditions and the following disclaimer.
11  Redistributions in binary form must reproduce the above copyright
12  notice, this list of conditions and the following disclaimer in
13  the documentation and/or other materials provided with the
14  distribution.
15 
16  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20  HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28 
29 #ifndef FREQLABEL_HDR
30 #define FREQLABEL_HDR
31 
32 #include <QLabel>
33 #include <QWidget>
34 #include <Qt>
35 #include <QMouseEvent>
36 #include <iostream>
37 
38 namespace GUISoDa {
39 
40  class FreqLabel : public QLabel {
41  Q_OBJECT
42 
43  public:
44  explicit FreqLabel(QWidget * parent = Q_NULLPTR,
45  Qt::WindowFlags f = Qt::WindowFlags());
46  ~FreqLabel();
47 
48 
49  double getFreq() const {
50  return frequency;
51  }
52 
53  void setFreqUpdate(double freq) {
54  setFreq(freq);
55  emit(newFreq(frequency));
56  }
57  signals:
58  void newFreq(double freq);
59 
60  public slots:
61  void setFreq(double freq);
62 
63  protected:
64  void mousePressEvent(QMouseEvent * event);
65 
66  double updateFrequency() {
67  double dif = ((double) int_freq);
68  double dff = 1e-6 * ((double) frac_freq);
69  frequency = (dif + dff) * 1e6;
70  return frequency;
71  }
72 
73  private:
74  double frequency; // in hz
75  long int_freq, frac_freq; // in MHz.
76 
77  QString freq2String();
78 
80 
81  int disp_w, disp_h; // width and height of actual string.
82  };
83 }
84 
85 #endif
double getFreq() const
Definition: freqlabel.hpp:49
double updateFrequency()
Definition: freqlabel.hpp:66
QString freq2String()
Definition: freqlabel.cpp:47
void setFreqUpdate(double freq)
Definition: freqlabel.hpp:53
void setFreq(double freq)
Definition: freqlabel.cpp:90
void mousePressEvent(QMouseEvent *event)
Definition: freqlabel.cpp:108
FreqLabel(QWidget *parent=Q_NULLPTR, Qt::WindowFlags f=Qt::WindowFlags())
Definition: freqlabel.cpp:35
void newFreq(double freq)