Exemplo n.º 1
0
def queryAttributeChoice(parentDialog):
  objName = str(pm.ls(sl=1)[0]) # getting the first selected object

  if QApplication.keyboardModifiers() == Qt.ControlModifier:
    attrs = pm.listAttr(objName, w=1) # Ctrl pressed => showing all writeable channels
  elif QApplication.keyboardModifiers() == Qt.AltModifier:
    attrs = pm.listAttr(objName, ud=1) # Alt pressed => showing only user defined channels
  else:
    attrs = pm.listAttr(objName, k=1) # otherwise showing only keyable channels

  choice = QInputDialog.getItem(parentDialog, "Attributes", "Choose an attribute to be driven", attrs)
  if choice[1]:
    return "{obj}.{attr}".format(obj=objName, attr=choice[0]) # formatting the full attribute name
  else: # if no choice has been made (window closed etc)
    return None
Exemplo n.º 2
0
	def keyPressEvent( self, ev ):
		modifiers = QApplication.keyboardModifiers()
		key = ev.key()
		if key in ( Qt.Key_Delete, Qt.Key_Backspace ):			
			self.onDeletePressed()
		elif key == Qt.Key_Escape: 
			self.selectNode( [] ) # deselect all
Exemplo n.º 3
0
	def keyPressEvent( self, ev ):
		modifiers = QApplication.keyboardModifiers()
		key = ev.key()

		if key in ( Qt.Key_Delete, Qt.Key_Backspace ):			
			self.onDeletePressed()
		elif key == Qt.Key_Escape: #deselect all
			self.selectNode( [] )

		#copy&paste
		elif ( key, modifiers ) == ( Qt.Key_C, Qt.ControlModifier ):
			if self.onClipboardCopy(): return
		elif ( key, modifiers ) == ( Qt.Key_X, Qt.ControlModifier ):
			if self.onClipboardCut(): return
		elif ( key, modifiers ) == ( Qt.Key_V, Qt.ControlModifier ):
			if self.onClipboardPaste(): return

		#open
		elif key == Qt.Key_Down \
			and ( modifiers in ( Qt.ControlModifier, Qt.ControlModifier | Qt.KeypadModifier ) ):
			item = self.currentItem() 
			if item:
				self.onItemActivated( item )
				return

		return super( GenericListWidget, self ).keyPressEvent( ev )
Exemplo n.º 4
0
    def keyPressEvent(self, ev):
        modifiers = QApplication.keyboardModifiers()
        key = ev.key()

        if key in (Qt.Key_Delete, Qt.Key_Backspace):
            self.onDeletePressed()
        elif key == Qt.Key_Escape:  #deselect all
            self.selectNode([])

        #copy&paste
        elif (key, modifiers) == (Qt.Key_C, Qt.ControlModifier):
            if self.onClipboardCopy(): return
        elif (key, modifiers) == (Qt.Key_X, Qt.ControlModifier):
            if self.onClipboardCut(): return
        elif (key, modifiers) == (Qt.Key_V, Qt.ControlModifier):
            if self.onClipboardPaste(): return

        #open
        elif key == Qt.Key_Down \
         and ( modifiers in ( Qt.ControlModifier, Qt.ControlModifier | Qt.KeypadModifier ) ):
            item = self.currentItem()
            if item:
                self.onItemActivated(item)
                return

        return super(GenericListWidget, self).keyPressEvent(ev)
Exemplo n.º 5
0
 def keyPressEvent(self, ev):
     modifiers = QApplication.keyboardModifiers()
     key = ev.key()
     if key in (Qt.Key_Delete, Qt.Key_Backspace):
         self.onDeletePressed()
     elif key == Qt.Key_Escape:
         self.selectNode([])  # deselect all
