SoDaRadio-5.0.3-master:8901fb5
soda_wfall_picker.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 SODAWFALL_PICKER_H
30 #define SODAWFALL_PICKER_H
31 #include <QBrush>
32 #include <QColor>
33 #include <QPen>
34 #include <qwt/qwt_picker_machine.h>
35 #include <boost/format.hpp>
36 
37 namespace GUISoDa {
38  class WFallPicker : public QwtPlotPicker {
39  public:
40  WFallPicker(int xAxis, int yAxis, QWidget * canvas) : QwtPlotPicker(xAxis, yAxis, canvas)
41  {
42  setStateMachine(new QwtPickerClickPointMachine);
43  setTrackerMode(QwtPicker::AlwaysOn);
44  setTrackerPen(QPen(Qt::white));
45  }
46 
47  QwtText trackerTextF(const QPointF & pos) const {
48  QColor trbgcolor(Qt::black);
49  trbgcolor.setAlpha(200); // translucent highlight
50 
51  QwtText text((boost::format("%'.4f MHz") % (pos.x() * 1e-6)).str().c_str());
52  text.setBackgroundBrush(QBrush(trbgcolor));
53 
54  return text;
55  }
56  };
57 }
58 
59 #endif // SODAWFALL_PICKER_H
QwtText trackerTextF(const QPointF &pos) const
WFallPicker(int xAxis, int yAxis, QWidget *canvas)