|
#include "sliceO_include.hpp"
// ----------------------------------------------------------------------------
//
// Edit_Paint_Pix_Add()
//
// change the 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_Add( SliceO_Frame *frame, Point_2D *pos_frm )
{
short k, l ;
assert( frame ) ;
assert( frame->Fct_Pixel_Set_TAG ) ;
unsigned short TAG_Cur = (unsigned short) Fct_Variable_Value( "$TAG_CUR" ) ;
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 ---
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, (unsigned char) TAG_Cur ) ;
// --- if nothing change, get out ---
if ( ! modif )
return ;
// --- we updated the image, the erase buffer is now different from the image. ---
frame->Flag_Set_On( CLASS_MODE_THIS, CLASS_MODE_NONE, CLASS_FLAG_TAG_ERASE ) ;
Fct_Update( UPDATE_ERASE ) ;
// --- Update the displayed tag image ---
Fct_Update( UPDATE_DISPLAY_TAG, CLASS_MODE_ALL, frame, ®ion ) ;
// --- we will need a redraw of this portion of the screen ---
Fct_Redraw( REDRAW_DB_OPENGL, CLASS_MODE_ALL, frame, ®ion ) ;
}
|