コード例 #1
0
void BandwidthGui::updateGroupInfo()
{
	QString temp;
	GroupDialog dial; //ToDo find correct parent
	dial.setText(m_grpYamlString);

	int result = dial.exec();
	if (result != QDialog::Accepted)
		return;
	temp = dial.text();
	if (m_grpYamlString == temp)
		return;

	GroupMap groupMap;
	if(!groupFromYaml(temp.toStdString(), &groupMap))
	{
		QMessageBox::warning(m_plot->parentWidget(), "Warning!", "Malformed YAML");
		return;
	}
	m_grpYamlString = temp;
	clearPlot();
	m_groupMap = groupMap;

	return;
}
コード例 #2
0
ファイル: spectrum.cpp プロジェクト: no3m/so2sdr
/*! clear all IQ data
 */
void Spectrum::clearIQ()
{
    for (int i = 0; i < sizeIQ; i++) {
        calibSigList[i].n       = 0;
        calibSigList[i].zsum[0] = 0.;
        calibSigList[i].zsum[1] = 0.;
        calibSigList[i].gain    = 1.0;
        calibSigList[i].phase   = 0.;
    }
    if (iqPlotOpen) emit(clearPlot());

    // reset fit params
    for (int i = 0; i < FIT_ORDER; i++) {
        aGain[i]  = 0.;
        aPhase[i] = 0.;
    }
}
コード例 #3
0
/*
 * Setup actions and the signal-slots used in the widget
 */
void PlottingWidget::setupActions()
{
    //ECG navigation control buttons
    prevAction = new QAction(QIcon(":/images/images/media-skip-backward-6.png"), "Prev.", this);
    playAction = new QAction(QIcon(":/images/images/media-playback-start-6.png"), "Play", this);
    pauseAction = new QAction(QIcon(":/images/images/media-playback-pause-6.png"), "Pause", this);
    nextAction = new QAction(QIcon(":/images/images/media-skip-forward-6.png"), "Next", this);

    //Signals-slots
    connect(prevAction, SIGNAL(triggered()), this, SLOT(prev()));
    connect(nextAction, SIGNAL(triggered()), this, SLOT(next()));
    connect(playAction, SIGNAL(triggered()), this, SLOT(play()));
    connect(pauseAction, SIGNAL(triggered()), this, SLOT(pause()));
    connect(timeframeComboBox,SIGNAL(currentIndexChanged(int)),this,SLOT(windowSizeChanged(int)));
    connect(getFilesButton, SIGNAL(clicked()), this, SLOT(getEcgFileList()));
    connect(resetPlotButton, SIGNAL(clicked()), this, SLOT(clearPlot()));
    connect(startingPointSlider, SIGNAL(valueChanged(int)), this, SLOT(updatePlot(int)));
    connect(ecgFilesWidget, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(fileSelected(QListWidgetItem*)));
    connect(playTimer, SIGNAL(timeout()), this, SLOT(next()));
}
コード例 #4
0
ファイル: Istep.cpp プロジェクト: nolanw/rtxiplugins
// The plugin consists of two loops. The outer loop counts cycles, or
// iterations of the inner loop. The inner loop increases the current by one 
// step each time through.
// Do all time keeping in seconds. When showing time to user, though, 
// convert to milliseconds.
void Istep::execute(void)
{
  V = input(0);

  Iout = offset;
  if (cycle < Ncycles)
  {
    if (step < Nsteps)
    {
      if (timeSinceStep >= delay && 
          timeSinceStep - delay + EPS < period * (duty / 100))
      {
        Iout += Amin + (step * deltaI);
      }
          
      if (periodsSincePlot >= PLOT_PERIOD || timeSinceStep <= EPS)
          plot(timeSinceStep * 1000.0, V / 1000, Iout);
      
      periodsSincePlot++;
      timeSinceStep += dt / 1000;
      
      if (timeSinceStep + EPS >= period)
      {
        startNewCurve();
        step++;
        timeSinceStep = periodsSincePlot = 0;
      }
    }
    
    if (step == Nsteps)
    {
      cycle++;
      step = 0;
      if (cycle < Ncycles)
        clearPlot();
    }
  }
  output(0) = Iout / factor;
  output(1) = Iout;
}
コード例 #5
0
ファイル: spectrum.cpp プロジェクト: no3m/so2sdr
/*! calculate gain and phase error for IQ balancing

   if force=true, will fit errors regardless of status of "measure data" option. This
   is needed to fit the error read in from disk when the bandmaps starts. Otherwise, fits
   only need to be done if data is being collected.
 */