Exemplo n.º 6
0
    def _on_keypressed_event(self, key_event):

        key = key_event.key()

        if key == Qt.Key_G:
            # jump to window
            self.disassembly_view.popup_jumpto_dialog()
            return True
        elif key == Qt.Key_N:
            # rename a label
            self.disassembly_view.popup_rename_label_dialog()
            return True
        elif key == Qt.Key_X:
            # XRef

            # get the variable
            if self.selected_operands:
                ins_addr, operand_idx = next(iter(self.selected_operands))
                block = self._insn_addr_to_block.get(ins_addr, None)
                if block is not None:
                    operand = block.addr_to_insns[ins_addr].get_operand(
                        operand_idx)
                    if operand is not None and operand.variable is not None:
                        self.disassembly_view.popup_xref_dialog(
                            operand.variable)
            return True
        elif key == Qt.Key_Escape or (
                key == Qt.Key_Left
                and QApplication.keyboardModifiers() & Qt.ALT != 0):
            # jump back
            self.disassembly_view.jump_back()
            return True
        elif key == Qt.Key_Right and QApplication.keyboardModifiers(
        ) & Qt.ALT != 0:
            # jump forward
            self.disassembly_view.jump_forward()

        elif key == Qt.Key_A:
            # switch between highlight mode
            if self._infodock.highlight_mode == OperandHighlightMode.SAME_TEXT:
                self._infodock.highlight_mode = OperandHighlightMode.SAME_IDENT
            else:
                self._infodock.highlight_mode = OperandHighlightMode.SAME_TEXT
            # refresh myself
            self.viewport().update()

        return False
Exemplo n.º 7
0
    def dragEvent(self):
        """ Event while dragging a 3d view """

        if self.TARGET_FNMESH is None:
            return

        dragPosition = cmds.draggerContext(DRAGGER, query=True, dragPoint=True)

        x = dragPosition[0]
        y = dragPosition[1]

        modifier = cmds.draggerContext(DRAGGER, query=True, modifier=True)

        if modifier == "none":
            self.MOD_FIRST = True

        qtModifier = QApplication.keyboardModifiers()

        if qtModifier == self.CTRL or qtModifier == self.SHIFT:

            # If this is the first click of dragging
            if self.MOD_FIRST is True:
                self.MOD_POINT = [x, y]

                # global MOD_FIRST
                self.MOD_FIRST = False

            length, degree = self.getDragInfo(x, y)

            if qtModifier == self.CTRL:
                length = 1.0
            if qtModifier == self.SHIFT:
                degree = 0.0

            # Convert
            point_in_3d, vector_in_3d = convertTo3D(self.MOD_POINT[0],
                                                    self.MOD_POINT[1])
        else:
            point_in_3d, vector_in_3d = convertTo3D(x, y)
            length = 1.0
            degree = 0.0

        # Get new transform matrix for new object
        transformMatrix = self.getMatrix(point_in_3d, vector_in_3d,
                                         self.TARGET_FNMESH, self.SCALE_ORIG,
                                         self.MATRIX_ORIG, length, degree)

        if transformMatrix is None:
            return

        # Apply new transform
        cmds.xform(self.DUPLICATED, matrix=transformMatrix)
        cmds.setAttr(self.DUPLICATED + ".shear", *[0, 0, 0])

        cmds.refresh(currentView=True, force=True)
