> That then just leaves you with the translation to deal with, for positioning > the scaled path where you want it. >
I really hate to post this again, but I believe I'm doing it right, but there's obviously something I'm not understanding. By trying to figure out what's wrong w/ my scaling, I've simplified it to doing transforms only which also shows the problem (new problem after making the changes suggested). I'm certain I have the destination bounds, the path bounds, and even the scaleXBy: yBy: factors correct, but I'll just stick w/ how I'm doing the 'translateXBy yBy:' and comment out the scaleXBy method. I plot my line, and it shows in the view perfect, as expected. If I try to resize the view, my plot starts to move incrementing by one, translating +1 for both x and y. Whether I resize my NSView larger or smaller, my curve moves to the upper right corner and then eventually off the view, as if x and y in 'translateXBy: yBy' constantly increment by one as I resize the view. So my thought is that somehow the transformations are not resetting to the identity matrix, but they are as far as I can tell. Maybe, I'm thinking, that the transforms are being added on top of each other as the view resizes. Anyone see anything wrong that I'm doing? - (void) drawRect:(NSRect) rect { NSRect bounds = [self bounds]; [[NSColor blackColor] setFill]; [NSBezierPath fillRect:bounds]; float xFactor = (bounds.size.width * 0.9) / maxXValue; float yFactor = (bounds.size.height * 0.9) / maxYValue; NSAffineTransform *xform = [NSAffineTransform transform]; // curve starts off translated up 2 and over 2, correct. // resizing view seems like x and y incr by 1 as view resizes. [xform translateXBy:2.0 yBy:2.0]; //[xform scaleXBy:xFactor yBy:yFactor]; [pointsPath transformUsingAffineTransform:xform]; [[NSColor whiteColor] setStroke]; [pointsPath setLineCapStyle:NSSquareLineCapStyle]; [pointsPath stroke]; return; } - (void) appendPoint:(NSPoint) point { if (firstPoint) { [pointsPath moveToPoint:point]; firstPoint = NO; } [pointsPath lineToPoint:point]; return; } - (void) updateXMax:(double) maxX yMax:(double) maxY { maxXValue = maxX; maxYValue = maxY; } This gets called for each point in my curve, which happens ~140 times. My curve shows up as expected, then I resize the window and the curve doesn't resize to the window, rather, it moves off the window in the original size. BOOL maxFlagDirty = NO; NSNumber *mse = [NSNumber numberWithDouble:[[data mse] doubleValue]]; NSNumber *iters = [NSNumber numberWithInt:[[data iterations] intValue]]; if ([iters doubleValue] > maxXValue) { maxXValue = [iters doubleValue]; maxFlagDirty = YES; } if ([mse doubleValue] > maxYValue) { maxYValue = [mse doubleValue]; maxFlagDirty = YES; } if (maxFlagDirty) { [graphView updateXMax:maxXValue yMax:maxYValue]; } NSPoint point = NSMakePoint([iters floatValue], [mse floatValue]); if ([self isWindowLoaded]) { [graphView appendPoint:point]; [graphView setNeedsDisplay:YES]; } _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com