DB File

 

 

 

The Tool_DB_File class enable you display a graphical view of the files currently loaded in sliceOmatic.  By clciking on one of these files, you can select the matching frames in the database.  Inversely, selecting frames in the database will change the value of the check marks beside the file's names.

 

The files are displayed as a 3 level structure:

·The first level is the directory where the file reside.

·The second level is the name of the file

·The third level is the frames (images) contained in the file.

 

 

The variables of the Tool_DB_File class are:

 

 

int           list_nb ;

//

 

DB_List *list_pt ;

//

 

 

The methods of the Tool_DB_File class are:

 

 

Tool_DB_File() ;

 

Constructor

 

~Tool_DB_File() ;

 

Destructor

 

int          Read( void ) ;

 

// There is no "Read" method for this class

 

 

The methods shared with the other SliceO_Tool classes are:

 

 

int          Click( int up_down ) ;

You must call this method if the user has activated a mouse button while the cursor is inside the tool

 

void          Draw( void ) ;

 

This method will draw the tool

 

int          Height( unsigned short nb=10 ) ;

This method returns the height (in pixel) of the tool. The "nb" parameter defines how many lines of information will be displayed.

 

int          Keyboard( int key ) ;

You must call this method if the user has activated a keyboard key while the cursor is inside the tool

 

void          Leave( void ) ;

 

You must call this method if the user move the cursor outside of the tool

 

int          Motion( int up_down ) ;

 

You must call this method if the user move the cursor inside the tool

 

int          Resize( Boxs *box ) ;

You must call this method to resize the tool. The tool will reside inside the bounding box of the "Boxs" class.

 

int          Scroll( int val ) ;

You must call this method if the user has activated the mouse wheel while the cursor is inside the tool

 

void          Update( UInt64 flag )

You must call this method when external events change the content of the tool.  The "flag" parameter is the "Update Flag" defining these changes.

The update should be called if one of the following flags are changed:

UPDATE_ALL_TOOLS

UPDATE_SELECTION          // the selected frames have changed

UPDATE_DATA_GLI          // the GLI data of a frame has changed

UPDATE_THRESHOLD

UPDATE_COLOR_TAG          // the color associated with the TAGs has changed

UPDATE_CUR_TAG          // the current TAG has changed

UPDATE_CURSOR          // the cursor has moved (needed for the white line)

UPDATE_COLOR_WORK

 

 

The DB_List structure is composed of:

 

 

typedef          struct          DB_List {

 

 

 

          unsigned short          state ;

          unsigned short          select ;

          unsigned short          line ;                      

          unsigned short          type ;                    

          unsigned short          level ;                    

          unsigned short          child_nb ;          

          unsigned short          child_id ;          

          unsigned short          child_tot ;          

 

// expand, collapse

// off, partial, on

// line displayed           

// root, frame...

// nesting level

// nb of immediate children (next level)

// id of this "child" (/vs/ previous level)

// total number of childs (all levels)

 

          void                    *back_pt ;          

 

// pointer to the original structure

 

          unsigned int          color ;                    

          char                    *title ;

          char                    *name ;

          char                    *icon ;

 

// default color for this title

 

 

          unsigned short          text_nb ;             

          int                    *text_offset ;             

          unsigned int          *text_color ;             

          char                    **text_title ;

          char                    **text_data ;

 

// user associated data

// horizontal pos of this text

// default color for this title

 

 

} DB_List ;

 

 

 

The values of the "select" variable are:

 

 

TOOL_LIST_SELECT_OFF

TOOL_LIST_SELECT_ON

TOOL_LIST_SELECT_PARTIAL

TOOL_LIST_SELECT_DELETE          

 

// Neither this element nor any of its children are selected

// This element and all its children are selected

// Only some of the children are selected

// This element is selected for deletion

 

The values of the "state" variable are:

 

 

TOOL_LIST_STATE_COLLAPSED

TOOL_LIST_STATE_EXPAND          

TOOL_LIST_STATE_LEAF          TOOL_LIST_STATE_LAST          TOOL_LIST_STATE_NO_ACCESS

// The children of this branch are not displayed

// The children of this branch are displayed

// This element has no children

// This is the last element at this level of the list

// This element can not be selected

 

 

 

An example of the usage of the Tool_DB_File class is given in the Samples\SliceO Tools\DB_File demo directory. 

 

 

The tool_db_file_ctrl.cpp file from the Tool_DB_File demo

 

...

 

// --- Interface tools ---

static          Boxs          box_box ;

 

// --- for DB_Class list Tool ---

static          Boxs          box_db ;

static          Tool_DB_File          tool_db ;

 

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

//

//          Function:          Ctrl_Register

//

//          Parameters:          mode (unsigned short *)          Used only for Tools.

//                                                            If this pointer is not NULL,

//                                                            use it to specify to what tool

//                                                            window we belong.

//                                                            SLICEO_TOOL_2D, _BASIC,_3D...

//                                                  

//          Returns:          (int)                    Vertical size of your menu (in pixels)

//

//          This is called once at the start of the program.  We need it to

//          know you are using your own func. and how much space to reserve

//          in the menu interface.  You must also change the "mode" flag to

