Know that you can merge annotations using shift-click. So to see how it can be done, look at the code in selectAnnotationWithEvent:. It merges the selections of the annotations and creates a new annotation from the merged selection. Also note that quadrilateral points are relative to the annotation bounds, so if you use them in another annotation you need to shift them. But using the selection is easier. I also have an applescript (available on the wiki) that can merge all highlights, which also works by merging the selections.
Christiaan On 16 Aug 2007, at 6:46 PM, Adam R. Maxwell wrote: > I've been highlighting a multi-column paper, and I agree with other > users that it's annoying to either have the highlight bounds extend > outside what I actually want to highlight, or have multiple short > highlights for each line (which shows up as multiple lines in the > outline view). > > For my own use, I thought I could merge markups together by > creating a new annotation in SKPDFView.m, but if I merge three > separate highlights (top, middle, bottom), I lose the middle line. > Am I missing something obvious? The only thing I can think of is > some restriction on ordering of quad points. > > - (void)mergeAnnotationsInSelection:(id)sender { > NSArray *annotations = [[self currentPage] annotations]; > NSMutableArray *quadPoints = [NSMutableArray array]; > NSRect bounds = NSZeroRect; > unsigned i, iMax = [annotations count]; > int markupType = -1; > SKPDFAnnotationMarkup *ann = nil; > > // don't remove while enumerating the current annotations > NSMutableArray *annotationsToRemove = [NSMutableArray array]; > > for (i = 0; i < iMax; i++) { > ann = [annotations objectAtIndex:i]; > if (NSIntersectsRect([ann bounds], selectionRect) && [ann > isMarkupAnnotation]) { > if (-1 == markupType) { > bounds = [ann bounds]; > markupType = [ann markupType]; > } > else if ([ann markupType] == markupType) { > bounds = NSUnionRect(bounds, [ann bounds]); > [quadPoints addObjectsFromArray:[ann > quadrilateralPoints]]; > [annotationsToRemove addObject:ann]; > } > } > } > > iMax = [annotationsToRemove count]; > for (i = 0; i < iMax; i++) > [self removeAnnotation:[annotationsToRemove objectAtIndex:i]]; > > NSMutableArray *quadStrings = [NSMutableArray arrayWithCapacity: > [quadPoints count]]; > iMax = [quadPoints count]; > for (i = 0; i < iMax; i++) > [quadStrings addObject:NSStringFromPoint([[quadPoints > objectAtIndex:i] pointValue])]; > ann = [[SKPDFAnnotationMarkup alloc] initWithBounds:bounds > markupType:markupType quadrilateralPointsAsStrings:quadStrings]; > [self addAnnotation:ann toPage:[self currentPage]]; > [ann release]; > [self setNeedsDisplayInRect:selectionRect ofPage:[self > currentPage]]; > } ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ _______________________________________________ skim-app-develop mailing list skim-app-develop@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/skim-app-develop