(self, pos=(0,0), angle=0, scale=1)
In-plane transformation function. Update the 3D transform based on the 2D changes
In-plane transformation function. Update the 3D transform based on the 2D changes
In - plane transformation function . Update the 3D transform based on the 2D changes
def transform(self, pos=(0,0), angle=0, scale=1):
        '''In-plane transformation function. Update the 3D transform based on the 2D changes'''
        center = self.shape * self.spacing / 2. + (self.shape + 1) % 2 * self.spacing / 2.
        inv = self.xfm.transform.homogeneous_inverse

        wpos = self.handle.center.representation.world_position
        wpos -= center
        if not isinstance(scale, (tuple, list, np.ndarray)):
            scale = [scale, scale]

        if self.axis == 1:
            trans = np.insert(pos[:2][::-1], self.axis, 0)
            wpos = np.insert(wpos[:2][::-1], self.axis, self.ipw_3d.ipw.slice_position)
            #angle = -angle
        else:
            trans = np.insert(pos[:2], self.axis, 0)
            wpos = np.insert(wpos[:2], self.axis, self.ipw_3d.ipw.slice_position)
        scale = np.insert(scale, self.axis, 1)

        self.parent._undolist.append(self.xfm.transform.matrix.to_array())

        self.xfm.transform.post_multiply()
        self.xfm.transform.translate(-wpos)
        self.xfm.transform.rotate_wxyz(np.degrees(angle), *self.ipw_3d.ipw.normal)
        self.xfm.transform.scale(scale)
        self.xfm.transform.translate(wpos)
        self.xfm.transform.translate(trans)
        self.xfm.transform.pre_multiply()

        self.xfm.widget.set_transform(self.xfm.filter.transform)
        self.xfm.update_pipeline()
        self.parent.update_slabs()

        np.save("/tmp/last_xfm.npy", self.parent.get_xfm())
def transform ( self , pos = ( 0 , 0 ) , angle = 0 , scale = 1 ) : center = self . shape * self . spacing / 2. + ( self . shape + 1 ) % 2 * self . spacing / 2. inv = self . xfm . transform . homogeneous_inverse wpos = self . handle . center . representation . world_position wpos -= center if not isinstance ( scale , ( tuple , list , np . ndarray ) ) : scale = [ scale , scale ] if self . axis == 1 : trans = np . insert ( pos [ : 2 ] [ : : - 1 ] , self . axis , 0 ) wpos = np . insert ( wpos [ : 2 ] [ : : - 1 ] , self . axis , self . ipw_3d . ipw . slice_position ) #angle = -angle else : trans = np . insert ( pos [ : 2 ] , self . axis , 0 ) wpos = np . insert ( wpos [ : 2 ] , self . axis , self . ipw_3d . ipw . slice_position ) scale = np . insert ( scale , self . axis , 1 ) self . parent . _undolist . append ( self . xfm . transform . matrix . to_array ( ) ) self . xfm . transform . post_multiply ( ) self . xfm . transform . translate ( - wpos ) self . xfm . transform . rotate_wxyz ( np . degrees ( angle ) , * self . ipw_3d . ipw . normal ) self . xfm . transform . scale ( scale ) self . xfm . transform . translate ( wpos ) self . xfm . transform . translate ( trans ) self . xfm . transform . pre_multiply ( ) self . xfm . widget . set_transform ( self . xfm . filter . transform ) self . xfm . update_pipeline ( ) self . parent . update_slabs ( ) np . save ( "/tmp/last_xfm.npy" , self . parent . get_xfm ( ) )