CLSSIS3820ScalerControlsView::CLSSIS3820ScalerControlsView(CLSSIS3820Scaler *scaler, QWidget *parent) :
	QWidget(parent)
{
	// Initialize member variables.

	scaler_ = 0;

	// Create UI elements.

	acquisitionModeBox_ = new QComboBox;

	startButton_ = new QPushButton(QIcon(":/22x22/media-playback-start.png"), "Start");
	startButton_->setMaximumHeight(25);

	stopButton_ = new QPushButton(QIcon(":/22x22/media-playback-stop.png"), "Stop");
	stopButton_->setMaximumHeight(25);

	statusLabel_ = new QLabel;

	dwellTimeBox_ = new QDoubleSpinBox;
	dwellTimeBox_->setFixedWidth(100);
	dwellTimeBox_->setAlignment(Qt::AlignCenter);

	scansPerBufferBox_ = new QSpinBox;
	scansPerBufferBox_->setFixedWidth(100);
	scansPerBufferBox_->setAlignment(Qt::AlignCenter);

	totalScansBox_ = new QSpinBox;
	totalScansBox_->setFixedWidth(100);
	totalScansBox_->setAlignment(Qt::AlignCenter);

	// Create and set layouts.

	QHBoxLayout *buttonsLayout = new QHBoxLayout;
	buttonsLayout->addWidget(startButton_);
	buttonsLayout->addWidget(stopButton_);

	QVBoxLayout *statusLayout = new QVBoxLayout;
	statusLayout->addWidget(statusLabel_, 0, Qt::AlignCenter);
	statusLayout->addLayout(buttonsLayout);
	statusLayout->addWidget(acquisitionModeBox_, 0, Qt::AlignCenter);

	QGridLayout *controlsLayout = new QGridLayout();
	controlsLayout->addWidget(new QLabel("Dwell Time: "), 0, 0, 1, 1, Qt::AlignRight);
	controlsLayout->addWidget(dwellTimeBox_, 0, 1);
	controlsLayout->addWidget(new QLabel("Scans per Buffer: "), 1, 0, 1, 1, Qt::AlignRight);
	controlsLayout->addWidget(scansPerBufferBox_, 1, 1);
	controlsLayout->addWidget(new QLabel("Total Scans: "), 2, 0, 1, 1, Qt::AlignRight);
	controlsLayout->addWidget(totalScansBox_, 2, 1);

	QHBoxLayout *layout = new QHBoxLayout;
	layout->addLayout(statusLayout);
	layout->addLayout(controlsLayout);

	setLayout(layout);

	// Make connections.

	connect(startButton_, SIGNAL(clicked()), this, SLOT(startScanning()));
	connect(stopButton_, SIGNAL(clicked()), this, SLOT(stopScanning()));
	connect(acquisitionModeBox_, SIGNAL(currentIndexChanged(int)), this, SLOT(setContinuous()));
	connect(dwellTimeBox_, SIGNAL(editingFinished()), this, SLOT(setDwellTime()));
	connect(scansPerBufferBox_, SIGNAL(editingFinished()), this, SLOT(setScansPerBuffer()));
	connect(totalScansBox_, SIGNAL(editingFinished()), this, SLOT(setTotalScans()));

	// Current settings.

	setScaler(scaler);

	refresh();
}
CLSSIS3820ScalerControlsView::CLSSIS3820ScalerControlsView(CLSSIS3820Scaler *scaler, QWidget *parent) :
	QWidget(parent)
{
	// Initialize member variables.

	scaler_ = 0;

	// Create UI elements.

	modeChoice_ = new QComboBox;
	modeChoice_->addItems(QStringList() << "Single Shot" << "Continuous");
	modeChoice_->setCurrentIndex(0);

	startButton_ = new QPushButton(QIcon(":/22x22/media-playback-start.png"), "Start");
	startButton_->setMaximumHeight(25);

	stopButton_ = new QPushButton(QIcon(":/22x22/media-playback-stop.png"), "Stop");
	stopButton_->setMaximumHeight(25);

	status_ = new QLabel;
	status_->setPixmap(QIcon(":/32x32/greenLEDOff.png").pixmap(25));

	time_ = new QSpinBox;
	time_->setRange(0, 1000000);
	time_->setValue(1000);
	time_->setSuffix(" ms");
	time_->setFixedWidth(100);
	time_->setAlignment(Qt::AlignCenter);

	scansPerBuffer_ = new QSpinBox;
	scansPerBuffer_->setRange(0, 10000);
	scansPerBuffer_->setValue(1);
	scansPerBuffer_->setFixedWidth(100);
	scansPerBuffer_->setAlignment(Qt::AlignCenter);

	totalScans_ = new QSpinBox;
	totalScans_->setRange(0, 10000);
	totalScans_->setValue(1);
	totalScans_->setFixedWidth(100);
	totalScans_->setAlignment(Qt::AlignCenter);

	// Create and set layouts.

	QHBoxLayout *startAndStopButtons = new QHBoxLayout;
	startAndStopButtons->addWidget(startButton_);
	startAndStopButtons->addWidget(stopButton_);

	QVBoxLayout *statusAndModeLayout = new QVBoxLayout;
	statusAndModeLayout->addWidget(status_, 0, Qt::AlignCenter);
	statusAndModeLayout->addLayout(startAndStopButtons);
	statusAndModeLayout->addWidget(modeChoice_, 0, Qt::AlignCenter);

	QHBoxLayout *timeLayout = new QHBoxLayout;
	timeLayout->addWidget(new QLabel("Dwell Time:"), 0, Qt::AlignRight);
	timeLayout->addWidget(time_);

	QHBoxLayout *scansPerBufferLayout = new QHBoxLayout;
	scansPerBufferLayout->addWidget(new QLabel("Scans per Buffer:"), 0, Qt::AlignRight);
	scansPerBufferLayout->addWidget(scansPerBuffer_);

	QHBoxLayout *totalScansLayout = new QHBoxLayout;
	totalScansLayout->addWidget(new QLabel("Total Scans"), 0, Qt::AlignRight);
	totalScansLayout->addWidget(totalScans_);

	QVBoxLayout *spinBoxLayout = new QVBoxLayout;
	spinBoxLayout->addLayout(timeLayout);
	spinBoxLayout->addLayout(scansPerBufferLayout);
	spinBoxLayout->addLayout(totalScansLayout);

	QHBoxLayout *layout = new QHBoxLayout;
	layout->addLayout(statusAndModeLayout);
	layout->addLayout(spinBoxLayout);

	setLayout(layout);

	// Make connections.

	connect(startButton_, SIGNAL(clicked()), this, SLOT(startScanning()));
	connect(stopButton_, SIGNAL(clicked()), this, SLOT(stopScanning()));
	connect(modeChoice_, SIGNAL(currentIndexChanged(int)), this, SLOT(setContinuous()));
	connect(time_, SIGNAL(editingFinished()), this, SLOT(setDwellTime()));
	connect(scansPerBuffer_, SIGNAL(editingFinished()), this, SLOT(setScansPerBuffer()));
	connect(totalScans_, SIGNAL(editingFinished()), this, SLOT(setTotalScans()));

	// Current settings.

	setScaler(scaler);
}