Fct_Pixel_Set_TAG

 

This function change the TAG  pixel value of a pixel identified by its 3D position.

 

 

Syntax

 

int  (*Fct_Pixel_Set_TAG)(

          SliceO_Class *pt,

          void *ima,

          Vect pos,

          unsigned char tag

)

 

 

Parameters

 

pt

Pointer to the class calling the function.

 

ima

Pointer to a Tomo_Image structure, as defined in the SliceO_File class.

 

pos

position of a point in the image plane.

 

tag

new tag value for the target pixel.

 

 

Return value

 

This function return "1" if the pixel has been successfully changed, "0" if it already has the correct value, "-1" if the operation could not be completed.

 

 

Remarks

 

By default, the function will apply the local transformation to the position and call the same function for the parent class in the tree.  The "root" class will change the actual value.

 

Pixel that are protected by a "TAG_Lock" will not be changed and the function will return "0".

 

The "Undo" operation may prevent this operation from completing successfully.  If this is the case, it will return "-1".

 

 

Requirements

 

Header:

          sliceO_include.hpp

 

Library:

          sliceO_Structures.lib

 

 

Example

 

Default callback for all classes except "Root"

 

// ----------------------------------------------------------------------------

//

//          Class_Class_Pixel_Set_TAG

//

//          Get one pixel from the original TAG image

//

// ----------------------------------------------------------------------------

int          Class_Class_Pixel_Set_TAG( SliceO_Class *pt, void *ima, Vect pos, unsigned char tag )

{

          // --- set the flags to reflect the fact that the tag has changed ---

          // === Note: for speed, we change the variable directly ===

          pt->m_flag_status[0] |= CLASS_FLAG_TAG_CALC | CLASS_FLAG_TAG_SAVE ;

 

          // --- Apply the current transformation to the pixel's coord ---

          if ( ! pt->m_ident )

              pos *= pt->m_new2old ;

 

          // --------------------------------------------------------------------

          // --- if there is a parent func, call it ---

          // --------------------------------------------------------------------

          SliceO_Class *parent = pt->Parent_Get_Pt() ;

 

          return( parent->Fct_Pixel_Set_TAG( parent, ima, pos, tag ) ) ;

}

 

Default callback for "Root" class

 

// ----------------------------------------------------------------------------

//

//          Class_Root_Pixel_Set_TAG

//

//          Get one pixel from the original TAG image

//

// ----------------------------------------------------------------------------

int          Class_Root_Pixel_Set_TAG( SliceO_Class *pt, void *ima, Vect pos, unsigned char tag )

{

          // --- set the flags to reflect the fact that the tag has changed ---

          // === Note: for speed, we change the variable directly ===

          pt->m_flag_status[0] |= CLASS_FLAG_TAG_CALC | CLASS_FLAG_TAG_SAVE ;

 

          // --------------------------------------------------------------------

          // --- Apply the changes directly to the pixel value in the file ---

          // --------------------------------------------------------------------

 

          // --- use the DLL library to get the pixel's address ---

          unsigned char *pix = (unsigned char *) Tomo_Image_Pixel_Get( NULL,

                                                        ((Tomo_Image *) ima), ((Tomo_Image *) ima)->data_tag, sizeof(char),

                                                        (int) pos.x, (int) pos.y, (int) pos.z, (int) pos.t ) ;

          if ( ! pix )

              return( 0 ) ;

 

          // --- already the correct value? ---

          if ( *pix == tag )

              return( 0 ) ;

 

          // --- save this pixel's info for the "keystroke undo" ---

          // Note: if undo overflow we may abort the operation (ret=-1)

          if ( ! Undo_Pixel_Record_TAG( pix, *pix, tag ) )

              return( -1 ) ;

 

          *pix = tag ;

 

          // --- set the flags to reflect the fact that the tag has changed ---

          ((Tomo_Image *) ima)->flag |= (SLICE_TAG_MODIF | SLICE_TAG_AUTO) ;

 

          return( 1 ) ;

}

 

See also