Next: , Up: State definitions



7.5.1.1 Snap result states

If the input kind is OFIK_DPR, then the value of struct dist_pass_result is expected to be filled. It contains the snap result (obtained by an mathgui0-Tree distance pass), which can be a hanger, an anchor, a GO with a parameter of the point position on the GO curve, an intersection represented by two GOs and a parameter, or an unsnapped point defined by its coordinates. The state's input type is the desired dist_pass_result.type determining which of the possibilities is the current one.

This is the structure definition:

     struct dist_pass_result
     {
         uns type;
         union
         {
             struct { struct go *go; struct geom_nearest geom; } go;
             struct { real dist; struct hanger *hanger; } hanger;
             struct { real dist; struct anchor *anchor; } anchor;
             struct { real dist; struct go *go1, *go2;
                       struct geom_intersection geom; } intersection;
             struct { real dist; struct geom_point point; } point;
         } data;
     };

During the step-by-step creation, the input hangers are specified. But they may not yet exist. For example, if the “snap to lines” mode is set on, then a hanger can be specified by a curve GO and a parameter defining a point position on the curve. The hanger itself is created no sooner than it is really needed, which is when an anchor of the created GO needs to be hung on it (during the execution of the state's action function). In the meantime, the GO Factory stores the snap result only; and if the effects of the action function are undone (because of Step back or transaction fail) the hanger is destroyed as well.

This also means that, apart from the “main” created GO, the GO Factory can create some parametric points, intersection points, or mouse-clicks as well.