mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-25 18:21:08 +00:00
Affine transfor cleanups
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@24922 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
fa264ae202
commit
2901859f81
3 changed files with 48 additions and 46 deletions
|
@ -1,3 +1,11 @@
|
|||
2007-03-22 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSAffineTransform.m: Avoid accessing internals of the base
|
||||
library class directly. Mark many methods as deprecated.
|
||||
* Headers/AppKit/NSAffineTransform.h: Mark gnustep extensions as
|
||||
deprecated. Perhaps we don't want to deprecate all of them though
|
||||
need feedback on that.
|
||||
|
||||
2007-03-21 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* Source/NSView.m (-gState): Generate a gstate if one is needed
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
@end
|
||||
|
||||
#if OS_API_VERSION(GS_API_NONE, GS_API_NONE)
|
||||
#if GS_API_VERSION(GS_API_NONE, 011500)
|
||||
@interface NSAffineTransform (GNUstep)
|
||||
- (void) translateToPoint: (NSPoint)point;
|
||||
- (void) scaleTo: (float)sx : (float)sy;
|
||||
|
@ -74,5 +75,6 @@
|
|||
|
||||
@end
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif /* _GNUstep_H_NSAffineTransform */
|
||||
|
|
|
@ -40,13 +40,7 @@
|
|||
#include "AppKit/NSBezierPath.h"
|
||||
#include "AppKit/PSOperators.h"
|
||||
|
||||
typedef struct internal
|
||||
{
|
||||
@defs(NSAffineTransform)
|
||||
} *iptr;
|
||||
|
||||
/* Private definitions */
|
||||
#define matrix (((iptr)self)->_matrix)
|
||||
#define A matrix.m11
|
||||
#define B matrix.m12
|
||||
#define C matrix.m21
|
||||
|
@ -90,14 +84,9 @@ static NSAffineTransformStruct identityTransform = {
|
|||
*/
|
||||
- (void) concat
|
||||
{
|
||||
float m[6];
|
||||
m[0] = matrix.m11;
|
||||
m[1] = matrix.m12;
|
||||
m[2] = matrix.m21;
|
||||
m[3] = matrix.m22;
|
||||
m[4] = matrix.tX;
|
||||
m[5] = matrix.tY;
|
||||
PSconcat(m);
|
||||
NSAffineTransformStruct matrix = [self transformStruct];
|
||||
|
||||
PSconcat((float*)&matrix);
|
||||
}
|
||||
|
||||
|
||||
|
@ -130,6 +119,8 @@ static NSAffineTransformStruct identityTransform = {
|
|||
|
||||
- (void) scaleTo: (float)sx : (float)sy
|
||||
{
|
||||
NSAffineTransformStruct matrix = [self transformStruct];
|
||||
|
||||
/* If it's rotated. */
|
||||
if (B != 0 || C != 0)
|
||||
{
|
||||
|
@ -145,32 +136,30 @@ static NSAffineTransformStruct identityTransform = {
|
|||
A = sx; B = 0;
|
||||
C = 0; D = sy;
|
||||
}
|
||||
// FIXME
|
||||
_isIdentity = NO;
|
||||
_isFlipY = NO;
|
||||
[self setTransformStruct: matrix];
|
||||
}
|
||||
|
||||
- (void) translateToPoint: (NSPoint)point
|
||||
{
|
||||
NSAffineTransformStruct matrix = [self transformStruct];
|
||||
float newTX, newTY;
|
||||
|
||||
newTX = point.x * A + point.y * C + TX;
|
||||
newTY = point.x * B + point.y * D + TY;
|
||||
TX = newTX;
|
||||
TY = newTY;
|
||||
[self setTransformStruct: matrix];
|
||||
}
|
||||
|
||||
|
||||
- (void) makeIdentityMatrix
|
||||
{
|
||||
matrix = identityTransform;
|
||||
// FIXME
|
||||
_isIdentity = YES;
|
||||
_isFlipY = NO;
|
||||
[self setTransformStruct: identityTransform];
|
||||
}
|
||||
|
||||
- (void) setFrameOrigin: (NSPoint)point
|
||||
{
|
||||
NSAffineTransformStruct matrix = [self transformStruct];
|
||||
float dx = point.x - TX;
|
||||
float dy = point.y - TY;
|
||||
[self translateToPoint: NSMakePoint(dx, dy)];
|
||||
|
@ -183,7 +172,9 @@ static NSAffineTransformStruct identityTransform = {
|
|||
|
||||
- (float) rotationAngle
|
||||
{
|
||||
NSAffineTransformStruct matrix = [self transformStruct];
|
||||
float rotationAngle = atan2(-C, A);
|
||||
|
||||
rotationAngle *= 180.0 / pi;
|
||||
if (rotationAngle < 0.0)
|
||||
rotationAngle += 360.0;
|
||||
|
@ -193,12 +184,16 @@ static NSAffineTransformStruct identityTransform = {
|
|||
|
||||
- (void) concatenateWith: (NSAffineTransform*)anotherMatrix
|
||||
{
|
||||
GSOnceMLog(@"deprecated ... use -prependTransform:");
|
||||
[self prependTransform: anotherMatrix];
|
||||
}
|
||||
|
||||
- (void) concatenateWithMatrix: (const float[6])anotherMatrix
|
||||
{
|
||||
NSAffineTransformStruct matrix = [self transformStruct];
|
||||
NSAffineTransformStruct amat;
|
||||
|
||||
GSOnceMLog(@"deprecated ... use -prependTransform:");
|
||||
amat.m11 = anotherMatrix[0];
|
||||
amat.m12 = anotherMatrix[1];
|
||||
amat.m21 = anotherMatrix[2];
|
||||
|
@ -206,18 +201,19 @@ static NSAffineTransformStruct identityTransform = {
|
|||
amat.tX = anotherMatrix[4];
|
||||
amat.tY = anotherMatrix[5];
|
||||
matrix = matrix_multiply(amat, matrix);
|
||||
// FIXME
|
||||
_isIdentity = NO;
|
||||
_isFlipY = NO;
|
||||
[self setTransformStruct: matrix];
|
||||
}
|
||||
|
||||
- (void)inverse
|
||||
{
|
||||
GSOnceMLog(@"deprecated ... use -invert:");
|
||||
[self invert];
|
||||
}
|
||||
|
||||
- (BOOL) isRotated
|
||||
{
|
||||
NSAffineTransformStruct matrix = [self transformStruct];
|
||||
|
||||
if (B == 0 && C == 0)
|
||||
{
|
||||
return NO;
|
||||
|
@ -230,6 +226,7 @@ static NSAffineTransformStruct identityTransform = {
|
|||
|
||||
- (void) boundingRectFor: (NSRect)rect result: (NSRect*)newRect
|
||||
{
|
||||
NSAffineTransformStruct matrix = [self transformStruct];
|
||||
/* Shortcuts of the usual rect values */
|
||||
float x = rect.origin.x;
|
||||
float y = rect.origin.y;
|
||||
|
@ -276,16 +273,13 @@ static NSAffineTransformStruct identityTransform = {
|
|||
|
||||
- (NSPoint) pointInMatrixSpace: (NSPoint)point
|
||||
{
|
||||
NSPoint new;
|
||||
|
||||
new.x = A * point.x + C * point.y + TX;
|
||||
new.y = B * point.x + D * point.y + TY;
|
||||
|
||||
return new;
|
||||
GSOnceMLog(@"deprecated ... use -transformPoint:");
|
||||
return [self transformPoint: point];
|
||||
}
|
||||
|
||||
- (NSPoint) deltaPointInMatrixSpace: (NSPoint)point
|
||||
{
|
||||
NSAffineTransformStruct matrix = [self transformStruct];
|
||||
NSPoint new;
|
||||
|
||||
new.x = A * point.x + C * point.y;
|
||||
|
@ -296,20 +290,13 @@ static NSAffineTransformStruct identityTransform = {
|
|||
|
||||
- (NSSize) sizeInMatrixSpace: (NSSize)size
|
||||
{
|
||||
NSSize new;
|
||||
|
||||
new.width = A * size.width + C * size.height;
|
||||
if (new.width < 0)
|
||||
new.width = - new.width;
|
||||
new.height = B * size.width + D * size.height;
|
||||
if (new.height < 0)
|
||||
new.height = - new.height;
|
||||
|
||||
return new;
|
||||
GSOnceMLog(@"deprecated ... use -transformSize:");
|
||||
return [self transformSize: size];
|
||||
}
|
||||
|
||||
- (NSRect) rectInMatrixSpace: (NSRect)rect
|
||||
{
|
||||
NSAffineTransformStruct matrix = [self transformStruct];
|
||||
NSRect new;
|
||||
|
||||
new.origin.x = A * rect.origin.x + C * rect.origin.y + TX;
|
||||
|
@ -333,19 +320,23 @@ static NSAffineTransformStruct identityTransform = {
|
|||
|
||||
- (void) setMatrix: (const float[6])replace
|
||||
{
|
||||
NSAffineTransformStruct matrix;
|
||||
|
||||
GSOnceMLog(@"deprecated ... use -setTransformStruct:");
|
||||
matrix.m11 = replace[0];
|
||||
matrix.m12 = replace[1];
|
||||
matrix.m21 = replace[2];
|
||||
matrix.m22 = replace[3];
|
||||
matrix.tX = replace[4];
|
||||
matrix.tY = replace[5];
|
||||
// FIXME
|
||||
_isIdentity = NO;
|
||||
_isFlipY = NO;
|
||||
[self setTransformStruct: matrix];
|
||||
}
|
||||
|
||||
- (void) getMatrix: (float[6])replace
|
||||
{
|
||||
NSAffineTransformStruct matrix = [self transformStruct];
|
||||
|
||||
GSOnceMLog(@"deprecated ... use -transformStruct");
|
||||
replace[0] = matrix.m11;
|
||||
replace[1] = matrix.m12;
|
||||
replace[2] = matrix.m21;
|
||||
|
@ -356,10 +347,11 @@ static NSAffineTransformStruct identityTransform = {
|
|||
|
||||
- (void) takeMatrixFromTransform: (NSAffineTransform *)aTransform
|
||||
{
|
||||
NSAffineTransformStruct matrix;
|
||||
|
||||
GSOnceMLog(@"deprecated ... use -transformStruct and setTransformStruct:");
|
||||
matrix = [aTransform transformStruct];
|
||||
// FIXME
|
||||
_isIdentity = NO;
|
||||
_isFlipY = NO;
|
||||
[self setTransformStruct: matrix];
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue