void AM4DBinningABEditor::placeRangeRectangle() { AMDataSource* inputSource; if(analysisBlock_->inputDataSourceCount() > 0 && (inputSource=analysisBlock_->inputDataSourceAt(0))) { int sumAxis = analysisBlock_->sumAxis(); double dataMin = inputSource->axisValue(sumAxis,0); double sumMin = inputSource->axisValue(sumAxis, analysisBlock_->sumRangeMin()); double sumMax = inputSource->axisValue(sumAxis, analysisBlock_->sumRangeMax()); double dataMax = inputSource->axisValue(sumAxis, inputSource->size(sumAxis)-1); rangeRectangle1_->setYAxisTarget(plot_->axisScaleVerticalRelative()); // note: does nothing if already correct rangeRectangle2_->setYAxisTarget(plot_->axisScaleVerticalRelative()); // note: does nothing if already correct rangeRectangle1_->setXAxisTarget(plot_->axisScaleBottom()); // note: does nothing if already correct rangeRectangle2_->setXAxisTarget(plot_->axisScaleBottom()); // note: does nothing if already correct rangeRectangle1_->setRect(QRectF(QPointF(dataMin,0), QPointF(sumMin,1)).normalized()); rangeRectangle2_->setRect(QRectF(QPointF(sumMax,0), QPointF(dataMax,1)).normalized()); rangeRectangle1_->setVisible(true); rangeRectangle2_->setVisible(true); } else { rangeRectangle1_->setVisible(false); rangeRectangle2_->setVisible(false); } }
void AMExternalScanDataSourceAB::copyValues(int dataSourceIndex) { AMDataSource* ds = scan_->dataSourceAt(dataSourceIndex); const AMnDIndex size = ds->size(); switch(ds->rank()) { case 0: values_.clear(); values_ << ds->value(AMnDIndex()); break; case 1: { values_.resize(size.i()); for(int i=0; i<size.i(); i++) values_[i] = ds->value(i); break; } case 2: { values_.resize(size.i()*size.j()); for(int i=0; i<size.i(); i++) for(int j=0; j<size.j(); j++) values_[i*size.j() + j] = ds->value(AMnDIndex(i,j)); break; } case 3: { values_.resize(size.i()*size.j()*size.k()); for(int i=0; i<size.i(); i++) for(int j=0; j<size.j(); j++) for(int k=0; k<size.k(); k++) values_[i*size.j()*size.k() + j*size.k() + k] = ds->value(AMnDIndex(i,j,k)); break; } case 4: { values_.resize(size.i()*size.j()*size.k()*size.l()); for(int i=0; i<size.i(); i++) for(int j=0; j<size.j(); j++) for(int k=0; k<size.k(); k++) for(int l=0; l<size.l(); l++) values_[i*size.j()*size.k()*size.l() + j*size.k()*size.l() + k*size.l() + l] = ds->value(AMnDIndex(i,j,k,l)); break; } case 5: { values_.resize(size.i()*size.j()*size.k()*size.l()*size.m()); for(int i=0; i<size.i(); i++) for(int j=0; j<size.j(); j++) for(int k=0; k<size.k(); k++) for(int l=0; l<size.l(); l++) for(int m=0; m<size.m(); m++) values_[i*size.j()*size.k()*size.l()*size.m() + j*size.k()*size.l()*size.m() + k*size.l()*size.m() + l*size.m() + m] = ds->value(AMnDIndex(i,j,k,l,m)); /// \todo oh god, we really need a block copy or a multi-dimensional iterator for AMDataSource::value()... break; } } }
// responds to GUI events void AM2DSummingABEditor::onSumAxisControlChanged(int newSumAxis) { if(newSumAxis == analysisBlock_->sumAxis()) return; // adjust the maximums for the ranges AMDataSource* inputSource; if(analysisBlock_->inputDataSourceCount() > 0 && (inputSource=analysisBlock_->inputDataSourceAt(0))) { int newRangeMax = inputSource->size(newSumAxis)-1; rangeMinControl_->setMaximum(newRangeMax); rangeMaxControl_->setMaximum(newRangeMax); } analysisBlock_->setSumAxis(newSumAxis); placeRangeRectangle(); }
void AMExternalScanDataSourceAB::copyAxisValues(int dataSourceIndex) { AMDataSource* ds = scan_->dataSourceAt(dataSourceIndex); const AMnDIndex size = ds->size(); axisValues_.clear(); for(int mu=0; mu<size.rank(); mu++) { // for each axis QVector<AMNumber> av; if(!axes_.at(mu).isUniform) { int axisLength = size.at(mu); for(int i=0; i<axisLength; i++) // copy all the axis values av << axisValue(mu, i); } axisValues_ << av; } }
bool AMExporter2DAscii::writeSeparateFiles(const QString &destinationFolderPath) { if (option_->higherDimensionsInRows()){ for (int s = 0, sSize = separateFileDataSources_.size(); s < sSize; s++) { setCurrentDataSource(separateFileDataSources_.at(s)); // sets currentDataSourceIndex_ AMDataSource* source = currentScan_->dataSourceAt(currentDataSourceIndex_); QFile output; QString separateFileName = parseKeywordString( destinationFolderPath % "/" % option_->separateSectionFileName() ); separateFileName = removeNonPrintableCharacters(separateFileName); if(!openFile(&output, separateFileName)) { AMErrorMon::report(AMErrorReport(this, AMErrorReport::Alert, -4, "Export failed (partially): You selected to create separate files for certain data sets. Could not open the file '" % separateFileName % "' for writing. Check that you have permission to save files there, and that a file with that name doesn't already exists.")); return false; } int spectraSize = source->size(2); QString columnDelimiter = option_->columnDelimiter(); QString newLineDelimiter = option_->newlineDelimiter(); QTextStream out(&output); int yRange = yRange_ == -1 ? currentScan_->scanSize(1) : (yRange_-1); int xRange = currentScan_->scanSize(0); for (int y = 0; y < yRange; y++){ for (int x = 0; x < xRange; x++){ QVector<double> data(spectraSize); source->values(AMnDIndex(x, y, 0), AMnDIndex(x, y, spectraSize-1), data.data()); for (int i = 0; i < spectraSize; i++) out << data.at(i) << columnDelimiter; out << newLineDelimiter; } } if (yRange_ != -1 && xIndex_ != -1){ for (int i = 0; i < xIndex_; i++){ QVector<double> data(spectraSize); source->values(AMnDIndex(i, yRange_-1, 0), AMnDIndex(i, yRange_-1, spectraSize-1), data.data()); for (int i = 0; i < spectraSize; i++) out << data.at(i) << columnDelimiter; out << newLineDelimiter; } out << newLineDelimiter; } output.close(); } } else{ for (int s = 0, sSize = separateFileDataSources_.size(); s < sSize; s++) { setCurrentDataSource(separateFileDataSources_.at(s)); // sets currentDataSourceIndex_ AMDataSource* source = currentScan_->dataSourceAt(currentDataSourceIndex_); QFile output; QString separateFileName = parseKeywordString( destinationFolderPath % "/" % option_->separateSectionFileName() ); separateFileName = removeNonPrintableCharacters(separateFileName); if(!openFile(&output, separateFileName)) { AMErrorMon::report(AMErrorReport(this, AMErrorReport::Alert, -4, "Export failed (partially): You selected to create separate files for certain data sets. Could not open the file '" % separateFileName % "' for writing. Check that you have permission to save files there, and that a file with that name doesn't already exists.")); return false; } int spectraSize = source->size(2); QString columnDelimiter = option_->columnDelimiter(); QString newLineDelimiter = option_->newlineDelimiter(); QTextStream out(&output); int yRange = yRange_ == -1 ? currentScan_->scanSize(1) : (yRange_-1); int xRange = currentScan_->scanSize(0); for (int i = 0; i < spectraSize; i++){ for (int y = 0; y < yRange; y++) for (int x = 0; x < xRange; x++) out << double(source->value(AMnDIndex(x, y, i))) << columnDelimiter; if (yRange_ != -1 && xIndex_ != -1){ for (int x = 0; x < xIndex_; x++) out << double(source->value(AMnDIndex(x, yRange_-1, i))) << columnDelimiter; } out << newLineDelimiter; } output.close(); } } return true; }
void AM4DBinningABEditor::updateSeriesData() { AMDataSource *source = analysisBlock_->inputDataSourceAt(0); if (source){ int sumAxis = analysisBlock_->sumAxis(); int sumAxisSize = source->size(sumAxis); QVector<double> xAxis(sumAxisSize); QVector<double> yAxis(sumAxisSize, 0); for (int i = 0; i < sumAxisSize; i++) xAxis[i] = double(source->axisValue(sumAxis, i)); switch (sumAxis){ case 0:{ for (int i = 0, iSize = analysisBlock_->size(0); i < iSize; i++){ for (int j = 0, jSize = analysisBlock_->size(1); j < jSize; j++){ for (int k = 0, kSize = analysisBlock_->size(2); k < kSize; k++){ QVector<double> temp(sumAxisSize); source->values(AMnDIndex(0, i, j, k), AMnDIndex(sumAxisSize-1, i, j, k), temp.data()); for (int l = 0; l < sumAxisSize; l++) yAxis[l] += temp.at(l); } } } break; } case 1:{ for (int i = 0, iSize = analysisBlock_->size(0); i < iSize; i++){ for (int j = 0, jSize = analysisBlock_->size(1); j < jSize; j++){ for (int k = 0, kSize = analysisBlock_->size(2); k < kSize; k++){ QVector<double> temp(sumAxisSize); source->values(AMnDIndex(i, 0, j, k), AMnDIndex(i, sumAxisSize-1, j, k), temp.data()); for (int l = 0; l < sumAxisSize; l++) yAxis[l] += temp.at(l); } } } break; } case 2:{ for (int i = 0, iSize = analysisBlock_->size(0); i < iSize; i++){ for (int j = 0, jSize = analysisBlock_->size(1); j < jSize; j++){ for (int k = 0, kSize = analysisBlock_->size(2); k < kSize; k++){ QVector<double> temp(sumAxisSize); source->values(AMnDIndex(i, j, 0, k), AMnDIndex(i, j, sumAxisSize-1, k), temp.data()); for (int l = 0; l < sumAxisSize; l++) yAxis[l] += temp.at(l); } } } break; } case 3:{ for (int i = 0, iSize = analysisBlock_->size(0); i < iSize; i++){ for (int j = 0, jSize = analysisBlock_->size(1); j < jSize; j++){ for (int k = 0, kSize = analysisBlock_->size(2); k < kSize; k++){ QVector<double> temp(sumAxisSize); source->values(AMnDIndex(i, j, k, 0), AMnDIndex(i, j, k, sumAxisSize-1), temp.data()); for (int l = 0; l < sumAxisSize; l++) yAxis[l] += temp.at(l); } } } break; } } seriesData_->setValues(xAxis, yAxis); } }
bool AMExporterGeneralAscii::writeSeparateFiles(const QString& destinationFolderPath) { for(int s=0; s<separateFileDataSources_.count(); s++) { setCurrentDataSource(separateFileDataSources_.at(s)); // sets currentDataSourceIndex_ AMDataSource* ds = currentScan_->dataSourceAt(currentDataSourceIndex_); QFile file; QString separateFileName = parseKeywordString( destinationFolderPath % "/" % option_->separateSectionFileName() ); if(!openFile(&file, separateFileName)) { AMErrorMon::report(AMErrorReport(this, AMErrorReport::Alert, -4, "Export failed (partially): You selected to create separate files for certain data sets. Could not open the file '" % separateFileName % "' for writing. Check that you have permission to save files there, and that a file with that name doesn't already exists.")); return false; } QTextStream ts(&file); // section header? if(option_->sectionHeaderIncluded()) { ts << parseKeywordString(option_->sectionHeader()); ts << option_->newlineDelimiter(); } // column header? if(option_->columnHeaderIncluded()) { // 1D data sources: if(ds->rank() == 0) { ts << parseKeywordString(option_->columnHeader()) << option_->columnDelimiter(); } else if(ds->rank() == 1) { if(separateFileIncludeX_.at(s)) ts << parseKeywordString(option_->columnHeader()) << ".X" << option_->columnDelimiter(); ts << parseKeywordString(option_->columnHeader()) << option_->columnDelimiter(); } else if(ds->rank() == 2) { // 2D if(separateFileIncludeX_.at(s)) ts << parseKeywordString(option_->columnHeader()) << ".X" << option_->columnDelimiter(); // need a loop over the second axis columns for(int cc=0; cc<ds->size(1); cc++) { setCurrentColumnIndex(cc); ts << parseKeywordString(option_->columnHeader()) << "[" << ds->axisValue(1, cc).toString() << ds->axisInfoAt(1).units << "]" << option_->columnDelimiter(); } } ts << option_->newlineDelimiter() << option_->columnHeaderDelimiter() << option_->newlineDelimiter(); } // table switch(ds->rank()) { case 0: ts << ds->value(AMnDIndex()).toString() << option_->columnDelimiter() << option_->newlineDelimiter(); break; case 1: { int maxTableRows = ds->size(0); for(int r=0; r<maxTableRows; r++) { if(separateFileIncludeX_.at(s)) { ts << ds->axisValue(0,r).toString() << option_->columnDelimiter(); } ts << ds->value(r).toString() << option_->columnDelimiter() << option_->newlineDelimiter(); } } break; case 2: { int maxTableRows = ds->size(0); for(int r=0; r<maxTableRows; r++) { if(separateFileIncludeX_.at(s)) ts << ds->axisValue(0,r).toString() << option_->columnDelimiter(); // need a loop over the second axis columns for(int cc=0; cc<ds->size(1); cc++) { ts << ds->value(AMnDIndex(r,cc)).toString() << option_->columnDelimiter(); } ts << option_->newlineDelimiter(); } } break; default: /// \todo Implement 3D break; } } return true; }
void AMExporterGeneralAscii::writeSeparateSections() { QTextStream ts(file_); for(int s=0; s<separateSectionDataSources_.count(); s++) { ts << option_->newlineDelimiter(); setCurrentDataSource(separateSectionDataSources_.at(s)); // sets currentDataSourceIndex_ AMDataSource* ds = currentScan_->dataSourceAt(currentDataSourceIndex_); // section header? if(option_->sectionHeaderIncluded()) { ts << parseKeywordString(option_->sectionHeader()); ts << option_->newlineDelimiter(); } // column header? if(option_->columnHeaderIncluded()) { // 1D data sources: if(ds->rank() == 0) { ts << parseKeywordString(option_->columnHeader()) << option_->columnDelimiter(); } else if(ds->rank() == 1) { if(separateSectionIncludeX_.at(s)) ts << parseKeywordString(option_->columnHeader()) << ".X" << option_->columnDelimiter(); ts << parseKeywordString(option_->columnHeader()) << option_->columnDelimiter(); } else if(ds->rank() == 2) { // 2D if(separateSectionIncludeX_.at(s)) ts << parseKeywordString(option_->columnHeader()) << ".X" << option_->columnDelimiter(); // need a loop over the second axis columns for(int cc=0; cc<ds->size(1); cc++) { setCurrentColumnIndex(cc); ts << parseKeywordString(option_->columnHeader()) << "[" << ds->axisValue(1, cc).toString() << ds->axisInfoAt(1).units << "]" << option_->columnDelimiter(); } } ts << option_->newlineDelimiter() << option_->columnHeaderDelimiter() << option_->newlineDelimiter(); } // table switch(ds->rank()) { case 0: ts << ds->value(AMnDIndex()).toString() << option_->columnDelimiter() << option_->newlineDelimiter(); break; case 1: { int maxTableRows = ds->size(0); for(int r=0; r<maxTableRows; r++) { if(separateSectionIncludeX_.at(s)) { ts << ds->axisValue(0,r).toString() << option_->columnDelimiter(); } ts << ds->value(r).toString() << option_->columnDelimiter() << option_->newlineDelimiter(); } } break; case 2: { int maxTableRows = ds->size(0); for(int r=0; r<maxTableRows; r++) { if(separateSectionIncludeX_.at(s)) ts << ds->axisValue(0,r).toString() << option_->columnDelimiter(); // need a loop over the second axis columns for(int cc=0; cc<ds->size(1); cc++) { ts << ds->value(AMnDIndex(r,cc)).toString() << option_->columnDelimiter(); } ts << option_->newlineDelimiter(); } } break; default: /// \todo Implement 3D break; } } }
void AMExporterGeneralAscii::writeMainTable() { QTextStream ts(file_); // 1. Column header. int maxTableRows = 0; if(option_->columnHeaderIncluded()) { for(int c=0; c<mainTableDataSources_.count(); c++) { setCurrentDataSource(mainTableDataSources_.at(c)); AMDataSource* ds = currentScan_->dataSourceAt(currentDataSourceIndex_); if(ds->size(0) > maxTableRows) maxTableRows = ds->size(0); // convenient... lets figure this out while we're looping through anyway // 1D data sources: if(ds->rank() == 1) { if(mainTableIncludeX_.at(c)) ts << parseKeywordString(option_->columnHeader()) << ".X" << option_->columnDelimiter(); ts << parseKeywordString(option_->columnHeader()) << option_->columnDelimiter(); } else { // 2D if(mainTableIncludeX_.at(c)) ts << parseKeywordString(option_->columnHeader()) << ".X" << option_->columnDelimiter(); // need a loop over the second axis columns for(int cc=0; cc<ds->size(1); cc++) { setCurrentColumnIndex(cc); ts << parseKeywordString(option_->columnHeader()) << "[" << ds->axisValue(1, cc).toString() << ds->axisInfoAt(1).units << "]" << option_->columnDelimiter(); } } } ts << option_->newlineDelimiter() << option_->columnHeaderDelimiter() << option_->newlineDelimiter(); } // 2. rows for(int r=0; r<maxTableRows; r++) { // over rows within columns for(int c=0; c<mainTableDataSources_.count(); c++) { setCurrentDataSource(mainTableDataSources_.at(c)); AMDataSource* ds = currentScan_->dataSourceAt(currentDataSourceIndex_); bool doPrint = (ds->size(0) > r); // print x column? if(mainTableIncludeX_.at(c)) { if(doPrint) ts << ds->axisValue(0,r).toString(); ts << option_->columnDelimiter(); } // 1D data sources: if(ds->rank() == 1) { if(doPrint) ts << ds->value(r).toString(); ts << option_->columnDelimiter(); } else if(ds->rank() == 2) { // need a loop over the second axis columns for(int cc=0; cc<ds->size(1); cc++) { if(doPrint) ts << ds->value(AMnDIndex(r,cc)).toString(); ts << option_->columnDelimiter(); } } } ts << option_->newlineDelimiter(); } }
void AMExporterGeneralAscii::writeSeparateSections() { QTextStream ts(file_); if (option_->higherDimensionsInRows()){ for(int s=0; s<separateSectionDataSources_.count(); s++) { ts << option_->newlineDelimiter(); setCurrentDataSource(separateSectionDataSources_.at(s)); // sets currentDataSourceIndex_ AMDataSource* ds = currentScan_->dataSourceAt(currentDataSourceIndex_); int precision = option_->exportPrecision(ds->name()); // section header? if(option_->sectionHeaderIncluded()) { ts << parseKeywordString(option_->sectionHeader()); ts << option_->newlineDelimiter(); } // column header? if(option_->columnHeaderIncluded()) { // 1D data sources: if(ds->rank() == 0) { ts << parseKeywordString(option_->columnHeader()) << option_->columnDelimiter(); } else if(ds->rank() == 1) { if(separateSectionIncludeX_.at(s)) ts << parseKeywordString(option_->columnHeader()) << ".X" << option_->columnDelimiter(); ts << parseKeywordString(option_->columnHeader()) << option_->columnDelimiter(); } else if(ds->rank() == 2) { // 2D if(separateSectionIncludeX_.at(s)) ts << parseKeywordString(option_->columnHeader()) << ".X" << option_->columnDelimiter(); // need a loop over the second axis columns for(int cc=0; cc<ds->size(1); cc++) { setCurrentColumnIndex(cc); ts << parseKeywordString(option_->columnHeader()) << "[" << ds->axisValue(1, cc).toString(precision) << ds->axisInfoAt(1).units << "]" << option_->columnDelimiter(); } } ts << option_->newlineDelimiter() << option_->columnHeaderDelimiter() << option_->newlineDelimiter(); } // table switch(ds->rank()) { case 0: ts << ds->value(AMnDIndex()).toString(precision) << option_->columnDelimiter() << option_->newlineDelimiter(); break; case 1: { int maxTableRows = ds->size(0); for(int r=0; r<maxTableRows; r++) { if(separateSectionIncludeX_.at(s)) { ts << ds->axisValue(0,r).toString(precision) << option_->columnDelimiter(); } ts << ds->value(r).toString(precision) << option_->columnDelimiter() << option_->newlineDelimiter(); } } break; case 2: { int maxTableRows = ds->size(0); for(int r=0; r<maxTableRows; r++) { if(separateSectionIncludeX_.at(s)) ts << ds->axisValue(0,r).toString(precision) << option_->columnDelimiter(); // need a loop over the second axis columns for(int cc=0; cc<ds->size(1); cc++) { ts << ds->value(AMnDIndex(r,cc)).toString(precision) << option_->columnDelimiter(); } ts << option_->newlineDelimiter(); } } break; default: /// \todo Implement 3D break; } } } // For writing out in columns. Essentially transposing the file. else{ for(int s=0; s<separateSectionDataSources_.count(); s++) { setCurrentDataSource(separateSectionDataSources_.at(s)); // sets currentDataSourceIndex_ AMDataSource* ds = currentScan_->dataSourceAt(currentDataSourceIndex_); int precision = option_->exportPrecision(ds->name()); // section header? if(option_->sectionHeaderIncluded()) { ts << parseKeywordString(option_->sectionHeader()); ts << option_->newlineDelimiter(); } // If including the X values. if (separateSectionIncludeX_.at(s)){ switch(ds->rank()){ case 0: break; case 1: case 2:{ ts << parseKeywordString(option_->columnHeader()) << ".X" << option_->columnDelimiter(); int maxTableColumns = ds->size(0); for(int column = 0; column < maxTableColumns; column++) ts << ds->axisValue(0,column).toString(precision) << option_->columnDelimiter(); ts << option_->newlineDelimiter(); break; } default: /// \todo 3D. break; } } // Main table with column headers prefacing rows. switch (ds->rank()){ case 0:{ if(option_->columnHeaderIncluded()) ts << parseKeywordString(option_->columnHeader()) << option_->columnDelimiter(); ts << ds->value(AMnDIndex()).toString(precision) << option_->columnDelimiter() << option_->newlineDelimiter(); break; } case 1:{ if (option_->columnHeaderIncluded()) ts << parseKeywordString(option_->columnHeader()) << option_->columnDelimiter(); int maxTableColumns = ds->size(0); for(int column = 0; column < maxTableColumns; column++) ts << ds->value(column).toString(precision) << option_->columnDelimiter(); ts << option_->newlineDelimiter(); break; } case 2:{ for (int cc = 0; cc < ds->size(1); cc++){ if (option_->columnHeaderIncluded()) ts << parseKeywordString(option_->columnHeader()) << "[" << ds->axisValue(1, cc).toString(precision) << ds->axisInfoAt(1).units << "]" << option_->columnDelimiter(); int maxTableColumns = ds->size(0); for (int column = 0; column < maxTableColumns; column++) ts << ds->value(AMnDIndex(column, cc)).toString(precision) << option_->columnDelimiter(); ts << option_->newlineDelimiter(); } break; } default: /// \todo 3D break; } } } }
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); }