Method Update_Child_A

 

Your_Class::Update_Child_A

 

The "Update_Child_A()" method is not called by sliceOmatic. It is however available to you if you need to update a region of the screen from within your DLL.  The default method just recursively call its children's method.  At the leaf of the database tree, the frame class catch the "Update_Child_A()" and use it to set the "Flag_Update" and "Flag_Redraw" variables for the appropriate frames.

 

An example of use would be in the MPR classes. If you receive an update for a region of a  2D slice, you will also need to update the matching region in the slices that have a different orientation.  this is done by calling "Update_Child_A()" (see example bellow).

 

 

Syntax

 

void Your_Class::Update_A(

          UInt64 flag,

          void *window,

          void *ima,

          Region_4D *region

)

 

 

Parameters

 

flag

is the value of the update you want to propagate. (also see Updates in the Ctrl section)

 

window

is a pointer to the window where you want to create the update.

 

ima

is a pointer to a TomoVision image header.

 

region

is a pointer to a 4D region to update.

 

 

Return value

 

This method does not return a value.

 

 

Remarks

 

 

Requirements

 

Header:

          sliceO_include.hpp

 

Library:

          sliceO_Structures.lib

 

 

Example

 

The default method

 

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

//

//          Update_Child_A()

//

//          param:          flag (UInt64)                              Update flag

//                    window (SliceO_Window *)          Window (NULL for all)

//                    ima (void *)                              Image (NULL for all)

//                    region (Region_4D *)                    Region to update

//

//          return:          (void)

//

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

void          SliceO_Class::Update_Child_A( UInt64 flag, void *window, void *ima, Region_4D *region )

{

          // --- propagate to all chidrens ---

          for ( int i=0; i < this->Child_Get_Nb(); i++ )

              Child_Get_Pt(i)->Update_Child_A( flag, window, ima, region ) ;

}

 

The frame method

 

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

//

//          Update_Child_A()

//

//          param:          flag (UInt64)                              Update flag

//                    window (SliceO_Window *)          Window (NULL for all)

//                    ima (void *)                              Image (NULL for all)

//                    region (Region_4D *)                    Region to update

//

//          return:          (void)

//

//          Note: This method only set the local flags in the DB, the general

//                flags have to be set elsewhere (Fct_Update, Fct_Redraw)

//

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

void          SliceO_Frame::Update_Child_A( UInt64 flag, void *window, void *ima, Region_4D *region )

{

          // --- only apply if this is the correct image for this frame ---

          if ( ima && (ima != this->m_ima) )

              return ;

 

          if ( (this->m_z < (int) region->min_z) || (this->m_z > (int) region->max_z) )

              return ;

 

          if ( (this->m_t < (int) region->min_t) || (this->m_t > (int) region->max_t) )

              return ;

 

          // --- region from 4D to 2D ---

          Region_2D reg_new( region->type, region->min_x, region->min_y, region->max_x, region->max_y ) ;

 

          Fct_Update( UPDATE_DATA_TAG | UPDATE_DISPLAY_TAG, window, this, &reg_new ) ;

          Fct_Redraw( REDRAW_DB_OPENGL, window, this, &reg_new ) ;

}

 

The MPR_Ortho method

 

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

//

//          Update_B()

//

//          Update one element or the complete structure (if flag is > 0)

//

//          param:          flag (unsigned int)          Update flag

//

//          return:          (void)

//

//          Note: the variable update_nb and update_pt are created in the Pixel_Set_TAG

//                    callback. It keep track of all the pixels that have been modified.

//

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

int          SliceO_Ortho::Update_B( UInt64 flag_update )

{

          // --- we are only interested in classes whose TAGs have been modified ---

          if ( ! update_nb )

              return( 1 ) ;

 

          if ( flag_update & UPDATE_DISPLAY_TAG ) {

 

              // --- which of the 3 directions is this one ? ---

              unsigned int class_id = this->Class_Id_Get() ;

              unsigned char dir = (class_id - CLASS_ID_ORTHO) >> 16 ;

 

              // --- For all the directions of the MPR ---

              for ( int i=0; i < 3; i++ ) {

 

                    // --- We do not need to "update" the original direction, it has already

                    // been done by sliceO ---

                    if ( dir != i ) {

 

                        // --- compute the region in this direction ---

                        SliceO_Ortho *ortho_i = (SliceO_Ortho *) this->Parent_Get_Pt()->Child_Get_Pt(i) ;

                        if ( ortho_i->Child_Get_Nb() ) {

 

                              // --- we can have more than 1 image modified per class ---

                              for ( int k=0; k < this->update_nb; k++ )

                                  ortho_i->Update_Child_A( flag_update, NULL, this->update_pt[k].ima, &(this->update_pt[k].region) ) ;

                        }

                    }

              }

 

              // --- clear the region (this prevent an infinite loop) ---

              FREE( update_pt ) ;

              update_nb = 0 ;

          }

          return( 1 ) ;

}

 

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

