Example #1
0
    def _snapEndPointToStandardAxis(self):
        """
        Snap the second endpoint of the line so that it lies on the nearest
        axis vector. (if its close enough) . This functions keeps the uses the
        current rubberband line vector and just extends the second end point 
        so that it lies at the intersection of the nearest axis vector and the 
        rcurrent rubberband line vector. 
        @return: The new endPoint2 i.e. the moving endpoint of the rubberband 
                 line . This value may be same as previous or snapped to lie on
                 the nearest axis (if one exists) 
        @rtype: B{A}
        """
        x_axis = V(1, 0, 0)
        y_axis = V(0, 1, 0)
        z_axis = V(0, 0, 1)

        endPoint2 = self.endPoint2
        currentLineVector = norm(self.endPoint2 - self.endPoint1)

        theta_x = angleBetween(x_axis, self.endPoint2)
        theta_y = angleBetween(y_axis, self.endPoint2)
        theta_z = angleBetween(z_axis, self.endPoint2)

        theta_x = min(theta_x, (180 - theta_x))
        theta_y = min(theta_y, (180 - theta_y))
        theta_z = min(theta_z, (180 - theta_z))

        theta = min(theta_x, theta_y, theta_z)

        if theta < 2.0:    
            if theta == theta_x:                
                self._standardAxisVectorForDrawingSnapReference = x_axis
            elif theta == theta_y:
                self._standardAxisVectorForDrawingSnapReference = y_axis
            elif theta == theta_z:                
                self._standardAxisVectorForDrawingSnapReference = z_axis

            endPoint2 = ptonline(self.endPoint2, 
                                 V(0, 0, 0), 
                                 self._standardAxisVectorForDrawingSnapReference)
        else:
            self._standardAxisVectorForDrawingSnapReference = None            

        return endPoint2
Example #2
0
    def _snapEndPointToStandardAxis(self):
        """
        Snap the second endpoint of the line so that it lies on the nearest
        axis vector. (if its close enough) . This functions keeps the uses the
        current rubberband line vector and just extends the second end point 
        so that it lies at the intersection of the nearest axis vector and the 
        rcurrent rubberband line vector. 
        @return: The new endPoint2 i.e. the moving endpoint of the rubberband 
                 line . This value may be same as previous or snapped to lie on
                 the nearest axis (if one exists) 
        @rtype: B{A}
        """
        x_axis = V(1, 0, 0)
        y_axis = V(0, 1, 0)
        z_axis = V(0, 0, 1)

        endPoint2 = self.endPoint2
        currentLineVector = norm(self.endPoint2 - self.endPoint1)

        theta_x = angleBetween(x_axis, self.endPoint2)
        theta_y = angleBetween(y_axis, self.endPoint2)
        theta_z = angleBetween(z_axis, self.endPoint2)

        theta_x = min(theta_x, (180 - theta_x))
        theta_y = min(theta_y, (180 - theta_y))
        theta_z = min(theta_z, (180 - theta_z))

        theta = min(theta_x, theta_y, theta_z)

        if theta < 2.0:
            if theta == theta_x:
                self._standardAxisVectorForDrawingSnapReference = x_axis
            elif theta == theta_y:
                self._standardAxisVectorForDrawingSnapReference = y_axis
            elif theta == theta_z:
                self._standardAxisVectorForDrawingSnapReference = z_axis

            endPoint2 = ptonline(
                self.endPoint2, V(0, 0, 0),
                self._standardAxisVectorForDrawingSnapReference)
        else:
            self._standardAxisVectorForDrawingSnapReference = None

        return endPoint2
Example #3
0
    def getHandlePoint(self, hdl, event):

        #First compute the intersection point of the mouseray with the plane
        #This will be our first self.handle_MovePt upon left down.
        #This value is further used in handleLeftDrag. -- Ninad 20070531
        p1, p2 = self.glpane.mousepoints(event)
        linePoint = p2
        lineVector = norm(p2 - p1)
        planeAxis = self.getaxis()
        planeNorm = norm(planeAxis)
        planePoint = self.center

        #Find out intersection of the mouseray with the plane.
        intersection = planeXline(planePoint, planeNorm, linePoint, lineVector)
        if intersection is None:
            intersection = ptonline(planePoint, linePoint, lineVector)

        handlePoint = intersection

        return handlePoint
Example #4
0
    def getHandlePoint(self, hdl, event):

        #First compute the intersection point of the mouseray with the plane 
        #This will be our first self.handle_MovePt upon left down. 
        #This value is further used in handleLeftDrag. -- Ninad 20070531
        p1, p2     = self.glpane.mousepoints(event)
        linePoint  = p2
        lineVector = norm(p2 - p1)
        planeAxis  = self.getaxis()
        planeNorm  = norm(planeAxis)
        planePoint = self.center

        #Find out intersection of the mouseray with the plane. 
        intersection = planeXline(planePoint, planeNorm, linePoint, lineVector)
        if intersection is None:
            intersection =  ptonline(planePoint, linePoint, lineVector)

        handlePoint = intersection

        return handlePoint