Mercurial > hg > svgui
comparison layer/NoteLayer.cpp @ 1414:fa986b91d77f
Merge from branch fix-static-analysis
author | Chris Cannam |
---|---|
date | Wed, 09 Jan 2019 15:24:51 +0000 |
parents | c8a6fd3f9dff |
children | 6f51297a0250 |
comparison
equal
deleted
inserted
replaced
1413:0930a27ebea2 | 1414:fa986b91d77f |
---|---|
46 | 46 |
47 //#define DEBUG_NOTE_LAYER 1 | 47 //#define DEBUG_NOTE_LAYER 1 |
48 | 48 |
49 NoteLayer::NoteLayer() : | 49 NoteLayer::NoteLayer() : |
50 SingleColourLayer(), | 50 SingleColourLayer(), |
51 m_model(0), | 51 m_model(nullptr), |
52 m_editing(false), | 52 m_editing(false), |
53 m_dragPointX(0), | 53 m_dragPointX(0), |
54 m_dragPointY(0), | 54 m_dragPointY(0), |
55 m_dragStartX(0), | 55 m_dragStartX(0), |
56 m_dragStartY(0), | 56 m_dragStartY(0), |
57 m_originalPoint(0, 0.0, 0, 1.f, tr("New Point")), | 57 m_originalPoint(0, 0.0, 0, 1.f, tr("New Point")), |
58 m_editingPoint(0, 0.0, 0, 1.f, tr("New Point")), | 58 m_editingPoint(0, 0.0, 0, 1.f, tr("New Point")), |
59 m_editingCommand(0), | 59 m_editingCommand(nullptr), |
60 m_verticalScale(AutoAlignScale), | 60 m_verticalScale(AutoAlignScale), |
61 m_scaleMinimum(0), | 61 m_scaleMinimum(0), |
62 m_scaleMaximum(0) | 62 m_scaleMaximum(0) |
63 { | 63 { |
64 SVDEBUG << "constructed NoteLayer" << endl; | 64 SVDEBUG << "constructed NoteLayer" << endl; |
367 } | 367 } |
368 | 368 |
369 RangeMapper * | 369 RangeMapper * |
370 NoteLayer::getNewVerticalZoomRangeMapper() const | 370 NoteLayer::getNewVerticalZoomRangeMapper() const |
371 { | 371 { |
372 if (!m_model) return 0; | 372 if (!m_model) return nullptr; |
373 | 373 |
374 RangeMapper *mapper; | 374 RangeMapper *mapper; |
375 | 375 |
376 double min, max; | 376 double min, max; |
377 bool logarithmic; | 377 bool logarithmic; |
378 QString unit; | 378 QString unit; |
379 getValueExtents(min, max, logarithmic, unit); | 379 getValueExtents(min, max, logarithmic, unit); |
380 | 380 |
381 if (min == max) return 0; | 381 if (min == max) return nullptr; |
382 | 382 |
383 if (logarithmic) { | 383 if (logarithmic) { |
384 mapper = new LogRangeMapper(0, 100, min, max, unit); | 384 mapper = new LogRangeMapper(0, 100, min, max, unit); |
385 } else { | 385 } else { |
386 mapper = new LinearRangeMapper(0, 100, min, max, unit); | 386 mapper = new LinearRangeMapper(0, 100, min, max, unit); |
943 NoteLayer::drawEnd(LayerGeometryProvider *, QMouseEvent *) | 943 NoteLayer::drawEnd(LayerGeometryProvider *, QMouseEvent *) |
944 { | 944 { |
945 // SVDEBUG << "NoteLayer::drawEnd(" << e->x() << "," << e->y() << ")" << endl; | 945 // SVDEBUG << "NoteLayer::drawEnd(" << e->x() << "," << e->y() << ")" << endl; |
946 if (!m_model || !m_editing) return; | 946 if (!m_model || !m_editing) return; |
947 finish(m_editingCommand); | 947 finish(m_editingCommand); |
948 m_editingCommand = 0; | 948 m_editingCommand = nullptr; |
949 m_editing = false; | 949 m_editing = false; |
950 } | 950 } |
951 | 951 |
952 void | 952 void |
953 NoteLayer::eraseStart(LayerGeometryProvider *v, QMouseEvent *e) | 953 NoteLayer::eraseStart(LayerGeometryProvider *v, QMouseEvent *e) |
956 | 956 |
957 if (!getPointToDrag(v, e->x(), e->y(), m_editingPoint)) return; | 957 if (!getPointToDrag(v, e->x(), e->y(), m_editingPoint)) return; |
958 | 958 |
959 if (m_editingCommand) { | 959 if (m_editingCommand) { |
960 finish(m_editingCommand); | 960 finish(m_editingCommand); |
961 m_editingCommand = 0; | 961 m_editingCommand = nullptr; |
962 } | 962 } |
963 | 963 |
964 m_editing = true; | 964 m_editing = true; |
965 } | 965 } |
966 | 966 |
983 m_editingCommand = new NoteModel::EditCommand(m_model, tr("Erase Point")); | 983 m_editingCommand = new NoteModel::EditCommand(m_model, tr("Erase Point")); |
984 | 984 |
985 m_editingCommand->deletePoint(m_editingPoint); | 985 m_editingCommand->deletePoint(m_editingPoint); |
986 | 986 |
987 finish(m_editingCommand); | 987 finish(m_editingCommand); |
988 m_editingCommand = 0; | 988 m_editingCommand = nullptr; |
989 m_editing = false; | 989 m_editing = false; |
990 } | 990 } |
991 | 991 |
992 void | 992 void |
993 NoteLayer::editStart(LayerGeometryProvider *v, QMouseEvent *e) | 993 NoteLayer::editStart(LayerGeometryProvider *v, QMouseEvent *e) |
1002 m_dragPointX = v->getXForFrame(m_editingPoint.frame); | 1002 m_dragPointX = v->getXForFrame(m_editingPoint.frame); |
1003 m_dragPointY = getYForValue(v, m_editingPoint.value); | 1003 m_dragPointY = getYForValue(v, m_editingPoint.value); |
1004 | 1004 |
1005 if (m_editingCommand) { | 1005 if (m_editingCommand) { |
1006 finish(m_editingCommand); | 1006 finish(m_editingCommand); |
1007 m_editingCommand = 0; | 1007 m_editingCommand = nullptr; |
1008 } | 1008 } |
1009 | 1009 |
1010 m_editing = true; | 1010 m_editing = true; |
1011 m_dragStartX = e->x(); | 1011 m_dragStartX = e->x(); |
1012 m_dragStartY = e->y(); | 1012 m_dragStartY = e->y(); |
1063 | 1063 |
1064 m_editingCommand->setName(newName); | 1064 m_editingCommand->setName(newName); |
1065 finish(m_editingCommand); | 1065 finish(m_editingCommand); |
1066 } | 1066 } |
1067 | 1067 |
1068 m_editingCommand = 0; | 1068 m_editingCommand = nullptr; |
1069 m_editing = false; | 1069 m_editing = false; |
1070 } | 1070 } |
1071 | 1071 |
1072 bool | 1072 bool |
1073 NoteLayer::editOpen(LayerGeometryProvider *v, QMouseEvent *e) | 1073 NoteLayer::editOpen(LayerGeometryProvider *v, QMouseEvent *e) |