Skip to content

Commit

Permalink
Fix paste disabling when VHs conflict
Browse files Browse the repository at this point in the history
Add lattice coordinates to coordinates_to_vhid so that conflicting VHs
can be detected
  • Loading branch information
nickfong committed Apr 27, 2018
1 parent 9055420 commit 4769654
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions cadnano/views/sliceview/nucleicacidpartitem.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,8 @@ def partVirtualHelixAddedSlot(self, sender: NucleicAcidPart,

assert len(self.coordinates_to_vhid.keys()) == len(set(self.coordinates_to_vhid.keys()))
assert len(self.coordinates_to_vhid.values()) == len(set(self.coordinates_to_vhid.values()))
else:
self.coordinates_to_vhid[coordinates] = id_num
# end def

def partVirtualHelixRemovingSlot(self, sender: NucleicAcidPart,
Expand Down Expand Up @@ -1111,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 @@ -1120,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

0 comments on commit 4769654

Please sign in to comment.