@@ -904,6 +904,51 @@ -(double)doublePrecisionPlotCoordinateForViewLength:(CGFloat)viewLength logPlotR
904904 return pow (10.0 , coordinate);
905905}
906906
907+ // Log-modulus
908+ -(CGFloat)viewCoordinateForViewLength : (NSDecimal )viewLength logModulusPlotRange : (CPTPlotRange *)range plotCoordinateValue : (NSDecimal )plotCoord
909+ {
910+ if ( !range ) {
911+ return CPTFloat (0.0 );
912+ }
913+
914+ NSDecimal factor = CPTDecimalDivide (CPTDecimalSubtract (plotCoord, range.locationDecimal ), range.lengthDecimal );
915+ if ( NSDecimalIsNotANumber (&factor) ) {
916+ factor = CPTDecimalFromInteger (0 );
917+ }
918+
919+ NSDecimal viewCoordinate = CPTDecimalMultiply (viewLength, factor);
920+
921+ return CPTDecimalCGFloatValue (viewCoordinate);
922+ }
923+
924+ -(CGFloat)viewCoordinateForViewLength : (CGFloat)viewLength logModulusPlotRange : (CPTPlotRange *)range doublePrecisionPlotCoordinateValue : (double )plotCoord
925+ {
926+ if ( !range || (range.lengthDouble == 0.0 ) ) {
927+ return CPTFloat (0.0 );
928+ }
929+
930+ double logLoc = CPTLogModulus (range.locationDouble );
931+ double logCoord = CPTLogModulus (plotCoord);
932+ double logEnd = CPTLogModulus (range.endDouble );
933+
934+ return viewLength * (CGFloat)( (logCoord - logLoc) / (logEnd - logLoc) );
935+ }
936+
937+
938+ -(double )doublePrecisionPlotCoordinateForViewLength : (CGFloat)viewLength logModulusPlotRange : (CPTPlotRange *)range boundsLength : (CGFloat)boundsLength
939+ {
940+ if ( boundsLength == 0.0 ) {
941+ return 0.0 ;
942+ }
943+
944+ double logLoc = CPTLogModulus (range.locationDouble );
945+ double logEnd = CPTLogModulus (range.endDouble );
946+ double coordinate = viewLength * (logEnd - logLoc) / boundsLength + logLoc;
947+
948+ return pow (10.0 , coordinate);
949+
950+ }
951+
907952// / @endcond
908953
909954#pragma mark -
@@ -944,6 +989,12 @@ -(CGPoint)plotAreaViewPointForPlotPoint:(NSArray *)plotPoint
944989 }
945990 break ;
946991
992+ case CPTScaleTypeLogModulus:
993+ {
994+ viewPoint.x = [self viewCoordinateForViewLength: layerSize.width logModulusPlotRange: self .xRange doublePrecisionPlotCoordinateValue: [plotPoint[CPTCoordinateX] doubleValue ]];
995+ }
996+ break ;
997+
947998 default :
948999 [NSException raise: CPTException format: @" Scale type not supported in CPTXYPlotSpace" ];
9491000 }
@@ -960,6 +1011,12 @@ -(CGPoint)plotAreaViewPointForPlotPoint:(NSArray *)plotPoint
9601011 }
9611012 break ;
9621013
1014+ case CPTScaleTypeLogModulus:
1015+ {
1016+ viewPoint.y = [self viewCoordinateForViewLength: layerSize.height logModulusPlotRange: self .yRange doublePrecisionPlotCoordinateValue: [plotPoint[CPTCoordinateY] doubleValue ]];
1017+ }
1018+ break ;
1019+
9631020 default :
9641021 [NSException raise: CPTException format: @" Scale type not supported in CPTXYPlotSpace" ];
9651022 }
@@ -995,6 +1052,13 @@ -(CGPoint)plotAreaViewPointForPlotPoint:(NSDecimal *)plotPoint numberOfCoordinat
9951052 }
9961053 break ;
9971054
1055+ case CPTScaleTypeLogModulus:
1056+ {
1057+ double x = CPTDecimalDoubleValue (plotPoint[CPTCoordinateX]);
1058+ viewPoint.x = [self viewCoordinateForViewLength: layerSize.width logModulusPlotRange: self .xRange doublePrecisionPlotCoordinateValue: x];
1059+ }
1060+ break ;
1061+
9981062 default :
9991063 [NSException raise: CPTException format: @" Scale type not supported in CPTXYPlotSpace" ];
10001064 }
@@ -1012,6 +1076,13 @@ -(CGPoint)plotAreaViewPointForPlotPoint:(NSDecimal *)plotPoint numberOfCoordinat
10121076 }
10131077 break ;
10141078
1079+ case CPTScaleTypeLogModulus:
1080+ {
1081+ double y = CPTDecimalDoubleValue (plotPoint[CPTCoordinateY]);
1082+ viewPoint.y = [self viewCoordinateForViewLength: layerSize.height logModulusPlotRange: self .yRange doublePrecisionPlotCoordinateValue: y];
1083+ }
1084+ break ;
1085+
10151086 default :
10161087 [NSException raise: CPTException format: @" Scale type not supported in CPTXYPlotSpace" ];
10171088 }
@@ -1044,6 +1115,10 @@ -(CGPoint)plotAreaViewPointForDoublePrecisionPlotPoint:(double *)plotPoint numbe
10441115 viewPoint.x = [self viewCoordinateForViewLength: layerSize.width logPlotRange: self .xRange doublePrecisionPlotCoordinateValue: plotPoint[CPTCoordinateX]];
10451116 break ;
10461117
1118+ case CPTScaleTypeLogModulus:
1119+ viewPoint.x = [self viewCoordinateForViewLength: layerSize.width logModulusPlotRange: self .xRange doublePrecisionPlotCoordinateValue: plotPoint[CPTCoordinateX]];
1120+ break ;
1121+
10471122 default :
10481123 [NSException raise: CPTException format: @" Scale type not supported in CPTXYPlotSpace" ];
10491124 }
@@ -1058,6 +1133,10 @@ -(CGPoint)plotAreaViewPointForDoublePrecisionPlotPoint:(double *)plotPoint numbe
10581133 viewPoint.y = [self viewCoordinateForViewLength: layerSize.height logPlotRange: self .yRange doublePrecisionPlotCoordinateValue: plotPoint[CPTCoordinateY]];
10591134 break ;
10601135
1136+ case CPTScaleTypeLogModulus:
1137+ viewPoint.y = [self viewCoordinateForViewLength: layerSize.height logModulusPlotRange: self .yRange doublePrecisionPlotCoordinateValue: plotPoint[CPTCoordinateY]];
1138+ break ;
1139+
10611140 default :
10621141 [NSException raise: CPTException format: @" Scale type not supported in CPTXYPlotSpace" ];
10631142 }
@@ -1097,6 +1176,10 @@ -(NSArray *)plotPointForPlotAreaViewPoint:(CGPoint)point
10971176 plotPoint[CPTCoordinateX] = @([self doublePrecisionPlotCoordinateForViewLength: point.x logPlotRange: self .xRange boundsLength: boundsSize.width]);
10981177 break ;
10991178
1179+ case CPTScaleTypeLogModulus:
1180+ plotPoint[CPTCoordinateX] = @([self doublePrecisionPlotCoordinateForViewLength: point.x logModulusPlotRange: self .xRange boundsLength: boundsSize.width]);
1181+ break ;
1182+
11001183 default :
11011184 [NSException raise: CPTException format: @" Scale type not supported in CPTXYPlotSpace" ];
11021185 }
@@ -1112,6 +1195,10 @@ -(NSArray *)plotPointForPlotAreaViewPoint:(CGPoint)point
11121195 case CPTScaleTypeLog:
11131196 plotPoint[CPTCoordinateY] = @([self doublePrecisionPlotCoordinateForViewLength: point.y logPlotRange: self .yRange boundsLength: boundsSize.height]);
11141197 break ;
1198+
1199+ case CPTScaleTypeLogModulus:
1200+ plotPoint[CPTCoordinateY] = @([self doublePrecisionPlotCoordinateForViewLength: point.y logModulusPlotRange: self .yRange boundsLength: boundsSize.height]);
1201+ break ;
11151202
11161203 default :
11171204 [NSException raise: CPTException format: @" Scale type not supported in CPTXYPlotSpace" ];
@@ -1147,6 +1234,10 @@ -(void)plotPoint:(NSDecimal *)plotPoint numberOfCoordinates:(NSUInteger)count fo
11471234 case CPTScaleTypeLog:
11481235 plotPoint[CPTCoordinateX] = CPTDecimalFromDouble ([self doublePrecisionPlotCoordinateForViewLength: point.x logPlotRange: self .xRange boundsLength: boundsSize.width]);
11491236 break ;
1237+
1238+ case CPTScaleTypeLogModulus:
1239+ plotPoint[CPTCoordinateX] = CPTDecimalFromDouble ([self doublePrecisionPlotCoordinateForViewLength: point.x logModulusPlotRange: self .xRange boundsLength: boundsSize.width]);
1240+ break ;
11501241
11511242 default :
11521243 [NSException raise: CPTException format: @" Scale type not supported in CPTXYPlotSpace" ];
@@ -1162,6 +1253,10 @@ -(void)plotPoint:(NSDecimal *)plotPoint numberOfCoordinates:(NSUInteger)count fo
11621253 plotPoint[CPTCoordinateY] = CPTDecimalFromDouble ([self doublePrecisionPlotCoordinateForViewLength: point.y logPlotRange: self .yRange boundsLength: boundsSize.height]);
11631254 break ;
11641255
1256+ case CPTScaleTypeLogModulus:
1257+ plotPoint[CPTCoordinateY] = CPTDecimalFromDouble ([self doublePrecisionPlotCoordinateForViewLength: point.y logModulusPlotRange: self .yRange boundsLength: boundsSize.height]);
1258+ break ;
1259+
11651260 default :
11661261 [NSException raise: CPTException format: @" Scale type not supported in CPTXYPlotSpace" ];
11671262 }
@@ -1194,6 +1289,10 @@ -(void)doublePrecisionPlotPoint:(double *)plotPoint numberOfCoordinates:(NSUInte
11941289 plotPoint[CPTCoordinateX] = [self doublePrecisionPlotCoordinateForViewLength: point.x logPlotRange: self .xRange boundsLength: boundsSize.width];
11951290 break ;
11961291
1292+ case CPTScaleTypeLogModulus:
1293+ plotPoint[CPTCoordinateX] = [self doublePrecisionPlotCoordinateForViewLength: point.x logModulusPlotRange: self .xRange boundsLength: boundsSize.width];
1294+ break ;
1295+
11971296 default :
11981297 [NSException raise: CPTException format: @" Scale type not supported in CPTXYPlotSpace" ];
11991298 }
@@ -1208,6 +1307,10 @@ -(void)doublePrecisionPlotPoint:(double *)plotPoint numberOfCoordinates:(NSUInte
12081307 plotPoint[CPTCoordinateY] = [self doublePrecisionPlotCoordinateForViewLength: point.y logPlotRange: self .yRange boundsLength: boundsSize.height];
12091308 break ;
12101309
1310+ case CPTScaleTypeLogModulus:
1311+ plotPoint[CPTCoordinateY] = [self doublePrecisionPlotCoordinateForViewLength: point.y logModulusPlotRange: self .yRange boundsLength: boundsSize.height];
1312+ break ;
1313+
12111314 default :
12121315 [NSException raise: CPTException format: @" Scale type not supported in CPTXYPlotSpace" ];
12131316 }
@@ -1758,6 +1861,9 @@ -(id)debugQuickLookObject
17581861 case CPTScaleTypeLog:
17591862 xScaleTypeDesc = @" CPTScaleTypeLog" ;
17601863 break ;
1864+
1865+ case CPTScaleTypeLogModulus:
1866+ xScaleTypeDesc = @" CPTScaleTypeLogModulus" ;
17611867
17621868 case CPTScaleTypeAngular:
17631869 xScaleTypeDesc = @" CPTScaleTypeAngular" ;
@@ -1789,6 +1895,9 @@ -(id)debugQuickLookObject
17891895 yScaleTypeDesc = @" CPTScaleTypeLog" ;
17901896 break ;
17911897
1898+ case CPTScaleTypeLogModulus:
1899+ yScaleTypeDesc = @" CPTScaleTypeLogModulus" ;
1900+
17921901 case CPTScaleTypeAngular:
17931902 yScaleTypeDesc = @" CPTScaleTypeAngular" ;
17941903 break ;
0 commit comments