#include <glib.h>
#include "scbpoint.h"
Go to the source code of this file.
Data Structures | |
struct | _ScbPoints |
Typedefs | |
typedef G_BEGIN_DECLS struct _ScbPoints | ScbPoints |
typedef ScbPoints * | ScbPointsPtr |
Functions | |
gboolean | erscribble_points_new (ScbPointsPtr points, const int initSize) |
void | erscribble_points_free (ScbPointsPtr points) |
void | erscribble_points_append (ScbPointsPtr points, ScbDevPointPtr point) |
int | erscribble_points_get_count (ScbPointsPtr ptr) |
ScbPointPtr | erscribble_points_get_data (ScbPointsPtr points) |
void | erscribble_points_dump (ScbPointsPtr points) |
typedef G_BEGIN_DECLS struct _ScbPoints ScbPoints |
Copyright (C) 2008 iRex Technologies B.V. All rights reserved.
typedef ScbPoints* ScbPointsPtr |
Definition at line 71 of file scbpoints.h.
void erscribble_points_append | ( | ScbPointsPtr | points, | |
ScbDevPointPtr | point | |||
) |
Definition at line 106 of file scbpoints.c.
References ERSCRIBBLE_RET_IF.
Referenced by erscribble_stroke_add_point().
00107 { 00108 ERSCRIBBLE_RET_IF(NULL == points || NULL == point, "Invalid pointer(s)!"); 00109 00110 // by value. they are binary compatible 00111 g_array_append_val(points->points, *((ScbPointPtr)point)); 00112 g_array_append_val(points->pressures, point->pressure); 00113 }
void erscribble_points_dump | ( | ScbPointsPtr | points | ) |
Definition at line 133 of file scbpoints.c.
References DUMPPRINTF, erscribble_points_get_count(), erscribble_points_get_data(), ERSCRIBBLE_RET_IF, _ScbPoint::x, and _ScbPoint::y.
00134 { 00135 ScbPointPtr point = erscribble_points_get_data(ptr); 00136 ERSCRIBBLE_RET_IF(NULL == point, ""); 00137 00138 int len = erscribble_points_get_count(ptr); 00139 DUMPPRINTF("points count %d. data:", len); 00140 while (len > 0) 00141 { 00142 DUMPPRINTF("(%d, %d)", point->x, point->y); 00143 ++point; --len; 00144 } 00145 }
void erscribble_points_free | ( | ScbPointsPtr | points | ) |
Definition at line 88 of file scbpoints.c.
References ERSCRIBBLE_RET_IF.
Referenced by erscribble_stroke_free().
00089 { 00090 ERSCRIBBLE_RET_IF(NULL == ptr, "Try to release NULL pointer!"); 00091 00092 if (ptr->points != NULL) 00093 { 00094 g_array_free(ptr->points, TRUE); 00095 ptr->points = NULL; 00096 } 00097 00098 if (ptr->pressures != NULL) 00099 { 00100 g_array_free(ptr->pressures, TRUE); 00101 ptr->pressures = NULL; 00102 } 00103 }
int erscribble_points_get_count | ( | ScbPointsPtr | ptr | ) |
Definition at line 116 of file scbpoints.c.
References ERSCRIBBLE_INVALID_COUNT, and ERSCRIBBLE_RET_INT_IF.
Referenced by erscribble_points_dump().
00117 { 00118 ERSCRIBBLE_RET_INT_IF(NULL == ptr, ERSCRIBBLE_INVALID_COUNT, "Attempt to access NULL pointer!"); 00119 ERSCRIBBLE_RET_INT_IF(NULL == ptr->points, ERSCRIBBLE_INVALID_COUNT, "Point array is not allocated!"); 00120 00121 // lengths are equal 00122 return ptr->points->len; 00123 }
ScbPointPtr erscribble_points_get_data | ( | ScbPointsPtr | points | ) |
Definition at line 126 of file scbpoints.c.
References ERSCRIBBLE_RET_NULL_IF.
Referenced by erscribble_points_dump(), and erscribble_stroke_get_point_data().
00127 { 00128 ERSCRIBBLE_RET_NULL_IF(NULL == ptr || NULL == ptr->points, "NULL pointer(s)"); 00129 return (ScbPointPtr)ptr->points->data; 00130 }
gboolean erscribble_points_new | ( | ScbPointsPtr | points, | |
const int | initSize | |||
) |
Definition at line 69 of file scbpoints.c.
References ERSCRIBBLE_RET_FALSE_IF.
Referenced by erscribble_stroke_new(), and erscribble_stroke_new_with_attributes().
00070 { 00071 ERSCRIBBLE_RET_FALSE_IF(NULL == ptr, "Invalid pointer!"); 00072 ERSCRIBBLE_RET_FALSE_IF(initSize <= 0, "Invalid initial size!"); 00073 00074 ptr->points = g_array_sized_new(FALSE, TRUE, sizeof(ScbPoint), initSize); 00075 00076 ERSCRIBBLE_RET_FALSE_IF(NULL == ptr->points, "Could not allocate enough memory!"); 00077 ptr->pressures = g_array_sized_new(FALSE, TRUE, sizeof(int), initSize); 00078 00079 if (NULL == ptr->pressures) 00080 { 00081 g_free(ptr->points); ptr->points = NULL; 00082 return FALSE; 00083 } 00084 return TRUE; 00085 }