|
// ----------------------------------------------------------------------------
// Constructor for the ROI class
// ----------------------------------------------------------------------------
inline SliceO_ROI::SliceO_ROI( SliceO_Class *parent, unsigned short id, SliceO_File *file, int bunch, int slice )
{
this->Class_Id_Set( CLASS_ID_ROI ) ;
this->Class_Instance_Set( id ) ;
this->Title_Set( "ROI" ) ;
...
// ====================================================================
// === Set the callbacks for the Metrics functions ===
// ====================================================================
Fct_Metrics_Get_Res = Class_ROI_Metrics_Get_Res ;
}
// ----------------------------------------------------------------------------
//
// Class_ROI_Metrics_Get_Res
//
// Get the image's resolution
//
// ----------------------------------------------------------------------------
int Class_ROI_Metrics_Get_Res( SliceO_Class *pt, void *ima, int *x, int *y )
{
// --- if a parent function exist, use it! ---
SliceO_Class *parent = pt->Parent_Get_Pt() ;
if ( parent && parent->Fct_Metrics_Get_Res )
parent->Fct_Metrics_Get_Res( parent, ima, x, y ) ;
// --- now correct with the values of the ROI ---
// The "min" and "max" values have been provided
// by the user through the interface
SliceO_ROI *roi = (SliceO_ROI *) pt ;
int max_x = (int) roi->roi_real.max_x ;
int min_x = (int) roi->roi_real.min_x ;
max_x = CLIP( 0, max_x, *x -1 ) ;
min_x = CLIP( 0, min_x, *x -1 ) ;
*x = max_x - min_x + 1 ;
int max_y = (int) roi->roi_real.max_y ;
int min_y = (int) roi->roi_real.min_y ;
max_y = CLIP( 0, max_y, *y -1 ) ;
min_y = CLIP( 0, min_y, *y -1 ) ;
*y = max_y - min_y + 1 ;
return( 1 ) ;
}
|