Example #1
0
    def __init__(self, modelPart, parent=None):
        """
        Parent should be either a SliceRootItem, or an AssemblyItem.

        Invariant: keys in _emptyhelixhash = 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 = modelPart
        self._controller = PartItemController(self, modelPart)
        self._activeSliceItem = ActiveSliceItem(self,
                                                modelPart.activeBaseIndex())
        self._scaleFactor = self._radius / modelPart.radius()
        self._emptyhelixhash = {}
        self._virtualHelixHash = {}
        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([], modelPart.generatorFullLattice())
        self.setFlag(QGraphicsItem.ItemHasNoContents)  # never call paint
        self.setZValue(styles.ZPARTITEM)
        self._initModifierCircle()
Example #2
0
 def __init__(self, modelPart, viewroot, activeTool, parent):
     """parent should always be pathrootitem"""
     super(PartItem, self).__init__(parent)
     self._modelPart = mP = modelPart
     self._viewroot = viewroot
     self._activeTool = activeTool
     self._activeSliceItem = ActiveSliceItem(self, mP.activeBaseIndex())
     self._activeVirtualHelixItem = None
     self._controller = PartItemController(self, mP)
     self._preXoverItems = []  # crossover-related
     self._virtualHelixHash = {}
     self._virtualHelixItemList = []
     self._vHRect = QRectF()
     self.setAcceptHoverEvents(True)
     self._initModifierRect()
     self._initResizeButtons()
     self._proxyParent = ProxyParentItem(self)
     self._proxyParent.setFlag(QGraphicsItem.ItemHasNoContents)