comparison data/model/EditableDenseThreeDimensionalModel.cpp @ 1429:48e9f538e6e9

Untabify
author Chris Cannam
date Thu, 01 Mar 2018 18:02:22 +0000
parents 667e369cfeab
children f97d64b8674f
comparison
equal deleted inserted replaced
1428:87ae75da6527 1429:48e9f538e6e9
319 const Column &values) 319 const Column &values)
320 { 320 {
321 QWriteLocker locker(&m_lock); 321 QWriteLocker locker(&m_lock);
322 322
323 while (index >= int(m_data.size())) { 323 while (index >= int(m_data.size())) {
324 m_data.push_back(Column()); 324 m_data.push_back(Column());
325 m_trunc.push_back(0); 325 m_trunc.push_back(0);
326 } 326 }
327 327
328 bool allChange = false; 328 bool allChange = false;
329 329
330 for (int i = 0; in_range_for(values, i); ++i) { 330 for (int i = 0; in_range_for(values, i); ++i) {
331 float value = values[i]; 331 float value = values[i];
332 if (ISNAN(value) || ISINF(value)) { 332 if (ISNAN(value) || ISINF(value)) {
333 continue; 333 continue;
334 } 334 }
335 if (!m_haveExtents || value < m_minimum) { 335 if (!m_haveExtents || value < m_minimum) {
336 m_minimum = value; 336 m_minimum = value;
337 allChange = true; 337 allChange = true;
338 } 338 }
339 if (!m_haveExtents || value > m_maximum) { 339 if (!m_haveExtents || value > m_maximum) {
340 m_maximum = value; 340 m_maximum = value;
341 allChange = true; 341 allChange = true;
342 } 342 }
343 m_haveExtents = true; 343 m_haveExtents = true;
344 } 344 }
345 345
346 truncateAndStore(index, values); 346 truncateAndStore(index, values);
347 347
349 349
350 sv_frame_t windowStart = index; 350 sv_frame_t windowStart = index;
351 windowStart *= m_resolution; 351 windowStart *= m_resolution;
352 352
353 if (m_notifyOnAdd) { 353 if (m_notifyOnAdd) {
354 if (allChange) { 354 if (allChange) {
355 emit modelChanged(); 355 emit modelChanged();
356 } else { 356 } else {
357 emit modelChangedWithin(windowStart, windowStart + m_resolution); 357 emit modelChangedWithin(windowStart, windowStart + m_resolution);
358 } 358 }
359 } else { 359 } else {
360 if (allChange) { 360 if (allChange) {
361 m_sinceLastNotifyMin = -1; 361 m_sinceLastNotifyMin = -1;
362 m_sinceLastNotifyMax = -1; 362 m_sinceLastNotifyMax = -1;
363 emit modelChanged(); 363 emit modelChanged();
364 } else { 364 } else {
365 if (m_sinceLastNotifyMin == -1 || 365 if (m_sinceLastNotifyMin == -1 ||
366 windowStart < m_sinceLastNotifyMin) { 366 windowStart < m_sinceLastNotifyMin) {
367 m_sinceLastNotifyMin = windowStart; 367 m_sinceLastNotifyMin = windowStart;
368 } 368 }
369 if (m_sinceLastNotifyMax == -1 || 369 if (m_sinceLastNotifyMax == -1 ||
370 windowStart > m_sinceLastNotifyMax) { 370 windowStart > m_sinceLastNotifyMax) {
371 m_sinceLastNotifyMax = windowStart; 371 m_sinceLastNotifyMax = windowStart;
372 } 372 }
373 } 373 }
374 } 374 }
375 } 375 }
376 376
377 QString 377 QString
378 EditableDenseThreeDimensionalModel::getBinName(int n) const 378 EditableDenseThreeDimensionalModel::getBinName(int n) const
460 460
461 void 461 void
462 EditableDenseThreeDimensionalModel::setCompletion(int completion, bool update) 462 EditableDenseThreeDimensionalModel::setCompletion(int completion, bool update)
463 { 463 {
464 if (m_completion != completion) { 464 if (m_completion != completion) {
465 m_completion = completion; 465 m_completion = completion;
466 466
467 if (completion == 100) { 467 if (completion == 100) {
468 468
469 m_notifyOnAdd = true; // henceforth 469 m_notifyOnAdd = true; // henceforth
470 emit modelChanged(); 470 emit modelChanged();
471 471
472 } else if (!m_notifyOnAdd) { 472 } else if (!m_notifyOnAdd) {
473 473
474 if (update && 474 if (update &&
475 m_sinceLastNotifyMin >= 0 && 475 m_sinceLastNotifyMin >= 0 &&
476 m_sinceLastNotifyMax >= 0) { 476 m_sinceLastNotifyMax >= 0) {
477 emit modelChangedWithin(m_sinceLastNotifyMin, 477 emit modelChangedWithin(m_sinceLastNotifyMin,
478 m_sinceLastNotifyMax + m_resolution); 478 m_sinceLastNotifyMax + m_resolution);
479 m_sinceLastNotifyMin = m_sinceLastNotifyMax = -1; 479 m_sinceLastNotifyMin = m_sinceLastNotifyMax = -1;
480 } else { 480 } else {
481 emit completionChanged(); 481 emit completionChanged();
482 } 482 }
483 } else { 483 } else {
484 emit completionChanged(); 484 emit completionChanged();
485 } 485 }
486 } 486 }
487 } 487 }
488 488
489 QString 489 QString
490 EditableDenseThreeDimensionalModel::toDelimitedDataString(QString delimiter) const 490 EditableDenseThreeDimensionalModel::toDelimitedDataString(QString delimiter) const
491 { 491 {
492 QReadLocker locker(&m_lock); 492 QReadLocker locker(&m_lock);
493 QString s; 493 QString s;
494 for (int i = 0; in_range_for(m_data, i); ++i) { 494 for (int i = 0; in_range_for(m_data, i); ++i) {
495 QStringList list; 495 QStringList list;
496 for (int j = 0; in_range_for(m_data.at(i), j); ++j) { 496 for (int j = 0; in_range_for(m_data.at(i), j); ++j) {
497 list << QString("%1").arg(m_data.at(i).at(j)); 497 list << QString("%1").arg(m_data.at(i).at(j));
498 } 498 }
499 s += list.join(delimiter) + "\n"; 499 s += list.join(delimiter) + "\n";
500 } 500 }
501 return s; 501 return s;
529 // For historical reasons we read and write "resolution" as "windowSize" 529 // For historical reasons we read and write "resolution" as "windowSize"
530 530
531 SVDEBUG << "EditableDenseThreeDimensionalModel::toXml" << endl; 531 SVDEBUG << "EditableDenseThreeDimensionalModel::toXml" << endl;
532 532
533 Model::toXml 533 Model::toXml
534 (out, indent, 534 (out, indent,
535 QString("type=\"dense\" dimensions=\"3\" windowSize=\"%1\" yBinCount=\"%2\" minimum=\"%3\" maximum=\"%4\" dataset=\"%5\" startFrame=\"%6\" %7") 535 QString("type=\"dense\" dimensions=\"3\" windowSize=\"%1\" yBinCount=\"%2\" minimum=\"%3\" maximum=\"%4\" dataset=\"%5\" startFrame=\"%6\" %7")
536 .arg(m_resolution) 536 .arg(m_resolution)
537 .arg(m_yBinCount) 537 .arg(m_yBinCount)
538 .arg(m_minimum) 538 .arg(m_minimum)
539 .arg(m_maximum) 539 .arg(m_maximum)
540 .arg(getObjectExportId(&m_data)) 540 .arg(getObjectExportId(&m_data))
541 .arg(m_startFrame) 541 .arg(m_startFrame)
542 .arg(extraAttributes)); 542 .arg(extraAttributes));
543 543
544 out << indent; 544 out << indent;
545 out << QString("<dataset id=\"%1\" dimensions=\"3\" separator=\" \">\n") 545 out << QString("<dataset id=\"%1\" dimensions=\"3\" separator=\" \">\n")
546 .arg(getObjectExportId(&m_data)); 546 .arg(getObjectExportId(&m_data));
547 547
548 for (int i = 0; i < (int)m_binNames.size(); ++i) { 548 for (int i = 0; i < (int)m_binNames.size(); ++i) {
549 if (m_binNames[i] != "") { 549 if (m_binNames[i] != "") {
550 out << indent + " "; 550 out << indent + " ";
551 out << QString("<bin number=\"%1\" name=\"%2\"/>\n") 551 out << QString("<bin number=\"%1\" name=\"%2\"/>\n")
552 .arg(i).arg(m_binNames[i]); 552 .arg(i).arg(m_binNames[i]);
553 } 553 }
554 } 554 }
555 555
556 for (int i = 0; i < (int)m_data.size(); ++i) { 556 for (int i = 0; i < (int)m_data.size(); ++i) {
557 out << indent + " "; 557 out << indent + " ";
558 out << QString("<row n=\"%1\">").arg(i); 558 out << QString("<row n=\"%1\">").arg(i);
559 for (int j = 0; j < (int)m_data.at(i).size(); ++j) { 559 for (int j = 0; j < (int)m_data.at(i).size(); ++j) {
560 if (j > 0) out << " "; 560 if (j > 0) out << " ";
561 out << m_data.at(i).at(j); 561 out << m_data.at(i).at(j);
562 } 562 }
563 out << QString("</row>\n"); 563 out << QString("</row>\n");
564 out.flush(); 564 out.flush();
565 } 565 }
566 566
567 out << indent + "</dataset>\n"; 567 out << indent + "</dataset>\n";
568 } 568 }