def update(self): "Update the screen." if len( self.skeinPanes ) < 1: return self.limitIndexSetArrowMouseDeleteCanvas() self.repository.viewpointLatitude.value = view_rotate.getBoundedLatitude( self.repository.viewpointLatitude.value ) self.repository.viewpointLongitude.value = round( self.repository.viewpointLongitude.value, 1 ) projectiveSpace = euclidean.ProjectiveSpace().getByLatitudeLongitude( self.repository.viewpointLatitude.value, self.repository.viewpointLongitude.value ) skeinPanesCopy = self.getUpdateSkeinPanes()[:] skeinPanesCopy.sort( compareLayerSequence ) if projectiveSpace.basisZ.z > 0.0: self.drawXYAxisLines( projectiveSpace ) else: skeinPanesCopy.reverse() self.drawZAxisLine( projectiveSpace ) for skeinPane in skeinPanesCopy: self.drawSkeinPane( projectiveSpace, skeinPane ) if projectiveSpace.basisZ.z > 0.0: self.drawZAxisLine( projectiveSpace ) else: self.drawXYAxisLines( projectiveSpace ) if self.repository.widthOfAxisNegativeSide.value > 0: self.drawRulings( self.negativeAxisLineX, projectiveSpace, self.negativeRulings ) self.drawRulings( self.negativeAxisLineY, projectiveSpace, self.negativeRulings ) self.drawRulings( self.negativeAxisLineZ, projectiveSpace, self.negativeRulings ) if self.repository.widthOfAxisPositiveSide.value > 0: self.drawRulings( self.positiveAxisLineX, projectiveSpace, self.positiveRulings ) self.drawRulings( self.positiveAxisLineY, projectiveSpace, self.positiveRulings ) self.drawRulings( self.positiveAxisLineZ, projectiveSpace, self.positiveRulings ) self.setDisplayLayerIndex()
def getDrawnSelectedColoredLine(self, coloredLine): "Get the drawn selected colored line." projectiveSpace = euclidean.ProjectiveSpace().getByLatitudeLongitude( self.repository.viewpointLatitude.value, self.repository.viewpointLongitude.value) return self.getDrawnColoredLine( self.arrowType, coloredLine, projectiveSpace, 'mouse_item', self.repository.widthOfSelectionThread.value)
def addLoop(endMultiplier, extrudeDerivation, loopLists, path, portionDirectionIndex, portionDirections, vertexes): "Add an indexed loop to the vertexes." portionDirection = portionDirections[portionDirectionIndex] if portionDirection.directionReversed == True: loopLists.append([]) loops = loopLists[-1] interpolationOffset = extrudeDerivation.interpolationDictionary['offset'] offset = interpolationOffset.getVector3ByPortion(portionDirection) if endMultiplier != None: if portionDirectionIndex == 0: setOffsetByMultiplier(interpolationOffset.path[1], interpolationOffset.path[0], endMultiplier, offset) elif portionDirectionIndex == len(portionDirections) - 1: setOffsetByMultiplier(interpolationOffset.path[-2], interpolationOffset.path[-1], endMultiplier, offset) scale = extrudeDerivation.interpolationDictionary[ 'scale'].getComplexByPortion(portionDirection) twist = extrudeDerivation.interpolationDictionary['twist'].getYByPortion( portionDirection) projectiveSpace = euclidean.ProjectiveSpace() if extrudeDerivation.tiltTop == None: tilt = extrudeDerivation.interpolationDictionary[ 'tilt'].getComplexByPortion(portionDirection) projectiveSpace = projectiveSpace.getByTilt(tilt) else: normals = getNormals(interpolationOffset, offset, portionDirection) normalFirst = normals[0] normalAverage = getNormalAverage(normals) if extrudeDerivation.tiltFollow and extrudeDerivation.oldProjectiveSpace != None: projectiveSpace = extrudeDerivation.oldProjectiveSpace.getNextSpace( normalAverage) else: projectiveSpace = projectiveSpace.getByBasisZTop( normalAverage, extrudeDerivation.tiltTop) extrudeDerivation.oldProjectiveSpace = projectiveSpace projectiveSpace.unbuckle(extrudeDerivation.maximumUnbuckling, normalFirst) projectiveSpace = projectiveSpace.getSpaceByXYScaleAngle(twist, scale) loop = [] if (abs(projectiveSpace.basisX) + abs(projectiveSpace.basisY)) < 0.0001: vector3Index = Vector3Index(len(vertexes)) addOffsetAddToLists(loop, offset, vector3Index, vertexes) loops.append(loop) return for point in path: vector3Index = Vector3Index(len(vertexes)) projectedVertex = projectiveSpace.getVector3ByPoint(point) vector3Index.setToVector3(projectedVertex) addOffsetAddToLists(loop, offset, vector3Index, vertexes) loops.append(loop)
def __init__(self, elementNode): 'Set defaults.' self.axisEnd = evaluate.getVector3ByPrefix(None, elementNode, 'axisEnd') self.axisStart = evaluate.getVector3ByPrefix(None, elementNode, 'axisStart') self.end = evaluate.getEvaluatedFloat(360.0, elementNode, 'end') self.loop = evaluate.getTransformedPathByKey([], elementNode, 'loop') self.sides = evaluate.getEvaluatedInt(None, elementNode, 'sides') self.start = evaluate.getEvaluatedFloat(0.0, elementNode, 'start') self.target = evaluate.getTransformedPathsByKey([], elementNode, 'target') if len(self.target) < 1: print('Warning, no target in derive in lathe for:') print(elementNode) return firstPath = self.target[0] if len(firstPath) < 3: print('Warning, firstPath length is less than three in derive in lathe for:') print(elementNode) self.target = [] return if self.axisStart == None: if self.axisEnd == None: self.axisStart = firstPath[0] self.axisEnd = firstPath[-1] else: self.axisStart = Vector3() self.axis = self.axisEnd - self.axisStart axisLength = abs(self.axis) if axisLength <= 0.0: print('Warning, axisLength is zero in derive in lathe for:') print(elementNode) self.target = [] return self.axis /= axisLength firstVector3 = firstPath[1] - self.axisStart firstVector3Length = abs(firstVector3) if firstVector3Length <= 0.0: print('Warning, firstVector3Length is zero in derive in lathe for:') print(elementNode) self.target = [] return firstVector3 /= firstVector3Length self.axisProjectiveSpace = euclidean.ProjectiveSpace().getByBasisZFirst(self.axis, firstVector3) if self.sides == None: distanceToLine = euclidean.getDistanceToLineByPaths(self.axisStart, self.axisEnd, self.target) self.sides = evaluate.getSidesMinimumThreeBasedOnPrecisionSides(elementNode, distanceToLine) endRadian = math.radians(self.end) startRadian = math.radians(self.start) self.isEndCloseToStart = euclidean.getIsRadianClose(endRadian, startRadian) if len(self.loop) < 1: self.loop = euclidean.getComplexPolygonByStartEnd(endRadian, 1.0, self.sides, startRadian) self.normal = euclidean.getNormalByPath(firstPath)
def motionGivenCoordinates( self, motionCoordinate, shift, startCoordinate ): "Move the motion viewpoint given the motion coordinates." latitudeLongitude = LatitudeLongitude( startCoordinate, motionCoordinate, self.window, shift ) viewVectors = euclidean.ProjectiveSpace().getByLatitudeLongitude( latitudeLongitude.latitude, latitudeLongitude.longitude ) motionCentered = self.window.getCentered( motionCoordinate ) motionCenteredNormalized = motionCentered / abs( motionCentered ) buttonOnePressedCentered = self.window.getCentered( startCoordinate ) buttonOnePressedAngle = math.degrees( math.atan2( buttonOnePressedCentered.imag, buttonOnePressedCentered.real ) ) buttonOnePressedLength = abs( buttonOnePressedCentered ) buttonOnePressedCorner = complex( buttonOnePressedLength, buttonOnePressedLength ) buttonOnePressedCornerBottomLeft = self.window.getScreenComplex( - buttonOnePressedCorner ) buttonOnePressedCornerUpperRight = self.window.getScreenComplex( buttonOnePressedCorner ) motionPressedStart = buttonOnePressedLength * motionCenteredNormalized motionPressedScreen = self.window.getScreenComplex( motionPressedStart ) motionColorName = '#4B0082' motionWidth = 9 self.canvas.delete('mouse_item') if abs( latitudeLongitude.deltaLongitude ) > 0.0: self.canvas.create_arc( buttonOnePressedCornerBottomLeft.real, buttonOnePressedCornerBottomLeft.imag, buttonOnePressedCornerUpperRight.real, buttonOnePressedCornerUpperRight.imag, extent = latitudeLongitude.originalDeltaLongitude, start = buttonOnePressedAngle, outline = motionColorName, outlinestipple = self.window.motionStippleName, style = settings.Tkinter.ARC, tags = 'mouse_item', width = motionWidth ) if abs( latitudeLongitude.deltaLatitude ) > 0.0: self.canvas.create_line( motionPressedScreen.real, motionPressedScreen.imag, motionCoordinate.real, motionCoordinate.imag, fill = motionColorName, arrow = 'last', arrowshape = self.window.arrowshape, stipple = self.window.motionStippleName, tags = 'mouse_item', width = motionWidth ) self.window.getDrawnLineText( motionCoordinate, 'mouse_item', 'Latitude: %s, Longitude: %s' % ( round( latitudeLongitude.latitude ), round( latitudeLongitude.longitude ) ) ) if self.repository.widthOfAxisPositiveSide.value > 0: self.window.getDrawnColoredLineMotion( self.window.positiveAxisLineX, viewVectors, self.repository.widthOfAxisPositiveSide.value ) self.window.getDrawnColoredLineMotion( self.window.positiveAxisLineY, viewVectors, self.repository.widthOfAxisPositiveSide.value ) self.window.getDrawnColoredLineMotion( self.window.positiveAxisLineZ, viewVectors, self.repository.widthOfAxisPositiveSide.value )
def derive(self, xmlElement): "Derive using the xmlElement." if len(self.target) < 1: print('Warning, no target in derive in lathe for:') print(xmlElement) return firstPath = self.target[0] if len(firstPath) < 3: print('Warning, firstPath length is less than three in derive in lathe for:') print(xmlElement) self.target = [] return if self.axisStart == None: if self.axisEnd == None: self.axisStart = firstPath[0] self.axisEnd = firstPath[-1] else: self.axisStart = Vector3() self.axis = self.axisEnd - self.axisStart axisLength = abs(self.axis) if axisLength <= 0.0: print('Warning, axisLength is zero in derive in lathe for:') print(xmlElement) self.target = [] return self.axis /= axisLength firstVector3 = firstPath[1] - self.axisStart firstVector3Length = abs(firstVector3) if firstVector3Length <= 0.0: print('Warning, firstVector3Length is zero in derive in lathe for:') print(xmlElement) self.target = [] return firstVector3 /= firstVector3Length self.axisProjectiveSpace = euclidean.ProjectiveSpace().getByBasisZFirst(self.axis, firstVector3) if self.sides == None: distanceToLine = euclidean.getDistanceToLineByPaths(self.axisStart, self.axisEnd, self.target) self.sides = evaluate.getSidesMinimumThreeBasedOnPrecisionSides(distanceToLine, xmlElement) if len(self.loop) < 1: self.loop = euclidean.getComplexPolygonByStartEnd(math.radians(self.end), 1.0, self.sides, math.radians(self.start)) self.normal = euclidean.getNormalByPath(firstPath)