tcl help wanted
- Subject: tcl help wanted
- From: "Arne Chr.Jorgensen" <instel-at-online.no>
- Date: Thu, 02 Dec 1999 13:35:02 +0100
- Content-Transfer-Encoding: 7bit
- Content-Type: text/plain; charset=us-ascii
- Sender: root-at-online.no
Hi,
Pretty frustrated :)
I don't have a book on Tcl/Tk and ..well, I don't know much.
I think tclVogle is at least pre Tcl version 3.6. ( not sure
what they had in 1991 )
I know that tcl/tk have had many changes, and the best thing had
been if I had the old version that
tclVogle was made with. ( Then it should just compile, and you
could run it )
So, I wanted some old version, - the oldest I have is 7.5, and I
have tried with this.
But this may be stupid, - so my question is. What version do you
others use ? ( I have version 8.0 and maybe 8.1 ? )
I just wished that I had some better knowledge of how tk/tcl work:
I will just make a small example of how ( as far as I understand
it ) tclVogle builds:
It uses a command file, and here I just show a simple example:
#
# math.cmds --
#
#include <math.h>
cos mth_dblRetDblCmd cos NULL
sin mth_dblRetDblCmd sin NULL
neg mth_negCmd NULL NULL
-----
This table, is used as the input to a program that will build the
program.
Here is the output.
-----
/* mathCmds.h : generated by build_cmd, do not edit */
#include "/home/program/local/tcl7.5/generic/tcl.h"
#include <math.h>
#include <stdio.h>
EXTERN int mth_dblRetDblCmd _ANSI_ARGS_((ClientData cdata,
Tcl_Interp *interp, int argc, char **argv));
EXTERN int mth_negCmd _ANSI_ARGS_((ClientData cdata, Tcl_Interp
*interp, int arg c, char **argv));
------
And the C file:
------
/* Itmpfile.c : generated by build_cmd, do not edit */
#include "tmpfile.h"
#include "/home/program/local/tk4.1/generic/tkInt.h"
int
init_tmpfile(interp)
Tcl_Interp *interp;
{
Tcl_CreateCommand(interp, "cos", mth_dblRetDblCmd,
(ClientData) cos, (void (*)()) NULL);
Tcl_CreateCommand(interp, "sin", mth_dblRetDblCmd,
(ClientData) sin, (void (*)()) NULL);
Tcl_CreateCommand(interp, "neg", mth_negCmd,
(ClientData) NULL, (void (*)()) NULL);
return 0;
}
------------------------------------------
Next is to compile and link it with tcl/tk and you have these new
commands available, either as
the other inbuild tcl/tk commands or as a seperate
application/library.
I will just <snip> a part of the input file for the graphics:
===============================================================================================
EXTERN int g_angleCmd _ANSI_ARGS_((ClientData cdata, Tcl_Interp
*interp, int argc, char **argv));
EXTERN int g_arcargsCmd _ANSI_ARGS_((ClientData cdata, Tcl_Interp
*interp, int argc, char **argv));
EXTERN int g_isobjCmd _ANSI_ARGS_((ClientData cdata, Tcl_Interp
*interp, int argc, char **argv));
EXTERN int g_loadobjCmd _ANSI_ARGS_((ClientData cdata, Tcl_Interp
*interp, int argc, char **argv));
EXTERN int g_lookatCmd _ANSI_ARGS_((ClientData cdata, Tcl_Interp
*interp, int argc, char **argv));
EXTERN int g_orthoCmd _ANSI_ARGS_((ClientData cdata, Tcl_Interp
*interp, int argc, char **argv));
EXTERN int g_polarviewCmd _ANSI_ARGS_((ClientData cdata,
Tcl_Interp *interp, int argc, char **argv));
EXTERN int g_rotateCmd _ANSI_ARGS_((ClientData cdata, Tcl_Interp
*interp, int argc, char **argv));
EXTERN int g_saveobjCmd _ANSI_ARGS_((ClientData cdata, Tcl_Interp
*interp, int argc, char **argv));
EXTERN int g_scaleCmd _ANSI_ARGS_((ClientData cdata, Tcl_Interp
*interp, int argc, char **argv));
EXTERN int g_viewportCmd _ANSI_ARGS_((ClientData cdata, Tcl_Interp
*interp, intargc, char **argv));
EXTERN int g_windowCmd _ANSI_ARGS_((ClientData cdata, Tcl_Interp
*interp, int argc, char **argv));
extern Tk_Window MainWindow; /* see README */
extern void backface();
extern void backfacedir();
extern void circleprecision();
extern void clipping();
extern void sector();
====================================================================================
This is just a random cut of some of the commands, in tcl/tk
======================================================================================
here is a short file tcl/tk file :
set RADIUS 10.0
set PI 3.14159265358979
set SphereID 1
set TextID 2
proc paintme {{w ".top"}} {
global SphereID TextID RADIUS PI
g_clipping 1
g_font "futura.m"
g_perspective 80.0 1.0 0.001 50.0
g_lookat 13.0 13.0 8.0 0.0 0.0 0.0 0.0
g_color black
g_clear
makesphere
maketext "Around the world in eighty days" $TextID
# draw the main one in cyan
g_color cyan
g_callobj $SphereID
# draw a smaller one outside the main one in white
g_color white
g_pushmatrix
g_translate 0.0 [expr -1.4*$RADIUS] [expr 1.4*$RADIUS]
g_scale 0.3 0.3 0.3
g_callobj $SphereID
g_popmatrix
# scale the text
g_boxfit [expr 2.0*$PI*$RADIUS] [expr 0.25*$RADIUS] 31
# now write the text in rings around the main sphere
g_color green
g_callobj $TextID ;#showroundtext "Around the world in
eighty days "
g_color blue
# note: that software text is rotated here as anything
else would be
# whether you use textang or rotate depends on what you
are trying
:
# note: that software text is rotated here as anything
else would be
# whether you use textang or rotate depends on what you
are trying
# to do. Experience is the best teacher here.
g_rotate 90.0 x
g_callobj $TextID ;#showroundtext "Around the world in
eighty days "
g_color red
g_rotate 90.0 z
g_callobj $TextID ;#showroundtext "Around the world in
eighty days "
}
# showroundtext
#
# draw string str wrapped around a circle in 3d
proc showroundtext {str} {
global RADIUS TextID
set inc [expr 360.0/[string length $str]]
for {set i 0; set x 0} {$i<360} {set i [expr $i+$inc];
incr x 1} {
g_pushmatrix
# find the spot on the edge of the sphere by
making it
# (0 0 0) in world coordinates
g_rotate $i y
: g_translate 0.0 0.0 $RADIUS
g_move 0.0 0.0 0.0
g_drawstr [string range $str $x $x]; # *str++
g_popmatrix
}
}
proc maketext {str id} {
global RADIUS
g_makeobj $id
showroundtext $str
g_closeobj
}
# makesphere
# create the sphere object
# makesphere
# create the sphere object
proc makesphere {} {
global SphereID RADIUS PI
g_makeobj $SphereID
for {set i 0} {$i<180} {incr i 20} {
g_pushmatrix
g_rotate $i y
g_circle 0.0 0.0 $RADIUS
g_popmatrix
}
g_pushmatrix
g_rotate 90.0 x
for {set a -90} {$a<90} {incr a 20} {
set r [expr $RADIUS*[cos [expr $a*$PI/180.0]]]
set z [expr -1*$RADIUS*[sin [expr $a*$PI/180.0]]]
g_pushmatrix
g_translate 0.0 0.0 $z
g_circle 0.0 0.0 $r
g_popmatrix
}
g_popmatrix
g_closeobj
}
***************************************************************************************************
I do feel stupid, because I can't get this to work as it should
should, but I think the whole problem is silly and simple.
There is something I have not set correctly in the Makefile, -
maybe link to X11R6, or linux. It made a file, with lots of
errors and warnings, and the output was a out.a file. Should it
rather be an .elf ?
Well, I haven't given up yet. Vogle works okay, but it is this
tcl bindings I just don't get right. I can send the Makefile to
anyone that would give it a shot.
No, I can include it here:
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# tclvogle makefile
##
TOP=/usr/local
LIB=$(TOP)/lib
##
#RANLIB=echo
RANLIB=ranlib
T_LIBS=-ltk -ltcl
X_LIBS=-lX11
M_LIBS=-lm
U_LIBS=-lvogle
TK_DIR=../tk1.4
TCL_DIR=$(TK_DIR)/tcl
X_CFLAGS=-I$(OPENWINHOME)/include
X_LFLAGS=-L$(OPENWINHOME)/lib
VOGLE=/usr/local/src/graphics/vogle/src
T_CFLAGS=-I. -I$(TCL_DIR) -I$(TK_DIR) -I../$(TK_DIR)/lib
-I$(VOGLE) -DVOGLE=1
T_LFLAGS=-L$(TK_DIR) -L$(TK_DIR)/lib -L$(TCL_DIR) -L$(VOGLE)
## add your own cflags here..
U_CFLAGS=
#D_CFLAGS=
D_CFLAGS=-DMALLOC_DEBUG -g
## debug libraries
#D_LIBS=
D_LIBS=/usr/lib/debug/malloc.o
CFLAGS=$(SYSCFLAGS) $(X_CFLAGS) $(T_CFLAGS) $(D_CFLAGS)
$(U_CFLAGS)
LDFLAGS=$(SYSLFLAGS) $(T_LFLAGS) $(X_LFLAGS)
GENERATED_OBJS=\
IvogleCmds.o \
ImathCmds.o \
IstringCmds.o \
IbuilderCmds.o
GENERATED_SRCS=\
IvogleCmds.c vogleCmds.h \
ImathCmds.c mathCmds.h \
IstringCmds.c stringCmds.h \
IbuilderCmds.c builderCmds.h
VOBJS=TG.o
EXT_OBJS=cmdsUtil.o mathCmds.o stringCmds.o builderCmds.o
OBJS=$(GENERATED_OBJS) tkGraphic.o tclVogle.o sigHandling.o
$(VOBJS) $(EXT_OBJS)
LIBS=$(U_LIBS) $(T_LIBS) $(X_LIBS) $(M_LIBS) $(D_LIBS)
TCLVOGLE=libtclvogle.a
VOGLELIB=$(VOGLE)/libvogle.a
all: $(TCLVOGLE)
$(TCLVOGLE): $(OBJS)
rm -f $(TCLVOGLE)
ar cr $(TCLVOGLE) $(OBJS)
$(RANLIB) $(TCLVOGLE)
tkcore:
cd $(TK_DIR); make libtk.a
vogleCmds.h IvogleCmds.c: vogle.cmds
build_cmds -p vogleCmds< vogle.cmds
mathCmds.h ImathCmds.c: math.cmds
build_cmds -p mathCmds< math.cmds
stringCmds.h IstringCmds.c: string.cmds
build_cmds -p stringCmds< string.cmds
builderCmds.h IbuilderCmds.c: builder.cmds
build_cmds -p builderCmds< builder.cmds
package:
cd ../g; make package
cd docs; make package
cd ../graphics/vogle; make clean
make clean
cd ..; tar cvf - tclvogle graphics/vogle | compress
>tclvogle.tar.Z
clean:
rm -f libtclvogle.a *.o core
rm -f g $(GENERATED_SRCS) .nse_depinfo .make.state
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Any suggestions or help ?
//ARNE
Date Index |
Thread Index |
Back to archive index |
Back to Mailing List Page
Problems or questions? Contact