#include <qsescan.h>


Public Types | |
| enum | QseScanRole { UnspecifiedRole = -1, NotUsedRole, UsedRole } |
Public Member Functions | |
| QseScan (const char *name) | |
| ~QseScan () | |
| QString | name () const |
| void | setName (QString name) |
| int | columnCount () const |
| void | setColumnCount (int n) |
| int | maxRowCount () const |
| void | setRowCount (int n) |
| void | clear () |
| QseColumn * | column (int n) const |
| QseColumn * | column (const QString &nm) const |
| QseColumn * | appendColumn () |
| void | setColumnNames (const char *nms) |
| void | appendHeader (const QString &h) |
| void | appendData (const char *l) |
| QseColumn * | appendColumn (const QString &name, const QseColumn *proto=NULL) |
| QString | scanCommand () const |
| QseScanRole | scanRole () const |
| void | setScanRole (const QseScanRole r) |
| void | setDefaultRoles () |
| void | writeScan (const QString &name) |
| QStringList | header () const |
| void | mergeHeaders (const QStringList &hdr) |
| QDateTime | scanDateTime () const |
| void | setScanDateTime (const QDateTime &datetime) |
| int | scanNumber () const |
| void | setScanNumber (int n) |
Private Attributes | |
| QStringList | m_Header |
| QList< QseColumn * > | m_Columns |
| QList< QseColumn * > | m_SpareColumns |
| QseScanRole | m_Role |
| QString | m_Name |
| QMutex | m_Mutex |
| QDateTime | m_ScanDateTime |
| int | m_ScanNumber |
Definition at line 14 of file qsescan.h.
| enum QseScan::QseScanRole |
Definition at line 22 of file qsescan.h.
00022 { 00023 UnspecifiedRole = -1, 00024 NotUsedRole, 00025 UsedRole } QseScanRole;
| QseScan::QseScan | ( | const char * | name | ) |
Definition at line 8 of file qsescan.cpp.
00009 : QObject(NULL), 00010 m_Role(UnspecifiedRole), 00011 m_Name(name), 00012 m_ScanNumber(-1) 00013 { 00014 }
| QseScan::~QseScan | ( | ) |
Definition at line 16 of file qsescan.cpp.
References column(), m_Columns, m_Mutex, and m_SpareColumns.
00017 { 00018 QMutexLocker lock(&m_Mutex); 00019 00020 QseColumn *column; 00021 00022 foreach (column, m_Columns) { 00023 delete column; 00024 } 00025 00026 foreach (column, m_SpareColumns) { 00027 delete column; 00028 } 00029 }

| QString QseScan::name | ( | ) | const |
Definition at line 31 of file qsescan.cpp.
References m_Mutex, and m_Name.
Referenced by QseAverager::mergeHeaders(), and QseDataExport::QseDataExport().
| void QseScan::setName | ( | QString | name | ) |
Definition at line 38 of file qsescan.cpp.
References m_Mutex, and m_Name.
Referenced by appendData(), and QseAverager::mergeHeaders().
| int QseScan::columnCount | ( | ) | const |
Definition at line 45 of file qsescan.cpp.
References m_Columns, and m_Mutex.
Referenced by QseAverager::addScans(), appendColumn(), appendData(), QseAverager::divideScan(), QseDataSet::maxColumnCount(), maxRowCount(), QseGraphController::selectScan(), setColumnCount(), setColumnNames(), SimpleGraphController::updateColumnsTable(), SimpleGraphController::updateGraph(), QseGraphController::updateGraph(), SummaryTableController::updateSummaryTableScanInfo(), SummaryTableController::updateSummaryTableScans(), writeScan(), and QseController::writeSettings().
| void QseScan::setColumnCount | ( | int | n | ) |
Definition at line 52 of file qsescan.cpp.
References columnCount(), m_Columns, m_Mutex, and m_SpareColumns.
Referenced by clear().
00053 { 00054 int sz = columnCount(); 00055 00056 for (int i = sz-1; i>=n; i--) { 00057 QMutexLocker lock(&m_Mutex); 00058 00059 if (m_Columns[i]) { 00060 m_SpareColumns.append(m_Columns.takeAt(i)); 00061 } 00062 } 00063 }

