# HG changeset patch # User Chris Cannam # Date 1138727985 0 # Node ID ca57f70b0e487ff3848b12ab50d7d8d51612e715 # Parent 179bf7b5ddea093d06eb17d864e46045001db978 * 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 diff -r 179bf7b5ddea -r ca57f70b0e48 layer/TimeInstantLayer.cpp --- a/layer/TimeInstantLayer.cpp Tue Jan 31 15:57:25 2006 +0000 +++ b/layer/TimeInstantLayer.cpp Tue Jan 31 17:19:45 2006 +0000 @@ -290,6 +290,8 @@ if (!localPoints.empty()) illuminateFrame = localPoints.begin()->frame; } + int prevX = -1; + for (SparseOneDimensionalModel::PointList::const_iterator i = points.begin(); i != points.end(); ++i) { @@ -298,6 +300,8 @@ ++j; int x = getXForFrame(p.frame); + if (x == prevX && p.frame != illuminateFrame) continue; + int iw = getXForFrame(p.frame + m_model->getResolution()) - x; if (iw < 2) { if (iw < 1) { @@ -316,7 +320,12 @@ } else { paint.setPen(brushColour); } - paint.drawRect(x, 0, iw - 1, m_view->height() - 1); + + if (iw > 1) { + paint.drawRect(x, 0, iw - 1, m_view->height() - 1); + } else { + paint.drawLine(x, 0, x, m_view->height() - 1); + } paint.setPen(m_colour); if (p.label != "") { @@ -337,6 +346,8 @@ p.label); } } + + prevX = x; } } @@ -381,6 +392,11 @@ { std::cerr << "TimeInstantLayer::drawEnd(" << e->x() << ")" << std::endl; if (!m_model || !m_editing) return; + QString newName = tr("Add Point at %1 s") + .arg(RealTime::frame2RealTime(m_editingPoint.frame, + m_model->getSampleRate()) + .toText(false).c_str()); + m_editingCommand->setName(newName); m_editingCommand->finish(); m_editingCommand = 0; m_editing = false; @@ -432,7 +448,14 @@ { std::cerr << "TimeInstantLayer::editEnd(" << e->x() << ")" << std::endl; if (!m_model || !m_editing) return; - if (m_editingCommand) m_editingCommand->finish(); + if (m_editingCommand) { + QString newName = tr("Move Point to %1 s") + .arg(RealTime::frame2RealTime(m_editingPoint.frame, + m_model->getSampleRate()) + .toText(false).c_str()); + m_editingCommand->setName(newName); + m_editingCommand->finish(); + } m_editingCommand = 0; m_editing = false; } diff -r 179bf7b5ddea -r ca57f70b0e48 layer/TimeInstantLayer.h --- a/layer/TimeInstantLayer.h Tue Jan 31 15:57:25 2006 +0000 +++ b/layer/TimeInstantLayer.h Tue Jan 31 17:19:45 2006 +0000 @@ -59,6 +59,8 @@ virtual bool isLayerScrollable() const; + virtual bool isLayerEditable() const { return true; } + virtual int getCompletion() const { return m_model->getCompletion(); } virtual QString toXmlString(QString indent = "", diff -r 179bf7b5ddea -r ca57f70b0e48 layer/TimeValueLayer.cpp --- a/layer/TimeValueLayer.cpp Tue Jan 31 15:57:25 2006 +0000 +++ b/layer/TimeValueLayer.cpp Tue Jan 31 17:19:45 2006 +0000 @@ -27,6 +27,7 @@ Layer(w), m_model(0), m_editing(false), + m_originalPoint(0, 0.0, tr("New Point")), m_editingPoint(0, 0.0, tr("New Point")), m_editingCommand(0), m_colour(Qt::black), @@ -497,6 +498,7 @@ float value = getValueForY(e->y()); m_editingPoint = SparseTimeValueModel::Point(frame, value, tr("New Point")); + m_originalPoint = m_editingPoint; if (m_editingCommand) m_editingCommand->finish(); m_editingCommand = new SparseTimeValueModel::EditCommand(m_model, @@ -546,6 +548,7 @@ if (points.empty()) return; m_editingPoint = *points.begin(); + m_originalPoint = m_editingPoint; if (m_editingCommand) { m_editingCommand->finish(); @@ -584,7 +587,25 @@ { std::cerr << "TimeValueLayer::editEnd(" << e->x() << "," << e->y() << ")" << std::endl; if (!m_model || !m_editing) return; - if (m_editingCommand) m_editingCommand->finish(); + + if (m_editingCommand) { + + QString newName = m_editingCommand->getName(); + + if (m_editingPoint.frame != m_originalPoint.frame) { + if (m_editingPoint.value != m_originalPoint.value) { + newName = tr("Edit Point"); + } else { + newName = tr("Relocate Point"); + } + } else { + newName = tr("Change Point Value"); + } + + m_editingCommand->setName(newName); + m_editingCommand->finish(); + } + m_editingCommand = 0; m_editing = false; } diff -r 179bf7b5ddea -r ca57f70b0e48 layer/TimeValueLayer.h --- a/layer/TimeValueLayer.h Tue Jan 31 15:57:25 2006 +0000 +++ b/layer/TimeValueLayer.h Tue Jan 31 17:19:45 2006 +0000 @@ -64,6 +64,8 @@ virtual bool isLayerScrollable() const; + virtual bool isLayerEditable() const { return true; } + virtual int getCompletion() const { return m_model->getCompletion(); } virtual QString toXmlString(QString indent = "", @@ -79,6 +81,7 @@ SparseTimeValueModel *m_model; bool m_editing; + SparseTimeValueModel::Point m_originalPoint; SparseTimeValueModel::Point m_editingPoint; SparseTimeValueModel::EditCommand *m_editingCommand; QColor m_colour; diff -r 179bf7b5ddea -r ca57f70b0e48 widgets/Pane.cpp --- a/widgets/Pane.cpp Tue Jan 31 15:57:25 2006 +0000 +++ b/widgets/Pane.cpp Tue Jan 31 17:19:45 2006 +0000 @@ -341,14 +341,14 @@ } else if (mode == ViewManager::DrawMode) { Layer *layer = getSelectedLayer(); - if (layer) { + if (layer && layer->isLayerEditable()) { layer->drawStart(e); } } else if (mode == ViewManager::EditMode) { Layer *layer = getSelectedLayer(); - if (layer) { + if (layer && layer->isLayerEditable()) { layer->editStart(e); } } @@ -430,7 +430,7 @@ } else if (mode == ViewManager::DrawMode) { Layer *layer = getSelectedLayer(); - if (layer) { + if (layer && layer->isLayerEditable()) { layer->drawEnd(e); update(); } @@ -438,7 +438,7 @@ } else if (mode == ViewManager::EditMode) { Layer *layer = getSelectedLayer(); - if (layer) { + if (layer && layer->isLayerEditable()) { layer->editEnd(e); update(); } @@ -577,14 +577,14 @@ } else if (mode == ViewManager::DrawMode) { Layer *layer = getSelectedLayer(); - if (layer) { + if (layer && layer->isLayerEditable()) { layer->drawDrag(e); } } else if (mode == ViewManager::EditMode) { Layer *layer = getSelectedLayer(); - if (layer) { + if (layer && layer->isLayerEditable()) { layer->editDrag(e); } }