next up previous contents index
Next: Interface to the Up: Implementation of the Previous: Graphic

Selection Mechanism

   

All functions and global variables dealing with the selection mechanism have the prefix ui_sel_. All selected units are held in a linear linked list starting at the pointer ui_sel_listPtr. It is set to point to an element on initialization. The number of selected units is stored in the globale variable ui_sel_numberOfSelectedItems. The total number of allocated items is kept in ui_sel_numberOfItems. This list is always increasing, i.e. memory is not freed by dispose(), but all unused elements are kept in the list, marked as such (Bit 0 in the component flags), and are used again when needed. New elements are attached at the beginning of the list.

typedef struct SelectionType {
    struct SelectionType     *nextPtr;
    struct PosType           gridPos;  
    int                      subNetNo;
    int                      unitNo;   
    int                      copyNo;   
    int                      flags;
};

For an unambiguous identification of the units, their subnet number is stored in addition to their grid position. This is necessary, since units in different subnets may have the same grid positions. On processing the action Units Copy Structure the unit number is saved, in order to keep track of the units during the copying process. After completion of the action, the component is superfluous. Table gif gives the meaning of the bits in the component flags.

  
Table: Meaning of the Bits in the flag item of each list element for the selection.

When several windows are used, units can be selected in multiple windows. The case of one unit being displayed in more than one window has to be observed. SNNS-XGUI therefore allows selection only of units belonging to an active layer, and at least one window with the same subnet number must be open. If a unit is selected in one window, the selection mark becomes visible in all displays.

When a unit is marked selected, a cross is drawn over the unit. It has to be assured that prior to drawing or deleting, all marks are reset, and get updated afterwards with the function ui_sel_reshowItems. All editor functions dealing with moving or deleting units ( prefix "` ui_action_"'), have to assure consistency of the selection list. This can be done by changing the flag, since these functions anyway have access to this element, when they process the selected unit.



next up previous contents index
Next: Interface to the Up: Implementation of the Previous: Graphic



Niels Mache
Wed May 17 11:23:58 MET DST 1995