//

//          Update_Child_A()

//

//          param:          flag (UInt64)                              Update flag

//                    window (SliceO_Window *)          Window (NULL for all)

//                    ima (void *)                              Image (NULL for all)

//                    region (Region_2D *)                    Region to update

//

//          return:          (void)

//

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

void          SliceO_Ortho::Update_Child_A( UInt64 flag, void *window, void *ima, Region_4D *region )

{

          // --- which of the 3 directions is this one ? ---

          unsigned int class_id = this->Class_Id_Get() ;

          // --- we have reserved 3 IDs for the Ortho class, one for each direction ---

          unsigned char dir = (class_id - CLASS_ID_ORTHO) >> 16 ;

 

          // --- original direction, nothing special ---

          if ( this->m_ident ) {

 

              // --- propagate to all chidrens ---

              for ( int i=0; i < this->Child_Get_Nb(); i++ )

                    Child_Get_Pt(i)->Update_Child_A( flag, window, ima, region ) ;

 

              return ;

          }

 

          // --- for the other directions, I have to transform the region.

          SliceO_Ortho *ortho_0 = (SliceO_Ortho *) this->Parent_Get_Pt()->Child_Get_Pt(0) ;

 

          // --- match from "ima" to slice number ---

          // I need the slice number for the "z" value in the region.

          int min_slice=100000, max_slice=-100000 ;

 

          if ( ima ) {

              for ( int j=0; j < ortho_0->real_files_nb; j++ ) {

 

                    if ( ortho_0->real_files_pt[j]->m_bunch_head[ortho_0->real_files_bunch[j]] != ima )

                        continue ;

                    if ( (ortho_0->real_files_z[j] < region->min_z) || (ortho_0->real_files_z[j] > region->max_z))

                        continue ;

                    if ( (ortho_0->real_files_t[j] < region->min_t) || (ortho_0->real_files_t[j] > region->max_t))

                        continue ;

 

                    min_slice = MIN( min_slice, j ) ;

                    max_slice = MAX( max_slice, j ) ;

              }

          } else {

              min_slice = 0 ;

              max_slice = ortho_0->real_files_nb ;

          }

 

          if ( max_slice < min_slice )

              return ;

 

          Region_4D reg_new(*region) ;

 

          reg_new.min_z = (float) min_slice ;

          reg_new.max_z = (float) max_slice ;

 

          reg_new *= this->m_old2new ;

 

          // --- propagate to all children ---

          for ( int i=0; i < this->Child_Get_Nb(); i++ )

              Child_Get_Pt(i)->Update_Child_A( flag, window, (void *) this->ortho_tomo_pt, &reg_new ) ;

}

 

See also

 

 

 

 

 

Example: default method

 

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

//

//          Update_Child_A()

//

//          param:          flag (UInt64)                              Update flag

//                    window (SliceO_Window *)          Window (NULL for all)

//                    ima (void *)                              Image (NULL for all)

//                    region (Region_4D *)                    Region to update

//

//          return:          (void)

//

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

void          SliceO_Class::Update_Child_A( UInt64 flag, void *window, void *ima, Region_4D *region )

{

          // --- propagate to all chidrens ---

          for ( int i=0; i < this->Child_Get_Nb(); i++ )

              Child_Get_Pt(i)->Update_Child_A( flag, window, ima, region ) ;

}

 

 

Example: frame method

 

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

//

//          Update_Child_A()

//

//          param:          flag (UInt64)                              Update flag

//                    window (SliceO_Window *)          Window (NULL for all)

//                    ima (void *)                              Image (NULL for all)

//                    region (Region_4D *)                    Region to update

//

//          return:          (void)

//

//          Note: This method only set the local flags in the DB, the general

//                flags have to be set elsewhere (Fct_Update, Fct_Redraw)

//

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

void          SliceO_Frame::Update_Child_A( UInt64 flag, void *window, void *ima, Region_4D *region )

{

          // --- only apply if this is the correct image for this frame ---

          if ( ima && (ima != this->m_ima) )

              return ;

 

          if ( (this->m_z < (int) region->min_z) || (this->m_z > (int) region->max_z) )

              return ;

 

          if ( (this->m_t < (int) region->min_t) || (this->m_t > (int) region->max_t) )

              return ;

 

          // --- region from 4D to 2D ---

          Region_2D reg_new( region->type, region->min_x, region->min_y, region->max_x, region->max_y ) ;

 

          Fct_Update( UPDATE_DATA_TAG | UPDATE_DISPLAY_TAG, window, this, &reg_new ) ;

          Fct_Redraw( REDRAW_DB_OPENGL, window, this, &reg_new ) ;

}

 

 

