void OutputTable::writeLabels() { if (traceRecords().isEmpty()) return; QString s; QTextStream text(&s); text << traceRecords()[0].label; for (int i = 1; i < traceRecords().size(); ++i) text << "\t" << traceRecords()[i].label; writeString(s); writeString("\n"); }
int OutputTableBase::traceSize() { if (traceRecords().isEmpty()) return 0; int theSize = -1; for (int i = 0; i < traceRecords().size(); ++i) { int nextSize = traceRecords().at(i).trace->history()->size(); if (theSize == -1) theSize = nextSize; else if (nextSize != theSize) { QString msg ("Output variable data buffers are of unequal size. %1 vs. %2"); throw Exception(msg.arg(nextSize).arg(theSize)); } } return theSize; }
void OutputTable::writeTraces() { int n = traceSize(); for (int i = 0; i < n; ++i) { writeTraces(traceRecords(), i); writeString("\n"); } }
void OutputCrosstab::checkTraces() { if (traceRecords().size() < 2) { QString msg("Crosstab output must have at least two traces"); throw Exception(msg, this); } Trace *y = traceRecords()[1].trace; checkAttribute(y, "rows"); checkAttribute(y, "columns"); rowClass = y->attribute("rows").toString(); columnClass = y->attribute("columns").toString(); for (int i = 2; i < traceRecords().size(); ++i) { Trace *y = traceRecords()[i].trace; checkAttribute(y, "rows"); checkAttribute(y, "columns"); checkAttribute(y, "rows", rowClass); checkAttribute(y, "columns", columnClass); } }
void OutputCrosstab::amend() { OutputTableBase::amend(); checkTraces(); for (int i = 1; i < traceRecords().size(); ++i) { Trace *trace = traceRecords()[i].trace; Model *rowParent = seekParent(trace, rowClass); Model *columnParent = seekParent(trace, columnClass); QString rowName = rowParent->id().label(); QString columnName = columnParent->id().label(); TraceKey key = qMakePair(rowName, columnName); if (traceMatrix.contains(key)) { QString msg("Crosstab entry is not unique. More than one entry for row '%1' and column '%2"); throw Exception(msg.arg(rowName).arg(columnName)); } if (!rowNames.contains(rowName)) rowNames << rowName; if (!columnNames.contains(columnName)) columnNames << columnName; traceMatrix[ key ] = trace; } }