Debian Codegraph @

src/mainwindow.cpp

raw symbols SCIP
1 /*
2 * Copyright (C) 2015, Mike Walters <[email protected]>
3 *
4 * This file is part of inspectrum.
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #include <QMessageBox>
21 #include <QtWidgets>
22 #include <QPixmapCache>
23 #include <QRubberBand>
24 #include <sstream>
25
26 #include "mainwindow.h"cxx . . $ `<file>/src/mainwindow.h`/
27 #include "util.h"cxx . . $ `<file>/src/util.h`/
28
29 MainWindowcxx . . $ MainWindow#::MainWindowcxx . . $ MainWindow#MainWindow(49f6e7a06ebc5aa8).()
30 {
31 setWindowTitlecxx . . $ QWidget#setWindowTitle(3520e46b33348bf6).(trcxx . . $ MainWindow#tr(75d9f1c324b4579d).("inspectrum"));
32
33 QPixmapCachecxx . . $ QPixmapCache#::setCacheLimitcxx . . $ QPixmapCache#setCacheLimit(d4f767463ce0a6b3).(40960);
34
35 dockcxx . . $ MainWindow#dock. = new SpectrogramControlscxx . . $ SpectrogramControls#(trcxx . . $ MainWindow#tr(75d9f1c324b4579d).("Controls"), this);
36 dockcxx . . $ MainWindow#dock.->setAllowedAreascxx . . $ QDockWidget#setAllowedAreas(49dde4d298fce72b).(Qtcxx . . $ Qt/::LeftDockWidgetAreacxx . . $ Qt/LeftDockWidgetArea. |cxx . . $ Qt/`operator|`(24a7713c06799b23). Qtcxx . . $ Qt/::RightDockWidgetAreacxx . . $ Qt/RightDockWidgetArea.);
37 addDockWidgetcxx . . $ QMainWindow#addDockWidget(315e3aea24dde9f7).(Qtcxx . . $ Qt/::LeftDockWidgetAreacxx . . $ Qt/LeftDockWidgetArea., dockcxx . . $ MainWindow#dock.);
38
39 inputcxx . . $ MainWindow#input. = new InputSourcecxx . . $ InputSource#();
40 inputcxx . . $ MainWindow#input.->subscribecxx . . $ AbstractSampleSource#subscribe(9fd1f6ac7dfa1247).(this);
41
42 plotscxx . . $ MainWindow#plots. = new PlotViewcxx . . $ PlotView#(inputcxx . . $ MainWindow#input.);
43 setCentralWidgetcxx . . $ QMainWindow#setCentralWidget(108f35f7aa7f3cf9).(plotscxx . . $ MainWindow#plots.);
44
45 // Connect dock inputs
46 connectcxx . . $ QObject#connect(835f87066c895669).(dockcxx . . $ MainWindow#dock., &SpectrogramControlscxx . . $ SpectrogramControls#::openFilecxx . . $ SpectrogramControls#openFile(7df51288a9ebd664)., this, &MainWindowcxx . . $ MainWindow#::openFilecxx . . $ MainWindow#openFile(7df51288a9ebd664).);
47 connectcxx . . $ QObject#connect(835f87066c895669).(dockcxx . . $ MainWindow#dock.->sampleRatecxx . . $ SpectrogramControls#sampleRate., static_cast<void (QLineEditcxx . . $ QLineEdit#::*)(const QStringcxx . . $ QString#&)>(&QLineEditcxx . . $ QLineEdit#::textChangedcxx . . $ QLineEdit#textChanged(3520e46b33348bf6).), this, static_cast<void (MainWindowcxx . . $ MainWindow#::*)(QStringcxx . . $ QString#)>(&MainWindowcxx . . $ MainWindow#::setSampleRatecxx . . $ MainWindow#setSampleRate(7df51288a9ebd664).));
48 connectcxx . . $ QObject#connect(835f87066c895669).(dockcxx . . $ MainWindow#dock., static_cast<void (SpectrogramControlscxx . . $ SpectrogramControls#::*)(int, int)>(&SpectrogramControlscxx . . $ SpectrogramControls#::fftOrZoomChangedcxx . . $ SpectrogramControls#fftOrZoomChanged(3e454b8ccf442868).), plotscxx . . $ MainWindow#plots., &PlotViewcxx . . $ PlotView#::setFFTAndZoomcxx . . $ PlotView#setFFTAndZoom(3e454b8ccf442868).);
49 connectcxx . . $ QObject#connect(835f87066c895669).(dockcxx . . $ MainWindow#dock.->powerMaxSlidercxx . . $ SpectrogramControls#powerMaxSlider., &QSlidercxx . . $ QSlider#::valueChangedcxx . . $ QAbstractSlider#valueChanged(d4f767463ce0a6b3)., plotscxx . . $ MainWindow#plots., &PlotViewcxx . . $ PlotView#::setPowerMaxcxx . . $ PlotView#setPowerMax(d4f767463ce0a6b3).);
50 connectcxx . . $ QObject#connect(835f87066c895669).(dockcxx . . $ MainWindow#dock.->powerMinSlidercxx . . $ SpectrogramControls#powerMinSlider., &QSlidercxx . . $ QSlider#::valueChangedcxx . . $ QAbstractSlider#valueChanged(d4f767463ce0a6b3)., plotscxx . . $ MainWindow#plots., &PlotViewcxx . . $ PlotView#::setPowerMincxx . . $ PlotView#setPowerMin(d4f767463ce0a6b3).);
51 connectcxx . . $ QObject#connect(835f87066c895669).(dockcxx . . $ MainWindow#dock.->cursorsCheckBoxcxx . . $ SpectrogramControls#cursorsCheckBox., &QCheckBoxcxx . . $ QCheckBox#::stateChangedcxx . . $ QCheckBox#stateChanged(d4f767463ce0a6b3)., plotscxx . . $ MainWindow#plots., &PlotViewcxx . . $ PlotView#::enableCursorscxx . . $ PlotView#enableCursors(b45ddcbc8423892c).);
52 connectcxx . . $ QObject#connect(835f87066c895669).(dockcxx . . $ MainWindow#dock.->scalesCheckBoxcxx . . $ SpectrogramControls#scalesCheckBox., &QCheckBoxcxx . . $ QCheckBox#::stateChangedcxx . . $ QCheckBox#stateChanged(d4f767463ce0a6b3)., plotscxx . . $ MainWindow#plots., &PlotViewcxx . . $ PlotView#::enableScalescxx . . $ PlotView#enableScales(b45ddcbc8423892c).);
53 connectcxx . . $ QObject#connect(835f87066c895669).(dockcxx . . $ MainWindow#dock.->annosCheckBoxcxx . . $ SpectrogramControls#annosCheckBox., &QCheckBoxcxx . . $ QCheckBox#::stateChangedcxx . . $ QCheckBox#stateChanged(d4f767463ce0a6b3)., plotscxx . . $ MainWindow#plots., &PlotViewcxx . . $ PlotView#::enableAnnotationscxx . . $ PlotView#enableAnnotations(b45ddcbc8423892c).);
54 connectcxx . . $ QObject#connect(835f87066c895669).(dockcxx . . $ MainWindow#dock.->annosCheckBoxcxx . . $ SpectrogramControls#annosCheckBox., &QCheckBoxcxx . . $ QCheckBox#::stateChangedcxx . . $ QCheckBox#stateChanged(d4f767463ce0a6b3)., dockcxx . . $ MainWindow#dock., &SpectrogramControlscxx . . $ SpectrogramControls#::enableAnnotationscxx . . $ SpectrogramControls#enableAnnotations(b45ddcbc8423892c).);
55 connectcxx . . $ QObject#connect(835f87066c895669).(dockcxx . . $ MainWindow#dock.->commentsCheckBoxcxx . . $ SpectrogramControls#commentsCheckBox., &QCheckBoxcxx . . $ QCheckBox#::stateChangedcxx . . $ QCheckBox#stateChanged(d4f767463ce0a6b3)., plotscxx . . $ MainWindow#plots., &PlotViewcxx . . $ PlotView#::enableAnnotationCommentsTooltipscxx . . $ PlotView#enableAnnotationCommentsTooltips(b45ddcbc8423892c).);
56 connectcxx . . $ QObject#connect(835f87066c895669).(dockcxx . . $ MainWindow#dock.->cursorSymbolsSpinBoxcxx . . $ SpectrogramControls#cursorSymbolsSpinBox., static_cast<void (QSpinBoxcxx . . $ QSpinBox#::*)(int)>(&QSpinBoxcxx . . $ QSpinBox#::valueChangedcxx . . $ QSpinBox#valueChanged(d4f767463ce0a6b3).), plotscxx . . $ MainWindow#plots., &PlotViewcxx . . $ PlotView#::setCursorSegmentscxx . . $ PlotView#setCursorSegments(d4f767463ce0a6b3).);
57
58 // Connect dock outputs
59 connectcxx . . $ QObject#connect(835f87066c895669).(plotscxx . . $ MainWindow#plots., &PlotViewcxx . . $ PlotView#::timeSelectionChangedcxx . . $ PlotView#timeSelectionChanged(9364e6e7bff7660)., dockcxx . . $ MainWindow#dock., &SpectrogramControlscxx . . $ SpectrogramControls#::timeSelectionChangedcxx . . $ SpectrogramControls#timeSelectionChanged(9364e6e7bff7660).);
60 connectcxx . . $ QObject#connect(835f87066c895669).(plotscxx . . $ MainWindow#plots., &PlotViewcxx . . $ PlotView#::zoomIncxx . . $ PlotView#zoomIn(49f6e7a06ebc5aa8)., dockcxx . . $ MainWindow#dock., &SpectrogramControlscxx . . $ SpectrogramControls#::zoomIncxx . . $ SpectrogramControls#zoomIn(49f6e7a06ebc5aa8).);
61 connectcxx . . $ QObject#connect(835f87066c895669).(plotscxx . . $ MainWindow#plots., &PlotViewcxx . . $ PlotView#::zoomOutcxx . . $ PlotView#zoomOut(49f6e7a06ebc5aa8)., dockcxx . . $ MainWindow#dock., &SpectrogramControlscxx . . $ SpectrogramControls#::zoomOutcxx . . $ SpectrogramControls#zoomOut(49f6e7a06ebc5aa8).);
62
63 // Set defaults after making connections so everything is in sync
64 dockcxx . . $ MainWindow#dock.->setDefaultscxx . . $ SpectrogramControls#setDefaults(49f6e7a06ebc5aa8).();
65
66 }
67
68 void MainWindowcxx . . $ MainWindow#::openFilecxx . . $ MainWindow#openFile(7df51288a9ebd664).(QStringcxx . . $ QString# fileName)
69 {
70 QStringcxx . . $ QString# titlecxx . . $ QString#QString(e1217c004a86c950).="%1: %2"cxx . . $ QString#QString(85c52e162fed56f9).;
71 this->setWindowTitlecxx . . $ QWidget#setWindowTitle(3520e46b33348bf6).(title.argcxx . . $ QString#arg(ec0c7a4bb7c7a5fe).(QApplicationcxx . . $ QApplication#::applicationNamecxx . . $ QCoreApplication#applicationName(4365c3963150523e).(),fileName.sectioncxx . . $ QString#section(6e922cf609fb9683).('/'cxx . . $ QChar#QChar(d4f767463ce0a6b3).,-1,-1)));
72
73 // Try to parse osmocom_fft filenames and extract the sample rate and center frequency.
74 // Example file name: "name-f2.411200e+09-s5.000000e+06-t20160807180210.cfile"
75 QRegularExpressioncxx . . $ QRegularExpression# rxcxx . . $ QRegularExpression#QRegularExpression(4279d2539df7cd4a).(QRegularExpressioncxx . . $ QRegularExpression#::anchoredPatterncxx . . $ QRegularExpression#anchoredPattern(fd988a2ab94d906b).("(.*)-f(.*)-s(.*)-.*\\.cfile"cxx . . $ QString#QString(85c52e162fed56f9).));
76 QStringcxx . . $ QString# basename = fileNamecxx . . $ QString#QString(e1217c004a86c950)..sectioncxx . . $ QString#section(6e922cf609fb9683).('/'cxx . . $ QChar#QChar(d4f767463ce0a6b3).,-1,-1);
77
78 auto match = rxcxx . . $ QRegularExpressionMatch#QRegularExpressionMatch(4c7bd13906b2250d)..matchcxx . . $ QRegularExpression#match(76cd69b0d626af6c).(basename);
79 if (match.hasMatchcxx . . $ QRegularExpressionMatch#hasMatch(50ce9a9e25b4a850).()) {
80 QStringcxx . . $ QString# centerfreq = matchcxx . . $ QString#QString(e1217c004a86c950)..capturedcxx . . $ QRegularExpressionMatch#captured(3f3c3d0e9c0eb37f).(2);
81 QStringcxx . . $ QString# samplerate = matchcxx . . $ QString#QString(e1217c004a86c950)..capturedcxx . . $ QRegularExpressionMatch#captured(3f3c3d0e9c0eb37f).(3);
82
83 stdcxx . . $ std/::stringstreamcxx . . $ std/stringstream# sscxx . . $ std/__cxx11/basic_stringstream#basic_stringstream(d3c8ea0e6521074c).(sampleratecxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d)..toUtf8cxx . . $ QString#toUtf8(ef52b713090bc85a).().constDatacxx . . $ QByteArray#constData(a9f41ea0e82d88cf).());
84
85 // Needs to be a double as the number is in scientific format
86 double rate;
87 ss >>cxx . . $ std/basic_istream#`operator>>`(f2556f805cc4390e). rate;
88 if (!ss.failcxx . . $ std/basic_ios#fail(50ce9a9e25b4a850).()) {
89 setSampleRatecxx . . $ MainWindow#setSampleRate(ba8836b59fb42830).(rate);
90 }
91 }
92
93 try
94 {
95 inputcxx . . $ MainWindow#input.->openFilecxx . . $ InputSource#openFile(85c52e162fed56f9).(fileName.toUtf8cxx . . $ QString#toUtf8(ef52b713090bc85a).().constDatacxx . . $ QByteArray#constData(a9f41ea0e82d88cf).());
96 }
97 catch (const stdcxx . . $ std/::exception &ex)
98 {
99 QMessageBoxcxx . . $ QMessageBox# msgBoxcxx . . $ QMessageBox#QMessageBox(c35ff04b6b0c50a0).(QMessageBoxcxx . . $ QMessageBox#::Criticalcxx . . $ QMessageBox#Critical., "Inspectrum openFile error"cxx . . $ QString#QString(85c52e162fed56f9)., QStringcxx . . $ QString#QString(85c52e162fed56f9).("%1: %2").argcxx . . $ QString#arg(bc823072288cbbb5).(fileName).argcxx . . $ QString#arg(bc823072288cbbb5).(excxx . . $ QString#QString(85c52e162fed56f9)..what()));
100 msgBox.execcxx . . $ QDialog#exec(b126dc7c1de90089).();
101 }
102 }
103
104 void MainWindowcxx . . $ MainWindow#::invalidateEventcxx . . $ MainWindow#invalidateEvent(49f6e7a06ebc5aa8).()
105 {
106 plotscxx . . $ MainWindow#plots.->setSampleRatecxx . . $ PlotView#setSampleRate(ba8836b59fb42830).(inputcxx . . $ MainWindow#input.->ratecxx . . $ InputSource#rate(31fa7155c10fdd13).());
107
108 // Only update the text box if it is not already representing
109 // the current value. Otherwise the cursor might jump or the
110 // representation might change (e.g. to scientific).
111 double currentValue = dockcxx . . $ MainWindow#dock.->sampleRatecxx . . $ SpectrogramControls#sampleRate.->textcxx . . $ QLineEdit#text(6ef7b6c27b00b43d).().toDoublecxx . . $ QString#toDouble(1bd8e57dd4a29c14).();
112 if(QStringcxx . . $ QString#::numbercxx . . $ QString#number(ac5d358e2e30f7ea).(inputcxx . . $ MainWindow#input.->ratecxx . . $ InputSource#rate(31fa7155c10fdd13).()) !=cxx . . $ `operator!=`(edf9e4f73813982f). QStringcxx . . $ QString#::numbercxx . . $ QString#number(ac5d358e2e30f7ea).(currentValue)) {
113 setSampleRatecxx . . $ MainWindow#setSampleRate(ba8836b59fb42830).(inputcxx . . $ MainWindow#input.->ratecxx . . $ InputSource#rate(31fa7155c10fdd13).());
114 }
115 }
116
117 void MainWindowcxx . . $ MainWindow#::setSampleRatecxx . . $ MainWindow#setSampleRate(7df51288a9ebd664).(QStringcxx . . $ QString# rate)
118 {
119 auto sampleRate = rate.toDoublecxx . . $ QString#toDouble(1bd8e57dd4a29c14).();
120 inputcxx . . $ MainWindow#input.->setSampleRatecxx . . $ InputSource#setSampleRate(ba8836b59fb42830).(sampleRate);
121 plotscxx . . $ MainWindow#plots.->setSampleRatecxx . . $ PlotView#setSampleRate(ba8836b59fb42830).(sampleRate);
122
123 // Save the sample rate in settings as we're likely to be opening the same file across multiple runs
124 QSettingscxx . . $ QSettings# settingscxx . . $ QSettings#QSettings(749de1b6ae65bddd).;
125 settings.setValuecxx . . $ QSettings#setValue(1c60a90c724e6bfb).("SampleRate"cxx . . $ QString#QString(85c52e162fed56f9)., sampleRatecxx . . $ QVariant#QVariant(ba8836b59fb42830).);
126 }
127
128 void MainWindowcxx . . $ MainWindow#::setSampleRatecxx . . $ MainWindow#setSampleRate(ba8836b59fb42830).(double rate)
129 {
130 dockcxx . . $ MainWindow#dock.->sampleRatecxx . . $ SpectrogramControls#sampleRate.->setTextcxx . . $ QLineEdit#setText(3520e46b33348bf6).(QStringcxx . . $ QString#::numbercxx . . $ QString#number(ac5d358e2e30f7ea).(rate));
131 }
132
133 void MainWindowcxx . . $ MainWindow#::setFormatcxx . . $ MainWindow#setFormat(7df51288a9ebd664).(QStringcxx . . $ QString# fmt)
134 {
135 inputcxx . . $ MainWindow#input.->setFormatcxx . . $ InputSource#setFormat(8d4ab0a187bf9331).(fmtcxx . . $ std/__cxx11/basic_string#basic_string(3bc0f77cdfbaa67f)..toUtf8cxx . . $ QString#toUtf8(ef52b713090bc85a).().constDatacxx . . $ QByteArray#constData(a9f41ea0e82d88cf).());
136 }