Mercurial > hg > svgui
comparison layer/TimeValueLayer.cpp @ 587:4806715f7a19
Seems to be a bad idea to use plain DEBUG symbol on OS/X (system wants it)
author | Chris Cannam |
---|---|
date | Tue, 14 Jun 2011 15:27:05 +0100 |
parents | f4960f8ce798 |
children | 5b72899d692b |
comparison
equal
deleted
inserted
replaced
586:1ae54a29e59e | 587:4806715f7a19 |
---|---|
79 if (m_model && m_model->getRDFTypeURI().endsWith("Change")) { | 79 if (m_model && m_model->getRDFTypeURI().endsWith("Change")) { |
80 setPlotStyle(PlotSegmentation); | 80 setPlotStyle(PlotSegmentation); |
81 } | 81 } |
82 | 82 |
83 #ifdef DEBUG_TIME_VALUE_LAYER | 83 #ifdef DEBUG_TIME_VALUE_LAYER |
84 DEBUG << "TimeValueLayer::setModel(" << model << ")" << endl; | 84 SVDEBUG << "TimeValueLayer::setModel(" << model << ")" << endl; |
85 #endif | 85 #endif |
86 | 86 |
87 emit modelReplaced(); | 87 emit modelReplaced(); |
88 } | 88 } |
89 | 89 |
346 max = std::max(fabsf(min), fabsf(max)); | 346 max = std::max(fabsf(min), fabsf(max)); |
347 min = -max; | 347 min = -max; |
348 } | 348 } |
349 | 349 |
350 #ifdef DEBUG_TIME_VALUE_LAYER | 350 #ifdef DEBUG_TIME_VALUE_LAYER |
351 DEBUG << "TimeValueLayer::getDisplayExtents: min = " << min << ", max = " << max << endl; | 351 SVDEBUG << "TimeValueLayer::getDisplayExtents: min = " << min << ", max = " << max << endl; |
352 #endif | 352 #endif |
353 | 353 |
354 return true; | 354 return true; |
355 } | 355 } |
356 | 356 |
369 | 369 |
370 m_scaleMinimum = min; | 370 m_scaleMinimum = min; |
371 m_scaleMaximum = max; | 371 m_scaleMaximum = max; |
372 | 372 |
373 #ifdef DEBUG_TIME_VALUE_LAYER | 373 #ifdef DEBUG_TIME_VALUE_LAYER |
374 DEBUG << "TimeValueLayer::setDisplayExtents: min = " << min << ", max = " << max << endl; | 374 SVDEBUG << "TimeValueLayer::setDisplayExtents: min = " << min << ", max = " << max << endl; |
375 #endif | 375 #endif |
376 | 376 |
377 emit layerParametersChanged(); | 377 emit layerParametersChanged(); |
378 return true; | 378 return true; |
379 } | 379 } |
401 getDisplayExtents(dmin, dmax); | 401 getDisplayExtents(dmin, dmax); |
402 | 402 |
403 int nr = mapper->getPositionForValue(dmax - dmin); | 403 int nr = mapper->getPositionForValue(dmax - dmin); |
404 | 404 |
405 #ifdef DEBUG_TIME_VALUE_LAYER | 405 #ifdef DEBUG_TIME_VALUE_LAYER |
406 DEBUG << "TimeValueLayer::getCurrentVerticalZoomStep: dmin = " << dmin << ", dmax = " << dmax << ", nr = " << nr << endl; | 406 SVDEBUG << "TimeValueLayer::getCurrentVerticalZoomStep: dmin = " << dmin << ", dmax = " << dmax << ", nr = " << nr << endl; |
407 #endif | 407 #endif |
408 | 408 |
409 delete mapper; | 409 delete mapper; |
410 | 410 |
411 return 100 - nr; | 411 return 100 - nr; |
456 if (newmax > max) { | 456 if (newmax > max) { |
457 newmax = max; | 457 newmax = max; |
458 } | 458 } |
459 | 459 |
460 #ifdef DEBUG_TIME_VALUE_LAYER | 460 #ifdef DEBUG_TIME_VALUE_LAYER |
461 DEBUG << "TimeValueLayer::setVerticalZoomStep: " << step << ": " << newmin << " -> " << newmax << " (range " << newdist << ")" << endl; | 461 SVDEBUG << "TimeValueLayer::setVerticalZoomStep: " << step << ": " << newmin << " -> " << newmax << " (range " << newdist << ")" << endl; |
462 #endif | 462 #endif |
463 | 463 |
464 setDisplayExtents(newmin, newmax); | 464 setDisplayExtents(newmin, newmax); |
465 } | 465 } |
466 | 466 |
824 if (log) { | 824 if (log) { |
825 val = LogRange::map(val); | 825 val = LogRange::map(val); |
826 } | 826 } |
827 | 827 |
828 #ifdef DEBUG_TIME_VALUE_LAYER | 828 #ifdef DEBUG_TIME_VALUE_LAYER |
829 DEBUG << "TimeValueLayer::getColourForValue: min " << min << ", max " | 829 SVDEBUG << "TimeValueLayer::getColourForValue: min " << min << ", max " |
830 << max << ", log " << log << ", value " << val << endl; | 830 << max << ", log " << log << ", value " << val << endl; |
831 #endif | 831 #endif |
832 | 832 |
833 QColor solid = ColourMapper(m_colourMap, min, max).map(val); | 833 QColor solid = ColourMapper(m_colourMap, min, max).map(val); |
834 return QColor(solid.red(), solid.green(), solid.blue(), 120); | 834 return QColor(solid.red(), solid.green(), solid.blue(), 120); |
868 QColor brushColour(getBaseQColor()); | 868 QColor brushColour(getBaseQColor()); |
869 brushColour.setAlpha(80); | 869 brushColour.setAlpha(80); |
870 paint.setBrush(brushColour); | 870 paint.setBrush(brushColour); |
871 | 871 |
872 #ifdef DEBUG_TIME_VALUE_LAYER | 872 #ifdef DEBUG_TIME_VALUE_LAYER |
873 DEBUG << "TimeValueLayer::paint: resolution is " | 873 SVDEBUG << "TimeValueLayer::paint: resolution is " |
874 << m_model->getResolution() << " frames" << endl; | 874 << m_model->getResolution() << " frames" << endl; |
875 #endif | 875 #endif |
876 | 876 |
877 float min = m_model->getValueMinimum(); | 877 float min = m_model->getValueMinimum(); |
878 float max = m_model->getValueMaximum(); | 878 float max = m_model->getValueMaximum(); |
1065 } | 1065 } |
1066 | 1066 |
1067 if (m_plotStyle == PlotSegmentation) { | 1067 if (m_plotStyle == PlotSegmentation) { |
1068 | 1068 |
1069 #ifdef DEBUG_TIME_VALUE_LAYER | 1069 #ifdef DEBUG_TIME_VALUE_LAYER |
1070 DEBUG << "drawing rect" << endl; | 1070 SVDEBUG << "drawing rect" << endl; |
1071 #endif | 1071 #endif |
1072 | 1072 |
1073 if (nx <= x) continue; | 1073 if (nx <= x) continue; |
1074 | 1074 |
1075 paint.setPen(QPen(getForegroundQColor(v), 2)); | 1075 paint.setPen(QPen(getForegroundQColor(v), 2)); |
1249 | 1249 |
1250 void | 1250 void |
1251 TimeValueLayer::drawStart(View *v, QMouseEvent *e) | 1251 TimeValueLayer::drawStart(View *v, QMouseEvent *e) |
1252 { | 1252 { |
1253 #ifdef DEBUG_TIME_VALUE_LAYER | 1253 #ifdef DEBUG_TIME_VALUE_LAYER |
1254 DEBUG << "TimeValueLayer::drawStart(" << e->x() << "," << e->y() << ")" << endl; | 1254 SVDEBUG << "TimeValueLayer::drawStart(" << e->x() << "," << e->y() << ")" << endl; |
1255 #endif | 1255 #endif |
1256 | 1256 |
1257 if (!m_model) return; | 1257 if (!m_model) return; |
1258 | 1258 |
1259 long frame = v->getFrameForX(e->x()); | 1259 long frame = v->getFrameForX(e->x()); |
1269 if (!points.empty()) { | 1269 if (!points.empty()) { |
1270 for (SparseTimeValueModel::PointList::iterator i = points.begin(); | 1270 for (SparseTimeValueModel::PointList::iterator i = points.begin(); |
1271 i != points.end(); ++i) { | 1271 i != points.end(); ++i) { |
1272 if (((i->frame / resolution) * resolution) != frame) { | 1272 if (((i->frame / resolution) * resolution) != frame) { |
1273 #ifdef DEBUG_TIME_VALUE_LAYER | 1273 #ifdef DEBUG_TIME_VALUE_LAYER |
1274 DEBUG << "ignoring out-of-range frame at " << i->frame << endl; | 1274 SVDEBUG << "ignoring out-of-range frame at " << i->frame << endl; |
1275 #endif | 1275 #endif |
1276 continue; | 1276 continue; |
1277 } | 1277 } |
1278 m_editingPoint = *i; | 1278 m_editingPoint = *i; |
1279 havePoint = true; | 1279 havePoint = true; |
1299 | 1299 |
1300 void | 1300 void |
1301 TimeValueLayer::drawDrag(View *v, QMouseEvent *e) | 1301 TimeValueLayer::drawDrag(View *v, QMouseEvent *e) |
1302 { | 1302 { |
1303 #ifdef DEBUG_TIME_VALUE_LAYER | 1303 #ifdef DEBUG_TIME_VALUE_LAYER |
1304 DEBUG << "TimeValueLayer::drawDrag(" << e->x() << "," << e->y() << ")" << endl; | 1304 SVDEBUG << "TimeValueLayer::drawDrag(" << e->x() << "," << e->y() << ")" << endl; |
1305 #endif | 1305 #endif |
1306 | 1306 |
1307 if (!m_model || !m_editing) return; | 1307 if (!m_model || !m_editing) return; |
1308 | 1308 |
1309 long frame = v->getFrameForX(e->x()); | 1309 long frame = v->getFrameForX(e->x()); |
1325 for (SparseTimeValueModel::PointList::iterator i = points.begin(); | 1325 for (SparseTimeValueModel::PointList::iterator i = points.begin(); |
1326 i != points.end(); ++i) { | 1326 i != points.end(); ++i) { |
1327 if (i->frame == m_editingPoint.frame && | 1327 if (i->frame == m_editingPoint.frame && |
1328 i->value == m_editingPoint.value) { | 1328 i->value == m_editingPoint.value) { |
1329 #ifdef DEBUG_TIME_VALUE_LAYER | 1329 #ifdef DEBUG_TIME_VALUE_LAYER |
1330 DEBUG << "ignoring current editing point at " << i->frame << ", " << i->value << endl; | 1330 SVDEBUG << "ignoring current editing point at " << i->frame << ", " << i->value << endl; |
1331 #endif | 1331 #endif |
1332 continue; | 1332 continue; |
1333 } | 1333 } |
1334 if (((i->frame / resolution) * resolution) != frame) { | 1334 if (((i->frame / resolution) * resolution) != frame) { |
1335 #ifdef DEBUG_TIME_VALUE_LAYER | 1335 #ifdef DEBUG_TIME_VALUE_LAYER |
1336 DEBUG << "ignoring out-of-range frame at " << i->frame << endl; | 1336 SVDEBUG << "ignoring out-of-range frame at " << i->frame << endl; |
1337 #endif | 1337 #endif |
1338 continue; | 1338 continue; |
1339 } | 1339 } |
1340 #ifdef DEBUG_TIME_VALUE_LAYER | 1340 #ifdef DEBUG_TIME_VALUE_LAYER |
1341 DEBUG << "adjusting to new point at " << i->frame << ", " << i->value << endl; | 1341 SVDEBUG << "adjusting to new point at " << i->frame << ", " << i->value << endl; |
1342 #endif | 1342 #endif |
1343 m_editingPoint = *i; | 1343 m_editingPoint = *i; |
1344 m_originalPoint = m_editingPoint; | 1344 m_originalPoint = m_editingPoint; |
1345 m_editingCommand->deletePoint(m_editingPoint); | 1345 m_editingCommand->deletePoint(m_editingPoint); |
1346 havePoint = true; | 1346 havePoint = true; |
1361 | 1361 |
1362 void | 1362 void |
1363 TimeValueLayer::drawEnd(View *, QMouseEvent *) | 1363 TimeValueLayer::drawEnd(View *, QMouseEvent *) |
1364 { | 1364 { |
1365 #ifdef DEBUG_TIME_VALUE_LAYER | 1365 #ifdef DEBUG_TIME_VALUE_LAYER |
1366 DEBUG << "TimeValueLayer::drawEnd" << endl; | 1366 SVDEBUG << "TimeValueLayer::drawEnd" << endl; |
1367 #endif | 1367 #endif |
1368 if (!m_model || !m_editing) return; | 1368 if (!m_model || !m_editing) return; |
1369 finish(m_editingCommand); | 1369 finish(m_editingCommand); |
1370 m_editingCommand = 0; | 1370 m_editingCommand = 0; |
1371 m_editing = false; | 1371 m_editing = false; |
1418 | 1418 |
1419 void | 1419 void |
1420 TimeValueLayer::editStart(View *v, QMouseEvent *e) | 1420 TimeValueLayer::editStart(View *v, QMouseEvent *e) |
1421 { | 1421 { |
1422 #ifdef DEBUG_TIME_VALUE_LAYER | 1422 #ifdef DEBUG_TIME_VALUE_LAYER |
1423 DEBUG << "TimeValueLayer::editStart(" << e->x() << "," << e->y() << ")" << endl; | 1423 SVDEBUG << "TimeValueLayer::editStart(" << e->x() << "," << e->y() << ")" << endl; |
1424 #endif | 1424 #endif |
1425 | 1425 |
1426 if (!m_model) return; | 1426 if (!m_model) return; |
1427 | 1427 |
1428 SparseTimeValueModel::PointList points = getLocalPoints(v, e->x()); | 1428 SparseTimeValueModel::PointList points = getLocalPoints(v, e->x()); |
1441 | 1441 |
1442 void | 1442 void |
1443 TimeValueLayer::editDrag(View *v, QMouseEvent *e) | 1443 TimeValueLayer::editDrag(View *v, QMouseEvent *e) |
1444 { | 1444 { |
1445 #ifdef DEBUG_TIME_VALUE_LAYER | 1445 #ifdef DEBUG_TIME_VALUE_LAYER |
1446 DEBUG << "TimeValueLayer::editDrag(" << e->x() << "," << e->y() << ")" << endl; | 1446 SVDEBUG << "TimeValueLayer::editDrag(" << e->x() << "," << e->y() << ")" << endl; |
1447 #endif | 1447 #endif |
1448 | 1448 |
1449 if (!m_model || !m_editing) return; | 1449 if (!m_model || !m_editing) return; |
1450 | 1450 |
1451 long frame = v->getFrameForX(e->x()); | 1451 long frame = v->getFrameForX(e->x()); |
1467 | 1467 |
1468 void | 1468 void |
1469 TimeValueLayer::editEnd(View *, QMouseEvent *) | 1469 TimeValueLayer::editEnd(View *, QMouseEvent *) |
1470 { | 1470 { |
1471 #ifdef DEBUG_TIME_VALUE_LAYER | 1471 #ifdef DEBUG_TIME_VALUE_LAYER |
1472 DEBUG << "TimeValueLayer::editEnd" << endl; | 1472 SVDEBUG << "TimeValueLayer::editEnd" << endl; |
1473 #endif | 1473 #endif |
1474 if (!m_model || !m_editing) return; | 1474 if (!m_model || !m_editing) return; |
1475 | 1475 |
1476 if (m_editingCommand) { | 1476 if (m_editingCommand) { |
1477 | 1477 |
1807 | 1807 |
1808 if (i->haveValue()) { | 1808 if (i->haveValue()) { |
1809 newPoint.value = i->getValue(); | 1809 newPoint.value = i->getValue(); |
1810 } else { | 1810 } else { |
1811 #ifdef DEBUG_TIME_VALUE_LAYER | 1811 #ifdef DEBUG_TIME_VALUE_LAYER |
1812 DEBUG << "Setting value on point at " << newPoint.frame << " from labeller"; | 1812 SVDEBUG << "Setting value on point at " << newPoint.frame << " from labeller"; |
1813 if (i == points.begin()) { | 1813 if (i == points.begin()) { |
1814 DEBUG << ", no prev point" << endl; | 1814 SVDEBUG << ", no prev point" << endl; |
1815 } else { | 1815 } else { |
1816 std::cerr << ", prev point is at " << prevPoint.frame << std::endl; | 1816 std::cerr << ", prev point is at " << prevPoint.frame << std::endl; |
1817 } | 1817 } |
1818 #endif | 1818 #endif |
1819 labeller.setValue<SparseTimeValueModel::Point> | 1819 labeller.setValue<SparseTimeValueModel::Point> |