Source Code

 

 

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

//

//                    Definition of the Class SliceO_Class

//

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

class          SLICEO_DB SliceO_Class {

 

 

          // ====================================================================

          // ===              Constructors                                                      ===

          // ====================================================================

public:

                    SliceO_Class( void ) ;

          virtual          ~SliceO_Class( void ) ;

 

          // ====================================================================

          // ===              We need a few flags                                                      ===

          // ====================================================================

private:

          // --- Flag for the update and redraw of this level ---

          unsigned int          m_flag_lock ;                              // critical region protection

 

public:

          UInt64                    *m_flag_update_a ;

          UInt64                    *m_flag_update_b ;

          UInt64                    *m_flag_redraw ;

          UInt64                    *m_flag_status ;                    // expand/collapse...

 

 

          unsigned short          *m_fps ;          // number of frames per seconds (1 to 30)

          UINT_PTR                    *m_timer ;          // ID of the timer for frame loops

 

public:

          inline void                    Lock_Set( int val ) ;

          inline unsigned int          Lock_Get( void ) ;

 

          void                    Update_A_Set_On(  unsigned char mode, void *window, UInt64 mask ) ;

          void                    Update_A_Set_Off( unsigned char mode, void *window, UInt64 mask ) ;

          UInt64                     Update_A_Get_Bit( unsigned char mode, void *window, UInt64 mask ) ;

 

          void                    Update_B_Set_On(  unsigned char mode, void *window, UInt64 mask ) ;

          void                    Update_B_Set_Off( unsigned char mode, void *window, UInt64 mask ) ;

          UInt64                     Update_B_Get_Bit( unsigned char mode, void *window, UInt64 mask ) ;

 

          void                    Redraw_Set_On(  unsigned char mode, void *window, UInt64 mask ) ;

          void                    Redraw_Set_Off( unsigned char mode, void *window, UInt64 mask ) ;

          UInt64                    Redraw_Get_Bit( unsigned char mode, void *window, UInt64 mask ) ;

 

          void                    Flag_Set_On(  unsigned char mode, void *window, UInt64 mask ) ;

          void                    Flag_Set_Off( unsigned char mode, void *window, UInt64 mask ) ;

          void                    Flag_Toggle(  unsigned char mode, void *window, UInt64 mask ) ;

          UInt64                    Flag_Get_Bit( unsigned char mode, void *window, UInt64 mask ) ;

 

          // --- set the visibility flag for an element an its decendants ---

          void          Visibility_Set( SliceO_Window *window, unsigned char recurs=1 ) ;

 

          // --- The update functions are virtual ---

          virtual int          Update_A( UInt64 flag ) ;

          virtual int          Update_B( UInt64 flag ) ;

 

          // --- we also have functions to propagate the updates to the childs ---

          virtual void          Update_Child_A( UInt64 flag, void *window, void *ima, Region_4D *region ) ;

 

 

          // ====================================================================

          // ===              Item identification                                                      ===

          // ====================================================================

public:

          unsigned int          m_index ;          // index of this class (start with 1) will be unique for

                              // each instances of each class (but they may not be

                              // sequential, and there will be holes)

private:

          char          *m_title ;          // name of this class

          char          *m_name ;          // name of this element

          char          *m_sort ;          // sort parameter of this element (as a char string)

          unsigned int          m_class_id ;          // id for this class (also use for error checking)

                              // This value is split in 3 parts:

                              // 0xFF000000 -> Magic number (0xAA000000 for Class)

                              // 0x00FF0000 -> Class number

                              // 0x0000FFFF -> Instance number

                              // Note : Class + Instance = Id

 

public:

          inline char          *Title_Get( void ) ;

          inline int          Title_Set( char *title ) ;

          inline char          *Name_Get( void ) ;

          inline int          Name_Set( char format[], ... ) ;

          inline char          *Sort_Get( void ) ;

          inline int          Sort_Set( char format[], ... ) ;

 

          inline unsigned int          Class_Magic_Get( void ) ;                    // 0xFF000000

          inline void          Class_Magic_Set( unsigned int) ;

          inline unsigned int          Class_Class_Get( void ) ;                    // 0x00FF0000

          inline void          Class_Class_Set( unsigned int) ;

          inline unsigned int          Class_Id_Get( void ) ;                    // 0x00FFFFFF

          inline void          Class_Id_Set( unsigned int) ;

          inline unsigned int          Class_Instance_Get( void ) ;

          inline void          Class_Instance_Set( unsigned int ) ;          // 0x0000FFFF

 

          // --- Stool is used for debugging ---

          // If "flag_recursive" is set, the function also stool all its children

          virtual void          Stool( int trace=ERROR_CODE_TRACE, int level=0, unsigned char recurs=1 ) ;

 

          // --- virtual functions ---

          virtual int          Resize( SliceO_Window *window, Region_2D *region=NULL ) ;

 

          // ====================================================================

          // ===              Structure Tree parameters                                            ===

          //          Each level can have multiple childs and one parent

          // ====================================================================

private:

          SliceO_Class          *m_parent_pt ;                    // poiter to parent structure

          int          m_child_nb ;                    // total number of children

          SliceO_Class          **m_child_pt ;                    // pointer to childrens

 

public:

          inline SliceO_Class    *Parent_Get_Pt( void ) ;

          inline void          Parent_Set_Pt( SliceO_Class *parent ) ;

          inline int          Child_Get_Nb( void ) ;

          inline SliceO_Class    *Child_Get_Pt( int child_id ) ;

 

          int          Child_Get_Cur( SliceO_Window *window ) ;

          int          Child_Delete( void ) ;                    // delete all childrens

          int          Child_Add( SliceO_Class *child ) ;

