コード例 #1
0
void PlotTableWidget::loadFromBagFile(const QString& fileName) {
  clearPlots();
  
  for (size_t row = 0; row < plotWidgets_.count(); ++row)
    for (size_t column = 0; column < plotWidgets_[row].count(); ++column)
      plotWidgets_[row][column]->setBroker(bagReader_);
  
  runPlots();
    
  bagReader_->read(fileName);
}
コード例 #2
0
So2sdrBandmap::So2sdrBandmap(QStringList args, QWidget *parent) : QMainWindow(parent)
{
    setupUi(this);
    initPointers();
    initVariables();

    // check to see if user directory exists
    initialized = checkUserDirectory();
    settingsFile = userDirectory()+"/so2sdr-bandmap.ini";

    // check for optional command argument giving station config file name
    if (args.size() > 1) {
        settingsFile = args[1].trimmed();
        // Qt doesn't understand that ~/... implies home directory...
        if (settingsFile.left(1)=="~") {
            if (settingsFile.left(2)=="~/") {
                settingsFile=QDir::homePath()+settingsFile.right(settingsFile.size()-1);
            } else {
                // for cases like ~name : no easy way to parse, give up
                QMessageBox msgBox;
                msgBox.setText("Please use the complete path to the settings file.");
                msgBox.setInformativeText(settingsFile);
                msgBox.setStandardButtons(QMessageBox::Ok);
                msgBox.setDefaultButton(QMessageBox::Ok);
                msgBox.exec();
                close();
            }
        }
    }
    QFileInfo fi(settingsFile);
    if (!fi.exists()) {
        QMessageBox msgBox;
        msgBox.setText("The settings file "+settingsFile+" does not exist.");
        msgBox.setInformativeText("Do you want to create it?");
        msgBox.setStandardButtons(QMessageBox::Save | QMessageBox::Cancel);
        msgBox.setDefaultButton(QMessageBox::Save);
        if (msgBox.exec()==QMessageBox::Cancel) {
            close();
        }
        firstTime=true;
    }
    settings = new  QSettings(settingsFile,QSettings::IniFormat,this);
    if (settings->status()!=QSettings::NoError) {
        errorBox.showMessage("ERROR: problem starting qsettings");
    }
    // if run the first time with default settings file for second radio,
    // set second radio
    if (firstTime && settingsFile.right(19)=="so2sdr-bandmap2.ini") {
        settings->setValue(s_sdr_nrig,1);
    }
    // restore window size and position
    QString tmp="BandmapWindow";
    settings->beginGroup(tmp);
    resize(settings->value("size", QSize(400, 594)).toSize());
    move(settings->value("pos", QPoint(200, 200)).toPoint());
    settings->endGroup();

    directory.setCurrent(dataDirectory());
    setWindowIcon(QIcon("icon24x24.png"));

    if (settings->value(s_sdr_reverse_scroll,s_sdr_reverse_scroll_def).toBool()) {
        horizontalLayout->removeWidget(CallLabel);
        horizontalLayout->removeWidget(FreqLabel);
        horizontalLayout->removeWidget(display);
        horizontalLayout->insertWidget(0,CallLabel);
        horizontalLayout->insertWidget(1,FreqLabel);
        horizontalLayout->insertWidget(2,display);
    }

    freqPixmap      = QPixmap(FreqLabel->width(), settings->value(s_sdr_fft,s_sdr_fft_def).toInt());
    callPixmap      = QPixmap(CallLabel->width(), settings->value(s_sdr_fft,s_sdr_fft_def).toInt());

    ipAddress= QHostAddress(QHostAddress::LocalHost).toString();
    if (!server.listen(QHostAddress::LocalHost,
                        settings->value(s_sdr_bandmap_tcp_port,s_sdr_bandmap_tcp_port_def).toInt())) {
        qDebug("couldn't start tcp server");
    }
    connect(&server, SIGNAL(newConnection()), this, SLOT(startConnection()));

    setFocusPolicy(Qt::StrongFocus);
    setFocusPolicy(Qt::NoFocus);
    display->setFocusPolicy(Qt::NoFocus);
    CallLabel->setFocusPolicy(Qt::NoFocus);
    FreqLabel->setFocusPolicy(Qt::NoFocus);

    checkBoxMark.setText("Mark");
    checkBoxMark.setToolTip("Enables signal detection.");
    toolBar->setMovable(false);
    QWidget* spacer1 = new QWidget();
    spacer1->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred);
    toolBar->addWidget(spacer1);
    toolBar->addWidget(&checkBoxMark);
    txLabel.clear();
    txLabel.setText("<font color=#000000>TX");
    toolBar->addWidget(&txLabel);
    slider.setToolTip("Gain for signal detection. To the right is LESS sensitive.");
    slider.setOrientation(Qt::Horizontal);
    connect(&slider,SIGNAL(valueChanged(int)),this,SLOT(updateLevel(int)));
    slider.setFixedWidth(60);
    slider.setMaximum(200);
    slider.setMinimum(0);
    slider.setSingleStep(10);
    slider.setPageStep(50);
    slider.setValue(settings->value(s_sdr_level,s_sdr_level_def).toInt());
    toolBar->addWidget(&slider);
    QWidget* spacer2 = new QWidget();
    spacer2->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred);
    toolBar->addWidget(spacer2);
    toolBar->addAction("&Help",this,SLOT(showHelp()));

    iqDialog  = new IQBalance(this, Qt::Window);
    iqDialog->clearPlots();
    showToolBar = new QAction("&toolbar",this);
    scaleX1   = new QAction("Zoom x&1", this);
    scaleX2   = new QAction("Zoom x&2", this);
    deleteAct = new QAction("&Delete Call", this);
    checkBoxMark.setChecked(settings->value(s_sdr_peakdetect,s_sdr_peakdetect_def).toBool());

    iqShowData = new QAction("IQ Balance", this);
    connect(iqShowData, SIGNAL(triggered()), this, SLOT(showIQData()));
    connect(&checkBoxMark, SIGNAL(clicked()), this, SLOT(emitParams()));
    connect(deleteAct, SIGNAL(triggered()), this, SLOT(deleteCallMouse()));
    showToolBar->setCheckable(true);
    showToolBar->setChecked(true);
    connect(showToolBar,SIGNAL(triggered(bool)),this,SLOT(setShowToolbar(bool)));
    scaleX1->setCheckable(true);
    scaleX2->setCheckable(true);
    scaleX2->setChecked(false);
    scaleX1->setChecked(true);
    connect(scaleX1, SIGNAL(triggered()), this, SLOT(setScaleX1()));
    connect(scaleX2, SIGNAL(triggered()), this, SLOT(setScaleX2()));
    connect(actionRun,SIGNAL(triggered()),this,SLOT(start()));

    sdrSetup = new SDRDialog(*settings,this);
    connect(actionSetup,SIGNAL(triggered()),sdrSetup,SLOT(show()));
    connect(actionSetup,SIGNAL(triggered()),this,SLOT(disconnectSignals()));
    connect(sdrSetup,SIGNAL(setupErrors(QString)),&errorBox,SLOT(showMessage(QString)));
    connect(sdrSetup,SIGNAL(update()),this,SLOT(setSdrType()));
    connect(sdrSetup,SIGNAL(restartSdr()),this,SLOT(restartSdr()));
    connect(display, SIGNAL(displayMouseQSY(int)), this, SLOT(mouseQSYDelta(int)));
    toolBarHeight = toolBar->height();

    // select type of SDR, create data source sdrSource
    spectrumProcessor = new Spectrum(this,*settings,userDirectory());
    switch ((SdrType)settings->value(s_sdr_type,s_sdr_type_def).toInt()) {
    case soundcard_t:
        sdrSource = new AudioReaderPortAudio(settingsFile);
        break;
    case afedri_t:
        sdrSource = new Afedri(settingsFile);
        break;
    case network_t:
        sdrSource = new NetworkSDR(settingsFile);
        break;
    }
    setSdrType();
    sdrSource->moveToThread(&sdrThread);
    connect(actionSetup,SIGNAL(triggered()),sdrSource,SLOT(stop()),Qt::DirectConnection);
    connect(&sdrThread,SIGNAL(started()),sdrSource,SLOT(initialize()));
    connect(sdrSource,SIGNAL(stopped()),&sdrThread,SLOT(quit()));
    connect(sdrSource,SIGNAL(stopped()),this,SLOT(disconnectSignals()));
    connect(sdrSource,SIGNAL(error(QString)),&errorBox,SLOT(showMessage(QString)));

    connect(spectrumProcessor, SIGNAL(spectrumReady(unsigned char*, unsigned char)), display,
            SLOT(plotSpectrum(unsigned char*, unsigned char)));
    connect(sdrSource, SIGNAL(ready(unsigned char *, unsigned char)),spectrumProcessor,
            SLOT(processData(unsigned char *, unsigned char)),Qt::QueuedConnection);
    connect(iqDialog, SIGNAL(closed(bool)), spectrumProcessor, SLOT(setPlotPoints(bool)));
    connect(iqDialog, SIGNAL(restart()), spectrumProcessor, SLOT(clearIQ()));
    connect(spectrumProcessor, SIGNAL(qsy(int)), this, SLOT(findQsy(int)));
    connect(spectrumProcessor, SIGNAL(clearPlot()), iqDialog, SLOT(clearPlots()));
    connect(spectrumProcessor, SIGNAL(gainPoint(int, double)), iqDialog, SLOT(plotGainPoint(int, double)));
    connect(spectrumProcessor, SIGNAL(phasePoint(int, double)), iqDialog, SLOT(plotPhasePoint(int, double)));
    connect(spectrumProcessor, SIGNAL(gainScale(double, double)), iqDialog, SLOT(setGainScale(double, double)));
    connect(spectrumProcessor, SIGNAL(phaseScale(double, double)), iqDialog, SLOT(setPhaseScale(double, double)));
    connect(spectrumProcessor, SIGNAL(plotGainFunc(double, double, double, double)), iqDialog,
           SLOT(plotGainFunc(double, double, double, double)));
    connect(spectrumProcessor, SIGNAL(plotPhaseFunc(double, double, double, double)), iqDialog,
           SLOT(plotPhaseFunc(double, double, double, double)));

    // vfoPos is the position of the red line indicating center
    vfoPos          = (height()-toolBarHeight)/ 2;
    dragPos         = vfoPos;
    display->setVfoPos(vfoPos);

    makeFreqScaleAbsolute();
    FreqLabel->setPixmap(freqPixmap);
    FreqLabel->update();

    startTimers();
    show();
}