void Spectrum::calcError(bool force)
{
    if (!force && !settings.value(s_sdr_iqdata[nrig],s_sdr_iqdata_def[nrig]).toBool()) return;
    double t;
    double phase, phaseDeg;
    double gain;
    double minPhase = 1000.0;
    double minGain  = 10.0;
    double maxPhase = 0.;
    double maxGain  = 0.;
    int    cnt      = 0;

    if (iqPlotOpen) emit(clearPlot());

    // skip points at end points
    int mid1 = sizeIQ / 2 - 5;
    int mid2 = mid1 + 10;

    for (int i = 5; i < (sizeIQ - 5); i++) {
        // skip points near zero freq
        if (i > mid1 && i < mid2) continue;

        if (calibSigList[i].n > 10) {
            calibSigList[i].z[0]  = calibSigList[i].zsum[0] / calibSigList[i].n;
            calibSigList[i].z[1]  = calibSigList[i].zsum[1] / calibSigList[i].n;
            t                     = sqrt(1.0 - 4.0 * calibSigList[i].z[0] * calibSigList[i].z[0]);
            phase                 = asin(2.0 * calibSigList[i].z[1] / t);
            phaseDeg              = phase * 180.0 / M_PI;
            calibSigList[i].phase = phaseDeg;
            if (phaseDeg > maxPhase) {
                maxPhase = phaseDeg;
            }
            if (phaseDeg < minPhase) {
                minPhase = phaseDeg;
            }
            gain                 = t / (1.0 - 2.0 * calibSigList[i].z[0]);
            calibSigList[i].gain = gain;
            if (gain > maxGain) {
                maxGain = gain;
            }
            if (gain < minGain) {
                minGain = gain;
            }
            if (iqPlotOpen) {
                // points plotted starting with negative freqs, zero freq in middle of
                // plot. j is x axis index
                int j = (i + sizeIQ / 2) % sizeIQ;
                emit(gainPoint(j, gain));
                emit(phasePoint(j, phaseDeg));
            }
            cnt++;
        }
    }
    if (cnt > 10) {
        fitErrors();
        if (iqPlotOpen) {
            emit(gainScale(minGain, maxGain));
            emit(phaseScale(minPhase, maxPhase));
            emit(plotGainFunc(aGain[0], aGain[1], aGain[2], aGain[3]));
            emit(plotPhaseFunc(aPhase[0], aPhase[1], aPhase[2], aPhase[3]));
        }
    }
}
コード例 #6
0
ファイル: plotter.cpp プロジェクト: AIS-Bonn/humanoid_op_ros
void Plotter::initPlugin(qt_gui_cpp::PluginContext& context)
{
	m_w = new QWidget;

	m_ui = new Ui::Plotter;
	m_ui->setupUi(m_w);

	context.addWidget(m_w);

	m_plotModel = new PlotModel(this);
	m_plotModel->rootPlot()->setUsedSettings(&m_settings);

	m_plotFilter = new PlotFilterModel(this);
	m_plotFilter->setSourceModel(m_plotModel);

	new JointStatePlot(getNodeHandle(), m_plotModel->rootPlot()); // The created JointStatePlot gets deleted when the root plot does, or all of its child plots

	m_ui->plotView->setModel(m_plotFilter);
	m_ui->plotView->setDragEnabled(true);

	m_ui->plotView->setItemDelegateForColumn(PlotModel::COL_ENABLED, new CheckBoxDelegate);
	m_ui->plotView->setItemDelegateForColumn(PlotModel::COL_COLOR, new ColorDelegate);

	m_ui->plot->addPlot(m_plotModel->rootPlot());

	connect(m_ui->pauseButton, SIGNAL(clicked(bool)), SLOT(handlePaused(bool)));
	connect(m_ui->playButton, SIGNAL(clicked(bool)), SLOT(handlePlay(bool)));
	connect(m_plotModel, SIGNAL(modelReset()), SLOT(updateTreeGeometry()));

	connect(m_ui->searchEdit, SIGNAL(textChanged(QString)), m_plotFilter, SLOT(setFilterRegExp(QString)));
	connect(m_ui->hideCheckBox, SIGNAL(clicked(bool)), m_plotFilter, SLOT(setHideDisabledPlots(bool)));

	m_sub_plot = getNodeHandle().subscribe("/plot", 100, &Plotter::plotDataReceived, this);
	qRegisterMetaType<plot_msgs::PlotConstPtr>("plot_msgs::PlotConstPtr");
	connect(this, SIGNAL(plotDataReceived(plot_msgs::PlotConstPtr)), SLOT(handlePlotData(plot_msgs::PlotConstPtr)), Qt::QueuedConnection);

	m_sub_timewarpStatus = getNodeHandle().subscribe("/tw/control_status", 1, &Plotter::timewarpStatusReceived, this);
	qRegisterMetaType<timewarp::TimeWarpControlConstPtr>("timewarp::TimeWarpControlConstPtr");
	connect(this, SIGNAL(timewarpStatusReceived(timewarp::TimeWarpControlConstPtr)), SLOT(handleTimewarpStatus(timewarp::TimeWarpControlConstPtr)), Qt::QueuedConnection);

	m_pub_timewarpControl = getNodeHandle().advertise<timewarp::TimeWarpControl>("/tw/control", 1);

	m_ui->plotView->installEventFilter(this);

	handleSelectionChanged(0.0, 0.0, false);
	connect(m_ui->plot, SIGNAL(timeChanged()), SLOT(updateTimeWarp()));
	connect(m_ui->plot, SIGNAL(stopPlaying()), SLOT(handleStopPlaying()));
	connect(m_ui->plot, SIGNAL(selectionChanged(double,double,bool)), SLOT(handleSelectionChanged(double,double,bool)));

	QMenu* menu = new QMenu(m_w); // Standard icon names: https://specifications.freedesktop.org/icon-naming-spec/icon-naming-spec-latest.html#names
	m_loadMenuAction = menu->addAction(QIcon::fromTheme("document-open"), "Load data", this, SLOT(load()));
	m_saveMenuAction = menu->addAction(QIcon::fromTheme("document-save"), "Save data", this, SLOT(save()));
	m_assignColoursAction = menu->addAction(QIcon::fromTheme("applications-graphics"), "Assign colours", this, SLOT(assignColours()));
	m_clearMenuAction = menu->addAction(QIcon::fromTheme("edit-delete"), "Clear data", this, SLOT(clear()));
	m_clearPlotMenuAction = menu->addAction(QIcon::fromTheme("edit-clear"), "Clear plot", this, SLOT(clearPlot()));
	m_refreshMenuAction = menu->addAction(QIcon::fromTheme("view-refresh"), "Refresh", this, SLOT(refresh()));
	m_ui->menuButton->setMenu(menu);

	connect(m_ui->pauseButton, SIGNAL(clicked(bool)), m_loadMenuAction, SLOT(setEnabled(bool)));
	connect(m_ui->pauseButton, SIGNAL(clicked(bool)), m_saveMenuAction, SLOT(setEnabled(bool)));
	m_loadMenuAction->setDisabled(true);
	m_saveMenuAction->setDisabled(true);

	m_io = new PlotIO(getNodeHandle(), m_plotModel->rootPlot(), this);
	connect(m_io, SIGNAL(progress(double)), SLOT(ioProgress(double)));

	m_progressDialog = new QProgressDialog(m_w);
	m_progressDialog->setLabelText(tr("I/O in progress"));
	m_progressDialog->setMinimum(0);
	m_progressDialog->setMaximum(100);
	m_progressDialog->setAutoClose(false);
	m_progressDialog->setAutoReset(false);
	m_progressDialog->setCancelButton(0);
}
コード例 #7
0
ファイル: EventViewer.cpp プロジェクト: bluemagic-club/aseba
	EventViewer::EventViewer(unsigned eventId, const QString& eventName, unsigned eventVariablesCount, MainWindow::EventViewers* eventsViewers) :
		eventId(eventId),
		eventsViewers(eventsViewers),
		values(eventVariablesCount),
		startingTime(QTime::currentTime())
	{
		QSettings settings;
		
		// create plot
		plot = new QwtPlot;
		plot->setCanvasBackground(Qt::white);
		plot->setAxisTitle(plot->xBottom, tr("Time (seconds)"));
		plot->setAxisTitle(plot->yLeft, tr("Values"));
		
		QwtLegend *legend = new QwtLegend;
		//legend->setItemMode(QwtLegend::CheckableItem);
		plot->insertLegend(legend, QwtPlot::BottomLegend);
		
		for (size_t i = 0; i < values.size(); i++)
		{
			QwtPlotCurve *curve = new QwtPlotCurve(QString("%0").arg(i));
			#if QWT_VERSION >= 0x060000
			curve->setData(new EventDataWrapper(timeStamps, values[i]));
			#else
			curve->setData(EventDataWrapper(timeStamps, values[i]));
			#endif
			curve->attach(plot);
			curve->setPen(QPen(QColor::fromHsv((i * 360) / values.size(), 255, 100), 2));
		}
		
		QVBoxLayout *layout = new QVBoxLayout(this);
		layout->addWidget(plot);
		
		// add control
		QHBoxLayout *controlLayout = new QHBoxLayout;
		
		status = new QLabel(tr("Recording..."));
		controlLayout->addWidget(status);
		
		pauseRunButton = new QPushButton(QPixmap(QString(":/images/pause.png")), tr("&Pause"));
		connect(pauseRunButton, SIGNAL(clicked()), SLOT(pauseRunCapture()));
		controlLayout->addWidget(pauseRunButton);
		
		QPushButton *clearButton = new QPushButton(QPixmap(QString(":/images/reset.png")), tr("&Clear"));
		connect(clearButton, SIGNAL(clicked()), SLOT(clearPlot()));
		controlLayout->addWidget(clearButton);
		
		const bool timeWindowEnabled(settings.value("EventViewer/timeWindowEnabled", false).toBool());
		timeWindowCheckBox = new QCheckBox(tr("time &window:"));
		controlLayout->addWidget(timeWindowCheckBox);
		timeWindowCheckBox->setChecked(timeWindowEnabled);
		
		timeWindowLength = new QDoubleSpinBox;
		timeWindowLength->setSuffix("s");
		connect(timeWindowCheckBox, SIGNAL(toggled(bool)), timeWindowLength, SLOT(setEnabled(bool))); 
		timeWindowLength->setValue(settings.value("EventViewer/timeWindowLength", 10.).toDouble());
		timeWindowLength->setEnabled(timeWindowEnabled);
		controlLayout->addWidget(timeWindowLength);
		controlLayout->addStretch();
		
		QPushButton *saveToFileButton = new QPushButton(QPixmap(QString(":/images/filesaveas.png")), tr("Save &As..."));
		connect(saveToFileButton, SIGNAL(clicked()), SLOT(saveToFile()));
		controlLayout->addWidget(saveToFileButton);
		
		layout->addLayout(controlLayout);
		
		// receive events
		eventsViewers->insert(eventId, this);
		isCapturing = true;
	}
