void RadMainWindow :: oporTest (void)
{
    complex<double> * opor = new complex<double> [nd];
    complex<double> * opor2 = new complex<double> [nd];

    for (int i=0; i<nd; i++)
    {
        opor[i] = complex<double>(0.0, 0.0);
        opor2[i] = complex<double>(0.0, 0.0);
    }

    for (int n=0; n< N1; n++)
    {
        double phase = pi*fsp*n*n/(N1*fcvant2) - pi*fsp*n/fcvant2 ; 
        double oc = cos (phase);
        double os = sin (phase);
        opor[n] = complex<double>(oc, os);
    }
    int N2 = (N1/2);
    for (int i=0; i<N2; i++)
    {
        opor2[i] = opor[i+N2];
        opor2[i+nd-N2] = opor[i];
    }
    radDataWidget * wOp = new radDataWidget (opor, N1);
    QMdiSubWindow * subWop = m_mdiArea->addSubWindow (wOp);
    wOp->setWindowTitle (tr("Opor before FFT"));
    wOp->show ();
    subWop->setAttribute (Qt::WA_DeleteOnClose);
    FFT_Transform fft;
    int nfft = nd;//4*FFT_Transform :: pow2roundup(N1);
    opor = fft (opor2, nfft, nfft, FFTW_FORWARD, FFTW_ESTIMATE);
    complex<double> * oporFFT = new complex<double> [nd];
    for (int i=0; i<nd; i++)
    {
        double re = real(opor[i])*nfft;
        double im = imag (opor[i])*nfft;
        oporFFT[i] = complex<double>(re, im);
    }

    radDataWidget * wOpFFT = new radDataWidget (oporFFT, N1);
    wOpFFT->setWindowTitle (tr("Opor after FFT"));
    QMdiSubWindow * subWopFFT = m_mdiArea->addSubWindow (wOpFFT);
    wOpFFT->show ();
    subWopFFT->setAttribute (Qt::WA_DeleteOnClose);
    delete [] opor2;
    delete [] opor;
    delete [] oporFFT;
}
void RadMainWindow :: slotFFT2Test (void)
{
    int nMatr (8);
    CMatrix tMatr (0.0, nMatr, nMatr);
    FFT2_Transform fft2;
    for (int i=0; i<nMatr; i++)
    {
        for (int j=i; j<nMatr; j++)
        {
            double rcorr = 0.5*cos (2*pi/4*(j-i))*(0.1e1-(j-i)/((double) nMatr));
            double icorr = 0.5*sin (2*pi/4*(j-i))*(0.1e1-(j-i)/((double) nMatr));
            tMatr(i, j) = complex<double> (rcorr, icorr);
            tMatr(j, i) = complex<double> (rcorr, icorr);
        }
    }
/*    complex<double> * cm = tMatr.getData();
    for (int i=0; i<nMatr*nMatr; i++)
        qDebug () << __PRETTY_FUNCTION__ << real (cm[i]) << imag (cm[i]);
*/
    radTableWidget * wMatr = new radTableWidget (tMatr.getData(), nMatr, nMatr);
    wMatr->setWindowTitle (tr("Source matrix"));
    QMdiSubWindow * subWMatr = m_mdiArea->addSubWindow (wMatr);
    wMatr->show();
    subWMatr->setAttribute (Qt::WA_DeleteOnClose);
    complex<double> * tMatrFFTData = fft2 (tMatr.getData(), nMatr, nMatr, FFTW_FORWARD, FFTW_ESTIMATE);
    CMatrix tMatrFFT (nMatr, nMatr);
    for (int i=0; i<nMatr; i++)
    {
        for (int j=0; j<nMatr; j++)
        {
            tMatrFFT(i, j) = tMatrFFTData[j+nMatr*i];
        }
    }
    delete [] tMatrFFTData;
    radTableWidget * wMatrFFT = new radTableWidget (tMatrFFT.getData(), nMatr, nMatr);
    wMatrFFT->setWindowTitle (tr("Source matrix after FFT"));

    QMdiSubWindow * subWMatrFFT = m_mdiArea->addSubWindow (wMatrFFT);
    wMatrFFT->show();
    subWMatrFFT->setAttribute (Qt::WA_DeleteOnClose);

    complex<double> * tMatrFFTRevData = fft2 (tMatrFFT.getData(), nMatr, nMatr, FFTW_BACKWARD, FFTW_ESTIMATE);
    radTableWidget * wMatrFFTRev = new radTableWidget (tMatrFFTRevData, nMatr, nMatr);
    wMatrFFTRev->setWindowTitle (tr("Source matrix after forward and backward FFT"));
    QMdiSubWindow * subWMatrFFTRev = m_mdiArea->addSubWindow (wMatrFFTRev);
    wMatrFFTRev->show();
    subWMatrFFTRev->setAttribute (Qt::WA_DeleteOnClose);
    delete [] tMatrFFTRevData;
}
Exemple #3
0
void PERPMainWindow::openForm(const QString &actionName)
{
	QString tableName = actionName;
	tableName.replace("table_", "");
	QString formName = QString("mdiform_%1").arg(tableName);
	if ( d->m_mapeoVentanas.contains(formName) ) {
		d->m_mdiArea->setActiveSubWindow(d->m_mapeoVentanas.value(formName));
		return;
	}
	DBFormDlg *dlg = new DBFormDlg(tableName, this);
	if ( dlg->openSuccess() ) {
		// Muy importante para el mapeo MDI
		dlg->setObjectName(formName);
		dlg->setAttribute(Qt::WA_DeleteOnClose);
		QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
		dlg->init();
		QApplication::restoreOverrideCursor();

		QMdiSubWindow *subWin = d->m_mdiArea->addSubWindow(dlg);
		d->m_mapeoVentanas.insert(formName, subWin);
		subWin->setOption(QMdiSubWindow::RubberBandResize, true);
		subWin->setOption(QMdiSubWindow::RubberBandMove, true);
		// Guardamos una referencia al objeto
		subWin->setAttribute(Qt::WA_DeleteOnClose);
		QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
		subWin->show();
		QApplication::restoreOverrideCursor();

		connect (dlg, SIGNAL(closingWindow(QWidget *)), this, SLOT(closeSubWindow(QWidget *)));
		connect (subWin, SIGNAL(aboutToActivate()), dlg, SLOT(refreshFilterTableView()));
		configuracion.applyDimensionForm(subWin);
	} else {
Exemple #4
0
void App::loadFixtureDefinition(const QString& path)
{
    QLCFixtureDef* fixtureDef = NULL;

    /* Attempt to create a fixture definition from the selected file */
    QString error(tr("Unrecognized file extension: %1").arg(path));
    if (path.toLower().endsWith(KExtFixture) == true)
        fixtureDef = loadQXF(path, error);
    else if (path.toLower().endsWith(KExtAvolitesFixture) == true)
        fixtureDef = loadD4(path, error);
    else
        fixtureDef = NULL;

    if (fixtureDef != NULL)
    {
        /* Create a new sub window and put a fixture editor widget
           in that sub window with the newly-created fixture def */
        QMdiSubWindow* sub = new QMdiSubWindow(centralWidget());
        QLCFixtureEditor* editor = new QLCFixtureEditor(sub, fixtureDef, path);

        sub->setWidget(editor);
        sub->setAttribute(Qt::WA_DeleteOnClose);
        qobject_cast<QMdiArea*> (centralWidget())->addSubWindow(sub);

        editor->show();
        sub->show();
    }
    else
    {
        QMessageBox::warning(this, tr("Fixture loading failed"),
                             tr("Unable to load fixture definition: ") + error);
    }
}
Exemple #5
0
void App::loadFixtureDefinition(const QString& path)
{
	/* Attempt to create a fixture definition from the selected file */
	QLCFixtureDef* fixtureDef = new QLCFixtureDef();
	QFile::FileError error = fixtureDef->loadXML(path);
	if (error == QFile::NoError)
	{
		QLCFixtureEditor* editor;
		QMdiSubWindow* sub;

		/* Create a new sub window and put a fixture editor widget
		   in that sub window with the newly-created fixture def */
		sub = new QMdiSubWindow(centralWidget());
		editor = new QLCFixtureEditor(sub, fixtureDef, path);

		sub->setWidget(editor);
		sub->setAttribute(Qt::WA_DeleteOnClose);
		qobject_cast<QMdiArea*> (centralWidget())->addSubWindow(sub);

		editor->show();
		sub->show();
	}
	else
	{
		delete fixtureDef;
		QMessageBox::warning(this, tr("Fixture loading failed"),
			tr("Unable to load fixture definition: ") +
			QLCFile::errorString(error));
	}
}
Exemple #6
0
void MainWindow::new_combo_trade()
{
    ComboTradeDialog *comboTradeDialog = new ComboTradeDialog;
    QMdiSubWindow *qMdiSubWindow = ui_->mdiArea_combo->addSubWindow(comboTradeDialog);
    qMdiSubWindow->setAttribute(Qt::WA_DeleteOnClose);
    qMdiSubWindow->setFixedSize(320, 240);
    qMdiSubWindow->setWindowFlags(qMdiSubWindow->windowFlags()& ~Qt::WindowMaximizeButtonHint& ~Qt::WindowMinimizeButtonHint);
    qMdiSubWindow->show();
}
void RadMainWindow :: initConvAz (void)
{
    RadarImageProc * rdConv = RadarImageProc::getRadarImage();
    if (!rdConv)
        return;
    ConvAzimuthWidget * cW = rdConv->getCAzWidget();
    QMdiSubWindow * subCW = m_mdiArea->addSubWindow (cW);
    cW->show();
    subCW->setAttribute (Qt::WA_DeleteOnClose);
}
Exemple #8
0
void FileNewController::react() {
   qDebug() << "Creating new window";
   EditSubWindow *newEditWindow = new EditSubWindow(&mdiMain);
   BufferRef buffer = bufferPool.getEmptyBuffer();
   newEditWindow->setBuffer(buffer);
   newEditWindow->show();
   QMdiSubWindow *subWindow = mdiMain.addSubWindow(newEditWindow);
   subWindow->setAttribute(Qt::WA_DeleteOnClose);
   subWindow->show();
}
void RadMainWindow :: slot3DMod (void)
{
    qDebug () << __PRETTY_FUNCTION__;
    imageCreatorForm * icf = new imageCreatorForm (0);
    connect (icf, SIGNAL (imagesData(generatingDataPlus)), this, SLOT (slotGologramCalc(generatingDataPlus)) );
    QMdiSubWindow * subCW = m_mdiArea->addSubWindow (icf);
    connect (icf, SIGNAL (rejected()), subCW, SLOT (close()) );
    icf->show();
    subCW->setAttribute (Qt::WA_DeleteOnClose);
    //icf->exec();
}
void MainWindow::showEncuesta() {
    if (encuesta == 0) {
        encuesta = new EncuestadorForm;
        QMdiSubWindow *subWin = mdiArea->addSubWindow(encuesta, Qt::SubWindow);
        subWin->setAttribute(Qt::WA_DeleteOnClose);
        encuesta->setParent(subWin);
    }
    encuesta->setWindowState(Qt::WindowMaximized);
    encuesta->show();
    encuesta->setFocus(Qt::ActiveWindowFocusReason);
    connect(encuesta, SIGNAL(destroyed()), this, SLOT(hideEncuesta()));
}
void MainWindow::showBarrio() {
    if (barrio == 0) {
        barrio = new BarrioForm;
        QMdiSubWindow *subWin = mdiArea->addSubWindow(barrio, Qt::SubWindow);
        subWin->setAttribute(Qt::WA_DeleteOnClose);
        barrio->setParent(subWin);
    }
    barrio->setWindowState(Qt::WindowMaximized);
    barrio->show();
    barrio->setFocus(Qt::ActiveWindowFocusReason);
    connect(barrio, SIGNAL(destroyed()), this, SLOT(hideBarrio()));
}
void MainWindow::showListado() {
    if (listado == 0) {
        listado = new Listado;
        QMdiSubWindow *subWin = mdiArea->addSubWindow(listado, Qt::SubWindow);
        subWin->setAttribute(Qt::WA_DeleteOnClose);
        listado->setParent(subWin);
    }
    listado->setWindowState(Qt::WindowMaximized);
    listado->show();
    listado->setFocus(Qt::ActiveWindowFocusReason);
    connect(listado, SIGNAL(destroyed()), this, SLOT(hideListado()));
}
Exemple #13
0
// função auxiliar que cria nova instância de uma "subWindow",
// já definindo qual será o "internal widget" dessa "subWindow":
QMdiSubWindow * MainWindow::createSubWindow_( QWidget * internalWidget )
{
	//Uma nova instância de determinada "subWindow" é criada
	// e adicionada ao objeto "mdiArea".
	// E um determinado "widget" é passado aqui para que se torne
	// o "internal Widget" dessa "subWindow":
	QMdiSubWindow * subWin = ui->mdiArea->addSubWindow( internalWidget );

	// Atributo "DeleteOnClose": no evento "close" dessa "subWindow",
	// a instância do objeto "QMdiSubWindow" será liberada/destruída:
	subWin->setAttribute(Qt::WA_DeleteOnClose);

	return subWin; // retorna endereço da nova "subWindow"
}
Exemple #14
0
void MainWindow::new_swing_trade()
{
    QString contractName = tr("Exchange-Contract-").append(QString("%1").arg(swing_counter_));
    SwingTradeDialog *swingTradeDialog = new SwingTradeDialog(contractName, swing_counter_, disp_, this);

    connect(swingTradeDialog, SIGNAL(update_contract(QString)), this, SLOT(update_swing_contract(QString)));

    QMdiSubWindow *qMdiSubWindow = ui_->mdiArea_swing->addSubWindow(swingTradeDialog);
    qMdiSubWindow->setAttribute(Qt::WA_DeleteOnClose);
    qMdiSubWindow->setFixedSize(265, 440);
    qMdiSubWindow->setWindowFlags(qMdiSubWindow->windowFlags()& ~Qt::WindowMaximizeButtonHint& ~Qt::WindowMinimizeButtonHint);
    qMdiSubWindow->setWindowTitle(contractName);
    qMdiSubWindow->show();

    swing_counter_++;
    selcon_->setCurrentText(contractName);
}
Exemple #15
0
void App::slotFileNew()
{
    QLCFixtureEditor* editor;
    QMdiSubWindow* sub;

    sub = new QMdiSubWindow(centralWidget());
    editor = new QLCFixtureEditor(sub, new QLCFixtureDef());

    sub->setWidget(editor);
    sub->setAttribute(Qt::WA_DeleteOnClose);
    sub->setWindowIcon(QIcon(":/fixture.png"));

    qobject_cast<QMdiArea*> (centralWidget())->addSubWindow(sub);

    editor->show();
    sub->show();
}
Exemple #16
0
PlotWithCurves* Group::insertPlot()
{
    QMdiSubWindow* window = new QMdiSubWindow;
    {
        window->setMinimumSize(250, 150);
        window->setWindowIcon(QIcon(":/res/mainWindow/closeAllPlots.png"));
        window->setAttribute(Qt::WA_DeleteOnClose);
    }
    PlotWithCurves* plot = new PlotWithCurves(samplesManager, curvesManagerView, window);
    {
        plot->connect(plot, SIGNAL(destroyed()), this, SLOT(retitle()));
        window->setWidget(plot);
        addSubWindow(window);
        window->show();
        retitle();
    }
    return plot;
}
QWidget*  ImprovedWorkspace::addWindow(QWidget* child,QAction* action)
{
    QMdiSubWindow* sub = addSubWindow(child);
    if(viewMode()==QMdiArea::TabbedView)
    {
        action->setChecked(true);
        sub->setVisible(true);
        child->setVisible(true);
    }
    insertActionAndSubWindow(action,sub);
    connect(action,SIGNAL(triggered()),this,SLOT(ensurePresent()));
    sub->setAttribute(Qt::WA_DeleteOnClose, false);
    child->setAttribute(Qt::WA_DeleteOnClose, false);
    sub->setObjectName(child->objectName());

    sub->installEventFilter(this);
    return sub;
}
Exemple #18
0
void CodeArea::addCodeWindow(Revision *r, QString fileText, int cursorPos = 0)
{
    //setup the widget
    CodeEdit *edit = new CodeEdit(this);
    edit->setPlainText( fileText );
    edit->rev = r;

    //set highlighter no matter what language, dirty hack
    SuperWordHighlighter *wh =
            new SuperWordHighlighter(edit->document());

    //setup the subwindow
    QMdiSubWindow *subWindow = addSubWindow( edit );
    subWindow->showMaximized();
    subWindow->setWindowTitle( edit->rev->getBufferName() );

    //don't delete windows when closed
    subWindow->setAttribute(Qt::WA_DeleteOnClose, false);

    //add to subwindow maps
    subWindowMap[r] = subWindow;
    subWindowMap2[subWindow] = r;

    //save the position, so that it may be restored
    if ( cursorPos > 0 )
    {
        QTextCursor cursor = edit->textCursor();
        cursor.setPosition( cursorPos );
        edit->setTextCursor( cursor );
    }

    notifyNewRevision(r);

    //listen changes
    edit->listenChanges();

    //edit->focusWidget();
    setActiveSubWindow( subWindow );

    //listen to zoom changes
    connect( this, SIGNAL(updateZoom(int)), edit, SLOT(onZoomChanged(int)) );

}
void DnsLookupPlugin::slotMainActionForMenuTriggered() {

    QWidget *parentWidget = qobject_cast<QWidget *> (parent());
    DnsLookupWidget *wgt = new DnsLookupWidget(parentWidget);
    //connect(wgt, SIGNAL(destroyed(QObject *)), this, SLOT(slotWidgetDestoryed(QObject *)));

    QMdiArea *mdiArea = 0;
    if(parentWidget) {
        mdiArea = qobject_cast<QMdiArea *>(parentWidget);
    }
    if(mdiArea) {
        QMdiSubWindow *subWindow = new QMdiSubWindow;
        subWindow->setWidget(wgt);
        subWindow->setAttribute(Qt::WA_DeleteOnClose);
        mdiArea->addSubWindow(subWindow);
        //connect(this, SIGNAL(signalPluginToBeUnloaded()), subWindow, SLOT(close()));

        connect(subWindow, SIGNAL(destroyed(QObject *)), this, SLOT(slotWidgetDestoryed(QObject *)));
        widgetList.append(subWindow);
    } else {
Exemple #20
0
void UserManagerPlugin::slotMainActionForMenuTriggered()
{
    if(isSingle() && UserManagerMainWindow::isRunning()) {
        //TODO: Activate the widget
        qDebug() << "----UserManagerPlugin::slotRun():UserManager Is Running!";
        return;
    }

    QWidget *parentWidget = qobject_cast<QWidget *> (parent());

    HEHUI::User user;
    HEHUI::LoginBase login(&user, name(), parentWidget);
    if (!login.isVerified()) {
        return ;
    }

    bool isYDAdmin = false;
    if(user.getBusinessAddress() == "DG") {
        isYDAdmin = false;
    } else if(user.getBusinessAddress() == "YD") {
        isYDAdmin = true;
    }

    UserManagerMainWindow *wgt = new UserManagerMainWindow(isYDAdmin, parentWidget);
    //connect(userManager, SIGNAL(destroyed(QObject *)), this, SLOT(slotUserManagerWidgetDestoryed(QObject *)));

    QMdiArea *mdiArea = 0;
    if(parentWidget) {
        mdiArea = qobject_cast<QMdiArea *>(parentWidget);
    }
    if(mdiArea) {
        QMdiSubWindow *subWindow = new QMdiSubWindow;
        subWindow->setWidget(wgt);
        subWindow->setAttribute(Qt::WA_DeleteOnClose);
        mdiArea->addSubWindow(subWindow);
        //connect(this, SIGNAL(signalPluginToBeUnloaded()), subWindow, SLOT(close()));

        connect(subWindow, SIGNAL(destroyed(QObject *)), this, SLOT(slotWidgetDestoryed(QObject *)));
        widgetList.append(subWindow);
    } else {
Exemple #21
0
void ChatList::addChatWindow(ChatWindow* chatw)
{

    connect(m_mainWindow, SIGNAL(closing()), chatw, SLOT(save()));
    int listSize = m_chatWindowList.size();
    beginInsertRows(QModelIndex(), listSize, listSize);


    m_chatMenu.addAction(chatw->toggleViewAction());
    connect(chatw, SIGNAL(ChatWindowHasChanged(ChatWindow *)), this, SLOT(changeChatWindow(ChatWindow *)));

    QMdiSubWindow* subWindowChat = static_cast<QMdiSubWindow*>(m_mainWindow->registerSubWindow(chatw,chatw->toggleViewAction()));

    connect(chatw->chat(), SIGNAL(changedName(QString)), subWindowChat, SLOT(setWindowTitle(QString)));
    m_chatWindowList.append(chatw);
    m_chatSubWindowList.append(subWindowChat);

    if((subWindowChat->height()<451)||(subWindowChat->width()<264))
    {
        subWindowChat->resize(264,451);
    }

    if(NULL!=subWindowChat)
    {
        chatw->setSubWindow(subWindowChat);
        subWindowChat->setWindowTitle(tr("%1 (Chat)").arg(chatw->getTitleFromChat()));
        subWindowChat->setWindowIcon(QIcon(":/chat.png"));
        subWindowChat->setAttribute(Qt::WA_DeleteOnClose, false);
        chatw->setAttribute(Qt::WA_DeleteOnClose, false);

        subWindowChat->setVisible(chatw->toggleViewAction()->isChecked());
    }


    endInsertRows();
}
/* Build Module GUI */
void IScale_DynClamp::Module::createGUI( void ) {

	QMdiSubWindow *subWindow  = new QMdiSubWindow;
	subWindow->setAttribute(Qt::WA_DeleteOnClose);
	subWindow->setWindowIcon(QIcon("/usr/local/lib/rtxi/RTXI-widget-icon.png"));
	subWindow->setWindowFlags(Qt::CustomizeWindowHint | Qt::WindowCloseButtonHint | 
	                          Qt::WindowMinimizeButtonHint );
	MainWindow::getInstance()->createMdi(subWindow); 
	subWindow->setWidget(this);

	mainWindow = new IScale_DynClampUI(subWindow);
	// Construct Main Layout - vertical layout
	QVBoxLayout *layout = new QVBoxLayout(this);
	setLayout(layout);
	layout->addWidget(mainWindow);

	// Model Combo Box
	mainWindow->modelComboBox->addItem("LivRudy 2009");
	mainWindow->modelComboBox->addItem("FaberRudy 2000");

	// Set GUI refresh rate
	QTimer *timer = new QTimer(this);
	timer->start(500);

	// Set validators
	mainWindow->APDRepolEdit->setValidator( new QIntValidator(mainWindow->APDRepolEdit) );
	mainWindow->minAPDEdit->setValidator( new QIntValidator(mainWindow->minAPDEdit) );
	mainWindow->stimWindowEdit->setValidator( new QIntValidator(mainWindow->stimWindowEdit) );
	mainWindow->numTrialEdit->setValidator( new QIntValidator(mainWindow->numTrialEdit) );
	mainWindow->intervalTimeEdit->setValidator( new QIntValidator(mainWindow->intervalTimeEdit) );
	mainWindow->BCLEdit->setValidator( new QDoubleValidator(mainWindow->BCLEdit) );
	mainWindow->stimMagEdit->setValidator( new QDoubleValidator(mainWindow->stimMagEdit) );
	mainWindow->stimLengthEdit->setValidator( new QDoubleValidator(mainWindow->stimLengthEdit) );
	mainWindow->CmEdit->setValidator( new QDoubleValidator(mainWindow->CmEdit) );
	mainWindow->LJPEdit->setValidator( new QDoubleValidator(mainWindow->CmEdit) );

	// Connect MainWindow elements to slot functions
	QObject::connect( mainWindow->addStepButton, SIGNAL(clicked(void)), 
	                  this, SLOT( addStep(void)) );
	QObject::connect( mainWindow->deleteStepButton, SIGNAL(clicked(void)), 
	                  this, SLOT( deleteStep(void)) );
	QObject::connect( mainWindow->saveProtocolButton, SIGNAL(clicked(void)), 
	                  this, SLOT( saveProtocol(void)) );
	QObject::connect( mainWindow->loadProtocolButton, SIGNAL(clicked(void)), 
	                  this, SLOT( loadProtocol(void)) );
	QObject::connect( mainWindow->clearProtocolButton, SIGNAL(clicked(void)), 
	                  this, SLOT( clearProtocol(void)) );
	QObject::connect( mainWindow->recordDataCheckBox, SIGNAL(clicked(void)), 
	                  this, SLOT( modify(void)) );
	QObject::connect( mainWindow->startProtocolButton, SIGNAL(toggled(bool)), 
	                  this, SLOT( toggleProtocol(void)) );
	QObject::connect( mainWindow->thresholdButton, SIGNAL(clicked(void)), 
	                  this, SLOT( toggleThreshold(void)) );
	QObject::connect( mainWindow->staticPacingButton, SIGNAL(clicked(void)), 
	                  this, SLOT( togglePace(void)) );
	QObject::connect( mainWindow->resetButton, SIGNAL(clicked(void)), 
	                  this, SLOT( reset(void)) );
	QObject::connect( mainWindow->modelComboBox, SIGNAL(activated(int)), 
	                  this, SLOT( changeModel(int)) );    
	QObject::connect( mainWindow->APDRepolEdit, SIGNAL(returnPressed(void)), 
	                  this, SLOT( modify(void)) );
	QObject::connect( mainWindow->minAPDEdit, SIGNAL(returnPressed(void)), 
	                  this, SLOT( modify(void)) );
	QObject::connect( mainWindow->stimWindowEdit, SIGNAL(returnPressed(void)), 
	                  this, SLOT( modify(void)) );
	QObject::connect( mainWindow->numTrialEdit, SIGNAL(returnPressed(void)), 
	                  this, SLOT( modify(void)) );
	QObject::connect( mainWindow->intervalTimeEdit, SIGNAL(returnPressed(void)), 
	                  this, SLOT( modify(void)) );
	QObject::connect( mainWindow->BCLEdit, SIGNAL(returnPressed(void)), 
	                  this, SLOT( modify(void)) );
	QObject::connect( mainWindow->stimMagEdit, SIGNAL(returnPressed(void)), 
	                  this, SLOT( modify(void)) );
	QObject::connect( mainWindow->stimLengthEdit, SIGNAL(returnPressed(void)), 
	                  this, SLOT( modify(void)) );
	QObject::connect( mainWindow->CmEdit, SIGNAL(returnPressed(void)), 
	                  this, SLOT( modify(void)) );
	QObject::connect( mainWindow->LJPEdit, SIGNAL(returnPressed(void)), 
	                  this, SLOT( modify(void)) );
	QObject::connect(timer, SIGNAL(timeout(void)), 
	                  this, SLOT(refreshDisplay(void)));

	// Connections to allow only one button being toggled at a time
	QObject::connect( mainWindow->thresholdButton, SIGNAL(toggled(bool)), 
	                  mainWindow->staticPacingButton, SLOT( setDisabled(bool)) );
	QObject::connect( mainWindow->thresholdButton, SIGNAL(toggled(bool)),
	                  mainWindow->startProtocolButton, SLOT( setDisabled(bool)) );
	QObject::connect( mainWindow->startProtocolButton, SIGNAL(toggled(bool)), 
	                  mainWindow->staticPacingButton, SLOT( setDisabled(bool)) );
	QObject::connect( mainWindow->startProtocolButton, SIGNAL(toggled(bool)), 
	                  mainWindow->thresholdButton, SLOT( setDisabled(bool)) );
	QObject::connect( mainWindow->staticPacingButton, SIGNAL(toggled(bool)), 
	                  mainWindow->thresholdButton, SLOT( setDisabled(bool)) );
	QObject::connect( mainWindow->staticPacingButton, SIGNAL(toggled(bool)), 
	                  mainWindow->startProtocolButton, SLOT( setDisabled(bool)) );

	// Connect states to workspace
	setData( Workspace::STATE, 0, &time );
	setData( Workspace::STATE, 1, &voltage );
	setData( Workspace::STATE, 2, &beatNum );
	setData( Workspace::STATE, 3, &APD );
	setData( Workspace::STATE, 4, &targetCurrent );
	setData( Workspace::STATE, 5, &scaledCurrent );

	subWindow->show();
	subWindow->adjustSize();
} // End createGUI()
Exemple #23
0
void RadMainWindow :: slotTest2 (void)
{
    qDebug () << __PRETTY_FUNCTION__;
    QString fileName = QFileDialog::getOpenFileName (this, tr("Open convolution data"), QDir::currentPath(), tr("All files (*)"));
    if (fileName.isEmpty())
        return;

    QTime * fftTime = new QTime;
    fftTime->start();
    FILE * fid6 = fopen (fileName.toAscii().constData(), "rb");
    if (!fid6)
        return;
    qDebug () << __PRETTY_FUNCTION__ << fid6 << na_ots;
    int h1 = fseek (fid6, nd*8*na_ots, SEEK_SET);
    if (h1 < 0)
    {
        fclose (fid6);
        return;
    }
    int read (0);
    CMatrix rgg1 (0.0, ndrz, na2);
//    complex<double>* rgg1Vec = new complex<double> [ndrz*na2];
    QFile rggMatrC("rgg1.dat");
    rggMatrC.open(QIODevice::WriteOnly);
    QTextStream rggStr(&rggMatrC);

    for (int i0=0; i0<na2; i0++)
    {
        double * stlb = new double [2*nd];
        double * stlb2 = new double [ndrz*2];
        int cr = fread (stlb, sizeof (double)/2, nd*2, fid6);
        if (cr == 0)
        {
            QMessageBox::warning(this, tr("Read data"), tr("Cannot read convolution data"), QMessageBox::Ok);
            return;
        }
        for (int j=0; j<ndrz*2;j++)
            stlb2[j]=stlb[j+2*ndv];
        for (int j=0; j<ndrz;j++)
        {
            rgg1(j, i0) = complex<double>(stlb2[2*j], stlb2[2*j+1]);
        }
        //qDebug () << __PRETTY_FUNCTION__ << i0 << na2 << cr;
        // << ndv << stlb2[0] << stlb2[2*ndv] << sizeof (quint32);
        delete [] stlb2;
        delete [] stlb;
        read++;
    }
    for (int i=0; i<20; i++)
    {
        for (int j=0; j<20; j++)
            rggStr << real (rgg1(i, j)) << " " << imag (rgg1(i, j)) << "i ";
        rggStr << endl;
    }
    qDebug () << __PRETTY_FUNCTION__ << QString ("Matrices were set") << ndrz << nas << na2;

//    CMatrix corf2 (complex<double>(0.0), ndrz, na2);
    CMatrix corf3 (complex<double>(0.0), ndrz, nas);
    QFile corfCont ("ctest.dat");
    corfCont.open (QIODevice::WriteOnly);
    QTextStream stCorf (&corfCont);
    int from_opor (0);
    //complex<double> * corfVec = new complex<double> [ndrz*na2];
    CMatrix corf (complex<double>(0.0), ndrz, na2);
    qDebug () << __PRETTY_FUNCTION__ << nas << na2;
    for (int i=0; i<ndrz; i++)
    {
        for (int j=0; j<nas; j++)
        {
            double x = (-nas/2+j)*dx;
            double rt = sqrt (R*R+x*x+H*H);
            double rt1 = rt - sqrt (R*R+H*H);
            int N0 = (int)(rt1/dnr);
            double phase = -4*pi*rt/lamb;
            corf3(N0, j) = complex<double>(cos(phase), sin(phase));
            //stCorf << (double)real (corf3(N0, i)) << " " << (double)imag (corf3(N0, i)) << " " << N0 << " " << i << endl;
            //qDebug () << __PRETTY_FUNCTION__ << x << phase << (double)real (corf3(N0, i)) << (double)imag (corf3(N0, i)) << N0 << i;
        }
        from_opor++;
    }
//    complex<double>* c = corf3.getData();
    complex<double> * corfVec = corf3.getData();
    Q_UNUSED (corfVec);
    for (int i=0; i<10/*ndrz*/; i++)
    {
        for (int j=0; j<nas; j++)
        {
            stCorf << qSetRealNumberPrecision(14) << real(corf3(i, j)) << " " << qSetRealNumberPrecision(14) << imag (corf3(i, j)) << "i ";
//                qDebug () << __PRETTY_FUNCTION__ << i << j << real(corf3(i, j)) << imag (corf3(i, j));
        }
        stCorf << endl;
        //qDebug () << __PRETTY_FUNCTION__ << i;
    }

    int cor_func (0);
    for (int i=0; i<nas/2; i++)
    {
        for (int j=0; j<ndrz; j++)
        {
            corf(j, i) = corf3(j, i+nas/2); //corfVec[j+(i+nas/2)*ndrz];//
            corf(j, i+na2-nas/2) = corf3(j, i); // corfVec[j + i*ndrz]; 
            /*if (sqrt (real (corf3(j, i+nas/2))*real (corf3(j, i+nas/2)) + imag (corf3(j, i+nas/2))*imag (corf3(j, i+nas/2))) > 0.1e-15 )
            {
                qDebug () << __PRETTY_FUNCTION__ << i << " " << j << real (corf(j, i+na2-nas/2)) << imag (corf(j, i+na2-nas/2)) << real (corf(j, i)) << imag (corf(j, i));// << real (corf.getData()[i*ndrz+j]) << imag (corf.getData()[i*ndrz+j]);
            }*/
        }
        cor_func++;
    }

    stCorf << QString("Matrix for FFT") << endl;

    for (int i=0; i<2; i++)
    {
        for (int j=0; j<na2; j++)
        {
            double x = real (corf(i,j));
            double y = imag (corf(i,j));
            //if ((i==0 && fabs (x + 0.50376075247194) <= 0.1e-5))// || fabs (xd) > 0.1e-15 || fabs (yd) > 0.1e-15)
            //    qDebug() << __PRETTY_FUNCTION__ << "Debug indices" << i << j;
            stCorf << qSetRealNumberPrecision(16) << x << " " << qSetRealNumberPrecision(16) << y << " ";
        }
        stCorf << endl;
    }
    stCorf << endl;

    FFT2_Transform fft2;// = new FFT2_Transform;
    complex<double> * corfw = fft2(corf.getData(), ndrz, na2, FFTW_FORWARD, FFTW_ESTIMATE);
    stCorf << QString("Results of FFT") << endl;
    int numMatr (0);
    CMatrix corf2 (ndrz, na2);
    for (int i=0; i<ndrz; i++)
    {
        for (int j=0; j<na2; j++)
        {
            corf2(i, j) = corfw[i*na2+j];
            if (i<10)
                stCorf << /*qSetFieldWidth(19) <<*/ qSetRealNumberPrecision(16) << real (corfw[i*na2+j])*ndrz*na2 << " " 
                       << /*qSetFieldWidth(19) <<*/ qSetRealNumberPrecision(16) << imag (corfw[i*na2+j])*ndrz*na2 << "i ";
            numMatr++;
        }
        if (i<10)
            stCorf << endl;
    }
    delete [] corfw;
    complex<double> * rggD = fft2(rgg1.getData(), ndrz, na2, FFTW_FORWARD, FFTW_ESTIMATE);
    CMatrix rgg (ndrz, na2);
    int cor_volfr (0);
    for (int i=0; i<ndrz; i++)
    {
        for (int j=0; j<na2; j++)
        {
            rgg (i, j) = rggD[i*na2+j];
            rgg (i, j) *= conj (corf2 (i, j));
            //rggD[j+i*na2] *= conj (corfw[j+i*na2]);
            //rggD[j+i*na2] /= na2*ndrz;
        }
        cor_volfr++;
    }
    delete [] rggD;
    complex<double> * rggBD = fft2(rgg.getData(), ndrz, na2, FFTW_BACKWARD, FFTW_ESTIMATE);
    double maxVal = 0.0;
//    double minVal = 0.0;//sqrt (real(rggBD[0])*real(rggBD[0])+imag(rggBD[0])*imag(rggBD[0]));
    for (int i=0; i<ndrz*nas/2; i++)
    {
        maxVal = qMax (maxVal, sqrt (real(rggBD[i])*real(rggBD[i])+imag(rggBD[i])*imag(rggBD[i])));
    }
    stCorf << tr("Results ") << endl;
    for (int i=0; i<5; i++)
    {
        for (int j=0; j<na2; j++)
        {
            stCorf << qSetRealNumberPrecision(16) << real (rggBD[i*na2+j])*na2*ndrz << " "
                   << qSetRealNumberPrecision(16) << imag (rggBD[i*na2+j])*na2*ndrz << "i ";
        }
        stCorf << endl;
    }
    qDebug () << __PRETTY_FUNCTION__ << tr ("Image was calculated");
    QImage * hIm = new QImage (ndrz, nas/2, QImage::Format_ARGB32);
//    qDebug () << __PRETTY_FUNCTION__ << hIm->colorCount ();
    double * imData = new double [ndrz*nas/2];
    int ii (0);
    quint32 maxvalim = 0;
    QVector<QRgb> colors;
    for (int i=0; i<ndrz; i++)
    {
        for (int j=0; j<nas/2;j++)
        {
            imData[ii] = sqrt (real(rggBD[ii])*real(rggBD[ii])+imag(rggBD[ii])*imag(rggBD[ii]))/maxVal;//*4000;
            uint val = (uint)(256*imData[ii])/20*20;///512/0.3);
            maxvalim = qMax (maxvalim, val);
            QRgb v = qRgb (val, val, val);
            if (!colors.contains(v))
                colors.append (v);
            QColor vCol (v);
            //int pIndex = hIm->pixelIndex (i, j);
            hIm->setPixel (i, j, v);//qRgb(255, 255, 255));
            //if (val > 0)
            //    qDebug () << __PRETTY_FUNCTION__ << i<< j << ii << imData[ii] << val << vCol ;
            ii++;
        }
    }
    delete [] imData;
    delete [] rggBD;
    //bool isLoaded = hIm->loadFromData (imData, ndrz*nas/2);
    qDebug () << __PRETTY_FUNCTION__ << maxvalim << maxVal;//isLoaded;
    hIm->save("rgg2a.png", "PNG");
    QPixmap pIm = QPixmap::fromImage (*hIm);
    QLabel * lIm = new QLabel ;
    QWidget * wImage = new QWidget;
    QHBoxLayout * hImLay = new QHBoxLayout (wImage);
    lIm->setPixmap (pIm);
    hImLay->addWidget (lIm);
    QMdiSubWindow * subIm = m_mdiArea->addSubWindow (wImage);
    wImage->show ();
    subIm->setAttribute (Qt::WA_DeleteOnClose);

    fclose (fid6);
    int msecs = fftTime->elapsed ();
    FFTTimeWidget * fftWidget = new FFTTimeWidget;
    fftWidget->setTimeElapsed (msecs);
    QMdiSubWindow * subFFTW = m_mdiArea->addSubWindow (fftWidget);
    fftWidget->show();
    subFFTW->setAttribute (Qt::WA_DeleteOnClose);
    delete fftTime;
}
Exemple #24
0
void RadMainWindow :: slotTest1 (void)
{
    if (fileName.isEmpty())
        return;

    QTime * fftTime = new QTime;
    fftTime->start();
    CalcOpor1 * cop = new CalcOpor1 (nd);
    complex<double> * opor = cop->calc();//new complex<double> [nd];
    qDebug () << __PRETTY_FUNCTION__ << N1;
    QFile fContData (QString ("stc4.dat"));
    fContData.open (QIODevice::WriteOnly);
    QTextStream stCont (&fContData);
    FFT_Transform fft;// = new FFT_Transform;
    radDataWidget * wOpFFT = new radDataWidget (opor, N1);
    QMdiSubWindow * subWopFFT = m_mdiArea->addSubWindow (wOpFFT);
    wOpFFT->show ();
    subWopFFT->setAttribute (Qt::WA_DeleteOnClose);
    QFile contOp ("opor_after_FFT.dat");
    contOp.open (QIODevice::WriteOnly);
    QTextStream stOp (&contOp);
    for (int i=0; i<N1; i++)
    {
        double re = real (opor[i])*nd;
        double im = imag (opor[i])*nd;
        stOp << re << " " << im << "i" << endl;
    }
    contOp.close ();

    QFile fData (fileName);
    quint8 * st = new quint8 [nd2];
    for (int i=0; i<nd2; i++)
    {
        st [i] = 0;
    }
    complex<double> * stc = new complex<double>[nd];
    complex<double> * stc1 = new complex<double>[nd];
    for (int i=0; i<nd; i++)
    {
        stc[i] = complex<double> (0.0, 0.0);
        stc1[i] = complex<double> (0.0, 0.0);
    }
    int a = 0;
    Q_UNUSED (a);

    FILE * fid5 = fopen (fileName.toAscii().constData(), "rb");
    qDebug () << __PRETTY_FUNCTION__ << fileName.toAscii().constData() << fid5;
    if (!fData.open (fid5, QIODevice::ReadOnly | QIODevice::Unbuffered))
        return;

    fileConvName = QFileDialog::getSaveFileName (this, tr("Save 1st data"), QDir::currentPath(), tr("All files (*)"));

    FILE * fid6 = fileConvName.isEmpty() ? 0 : fopen (fileConvName.toAscii().constData(), "w+");

    qDebug () << __PRETTY_FUNCTION__ << (int)na;
    QAbstractItemModel * radModel = new QStandardItemModel (nd2, 1, 0);// (nd2, na);

    int nr (0);
    QFile fContStData (QString ("stc.dat"));
    fContStData.open (QIODevice::WriteOnly);
    QTextStream stContSt (&fContStData);
    QSize imSize (nd, na/50);
    QImage * convImage = new QImage (imSize, QImage::Format_RGB32);//QImage::Format_Mono);
    if (!convImage || convImage->size().isNull())
    {
        if (convImage)
            delete convImage;
        return;
    }
    convImage->fill (0);
    double * vals = new double [50*nd];
    double maxval = 0.0;
    for (int i0=0; i0<na; i0++)
    {
        qDebug () << __PRETTY_FUNCTION__ << QString("Read new data");
        int cr = fread (st, sizeof (quint8), nd2, fid5);
        if (cr <= 0)
            return;
        for (int ii=0; ii< nd2; ii++)
        {
            if (i0<1)
            {
                QModelIndex wcIndex = radModel->index (nr, 0);
                radModel->setData (wcIndex, QString::number (st[ii]), Qt::DisplayRole);
                nr++;
            }
        }

        for (int ii=0; ii<128; ii++)
            st[ii] = 0.0;

        for (int ii=0; ii<ndn; ii++)
        {
            double re = st[2*ii+1];
            double im = st[2*ii];
            if (re > 128)
                re -= 256;
            if (im > 128)
                im -= 256;
            if (i0==0)
                stContSt << re << " " << im << endl;
            stc[ii] = complex<double> (re, im);//st[2*ii], st[2*ii+1]);
        }
        complex<double> * stc4 = 0;//new complex<double> [nd];
        qDebug () << __PRETTY_FUNCTION__ << QString ("Forward fft");
        stc4 = fft (stc, nd, nd, FFTW_FORWARD, FFTW_ESTIMATE);
        qDebug () << __PRETTY_FUNCTION__ << i0 << na;
        for (int ii=0; ii<nd; ii++)
        {
            double re = real (stc4[ii])*nd;
            double im = imag (stc4[ii])*nd;
            stc4[ii] = complex<double> (re, im);
            if (i0==0)
                stCont << re << (im >= 0 ? "+" : " ") << im << "i" << endl;
        }
        int n2 = FFT_Transform::pow2roundup(nd);//1024;
        qDebug () << __PRETTY_FUNCTION__ << n2;//QString ("Reverse fft");
        //complex<double> * xConv = new complex<double>[n2];
        for (int ii=0; ii<nd; ii++)
        {
            double rstc4 = real (stc4[ii])/nd;
            double imstc4 = imag (stc4[ii])/nd;
            double ropor = real (opor[ii]);
            double imopor = imag (opor[ii]);
            complex<double> res = complex<double> ((rstc4 * ropor - imstc4*imopor), (rstc4*imopor+imstc4*ropor));
            stc1[ii] = res;//stc4[i]*opor[i];///(nd*nd);
            //qDebug () << __PRETTY_FUNCTION__ << ii << nd;
            //if (i<10)
            //    qDebug () << __PRETTY_FUNCTION__ << real (res) << imag(res) << real (xConv[i]) << imag (xConv[i]);
        }
        delete [] stc4;

        complex<double> * xfft = 0;//new complex<double> [nd];
        qDebug () << __PRETTY_FUNCTION__ << QString ("Reverse fft");
        xfft = fft (stc1, nd, nd, FFTW_BACKWARD, FFTW_ESTIMATE );//| FFTW_MEASURE);
        //delete [] xConv;
        double * stc2 = new double [2*nd];
        double * stc2abs = new double [nd];
        for (int ii=0; ii<nd; ii++)
        {
            int ind = ii;//(ii==0 ? nd-1 : ii-1);
            stc2[2*ii] = real (xfft[ind])/nd;//stc3[i]);
            stc2[2*ii+1] = imag (xfft[ind])/nd;
//            stc2Op << stc2[2*i] << " " << stc2[2*i+1] << endl;
            stc2abs[ii] = sqrt (stc2[2*ii]*stc2[2*ii] + stc2[2*ii+1]*stc2[2*ii+1]);
            if (i0==0)
                maxval = qMax (maxval, stc2abs[ii]);
            double gray (i0==0 ? 0.0 : (stc2abs[ii]/maxval)*20000);
            vals [(i0+1)%50+ii] = gray;
            if ((i0+1)/50*50 == i0+1)
            {
                double gray_ave (0.0);
                for (int iii=0; iii<50; iii++)
                    gray_ave += vals [iii];
                uint val = (uint)(256*(gray_ave/5.0e1));

                QRgb v = qRgb (val, val, val);
                ////qDebug ()  << __PRETTY_FUNCTION__ << v;
                convImage->setPixel (ii, i0/50, v);//qRgb(val, val, val));
            }

            //qDebug () << __PRETTY_FUNCTION__ << ii << (double)stc2abs[ii];

        }
        if (i0==0)
        {
            radDataWidget * wStc2 = new radDataWidget();
            wStc2->setWindowTitle (tr("Stc2 after FFT"));
            QAbstractItemModel * radCModel = new QStandardItemModel (nd, 2, 0);// (nd2, na);
            radCModel->setHeaderData (0, Qt::Horizontal, QString("Real"), Qt::DisplayRole);
            radCModel->setHeaderData (1, Qt::Horizontal, QString("Image"), Qt::DisplayRole);
            radCModel->setHeaderData (2, Qt::Horizontal, QString("Module"), Qt::DisplayRole);
            for (int ii=0; ii<nd; ii++)
            {
                QModelIndex wIndex = radCModel->index (ii, 0);
                radCModel->setData (wIndex, (double)(stc2[2*ii]), Qt::DisplayRole);
                wIndex = radCModel->index (ii, 1);
                radCModel->setData (wIndex, (double)(stc2[2*ii+1]), Qt::DisplayRole);
//                wIndex = radCModel->index (ii, 2);
//                radCModel->setData (wIndex, (double)stc2abs[ii], Qt::DisplayRole);
            }
            wStc2->setModel (radCModel);
            QMdiSubWindow * subWStc2 = m_mdiArea->addSubWindow (wStc2);
            wStc2->show ();
            subWStc2->setAttribute (Qt::WA_DeleteOnClose);
        }
        if (fid6)
        {
            qDebug () << __PRETTY_FUNCTION__ << QString ("Write data");
            size_t h = fwrite (stc2, sizeof (double)/2, 2*nd, fid6);
            int ier = ferror (fid6);
            qDebug () << __PRETTY_FUNCTION__ << QString ("Data were written %1 bytes, error indicator =%2 ").arg (h).arg(ier);
            if (ier)
                qDebug () << __PRETTY_FUNCTION__ << tr ("Write error");
        }
        delete [] xfft;

        delete [] stc2abs;
        delete [] stc2;
    }
    delete [] vals;
    qDebug () << __PRETTY_FUNCTION__ << QString ("Data were read and processed");
    fContData.close();
//    double * stc2abs = new double [nd];
    qDebug () << __PRETTY_FUNCTION__ << convImage->size () << imSize;
/*    QFile fileStc2 ("stc2.dat");
    fileStc2.open (QIODevice::WriteOnly);
    QTextStream stc2Op (&fileStc2);
    for (int i0=0; i0<na; i0++)
    {
        for (int i=0; i<nd; i++)
        {
            int ind = (i==0 ? nd-1 : i-1);
            stc2[2*i] = real (xfft[ind])/nd;//stc3[i]);
            stc2[2*i+1] = imag (xfft[ind])/nd;
            stc2Op << stc2[2*i] << " " << stc2[2*i+1] << endl;
            stc2abs[i] = sqrt (stc2[2*i]*stc2[2*i] + stc2[2*i+1]*stc2[2*i+1]);
            double gray (stc2abs[i]);
            uint val = (uint)(256*gray);

            QRgb v = qRgb (val, val, val);
            Q_UNUSED (v);
            ////qDebug ()  << __PRETTY_FUNCTION__ << v;
            convImage->setPixel (i, i0/5, v);//qRgb(val, val, val));

    ////        qDebug () << __PRETTY_FUNCTION__ << i << (double)stc2abs[i];
        }
        delete [] xfft;

        if (i0==0)
        {
            radDataWidget * wStc2 = new radDataWidget();
            wStc2->setWindowTitle (tr("Stc2 after FFT"));
            QAbstractItemModel * radCModel = new QStandardItemModel (nd, 3, 0);// (nd2, na);
            radCModel->setHeaderData (0, Qt::Horizontal, QString("Real"), Qt::DisplayRole);
            radCModel->setHeaderData (1, Qt::Horizontal, QString("Image"), Qt::DisplayRole);
            radCModel->setHeaderData (2, Qt::Horizontal, QString("Module"), Qt::DisplayRole);
            for (int i=0; i<nd; i++)
            {
                QModelIndex wIndex = radCModel->index (i, 0);
                radCModel->setData (wIndex, (double)(stc2[2*i]), Qt::DisplayRole);
                wIndex = radCModel->index (i, 1);
                radCModel->setData (wIndex, (double)(stc2[2*i+1]), Qt::DisplayRole);
                wIndex = radCModel->index (i, 2);
                radCModel->setData (wIndex, (double)stc2abs[i], Qt::DisplayRole);
            }
            wStc2->setModel (radCModel);
            QMdiSubWindow * subWStc2 = m_mdiArea->addSubWindow (wStc2);
            wStc2->show ();
            subWStc2->setAttribute (Qt::WA_DeleteOnClose);
        }

    //    delete [] stc3;
    ////        qDebug () << __PRETTY_FUNCTION__ << h;
    }
*/
    QString fileImageName = QString ("rgg.png");
    convImage->save (fileImageName, "PNG");

    rggImageWidget * imW = new rggImageWidget;
    imW->setImage (*convImage);
    QMdiSubWindow * subImW = m_mdiArea->addSubWindow (imW);
    imW->show ();
    subImW->setAttribute (Qt::WA_DeleteOnClose);

    int msecs = fftTime->elapsed ();
    FFTTimeWidget * fftWidget = new FFTTimeWidget;
    fftWidget->setTimeElapsed (msecs);
    QMdiSubWindow * subFFTW = m_mdiArea->addSubWindow (fftWidget);
    fftWidget->show();
    subFFTW->setAttribute (Qt::WA_DeleteOnClose);
    delete fftTime;
//    delete [] stc4;
//    delete [] opor;
//    delete [] opor2;
    delete [] stc1;
//    delete [] stc;
    delete [] st;
    delete cop;
    if (fid6)
        fclose (fid6);
    actCalc2->setEnabled (true);
}
Exemple #25
0
void RadMainWindow :: stcFFTTest (void)
{
    if (fileName.isEmpty())
        return;

    radDataWidget * w = new radDataWidget();
    QFile fData (fileName);
    quint8 * st = new quint8 [nd2];
    for (int i=0; i<nd2; i++)
    {
        st [i] = 0;
    }
    complex<double>* stc = new complex<double> [nd];
    complex<double>* stc1 = new complex<double> [nd];
    for (int i=0; i<nd; i++)
    {
        stc[i] = complex<double> (0.0, 0.0);
        stc1[i] = complex<double> (0.0, 0.0);
    }
    int a = 0;
    Q_UNUSED (a);

    FILE * fid5 = fopen (fileName.toAscii().constData(), "rb");
    qDebug () << __PRETTY_FUNCTION__ << fileName.toAscii().constData() << fid5;
    if (!fData.open (fid5, QIODevice::ReadOnly | QIODevice::Unbuffered))
        return;

    qDebug () << __PRETTY_FUNCTION__ << (int)na;
    QAbstractItemModel * radModel = new QStandardItemModel (nd2, 1, 0);// (nd2, na);

    int nr (0);
    QFile fContStData (QString ("stc.dat"));
    fContStData.open (QIODevice::WriteOnly);
    QTextStream stContSt (&fContStData);
    int cr = fread (st, sizeof (quint8), nd2, fid5);
    if (cr <= 0)
        return;
    for (int ii=0; ii< nd2; ii++)
    {
        QModelIndex wcIndex = radModel->index (nr, 0);
        radModel->setData (wcIndex, QString::number (st[ii]), Qt::DisplayRole);
        nr++;
    }
    for (int ii=0; ii<128; ii++)
        st[ii] = 0.0;

    for (int ii=1; ii<=ndn; ii++)
    {
        double re = st[2*ii-1];
        double im = st[2*ii-2];
        if (re > 128)
            re -= 256;
        if (im > 128)
            im -= 256;
        stContSt << re << " " << im << endl;
        stc[ii-1] = complex<double> (re, im);//st[2*ii], st[2*ii+1]);
    }
    for (int i=ndn; i<nd; i++)
        stc[i] = complex<double>(0.0, 0.0);
    radDataWidget * wStc = new radDataWidget(stc, nd);
    QMdiSubWindow * subWStc = m_mdiArea->addSubWindow (wStc);
    wStc->show();
    subWStc->setAttribute (Qt::WA_DeleteOnClose);
    w->setModel (radModel);
    fData.close ();
    QMdiSubWindow * subW = m_mdiArea->addSubWindow (w);
    w->show ();
    subW->setAttribute (Qt::WA_DeleteOnClose);

    FFT_Transform fft;// = new FFT_Transform;
    complex<double>* stc4 = new complex<double> [nd];
    stc4 = fft (stc, nd, nd, FFTW_FORWARD, FFTW_ESTIMATE);
    for (int i=0; i<nd; i++)
    {
        stc4[i] *= nd;
    }
    radDataWidget * wStcFFT = new radDataWidget(stc4, nd);
    QMdiSubWindow * subWStcFFT = m_mdiArea->addSubWindow (wStcFFT);
    wStcFFT->show ();
    subWStcFFT->setAttribute (Qt::WA_DeleteOnClose);
    delete [] stc4;
}
void MainWindow::openPage( int type, quint32 accountid )
{
    if( type <= 0 )
        return;

    QUuid id;
    PageWidgetMember *tab = NULL;
    QString header;

    //usual window
    if( type != 13 )
    {
        if( !hList.contains( type, id ) )
        {
            //create page
            tab = createPage( type, accountid, header );
        }
        else
        {
            //show page
            setPageActive( id, accountid );
            return;
        }
    }
    //transactions window
    else if( type == 13 && accountid > 0 )
    {
        if( !hList.trContains( accountid, id ) )
        {
            tab = createPage( type, accountid, header );
        }
        else
        {
            setPageActive( id );
            return;
        }
    }

    // -------
    // -------

    if( tab == NULL )
        return;

    connect( tab, SIGNAL( closeRequest( const QUuid & ) ), this, SLOT( closePage( const QUuid & ) ) );
    connect( tab, SIGNAL( closed( int ) ), this, SLOT( closedPage( int ) ) );
    connect( tab, SIGNAL( headerChanged( const QString & ) ), this, SLOT( changeHeader( const QString & ) ) );

    //create an empty tab on tabwidget
    disconnect( tabWidget, SIGNAL( currentChanged(int) ), this, SLOT( setPageActive(int) ) );

    tabWidget->addTab( new QWidget(), header );
    tabWidget->setCurrentIndex( tabWidget->count()-1 );
    if( tab->hasIcon() )
        tabWidget->setTabIcon( tabWidget->count()-1, *tab->icon() );

    connect( tabWidget, SIGNAL( currentChanged(int) ), this, SLOT( setPageActive(int) ) );
    // ----

    //create and show window in MDI Area
    QMdiSubWindow *subW = new QMdiSubWindow(this);
    subW->setWidget( tab );
    subW->setWindowTitle( header );
    subW->setAttribute( Qt::WA_DeleteOnClose );
    mdiArea->addSubWindow( subW );
    subW->showMaximized();
    subW->show();
    // -----


    //creating a handler for the tab
    Handler *h = new Handler();
    h->id = QUuid::createUuid();
    h->accountid = accountid;
    h->type = type;
    h->number = tabWidget->count()-1;
    // -----

    tab->setHandler( *h );
    hList.append( h );
}
PerformanceMeasurement::Panel::Panel(QWidget *parent) : QWidget(parent),
	Workspace::Instance("Performance Measurement", vars, num_vars), state(INIT1), duration(0),
	lastRead(0), timestep(0), maxDuration(0), maxTimestep(0), jitter(0) {

		QWidget::setAttribute(Qt::WA_DeleteOnClose);

		// Make Mdi
		QMdiSubWindow *subWindow = new QMdiSubWindow;
	   subWindow->setWindowIcon(QIcon("/usr/local/lib/rtxi/RTXI-widget-icon.png"));
		subWindow->setAttribute(Qt::WA_DeleteOnClose);
		subWindow->setFixedSize(310,200);
		MainWindow::getInstance()->createMdi(subWindow);

		// Create main layout
		QVBoxLayout *layout = new QVBoxLayout;
		QString suffix = QString("s)").prepend(QChar(0x3BC));

		// Create child widget and gridLayout
		QGridLayout *gridLayout = new QGridLayout;

		durationEdit = new QLineEdit(subWindow);
		durationEdit->setReadOnly(true);
		gridLayout->addWidget(new QLabel(tr("Computation Time (").append(suffix)), 1, 0);
		gridLayout->addWidget(durationEdit, 1, 1);

		maxDurationEdit = new QLineEdit(subWindow);
		maxDurationEdit->setReadOnly(true);
		gridLayout->addWidget(new QLabel(tr("Peak Computation Time (").append(suffix)), 2, 0);
		gridLayout->addWidget(maxDurationEdit, 2, 1);

		timestepEdit = new QLineEdit(subWindow);
		timestepEdit->setReadOnly(true);
		gridLayout->addWidget(new QLabel(tr("Real-time Period (").append(suffix)), 3, 0);
		gridLayout->addWidget(timestepEdit, 3, 1);

		maxTimestepEdit = new QLineEdit(subWindow);
		maxTimestepEdit->setReadOnly(true);
		gridLayout->addWidget(new QLabel(tr("Peak Real-time Period (").append(suffix)), 4, 0);
		gridLayout->addWidget(maxTimestepEdit, 4, 1);

		timestepJitterEdit = new QLineEdit(subWindow);
		timestepJitterEdit->setReadOnly(true);
		gridLayout->addWidget(new QLabel(tr("Real-time Jitter (").append(suffix)), 5, 0);
		gridLayout->addWidget(timestepJitterEdit, 5, 1);

		QPushButton *resetButton = new QPushButton("Reset", this);
		gridLayout->addWidget(resetButton, 6, 1);
		QObject::connect(resetButton,SIGNAL(released(void)),this,SLOT(reset(void)));

		// Attach child widget to parent widget
		layout->addLayout(gridLayout);

		// Attach gridLayout to Widget
		setLayout(layout);
		setWindowTitle(QString::number(getID()) + tr(" RT Benchmarks"));

		// Set layout to Mdi
		subWindow->setWidget(this);
		show();

		QTimer *timer = new QTimer(this);
		timer->start(1000);
		QObject::connect(timer,SIGNAL(timeout(void)),this,SLOT(update(void)));
		resetMaxTimer = new QTimer(this);
		QObject::connect(resetMaxTimer,SIGNAL(timeout(void)),this,SLOT(resetMaxTimeStep(void)));

		// Connect states to workspace
		setData(Workspace::STATE, 0, &duration);
		setData(Workspace::STATE, 1, &maxDuration);
		setData(Workspace::STATE, 2, &timestep);
		setData(Workspace::STATE, 3, &maxTimestep);
		setData(Workspace::STATE, 4, &jitter);

		setActive(true);
		saveStats = false;
}