void AM3DNormalizationABEditor::populateComboBox()
{
	AMDataSource *tempSource = 0;
	int inputCount = analysisBlock_->inputDataSourceCount();

	for (int i = 0; i < inputCount; i++){

		tempSource = analysisBlock_->inputDataSourceAt(i);

		if (analysisBlock_->name() != tempSource->name()){

			dataNames_->addItem(tempSource->description(), tempSource->name());
			normalizationNames_->addItem(tempSource->description(), tempSource->name());
		}
	}
}
void AMDataSourcesEditor::onDataSourceDescriptionChanged()
{
	QModelIndex index = scanSetView_->currentIndex();
	AMDataSource *dataSource = model_->dataSourceAt(index.parent().row(), index.row());
	if (dataSource){

		descriptionEdit_->setText(dataSource->description());
		scanSetView_->update(index);
	}
}
void AMDataSourcesEditor::onSetViewIndexChanged(const QModelIndex &selected, const QModelIndex &deselected) {

	removeDetailEditor();

	// Nothing selected?
	////////////////////////
	if(!selected.isValid()) {
		nameEdit_->clear();
		descriptionEdit_->clear();
		descriptionEdit_->setReadOnly(true);
		addDataSourceButton_->setDisabled(true);
		return;
	}

	addDataSourceButton_->setEnabled(true);

	// Scan selected? (No selected data source)
	/////////////////////////
	if(!selected.parent().isValid()) {
		nameEdit_->clear();
		descriptionEdit_->clear();
		descriptionEdit_->setReadOnly(true);
		return;
	}


	// Data source selected.
	/////////////////

	// Remove old connection to the data source description.
	int oldSi = deselected.parent().row();
	int oldDi = deselected.row();
	AMDataSource *oldDataSource = model_->dataSourceAt(oldSi, oldDi);
	if (oldDataSource)
		disconnect(oldDataSource->signalSource(), SIGNAL(infoChanged()), this, SLOT(onDataSourceDescriptionChanged()));

	// Setup new data source.
	int si = selected.parent().row();
	int di = selected.row();
	AMDataSource* dataSource = model_->dataSourceAt(si, di);
	if(!dataSource)
		return;

	connect(dataSource->signalSource(), SIGNAL(infoChanged()), this, SLOT(onDataSourceDescriptionChanged()));

	nameEdit_->setText(dataSource->name());
	descriptionEdit_->setText(dataSource->description());
	descriptionEdit_->setReadOnly(false);

	installDetailEditor(dataSource->createEditorWidget());

	// Set the new selected data source as the exclusive view preference.
	model_->setExclusiveDataSourceByName(dataSource->name());
}
void AM1DBasicIntegralABEditor::populateComboBox()
{
    AMDataSource *tempSource = 0;

    for (int i = 0; i < analysisBlock_->inputDataSourceCount(); i++) {

        tempSource = analysisBlock_->inputDataSourceAt(i);

        if (analysisBlock_->name() != tempSource->name() && !tempSource->hiddenFromUsers())
            names_->addItem(tempSource->description(), tempSource->name());
    }
}
void AM4DBinningABEditor::populateComboBox()
{
	AMDataSource *tempSource = 0;

	for (int i = 0; i < analysisBlock_->inputDataSourceCount(); i++){

		tempSource = analysisBlock_->inputDataSourceAt(i);

		if (analysisBlock_->name() != tempSource->name())
			names_->addItem(tempSource->description(), tempSource->name());
	}
}
void AMOrderReductionABEditor::populateComboBox()
{
	AMDataSource *source = 0;

	for (int i = 0, size = analysisBlock_->inputDataSourceCount(); i < size; i++){

		source = analysisBlock_->inputDataSourceAt(i);

		if (analysisBlock_->name() != source->name())
			sourceNames_->addItem(source->description(), source->name());
	}

	if (analysisBlock_->rank() != 0){

		for (int i = 0, size = analysisBlock_->currentInputSource()->rank(); i < size; i++)
			reducedAxisOptions_->insertItem(i, analysisBlock_->currentInputSource()->axisInfoAt(i).description, i);
	}
}
Beispiel #7
0
QVariant AMScanSetModel::data(const QModelIndex & index, int role) const {
	if(!index.isValid())
		return QVariant();

	// scan-level index:
	///////////////////////////
	if(index.internalId() == -1 && index.row() < scans_.count() && index.column() == 0) {
		AMScan* scan = scans_.at(index.row());

		switch(role) {
		case Qt::DisplayRole: {
				QString rv = scan->fullName();
				if(scan->modified())
					rv.append( " (modified)");
				return rv;
			}
			break;
		case Qt::DecorationRole:
			/// \bug this is temporary and meaningless. It's just the color of the first data source in the scan.
			if(scan->dataSourceCount() > 0)
				return sourcePlotSettings_.at(index.row()).at(0).linePen.color();
			else
				return QVariant();
			break;
		case Qt::ToolTipRole:
			return QString("%1, #%2 (sample: %3): %4").arg(scan->name()).arg(scan->number()).arg(scan->sampleName()).arg(AMDateTimeUtils::prettyDateTime(scan->dateTime(), "h:mm:ssap"));
			break;
		case AM::DescriptionRole:
			return QString("%1, on %2").arg(AMDateTimeUtils::prettyDateTime(scan->dateTime())).arg(scan->sampleName());
		case AM::DateTimeRole:
			return scan->dateTime();
		case Qt::CheckStateRole:
			return QVariant();	/// \todo For now... No checking/unchecking scans.
			break;
		case AM::PointerRole:
			return qVariantFromValue(scan);
			break;
		case AM::ModifiedRole:
			return scan->modified();
		case AM::CanCloseRole:	// allows views to show the 'close' button beside each scan, to delete it. Do we want this on?
			return true;
		case AM::NameRole: {
				return scan->fullName();
			}
			break;
		default:
			return QVariant();
			break;
		}
	}


	// data source-level index:
	////////////////////////////
	if(index.internalId() >= 0 && index.internalId() < scans_.count() ) {
		AMScan* scan = scans_.at(index.internalId());

		if(index.row() < scan->dataSourceCount() && index.column() == 0) {
			AMDataSource* dataSource = scan->dataSourceAt(index.row());

			switch(role) {
			case Qt::DisplayRole:
				return QString("%1 (%2)").arg(dataSource->description(), dataSource->name());
				break;
			case Qt::DecorationRole:
				return sourcePlotSettings_.at(index.internalId()).at(index.row()).linePen.color();
				break;
			case Qt::ToolTipRole:
			case AM::NameRole:
				return dataSource->name();
			case AM::DescriptionRole:
				return dataSource->description();
			case AM::DetailedDescriptionRole:
				return QString("%1 (%2) From scan: %3\n%4").arg(dataSource->description(),
																dataSource->name(),
																scan->name(),
																//scan->evaluatedName(),
																dataSource->typeDescription());
				break;
			case Qt::CheckStateRole:	// this controls visibility on plots.
				if(isVisible(index.internalId(), index.row()))
					return Qt::Checked;
				else
					return Qt::Unchecked;
				break;
			case AM::PointerRole:
				return qVariantFromValue(dataSource);
				break;
			case AM::PriorityRole:
				return sourcePlotSettings_.at(index.internalId()).at(index.row()).priority;
				break;
			case AM::CanCloseRole:	// allows views to show the 'close' button beside each scan, to delete it.
				return true;
			case AM::LinePenRole:
				return sourcePlotSettings_.at(index.internalId()).at(index.row()).linePen;
			case AM::RankRole:
				return dataSource->rank();
			case AMScanSetModel::ColorMapRole:
				return qVariantFromValue(sourcePlotSettings_.at(index.internalId()).at(index.row()).colorMap);
			case AMScanSetModel::MarkerColorRole:
				return qVariantFromValue(sourcePlotSettings_.at(index.internalId()).at(index.row()).markerColor);
			case AMScanSetModel::MarkerShapeRole:
				return QVariant(sourcePlotSettings_.at(index.internalId()).at(index.row()).markerShape);
			default:
				return QVariant();
				break;
			}
		}
	}

	return QVariant();
}
void AMDataSourcesEditor::onCloseButtonClicked(const QModelIndex &index) {

	// handle data source-level indexes only:
	if(!index.parent().isValid())
		return;

	int dataSourceIndex = index.row();
	int scanIndex = index.parent().row();

	AMScan* scan = model_->scanAt(scanIndex);
	if(!scan || dataSourceIndex >= scan->dataSourceCount())
		return;

	if (dataSourceIndex < scan->rawDataSourceCount()){

		QMessageBox::warning(this, "Can not remove raw data sources.", QString("Acquaman does not allow the deletion of raw data sources."));
		return;
	}

	AMDataSource* dataSource = scan->dataSourceAt(dataSourceIndex);
	int response = QMessageBox::question(this, "Remove Data Source?", QString("Remove this data source? \n\n'%1' (%2)\n\nThe data source will be deleted, and no longer visible in any plots. Any other data sources that depend on this data source will be reset.  Raw data will NOT be deleted, and you can re-create the data source later if you need it.").arg(dataSource->description()).arg(dataSource->name()), QMessageBox::Ok | QMessageBox::Cancel, QMessageBox::Ok);

	if(response == QMessageBox::Ok)
		scan->deleteDataSourceAt(dataSourceIndex);
}
Beispiel #9
0
void AM3dDataSourceView::updatePlotFromDataSource()
{
	// Know from previously that the rank of this data source is 2.

	// Or the scan is 0, which means we have no data to show.
	if(scan_ == 0) {
		surfacePlot_->loadFromData(0,0,0);
		return;
	}


	AMDataSource* ds = scan_->dataSourceAt(dataSourceIndex_);

	double minZ = 0, maxZ = 1;
	int sizeX = ds->size(0);
	int sizeY = ds->size(1);

	bool uniformAxisScales = ds->axisInfoAt(0).isUniform && ds->axisInfoAt(1).isUniform;

	if(uniformAxisScales) {
		qDebug() << "Uniform axis scales. Using simplest (uniform) grid filling";
		double** zValues = new2dArray<double>(sizeX, sizeY);

		if(logScaleEnabled_) {
			if(sizeX > 0 && sizeY > 0)
				minZ = maxZ = log(qMax(logMin_,(double)ds->value(AMnDIndex(0,0))));

			for(int i=0; i<sizeX; i++)
				for(int j=0; j<sizeY; j++) {
					double zValue = log(qMax(logMin_,(double)ds->value(AMnDIndex(i,j))));
					minZ = qMin(minZ, zValue);
					maxZ = qMax(maxZ, zValue);
					zValues[i][j] = zValue;
				}
		}
		else {
			if(sizeX > 0 && sizeY > 0)
				minZ = maxZ = ds->value(AMnDIndex(0,0));

			for(int i=0; i<sizeX; i++)
				for(int j=0; j<sizeY; j++) {
					double zValue = ds->value(AMnDIndex(i,j));
					minZ = qMin(minZ, zValue);
					maxZ = qMax(maxZ, zValue);
					zValues[i][j] = zValue;
				}
		}

		surfacePlot_->loadFromData(zValues,
								   sizeX,
								   sizeY,
								   ds->axisValue(0,0),
								   ds->axisValue(0,sizeX-1),
								   ds->axisValue(1,0),
								   ds->axisValue(1,sizeY-1));

		// called from loadFromData(): surfacePlot_->updateData();
		// not necessary?: surfacePlot_->updateGL();

		delete2dArray(zValues);
	}
	else {	// non-uniform axis scale grid
		qDebug() << "Non-uniform axis scale. Using irregular grid";

		Qwt3D::Triple** gridValues = new2dArray<Qwt3D::Triple>(sizeX, sizeY);

		if(logScaleEnabled_) {
			if(sizeX >0 && sizeY > 0)
				minZ = maxZ = log(qMax(logMin_,(double)ds->value(AMnDIndex(0,0))));

			for(int i=0; i<sizeX; i++) {
				double xAxisValue = ds->axisValue(0,i);
				for(int j=0; j<sizeY; j++) {
					double zValue = log(qMax(logMin_,(double)ds->value(AMnDIndex(i,j))));
					minZ = qMin(minZ, zValue);
					maxZ = qMax(maxZ, zValue);
					gridValues[i][j] = Qwt3D::Triple(xAxisValue, ds->axisValue(1,j), zValue);
				}
			}
		}
		else {
			if(sizeX >0 && sizeY > 0)
				minZ = maxZ = ds->value(AMnDIndex(0,0));

			for(int i=0; i<sizeX; i++) {
				double xAxisValue = ds->axisValue(0,i);
				for(int j=0; j<sizeY; j++) {
					double zValue = ds->value(AMnDIndex(i,j));
					minZ = qMin(minZ, zValue);
					maxZ = qMax(maxZ, zValue);
					gridValues[i][j] = Qwt3D::Triple(xAxisValue, ds->axisValue(1,j), zValue);
				}
			}
		}

		surfacePlot_->loadFromData(gridValues, sizeX, sizeY);
		delete2dArray(gridValues);
	}

	// doesnt realy do anyting: surfacePlot_->coordinates()->setAutoScale(true);

	double zRange = maxZ - minZ;
	double xRange = (double)ds->axisValue(0, sizeX-1) - (double)ds->axisValue(0,0);
	double yRange = (double)ds->axisValue(1, sizeY-1) - (double)ds->axisValue(1,0);

	surfacePlot_->setScale(100*zRange/xRange, 100*zRange/yRange, 100);

	double drad = (surfacePlot_->hull().maxVertex-surfacePlot_->hull().minVertex).length();
	drad *= 30/20.;
	surfacePlot_->setLightShift(drad,drad,drad);
	surfacePlot_->setLightRotation(90,0,0);

	AMAxisInfo xInfo = ds->axisInfoAt(0);
	AMAxisInfo yInfo = ds->axisInfoAt(1);

	QString xLabel = xInfo.description % " (" % xInfo.units % ")";
	QString yLabel = yInfo.description % " (" % yInfo.units % ")";
	QString zLabel = ds->description();

	surfacePlot_->coordinates()->axes[Qwt3D::X1].setLabelString(xLabel);
	surfacePlot_->coordinates()->axes[Qwt3D::X2].setLabelString(xLabel);
	surfacePlot_->coordinates()->axes[Qwt3D::X3].setLabelString(xLabel);
	surfacePlot_->coordinates()->axes[Qwt3D::X4].setLabelString(xLabel);

	surfacePlot_->coordinates()->axes[Qwt3D::Y1].setLabelString(yLabel);
	surfacePlot_->coordinates()->axes[Qwt3D::Y2].setLabelString(yLabel);
	surfacePlot_->coordinates()->axes[Qwt3D::Y3].setLabelString(yLabel);
	surfacePlot_->coordinates()->axes[Qwt3D::Y4].setLabelString(yLabel);

	surfacePlot_->coordinates()->axes[Qwt3D::Z1].setLabelString(zLabel);
	surfacePlot_->coordinates()->axes[Qwt3D::Z2].setLabelString(zLabel);
	surfacePlot_->coordinates()->axes[Qwt3D::Z3].setLabelString(zLabel);
	surfacePlot_->coordinates()->axes[Qwt3D::Z4].setLabelString(zLabel);
}