1 #import "CPTDefinitions.h" 2 #import "CPTResponder.h" 3 4 @class CPTLayer; 5 @class CPTPlotRange; 6 @class CPTGraph; 7 @class CPTPlotSpace; 8 9 /// @name Plot Space 10 /// @{ 11 12 /** @brief Plot space coordinate change notification. 13 * 14 * This notification is posted to the default notification center whenever the mapping between 15 * the plot space coordinate system and drawing coordinates changes. 16 * @ingroup notification 17 **/ 18 extern NSString * const CPTPlotSpaceCoordinateMappingDidChangeNotification; 19 20 /// @} 21 22 /** @brief Plot space delegate. 23 **/ 24 @protocol CPTPlotSpaceDelegate <NSObject> 25 26 @optional 27 28 /// @name Scrolling 29 /// @{ 30 31 /** @brief Informs the receiver that it should uniformly scale (e.g., in response to a pinch on iOS) 32 * @param space The plot space. 33 * @param interactionScale The scaling factor. 34 * @param interactionPoint The coordinates of the scaling centroid. 35 * @return YES should be returned if the gesture should be handled by the plot space, and NO to prevent handling. 36 * In either case, the delegate may choose to take extra actions, or handle the scaling itself. 37 **/ 38 -(BOOL)plotSpace:(CPTPlotSpace*)space shouldScaleBy:(CGFloat)interactionScale aboutPoint:(CGPoint)interactionPoint; 39 40 /** @brief Notifies that plot space intercepted a device down event. 41 * @param space The plot space. 42 * @param event The native event (e.g., UIEvent on iPhone) 43 * @param point The point in the host view. 44 * @return Whether the plot space should handle the event or not. 45 * In either case, the delegate may choose to take extra actions, or handle the scaling itself. 46 **/ 47 -(BOOL)plotSpace:(CPTPlotSpace *)space shouldHandlePointingDeviceDownEvent:(id)event atPoint:(CGPoint)point; 48 49 /** @brief Notifies that plot space intercepted a device dragged event. 50 * @param space The plot space. 51 * @param event The native event (e.g., UIEvent on iPhone) 52 * @param point The point in the host view. 53 * @return Whether the plot space should handle the event or not. 54 * In either case, the delegate may choose to take extra actions, or handle the scaling itself. 55 **/ 56 -(BOOL)plotSpace:(CPTPlotSpace *)space shouldHandlePointingDeviceDraggedEvent:(id)event atPoint:(CGPoint)point; 57 58 /** @brief Notifies that plot space intercepted a device cancelled event. 59 * @param space The plot space. 60 * @param event The native event (e.g., UIEvent on iPhone) 61 * @return Whether the plot space should handle the event or not. 62 * In either case, the delegate may choose to take extra actions, or handle the scaling itself. 63 **/ 64 -(BOOL)plotSpace:(CPTPlotSpace *)space shouldHandlePointingDeviceCancelledEvent:(id)event; 65 66 /** @brief Notifies that plot space intercepted a device up event. 67 * @param space The plot space. 68 * @param event The native event (e.g., UIEvent on iPhone) 69 * @param point The point in the host view. 70 * @return Whether the plot space should handle the event or not. 71 * In either case, the delegate may choose to take extra actions, or handle the scaling itself. 72 **/ 73 -(BOOL)plotSpace:(CPTPlotSpace *)space shouldHandlePointingDeviceUpEvent:(id)event atPoint:(CGPoint)point; 74 75 /** @brief Notifies that plot space is going to scroll. 76 * @param space The plot space. 77 * @param proposedDisplacementVector The proposed amount by which the plot space will shift 78 * @return The displacement actually applied. 79 **/ 80 -(CGPoint)plotSpace:(CPTPlotSpace *)space willDisplaceBy:(CGPoint)proposedDisplacementVector; 81 82 /** @brief Notifies that plot space is going to change a plot range. 83 * @param space The plot space. 84 * @param newRange The proposed new plot range. 85 * @param coordinate The coordinate of the range. 86 * @return The new plot range to be used. 87 **/ 88 -(CPTPlotRange *)plotSpace:(CPTPlotSpace *)space willChangePlotRangeTo:(CPTPlotRange *)newRange forCoordinate:(CPTCoordinate)coordinate; 89 90 /** @brief Notifies that plot space has changed a plot range. 91 * @param space The plot space. 92 * @param coordinate The coordinate of the range. 93 **/ 94 -(void)plotSpace:(CPTPlotSpace *)space didChangePlotRangeForCoordinate:(CPTCoordinate)coordinate; 95 96 /// @} 97 98 @end 99 100 #pragma mark - 101 102 @interface CPTPlotSpace : NSObject <CPTResponder, NSCoding> { 103 @private 104 __weak CPTGraph *graph; 105 id <NSCopying, NSCoding, NSObject> identifier; 106 __weak id <CPTPlotSpaceDelegate> delegate; 107 BOOL allowsUserInteraction; 108 } 109 110 @property (nonatomic, readwrite, copy) id <NSCopying, NSCoding, NSObject> identifier; 111 @property (nonatomic, readwrite, assign) BOOL allowsUserInteraction; 112 @property (nonatomic, readwrite, assign) __weak CPTGraph *graph; 113 @property (nonatomic, readwrite, assign) __weak id <CPTPlotSpaceDelegate> delegate; 114 115 @end 116 117 #pragma mark - 118 119 /** @category CPTPlotSpace(AbstractMethods) 120 * @brief CPTPlotSpace abstract methods—must be overridden by subclasses 121 **/ 122 @interface CPTPlotSpace(AbstractMethods) 123 124 /// @name Coordinate Space Conversions 125 /// @{ 126 -(CGPoint)plotAreaViewPointForPlotPoint:(NSDecimal *)plotPoint; 127 -(CGPoint)plotAreaViewPointForDoublePrecisionPlotPoint:(double *)plotPoint; 128 -(void)plotPoint:(NSDecimal *)plotPoint forPlotAreaViewPoint:(CGPoint)point; 129 -(void)doublePrecisionPlotPoint:(double *)plotPoint forPlotAreaViewPoint:(CGPoint)point; 130 /// @} 131 132 /// @name Coordinate Range 133 /// @{ 134 -(void)setPlotRange:(CPTPlotRange *)newRange forCoordinate:(CPTCoordinate)coordinate; 135 -(CPTPlotRange *)plotRangeForCoordinate:(CPTCoordinate)coordinate; 136 /// @} 137 138 /// @name Scale Types 139 /// @{ 140 -(void)setScaleType:(CPTScaleType)newType forCoordinate:(CPTCoordinate)coordinate; 141 -(CPTScaleType)scaleTypeForCoordinate:(CPTCoordinate)coordinate; 142 /// @} 143 144 /// @name Adjusting Ranges 145 /// @{ 146 -(void)scaleToFitPlots:(NSArray *)plots; 147 -(void)scaleBy:(CGFloat)interactionScale aboutPoint:(CGPoint)interactionPoint; 148 /// @} 149 150 @end 151