00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include <stdlib.h>
00023 #include <tcl.h>
00024 #include "config.h"
00025 #include "VMDApp.h"
00026 #include "Spaceball.h"
00027 #include "utilities.h"
00028
00029
00030 static void spaceball_usage(Tcl_Interp *interp) {
00031 Tcl_AppendResult(interp, "spaceball usage:\n",
00032 "spaceball mode <mode>\n",
00033 " modes: normal, maxaxis, scale, animate, tracker, user\n",
00034 "spaceball sensitivity <sensitivity>\n",
00035 "spaceball nullregion <nullregion>\n",
00036 NULL);
00037 }
00038
00039
00040 int text_cmd_spaceball(ClientData cd, Tcl_Interp *interp, int argc,
00041 const char *argv[]) {
00042
00043 VMDApp *app = (VMDApp *)cd;
00044
00045 if (argc < 3 || argc > 4) {
00046
00047 spaceball_usage(interp);
00048 return TCL_ERROR;
00049 }
00050
00051 if(!strupncmp(argv[1], "mode", CMDLEN)) {
00052 int m1 = Spaceball::NORMAL;
00053
00054 if (!strupncmp(argv[2], "normal", CMDLEN)) m1 = Spaceball::NORMAL;
00055 else if (!strupncmp(argv[2], "maxaxis", CMDLEN)) m1 = Spaceball::MAXAXIS;
00056 else if (!strupncmp(argv[2], "scale", CMDLEN)) m1 = Spaceball::SCALING;
00057 else if (!strupncmp(argv[2], "animate", CMDLEN)) m1 = Spaceball::ANIMATE;
00058 else if (!strupncmp(argv[2], "tracker", CMDLEN)) m1 = Spaceball::TRACKER;
00059 else if (!strupncmp(argv[2], "user", CMDLEN)) m1 = Spaceball::USER;
00060
00061 if (!app->spaceball_set_mode(m1)) {
00062 Tcl_AppendResult(interp, "Unable to set Spaceball mode to ",
00063 argv[2], argc > 3 ? argv[3] : NULL, NULL);
00064
00065
00066 spaceball_usage(interp);
00067 return TCL_ERROR;
00068 }
00069 } else if(!strupncmp(argv[1], "sensitivity", CMDLEN)) {
00070 float s;
00071 if (sscanf(argv[2], "%f", &s) == 1) {
00072 if (!app->spaceball_set_sensitivity(s)) {
00073
00074 spaceball_usage(interp);
00075 return TCL_ERROR;
00076 }
00077 } else {
00078
00079 spaceball_usage(interp);
00080 return TCL_ERROR;
00081 }
00082 } else if(!strupncmp(argv[1], "nullregion", CMDLEN)) {
00083 int nr;
00084 if (sscanf(argv[2], "%d", &nr) == 1) {
00085 if (!app->spaceball_set_null_region(nr)) {
00086
00087 spaceball_usage(interp);
00088 return TCL_ERROR;
00089 }
00090 } else {
00091
00092 spaceball_usage(interp);
00093 return TCL_ERROR;
00094 }
00095 } else {
00096
00097 spaceball_usage(interp);
00098 return TCL_ERROR;
00099 }
00100
00101
00102 return TCL_OK;
00103 }
00104