From 2206c9cdc5bea1552a0fbf66e7e9f310e7bdc880 Mon Sep 17 00:00:00 2001 From: Bibiko Date: Sat, 9 Oct 2010 14:12:40 +0000 Subject: =?UTF-8?q?=E2=80=A2=20improved=20field=20editor=20sheet=20to=20su?= =?UTF-8?q?pport=20geometry=20fields=20-=20additionally=20it=20shows=20the?= =?UTF-8?q?=20image=20-=20image=20can=20be=20saved=20as=20pdf=20if=20image?= =?UTF-8?q?=20is=20displayed=20via=20Save=20button;=20if=20text=20is=20sel?= =?UTF-8?q?ected=20the=20wkt=20string=20will=20be=20saved?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Source/SPGeometryDataView.m | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) (limited to 'Source/SPGeometryDataView.m') 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 { @@ -243,6 +252,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 */ -- cgit v1.2.3