annotate data/model/EditableDenseThreeDimensionalModel.cpp @ 1047:26cf6d5251ec cxx11

Further dedicated-types fixes
author Chris Cannam
date Tue, 10 Mar 2015 17:02:52 +0000
parents 31f01931b781
children 0fd3661bcfff
rev   line source
Chris@152 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@152 2
Chris@152 3 /*
Chris@152 4 Sonic Visualiser
Chris@152 5 An audio file viewer and annotation editor.
Chris@152 6 Centre for Digital Music, Queen Mary, University of London.
Chris@202 7 This file copyright 2006 Chris Cannam and QMUL.
Chris@152 8
Chris@152 9 This program is free software; you can redistribute it and/or
Chris@152 10 modify it under the terms of the GNU General Public License as
Chris@152 11 published by the Free Software Foundation; either version 2 of the
Chris@152 12 License, or (at your option) any later version. See the file
Chris@152 13 COPYING included with this distribution for more information.
Chris@152 14 */
Chris@152 15
Chris@152 16 #include "EditableDenseThreeDimensionalModel.h"
Chris@152 17
Chris@478 18 #include "base/LogRange.h"
Chris@478 19
Chris@152 20 #include <QTextStream>
Chris@387 21 #include <QStringList>
Chris@536 22 #include <QReadLocker>
Chris@536 23 #include <QWriteLocker>
Chris@387 24
Chris@181 25 #include <iostream>
Chris@181 26
Chris@256 27 #include <cmath>
Chris@534 28 #include <cassert>
Chris@256 29
Chris@1044 30 using std::vector;
Chris@1044 31
Chris@607 32 #include "system/System.h"
Chris@607 33
Chris@1040 34 EditableDenseThreeDimensionalModel::EditableDenseThreeDimensionalModel(sv_samplerate_t sampleRate,
Chris@929 35 int resolution,
Chris@929 36 int yBinCount,
Chris@535 37 CompressionType compression,
Chris@152 38 bool notifyOnAdd) :
Chris@611 39 m_startFrame(0),
Chris@152 40 m_sampleRate(sampleRate),
Chris@152 41 m_resolution(resolution),
Chris@152 42 m_yBinCount(yBinCount),
Chris@535 43 m_compression(compression),
Chris@152 44 m_minimum(0.0),
Chris@152 45 m_maximum(0.0),
Chris@256 46 m_haveExtents(false),
Chris@152 47 m_notifyOnAdd(notifyOnAdd),
Chris@152 48 m_sinceLastNotifyMin(-1),
Chris@152 49 m_sinceLastNotifyMax(-1),
Chris@152 50 m_completion(100)
Chris@152 51 {
Chris@152 52 }
Chris@152 53
Chris@152 54 bool
Chris@152 55 EditableDenseThreeDimensionalModel::isOK() const
Chris@152 56 {
Chris@152 57 return true;
Chris@152 58 }
Chris@152 59
Chris@1040 60 sv_samplerate_t
Chris@152 61 EditableDenseThreeDimensionalModel::getSampleRate() const
Chris@152 62 {
Chris@152 63 return m_sampleRate;
Chris@152 64 }
Chris@152 65
Chris@1038 66 sv_frame_t
Chris@152 67 EditableDenseThreeDimensionalModel::getStartFrame() const
Chris@152 68 {
Chris@611 69 return m_startFrame;
Chris@611 70 }
Chris@611 71
Chris@611 72 void
Chris@1038 73 EditableDenseThreeDimensionalModel::setStartFrame(sv_frame_t f)
Chris@611 74 {
Chris@611 75 m_startFrame = f;
Chris@152 76 }
Chris@152 77
Chris@1038 78 sv_frame_t
Chris@152 79 EditableDenseThreeDimensionalModel::getEndFrame() const
Chris@152 80 {
Chris@152 81 return m_resolution * m_data.size() + (m_resolution - 1);
Chris@152 82 }
Chris@152 83
Chris@152 84 Model *
Chris@152 85 EditableDenseThreeDimensionalModel::clone() const
Chris@152 86 {
Chris@536 87 QReadLocker locker(&m_lock);
Chris@534 88
Chris@152 89 EditableDenseThreeDimensionalModel *model =
Chris@152 90 new EditableDenseThreeDimensionalModel
Chris@535 91 (m_sampleRate, m_resolution, m_yBinCount, m_compression);
Chris@152 92
Chris@152 93 model->m_minimum = m_minimum;
Chris@152 94 model->m_maximum = m_maximum;
Chris@256 95 model->m_haveExtents = m_haveExtents;
Chris@152 96
Chris@929 97 for (int i = 0; i < m_data.size(); ++i) {
Chris@533 98 model->setColumn(i, m_data.at(i));
Chris@152 99 }
Chris@152 100
Chris@152 101 return model;
Chris@152 102 }
Chris@152 103
Chris@929 104 int
Chris@152 105 EditableDenseThreeDimensionalModel::getResolution() const
Chris@152 106 {
Chris@152 107 return m_resolution;
Chris@152 108 }
Chris@152 109
Chris@152 110 void
Chris@929 111 EditableDenseThreeDimensionalModel::setResolution(int sz)
Chris@152 112 {
Chris@152 113 m_resolution = sz;
Chris@152 114 }
Chris@152 115
Chris@929 116 int
Chris@182 117 EditableDenseThreeDimensionalModel::getWidth() const
Chris@182 118 {
Chris@182 119 return m_data.size();
Chris@182 120 }
Chris@182 121
Chris@929 122 int
Chris@182 123 EditableDenseThreeDimensionalModel::getHeight() const
Chris@152 124 {
Chris@152 125 return m_yBinCount;
Chris@152 126 }
Chris@152 127
Chris@152 128 void
Chris@929 129 EditableDenseThreeDimensionalModel::setHeight(int sz)
Chris@152 130 {
Chris@152 131 m_yBinCount = sz;
Chris@152 132 }
Chris@152 133
Chris@152 134 float
Chris@152 135 EditableDenseThreeDimensionalModel::getMinimumLevel() const
Chris@152 136 {
Chris@152 137 return m_minimum;
Chris@152 138 }
Chris@152 139
Chris@152 140 void
Chris@152 141 EditableDenseThreeDimensionalModel::setMinimumLevel(float level)
Chris@152 142 {
Chris@152 143 m_minimum = level;
Chris@152 144 }
Chris@152 145
Chris@152 146 float
Chris@152 147 EditableDenseThreeDimensionalModel::getMaximumLevel() const
Chris@152 148 {
Chris@152 149 return m_maximum;
Chris@152 150 }
Chris@152 151
Chris@152 152 void
Chris@152 153 EditableDenseThreeDimensionalModel::setMaximumLevel(float level)
Chris@152 154 {
Chris@152 155 m_maximum = level;
Chris@152 156 }
Chris@152 157
Chris@533 158 EditableDenseThreeDimensionalModel::Column
Chris@929 159 EditableDenseThreeDimensionalModel::getColumn(int index) const
Chris@152 160 {
Chris@536 161 QReadLocker locker(&m_lock);
Chris@937 162 if (index < 0 || index >= m_data.size()) return Column();
Chris@534 163 return expandAndRetrieve(index);
Chris@152 164 }
Chris@152 165
Chris@152 166 float
Chris@929 167 EditableDenseThreeDimensionalModel::getValueAt(int index, int n) const
Chris@152 168 {
Chris@534 169 Column c = getColumn(index);
Chris@929 170 if (int(n) < c.size()) return c.at(n);
Chris@534 171 return m_minimum;
Chris@534 172 }
Chris@152 173
Chris@535 174 //static int given = 0, stored = 0;
Chris@534 175
Chris@534 176 void
Chris@929 177 EditableDenseThreeDimensionalModel::truncateAndStore(int index,
Chris@534 178 const Column &values)
Chris@534 179 {
Chris@929 180 assert(int(index) < m_data.size());
Chris@534 181
Chris@843 182 //cout << "truncateAndStore(" << index << ", " << values.size() << ")" << endl;
Chris@534 183
Chris@535 184 // The default case is to store the entire column at m_data[index]
Chris@535 185 // and place 0 at m_trunc[index] to indicate that it has not been
Chris@535 186 // truncated. We only do clever stuff if one of the clever-stuff
Chris@535 187 // tests works out.
Chris@535 188
Chris@534 189 m_trunc[index] = 0;
Chris@535 190 if (index == 0 ||
Chris@535 191 m_compression == NoCompression ||
Chris@929 192 values.size() != int(m_yBinCount)) {
Chris@535 193 // given += values.size();
Chris@535 194 // stored += values.size();
Chris@534 195 m_data[index] = values;
Chris@534 196 return;
Chris@152 197 }
Chris@152 198
Chris@535 199 // Maximum distance between a column and the one we refer to as
Chris@535 200 // the source of its truncated values. Limited by having to fit
Chris@535 201 // in a signed char, but in any case small values are usually
Chris@535 202 // better
Chris@535 203 static int maxdist = 6;
Chris@534 204
Chris@535 205 bool known = false; // do we know whether to truncate at top or bottom?
Chris@535 206 bool top = false; // if we do know, will we truncate at top?
Chris@534 207
Chris@535 208 // If the previous column is not truncated, then it is the only
Chris@535 209 // candidate for comparison. If it is truncated, then the column
Chris@535 210 // that it refers to is the only candidate. Either way, we only
Chris@535 211 // have one possible column to compare against here, and we are
Chris@535 212 // being careful to ensure it is not a truncated one (to avoid
Chris@535 213 // doing more work recursively when uncompressing).
Chris@534 214 int tdist = 1;
Chris@534 215 int ptrunc = m_trunc[index-1];
Chris@534 216 if (ptrunc < 0) {
Chris@534 217 top = false;
Chris@534 218 known = true;
Chris@534 219 tdist = -ptrunc + 1;
Chris@534 220 } else if (ptrunc > 0) {
Chris@534 221 top = true;
Chris@534 222 known = true;
Chris@534 223 tdist = ptrunc + 1;
Chris@534 224 }
Chris@534 225
Chris@534 226 Column p = expandAndRetrieve(index - tdist);
Chris@534 227 int h = m_yBinCount;
Chris@534 228
Chris@534 229 if (p.size() == h && tdist <= maxdist) {
Chris@534 230
Chris@534 231 int bcount = 0, tcount = 0;
Chris@534 232 if (!known || !top) {
Chris@535 233 // count how many identical values there are at the bottom
Chris@534 234 for (int i = 0; i < h; ++i) {
Chris@534 235 if (values.at(i) == p.at(i)) ++bcount;
Chris@534 236 else break;
Chris@534 237 }
Chris@534 238 }
Chris@534 239 if (!known || top) {
Chris@535 240 // count how many identical values there are at the top
Chris@534 241 for (int i = h; i > 0; --i) {
Chris@534 242 if (values.at(i-1) == p.at(i-1)) ++tcount;
Chris@534 243 else break;
Chris@534 244 }
Chris@534 245 }
Chris@534 246 if (!known) top = (tcount > bcount);
Chris@534 247
Chris@535 248 int limit = h / 4; // don't bother unless we have at least this many
Chris@534 249 if ((top ? tcount : bcount) > limit) {
Chris@534 250
Chris@534 251 if (!top) {
Chris@535 252 // create a new column with h - bcount values from bcount up
Chris@534 253 Column tcol(h - bcount);
Chris@535 254 // given += values.size();
Chris@535 255 // stored += h - bcount;
Chris@534 256 for (int i = bcount; i < h; ++i) {
Chris@534 257 tcol[i - bcount] = values.at(i);
Chris@534 258 }
Chris@534 259 m_data[index] = tcol;
Chris@1038 260 m_trunc[index] = (signed char)(-tdist);
Chris@534 261 return;
Chris@534 262 } else {
Chris@535 263 // create a new column with h - tcount values from 0 up
Chris@534 264 Column tcol(h - tcount);
Chris@535 265 // given += values.size();
Chris@535 266 // stored += h - tcount;
Chris@534 267 for (int i = 0; i < h - tcount; ++i) {
Chris@534 268 tcol[i] = values.at(i);
Chris@534 269 }
Chris@534 270 m_data[index] = tcol;
Chris@1038 271 m_trunc[index] = (signed char)(tdist);
Chris@534 272 return;
Chris@534 273 }
Chris@534 274 }
Chris@534 275 }
Chris@534 276
Chris@535 277 // given += values.size();
Chris@535 278 // stored += values.size();
Chris@843 279 // cout << "given: " << given << ", stored: " << stored << " ("
Chris@843 280 // << ((float(stored) / float(given)) * 100.f) << "%)" << endl;
Chris@534 281
Chris@535 282 // default case if nothing wacky worked out
Chris@534 283 m_data[index] = values;
Chris@534 284 return;
Chris@534 285 }
Chris@534 286
Chris@534 287 EditableDenseThreeDimensionalModel::Column
Chris@929 288 EditableDenseThreeDimensionalModel::expandAndRetrieve(int index) const
Chris@534 289 {
Chris@535 290 // See comment above m_trunc declaration in header
Chris@535 291
Chris@941 292 assert(index >= 0 && index < int(m_data.size()));
Chris@534 293 Column c = m_data.at(index);
Chris@534 294 if (index == 0) {
Chris@534 295 return c;
Chris@534 296 }
Chris@534 297 int trunc = (int)m_trunc[index];
Chris@534 298 if (trunc == 0) {
Chris@534 299 return c;
Chris@534 300 }
Chris@534 301 bool top = true;
Chris@534 302 int tdist = trunc;
Chris@534 303 if (trunc < 0) { top = false; tdist = -trunc; }
Chris@534 304 Column p = expandAndRetrieve(index - tdist);
Chris@537 305 int psize = p.size(), csize = c.size();
Chris@941 306 if (psize != m_yBinCount) {
Chris@843 307 cerr << "WARNING: EditableDenseThreeDimensionalModel::expandAndRetrieve: Trying to expand from incorrectly sized column" << endl;
Chris@534 308 }
Chris@534 309 if (top) {
Chris@537 310 for (int i = csize; i < psize; ++i) {
Chris@534 311 c.push_back(p.at(i));
Chris@534 312 }
Chris@534 313 } else {
Chris@593 314 // push_front is very slow on QVector -- but not enough to
Chris@593 315 // make it desirable to choose a different container, since
Chris@593 316 // QVector has all the other advantages for us. easier to
Chris@593 317 // write the whole array out to a new vector
Chris@593 318 Column cc(psize);
Chris@593 319 for (int i = 0; i < psize - csize; ++i) {
Chris@593 320 cc[i] = p.at(i);
Chris@534 321 }
Chris@593 322 for (int i = 0; i < csize; ++i) {
Chris@593 323 cc[i + (psize - csize)] = c.at(i);
Chris@593 324 }
Chris@593 325 return cc;
Chris@534 326 }
Chris@534 327 return c;
Chris@152 328 }
Chris@152 329
Chris@152 330 void
Chris@929 331 EditableDenseThreeDimensionalModel::setColumn(int index,
Chris@182 332 const Column &values)
Chris@152 333 {
Chris@536 334 QWriteLocker locker(&m_lock);
Chris@152 335
Chris@929 336 while (int(index) >= m_data.size()) {
Chris@182 337 m_data.push_back(Column());
Chris@534 338 m_trunc.push_back(0);
Chris@152 339 }
Chris@152 340
Chris@152 341 bool allChange = false;
Chris@152 342
Chris@534 343 // if (values.size() > m_yBinCount) m_yBinCount = values.size();
Chris@439 344
Chris@929 345 for (int i = 0; i < values.size(); ++i) {
Chris@256 346 float value = values[i];
Chris@606 347 if (ISNAN(value) || ISINF(value)) {
Chris@256 348 continue;
Chris@256 349 }
Chris@256 350 if (!m_haveExtents || value < m_minimum) {
Chris@256 351 m_minimum = value;
Chris@152 352 allChange = true;
Chris@152 353 }
Chris@256 354 if (!m_haveExtents || value > m_maximum) {
Chris@256 355 m_maximum = value;
Chris@152 356 allChange = true;
Chris@152 357 }
Chris@256 358 m_haveExtents = true;
Chris@152 359 }
Chris@152 360
Chris@534 361 truncateAndStore(index, values);
Chris@534 362
Chris@593 363 // assert(values == expandAndRetrieve(index));
Chris@152 364
Chris@182 365 long windowStart = index;
Chris@182 366 windowStart *= m_resolution;
Chris@182 367
Chris@152 368 if (m_notifyOnAdd) {
Chris@152 369 if (allChange) {
Chris@152 370 emit modelChanged();
Chris@152 371 } else {
Chris@931 372 emit modelChangedWithin(windowStart, windowStart + m_resolution);
Chris@152 373 }
Chris@152 374 } else {
Chris@152 375 if (allChange) {
Chris@152 376 m_sinceLastNotifyMin = -1;
Chris@152 377 m_sinceLastNotifyMax = -1;
Chris@152 378 emit modelChanged();
Chris@152 379 } else {
Chris@152 380 if (m_sinceLastNotifyMin == -1 ||
Chris@152 381 windowStart < m_sinceLastNotifyMin) {
Chris@152 382 m_sinceLastNotifyMin = windowStart;
Chris@152 383 }
Chris@152 384 if (m_sinceLastNotifyMax == -1 ||
Chris@152 385 windowStart > m_sinceLastNotifyMax) {
Chris@152 386 m_sinceLastNotifyMax = windowStart;
Chris@152 387 }
Chris@152 388 }
Chris@152 389 }
Chris@152 390 }
Chris@152 391
Chris@152 392 QString
Chris@929 393 EditableDenseThreeDimensionalModel::getBinName(int n) const
Chris@152 394 {
Chris@939 395 if (n >= 0 && (int)m_binNames.size() > n) return m_binNames[n];
Chris@152 396 else return "";
Chris@152 397 }
Chris@152 398
Chris@152 399 void
Chris@929 400 EditableDenseThreeDimensionalModel::setBinName(int n, QString name)
Chris@152 401 {
Chris@929 402 while ((int)m_binNames.size() <= n) m_binNames.push_back("");
Chris@152 403 m_binNames[n] = name;
Chris@152 404 emit modelChanged();
Chris@152 405 }
Chris@152 406
Chris@152 407 void
Chris@152 408 EditableDenseThreeDimensionalModel::setBinNames(std::vector<QString> names)
Chris@152 409 {
Chris@152 410 m_binNames = names;
Chris@152 411 emit modelChanged();
Chris@152 412 }
Chris@152 413
Chris@478 414 bool
Chris@886 415 EditableDenseThreeDimensionalModel::hasBinValues() const
Chris@886 416 {
Chris@886 417 return !m_binValues.empty();
Chris@886 418 }
Chris@886 419
Chris@886 420 float
Chris@929 421 EditableDenseThreeDimensionalModel::getBinValue(int n) const
Chris@886 422 {
Chris@929 423 if (n < (int)m_binValues.size()) return m_binValues[n];
Chris@886 424 else return 0.f;
Chris@886 425 }
Chris@886 426
Chris@886 427 void
Chris@886 428 EditableDenseThreeDimensionalModel::setBinValues(std::vector<float> values)
Chris@886 429 {
Chris@886 430 m_binValues = values;
Chris@886 431 }
Chris@886 432
Chris@886 433 QString
Chris@886 434 EditableDenseThreeDimensionalModel::getBinValueUnit() const
Chris@886 435 {
Chris@886 436 return m_binValueUnit;
Chris@886 437 }
Chris@886 438
Chris@886 439 void
Chris@886 440 EditableDenseThreeDimensionalModel::setBinValueUnit(QString unit)
Chris@886 441 {
Chris@886 442 m_binValueUnit = unit;
Chris@886 443 }
Chris@886 444
Chris@886 445 bool
Chris@478 446 EditableDenseThreeDimensionalModel::shouldUseLogValueScale() const
Chris@478 447 {
Chris@536 448 QReadLocker locker(&m_lock);
Chris@534 449
Chris@1044 450 vector<double> sample;
Chris@1044 451 vector<int> n;
Chris@478 452
Chris@478 453 for (int i = 0; i < 10; ++i) {
Chris@929 454 int index = i * 10;
Chris@478 455 if (index < m_data.size()) {
Chris@533 456 const Column &c = m_data.at(index);
Chris@1044 457 while (c.size() > int(sample.size())) {
Chris@1044 458 sample.push_back(0.0);
Chris@478 459 n.push_back(0);
Chris@478 460 }
Chris@478 461 for (int j = 0; j < c.size(); ++j) {
Chris@533 462 sample[j] += c.at(j);
Chris@478 463 ++n[j];
Chris@478 464 }
Chris@478 465 }
Chris@478 466 }
Chris@478 467
Chris@478 468 if (sample.empty()) return false;
Chris@1044 469 for (decltype(sample)::size_type j = 0; j < sample.size(); ++j) {
Chris@1044 470 if (n[j]) sample[j] /= n[j];
Chris@478 471 }
Chris@478 472
Chris@1044 473 return LogRange::useLogScale(sample);
Chris@478 474 }
Chris@478 475
Chris@152 476 void
Chris@333 477 EditableDenseThreeDimensionalModel::setCompletion(int completion, bool update)
Chris@152 478 {
Chris@152 479 if (m_completion != completion) {
Chris@152 480 m_completion = completion;
Chris@152 481
Chris@152 482 if (completion == 100) {
Chris@152 483
Chris@152 484 m_notifyOnAdd = true; // henceforth
Chris@152 485 emit modelChanged();
Chris@152 486
Chris@152 487 } else if (!m_notifyOnAdd) {
Chris@152 488
Chris@333 489 if (update &&
Chris@333 490 m_sinceLastNotifyMin >= 0 &&
Chris@152 491 m_sinceLastNotifyMax >= 0) {
Chris@931 492 emit modelChangedWithin(m_sinceLastNotifyMin,
Chris@931 493 m_sinceLastNotifyMax + m_resolution);
Chris@152 494 m_sinceLastNotifyMin = m_sinceLastNotifyMax = -1;
Chris@152 495 } else {
Chris@152 496 emit completionChanged();
Chris@152 497 }
Chris@152 498 } else {
Chris@152 499 emit completionChanged();
Chris@152 500 }
Chris@152 501 }
Chris@152 502 }
Chris@152 503
Chris@318 504 QString
Chris@318 505 EditableDenseThreeDimensionalModel::toDelimitedDataString(QString delimiter) const
Chris@318 506 {
Chris@536 507 QReadLocker locker(&m_lock);
Chris@318 508 QString s;
Chris@929 509 for (int i = 0; i < m_data.size(); ++i) {
Chris@318 510 QStringList list;
Chris@929 511 for (int j = 0; j < m_data.at(i).size(); ++j) {
Chris@533 512 list << QString("%1").arg(m_data.at(i).at(j));
Chris@318 513 }
Chris@318 514 s += list.join(delimiter) + "\n";
Chris@318 515 }
Chris@318 516 return s;
Chris@318 517 }
Chris@318 518
Chris@838 519 QString
Chris@1038 520 EditableDenseThreeDimensionalModel::toDelimitedDataStringSubset(QString delimiter, sv_frame_t f0, sv_frame_t f1) const
Chris@838 521 {
Chris@838 522 QReadLocker locker(&m_lock);
Chris@838 523 QString s;
Chris@929 524 for (int i = 0; i < m_data.size(); ++i) {
Chris@1038 525 sv_frame_t fr = m_startFrame + i * m_resolution;
Chris@1038 526 if (fr >= f0 && fr < f1) {
Chris@838 527 QStringList list;
Chris@929 528 for (int j = 0; j < m_data.at(i).size(); ++j) {
Chris@838 529 list << QString("%1").arg(m_data.at(i).at(j));
Chris@838 530 }
Chris@838 531 s += list.join(delimiter) + "\n";
Chris@838 532 }
Chris@838 533 }
Chris@838 534 return s;
Chris@838 535 }
Chris@838 536
Chris@152 537 void
Chris@152 538 EditableDenseThreeDimensionalModel::toXml(QTextStream &out,
Chris@314 539 QString indent,
Chris@314 540 QString extraAttributes) const
Chris@152 541 {
Chris@536 542 QReadLocker locker(&m_lock);
Chris@534 543
Chris@152 544 // For historical reasons we read and write "resolution" as "windowSize"
Chris@152 545
Chris@690 546 SVDEBUG << "EditableDenseThreeDimensionalModel::toXml" << endl;
Chris@318 547
Chris@314 548 Model::toXml
Chris@314 549 (out, indent,
Chris@611 550 QString("type=\"dense\" dimensions=\"3\" windowSize=\"%1\" yBinCount=\"%2\" minimum=\"%3\" maximum=\"%4\" dataset=\"%5\" startFrame=\"%6\" %7")
Chris@152 551 .arg(m_resolution)
Chris@152 552 .arg(m_yBinCount)
Chris@152 553 .arg(m_minimum)
Chris@152 554 .arg(m_maximum)
Chris@152 555 .arg(getObjectExportId(&m_data))
Chris@611 556 .arg(m_startFrame)
Chris@152 557 .arg(extraAttributes));
Chris@152 558
Chris@152 559 out << indent;
Chris@152 560 out << QString("<dataset id=\"%1\" dimensions=\"3\" separator=\" \">\n")
Chris@152 561 .arg(getObjectExportId(&m_data));
Chris@152 562
Chris@929 563 for (int i = 0; i < (int)m_binNames.size(); ++i) {
Chris@152 564 if (m_binNames[i] != "") {
Chris@152 565 out << indent + " ";
Chris@152 566 out << QString("<bin number=\"%1\" name=\"%2\"/>\n")
Chris@152 567 .arg(i).arg(m_binNames[i]);
Chris@152 568 }
Chris@152 569 }
Chris@152 570
Chris@929 571 for (int i = 0; i < (int)m_data.size(); ++i) {
Chris@152 572 out << indent + " ";
Chris@152 573 out << QString("<row n=\"%1\">").arg(i);
Chris@929 574 for (int j = 0; j < (int)m_data.at(i).size(); ++j) {
Chris@152 575 if (j > 0) out << " ";
Chris@533 576 out << m_data.at(i).at(j);
Chris@152 577 }
Chris@152 578 out << QString("</row>\n");
Chris@318 579 out.flush();
Chris@152 580 }
Chris@152 581
Chris@152 582 out << indent + "</dataset>\n";
Chris@152 583 }
Chris@152 584
Chris@152 585