Group rotation
Group rotation
- Subject: Group rotation
- From: "Ghufran Ahamad" <email@hidden>
- Date: Tue, 29 Apr 2008 10:55:01 +0530
Hi All,
I want to do group rotation for various objects. Objects are getting rotate
correctly on their center but when I group them the rotated object has got
shift. Note: In case of group only rotated object has got shift. Below is
the code snippet. Let me know I doing correct or not.
-(NSRect)drawingBoundForGroup:(int)in_Group
{
NSRect rect = NSZeroRect;
NSArray *objTlGraphic = [[self document] graphics];
unsigned i,c = [objTlGraphic count];
if(in_Group != 0)
{
for(i = 0; i < c;i++)
{
if([[objTlGraphic objectAtIndex:i] GroupNO]==in_Group)
{
rect=NSUnionRect(rect,[[objTlGraphic objectAtIndex:i] bounds]);
NSLog(@"Object Center Log Index= %d %d",rect,i);
}
}
}
return rect;
}
int Id_Group=[curGraphic GroupNO];
NSRect stRect=[curGraphic drawingBoundForGroup:Id_Group];
NSAffineTransform* xform = [NSAffineTransform transform];
[currentContext saveGraphicsState];
[NSBezierPath clipRect:drawingBounds];
NSPoint center = NSMakePoint(NSMidX(stRect), NSMidY(stRect));
[xform translateXBy:center.x yBy:center.y];
[xform rotateByDegrees:[curGraphic GetAngle]];
[xform translateXBy:-center.x yBy:-center.y];
[xform concat];
[curGraphic drawInView:self isSelected:isSelected];
[currentContext restoreGraphicsState];
[self setNeedsDisplay:YES];
Thanks in advance,
Ghufran Ahmad
+91 - 9953130470
Skype ID: ghufran_khan81
AOL ID: gahmad81
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden