Mercurial > hg > svgui
comparison layer/TimeValueLayer.cpp @ 1266:a34a2a25907c
Untabify
author | Chris Cannam |
---|---|
date | Thu, 01 Mar 2018 18:02:22 +0000 |
parents | 491dd600570c |
children | 1d7921b1852f |
comparison
equal
deleted
inserted
replaced
1265:6e724c81f18f | 1266:a34a2a25907c |
---|---|
158 else return ""; | 158 else return ""; |
159 } | 159 } |
160 | 160 |
161 int | 161 int |
162 TimeValueLayer::getPropertyRangeAndValue(const PropertyName &name, | 162 TimeValueLayer::getPropertyRangeAndValue(const PropertyName &name, |
163 int *min, int *max, int *deflt) const | 163 int *min, int *max, int *deflt) const |
164 { | 164 { |
165 int val = 0; | 165 int val = 0; |
166 | 166 |
167 if (name == "Colour" && m_plotStyle == PlotSegmentation) { | 167 if (name == "Colour" && m_plotStyle == PlotSegmentation) { |
168 | 168 |
171 if (deflt) *deflt = 0; | 171 if (deflt) *deflt = 0; |
172 | 172 |
173 val = m_colourMap; | 173 val = m_colourMap; |
174 | 174 |
175 } else if (name == "Plot Type") { | 175 } else if (name == "Plot Type") { |
176 | 176 |
177 if (min) *min = 0; | 177 if (min) *min = 0; |
178 if (max) *max = 6; | 178 if (max) *max = 6; |
179 if (deflt) *deflt = int(PlotConnectedPoints); | 179 if (deflt) *deflt = int(PlotConnectedPoints); |
180 | 180 |
181 val = int(m_plotStyle); | 181 val = int(m_plotStyle); |
182 | 182 |
183 } else if (name == "Vertical Scale") { | 183 } else if (name == "Vertical Scale") { |
184 | 184 |
185 if (min) *min = 0; | 185 if (min) *min = 0; |
186 if (max) *max = 3; | 186 if (max) *max = 3; |
187 if (deflt) *deflt = int(AutoAlignScale); | 187 if (deflt) *deflt = int(AutoAlignScale); |
188 | 188 |
189 val = int(m_verticalScale); | 189 val = int(m_verticalScale); |
190 | 190 |
191 } else if (name == "Scale Units") { | 191 } else if (name == "Scale Units") { |
192 | 192 |
193 if (deflt) *deflt = 0; | 193 if (deflt) *deflt = 0; |
194 if (m_model) { | 194 if (m_model) { |
209 if (max) *max = 0; | 209 if (max) *max = 0; |
210 if (deflt) *deflt = 0; | 210 if (deflt) *deflt = 0; |
211 val = (m_derivative ? 1.0 : 0.0); | 211 val = (m_derivative ? 1.0 : 0.0); |
212 | 212 |
213 } else { | 213 } else { |
214 | 214 |
215 val = SingleColourLayer::getPropertyRangeAndValue(name, min, max, deflt); | 215 val = SingleColourLayer::getPropertyRangeAndValue(name, min, max, deflt); |
216 } | 216 } |
217 | 217 |
218 return val; | 218 return val; |
219 } | 219 } |
220 | 220 |
221 QString | 221 QString |
222 TimeValueLayer::getPropertyValueLabel(const PropertyName &name, | 222 TimeValueLayer::getPropertyValueLabel(const PropertyName &name, |
223 int value) const | 223 int value) const |
224 { | 224 { |
225 if (name == "Colour" && m_plotStyle == PlotSegmentation) { | 225 if (name == "Colour" && m_plotStyle == PlotSegmentation) { |
226 return ColourMapper::getColourMapName(value); | 226 return ColourMapper::getColourMapName(value); |
227 } else if (name == "Plot Type") { | 227 } else if (name == "Plot Type") { |
228 switch (value) { | 228 switch (value) { |
229 default: | 229 default: |
230 case 0: return tr("Points"); | 230 case 0: return tr("Points"); |
231 case 1: return tr("Stems"); | 231 case 1: return tr("Stems"); |
232 case 2: return tr("Connected Points"); | 232 case 2: return tr("Connected Points"); |
233 case 3: return tr("Lines"); | 233 case 3: return tr("Lines"); |
234 case 4: return tr("Curve"); | 234 case 4: return tr("Curve"); |
235 case 5: return tr("Segmentation"); | 235 case 5: return tr("Segmentation"); |
236 case 6: return tr("Discrete Curves"); | 236 case 6: return tr("Discrete Curves"); |
237 } | 237 } |
238 } else if (name == "Vertical Scale") { | 238 } else if (name == "Vertical Scale") { |
239 switch (value) { | 239 switch (value) { |
240 default: | 240 default: |
241 case 0: return tr("Auto-Align"); | 241 case 0: return tr("Auto-Align"); |
242 case 1: return tr("Linear"); | 242 case 1: return tr("Linear"); |
243 case 2: return tr("Log"); | 243 case 2: return tr("Log"); |
244 case 3: return tr("+/-1"); | 244 case 3: return tr("+/-1"); |
245 } | 245 } |
246 } | 246 } |
247 return SingleColourLayer::getPropertyValueLabel(name, value); | 247 return SingleColourLayer::getPropertyValueLabel(name, value); |
248 } | 248 } |
249 | 249 |
250 void | 250 void |
251 TimeValueLayer::setProperty(const PropertyName &name, int value) | 251 TimeValueLayer::setProperty(const PropertyName &name, int value) |
252 { | 252 { |
253 if (name == "Colour" && m_plotStyle == PlotSegmentation) { | 253 if (name == "Colour" && m_plotStyle == PlotSegmentation) { |
254 setFillColourMap(value); | 254 setFillColourMap(value); |
255 } else if (name == "Plot Type") { | 255 } else if (name == "Plot Type") { |
256 setPlotStyle(PlotStyle(value)); | 256 setPlotStyle(PlotStyle(value)); |
257 } else if (name == "Vertical Scale") { | 257 } else if (name == "Vertical Scale") { |
258 setVerticalScale(VerticalScale(value)); | 258 setVerticalScale(VerticalScale(value)); |
259 } else if (name == "Scale Units") { | 259 } else if (name == "Scale Units") { |
260 if (m_model) { | 260 if (m_model) { |
261 m_model->setScaleUnits | 261 m_model->setScaleUnits |
262 (UnitDatabase::getInstance()->getUnitById(value)); | 262 (UnitDatabase::getInstance()->getUnitById(value)); |
263 emit modelChanged(); | 263 emit modelChanged(); |
321 { | 321 { |
322 // We don't illuminate sections in the line or curve modes, so | 322 // We don't illuminate sections in the line or curve modes, so |
323 // they're always scrollable | 323 // they're always scrollable |
324 | 324 |
325 if (m_plotStyle == PlotLines || | 325 if (m_plotStyle == PlotLines || |
326 m_plotStyle == PlotCurve || | 326 m_plotStyle == PlotCurve || |
327 m_plotStyle == PlotDiscreteCurves) return true; | 327 m_plotStyle == PlotDiscreteCurves) return true; |
328 | 328 |
329 QPoint discard; | 329 QPoint discard; |
330 return !v->shouldIlluminateLocalFeatures(this, discard); | 330 return !v->shouldIlluminateLocalFeatures(this, discard); |
331 } | 331 } |
536 if (!m_model) return SparseTimeValueModel::PointList(); | 536 if (!m_model) return SparseTimeValueModel::PointList(); |
537 | 537 |
538 sv_frame_t frame = v->getFrameForX(x); | 538 sv_frame_t frame = v->getFrameForX(x); |
539 | 539 |
540 SparseTimeValueModel::PointList onPoints = | 540 SparseTimeValueModel::PointList onPoints = |
541 m_model->getPoints(frame); | 541 m_model->getPoints(frame); |
542 | 542 |
543 if (!onPoints.empty()) { | 543 if (!onPoints.empty()) { |
544 return onPoints; | 544 return onPoints; |
545 } | 545 } |
546 | 546 |
547 SparseTimeValueModel::PointList prevPoints = | 547 SparseTimeValueModel::PointList prevPoints = |
548 m_model->getPreviousPoints(frame); | 548 m_model->getPreviousPoints(frame); |
549 SparseTimeValueModel::PointList nextPoints = | 549 SparseTimeValueModel::PointList nextPoints = |
550 m_model->getNextPoints(frame); | 550 m_model->getNextPoints(frame); |
551 | 551 |
552 SparseTimeValueModel::PointList usePoints = prevPoints; | 552 SparseTimeValueModel::PointList usePoints = prevPoints; |
553 | 553 |
554 if (prevPoints.empty()) { | 554 if (prevPoints.empty()) { |
555 usePoints = nextPoints; | 555 usePoints = nextPoints; |
556 } else if (nextPoints.empty()) { | 556 } else if (nextPoints.empty()) { |
557 // stick with prevPoints | 557 // stick with prevPoints |
558 } else if (prevPoints.begin()->frame < v->getStartFrame() && | 558 } else if (prevPoints.begin()->frame < v->getStartFrame() && |
559 !(nextPoints.begin()->frame > v->getEndFrame())) { | 559 !(nextPoints.begin()->frame > v->getEndFrame())) { |
560 usePoints = nextPoints; | 560 usePoints = nextPoints; |
561 } else if (nextPoints.begin()->frame - frame < | 561 } else if (nextPoints.begin()->frame - frame < |
562 frame - prevPoints.begin()->frame) { | 562 frame - prevPoints.begin()->frame) { |
563 usePoints = nextPoints; | 563 usePoints = nextPoints; |
564 } | 564 } |
565 | 565 |
566 if (!usePoints.empty()) { | 566 if (!usePoints.empty()) { |
567 int fuzz = 2; | 567 int fuzz = 2; |
568 int px = v->getXForFrame(usePoints.begin()->frame); | 568 int px = v->getXForFrame(usePoints.begin()->frame); |
569 if ((px > x && px - x > fuzz) || | 569 if ((px > x && px - x > fuzz) || |
570 (px < x && x - px > fuzz + 3)) { | 570 (px < x && x - px > fuzz + 3)) { |
571 usePoints.clear(); | 571 usePoints.clear(); |
572 } | 572 } |
573 } | 573 } |
574 | 574 |
575 return usePoints; | 575 return usePoints; |
576 } | 576 } |
577 | 577 |
595 if (!m_model || !m_model->getSampleRate()) return ""; | 595 if (!m_model || !m_model->getSampleRate()) return ""; |
596 | 596 |
597 SparseTimeValueModel::PointList points = getLocalPoints(v, x); | 597 SparseTimeValueModel::PointList points = getLocalPoints(v, x); |
598 | 598 |
599 if (points.empty()) { | 599 if (points.empty()) { |
600 if (!m_model->isReady()) { | 600 if (!m_model->isReady()) { |
601 return tr("In progress"); | 601 return tr("In progress"); |
602 } else { | 602 } else { |
603 return tr("No local points"); | 603 return tr("No local points"); |
604 } | 604 } |
605 } | 605 } |
606 | 606 |
607 sv_frame_t useFrame = points.begin()->frame; | 607 sv_frame_t useFrame = points.begin()->frame; |
608 | 608 |
609 RealTime rt = RealTime::frame2RealTime(useFrame, m_model->getSampleRate()); | 609 RealTime rt = RealTime::frame2RealTime(useFrame, m_model->getSampleRate()); |
624 } | 624 } |
625 | 625 |
626 QString text; | 626 QString text; |
627 | 627 |
628 if (points.begin()->label == "") { | 628 if (points.begin()->label == "") { |
629 text = QString(tr("Time:\t%1\nValue:\t%2\nNo label")) | 629 text = QString(tr("Time:\t%1\nValue:\t%2\nNo label")) |
630 .arg(rt.toText(true).c_str()) | 630 .arg(rt.toText(true).c_str()) |
631 .arg(valueText); | 631 .arg(valueText); |
632 } else { | 632 } else { |
633 text = QString(tr("Time:\t%1\nValue:\t%2\nLabel:\t%4")) | 633 text = QString(tr("Time:\t%1\nValue:\t%2\nLabel:\t%4")) |
634 .arg(rt.toText(true).c_str()) | 634 .arg(rt.toText(true).c_str()) |
635 .arg(valueText) | 635 .arg(valueText) |
636 .arg(points.begin()->label); | 636 .arg(points.begin()->label); |
637 } | 637 } |
638 | 638 |
639 pos = QPoint(v->getXForFrame(useFrame), | 639 pos = QPoint(v->getXForFrame(useFrame), |
640 getYForValue(v, points.begin()->value)); | 640 getYForValue(v, points.begin()->value)); |
641 return text; | 641 return text; |
642 } | 642 } |
643 | 643 |
644 bool | 644 bool |
645 TimeValueLayer::snapToFeatureFrame(LayerGeometryProvider *v, sv_frame_t &frame, | 645 TimeValueLayer::snapToFeatureFrame(LayerGeometryProvider *v, sv_frame_t &frame, |
646 int &resolution, | 646 int &resolution, |
647 SnapType snap) const | 647 SnapType snap) const |
648 { | 648 { |
649 if (!m_model) { | 649 if (!m_model) { |
650 return Layer::snapToFeatureFrame(v, frame, resolution, snap); | 650 return Layer::snapToFeatureFrame(v, frame, resolution, snap); |
651 } | 651 } |
652 | 652 |
653 resolution = m_model->getResolution(); | 653 resolution = m_model->getResolution(); |
654 SparseTimeValueModel::PointList points; | 654 SparseTimeValueModel::PointList points; |
655 | 655 |
656 if (snap == SnapNeighbouring) { | 656 if (snap == SnapNeighbouring) { |
657 | 657 |
658 points = getLocalPoints(v, v->getXForFrame(frame)); | 658 points = getLocalPoints(v, v->getXForFrame(frame)); |
659 if (points.empty()) return false; | 659 if (points.empty()) return false; |
660 frame = points.begin()->frame; | 660 frame = points.begin()->frame; |
661 return true; | 661 return true; |
662 } | 662 } |
663 | 663 |
664 points = m_model->getPoints(frame, frame); | 664 points = m_model->getPoints(frame, frame); |
665 sv_frame_t snapped = frame; | 665 sv_frame_t snapped = frame; |
666 bool found = false; | 666 bool found = false; |
667 | 667 |
668 for (SparseTimeValueModel::PointList::const_iterator i = points.begin(); | 668 for (SparseTimeValueModel::PointList::const_iterator i = points.begin(); |
669 i != points.end(); ++i) { | 669 i != points.end(); ++i) { |
670 | 670 |
671 if (snap == SnapRight) { | 671 if (snap == SnapRight) { |
672 | 672 |
673 if (i->frame > frame) { | 673 if (i->frame > frame) { |
674 snapped = i->frame; | 674 snapped = i->frame; |
675 found = true; | 675 found = true; |
676 break; | 676 break; |
677 } | 677 } |
678 | 678 |
679 } else if (snap == SnapLeft) { | 679 } else if (snap == SnapLeft) { |
680 | 680 |
681 if (i->frame <= frame) { | 681 if (i->frame <= frame) { |
682 snapped = i->frame; | 682 snapped = i->frame; |
683 found = true; // don't break, as the next may be better | 683 found = true; // don't break, as the next may be better |
684 } else { | 684 } else { |
685 break; | 685 break; |
686 } | 686 } |
687 | 687 |
688 } else { // nearest | 688 } else { // nearest |
689 | 689 |
690 SparseTimeValueModel::PointList::const_iterator j = i; | 690 SparseTimeValueModel::PointList::const_iterator j = i; |
691 ++j; | 691 ++j; |
692 | 692 |
693 if (j == points.end()) { | 693 if (j == points.end()) { |
694 | 694 |
695 snapped = i->frame; | 695 snapped = i->frame; |
696 found = true; | 696 found = true; |
697 break; | 697 break; |
698 | 698 |
699 } else if (j->frame >= frame) { | 699 } else if (j->frame >= frame) { |
700 | 700 |
701 if (j->frame - frame < frame - i->frame) { | 701 if (j->frame - frame < frame - i->frame) { |
702 snapped = j->frame; | 702 snapped = j->frame; |
703 } else { | 703 } else { |
704 snapped = i->frame; | 704 snapped = i->frame; |
705 } | 705 } |
706 found = true; | 706 found = true; |
707 break; | 707 break; |
708 } | 708 } |
709 } | 709 } |
710 } | 710 } |
711 | 711 |
712 frame = snapped; | 712 frame = snapped; |
713 return found; | 713 return found; |
714 } | 714 } |
717 TimeValueLayer::snapToSimilarFeature(LayerGeometryProvider *v, sv_frame_t &frame, | 717 TimeValueLayer::snapToSimilarFeature(LayerGeometryProvider *v, sv_frame_t &frame, |
718 int &resolution, | 718 int &resolution, |
719 SnapType snap) const | 719 SnapType snap) const |
720 { | 720 { |
721 if (!m_model) { | 721 if (!m_model) { |
722 return Layer::snapToSimilarFeature(v, frame, resolution, snap); | 722 return Layer::snapToSimilarFeature(v, frame, resolution, snap); |
723 } | 723 } |
724 | 724 |
725 resolution = m_model->getResolution(); | 725 resolution = m_model->getResolution(); |
726 | 726 |
727 const SparseTimeValueModel::PointList &points = m_model->getPoints(); | 727 const SparseTimeValueModel::PointList &points = m_model->getPoints(); |
761 i = points.begin(); | 761 i = points.begin(); |
762 distant = true; | 762 distant = true; |
763 } | 763 } |
764 } | 764 } |
765 | 765 |
766 if (snap == SnapRight) { | 766 if (snap == SnapRight) { |
767 | 767 |
768 if (i->frame > matchframe && | 768 if (i->frame > matchframe && |
769 fabs(i->value - matchvalue) < epsilon) { | 769 fabs(i->value - matchvalue) < epsilon) { |
770 snapped = i->frame; | 770 snapped = i->frame; |
771 found = true; | 771 found = true; |
772 break; | 772 break; |
773 } | 773 } |
774 | 774 |
775 } else if (snap == SnapLeft) { | 775 } else if (snap == SnapLeft) { |
776 | 776 |
777 if (i->frame < matchframe) { | 777 if (i->frame < matchframe) { |
778 if (fabs(i->value - matchvalue) < epsilon) { | 778 if (fabs(i->value - matchvalue) < epsilon) { |
779 snapped = i->frame; | 779 snapped = i->frame; |
780 found = true; // don't break, as the next may be better | 780 found = true; // don't break, as the next may be better |
781 } | 781 } |
782 } else if (found || distant) { | 782 } else if (found || distant) { |
783 break; | 783 break; |
784 } | 784 } |
785 | 785 |
786 } else { | 786 } else { |
787 // no other snap types supported | 787 // no other snap types supported |
788 } | 788 } |
789 | 789 |
790 ++i; | 790 ++i; |
791 } | 791 } |
792 | 792 |
793 frame = snapped; | 793 frame = snapped; |
924 sv_frame_t frame0 = v->getFrameForX(x0); | 924 sv_frame_t frame0 = v->getFrameForX(x0); |
925 sv_frame_t frame1 = v->getFrameForX(x1); | 925 sv_frame_t frame1 = v->getFrameForX(x1); |
926 if (m_derivative) --frame0; | 926 if (m_derivative) --frame0; |
927 | 927 |
928 SparseTimeValueModel::PointList points(m_model->getPoints | 928 SparseTimeValueModel::PointList points(m_model->getPoints |
929 (frame0, frame1)); | 929 (frame0, frame1)); |
930 if (points.empty()) return; | 930 if (points.empty()) return; |
931 | 931 |
932 paint.setPen(getBaseQColor()); | 932 paint.setPen(getBaseQColor()); |
933 | 933 |
934 QColor brushColour(getBaseQColor()); | 934 QColor brushColour(getBaseQColor()); |
935 brushColour.setAlpha(80); | 935 brushColour.setAlpha(80); |
936 paint.setBrush(brushColour); | 936 paint.setBrush(brushColour); |
937 | 937 |
938 #ifdef DEBUG_TIME_VALUE_LAYER | 938 #ifdef DEBUG_TIME_VALUE_LAYER |
939 cerr << "TimeValueLayer::paint: resolution is " | 939 cerr << "TimeValueLayer::paint: resolution is " |
940 << m_model->getResolution() << " frames" << endl; | 940 << m_model->getResolution() << " frames" << endl; |
941 #endif | 941 #endif |
942 | 942 |
943 double min = m_model->getValueMinimum(); | 943 double min = m_model->getValueMinimum(); |
944 double max = m_model->getValueMaximum(); | 944 double max = m_model->getValueMaximum(); |
945 if (max == min) max = min + 1.0; | 945 if (max == min) max = min + 1.0; |
946 | 946 |
947 int origin = int(nearbyint(v->getPaintHeight() - | 947 int origin = int(nearbyint(v->getPaintHeight() - |
948 (-min * v->getPaintHeight()) / (max - min))); | 948 (-min * v->getPaintHeight()) / (max - min))); |
949 | 949 |
950 QPoint localPos; | 950 QPoint localPos; |
951 sv_frame_t illuminateFrame = -1; | 951 sv_frame_t illuminateFrame = -1; |
952 | 952 |
953 if (v->shouldIlluminateLocalFeatures(this, localPos)) { | 953 if (v->shouldIlluminateLocalFeatures(this, localPos)) { |
954 SparseTimeValueModel::PointList localPoints = | 954 SparseTimeValueModel::PointList localPoints = |
955 getLocalPoints(v, localPos.x()); | 955 getLocalPoints(v, localPos.x()); |
956 #ifdef DEBUG_TIME_VALUE_LAYER | 956 #ifdef DEBUG_TIME_VALUE_LAYER |
957 cerr << "TimeValueLayer: " << localPoints.size() << " local points" << endl; | 957 cerr << "TimeValueLayer: " << localPoints.size() << " local points" << endl; |
958 #endif | 958 #endif |
959 if (!localPoints.empty()) illuminateFrame = localPoints.begin()->frame; | 959 if (!localPoints.empty()) illuminateFrame = localPoints.begin()->frame; |
960 } | 960 } |
961 | 961 |
962 int w = | 962 int w = |
963 v->getXForFrame(frame0 + m_model->getResolution()) - | 963 v->getXForFrame(frame0 + m_model->getResolution()) - |
964 v->getXForFrame(frame0); | 964 v->getXForFrame(frame0); |
965 | 965 |
966 if (m_plotStyle == PlotStems) { | 966 if (m_plotStyle == PlotStems) { |
967 if (w < 2) w = 2; | 967 if (w < 2) w = 2; |
968 } else { | 968 } else { |
969 if (w < 1) w = 1; | 969 if (w < 1) w = 1; |
988 } | 988 } |
989 | 989 |
990 sv_frame_t prevFrame = 0; | 990 sv_frame_t prevFrame = 0; |
991 | 991 |
992 for (SparseTimeValueModel::PointList::const_iterator i = points.begin(); | 992 for (SparseTimeValueModel::PointList::const_iterator i = points.begin(); |
993 i != points.end(); ++i) { | 993 i != points.end(); ++i) { |
994 | 994 |
995 if (m_derivative && i == points.begin()) continue; | 995 if (m_derivative && i == points.begin()) continue; |
996 | 996 |
997 const SparseTimeValueModel::Point &p(*i); | 997 const SparseTimeValueModel::Point &p(*i); |
998 | 998 |
999 double value = p.value; | 999 double value = p.value; |
1000 if (m_derivative) { | 1000 if (m_derivative) { |
1001 SparseTimeValueModel::PointList::const_iterator j = i; | 1001 SparseTimeValueModel::PointList::const_iterator j = i; |
1002 --j; | 1002 --j; |
1003 value -= j->value; | 1003 value -= j->value; |
1004 } | 1004 } |
1005 | 1005 |
1006 int x = v->getXForFrame(p.frame); | 1006 int x = v->getXForFrame(p.frame); |
1007 int y = getYForValue(v, value); | 1007 int y = getYForValue(v, value); |
1008 | 1008 |
1009 bool gap = false; | 1009 bool gap = false; |
1010 if (m_plotStyle == PlotDiscreteCurves) { | 1010 if (m_plotStyle == PlotDiscreteCurves) { |
1011 if (value == 0.0) { | 1011 if (value == 0.0) { |
1012 // Treat zeros as gaps | 1012 // Treat zeros as gaps |
1022 if (textY < paint.fontMetrics().ascent() + 1) { | 1022 if (textY < paint.fontMetrics().ascent() + 1) { |
1023 textY = paint.fontMetrics().ascent() + 1; | 1023 textY = paint.fontMetrics().ascent() + 1; |
1024 } | 1024 } |
1025 } | 1025 } |
1026 | 1026 |
1027 bool haveNext = false; | 1027 bool haveNext = false; |
1028 double nvalue = 0.f; | 1028 double nvalue = 0.f; |
1029 sv_frame_t nf = v->getModelsEndFrame(); | 1029 sv_frame_t nf = v->getModelsEndFrame(); |
1030 int nx = v->getXForFrame(nf); | 1030 int nx = v->getXForFrame(nf); |
1031 int ny = y; | 1031 int ny = y; |
1032 | 1032 |
1033 SparseTimeValueModel::PointList::const_iterator j = i; | 1033 SparseTimeValueModel::PointList::const_iterator j = i; |
1034 ++j; | 1034 ++j; |
1035 | 1035 |
1036 if (j != points.end()) { | 1036 if (j != points.end()) { |
1037 const SparseTimeValueModel::Point &q(*j); | 1037 const SparseTimeValueModel::Point &q(*j); |
1038 nvalue = q.value; | 1038 nvalue = q.value; |
1039 if (m_derivative) nvalue -= p.value; | 1039 if (m_derivative) nvalue -= p.value; |
1040 nf = q.frame; | 1040 nf = q.frame; |
1041 nx = v->getXForFrame(nf); | 1041 nx = v->getXForFrame(nf); |
1042 ny = getYForValue(v, nvalue); | 1042 ny = getYForValue(v, nvalue); |
1043 haveNext = true; | 1043 haveNext = true; |
1044 } | 1044 } |
1045 | 1045 |
1046 // cout << "frame = " << p.frame << ", x = " << x << ", haveNext = " << haveNext | 1046 // cout << "frame = " << p.frame << ", x = " << x << ", haveNext = " << haveNext |
1047 // << ", nx = " << nx << endl; | 1047 // << ", nx = " << nx << endl; |
1048 | 1048 |
1053 pen = QPen(getBaseQColor(), 3); | 1053 pen = QPen(getBaseQColor(), 3); |
1054 brush = QBrush(Qt::NoBrush); | 1054 brush = QBrush(Qt::NoBrush); |
1055 } else if (m_plotStyle == PlotSegmentation) { | 1055 } else if (m_plotStyle == PlotSegmentation) { |
1056 pen = QPen(getForegroundQColor(v)); | 1056 pen = QPen(getForegroundQColor(v)); |
1057 brush = QBrush(getColourForValue(v, value)); | 1057 brush = QBrush(getColourForValue(v, value)); |
1058 } else if (m_plotStyle == PlotLines || | 1058 } else if (m_plotStyle == PlotLines || |
1059 m_plotStyle == PlotCurve) { | 1059 m_plotStyle == PlotCurve) { |
1060 brush = QBrush(Qt::NoBrush); | 1060 brush = QBrush(Qt::NoBrush); |
1061 } | 1061 } |
1062 | 1062 |
1063 paint.setPen(PaintAssistant::scalePen(pen)); | 1063 paint.setPen(PaintAssistant::scalePen(pen)); |
1064 paint.setBrush(brush); | 1064 paint.setBrush(brush); |
1065 | 1065 |
1066 if (m_plotStyle == PlotStems) { | 1066 if (m_plotStyle == PlotStems) { |
1067 if (y < origin - 1) { | 1067 if (y < origin - 1) { |
1068 paint.drawLine(x + w/2, y + 1, x + w/2, origin); | 1068 paint.drawLine(x + w/2, y + 1, x + w/2, origin); |
1069 } else if (y > origin + 1) { | 1069 } else if (y > origin + 1) { |
1070 paint.drawLine(x + w/2, origin, x + w/2, y - 1); | 1070 paint.drawLine(x + w/2, origin, x + w/2, y - 1); |
1071 } | 1071 } |
1072 } | 1072 } |
1073 | 1073 |
1074 bool illuminate = false; | 1074 bool illuminate = false; |
1075 | 1075 |
1076 if (illuminateFrame == p.frame) { | 1076 if (illuminateFrame == p.frame) { |
1077 | 1077 |
1078 // not equipped to illuminate the right section in line | 1078 // not equipped to illuminate the right section in line |
1079 // or curve mode | 1079 // or curve mode |
1080 | 1080 |
1081 if (m_plotStyle != PlotCurve && | 1081 if (m_plotStyle != PlotCurve && |
1082 m_plotStyle != PlotDiscreteCurves && | 1082 m_plotStyle != PlotDiscreteCurves && |
1083 m_plotStyle != PlotLines) { | 1083 m_plotStyle != PlotLines) { |
1084 illuminate = true; | 1084 illuminate = true; |
1085 } | 1085 } |
1086 } | 1086 } |
1087 | 1087 |
1088 if (m_plotStyle != PlotLines && | 1088 if (m_plotStyle != PlotLines && |
1089 m_plotStyle != PlotCurve && | 1089 m_plotStyle != PlotCurve && |
1090 m_plotStyle != PlotDiscreteCurves && | 1090 m_plotStyle != PlotDiscreteCurves && |
1091 m_plotStyle != PlotSegmentation) { | 1091 m_plotStyle != PlotSegmentation) { |
1092 if (illuminate) { | 1092 if (illuminate) { |
1093 paint.save(); | 1093 paint.save(); |
1094 paint.setPen(PaintAssistant::scalePen(getForegroundQColor(v))); | 1094 paint.setPen(PaintAssistant::scalePen(getForegroundQColor(v))); |
1095 paint.setBrush(getForegroundQColor(v)); | 1095 paint.setBrush(getForegroundQColor(v)); |
1096 } | 1096 } |
1097 if (m_plotStyle != PlotStems || | 1097 if (m_plotStyle != PlotStems || |
1098 w > 1) { | 1098 w > 1) { |
1099 paint.drawRect(x, y - 1, w, 2); | 1099 paint.drawRect(x, y - 1, w, 2); |
1100 } | 1100 } |
1101 if (illuminate) { | 1101 if (illuminate) { |
1102 paint.restore(); | 1102 paint.restore(); |
1103 } | 1103 } |
1104 } | 1104 } |
1105 | 1105 |
1106 if (m_plotStyle == PlotConnectedPoints || | 1106 if (m_plotStyle == PlotConnectedPoints || |
1107 m_plotStyle == PlotLines || | 1107 m_plotStyle == PlotLines || |
1108 m_plotStyle == PlotDiscreteCurves || | 1108 m_plotStyle == PlotDiscreteCurves || |
1109 m_plotStyle == PlotCurve) { | 1109 m_plotStyle == PlotCurve) { |
1110 | 1110 |
1111 if (haveNext) { | 1111 if (haveNext) { |
1112 | 1112 |
1113 if (m_plotStyle == PlotConnectedPoints) { | 1113 if (m_plotStyle == PlotConnectedPoints) { |
1114 | 1114 |
1115 paint.save(); | 1115 paint.save(); |
1116 paint.setPen(PaintAssistant::scalePen(brushColour)); | 1116 paint.setPen(PaintAssistant::scalePen(brushColour)); |
1117 paint.drawLine(x + w, y, nx, ny); | 1117 paint.drawLine(x + w, y, nx, ny); |
1118 paint.restore(); | 1118 paint.restore(); |
1119 | 1119 |
1120 } else if (m_plotStyle == PlotLines) { | 1120 } else if (m_plotStyle == PlotLines) { |
1121 | 1121 |
1122 if (pointCount == 0) { | 1122 if (pointCount == 0) { |
1123 path.moveTo(x + w/2, y); | 1123 path.moveTo(x + w/2, y); |
1124 } | 1124 } |
1125 | 1125 |
1126 // paint.drawLine(x + w/2, y, nx + w/2, ny); | 1126 // paint.drawLine(x + w/2, y, nx + w/2, ny); |
1127 path.lineTo(nx + w/2, ny); | 1127 path.lineTo(nx + w/2, ny); |
1128 | 1128 |
1129 } else { | 1129 } else { |
1130 | 1130 |
1131 double x0 = x + double(w)/2; | 1131 double x0 = x + double(w)/2; |
1132 double x1 = nx + double(w)/2; | 1132 double x1 = nx + double(w)/2; |
1133 | 1133 |
1134 double y0 = y; | 1134 double y0 = y; |
1135 double y1 = ny; | 1135 double y1 = ny; |
1136 | 1136 |
1137 if (m_plotStyle == PlotDiscreteCurves) { | 1137 if (m_plotStyle == PlotDiscreteCurves) { |
1138 bool nextGap = | 1138 bool nextGap = |
1139 (nvalue == 0.0) || | 1139 (nvalue == 0.0) || |
1140 (nf - p.frame >= m_model->getResolution() * 2); | 1140 (nf - p.frame >= m_model->getResolution() * 2); |
1142 x1 = x0; | 1142 x1 = x0; |
1143 y1 = y0; | 1143 y1 = y0; |
1144 } | 1144 } |
1145 } | 1145 } |
1146 | 1146 |
1147 if (pointCount == 0 || gap) { | 1147 if (pointCount == 0 || gap) { |
1148 path.moveTo((x0 + x1) / 2, (y0 + y1) / 2); | 1148 path.moveTo((x0 + x1) / 2, (y0 + y1) / 2); |
1149 } | 1149 } |
1150 | 1150 |
1151 if (nx - x > 5) { | 1151 if (nx - x > 5) { |
1152 path.cubicTo(x0, y0, | 1152 path.cubicTo(x0, y0, |
1153 x0, y0, | 1153 x0, y0, |
1154 (x0 + x1) / 2, (y0 + y1) / 2); | 1154 (x0 + x1) / 2, (y0 + y1) / 2); |
1155 | 1155 |
1156 // // or | 1156 // // or |
1157 // path.quadTo(x0, y0, (x0 + x1) / 2, (y0 + y1) / 2); | 1157 // path.quadTo(x0, y0, (x0 + x1) / 2, (y0 + y1) / 2); |
1158 | 1158 |
1159 } else { | 1159 } else { |
1160 path.lineTo(x0, y0); | 1160 path.lineTo(x0, y0); |
1161 path.lineTo((x0 + x1) / 2, (y0 + y1) / 2); | 1161 path.lineTo((x0 + x1) / 2, (y0 + y1) / 2); |
1162 } | 1162 } |
1163 } | 1163 } |
1164 } | 1164 } |
1165 } | 1165 } |
1166 | 1166 |
1167 if (m_plotStyle == PlotSegmentation) { | 1167 if (m_plotStyle == PlotSegmentation) { |
1168 | 1168 |
1169 #ifdef DEBUG_TIME_VALUE_LAYER | 1169 #ifdef DEBUG_TIME_VALUE_LAYER |
1170 cerr << "drawing rect" << endl; | 1170 cerr << "drawing rect" << endl; |
1171 #endif | 1171 #endif |
1172 | 1172 |
1173 if (nx <= x) continue; | 1173 if (nx <= x) continue; |
1174 | 1174 |
1175 paint.setPen(PaintAssistant::scalePen(QPen(getForegroundQColor(v), 2))); | 1175 paint.setPen(PaintAssistant::scalePen(QPen(getForegroundQColor(v), 2))); |
1176 | 1176 |
1177 if (!illuminate) { | 1177 if (!illuminate) { |
1178 if (!m_drawSegmentDivisions || | 1178 if (!m_drawSegmentDivisions || |
1179 nx < x + 5 || | 1179 nx < x + 5 || |
1180 x >= v->getPaintWidth() - 1) { | 1180 x >= v->getPaintWidth() - 1) { |
1181 paint.setPen(Qt::NoPen); | 1181 paint.setPen(Qt::NoPen); |
1182 } | 1182 } |
1183 } | 1183 } |
1184 | 1184 |
1185 paint.drawRect(x, -1, nx - x, v->getPaintHeight() + 1); | 1185 paint.drawRect(x, -1, nx - x, v->getPaintHeight() + 1); |
1186 } | 1186 } |
1187 | 1187 |
1188 if (v->shouldShowFeatureLabels()) { | 1188 if (v->shouldShowFeatureLabels()) { |
1189 | 1189 |
1190 QString label = p.label; | 1190 QString label = p.label; |
1191 bool italic = false; | 1191 bool italic = false; |
1220 ++pointCount; | 1220 ++pointCount; |
1221 } | 1221 } |
1222 | 1222 |
1223 if (m_plotStyle == PlotDiscreteCurves) { | 1223 if (m_plotStyle == PlotDiscreteCurves) { |
1224 paint.setRenderHint(QPainter::Antialiasing, true); | 1224 paint.setRenderHint(QPainter::Antialiasing, true); |
1225 paint.drawPath(path); | 1225 paint.drawPath(path); |
1226 } else if ((m_plotStyle == PlotCurve || m_plotStyle == PlotLines) | 1226 } else if ((m_plotStyle == PlotCurve || m_plotStyle == PlotLines) |
1227 && !path.isEmpty()) { | 1227 && !path.isEmpty()) { |
1228 paint.setRenderHint(QPainter::Antialiasing, pointCount <= v->getPaintWidth()); | 1228 paint.setRenderHint(QPainter::Antialiasing, pointCount <= v->getPaintWidth()); |
1229 paint.drawPath(path); | 1229 paint.drawPath(path); |
1230 } | 1230 } |
1231 | 1231 |
1232 paint.restore(); | 1232 paint.restore(); |
1233 | 1233 |
1234 // looks like save/restore doesn't deal with this: | 1234 // looks like save/restore doesn't deal with this: |
1347 | 1347 |
1348 m_originalPoint = m_editingPoint; | 1348 m_originalPoint = m_editingPoint; |
1349 | 1349 |
1350 if (m_editingCommand) finish(m_editingCommand); | 1350 if (m_editingCommand) finish(m_editingCommand); |
1351 m_editingCommand = new SparseTimeValueModel::EditCommand(m_model, | 1351 m_editingCommand = new SparseTimeValueModel::EditCommand(m_model, |
1352 tr("Draw Point")); | 1352 tr("Draw Point")); |
1353 if (!havePoint) { | 1353 if (!havePoint) { |
1354 m_editingCommand->addPoint(m_editingPoint); | 1354 m_editingCommand->addPoint(m_editingPoint); |
1355 } | 1355 } |
1356 | 1356 |
1357 m_editing = true; | 1357 m_editing = true; |
1440 if (points.empty()) return; | 1440 if (points.empty()) return; |
1441 | 1441 |
1442 m_editingPoint = *points.begin(); | 1442 m_editingPoint = *points.begin(); |
1443 | 1443 |
1444 if (m_editingCommand) { | 1444 if (m_editingCommand) { |
1445 finish(m_editingCommand); | 1445 finish(m_editingCommand); |
1446 m_editingCommand = 0; | 1446 m_editingCommand = 0; |
1447 } | 1447 } |
1448 | 1448 |
1449 m_editing = true; | 1449 m_editing = true; |
1450 } | 1450 } |
1451 | 1451 |
1490 | 1490 |
1491 m_editingPoint = *points.begin(); | 1491 m_editingPoint = *points.begin(); |
1492 m_originalPoint = m_editingPoint; | 1492 m_originalPoint = m_editingPoint; |
1493 | 1493 |
1494 if (m_editingCommand) { | 1494 if (m_editingCommand) { |
1495 finish(m_editingCommand); | 1495 finish(m_editingCommand); |
1496 m_editingCommand = 0; | 1496 m_editingCommand = 0; |
1497 } | 1497 } |
1498 | 1498 |
1499 m_editing = true; | 1499 m_editing = true; |
1500 } | 1500 } |
1501 | 1501 |
1513 frame = frame / m_model->getResolution() * m_model->getResolution(); | 1513 frame = frame / m_model->getResolution() * m_model->getResolution(); |
1514 | 1514 |
1515 double value = getValueForY(v, e->y()); | 1515 double value = getValueForY(v, e->y()); |
1516 | 1516 |
1517 if (!m_editingCommand) { | 1517 if (!m_editingCommand) { |
1518 m_editingCommand = new SparseTimeValueModel::EditCommand(m_model, | 1518 m_editingCommand = new SparseTimeValueModel::EditCommand(m_model, |
1519 tr("Drag Point")); | 1519 tr("Drag Point")); |
1520 } | 1520 } |
1521 | 1521 |
1522 m_editingCommand->deletePoint(m_editingPoint); | 1522 m_editingCommand->deletePoint(m_editingPoint); |
1523 m_editingPoint.frame = frame; | 1523 m_editingPoint.frame = frame; |
1524 m_editingPoint.value = float(value); | 1524 m_editingPoint.value = float(value); |
1533 #endif | 1533 #endif |
1534 if (!m_model || !m_editing) return; | 1534 if (!m_model || !m_editing) return; |
1535 | 1535 |
1536 if (m_editingCommand) { | 1536 if (m_editingCommand) { |
1537 | 1537 |
1538 QString newName = m_editingCommand->getName(); | 1538 QString newName = m_editingCommand->getName(); |
1539 | 1539 |
1540 if (m_editingPoint.frame != m_originalPoint.frame) { | 1540 if (m_editingPoint.frame != m_originalPoint.frame) { |
1541 if (m_editingPoint.value != m_originalPoint.value) { | 1541 if (m_editingPoint.value != m_originalPoint.value) { |
1542 newName = tr("Edit Point"); | 1542 newName = tr("Edit Point"); |
1543 } else { | 1543 } else { |
1544 newName = tr("Relocate Point"); | 1544 newName = tr("Relocate Point"); |
1545 } | 1545 } |
1546 } else { | 1546 } else { |
1547 newName = tr("Change Point Value"); | 1547 newName = tr("Change Point Value"); |
1548 } | 1548 } |
1549 | 1549 |
1550 m_editingCommand->setName(newName); | 1550 m_editingCommand->setName(newName); |
1551 finish(m_editingCommand); | 1551 finish(m_editingCommand); |
1552 } | 1552 } |
1553 | 1553 |
1554 m_editingCommand = 0; | 1554 m_editingCommand = 0; |
1555 m_editing = false; | 1555 m_editing = false; |
1556 } | 1556 } |
1598 TimeValueLayer::moveSelection(Selection s, sv_frame_t newStartFrame) | 1598 TimeValueLayer::moveSelection(Selection s, sv_frame_t newStartFrame) |
1599 { | 1599 { |
1600 if (!m_model) return; | 1600 if (!m_model) return; |
1601 | 1601 |
1602 SparseTimeValueModel::EditCommand *command = | 1602 SparseTimeValueModel::EditCommand *command = |
1603 new SparseTimeValueModel::EditCommand(m_model, | 1603 new SparseTimeValueModel::EditCommand(m_model, |
1604 tr("Drag Selection")); | 1604 tr("Drag Selection")); |
1605 | 1605 |
1606 SparseTimeValueModel::PointList points = | 1606 SparseTimeValueModel::PointList points = |
1607 m_model->getPoints(s.getStartFrame(), s.getEndFrame()); | 1607 m_model->getPoints(s.getStartFrame(), s.getEndFrame()); |
1608 | 1608 |
1609 for (SparseTimeValueModel::PointList::iterator i = points.begin(); | 1609 for (SparseTimeValueModel::PointList::iterator i = points.begin(); |
1610 i != points.end(); ++i) { | 1610 i != points.end(); ++i) { |
1611 | 1611 |
1612 if (s.contains(i->frame)) { | 1612 if (s.contains(i->frame)) { |
1613 SparseTimeValueModel::Point newPoint(*i); | 1613 SparseTimeValueModel::Point newPoint(*i); |
1614 newPoint.frame = i->frame + newStartFrame - s.getStartFrame(); | 1614 newPoint.frame = i->frame + newStartFrame - s.getStartFrame(); |
1615 command->deletePoint(*i); | 1615 command->deletePoint(*i); |
1616 command->addPoint(newPoint); | 1616 command->addPoint(newPoint); |
1617 } | 1617 } |
1618 } | 1618 } |
1619 | 1619 |
1620 finish(command); | 1620 finish(command); |
1621 } | 1621 } |
1622 | 1622 |
1624 TimeValueLayer::resizeSelection(Selection s, Selection newSize) | 1624 TimeValueLayer::resizeSelection(Selection s, Selection newSize) |
1625 { | 1625 { |
1626 if (!m_model) return; | 1626 if (!m_model) return; |
1627 | 1627 |
1628 SparseTimeValueModel::EditCommand *command = | 1628 SparseTimeValueModel::EditCommand *command = |
1629 new SparseTimeValueModel::EditCommand(m_model, | 1629 new SparseTimeValueModel::EditCommand(m_model, |
1630 tr("Resize Selection")); | 1630 tr("Resize Selection")); |
1631 | 1631 |
1632 SparseTimeValueModel::PointList points = | 1632 SparseTimeValueModel::PointList points = |
1633 m_model->getPoints(s.getStartFrame(), s.getEndFrame()); | 1633 m_model->getPoints(s.getStartFrame(), s.getEndFrame()); |
1634 | 1634 |
1635 double ratio = | 1635 double ratio = |
1636 double(newSize.getEndFrame() - newSize.getStartFrame()) / | 1636 double(newSize.getEndFrame() - newSize.getStartFrame()) / |
1637 double(s.getEndFrame() - s.getStartFrame()); | 1637 double(s.getEndFrame() - s.getStartFrame()); |
1638 | 1638 |
1639 for (SparseTimeValueModel::PointList::iterator i = points.begin(); | 1639 for (SparseTimeValueModel::PointList::iterator i = points.begin(); |
1640 i != points.end(); ++i) { | 1640 i != points.end(); ++i) { |
1641 | 1641 |
1642 if (s.contains(i->frame)) { | 1642 if (s.contains(i->frame)) { |
1643 | 1643 |
1644 double target = double(i->frame); | 1644 double target = double(i->frame); |
1645 target = double(newSize.getStartFrame()) + | 1645 target = double(newSize.getStartFrame()) + |
1646 target - double(s.getStartFrame()) * ratio; | 1646 target - double(s.getStartFrame()) * ratio; |
1647 | 1647 |
1648 SparseTimeValueModel::Point newPoint(*i); | 1648 SparseTimeValueModel::Point newPoint(*i); |
1649 newPoint.frame = lrint(target); | 1649 newPoint.frame = lrint(target); |
1650 command->deletePoint(*i); | 1650 command->deletePoint(*i); |
1651 command->addPoint(newPoint); | 1651 command->addPoint(newPoint); |
1652 } | 1652 } |
1653 } | 1653 } |
1654 | 1654 |
1655 finish(command); | 1655 finish(command); |
1656 } | 1656 } |
1657 | 1657 |
1659 TimeValueLayer::deleteSelection(Selection s) | 1659 TimeValueLayer::deleteSelection(Selection s) |
1660 { | 1660 { |
1661 if (!m_model) return; | 1661 if (!m_model) return; |
1662 | 1662 |
1663 SparseTimeValueModel::EditCommand *command = | 1663 SparseTimeValueModel::EditCommand *command = |
1664 new SparseTimeValueModel::EditCommand(m_model, | 1664 new SparseTimeValueModel::EditCommand(m_model, |
1665 tr("Delete Selected Points")); | 1665 tr("Delete Selected Points")); |
1666 | 1666 |
1667 SparseTimeValueModel::PointList points = | 1667 SparseTimeValueModel::PointList points = |
1668 m_model->getPoints(s.getStartFrame(), s.getEndFrame()); | 1668 m_model->getPoints(s.getStartFrame(), s.getEndFrame()); |
1669 | 1669 |
1670 for (SparseTimeValueModel::PointList::iterator i = points.begin(); | 1670 for (SparseTimeValueModel::PointList::iterator i = points.begin(); |
1671 i != points.end(); ++i) { | 1671 i != points.end(); ++i) { |
1672 | 1672 |
1673 if (s.contains(i->frame)) { | 1673 if (s.contains(i->frame)) { |
1674 command->deletePoint(*i); | 1674 command->deletePoint(*i); |
1675 } | 1675 } |
1676 } | 1676 } |
1682 TimeValueLayer::copy(LayerGeometryProvider *v, Selection s, Clipboard &to) | 1682 TimeValueLayer::copy(LayerGeometryProvider *v, Selection s, Clipboard &to) |
1683 { | 1683 { |
1684 if (!m_model) return; | 1684 if (!m_model) return; |
1685 | 1685 |
1686 SparseTimeValueModel::PointList points = | 1686 SparseTimeValueModel::PointList points = |
1687 m_model->getPoints(s.getStartFrame(), s.getEndFrame()); | 1687 m_model->getPoints(s.getStartFrame(), s.getEndFrame()); |
1688 | 1688 |
1689 for (SparseTimeValueModel::PointList::iterator i = points.begin(); | 1689 for (SparseTimeValueModel::PointList::iterator i = points.begin(); |
1690 i != points.end(); ++i) { | 1690 i != points.end(); ++i) { |
1691 if (s.contains(i->frame)) { | 1691 if (s.contains(i->frame)) { |
1692 Clipboard::Point point(i->frame, i->value, i->label); | 1692 Clipboard::Point point(i->frame, i->value, i->label); |
1693 point.setReferenceFrame(alignToReference(v, i->frame)); | 1693 point.setReferenceFrame(alignToReference(v, i->frame)); |
1694 to.addPoint(point); | 1694 to.addPoint(point); |
1695 } | 1695 } |
1696 } | 1696 } |
1722 realign = true; | 1722 realign = true; |
1723 } | 1723 } |
1724 } | 1724 } |
1725 | 1725 |
1726 SparseTimeValueModel::EditCommand *command = | 1726 SparseTimeValueModel::EditCommand *command = |
1727 new SparseTimeValueModel::EditCommand(m_model, tr("Paste")); | 1727 new SparseTimeValueModel::EditCommand(m_model, tr("Paste")); |
1728 | 1728 |
1729 enum ValueAvailability { | 1729 enum ValueAvailability { |
1730 UnknownAvailability, | 1730 UnknownAvailability, |
1731 NoValues, | 1731 NoValues, |
1732 SomeValues, | 1732 SomeValues, |
1926 | 1926 |
1927 int cmap = attributes.value("colourMap").toInt(&ok); | 1927 int cmap = attributes.value("colourMap").toInt(&ok); |
1928 if (ok) setFillColourMap(cmap); | 1928 if (ok) setFillColourMap(cmap); |
1929 | 1929 |
1930 PlotStyle style = (PlotStyle) | 1930 PlotStyle style = (PlotStyle) |
1931 attributes.value("plotStyle").toInt(&ok); | 1931 attributes.value("plotStyle").toInt(&ok); |
1932 if (ok) setPlotStyle(style); | 1932 if (ok) setPlotStyle(style); |
1933 | 1933 |
1934 VerticalScale scale = (VerticalScale) | 1934 VerticalScale scale = (VerticalScale) |
1935 attributes.value("verticalScale").toInt(&ok); | 1935 attributes.value("verticalScale").toInt(&ok); |
1936 if (ok) setVerticalScale(scale); | 1936 if (ok) setVerticalScale(scale); |
1937 | 1937 |
1938 bool draw = (attributes.value("drawDivisions").trimmed() == "true"); | 1938 bool draw = (attributes.value("drawDivisions").trimmed() == "true"); |
1939 setDrawSegmentDivisions(draw); | 1939 setDrawSegmentDivisions(draw); |
1940 | 1940 |