Iterate among the classes of the DB tree.
Syntax
SliceO_Class * Iterator_Class(
char iter_id,
unsigned int class_id,
void * window=NULL,
unsigned char flag=0
) ;
Parameters
iter_id
Index of the iterator you want to use. There can only be one iterator open at the same time for each index. There are MAX_ITERATOR_ID id, but only ITERATOR_USER_1 and ITERATOR_USER_2 should be used in user functions.
class_id
Id of the class you want to get. You can limit the search to a specific class ID (ex frames only) or be general and return all classes.
Ex, iterating among frames only:
SliceO_Frame *frame = (SliceO_Frame *) Iterator_Class( ITERATOR_USER_1, CLASS_ID_FRAME )
window
Pointer to a window if you want to limit your iterations to the classes that have an attribute specific to one window. For example, if you want only the classes that are visible, you may want to limit the search to a specific window. By default, window = NULL and all windows are used.
flag
Condition for looking only at specific classes.
The accepted values are:
|
|
ITER_FLAG_VISIBLE
|
Only classes that are visible in the specified windows are returned
|
|
|
ITER_FLAG_SELECT
|
Only the classes that are selected in the specified windows are returned
|
|
|
ITER_FLAG_CURRENT
|
Only the current classes are returned
|
|
|
ITER_FLAG_COLOR
|
Only color (RGB) frames are returned
|
Return value
This function return a pointer to a class.
Remarks
Requirements
Header:
sliceO_include.hpp
Library:
sliceO_Structures.lib
Example
Iterate among all the frames in the DB tree
|
if ( Iterator_Init( ITERATOR_USER_1, "Demo Iterator" ) ) {
while ( SliceO_Frame *frame = (SliceO_Frame *) Iterator_Class( ITERATOR_USER_1, CLASS_ID_FRAME ) ) {
...
}
Iterator_End( ITERATOR_USER_1 ) ;
}
|
|
Searching all the frames of the currently selected parent
|
...
// --- I need a pointer to the current window ---
SliceO_Window *Window_Cur = (SliceO_Window *) Fct_Variable_Value( "$WINDOW_CUR" ) ;
int group_id=0, count=0, z=0 ;
// --- First locate the "group" (one level higher than the frames ---
if ( ! Iterator_Init( ITERATOR_USER_2, "Fct_Contour_Compute" ) )
return( 0 ) ;
while( SliceO_Frame *frame = (SliceO_Frame *) Iterator_Class( ITERATOR_USER_2, CLASS_ID_FRAME, Window_Cur, ITER_FLAG_SELECT ) ) {
group_id = frame->Parent_Get_Pt()->Class_Id_Get() ;
break ;
}
Iterator_End( ITERATOR_USER_2 ) ;
// --- if no group selected, get out ---
if ( ! group_id )
return( 1 ) ;
// --- Now we loop for all the selected "groups" ---
if ( ! Iterator_Init( ITERATOR_USER_2, "Fct_Contour_Compute" ) )
return( 0 ) ;
while( SliceO_Class *group = Iterator_Class( ITERATOR_USER_2, group_id, Window_Cur, ITER_FLAG_SELECT ) ) {
...
}
Iterator_End( ITERATOR_USER_2 ) ;
...
|
|
See also
Iterator_Init
Iterator_End