[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r7671 - in grc/branches/grc_reloaded: notes src/grc sr
From: |
jblum |
Subject: |
[Commit-gnuradio] r7671 - in grc/branches/grc_reloaded: notes src/grc src/grc/elements src/grc/gui src/grc/gui/elements src/grc/platforms/gnuradio_python |
Date: |
Wed, 13 Feb 2008 20:22:48 -0700 (MST) |
Author: jblum
Date: 2008-02-13 20:22:48 -0700 (Wed, 13 Feb 2008)
New Revision: 7671
Added:
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/default_flow_graph.grc.xml
Modified:
grc/branches/grc_reloaded/notes/todo.txt
grc/branches/grc_reloaded/src/grc/ActionHandler.py
grc/branches/grc_reloaded/src/grc/Actions.py
grc/branches/grc_reloaded/src/grc/elements/FlowGraph.py
grc/branches/grc_reloaded/src/grc/elements/Param.py
grc/branches/grc_reloaded/src/grc/elements/Platform.py
grc/branches/grc_reloaded/src/grc/gui/DrawingArea.py
grc/branches/grc_reloaded/src/grc/gui/MainWindow.py
grc/branches/grc_reloaded/src/grc/gui/SignalBlockSelectionWindow.py
grc/branches/grc_reloaded/src/grc/gui/elements/Connection.py
grc/branches/grc_reloaded/src/grc/gui/elements/FlowGraph.py
grc/branches/grc_reloaded/src/grc/gui/elements/Param.py
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/Platform.py
Log:
undo and redo, default flow graph
Modified: grc/branches/grc_reloaded/notes/todo.txt
===================================================================
--- grc/branches/grc_reloaded/notes/todo.txt 2008-02-14 02:13:11 UTC (rev
7670)
+++ grc/branches/grc_reloaded/notes/todo.txt 2008-02-14 03:22:48 UTC (rev
7671)
@@ -8,7 +8,6 @@
reload(usrp) in usrp diagnostics
setup.py for grc
-
############ Blocks to Add: ####################
-ofdm (blks2)
-cpm (blks2)
@@ -54,4 +53,4 @@
############ connect packet mod to demod: ####################
gr.packed_to_unpacked_bb(self.bits_per_symbol(), gr.GR_MSB_FIRST)
gr.unpack_k_bits_bb(self.bits_per_symbol())
-
\ No newline at end of file
+
Modified: grc/branches/grc_reloaded/src/grc/ActionHandler.py
===================================================================
--- grc/branches/grc_reloaded/src/grc/ActionHandler.py 2008-02-14 02:13:11 UTC
(rev 7670)
+++ grc/branches/grc_reloaded/src/grc/ActionHandler.py 2008-02-14 03:22:48 UTC
(rev 7671)
@@ -240,26 +240,19 @@
gui.HotKeysDialog()
elif state == MATH_EXPR_WINDOW_DISPLAY:
gui.MathExprDialog()
- elif state == FLOW_GRAPH_WINDOW_RESIZE:
+ elif state == FLOW_GRAPH_WINDOW_RESIZE: #TODO remove
dimensions =
gui.FlowGraphWindowSizeDialog(self.get_flow_graph().get_size_request()).run()
if dimensions:
self.get_flow_graph().set_size_request(*dimensions)
self.get_page().get_state_cache().save_new_state(self.get_flow_graph().export_data())
self.get_page().set_saved(False)
##############################################################################################
- # Variable and Param Modifications
+ # Param Modifications
##############################################################################################
elif state == BLOCK_PARAM_MODIFY:
if self.get_flow_graph().param_modify_selected():
self.get_page().get_state_cache().save_new_state(self.get_flow_graph().export_data())
- self.get_page().set_saved(False)
- elif state == VARIABLE_MODIFY:
-
self.get_page().get_state_cache().save_new_state(self.get_flow_graph().export_data())
- self.get_page().set_saved(False)
- self.get_flow_graph().update()
- elif state == VARIABLE_REORDER:
-
self.get_page().get_state_cache().save_new_state(self.get_flow_graph().export_data())
- self.get_page().set_saved(False)
+ self.get_page().set_saved(False)
##############################################################################################
# Undo/Redo
##############################################################################################
@@ -268,12 +261,14 @@
if n:
self.handle_states(NOTHING_SELECT)
self.get_flow_graph().import_data(n)
+ self.get_flow_graph().update()
self.get_page().set_saved(False)
elif state == FLOW_GRAPH_REDO:
n = self.get_page().get_state_cache().get_next_state()
if n:
self.handle_states(NOTHING_SELECT)
self.get_flow_graph().import_data(n)
+ self.get_flow_graph().update()
self.get_page().set_saved(False)
##############################################################################################
# New/Open/Save/Close
@@ -282,7 +277,7 @@
self.main_window.new_page()
elif state == FLOW_GRAPH_OPEN:
file_path =
gui.OpenFlowGraphFileDialog(self.get_flow_graph() and
self.get_page().get_file_path() or '').run()
- if file_path != None:
self.main_window.new_page(file_path, manual_open=True)
+ if file_path: self.main_window.new_page(file_path,
manual_open=True)
elif state == FLOW_GRAPH_CLOSE:
self.main_window.close_page()
elif state == FLOW_GRAPH_SAVE:
@@ -308,7 +303,7 @@
pixbuf.get_from_drawable(pixmap,
pixmap.get_colormap(), 0, 0, 0, 0, width, height)
pixbuf.save(file_path,
IMAGE_FILE_EXTENSION[1:])
##############################################################################################
- # Run/Stop
+ # Exec/Stop
##############################################################################################
elif state == FLOW_GRAPH_EXEC:
if not self.get_page().get_pid_file():
@@ -326,7 +321,7 @@
##############################################################################################
# Global Actions for all States
##############################################################################################
- #set the exec button if the flow graph is valid and is not
already running
+ #set the exec and stop buttons
self.update_exec_stop()
#saved status
get_action_from_name(FLOW_GRAPH_SAVE).set_sensitive(not
self.get_page().get_saved())
Modified: grc/branches/grc_reloaded/src/grc/Actions.py
===================================================================
--- grc/branches/grc_reloaded/src/grc/Actions.py 2008-02-14 02:13:11 UTC
(rev 7670)
+++ grc/branches/grc_reloaded/src/grc/Actions.py 2008-02-14 03:22:48 UTC
(rev 7671)
@@ -53,9 +53,6 @@
CONNECTION_CREATE = 'conection create'
ELEMENT_REMOVE = 'element remove'
-VARIABLE_MODIFY = 'variable modify'
-VARIABLE_REORDER = 'variable reorder'
-
FLOW_GRAPH_OPEN = 'flow graph open'
FLOW_GRAPH_UNDO = 'flow graph undo'
FLOW_GRAPH_REDO = 'flow graph redo'
Modified: grc/branches/grc_reloaded/src/grc/elements/FlowGraph.py
===================================================================
--- grc/branches/grc_reloaded/src/grc/elements/FlowGraph.py 2008-02-14
02:13:11 UTC (rev 7670)
+++ grc/branches/grc_reloaded/src/grc/elements/FlowGraph.py 2008-02-14
03:22:48 UTC (rev 7671)
@@ -171,8 +171,9 @@
source_block_id =
connection_n['source_block_id']
sink_block_id = connection_n['sink_block_id']
#verify the blocks
- assert(source_block_id in self.get_block_ids())
- assert(sink_block_id in self.get_block_ids())
+ block_ids = map(lambda b: b.get_id(),
self.get_blocks())
+ assert(source_block_id in block_ids)
+ assert(sink_block_id in block_ids)
#get the blocks
source_block = self.get_block(source_block_id)
sink_block = self.get_block(sink_block_id)
@@ -187,11 +188,5 @@
sink = sink_block.get_sink(sink_key)
#build the connection
self.connect(source, sink)
- except AssertionError: pass #TODO messages print problem
- return []
-
-
-
-
-
+ except AssertionError: pass #TODO messages print
problem
Modified: grc/branches/grc_reloaded/src/grc/elements/Param.py
===================================================================
--- grc/branches/grc_reloaded/src/grc/elements/Param.py 2008-02-14 02:13:11 UTC
(rev 7670)
+++ grc/branches/grc_reloaded/src/grc/elements/Param.py 2008-02-14 03:22:48 UTC
(rev 7671)
@@ -145,7 +145,7 @@
try:
assert(self.get_type() in self.TYPES)
try: self.evaluate()
- except:
+ except:
#if the evaluate failed but added no error
messages, add the generic one below
if not self.get_error_messages():
self._add_error_message('Value "%s"
cannot be evaluated.'%self.get_value())
Modified: grc/branches/grc_reloaded/src/grc/elements/Platform.py
===================================================================
--- grc/branches/grc_reloaded/src/grc/elements/Platform.py 2008-02-14
02:13:11 UTC (rev 7670)
+++ grc/branches/grc_reloaded/src/grc/elements/Platform.py 2008-02-14
03:22:48 UTC (rev 7671)
@@ -31,18 +31,22 @@
class Platform(_Element):
- def __init__(self, name, key, path):
+ def __init__(self, name, key, path, block_tree, default_flow_graph):
"""!
Make a platform from the arguments.
@param name the platform name
@param key the unique platform key
@param path the file path to this platform
+ @param block_tree the nested tree of block keys and categories
+ @param default_flow_graph the default flow graph file path
@return a platform object
"""
_Element.__init__(self)
self._name = name
self._key = key
self._path = path
+ self._block_tree = block_tree
+ self._default_flow_graph = default_flow_graph
#create a dummy flow graph for the blocks
flow_graph = _Element(self)
#load the blocks
@@ -68,16 +72,12 @@
def is_platform(self): return True
- def get_new_flow_graph(self):
- return self.FlowGraph(self)
+ def get_new_flow_graph(self): return self.FlowGraph(self)
- def get_block_tree(self):
- """
- Get a tree containing all blocks and their categories.
- @return the block tree
- """
- return self.BLOCK_TREE
+ def get_block_tree(self): return self._block_tree
+ def get_default_flow_graph(self): return self._default_flow_graph
+
##############################################
# Access Blocks
##############################################
Modified: grc/branches/grc_reloaded/src/grc/gui/DrawingArea.py
===================================================================
--- grc/branches/grc_reloaded/src/grc/gui/DrawingArea.py 2008-02-14
02:13:11 UTC (rev 7670)
+++ grc/branches/grc_reloaded/src/grc/gui/DrawingArea.py 2008-02-14
03:22:48 UTC (rev 7671)
@@ -114,3 +114,4 @@
if not self.pixmap or (width, height) !=
self.pixmap.get_size():
self.pixmap = gtk.gdk.Pixmap(self.window, width,
height, -1)
self._main_window.get_flow_graph().update()
+ return True
Modified: grc/branches/grc_reloaded/src/grc/gui/MainWindow.py
===================================================================
--- grc/branches/grc_reloaded/src/grc/gui/MainWindow.py 2008-02-14 02:13:11 UTC
(rev 7670)
+++ grc/branches/grc_reloaded/src/grc/gui/MainWindow.py 2008-02-14 03:22:48 UTC
(rev 7671)
@@ -52,10 +52,10 @@
self.set_pid_file('')
#import the file
self.main_window = main_window
- #TODO initial_state =
ParseXML.from_xml(ParseXML.from_file(file_path or INITIAL_FLOW_GRAPH_FILE))
- initial_state = None
- self.state_cache = StateCache(initial_state)
- self.set_file_path(file_path)
+ self.set_file_path(file_path)
+ file_path = file_path or
flow_graph.get_parent().get_default_flow_graph()
+ initial_state = ParseXML.from_xml(ParseXML.from_file(file_path))
+ self.state_cache = StateCache(initial_state)
self.set_saved(True)
#parse xml success, initialize page
gtk.HBox.__init__(self, False, 0)
@@ -246,10 +246,9 @@
"""
self.current_page = self.notebook.get_nth_page(page_num)
Messages.send_page_switch(self.current_page.get_file_path())
- #TODO may not need since we have multiple flow graph instances
now
- #TODO state =
self.get_page().get_state_cache().get_current_state()
- #TODO self.get_flow_graph().from_nested_data(state)
- #TODO self.handle_states(NOTHING_SELECT)
+ state = self.get_page().get_state_cache().get_current_state()
+ self.get_flow_graph().import_data(state)
+ self.handle_states(NOTHING_SELECT)
############################################################
## Report Window
@@ -348,7 +347,7 @@
#remove the page
self.notebook.remove_page(self.notebook.page_num(self.page_to_be_closed))
if ensure and self.notebook.get_n_pages() == 0: self.new_page()
#no pages, make a new one
- self.page_to_be_closed = None #set the page to be closed back
to None
+ self.page_to_be_closed = None #set the page to be closed back
to None
############################################################
## Misc
@@ -395,7 +394,7 @@
Get the selected flow graph.
@return the selected flow graph
"""
- return self.current_page.get_flow_graph()
+ return self.get_page().get_flow_graph()
############################################################
## Helpers
Modified: grc/branches/grc_reloaded/src/grc/gui/SignalBlockSelectionWindow.py
===================================================================
--- grc/branches/grc_reloaded/src/grc/gui/SignalBlockSelectionWindow.py
2008-02-14 02:13:11 UTC (rev 7670)
+++ grc/branches/grc_reloaded/src/grc/gui/SignalBlockSelectionWindow.py
2008-02-14 03:22:48 UTC (rev 7671)
@@ -20,6 +20,8 @@
#The signal block selection window gives the user a tree selection to choose a
signal block.
address@hidden Josh Blum
+#TODO protect against empty categories, make recursive, protect against name
that DNE
+
from grc.Constants import *
import pygtk
pygtk.require('2.0')
Modified: grc/branches/grc_reloaded/src/grc/gui/elements/Connection.py
===================================================================
--- grc/branches/grc_reloaded/src/grc/gui/elements/Connection.py
2008-02-14 02:13:11 UTC (rev 7670)
+++ grc/branches/grc_reloaded/src/grc/gui/elements/Connection.py
2008-02-14 03:22:48 UTC (rev 7671)
@@ -25,8 +25,24 @@
import Colors
class Connection(Element):
- """A graphical connection for ports."""
+ """A graphical connection for ports."""
+ def get_coordinate(self):
+ """!
+ Get the 0,0 coordinate.
+ Coordinates are irrelevant in connection.
+ @return 0, 0
+ """
+ return (0, 0)
+
+ def get_rotation(self):
+ """!
+ Get the 0 degree rotation.
+ Rotations are irrelevant in connection.
+ @return 0
+ """
+ return 0
+
def update(self):
"""Add the horizontal and vertical lines that will connect the
two parameters."""
self.clear()
Modified: grc/branches/grc_reloaded/src/grc/gui/elements/FlowGraph.py
===================================================================
--- grc/branches/grc_reloaded/src/grc/gui/elements/FlowGraph.py 2008-02-14
02:13:11 UTC (rev 7670)
+++ grc/branches/grc_reloaded/src/grc/gui/elements/FlowGraph.py 2008-02-14
03:22:48 UTC (rev 7671)
@@ -25,13 +25,13 @@
from Colors import BACKGROUND_COLOR, TXT_COLOR
from grc.gui.SignalBlockParamsDialog import SignalBlockParamsDialog
from Element import Element
+from grc.elements import FlowGraph as _FlowGraph
import pygtk
pygtk.require('2.0')
import gtk
import random
-from grc import ParseXML
from grc import Messages
class FlowGraph(Element):
@@ -217,10 +217,10 @@
"""Call update on all elements."""
map(lambda e: e.update(), self.get_elements())
#set the size of the flow graph area
- old_x, old_y = self.get_size()
- try: new_x, new_y = self.get_option('window_size')
- except: new_x, new_y = old_x, old_y
- if new_x != old_x or new_y != old_y:
self.drawing_area.set_size_request(new_x, new_y)
+ #old_x, old_y = self.get_size()
+ #try: new_x, new_y = self.get_option('window_size')
+ #except: new_x, new_y = old_x, old_y
+ #if new_x != old_x or new_y != old_y:
self.drawing_area.set_size_request(new_x, new_y)
#draw the flow graph
self.draw()
@@ -233,7 +233,7 @@
set the Element highlighted, handle the state change, and
redraw the FlowGraph."""
self.set_coordinate(coordinate)
if left_click:
- if self.selected_element != None:
self.selected_element.set_highlighted(False)
+ if self.selected_element:
self.selected_element.set_highlighted(False)
self.count = 0
self.mouse_pressed = True
old_selection = self.selected_element
@@ -262,7 +262,6 @@
self.mouse_pressed = False
self.handle_states(BLOCK_PARAM_MODIFY)
self.draw()
- return True
def handle_mouse_button_release(self, left_click, coordinate):
"""A mouse button is released, record the state."""
@@ -283,19 +282,19 @@
self.move_selected((deltaX,deltaY))
self.handle_states(BLOCK_MOVE)
self.has_moved = False
- return True
def handle_mouse_motion(self, coordinate):
- """The mouse has moved. If mouse_pressed is true, react to the
motions:
- - if an Element is highlighted, this will move the
Element by redrawing it at the new position."""
- get_scroll_pane = self.drawing_area.get_parent()
+ """
+ The mouse has moved. If mouse_pressed is true, react to the
motions:
+ If an Element is highlighted, this will move the Element by
redrawing it at the new position.
+ """
fgW,fgH = self.get_size()
self.count = (1 +
self.count)%MOTION_DETECT_REDRAWING_SENSITIVITY
- # to perform a movement, the mouse must be pressed, an
element selected, count of zero. #
+ #to perform a movement, the mouse must be pressed, an element
selected, count of zero.
if self.mouse_pressed and\
self.count == 0 and\
- self.selected_element != None:
- # The event coordinates must be within 10 pixels
away from the bounds of the flow graph. #
+ self.selected_element:
+ #The event coordinates must be within 10 pixels away
from the bounds of the flow graph.
x,y = coordinate
if x <= BORDER_PROXIMITY_SENSITIVITY:
x = BORDER_PROXIMITY_SENSITIVITY
@@ -305,26 +304,26 @@
y = BORDER_PROXIMITY_SENSITIVITY
if y >= fgH - BORDER_PROXIMITY_SENSITIVITY:
y = fgH - BORDER_PROXIMITY_SENSITIVITY
- # get the change in coordinates #
+ #get the change in coordinates
X,Y = self.get_coordinate()
deltaX = int(x - X)
deltaY = int(y - Y)
- vAdj = get_scroll_pane.get_vadjustment().get_value()
- hAdj = get_scroll_pane.get_hadjustment().get_value()
- width = get_scroll_pane.get_hadjustment().page_size
- height = get_scroll_pane.get_vadjustment().page_size
- # scroll horizontal if we moved near the border #
+ vAdj =
self.get_scroll_pane().get_vadjustment().get_value()
+ hAdj =
self.get_scroll_pane().get_hadjustment().get_value()
+ width =
self.get_scroll_pane().get_hadjustment().page_size
+ height =
self.get_scroll_pane().get_vadjustment().page_size
+ #scroll horizontal if we moved near the border
if x-hAdj > width-SCROLL_PROXIMITY_SENSITIVITY and\
hAdj+SCROLL_DISTANCE < fgW - width:
-
get_scroll_pane.get_hadjustment().set_value(hAdj+SCROLL_DISTANCE)
+
self.get_scroll_pane().get_hadjustment().set_value(hAdj+SCROLL_DISTANCE)
elif x-hAdj < SCROLL_PROXIMITY_SENSITIVITY:
-
get_scroll_pane.get_hadjustment().set_value(hAdj-SCROLL_DISTANCE)
- # scroll vertical if we moved near the border #
+
self.get_scroll_pane().get_hadjustment().set_value(hAdj-SCROLL_DISTANCE)
+ #scroll vertical if we moved near the border
if y-vAdj > height-SCROLL_PROXIMITY_SENSITIVITY and\
vAdj+SCROLL_DISTANCE < fgH - height:
-
get_scroll_pane.get_vadjustment().set_value(vAdj+SCROLL_DISTANCE)
+
self.get_scroll_pane().get_vadjustment().set_value(vAdj+SCROLL_DISTANCE)
elif y-vAdj < SCROLL_PROXIMITY_SENSITIVITY:
-
get_scroll_pane.get_vadjustment().set_value(vAdj-SCROLL_DISTANCE)
- # move the selected element and record the new
coordinate #
+
self.get_scroll_pane().get_vadjustment().set_value(vAdj-SCROLL_DISTANCE)
+ #move the selected element and record the new
coordinate
self.move_selected((deltaX, deltaY))
self.set_coordinate(coordinate)
Modified: grc/branches/grc_reloaded/src/grc/gui/elements/Param.py
===================================================================
--- grc/branches/grc_reloaded/src/grc/gui/elements/Param.py 2008-02-14
02:13:11 UTC (rev 7670)
+++ grc/branches/grc_reloaded/src/grc/gui/elements/Param.py 2008-02-14
03:22:48 UTC (rev 7671)
@@ -198,11 +198,11 @@
tail,head = path.split(data)
if len(head) >= suggested_length:
dt_str = head
else: dt_str =
tail[0:suggested_length-len(head)] + '...' + head
- elif isinstance(data, (list, tuple)): #vector types
- for i,e in enumerate(data): data[i] = to_str(e)
- # only keep the first X elements of the
list:
- X = (100/len(str(data))) + 1 #display more
for non complex vectors
- dt_str = '[' # replace the
removed elements with a '...'
+ elif isinstance(data, (list, tuple, set)): #vector types
+ data = map(to_str, data)
+ #only keep the first X elements of the list
+ X = (100/len(str(data))) + 1 #display more for
non complex vectors
+ dt_str = '[' #replace the removed elements with
a '...'
for i,f in enumerate(data):
if i < X or i+1 == len(data): #leave
one on the end
dt_str = dt_str + f
Modified:
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/Platform.py
===================================================================
--- grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/Platform.py
2008-02-14 02:13:11 UTC (rev 7670)
+++ grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/Platform.py
2008-02-14 03:22:48 UTC (rev 7671)
@@ -28,7 +28,17 @@
from Port import Source,Sink
from Param import Param as _Param
+PATH = os.path.dirname(__file__)
+
BLOCK_TREE = [
+ ('Sources', [
+
+ ]
+ ),
+ ('Sinks', [
+
+ ]
+ ),
('Operators',[
'add',
'add_const',
@@ -43,10 +53,10 @@
),
]
+DEFAULT_FLOW_GRAPH = PATH + '/default_flow_graph.grc.xml'
+
class Platform(_Platform):
- BLOCK_TREE = BLOCK_TREE
-
def __init__(self):
"""!
Make a platform from the arguments.
@@ -59,7 +69,9 @@
self,
name='GNURadio Python',
key='gnuradio_python',
- path=os.path.dirname(__file__),
+ path=PATH,
+ block_tree = BLOCK_TREE,
+ default_flow_graph = DEFAULT_FLOW_GRAPH,
)
##############################################
Added:
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/default_flow_graph.grc.xml
===================================================================
---
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/default_flow_graph.grc.xml
(rev 0)
+++
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/default_flow_graph.grc.xml
2008-02-14 03:22:48 UTC (rev 7671)
@@ -0,0 +1,18 @@
+<?xml version="1.0"?>
+<flow_graph>
+ <block>
+ <key>options</key>
+ <param>
+ <key>id</key>
+ <value>options</value>
+ </param>
+ <param>
+ <key>window_size</key>
+ <value>1000, 1000</value>
+ </param>
+ <param>
+ <key>position</key>
+ <value>{'x': 20, 'y': 20, 'rot': 0}</value>
+ </param>
+ </block>
+</flow_graph>
\ No newline at end of file
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r7671 - in grc/branches/grc_reloaded: notes src/grc src/grc/elements src/grc/gui src/grc/gui/elements src/grc/platforms/gnuradio_python,
jblum <=