[Chlor-commits] SF.net SVN: chlor: [546] trunk/src
Status: Pre-Alpha
Brought to you by:
lenny222
From: Chlor c. to s. <chl...@li...> - 2007-05-28 14:28:29
|
Revision: 546 http://svn.sourceforge.net/chlor/?rev=546&view=rev Author: lenny222 Date: 2007-05-28 07:28:28 -0700 (Mon, 28 May 2007) Log Message: ----------- add indendation to CConsoleExport Modified Paths: -------------- trunk/src/core/ChlorDocument.m trunk/src/io/console/CConsoleExport.h trunk/src/io/console/CConsoleExport.m trunk/src/io/svg/import/core/CSvgFactory.m trunk/src/io/svg/import/core/CSvgImportVisitor.m trunk/src/io/svg/import/elements/CSvgDefinitions.h trunk/src/io/svg/import/elements/CSvgDefinitions.m trunk/src/io/svg/import/elements/CSvgGroup.m trunk/src/notes/TODO.txt trunk/src/tests/CAffineMapTest.m Modified: trunk/src/core/ChlorDocument.m =================================================================== --- trunk/src/core/ChlorDocument.m 2007-05-28 13:07:51 UTC (rev 545) +++ trunk/src/core/ChlorDocument.m 2007-05-28 14:28:28 UTC (rev 546) @@ -58,7 +58,7 @@ // Create the layers. m_layers = [[CLayers alloc] init]; -#if 1 +#if 0 // Add a temporary welcome text. { CText* text = [[CText alloc] init]; Modified: trunk/src/io/console/CConsoleExport.h =================================================================== --- trunk/src/io/console/CConsoleExport.h 2007-05-28 13:07:51 UTC (rev 545) +++ trunk/src/io/console/CConsoleExport.h 2007-05-28 14:28:28 UTC (rev 546) @@ -24,6 +24,25 @@ */ @interface CConsoleExport : CVisitor { + /** + * The level of output indendation. + */ + int m_levelOfOutputIndendation; } +/** + * Begins a new output group. The level of output indendation is increased by one. + */ +- (void) beginOutputGroup: (NSString*) theGroupName; + +/** + * Ends a new output group. The level of output indendation is increased by one. + */ +- (void) endOutputGroup: (NSString*) theGroupName; + +/** + * Writes an indendet string to the output. + */ +- (void) output: (NSString*) theString; + @end Modified: trunk/src/io/console/CConsoleExport.m =================================================================== --- trunk/src/io/console/CConsoleExport.m 2007-05-28 13:07:51 UTC (rev 545) +++ trunk/src/io/console/CConsoleExport.m 2007-05-28 14:28:28 UTC (rev 546) @@ -29,37 +29,107 @@ @implementation CConsoleExport +- (void) beginOutputGroup: (NSString*) theGroupName +{ + [theGroupName retain]; + + // Write theGroupName to output. + [self output: [NSString stringWithFormat: @"begin %@", theGroupName]]; + + // Increase the level of indendation. + ++m_levelOfOutputIndendation; + + [theGroupName release]; +} + +- (void) endOutputGroup: (NSString*) theGroupName +{ + [theGroupName retain]; + + // Decrease the level of indendation. + --m_levelOfOutputIndendation; + NSAssert( m_levelOfOutputIndendation >= 0, nil ); + + // Write theGroupName to output. + [self output: [NSString stringWithFormat: @"end %@", theGroupName]]; + + [theGroupName release]; +} + +- (id) init +{ + self = [super init]; + + if( self ) + { + m_levelOfOutputIndendation = 0; + } + + return self; +} + +- (void) output: (NSString*) theString +{ + [theString retain]; + + // Create the output string. + NSMutableString* outPutString = + [[NSMutableString stringWithCapacity: [theString length] + m_levelOfOutputIndendation * 4] retain]; + + // Prepend indendation. + int i; + for( i = 0; i < m_levelOfOutputIndendation; ++i ) + [outPutString appendString: @" "]; + + // Append theString. + [outPutString appendString: theString]; + + // Write outPutString to output. + NSLog( outPutString ); + + [outPutString release]; + [theString release]; +} + - (void) visitDocument: (ChlorDocument*) aDocument { - NSLog( @"document begin" ); - NSLog( @"width, height: %f %f", [aDocument width], [aDocument height] ); + [self beginOutputGroup: @"document"]; + [self output: [NSString stringWithFormat: @"width, height: %f %f", [aDocument width], [aDocument height]]]; + [super visitDocument: aDocument]; - NSLog( @"document end" ); + + [self endOutputGroup: @"document"]; } - (void) visitFill: (CFill*) aFill { NSParameterAssert( aFill != nil ); - NSLog( @"fill begin" ); + [self beginOutputGroup: @"fill"]; // Is stroke paint a solid paint?. CSolidPaint* solid = nil; if( [[aFill paint] isKindOfClass: [CSolidPaint class]] ) + { solid = (CSolidPaint*) [aFill paint]; + } else + { + [self endOutputGroup: @"fill"]; return; + } CGColorRef color = [solid color]; const float* components = CGColorGetComponents( color ); - NSLog( @"RGBA:" ); + [self output: @"RGBA:"]; + size_t i; for( i = 0; i < CGColorGetNumberOfComponents( color ); ++i ) - NSLog( @"%f ", components[ i ] ); + [self output: [NSString stringWithFormat: @"%f ", components[ i ]]]; - NSLog( @"fill end" ); + [self endOutputGroup: @"fill"]; } - (void) visitGroup: (CGroup*) aGroup @@ -69,30 +139,32 @@ - (void) visitLayer: (CLayer*) aLayer { - NSLog( @"layer begin" ); - NSLog( @"visible: %i", [aLayer isVisible] ); + [self beginOutputGroup: @"layer"]; + [self output: [NSString stringWithFormat: @"visible: %i", [aLayer isVisible]]]; + [super visitLayer: aLayer]; - NSLog( @"layer end" ); + + [self endOutputGroup: @"layer"]; } - (void) visitPath: (CPath*) aPath { - NSLog( @"path begin" ); - NSLog( @"visible: %i", [aPath isVisible] ); - + [self beginOutputGroup: @"path"]; + [self output: [NSString stringWithFormat: @"visible: %i", [aPath isVisible]]]; + // Export sub paths. [super visitPath: aPath]; - + if( [aPath stroke] ) [self visitStroke: [aPath stroke]]; - + if( [aPath fill] ) [self visitFill: [aPath fill]]; - + if( [aPath shadow] ) [self visitShadow: [aPath shadow]]; - - NSLog( @"path end" ); + + [self endOutputGroup: @"path"]; } - (void) visitSegment: (CSegment*) aSegment @@ -101,22 +173,22 @@ switch( segmentDegree ) { case 0: - NSLog( @"moveto %f %f", [[aSegment knot] x], [[aSegment knot] y] ); + [self output: [NSString stringWithFormat: @"moveto %f %f", [[aSegment knot] x], [[aSegment knot] y]]]; break; case 1: - NSLog( @"lineto %f %f", [[aSegment knot] x], [[aSegment knot] y] ); + [self output: [NSString stringWithFormat: @"lineto %f %f", [[aSegment knot] x], [[aSegment knot] y]]]; break; case 3: { CPathNode* n1 = [[aSegment nodes] objectAtIndex: 1]; CPathNode* n2 = [[aSegment nodes] objectAtIndex: 2]; CPathNode* n3 = [[aSegment nodes] objectAtIndex: 3]; - NSLog( - @"curveto %f %f %f %f %f %f", [n1 x], [n1 y], [n2 x], [n2 y], [n3 x], [n3 y] ); + + [self output: [NSString stringWithFormat: @"curveto %f %f %f %f %f %f", [n1 x], [n1 y], [n2 x], [n2 y], [n3 x], [n3 y]]]; break; } default: - NSLog( @"Error: Unhandled segment degree %@!", [aSegment degree] ); + [self output: [NSString stringWithFormat: @"Error: Unhandled segment degree %@!", [aSegment degree]]]; } } @@ -124,8 +196,8 @@ { NSParameterAssert( aStroke != nil ); - NSLog( @"stroke begin" ); - NSLog( @"lineWidth: %f", [aStroke lineWidth] ); + [self beginOutputGroup: @"stroke"]; + [self output: [NSString stringWithFormat: @"lineWidth: %f", [aStroke lineWidth]]]; // Is stroke paint a solid paint?. CSolidPaint* solid = nil; @@ -136,24 +208,30 @@ } else { - NSLog( @"TODO: CConsoleExport visitStroke: unhandled paint." ); + [self output: @"TODO: unhandled paint."]; + [self endOutputGroup: @"stroke"]; return; } - + CGColorRef color = [solid color]; const float* components = CGColorGetComponents( color ); - - NSLog( @"RGBA:" ); + + [self output: @"RGBA:"]; + size_t i; for( i = 0; i < CGColorGetNumberOfComponents( color ); ++i ) - NSLog( @"%f ", components[ i ] ); - - NSLog( @"stroke end" ); + [self output: [NSString stringWithFormat: @"%f ", components[ i ]]]; + + [self endOutputGroup: @"stroke"]; } - (void) visitText: (CText*) aText { - NSLog( @"text" ); + [self beginOutputGroup: @"text"]; + + [self output: [NSString stringWithFormat: @"string: \"%@\"", [aText string]]]; + + [self endOutputGroup: @"text"]; } @end Modified: trunk/src/io/svg/import/core/CSvgFactory.m =================================================================== --- trunk/src/io/svg/import/core/CSvgFactory.m 2007-05-28 13:07:51 UTC (rev 545) +++ trunk/src/io/svg/import/core/CSvgFactory.m 2007-05-28 14:28:28 UTC (rev 546) @@ -133,7 +133,7 @@ // Create the right SVG node. switch( [entry unsignedIntValue] ) { - case CSvgElementDescription: svgNode = [CSvgDefinitions alloc]; break; + case CSvgElementDescription: svgNode = [CSvgDescription alloc]; break; case CSvgElementTitle: svgNode = [CSvgGroup alloc]; break; default: NSLog( @"Error: CSvgNodeFactory svgDescriptionNodeWithElementName: Unhandled element!" ); Modified: trunk/src/io/svg/import/core/CSvgImportVisitor.m =================================================================== --- trunk/src/io/svg/import/core/CSvgImportVisitor.m 2007-05-28 13:07:51 UTC (rev 545) +++ trunk/src/io/svg/import/core/CSvgImportVisitor.m 2007-05-28 14:28:28 UTC (rev 546) @@ -81,6 +81,7 @@ { NSAssert( theSvgPaint != nil, @"The paint is not given!" ); + // What is the paint type? switch( theSvgPaint->m_type ) { case CSvgPaintColor: @@ -114,7 +115,7 @@ case CSvgPaintCurrentColor: NSLog( @"TODO: CSvgImportVisitor chlorPaintForSvgStroke: Unhandled paint type CSvgPaintCurrentColor!" ); return nil; - + case CSvgPaintUri: NSLog( @"TODO: CSvgImportVisitor chlorPaintForSvgStroke: Unhandled paint type CSvgPaintUri!" ); return nil; Modified: trunk/src/io/svg/import/elements/CSvgDefinitions.h =================================================================== --- trunk/src/io/svg/import/elements/CSvgDefinitions.h 2007-05-28 13:07:51 UTC (rev 545) +++ trunk/src/io/svg/import/elements/CSvgDefinitions.h 2007-05-28 14:28:28 UTC (rev 546) @@ -21,6 +21,16 @@ @interface CSvgDefinitions : CSvgContainerNode { + /** + * The dictionary mapping object ids to definitions. + */ + NSMutableDictionary* m_definitionsForObjectIds; } +/** + * Returns the dictionary mapping object ids to definitions. + */ +- (NSMutableDictionary*) definitionsForObjectIds; + + @end Modified: trunk/src/io/svg/import/elements/CSvgDefinitions.m =================================================================== --- trunk/src/io/svg/import/elements/CSvgDefinitions.m 2007-05-28 13:07:51 UTC (rev 545) +++ trunk/src/io/svg/import/elements/CSvgDefinitions.m 2007-05-28 14:28:28 UTC (rev 546) @@ -21,6 +21,12 @@ @implementation CSvgDefinitions +- (void) dealloc +{ + [m_definitionsForObjectIds release]; + [super dealloc]; +} + - (id) initWithParent: (CSvgNode*) theParent parser: (NSXMLParser*) theParser @@ -34,10 +40,17 @@ if( self ) { + m_definitionsForObjectIds = [[NSMutableDictionary alloc] init]; + NSLog( @"TODO: CSvgDefinitions!" ); } return self; } +- (NSMutableDictionary*) definitionsForObjectIds +{ + return m_definitionsForObjectIds; +} + @end Modified: trunk/src/io/svg/import/elements/CSvgGroup.m =================================================================== --- trunk/src/io/svg/import/elements/CSvgGroup.m 2007-05-28 13:07:51 UTC (rev 545) +++ trunk/src/io/svg/import/elements/CSvgGroup.m 2007-05-28 14:28:28 UTC (rev 546) @@ -88,7 +88,7 @@ { // Add child SVG node. [self addChild: svgNode]; - } + } // Try to create a SVG container node from the given SVG element name. else if( ( svgNode = [CSvgFactory Modified: trunk/src/notes/TODO.txt =================================================================== --- trunk/src/notes/TODO.txt 2007-05-28 13:07:51 UTC (rev 545) +++ trunk/src/notes/TODO.txt 2007-05-28 14:28:28 UTC (rev 546) @@ -19,7 +19,13 @@ - Write a CGColor => NSColor method - BUG: draw a shape, click on the fill/stroke selector => a giant shape is drawn - TODO: the selection should be drawn while rescaling objects with the mouse -- TODO: while rescaling shapes, they should be rounded to pixels to aoid them be drawn blurry +- TODO: while rescaling shapes, they should be rounded to pixels to aovid them be drawn blurry +- TODO: Zoom + - Apply a CoreGraphics affine trafo while rendering OR + - PRO: the renderer wouldn't be bothered with view details + - INT: How to avoid that this scales the line thickness of for exmample the selection rectangle? + - Put a scaling factor into the renderer + - CON: that's not render business, it's view related - TODO: Provide settings dialogs for the shape tools (for example to define number of polygon edges etc.) - BUG: if one rescales objects by dragging the bottonCenter selection handle the upper selection edge moves - TODO: make the scroll view know the document size @@ -50,6 +56,7 @@ SVG import ---------- +- TODO: definitions - TODO: if the document width/heigth are in percent just make the documents the size of the shape boundary box of all included objects - TODO: write unit tests for SVG import - TODO: move all NSScanner using code to CSvgScanner Modified: trunk/src/tests/CAffineMapTest.m =================================================================== --- trunk/src/tests/CAffineMapTest.m 2007-05-28 13:07:51 UTC (rev 545) +++ trunk/src/tests/CAffineMapTest.m 2007-05-28 14:28:28 UTC (rev 546) @@ -48,7 +48,7 @@ // Apply the affine map. CPoint* result = [[m_affineMap transformedPoint: m_point] retain]; - // Test rotation result. + // Test the transformation result. @try { STAssertEqualsWithAccuracy( [result x], 0.0, [CGeometry accuracy], nil ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |