mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-26 00:50:56 +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>
|
2007-03-21 Fred Kiefer <FredKiefer@gmx.de>
|
||||||
|
|
||||||
* Source/NSView.m (-gState): Generate a gstate if one is needed
|
* Source/NSView.m (-gState): Generate a gstate if one is needed
|
||||||
|
|
|
@ -41,6 +41,7 @@
|
||||||
@end
|
@end
|
||||||
|
|
||||||
#if OS_API_VERSION(GS_API_NONE, GS_API_NONE)
|
#if OS_API_VERSION(GS_API_NONE, GS_API_NONE)
|
||||||
|
#if GS_API_VERSION(GS_API_NONE, 011500)
|
||||||
@interface NSAffineTransform (GNUstep)
|
@interface NSAffineTransform (GNUstep)
|
||||||
- (void) translateToPoint: (NSPoint)point;
|
- (void) translateToPoint: (NSPoint)point;
|
||||||
- (void) scaleTo: (float)sx : (float)sy;
|
- (void) scaleTo: (float)sx : (float)sy;
|
||||||
|
@ -74,5 +75,6 @@
|
||||||
|
|
||||||
@end
|
@end
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* _GNUstep_H_NSAffineTransform */
|
#endif /* _GNUstep_H_NSAffineTransform */
|
||||||
|
|
|
@ -40,13 +40,7 @@
|
||||||
#include "AppKit/NSBezierPath.h"
|
#include "AppKit/NSBezierPath.h"
|
||||||
#include "AppKit/PSOperators.h"
|
#include "AppKit/PSOperators.h"
|
||||||
|
|
||||||
typedef struct internal
|
|
||||||
{
|
|
||||||
@defs(NSAffineTransform)
|
|
||||||
} *iptr;
|
|
||||||
|
|
||||||
/* Private definitions */
|
/* Private definitions */
|
||||||
#define matrix (((iptr)self)->_matrix)
|
|
||||||
#define A matrix.m11
|
#define A matrix.m11
|
||||||
#define B matrix.m12
|
#define B matrix.m12
|
||||||
#define C matrix.m21
|
#define C matrix.m21
|
||||||
|
@ -90,14 +84,9 @@ static NSAffineTransformStruct identityTransform = {
|
||||||
*/
|
*/
|
||||||
- (void) concat
|
- (void) concat
|
||||||
{
|
{
|
||||||
float m[6];
|
NSAffineTransformStruct matrix = [self transformStruct];
|
||||||
m[0] = matrix.m11;
|
|
||||||
m[1] = matrix.m12;
|
PSconcat((float*)&matrix);
|
||||||
m[2] = matrix.m21;
|
|
||||||
m[3] = matrix.m22;
|
|
||||||
m[4] = matrix.tX;
|
|
||||||
m[5] = matrix.tY;
|
|
||||||
PSconcat(m);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -130,6 +119,8 @@ static NSAffineTransformStruct identityTransform = {
|
||||||
|
|
||||||
- (void) scaleTo: (float)sx : (float)sy
|
- (void) scaleTo: (float)sx : (float)sy
|
||||||
{
|
{
|
||||||
|
NSAffineTransformStruct matrix = [self transformStruct];
|
||||||
|
|
||||||
/* If it's rotated. */
|
/* If it's rotated. */
|
||||||
if (B != 0 || C != 0)
|
if (B != 0 || C != 0)
|
||||||
{
|
{
|
||||||
|
@ -145,32 +136,30 @@ static NSAffineTransformStruct identityTransform = {
|
||||||
A = sx; B = 0;
|
A = sx; B = 0;
|
||||||
C = 0; D = sy;
|
C = 0; D = sy;
|
||||||
}
|
}
|
||||||
// FIXME
|
[self setTransformStruct: matrix];
|
||||||
_isIdentity = NO;
|
|
||||||
_isFlipY = NO;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) translateToPoint: (NSPoint)point
|
- (void) translateToPoint: (NSPoint)point
|
||||||
{
|
{
|
||||||
|
NSAffineTransformStruct matrix = [self transformStruct];
|
||||||
float newTX, newTY;
|
float newTX, newTY;
|
||||||
|
|
||||||
newTX = point.x * A + point.y * C + TX;
|
newTX = point.x * A + point.y * C + TX;
|
||||||
newTY = point.x * B + point.y * D + TY;
|
newTY = point.x * B + point.y * D + TY;
|
||||||
TX = newTX;
|
TX = newTX;
|
||||||
TY = newTY;
|
TY = newTY;
|
||||||
|
[self setTransformStruct: matrix];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
- (void) makeIdentityMatrix
|
- (void) makeIdentityMatrix
|
||||||
{
|
{
|
||||||
matrix = identityTransform;
|
[self setTransformStruct: identityTransform];
|
||||||
// FIXME
|
|
||||||
_isIdentity = YES;
|
|
||||||
_isFlipY = NO;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) setFrameOrigin: (NSPoint)point
|
- (void) setFrameOrigin: (NSPoint)point
|
||||||
{
|
{
|
||||||
|
NSAffineTransformStruct matrix = [self transformStruct];
|
||||||
float dx = point.x - TX;
|
float dx = point.x - TX;
|
||||||
float dy = point.y - TY;
|
float dy = point.y - TY;
|
||||||
[self translateToPoint: NSMakePoint(dx, dy)];
|
[self translateToPoint: NSMakePoint(dx, dy)];
|
||||||
|
@ -183,7 +172,9 @@ static NSAffineTransformStruct identityTransform = {
|
||||||
|
|
||||||
- (float) rotationAngle
|
- (float) rotationAngle
|
||||||
{
|
{
|
||||||
|
NSAffineTransformStruct matrix = [self transformStruct];
|
||||||
float rotationAngle = atan2(-C, A);
|
float rotationAngle = atan2(-C, A);
|
||||||
|
|
||||||
rotationAngle *= 180.0 / pi;
|
rotationAngle *= 180.0 / pi;
|
||||||
if (rotationAngle < 0.0)
|
if (rotationAngle < 0.0)
|
||||||
rotationAngle += 360.0;
|
rotationAngle += 360.0;
|
||||||
|
@ -193,12 +184,16 @@ static NSAffineTransformStruct identityTransform = {
|
||||||
|
|
||||||
- (void) concatenateWith: (NSAffineTransform*)anotherMatrix
|
- (void) concatenateWith: (NSAffineTransform*)anotherMatrix
|
||||||
{
|
{
|
||||||
|
GSOnceMLog(@"deprecated ... use -prependTransform:");
|
||||||
[self prependTransform: anotherMatrix];
|
[self prependTransform: anotherMatrix];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) concatenateWithMatrix: (const float[6])anotherMatrix
|
- (void) concatenateWithMatrix: (const float[6])anotherMatrix
|
||||||
{
|
{
|
||||||
|
NSAffineTransformStruct matrix = [self transformStruct];
|
||||||
NSAffineTransformStruct amat;
|
NSAffineTransformStruct amat;
|
||||||
|
|
||||||
|
GSOnceMLog(@"deprecated ... use -prependTransform:");
|
||||||
amat.m11 = anotherMatrix[0];
|
amat.m11 = anotherMatrix[0];
|
||||||
amat.m12 = anotherMatrix[1];
|
amat.m12 = anotherMatrix[1];
|
||||||
amat.m21 = anotherMatrix[2];
|
amat.m21 = anotherMatrix[2];
|
||||||
|
@ -206,18 +201,19 @@ static NSAffineTransformStruct identityTransform = {
|
||||||
amat.tX = anotherMatrix[4];
|
amat.tX = anotherMatrix[4];
|
||||||
amat.tY = anotherMatrix[5];
|
amat.tY = anotherMatrix[5];
|
||||||
matrix = matrix_multiply(amat, matrix);
|
matrix = matrix_multiply(amat, matrix);
|
||||||
// FIXME
|
[self setTransformStruct: matrix];
|
||||||
_isIdentity = NO;
|
|
||||||
_isFlipY = NO;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)inverse
|
- (void)inverse
|
||||||
{
|
{
|
||||||
|
GSOnceMLog(@"deprecated ... use -invert:");
|
||||||
[self invert];
|
[self invert];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL) isRotated
|
- (BOOL) isRotated
|
||||||
{
|
{
|
||||||
|
NSAffineTransformStruct matrix = [self transformStruct];
|
||||||
|
|
||||||
if (B == 0 && C == 0)
|
if (B == 0 && C == 0)
|
||||||
{
|
{
|
||||||
return NO;
|
return NO;
|
||||||
|
@ -230,6 +226,7 @@ static NSAffineTransformStruct identityTransform = {
|
||||||
|
|
||||||
- (void) boundingRectFor: (NSRect)rect result: (NSRect*)newRect
|
- (void) boundingRectFor: (NSRect)rect result: (NSRect*)newRect
|
||||||
{
|
{
|
||||||
|
NSAffineTransformStruct matrix = [self transformStruct];
|
||||||
/* Shortcuts of the usual rect values */
|
/* Shortcuts of the usual rect values */
|
||||||
float x = rect.origin.x;
|
float x = rect.origin.x;
|
||||||
float y = rect.origin.y;
|
float y = rect.origin.y;
|
||||||
|
@ -276,16 +273,13 @@ static NSAffineTransformStruct identityTransform = {
|
||||||
|
|
||||||
- (NSPoint) pointInMatrixSpace: (NSPoint)point
|
- (NSPoint) pointInMatrixSpace: (NSPoint)point
|
||||||
{
|
{
|
||||||
NSPoint new;
|
GSOnceMLog(@"deprecated ... use -transformPoint:");
|
||||||
|
return [self transformPoint: point];
|
||||||
new.x = A * point.x + C * point.y + TX;
|
|
||||||
new.y = B * point.x + D * point.y + TY;
|
|
||||||
|
|
||||||
return new;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSPoint) deltaPointInMatrixSpace: (NSPoint)point
|
- (NSPoint) deltaPointInMatrixSpace: (NSPoint)point
|
||||||
{
|
{
|
||||||
|
NSAffineTransformStruct matrix = [self transformStruct];
|
||||||
NSPoint new;
|
NSPoint new;
|
||||||
|
|
||||||
new.x = A * point.x + C * point.y;
|
new.x = A * point.x + C * point.y;
|
||||||
|
@ -296,20 +290,13 @@ static NSAffineTransformStruct identityTransform = {
|
||||||
|
|
||||||
- (NSSize) sizeInMatrixSpace: (NSSize)size
|
- (NSSize) sizeInMatrixSpace: (NSSize)size
|
||||||
{
|
{
|
||||||
NSSize new;
|
GSOnceMLog(@"deprecated ... use -transformSize:");
|
||||||
|
return [self transformSize: size];
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSRect) rectInMatrixSpace: (NSRect)rect
|
- (NSRect) rectInMatrixSpace: (NSRect)rect
|
||||||
{
|
{
|
||||||
|
NSAffineTransformStruct matrix = [self transformStruct];
|
||||||
NSRect new;
|
NSRect new;
|
||||||
|
|
||||||
new.origin.x = A * rect.origin.x + C * rect.origin.y + TX;
|
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
|
- (void) setMatrix: (const float[6])replace
|
||||||
{
|
{
|
||||||
|
NSAffineTransformStruct matrix;
|
||||||
|
|
||||||
|
GSOnceMLog(@"deprecated ... use -setTransformStruct:");
|
||||||
matrix.m11 = replace[0];
|
matrix.m11 = replace[0];
|
||||||
matrix.m12 = replace[1];
|
matrix.m12 = replace[1];
|
||||||
matrix.m21 = replace[2];
|
matrix.m21 = replace[2];
|
||||||
matrix.m22 = replace[3];
|
matrix.m22 = replace[3];
|
||||||
matrix.tX = replace[4];
|
matrix.tX = replace[4];
|
||||||
matrix.tY = replace[5];
|
matrix.tY = replace[5];
|
||||||
// FIXME
|
[self setTransformStruct: matrix];
|
||||||
_isIdentity = NO;
|
|
||||||
_isFlipY = NO;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) getMatrix: (float[6])replace
|
- (void) getMatrix: (float[6])replace
|
||||||
{
|
{
|
||||||
|
NSAffineTransformStruct matrix = [self transformStruct];
|
||||||
|
|
||||||
|
GSOnceMLog(@"deprecated ... use -transformStruct");
|
||||||
replace[0] = matrix.m11;
|
replace[0] = matrix.m11;
|
||||||
replace[1] = matrix.m12;
|
replace[1] = matrix.m12;
|
||||||
replace[2] = matrix.m21;
|
replace[2] = matrix.m21;
|
||||||
|
@ -356,10 +347,11 @@ static NSAffineTransformStruct identityTransform = {
|
||||||
|
|
||||||
- (void) takeMatrixFromTransform: (NSAffineTransform *)aTransform
|
- (void) takeMatrixFromTransform: (NSAffineTransform *)aTransform
|
||||||
{
|
{
|
||||||
|
NSAffineTransformStruct matrix;
|
||||||
|
|
||||||
|
GSOnceMLog(@"deprecated ... use -transformStruct and setTransformStruct:");
|
||||||
matrix = [aTransform transformStruct];
|
matrix = [aTransform transformStruct];
|
||||||
// FIXME
|
[self setTransformStruct: matrix];
|
||||||
_isIdentity = NO;
|
|
||||||
_isFlipY = NO;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue