blob: 1b0108a494958cc4052372c589c130b02fff5e0c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
|
//
// Transformer.h
// TikZiT
//
// Copyright 2010 Aleks Kissinger. All rights reserved.
//
//
// This file is part of TikZiT.
//
// TikZiT is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// TikZiT is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with TikZiT. If not, see <http://www.gnu.org/licenses/>.
//
#import <Foundation/Foundation.h>
extern float const PIXELS_PER_UNIT;
/*!
@class Transformer
@brief Do affine coordinate transforms between an abstract co-ordinate
space (such as the graph's) and the screen's.
This currently allows zooming and panning.
*/
@interface Transformer : NSObject <NSCopying> {
NSPoint origin;
float x_scale;
float y_scale;
}
/*!
@brief The screen co-ordinate of the abstract space origin.
*/
@property (assign) NSPoint origin;
/*!
@brief The scale (from abstract space to screen space)
@detail This is the size of a single unit (a distance of 1.0)
of the abstract space on the screen.
Around 50 is a reasonable value.
*/
@property (assign) float scale;
/*!
@brief Whether co-ordinates are flipped about the X axis
@detail TikZ considers X co-ordinates to run left to right,
which is not necessarily how the screen views
them.
*/
@property (assign,getter=isFlippedAboutXAxis) BOOL flippedAboutXAxis;
/*!
@brief Whether co-ordinates are flipped about the Y axis
@detail TikZ considers Y co-ordinates to run up the page,
which is not necessarily how the screen views
them.
*/
@property (assign,getter=isFlippedAboutYAxis) BOOL flippedAboutYAxis;
/*!
@brief Transform a point from screen space to abstract space.
@param p a point in screen space.
@result A point in abstract space.
*/
- (NSPoint)fromScreen:(NSPoint)p;
/*!
@brief Transform a point from abstract space to screen space.
@param p a point in abstract space.
@result A point in screen space.
*/
- (NSPoint)toScreen:(NSPoint)p;
/*!
@brief Scale a distance from screen space to abstract space.
@param dist a distance in screen space.
@result A distance in abstract space.
*/
- (float)scaleFromScreen:(float)dist;
/*!
@brief Scale a distance from abstract space to screen space.
@param dist a distance in abstract space.
@result A distance in screen space.
*/
- (float)scaleToScreen:(float)dist;
/*!
@brief Scale a rectangle from screen space to abstract space.
@param r a rectangle in screen space.
@result A rectangle in abstract space.
*/
- (NSRect)rectFromScreen:(NSRect)r;
/*!
@brief Scale a rectangle from abstract space to screen space.
@param r a rectangle in abstract space.
@result A rectangle in screen space.
*/
- (NSRect)rectToScreen:(NSRect)r;
/*!
@brief Factory method to get an identity transformer.
@result A transformer.
*/
+ (Transformer*)transformer;
/*!
@brief Factory method to get a transformer identical to another
@result A transformer.
*/
+ (Transformer*)transformerWithTransformer:(Transformer*)t;
/*!
@brief Factory method to get a transformer.
@param o The screen co-ordinate of the abstract space origin
@param scale The scale (from abstract space to screen space)
@result A transformer.
*/
+ (Transformer*)transformerWithOrigin:(NSPoint)o andScale:(float)scale;
/*!
@brief Get a global 'actual size' transformer.
@result A transformer.
*/
+ (Transformer*)defaultTransformer;
/*!
@brief A transformer set up from two bounding rects.
graphRect is made as large as possible while still fitting into screenRect.
@result A transformer.
*/
+ (Transformer*)transformerToFit:(NSRect)graphRect intoScreenRect:(NSRect)screenRect flippedAboutXAxis:(BOOL)flipX flippedAboutYAxis:(BOOL)flipY;
+ (Transformer*)transformerToFit:(NSRect)graphRect intoScreenRect:(NSRect)screenRect flippedAboutXAxis:(BOOL)flipX;
+ (Transformer*)transformerToFit:(NSRect)graphRect intoScreenRect:(NSRect)screenRect flippedAboutYAxis:(BOOL)flipY;
+ (Transformer*)transformerToFit:(NSRect)graphRect intoScreenRect:(NSRect)screenRect;
@end
// vi:ft=objc:noet:ts=4:sts=4:sw=4
|