Mercurial > hg > svgui
comparison layer/TextLayer.cpp @ 125:999ae0f7d10c
* Change preferences dialog to ok/apply/cancel model
* Make preferences persist in a config file
* Change instance() to getInstance() for all singleton types
* Make pasting to time-value layer with no values in clipboard ask you how to
generate the values
* Fix bad behaviour caused by importing "data"-type (i.e. 3d dense) model from
annotation file without a fixed window size available
author | Chris Cannam |
---|---|
date | Thu, 27 Jul 2006 16:06:32 +0000 |
parents | 0f36cdf407a6 |
children | 33929e0c3c6b |
comparison
equal
deleted
inserted
replaced
124:bd6e85b3d88b | 125:999ae0f7d10c |
---|---|
703 to.addPoint(point); | 703 to.addPoint(point); |
704 } | 704 } |
705 } | 705 } |
706 } | 706 } |
707 | 707 |
708 void | 708 bool |
709 TextLayer::paste(const Clipboard &from, int frameOffset) | 709 TextLayer::paste(const Clipboard &from, int frameOffset, bool interactive) |
710 { | 710 { |
711 if (!m_model) return; | 711 if (!m_model) return false; |
712 | 712 |
713 const Clipboard::PointList &points = from.getPoints(); | 713 const Clipboard::PointList &points = from.getPoints(); |
714 | 714 |
715 TextModel::EditCommand *command = | 715 TextModel::EditCommand *command = |
716 new TextModel::EditCommand(m_model, tr("Paste")); | 716 new TextModel::EditCommand(m_model, tr("Paste")); |
717 | |
718 float valueMin = 0.0, valueMax = 1.0; | |
719 for (Clipboard::PointList::const_iterator i = points.begin(); | |
720 i != points.end(); ++i) { | |
721 if (i->haveValue()) { | |
722 if (i->getValue() < valueMin) valueMin = i->getValue(); | |
723 if (i->getValue() > valueMax) valueMax = i->getValue(); | |
724 } | |
725 } | |
726 if (valueMax < valueMin + 1.0) valueMax = valueMin + 1.0; | |
717 | 727 |
718 for (Clipboard::PointList::const_iterator i = points.begin(); | 728 for (Clipboard::PointList::const_iterator i = points.begin(); |
719 i != points.end(); ++i) { | 729 i != points.end(); ++i) { |
720 | 730 |
721 if (!i->haveFrame()) continue; | 731 if (!i->haveFrame()) continue; |
722 size_t frame = 0; | 732 size_t frame = 0; |
723 if (frameOffset > 0 || -frameOffset < i->getFrame()) { | 733 if (frameOffset > 0 || -frameOffset < i->getFrame()) { |
724 frame = i->getFrame() + frameOffset; | 734 frame = i->getFrame() + frameOffset; |
725 } | 735 } |
726 TextModel::Point newPoint(frame); | 736 TextModel::Point newPoint(frame); |
727 if (i->haveValue()) newPoint.height = i->haveValue(); | 737 |
728 if (i->haveLabel()) newPoint.label = i->getLabel(); | 738 if (i->haveValue()) { |
729 else newPoint.label = tr("New Point"); | 739 newPoint.height = (i->getValue() - valueMin) / (valueMax - valueMin); |
740 } else { | |
741 newPoint.height = 0.5; | |
742 } | |
743 | |
744 if (i->haveLabel()) { | |
745 newPoint.label = i->getLabel(); | |
746 } else if (i->haveValue()) { | |
747 newPoint.label = QString("%1").arg(i->getValue()); | |
748 } else { | |
749 newPoint.label = tr("New Point"); | |
750 } | |
730 | 751 |
731 command->addPoint(newPoint); | 752 command->addPoint(newPoint); |
732 } | 753 } |
733 | 754 |
734 command->finish(); | 755 command->finish(); |
756 return true; | |
735 } | 757 } |
736 | 758 |
737 QString | 759 QString |
738 TextLayer::toXmlString(QString indent, QString extraAttributes) const | 760 TextLayer::toXmlString(QString indent, QString extraAttributes) const |
739 { | 761 { |