[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r10714 - gnuradio/trunk/gr-wxgui/src/python/plotter
From: |
jblum |
Subject: |
[Commit-gnuradio] r10714 - gnuradio/trunk/gr-wxgui/src/python/plotter |
Date: |
Mon, 30 Mar 2009 14:57:00 -0600 (MDT) |
Author: jblum
Date: 2009-03-30 14:57:00 -0600 (Mon, 30 Mar 2009)
New Revision: 10714
Modified:
gnuradio/trunk/gr-wxgui/src/python/plotter/grid_plotter_base.py
Log:
option to enforce padding aspect ratio in grid plotters
Modified: gnuradio/trunk/gr-wxgui/src/python/plotter/grid_plotter_base.py
===================================================================
--- gnuradio/trunk/gr-wxgui/src/python/plotter/grid_plotter_base.py
2009-03-30 20:53:06 UTC (rev 10713)
+++ gnuradio/trunk/gr-wxgui/src/python/plotter/grid_plotter_base.py
2009-03-30 20:57:00 UTC (rev 10714)
@@ -62,6 +62,7 @@
#setup point label cache
self._point_label_cache =
self.new_gl_cache(self._draw_point_label, 75)
self.enable_point_label(False)
+ self.enable_grid_aspect_ratio(False)
self.set_point_label_coordinate(None)
common.point_label_thread(self)
#init grid plotter
@@ -84,6 +85,20 @@
self.update()
self.unlock()
+ def enable_grid_aspect_ratio(self, enable=None):
+ """
+ Enable/disable the grid aspect ratio.
+ If enabled, enforce the aspect ratio on the padding:
+ horizontal_padding:vertical_padding == width:height
+ @param enable true to enable
+ @return the enable state when None
+ """
+ if enable is None: return self._enable_grid_aspect_ratio
+ self.lock()
+ self._enable_grid_aspect_ratio = enable
+ for cache in self._gl_caches: cache.changed(True)
+ self.unlock()
+
def enable_point_label(self, enable=None):
"""
Enable/disable the point label.
@@ -204,6 +219,23 @@
self.padding_right = max(2*TICK_LABEL_PADDING,
self.padding_right_min)
self.padding_bottom = max(2*AXIS_LABEL_PADDING +
TICK_LABEL_PADDING + x_label.get_size()[1] + max([label.get_size()[1] for tick,
label in x_tick_labels]), self.padding_bottom_min)
self.padding_left = max(2*AXIS_LABEL_PADDING +
TICK_LABEL_PADDING + y_label.get_size()[1] + max([label.get_size()[0] for tick,
label in y_tick_labels]), self.padding_left_min)
+ #enforce padding aspect ratio if enabled
+ if self.enable_grid_aspect_ratio():
+ w_over_h_ratio = float(self.width)/float(self.height)
+ horizontal_padding = float(self.padding_right +
self.padding_left)
+ veritical_padding = float(self.padding_top +
self.padding_bottom)
+ if w_over_h_ratio >
horizontal_padding/veritical_padding:
+ #increase the horizontal padding
+ new_padding = veritical_padding*w_over_h_ratio
- horizontal_padding
+ #distribute the padding to left and right
+ self.padding_left += int(round(new_padding/2))
+ self.padding_right += int(round(new_padding/2))
+ else:
+ #increase the vertical padding
+ new_padding = horizontal_padding/w_over_h_ratio
- veritical_padding
+ #distribute the padding to top and bottom
+ self.padding_top += int(round(new_padding/2))
+ self.padding_bottom += int(round(new_padding/2))
##################################################
# Draw Grid X
##################################################
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r10714 - gnuradio/trunk/gr-wxgui/src/python/plotter,
jblum <=