Status: New Owner: ---- CC: alexandr...@gmail.com Labels: Type-Defect Priority-Medium Component-Roassal Milestone-5.0
New issue 1089 by tu...@tudorgirba.com: Roassal should export PNG https://code.google.com/p/moose-technology/issues/detail?id=1089
We have a first draft of RTPNGExporter, but the problem is that it provides only the visible part of the morph.
The problem is here: exportToFile PNGReadWriter putForm: view view canvas morph imageForm onFileNamed: self fileName
Comment #1 on issue 1089 by tu...@tudorgirba.com: Roassal should export PNG https://code.google.com/p/moose-technology/issues/detail?id=1089
Ideally, we should delegate to the AthensCairoCanvas, but somehow the athens canvas instance from the TRCanvas is empty.
We certainly do not want to re-render the scene because some picture can be expensive to produce.
Comment #2 on issue 1089 by nicolaih...@gmail.com: Roassal should export PNG https://code.google.com/p/moose-technology/issues/detail?id=1089
Yes, somehow your canvas in TRCanvas is only used for shape creations (computePath). Drawing is done with TRMorphs cairo-surface.
AthensCairoSurface has a writeToPng: method for writing the current surface data as a png file.
Comment #3 on issue 1089 by tu...@tudorgirba.com: Roassal should export PNG https://code.google.com/p/moose-technology/issues/detail?id=1089
Indeed. However, we probably have to redraw everything again given that the canvas in the TRMorph is only the visible one
Comment #4 on issue 1089 by tu...@tudorgirba.com: Roassal should export PNG https://code.google.com/p/moose-technology/issues/detail?id=1089
I tried this, but somehow it does not work:
exportToFile | completeMorph | completeMorph := view view canvas morphClass new canvas: view view canvas; extent: view view canvas encompassingRectangle extent. PNGReadWriter putForm: completeMorph imageForm onFileNamed: self fileName
Any idea why?
Comment #5 on issue 1089 by tu...@tudorgirba.com: Roassal should export PNG https://code.google.com/p/moose-technology/issues/detail?id=1089
How do I render an existing trachel shape on an Athens surface?
Comment #6 on issue 1089 by tu...@tudorgirba.com: Roassal should export PNG https://code.google.com/p/moose-technology/issues/detail?id=1089
Here is a script that Alex put together. It almost work, but we still need to extract the logic from TRMorph. Also, there still is a problem with the logic as the picture is shifted to the right.
b := RTMondrianViewBuilder new. b shape rectangle withBorder; width: [ :cls | cls numberOfVariables * 5]; height: #numberOfMethods; linearFillColor: #numberOfLinesOfCode within: RTObject withAllSubclasses. b nodes: RTObject withAllSubclasses. b edgesFrom: #superclass. b treeLayout. b build.
form := FormCanvas extent: (b view canvas encompassingRectangle) extent. m := TRMorph new. m canvas: b view canvas. m extent: (b view canvas encompassingRectangle) extent. m createSurface. m drawOn: form. m surface writeToPng: 'foo.png'
Comment #7 on issue 1089 by tu...@tudorgirba.com: Roassal should export PNG https://code.google.com/p/moose-technology/issues/detail?id=1089
Can anyone else look at this?
Comment #8 on issue 1089 by tu...@tudorgirba.com: Roassal should export PNG https://code.google.com/p/moose-technology/issues/detail?id=1089
Here is a standalone script that seems to almost works. There is still seems to be a problem with one pixel at the bottom and to the right that gets cut.
b := RTMondrianViewBuilder new. b shape rectangle withBorder; width: [ :cls | cls numberOfVariables * 5]; height: #numberOfMethods; linearFillColor: #numberOfLinesOfCode within: RTObject withAllSubclasses. b nodes: RTObject withAllSubclasses. b edgesFrom: #superclass. b treeLayout. b build.
trachelCanvas := b view canvas. form := FormCanvas extent: (trachelCanvas encompassingRectangle) extent. session := Smalltalk session. surface := AthensCairoSurface extent: (trachelCanvas encompassingRectangle extent) asIntegerPoint. form fillRectangle: trachelCanvas encompassingRectangle color: trachelCanvas color. "The drawing has to be done when a change in the shapes occured or when there is an animation." surface drawDuring: [:cs | surface clear. "We display the elements that are subject to the camera" trachelCanvas shapes do: [ :trachelShape | trachelShape drawOn: cs. ]. "We display the elements that are _NOT_ subject to the camera" trachelCanvas fixedShapes do: [ :trachelShape | trachelShape drawOn: cs. ]. ]. "aCanvas translucentImage: surface asForm at: self bounds origin." "asForm creates a new Form, which is likely to be expensive. This can be cached" form image: surface asForm at: trachelCanvas encompassingRectangle origin sourceRect: (0 @ 0 extent: surface extent) rule: 34. surface writeToPng: 'foo.png'
Comment #9 on issue 1089 by tu...@tudorgirba.com: Roassal should export PNG https://code.google.com/p/moose-technology/issues/detail?id=1089
I integrated this in RTPNGExporter, but we still have the one pixel problem.
Comment #10 on issue 1089 by alexandr...@gmail.com: Roassal should export PNG https://code.google.com/p/moose-technology/issues/detail?id=1089
I've tried this and it looks okay (simply adding 10 @ 10 to the extent):
b := RTMondrianViewBuilder new. b shape rectangle withBorder; width: [ :cls | cls numberOfVariables * 5]; height: #numberOfMethods; linearFillColor: #numberOfLinesOfCode within: RTObject withAllSubclasses. b nodes: RTObject withAllSubclasses. b edgesFrom: #superclass. b treeLayout. b build.
trachelCanvas := b view canvas. form := FormCanvas extent: (trachelCanvas encompassingRectangle) extent. session := Smalltalk session. surface := AthensCairoSurface extent: (trachelCanvas encompassingRectangle extent + (10 @ 10)) asIntegerPoint. form fillRectangle: (trachelCanvas encompassingRectangle expandBy: 10 @ 10) color: trachelCanvas color. "The drawing has to be done when a change in the shapes occured or when there is an animation." surface drawDuring: [:cs | surface clear. "We display the elements that are subject to the camera" trachelCanvas shapes do: [ :trachelShape | trachelShape drawOn: cs. ]. "We display the elements that are _NOT_ subject to the camera" trachelCanvas fixedShapes do: [ :trachelShape | trachelShape drawOn: cs. ]. ]. "aCanvas translucentImage: surface asForm at: self bounds origin." "asForm creates a new Form, which is likely to be expensive. This can be cached" form image: surface asForm at: trachelCanvas encompassingRectangle origin sourceRect: (0 @ 0 extent: surface extent) rule: 34. surface writeToPng: '/tmp/foo.png'
Comment #11 on issue 1089 by nicolaih...@gmail.com: Roassal should export PNG https://code.google.com/p/moose-technology/issues/detail?id=1089
How is adding 10@10 a solution?
1. asIntegerPoint rounds down. 2. encompassingRectangle does not take the strokewidth into account.
Comment #12 on issue 1089 by nicolaih...@gmail.com: Roassal should export PNG https://code.google.com/p/moose-technology/issues/detail?id=1089
Other observiations:
- file chooser dialog has "Your title here" as title. - cancel file chooser dialog -> MessageNotUnderstood: receiver of ""fullName"" is nil
Updates: Status: Fixed
Comment #13 on issue 1089 by tu...@tudorgirba.com: Roassal should export PNG https://code.google.com/p/moose-technology/issues/detail?id=1089
@Nicolai: Thanks for finding the issues. They are fixed now.
@Alex: Looks great. Thanks!