| int QseScan::maxRowCount | ( | ) | const |
Definition at line 74 of file qsescan.cpp.
References column(), columnCount(), and QseColumn::rowCount().
Referenced by QseNormalizer::matchesScan(), QseAveragerRole::matchesScan(), SimpleGraphController::updateScansTable(), SummaryTableController::updateSummaryTableScanInfo(), SummaryTableController::updateSummaryTableScans(), and writeScan().
00075 { 00076 int maxcount = 0; 00077 int nc = columnCount(); 00078 00079 for (int i=0; i<nc; i++) { 00080 QseColumn *c = column(i); 00081 00082 if (c) { 00083 int nr = c->rowCount(); 00084 00085 if (nr > maxcount) { 00086 maxcount = nr; 00087 } 00088 } 00089 } 00090 00091 return maxcount; 00092 }

| void QseScan::setRowCount | ( | int | n | ) |
Definition at line 94 of file qsescan.cpp.
References column(), m_Columns, and m_Mutex.
Referenced by appendColumn(), and appendData().
00095 { 00096 QMutexLocker lock(&m_Mutex); 00097 QseColumn *column; 00098 00099 foreach (column, m_Columns) { 00100 column -> setRowCount(n); 00101 } 00102 }

| void QseScan::clear | ( | ) |
Definition at line 65 of file qsescan.cpp.
References m_Header, m_Mutex, and setColumnCount().
Referenced by appendColumn().
00066 { 00067 setColumnCount(0); 00068 00069 QMutexLocker lock(&m_Mutex); 00070 00071 m_Header.clear(); 00072 }

| QseColumn * QseScan::column | ( | int | n | ) | const |
Definition at line 104 of file qsescan.cpp.
References m_Columns.
Referenced by QseAverager::addScans(), appendColumn(), appendData(), QseDataExport::applyPressed(), column(), SimpleGraphController::columnsTableContextMenu(), QseDataSetModel::data(), QseAverager::divideScan(), maxRowCount(), QseDataReference::QseDataReference(), QseController::readSettings(), QseGraphController::selectScan(), setColumnNames(), setDefaultRoles(), setRowCount(), SummaryTableController::summaryTableContextMenu(), SimpleGraphController::updateColumnsTable(), SimpleGraphController::updateGraph(), QseGraphController::updateGraph(), SummaryTableController::updateSummaryTableColumnInfo(), SummaryTableController::updateSummaryTableScans(), writeScan(), QseController::writeSettings(), and ~QseScan().
00105 { 00106 if ((0 <= n) && (n < m_Columns.size())) { 00107 return m_Columns.at(n); 00108 } else { 00109 return NULL; 00110 } 00111 }
| QseColumn * QseScan::column | ( | const QString & | nm | ) | const |
Definition at line 113 of file qsescan.cpp.
References column(), m_Columns, m_Mutex, and QseColumn::name().
00114 { 00115 QMutexLocker lock(&m_Mutex); 00116 QseColumn *column; 00117 00118 foreach (column, m_Columns) { 00119 if (column && (column->name()==nm)) { 00120 return column; 00121 } 00122 } 00123 00124 return NULL; 00125 }

| QseColumn * QseScan::appendColumn | ( | ) |
Definition at line 127 of file qsescan.cpp.
References clear(), m_Columns, m_Mutex, and m_SpareColumns.
Referenced by QseAverager::addScans(), appendColumn(), appendData(), and setColumnNames().
00128 { 00129 QseColumn *col=NULL; 00130 00131 { 00132 QMutexLocker lock(&m_Mutex); 00133 00134 if (m_SpareColumns.size()) { 00135 col = m_SpareColumns.takeLast(); 00136 col -> clear(); 00137 } else { 00138 col = new QseColumn(); 00139 } 00140 00141 m_Columns.append(col); 00142 } 00143 00144 return col; 00145 }

| void QseScan::setColumnNames | ( | const char * | nms | ) |
Definition at line 147 of file qsescan.cpp.
References appendColumn(), column(), columnCount(), and QseColumn::setName().
00148 { 00149 const char *ptr = nms + 3; 00150 const char *found, *next; 00151 int nc = columnCount(); 00152 int col; 00153 char nam[256]; 00154 00155 for (col = 0; ptr; col++) { 00156 found = strstr(ptr, " "); 00157 if (found) { 00158 next = found + 2; 00159 } else { 00160 next = NULL; 00161 } 00162 00163 QseColumn* c= NULL; 00164 00165 if (col >= nc) { 00166 c = appendColumn(); 00167 nc++; 00168 } else { 00169 c = column(col); 00170 } 00171 00172 if (next) { 00173 qstrncpy(nam, ptr, found-ptr+1); 00174 c->setName(nam); 00175 } else { 00176 c->setName(ptr); 00177 } 00178 00179 ptr = next; 00180 } 00181 }

| void QseScan::appendHeader | ( | const QString & | h | ) |
Definition at line 183 of file qsescan.cpp.
References m_Header, and m_Mutex.
Referenced by mergeHeaders().
| void QseScan::appendData | ( | const char * | l | ) |
Definition at line 212 of file qsescan.cpp.
References appendColumn(), column(), columnCount(), setName(), and setRowCount().
00213 { 00214 int nc = columnCount(); 00215 const char *ptr = l; 00216 char *next; 00217 00218 for (int col = 0; ptr; col++) { 00219 double val; 00220 val = strtod(ptr, &next); 00221 00222 if (ptr == next) { 00223 return ; 00224 } 00225 00226 QseColumn *c=NULL; 00227 00228 if (col >= nc) { 00229 c = appendColumn(); 00230 c -> setName(QString("col%1").arg(col)); 00231 00232 if (nc > 0) { 00233 c -> setRowCount(column(0)->rowCount() - 1); 00234 } 00235 00236 nc++; 00237 } else { 00238 c = column(col); 00239 } 00240 00241 c -> appendData(val); 00242 00243 ptr = next; 00244 } 00245 00246 printf("\n"); 00247 }

Definition at line 262 of file qsescan.cpp.
References appendColumn(), column(), columnCount(), QseColumn::setName(), and setRowCount().
00263 { 00264 QseColumn *res = appendColumn(); 00265 00266 res->setName(name); 00267 00268 if (proto) { 00269 res -> setRowCount(proto -> rowCount()); 00270 res -> assignment(proto); 00271 } else if (columnCount() > 0) { 00272 res -> setRowCount(column(0)->rowCount()); 00273 res -> assignment(0.0); 00274 } 00275 00276 return res; 00277 }

| QString QseScan::scanCommand | ( | ) | const |
Definition at line 249 of file qsescan.cpp.
References m_Header, and m_Mutex.
Referenced by QseAverager::addScans(), QseDataExport::applyPressed(), QseNormalizer::matchesScan(), QseAveragerRole::matchesScan(), QseAveragerRole::styledScanItem(), SimpleGraphController::updateGraph(), QseGraphController::updateGraph(), and SimpleGraphController::updateScansTable().
00250 { 00251 QMutexLocker lock(&m_Mutex); 00252 00253 int ix = m_Header.indexOf(QRegExp("^#S.*$")); 00254 00255 if (ix >= 0) { 00256 return m_Header[ix]; 00257 } else { 00258 return ""; 00259 } 00260 }
| QseScan::QseScanRole QseScan::scanRole | ( | ) | const |
Definition at line 283 of file qsescan.cpp.
References m_Mutex, and m_Role.
Referenced by QseAveragerRole::matchesScan(), and QseController::writeSettings().
| void QseScan::setScanRole | ( | const QseScanRole | r | ) |
Definition at line 293 of file qsescan.cpp.
References m_Mutex, and m_Role.
Referenced by setDefaultRoles().
| void QseScan::setDefaultRoles | ( | ) |
Definition at line 300 of file qsescan.cpp.
References column(), m_Columns, m_Mutex, QseColumn::setDefaultRoles(), setScanRole(), and UnspecifiedRole.
00301 { 00302 setScanRole(QseScan::UnspecifiedRole); 00303 int sz; 00304 { 00305 QMutexLocker lock(&m_Mutex); 00306 sz = m_Columns.size(); 00307 } 00308 00309 for (int i=0; i<sz; i++) { 00310 QseColumn *c = column(i); 00311 00312 if (c) { 00313 c ->setDefaultRoles(); 00314 } 00315 } 00316 }

