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

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

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

#import "MiscDiagramShape.h"
#import "MiscCircleShape.h"
#import "MiscCylinderShape.h"
#import "MiscDiamondShape.h"
#import "MiscHexagonShape.h"
#import "MiscHorizontalArrowShape.h"
#import "MiscHorizontalTriangleShape.h"
//#import "MiscParallelLinesShape.h"
#import "MiscParallelogramShape.h"
#import "MiscRectangleShape.h"
#import "MiscRoundedRectShape.h"
#import "MiscVerticalArrowShape.h"
#import "MiscVerticalTriangleShape.h"								 

@implementation MiscDiagramShape
/*"The MiscDiagramShape class cluster manages shapes equivalent to the symbols 
found in Diagram(tm) from Lighthouse Design.


The shape type of an MiscDiagramShape instance cannot be changed. You have to instantiate
a new instance with the appropiate shape and the bounds of the old instance.

A MiscDiagramShape instance can be moved with #moveTo: and resized with #sizeTo: and #innerSizeTo:. 
The method #bounds returns the shape bounds
and #innerBounds returns the bounds of a rectangle of maximum size inscribed in the shape.
The class method #calcSizeForInnerSize: gives the minimal size for a shape type such that a
rectangle of a given size can be fully inscribed.
The bounds and innerBounds are defined like this:

Shapes can be drawn in a view with #drawOutline, #drawFill and #drawShadowWithDelta:.

The method #hit provides hit detection with a hit path and the method #calcIntersection:angle:toPoint:
calculates the intersection of a shape with a line running through the shape's middle.
The angle of the intersection is given in degrees and is defined like this: 

"*/ 

 

+ newWithZone:(NSZone *)aZone shapeType:(MiscShapeType)aShapeType bounds:(NSRect)aRect
/*"Creates and returns a new MiscDiagramShape instance of type aShapeType and bounds aRect.
Note, the returned instance is not autoreleased. You are responsible for releasing it.
Use #shapeOfType:bounds: if you want an autoreleased shape."*/
{
	switch(aShapeType){
		case MiscCircleShapeType:
			return [[MiscCircleShape allocWithZone:aZone] initBounds:aRect];
		case MiscCylinderShapeType:
			return [[MiscCylinderShape allocWithZone:aZone] initBounds:aRect];
		case MiscDiamondShapeType:
			return [[MiscDiamondShape allocWithZone:aZone] initBounds:aRect];
		case MiscHexagonShapeType:	
			return [[MiscHexagonShape allocWithZone:aZone] initBounds:aRect];
		case MiscHorizontalArrowShapeType:
			return [[MiscHorizontalArrowShape allocWithZone:aZone] initBounds:aRect];
		case MiscHorizontalTriangleShapeType:
			return [[MiscHorizontalTriangleShape allocWithZone:aZone] initBounds:aRect];
		case MiscParallelLinesShapeType:
		//	return [[MiscParallelLinesShape allocWithZone:aZone] initBounds:aRect];
		case MiscParallelogramShapeType:
			return [[MiscParallelogramShape allocWithZone:aZone] initBounds:aRect];
		case MiscRectangleShapeType:
			return [[MiscRectangleShape allocWithZone:aZone] initBounds:aRect];
		case MiscRoundedRectShapeType:
			return [[MiscRoundedRectShape allocWithZone:aZone] initBounds:aRect];
		case MiscVerticalArrowShapeType:
			return [[MiscVerticalArrowShape allocWithZone:aZone] initBounds:aRect];
		case MiscVerticalTriangleShapeType:
			return [[MiscVerticalTriangleShape allocWithZone:aZone] initBounds:aRect];
	}
}

+ shapeOfType:(MiscShapeType)aShapeType bounds:(NSRect)aRect
/*"Creates and returns a new MiscDiagramShape instance of type aShapeType and bounds aRect."*/
{
	return [[self newWithZone:[self zone] shapeType:aShapeType bounds:aRect] autorelease];
}

// ******************************************************************
// placeholders, not very interesting

