| 984 | } |
| 985 | |
| 986 | void |
| 987 | TrackerPanel::onAverageButtonClicked() |
| 988 | { |
| 989 | TrackerContextPtr context = getContext(); |
| 990 | |
| 991 | assert(context); |
| 992 | std::list<TrackMarkerPtr> markers; |
| 993 | context->getSelectedMarkers(&markers); |
| 994 | if ( markers.empty() ) { |
| 995 | Dialogs::warningDialog( tr("Average").toStdString(), tr("No tracks selected").toStdString() ); |
| 996 | |
| 997 | return; |
| 998 | } |
| 999 | |
| 1000 | TrackMarkerPtr marker = makeTrackInternal(); |
| 1001 | KnobDoublePtr centerKnob = marker->getCenterKnob(); |
| 1002 | |
| 1003 | #ifdef AVERAGE_ALSO_PATTERN_QUAD |
| 1004 | KnobDoublePtr topLeftKnob = marker->getPatternTopLeftKnob(); |
| 1005 | KnobDoublePtr topRightKnob = marker->getPatternTopRightKnob(); |
| 1006 | KnobDoublePtr btmRightKnob = marker->getPatternBtmRightKnob(); |
| 1007 | KnobDoublePtr btmLeftKnob = marker->getPatternBtmLeftKnob(); |
| 1008 | #endif |
| 1009 | |
| 1010 | RangeD keyframesRange; |
| 1011 | keyframesRange.min = std::numeric_limits<int>::max(); |
| 1012 | keyframesRange.max = std::numeric_limits<int>::min(); |
| 1013 | for (std::list<TrackMarkerPtr>::iterator it = markers.begin(); it != markers.end(); ++it) { |
| 1014 | KnobDoublePtr markCenter = (*it)->getCenterKnob(); |
| 1015 | double mini, maxi; |
| 1016 | bool hasKey = markCenter->getFirstKeyFrameTime(ViewSpec(0), 0, &mini); |
| 1017 | if (!hasKey) { |
| 1018 | continue; |
| 1019 | } |
| 1020 | if (mini < keyframesRange.min) { |
| 1021 | keyframesRange.min = mini; |
| 1022 | } |
| 1023 | hasKey = markCenter->getLastKeyFrameTime(ViewSpec(0), 0, &maxi); |
| 1024 | |
| 1025 | ///both dimensions must have keyframes |
| 1026 | assert(hasKey); |
| 1027 | if (maxi > keyframesRange.max) { |
| 1028 | keyframesRange.max = maxi; |
| 1029 | } |
| 1030 | } |
| 1031 | |
| 1032 | bool hasKeyFrame = keyframesRange.min != std::numeric_limits<int>::min() && keyframesRange.max != std::numeric_limits<int>::max(); |
| 1033 | for (double t = keyframesRange.min; t <= keyframesRange.max; t += 1) { |
| 1034 | Point avgCenter; |
| 1035 | avgCenter.x = avgCenter.y = 0.; |
| 1036 | |
| 1037 | #ifdef AVERAGE_ALSO_PATTERN_QUAD |
| 1038 | Point avgTopLeft, avgTopRight, avgBtmRight, avgBtmLeft; |
| 1039 | avgTopLeft.x = avgTopLeft.y = avgTopRight.x = avgTopRight.y = avgBtmRight.x = avgBtmRight.y = avgBtmLeft.x = avgBtmLeft.y = 0; |
| 1040 | #endif |
| 1041 | |
| 1042 | |
| 1043 | for (std::list<TrackMarkerPtr>::iterator it = markers.begin(); it != markers.end(); ++it) { |
nothing calls this directly
no test coverage detected