Exemplo n.º 8
0
    def doMove( mouseX, mouseY ):
    
        cmds.undoInfo( swf=0 )
        
        if Tool_global.mousePressed: return None
        modifiers = QApplication.keyboardModifiers()
        
        if modifiers != QtCore.Qt.ShiftModifier:
            Tool_global.stilPressed_shift   = False
        if modifiers != QtCore.Qt.ControlModifier:
            Tool_global.stilPressed_control = False
        
        selObj  = Functions.getSelectedObject()
        instObj = Functions.getInstanceObject()
        ground = Functions.getGround()
        intersectPoint, intersectNormal = Functions.getIntersectPointAndNormal( mouseX, 
                                                                                mouseY, 
                                                                                ground )
        Tool_global.mouseX = mouseX
        Tool_global.mouseY = mouseY
        Tool_global.targetViewSize = Functions.getTargetViewSize( selObj, intersectPoint ) * Tool_global.currentSize

        transMatrixList = [1,0,0,0,
                           0,1,0,0,
                           0,0,1,0,
                           Tool_global.intersectPoint.x, Tool_global.intersectPoint.y, Tool_global.intersectPoint.z, 1]
        
        
        if not Tool_global.stilPressed_control and modifiers == QtCore.Qt.ControlModifier and modifiers != QtCore.Qt.ShiftModifier:
            Tool_global.scaleEditMatrix = Functions.getScaleEditMatrix( mouseX, mouseY )

        elif not Tool_global.stilPressed_shift and  modifiers != QtCore.Qt.ControlModifier and modifiers == QtCore.Qt.ShiftModifier:
            Tool_global.rotationYEditMatrix = Functions.getRotationYEditMatrix(mouseX, mouseY)
            Tool_global.rotationEditMatrix = Functions.getRotationEditMatrix( mouseX, mouseY )
        else:
            Tool_global.intersectPoint = intersectPoint
            Tool_global.intersectNormal = intersectNormal
        
        if not Tool_global.randomMatrixExists:
            Tool_global.randomMatrix       = Functions.getRandomMatrix()
            Tool_global.randomMatrixExists = True
        
        transMatrix = listToMatrix( transMatrixList )
        normalRotMatrix    = Functions.getRotationMatrixFromNormal( Tool_global.intersectNormal )
        editMatrix = Tool_global.rotationYEditMatrix * Tool_global.randomMatrix * normalRotMatrix*Tool_global.scaleEditMatrix*Tool_global.rotationEditMatrix
        offsetMatrix = Functions.getOffsetMatrix(editMatrix,normalRotMatrix)    
        Tool_global.cuMatrix = editMatrix * offsetMatrix * transMatrix
        mtxList = matrixToList( Tool_global.cuMatrix )
        cmds.xform( instObj, ws=1, matrix=mtxList )
        cmds.undoInfo( swf=1 )
Exemplo n.º 9
0
 def doRelease(self, event ):
     
     import random
     
     count = Window_global.ui_listWidgetPut.count()
     Tool_global.randomIndex = int( random.uniform( 0, count ) )
     Tool_global.targetViewSize = None
     
     Tool_global.mousePressed = False
     
     modifiers = QApplication.keyboardModifiers()
     Tool_global.stilPressed_shift   = modifiers == QtCore.Qt.ShiftModifier
     Tool_global.stilPressed_control = modifiers == QtCore.Qt.ControlModifier
     
     Functions.getRandomMatrix()
Exemplo n.º 10
0
    def toggle_instruction_selection(self, insn_addr):
        """
        Toggle the selection state of an instruction in the disassembly view.

        :param int insn_addr: Address of the instruction to toggle.
        :return:              None
        """

        if insn_addr in self._flow_graph.selected_insns:
            self._flow_graph.unselect_instruction(insn_addr)
        else:
            self._flow_graph.select_instruction(
                insn_addr,
                unique=QApplication.keyboardModifiers() & Qt.CTRL == 0)
            self._flow_graph.show_instruction(insn_addr)
Exemplo n.º 11
0
    def toggle_operand_selection(self, insn_addr, operand_idx):
        """
        Toggle the selection state of an operand of an instruction in the disassembly view.

        :param int insn_addr:   Address of the instruction to toggle.
        :param int operand_idx: The operand to toggle.
        :return:                None
        """

        if (insn_addr, operand_idx) in self._flow_graph.selected_operands:
            self._flow_graph.unselect_operand(insn_addr, operand_idx)
        else:
            self._flow_graph.select_operand(
                insn_addr,
                operand_idx,
                unique=QApplication.keyboardModifiers() & Qt.CTRL == 0)
            self._flow_graph.show_instruction(insn_addr)