//          reflect in what tool window you want to appear.

//

//          Note: If you do not need a graphic interface, just comment out

//                the "Ctrl_Register" function.

//

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

extern "C" __declspec(dllexport) int          Ctrl_Register( unsigned short *mode )

{

          // --- this is a 2D TAG tool only ---

          if ( mode )

              (*mode) = SLICEO_TOOL_2D ;

 

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

// In the "Config" menu, the user can change the interface's size.

// This action change a number of variables that are used to compute

// the size of the tool in the interface.  We now load a few of these

// variables and use them to compute the dimension of our interface box.

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

short          Title_Dim =           (short) Fct_Variable_Value( "$INTERFACE_TITLE_DIM_BIG" ) ;

short          Space_Dim =           (short) Fct_Variable_Value( "$INTERFACE_SPACE_DIM" ) ;

 

          // --- compute the height of the interface ---

          short height = Title_Dim                              // title at top of tool

                         + tool_db.Height(10)          // selection tool with 10 line of text

                         + Space_Dim ;                              // space at the bottom

 

          return( height ) ;

}

 

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

//

//          Function:          Ctrl_Create

//

//          Parameters:          wnd (HWND)          Pointer to Window's created window

//                              width (int)          horiz. size of the window

//                              height (int)          vert. size of the window

//          Returns:          (int)                    0 if error

//

//          This is called once when your control window is created

//

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

extern "C" __declspec(dllexport) int          Ctrl_Create( HWND wnd, int width, int height )

{

char   *Title_Font_Name =   (char *) Fct_Variable_Value( "$INTERFACE_TITLE_FONT_NAME" ) ;

char   *Title_Font_Weight = (char *) Fct_Variable_Value( "$INTERFACE_TITLE_FONT_WEIGHT" ) ;

short          Title_Font_Scale =  (short)  Fct_Variable_Value( "$INTERFACE_TITLE_FONT_SCALE" ) ;

short          Border_Dim =              (short)  Fct_Variable_Value( "$INTERFACE_BORDER_DIM" ) ;

 

          box_box.Name = "------- SliceO DB File -------" ;

          box_box.Flag      = OUTIL_DISABLE | OUTIL_NO_3D ;

          box_box.Pos_X     = 1 ;

          box_box.Pos_Y     = 1 ;

          box_box.Dim_X     = width - 2 ;

          box_box.Dim_Y     = height - 2 ;

          box_box.border    = Border_Dim;

          box_box.color.set( WINDOW_COLOR_TOOL_R,

                                 WINDOW_COLOR_TOOL_G,

                                 WINDOW_COLOR_TOOL_B ) ;

          box_box.Font_Name   = Title_Font_Name ;

          box_box.Font_Scale  = Title_Font_Scale ;

          box_box.Font_Weight = Title_Font_Weight ;

          box_box.Init( wnd ) ; 

 

          return( 1 ) ;

}

 

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

//

//          Function:          Ctrl_Resize

//

//          Parameters:          wnd (HWND)          Pointer to Window's created window

//                              width (int)          horiz. size of the window

//                              height (int)          vert. size of the window

//          Returns:          (int)                    0 if error

//

//          This is called once when your control window is created

//

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

extern "C" __declspec(dllexport) int          Ctrl_Resize( HWND wnd, int width, int height )

{

short          p_x, p_y, d_x, d_y ;

 

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

// In the "Config" menu, the user can change the interface's size.

// This action change a number of variables that are used to compute

// the size of the tool in the intearface.  We now load a few of these

// variables and use them to compute the dimension of our interface tools.

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

char   *Title_Font_Name =   (char *) Fct_Variable_Value( "$INTERFACE_TITLE_FONT_NAME" ) ;

char   *Title_Font_Weight = (char *) Fct_Variable_Value( "$INTERFACE_TITLE_FONT_WEIGHT" ) ;

short          Title_Font_Scale =  (short)  Fct_Variable_Value( "$INTERFACE_TITLE_FONT_SCALE" ) ;

char   *Tools_Font_Name =   (char *) Fct_Variable_Value( "$INTERFACE_TOOL_FONT_NAME" ) ;

char   *Tools_Font_Weigth = (char *) Fct_Variable_Value( "$INTERFACE_TOOL_FONT_WEIGHT" ) ;

short          Tools_Font_Scale =  (short)  Fct_Variable_Value( "$INTERFACE_TOOL_FONT_SCALE" ) ;

 

short          Space_Dim =              (short)  Fct_Variable_Value( "$INTERFACE_SPACE_DIM" ) ;

short          Border_Dim =              (short)  Fct_Variable_Value( "$INTERFACE_BORDER_DIM" ) ;

 

 

          if ( wnd ) {

              box_box.Pos_X     = 1 ;

              box_box.Pos_Y     = 1 ;

              box_box.Dim_X     = width - 2 ;

              box_box.Dim_Y     = height - 2 ;

              box_box.border    = Border_Dim;

              box_box.Font_Name   = Title_Font_Name ;

              box_box.Font_Scale  = Title_Font_Scale ;

              box_box.Font_Weight = Title_Font_Weight ;

              box_box.Init( wnd ) ; 

          } else {

              wnd = box_box.wnd ;

          }

 

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

          // --- DB File selection Tool

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

          p_x = box_box.Pos_X + Space_Dim ;

          p_y = box_box.Pos_Y + Space_Dim ;

          d_x = box_box.Dim_X - 2*Space_Dim ;

          d_y = tool_db.Height(10) ;

 

          // --- The tool will be inside this box ---

          box_db.Flag = OUTIL_NO_3D ;

          box_db.Pos_X = p_x ;

          box_db.Pos_Y = p_y ;

          box_db.Dim_X = d_x ;

          box_db.Dim_Y = d_y ;

          box_db.color = box_box.color ;

          box_db.border    = Border_Dim;

          box_db.Font_Name   = Tools_Font_Name ;

          box_db.Font_Weight = Tools_Font_Weigth ;

          box_db.Font_Scale  = Tools_Font_Scale ; // + 1 ;

          box_db.Init( wnd ) ;

 

          // --- now prepare the tool itself ---

          tool_db.Resize( &box_db ) ;

 

          return( 1 ) ;

}

 

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

