Hello,
added a new function to the oscope view.
With clicking the left mouse button you can mark two positions in the
view to measure the Time and Amplitude differences. With a third click
the function is dissabled again.


mfg
Gilbert Forkel
Index: gr-wxgui/src/python/plotter/channel_plotter.py
===================================================================
--- gr-wxgui/src/python/plotter/channel_plotter.py	(Revision 9705)
+++ gr-wxgui/src/python/plotter/channel_plotter.py	(Arbeitskopie)
@@ -95,6 +95,7 @@
 		self._draw_waveforms()
 		glDisable(GL_SCISSOR_TEST)
 		self._draw_point_label()
+		self._draw_markers()
 		#swap buffer into display
 		self.SwapBuffers()
 		self.unlock()
Index: gr-wxgui/src/python/plotter/plotter_base.py
===================================================================
--- gr-wxgui/src/python/plotter/plotter_base.py	(Revision 9705)
+++ gr-wxgui/src/python/plotter/plotter_base.py	(Arbeitskopie)
@@ -37,6 +37,9 @@
 POINT_LABEL_FONT_SIZE = 8
 POINT_LABEL_COLOR_SPEC = (1, 1, .5)
 POINT_LABEL_PADDING = 3
+MARKER_LINE_COLOR_SPEC = (1, 0, 0)
+MARKER_LABEL_FONT_SIZE = 12
+MARKER_LABEL_PADDING = 4
 
 ##################################################
 # OpenGL WX Plotter Canvas
@@ -136,6 +139,9 @@
 		#setup point label
 		self.enable_point_label(False)
 		self._mouse_coordinate = None
+		self.marker0 = None
+		self.marker1 = None
+		self.Bind(wx.EVT_LEFT_DOWN, self._on_left_down)
 		self.Bind(wx.EVT_MOTION, self._on_motion)
 		self.Bind(wx.EVT_LEAVE_WINDOW, self._on_leave_window)
 
@@ -149,6 +155,20 @@
 		if time.time() - self._update_ts > 0.03: self.update()
 		self.unlock()
 
+	def _on_left_down(self, event):
+		"""
+		Left Mouse button pressed. Used for Markers.
+		"""
+		self.lock()
+		if self.marker0 is None: self.marker0 =  event.GetPosition()
+		else:
+			if self.marker1 is None: self.marker1 =  event.GetPosition()
+			else:
+				self.marker0 = None
+				self.marker1 = None
+		if time.time() - self._update_ts > 0.03: self.update()
+		self.unlock()
+
 	def _on_leave_window(self, event):
 		"""
 		Mouse leave window, set the position to None.
@@ -391,3 +411,60 @@
 		if x > self.width/2: x -= w+2*POINT_LABEL_PADDING
 		self._draw_rect(x, y-h-2*POINT_LABEL_PADDING, w+2*POINT_LABEL_PADDING, h+2*POINT_LABEL_PADDING)
 		txt.draw_text(wx.Point(x+POINT_LABEL_PADDING, y-h-POINT_LABEL_PADDING))
+
+	def _draw_markers(self):
+		"""
+		Draw the markers and display delta of time and amplitude.
+		Todo: Calculate Frequency
+		"""
+		if self.marker0 == None: return
+		glColor3f(*MARKER_LINE_COLOR_SPEC)
+		x0, y0 = self.marker0
+		if x0 < self.padding_left or x0 > self.width-self.padding_right: return
+                if y0 < self.padding_top or y0 > self.height-self.padding_bottom: return
+		#scale to window bounds
+                x0_win_scalar = float(x0 - self.padding_left)/(self.width-self.padding_left-self.padding_right)
+                y0_win_scalar = float((self.height - y0) - self.padding_bottom)/(self.height-self.padding_top-self.padding_bottom)
+                #scale to grid bounds
+                x0_val = self.x_scalar*(x0_win_scalar*(self.x_max-self.x_min) + self.x_min)
+                y0_val = self.y_scalar*(y0_win_scalar*(self.y_max-self.y_min) + self.y_min)
+
+                self._draw_line(
+			(x0, self.padding_top, 0),
+			(x0, self.height-self.padding_top-self.padding_bottom, 0)
+		)
+		self._draw_line(
+			(self.padding_left, y0, 0),
+			(self.width-self.padding_right, y0, 0)
+		)
+		if self.marker1 == None: return
+		x1, y1 = self.marker1
+		#scale to window bounds
+                x1_win_scalar = float(x1 - self.padding_left)/(self.width-self.padding_left-self.padding_right)
+                y1_win_scalar = float((self.height - y1) - self.padding_bottom)/(self.height-self.padding_top-self.padding_bottom)
+                #scale to grid bounds
+                x1_val = self.x_scalar*(x1_win_scalar*(self.x_max-self.x_min) + self.x_min)
+                y1_val = self.y_scalar*(y1_win_scalar*(self.y_max-self.y_min) + self.y_min)
+
+		self._draw_line(
+                        (x1, self.padding_top, 0),
+                        (x1, self.height-self.padding_top, 0)
+                )
+                self._draw_line(
+                        (self.padding_left, y1, 0),
+                        (self.width-self.padding_right, y1, 0)
+                )
+		x_delta = (x1_val-x0_val) if (x1_val>x0_val) else (x0_val-x1_val);
+		label_str = common.label_format(x_delta) + self.x_units
+		txt = gltext.Text(label_str, font_size=MARKER_LABEL_FONT_SIZE)
+		w, h = txt.get_size()
+		self._draw_rect(x0+(x1-x0-w)/2-MARKER_LABEL_PADDING, y1+MARKER_LABEL_PADDING, w+2*MARKER_LABEL_PADDING, h+2*MARKER_LABEL_PADDING)
+		txt.draw_text(wx.Point(x0+(x1-x0-w)/2, y1+2*MARKER_LABEL_PADDING))
+
+		y_delta = (y1_val-y0_val) if (y1_val>y0_val) else (y0_val-y1_val);
+                label_str = common.label_format(y_delta) + self.y_units
+		txt = gltext.Text(label_str, font_size=MARKER_LABEL_FONT_SIZE)
+                w, h = txt.get_size()
+		glColor3f(*MARKER_LINE_COLOR_SPEC)
+		self._draw_rect(x1+MARKER_LABEL_PADDING, y0+(y1-y0-h)/2-MARKER_LABEL_PADDING, w+2*MARKER_LABEL_PADDING, h+2*MARKER_LABEL_PADDING)
+                txt.draw_text(wx.Point(x1+2*MARKER_LABEL_PADDING, y0+(y1-y0-h)/2))
_______________________________________________
Patch-gnuradio mailing list
Patch-gnuradio@gnu.org
http://lists.gnu.org/mailman/listinfo/patch-gnuradio

Reply via email to