Mercurial > hg > svgui
changeset 22:179bf7b5ddea
* Update some copyright notice dates
* Add commands for basic editing operations in time-instants and time-value layers
author | Chris Cannam |
---|---|
date | Tue, 31 Jan 2006 15:57:25 +0000 |
parents | 3a506d25d95a |
children | ca57f70b0e48 |
files | layer/TimeInstantLayer.cpp layer/TimeInstantLayer.h layer/TimeValueLayer.cpp layer/TimeValueLayer.h |
diffstat | 4 files changed, 56 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/layer/TimeInstantLayer.cpp Mon Jan 30 17:51:56 2006 +0000 +++ b/layer/TimeInstantLayer.cpp Tue Jan 31 15:57:25 2006 +0000 @@ -26,6 +26,7 @@ m_model(0), m_editing(false), m_editingPoint(0, tr("New Point")), + m_editingCommand(0), m_colour(QColor(200, 50, 255)) { m_view->addLayer(this); @@ -349,8 +350,14 @@ long frame = getFrameForX(e->x()); if (frame < 0) frame = 0; frame = frame / m_model->getResolution() * m_model->getResolution(); + m_editingPoint = SparseOneDimensionalModel::Point(frame, tr("New Point")); - m_model->addPoint(m_editingPoint); + + if (m_editingCommand) m_editingCommand->finish(); + m_editingCommand = new SparseOneDimensionalModel::EditCommand(m_model, + tr("Draw Point")); + m_editingCommand->addPoint(m_editingPoint); + m_editing = true; } @@ -364,9 +371,9 @@ long frame = getFrameForX(e->x()); if (frame < 0) frame = 0; frame = frame / m_model->getResolution() * m_model->getResolution(); - m_model->deletePoint(m_editingPoint); + m_editingCommand->deletePoint(m_editingPoint); m_editingPoint.frame = frame; - m_model->addPoint(m_editingPoint); + m_editingCommand->addPoint(m_editingPoint); } void @@ -374,6 +381,8 @@ { std::cerr << "TimeInstantLayer::drawEnd(" << e->x() << ")" << std::endl; if (!m_model || !m_editing) return; + m_editingCommand->finish(); + m_editingCommand = 0; m_editing = false; } @@ -388,6 +397,12 @@ if (points.empty()) return; m_editingPoint = *points.begin(); + + if (m_editingCommand) { + m_editingCommand->finish(); + m_editingCommand = 0; + } + m_editing = true; } @@ -401,9 +416,15 @@ long frame = getFrameForX(e->x()); if (frame < 0) frame = 0; frame = frame / m_model->getResolution() * m_model->getResolution(); - m_model->deletePoint(m_editingPoint); + + if (!m_editingCommand) { + m_editingCommand = new SparseOneDimensionalModel::EditCommand(m_model, + tr("Drag Point")); + } + + m_editingCommand->deletePoint(m_editingPoint); m_editingPoint.frame = frame; - m_model->addPoint(m_editingPoint); + m_editingCommand->addPoint(m_editingPoint); } void @@ -411,6 +432,8 @@ { std::cerr << "TimeInstantLayer::editEnd(" << e->x() << ")" << std::endl; if (!m_model || !m_editing) return; + if (m_editingCommand) m_editingCommand->finish(); + m_editingCommand = 0; m_editing = false; }
--- a/layer/TimeInstantLayer.h Mon Jan 30 17:51:56 2006 +0000 +++ b/layer/TimeInstantLayer.h Tue Jan 31 15:57:25 2006 +0000 @@ -72,6 +72,7 @@ SparseOneDimensionalModel *m_model; bool m_editing; SparseOneDimensionalModel::Point m_editingPoint; + SparseOneDimensionalModel::EditCommand *m_editingCommand; QColor m_colour; };
--- a/layer/TimeValueLayer.cpp Mon Jan 30 17:51:56 2006 +0000 +++ b/layer/TimeValueLayer.cpp Tue Jan 31 15:57:25 2006 +0000 @@ -28,6 +28,7 @@ m_model(0), m_editing(false), m_editingPoint(0, 0.0, tr("New Point")), + m_editingCommand(0), m_colour(Qt::black), m_plotStyle(PlotConnectedPoints) { @@ -496,7 +497,12 @@ float value = getValueForY(e->y()); m_editingPoint = SparseTimeValueModel::Point(frame, value, tr("New Point")); - m_model->addPoint(m_editingPoint); + + if (m_editingCommand) m_editingCommand->finish(); + m_editingCommand = new SparseTimeValueModel::EditCommand(m_model, + tr("Draw Point")); + m_editingCommand->addPoint(m_editingPoint); + m_editing = true; } @@ -513,10 +519,10 @@ float value = getValueForY(e->y()); - m_model->deletePoint(m_editingPoint); + m_editingCommand->deletePoint(m_editingPoint); m_editingPoint.frame = frame; m_editingPoint.value = value; - m_model->addPoint(m_editingPoint); + m_editingCommand->addPoint(m_editingPoint); } void @@ -524,6 +530,8 @@ { std::cerr << "TimeValueLayer::drawEnd(" << e->x() << "," << e->y() << ")" << std::endl; if (!m_model || !m_editing) return; + m_editingCommand->finish(); + m_editingCommand = 0; m_editing = false; } @@ -538,6 +546,12 @@ if (points.empty()) return; m_editingPoint = *points.begin(); + + if (m_editingCommand) { + m_editingCommand->finish(); + m_editingCommand = 0; + } + m_editing = true; } @@ -554,10 +568,15 @@ float value = getValueForY(e->y()); - m_model->deletePoint(m_editingPoint); + if (!m_editingCommand) { + m_editingCommand = new SparseTimeValueModel::EditCommand(m_model, + tr("Drag Point")); + } + + m_editingCommand->deletePoint(m_editingPoint); m_editingPoint.frame = frame; m_editingPoint.value = value; - m_model->addPoint(m_editingPoint); + m_editingCommand->addPoint(m_editingPoint); } void @@ -565,6 +584,8 @@ { std::cerr << "TimeValueLayer::editEnd(" << e->x() << "," << e->y() << ")" << std::endl; if (!m_model || !m_editing) return; + if (m_editingCommand) m_editingCommand->finish(); + m_editingCommand = 0; m_editing = false; }
--- a/layer/TimeValueLayer.h Mon Jan 30 17:51:56 2006 +0000 +++ b/layer/TimeValueLayer.h Tue Jan 31 15:57:25 2006 +0000 @@ -80,6 +80,7 @@ SparseTimeValueModel *m_model; bool m_editing; SparseTimeValueModel::Point m_editingPoint; + SparseTimeValueModel::EditCommand *m_editingCommand; QColor m_colour; PlotStyle m_plotStyle; };