#include "waveformParams.h" WaveformParams::WaveformParams( int wf, WaveformParams* sib, QWidget* parent ) : QWidget( parent ) { // Copy parameters to member variables. wfNum = wf; sibling = sib; // Create the layouts and group boxes to be used. QVBoxLayout* layout = new QVBoxLayout; //QGridLayout* layout = new QGridLayout; QGroupBox* gen = new QGroupBox( tr( "Waveform General Parameters" ) ); //QGroupBox* dds = new QGroupBox( tr( "Waveform DDS Parameters" ) ); //QGroupBox* pulse = new QGroupBox( tr( "Pulse Out Parameters" ) ); //QGroupBox* attention = new QGroupBox( tr( "Attention Parameters" ) ); QGridLayout* genLayout = new QGridLayout; //QVBoxLayout* ddsLayout = new QVBoxLayout; //QVBoxLayout* pulseLayout = new QVBoxLayout; //QVBoxLayout* attentionLayout = new QVBoxLayout; // Create the lables and lineEdits. genLabels[0] = new QLabel( "Presums" ); genLabels[1] = new QLabel( "TX Mask" ); genLabels[2] = new QLabel( "Start Freq (MHz)" ); genLabels[3] = new QLabel( "Stop Freq (MHz)" ); genLabels[4] = new QLabel( "Zero Pi Mod (true or false)" ); genLabels[5] = new QLabel( "Angle" ); genLabels[6] = new QLabel( "Length Mult." ); genLabels[7] = new QLabel( "DAQ Rec Length (us)" ); genLabels[8] = new QLabel( "DAQ Rec Delay (us)" ); for( int i = 0; i < genNum; ++i ) { genLines[i] = new QLineEdit( "0" ); } // Hide a QLineEdit. genLines[4]->hide(); // Disable a QLineEdit genLines[5]->setEnabled( false ); // Create the combo box and add the items. genComboMod = new QComboBox( this ); genComboMod->addItem( "False" ); genComboMod->addItem( "True" ); // Create the tables. ddsTable = new QTableWidget( 3, 8, this ); pulseTable = new QTableWidget( 2, 8, this ); attentionTable = new QTableWidget( 4, 4, this ); // Connection signals to slots. connect( this, SIGNAL( writeMsg( QString, int ) ), parent, SLOT( writeToLog( QString, int ) ) ); connect( this, SIGNAL( valueChanged( int ) ), parent, SLOT( valuesChanged( int ) ) ); connect( ddsTable, SIGNAL( cellChanged( int, int ) ), this, SLOT( dChanged( int, int ) ) ); connect( genLines[0], SIGNAL( editingFinished() ), parent, SLOT( displayDataRate() ) ); connect( genLines[7], SIGNAL( editingFinished() ), parent, SLOT( displayDataRate() ) ); connect( genLines[2], SIGNAL( editingFinished() ), parent, SLOT( wfFreqChange() ) ); connect( genLines[3], SIGNAL( editingFinished() ), parent, SLOT( wfFreqChange() ) ); connect( genLines[6], SIGNAL( editingFinished() ), parent, SLOT( hiChanChange() ) ); // Set the row and column titles in the tables. QStringList ddsV; QStringList ddsH; QStringList pulseV; QStringList pulseH; QStringList attentionV; QStringList attentionH; ddsV << "Start Frequency" << "Phase Start Zero" << "Phase Start Pi"; ddsH << "DDS1" << "DDS2" << "DDS3" << "DDS4" << "DDS5" << "DDS6" << "DDS7" << "DDS8"; pulseV << "Start Count" << "Width Count"; pulseH << "Pulse Out 0" << "Pulse Out 1" << "Pulse Out 2" << "Pulse Out 3" << "Pulse Out 4" << "Pulse Out 5" << "Pulse Out 6" << "Pulse Out 7"; attentionV << "Chan 1 - Attention 1" << "Chan 1 - Attention 2" << "Chan 2 - Attention 1" << "Chan 2 - Attention 2"; attentionH << "A" << "B" << "C" << "D"; ddsTable->setVerticalHeaderLabels( ddsV ); ddsTable->setHorizontalHeaderLabels( ddsH ); pulseTable->setVerticalHeaderLabels( pulseV ); pulseTable->setHorizontalHeaderLabels( pulseH ); attentionTable->setVerticalHeaderLabels( attentionV ); attentionTable->setHorizontalHeaderLabels( attentionH ); // Add the general elements to the grid layout. for( int j = 0; j < genNum; ++j ) { genLayout->addWidget( genLabels[j], 1, j, Qt::AlignCenter ); genLayout->addWidget( genLines[j], 2, j ); } // Add the combo box to the layout. genLayout->addWidget( genComboMod, 2, 4 ); // Add the tables to the layouts. //ddsLayout->addWidget( ddsTable ); //pulseLayout->addWidget( pulseTable ); //attentionLayout->addWidget( attentionTable ); QTabWidget* otherParams = new QTabWidget( this ); otherParams->addTab( ddsTable, "DDS Parameters" ); otherParams->addTab( pulseTable, "Pulse Out Parameters" ); otherParams->addTab( attentionTable, "Attention Parameters" ); // Set the layouts of the QGroupBoxes. gen->setLayout( genLayout ); //dds->setLayout( ddsLayout ); //pulse->setLayout( pulseLayout ); //attention->setLayout( attentionLayout ); // Add the QGroupBoxes to the main layout. /*layout->addWidget( gen ); layout->addWidget( dds ); layout->addWidget( pulse ); layout->addWidget( attention );*/ /*layout->addWidget( gen, 1, 0, 1, 2 ); layout->addWidget( dds, 2, 0 ); layout->addWidget( pulse, 2, 1 ); layout->addWidget( attention, 3, 0, 1, 2 );*/ layout->addWidget( gen ); layout->addWidget( otherParams ); // If there is a sibling tab passed in, copy the value. Otherwise, set default values of 0. if( sibling ) { copyVals(); } else { setZeros(); } // Set the main layout. this->setLayout( layout ); } WaveformParams::~WaveformParams() { } void WaveformParams::setValue( int table, int row, int column, QString value ) { // Initialize the new cell item. QTableWidgetItem* newItem = NULL; // Perform actions depending on which set of parameters is being affected. switch( table ) { case GENERALP: if( column == 4 ) { if( value == "true" ) { genComboMod->setCurrentIndex( 1 ); } else { genComboMod->setCurrentIndex( 0 ); } } else { genLines[ column ]->setText( value ); // Set the QLineEdit's text. } break; case DDSP: newItem = new QTableWidgetItem( value ); // Create a new Item with the value. if( ( row == 0 ) || ( row == 2 ) ) { newItem->setFlags( Qt::NoItemFlags ); newItem->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled ); } ddsTable->setItem( row, column, newItem ); // Set the cell's item to the new item. break; case PULSEP: newItem = new QTableWidgetItem( value ); // Create a new Item with the value. pulseTable->setItem( row, column, newItem ); // Set the cell's item to the new item. break; case ATTENTP: newItem = new QTableWidgetItem( value ); // Create a new Item with the value. attentionTable->setItem( row, column, newItem ); // Set the cell's item to the new item. break; } } QString WaveformParams::getValue( int table, int row, int column ) { // Create the string that will be returned. QString val; // Depending on the type of table, the value will be retrieved. switch( table ) { case GENERALP: if( column == 4 ) { if( genComboMod->currentIndex() == 0 ) { val = "false"; } else { val = "true"; } } else { val = genLines[ column ]->text(); // Set the QLineEdit's text. } break; case DDSP: val = ddsTable->item( row, column )->text(); break; case PULSEP: val = pulseTable->item( row, column )->text(); break; case ATTENTP: val = attentionTable->item( row, column )->text(); break; } // Return the string that now contains the specified value. return val; } void WaveformParams::gChanged() { emit valueChanged( GENERALP ); } void WaveformParams::dChanged( int r, int c ) { if( r == 1 ) { int fudgeNum = ddsTable->item( 1, c )->text().toInt(); int phaseNum = ( 32768 + fudgeNum ) % 65536; QString newVal; newVal.setNum( phaseNum ); QTableWidgetItem* newItem = NULL; newItem = new QTableWidgetItem( newVal ); // Create a new Item with the value. ddsTable->setItem( 2, c, newItem ); // Set the cell's item to the new item. } } int WaveformParams::getNumber() { return wfNum; } void WaveformParams::copyVals() { // Copy general values. for( int i = 0; i < genNum; ++i ) { this->setValue( GENERALP, 0, i, sibling->getValue( GENERALP, 0, i ) ); } // Copy DDS values. for( int j = 0; j < 8; ++j ) { for( int k = 0; k < 3; ++k ) { this->setValue( DDSP, k, j, sibling->getValue( DDSP, k, j ) ); } } // Copy Pulse Out values. for( int m = 0; m < 8; ++m ) { for( int n = 0; n < 2; ++n ) { this->setValue( PULSEP, n, m, sibling->getValue( PULSEP, n, m ) ); } } // Copy Attention values. for( int p = 0; p < 4; ++p ) { for( int q = 0; q < 4; ++q ) { this->setValue( ATTENTP, q, p, sibling->getValue( ATTENTP, q, p ) ); } } } void WaveformParams::setZeros() { QString val = "0"; // Copy general values. for( int i = 0; i < genNum; ++i ) { this->setValue( GENERALP, 0, i, val ); } // Copy DDS values. for( int j = 0; j < 8; ++j ) { for( int k = 0; k < 3; ++k ) { this->setValue( DDSP, k, j, val ); } } // Copy Pulse Out values. for( int m = 0; m < 8; ++m ) { for( int n = 0; n < 2; ++n ) { this->setValue( PULSEP, n, m, val ); } } // Copy Attention values. for( int p = 0; p < 4; ++p ) { for( int q = 0; q < 4; ++q ) { this->setValue( ATTENTP, q, p, val ); } } }