Mercurial > hg > svgui
comparison layer/TimeValueLayer.cpp @ 55:128ebfeeebee
* Add Insert Instant function in main window
* Ensure selections and window geometry are saved in session file
* Add wait cursor on session file save
* Various improvements to display of texts in pane (clearer readability)
* Use commands for setting properties on layers and panes
(still need to batch up multiple sets on the same property)
* Fix failure of spectrogram to refresh when initial part became visible
* Some fixes & paint optimisations in View &c
* Make curve mode for time value layers work properly when resolution == 1
* Some vague improvements for time value layer vertical scale
author | Chris Cannam |
---|---|
date | Thu, 16 Mar 2006 18:46:00 +0000 |
parents | ad214997dddb |
children | 01ab51f72e84 |
comparison
equal
deleted
inserted
replaced
54:8dae7f6732c1 | 55:128ebfeeebee |
---|---|
404 v->getXForFrame(frame0 + m_model->getResolution()) - | 404 v->getXForFrame(frame0 + m_model->getResolution()) - |
405 v->getXForFrame(frame0); | 405 v->getXForFrame(frame0); |
406 | 406 |
407 paint.save(); | 407 paint.save(); |
408 | 408 |
409 if (w > 1 && | |
410 (m_plotStyle == PlotLines || | |
411 m_plotStyle == PlotCurve)) { | |
412 paint.setRenderHint(QPainter::Antialiasing, true); | |
413 } | |
414 QPainterPath path; | 409 QPainterPath path; |
410 int pointCount = 0; | |
415 | 411 |
416 for (SparseTimeValueModel::PointList::const_iterator i = points.begin(); | 412 for (SparseTimeValueModel::PointList::const_iterator i = points.begin(); |
417 i != points.end(); ++i) { | 413 i != points.end(); ++i) { |
418 | 414 |
419 const SparseTimeValueModel::Point &p(*i); | 415 const SparseTimeValueModel::Point &p(*i); |
502 | 498 |
503 paint.drawLine(x + w/2, y, nx + w/2, ny); | 499 paint.drawLine(x + w/2, y, nx + w/2, ny); |
504 | 500 |
505 } else { | 501 } else { |
506 | 502 |
507 if (path.isEmpty()) { | 503 float x0 = x + float(w)/2; |
508 path.moveTo(x + w/2, y); | 504 float x1 = nx + float(w)/2; |
505 | |
506 float y0 = y; | |
507 float y1 = ny; | |
508 | |
509 if (pointCount == 0) { | |
510 path.moveTo((x0 + x1) / 2, (y0 + y1) / 2); | |
509 } | 511 } |
512 ++pointCount; | |
510 | 513 |
511 if (nx - x > 5) { | 514 if (nx - x > 5) { |
512 path.cubicTo(x + w, y, nx, ny, nx + w/2, ny); | 515 path.cubicTo(x0, y0, |
516 x0, y0, | |
517 (x0 + x1) / 2, (y0 + y1) / 2); | |
518 | |
519 // // or | |
520 // path.quadTo(x0, y0, (x0 + x1) / 2, (y0 + y1) / 2); | |
521 | |
513 } else { | 522 } else { |
514 path.lineTo(nx + w/2, ny); | 523 path.lineTo((x0 + x1) / 2, (y0 + y1) / 2); |
515 } | 524 } |
516 } | 525 } |
517 } | 526 } |
518 } | 527 } |
519 | 528 |
527 } | 536 } |
528 | 537 |
529 paint.drawRect(x, -1, nx - x, v->height() + 1); | 538 paint.drawRect(x, -1, nx - x, v->height() + 1); |
530 } | 539 } |
531 | 540 |
532 /// if (p.label != "") { | 541 if (p.label != "") { |
533 /// paint.drawText(x + 5, y - paint.fontMetrics().height() + paint.fontMetrics().ascent(), p.label); | 542 paint.drawText(x + 5, y - paint.fontMetrics().height() + paint.fontMetrics().ascent(), p.label); |
534 /// } | 543 } |
535 } | 544 } |
536 | 545 |
537 if (m_plotStyle == PlotCurve && !path.isEmpty()) { | 546 if (m_plotStyle == PlotCurve && !path.isEmpty()) { |
547 paint.setRenderHint(QPainter::Antialiasing, pointCount <= v->width()); | |
538 paint.drawPath(path); | 548 paint.drawPath(path); |
539 } | 549 } |
540 | 550 |
541 paint.restore(); | 551 paint.restore(); |
542 | 552 |
545 } | 555 } |
546 | 556 |
547 int | 557 int |
548 TimeValueLayer::getVerticalScaleWidth(View *v, QPainter &paint) const | 558 TimeValueLayer::getVerticalScaleWidth(View *v, QPainter &paint) const |
549 { | 559 { |
550 return 100; //!!! | 560 if (m_plotStyle == PlotSegmentation) return 0; |
561 return paint.fontMetrics().width("+0.000e+00") + 15; | |
551 } | 562 } |
552 | 563 |
553 void | 564 void |
554 TimeValueLayer::paintVerticalScale(View *v, QPainter &paint, QRect rect) const | 565 TimeValueLayer::paintVerticalScale(View *v, QPainter &paint, QRect rect) const |
555 { | 566 { |
556 if (!m_model) return; | 567 if (!m_model) return; |
568 if (m_plotStyle == PlotSegmentation) return; | |
557 | 569 |
558 float val = m_model->getValueMinimum(); | 570 float val = m_model->getValueMinimum(); |
559 float inc = (m_model->getValueMaximum() - val) / 10; | 571 float inc = (m_model->getValueMaximum() - val) / 10; |
560 | 572 |
573 char buffer[40]; | |
574 | |
575 int w = getVerticalScaleWidth(v, paint); | |
576 | |
561 while (val < m_model->getValueMaximum()) { | 577 while (val < m_model->getValueMaximum()) { |
562 int y = getYForValue(v, val); | 578 int y = getYForValue(v, val); |
563 QString label = QString("%1").arg(val); | 579 // QString label = QString("%1").arg(val); |
564 paint.drawLine(100 - 10, y, 100, y); | 580 sprintf(buffer, "%+.3e", val); |
565 paint.drawText(100 - 15 - paint.fontMetrics().width(label), | 581 QString label = QString(buffer); |
566 y - paint.fontMetrics().height() /2 + paint.fontMetrics().ascent(), | 582 paint.drawLine(w - 5, y, w, y);// 100 - 10, y, 100, y); |
583 paint.drawText(5, // 100 - 15 - paint.fontMetrics().width(label), | |
584 y - paint.fontMetrics().height() + paint.fontMetrics().ascent(), | |
567 label); | 585 label); |
568 val += inc; | 586 val += inc; |
569 } | 587 } |
570 | 588 |
571 } | 589 } |