diff options
Diffstat (limited to 'Source/SPGeometryDataView.m')
-rw-r--r-- | Source/SPGeometryDataView.m | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/Source/SPGeometryDataView.m b/Source/SPGeometryDataView.m index 95e6d2b7..95d9c7db 100644 --- a/Source/SPGeometryDataView.m +++ b/Source/SPGeometryDataView.m @@ -28,16 +28,22 @@ @implementation SPGeometryDataView /** - * Initialize SPGeometryDataView object + * Initialize SPGeometryDataView object with default targetDimension */ - (id)initWithCoordinates:(NSDictionary*)coord { + return [self initWithCoordinates:coord targetDimension:400.0]; +} + +/** + * Initialize SPGeometryDataView object + */ +- (id)initWithCoordinates:(NSDictionary*)coord targetDimension:(CGFloat)targetDimension +{ CGFloat maxDim; - CGFloat targetDim = 400.0; margin_offset = 10.0; - type = [coord objectForKey:@"type"]; coordinates = [coord objectForKey:@"coordinates"]; @@ -51,7 +57,7 @@ maxDim = (width > height) ? width : height; if(maxDim != 0) - zoom_factor = targetDim/maxDim; + zoom_factor = targetDimension/maxDim; else zoom_factor = 1.0; @@ -224,6 +230,9 @@ } } +/** + * Return the geometry as NSImage by using targetDimension + */ - (NSImage*)thumbnailImage { @@ -244,6 +253,20 @@ } /** + * Return PDF data of the geometry image + */ +- (NSData*)pdfData +{ + if(!type || ![type length] || !coordinates || ![coordinates count]) return nil; + + NSSize mySize = self.bounds.size; + NSRect myBounds = [self bounds]; + + return [self dataWithPDFInsideRect:myBounds]; + +} + +/** * dealloc */ - (void)dealloc |