Example: MPR_Ortho method

 

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

//

//          Update_B()

//

//          Update one element or the complete structure (if flag is > 0)

//

//          param:          flag (unsigned int)          Update flag

//

//          return:          (void)

//

//          Note: the variable update_nb and update_pt are created in the Pixel_Set_TAG

//                    callback. It keep track of all the pixels that have been modified.

//

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

int          SliceO_Ortho::Update_B( UInt64 flag_update )

{

          // --- we are only interested in classes whose TAGs have been modified ---

          if ( ! update_nb )

              return( 1 ) ;

 

          if ( flag_update & UPDATE_DISPLAY_TAG ) {

 

              // --- which of the 3 directions is this one ? ---

              unsigned int class_id = this->Class_Id_Get() ;

              unsigned char dir = (class_id - CLASS_ID_ORTHO) >> 16 ;

 

              // --- For all the directions of the MPR ---

              for ( int i=0; i < 3; i++ ) {

 

                    // --- We do not need to "update" the original direction, it has already

                    // been done by sliceO ---

                    if ( dir != i ) {

 

                        // --- compute the region in this direction ---

                        SliceO_Ortho *ortho_i = (SliceO_Ortho *) this->Parent_Get_Pt()->Child_Get_Pt(i) ;

                        if ( ortho_i->Child_Get_Nb() ) {

 

                              // --- we can have more than 1 image modified per class ---

                              for ( int k=0; k < this->update_nb; k++ )

                                  ortho_i->Update_Child_A( flag_update, NULL, this->update_pt[k].ima, &(this->update_pt[k].region) ) ;

                        }

                    }

              }

 

              // --- clear the region (this prevent an infinite loop) ---

              FREE( update_pt ) ;

              update_nb = 0 ;

          }

          return( 1 ) ;

}

 

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

//

//          Update_Child_A()

//

//          param:          flag (UInt64)                              Update flag

//                    window (SliceO_Window *)          Window (NULL for all)

//                    ima (void *)                              Image (NULL for all)

//                    region (Region_2D *)                    Region to update

//

//          return:          (void)

//

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

void          SliceO_Ortho::Update_Child_A( UInt64 flag, void *window, void *ima, Region_4D *region )

{

          // --- which of the 3 directions is this one ? ---

          unsigned int class_id = this->Class_Id_Get() ;

          unsigned char dir = (class_id - CLASS_ID_ORTHO) >> 16 ;

 

          // --- original direction, nothing special ---

          if ( this->m_ident ) {

 

              // --- propagate to all chidrens ---

              for ( int i=0; i < this->Child_Get_Nb(); i++ )

                    Child_Get_Pt(i)->Update_Child_A( flag, window, ima, region ) ;

 

              return ;

          }

 

          // --- for the other directions, I have to transform the region.

          SliceO_Ortho *ortho_0 = (SliceO_Ortho *) this->Parent_Get_Pt()->Child_Get_Pt(0) ;

 

          // --- match from "ima" to slice number ---

          // I need the slice number for the "z" value in the region.

          int min_slice=100000, max_slice=-100000 ;

 

          if ( ima ) {

              for ( int j=0; j < ortho_0->real_files_nb; j++ ) {

 

                    if ( ortho_0->real_files_pt[j]->m_bunch_head[ortho_0->real_files_bunch[j]] != ima )

                        continue ;

                    if ( (ortho_0->real_files_z[j] < region->min_z) || (ortho_0->real_files_z[j] > region->max_z))

                        continue ;

                    if ( (ortho_0->real_files_t[j] < region->min_t) || (ortho_0->real_files_t[j] > region->max_t))

                        continue ;

 

                    min_slice = MIN( min_slice, j ) ;

                    max_slice = MAX( max_slice, j ) ;

              }

          } else {

              min_slice = 0 ;

              max_slice = ortho_0->real_files_nb ;

          }

 

          if ( max_slice < min_slice )

              return ;

 

          Region_4D reg_new(*region) ;

 

          reg_new.min_z = (float) min_slice ;

          reg_new.max_z = (float) max_slice ;

 

          reg_new *= this->m_old2new ;

 

          // --- propagate to all children ---

          for ( int i=0; i < this->Child_Get_Nb(); i++ )

              Child_Get_Pt(i)->Update_Child_A( flag, window, (void *) this->ortho_tomo_pt, &reg_new ) ;

}