scribble/inc/ink.h File Reference

#include <gtk/gtk.h>

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _Ink
struct  _Stroke
struct  _InkPoint

Typedefs

typedef struct _InkPtrInk
typedef struct _StrokePtrStroke
typedef struct _InkPointPtrInkPoint
typedef struct _Ink Ink
typedef struct _Stroke Stroke
typedef struct _InkPoint InkPoint

Functions

PtrInk construct_ink ()
void destroy_ink (PtrInk ink)
PtrStroke construct_stroke ()
PtrStroke destroy_stroke (PtrStroke stroke)
PtrInkPoint construct_point ()
PtrInkPoint destroy_point (PtrInkPoint point)
unsigned char ink_add_stroke (PtrInk ink, PtrStroke stroke)
int get_num_of_strokes (PtrInk ink)
unsigned char ink_add_point (PtrStroke stroke, PtrInkPoint point)
int get_num_of_points (PtrStroke stroke)


Typedef Documentation

typedef struct _Ink Ink

typedef struct _InkPoint InkPoint

typedef struct _Ink* PtrInk

Copyright (C) 2005-2008 iRex Technologies B.V. All rights reserved.

Definition at line 33 of file ink.h.

typedef struct _InkPoint* PtrInkPoint

Definition at line 35 of file ink.h.

typedef struct _Stroke* PtrStroke

Definition at line 34 of file ink.h.

typedef struct _Stroke Stroke


Function Documentation

PtrInk construct_ink (  ) 

Copyright (C) 2005-2008 iRex Technologies B.V. All rights reserved.

Definition at line 43 of file ink.c.

00044 {
00045     PtrInk ink = NULL;
00046 
00047     ink = malloc (sizeof (Ink));
00048     if (ink)
00049         memset (ink, 0, sizeof (Ink));
00050   
00051     SB_INKPRINTF("return %p \n", ink);
00052     return ink;
00053 }

PtrInkPoint construct_point (  ) 

Definition at line 103 of file ink.c.

00104 {
00105     PtrInkPoint point = NULL;
00106 
00107     point = malloc (sizeof (InkPoint));
00108     if (point)
00109         memset (point, 0, sizeof (InkPoint));
00110 
00111     SB_INKPRINTF("return %p \n", point);
00112     return point;
00113 }

PtrStroke construct_stroke (  ) 

Definition at line 70 of file ink.c.

00071 {
00072     PtrStroke stroke = NULL;
00073 
00074     stroke = malloc (sizeof (Stroke));
00075     if (stroke)
00076         memset (stroke, 0, sizeof (Stroke));
00077 
00078   //init range
00079     stroke->min_x = stroke->min_y = INT_MAX;
00080     stroke->max_x = stroke->max_y = INT_MIN;
00081     SB_INKPRINTF("initial construct %p \n", stroke);
00082     return stroke;
00083 }

void destroy_ink ( PtrInk  ink  ) 

Definition at line 56 of file ink.c.

00057 {
00058     PtrStroke stroke = NULL;
00059     if (ink == NULL)
00060         return;
00061     stroke = ink->firstStroke;
00062     while (stroke)
00063         stroke = destroy_stroke (stroke);
00064 
00065     SB_INKPRINTF("return (%p)\n", ink);
00066     free (ink);
00067 }

Here is the call graph for this function:

PtrInkPoint destroy_point ( PtrInkPoint  point  ) 

Definition at line 116 of file ink.c.

00117 {
00118     PtrInkPoint nextPoint = NULL;
00119     if (point == NULL)
00120         return NULL;
00121     nextPoint = point->nextPoint;
00122 
00123     SB_INKPRINTF("return %p \n", point);
00124     free (point);
00125     return nextPoint;
00126 }

PtrStroke destroy_stroke ( PtrStroke  stroke  ) 

Definition at line 86 of file ink.c.

00087 {
00088     PtrInkPoint point = NULL;
00089     PtrStroke nextStroke = NULL;
00090     if (stroke == NULL)
00091         return NULL;
00092     nextStroke = stroke->nextStroke;
00093     point = stroke->firstPoint;
00094     while (point)
00095         point = destroy_point (point);
00096 
00097     SB_INKPRINTF("return(%p)\n", stroke);
00098     free (stroke);
00099     return nextStroke;
00100 }

Here is the call graph for this function:

int get_num_of_points ( PtrStroke  stroke  ) 

Definition at line 189 of file ink.c.

00190 {
00191     if (stroke == NULL)
00192         return 0;
00193     return stroke->nPoints;
00194 }

int get_num_of_strokes ( PtrInk  ink  ) 

Definition at line 152 of file ink.c.

00153 {
00154     if (ink == NULL)
00155         return 0;
00156     return ink->nStrokes;
00157 }

unsigned char ink_add_point ( PtrStroke  stroke,
PtrInkPoint  point 
)

Definition at line 161 of file ink.c.

00162 {
00163     if (stroke == NULL || point == NULL)
00164     {
00165         SB_INKERRPRINTF("failed:incorrect arguments\n");
00166         return 0;
00167     }
00168 
00169     if (stroke->lastPoint == NULL)
00170     {
00171         stroke->lastPoint=stroke->firstPoint = point;
00172         stroke->nPoints = 1;
00173     }
00174     else
00175     {
00176         stroke->lastPoint=stroke->lastPoint->nextPoint = point;
00177         stroke->nPoints += 1;
00178     }
00179 
00180     //recompute the range, if saved, maybe duplicated when load from file!!
00181     if( point->x < stroke->min_x) stroke->min_x=point->x;
00182     if( point->x > stroke->max_x) stroke->max_x=point->x;
00183     if( point->y < stroke->min_y) stroke->min_y=point->y;
00184     if( point->y > stroke->max_y) stroke->max_y=point->y;
00185 
00186     return 1;
00187 }

unsigned char ink_add_stroke ( PtrInk  ink,
PtrStroke  stroke 
)

Definition at line 130 of file ink.c.

00131 {
00132     if (ink == NULL || stroke == NULL)
00133     {
00134         SB_INKERRPRINTF("failed:incorrect arguments\n");
00135         return 0;
00136     }
00137 
00138     if (ink->lastStroke == NULL)
00139     {
00140         ink->firstStroke = ink->lastStroke= stroke;
00141         ink->nStrokes = 1;
00142     }
00143     else
00144     {
00145         ink->lastStroke=ink->lastStroke->nextStroke = stroke;
00146         ink->nStrokes += 1;
00147     }
00148     return 1;
00149 }


Generated on Sun Dec 14 17:14:26 2008 by  doxygen 1.5.6