geo-clip

geo-clip — A simple poly-shape to rectangle pipeline clipper.

Synopsis




            GeoClip;
#define     GEO_TYPE_CLIP
GType       geo_clip_get_type               (void);
            GeoPipeline;
#define     GEO_TYPE_PIPELINE
GType       geo_pipeline_get_type           (void);
GeoClip*    geo_clip_new                    (gboolean open,
                                             double x1,
                                             double y1,
                                             double x2,
                                             double y2);
void        geo_clip_free                   (GeoClip *clip);
void        geo_clip_add_point              (GeoClip *clip,
                                             double x,
                                             double y);
void        geo_clip_finish                 (GeoClip *clip);
FooCanvasPoints* geo_clip_to_points         (GeoClip *clip);

Description

This function is used to work-around compatibility issues between the FooCanvas and the underlying GDK drawing mechanism. The FooCanvas uses canvas coordinates expressed as a 32 bit integer. GDK uses 16 bit short coordinates. If a shape is managed by the canvas for a particular scale that converts to be larger in canvas coordinate width or height than MAX_SHORT, strange expose event handling and point tests will result.

A short term solution to this problem is to clip to some rectangle that is smaller than MAX_SHORT in canvas coordinates. Presently the GeoCanvasLines and GeoCanvasShapes objects use this clipping algorithm in collaboration with the GeoCanvas extents-level property in order to determine when to clip.

Details

GeoClip

typedef struct {
        GeoPipeline left, top, right, bot;
        gboolean open;
        GArray *array;
} GeoClip;


GEO_TYPE_CLIP

#define GEO_TYPE_CLIP (geo_clip_get_type())


geo_clip_get_type ()

GType       geo_clip_get_type               (void);

Returns :

GeoPipeline

typedef struct {
        double value, px, py, fx, fy;
        int edge, stage;
} GeoPipeline;


GEO_TYPE_PIPELINE

#define GEO_TYPE_PIPELINE (geo_pipeline_get_type())


geo_pipeline_get_type ()

GType       geo_pipeline_get_type           (void);

Returns :

geo_clip_new ()

GeoClip*    geo_clip_new                    (gboolean open,
                                             double x1,
                                             double y1,
                                             double x2,
                                             double y2);

Initializes a structure to be used for pipeline clipping of a polyline or polygon to a rectangle.

open : If this is an open or closed shape.
x1 : The leftmost coordinate of the clipping rectangle.
y1 : The topmost coordinate of the clipping rectangle.
x2 : The rightmost coordinate of the clipping rectangle.
y2 : The bottommost coordinate of the clipping rectangle.
Returns : A new GeoClip structure to be used for point clipping.

geo_clip_free ()

void        geo_clip_free                   (GeoClip *clip);

Use this to free the filled GeoClip structure.

clip :

geo_clip_add_point ()

void        geo_clip_add_point              (GeoClip *clip,
                                             double x,
                                             double y);

Add an additional point to the shape to be clipped. Call this routine until all points are added.

clip :
x : The x-coordinate of the next point in the shape.
y : The y-coordinate of the next point in the shape.

geo_clip_finish ()

void        geo_clip_finish                 (GeoClip *clip);

Tells the clipping algorithm that we are at the end of the pipeline. That is, all points have been added.

clip :

geo_clip_to_points ()

FooCanvasPoints* geo_clip_to_points         (GeoClip *clip);

Allocates a new array of type FooCanvasPoints filled with the clipped shape from the GeoClip structure.

clip : clip data
Returns : A newly allocated array of FooCanvasPoints.