Ctrl_Register

 

The "Ctrl_Register()" function is called when sliceOmatic create its interface windows. 

 

If you want your module to have a user interface, you need to have this function present.

 

 

Syntax

 

extern "C" __declspec(dllexport) int          Ctrl_Register(

          unsigned short *mode

)

 

 

Parameters

 

mode

The function has 1 argument, a pointer to an unsigned short.  This argument is only used if your module is a Tool. If it is, you use this pointer to specify the different modes for which your tool is available.  For example, the "3D matrix" tool is only available for 3D modes, while the "snapshot" tool is available in all modes.  The different modes are defined in the file "db_define.hpp" and are:

SLICEO_TOOL_CLASS, SLICEO_TOOL_SLICEO_2D, SLICEO_TOOL_TAG_2D, SLICEO_TOOL_USER_2D, SLICEO_TOOL_SLICEO_3D, SLICEO_TOOL_USER_3D

We also have:

SLICEO_TOOL_2D = (SLICEO_TOOL_CLASS|SLICEO_TOOL_SLICEO_2D|SLICEO_TOOL_TAG_2D|SLICEO_TOOL_USER_2D)

SLICEO_TOOL_3D = (SLICEO_TOOL_SLICEO_3D|SLICEO_TOOL_USER_3D)

 

 

Return value

 

The function returns the vertical size (in pixels) you need for your interface.

 

 

Remarks

 

This function is only optional if you do not have a control window.

 

 

Requirements

 

Header:

          sliceO_include.hpp

 

Library:

          sliceO_Structures.lib

 

 

Example

 

Example 1: This is the Ctrl_Register() function for the "Edit mode" module. 

 

You will notice that the vertical size of the interface is function of the size of the different tools in the interface.  since the user can change the general size of the tools with the configuration menu, we call the variable containing these values to compute the actual interface's size.

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

//

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

//

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

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

{

short          Button_Dim_Sml = (short) Fct_Variable_Value( "$INTERFACE_BUTTON_DIM_SML" ) ;

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

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

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

 

          short height = Title_Dim          // title at top of tool

                    + tool_brush.Height()          // brush selection

                    + Space_Dim

                    + tool_tag.Height(4)          // tag selection tool (4 buttons high)

                    + Space_Dim

                    + 3*Button_Dim_Sml + 2          // Open/Erosion/Load...

                    + Space_Dim ;

 

          return( height ) ;

}

 

 

Example 2: This is the Ctrl_Register() function for the "3D Smoothing tool" module. 

 

Since this is a tool, we must use the "mode" argument to specify that this tool is only available in 3D modes.

 

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

//

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

//

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

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

{

          // --- this is a 3D tool only ---

          if ( mode )

              (*mode) = SLICEO_TOOL_3D ;

 

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

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

short          Button_Dim_Sml = (short) Fct_Variable_Value( "$INTERFACE_BUTTON_DIM_SML" ) ;  // BUT_DIM - SPACE

 

          short height = Title_Dim + 2          // title at top of tool

                    + Button_Dim_Sml          // smooth buttons

                    + Space_Dim ;

 

          return( height ) ;

}

 

 

See also

 

Script_Parse