def strandResizedSlot(self, strand, indices): """Receives notification from the model when a strand is resized""" #print "solid.StrandItem.strandResizedSlot", self._modelStrand.idxs() self.updateSize() self._virtualHelixItem.updateDecorators() m = Mom() m.updateSelectionBoxes()
def cadnanoVBaseToMayaCoords(self, base, strand): """ Given a Strand and a Base, returns a 3D location of that base """ m = Mom() mID = m.strandMayaID(strand) cylinderName = "%s%s" % (m.helixNodeName, mID) if cmds.objExists(cylinderName): rise = cmds.getAttr("%s.rise" % cylinderName) startBase = cmds.getAttr("%s.startBase" % cylinderName) startPos = cmds.getAttr("%s.startPos" % cylinderName) base0Pos = startPos[0][1] + (startBase * rise) ourPos = base0Pos - (base * rise) zComp = ourPos rotation = cmds.getAttr("%s.rotation" % cylinderName) radius = cmds.getAttr("%s.radius" % cylinderName) parity = cmds.getAttr("%s.parity" % cylinderName) strandType = cmds.getAttr("%s.strandType" % cylinderName) rotationOffset = cmds.getAttr("%s.rotationOffset" % cylinderName) decoratorRotOffset = cmds.getAttr("%s.decoratorRotOffset" % cylinderName) # not clear why decoratorRotOffset is not in radians but # rotationOffset is decoratorRotOffset = decoratorRotOffset * math.pi / 180 starting_rotation = (math.pi * (not parity)) + rotationOffset + decoratorRotOffset + (math.pi * strandType) fullrotation = -rotation * base * math.pi / 180 # print full rotation xComp = self._x + radius * math.cos(starting_rotation + fullrotation) yComp = self._y + radius * math.sin(starting_rotation + fullrotation) # print "%f %f %f" % (xComp, yComp, zComp) return (xComp, yComp, zComp) else: raise IndexError
def __init__(self, mID, modelStrand, virtualHelixItem): """ The parent should be a VirtualHelixItem. Initialize function creates the Maya Node for the strand, and setups the lookup tables inside of mayaObjectManager (Mom) so that the Maya Node can be globally found given a strand, and the other way around. Also, sets up StrandItemController that is used to setup all the slots and signals between strand model and this strandItem. """ self._modelStrand = modelStrand self._virtualHelixItem = virtualHelixItem self._viewroot = app().activeDocument.win.solidroot mayaNodeInfo = () # print "solidview.StrandItem.__init__ %s" % mID if(modelStrand.strandSet().isScaffold()): mayaNodeInfo = self.createMayaHelixNodes(virtualHelixItem.x(), virtualHelixItem.y(), modelStrand.oligo().color(), StrandType.SCAFFOLD, mID) else: mayaNodeInfo = self.createMayaHelixNodes(virtualHelixItem.x(), virtualHelixItem.y(), modelStrand.oligo().color(), StrandType.STAPLE, mID) #self.onStrandDidMove(strand) m = Mom() m.cnToMaya[modelStrand] = mayaNodeInfo m.mayaToCn[mayaNodeInfo[2]] = modelStrand m.mayaToCn[mayaNodeInfo[0]] = modelStrand self.updateSize() self._controller = StrandItemController(self, modelStrand)
def doPress(self): # print "PRESS" self.isMouseDown = True am = self.activeManip() m = Mom() m.strandsSelected( self.helicesNames, (am is self.fDistanceFrontManip, am is self.fDistanceBackManip)) self.createHelixDragMarker() selectedItems = cmds.ls(Mom().helixTransformName + "*", selection=True) bbox = cmds.exactWorldBoundingBox(selectedItems) cmds.setAttr(helixManip.transformName + ".scale", bbox[3] - bbox[0], 0, bbox[4] - bbox[1], type="double3") z = 0 if am is self.fDistanceFrontManip: z = bbox[5] elif am is self.fDistanceBackManip: z = bbox[2] self.moveHelixDragMarkerTo( ((bbox[0] + bbox[3]) / 2, (bbox[1] + bbox[4]) / 2, z)) cmds.showHidden(helixManip.transformName) self.calculateDeltaBounds() return OpenMaya.kUnknownParameter
def strandRemovedSlot(self, strand): """ Receives notification from the model when a strand is removed. Deletes the strand related mapping in mayaObjectManager, deletes all the Maya nodes, deletes all the decorators(live in the virtualHelixItem right now), deletes itself from the virtualHelixItem, and disconnects itself from the controller. """ mom = Mom() mID = mom.strandMayaID(strand) mom.removeIDMapping(mID, strand) # print "solidview.StrandItem.strandRemovedSlot %s" % mID transformName = "%s%s" % (mom.helixTransformName, mID) cylinderName = "%s%s" % (mom.helixNodeName, mID) meshName = "%s%s" % (mom.helixMeshName, mID) if cmds.objExists(transformName): cmds.delete(transformName) if cmds.objExists(cylinderName): cmds.delete(cylinderName) if cmds.objExists(meshName): cmds.delete(meshName) if mID in self._virtualHelixItem.StrandIDs(): self._virtualHelixItem.StrandIDs().remove(mID) self._virtualHelixItem.updateDecorators() self._virtualHelixItem.removeStrandItem(self) self._virtualHelixItem = None self._modelStrand = None self._controller.disconnectSignals() self._controller = None
def oligoAppearanceChangedSlot(self, oligo): """ Receives notification from the model when a oligo changes appearance. Updates the color of the strandItem associated with this strand """ mom = Mom() id = mom.strandMayaID(self._modelStrand) self.updateColor(id, oligo.color()) pass
def strandHasNewOligoSlot(self, strand): """ Receives notification from the model when there is a new oligo. Updates the color of the strandItem associated with this strand """ mom = Mom() self._controller.reconnectOligoSignals() mID = mom.strandMayaID(strand) self.updateColor(mID, strand.oligo().color())
def clearDecorators(self): """Remove all the Pre-Decortators""" m = Mom() for mID in self.stapleModIndicatorIDs: transformName = "%s%s" % (m.decoratorTransformName, mID) # print "delete %s" % transformName m = Mom() m.removeDecoratorMapping(mID) if cmds.objExists(transformName): cmds.delete(transformName) self.stapleModIndicatorIDs = [] self.stapleIndicatorCount = 0
def updateSize(self): """ Update Maya's Half Cylinder Node attributes related to the size """ mom = Mom() mID = mom.strandMayaID(self._modelStrand) cylinderName = "%s%s" % (mom.helixNodeName, mID) endpoints = self._modelStrand.idxs() totalNumBases = \ self._virtualHelixItem.virtualHelix().part().maxBaseIdx() cmds.setAttr("%s.startBase" % cylinderName, endpoints[0]) cmds.setAttr("%s.endBase" % cylinderName, endpoints[1]) cmds.setAttr("%s.totalBases" % cylinderName, int(totalNumBases))
def strandAddedSlot(self, sender, strand): """ Instantiates a StrandItem upon notification that the model has a new Strand. The StrandItem is responsible for creating its own controller for communication with the model, and for adding itself to its parent (which is *this* VirtualHelixItem, i.e. 'self'). """ # print "solidview.VirtualHelixItem.strandAddedSlot" m = Mom() mID = m.strandMayaID(strand) self.strandIDs.append(mID) sI = StrandItem(mID, strand, self) self._strandItems[sI] = True self.updateDecorators()
def strandAddedSlot(self, sender, strand): """ Instantiates a StrandItem upon notification that the model has a new Strand. The StrandItem is responsible for creating its own controller for communication with the model, and for adding itself to its parent (which is *this* VirtualHelixItem, i.e. 'self'). """ #print "solidview.VirtualHelixItem.strandAddedSlot" m = Mom() mID = m.strandMayaID(strand) self.strandIDs.append(mID) sI = StrandItem(mID, strand, self) self._strandItems[sI] = True self.updateDecorators()
def selectionCallback(clientData): """ Callback function that is called when the selection changes in Maya. """ clientData.deleteManipulators() #print "mayaSelcectionContex: selectionCallback called" selectionList = OpenMaya.MSelectionList() OpenMaya.MGlobal.getActiveSelectionList(selectionList) selectionIter = OpenMaya.MItSelectionList(selectionList) decoratorList = [] helixList = [] m = Mom() manipulator = None manipObject = OpenMaya.MObject() while not selectionIter.isDone(): transformNode = OpenMaya.MObject() dagNode = OpenMaya.MFnDagNode() try: selectionIter.getDependNode(transformNode) if transformNode.isNull() or not transformNode.hasFn( \ OpenMaya.MFn.kDependencyNode): selectionIter.next() continue dagNode = OpenMaya.MFnDagNode(transformNode) except: selectionIter.next() continue if dagNode.name().startswith(m.decoratorTransformName): if dagNode.name() not in decoratorList: decoratorList.append(dagNode.name()) elif dagNode.name().startswith(m.helixTransformName): Unused, HNumber = dagNode.name().split("_") helixName = "%s%s" % (m.helixNodeName, HNumber) helixNode = m.getNodeFromName(helixName) if helixNode: helixList.append(helixName) if manipulator is None: manipulator = \ OpenMayaMPx.MPxManipContainer.newManipulator( "spHelixManip", manipObject) if manipulator is not None: clientData.addManipulator(manipObject) manipulator.addHelix(HNumber) #print "selectionCallback ", dagNode.name(), helixNode selectionIter.next() m.staplePreDecoratorSelected(decoratorList) if manipulator is not None: manipulator.finishedAddingHelices() m.strandsSelected(helixList) m.updateSelectionBoxes()
def updateColor(self, mID, colorname): """ Update the color of the Maya's Mesh Node associated with a this StrandItem, this is done by creating a shadingNode for each color or connecting the Mesh Mode to an existing shadingNode if one exists for a given color. """ m = Mom() meshName = "%s%s" % (m.helixMeshName, mID) color = QColor(colorname) colorval = "%d_%d_%d" % (color.red(), color.green(), color.blue()) shaderName = "%s%d_%d_%d" % (m.helixShaderName, color.red(), color.green(), color.blue()) if not cmds.objExists(shaderName): # Shader does not exist create one cmds.shadingNode('lambert', asShader=True, name=shaderName) cmds.sets(n="%sSG" % shaderName, r=True, nss=True, em=True) cmds.connectAttr("%s.outColor" % shaderName, "%sSG.surfaceShader" % shaderName) cmds.setAttr("%s.color" % shaderName, color.redF(), color.greenF(), color.blueF(), type="double3") cmds.sets(meshName, forceElement="%sSG" % shaderName) else: #shader exist connect cmds.sets(meshName, forceElement="%sSG" % shaderName)
def createDecorators(self, strand): """Create a set of new Pre-Decortators for a given strand""" m = Mom() strandId = m.strandMayaID(strand) totalNumBases = self._modelVirtualHelix.part().maxBaseIdx() preDecoratorIdxList = strand.getPreDecoratorIdxList() for baseIdx in preDecoratorIdxList: # XXX [SB+AT] NOT THREAD SAFE while cmds.objExists("%s%s_%s" % (m.decoratorNodeName, strandId, self.stapleIndicatorCount)): self.stapleIndicatorCount += 1 stapleId = "%s_%s" % (strandId, self.stapleIndicatorCount) coords = self.cadnanoVBaseToMayaCoords(baseIdx, strand) stapleModNodeInfo = self.createDecoratorNodes(coords, stapleId) self.stapleModIndicatorIDs.append(stapleId) m = Mom() m.decoratorToVirtualHelixItem[stapleModNodeInfo[2]] = (self, baseIdx, strand) m.decoratorToVirtualHelixItem[stapleModNodeInfo[1]] = (self, baseIdx, strand)
def createMayaHelixNodes(self, x, y, colorname, strandType, mID): """ Create all the Maya nodes, set the initial attributes and connections. There are 3 Maya nodes associated with each Strand: Transform Node, Shape Node (spHalfCylinderHelixNode), and a Mesh Node (a generic Maya Node that is used for rendering) The Mesh Node is the child of the Transform Node, and spHalfCylinderHelixNode node inputs the shape data into the Mesh Node, using cmds.connectAttr command ________________ | Transform Node | ---------------- | ________________ .inMesh .outputMesh _____________________ | Mesh Node |<---------------------------| HalfCylinderHelixNode | ---------------- ----------------------- """ m = Mom() cylinderName = "%s%s" % (m.helixNodeName, mID) transformName = "%s%s" % (m.helixTransformName, mID) meshName = "%s%s" % (m.helixMeshName, mID) # shaderName = "%s%s" % (m.helixShaderName, mID) cmds.createNode("transform", name=transformName, skipSelect=True) cmds.setAttr("%s.rotateX" % transformName, 90) cmds.setAttr("%s.translateX" % transformName, x) cmds.setAttr("%s.translateY" % transformName, y) cmds.createNode("mesh", name=meshName, parent=transformName, skipSelect=True) cmds.createNode("spHalfCylinderHelixNode", name=cylinderName, skipSelect=True) cmds.connectAttr("%s.outputMesh" % cylinderName, "%s.inMesh" % meshName) # XXX - [SB] This should go away and we will ask the model for # the right numbers... vhi = self._virtualHelixItem part = vhi.partItem().part() cSType = part.crossSectionType() cmds.setAttr("%s.rotation" % cylinderName, part.twistPerBase()) cmds.setAttr("%s.parity" % cylinderName, vhi.isEvenParity()) if cSType == LatticeType.HONEYCOMB: cmds.setAttr("%s.rotationOffset" % cylinderName, 250) cmds.setAttr("%s.decoratorRotOffset" % cylinderName, 90) elif cSType == LatticeType.SQUARE: cmds.setAttr("%s.rotationOffset" % cylinderName, 125) cmds.setAttr("%s.decoratorRotOffset" % cylinderName, 200) else: raise NotImplementedError cmds.setAttr("%s.strandType" % cylinderName, strandType) self.updateColor(mID, colorname) cmds.select(transformName) cmds.polySoftEdge(a=89.99) cmds.setAttr("%s.displayEdges" % meshName, 2) cmds.select(clear=True) return (cylinderName, transformName, meshName)
def selectedChangedSlot(self, strand, indices): #print "solidview.stranditem.selectedChangedSlot", strand, indices mom = Mom() if mom.ignoreExternalSelectionSignal: return mID = mom.strandMayaID(strand) mom.ignoreExternalSelectionSignal = True transformName = "%s%s" % (mom.helixTransformName, mID) if cmds.objExists(transformName): if(indices[0] or indices[1]): cmds.select(transformName, add=True) # print "selecting a strand" self._viewroot.addToSelectionDict(strand) else: # print "deselecting in the slot" cmds.select(transformName, deselect=True) self._viewroot.removeFromSelectionDict(strand) mom.ignoreExternalSelectionSignal = False
def doRelease(self): # print "RELEASED" self.isMouseDown = False if(self.deltaFront != 0): app().activeDocument.document().resizeSelection(self.deltaFront) if(self.deltaBack != 0): app().activeDocument.document().resizeSelection(self.deltaBack) m = Mom() m.strandsSelected(self.helicesNames, (True, True)) cmds.hide(helixManip.transformName) self.frontDistance = 0 self.backDistance = 0 return OpenMaya.kUnknownParameter
def addHelix(self, HNumber): m = Mom() h = self.helix() h.id = HNumber h.helixTransform = m.getNodeFromName( "%s%s" % (m.helixTransformName, HNumber)) h.helixNode = m.getNodeFromName("%s%s" % (m.helixNodeName, HNumber)) nodeFn = OpenMaya.MFnDependencyNode(h.helixNode) h.helixName = nodeFn.name() self.helices[h.id] = h self.helicesNames.append(h.helixName) # we only connect the first node, so that the update events trigger # the delta value will be the same for all the helices if(len(self.helices) == 1): self.firstHelix = h.id self.connectToDependNode(h)
def doPress(self): # print "PRESS" self.isMouseDown = True am = self.activeManip() m = Mom() m.strandsSelected( self.helicesNames, (am is self.fDistanceFrontManip, am is self.fDistanceBackManip) ) self.createHelixDragMarker() selectedItems = cmds.ls(Mom().helixTransformName + "*", selection=True) bbox = cmds.exactWorldBoundingBox(selectedItems) cmds.setAttr( helixManip.transformName + ".scale", bbox[3] - bbox[0], 0, bbox[4] - bbox[1], type="double3") z = 0 if am is self.fDistanceFrontManip: z = bbox[5] elif am is self.fDistanceBackManip: z = bbox[2] self.moveHelixDragMarkerTo(( (bbox[0] + bbox[3]) / 2, (bbox[1] + bbox[4]) / 2, z )) cmds.showHidden(helixManip.transformName) self.calculateDeltaBounds() return OpenMaya.kUnknownParameter
def cadnanoVBaseToMayaCoords(self, base, strand): """ Given a Strand and a Base, returns a 3D location of that base """ m = Mom() mID = m.strandMayaID(strand) cylinderName = "%s%s" % (m.helixNodeName, mID) if cmds.objExists(cylinderName): rise = cmds.getAttr("%s.rise" % cylinderName) startBase = cmds.getAttr("%s.startBase" % cylinderName) startPos = cmds.getAttr("%s.startPos" % cylinderName) base0Pos = startPos[0][1] + (startBase * rise) ourPos = base0Pos - (base * rise) zComp = ourPos rotation = cmds.getAttr("%s.rotation" % cylinderName) radius = cmds.getAttr("%s.radius" % cylinderName) parity = cmds.getAttr("%s.parity" % cylinderName) strandType = cmds.getAttr("%s.strandType" % cylinderName) rotationOffset = cmds.getAttr("%s.rotationOffset" % cylinderName) decoratorRotOffset = cmds.getAttr("%s.decoratorRotOffset" % cylinderName) # not clear why decoratorRotOffset is not in radians but # rotationOffset is decoratorRotOffset = decoratorRotOffset * math.pi / 180 starting_rotation = (math.pi * (not parity)) + rotationOffset + \ decoratorRotOffset + \ (math.pi * strandType) fullrotation = -rotation * base * math.pi / 180 #print full rotation xComp = self._x + radius * \ math.cos(starting_rotation + fullrotation) yComp = self._y + radius * \ math.sin(starting_rotation + fullrotation) #print "%f %f %f" % (xComp, yComp, zComp) return (xComp, yComp, zComp) else: raise IndexError
def updateDecorators(self): """ Clears out Pre-Decorators, and re-populates them if they should be visible """ self.clearDecorators() if self._modState: m = Mom() for mID in self.strandIDs: mayaNodeInfo = "%s%s" % (m.helixMeshName, mID) #print "mayaNodeInfo: %s" % mayaNodeInfo strand = m.mayaToCn[mayaNodeInfo] if(strand.strandSet().isStaple()): self.createDecorators(strand)
def dagParentRemovedCallback(child, parent, clientData): """ Callback function that removes the strands from the model if the 3D strand is delete in 3D view. """ mom = Mom() children = child.fullPathName().split("|") for c in children: if c.startswith(mom.helixMeshName): if c in mom.mayaToCn: strand = mom.mayaToCn[c] if strand: # print "Strand %s : %s needs removal" % (c, strand) mID = mom.strandMayaID(strand) mom.removeIDMapping(mID, strand) strand.strandSet().removeStrand(strand) else: print "Error: no Strand inside mayaObjectModel" else: pass # print "dagParentRemovedCallback: %s already deleted" % c elif c.startswith(mom.decoratorMeshName): if c in mom.decoratorToVirtualHelixItem: pass
def dagParentRemovedCallback(child, parent, clientData): """ Callback function that removes the strands from the model if the 3D strand is delete in 3D view. """ mom = Mom() children = child.fullPathName().split("|") for c in children: if c.startswith(mom.helixMeshName): if c in mom.mayaToCn: strand = mom.mayaToCn[c] if strand: # print "Strand %s : %s needs removal" % (c, strand) mID = mom.strandMayaID(strand) mom.removeIDMapping(mID, strand) strand.strandSet().removeStrand(strand) else: print("Error: no Strand inside mayaObjectModel") else: pass # print "dagParentRemovedCallback: %s already deleted" % c elif c.startswith(mom.decoratorMeshName): if c in mom.decoratorToVirtualHelixItem: pass
def partDimensionsChangedSlot(self, part): """ Receives notification from the model when a dimentions of the part changes. Needs to change an attribute of every Maya Helix Nodes, so that they are all are aligned corectly with new strands that are created. """ mom = Mom() for vh in self._virtualHelixItems: for mID in vh.StrandIDs(): cylinderName = "%s%s" % (mom.helixNodeName, mID) totalNumBases = self._part.maxBaseIdx() cmds.setAttr("%s.totalBases" % cylinderName, int(totalNumBases)) vh.updateDecorators()
def activeManip(self): try: activeManip = OpenMaya.MObject() self.isManipActive(OpenMaya.MFn.kDistanceManip, activeManip) m = Mom() if activeManip == self.fDistanceFrontManip.node(): return self.fDistanceFrontManip elif activeManip == self.fDistanceBackManip.node(): return self.fDistanceBackManip except: sys.stderr.write("ERROR: helixManip.activeManip\n") raise return None
def doDrag(self): #print "DRAGGING" am = self.activeManip() selectedItems = cmds.ls(Mom().helixTransformName + "*", selection=True) bbox = cmds.exactWorldBoundingBox(selectedItems) z = 0 if am is self.fDistanceFrontManip: self.moveHelixDragMarkerTo( ((bbox[0] + bbox[3]) / 2, (bbox[1] + bbox[4]) / 2, bbox[5] + self.frontDistance)) elif am is self.fDistanceBackManip: self.moveHelixDragMarkerTo( ((bbox[0] + bbox[3]) / 2, (bbox[1] + bbox[4]) / 2, bbox[2] - self.backDistance)) return OpenMaya.kUnknownParameter
def clearDecorators(self): """Remove all the Pre-Decortators""" m = Mom() for mID in self.stapleModIndicatorIDs: transformName = "%s%s" % (m.decoratorTransformName, mID) #print "delete %s" % transformName m = Mom() m.removeDecoratorMapping(mID) if cmds.objExists(transformName): cmds.delete(transformName) self.stapleModIndicatorIDs = [] self.stapleIndicatorCount = 0
def createDecoratorNodes(self, coords, mID): """Create a actual Maya Nodes for a new Pre-Decortators""" m = Mom() stapleModIndicatorName = "%s%s" % (m.decoratorNodeName, mID) transformName = "%s%s" % (m.decoratorTransformName, mID) meshName = "%s%s" % (m.decoratorMeshName, mID) shaderName = "%s" % m.decoratorShaderName cmds.createNode("transform", name=transformName, skipSelect=True) cmds.setAttr("%s.rotateX" % transformName, 90) cmds.setAttr("%s.translateX" % transformName, coords[0]) cmds.setAttr("%s.translateY" % transformName, coords[1]) cmds.setAttr("%s.translateZ" % transformName, coords[2]) cmds.createNode("mesh", name=meshName, parent=transformName, skipSelect=True) #cmds.createNode("spPreDecoratorNode", name=stapleModIndicatorName) cmds.createNode("polySphere", name=stapleModIndicatorName, skipSelect=True) cmds.setAttr("%s.radius" % stapleModIndicatorName, .25) cmds.setAttr("%s.subdivisionsAxis" % stapleModIndicatorName, 4) cmds.setAttr("%s.subdivisionsHeight" % stapleModIndicatorName, 4) #cmds.connectAttr("%s.outputMesh" % stapleModIndicatorName, # "%s.inMesh" % meshName) cmds.connectAttr("%s.output" % stapleModIndicatorName, "%s.inMesh" % meshName) if not cmds.objExists(shaderName): # Shader does not exist create one cmds.shadingNode('lambert', asShader=True, name=shaderName) cmds.sets(n="%sSG" % shaderName, r=True, nss=True, em=True) cmds.connectAttr("%s.outColor" % shaderName, "%sSG.surfaceShader" % shaderName) cmds.setAttr("%s.color" % shaderName, 0.0, 0.0, 0.0, type="double3") cmds.sets(meshName, forceElement="%sSG" % shaderName) else: #shader exist connect cmds.sets(meshName, forceElement="%sSG" % shaderName) return (stapleModIndicatorName, transformName, meshName, shaderName)
def plugToManipConversion(self, manipIndex): #print "plugToManipCalled" manipData = OpenMayaUI.MManipData() try: frontManip = OpenMayaUI.MFnDistanceManip(self.fDistanceFrontManip) backManip = OpenMayaUI.MFnDistanceManip(self.fDistanceBackManip) boundBoxCenter = OpenMaya.MVector() boundBoxScale = OpenMaya.MVector() selectedItems = cmds.ls( Mom().helixTransformName + "*", selection=True) bbox = cmds.exactWorldBoundingBox(selectedItems) boundBoxCenter.x = float((bbox[0] + bbox[3]) / 2) boundBoxCenter.y = float((bbox[1] + bbox[4]) / 2) boundBoxCenter.z = float((bbox[2] + bbox[5]) / 2) boundBoxScale.x = float(bbox[3] - bbox[0]) boundBoxScale.y = float(bbox[4] - bbox[1]) boundBoxScale.z = float(bbox[5] - bbox[2]) if(manipIndex == frontManip.currentPointIndex()): ws = boundBoxCenter + project(boundBoxScale / 2, self.frontDir) ws += self.frontDir * \ (self.manipHandleOffset + self.frontDistance) numData = OpenMaya.MFnNumericData() numDataObj = numData.create(OpenMaya.MFnNumericData.k3Double) numData.setData3Double(ws.x, ws.y, ws.z) manipData = OpenMayaUI.MManipData(numDataObj) elif(manipIndex == backManip.currentPointIndex()): ws = boundBoxCenter + project(boundBoxScale / 2, self.backDir) ws += self.backDir * \ (self.manipHandleOffset + self.backDistance) numData = OpenMaya.MFnNumericData() numDataObj = numData.create(OpenMaya.MFnNumericData.k3Double) numData.setData3Double(ws.x, ws.y, ws.z) manipData = OpenMayaUI.MManipData(numDataObj) elif(manipIndex == frontManip.startPointIndex()): ws = boundBoxCenter + project(boundBoxScale / 2, self.frontDir) numData = OpenMaya.MFnNumericData() numDataObj = numData.create(OpenMaya.MFnNumericData.k3Float) numData.setData3Float(ws.x, ws.y, ws.z) manipData = OpenMayaUI.MManipData(numDataObj) elif(manipIndex == backManip.startPointIndex()): ws = boundBoxCenter + project(boundBoxScale / 2, self.backDir) numData = OpenMaya.MFnNumericData() numDataObj = numData.create(OpenMaya.MFnNumericData.k3Float) numData.setData3Float(ws.x, ws.y, ws.z) manipData = OpenMayaUI.MManipData(numDataObj) except: sys.stderr.write("ERROR: helixManip.plugToManipConversion\n") raise return manipData
def getStrand(self, helix): m = Mom() return m.mayaToCn[helix.helixName]