Mercurial > hg > svgui
comparison layer/TimeValueLayer.cpp @ 1408:c8a6fd3f9dff fix-static-analysis
Use nullptr throughout
author | Chris Cannam |
---|---|
date | Mon, 26 Nov 2018 14:33:54 +0000 |
parents | b0eeec95ab5b |
children | 62e908518c71 |
comparison
equal
deleted
inserted
replaced
1407:05d614f6e46d | 1408:c8a6fd3f9dff |
---|---|
52 | 52 |
53 //#define DEBUG_TIME_VALUE_LAYER 1 | 53 //#define DEBUG_TIME_VALUE_LAYER 1 |
54 | 54 |
55 TimeValueLayer::TimeValueLayer() : | 55 TimeValueLayer::TimeValueLayer() : |
56 SingleColourLayer(), | 56 SingleColourLayer(), |
57 m_model(0), | 57 m_model(nullptr), |
58 m_editing(false), | 58 m_editing(false), |
59 m_originalPoint(0, 0.0, tr("New Point")), | 59 m_originalPoint(0, 0.0, tr("New Point")), |
60 m_editingPoint(0, 0.0, tr("New Point")), | 60 m_editingPoint(0, 0.0, tr("New Point")), |
61 m_editingCommand(0), | 61 m_editingCommand(nullptr), |
62 m_colourMap(0), | 62 m_colourMap(0), |
63 m_colourInverted(false), | 63 m_colourInverted(false), |
64 m_plotStyle(PlotConnectedPoints), | 64 m_plotStyle(PlotConnectedPoints), |
65 m_verticalScale(AutoAlignScale), | 65 m_verticalScale(AutoAlignScale), |
66 m_drawSegmentDivisions(true), | 66 m_drawSegmentDivisions(true), |
509 } | 509 } |
510 | 510 |
511 RangeMapper * | 511 RangeMapper * |
512 TimeValueLayer::getNewVerticalZoomRangeMapper() const | 512 TimeValueLayer::getNewVerticalZoomRangeMapper() const |
513 { | 513 { |
514 if (!m_model) return 0; | 514 if (!m_model) return nullptr; |
515 | 515 |
516 RangeMapper *mapper; | 516 RangeMapper *mapper; |
517 | 517 |
518 double min, max; | 518 double min, max; |
519 bool logarithmic; | 519 bool logarithmic; |
520 QString unit; | 520 QString unit; |
521 getValueExtents(min, max, logarithmic, unit); | 521 getValueExtents(min, max, logarithmic, unit); |
522 | 522 |
523 if (min == max) return 0; | 523 if (min == max) return nullptr; |
524 | 524 |
525 if (logarithmic) { | 525 if (logarithmic) { |
526 mapper = new LogRangeMapper(0, 100, min, max, unit); | 526 mapper = new LogRangeMapper(0, 100, min, max, unit); |
527 } else { | 527 } else { |
528 mapper = new LinearRangeMapper(0, 100, min, max, unit); | 528 mapper = new LinearRangeMapper(0, 100, min, max, unit); |
1428 #ifdef DEBUG_TIME_VALUE_LAYER | 1428 #ifdef DEBUG_TIME_VALUE_LAYER |
1429 cerr << "TimeValueLayer::drawEnd" << endl; | 1429 cerr << "TimeValueLayer::drawEnd" << endl; |
1430 #endif | 1430 #endif |
1431 if (!m_model || !m_editing) return; | 1431 if (!m_model || !m_editing) return; |
1432 finish(m_editingCommand); | 1432 finish(m_editingCommand); |
1433 m_editingCommand = 0; | 1433 m_editingCommand = nullptr; |
1434 m_editing = false; | 1434 m_editing = false; |
1435 } | 1435 } |
1436 | 1436 |
1437 void | 1437 void |
1438 TimeValueLayer::eraseStart(LayerGeometryProvider *v, QMouseEvent *e) | 1438 TimeValueLayer::eraseStart(LayerGeometryProvider *v, QMouseEvent *e) |
1444 | 1444 |
1445 m_editingPoint = *points.begin(); | 1445 m_editingPoint = *points.begin(); |
1446 | 1446 |
1447 if (m_editingCommand) { | 1447 if (m_editingCommand) { |
1448 finish(m_editingCommand); | 1448 finish(m_editingCommand); |
1449 m_editingCommand = 0; | 1449 m_editingCommand = nullptr; |
1450 } | 1450 } |
1451 | 1451 |
1452 m_editing = true; | 1452 m_editing = true; |
1453 } | 1453 } |
1454 | 1454 |
1473 (m_model, tr("Erase Point")); | 1473 (m_model, tr("Erase Point")); |
1474 | 1474 |
1475 m_editingCommand->deletePoint(m_editingPoint); | 1475 m_editingCommand->deletePoint(m_editingPoint); |
1476 | 1476 |
1477 finish(m_editingCommand); | 1477 finish(m_editingCommand); |
1478 m_editingCommand = 0; | 1478 m_editingCommand = nullptr; |
1479 m_editing = false; | 1479 m_editing = false; |
1480 } | 1480 } |
1481 | 1481 |
1482 void | 1482 void |
1483 TimeValueLayer::editStart(LayerGeometryProvider *v, QMouseEvent *e) | 1483 TimeValueLayer::editStart(LayerGeometryProvider *v, QMouseEvent *e) |
1494 m_editingPoint = *points.begin(); | 1494 m_editingPoint = *points.begin(); |
1495 m_originalPoint = m_editingPoint; | 1495 m_originalPoint = m_editingPoint; |
1496 | 1496 |
1497 if (m_editingCommand) { | 1497 if (m_editingCommand) { |
1498 finish(m_editingCommand); | 1498 finish(m_editingCommand); |
1499 m_editingCommand = 0; | 1499 m_editingCommand = nullptr; |
1500 } | 1500 } |
1501 | 1501 |
1502 m_editing = true; | 1502 m_editing = true; |
1503 } | 1503 } |
1504 | 1504 |
1552 | 1552 |
1553 m_editingCommand->setName(newName); | 1553 m_editingCommand->setName(newName); |
1554 finish(m_editingCommand); | 1554 finish(m_editingCommand); |
1555 } | 1555 } |
1556 | 1556 |
1557 m_editingCommand = 0; | 1557 m_editingCommand = nullptr; |
1558 m_editing = false; | 1558 m_editing = false; |
1559 } | 1559 } |
1560 | 1560 |
1561 bool | 1561 bool |
1562 TimeValueLayer::editOpen(LayerGeometryProvider *v, QMouseEvent *e) | 1562 TimeValueLayer::editOpen(LayerGeometryProvider *v, QMouseEvent *e) |
1801 | 1801 |
1802 static int prevSelection = 0; | 1802 static int prevSelection = 0; |
1803 | 1803 |
1804 bool ok = false; | 1804 bool ok = false; |
1805 QString selected = ListInputDialog::getItem | 1805 QString selected = ListInputDialog::getItem |
1806 (0, tr("Choose value calculation"), | 1806 (nullptr, tr("Choose value calculation"), |
1807 text, options, prevSelection, &ok); | 1807 text, options, prevSelection, &ok); |
1808 | 1808 |
1809 if (!ok) { | 1809 if (!ok) { |
1810 delete command; | 1810 delete command; |
1811 return false; | 1811 return false; |
1825 labeller.setType(generation); | 1825 labeller.setType(generation); |
1826 | 1826 |
1827 if (generation == Labeller::ValueFromCyclicalCounter || | 1827 if (generation == Labeller::ValueFromCyclicalCounter || |
1828 generation == Labeller::ValueFromTwoLevelCounter) { | 1828 generation == Labeller::ValueFromTwoLevelCounter) { |
1829 int cycleSize = QInputDialog::getInt | 1829 int cycleSize = QInputDialog::getInt |
1830 (0, tr("Select cycle size"), | 1830 (nullptr, tr("Select cycle size"), |
1831 tr("Cycle size:"), 4, 2, 16, 1); | 1831 tr("Cycle size:"), 4, 2, 16, 1); |
1832 labeller.setCounterCycleSize(cycleSize); | 1832 labeller.setCounterCycleSize(cycleSize); |
1833 } | 1833 } |
1834 | 1834 |
1835 prevSelection = selection; | 1835 prevSelection = selection; |
1880 } else { | 1880 } else { |
1881 cerr << ", prev point is at " << prevPoint.frame << endl; | 1881 cerr << ", prev point is at " << prevPoint.frame << endl; |
1882 } | 1882 } |
1883 #endif | 1883 #endif |
1884 labeller.setValue<SparseTimeValueModel::Point> | 1884 labeller.setValue<SparseTimeValueModel::Point> |
1885 (newPoint, (i == points.begin()) ? 0 : &prevPoint); | 1885 (newPoint, (i == points.begin()) ? nullptr : &prevPoint); |
1886 #ifdef DEBUG_TIME_VALUE_LAYER | 1886 #ifdef DEBUG_TIME_VALUE_LAYER |
1887 cerr << "New point value = " << newPoint.value << endl; | 1887 cerr << "New point value = " << newPoint.value << endl; |
1888 #endif | 1888 #endif |
1889 if (labeller.actingOnPrevPoint() && i != points.begin()) { | 1889 if (labeller.actingOnPrevPoint() && i != points.begin()) { |
1890 usePrev = true; | 1890 usePrev = true; |