adding a tcl command

For developers writing C++, Fortran, Java, code who have questions or comments to make.

Moderators: silvia, selimgunay, Moderators

Post Reply
aneeman
Posts: 90
Joined: Thu Jan 12, 2006 1:13 pm
Contact:

adding a tcl command

Post by aneeman »

Hi,

I was wondering if I could get some hints on adding a tcl command to opensees.
Here's what I'd like to say, but it in C++:

GUI gui =new GUI();
gui.createGUI( Domain * d );

OK, so any hints (general or specific) on how to wrap this in tcl would be great!

thanks,

alisa
fmk
Site Admin
Posts: 5884
Joined: Fri Jun 11, 2004 2:33 pm
Location: UC Berkeley
Contact:

Post by fmk »

the easiest way would be to modify OpenSees/SRC/commands.cpp

int guiCommands(ClientData clientData, Tcl_Interp *interp, int argc, TCL_Char **argv);

int g3AppInit(Tcl_Interp *interp) {
.. existing code

Tcl_CreateObjCommand(interp, "gui", guiCommands,
(ClientData)NULL, (Tcl_CmdDeleteProc *)NULL);
..
}

int
guiCommands(ClientData clientData, Tcl_Interp *interp, int argc, TCL_Char **argv)
{

... your code
}
aneeman
Posts: 90
Joined: Thu Jan 12, 2006 1:13 pm
Contact:

adding a tcl command in VC++

Post by aneeman »

That worked fine on the linux side - but it seems command.cpp is a lot touchier in VC++ if you try to include other files- could you mention anything about doing

int
TclModelBuilderVisCommand (ClientData clientData, Tcl_Interp *interp, int argc, TCL_Char **argv, TclModelBuilder *theTclBuilder);

and getting the tcl interpreter to recognize the command?

I've created a subproject in OpenSees with my visualization files that compiles & builds a lib file nicely so I think I'm ready. (I've also tested the code in quickMain and the gui runs fine).

Thanks!

alisa
fmk
Site Admin
Posts: 5884
Joined: Fri Jun 11, 2004 2:33 pm
Location: UC Berkeley
Contact:

Post by fmk »

can you be a bit more specific about the problems you are encountering on the windows side?
aneeman
Posts: 90
Joined: Thu Jan 12, 2006 1:13 pm
Contact:

Post by aneeman »

fmk wrote:can you be a bit more specific about the problems you are encountering on the windows side?
if I add to commands.cpp:
#include <GlutWin.h>

Build-> Build Opensees.exe


--------------------Configuration: openSees - Win32Debug--------------------
Compiling...
commands.cpp
c:\program files\microsoft visual studio\vc98\include\windef.h(145) : error C2378: 'FLOAT' : redefinition; symbol cannot be overloaded with a typedef
c:\opensees1.7.0\opensees\other\superlu_3.0\src\util.h(99) : see declaration of 'FLOAT'

:
more similar

openSees.exe - 102 error(s), 0 warning(s)

As an aside, without #include <GlutWin.h> I still get errors (link errors) but if I do
Build -> Execute OpenSees.exe
it forces linking, completes the build & runs the OpenSees command line.

I've since figured how to put the new gui command into TclModelBuilder.cpp and reference my extern function, that lives in the subproject (similar to the element command) - its running fine.
Post Reply