コード例 #8
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();
}
コード例 #9
0
void plotWindow::setupPlotWindow()
{
  plot = new QGraphicsView(this);
  plot->setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform | QPainter::TextAntialiasing);
  plot->setScene(&plotdata);
  QWidget *centralWidget = new QWidget;
  QVBoxLayout *centralLayout = new QVBoxLayout;
  QHBoxLayout *topContainerLayout = new QHBoxLayout;
  QGridLayout *topLayout = new QGridLayout;
  centralWidget->setLayout(centralLayout);
  const int margin = centralLayout->margin();
  centralLayout->setMargin(0);
  centralLayout->addLayout(topContainerLayout);
  centralLayout->addWidget(plot);
  topContainerLayout->setMargin(margin);
  topContainerLayout->addLayout(topLayout);
  topContainerLayout->addStretch();

  QLabel *matfileLabel = new QLabel("MAT file");
  QLabel *xvarLabel = new QLabel("X Coordinate");
  QLabel *yvarLabel = new QLabel("Y Coordinate");
  QLabel *ptlabelLabel = new QLabel("LABEL");
  QLabel *dimLabel = new QLabel("DIM");

  matfile = new QLineEdit;
  matfile->setReadOnly(true);
  QAction *matfileAct = new QAction(QIcon(":/res/images/cr16-action-fileopen.png"), tr("&Open"), this);
  QToolButton *matfileButton = new QToolButton();
  matfileButton->setDefaultAction(matfileAct);
  connect(matfileAct, SIGNAL(triggered()), this, SLOT(open()));

  xvar = new QComboBox;
  yvar = new QComboBox;
  ptlabel = new QSpinBox;
  dim = new QSpinBox;

  plotSelect = new QListWidget;
  plotSelect->setSelectionMode(QAbstractItemView::SingleSelection);
  QVBoxLayout *dockLayout = new QVBoxLayout;
  QHBoxLayout *buttonsLayout = new QHBoxLayout;
  QWidget     *dockWidget = new QWidget;
  QAction     *removePlotAct = new QAction(QIcon(":/res/images/cr16-action-eraser.png"), "Remove Selected", this);
  QToolButton *removePlotButton = new QToolButton;
  removePlotButton->setDefaultAction(removePlotAct);
  connect(removePlotAct, SIGNAL(triggered()), this, SLOT(removePlot()));

  QAction     *colorizePlotAct = new QAction(QIcon(":/res/images/cr16-action-colorize.png"), "Change Color", this);
  QToolButton *colorizePlotButton = new QToolButton;
  colorizePlotButton->setDefaultAction(colorizePlotAct);
  connect(colorizePlotAct, SIGNAL(triggered()), this, SLOT(colorizePlot()));

  dockWidget->setLayout(dockLayout);
  dockLayout->setMargin(0);
  dockLayout->addSpacing(margin);
  dockLayout->addLayout(buttonsLayout);
  dockLayout->addWidget(plotSelect);
  buttonsLayout->addWidget(removePlotButton);
  buttonsLayout->addWidget(colorizePlotButton);

  QAction *addPlotAct = new QAction(QIcon(":/res/images/cr16-action-add.png"), tr("Add Plot"), this);
  QToolButton *addPlotButton = new QToolButton();
  addPlotButton->setDefaultAction(addPlotAct);
  connect(addPlotAct, SIGNAL(triggered()), this, SLOT(addPlot()));

  QAction *clearAllPlotAct = new QAction(QIcon(":/res/images/cr16-action-remove.png"), tr("Clear All"), this);
  QToolButton *clearAllPlotButton = new QToolButton();
  clearAllPlotButton->setDefaultAction(clearAllPlotAct);
  connect(clearAllPlotAct, SIGNAL(triggered()), this, SLOT(clearPlot()));

  QAction *printAct = new QAction(QIcon(":/res/images/cr16-action-fileprint.png"), tr("Print"), this);
  QToolButton *printButton = new QToolButton();
  printButton->setDefaultAction(printAct);
  connect(printAct, SIGNAL(triggered()), this, SLOT(print()));

  QAction *exportSvgAct = new QAction(QIcon(":/res/images/cr16-action-svg-export.png"), tr("Export to SVG"), this);
  QToolButton *exportSvgButton = new QToolButton();
  exportSvgButton->setDefaultAction( exportSvgAct );
  connect( exportSvgAct, SIGNAL(triggered()), this, SLOT(exportSvg()) );
  
  QComboBox* xyLog = new QComboBox;
  xyLog->insertItem(0, "Linear");
  xyLog->insertItem(1, "SemiLogX");
  xyLog->insertItem(2, "SemiLogY");
  xyLog->insertItem(3, "LogLog");
  xyLog->setCurrentIndex(0);
  connect( xyLog, SIGNAL(currentIndexChanged(int)), &plotdata, SLOT(setAxes(int)) );

  this->addWidget(dockWidget);
  this->addWidget(centralWidget);

  topLayout->addWidget(matfileLabel, 0, 0);
  topLayout->addWidget(xvarLabel, 0, 2);
  topLayout->addWidget(yvarLabel, 0, 3);
  topLayout->addWidget(ptlabelLabel, 0, 4);
  topLayout->addWidget(dimLabel, 0, 5);
  topLayout->addWidget(matfile, 1, 0);
  topLayout->addWidget(matfileButton, 1, 1);
  topLayout->addWidget(xvar, 1, 2);
  topLayout->addWidget(yvar, 1, 3);
  topLayout->addWidget(ptlabel, 1, 4);
  topLayout->addWidget(dim, 1, 5);
  topLayout->addWidget(addPlotButton, 1, 6);
  topLayout->addWidget(clearAllPlotButton, 1, 7);
  topLayout->addWidget(printButton, 1, 8);
  topLayout->addWidget(exportSvgButton, 1, 9 );
  topLayout->addWidget(xyLog, 2, 0 );

  plot->setMinimumSize(plot->mapFromScene(plotdata.sceneRect()).boundingRect().size()*1.1 +
                       QSize(2*plot->frameWidth(), 2*plot->frameWidth()));
}
コード例 #10
0
ファイル: plot.c プロジェクト: cbelth/PurdueCS
void createPlot( char * funcFile, double minX, double maxX) {
    int nvals = MAXCOLS;
    double yy[MAXCOLS];

    clearPlot();

    // Evaluate function and store in vector yy
    double n;
    //for (int i = minX; i <= maxX * (80 / (2.0 * maxX)); i++) {
    int count = 0;
    double step = (maxX - minX) / MAXCOLS;
    //printf("%lf\n" , step);
    for (double i = minX; count < 80; i = (i + step)) {
        //printf("Step %lf\n", i);
        yy[count] = rpn_eval(funcFile, i);
        count++;
        //printf("count: %d x: %lf y: %lf\n", count, i, yy[count - 1]);
    }

    //Compute maximum and minimum y in vector yy
    double maxY = yy[0];
    for (int i = 1; i < MAXCOLS; i++) {
        if (yy[i] > maxY)
            maxY = yy[i];
    }
    //printf("%lf\n", maxY);
    double minY = yy[0];
    for (int i = 1; i < MAXCOLS; i++) {
        if (yy[i] < minY)
            minY = yy[i];
    }
    //printf("%lf\n", minY);

    for (int i = 0; i < MAXCOLS; i++) {
        yy[i] = (yy[i] - minY) * (MAXROWS / (maxY - minY));
        //printf("x: %d y: %lf\n", i, yy[i]);
    }

    //Plot x axis
    //Plot y axis
    
    if (minY >= 0) {
        for (int i = 0; i < MAXROWS; i++) {
            for (int j = 0; j < MAXCOLS; j++) {
                if (i == 39) {
                    plot[i][j] = '_';
                } else if (j == 40) {
                    plot[i][j] = '|';
                }
            }
        }
    } else {
        for (int i = 0; i < MAXROWS; i++) {
            for (int j = 0; j < MAXCOLS; j++) {
                if (i == 19) {
                    plot[i][j] = '_';
                } else if (j == 40) {
                    plot[i][j] = '|';
                }
            }
        }
    }

    int yVal;
    for (int i = 0; i < 80; i++) {
        yVal = (int) yy[i];
        //printf("x: %d y: %d\n", i, yVal);
        if (yVal < 0) {
            yVal = yVal * -1;
            plot[yVal][i] = '*';
        } else {
            plot[39 - yVal][i] = '*';
        }
    }

    // minX is plotted at column 0 and maxX is plotted ar MAXCOLS-1
    // minY is plotted at row 0 and maxY is plotted at MAXROWS-1

    printPlot();

}