Previous Next Up Title Contents Index Functions Index Top Library

9
Structure Visibility
and Detectability


VISIBILITY

Most interactive graphic applications need, along execution time, to made visible or invisible some structures or some primitives in structures. There are several solutions to manage visibility. Three simple methods are discussed below:

Managing visibility by changing structure identifier :

Let us consider a scene S made up of n structure of identifiers S0 to Sn-1. In order to made invisible structure Si (0<=i<=n-1) it suffices to change its identifier by a value different to S, S0...Sn-1. Simply choose a positive value for S, S0...Sn-1 and rename Si by -Si : during redraw, the traversal process find the pexec_struct(Si) in the scene. Si does not exist, so it is not visible. To change structure identifier, just call the pchange_struct_id PHIGS function. So 2 calls are enough to change visibility of structure Si.:

pchange_struct_id (Si,-Si); Si = -Si;

predraw_all_structs (ws_id, ...);

Note that if the scene has to be rebuilt, it must always refer to the positive value of Si.

Managing visibility by changing scene content :

In order to made invisible structure Si (0<=i<=n-1) it is also possible to remove it from the scene, for example by changing the i-th integer value of its structure identifier list. Simply choose a positive value for S, S0...Sn-1 and changing Si by -Si as the i-th integer value of the scene structure identifier list. Note that structure whose identifier is -Si must not exit. So 2 calls are enough to change visibility of structure Si.:

struct_id_list.ints[i] *= -1;

tscene (S, &struct_id_list, view_ind);

predraw_all_structs (ws_id, ...);

Managing visibility by name-set and invisibility filter :

The concept of Name Set allows managing visibility of structure on a given workstation, in opposite to the 2 last methods which manage visibility for every opened workstations. The filter is defined according to a
workstation : a structure can be visible on one workstation and invisible on another. This method also allows visibility managing of certain primitives in a structure without any CSS modification.

In order to manage visibility by filter, the structures must contain a name set element (inserted by padd_name_set PHIGS function). To fully grasp the notion of the Name Set and the associated filters, refer to the "Name Set" paragraphs in the GPHIGS manuals.

However, PHIGURE simplifies the use of Name Sets, on one hand with the tadd_names_set and tremove_names_set functions, which insert respectively an add name to set element and a remove name to set element after given label in a structure, and on the other hand with the function tstruct_create_flags, which is used to control insertion of an add name to set element of value STRID to any structure whose identifier is STRID and which was opened by PHIGURE.

If the second parameter of the function tstruct_create_flags is TINSERT_NAME_SET, then the visibility of structures created by PHIGURE is handled as described in the following example :

This method needs a list of N integers, equal to respectively ±S1, ±S2, ±S3,... ±SN. This list must be used as an input parameter of the PHIGS function pset_invis_filter (set invisibility filter) as the invisibility filter inclusion set (this list will henceforth be called the inclusion set). When redrawing, if the i th element of the inclusion set is equal to +Si, then the structure Si will be invisible ; otherwise it will be visible. To change the visibility of the Si structure interactively, just change the sign of the i th element of the list as an input parameter to the function pset_invis_filter (that is, of course, if the Si identifer is not zero).

This method is workstation dependant but is more CPU intensive during "redraw all structures".

Example : creation of a scene of 5 structures whose identifiers are respectively 1,2,3,4, and 5, with structure 3 and 5 invisible on the workstation whose identifier is wkid.

static Pint id_list={1,2,3,4,5};

static Pint_list struct_id_list={5,id_list};

static Pint invis_structs={-1,-2,3,-4,5};

Pfilter invis_filter;

tscene (scene, &struct_list, view_ind);

invis_filter.incl_set.num_ints = 5;

invis_filter.incl_set.ints = invis_structs;

pset_invis_filter (wkid, &invis_filter);

predraw_all_structs (wkid,PFLAG_ALWAYS);

After the execution of these lines, structure 3 and 5 are invisible. In order to change the visibility of the i-th structure of the scene, just call :

invis_struct[i] *= -1;

pset_invis_filter (wkid, &invis_filter);

predraw_all_structs (wkid,PFLAG_ALWAYS);

DETECTABILITY

The detectability of the structures is controlled in the same way by calling the function pset_pick_filter (set pick filter) instead of the function pset_invis_filter. However, when redrawing, if the i-th element of the inclusion set is equal to +Si, then the structure Si will be detectable ; otherwise, it will be undetectable. Therefore, for the preceding example, structures 3 and 5 are detectable and structures 1, 2 and 4 are undetectable.

The PHIGS functions pset_invis_filter and pset_pick_filter, and PHIGURE functions tadd_names_set and tremove_names_set, are described later.


Previous Next Up Title Contents Index Functions Index Top Library