- (NSRect)bounds
/*"Returns the bounds of the receiver. See figure above for the 
difference between bounds and inner bounds."*/
{
	return NSMakeRect(0,0,0,0);
}

- (NSRect)innerBounds
/*"Returns the inner bounds of the receiver. See figure above for the 
difference between bounds and inner bounds."*/

{
	return NSMakeRect(0,0,0,0);
}

- (MiscShapeType)shapeType
/*"Returns the shape type of the receiver."*/
{
	return MiscCircleShapeType;
}


- (void)moveTo:(NSPoint)aPos
/*"Moves the receiver to point aPos."*/
{
	return;
}

- (void)sizeTo:(NSSize)aSize
/*"Changes size of receiver to aSize. See figure above for the 
difference between bounds and inner bounds."*/
{
	return;
}

- (void)innerSizeTo:(NSSize)aSize
/*"Changes inner size of receiver to aSize. See figure above for the 
difference between bounds and inner bounds."*/
{
	return;
}

- (void)calcIntersection:(NSPoint *)ip angle:(float *)alpha toPoint:(NSPoint)aPoint
/*"Calculates the intersection of a line running through aPoint and the middle point of the
receiver's bounds with the receiver's outline. The resulting intersection point is placed 
in ip and the resulting intersection angle (given in degrees) in alpha. See figure above
for a definition of the intersection angle."*/
{
	return;
}

+ (NSSize)calcSizeForInnerSize:(NSSize)aSize shapeType:(MiscShapeType)aShapeType
/*"Calculates the minimal size for a shape of type aShapeType such that a rectangle 
of size aSize can be inscribed in the shape."*/ 
{
	switch(aShapeType){
		case MiscCircleShapeType:
			return [MiscCircleShape calcSizeForInnerSize:aSize];
		case MiscCylinderShapeType:
			return [MiscCylinderShape calcSizeForInnerSize:aSize];
		case MiscDiamondShapeType:
			return [MiscDiamondShape calcSizeForInnerSize:aSize];
		case MiscHexagonShapeType:	
			return [MiscHexagonShape calcSizeForInnerSize:aSize];
		case MiscHorizontalArrowShapeType:
			return [MiscHorizontalArrowShape calcSizeForInnerSize:aSize];
		case MiscHorizontalTriangleShapeType:
			return [MiscHorizontalTriangleShape calcSizeForInnerSize:aSize];
		case MiscParallelLinesShapeType:
		//	return [MiscParallelLinesShape calcSizeForInnerSize:aSize];
		case MiscParallelogramShapeType:
			return [MiscParallelogramShape calcSizeForInnerSize:aSize];
		case MiscRectangleShapeType:
			return [MiscRectangleShape calcSizeForInnerSize:aSize];
		case MiscRoundedRectShapeType:
			return [MiscRoundedRectShape calcSizeForInnerSize:aSize];
		case MiscVerticalArrowShapeType:
			return [MiscVerticalArrowShape calcSizeForInnerSize:aSize];
		case MiscVerticalTriangleShapeType:
			return [MiscVerticalTriangleShape calcSizeForInnerSize:aSize];
	}
}

- (void)drawOutline
/*"Draws the shape outline. The PostScript focus must be 
locked on a view when this method is invoked."*/
{
	return;
}

- (void)drawFill
/*"Draws the shape fill. The PostScript focus must be 
locked on a view when this method is invoked."*/
{
	return;
}

- (void)drawShadowWithDelta:(NSPoint)aPos
/*"Draws the shape fill with the receiver displaced with delta aPos. 
The PostScript focus must be locked on a view when this method is invoked."*/
{
	return;
}

- (BOOL)hit:(MiscHitPath *)hitPath
/*"Returns whether the hit path hitPath intersects the receiver.
The PostScript focus must be locked on a view when this method is invoked."*/
{
	return NO;
}

- initWithCoder:(NSCoder *)coder
{
	return [super initWithCoder:coder];
}

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

- copyWithZone:(NSZone *)aZone
{
	return nil;
}

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


	
