ftp.nice.ch/pub/next/graphics/vector/Wood.0.72.s.tar.gz#/Wood/WoodFuture/TreeDiagram/MiscConcreteShape.m

This is MiscConcreteShape.m in view mode; [Download] [Up]

/*
		Copyright (c) Uwe Hoffmann, 1995.
                  All Rights Reserved.

Filename: MiscConcreteShape.m
Author:   Uwe Hoffmann
Date:	  Sep 07, 1995

$Id: MiscConcreteShape.m,v 1.0 1995/09/07 11:22:00 Uwe Hoffmann Exp $
 $Log: MiscConcreteShape.m,v $
*/

#import <appkit/appkit.h>
#import <foundation/foundation.h>
#import <foundation/NSArchiver.h>

#import "MiscConcreteShape.h"
#import "MiscUserPath.h"
#import "MiscHitPath.h"


@implementation MiscConcreteShape 

- initBounds:(NSRect)aRect
{
	path = [[MiscUserPath allocWithZone:[self zone]] init];
	[self makePathWithBounds:aRect];
	return self;
}

- (void)dealloc
{
	[path release];
   	return [super dealloc];
}

- copyWithZone:(NSZone *)aZone
{
	MiscConcreteShape *theCopy;
	
	theCopy = (MiscConcreteShape *)NSCopyObject(self, 0, aZone);	
	theCopy->path = [path copyWithZone:aZone];	
	return theCopy;
}

- copy
{
	return [self copyWithZone:NULL];
}

- (NSRect)bounds
{
	return [path bounds];
}

- (void)moveTo:(NSPoint)aPos
{
	NSRect r;
	
	r = [path bounds];
	r.origin = aPos;
	[self fillParamsWithBounds:r];
}

- (void)sizeTo:(NSSize)aSize
{
	NSRect r;
	
	r = [path bounds];
	r.size = aSize;
	[self fillParamsWithBounds:r];
}

- (void)drawOutline
{
	[path send:dps_ustroke cached:YES];
}

- (void)drawFill
{
	[path send:dps_ufill cached:YES];
}

- (void)drawShadowWithDelta:(NSPoint)aPos
{
	NSRect r;
	NSPoint original;
	
	r = [path bounds];
	original = r.origin;
	r.origin = aPos;
	[self fillParamsWithBounds:r];
	[path send:dps_ufill cached:YES];
	r.origin = original;
	[self fillParamsWithBounds:r];
}

- (BOOL)hit:(MiscHitPath *)hitPath
{
	return [hitPath hit:dps_inufill path:path];
}

- initWithCoder:(NSCoder *)coder
{
	[super initWithCoder:coder];
	path = [[coder decodeObject] retain];
	return self;
}

- (void)encodeWithCoder:(NSCoder *)coder
{
	[super encodeWithCoder:coder];
	[coder encodeObject:path];
}


- (void)makePathWithBounds:(NSRect)aRect
{
	return;
}

- (void)fillParamsWithBounds:(NSRect)aRect
{
	return;
}

+ (NSSize)calcSizeForInnerSize:(NSSize)aSize
{
	NSSize s;
	
	s.width = s.height = 0;
	return s;
}
		              
@end


BOOL straddles(NSPoint p1, NSPoint p2, NSPoint p3, NSPoint p4)
{
	float crossP1, crossP2;
	
	crossP1 = (p3.x - p1.x) * (p2.y - p1.y) - (p2.x - p1.x) * (p3.y - p1.y); 
	crossP2 = (p4.x - p1.x) * (p2.y - p1.y) - (p2.x - p1.x) * (p4.y - p1.y);
	if((crossP1 > 0 && crossP2 < 0) || (crossP1 < 0 && crossP2 > 0)){
		crossP1 = (p1.x - p3.x) * (p4.y - p3.y) - (p4.x - p3.x) * (p1.y - p3.y); 
		crossP2 = (p2.x - p3.x) * (p4.y - p3.y) - (p4.x - p3.x) * (p2.y - p3.y);
		if((crossP1 > 0 && crossP2 < 0) || (crossP1 < 0 && crossP2 > 0))
			return YES;
		else
			return NO;
	} else
		return NO;
} 

	

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.