[Drawkit] Transforms / ScaleBy

Allan Daly allandaly at me.com
Thu Apr 30 19:45:34 PDT 2009


Mike, Graham,

Picking up on this thread ... for my DXF importer I need to be able to  
scale DKShapeGroups by a scale factor that I read out of the DXF  
INSERT entity data. Actually there can be separate X and Y scale  
factors. How do I apply these to DKShapeGroups, or for that matter any  
DKDrawableObject?

 From reading through the message string below I can see that  
NSAffineTransformation objects are involved, and from looking at the  
API documentation on that I sort of get it, but frankly it eludes me  
right now. Could either of you provide any help to get me pointed in  
the right direction on this? And/or do you know any good links to send  
me that would help me understand what the heck an AffineTransformation  
is and how I should use it? Seem to me that I fundamentally do not  
understand these Transformation objects and I would like to.

Thanks.

-Allan


On Apr 8, 2009, at 5:41 AM, Mike Caron wrote:

> Roger that, huston!
>
> Just to test that I was in fact doing the right thing, I whipped up  
> a custom view cocoa app that draws some lines on initialization,  
> saved as a Bezier path. Two buttons, rescale and translate take  
> inputs from text boxes and allow transforms to happen. Using those I  
> was able to see transforms happen as expected.
>
> Cheers,
> Mike
>
>
> On Wed, Apr 8, 2009 at 12:25 AM, Graham Cox <graham.cox at bigpond.com>  
> wrote:
>
> On 08/04/2009, at 10:35 AM, Michael Caron wrote:
>
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hm. Seems like doing it that way yields the same second bounding  
> box. Doesn't matter if I'm using the origin or not:
>
>        NSRect boundingBox = [currentLayer unionOfAllObjectBounds];
>        // x=16.0239811, y=15.9680157
>       // h=18.1520519, w=18.1520519
>
>
>        // Get the identity transform
>        NSAffineTransform* txfm = [NSAffineTransform transform];
>
>        // translate to origin
>        [txfm translateXBy:-(boundingBox.origin.x) yBy:- 
> (boundingBox.origin.y)];
>
>        // scale by 1000
>        [txfm scaleBy: [[self metadataObjectForKey:@"scaleFactor"]  
> doubleValue]];
>
>        [currentLayer applyTransformToObjects:txfm];
>
>        NSRect boundingBox2 = [currentLayer unionOfAllObjectBounds];
>        // x=25086.7695, y=25030.8047
>        // h=26.4765625, w=26.4765625
>
> Any thoughts?
>
>
> Hmm, well I'm not sure.
>
> It might turn out that the method is buggy - it hasn't been used  
> very much. That said, the width/height results you're getting really  
> don't make much sense.  You could try tracing through the loop  
> within -applyTransformToObjects: in the debugger and just verifying  
> that each individual value is doing the expected thing.
>
>
> --Graham
>
>
> _______________________________________________
> Drawkit mailing list
> Drawkit at lists.apptree.net
> http://lists.apptree.net/listinfo.cgi/drawkit-apptree.net
>
> _______________________________________________
> Drawkit mailing list
> Drawkit at lists.apptree.net
> http://lists.apptree.net/listinfo.cgi/drawkit-apptree.net

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.apptree.net/pipermail/drawkit-apptree.net/attachments/20090430/8200412b/attachment.htm>


More information about the Drawkit mailing list