Geocanvas Reference Manual |
---|
geo-clipgeo-clip — A simple poly-shape to rectangle pipeline clipper. |
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);
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.
typedef struct { GeoPipeline left, top, right, bot; gboolean open; GArray *array; } GeoClip;
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. |
void geo_clip_free (GeoClip *clip);
Use this to free the filled GeoClip structure.
clip : |
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. |
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 : |
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. |
<< geo-utilities |