def isStrandInSet(self, strand: StrandT) -> bool: sl = self.strand_array if sl[strand.lowIdx()] == strand and sl[strand.highIdx()] == strand: return True else: return False
def _updateAppearance(self, strand: StrandT): """Prepare Strand for drawing, positions are relative to the :class:`PathVirtualHelixItem`: 1. Show or hide caps depending on L and R connectivity. 2. Determine line coordinates. 3. Apply paint styles. """ # 0. Setup vhi = self._virtual_helix_item bw = _BASE_WIDTH half_base_width = bw / 2.0 low_idx, high_idx = strand.lowIdx(), strand.highIdx() l_upper_left_x, l_upper_left_y = vhi.upperLeftCornerOfBase( low_idx, strand) h_upper_left_x, h_upper_left_y = vhi.upperLeftCornerOfBase( high_idx, strand) low_cap = self._low_cap high_cap = self._high_cap dual_cap = self._dual_cap # 1. Cap visibilty lx = l_upper_left_x + bw # draw from right edge of base low_cap.safeSetPos(l_upper_left_x, l_upper_left_y) if strand.connectionLow() is not None: # has low xover # if we are hiding it, we might as well make sure it is reparented to the StrandItem low_cap.restoreParent() low_cap.hide() else: # has low cap if not low_cap.isVisible(): low_cap.show() hx = h_upper_left_x # draw to edge of base high_cap.safeSetPos(h_upper_left_x, h_upper_left_y) if strand.connectionHigh() is not None: # has high xover # if we are hiding it, we might as well make sure it is reparented to the StrandItem high_cap.restoreParent() high_cap.hide() else: # has high cap if not high_cap.isVisible(): high_cap.show() # special case: single-base strand with no L or H connections, # (unconnected caps were made visible in previous block of code) if strand.length() == 1 and (low_cap.isVisible() and high_cap.isVisible()): low_cap.hide() high_cap.hide() dual_cap.safeSetPos(l_upper_left_x, l_upper_left_y) dual_cap.show() else: dual_cap.hide() # 2. Xover drawing xo = self.xover_3p_end if strand.connection3p(): xo.update(strand) xo.showIt() else: xo.restoreParent() xo.hideIt() # 3. Refresh insertionItems if necessary drawing self.refreshInsertionItems(strand) # 4. Line drawing hy = ly = l_upper_left_y + half_base_width self.setLine(lx, ly, hx, hy) rectf = QRectF(l_upper_left_x + bw, l_upper_left_y, bw * (high_idx - low_idx - 1), bw) self._click_area.setRect(rectf) self._updateColor(strand)
def _updateAppearance(self, strand: StrandT): """Prepare Strand for drawing, positions are relative to the :class:`PathVirtualHelixItem`: 1. Show or hide caps depending on L and R connectivity. 2. Determine line coordinates. 3. Apply paint styles. """ # 0. Setup vhi = self._virtual_helix_item bw = _BASE_WIDTH half_base_width = bw / 2.0 low_idx, high_idx = strand.lowIdx(), strand.highIdx() l_upper_left_x, l_upper_left_y = vhi.upperLeftCornerOfBase(low_idx, strand) h_upper_left_x, h_upper_left_y = vhi.upperLeftCornerOfBase(high_idx, strand) low_cap = self._low_cap high_cap = self._high_cap dual_cap = self._dual_cap # 1. Cap visibilty lx = l_upper_left_x + bw # draw from right edge of base low_cap.safeSetPos(l_upper_left_x, l_upper_left_y) if strand.connectionLow() is not None: # has low xover # if we are hiding it, we might as well make sure it is reparented to the StrandItem low_cap.restoreParent() low_cap.hide() else: # has low cap if not low_cap.isVisible(): low_cap.show() hx = h_upper_left_x # draw to edge of base high_cap.safeSetPos(h_upper_left_x, h_upper_left_y) if strand.connectionHigh() is not None: # has high xover # if we are hiding it, we might as well make sure it is reparented to the StrandItem high_cap.restoreParent() high_cap.hide() else: # has high cap if not high_cap.isVisible(): high_cap.show() # special case: single-base strand with no L or H connections, # (unconnected caps were made visible in previous block of code) if strand.length() == 1 and (low_cap.isVisible() and high_cap.isVisible()): low_cap.hide() high_cap.hide() dual_cap.safeSetPos(l_upper_left_x, l_upper_left_y) dual_cap.show() else: dual_cap.hide() # 2. Xover drawing xo = self.xover_3p_end if strand.connection3p(): xo.update(strand) xo.showIt() else: xo.restoreParent() xo.hideIt() # 3. Refresh insertionItems if necessary drawing self.refreshInsertionItems(strand) # 4. Line drawing hy = ly = l_upper_left_y + half_base_width self.setLine(lx, ly, hx, hy) rectf = QRectF(l_upper_left_x + bw, l_upper_left_y, bw*(high_idx - low_idx - 1), bw) self._click_area.setRect(rectf) self._updateColor(strand)