[Drawkit] SonoDraw Beta 1 now available

Brad Larson larson at sonoplot.com
Fri Aug 1 14:22:37 PDT 2008


On Jul 29, 2008, at 8:30 PM, Graham Cox wrote:
>
>> and I'm tracking down a glitch with DKArcPath where it doesn't  
>> always draw with the correct radius.
>
> Hmm, be good to know what that one is - not noticed it.


This one is really strange.  The problem is in DKArcPath's  
arcCreateLoop: method, and you can see it in the default drawing that  
comes up when you start the binary version of SonoDraw that I posted.   
Clicking sets the center just fine.  Moving the mouse straight down  
draws the radius just fine in the preview, but when you click to set  
the radius and ending angle, the radius gets set to 0.  The relevant  
code is as follows:

case NSLeftMouseDown:
{
	if ( phase == 0 )
	{
		// set radius as the distance from this click to the centre, and the
		// start angle based on the slope of this line
					
		mRadius = hypotf( p.x - mCentre.x, p.y - mCentre.y );
		mEndAngle = atan2f( p.y - mCentre.y, p.x - mCentre.x );
		++phase;	// now setting the arc
					
		if([self arcType] == kDKArcPathCircle )
			loop = NO;
	}
	else
		loop = NO;
}

Whatever is going wrong, is going wrong at mRadius.  So I put an NSLog  
right after the mRadius= line to catch the new radius value:

NSLog(@"Radius: %f", mRadius);

and as soon as I did that, the arcs all draw properly.  What is this,  
Schroedinger's Variable?  By observing it we set its value?  Anyway, I  
replaced the hypotf function with the following:

mRadius = sqrt( (p.x - mCentre.x) * (p.x - mCentre.x) + (p.y -  
mCentre.y) * (p.y - mCentre.y) );

and it now works just fine.

I've seen weirdness like this before when dealing with CF pointers and  
garbage collection, but I even turned off garbage collection,  
recompiled, and this had the same exact behavior.  I have no idea what  
causes this with the hypotf function, but the manual implementation  
fixes the problem.

______________________
Brad Larson
SonoPlot, Inc.
3030 Laura Lane, Suite 120
Middleton, WI 53562





More information about the Drawkit mailing list