Mercurial > hg > svgui
comparison layer/ImageLayer.cpp @ 360:d58701996fae
* Update remaining editable layers to support proper realignment on copy/paste
* Permit pasting when no suitable layer is current: create a new layer on paste
* Add preference for showing the splash screen or not
* Rename spectrogram smoothing prefs (partly following Craig's suggestions)
author | Chris Cannam |
---|---|
date | Wed, 06 Feb 2008 14:15:09 +0000 |
parents | 020c485aa7e0 |
children | e1a9e478b7f2 |
comparison
equal
deleted
inserted
replaced
359:020c485aa7e0 | 360:d58701996fae |
---|---|
28 #include <QPainter> | 28 #include <QPainter> |
29 #include <QMouseEvent> | 29 #include <QMouseEvent> |
30 #include <QInputDialog> | 30 #include <QInputDialog> |
31 #include <QMutexLocker> | 31 #include <QMutexLocker> |
32 #include <QTextStream> | 32 #include <QTextStream> |
33 #include <QMessageBox> | |
33 | 34 |
34 #include <iostream> | 35 #include <iostream> |
35 #include <cmath> | 36 #include <cmath> |
36 | 37 |
37 ImageLayer::ImageMap | 38 ImageLayer::ImageMap |
810 m_model->getPoints(s.getStartFrame(), s.getEndFrame()); | 811 m_model->getPoints(s.getStartFrame(), s.getEndFrame()); |
811 | 812 |
812 for (ImageModel::PointList::iterator i = points.begin(); | 813 for (ImageModel::PointList::iterator i = points.begin(); |
813 i != points.end(); ++i) { | 814 i != points.end(); ++i) { |
814 if (s.contains(i->frame)) { | 815 if (s.contains(i->frame)) { |
815 //!!! inadequate | |
816 Clipboard::Point point(i->frame, i->label); | 816 Clipboard::Point point(i->frame, i->label); |
817 point.setReferenceFrame(m_model->alignToReference(i->frame)); | 817 point.setReferenceFrame(alignToReference(v, i->frame)); |
818 to.addPoint(point); | 818 to.addPoint(point); |
819 } | 819 } |
820 } | 820 } |
821 } | 821 } |
822 | 822 |
824 ImageLayer::paste(View *v, const Clipboard &from, int frameOffset, bool /* interactive */) | 824 ImageLayer::paste(View *v, const Clipboard &from, int frameOffset, bool /* interactive */) |
825 { | 825 { |
826 if (!m_model) return false; | 826 if (!m_model) return false; |
827 | 827 |
828 const Clipboard::PointList &points = from.getPoints(); | 828 const Clipboard::PointList &points = from.getPoints(); |
829 | |
830 bool realign = false; | |
831 | |
832 if (clipboardHasDifferentAlignment(v, from)) { | |
833 | |
834 QMessageBox::StandardButton button = | |
835 QMessageBox::question(v, tr("Re-align pasted items?"), | |
836 tr("The items you are pasting came from a layer with different source material from this one. Do you want to re-align them in time, to match the source material for this layer?"), | |
837 QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel, | |
838 QMessageBox::Yes); | |
839 | |
840 if (button == QMessageBox::Cancel) { | |
841 return false; | |
842 } | |
843 | |
844 if (button == QMessageBox::Yes) { | |
845 realign = true; | |
846 } | |
847 } | |
829 | 848 |
830 ImageModel::EditCommand *command = | 849 ImageModel::EditCommand *command = |
831 new ImageModel::EditCommand(m_model, tr("Paste")); | 850 new ImageModel::EditCommand(m_model, tr("Paste")); |
832 | 851 |
833 for (Clipboard::PointList::const_iterator i = points.begin(); | 852 for (Clipboard::PointList::const_iterator i = points.begin(); |
834 i != points.end(); ++i) { | 853 i != points.end(); ++i) { |
835 | 854 |
836 if (!i->haveFrame()) continue; | 855 if (!i->haveFrame()) continue; |
856 | |
837 size_t frame = 0; | 857 size_t frame = 0; |
838 if (frameOffset > 0 || -frameOffset < i->getFrame()) { | 858 |
839 frame = i->getFrame() + frameOffset; | 859 if (!realign) { |
840 } | 860 |
861 frame = i->getFrame(); | |
862 | |
863 } else { | |
864 | |
865 if (i->haveReferenceFrame()) { | |
866 frame = i->getReferenceFrame(); | |
867 frame = alignFromReference(v, frame); | |
868 } else { | |
869 frame = i->getFrame(); | |
870 } | |
871 } | |
872 | |
841 ImageModel::Point newPoint(frame); | 873 ImageModel::Point newPoint(frame); |
842 | 874 |
843 //!!! inadequate | 875 //!!! inadequate |
844 | 876 |
845 if (i->haveLabel()) { | 877 if (i->haveLabel()) { |