void AnnotationGroup::deleteFromFrame(int frame) { for(unsigned int j = 0; j < vannotations_.size(); j++) { Annotation* annotation = vannotations_[j]; if(annotation->getMaxFrame() >= frame) annotation->setMaxFrame(annotation->getMaxFrame() - 1); if(annotation->getMinFrame() >= frame) annotation->setMinFrame(annotation->getMinFrame() - 1); } }
void AnnotationGroup::mergeAnnotations(std::vector<Annotation*> annotations, int sourceMinFrame, int targetMinFrame, int targetRange) { std::vector<Annotation*> toMerge; for(unsigned int i = 0; i < annotations.size(); i++) { Annotation* annotation = annotations[i]; if(annotation->getMinFrame() <= sourceMinFrame + targetRange && annotation->getMaxFrame() >= sourceMinFrame) toMerge.push_back(annotation->copy()); } for(unsigned int i = 0; i < toMerge.size(); i++) { Annotation* annotation = toMerge[i]; // Remap frames int frameOffset = targetMinFrame - sourceMinFrame; int newMinFrame = std::max(sourceMinFrame, annotation->getMinFrame()); int annotationRange = annotation->getMaxFrame() - annotation->getMinFrame(); int range = std::min(annotationRange,targetRange); annotation->setMinFrame(newMinFrame + frameOffset); annotation->setMaxFrame(newMinFrame + frameOffset + range); annotation->remapCenterPoints(frameOffset); vannotations_.push_back(annotation); } }