[Yt-svn] commit/yt: MatthewTurk: Adding ticks to the colorbar in the plotwindow widget.
Bitbucket
commits-noreply at bitbucket.org
Fri Apr 22 20:21:16 PDT 2011
1 new changeset in yt:
http://bitbucket.org/yt_analysis/yt/changeset/483d863d4201/
changeset: r4192:483d863d4201
branch: yt
user: MatthewTurk
date: 2011-04-23 05:21:08
summary: Adding ticks to the colorbar in the plotwindow widget.
affected #: 3 files (1.8 KB)
--- a/yt/gui/reason/html/js/widget_plotwindow.js Fri Apr 22 19:34:15 2011 -0400
+++ b/yt/gui/reason/html/js/widget_plotwindow.js Fri Apr 22 23:21:08 2011 -0400
@@ -96,7 +96,7 @@
}
}, {
xtype:'panel',
- id: 'colorbar' + python_varname,
+ id: 'colorbar_' + python_varname,
autoEl: {
tag: 'img',
id: "cb_" + python_varname,
@@ -110,6 +110,16 @@
y: 10,
width: 30,
height: 400,
+ }, {
+ xtype: 'panel',
+ id: 'ticks_' + python_varname,
+ layout: 'absolute',
+ y: 10,
+ x: 540,
+ width: 40,
+ height: 400,
+ items : [],
+ border: false,
}, { xtype: 'multislider',
id: 'slider_' + python_varname,
minValue: 0,
@@ -357,6 +367,8 @@
this.panel.doLayout();
this.panel.show();
this.image_panel = this.panel.get("image_panel_"+python_varname);
+ this.ticks = this.panel.get("ticks_"+python_varname);
+ var ticks = this.ticks;
this.metadata_panel = this.panel.get("rhs_panel_" + python_varname).get("metadata_" + python_varname);
this.zoom_scroll = this.panel.get("slider_" + python_varname);
var image_dom = this.image_panel.el.dom;
@@ -369,6 +381,24 @@
examine = this.metadata_panel;
this.metadata_panel.update(payload['metadata_string']);
metadata_string = payload['metadata_string'];
+ ticks.removeAll();
+ Ext.each(payload['ticks'], function(tick, index) {
+ ticks.add({xtype:'panel',
+ width: 10, height:1,
+ style: 'background-color: #000000;',
+ html:' ',
+ x:0, y: tick[0]});
+ ticks.add({xtype:'panel',
+ width: 30, height:15,
+ border: false,
+ style: 'font-family: "Inconsolata", monospace;' +
+ 'font-size: 12px;',
+ html: ' ' + tick[2] + ' ',
+ x:12, y: tick[0]-6});
+ examine = tick;
+ });
+ //examine = ticks;
+ ticks.doLayout();
}
yt_rpc.ExtDirectREPL.execute(
--- a/yt/visualization/plot_window.py Fri Apr 22 19:34:15 2011 -0400
+++ b/yt/visualization/plot_window.py Fri Apr 22 23:21:08 2011 -0400
@@ -32,6 +32,7 @@
from .fixed_resolution import \
FixedResolutionBuffer
from .plot_modifications import get_smallest_appropriate_unit
+from .loglocator import LogLocator
from yt.funcs import *
from yt.utilities.amr_utils import write_png_to_file
@@ -342,17 +343,34 @@
x_width = self.xlim[1] - self.xlim[0]
zoom_fac = na.log10(x_width*self._frb.pf['unitary'])/na.log10(min_zoom)
zoom_fac = 100.0*max(0.0, zoom_fac)
+ ticks = self.get_ticks(self._frb[field].min(),
+ self._frb[field].max())
payload = {'type':'png_string',
'image_data':img_data,
'metadata_string': self.get_metadata(field),
- 'zoom': zoom_fac}
+ 'zoom': zoom_fac,
+ 'ticks': ticks}
payload.update(addl_keys)
ph.add_payload(payload)
+ def get_ticks(self, mi, ma, height = 400):
+ # This will eventually change to work with non-logged fields
+ ll = LogLocator()
+ tick_locs = ll(mi, ma)
+ ticks = []
+ mi = na.log10(mi)
+ ma = na.log10(ma)
+ for v1,v2 in zip(tick_locs, na.log10(tick_locs)):
+ if v2 < mi or v2 > ma: continue
+ p = height - height * (v2 - mi)/(ma - mi)
+ ticks.append((p,v1,v2))
+ #print v1, v2, mi, ma, height, p
+ return ticks
+
def get_colorbar(self, field, height = 400, width = 40):
# Right now there's just the single 'cmap', but that will eventually
# change. I think?
- vals = na.mgrid[0:1:height * 1j] * na.ones(width)[:,None]
+ vals = na.mgrid[1:0:height * 1j] * na.ones(width)[:,None]
vals = vals.transpose()
to_plot = apply_colormap(vals)
tf = tempfile.TemporaryFile()
Repository URL: https://bitbucket.org/yt_analysis/yt/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
More information about the yt-svn
mailing list