|
// ----------------------------------------------------------------------------
//
// Edit_Paint_Pix_Erase()
//
// bring back to old tag value under the brush
//
// Param: frame (SliceO_Frame *) ptr to the frame under the cursor
// pos_frm (Point_2D) cursor position in FRM space
//
// return: (void)
//
// ----------------------------------------------------------------------------
void Edit_Paint_Pix_Erase( SliceO_Frame *frame, Point_2D *pos_frm )
{
short k, l ;
assert( frame ) ;
assert( frame->Fct_Pixel_Set_TAG ) ;
unsigned char **erase = frame->Erase_Get() ;
if ( ! erase )
return ;
unsigned short *Brush_Size = (unsigned short *) Fct_Variable_Value( "$BRUSH_SIZE" ) ;
unsigned short Brush_Radius = (unsigned short) Fct_Variable_Value( "$BRUSH_RADIUS" ) ;
unsigned short Brush_Cur = (unsigned short) Fct_Variable_Value( "$BRUSH_CUR" ) ;
unsigned char ***Brush_Pt = (unsigned char ***) Fct_Variable_Value( "$BRUSH_PT" ) ;
// --- Get the brush's parameters ---
short b_size = Brush_Size[Brush_Cur] - 1 ;
short b_start = Brush_Radius - b_size ;
// --- compute brush position ---
Region_2D region( COORD_FRM,
(*pos_frm)[0] - b_size,
(*pos_frm)[1] - b_size,
(*pos_frm)[0] + b_size,
(*pos_frm)[1] + b_size ) ;
// --- stay inside the image ---
Region_2D cull( COORD_FRM, 0, 0, frame->m_x-1, frame->m_y-1 ) ;
short o_x=0 ;
if ( region[0] < 0.0f )
o_x = - (int) region[0] ;
short o_y=0 ;
if ( region[1] < 0.0f )
o_y = - (int) region[1] ;
if ( ! region.Cull( cull ) )
return ;
int modif = 0 ;
// --- change the actual tag values ---
unsigned short TAG_Cur = (unsigned short) Fct_Variable_Value( "$TAG_CUR" ) ;
Vect pos ;
pos.z = frame->m_z ;
pos.t = frame->m_t ;
for ( pos.y = region[1], l = b_start+o_y; pos.y <= region[3]; pos.y++, l++ )
for ( pos.x = region[0], k = b_start+o_x; pos.x <= region[2]; pos.x++, k++ )
if ( Brush_Pt[Brush_Cur][l][k] )
modif |= frame->Fct_Pixel_Set_TAG( frame,
frame->m_ima,
pos,
erase[(int)pos[1]][(int)pos[0]] ) ;
// --- if nothing change, get out ---
if ( ! modif )
return ;
// --- Update the displayed tag image ---
Fct_Update( UPDATE_DISPLAY_TAG, CLASS_MODE_ALL, frame, ®ion ) ;
Fct_Redraw( REDRAW_DB_OPENGL, CLASS_MODE_ALL, frame, ®ion ) ;
}
|