sliceO_Class::Update_A, B

 

SliceO_Class::Update_A

SliceO_Class::Update_B

 

If they exist, the Update_A() and Update_B() method are called by sliceOmatic.

 

Update_A is called as soon as the changes are detected (one per loop).

 

Update_B will only be called when more immediate operations have been done (once all current redraw demand have been met). This is used to update non-essential part of the interface.

 

Both function receive a 64 bit unsigned integer as argument.  This argument is the current value of the update flag.

 

 

Syntax

 

virtual int  Update_A(

          UInt64 flag

)

 

virtual int  Update_B(

          UInt64 flag

)

 

 

Parameters

 

flag

The current "Update Flag" value.  This is an "or" of all the updates that occurred since the last processing of the updates.

 

 

Return value

 

The methods returns 0 if an error occurred, 1 otherwise.

 

 

Remarks

 

These methods are optional.  If you do not have any updates to do, you can omit them.

 

There are 2 copies of the update flag, Each function receive its own copy. Once all "Update_A()" methods have been called, one copy is reset, once all "Update_B()" have been called, the second copy is reset.

 

The default method for these do nothing.

 

Requirements

 

Header:

          sliceO_include.hpp

 

Library:

          sliceO_Structures.lib

 

 

Example

 

In "MPR_Ortho" and "MOR_Oblique" classes, when we change the tag values on the frames in one direction, we also have to change the corresponding tags in the other directions. We do this by keeping a list of all modified TAG regions, then using the "Update_B", we compute the region to refresh in the other direction when we can.

 

In the callback "Pixel_Set_TAG" we fill out the "update_pt" structures with the modified regions. "Update_nb" keep a count of how many of these have been created.

 

Then we have the following "Update_B" virtual method:

 

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

//

//          Update_B()

//

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

//

//          param:          flag (unsigned int)          Update flag

//

//          return:          (void)

//

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

int          SliceO_Ortho::Update_B( UInt64 flag_update )

{

          VALIDITY_TEST_ORTHO( this, "SliceO_Ortho::Update_B" ) ;

 

          // --- 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 ;

 

              Error_Fct( hwnd, ERROR_CODE_TRACE_1, "Update_B for (%s) dir: %d", this->Name_Get(), dir ) ;

 

              // --- 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()

//

//          High priority update of this childrens

//

//          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 )

{

          VALIDITY_TEST_ORTHO( this, "SliceO_Ortho::Update_Child_A" ) ;

 

          // --- wich 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 chidrens ---

          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

 

The Update Fct

Update_A

Update_B

Ctrl_Update