          int          Descendant_Get_Nb( void ) ;

 

          // --- compare return an integer evaluating 2 elements of the same class ---

          virtual int          Sort( unsigned char recurs=1 ) ;

          virtual int          Compare( SliceO_Class *pt_b ) ;

 

          // --- get the name of the icon for this class ---

          virtual char          *Icon_Name( void ) ;

 

          // ====================================================================

          // ===              Interface events                                                      ===

          //  Some class may have gadgets that can interact with the mouse   

          // ====================================================================

public:

          virtual int          Interface_Click(  SliceO_Window *window, int up_down, Point_2D *mouse_inf ) ;

          virtual int          Interface_Motion( SliceO_Window *window, int up_down, Point_2D *mouse_inf ) ;

          virtual int          Interface_Scroll( SliceO_Window *window, int count,   Point_2D *mouse_inf ) ;

          virtual int          Interface_Key(    SliceO_Window *window, int key,     Point_2D *mouse_inf ) ;

          virtual int          Interface_Select( SliceO_Window *window, Region_2D *region_inf ) ;

 

          // ====================================================================

          // ===              Total Display range of this structure                        ===

          //  Everything incuded in this structure or its children fit in

          //  this screen range.  The range is define by its 2 extrems in

          //  infinite window space.

          // ====================================================================

private:

          Region_2D   *m_inside ;    // pos of this element (in Inf space)

 

public:

          // --- querry the display range values ---

          Region_2D   Inside_Get( SliceO_Window *window ) ;

          void              Inside_Set( SliceO_Window *window, Region_2D region ) ;

          void              Inside_Set( SliceO_Window *window, int left, int bot, int right, int top ) ;

          // --- clear the display range ---

          void              Inside_Clear( SliceO_Window *window ) ;

          // --- add to the display range ---

          void              Inside_Add( SliceO_Window *window, Region_2D reg ) ;

 

          // --- return 1 if part of the region is inside the display range ---

          int              Inside_Range( SliceO_Window *window, Region_2D reg ) ;

          // --- return 1 if the point is inside the display range ---

          int              Inside_Pt( SliceO_Window *window, Point_2D pt ) ;

 

 

          // ====================================================================

          // --- We can have a number of user structures associated ---

          // Note: make sure that the ID you use for your structure is unique.

          //           TomoVision reserve ID 0 through 100

          // Note: The "allocator" parameter is for the memory manager to keep

          //           track of the total amount of memory used.

private:

          int          m_user_nb ;          // number of user data pointers

          unsigned int          *m_user_id ;          // an index for each data pointer

          SliceO_Buffer          **m_user_pt ;          // vector of data pointers

 

public:

          SliceO_Buffer  *User_Get( unsigned int id ) ;

          int          User_Set( unsigned int id, SliceO_Buffer *pt ) ;

          int          User_Delete( unsigned int id ) ;

          void          User_Stool( int trace, int level=0, unsigned int id=0 ) ;

          UInt64          User_Memory( void ) ;          // total user memory usage

          UInt64          User_Cleanup( int level ) ; // cleanup of a priority level

          // ====================================================================

 

          // ====================================================================

          // ===              Mutual exclusion                                                      ===

          // ====================================================================

private:

          HANDLE          mutex ;

 

public:

          void          Mutex_Open(  char *str ) ;

          void          Mutex_Close( char *str ) ;

 

          // ====================================================================

          // ===              From original data to current data                                  ===

          // ====================================================================

public:

          unsigned char          m_ident ; // 1 if old2new is identity

          Matrix          m_old2new ;

          Matrix          m_new2old ;

 

public:

          // ====================================================================

          // --- we also have callbacks for the pixel values ---

          int          (*Fct_Pixel_Get_GLI)( SliceO_Class *pt, void *ima, Vect pos ) ;

          unsigned char          (*Fct_Pixel_Get_TAG)( SliceO_Class *pt, void *ima, Vect pos ) ;

          int          (*Fct_Pixel_Set_TAG)( SliceO_Class *pt, void *ima, Vect pos, unsigned char tag ) ;

 

          // ====================================================================

          // Return the x & y image resolution

          int          (*Fct_Metrics_Get_Res)( SliceO_Class *pt, void *ima, int *x, int *y ) ;

          // return the 3D coord of a point in the image plane

          Vect          (*Fct_Metrics_Get_Pos)( SliceO_Class *pt, void *ima, Vect pos_2D ) ;

 

 

          // ====================================================================

          // --- we also have callbacks for drawing the structure ---

          int          (*Fct_Draw_Highlight)(          SliceO_Class *pt, UInt64 flag, SliceO_Window *window ) ;

          // --- default value is at "0", but first we try all the other ones. if

          // --- a callback is present and it return=2, we do not call default.

          int          (*Fct_Draw_Base[CALLBACK_NB_BASE])(       SliceO_Class *pt, UInt64 flag, SliceO_Window *window ) ;

          // --- these callback are to add drawings on top of the base.  The are called

          // in increasing value starting at 0.  So the latest will be on top ---

          int          (*Fct_Draw_OpenGL[CALLBACK_NB_OPENGL])(   SliceO_Class *pt, UInt64 flag, SliceO_Window *window ) ;

          int          (*Fct_Draw_Stencil[CALLBACK_NB_STENCIL])( SliceO_Class *pt, UInt64 flag, SliceO_Window *window ) ;

          // --- this callback is to add 3D elements for each class in the 3D windows. ---

          int          (*Fct_Draw_3D[CALLBACK_NB_3D])(          SliceO_Class *pt, UInt64 flag, SliceO_Window *window ) ;

          // ====================================================================

 

} ;