[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r9071 - in grc/trunk/src: grc grc/gui grc/gui/elements
From: |
jblum |
Subject: |
[Commit-gnuradio] r9071 - in grc/trunk/src: grc grc/gui grc/gui/elements grc_gnuradio |
Date: |
Wed, 30 Jul 2008 19:55:59 -0600 (MDT) |
Author: jblum
Date: 2008-07-30 19:55:59 -0600 (Wed, 30 Jul 2008)
New Revision: 9071
Modified:
grc/trunk/src/grc/ActionHandler.py
grc/trunk/src/grc/Actions.py
grc/trunk/src/grc/gui/DrawingArea.py
grc/trunk/src/grc/gui/elements/FlowGraph.py
grc/trunk/src/grc_gnuradio/FlowGraph.py
grc/trunk/src/grc_gnuradio/Param.py
Log:
control select mask in flow graph
Modified: grc/trunk/src/grc/ActionHandler.py
===================================================================
--- grc/trunk/src/grc/ActionHandler.py 2008-07-31 01:33:27 UTC (rev 9070)
+++ grc/trunk/src/grc/ActionHandler.py 2008-07-31 01:55:59 UTC (rev 9071)
@@ -57,6 +57,7 @@
self.main_window = gui.MainWindow(self.handle_states, platform)
self.main_window.connect('delete_event', self._quit)
self.main_window.connect('key_press_event',
self._handle_key_press)
+ self.main_window.connect('key_release_event',
self._handle_key_release)
self.get_page = self.main_window.get_page
self.get_flow_graph = self.main_window.get_flow_graph
self.get_focus_flag =
self.main_window.drawing_area.get_focus_flag
@@ -70,6 +71,8 @@
gtk.gdk.threads_init()
gtk.main()
+ def _handle_key_release(self, widget, event):
self.get_flow_graph().set_ctrl_mask(False)
+
def _handle_key_press(self, widget, event):
"""
Handle key presses from the keyboard.
@@ -79,11 +82,12 @@
@return true if the flow graph is in active use
"""
keyname = gtk.gdk.keyval_name(event.keyval)
- #print 'Key "%s" (%d) was pressed' % (keyname, event.keyval)
ctrl = event.state & gtk.gdk.CONTROL_MASK
alt = event.state & gtk.gdk.MOD1_MASK
shift = event.state & gtk.gdk.SHIFT_MASK
- #################### save/open/new/close
###############################
+ #update flow graph ctrl mask
+ self.get_flow_graph().set_ctrl_mask(keyname in ('Control_L',
'Control_R'))
+ #################### save/open/new/close
###############################
if ctrl and keyname == 's':
self.handle_states(FLOW_GRAPH_SAVE)
elif ctrl and keyname == 'o':
@@ -92,45 +96,45 @@
self.handle_states(FLOW_GRAPH_NEW)
elif ctrl and keyname == 'q':
self.handle_states(FLOW_GRAPH_CLOSE)
- #################### Cut/Copy/Paste
###############################
+ #################### Cut/Copy/Paste
###############################
elif self.get_focus_flag() and ctrl and keyname == 'x': #mouse
focus
self.handle_states(BLOCK_CUT)
elif self.get_focus_flag() and ctrl and keyname == 'c': #mouse
focus
self.handle_states(BLOCK_COPY)
elif self.get_focus_flag() and ctrl and keyname == 'v': #mouse
focus
self.handle_states(BLOCK_PASTE)
- #################### Undo/Redo
###############################
+ #################### Undo/Redo ###############################
elif ctrl and keyname == 'z':
self.handle_states(FLOW_GRAPH_UNDO)
elif ctrl and keyname == 'y':
self.handle_states(FLOW_GRAPH_REDO)
- #################### Delete ###############################
+ #################### Delete ###############################
elif self.get_focus_flag() and keyname == 'Delete': #mouse
focus
self.handle_states(ELEMENT_DELETE)
- #################### Params ###############################
+ #################### Params ###############################
elif self.get_focus_flag() and keyname == 'Return': #mouse
focus
self.handle_states(BLOCK_PARAM_MODIFY)
- #################### Rotate ###############################
+ #################### Rotate ###############################
elif self.get_focus_flag() and keyname == 'Right': #mouse focus
self.handle_states(BLOCK_ROTATE_RIGHT)
elif self.get_focus_flag() and keyname == 'Left': #mouse focus
self.handle_states(BLOCK_ROTATE_LEFT)
- #################### Enable/Disable
###############################
+ #################### Enable/Disable
###############################
elif self.get_focus_flag() and keyname == 'e': #mouse focus
self.handle_states(BLOCK_ENABLE)
elif self.get_focus_flag() and keyname == 'd': #mouse focus
self.handle_states(BLOCK_DISABLE)
- #################### Data Type
###############################
+ #################### Data Type ###############################
elif self.get_focus_flag() and keyname == 'Down': #mouse focus
self.handle_states(BLOCK_INC_TYPE)
elif self.get_focus_flag() and keyname == 'Up': #mouse focus
self.handle_states(BLOCK_DEC_TYPE)
- #################### Port Controllers
###############################
+ #################### Port Controllers
###############################
elif self.get_focus_flag() and keyname in ('equal','plus',
'KP_Add'): #mouse focus
self.handle_states(PORT_CONTROLLER_INC)
elif self.get_focus_flag() and keyname in ('minus',
'KP_Subtract'): #mouse focus
self.handle_states(PORT_CONTROLLER_DEC)
- #################### Gen/Exec/Stop/Print
###############################
+ #################### Gen/Exec/Stop/Print
###############################
elif keyname == 'F5':
self.handle_states(FLOW_GRAPH_GEN)
elif keyname == 'F6':
@@ -172,7 +176,7 @@
"""
#print state
##############################################################################################
- # Initalize/Quit
+ # Initalize/Quit
##############################################################################################
if state == APPLICATION_INITIALIZE:
for action in ACTIONS_LIST: action.set_sensitive(False)
#set all actions disabled
@@ -193,7 +197,7 @@
gtk.main_quit()
exit(0)
##############################################################################################
- # Selections
+ # Selections
##############################################################################################
elif state == ELEMENT_SELECT:
self.get_flow_graph().update()
@@ -201,7 +205,7 @@
self.get_flow_graph().unselect()
self.get_flow_graph().update()
##############################################################################################
- # Enable/Disable
+ # Enable/Disable
##############################################################################################
elif state == BLOCK_ENABLE:
if self.get_flow_graph().enable_selected(True):
@@ -214,7 +218,7 @@
self.get_page().get_state_cache().save_new_state(self.get_flow_graph().export_data())
self.get_page().set_saved(False)
##############################################################################################
- # Cut/Copy/Paste
+ # Cut/Copy/Paste
##############################################################################################
elif state == BLOCK_CUT:
self.handle_states(BLOCK_COPY)
@@ -228,7 +232,7 @@
self.get_page().get_state_cache().save_new_state(self.get_flow_graph().export_data())
self.get_page().set_saved(False)
##############################################################################################
- # Move/Rotate/Delete/Create
+ # Move/Rotate/Delete/Create
##############################################################################################
elif state == BLOCK_MOVE:
self.get_page().get_state_cache().save_new_state(self.get_flow_graph().export_data())
@@ -275,7 +279,7 @@
self.get_page().get_state_cache().save_new_state(self.get_flow_graph().export_data())
self.get_page().set_saved(False)
##############################################################################################
- # Window stuff
+ # Window stuff
##############################################################################################
elif state == PREFS_WINDOW_DISPLAY:
gui.PreferencesDialog()
@@ -285,7 +289,7 @@
elif state == HOTKEYS_WINDOW_DISPLAY:
gui.HotKeysDialog()
##############################################################################################
- # Param Modifications
+ # Param Modifications
##############################################################################################
elif state == BLOCK_PARAM_MODIFY:
if self.get_flow_graph().param_modify_selected():
@@ -293,7 +297,7 @@
self.get_page().get_state_cache().save_new_state(self.get_flow_graph().export_data())
self.get_page().set_saved(False)
##############################################################################################
- # Undo/Redo
+ # Undo/Redo
##############################################################################################
elif state == FLOW_GRAPH_UNDO:
n = self.get_page().get_state_cache().get_prev_state()
@@ -310,7 +314,7 @@
self.get_flow_graph().update()
self.get_page().set_saved(False)
##############################################################################################
- # New/Open/Save/Close
+ # New/Open/Save/Close
##############################################################################################
elif state == FLOW_GRAPH_NEW:
self.main_window.new_page()
@@ -344,7 +348,7 @@
pixbuf.get_from_drawable(pixmap,
pixmap.get_colormap(), 0, 0, 0, 0, width, height)
pixbuf.save(file_path, IMAGE_FILE_EXTENSION[1:])
##############################################################################################
- # Gen/Exec/Stop
+ # Gen/Exec/Stop
##############################################################################################
elif state == FLOW_GRAPH_GEN:
if not self.get_page().get_pid():
@@ -370,7 +374,7 @@
pass
else: print '!!! State "%s" not handled !!!'%state
##############################################################################################
- # Global Actions for all States
+ # Global Actions for all States
##############################################################################################
#update general buttons
get_action_from_name(ELEMENT_DELETE).set_sensitive(bool(self.get_flow_graph().get_selected_elements()))
@@ -382,16 +386,8 @@
get_action_from_name(BLOCK_COPY).set_sensitive(bool(self.get_flow_graph().get_selected_blocks()))
get_action_from_name(BLOCK_PASTE).set_sensitive(bool(self.clipboard))
#update enable/disable
- get_action_from_name(BLOCK_ENABLE).set_sensitive(bool(
- self.get_flow_graph().get_selected_blocks() or \
- self.get_flow_graph().get_selected_block() and \
- not
self.get_flow_graph().get_selected_block().get_enabled()
- ))
- get_action_from_name(BLOCK_DISABLE).set_sensitive(bool(
- self.get_flow_graph().get_selected_blocks() or \
- self.get_flow_graph().get_selected_block() and \
- self.get_flow_graph().get_selected_block().get_enabled()
- ))
+
get_action_from_name(BLOCK_ENABLE).set_sensitive(bool(self.get_flow_graph().get_selected_blocks()))
+
get_action_from_name(BLOCK_DISABLE).set_sensitive(bool(self.get_flow_graph().get_selected_blocks()))
#set the exec and stop buttons
self.update_exec_stop()
#saved status
Modified: grc/trunk/src/grc/Actions.py
===================================================================
--- grc/trunk/src/grc/Actions.py 2008-07-31 01:33:27 UTC (rev 9070)
+++ grc/trunk/src/grc/Actions.py 2008-07-31 01:55:59 UTC (rev 9071)
@@ -28,12 +28,9 @@
######################################################################################################
# States
######################################################################################################
-
APPLICATION_INITIALIZE = 'app init'
APPLICATION_QUIT = 'app quit'
-
PARAM_MODIFY = 'param modify'
-
BLOCK_MOVE = 'block move'
BLOCK_ROTATE_LEFT = 'block rotate left'
BLOCK_ROTATE_RIGHT = 'block rotate right'
@@ -42,19 +39,15 @@
BLOCK_DEC_TYPE = 'block decrement type'
BLOCK_ENABLE = 'block enable'
BLOCK_DISABLE = 'block disable'
-
BLOCK_CUT = 'block cut'
BLOCK_COPY = 'block copy'
BLOCK_PASTE = 'block paste'
-
PORT_CONTROLLER_INC = 'port controller increment'
PORT_CONTROLLER_DEC = 'port controller decrement'
-
ELEMENT_CREATE = 'element create'
ELEMENT_DELETE = 'element delete'
ELEMENT_SELECT = 'element select'
NOTHING_SELECT = 'nothing select'
-
FLOW_GRAPH_OPEN = 'flow graph open'
FLOW_GRAPH_UNDO = 'flow graph undo'
FLOW_GRAPH_REDO = 'flow graph redo'
@@ -66,7 +59,6 @@
FLOW_GRAPH_EXEC = 'flow graph exec'
FLOW_GRAPH_KILL = 'flow graph kill'
FLOW_GRAPH_SCREEN_CAPTURE = 'flow graph screen capture'
-
ABOUT_WINDOW_DISPLAY = 'about window display'
HOTKEYS_WINDOW_DISPLAY = 'hotkeys window display'
PREFS_WINDOW_DISPLAY = 'prefs window display'
@@ -74,7 +66,6 @@
######################################################################################################
# Actions
######################################################################################################
-
ACTIONS_LIST = (
gtk.Action(FLOW_GRAPH_NEW, '_New', 'Create a new flow graph',
'gtk-new'),
gtk.Action(FLOW_GRAPH_OPEN, '_Open', 'Open an existing flow graph',
'gtk-open'),
@@ -84,12 +75,12 @@
gtk.Action(APPLICATION_QUIT, '_Quit', 'Quit program', 'gtk-quit'),
gtk.Action(FLOW_GRAPH_UNDO, '_Undo', 'Undo a change to the flow graph',
'gtk-undo'),
gtk.Action(FLOW_GRAPH_REDO, '_Redo', 'Redo a change to the flow graph',
'gtk-redo'),
- gtk.Action(ELEMENT_DELETE, '_Delete', 'Delete the selected block',
'gtk-delete'),
- gtk.Action(BLOCK_ROTATE_LEFT, 'Rotate _Left', 'Rotate the block 90
degrees', 'gtk-go-back'),
- gtk.Action(BLOCK_ROTATE_RIGHT, 'Rotate _Right', 'Rotate the block -90
degrees', 'gtk-go-forward'),
+ gtk.Action(ELEMENT_DELETE, '_Delete', 'Delete the selected blocks',
'gtk-delete'),
+ gtk.Action(BLOCK_ROTATE_LEFT, 'Rotate _Left', 'Rotate the selected
blocks 90 degrees', 'gtk-go-back'),
+ gtk.Action(BLOCK_ROTATE_RIGHT, 'Rotate _Right', 'Rotate the selected
blocks -90 degrees', 'gtk-go-forward'),
gtk.Action(BLOCK_PARAM_MODIFY, '_Properties', 'Modify params for the
selected block', 'gtk-properties'),
- gtk.Action(BLOCK_ENABLE, 'E_nable', 'Enable the block', 'gtk-connect'),
- gtk.Action(BLOCK_DISABLE, 'D_isable', 'Disable the block',
'gtk-disconnect'),
+ gtk.Action(BLOCK_ENABLE, 'E_nable', 'Enable the selected blocks',
'gtk-connect'),
+ gtk.Action(BLOCK_DISABLE, 'D_isable', 'Disable the selected blocks',
'gtk-disconnect'),
gtk.Action(BLOCK_CUT, 'Cu_t', 'Cut', 'gtk-cut'),
gtk.Action(BLOCK_COPY, '_Copy', 'Copy', 'gtk-copy'),
gtk.Action(BLOCK_PASTE, '_Paste', 'Paste', 'gtk-paste'),
Modified: grc/trunk/src/grc/gui/DrawingArea.py
===================================================================
--- grc/trunk/src/grc/gui/DrawingArea.py 2008-07-31 01:33:27 UTC (rev
9070)
+++ grc/trunk/src/grc/gui/DrawingArea.py 2008-07-31 01:55:59 UTC (rev
9071)
@@ -29,14 +29,14 @@
"""
DrawingArea is the gtk pixel map that graphical elements may draw
themselves on.
The drawing area also responds to mouse and key events.
- """
-
+ """
+
def __init__(self, main_window):
"""!
DrawingArea contructor.
Connect event handlers.
@param main_window the main_window containing all flow graphs
- """
+ """
self._main_window = main_window
#inject drawing area into main_window
self._main_window.drawing_area = self
@@ -44,50 +44,48 @@
self.set_size_request(MIN_WINDOW_WIDTH, MIN_WINDOW_HEIGHT)
self.connect('expose-event', self._handle_window_expose)
self.connect('motion-notify-event', self._handle_mouse_motion)
- self.connect('button-press-event',
self._handle_mouse_button_press)
- self.connect('button-release-event',
self._handle_mouse_button_release)
+ self.connect('button-press-event',
self._handle_mouse_button_press)
+ self.connect('button-release-event',
self._handle_mouse_button_release)
self.set_events(
gtk.gdk.BUTTON_PRESS_MASK | \
gtk.gdk.POINTER_MOTION_MASK | \
gtk.gdk.BUTTON_RELEASE_MASK | \
gtk.gdk.LEAVE_NOTIFY_MASK | \
gtk.gdk.ENTER_NOTIFY_MASK
- )
- #setup the focus flag
+ )
+ #setup the focus flag
self._focus_flag = False
- self.get_focus_flag = lambda: self._focus_flag
+ self.get_focus_flag = lambda: self._focus_flag
self.connect("leave-notify-event", self._handle_focus_event,
False)
- self.connect("enter-notify-event", self._handle_focus_event,
True)
- #pixmap for drawing to
+ self.connect("enter-notify-event", self._handle_focus_event,
True)
+ #pixmap for drawing
self.pixmap = None
self.gc = None
-
+
def draw(self):
"""!
Draw the pixmap onto this drawing area.
"""
- self.window.draw_drawable(self.gc, self.pixmap, 0, 0, 0, 0, -1,
-1)
-
+ self.window.draw_drawable(self.gc, self.pixmap, 0, 0, 0, 0, -1,
-1)
##########################################################################
- ## Handlers
-
##########################################################################
-
+ ## Handlers
+
##########################################################################
def _handle_focus_event(self, widget, event, focus_flag):
"""Record the focus state of the flow graph window."""
self._focus_flag = focus_flag
-
+
def _handle_mouse_button_press(self, widget, event):
"""!
Forward button click information to the flow graph.
- """
+ """
self._main_window.get_flow_graph().handle_mouse_button_press(
left_click=(event.button == 1),
double_click=(event.type == gtk.gdk._2BUTTON_PRESS),
coordinate=(event.x, event.y),
- )
+ )
return True
-
+
def _handle_mouse_button_release(self, widget, event):
"""!
Forward button release information to the flow graph.
@@ -95,25 +93,25 @@
self._main_window.get_flow_graph().handle_mouse_button_release(
left_click=(event.button == 1),
coordinate=(event.x, event.y),
- )
+ )
return True
-
- def _handle_mouse_motion(self, widget, event):
+
+ def _handle_mouse_motion(self, widget, event):
"""!
Forward mouse motion information to the flow graph.
"""
self._main_window.get_flow_graph().handle_mouse_motion(
coordinate=(event.x, event.y),
- )
+ )
return True
-
- def _handle_window_expose(self, widget, event):
+
+ def _handle_window_expose(self, widget, event):
"""!
Called when the window initially appears or is resized: create
a new pixmap, draw the flow graph.
"""
self.gc = self.window.new_gc()
width, height = self.get_size_request()
- if not self.pixmap or (width, height) !=
self.pixmap.get_size():
+ 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().draw()
return True
Modified: grc/trunk/src/grc/gui/elements/FlowGraph.py
===================================================================
--- grc/trunk/src/grc/gui/elements/FlowGraph.py 2008-07-31 01:33:27 UTC (rev
9070)
+++ grc/trunk/src/grc/gui/elements/FlowGraph.py 2008-07-31 01:55:59 UTC (rev
9071)
@@ -52,13 +52,20 @@
Element.__init__(self)
#when is the flow graph selected? (used by keyboard event
handler)
self.is_selected = lambda: bool(self.get_selected_elements())
+ #ctrl mask
+ self.set_ctrl_mask(False)
#important vars dealing with mouse event tracking
self.element_moved = False
self.mouse_pressed = False
self.unselect()
self.time = 0
self.press_coor = (0, 0)
+ #selected ports
+ self._old_selected_port = None
+ self._new_selected_port = None
+ def set_ctrl_mask(self, ctrl): self._ctrl = ctrl
+
def _get_unique_id(self, base_id=''):
"""!
Get a unique id starting with the base id.
@@ -170,14 +177,14 @@
self.connect(source, sink)
#set all pasted elements selected
for block in selected: selected =
selected.union(set(block.get_connections()))
- self._selected_group = list(selected)
+ self._selected_elements = list(selected)
###########################################################################
# Modify Selected
###########################################################################
def type_controller_modify_selected(self, direction):
- """
- !Change the registered type controller for the selected signal
blocks.
+ """!
+ Change the registered type controller for the selected signal
blocks.
@param direction +1 or -1
@return true for change
"""
@@ -241,9 +248,9 @@
"""
changed = False
for selected_block in self.get_selected_blocks():
- if selected_block.get_enabled() != enable: changed =
True
- selected_block.set_enabled(enable)
- changed = True
+ if selected_block.get_enabled() != enable:
+ selected_block.set_enabled(enable)
+ changed = True
return changed
def move_selected(self, delta_coordinate):
@@ -292,7 +299,7 @@
@return true if changed.
"""
changed = False
- for selected_element in self.get_selected_blocks() +
self.get_selected_connections():
+ for selected_element in self.get_selected_elements():
self.remove_element(selected_element)
changed = True
return changed
@@ -318,7 +325,7 @@
self.get_gc().foreground = Colors.TXT_COLOR
self.get_pixmap().draw_points(self.get_gc(),
points)
#draw multi select rectangle
- if self.mouse_pressed and not
self.get_selected_elements():
+ if self.mouse_pressed and (not
self.get_selected_elements() or self._ctrl):
#coordinates
x1, y1 = self.press_coor
x2, y2 = self.get_coordinate()
@@ -333,8 +340,8 @@
#draw blocks on top of connections
for element in self.get_connections() +
self.get_blocks():
element.draw(self.get_pixmap())
- #draw any selected element as the topmost
- for selected_element in self.get_selected_blocks() +
self.get_selected_connections():
+ #draw selected blocks on top of selected connections
+ for selected_element in self.get_selected_connections()
+ self.get_selected_blocks():
selected_element.draw(self.get_pixmap())
self.get_drawing_area().draw()
@@ -360,31 +367,42 @@
## Get Selected
##########################################################################
def unselect(self):
- """Set selected element to None."""
- self._selected_group = []
+ """!
+ Set selected elements to an empty set.
+ """
+ self._selected_elements = []
def what_is_selected(self, coor, coor_m=None):
"""!
What is selected?
At the given coordinate, return the elements found to be
selected.
If coor_m is unspecified, return a list of only the first
element found to be selected:
- - iterate though the elements backwards since top elements are
at the end of the list
- - if an element is selected, place it at the end of the list so
that is is drawn last,
- and hence on top.
+ Iterate though the elements backwardssince top elements are at
the end of the list.
+ If an element is selected, place it at the end of the list so
that is is drawn last,
+ and hence on top. Update the selected port information.
@param coor the coordinate of the mouse click
@param coor_m the coordinate for multi select
- @return the selected elements or empty list
+ @return the selected blocks and connections or an empty list
"""
+ selected_port = None
selected = set()
#check the elements
for element in reversed(self.get_elements()):
selected_element = element.what_is_selected(coor,
coor_m)
- if selected_element:
- if not coor_m:
- self.get_elements().remove(element)
- self.get_elements().append(element)
- return [selected_element]
- selected.add(selected_element)
+ if not selected_element: continue
+ #update the selected port information
+ if selected_element.is_port():
+ if not coor_m: selected_port = selected_element
+ selected_element = selected_element.get_parent()
+ selected.add(selected_element)
+ #single select mode, break
+ if not coor_m:
+ self.get_elements().remove(element)
+ self.get_elements().append(element)
+ break;
+ #update selected ports
+ self._old_selected_port = self._new_selected_port
+ self._new_selected_port = selected_port
return list(selected)
def get_selected_connections(self):
@@ -404,8 +422,7 @@
"""
selected = set()
for selected_element in self.get_selected_elements():
- if selected_element.is_port():
selected.add(selected_element.get_parent())
- elif selected_element.is_block():
selected.add(selected_element)
+ if selected_element.is_block():
selected.add(selected_element)
return list(selected)
def get_selected_block(self):
@@ -420,7 +437,7 @@
Get the group of selected elements.
@return sub set of elements in this flow graph
"""
- return self._selected_group
+ return self._selected_elements
def get_selected_element(self):
"""!
@@ -429,6 +446,22 @@
"""
return self.get_selected_elements() and
self.get_selected_elements()[0] or None
+ def update_selected_elements(self, selected_elements):
+ """!
+ Update the selected elements.
+ If the control mask is set, merge with the current elements.
+ @param selected_elements a list or set of elements
+ """
+ old_elements = set(self.get_selected_elements())
+ self._selected_elements = list(set(selected_elements))
+ new_elements = set(self.get_selected_elements())
+ #if ctrl, set the selected elements to the union - intersection
of old and new
+ if self._ctrl:
+ self._selected_elements = list(
+ set.union(old_elements, new_elements) -
set.intersection(old_elements, new_elements)
+ )
+ self.handle_states(ELEMENT_SELECT)
+
##########################################################################
## Event Handlers
##########################################################################
@@ -444,29 +477,25 @@
if left_click:
self.time = 0
self.mouse_pressed = True
- old_selection = self.get_selected_element()
new_selection =
self.what_is_selected(self.get_coordinate())
- #update the selections if the new selection is not in
the current blocks/connections
- #allows us to move entire selected groups of
blocks/connections
- if not (
- new_selection and new_selection[0] in \
- self.get_selected_blocks() +
self.get_selected_connections()
- ): self._selected_group = new_selection
+ #update the selections if the new selection is not in
the selected
+ #allows us to move entire selected groups of elements
+ if self._ctrl or not (
+ new_selection and new_selection[0] in
self.get_selected_elements()
+ ): self.update_selected_elements(new_selection)
#this selection and the last were ports, try to connect
them
- if old_selection and self.get_selected_element() and \
- old_selection is not
self.get_selected_element() and \
- self.get_selected_element().is_port() and \
- old_selection.is_port():
+ if self._old_selected_port and self._new_selected_port
and \
+ self._old_selected_port is not
self._new_selected_port:
try:
- self.connect(old_selection,
self.get_selected_element())
+ self.connect(self._old_selected_port,
self._new_selected_port)
self.handle_states(ELEMENT_CREATE)
except: Messages.send_fail_connection()
+ self._old_selected_port = None
+ self._new_selected_port = None
#double click detected, bring up params dialog if
possible
if double_click and self.get_selected_block():
self.mouse_pressed = False
self.handle_states(BLOCK_PARAM_MODIFY)
- #handle the state change with the new selection
- self.handle_states(ELEMENT_SELECT)
def handle_mouse_button_release(self, left_click, coordinate):
"""!
@@ -489,10 +518,9 @@
self.move_selected((deltaX, deltaY))
self.handle_states(BLOCK_MOVE)
self.element_moved = False
- elif not self.element_moved and not
self.get_selected_elements():
- self._selected_group =
self.what_is_selected(self.get_coordinate(), self.press_coor)
- self.update()
- self.draw()
+ elif not self.element_moved and (not
self.get_selected_elements() or self._ctrl):
+
self.update_selected_elements(self.what_is_selected(self.get_coordinate(),
self.press_coor))
+ self.draw()
def handle_mouse_motion(self, coordinate):
"""!
@@ -520,7 +548,7 @@
adj.emit('changed')
#move the selected element and record the new coordinate
X, Y = self.get_coordinate()
- self.move_selected((int(x - X), int(y - Y)))
+ if not self._ctrl: self.move_selected((int(x - X),
int(y - Y)))
self.draw()
self.set_coordinate((x, y))
#update time
Modified: grc/trunk/src/grc_gnuradio/FlowGraph.py
===================================================================
--- grc/trunk/src/grc_gnuradio/FlowGraph.py 2008-07-31 01:33:27 UTC (rev
9070)
+++ grc/trunk/src/grc_gnuradio/FlowGraph.py 2008-07-31 01:55:59 UTC (rev
9071)
@@ -81,7 +81,9 @@
Exclude paramterized variables.
@return a sorted list of variable blocks in order of dependency
(indep -> dep)
"""
- variables = filter(lambda b: b.get_key() in ('variable',
'variable_slider', 'variable_chooser', 'variable_text_box'),
self.get_enabled_blocks())
+ variables = filter(lambda b: b.get_key() in (
+ 'variable', 'variable_slider', 'variable_chooser',
'variable_text_box'
+ ), self.get_enabled_blocks())
#map var id to variable block
id2var = dict([(var.get_id(), var) for var in variables])
#map var id to variable code
Modified: grc/trunk/src/grc_gnuradio/Param.py
===================================================================
--- grc/trunk/src/grc_gnuradio/Param.py 2008-07-31 01:33:27 UTC (rev 9070)
+++ grc/trunk/src/grc_gnuradio/Param.py 2008-07-31 01:55:59 UTC (rev 9071)
@@ -42,8 +42,9 @@
def get_hide(self):
"""!
Get the hide value from the base class.
- If hide was empty and this is a type controller, set hide to
part.
- @return hide the hide param string
+ If hide was empty, and this is a type controller, set hide to
part.
+ If hide was empty, and this is an id of a non variable, set
hide to part.
+ @return hide the hide property string
"""
hide = _Param.get_hide(self)
#hide IO controlling params
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r9071 - in grc/trunk/src: grc grc/gui grc/gui/elements grc_gnuradio,
jblum <=