Exemplo n.º 12
0
    def _handle_click ( self, column, allow_shift = True ):
        """ Perform 'special' click handling on either a cell or column header.
            Returns True if special handling occurred, or False to indicate that
            normal handling can proceed.
        """
        modifiers = int( QApplication.keyboardModifiers() )
        control   = modifiers & Qt.ControlModifier
        if allow_shift and (modifiers & Qt.ShiftModifier):
            do_later( self._hide_show_section, column, control )

            return True

        if control:
            self.column_width( column )
            self.set_column_widths()

            return True

        return False
Exemplo n.º 13
0
 def acceptNavigationRequest(self, frame, request, type):
     modifiers = QApplication.keyboardModifiers()
     if modifiers == Qt.ControlModifier and type == QWebPage.NavigationTypeLinkClicked:
         QDesktopServices.openUrl(request.url())
     return False
Exemplo n.º 14
0
 def __init__(self, event):
     self.text = event.text().strip()
     mods = QApplication.keyboardModifiers()
     self.shift = mods == QtCore.Qt.ShiftModifier
Exemplo n.º 15
0
 def acceptNavigationRequest(self, frame, request, type):
     modifiers = QApplication.keyboardModifiers()
     if modifiers == Qt.ControlModifier and type == QWebPage.NavigationTypeLinkClicked:
         QDesktopServices.openUrl(request.url())
     return False
Exemplo n.º 16
0
    def getMatrix(self,
                  mPoint,
                  mVector,
                  targetFnMesh,
                  scale_orig,
                  matrix_orig,
                  scale_plus=1,
                  degree_plus=0.0):
        """ Return a list of values which consist a new transform matrix.
            Args:
                mPoint  (OpenMaya.MPoint)
                mVector (OpenMaya.MVector)
            Returns:
                list : 16 values for matrixs
        """
        # Position of new object
        OP, faceID = self.getIntersection(mPoint, mVector, targetFnMesh)

        # If it doesn't intersect to any geometries, return None
        if OP is None and faceID is None:
            return None

        qtMod = QApplication.keyboardModifiers()
        if qtMod == (self.CTRL | self.SHIFT):
            OP = getClosestVertex(OP, faceID, targetFnMesh)

        # Get normal vector and tangent vector
        if self.ROTATION is False:
            NV = OpenMaya.MVector(matrix_orig[4], matrix_orig[5],
                                  matrix_orig[6])
            NV.normalize()
            TV = OpenMaya.MVector(matrix_orig[0], matrix_orig[1],
                                  matrix_orig[2])
            TV.normalize()
        else:
            NV = self.getNormal(OP, targetFnMesh)
            TV = self.getTangent(faceID, targetFnMesh)

        # Ctrl-hold rotation
        if qtMod == self.CTRL:
            try:
                rad = math.radians(degree_plus)
                q1 = NV.x * math.sin(rad / 2)
                q2 = NV.y * math.sin(rad / 2)
                q3 = NV.z * math.sin(rad / 2)
                q4 = math.cos(rad / 2)
                TV = TV.rotateBy(q1, q2, q3, q4)
            except TypeError:
                pass

        # Bitangent vector
        BV = TV ^ NV
        BV.normalize()

        # 4x4 Transform Matrix
        try:
            x = scale_orig[0] * (scale_plus / 100 + 1.0)
            y = scale_orig[1] * (scale_plus / 100 + 1.0)
            z = scale_orig[2] * (scale_plus / 100 + 1.0)
            TV *= x
            NV *= y
            BV *= z
        except TypeError:
            pass
        finally:
            matrix = [
                TV.x, TV.y, TV.z, 0, NV.x, NV.y, NV.z, 0, BV.x, BV.y, BV.z, 0,
                OP.x, OP.y, OP.z, 1
            ]

        return matrix