| void QseScan::writeScan | ( | const QString & | name | ) |
Definition at line 318 of file qsescan.cpp.
References column(), columnCount(), QseColumn::data(), m_Header, m_Mutex, maxRowCount(), and QseColumn::name().
00319 { 00320 FILE *f = fopen(qPrintable(name),"w"); 00321 int nr = maxRowCount(); 00322 int nc = columnCount(); 00323 int hsz; 00324 00325 { 00326 QMutexLocker lock(&m_Mutex); 00327 hsz = m_Header.size(); 00328 } 00329 00330 for (int i = 0; i < hsz; i++) { 00331 QMutexLocker lock(&m_Mutex); 00332 fputs(qPrintable(m_Header[i]+"\n"), f); 00333 } 00334 00335 fprintf(f,"#N"); 00336 00337 for (int i = 0; i < nc; i++) { 00338 QseColumn *c = column(i); 00339 if (c) { 00340 fprintf(f,"\t%s", qPrintable(c->name())); 00341 } 00342 } 00343 00344 fprintf(f,"\n"); 00345 00346 for (int r = 0; r<nr; r++) { 00347 fprintf(f, "%d", r); 00348 00349 for (int i = 0; i < nc; i++) { 00350 QseColumn *c = column(i); 00351 if (c) { 00352 fprintf(f,"\t%0.12g", c->data(r)); 00353 } 00354 } 00355 00356 fprintf(f,"\n"); 00357 } 00358 00359 fclose(f); 00360 }

| QStringList QseScan::header | ( | ) | const |
Definition at line 189 of file qsescan.cpp.
References m_Header, and m_Mutex.
Referenced by QseDataExport::applyPressed(), QseAverager::mergeHeaders(), and QseNormalizer::normalizeScan().
| void QseScan::mergeHeaders | ( | const QStringList & | hdr | ) |
Definition at line 195 of file qsescan.cpp.
References appendHeader(), m_Header, and m_Mutex.
Referenced by QseAverager::mergeHeaders().
00196 { 00197 QString hdrline; 00198 00199 foreach (hdrline, hdr) { 00200 bool nocont; 00201 { 00202 QMutexLocker lock(&m_Mutex); 00203 nocont = !m_Header.contains(hdrline); 00204 } 00205 00206 if (nocont) { 00207 appendHeader(hdrline); 00208 } 00209 } 00210 }

| QDateTime QseScan::scanDateTime | ( | ) | const |
Definition at line 362 of file qsescan.cpp.
References m_ScanDateTime.
00363 { 00364 return m_ScanDateTime; 00365 }
| void QseScan::setScanDateTime | ( | const QDateTime & | datetime | ) |
Definition at line 367 of file qsescan.cpp.
References m_ScanDateTime.
Referenced by QseAverager::mergeHeaders().
00368 { 00369 m_ScanDateTime = datetime; 00370 }
| int QseScan::scanNumber | ( | ) | const |
Definition at line 372 of file qsescan.cpp.
References m_ScanNumber.
Referenced by QseNormalizer::normalizeScan(), QseAverager::normalizeScan(), and QseGraphController::updateGraph().
00373 { 00374 return m_ScanNumber; 00375 }
| void QseScan::setScanNumber | ( | int | n | ) |
Definition at line 377 of file qsescan.cpp.
References m_ScanNumber.
00378 { 00379 m_ScanNumber = n; 00380 }
QStringList QseScan::m_Header [private] |
Definition at line 67 of file qsescan.h.
Referenced by appendHeader(), clear(), header(), mergeHeaders(), scanCommand(), and writeScan().
QList<QseColumn*> QseScan::m_Columns [private] |
Definition at line 68 of file qsescan.h.
Referenced by appendColumn(), column(), columnCount(), setColumnCount(), setDefaultRoles(), setRowCount(), and ~QseScan().
QList<QseColumn*> QseScan::m_SpareColumns [private] |
Definition at line 69 of file qsescan.h.
Referenced by appendColumn(), setColumnCount(), and ~QseScan().
QseScanRole QseScan::m_Role [private] |
QString QseScan::m_Name [private] |
QMutex QseScan::m_Mutex [mutable, private] |
Definition at line 72 of file qsescan.h.
Referenced by appendColumn(), appendHeader(), clear(), column(), columnCount(), header(), mergeHeaders(), name(), scanCommand(), scanRole(), setColumnCount(), setDefaultRoles(), setName(), setRowCount(), setScanRole(), writeScan(), and ~QseScan().
QDateTime QseScan::m_ScanDateTime [private] |
int QseScan::m_ScanNumber [private] |
1.5.5