Mercurial > hg > svgui
comparison layer/TimeInstantLayer.cpp @ 23:ca57f70b0e48
* Add Zero Crossings output from zc plugin (as well as Zero Crossings Count)
* Use brief friendly names for layers instead of full transform descriptions
* Clearer command names for editing commands
* Some efficiencies in drawing dense points in TimeInstantLayer
author | Chris Cannam |
---|---|
date | Tue, 31 Jan 2006 17:19:45 +0000 |
parents | 179bf7b5ddea |
children | dcdb21b62dbb |
comparison
equal
deleted
inserted
replaced
22:179bf7b5ddea | 23:ca57f70b0e48 |
---|---|
288 SparseOneDimensionalModel::PointList localPoints = | 288 SparseOneDimensionalModel::PointList localPoints = |
289 getLocalPoints(localPos.x()); | 289 getLocalPoints(localPos.x()); |
290 if (!localPoints.empty()) illuminateFrame = localPoints.begin()->frame; | 290 if (!localPoints.empty()) illuminateFrame = localPoints.begin()->frame; |
291 } | 291 } |
292 | 292 |
293 int prevX = -1; | |
294 | |
293 for (SparseOneDimensionalModel::PointList::const_iterator i = points.begin(); | 295 for (SparseOneDimensionalModel::PointList::const_iterator i = points.begin(); |
294 i != points.end(); ++i) { | 296 i != points.end(); ++i) { |
295 | 297 |
296 const SparseOneDimensionalModel::Point &p(*i); | 298 const SparseOneDimensionalModel::Point &p(*i); |
297 SparseOneDimensionalModel::PointList::const_iterator j = i; | 299 SparseOneDimensionalModel::PointList::const_iterator j = i; |
298 ++j; | 300 ++j; |
299 | 301 |
300 int x = getXForFrame(p.frame); | 302 int x = getXForFrame(p.frame); |
303 if (x == prevX && p.frame != illuminateFrame) continue; | |
304 | |
301 int iw = getXForFrame(p.frame + m_model->getResolution()) - x; | 305 int iw = getXForFrame(p.frame + m_model->getResolution()) - x; |
302 if (iw < 2) { | 306 if (iw < 2) { |
303 if (iw < 1) { | 307 if (iw < 1) { |
304 iw = 2; | 308 iw = 2; |
305 if (j != points.end()) { | 309 if (j != points.end()) { |
314 if (p.frame == illuminateFrame) { | 318 if (p.frame == illuminateFrame) { |
315 paint.setPen(Qt::black); //!!! | 319 paint.setPen(Qt::black); //!!! |
316 } else { | 320 } else { |
317 paint.setPen(brushColour); | 321 paint.setPen(brushColour); |
318 } | 322 } |
319 paint.drawRect(x, 0, iw - 1, m_view->height() - 1); | 323 |
324 if (iw > 1) { | |
325 paint.drawRect(x, 0, iw - 1, m_view->height() - 1); | |
326 } else { | |
327 paint.drawLine(x, 0, x, m_view->height() - 1); | |
328 } | |
320 paint.setPen(m_colour); | 329 paint.setPen(m_colour); |
321 | 330 |
322 if (p.label != "") { | 331 if (p.label != "") { |
323 | 332 |
324 // only draw if there's enough room from here to the next point | 333 // only draw if there's enough room from here to the next point |
335 paint.drawText(x + iw + 2, | 344 paint.drawText(x + iw + 2, |
336 m_view->height() - paint.fontMetrics().height(), | 345 m_view->height() - paint.fontMetrics().height(), |
337 p.label); | 346 p.label); |
338 } | 347 } |
339 } | 348 } |
349 | |
350 prevX = x; | |
340 } | 351 } |
341 } | 352 } |
342 | 353 |
343 void | 354 void |
344 TimeInstantLayer::drawStart(QMouseEvent *e) | 355 TimeInstantLayer::drawStart(QMouseEvent *e) |
379 void | 390 void |
380 TimeInstantLayer::drawEnd(QMouseEvent *e) | 391 TimeInstantLayer::drawEnd(QMouseEvent *e) |
381 { | 392 { |
382 std::cerr << "TimeInstantLayer::drawEnd(" << e->x() << ")" << std::endl; | 393 std::cerr << "TimeInstantLayer::drawEnd(" << e->x() << ")" << std::endl; |
383 if (!m_model || !m_editing) return; | 394 if (!m_model || !m_editing) return; |
395 QString newName = tr("Add Point at %1 s") | |
396 .arg(RealTime::frame2RealTime(m_editingPoint.frame, | |
397 m_model->getSampleRate()) | |
398 .toText(false).c_str()); | |
399 m_editingCommand->setName(newName); | |
384 m_editingCommand->finish(); | 400 m_editingCommand->finish(); |
385 m_editingCommand = 0; | 401 m_editingCommand = 0; |
386 m_editing = false; | 402 m_editing = false; |
387 } | 403 } |
388 | 404 |
430 void | 446 void |
431 TimeInstantLayer::editEnd(QMouseEvent *e) | 447 TimeInstantLayer::editEnd(QMouseEvent *e) |
432 { | 448 { |
433 std::cerr << "TimeInstantLayer::editEnd(" << e->x() << ")" << std::endl; | 449 std::cerr << "TimeInstantLayer::editEnd(" << e->x() << ")" << std::endl; |
434 if (!m_model || !m_editing) return; | 450 if (!m_model || !m_editing) return; |
435 if (m_editingCommand) m_editingCommand->finish(); | 451 if (m_editingCommand) { |
452 QString newName = tr("Move Point to %1 s") | |
453 .arg(RealTime::frame2RealTime(m_editingPoint.frame, | |
454 m_model->getSampleRate()) | |
455 .toText(false).c_str()); | |
456 m_editingCommand->setName(newName); | |
457 m_editingCommand->finish(); | |
458 } | |
436 m_editingCommand = 0; | 459 m_editingCommand = 0; |
437 m_editing = false; | 460 m_editing = false; |
438 } | 461 } |
439 | 462 |
440 QString | 463 QString |