예제 #1
0
    def moveAbsolute(self):
        """
        Move selected chunk(s), jig(s) to absolute X, Y, and Z by computing
        the bbox center of everything as if they were one big chunk, then move
        everything as a unit.
        """
        movables = self.graphicsMode.getMovablesForLeftDragging()
        if not movables:
            env.history.message(redmsg("No chunks or movable jigs selected."))
            return

        ## Compute bbox for selected chunk(s).

        bbox = BBox()
        for m in movables:
            if hasattr(m, "bbox"): # Fixes bug 1990. Mark 060702.
                bbox.merge(m.bbox)
        pt1 = bbox.center() # pt1 = center point for bbox of selected chunk(s).

        pt2 = self.propMgr.get_move_xyz() # pt2 = X, Y, Z values from PM
        offset = pt2 - pt1 # Compute offset for translating the selection

        self.assy.translateSpecifiedMovables(offset,
                                             movables = movables)

        # Print history message about what happened.
        if len(movables) == 1:
            msg = "[%s] moved to [X: %.2f] [Y: %.2f] [Z: %.2f]" % (movables[0].name, pt2[0], pt2[1], pt2[2])
        else:
            msg = "Selected chunks/jigs moved by offset [X: %.2f] [Y: %.2f] [Z: %.2f]" % (offset[0], offset[1], offset[2])
        env.history.message(msg)
        self.o.gl_update()
        return
예제 #2
0
    def moveAbsolute(self):
        """
        Move selected chunk(s), jig(s) to absolute X, Y, and Z by computing
        the bbox center of everything as if they were one big chunk, then move
        everything as a unit.
        """
        movables = self.graphicsMode.getMovablesForLeftDragging()
        if not movables:
            env.history.message(redmsg("No chunks or movable jigs selected."))
            return

        ## Compute bbox for selected chunk(s).

        bbox = BBox()
        for m in movables:
            if hasattr(m, "bbox"):  # Fixes bug 1990. Mark 060702.
                bbox.merge(m.bbox)
        pt1 = bbox.center(
        )  # pt1 = center point for bbox of selected chunk(s).

        pt2 = self.propMgr.get_move_xyz()  # pt2 = X, Y, Z values from PM
        offset = pt2 - pt1  # Compute offset for translating the selection

        self.assy.translateSpecifiedMovables(offset, movables=movables)

        # Print history message about what happened.
        if len(movables) == 1:
            msg = "[%s] moved to [X: %.2f] [Y: %.2f] [Z: %.2f]" % (
                movables[0].name, pt2[0], pt2[1], pt2[2])
        else:
            msg = "Selected chunks/jigs moved by offset [X: %.2f] [Y: %.2f] [Z: %.2f]" % (
                offset[0], offset[1], offset[2])
        env.history.message(msg)
        self.o.gl_update()
        return
예제 #3
0
 def _updateBBox(self, curveList):
     """
     Recompute the bounding box for the list of curves
     """
     bbox = BBox()
     for c in curveList[1:]:
         bbox.merge(c.bbox)
     curveList[0] = bbox
예제 #4
0
 def _updateBBox(self, curveList):
     """
     Recompute the bounding box for the list of curves
     """
     bbox = BBox()
     for c in curveList[1:]:
         bbox.merge(c.bbox)
     curveList[0] = bbox
예제 #5
0
    def __computeBBox(self):
        """
        Compute the plane's current bounding box.
        """

        # The move absolute method moveAbsolute() in Move_Command relies on a
        # 'bbox' attribute for the movables. This attribute is really useless
        # for Planes otherwise. Instead of modifying that method, I added the
        # attribute bbox here to fix BUG 2473.
        # -- ninad 2007-06-27.

        hw = self.width * 0.5
        hh = self.height * 0.5

        corners_pos = [
            V(-hw, hh, 0.0),
            V(-hw, -hh, 0.0),
            V(hw, -hh, 0.0),
            V(hw, hh, 0.0)
        ]
        abs_pos = []

        for pos in corners_pos:
            abs_pos += [self.quat.rot(pos) + self.center]

        return BBox(abs_pos)
예제 #6
0
    def __init__(self, right, up, normal):
        """
        A shape is a set of curves defining the whole cutout.
        """
        self.curves = []
        self.bbox = BBox()

        # These arguments are required to be orthonormal:
        self.right = right
        self.up = up
        self.normal = normal
예제 #7
0
    def _addCurve(self, layer, c):
        """
        Add curve into its own layer, update the bbox
        """
        self.havelist = 0

        if not layer in self.layeredCurves:
            bbox = BBox()
            self.layeredCurves[layer] = [bbox, c]
        else:
            self.layeredCurves[layer] += [c]
        self.layeredCurves[layer][0].merge(c.bbox)
예제 #8
0
    def _computeBBox(self):
        """
        Construct the 3D bounding box for this volume.
        """
        self.rad = vlen(self.ptlist[1] - self.ptlist[0])
        self.cirCenter = self.project_2d(self.ptlist[0])

        bbhi = self.cirCenter + V(self.rad, self.rad)
        bblo = self.cirCenter - V(self.rad, self.rad)

        x, y = self.right, self.up
        self.bbox = BBox(V(bblo, bbhi), V(x, y), self.slab)
예제 #9
0
 def _computeBBox(self):
     """
     Construct the 3d bounding box for the area
     """  
     # compute bounding rectangle (2d)
     self.pt2d = map( self.project_2d, self.ptlist)
     assert not (None in self.pt2d)
     
     self.bboxhi = reduce(maximum, self.pt2d)
     self.bboxlo = reduce(minimum, self.pt2d)
     bboxlo, bboxhi = self.bboxlo, self.bboxhi
     
     # compute 3d bounding box
     # Note: bboxlo, bboxhi are 2d coordinates relative to the on plane
     # 2D coordinate system: self.right and self.up. When constructing
     # the 3D bounding box, the coordinates will be transformed back to 
     # 3d world coordinates.
     if self.slab:
         x, y = self.right, self.up
         self.bbox = BBox(V(bboxlo, bboxhi), V(x, y), self.slab)
     else:
         self.bbox = BBox()
     return
예제 #10
0
    def __computeBBox(self):
        """
        Compute current bounding box.
        """
        hw = self.width / 2.0
        hh = self.height / 2.0
        corners_pos = [
            V(-hw, hh, 0.0),
            V(-hw, -hh, 0.0),
            V(hw, -hh, 0.0),
            V(hw, hh, 0.0)
        ]
        abs_pos = []
        for pos in corners_pos:
            abs_pos += [self.quat.rot(pos) + self.center]

        return BBox(abs_pos)