Class: MemInspect::AquatermViewer
- Defined in:
- lib/mem_inspect/aquaterm_viewer.rb
Overview
Prints plots of memory to an AquaTerm window.
Requires RubyCocoa and the AquaTerm framework.
Constant Summary collapse
- BLACK =
unalloc
0
- WHITE =
1
- RED =
2
- GREEN =
3
- GRAY =
free
4
Instance Method Summary collapse
-
#close ⇒ Object
Close the plot.
-
#draw ⇒ Object
Draws a plot and renders it in the active plot window.
-
#fill_background ⇒ Object
Fills the background of the plot, erasing the current contents.
-
#initialize(width, height) ⇒ AquatermViewer
constructor
Creates a new AquatermViewer.
Methods inherited from Viewer
Constructor Details
#initialize(width, height) ⇒ AquatermViewer
Creates a new AquatermViewer.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/mem_inspect/aquaterm_viewer.rb', line 23 def initialize(width, height) super @adapter = OSX::AQTAdapter.alloc.init @adapter.openPlotWithIndex 1 @adapter.setPlotSize [@width, @height] @adapter.setPlotTitle 'Memory Map' @adapter.setColormapEntry_red_green_blue 0, 0.0, 0.0, 0.0 # black @adapter.setColormapEntry_red_green_blue 1, 1.0, 1.0, 1.0 # white @adapter.setColormapEntry_red_green_blue 2, 1.0, 0.0, 0.0 # red @adapter.setColormapEntry_red_green_blue 3, 0.0, 1.0, 0.0 # green @adapter.setColormapEntry_red_green_blue 4, 0.7, 0.7, 0.7 # gray end |
Instance Method Details
#close ⇒ Object
Close the plot
79 80 81 |
# File 'lib/mem_inspect/aquaterm_viewer.rb', line 79 def close @adapter.closePlot end |
#draw ⇒ Object
Draws a plot and renders it in the active plot window.
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/mem_inspect/aquaterm_viewer.rb', line 41 def draw fill_background color = BLACK last_color = color x = 0 y = 0 @mem_inspect.walk do |address, size, object| x, y = coords_for address color = case object when :__free then GRAY when :__node then RED when :__varmap, :__scope, :__unknown then WHITE else GREEN end @adapter.takeColorFromColormapEntry color unless color == last_color @adapter.moveToPoint [x, y] if x == 0 @adapter.addLineToPoint [x + 1, y + 1] last_color = color end ensure # coords_for raises when out-of-bounds @adapter.renderPlot end |
#fill_background ⇒ Object
Fills the background of the plot, erasing the current contents.
71 72 73 74 |
# File 'lib/mem_inspect/aquaterm_viewer.rb', line 71 def fill_background @adapter.takeColorFromColormapEntry BLACK @adapter.addFilledRect [0, 0, @width, @height] # background end |