コード例 #1
0
    def __init__(self, model_part, parent=None):
        """
        Parent should be either a SliceRootItem, or an AssemblyItem.

        Invariant: keys in _empty_helix_hash = range(_nrows) x range(_ncols)
        where x is the cartesian product.
        
        Order matters for deselector, probe, and setlattice
        """
        super(PartItem, self).__init__(parent)
        self._part = model_part
        self._controller = PartItemController(self, model_part)
        self._active_slice_item = ActiveSliceItem(self,
                                                  model_part.activeBaseIndex())
        self._scaleFactor = self._RADIUS / model_part.radius()
        self._empty_helix_hash = {}
        self._virtual_helix_hash = {}
        self._nrows, self._ncols = 0, 0
        self._rect = QRectF(0, 0, 0, 0)
        self._initDeselector()
        # Cache of VHs that were active as of last call to activeSliceChanged
        # If None, all slices will be redrawn and the cache will be filled.
        # Connect destructor. This is for removing a part from scenes.
        self.probe = self.IntersectionProbe(self)
        # initialize the PartItem with an empty set of old coords
        self._setLattice([], model_part.generatorFullLattice())
        self.setFlag(QGraphicsItem.ItemHasNoContents)  # never call paint
        self.setZValue(styles.ZPARTITEM)
        self._initModifierCircle()
コード例 #2
0
 def __init__(self, model_part, viewroot, active_tool_getter, parent):
     """parent should always be pathrootitem"""
     super(PartItem, self).__init__(parent)
     self._model_part = m_p = model_part
     self._viewroot = viewroot
     self._getActiveTool = active_tool_getter
     self._activeSliceItem = ActiveSliceItem(self, m_p.activeBaseIndex())
     self._active_virtual_helix_item = None
     self._controller = PartItemController(self, m_p)
     self._pre_xover_items = []  # crossover-related
     self._virtual_helix_hash = {}
     self._virtual_helix_item_list = []
     self._vh_rect = QRectF()
     self.setAcceptHoverEvents(True)
     self._initModifierRect()
     self._initResizeButtons()
     self._proxy_parent = ProxyParentItem(self)
     self._proxy_parent.setFlag(QGraphicsItem.ItemHasNoContents)