Skip to content

Commit

Permalink
fixed reference check issue, added search and replace to control list
Browse files Browse the repository at this point in the history
  • Loading branch information
gbarlier committed Apr 9, 2013
1 parent 8959731 commit 0ba8f2c
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 7 deletions.
30 changes: 24 additions & 6 deletions anim_picker/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -1924,7 +1924,10 @@ def set_handles(self, handles=list()):
# Set current visibility status
for handle in self.handles:
handle.setVisible(self.get_edit_status())


# Set new point count
self.point_count = len(self.handles)

#===========================================================================
# Mouse events ---
def hoverEnterEvent(self, event=None):
Expand Down Expand Up @@ -2410,7 +2413,7 @@ def search_and_replace_controls(self):
# Open Search and replace dialog window
search, replace, ok = SearchAndReplaceDialog.get()
if not ok:
return
return False

# Parse controls
node_missing = False
Expand All @@ -2429,6 +2432,8 @@ def search_and_replace_controls(self):
# Update list
self.set_control_list(controls)

return True

def select_associated_controls(self, modifier=None):
'''Will select maya associated controls
'''
Expand Down Expand Up @@ -3012,14 +3017,21 @@ def add_target_control_field(self):

btn = CallbackButton(callback=self.add_selected_controls_event)
btn.setText('Add Selection')
btn.setToolTip('Add selected controls to list')
btn.setMinimumWidth(75)
btn_layout1.addWidget(btn)

btn = CallbackButton(callback=self.remove_controls_event)
btn.setText('Remove')
btn.setToolTip('Remove selected controls')
btn.setMinimumWidth(75)
btn_layout1.addWidget(btn)

btn = CallbackButton(callback=self.search_replace_controls_event)
btn.setText('Search & Replace')
btn.setToolTip('Will search and replace all controls names')
layout.addWidget(btn)

self.right_layout.addWidget(group_box)

def add_custom_menus_field(self):
Expand Down Expand Up @@ -3220,8 +3232,8 @@ def _populate_ctrl_list_widget(self):
item.setText(controls[i])
self.control_list.addItem(item)

if controls:
self.control_list.setCurrentRow(0)
# if controls:
# self.control_list.setCurrentRow(0)

def edit_ctrl_name_event(self, item=None):
'''Double click event on associated ctrls list
Expand Down Expand Up @@ -3267,7 +3279,13 @@ def remove_controls_event(self):

# Update display
self._populate_ctrl_list_widget()


def search_replace_controls_event(self):
'''Will search and replace controls names for related picker item
'''
if self.picker_item.search_and_replace_controls():
self._populate_ctrl_list_widget()

def get_controls_from_list(self):
'''Return the controls from list widget
'''
Expand Down Expand Up @@ -3460,7 +3478,7 @@ def add_character_selector(self):
self.char_selector_cb.nodes = list()

# Add option buttons
btns_layout = QtGui.QHBoxLayout(box)
btns_layout = QtGui.QHBoxLayout()
box_layout.addLayout(btns_layout)

# Add horizont spacer
Expand Down
5 changes: 4 additions & 1 deletion anim_picker/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,11 @@ def exists(self):
def _assert_exists(self):
assert self.exists(), 'Data node "%s" not found.'%self.name

def is_referenced(self):
return cmds.referenceQuery(self.name, inr=True)

def _assert_not_referenced(self):
assert not cmds.referenceQuery(self.name, inr=True), 'Data node "%s" is referenced, and can not be modified.'%self.name
assert self.is_referenced, 'Data node "%s" is referenced, and can not be modified.'%self.name

def create(self):
'''Will create data node
Expand Down

0 comments on commit 0ba8f2c

Please sign in to comment.