Mercurial > hg > svgui
comparison layer/TimeValueLayer.cpp @ 1216:dc2af6616c83
Merge from branch 3.0-integration
author | Chris Cannam |
---|---|
date | Fri, 13 Jan 2017 10:29:50 +0000 |
parents | 69ff93e0c624 |
children | 491dd600570c |
comparison
equal
deleted
inserted
replaced
1048:e8102ff5573b | 1216:dc2af6616c83 |
---|---|
19 #include "base/RealTime.h" | 19 #include "base/RealTime.h" |
20 #include "base/Profiler.h" | 20 #include "base/Profiler.h" |
21 #include "base/LogRange.h" | 21 #include "base/LogRange.h" |
22 #include "base/RangeMapper.h" | 22 #include "base/RangeMapper.h" |
23 #include "base/Pitch.h" | 23 #include "base/Pitch.h" |
24 #include "ColourDatabase.h" | |
25 #include "view/View.h" | 24 #include "view/View.h" |
26 | 25 |
27 #include "data/model/SparseTimeValueModel.h" | 26 #include "data/model/SparseTimeValueModel.h" |
28 #include "data/model/Labeller.h" | 27 #include "data/model/Labeller.h" |
29 | 28 |
30 #include "widgets/ItemEditDialog.h" | 29 #include "widgets/ItemEditDialog.h" |
31 #include "widgets/ListInputDialog.h" | 30 #include "widgets/ListInputDialog.h" |
32 #include "widgets/TextAbbrev.h" | 31 #include "widgets/TextAbbrev.h" |
33 | 32 |
33 #include "ColourDatabase.h" | |
34 #include "ColourMapper.h" | 34 #include "ColourMapper.h" |
35 #include "PianoScale.h" | 35 #include "PianoScale.h" |
36 #include "LinearNumericalScale.h" | 36 #include "LinearNumericalScale.h" |
37 #include "LogNumericalScale.h" | 37 #include "LogNumericalScale.h" |
38 #include "LinearColourScale.h" | 38 #include "LinearColourScale.h" |
39 #include "LogColourScale.h" | 39 #include "LogColourScale.h" |
40 #include "PaintAssistant.h" | |
40 | 41 |
41 #include <QPainter> | 42 #include <QPainter> |
42 #include <QPainterPath> | 43 #include <QPainterPath> |
43 #include <QMouseEvent> | 44 #include <QMouseEvent> |
44 #include <QRegExp> | 45 #include <QRegExp> |
129 TimeValueLayer::getPropertyType(const PropertyName &name) const | 130 TimeValueLayer::getPropertyType(const PropertyName &name) const |
130 { | 131 { |
131 if (name == "Plot Type") return ValueProperty; | 132 if (name == "Plot Type") return ValueProperty; |
132 if (name == "Vertical Scale") return ValueProperty; | 133 if (name == "Vertical Scale") return ValueProperty; |
133 if (name == "Scale Units") return UnitsProperty; | 134 if (name == "Scale Units") return UnitsProperty; |
134 if (name == "Colour" && m_plotStyle == PlotSegmentation) return ValueProperty; | 135 if (name == "Colour" && m_plotStyle == PlotSegmentation) return ColourMapProperty; |
135 if (name == "Draw Segment Division Lines") return ToggleProperty; | 136 if (name == "Draw Segment Division Lines") return ToggleProperty; |
136 if (name == "Show Derivative") return ToggleProperty; | 137 if (name == "Show Derivative") return ToggleProperty; |
137 return SingleColourLayer::getPropertyType(name); | 138 return SingleColourLayer::getPropertyType(name); |
138 } | 139 } |
139 | 140 |
314 m_derivative = show; | 315 m_derivative = show; |
315 emit layerParametersChanged(); | 316 emit layerParametersChanged(); |
316 } | 317 } |
317 | 318 |
318 bool | 319 bool |
319 TimeValueLayer::isLayerScrollable(const View *v) const | 320 TimeValueLayer::isLayerScrollable(const LayerGeometryProvider *v) const |
320 { | 321 { |
321 // We don't illuminate sections in the line or curve modes, so | 322 // We don't illuminate sections in the line or curve modes, so |
322 // they're always scrollable | 323 // they're always scrollable |
323 | 324 |
324 if (m_plotStyle == PlotLines || | 325 if (m_plotStyle == PlotLines || |
528 | 529 |
529 return mapper; | 530 return mapper; |
530 } | 531 } |
531 | 532 |
532 SparseTimeValueModel::PointList | 533 SparseTimeValueModel::PointList |
533 TimeValueLayer::getLocalPoints(View *v, int x) const | 534 TimeValueLayer::getLocalPoints(LayerGeometryProvider *v, int x) const |
534 { | 535 { |
535 if (!m_model) return SparseTimeValueModel::PointList(); | 536 if (!m_model) return SparseTimeValueModel::PointList(); |
536 | 537 |
537 sv_frame_t frame = v->getFrameForX(x); | 538 sv_frame_t frame = v->getFrameForX(x); |
538 | 539 |
585 } | 586 } |
586 return ""; | 587 return ""; |
587 } | 588 } |
588 | 589 |
589 QString | 590 QString |
590 TimeValueLayer::getFeatureDescription(View *v, QPoint &pos) const | 591 TimeValueLayer::getFeatureDescription(LayerGeometryProvider *v, QPoint &pos) const |
591 { | 592 { |
592 int x = pos.x(); | 593 int x = pos.x(); |
593 | 594 |
594 if (!m_model || !m_model->getSampleRate()) return ""; | 595 if (!m_model || !m_model->getSampleRate()) return ""; |
595 | 596 |
639 getYForValue(v, points.begin()->value)); | 640 getYForValue(v, points.begin()->value)); |
640 return text; | 641 return text; |
641 } | 642 } |
642 | 643 |
643 bool | 644 bool |
644 TimeValueLayer::snapToFeatureFrame(View *v, sv_frame_t &frame, | 645 TimeValueLayer::snapToFeatureFrame(LayerGeometryProvider *v, sv_frame_t &frame, |
645 int &resolution, | 646 int &resolution, |
646 SnapType snap) const | 647 SnapType snap) const |
647 { | 648 { |
648 if (!m_model) { | 649 if (!m_model) { |
649 return Layer::snapToFeatureFrame(v, frame, resolution, snap); | 650 return Layer::snapToFeatureFrame(v, frame, resolution, snap); |
711 frame = snapped; | 712 frame = snapped; |
712 return found; | 713 return found; |
713 } | 714 } |
714 | 715 |
715 bool | 716 bool |
716 TimeValueLayer::snapToSimilarFeature(View *v, sv_frame_t &frame, | 717 TimeValueLayer::snapToSimilarFeature(LayerGeometryProvider *v, sv_frame_t &frame, |
717 int &resolution, | 718 int &resolution, |
718 SnapType snap) const | 719 SnapType snap) const |
719 { | 720 { |
720 if (!m_model) { | 721 if (!m_model) { |
721 return Layer::snapToSimilarFeature(v, frame, resolution, snap); | 722 return Layer::snapToSimilarFeature(v, frame, resolution, snap); |
792 frame = snapped; | 793 frame = snapped; |
793 return found; | 794 return found; |
794 } | 795 } |
795 | 796 |
796 void | 797 void |
797 TimeValueLayer::getScaleExtents(View *v, double &min, double &max, bool &log) const | 798 TimeValueLayer::getScaleExtents(LayerGeometryProvider *v, double &min, double &max, bool &log) const |
798 { | 799 { |
799 min = 0.0; | 800 min = 0.0; |
800 max = 0.0; | 801 max = 0.0; |
801 log = false; | 802 log = false; |
802 | 803 |
828 cerr << "TimeValueLayer::getScaleExtents: min = " << min << ", max = " << max << endl; | 829 cerr << "TimeValueLayer::getScaleExtents: min = " << min << ", max = " << max << endl; |
829 #endif | 830 #endif |
830 } | 831 } |
831 | 832 |
832 int | 833 int |
833 TimeValueLayer::getYForValue(View *v, double val) const | 834 TimeValueLayer::getYForValue(LayerGeometryProvider *v, double val) const |
834 { | 835 { |
835 double min = 0.0, max = 0.0; | 836 double min = 0.0, max = 0.0; |
836 bool logarithmic = false; | 837 bool logarithmic = false; |
837 int h = v->height(); | 838 int h = v->getPaintHeight(); |
838 | 839 |
839 getScaleExtents(v, min, max, logarithmic); | 840 getScaleExtents(v, min, max, logarithmic); |
840 | 841 |
841 #ifdef DEBUG_TIME_VALUE_LAYER | 842 #ifdef DEBUG_TIME_VALUE_LAYER |
842 cerr << "getYForValue(" << val << "): min " << min << ", max " | 843 cerr << "getYForValue(" << val << "): min " << min << ", max " |
849 | 850 |
850 return int(h - ((val - min) * h) / (max - min)); | 851 return int(h - ((val - min) * h) / (max - min)); |
851 } | 852 } |
852 | 853 |
853 double | 854 double |
854 TimeValueLayer::getValueForY(View *v, int y) const | 855 TimeValueLayer::getValueForY(LayerGeometryProvider *v, int y) const |
855 { | 856 { |
856 double min = 0.0, max = 0.0; | 857 double min = 0.0, max = 0.0; |
857 bool logarithmic = false; | 858 bool logarithmic = false; |
858 int h = v->height(); | 859 int h = v->getPaintHeight(); |
859 | 860 |
860 getScaleExtents(v, min, max, logarithmic); | 861 getScaleExtents(v, min, max, logarithmic); |
861 | 862 |
862 double val = min + (double(h - y) * double(max - min)) / h; | 863 double val = min + (double(h - y) * double(max - min)) / h; |
863 | 864 |
875 QString unit = getScaleUnits(); | 876 QString unit = getScaleUnits(); |
876 return (m_verticalScale == AutoAlignScale && unit != ""); | 877 return (m_verticalScale == AutoAlignScale && unit != ""); |
877 } | 878 } |
878 | 879 |
879 QColor | 880 QColor |
880 TimeValueLayer::getColourForValue(View *v, double val) const | 881 TimeValueLayer::getColourForValue(LayerGeometryProvider *v, double val) const |
881 { | 882 { |
882 double min, max; | 883 double min, max; |
883 bool log; | 884 bool log; |
884 getScaleExtents(v, min, max, log); | 885 getScaleExtents(v, min, max, log); |
885 | 886 |
906 return ColourDatabase::getInstance()->getColourIndex | 907 return ColourDatabase::getInstance()->getColourIndex |
907 (QString(darkbg ? "Bright Green" : "Green")); | 908 (QString(darkbg ? "Bright Green" : "Green")); |
908 } | 909 } |
909 | 910 |
910 void | 911 void |
911 TimeValueLayer::paint(View *v, QPainter &paint, QRect rect) const | 912 TimeValueLayer::paint(LayerGeometryProvider *v, QPainter &paint, QRect rect) const |
912 { | 913 { |
913 if (!m_model || !m_model->isOK()) return; | 914 if (!m_model || !m_model->isOK()) return; |
914 | 915 |
915 sv_samplerate_t sampleRate = m_model->getSampleRate(); | 916 sv_samplerate_t sampleRate = m_model->getSampleRate(); |
916 if (!sampleRate) return; | 917 if (!sampleRate) return; |
941 | 942 |
942 double min = m_model->getValueMinimum(); | 943 double min = m_model->getValueMinimum(); |
943 double max = m_model->getValueMaximum(); | 944 double max = m_model->getValueMaximum(); |
944 if (max == min) max = min + 1.0; | 945 if (max == min) max = min + 1.0; |
945 | 946 |
946 int origin = int(nearbyint(v->height() - | 947 int origin = int(nearbyint(v->getPaintHeight() - |
947 (-min * v->height()) / (max - min))); | 948 (-min * v->getPaintHeight()) / (max - min))); |
948 | 949 |
949 QPoint localPos; | 950 QPoint localPos; |
950 sv_frame_t illuminateFrame = -1; | 951 sv_frame_t illuminateFrame = -1; |
951 | 952 |
952 if (v->shouldIlluminateLocalFeatures(this, localPos)) { | 953 if (v->shouldIlluminateLocalFeatures(this, localPos)) { |
976 int textY = 0; | 977 int textY = 0; |
977 if (m_plotStyle == PlotSegmentation) { | 978 if (m_plotStyle == PlotSegmentation) { |
978 textY = v->getTextLabelHeight(this, paint); | 979 textY = v->getTextLabelHeight(this, paint); |
979 } else { | 980 } else { |
980 int originY = getYForValue(v, 0.f); | 981 int originY = getYForValue(v, 0.f); |
981 if (originY > 0 && originY < v->height()) { | 982 if (originY > 0 && originY < v->getPaintHeight()) { |
982 paint.save(); | 983 paint.save(); |
983 paint.setPen(getPartialShades(v)[1]); | 984 paint.setPen(getPartialShades(v)[1]); |
984 paint.drawLine(x0, originY, x1, originY); | 985 paint.drawLine(x0, originY, x1, originY); |
985 paint.restore(); | 986 paint.restore(); |
986 } | 987 } |
1181 paint.setPen(QPen(getForegroundQColor(v), 2)); | 1182 paint.setPen(QPen(getForegroundQColor(v), 2)); |
1182 | 1183 |
1183 if (!illuminate) { | 1184 if (!illuminate) { |
1184 if (!m_drawSegmentDivisions || | 1185 if (!m_drawSegmentDivisions || |
1185 nx < x + 5 || | 1186 nx < x + 5 || |
1186 x >= v->width() - 1) { | 1187 x >= v->getPaintWidth() - 1) { |
1187 paint.setPen(Qt::NoPen); | 1188 paint.setPen(Qt::NoPen); |
1188 } | 1189 } |
1189 } | 1190 } |
1190 | 1191 |
1191 paint.drawRect(x, -1, nx - x, v->height() + 1); | 1192 paint.drawRect(x, -1, nx - x, v->getPaintHeight() + 1); |
1192 } | 1193 } |
1193 | 1194 |
1194 if (v->shouldShowFeatureLabels()) { | 1195 if (v->shouldShowFeatureLabels()) { |
1195 | 1196 |
1196 QString label = p.label; | 1197 QString label = p.label; |
1212 haveRoom = (haveRoom && | 1213 haveRoom = (haveRoom && |
1213 (nx > x + 6 + paint.fontMetrics().width(label))); | 1214 (nx > x + 6 + paint.fontMetrics().width(label))); |
1214 if (haveRoom || | 1215 if (haveRoom || |
1215 (!haveNext && | 1216 (!haveNext && |
1216 (pointCount == 0 || !italic))) { | 1217 (pointCount == 0 || !italic))) { |
1217 v->drawVisibleText(paint, x + 5, textY, label, | 1218 PaintAssistant::drawVisibleText(v, paint, x + 5, textY, label, |
1218 italic ? | 1219 italic ? |
1219 View::OutlinedItalicText : | 1220 PaintAssistant::OutlinedItalicText : |
1220 View::OutlinedText); | 1221 PaintAssistant::OutlinedText); |
1221 } | 1222 } |
1222 } | 1223 } |
1223 } | 1224 } |
1224 | 1225 |
1225 prevFrame = p.frame; | 1226 prevFrame = p.frame; |
1229 if (m_plotStyle == PlotDiscreteCurves) { | 1230 if (m_plotStyle == PlotDiscreteCurves) { |
1230 paint.setRenderHint(QPainter::Antialiasing, true); | 1231 paint.setRenderHint(QPainter::Antialiasing, true); |
1231 paint.drawPath(path); | 1232 paint.drawPath(path); |
1232 } else if ((m_plotStyle == PlotCurve || m_plotStyle == PlotLines) | 1233 } else if ((m_plotStyle == PlotCurve || m_plotStyle == PlotLines) |
1233 && !path.isEmpty()) { | 1234 && !path.isEmpty()) { |
1234 paint.setRenderHint(QPainter::Antialiasing, pointCount <= v->width()); | 1235 paint.setRenderHint(QPainter::Antialiasing, pointCount <= v->getPaintWidth()); |
1235 paint.drawPath(path); | 1236 paint.drawPath(path); |
1236 } | 1237 } |
1237 | 1238 |
1238 paint.restore(); | 1239 paint.restore(); |
1239 | 1240 |
1240 // looks like save/restore doesn't deal with this: | 1241 // looks like save/restore doesn't deal with this: |
1241 paint.setRenderHint(QPainter::Antialiasing, false); | 1242 paint.setRenderHint(QPainter::Antialiasing, false); |
1242 } | 1243 } |
1243 | 1244 |
1244 int | 1245 int |
1245 TimeValueLayer::getVerticalScaleWidth(View *v, bool, QPainter &paint) const | 1246 TimeValueLayer::getVerticalScaleWidth(LayerGeometryProvider *v, bool, QPainter &paint) const |
1246 { | 1247 { |
1247 if (!m_model || shouldAutoAlign()) { | 1248 if (!m_model || shouldAutoAlign()) { |
1248 return 0; | 1249 return 0; |
1249 } else if (m_plotStyle == PlotSegmentation) { | 1250 } else if (m_plotStyle == PlotSegmentation) { |
1250 if (m_verticalScale == LogScale) { | 1251 if (m_verticalScale == LogScale) { |
1260 } | 1261 } |
1261 } | 1262 } |
1262 } | 1263 } |
1263 | 1264 |
1264 void | 1265 void |
1265 TimeValueLayer::paintVerticalScale(View *v, bool, QPainter &paint, QRect) const | 1266 TimeValueLayer::paintVerticalScale(LayerGeometryProvider *v, bool, QPainter &paint, QRect) const |
1266 { | 1267 { |
1267 if (!m_model || m_model->getPoints().empty()) return; | 1268 if (!m_model || m_model->getPoints().empty()) return; |
1268 | 1269 |
1269 QString unit; | 1270 QString unit; |
1270 double min, max; | 1271 double min, max; |
1271 bool logarithmic; | 1272 bool logarithmic; |
1272 | 1273 |
1273 int w = getVerticalScaleWidth(v, false, paint); | 1274 int w = getVerticalScaleWidth(v, false, paint); |
1274 int h = v->height(); | 1275 int h = v->getPaintHeight(); |
1275 | 1276 |
1276 if (m_plotStyle == PlotSegmentation) { | 1277 if (m_plotStyle == PlotSegmentation) { |
1277 | 1278 |
1278 getValueExtents(min, max, logarithmic, unit); | 1279 getValueExtents(min, max, logarithmic, unit); |
1279 | 1280 |
1312 mw)); | 1313 mw)); |
1313 } | 1314 } |
1314 } | 1315 } |
1315 | 1316 |
1316 void | 1317 void |
1317 TimeValueLayer::drawStart(View *v, QMouseEvent *e) | 1318 TimeValueLayer::drawStart(LayerGeometryProvider *v, QMouseEvent *e) |
1318 { | 1319 { |
1319 #ifdef DEBUG_TIME_VALUE_LAYER | 1320 #ifdef DEBUG_TIME_VALUE_LAYER |
1320 cerr << "TimeValueLayer::drawStart(" << e->x() << "," << e->y() << ")" << endl; | 1321 cerr << "TimeValueLayer::drawStart(" << e->x() << "," << e->y() << ")" << endl; |
1321 #endif | 1322 #endif |
1322 | 1323 |
1362 | 1363 |
1363 m_editing = true; | 1364 m_editing = true; |
1364 } | 1365 } |
1365 | 1366 |
1366 void | 1367 void |
1367 TimeValueLayer::drawDrag(View *v, QMouseEvent *e) | 1368 TimeValueLayer::drawDrag(LayerGeometryProvider *v, QMouseEvent *e) |
1368 { | 1369 { |
1369 #ifdef DEBUG_TIME_VALUE_LAYER | 1370 #ifdef DEBUG_TIME_VALUE_LAYER |
1370 cerr << "TimeValueLayer::drawDrag(" << e->x() << "," << e->y() << ")" << endl; | 1371 cerr << "TimeValueLayer::drawDrag(" << e->x() << "," << e->y() << ")" << endl; |
1371 #endif | 1372 #endif |
1372 | 1373 |
1424 m_editingPoint.value = float(value); | 1425 m_editingPoint.value = float(value); |
1425 m_editingCommand->addPoint(m_editingPoint); | 1426 m_editingCommand->addPoint(m_editingPoint); |
1426 } | 1427 } |
1427 | 1428 |
1428 void | 1429 void |
1429 TimeValueLayer::drawEnd(View *, QMouseEvent *) | 1430 TimeValueLayer::drawEnd(LayerGeometryProvider *, QMouseEvent *) |
1430 { | 1431 { |
1431 #ifdef DEBUG_TIME_VALUE_LAYER | 1432 #ifdef DEBUG_TIME_VALUE_LAYER |
1432 cerr << "TimeValueLayer::drawEnd" << endl; | 1433 cerr << "TimeValueLayer::drawEnd" << endl; |
1433 #endif | 1434 #endif |
1434 if (!m_model || !m_editing) return; | 1435 if (!m_model || !m_editing) return; |
1436 m_editingCommand = 0; | 1437 m_editingCommand = 0; |
1437 m_editing = false; | 1438 m_editing = false; |
1438 } | 1439 } |
1439 | 1440 |
1440 void | 1441 void |
1441 TimeValueLayer::eraseStart(View *v, QMouseEvent *e) | 1442 TimeValueLayer::eraseStart(LayerGeometryProvider *v, QMouseEvent *e) |
1442 { | 1443 { |
1443 if (!m_model) return; | 1444 if (!m_model) return; |
1444 | 1445 |
1445 SparseTimeValueModel::PointList points = getLocalPoints(v, e->x()); | 1446 SparseTimeValueModel::PointList points = getLocalPoints(v, e->x()); |
1446 if (points.empty()) return; | 1447 if (points.empty()) return; |
1454 | 1455 |
1455 m_editing = true; | 1456 m_editing = true; |
1456 } | 1457 } |
1457 | 1458 |
1458 void | 1459 void |
1459 TimeValueLayer::eraseDrag(View *, QMouseEvent *) | 1460 TimeValueLayer::eraseDrag(LayerGeometryProvider *, QMouseEvent *) |
1460 { | 1461 { |
1461 } | 1462 } |
1462 | 1463 |
1463 void | 1464 void |
1464 TimeValueLayer::eraseEnd(View *v, QMouseEvent *e) | 1465 TimeValueLayer::eraseEnd(LayerGeometryProvider *v, QMouseEvent *e) |
1465 { | 1466 { |
1466 if (!m_model || !m_editing) return; | 1467 if (!m_model || !m_editing) return; |
1467 | 1468 |
1468 m_editing = false; | 1469 m_editing = false; |
1469 | 1470 |
1481 m_editingCommand = 0; | 1482 m_editingCommand = 0; |
1482 m_editing = false; | 1483 m_editing = false; |
1483 } | 1484 } |
1484 | 1485 |
1485 void | 1486 void |
1486 TimeValueLayer::editStart(View *v, QMouseEvent *e) | 1487 TimeValueLayer::editStart(LayerGeometryProvider *v, QMouseEvent *e) |
1487 { | 1488 { |
1488 #ifdef DEBUG_TIME_VALUE_LAYER | 1489 #ifdef DEBUG_TIME_VALUE_LAYER |
1489 cerr << "TimeValueLayer::editStart(" << e->x() << "," << e->y() << ")" << endl; | 1490 cerr << "TimeValueLayer::editStart(" << e->x() << "," << e->y() << ")" << endl; |
1490 #endif | 1491 #endif |
1491 | 1492 |
1504 | 1505 |
1505 m_editing = true; | 1506 m_editing = true; |
1506 } | 1507 } |
1507 | 1508 |
1508 void | 1509 void |
1509 TimeValueLayer::editDrag(View *v, QMouseEvent *e) | 1510 TimeValueLayer::editDrag(LayerGeometryProvider *v, QMouseEvent *e) |
1510 { | 1511 { |
1511 #ifdef DEBUG_TIME_VALUE_LAYER | 1512 #ifdef DEBUG_TIME_VALUE_LAYER |
1512 cerr << "TimeValueLayer::editDrag(" << e->x() << "," << e->y() << ")" << endl; | 1513 cerr << "TimeValueLayer::editDrag(" << e->x() << "," << e->y() << ")" << endl; |
1513 #endif | 1514 #endif |
1514 | 1515 |
1530 m_editingPoint.value = float(value); | 1531 m_editingPoint.value = float(value); |
1531 m_editingCommand->addPoint(m_editingPoint); | 1532 m_editingCommand->addPoint(m_editingPoint); |
1532 } | 1533 } |
1533 | 1534 |
1534 void | 1535 void |
1535 TimeValueLayer::editEnd(View *, QMouseEvent *) | 1536 TimeValueLayer::editEnd(LayerGeometryProvider *, QMouseEvent *) |
1536 { | 1537 { |
1537 #ifdef DEBUG_TIME_VALUE_LAYER | 1538 #ifdef DEBUG_TIME_VALUE_LAYER |
1538 cerr << "TimeValueLayer::editEnd" << endl; | 1539 cerr << "TimeValueLayer::editEnd" << endl; |
1539 #endif | 1540 #endif |
1540 if (!m_model || !m_editing) return; | 1541 if (!m_model || !m_editing) return; |
1560 m_editingCommand = 0; | 1561 m_editingCommand = 0; |
1561 m_editing = false; | 1562 m_editing = false; |
1562 } | 1563 } |
1563 | 1564 |
1564 bool | 1565 bool |
1565 TimeValueLayer::editOpen(View *v, QMouseEvent *e) | 1566 TimeValueLayer::editOpen(LayerGeometryProvider *v, QMouseEvent *e) |
1566 { | 1567 { |
1567 if (!m_model) return false; | 1568 if (!m_model) return false; |
1568 | 1569 |
1569 SparseTimeValueModel::PointList points = getLocalPoints(v, e->x()); | 1570 SparseTimeValueModel::PointList points = getLocalPoints(v, e->x()); |
1570 if (points.empty()) return false; | 1571 if (points.empty()) return false; |
1683 | 1684 |
1684 finish(command); | 1685 finish(command); |
1685 } | 1686 } |
1686 | 1687 |
1687 void | 1688 void |
1688 TimeValueLayer::copy(View *v, Selection s, Clipboard &to) | 1689 TimeValueLayer::copy(LayerGeometryProvider *v, Selection s, Clipboard &to) |
1689 { | 1690 { |
1690 if (!m_model) return; | 1691 if (!m_model) return; |
1691 | 1692 |
1692 SparseTimeValueModel::PointList points = | 1693 SparseTimeValueModel::PointList points = |
1693 m_model->getPoints(s.getStartFrame(), s.getEndFrame()); | 1694 m_model->getPoints(s.getStartFrame(), s.getEndFrame()); |
1701 } | 1702 } |
1702 } | 1703 } |
1703 } | 1704 } |
1704 | 1705 |
1705 bool | 1706 bool |
1706 TimeValueLayer::paste(View *v, const Clipboard &from, sv_frame_t /* frameOffset */, | 1707 TimeValueLayer::paste(LayerGeometryProvider *v, const Clipboard &from, sv_frame_t /* frameOffset */, |
1707 bool interactive) | 1708 bool interactive) |
1708 { | 1709 { |
1709 if (!m_model) return false; | 1710 if (!m_model) return false; |
1710 | 1711 |
1711 const Clipboard::PointList &points = from.getPoints(); | 1712 const Clipboard::PointList &points = from.getPoints(); |
1713 bool realign = false; | 1714 bool realign = false; |
1714 | 1715 |
1715 if (clipboardHasDifferentAlignment(v, from)) { | 1716 if (clipboardHasDifferentAlignment(v, from)) { |
1716 | 1717 |
1717 QMessageBox::StandardButton button = | 1718 QMessageBox::StandardButton button = |
1718 QMessageBox::question(v, tr("Re-align pasted items?"), | 1719 QMessageBox::question(v->getView(), tr("Re-align pasted items?"), |
1719 tr("The items you are pasting came from a layer with different source material from this one. Do you want to re-align them in time, to match the source material for this layer?"), | 1720 tr("The items you are pasting came from a layer with different source material from this one. Do you want to re-align them in time, to match the source material for this layer?"), |
1720 QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel, | 1721 QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel, |
1721 QMessageBox::Yes); | 1722 QMessageBox::Yes); |
1722 | 1723 |
1723 if (button == QMessageBox::Cancel) { | 1724 if (button == QMessageBox::Cancel) { |