diff options
author | Manusheel <manusheel@localhost.localdomain> | 2007-07-24 15:10:45 (GMT) |
---|---|---|
committer | Manusheel <manusheel@localhost.localdomain> | 2007-07-24 15:10:45 (GMT) |
commit | 90bf7269de06b9b1398de7eb387d52cffda72694 (patch) | |
tree | 77ea1758d6ca176d3c4c97275efdb9a4539c2e59 /fill_src | |
parent | 9c0b7121410f4d013d2cc67e5b7490c593abdb74 (diff) |
Bugs fixed, new functions added, existing functions changed
Diffstat (limited to 'fill_src')
-rw-r--r-- | fill_src/.svn/all-wcprops | 47 | ||||
-rw-r--r-- | fill_src/.svn/entries | 112 | ||||
-rw-r--r-- | fill_src/.svn/format | 1 | ||||
-rw-r--r-- | fill_src/.svn/text-base/Makefile.svn-base | 55 | ||||
-rw-r--r-- | fill_src/.svn/text-base/eggfill.c.svn-base | 193 | ||||
-rw-r--r-- | fill_src/.svn/text-base/eggfill.h.svn-base | 63 | ||||
-rw-r--r-- | fill_src/.svn/text-base/fill.c.svn-base | 79 | ||||
-rw-r--r-- | fill_src/.svn/text-base/fill.defs.svn-base | 22 | ||||
-rw-r--r-- | fill_src/.svn/text-base/fill.override.svn-base | 15 | ||||
-rw-r--r-- | fill_src/.svn/text-base/fillmodule.c.svn-base | 65 | ||||
-rw-r--r-- | fill_src/Makefile | 55 | ||||
-rw-r--r-- | fill_src/eggfill.c | 193 | ||||
-rw-r--r-- | fill_src/eggfill.h | 63 | ||||
-rw-r--r-- | fill_src/fill.c | 79 | ||||
-rw-r--r-- | fill_src/fill.defs | 22 | ||||
-rw-r--r-- | fill_src/fill.override | 15 | ||||
-rw-r--r-- | fill_src/fillmodule.c | 65 |
17 files changed, 1144 insertions, 0 deletions
diff --git a/fill_src/.svn/all-wcprops b/fill_src/.svn/all-wcprops new file mode 100644 index 0000000..b2713ff --- /dev/null +++ b/fill_src/.svn/all-wcprops @@ -0,0 +1,47 @@ +K 25 +svn:wc:ra_dav:version-url +V 31 +/svn/!svn/ver/73/trunk/fill_src +END +eggfill.h +K 25 +svn:wc:ra_dav:version-url +V 41 +/svn/!svn/ver/73/trunk/fill_src/eggfill.h +END +fill.override +K 25 +svn:wc:ra_dav:version-url +V 45 +/svn/!svn/ver/73/trunk/fill_src/fill.override +END +fill.defs +K 25 +svn:wc:ra_dav:version-url +V 41 +/svn/!svn/ver/73/trunk/fill_src/fill.defs +END +fill.c +K 25 +svn:wc:ra_dav:version-url +V 38 +/svn/!svn/ver/73/trunk/fill_src/fill.c +END +eggfill.c +K 25 +svn:wc:ra_dav:version-url +V 41 +/svn/!svn/ver/73/trunk/fill_src/eggfill.c +END +Makefile +K 25 +svn:wc:ra_dav:version-url +V 40 +/svn/!svn/ver/73/trunk/fill_src/Makefile +END +fillmodule.c +K 25 +svn:wc:ra_dav:version-url +V 44 +/svn/!svn/ver/73/trunk/fill_src/fillmodule.c +END diff --git a/fill_src/.svn/entries b/fill_src/.svn/entries new file mode 100644 index 0000000..c8a6985 --- /dev/null +++ b/fill_src/.svn/entries @@ -0,0 +1,112 @@ +8 + +dir +76 +https://oficina.googlecode.com/svn/trunk/fill_src +https://oficina.googlecode.com/svn + + + +2007-07-23T17:47:19.360150Z +73 +pekayatt + + +svn:special svn:externals svn:needs-lock + + + + + + + + + + + +e2fb0b9f-bc32-0410-ab74-19e9d00b4e58 + +eggfill.h +file + + + + +2007-07-23T19:49:36.000000Z +5caebde9b82e0aed2dfc7a9e78e7ba37 +2007-07-23T17:47:19.360150Z +73 +pekayatt + +fill.override +file + + + + +2007-07-23T19:49:36.000000Z +8a88924614be96f7743360b57972c735 +2007-07-23T17:47:19.360150Z +73 +pekayatt + +fill.defs +file + + + + +2007-07-23T19:49:36.000000Z +73392e9b1d2f00ff7560fafd2f63afe6 +2007-07-23T17:47:19.360150Z +73 +pekayatt + +fill.c +file + + + + +2007-07-23T19:49:36.000000Z +29e282d52adc6113fb9deade1c0874fe +2007-07-23T17:47:19.360150Z +73 +pekayatt + +eggfill.c +file + + + + +2007-07-23T19:49:36.000000Z +a97a14d9c934b42346748a925d532185 +2007-07-23T17:47:19.360150Z +73 +pekayatt + +Makefile +file + + + + +2007-07-23T19:49:36.000000Z +c09aa8e741fa2d9fb4aa477c6331c86d +2007-07-23T17:47:19.360150Z +73 +pekayatt + +fillmodule.c +file + + + + +2007-07-23T19:49:36.000000Z +882baa193e1332c948ba7b6972180ca6 +2007-07-23T17:47:19.360150Z +73 +pekayatt + diff --git a/fill_src/.svn/format b/fill_src/.svn/format new file mode 100644 index 0000000..45a4fb7 --- /dev/null +++ b/fill_src/.svn/format @@ -0,0 +1 @@ +8 diff --git a/fill_src/.svn/text-base/Makefile.svn-base b/fill_src/.svn/text-base/Makefile.svn-base new file mode 100644 index 0000000..dc1f3ec --- /dev/null +++ b/fill_src/.svn/text-base/Makefile.svn-base @@ -0,0 +1,55 @@ +#Copyright 2007, NATE-LSI-EPUSP + +#Oficina is developed in Brazil at Escola Politécnica of +#Universidade de São Paulo. NATE is part of LSI (Integrable +#Systems Laboratory) and stands for Learning, Work and Entertainment +#Research Group. Visit our web page: +#www.nate.lsi.usp.br +#Suggestions, bugs and doubts, please email oficina@lsi.usp.br + +#Oficina is free software; you can redistribute it and/or +#modify it under the terms of the GNU General Public License +#as published by the Free Software Foundation version 2 of +#the License. + +#Oficina is distributed in the hope that it will be useful, +#but WITHOUT ANY WARRANTY; without even the implied warranty of +#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +#General Public License for more details. + +#You should have received a copy of the GNU General Public +#License along with Oficina; if not, write to the +#Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, +#Boston, MA 02110-1301 USA. +#The copy of the GNU General Public License is found in the +#COPYING file included in the source distribution. + + +#Authors: + +#Joyce Alessandra Saul (joycealess@gmail.com) +#Andre Mossinato (andremossinato@gmail.com) +#Nathalia Sautchuk Patrício (nathalia.sautchuk@gmail.com) +#Pedro Kayatt (pekayatt@gmail.com) +#Rafael Barbolo Lopes (barbolo@gmail.com) +#Alexandre A. Gonçalves Martinazzo (alexandremartinazzo@gmail.com) + +CFLAGS = `pkg-config --cflags gtk+-2.0 pygtk-2.0` -I/usr/include/python2.5/ -I. -I/usr/include/pygtk-2.0/ +LDFLAGS = `pkg-config --libs gtk+-2.0 pygtk-2.0` + +fill.so: fill.o eggfill.o fillmodule.o + $(CC) $(LDFLAGS) -shared $^ -o $@ + +DEFS=`pkg-config --variable=defsdir pygtk-2.0` +# Generate the C wrapper +fill.c: fill.defs fill.override + pygtk-codegen-2.0 --prefix fill \ + --register $(DEFS)/gdk-types.defs \ + --register $(DEFS)/gdk-base.defs \ + --register $(DEFS)/gtk-types.defs \ + --override fill.override \ + fill.defs > $@ + +clean: + rm -f fill.so *.o fill.c *~ + diff --git a/fill_src/.svn/text-base/eggfill.c.svn-base b/fill_src/.svn/text-base/eggfill.c.svn-base new file mode 100644 index 0000000..5f1010a --- /dev/null +++ b/fill_src/.svn/text-base/eggfill.c.svn-base @@ -0,0 +1,193 @@ +/* +eggfill.c + +Fill function and queue list + + +Copyright 2007, NATE-LSI-EPUSP + +Oficina is developed in Brazil at Escola Politécnica of +Universidade de São Paulo. NATE is part of LSI (Integrable +Systems Laboratory) and stands for Learning, Work and Entertainment +Research Group. Visit our web page: +www.nate.lsi.usp.br +Suggestions, bugs and doubts, please email oficina@lsi.usp.br + +Oficina is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation version 2 of +the License. + +Oficina is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public +License along with Oficina; if not, write to the +Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, +Boston, MA 02110-1301 USA. +The copy of the GNU General Public License is found in the +COPYING file included in the source distribution. + + +Authors: + +Joyce Alessandra Saul (joycealess@gmail.com) +Andre Mossinato (andremossinato@gmail.com) +Nathalia Sautchuk Patrício (nathalia.sautchuk@gmail.com) +Pedro Kayatt (pekayatt@gmail.com) +Rafael Barbolo Lopes (barbolo@gmail.com) +Alexandre A. Gonçalves Martinazzo (alexandremartinazzo@gmail.com) + +*/
+#include <gtk/gtk.h>
+#include "eggfill.h"
+ +/*for queue*/
+#define front(Q) ( (Q)->Front )
+#define rear(Q) ( (Q)->Rear )
+
+struct Node {
+ ElementType Element;
+ PtrToNode Next;
+ };
+
+struct QueueL{
+ PtrToNode Front;
+ PtrToNode Rear;
+ } ;
+
+/* this queue has a Header that points to the Front and Rear elements */
+/* empty queue: Q->Front = NULL and Q->Rear = NULL */
+
+/* check if queue Q is empty */
+int IsEmpty( Queue Q ){
+ return ((front(Q)==NULL) && (rear(Q)==NULL));
+}
+
+Queue CreateQueue( void ){
+ Queue Q;
+ Q = malloc ( sizeof (struct Node));
+
+ /* check if there is enough space */
+ if( Q == NULL )
+ printf( "Out of space!!!" );
+
+ front(Q) = NULL;
+ rear(Q) = NULL;
+
+ return Q;
+}
+
+void DisposeQueue( Queue Q ){
+ MakeEmpty(Q);
+ free(Q);
+}
+
+void MakeEmpty( Queue Q ){
+ if( Q == NULL )
+ printf( "Must use CreateQueue first" );
+ else
+ while( !IsEmpty( Q ) )
+ Dequeue( Q );
+}
+
+
+void Enqueue( ElementType X, Queue Q ){
+ PtrToNode TmpCell;
+ TmpCell = malloc( sizeof( struct Node ) );
+ if( TmpCell == NULL )
+ printf( "Out of space!!!" );
+ else {
+ TmpCell->Element = X;
+ TmpCell->Next = NULL;//rear(Q);
+ if (IsEmpty(Q)){
+ //printf("The Queue is empty\n");
+ front(Q)=TmpCell;
+ } else rear(Q)->Next = TmpCell;
+ rear(Q) = TmpCell;
+ }
+}
+
+
+//Mostra o Elemento e 1o da Fila
+ElementType Front( Queue Q ){
+ if (IsEmpty(Q)){
+ printf( "Empty queue" );
+ return 0; /* Return value used to avoid warning */
+ } else {
+ return front(Q)->Element;
+ }
+}
+
+void Dequeue( Queue Q ){
+ PtrToNode tmpCell;
+ tmpCell = malloc( sizeof( struct Node ) );
+ if( IsEmpty( Q ) )
+ printf( "Empty queue" );
+ else {
+ tmpCell=front(Q);
+ front(Q)=front(Q)->Next;
+ if (front(Q)==NULL)
+ rear(Q)=NULL;
+ free(tmpCell);
+ }
+}
/* end of queue*/ +
+void fill(GdkDrawable *drawable, GdkGC *gc, int x, int y, int width, int height, int color){
+
+ int color_start;
+
+ Queue lista_xy; +
+ lista_xy = CreateQueue();
+
+ GdkImage *image;
+ image = gdk_drawable_get_image(drawable,0,0,width,height);
+
+ color_start = gdk_image_get_pixel(image, x, y);
+
+ if (color!=color_start) {
+ Enqueue(x, lista_xy);
+ Enqueue(y, lista_xy);
+ gdk_image_put_pixel(image, x, y, color);
+ while (!IsEmpty(lista_xy)) {
+ if (x+1 < width){
+ if (gdk_image_get_pixel(image, x+1, y) == color_start){
+ gdk_image_put_pixel(image, x+1, y, color);
+ Enqueue(x+1, lista_xy);
+ Enqueue(y, lista_xy);
+ }
+ }
+ if (x-1 >= 0){
+ if (gdk_image_get_pixel(image, x-1, y) == color_start){
+ gdk_image_put_pixel(image, x-1, y, color);
+ Enqueue(x-1, lista_xy);
+ Enqueue(y, lista_xy);
+ }
+ }
+ if (y+1 < height){
+ if (gdk_image_get_pixel(image, x, y+1) == color_start){ + gdk_image_put_pixel(image, x, y+1, color);
+ Enqueue(x, lista_xy);
+ Enqueue(y+1, lista_xy);
+ }
+ }
+ if (y-1 >= 0){
+ if (gdk_image_get_pixel(image, x, y-1) == color_start){ + gdk_image_put_pixel(image, x, y-1, color);
+ Enqueue(x, lista_xy);
+ Enqueue(y-1, lista_xy);
+ }
+ }
+ x = Front(lista_xy);
+ Dequeue(lista_xy);
+ y = Front(lista_xy);
+ Dequeue(lista_xy);
+ }
+ }
+
+ gdk_draw_image(drawable, gc, image, 0,0,0,0,width,height);
+
+}
diff --git a/fill_src/.svn/text-base/eggfill.h.svn-base b/fill_src/.svn/text-base/eggfill.h.svn-base new file mode 100644 index 0000000..2d1d90a --- /dev/null +++ b/fill_src/.svn/text-base/eggfill.h.svn-base @@ -0,0 +1,63 @@ +/* +eggfill.h + +Fill function and queue list + + +Copyright 2007, NATE-LSI-EPUSP + +Oficina is developed in Brazil at Escola Politécnica of +Universidade de São Paulo. NATE is part of LSI (Integrable +Systems Laboratory) and stands for Learning, Work and Entertainment +Research Group. Visit our web page: +www.nate.lsi.usp.br +Suggestions, bugs and doubts, please email oficina@lsi.usp.br + +Oficina is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation version 2 of +the License. + +Oficina is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public +License along with Oficina; if not, write to the +Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, +Boston, MA 02110-1301 USA. +The copy of the GNU General Public License is found in the +COPYING file included in the source distribution. + + +Authors: + +Joyce Alessandra Saul (joycealess@gmail.com) +Andre Mossinato (andremossinato@gmail.com) +Nathalia Sautchuk Patrício (nathalia.sautchuk@gmail.com) +Pedro Kayatt (pekayatt@gmail.com) +Rafael Barbolo Lopes (barbolo@gmail.com) +Alexandre A. Gonçalves Martinazzo (alexandremartinazzo@gmail.com) + +*/ +#include <stdio.h> +#include <stdlib.h> +#include <gtk/gtk.h>
+ +/*to implement a queue */
+typedef int ElementType;
+struct Node;
+typedef struct Node *PtrToNode;
+typedef PtrToNode List;
+typedef PtrToNode Position;
+typedef struct QueueL *Queue;
+int IsEmpty( Queue Q );
+Queue CreateQueue( void );
+void DisposeQueue( Queue Q );
+void MakeEmpty( Queue Q );
+void Enqueue( ElementType X, Queue Q );
+ElementType Front( Queue Q );
+void Dequeue( Queue Q ); +/*end of queue*/
+void fill(GdkDrawable *drawable, GdkGC *gc, int x, int y, int width, int height, int color);
diff --git a/fill_src/.svn/text-base/fill.c.svn-base b/fill_src/.svn/text-base/fill.c.svn-base new file mode 100644 index 0000000..39c4e34 --- /dev/null +++ b/fill_src/.svn/text-base/fill.c.svn-base @@ -0,0 +1,79 @@ +/* -- THIS FILE IS GENERATED - DO NOT EDIT *//* -*- Mode: C; c-basic-offset: 4 -*- */ + +#include <Python.h> + + + +#line 3 "fill.override" +#include <Python.h> +#include <gtk/gtk.h> +#include "pygobject.h" +#include "eggfill.h" +#line 13 "fill.c" + + +/* ---------- types from other modules ---------- */ +static PyTypeObject *_PyGdkDrawable_Type; +#define PyGdkDrawable_Type (*_PyGdkDrawable_Type) +static PyTypeObject *_PyGdkGC_Type; +#define PyGdkGC_Type (*_PyGdkGC_Type) + + +/* ---------- forward type declarations ---------- */ + +#line 25 "fill.c" + + + +/* ----------- functions ----------- */ + +static PyObject * +_wrap_fill(PyObject *self, PyObject *args, PyObject *kwargs) +{ + static char *kwlist[] = { "drawable", "gc", "x", "y", "width", "height", "color", NULL }; + PyGObject *drawable, *gc; + int x, y, width, height, color; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs,"O!O!iiiii:fill", kwlist, &PyGdkDrawable_Type, &drawable, &PyGdkGC_Type, &gc, &x, &y, &width, &height, &color)) + return NULL; + + fill(GDK_DRAWABLE(drawable->obj), GDK_GC(gc->obj), x, y, width, height, color); + + Py_INCREF(Py_None); + return Py_None; +} + +const PyMethodDef fill_functions[] = { + { "fill", (PyCFunction)_wrap_fill, METH_VARARGS|METH_KEYWORDS, + NULL }, + { NULL, NULL, 0, NULL } +}; + +/* initialise stuff extension classes */ +void +fill_register_classes(PyObject *d) +{ + PyObject *module; + + if ((module = PyImport_ImportModule("gtk.gdk")) != NULL) { + _PyGdkDrawable_Type = (PyTypeObject *)PyObject_GetAttrString(module, "Drawable"); + if (_PyGdkDrawable_Type == NULL) { + PyErr_SetString(PyExc_ImportError, + "cannot import name Drawable from gtk.gdk"); + return ; + } + _PyGdkGC_Type = (PyTypeObject *)PyObject_GetAttrString(module, "GC"); + if (_PyGdkGC_Type == NULL) { + PyErr_SetString(PyExc_ImportError, + "cannot import name GC from gtk.gdk"); + return ; + } + } else { + PyErr_SetString(PyExc_ImportError, + "could not import gtk.gdk"); + return ; + } + + +#line 79 "fill.c" +} diff --git a/fill_src/.svn/text-base/fill.defs.svn-base b/fill_src/.svn/text-base/fill.defs.svn-base new file mode 100644 index 0000000..d2ebadf --- /dev/null +++ b/fill_src/.svn/text-base/fill.defs.svn-base @@ -0,0 +1,22 @@ +;; -*- scheme -*- +; object definitions ... +;; Enumerations and flags ... + + +;; From eggfill.h + +(define-function fill + (c-name "fill") + (return-type "none") + (parameters + '("GdkDrawable*" "drawable") + '("GdkGC*" "gc") + '("int" "x") + '("int" "y") + '("int" "width") + '("int" "height") + '("int" "color") + ) +) + + diff --git a/fill_src/.svn/text-base/fill.override.svn-base b/fill_src/.svn/text-base/fill.override.svn-base new file mode 100644 index 0000000..85a2f70 --- /dev/null +++ b/fill_src/.svn/text-base/fill.override.svn-base @@ -0,0 +1,15 @@ +%% +headers +#include <Python.h> +#include <gtk/gtk.h> +#include "pygobject.h" +#include "eggfill.h" +%% +modulename fill +%% +import gtk.gdk.Drawable as PyGdkDrawable_Type +import gtk.gdk.GC as PyGdkGC_Type +%% +ignore-glob + *_get_type +%% diff --git a/fill_src/.svn/text-base/fillmodule.c.svn-base b/fill_src/.svn/text-base/fillmodule.c.svn-base new file mode 100644 index 0000000..37f380c --- /dev/null +++ b/fill_src/.svn/text-base/fillmodule.c.svn-base @@ -0,0 +1,65 @@ +/* +Fill wrapper + + +Copyright 2007, NATE-LSI-EPUSP + +Oficina is developed in Brazil at Escola Politécnica of +Universidade de São Paulo. NATE is part of LSI (Integrable +Systems Laboratory) and stands for Learning, Work and Entertainment +Research Group. Visit our web page: +www.nate.lsi.usp.br +Suggestions, bugs and doubts, please email oficina@lsi.usp.br + +Oficina is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation version 2 of +the License. + +Oficina is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public +License along with Oficina; if not, write to the +Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, +Boston, MA 02110-1301 USA. +The copy of the GNU General Public License is found in the +COPYING file included in the source distribution. + + +Authors: + +Joyce Alessandra Saul (joycealess@gmail.com) +Andre Mossinato (andremossinato@gmail.com) +Nathalia Sautchuk Patrício (nathalia.sautchuk@gmail.com) +Pedro Kayatt (pekayatt@gmail.com) +Rafael Barbolo Lopes (barbolo@gmail.com) +Alexandre A. Gonçalves Martinazzo (alexandremartinazzo@gmail.com) +Bruno Gola (brunogola@gmail.com) + +*/ +#include <pygobject.h> + +void fill_register_classes (PyObject *d); + +extern PyMethodDef fill_functions[]; + +DL_EXPORT(void) +initfill(void) +{ + PyObject *m, *d; + + init_pygobject (); + + m = Py_InitModule ("fill", fill_functions); + d = PyModule_GetDict (m); + + fill_register_classes (d); + + if (PyErr_Occurred ()) { + Py_FatalError ("can't initialise module fill"); + } + +} diff --git a/fill_src/Makefile b/fill_src/Makefile new file mode 100644 index 0000000..dc1f3ec --- /dev/null +++ b/fill_src/Makefile @@ -0,0 +1,55 @@ +#Copyright 2007, NATE-LSI-EPUSP + +#Oficina is developed in Brazil at Escola Politécnica of +#Universidade de São Paulo. NATE is part of LSI (Integrable +#Systems Laboratory) and stands for Learning, Work and Entertainment +#Research Group. Visit our web page: +#www.nate.lsi.usp.br +#Suggestions, bugs and doubts, please email oficina@lsi.usp.br + +#Oficina is free software; you can redistribute it and/or +#modify it under the terms of the GNU General Public License +#as published by the Free Software Foundation version 2 of +#the License. + +#Oficina is distributed in the hope that it will be useful, +#but WITHOUT ANY WARRANTY; without even the implied warranty of +#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +#General Public License for more details. + +#You should have received a copy of the GNU General Public +#License along with Oficina; if not, write to the +#Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, +#Boston, MA 02110-1301 USA. +#The copy of the GNU General Public License is found in the +#COPYING file included in the source distribution. + + +#Authors: + +#Joyce Alessandra Saul (joycealess@gmail.com) +#Andre Mossinato (andremossinato@gmail.com) +#Nathalia Sautchuk Patrício (nathalia.sautchuk@gmail.com) +#Pedro Kayatt (pekayatt@gmail.com) +#Rafael Barbolo Lopes (barbolo@gmail.com) +#Alexandre A. Gonçalves Martinazzo (alexandremartinazzo@gmail.com) + +CFLAGS = `pkg-config --cflags gtk+-2.0 pygtk-2.0` -I/usr/include/python2.5/ -I. -I/usr/include/pygtk-2.0/ +LDFLAGS = `pkg-config --libs gtk+-2.0 pygtk-2.0` + +fill.so: fill.o eggfill.o fillmodule.o + $(CC) $(LDFLAGS) -shared $^ -o $@ + +DEFS=`pkg-config --variable=defsdir pygtk-2.0` +# Generate the C wrapper +fill.c: fill.defs fill.override + pygtk-codegen-2.0 --prefix fill \ + --register $(DEFS)/gdk-types.defs \ + --register $(DEFS)/gdk-base.defs \ + --register $(DEFS)/gtk-types.defs \ + --override fill.override \ + fill.defs > $@ + +clean: + rm -f fill.so *.o fill.c *~ + diff --git a/fill_src/eggfill.c b/fill_src/eggfill.c new file mode 100644 index 0000000..5f1010a --- /dev/null +++ b/fill_src/eggfill.c @@ -0,0 +1,193 @@ +/* +eggfill.c + +Fill function and queue list + + +Copyright 2007, NATE-LSI-EPUSP + +Oficina is developed in Brazil at Escola Politécnica of +Universidade de São Paulo. NATE is part of LSI (Integrable +Systems Laboratory) and stands for Learning, Work and Entertainment +Research Group. Visit our web page: +www.nate.lsi.usp.br +Suggestions, bugs and doubts, please email oficina@lsi.usp.br + +Oficina is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation version 2 of +the License. + +Oficina is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public +License along with Oficina; if not, write to the +Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, +Boston, MA 02110-1301 USA. +The copy of the GNU General Public License is found in the +COPYING file included in the source distribution. + + +Authors: + +Joyce Alessandra Saul (joycealess@gmail.com) +Andre Mossinato (andremossinato@gmail.com) +Nathalia Sautchuk Patrício (nathalia.sautchuk@gmail.com) +Pedro Kayatt (pekayatt@gmail.com) +Rafael Barbolo Lopes (barbolo@gmail.com) +Alexandre A. Gonçalves Martinazzo (alexandremartinazzo@gmail.com) + +*/
+#include <gtk/gtk.h>
+#include "eggfill.h"
+ +/*for queue*/
+#define front(Q) ( (Q)->Front )
+#define rear(Q) ( (Q)->Rear )
+
+struct Node {
+ ElementType Element;
+ PtrToNode Next;
+ };
+
+struct QueueL{
+ PtrToNode Front;
+ PtrToNode Rear;
+ } ;
+
+/* this queue has a Header that points to the Front and Rear elements */
+/* empty queue: Q->Front = NULL and Q->Rear = NULL */
+
+/* check if queue Q is empty */
+int IsEmpty( Queue Q ){
+ return ((front(Q)==NULL) && (rear(Q)==NULL));
+}
+
+Queue CreateQueue( void ){
+ Queue Q;
+ Q = malloc ( sizeof (struct Node));
+
+ /* check if there is enough space */
+ if( Q == NULL )
+ printf( "Out of space!!!" );
+
+ front(Q) = NULL;
+ rear(Q) = NULL;
+
+ return Q;
+}
+
+void DisposeQueue( Queue Q ){
+ MakeEmpty(Q);
+ free(Q);
+}
+
+void MakeEmpty( Queue Q ){
+ if( Q == NULL )
+ printf( "Must use CreateQueue first" );
+ else
+ while( !IsEmpty( Q ) )
+ Dequeue( Q );
+}
+
+
+void Enqueue( ElementType X, Queue Q ){
+ PtrToNode TmpCell;
+ TmpCell = malloc( sizeof( struct Node ) );
+ if( TmpCell == NULL )
+ printf( "Out of space!!!" );
+ else {
+ TmpCell->Element = X;
+ TmpCell->Next = NULL;//rear(Q);
+ if (IsEmpty(Q)){
+ //printf("The Queue is empty\n");
+ front(Q)=TmpCell;
+ } else rear(Q)->Next = TmpCell;
+ rear(Q) = TmpCell;
+ }
+}
+
+
+//Mostra o Elemento e 1o da Fila
+ElementType Front( Queue Q ){
+ if (IsEmpty(Q)){
+ printf( "Empty queue" );
+ return 0; /* Return value used to avoid warning */
+ } else {
+ return front(Q)->Element;
+ }
+}
+
+void Dequeue( Queue Q ){
+ PtrToNode tmpCell;
+ tmpCell = malloc( sizeof( struct Node ) );
+ if( IsEmpty( Q ) )
+ printf( "Empty queue" );
+ else {
+ tmpCell=front(Q);
+ front(Q)=front(Q)->Next;
+ if (front(Q)==NULL)
+ rear(Q)=NULL;
+ free(tmpCell);
+ }
+}
/* end of queue*/ +
+void fill(GdkDrawable *drawable, GdkGC *gc, int x, int y, int width, int height, int color){
+
+ int color_start;
+
+ Queue lista_xy; +
+ lista_xy = CreateQueue();
+
+ GdkImage *image;
+ image = gdk_drawable_get_image(drawable,0,0,width,height);
+
+ color_start = gdk_image_get_pixel(image, x, y);
+
+ if (color!=color_start) {
+ Enqueue(x, lista_xy);
+ Enqueue(y, lista_xy);
+ gdk_image_put_pixel(image, x, y, color);
+ while (!IsEmpty(lista_xy)) {
+ if (x+1 < width){
+ if (gdk_image_get_pixel(image, x+1, y) == color_start){
+ gdk_image_put_pixel(image, x+1, y, color);
+ Enqueue(x+1, lista_xy);
+ Enqueue(y, lista_xy);
+ }
+ }
+ if (x-1 >= 0){
+ if (gdk_image_get_pixel(image, x-1, y) == color_start){
+ gdk_image_put_pixel(image, x-1, y, color);
+ Enqueue(x-1, lista_xy);
+ Enqueue(y, lista_xy);
+ }
+ }
+ if (y+1 < height){
+ if (gdk_image_get_pixel(image, x, y+1) == color_start){ + gdk_image_put_pixel(image, x, y+1, color);
+ Enqueue(x, lista_xy);
+ Enqueue(y+1, lista_xy);
+ }
+ }
+ if (y-1 >= 0){
+ if (gdk_image_get_pixel(image, x, y-1) == color_start){ + gdk_image_put_pixel(image, x, y-1, color);
+ Enqueue(x, lista_xy);
+ Enqueue(y-1, lista_xy);
+ }
+ }
+ x = Front(lista_xy);
+ Dequeue(lista_xy);
+ y = Front(lista_xy);
+ Dequeue(lista_xy);
+ }
+ }
+
+ gdk_draw_image(drawable, gc, image, 0,0,0,0,width,height);
+
+}
diff --git a/fill_src/eggfill.h b/fill_src/eggfill.h new file mode 100644 index 0000000..2d1d90a --- /dev/null +++ b/fill_src/eggfill.h @@ -0,0 +1,63 @@ +/* +eggfill.h + +Fill function and queue list + + +Copyright 2007, NATE-LSI-EPUSP + +Oficina is developed in Brazil at Escola Politécnica of +Universidade de São Paulo. NATE is part of LSI (Integrable +Systems Laboratory) and stands for Learning, Work and Entertainment +Research Group. Visit our web page: +www.nate.lsi.usp.br +Suggestions, bugs and doubts, please email oficina@lsi.usp.br + +Oficina is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation version 2 of +the License. + +Oficina is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public +License along with Oficina; if not, write to the +Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, +Boston, MA 02110-1301 USA. +The copy of the GNU General Public License is found in the +COPYING file included in the source distribution. + + +Authors: + +Joyce Alessandra Saul (joycealess@gmail.com) +Andre Mossinato (andremossinato@gmail.com) +Nathalia Sautchuk Patrício (nathalia.sautchuk@gmail.com) +Pedro Kayatt (pekayatt@gmail.com) +Rafael Barbolo Lopes (barbolo@gmail.com) +Alexandre A. Gonçalves Martinazzo (alexandremartinazzo@gmail.com) + +*/ +#include <stdio.h> +#include <stdlib.h> +#include <gtk/gtk.h>
+ +/*to implement a queue */
+typedef int ElementType;
+struct Node;
+typedef struct Node *PtrToNode;
+typedef PtrToNode List;
+typedef PtrToNode Position;
+typedef struct QueueL *Queue;
+int IsEmpty( Queue Q );
+Queue CreateQueue( void );
+void DisposeQueue( Queue Q );
+void MakeEmpty( Queue Q );
+void Enqueue( ElementType X, Queue Q );
+ElementType Front( Queue Q );
+void Dequeue( Queue Q ); +/*end of queue*/
+void fill(GdkDrawable *drawable, GdkGC *gc, int x, int y, int width, int height, int color);
diff --git a/fill_src/fill.c b/fill_src/fill.c new file mode 100644 index 0000000..39c4e34 --- /dev/null +++ b/fill_src/fill.c @@ -0,0 +1,79 @@ +/* -- THIS FILE IS GENERATED - DO NOT EDIT *//* -*- Mode: C; c-basic-offset: 4 -*- */ + +#include <Python.h> + + + +#line 3 "fill.override" +#include <Python.h> +#include <gtk/gtk.h> +#include "pygobject.h" +#include "eggfill.h" +#line 13 "fill.c" + + +/* ---------- types from other modules ---------- */ +static PyTypeObject *_PyGdkDrawable_Type; +#define PyGdkDrawable_Type (*_PyGdkDrawable_Type) +static PyTypeObject *_PyGdkGC_Type; +#define PyGdkGC_Type (*_PyGdkGC_Type) + + +/* ---------- forward type declarations ---------- */ + +#line 25 "fill.c" + + + +/* ----------- functions ----------- */ + +static PyObject * +_wrap_fill(PyObject *self, PyObject *args, PyObject *kwargs) +{ + static char *kwlist[] = { "drawable", "gc", "x", "y", "width", "height", "color", NULL }; + PyGObject *drawable, *gc; + int x, y, width, height, color; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs,"O!O!iiiii:fill", kwlist, &PyGdkDrawable_Type, &drawable, &PyGdkGC_Type, &gc, &x, &y, &width, &height, &color)) + return NULL; + + fill(GDK_DRAWABLE(drawable->obj), GDK_GC(gc->obj), x, y, width, height, color); + + Py_INCREF(Py_None); + return Py_None; +} + +const PyMethodDef fill_functions[] = { + { "fill", (PyCFunction)_wrap_fill, METH_VARARGS|METH_KEYWORDS, + NULL }, + { NULL, NULL, 0, NULL } +}; + +/* initialise stuff extension classes */ +void +fill_register_classes(PyObject *d) +{ + PyObject *module; + + if ((module = PyImport_ImportModule("gtk.gdk")) != NULL) { + _PyGdkDrawable_Type = (PyTypeObject *)PyObject_GetAttrString(module, "Drawable"); + if (_PyGdkDrawable_Type == NULL) { + PyErr_SetString(PyExc_ImportError, + "cannot import name Drawable from gtk.gdk"); + return ; + } + _PyGdkGC_Type = (PyTypeObject *)PyObject_GetAttrString(module, "GC"); + if (_PyGdkGC_Type == NULL) { + PyErr_SetString(PyExc_ImportError, + "cannot import name GC from gtk.gdk"); + return ; + } + } else { + PyErr_SetString(PyExc_ImportError, + "could not import gtk.gdk"); + return ; + } + + +#line 79 "fill.c" +} diff --git a/fill_src/fill.defs b/fill_src/fill.defs new file mode 100644 index 0000000..d2ebadf --- /dev/null +++ b/fill_src/fill.defs @@ -0,0 +1,22 @@ +;; -*- scheme -*- +; object definitions ... +;; Enumerations and flags ... + + +;; From eggfill.h + +(define-function fill + (c-name "fill") + (return-type "none") + (parameters + '("GdkDrawable*" "drawable") + '("GdkGC*" "gc") + '("int" "x") + '("int" "y") + '("int" "width") + '("int" "height") + '("int" "color") + ) +) + + diff --git a/fill_src/fill.override b/fill_src/fill.override new file mode 100644 index 0000000..85a2f70 --- /dev/null +++ b/fill_src/fill.override @@ -0,0 +1,15 @@ +%% +headers +#include <Python.h> +#include <gtk/gtk.h> +#include "pygobject.h" +#include "eggfill.h" +%% +modulename fill +%% +import gtk.gdk.Drawable as PyGdkDrawable_Type +import gtk.gdk.GC as PyGdkGC_Type +%% +ignore-glob + *_get_type +%% diff --git a/fill_src/fillmodule.c b/fill_src/fillmodule.c new file mode 100644 index 0000000..37f380c --- /dev/null +++ b/fill_src/fillmodule.c @@ -0,0 +1,65 @@ +/* +Fill wrapper + + +Copyright 2007, NATE-LSI-EPUSP + +Oficina is developed in Brazil at Escola Politécnica of +Universidade de São Paulo. NATE is part of LSI (Integrable +Systems Laboratory) and stands for Learning, Work and Entertainment +Research Group. Visit our web page: +www.nate.lsi.usp.br +Suggestions, bugs and doubts, please email oficina@lsi.usp.br + +Oficina is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation version 2 of +the License. + +Oficina is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public +License along with Oficina; if not, write to the +Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, +Boston, MA 02110-1301 USA. +The copy of the GNU General Public License is found in the +COPYING file included in the source distribution. + + +Authors: + +Joyce Alessandra Saul (joycealess@gmail.com) +Andre Mossinato (andremossinato@gmail.com) +Nathalia Sautchuk Patrício (nathalia.sautchuk@gmail.com) +Pedro Kayatt (pekayatt@gmail.com) +Rafael Barbolo Lopes (barbolo@gmail.com) +Alexandre A. Gonçalves Martinazzo (alexandremartinazzo@gmail.com) +Bruno Gola (brunogola@gmail.com) + +*/ +#include <pygobject.h> + +void fill_register_classes (PyObject *d); + +extern PyMethodDef fill_functions[]; + +DL_EXPORT(void) +initfill(void) +{ + PyObject *m, *d; + + init_pygobject (); + + m = Py_InitModule ("fill", fill_functions); + d = PyModule_GetDict (m); + + fill_register_classes (d); + + if (PyErr_Occurred ()) { + Py_FatalError ("can't initialise module fill"); + } + +} |