Skip to content

Commit

Permalink
Merge pull request #162 from nickfong/nbf/vh-copy-paste
Browse files Browse the repository at this point in the history
Implement copying and pasting in the SliceView
  • Loading branch information
grinner authored May 11, 2018
2 parents 24726d3 + 825c51c commit 8daf824
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions cadnano/fileio/lattice.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ def isOddParity(row: int, column: int) -> bool:
# end def

@staticmethod
def distanceFromClosestLatticeCoord(radius: float,
x: float, y: float,
def distanceFromClosestLatticeCoord(x: float, y: float,
radius: float,
scale_factor: float = 1.0) -> Vec2T:
"""Given a x and y position, determine closest lattice coordinate and
the distance to the center of those coordinates.
Expand Down
10 changes: 4 additions & 6 deletions cadnano/fileio/v3decode.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,10 @@ def decodePart( document: DocT,
'crossover_span_angle',
'max_vhelix_length'
):
value = part_dict[key]
part.setProperty(key, value, use_undostack=False)
part.partPropertyChangedSignal.emit(part, key, value)
value = part_dict.get(key)
if value is not None:
part.setProperty(key, value, use_undostack=False)
part.partPropertyChangedSignal.emit(part, key, value)
# end def


Expand All @@ -260,8 +261,6 @@ def importToPart( part_instance : ObjectInstance,
assert isinstance(offset, (tuple, list)) or offset is None
assert isinstance(use_undostack, bool)

# print('Importing to part where use_undostack is %s' % use_undostack)

part = part_instance.reference()
if use_undostack:
undostack = part.undoStack()
Expand Down Expand Up @@ -331,7 +330,6 @@ def importToPart( part_instance : ObjectInstance,
if i not in copied_vh_index_set:
continue
if idx_set is not None:
# print("getting", new_id_num)
fwd_strand_set, rev_strand_set = part.getStrandSets(i + id_num_offset)
fwd_idxs, rev_idxs = idx_set
fwd_colors, rev_colors = color_list[i]
Expand Down
2 changes: 0 additions & 2 deletions cadnano/views/propertyview/propertyeditorwidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,6 @@ def outlinerItemSelectionChanged(self):
item_types = set([item.itemType() for item in selected_items])
num_types = len(item_types)
if num_types != 1: # assume no mixed types for now
# print("outlinerItemSelectionChanged returning1")
# print(item_types)
return
item_type = item_types.pop()
outline_view_obj_list = [item.outlineViewObj() for item in selected_items if item.isSelected()]
Expand Down
4 changes: 4 additions & 0 deletions cadnano/views/sliceview/nucleicacidpartitem.py
Original file line number Diff line number Diff line change
Expand Up @@ -1113,6 +1113,7 @@ def selectToolHoverEnter(self, tool, event):
# placing clipboard's min_id_same_parity on the hovered_coord,
# hint neighboring coords with offsets corresponding to clipboard vhs
hinted_coordinates = []
copied_coordinates = []
for i in range(len(vh_id_list)):
vh_id, vh_len = vh_id_list[i]
position_xy = part.locationQt(vh_id, self.scaleFactor())
Expand All @@ -1122,11 +1123,14 @@ def selectToolHoverEnter(self, tool, event):
self.scale_factor)
hint_coord = (hov_row+(copied_row-min_row), hov_col+(copied_col-min_col))
hinted_coordinates.append(hint_coord)
copied_coordinates.append((copied_row, copied_col))

# If any of the highlighted coordinates conflict with any existing VHs, abort
if any(coord in self.coordinates_to_vhid.keys() for coord in hinted_coordinates):
print('Conflict')
self.copypaste_origin_offset = None
return
print(self.coordinates_to_vhid)

for i, hint_coord in enumerate(hinted_coordinates):
self.griditem.showCreateHint(hint_coord, next_idnums=(i+id_offset, i+id_offset))
Expand Down
2 changes: 1 addition & 1 deletion cadnano/views/sliceview/tools/selectslicetool.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ def pasteClipboard(self):
return

doc.undoStack().beginMacro("Paste VirtualHelices")
new_vh_set = v3decode.importToPart(part_instance, self.clipboard, offset, ignore_neighbors=True)
new_vh_set = v3decode.importToPart(part_instance, self.clipboard, offset)
doc.undoStack().endMacro()
self.modelClear()
self.clipboard = None
Expand Down

0 comments on commit 8daf824

Please sign in to comment.