Mercurial > hg > svgui
comparison layer/FlexiNoteLayer.cpp @ 656:902c7c9d77ea tonioni
vertical scale adapts to note range
author | matthiasm |
---|---|
date | Wed, 19 Jun 2013 22:05:45 +0100 |
parents | c572a0705223 |
children | ac26de7b727a |
comparison
equal
deleted
inserted
replaced
655:c572a0705223 | 656:902c7c9d77ea |
---|---|
1050 void | 1050 void |
1051 FlexiNoteLayer::editEnd(View *v, QMouseEvent *e) | 1051 FlexiNoteLayer::editEnd(View *v, QMouseEvent *e) |
1052 { | 1052 { |
1053 // SVDEBUG << "FlexiNoteLayer::editEnd(" << e->x() << "," << e->y() << ")" << endl; | 1053 // SVDEBUG << "FlexiNoteLayer::editEnd(" << e->x() << "," << e->y() << ")" << endl; |
1054 std::cerr << "FlexiNoteLayer::editEnd(" << e->x() << "," << e->y() << ")" << std::endl; | 1054 std::cerr << "FlexiNoteLayer::editEnd(" << e->x() << "," << e->y() << ")" << std::endl; |
1055 | 1055 |
1056 if (!m_model || !m_editing) return; | 1056 if (!m_model || !m_editing) return; |
1057 | 1057 |
1058 if (m_editingCommand) { | 1058 if (m_editingCommand) { |
1059 | 1059 |
1060 QString newName = m_editingCommand->getName(); | 1060 QString newName = m_editingCommand->getName(); |
1530 attributes.value("verticalScale").toInt(&ok); | 1530 attributes.value("verticalScale").toInt(&ok); |
1531 if (ok) setVerticalScale(scale); | 1531 if (ok) setVerticalScale(scale); |
1532 | 1532 |
1533 float min = attributes.value("scaleMinimum").toFloat(&ok); | 1533 float min = attributes.value("scaleMinimum").toFloat(&ok); |
1534 float max = attributes.value("scaleMaximum").toFloat(&alsoOk); | 1534 float max = attributes.value("scaleMaximum").toFloat(&alsoOk); |
1535 if (ok && alsoOk) setDisplayExtents(min, max); | 1535 // if (ok && alsoOk) setDisplayExtents(min, max); |
1536 } | 1536 } |
1537 | 1537 |
1538 void | 1538 void |
1539 FlexiNoteLayer::setVerticalRangeToNoteRange() | 1539 FlexiNoteLayer::setVerticalRangeToNoteRange(View *v) |
1540 { | 1540 { |
1541 float minf = std::numeric_limits<float>::max();; | 1541 float minf = std::numeric_limits<float>::max(); |
1542 float maxf = 0; | 1542 float maxf = 0; |
1543 bool hasNotes = 0; | |
1543 for (FlexiNoteModel::PointList::const_iterator i = m_model->getPoints().begin(); | 1544 for (FlexiNoteModel::PointList::const_iterator i = m_model->getPoints().begin(); |
1544 i != m_model->getPoints().end(); ++i) { | 1545 i != m_model->getPoints().end(); ++i) { |
1546 hasNotes = 1; | |
1545 FlexiNote note = *i; | 1547 FlexiNote note = *i; |
1546 if (note.value < minf) minf = note.value; | 1548 if (note.value < minf) minf = note.value; |
1547 else if (note.value > maxf) maxf = note.value; | 1549 if (note.value > maxf) maxf = note.value; |
1548 std::cerr << "min frequency:" << minf << ", max frequency: " << maxf << std::endl; | 1550 } |
1549 } | 1551 |
1550 | 1552 std::cerr << "min frequency:" << minf << ", max frequency: " << maxf << std::endl; |
1551 if (this) { | 1553 |
1552 setDisplayExtents(minf,maxf); | 1554 if (hasNotes) { |
1553 } | 1555 v->getLayer(1)->setDisplayExtents(minf*0.8,maxf*1.2); |
1554 } | 1556 // MM: this is a hack because we rely on |
1555 | 1557 // * this layer being automatically aligned to layer 1 |
1556 | 1558 // * layer one is a log frequency layer. |
1559 } | |
1560 } | |
1561 | |
1562 |