Mercurial > hg > svgui
comparison layer/FlexiNoteLayer.cpp @ 808:40c6c9344ff6 warnfix_no_size_t
Merge from branch tony_integration
author | Chris Cannam |
---|---|
date | Wed, 18 Jun 2014 08:40:46 +0100 |
parents | 4c8ca536b54f d6b79166ae0d |
children | a9731b49745a |
comparison
equal
deleted
inserted
replaced
807:e4773943c9c1 | 808:40c6c9344ff6 |
---|---|
816 float max = m_model->getValueMaximum(); | 816 float max = m_model->getValueMaximum(); |
817 if (max == min) max = min + 1.0; | 817 if (max == min) max = min + 1.0; |
818 | 818 |
819 QPoint localPos; | 819 QPoint localPos; |
820 FlexiNoteModel::Point illuminatePoint(0); | 820 FlexiNoteModel::Point illuminatePoint(0); |
821 // bool shouldIlluminate = false; | 821 bool shouldIlluminate = false; |
822 | 822 |
823 // if (v->shouldIlluminateLocalFeatures(this, localPos)) { | 823 if (v->shouldIlluminateLocalFeatures(this, localPos)) { |
824 // shouldIlluminate = getPointToDrag(v, localPos.x(), localPos.y(), | 824 shouldIlluminate = getPointToDrag(v, localPos.x(), localPos.y(), |
825 // illuminatePoint); | 825 illuminatePoint); |
826 // } | 826 } |
827 | 827 |
828 paint.save(); | 828 paint.save(); |
829 paint.setRenderHint(QPainter::Antialiasing, false); | 829 paint.setRenderHint(QPainter::Antialiasing, false); |
830 | 830 |
831 for (FlexiNoteModel::PointList::const_iterator i = points.begin(); | 831 for (FlexiNoteModel::PointList::const_iterator i = points.begin(); |
845 | 845 |
846 if (w < 1) w = 1; | 846 if (w < 1) w = 1; |
847 paint.setPen(getBaseQColor()); | 847 paint.setPen(getBaseQColor()); |
848 paint.setBrush(brushColour); | 848 paint.setBrush(brushColour); |
849 | 849 |
850 // if (shouldIlluminate && | 850 if (shouldIlluminate && |
851 // // "illuminatePoint == p" | 851 // "illuminatePoint == p" |
852 // !FlexiNoteModel::Point::Comparator()(illuminatePoint, p) && | 852 !FlexiNoteModel::Point::Comparator()(illuminatePoint, p) && |
853 // !FlexiNoteModel::Point::Comparator()(p, illuminatePoint)) { | 853 !FlexiNoteModel::Point::Comparator()(p, illuminatePoint)) { |
854 // | 854 |
855 // paint.setPen(v->getForeground()); | 855 paint.drawLine(x, -1, x, v->height() + 1); |
856 // paint.setBrush(v->getForeground()); | 856 paint.drawLine(x+w, -1, x+w, v->height() + 1); |
857 // | 857 |
858 // QString vlabel = QString("%1%2").arg(p.value).arg(m_model->getScaleUnits()); | 858 paint.setPen(v->getForeground()); |
859 // v->drawVisibleText(paint, | 859 // paint.setBrush(v->getForeground()); |
860 // x - paint.fontMetrics().width(vlabel) - 2, | 860 |
861 // y + paint.fontMetrics().height()/2 | 861 QString vlabel = QString("freq: %1%2").arg(p.value).arg(m_model->getScaleUnits()); |
862 // - paint.fontMetrics().descent(), | 862 // v->drawVisibleText(paint, |
863 // vlabel, View::OutlinedText); | 863 // x - paint.fontMetrics().width(vlabel) - 2, |
864 // | 864 // y + paint.fontMetrics().height()/2 |
865 // QString hlabel = RealTime::frame2RealTime | 865 // - paint.fontMetrics().descent(), |
866 // (p.frame, m_model->getSampleRate()).toText(true).c_str(); | 866 // vlabel, View::OutlinedText); |
867 // v->drawVisibleText(paint, | 867 v->drawVisibleText(paint, |
868 // x, | 868 x, |
869 // y - h/2 - paint.fontMetrics().descent() - 2, | 869 y - h/2 - 2 - paint.fontMetrics().height() |
870 // hlabel, View::OutlinedText); | 870 - paint.fontMetrics().descent(), |
871 // } | 871 vlabel, View::OutlinedText); |
872 | |
873 QString hlabel = "dur: " + QString(RealTime::frame2RealTime | |
874 (p.duration, m_model->getSampleRate()).toText(true).c_str()); | |
875 v->drawVisibleText(paint, | |
876 x, | |
877 y - h/2 - paint.fontMetrics().descent() - 2, | |
878 hlabel, View::OutlinedText); | |
879 | |
880 QString llabel = QString("%1").arg(p.label); | |
881 v->drawVisibleText(paint, | |
882 x, | |
883 y + h + 2 + paint.fontMetrics().descent(), | |
884 llabel, View::OutlinedText); | |
885 } | |
872 | 886 |
873 paint.drawRect(x, y - h/2, w, h); | 887 paint.drawRect(x, y - h/2, w, h); |
874 } | 888 } |
875 | 889 |
876 paint.restore(); | 890 paint.restore(); |
1277 int duration = 10000; | 1291 int duration = 10000; |
1278 | 1292 |
1279 int frame = v->getFrameForX(e->x()); | 1293 int frame = v->getFrameForX(e->x()); |
1280 float value = getValueForY(v, e->y()); | 1294 float value = getValueForY(v, e->y()); |
1281 | 1295 |
1296 FlexiNoteModel::PointList noteList = m_model->getPoints(); | |
1297 | |
1282 if (m_intelligentActions) { | 1298 if (m_intelligentActions) { |
1283 int smallestRightNeighbourFrame = 0; | 1299 int smallestRightNeighbourFrame = 0; |
1284 for (FlexiNoteModel::PointList::const_iterator i = m_model->getPoints().begin(); | 1300 for (FlexiNoteModel::PointList::const_iterator i = noteList.begin(); |
1285 i != m_model->getPoints().end(); ++i) { | 1301 i != noteList.end(); ++i) { |
1286 FlexiNote currentNote = *i; | 1302 FlexiNote currentNote = *i; |
1287 if (currentNote.frame > frame) { | 1303 if (currentNote.frame > frame) { |
1288 smallestRightNeighbourFrame = currentNote.frame; | 1304 smallestRightNeighbourFrame = currentNote.frame; |
1289 break; | 1305 break; |
1290 } | 1306 } |
1291 } | 1307 } |
1292 | 1308 if (smallestRightNeighbourFrame > 0) { |
1293 duration = std::min(smallestRightNeighbourFrame - frame + 1, duration); | 1309 duration = std::min(smallestRightNeighbourFrame - frame + 1, duration); |
1294 duration = (duration > 0) ? duration : 0; | 1310 duration = (duration > 0) ? duration : 0; |
1311 } | |
1295 } | 1312 } |
1296 | 1313 |
1297 if (!m_intelligentActions || | 1314 if (!m_intelligentActions || |
1298 (m_model->getPoints(frame).empty() && duration > 0)) { | 1315 (m_model->getPoints(frame).empty() && duration > 0)) { |
1299 FlexiNote newNote(frame, value, duration, 100, "new note"); | 1316 FlexiNote newNote(frame, value, duration, 100, "new note"); |
1311 | 1328 |
1312 cerr << "FlexiNoteLayer::getAssociatedPitchModel()" << endl; | 1329 cerr << "FlexiNoteLayer::getAssociatedPitchModel()" << endl; |
1313 | 1330 |
1314 for (int i = 0; i < v->getLayerCount(); ++i) { | 1331 for (int i = 0; i < v->getLayerCount(); ++i) { |
1315 Layer *layer = v->getLayer(i); | 1332 Layer *layer = v->getLayer(i); |
1316 if (layer && !layer->isLayerDormant(v) && | 1333 if (layer && |
1317 layer->getLayerPresentationName() != "candidate") { | 1334 layer->getLayerPresentationName() != "candidate") { |
1318 cerr << "FlexiNoteLayer::getAssociatedPitchModel: looks like our layer is " << layer << endl; | 1335 cerr << "FlexiNoteLayer::getAssociatedPitchModel: looks like our layer is " << layer << endl; |
1319 SparseTimeValueModel *model = qobject_cast<SparseTimeValueModel *> | 1336 SparseTimeValueModel *model = qobject_cast<SparseTimeValueModel *> |
1320 (layer->getModel()); | 1337 (layer->getModel()); |
1321 cerr << "FlexiNoteLayer::getAssociatedPitchModel: and its model is " << model << endl; | 1338 cerr << "FlexiNoteLayer::getAssociatedPitchModel: and its model is " << model << endl; |
1472 if (closeToTop) { v->setCursor(Qt::CrossCursor); m_editMode = DragNote; return; } | 1489 if (closeToTop) { v->setCursor(Qt::CrossCursor); m_editMode = DragNote; return; } |
1473 if (closeToBottom) { v->setCursor(Qt::UpArrowCursor); m_editMode = SplitNote; return; } | 1490 if (closeToBottom) { v->setCursor(Qt::UpArrowCursor); m_editMode = SplitNote; return; } |
1474 | 1491 |
1475 v->setCursor(Qt::ArrowCursor); | 1492 v->setCursor(Qt::ArrowCursor); |
1476 | 1493 |
1477 // std::cerr << "Mouse moved in edit mode over FlexiNoteLayer" << std::endl; | 1494 std::cerr << "Mouse moved in edit mode over FlexiNoteLayer" << std::endl; |
1478 // v->setCursor(Qt::SizeHorCursor); | 1495 // v->setCursor(Qt::SizeHorCursor); |
1479 | 1496 |
1480 } | 1497 } |
1481 | 1498 |
1482 void | 1499 void |
1634 } | 1651 } |
1635 } | 1652 } |
1636 | 1653 |
1637 finish(command); | 1654 finish(command); |
1638 } | 1655 } |
1656 | |
1657 void | |
1658 FlexiNoteLayer::deleteSelectionInclusive(Selection s) | |
1659 { | |
1660 if (!m_model) return; | |
1661 | |
1662 FlexiNoteModel::EditCommand *command = | |
1663 new FlexiNoteModel::EditCommand(m_model, tr("Delete Selected Points")); | |
1664 | |
1665 FlexiNoteModel::PointList points = | |
1666 m_model->getPoints(s.getStartFrame(), s.getEndFrame()); | |
1667 | |
1668 for (FlexiNoteModel::PointList::iterator i = points.begin(); | |
1669 i != points.end(); ++i) { | |
1670 bool overlap = !( | |
1671 ((s.getStartFrame() <= i->frame) && (s.getEndFrame() <= i->frame)) || // selection is left of note | |
1672 ((s.getStartFrame() >= (i->frame+i->duration)) && (s.getEndFrame() >= (i->frame+i->duration))) // selection is right of note | |
1673 ); | |
1674 if (overlap) { | |
1675 command->deletePoint(*i); | |
1676 } | |
1677 } | |
1678 | |
1679 finish(command); | |
1680 } | |
1639 | 1681 |
1640 void | 1682 void |
1641 FlexiNoteLayer::copy(View *v, Selection s, Clipboard &to) | 1683 FlexiNoteLayer::copy(View *v, Selection s, Clipboard &to) |
1642 { | 1684 { |
1643 if (!m_model) return; | 1685 if (!m_model) return; |