示例#1
0
    def mouseReleaseEvent(self, event, camControl, scene):
        '''Handle the mouse press event, returning an EventReport

        @param:     event       The event.
        @param:     camControl  The scene's camera control for this event.
        @param:     scene       The scene.
        @returns:   An instance of EventReport.
        '''
        result = EventReport(True)

        # if not handled, either perform selection or view manipulation
        hasCtrl, hasAlt, hasShift = getModState()
        btn = event.button()
        if (btn == LEFT_BTN and not hasAlt):
            self.selecting = False
            if (self.currPoint is None):
                # TODO: Eventually shift this to allow for a selection REGION
                selected = self.selectSingle(scene, camControl,
                                             (event.x(), event.y()))
            else:
                selected = self.selectRegion(scene, camControl, self.downPoint,
                                             self.currPoint)
                # Need to stop drawing the selection region
                result.needsRedraw = True

            if (selected):
                if (hasShift and hasCtrl):
                    # add
                    result.needsRedraw |= Select.addToGlobalSelection(
                        selected) > 0
                elif (hasShift):
                    # toggle
                    result.needsRedraw |= Select.toggleGlobalSelection(
                        selected) > 0
                elif (hasCtrl):
                    # remove
                    result.needsRedraw |= Select.removeFromGlobalSelection(
                        selected) > 0
                else:
                    # replace
                    result.needsRedraw |= Select.setGlobalSelection(
                        selected) > 0
            else:
                if (not (hasShift or hasCtrl)):
                    result.needsRedraw |= Select.clearGlobalSelection() > 0
            self.currPoint = self.downPoint = None
        if (result.needsRedraw):
            self.selectionChanged()
        return result