//

//          Function:          Ctrl_Draw

//

//          Parameters:          (void)

//          Returns:          (int)                    0 if error

//

//          This is called each time your menu has to be re-drawn

//

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

extern "C" __declspec(dllexport) int          Ctrl_Draw( HWND wnd )

{

          // --- if the window if off or invisible, we can get out ---

          if ( ! Flag_Ctrl_Wnd_On )

              return( 1 ) ;

          if ( ! Flag_Ctrl_Visible )

              return( 1 ) ;

 

          box_box.Draw() ;

 

          // --- DB_Class list Tool ---

          tool_db.Draw() ;

 

          return( 1 ) ;

}

 

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

//

//          Function:          Ctrl_Leave

//

//          Parameters:          (void)

//          Returns:          (int)                    0 if error

//

//          This is called each time the cursor leave your menu

//

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

extern "C" __declspec(dllexport) int          Ctrl_Leave( void )

{

          // --- if the window if off or invisible, we can get out ---

          if ( ! Flag_Ctrl_Wnd_On )

              return( 1 ) ;

          if ( ! Flag_Ctrl_Visible )

              return( 1 ) ;

 

          tool_db.Leave() ;

 

          return( 1 ) ;

}

 

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

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

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

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

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

 

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

//

//          Function:          Ctrl_Click

//

//          Parameters:          wnd (HWND)          Pointer to Window's generating the signal

//                              up_down (int)          state of the mouse buttons

//                              x, y (int)          current cursor position

//          Returns:          (int)                    0 if error

//

//          This is called each time the cursor is inside your menu and the state

//          of the mouse buttons has changed.

//

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

extern "C" __declspec(dllexport) int          Ctrl_Click( HWND wnd, int up_down, short x, short y )

{

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

          // ---              DB_Class List Tool                              ---

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

          if ( tool_db.Click( up_down ) >= 0  ) {

          }

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

 

          return( 0 ) ;

}

 

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

//

//          Function:          Ctrl_Motion

//

//          Parameters:          wnd (HWND)          Pointer to Window's generating the signal

//                              up_down (int)          state of the mouse buttons

//                              x, y (int)          current cursor position

//          Returns:          (int)                    0 if error

//

//          This is called each time the cursor is inside your menu and the cursor

//          has moved.

//

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

extern "C" __declspec(dllexport) int          Ctrl_Motion( HWND wnd, int up_down, short x, short y )

{

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

          // The mouse has moved.  By calling "select" we

          // insure that the box will get the "select" color

          // if the cursor is over it.

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

 

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

          // ---              DB_Class List Tool                              ---

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

          if ( box_db.Select( up_down ) ) {

              return( tool_db.Motion( up_down ) ) ;

          }

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

 

          return( 0 ) ;

}

 

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

//

//          Function:          Ctrl_Scroll

//

//          Parameters:          count (int)          number of mouse wheel cliks

//          Returns:          (int)                    0 if error

//

//          This is called each time the cursor is inside your menu and the mouse

//          wheel has been activated.

//

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

extern "C" __declspec(dllexport) int          Ctrl_Scroll( HWND wnd, int count, short x, short y )

{

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

          // ---              DB_Class List Tool                              ---

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

          if ( box_db.Select( KEY_QUERY ) ) {

              return( tool_db.Scroll( count ) ) ;

          }

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

 

          return( 0 ) ;

}

 

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

//

//          Function:          Ctrl_Update

//

//          Parameters:          (void)

//          Returns:          (int)                    0 if error

//

//          This is called each time something has been modified from another

//          control and sliceO Beleive it may affect you.

//

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

int          Ctrl_Update( UInt64 flag )

{

          if ( ! Flag_Ctrl_Wnd_On )

              return( 1 ) ;

 

          // --- We changed the database ---

          if ( flag & (UPDATE_FILE) ) {

              tool_db.Update( flag ) ;

          }

 

          if ( flag & (UPDATE_SELECTION) ) {

              tool_db.Update( flag ) ;

          }

 

          return( 1 ) ;

}

 

...