Commit 207c57b9 authored by Bruno Coudoin's avatar Bruno Coudoin

Integrated the writing tutor activity from Jozef Cerven jcmail80 on gmail / com.

svn path=/trunk/; revision=2627
parent 8d346ffc
2007-05-02 Bruno coudoin <bruno.coudoin@free.fr>
Integrated the writing tutor activity from Jozef Cerven jcmail80 on gmail / com.
* Makefile.am:
* boards/Makefile.am:
* boards/writing_tutor.xml.in:
* boards/writing_tutor/anim_pen.txt:
* boards/writing_tutor_image_match.xml.in:
* boards/writing_tutor_missing_match.xml.in:
* boards/writing_tutor_pattern_admin.xml.in:
* boards/writing_tutor_template_match.xml.in:
* configure.in:
* gcompris-edit.desktop.in:
* macosx/Makefile.am:
* src/boards/python.c: (pythonboard_init):
* src/boards/python/DTW/Makefile.am:
* src/boards/python/DTW/dtw.py:
* src/boards/python/Makefile.am:
* src/boards/python/writing_tutor_common.py:
* src/boards/python/writing_tutor_image_match.py:
* src/boards/python/writing_tutor_missing_match.py:
* src/boards/python/writing_tutor_pattern_admin.py:
* src/boards/python/writing_tutor_template_match.py:
* src/gcompris/config.c:
*** RELEASE 8.3.1 ***
2007-04-29 Bruno coudoin <bruno.coudoin@free.fr>
......
......@@ -10,11 +10,11 @@ else
DOCS_SUBDIR=
endif
SUBDIRS = po src boards $(DOCS_SUBDIR) autopackage macosx
SUBDIRS = po src boards $(DOCS_SUBDIR) autopackage
#if OS_MACOSX
#SUBDIRS += macosx
#endif
if OS_MACOSX
SUBDIRS += macosx
endif
icondir=$(datadir)/pixmaps
......@@ -47,7 +47,13 @@ EXTRA_DIST = \
intltool-extract.in \
intltool-merge.in \
intltool-update.in \
gnome2-macros \
gnome2-macros/autogen.sh \
gnome2-macros/compiler-flags.m4 \
gnome2-macros/curses.m4 \
gnome2-macros/gnome2-macros.dep \
gnome2-macros/gnome-autogen.sh \
gnome2-macros/gnome-common.m4 \
gnome2-macros/gnome-deprecated-macros.m4 \
README.mingw README.translators README.windows \
config.h.mingw Makefile.mingw global_win32.mak gcompris.ico gc_admin.ico gcompris-uninstal.ico \
gcompris-installer.nsi
......
......@@ -136,7 +136,13 @@ xml_in_files = \
tuxpaint.xml.in \
watercycle.xml.in \
wordprocessor.xml.in \
wordsgame.xml.in
wordsgame.xml.in \
writing_tutor_image_match.xml.in \
writing_tutor_missing_match.xml.in \
writing_tutor_pattern_admin.xml.in \
writing_tutor_template_match.xml.in \
writing_tutor.xml.in
xml_DATA = $(xml_in_files:.xml.in=.xml)
......
<?xml version="1.0" encoding="UTF-8"?>
<GCompris>
<Board
name="writing_tutor"
type="menu"
section="/experimental"
icon="boardicons/writing_tutor_tablet.png"
difficulty="0"
author="Jozef Cerven (jcmail80@gmail.com)">
<_title>TBD</_title>
<_description>TBD</description>
</Board>
</GCompris>
writing_tutor/anim_pen.gif
<?xml version="1.0" encoding="UTF-8"?>
<GCompris>
<Board
name="writing_tutor_image_match"
type="python:writing_tutor_image_match"
section="/experimental/writing_tutor"
icon="boardicons/writing_tutor_image_match.png"
difficulty="1"
mode="normal"
author="Jozef Cerven (jcmail80@gmail.com)"
boarddir="tutor">
<title>TBD</title>
<description>TBD</description>
<prerequisite>TBD</prerequisite>
<goal></goal>
<manual></manual>
</Board>
</GCompris>
<?xml version="1.0" encoding="UTF-8"?>
<GCompris>
<Board
name="writing_tutor_missing_match"
type="python:writing_tutor_missing_match"
section="/experimental/writing_tutor"
icon="boardicons/writing_tutor_missing_match.png"
difficulty="1"
mode="normal"
author="Jozef Cerven (jcmail80@gmail.com)"
boarddir="tutor">
<title>Dopĺňanie chýbajúceho písmena</title>
<description>Úlohou je uhádnuť chýbajúce
písmenko,a správne ho napísať</description>
<prerequisite>2. trieda na ZŠ</prerequisite>
<goal>Uhádnuť a správne napísať chýbajúce písmeno/tvar.</goal>
<manual>V ľavej časti sa zobrazí slovo, v ktorom chýba niektoré písmenko, ktoré treba uhádnuť, a potom ho správne napísať. Keď ho už máme napísané, stlačíme ruku v spodnom paneli.
</manual>
</Board>
</GCompris>
<?xml version="1.0" encoding="UTF-8"?>
<GCompris>
<Board
name="writing_tutor_pattern_admin"
type="python:writing_tutor_pattern_admin"
section="/experimental/writing_tutor"
icon="boardicons/writing_tutor_pattern_admin.png"
difficulty="1"
mode="normal"
author="Jozef Cerven (jcmail80@gmail.com)"
boarddir="tutor">
<_title>TBD</_title>
<_description>TBD</_description>
<_prerequisite></_prerequisite>
<_goal></_goal>
<_manual></_manual>
</Board>
</GCompris>
<?xml version="1.0" encoding="UTF-8"?>
<GCompris>
<Board
name="writing_tutor_template_match"
type="python:writing_tutor_template_match"
section="/experimental/writing_tutor"
icon="boardicons/writing_tutor_template_match.png"
difficulty="1"
mode="normal"
author="Jozef Cerven (jcmail80@gmail.com)"
boarddir="tutor">
<_title>TBD</_title>
<_description>TBD</description>
<_prerequisite></_prerequisite>
<_goal></_goal>
<_manual></manual>
</Board>
</GCompris>
......@@ -218,7 +218,7 @@ fi
LDFLAGS="${LDFLAGS} ${XF86VM_LIBS}"
dnl Add the languages which your application supports here.
ALL_LINGUAS="am ar ar_TN az bg ca cs da de dz el en_CA en_GB es et eu fi fr ga gl gu he hi hr hu id it ja ka ko lt mk ml mr ms nb ne nl nn oc pa pl pt pt_BR ro ru rw sk sl so sq sr sr@Latn sv th tr vi wa zh_CN zh_TW"
ALL_LINGUAS="am ar ar_TN az bg ca cs da de dz el en_CA en_GB es et eu fi fr ga gl gu he hi hr hu id it ja ka ko lt mk ml mr ms nb ne nl nn oc pa pl pt pt_BR ro ru rw sk sl so sq sr sr@Latn sv ta th tr vi wa zh_CN zh_TW"
dnl GCompris needs to know which locale are supported
AC_SUBST(ALL_LINGUAS)
......@@ -584,6 +584,7 @@ src/Makefile
src/gcompris/Makefile
src/boards/Makefile
src/boards/python/Makefile
src/boards/python/DTW/Makefile
src/boards/python/gcompris/Makefile
src/boards/python/gcompris/admin/Makefile
src/boards/python/gcompris/anim/Makefile
......
......@@ -6,7 +6,7 @@ Exec=gcompris -a --nolockcheck
Icon=gcompris-edit.png
Terminal=false
Type=Application
Categories=Education;Teaching;
Categories=Education;
StartupNotify=true
X-GNOME-Bugzilla-Bugzilla=GNOME
X-GNOME-Bugzilla-Product=gcompris
......
......@@ -4,3 +4,16 @@ gcompris_SOURCES = main.c
gcompris_CFLAGS = -x c -fpascal-strings
gcompris_LDFLAGS = -framework Carbon -framework Cocoa
EXTRA_DIST = \
build-gtk.sh \
fonts.conf \
GCompris.icns \
gcompris.png \
gcompris.svg \
glibconfig.h \
Info-gnustep.plist \
Info.plist \
pangorc \
PkgInfo
......@@ -170,7 +170,9 @@ pythonboard_init (GcomprisBoard *agcomprisBoard){
} else {
/* Add the python plugins dir to the python's search path */
#ifndef DISABLE_USER_PLUGIN_DIR
userplugindir = g_strconcat(g_get_home_dir(), "/.gcompris/Plugins/", NULL);
userplugindir = g_strconcat(g_get_home_dir(), properties->config_dir,
"/Plugins/",
NULL);
execstr = g_strdup_printf("import sys; sys.path.append('%s/python'); sys.path.append('%s')",
userplugindir, properties->package_python_plugin_dir);
g_free(userplugindir);
......@@ -220,9 +222,10 @@ pythonboard_init (GcomprisBoard *agcomprisBoard){
/* Test if board come with -L option */
g_warning("board_dir: %s package_data_dir %s",
g_warning("board_dir: '%s' package_data_dir '%s' file_name '%s'",
board->board_dir,
properties->package_python_plugin_dir);
properties->package_python_plugin_dir,
board_file_name);
if (strcmp(board->board_dir, properties->package_python_plugin_dir)!=0){
boarddir = g_strdup_printf("sys.path.append('%s/')", board->board_dir);
......
SUBDIRS=
pythondir = $(PYTHON_PLUGIN_DIR)/DTW
dist_python_DATA= \
__init__.py \
dtw.py
# gcompris/tutor/DTW/dtw.py - Writing Tutor project
#
# Author: Jozef Cerven, 5mi, (c) 2006/2007
# FACULTY OF MATHEMATICS, PHYSICS AND INFORMATICS COMENIUS UNIVERSITY BRATISLAVA, Informatics Teaching and Basic of Informatics department
# http://www.edi.fmph.uniba.sk
#
# This program 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; either version 2 of the License, or
# (at your option) any later version.
#
# This program 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 this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
import os
import gtk
from Numeric import *
import math
#
# implementacia DTW algoritmu - na porovnavanie 2och obrazcov(predloha/reference <-> vzorka/sample)
#
# BEGIN OF class DTW ************************************
class DTW:
def __init__(self, save_path, pattern):
self.save_path = save_path
self.pattern = pattern
def compute_dtw(self, vzorka_file, predloha_file):
pf = open(predloha_file, "r")
self.plines = pf.readlines()
pf.close()
vf = open(vzorka_file, "r")
self.vlines = vf.readlines()
vf.close()
# matica lokalnych vzdialenosti
loc_dist = [None] * len(self.plines)
glob_dist = [None] * len(self.plines)
tmp = [None] * len(self.plines)
print "len(self.plines)=", len(self.plines)
print "predloha_file=", predloha_file
print "len(self.vlines)=", len(self.vlines)
print "vzorka_file", vzorka_file
# zlozitost je O(n*m)
for i in range(len(self.plines)):
loc_dist[i] = [None] * len(self.vlines)
glob_dist[i] = [None] * len(self.vlines)
tmp[i] = [None] * len(self.vlines)
pline = self.plines[i].split()
while gtk.events_pending(): gtk.main_iteration() # for animation refresh...
for j in range(len(self.vlines)):
vline = self.vlines[j].split()
loc_dist[i][j] = math.sqrt((int(float(pline[0]))-int(float(vline[0])))**2 +
(int(float(pline[1]))-int(float(vline[1])))**2 +
(int(float(pline[2]))-int(float(vline[2])))**2)
# matica globalnych vzdialenosti
i = 0
j = 0
glob_dist[i][j] = loc_dist[i][j]
tmp[i][j] = [0,0] #?
# j!=0
for j in range(len(self.vlines)-1): # 1..n-1
glob_dist[i][j+1] = loc_dist[i][j+1] + glob_dist[i][j]
tmp[i][j+1] = [i, j]
# i!=0
for i in range(len(self.plines)-1): # 1..n-1
j = 0
glob_dist[i+1][j] = loc_dist[i+1][j] + glob_dist[i][j]
tmp[i+1][j] = [i,j]
for j in range(len(self.vlines)-1): # 1..n-1
while gtk.events_pending(): gtk.main_iteration() # for animation refresh...
glob_dist[i+1][j+1] = loc_dist[i+1][j+1] + min(min(glob_dist[i][j+1],glob_dist[i+1][j]),glob_dist[i][j])
if glob_dist[i][j] <= glob_dist[i][j+1]:
if glob_dist[i][j] <= glob_dist[i+1][j]:
tmp[i+1][j+1] = [i,j]
else:
tmp[i+1][j+1] = [i+1,j]
else:
if glob_dist[i][j+1] <= glob_dist[i+1][j]:
tmp[i+1][j+1] = [i,j+1]
else:
tmp[i+1][j+1] = [i+1,j]
return glob_dist[len(glob_dist)-1][len(glob_dist[0])-1] #?
# vypocita dtw pre test_vzorka count-krat, teda count-krat porovna test_vzorka s referencnyni predlohami,a vrati najlepsie (min) cislo
def dtw(self, test_vzorka, count):
self.count = count
self.test_vzorka = test_vzorka
predlohy_dir = self.save_path + "/writing_tutor/predlohy/" + self.pattern + "/"
if not os.path.exists(predlohy_dir):
print "%s DOES NOT EXISTS!", predlohy_dir
else:
arglist = []
os.path.walk(predlohy_dir,self.walk_callback,arglist)
return self.dtw_res
def walk_callback(self, arg, dirname, fnames ):
_count = 1
dtw_res = [None] * 10
if self.count > 10:
self.count = 10
#print "dirname: ", dirname
if len(fnames) < 1:
print "dtw.py: walk_callback: len(fnames)<1 !! : ", len(fnames)
for _filename in fnames: # porovna test s predlohami
if os.path.getsize(dirname+_filename) > 0:
#print "df: ", dirname , _filename
_dtw_res = self.compute_dtw(self.test_vzorka, dirname + _filename)
#dtw_res[_count-1] = self.compute_dtw(self.test_vzorka, dirname + _filename)
dtw_res[_count-1] = int(_dtw_res / ((len(self.plines) * len(self.vlines)))*100)
print "_dtw_res=", str(_dtw_res),",plines=",str(len(self.plines)),", vlines=",str(len(self.vlines))
if _count == self.count: # tolko dtw porovnani, kolko je parameter count
break
else:
_count = _count + 1
# ak je count > 1, potom vrati minimum z jednotlivych dtw_res
_min = dtw_res[0]
for i in range(self.count): # 0..n-1
if _min > dtw_res[i]:
_min = dtw_res[i]
print "dtw_res["+str(i)+"]=", dtw_res[i]
self.dtw_res = _min
# END OF class DTW ************************************
SUBDIRS=gcompris connect4p admin
SUBDIRS=gcompris connect4p admin DTW
pythondir = $(PYTHON_PLUGIN_DIR)
......@@ -26,6 +26,11 @@ dist_python_DATA= \
searace.py \
sudoku.py \
tuxpaint.py \
watercycle.py
watercycle.py \
writing_tutor_common.py \
writing_tutor_image_match.py \
writing_tutor_missing_match.py \
writing_tutor_pattern_admin.py \
writing_tutor_template_match.py
# gcompris/tutor/common.py - Writing Tutor project
#
# Author: Jozef Cerven, 5mi, (c) 2006/2007
# FACULTY OF MATHEMATICS, PHYSICS AND INFORMATICS COMENIUS UNIVERSITY BRATISLAVA, Informatics Teaching and Basic of Informatics department
# http://www.edi.fmph.uniba.sk
#
# This program 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; either version 2 of the License, or
# (at your option) any later version.
#
# This program 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 this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
import gnomecanvas
import gcompris
import gcompris.utils
import gcompris.bonus
import gcompris.skin
import gcompris.anim
import gcompris.sound
import gcompris.admin
import gcompris.score
import gtk
import gtk.gdk
import random
import pango
import time
import os
import socket
import fcntl
import struct
import re
import glob
import string
import time
# BEGIN OF class GtkInputDialog ************************************
class GtkInputDialog:
inputd = None
def __init__(self, Gcompris_template_match_instance):
self.gd_instance = Gcompris_template_match_instance
self.inputd = gtk.InputDialog()
self.inputd.move((gcompris.BOARD_WIDTH)/2, (gcompris.BOARD_HEIGHT)/2) # !
self.inputd.connect("enable-device", self.clb_enable_device)
self.inputd.connect("disable-device", self.clb_disable_device)
self.inputd.connect("response", self.clb_close_dialog, None)
self.inputd.run()
def clb_close_dialog(self, inputdialog, deviceid, x=None):
self.inputd.hide()
def clb_enable_device(self, inputdialog, deviceid, x=None):
print "clb_enable_device", deviceid.name
if (deviceid.source == gtk.gdk.SOURCE_PEN) and (deviceid.mode == gtk.gdk.MODE_SCREEN or deviceid.mode == gtk.gdk.MODE_WINDOW):
self.gd_instance.set_tablet_indicator(1)
self.clb_close_dialog(inputdialog, deviceid)
def clb_disable_device(self, inputdialog, deviceid, x=None):
print "clb_disable_device", deviceid.name
if (deviceid.source == gtk.gdk.SOURCE_PEN):
self.gd_instance.set_tablet_indicator(0)
self.clb_close_dialog(inputdialog, deviceid)
# END OF class GtkInputDialog ************************************
def draw_guiding_lines(_pixmap, _area, _pattern, _right, _color='SlateGrey'):
"""
Description:
Paint guiding lines according to type of shape (lower, upper, digit, script,...)
Arguments:
_pixmap -- gtk.gdk.Pixmap
_area -- gtk.DrawingArea
_pattern -- pattern to be written
_color -- foreground color of lines, color string specified in the X11 rgb.txt
"""
left = 60
right = _right
top = 60
bottom = 450
colormap = _area.get_colormap()
_color_ = colormap.alloc_color(_color)
gc_solid = _pixmap.new_gc()
gc_solid.copy(_area.get_style().black_gc)
gc_solid.set_foreground(_color_)
gc_solid.set_line_attributes(2, gtk.gdk.LINE_SOLID, gtk.gdk.CAP_BUTT, gtk.gdk.JOIN_MITER)
gc_dash = _pixmap.new_gc()
gc_dash.copy(gc_solid)
gc_dash.set_foreground(_color_)
gc_dash.set_line_attributes(1, gtk.gdk.LINE_ON_OFF_DASH, gtk.gdk.CAP_BUTT, gtk.gdk.JOIN_MITER)
_pixmap.draw_line(gc_dash, left, top, right, top) # top line
_pixmap.draw_line(gc_dash, left, bottom, right, bottom) # bottom line
if _pattern[0] == '_': # tlacene pismena..(in english?)
_pixmap.draw_line(gc_solid, left, top+40, right, top+40) # top1 line
if _pattern[1] in ['a','b','c','d','e','f','h','i','k','l','m','n','o','r','s','t','u','v','z']:
_pixmap.draw_line(gc_dash, left, 200, right, 200)
_pixmap.draw_line(gc_solid, left, bottom-40, right, bottom-40)
elif _pattern[1] in ['g','p']:
_pixmap.draw_line(gc_dash, left, 320, right, 320)
_pixmap.draw_line(gc_solid, left, bottom-40, right, bottom-40)
elif _pattern[1] in ['j']:
_pixmap.draw_line(gc_dash, left, 210, right, 210)
_pixmap.draw_line(gc_solid, left, bottom-50, right, bottom-50)
elif _pattern[1] in ['A','B','E','F','G','H','J','K','P','R',]:
_pixmap.draw_line(gc_dash, left, 260, right, 260)
_pixmap.draw_line(gc_solid, left, bottom-40, right, bottom-40)
elif _pattern[1] in ['C','D','I','L','M','N','O','S','T','U','V','Z']:
_pixmap.draw_line(gc_dash, left, 200, right, 200)
_pixmap.draw_line(gc_solid, left, bottom-40, right, bottom-40)
elif _pattern[0] == '@': # geometric shapes
pass
else: # pisane pismena male aj velke, a cislice 0-9
_pixmap.draw_line(gc_solid, left, top+40, right, top+40) # top1 line
if _pattern[0] not in ['f','g','G','j','J','p']:
_pixmap.draw_line(gc_dash, left, 240, right, 240)
_pixmap.draw_line(gc_solid, left, bottom-40, right, bottom-40)
else:
_pixmap.draw_line(gc_dash, left, 210, right, 210)
_pixmap.draw_line(gc_solid, left, bottom-110, right, bottom-110)
def get_ip_address(ifname):
try:
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
return socket.inet_ntoa(fcntl.ioctl(s.fileno(), 0x8915, struct.pack('256s', ifname[:15]))[20:24])
except:
return "127.0.0.1"
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -110,7 +110,7 @@ static gchar *linguas[] = {
"sr@Latn_YU.ISO-8859-2", N_("Serbian (Latin)"),
"sr_YU.UTF-8", N_("Serbian"),
"sv_FI.UTF-8", N_("Swedish"),
/* "ta_IN.UTF-8", N_("Tamil"), */
"ta_IN.UTF-8", N_("Tamil"),
"th_TH.UTF-8", N_("Thai"),
"tr_TR.UTF-8", N_("Turkish"),
"vi_VN.UTF-8", N_("Vietnamese"),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment