Skip to content

Commit 2adde05

Browse files
committed
Merge branch 'master' into release-2.0
2 parents 161d0da + 87c19cd commit 2adde05

137 files changed

Lines changed: 2252 additions & 2474 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

QCPlugin/CPBarPlotPlugin.h

Lines changed: 0 additions & 12 deletions
This file was deleted.

QCPlugin/CPPieChartPlugin.h

Lines changed: 0 additions & 15 deletions
This file was deleted.

QCPlugin/CPTBarPlotPlugin.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#import "CorePlotQCPlugIn.h"
2+
#import <Cocoa/Cocoa.h>
3+
4+
@interface CPTBarPlotPlugIn : CorePlotQCPlugIn<CPTBarPlotDataSource>
5+
6+
@property (readwrite, assign) double inputBaseValue;
7+
@property (readwrite, assign) double inputBarWidth;
8+
@property (readwrite, assign) double inputBarOffset;
9+
@property (readwrite, assign) BOOL inputHorizontalBars;
10+
11+
@end
Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#import "CPBarPlotPlugIn.h"
1+
#import "CPTBarPlotPlugIn.h"
22

3-
@implementation CPBarPlotPlugIn
3+
@implementation CPTBarPlotPlugIn
44

55
/*
66
* NOTE: It seems that QC plugins don't inherit dynamic input ports which is
@@ -114,18 +114,16 @@ -(void)addPlotWithIndex:(NSUInteger)index
114114
forKey:[NSString stringWithFormat:@"plotDataLineColor%lu", (unsigned long)index]
115115
withAttributes:@{ QCPortAttributeNameKey: [NSString stringWithFormat:@"Plot Line Color %lu", (unsigned long)(index + 1)],
116116
QCPortAttributeTypeKey: QCPortTypeColor,
117-
QCPortAttributeDefaultValueKey: (id)lineColor }
117+
QCPortAttributeDefaultValueKey: CFBridgingRelease(lineColor) }
118118
];
119-
CGColorRelease(lineColor);
120119

121120
CGColorRef fillColor = [self newDefaultColorForPlot:index alpha:0.25];
122121
[self addInputPortWithType:QCPortTypeColor
123122
forKey:[NSString stringWithFormat:@"plotFillColor%lu", (unsigned long)index]
124123
withAttributes:@{ QCPortAttributeNameKey: [NSString stringWithFormat:@"Plot Fill Color %lu", (unsigned long)(index + 1)],
125124
QCPortAttributeTypeKey: QCPortTypeColor,
126-
QCPortAttributeDefaultValueKey: (id)fillColor }
125+
QCPortAttributeDefaultValueKey: CFBridgingRelease(fillColor) }
127126
];
128-
CGColorRelease(fillColor);
129127

130128
[self addInputPortWithType:QCPortTypeNumber
131129
forKey:[NSString stringWithFormat:@"plotDataLineWidth%lu", (unsigned long)index]
@@ -139,35 +137,40 @@ -(void)addPlotWithIndex:(NSUInteger)index
139137
CPTBarPlot *barPlot = [CPTBarPlot tubularBarPlotWithColor:[CPTColor greenColor] horizontalBars:NO];
140138
barPlot.identifier = [NSString stringWithFormat:@"Bar Plot %lu", (unsigned long)(index + 1)];
141139
barPlot.dataSource = self;
142-
[graph addPlot:barPlot];
140+
[self.graph addPlot:barPlot];
143141
}
144142

145143
-(void)removePlots:(NSUInteger)count
146144
{
147145
// Clean up a deleted plot
146+
CPTGraph *theGraph = self.graph;
148147

149-
for ( int i = numberOfPlots; i > numberOfPlots - count; i-- ) {
150-
[self removeInputPortForKey:[NSString stringWithFormat:@"plotNumbers%i", i - 1]];
151-
[self removeInputPortForKey:[NSString stringWithFormat:@"plotDataLineColor%i", i - 1]];
152-
[self removeInputPortForKey:[NSString stringWithFormat:@"plotFillColor%i", i - 1]];
153-
[self removeInputPortForKey:[NSString stringWithFormat:@"plotDataLineWidth%i", i - 1]];
148+
NSUInteger plotCount = self.numberOfPlots;
154149

155-
[graph removePlot:[[graph allPlots] lastObject]];
150+
for ( NSUInteger i = plotCount; i > plotCount - count; i-- ) {
151+
[self removeInputPortForKey:[NSString stringWithFormat:@"plotNumbers%lu", (unsigned long)(i - 1)]];
152+
[self removeInputPortForKey:[NSString stringWithFormat:@"plotDataLineColor%lu", (unsigned long)(i - 1)]];
153+
[self removeInputPortForKey:[NSString stringWithFormat:@"plotFillColor%lu", (unsigned long)(i - 1)]];
154+
[self removeInputPortForKey:[NSString stringWithFormat:@"plotDataLineWidth%lu", (unsigned long)(i - 1)]];
155+
156+
[theGraph removePlot:[[theGraph allPlots] lastObject]];
156157
}
157158
}
158159

159160
-(BOOL)configurePlots
160161
{
162+
CPTGraph *theGraph = self.graph;
163+
161164
// The pixel width of a single plot unit (1..2) along the x axis of the plot
162-
double count = (double)[[graph allPlots] count];
163-
double unitWidth = graph.plotAreaFrame.bounds.size.width / (self.inputXMax - self.inputXMin);
165+
double count = (double)[[theGraph allPlots] count];
166+
double unitWidth = theGraph.plotAreaFrame.bounds.size.width / (self.inputXMax - self.inputXMin);
164167
double barWidth = self.inputBarWidth * unitWidth / count;
165168

166169
// Configure scatter plots for active plot inputs
167-
for ( CPTBarPlot *plot in [graph allPlots] ) {
168-
int index = [[graph allPlots] indexOfObject:plot];
170+
for ( CPTBarPlot *plot in [theGraph allPlots] ) {
171+
NSUInteger index = [[theGraph allPlots] indexOfObject:plot];
169172
CPTMutableLineStyle *lineStyle = [CPTMutableLineStyle lineStyle];
170-
lineStyle.lineColor = [CPTColor colorWithCGColor:(CGColorRef)[self dataLineColor : index]];
173+
lineStyle.lineColor = [CPTColor colorWithCGColor:[self dataLineColor:index]];
171174
lineStyle.lineWidth = [self dataLineWidth:index];
172175
plot.lineStyle = lineStyle;
173176
plot.baseValue = @(self.inputBaseValue);
@@ -187,33 +190,30 @@ -(BOOL)configurePlots
187190

188191
-(NSUInteger)numberOfRecordsForPlot:(CPTPlot *)plot
189192
{
190-
NSUInteger plotIndex = [[graph allPlots] indexOfObject:plot];
193+
NSUInteger plotIndex = [[self.graph allPlots] indexOfObject:plot];
191194
NSString *key = [NSString stringWithFormat:@"plotNumbers%lu", (unsigned long)plotIndex];
192195

193-
if ( ![self valueForInputKey:key] ) {
194-
return 0;
195-
}
196-
197196
return [[self valueForInputKey:key] count];
198197
}
199198

200-
-(NSArray *)numbersForPlot:(CPTBarPlot *)plot field:(NSUInteger)fieldEnum recordIndexRange:(NSRange)indexRange
199+
-(NSArray *)numbersForPlot:(CPTPlot *)plot field:(NSUInteger)fieldEnum recordIndexRange:(NSRange)indexRange
201200
{
202-
NSUInteger plotIndex = [[graph allPlots] indexOfObject:plot];
201+
NSUInteger plotIndex = [[self.graph allPlots] indexOfObject:plot];
203202
NSString *key = [NSString stringWithFormat:@"plotNumbers%lu", (unsigned long)plotIndex];
204203

205-
if ( ![self valueForInputKey:key] ) {
204+
NSDictionary *dict = [self valueForInputKey:key];
205+
206+
if ( !dict ) {
206207
return nil;
207208
}
208209

209-
NSDictionary *dict = [self valueForInputKey:key];
210210
NSUInteger keyCount = [[dict allKeys] count];
211211
NSMutableArray *array = [NSMutableArray array];
212212

213213
if ( fieldEnum == CPTBarPlotFieldBarLocation ) {
214214
// Calculate horizontal position of bar - nth bar index + barWidth*plotIndex + 0.5
215215
float xpos;
216-
float plotCount = [[graph allPlots] count];
216+
float plotCount = [[self.graph allPlots] count];
217217

218218
for ( NSUInteger i = 0; i < keyCount; i++ ) {
219219
xpos = (float)i + (float)plotIndex / (plotCount);

QCPlugin/CPTPieChartPlugin.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#import "CorePlotQCPlugIn.h"
2+
#import <Cocoa/Cocoa.h>
3+
4+
@interface CPTPieChartPlugIn : CorePlotQCPlugIn<CPTPieChartDataSource>
5+
6+
@property (readwrite, assign) double inputPieRadius;
7+
@property (readwrite, assign) double inputSliceLabelOffset;
8+
@property (readwrite, assign) double inputStartAngle;
9+
@property (readwrite, assign) NSUInteger inputSliceDirection;
10+
@property (readwrite, assign) double inputBorderWidth;
11+
@property (readwrite, assign) CGColorRef inputBorderColor;
12+
@property (readwrite, assign) CGColorRef inputLabelColor;
13+
14+
@end
Lines changed: 30 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#import "CPPieChartPlugin.h"
1+
#import "CPTPieChartPlugin.h"
22

3-
@implementation CPPieChartPlugIn
3+
@implementation CPTPieChartPlugIn
44

55
/*
66
* NOTE: It seems that QC plugins don't inherit dynamic input ports which is
@@ -108,18 +108,16 @@ +(NSDictionary *)attributesForPropertyPortWithKey:(NSString *)key
108108
CGColorRef grayColor = CGColorCreateGenericGray(0.0, 1.0);
109109
NSDictionary *result = @{
110110
QCPortAttributeNameKey: @"Border Color",
111-
QCPortAttributeDefaultValueKey: (id)grayColor
111+
QCPortAttributeDefaultValueKey: CFBridgingRelease(grayColor)
112112
};
113-
CGColorRelease(grayColor);
114113
return result;
115114
}
116115
else if ( [key isEqualToString:@"inputLabelColor"] ) {
117116
CGColorRef grayColor = CGColorCreateGenericGray(1.0, 1.0);
118117
NSDictionary *result = @{
119118
QCPortAttributeNameKey: @"Label Color",
120-
QCPortAttributeDefaultValueKey: (id)grayColor
119+
QCPortAttributeDefaultValueKey: CFBridgingRelease(grayColor)
121120
};
122-
CGColorRelease(grayColor);
123121
return result;
124122
}
125123
else {
@@ -149,16 +147,15 @@ -(void)addPlotWithIndex:(NSUInteger)index
149147
forKey:[NSString stringWithFormat:@"plotFillColor%lu", (unsigned long)index]
150148
withAttributes:@{ QCPortAttributeNameKey: [NSString stringWithFormat:@"Primary Fill Color %lu", (unsigned long)(index + 1)],
151149
QCPortAttributeTypeKey: QCPortTypeColor,
152-
QCPortAttributeDefaultValueKey: (id)grayColor }
150+
QCPortAttributeDefaultValueKey: CFBridgingRelease(grayColor) }
153151
];
154-
CGColorRelease(grayColor);
155152

156153
// Add the new plot to the graph
157-
CPTPieChart *pieChart = [[[CPTPieChart alloc] init] autorelease];
154+
CPTPieChart *pieChart = [[CPTPieChart alloc] init];
158155
pieChart.identifier = [NSString stringWithFormat:@"Pie Chart %lu", (unsigned long)(index + 1)];
159156
pieChart.dataSource = self;
160157

161-
[graph addPlot:pieChart];
158+
[self.graph addPlot:pieChart];
162159
}
163160
}
164161

@@ -167,26 +164,29 @@ -(void)addPlotWithIndex:(NSUInteger)index
167164

168165
-(void)createGraph
169166
{
170-
if ( !graph ) {
167+
if ( !self.graph ) {
171168
// Create graph from theme
172169
CPTTheme *theme = [CPTTheme themeNamed:kCPTPlainWhiteTheme];
173-
graph = (CPTXYGraph *)[theme newGraph];
174-
graph.axisSet = nil;
170+
self.graph = (CPTXYGraph *)[theme newGraph];
171+
172+
self.graph.axisSet = nil;
175173
}
176174
}
177175

178176
-(BOOL)configureAxis
179177
{
180178
// We use no axis for the pie chart
181-
graph.axisSet = nil;
182-
graph.plotAreaFrame.plotArea.borderLineStyle = nil;
179+
self.graph.axisSet = nil;
180+
181+
self.graph.plotAreaFrame.plotArea.borderLineStyle = nil;
182+
183183
return YES;
184184
}
185185

186186
-(BOOL)configurePlots
187187
{
188188
// Configure the pie chart
189-
for ( CPTPieChart *pieChart in [graph allPlots] ) {
189+
for ( CPTPieChart *pieChart in [self.graph allPlots] ) {
190190
pieChart.plotArea.borderLineStyle = nil;
191191

192192
pieChart.pieRadius = self.inputPieRadius * MIN(self.inputPixelsWide, self.inputPixelsHigh) / 2.0;
@@ -218,27 +218,25 @@ -(BOOL)configurePlots
218218

219219
-(NSUInteger)numberOfRecordsForPlot:(CPTPlot *)plot
220220
{
221-
NSUInteger plotIndex = [[graph allPlots] indexOfObject:plot];
221+
NSUInteger plotIndex = [[self.graph allPlots] indexOfObject:plot];
222222
NSString *key = [NSString stringWithFormat:@"plotNumbers%lu", (unsigned long)plotIndex];
223223

224-
if ( ![self valueForInputKey:key] ) {
225-
return 0;
226-
}
227-
228224
return [[self valueForInputKey:key] count];
229225
}
230226

231227
-(id)numberForPlot:(CPTPlot *)plot field:(NSUInteger)fieldEnum recordIndex:(NSUInteger)index
232228
{
233-
NSUInteger plotIndex = [[graph allPlots] indexOfObject:plot];
229+
NSUInteger plotIndex = [[self.graph allPlots] indexOfObject:plot];
234230
NSString *key = [NSString stringWithFormat:@"plotNumbers%lu", (unsigned long)plotIndex];
235231

236-
if ( ![self valueForInputKey:key] ) {
232+
NSDictionary *dict = [self valueForInputKey:key];
233+
234+
if ( dict ) {
235+
return [NSDecimalNumber decimalNumberWithString:[dict[[NSString stringWithFormat:@"%lu", (unsigned long)index]] stringValue]];
236+
}
237+
else {
237238
return nil;
238239
}
239-
240-
NSDictionary *dict = [self valueForInputKey:key];
241-
return [NSDecimalNumber decimalNumberWithString:[dict[[NSString stringWithFormat:@"%lu", (unsigned long)index]] stringValue]];
242240
}
243241

244242
-(CPTFill *)sliceFillForPieChart:(CPTPieChart *)pieChart recordIndex:(NSUInteger)index
@@ -258,23 +256,23 @@ -(CPTFill *)sliceFillForPieChart:(CPTPieChart *)pieChart recordIndex:(NSUInteger
258256

259257
CGColorRelease(fillColor);
260258

261-
return [[[CPTFill alloc] initWithColor:fillCPColor] autorelease];
259+
return [[CPTFill alloc] initWithColor:fillCPColor];
262260
}
263261

264262
-(CPTTextLayer *)sliceLabelForPieChart:(CPTPieChart *)pieChart recordIndex:(NSUInteger)index
265263
{
266-
NSUInteger plotIndex = [[graph allPlots] indexOfObject:pieChart];
264+
NSUInteger plotIndex = [[self.graph allPlots] indexOfObject:pieChart];
267265
NSString *key = [NSString stringWithFormat:@"plotLabels%lu", (unsigned long)plotIndex];
268266

269-
if ( ![self valueForInputKey:key] ) {
267+
NSDictionary *dict = [self valueForInputKey:key];
268+
269+
if ( !dict ) {
270270
return nil;
271271
}
272272

273-
NSDictionary *dict = [self valueForInputKey:key];
274-
275273
NSString *label = dict[[NSString stringWithFormat:@"%lu", (unsigned long)index]];
276274

277-
CPTTextLayer *layer = [[[CPTTextLayer alloc] initWithText:label] autorelease];
275+
CPTTextLayer *layer = [[CPTTextLayer alloc] initWithText:label];
278276
[layer sizeToFit];
279277

280278
CPTMutableTextStyle *style = [CPTMutableTextStyle textStyle];
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#import "CorePlotQCPlugIn.h"
22
#import <Cocoa/Cocoa.h>
33

4-
@interface CPScatterPlotPlugIn : CorePlotQCPlugIn {
5-
}
4+
@interface CPTScatterPlotPlugIn : CorePlotQCPlugIn
65

76
@end

0 commit comments

Comments
 (0)