source: orbit/iOS/Orbit/Orbit/CorePlotHeaders/CPTPlot.h @ e5b8e57

ServoTab_Interfacepyramid
Last change on this file since e5b8e57 was a9059a5, checked in by Steve Castellotti <sc@…>, 10 years ago

Arduino:

  • updated to permit custom setting of Throttle, Yaw, and Pitch

Android:

  • Minor tweak to Configuration location

iOS:

  • Property mode set to 100644
File size: 10.7 KB
Line 
1#import "CPTAnnotationHostLayer.h"
2#import "CPTDefinitions.h"
3#import "CPTMutableTextStyle.h"
4#import "CPTNumericDataType.h"
5#import "CPTPlotRange.h"
6
7/// @file
8
9@class CPTLegend;
10@class CPTMutableNumericData;
11@class CPTNumericData;
12@class CPTPlot;
13@class CPTPlotArea;
14@class CPTPlotSpace;
15@class CPTPlotSpaceAnnotation;
16@class CPTPlotRange;
17
18/// @ingroup plotBindingsAllPlots
19/// @{
20extern NSString *const CPTPlotBindingDataLabels;
21/// @}
22
23/**
24 *  @brief Enumeration of cache precisions.
25 **/
26typedef enum _CPTPlotCachePrecision {
27    CPTPlotCachePrecisionAuto,   ///< Cache precision is determined automatically from the data. All cached data will be converted to match the last data loaded.
28    CPTPlotCachePrecisionDouble, ///< All cached data will be converted to double precision.
29    CPTPlotCachePrecisionDecimal ///< All cached data will be converted to @ref NSDecimal.
30}
31CPTPlotCachePrecision;
32
33#pragma mark -
34
35/**
36 *  @brief A plot data source.
37 **/
38@protocol CPTPlotDataSource<NSObject>
39
40/// @name Data Values
41/// @{
42
43/** @brief @required The number of data points for the plot.
44 *  @param plot The plot.
45 *  @return The number of data points for the plot.
46 **/
47-(NSUInteger)numberOfRecordsForPlot:(CPTPlot *)plot;
48
49@optional
50
51/** @brief @optional Gets a range of plot data for the given plot and field.
52 *  Implement one and only one of the optional methods in this section.
53 *  @param plot The plot.
54 *  @param fieldEnum The field index.
55 *  @param indexRange The range of the data indexes of interest.
56 *  @return An array of data points.
57 **/
58-(NSArray *)numbersForPlot:(CPTPlot *)plot field:(NSUInteger)fieldEnum recordIndexRange:(NSRange)indexRange;
59
60/** @brief @optional Gets a plot data value for the given plot and field.
61 *  Implement one and only one of the optional methods in this section.
62 *  @param plot The plot.
63 *  @param fieldEnum The field index.
64 *  @param idx The data index of interest.
65 *  @return A data point.
66 **/
67-(NSNumber *)numberForPlot:(CPTPlot *)plot field:(NSUInteger)fieldEnum recordIndex:(NSUInteger)idx;
68
69/** @brief @optional Gets a range of plot data for the given plot and field.
70 *  Implement one and only one of the optional methods in this section.
71 *  @param plot The plot.
72 *  @param fieldEnum The field index.
73 *  @param indexRange The range of the data indexes of interest.
74 *  @return A retained C array of data points.
75 **/
76-(double *)doublesForPlot:(CPTPlot *)plot field:(NSUInteger)fieldEnum recordIndexRange:(NSRange)indexRange;
77
78/** @brief @optional Gets a plot data value for the given plot and field.
79 *  Implement one and only one of the optional methods in this section.
80 *  @param plot The plot.
81 *  @param fieldEnum The field index.
82 *  @param idx The data index of interest.
83 *  @return A data point.
84 **/
85-(double)doubleForPlot:(CPTPlot *)plot field:(NSUInteger)fieldEnum recordIndex:(NSUInteger)idx;
86
87/** @brief @optional Gets a range of plot data for the given plot and field.
88 *  Implement one and only one of the optional methods in this section.
89 *  @param plot The plot.
90 *  @param fieldEnum The field index.
91 *  @param indexRange The range of the data indexes of interest.
92 *  @return A one-dimensional array of data points.
93 **/
94-(CPTNumericData *)dataForPlot:(CPTPlot *)plot field:(NSUInteger)fieldEnum recordIndexRange:(NSRange)indexRange;
95
96/** @brief @optional Gets a range of plot data for all fields of the given plot simultaneously.
97 *  Implement one and only one of the optional methods in this section.
98 *
99 *  The data returned from this method should be a two-dimensional array. It can be arranged
100 *  in row- or column-major order although column-major will load faster, especially for large arrays.
101 *  The array should have the same number of rows as the length of @par{indexRange}.
102 *  The number of columns should be equal to the number of plot fields required by the plot.
103 *  The column index (zero-based) corresponds with the field index.
104 *  The data type will be converted to match the @link CPTPlot::cachePrecision cachePrecision @endlink if needed.
105 *
106 *  @param plot The plot.
107 *  @param indexRange The range of the data indexes of interest.
108 *  @return A two-dimensional array of data points.
109 **/
110-(CPTNumericData *)dataForPlot:(CPTPlot *)plot recordIndexRange:(NSRange)indexRange;
111
112/// @}
113
114/// @name Data Labels
115/// @{
116
117/** @brief @optional Gets a range of data labels for the given plot.
118 *  @param plot The plot.
119 *  @param indexRange The range of the data indexes of interest.
120 *  @return An array of data labels.
121 **/
122-(NSArray *)dataLabelsForPlot:(CPTPlot *)plot recordIndexRange:(NSRange)indexRange;
123
124/** @brief @optional Gets a data label for the given plot.
125 *  This method will not be called if
126 *  @link CPTPlotDataSource::dataLabelsForPlot:recordIndexRange: -dataLabelsForPlot:recordIndexRange: @endlink
127 *  is also implemented in the datasource.
128 *  @param plot The plot.
129 *  @param idx The data index of interest.
130 *  @return The data label for the point with the given index.
131 *  If you return @nil, the default data label will be used. If you return an instance of NSNull,
132 *  no label will be shown for the index in question.
133 **/
134-(CPTLayer *)dataLabelForPlot:(CPTPlot *)plot recordIndex:(NSUInteger)idx;
135
136/// @}
137
138@end
139
140#pragma mark -
141
142/**
143 *  @brief Plot delegate.
144 **/
145@protocol CPTPlotDelegate<NSObject>
146
147@optional
148
149/// @name Point Selection
150/// @{
151
152/** @brief @optional Informs the delegate that a data label was
153 *  @if MacOnly clicked. @endif
154 *  @if iOSOnly touched. @endif
155 *  @param plot The plot.
156 *  @param idx The index of the
157 *  @if MacOnly clicked data label. @endif
158 *  @if iOSOnly touched data label. @endif
159 **/
160-(void)plot:(CPTPlot *)plot dataLabelWasSelectedAtRecordIndex:(NSUInteger)idx;
161
162/** @brief @optional Informs the delegate that a data label was
163 *  @if MacOnly clicked. @endif
164 *  @if iOSOnly touched. @endif
165 *  @param plot The plot.
166 *  @param idx The index of the
167 *  @if MacOnly clicked data label. @endif
168 *  @if iOSOnly touched data label. @endif
169 *  @param event The event that triggered the selection.
170 **/
171-(void)plot:(CPTPlot *)plot dataLabelWasSelectedAtRecordIndex:(NSUInteger)idx withEvent:(CPTNativeEvent *)event;
172
173/// @}
174
175/// @name Drawing
176/// @{
177
178/**
179 *  @brief @optional Informs the delegate that plot drawing is finished.
180 *  @param plot The plot.
181 **/
182-(void)didFinishDrawing:(CPTPlot *)plot;
183
184/// @}
185
186@end
187
188#pragma mark -
189
190@interface CPTPlot : CPTAnnotationHostLayer {
191    @private
192    __cpt_weak id<CPTPlotDataSource> dataSource;
193    NSString *title;
194    CPTPlotSpace *plotSpace;
195    BOOL dataNeedsReloading;
196    NSMutableDictionary *cachedData;
197    NSUInteger cachedDataCount;
198    CPTPlotCachePrecision cachePrecision;
199    BOOL needsRelabel;
200    CGFloat labelOffset;
201    CGFloat labelRotation;
202    NSUInteger labelField;
203    CPTTextStyle *labelTextStyle;
204    NSNumberFormatter *labelFormatter;
205    NSRange labelIndexRange;
206    NSMutableArray *labelAnnotations;
207    CPTShadow *labelShadow;
208    BOOL alignsPointsToPixels;
209}
210
211/// @name Data Source
212/// @{
213@property (nonatomic, readwrite, cpt_weak_property) __cpt_weak id<CPTPlotDataSource> dataSource;
214/// @}
215
216/// @name Identification
217/// @{
218@property (nonatomic, readwrite, copy) NSString *title;
219/// @}
220
221/// @name Plot Space
222/// @{
223@property (nonatomic, readwrite, retain) CPTPlotSpace *plotSpace;
224/// @}
225
226/// @name Plot Area
227/// @{
228@property (nonatomic, readonly, retain) CPTPlotArea *plotArea;
229/// @}
230
231/// @name Data Loading
232/// @{
233@property (nonatomic, readonly, assign) BOOL dataNeedsReloading;
234/// @}
235
236/// @name Data Cache
237/// @{
238@property (nonatomic, readonly, assign) NSUInteger cachedDataCount;
239@property (nonatomic, readonly, assign) BOOL doublePrecisionCache;
240@property (nonatomic, readwrite, assign) CPTPlotCachePrecision cachePrecision;
241@property (nonatomic, readonly, assign) CPTNumericDataType doubleDataType;
242@property (nonatomic, readonly, assign) CPTNumericDataType decimalDataType;
243/// @}
244
245/// @name Data Labels
246/// @{
247@property (nonatomic, readonly, assign) BOOL needsRelabel;
248@property (nonatomic, readwrite, assign) CGFloat labelOffset;
249@property (nonatomic, readwrite, assign) CGFloat labelRotation;
250@property (nonatomic, readwrite, assign) NSUInteger labelField;
251@property (nonatomic, readwrite, copy) CPTTextStyle *labelTextStyle;
252@property (nonatomic, readwrite, retain) NSNumberFormatter *labelFormatter;
253@property (nonatomic, readwrite, retain) CPTShadow *labelShadow;
254/// @}
255
256/// @name Drawing
257/// @{
258@property (nonatomic, readwrite, assign) BOOL alignsPointsToPixels;
259/// @}
260
261/// @name Data Labels
262/// @{
263-(void)setNeedsRelabel;
264-(void)relabel;
265-(void)relabelIndexRange:(NSRange)indexRange;
266-(void)repositionAllLabelAnnotations;
267/// @}
268
269/// @name Data Loading
270/// @{
271-(void)setDataNeedsReloading;
272-(void)reloadData;
273-(void)reloadDataIfNeeded;
274-(void)reloadDataInIndexRange:(NSRange)indexRange;
275-(void)insertDataAtIndex:(NSUInteger)idx numberOfRecords:(NSUInteger)numberOfRecords;
276-(void)deleteDataInIndexRange:(NSRange)indexRange;
277/// @}
278
279/// @name Plot Data
280/// @{
281+(id)nilData;
282-(id)numbersFromDataSourceForField:(NSUInteger)fieldEnum recordIndexRange:(NSRange)indexRange;
283-(BOOL)loadNumbersForAllFieldsFromDataSourceInRecordIndexRange:(NSRange)indexRange;
284/// @}
285
286/// @name Data Cache
287/// @{
288-(CPTMutableNumericData *)cachedNumbersForField:(NSUInteger)fieldEnum;
289-(NSNumber *)cachedNumberForField:(NSUInteger)fieldEnum recordIndex:(NSUInteger)idx;
290-(double)cachedDoubleForField:(NSUInteger)fieldEnum recordIndex:(NSUInteger)idx;
291-(NSDecimal)cachedDecimalForField:(NSUInteger)fieldEnum recordIndex:(NSUInteger)idx;
292-(NSArray *)cachedArrayForKey:(NSString *)key;
293-(id)cachedValueForKey:(NSString *)key recordIndex:(NSUInteger)idx;
294
295-(void)cacheNumbers:(id)numbers forField:(NSUInteger)fieldEnum;
296-(void)cacheNumbers:(id)numbers forField:(NSUInteger)fieldEnum atRecordIndex:(NSUInteger)idx;
297-(void)cacheArray:(NSArray *)array forKey:(NSString *)key;
298-(void)cacheArray:(NSArray *)array forKey:(NSString *)key atRecordIndex:(NSUInteger)idx;
299/// @}
300
301/// @name Plot Data Ranges
302/// @{
303-(CPTPlotRange *)plotRangeForField:(NSUInteger)fieldEnum;
304-(CPTPlotRange *)plotRangeForCoordinate:(CPTCoordinate)coord;
305/// @}
306
307/// @name Legends
308/// @{
309-(NSUInteger)numberOfLegendEntries;
310-(NSString *)titleForLegendEntryAtIndex:(NSUInteger)idx;
311-(void)drawSwatchForLegend:(CPTLegend *)legend atIndex:(NSUInteger)idx inRect:(CGRect)rect inContext:(CGContextRef)context;
312/// @}
313
314@end
315
316#pragma mark -
317
318/** @category CPTPlot(AbstractMethods)
319 *  @brief CPTPlot abstract methods—must be overridden by subclasses
320 **/
321@interface CPTPlot(AbstractMethods)
322
323/// @name Fields
324/// @{
325-(NSUInteger)numberOfFields;
326-(NSArray *)fieldIdentifiers;
327-(NSArray *)fieldIdentifiersForCoordinate:(CPTCoordinate)coord;
328/// @}
329
330/// @name Data Labels
331/// @{
332-(void)positionLabelAnnotation:(CPTPlotSpaceAnnotation *)label forIndex:(NSUInteger)idx;
333/// @}
334
335/// @name User Interaction
336/// @{
337-(NSUInteger)dataIndexFromInteractionPoint:(CGPoint)point;
338/// @}
339
340@end
Note: See TracBrowser for help on using the repository browser.