Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

cmd_spaceball.C

Go to the documentation of this file.
00001 /***************************************************************************
00002  *cr                                                                       
00003  *cr            (C) Copyright 1995-2019 The Board of Trustees of the           
00004  *cr                        University of Illinois                       
00005  *cr                         All Rights Reserved                        
00006  *cr                                                                   
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  * RCS INFORMATION:
00011  *
00012  *      $RCSfile: cmd_spaceball.C,v $
00013  *      $Author: johns $        $Locker:  $             $State: Exp $
00014  *      $Revision: 1.10 $      $Date: 2019/01/17 21:21:03 $
00015  *
00016  ***************************************************************************
00017  * DESCRIPTION:
00018  *   Text commands for control of Spaceball/SpaceNavigator/Magellan
00019  *   and similar 6DOF input devices.
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 // print usage message
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     // if here, something went wrong, so return an error message
00047     spaceball_usage(interp);
00048     return TCL_ERROR;
00049   }
00050 
00051   if(!strupncmp(argv[1], "mode", CMDLEN)) {
00052     int m1 = Spaceball::NORMAL;
00053     // see if these are string values
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       // if here, something went wrong, so return an error message
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         // if here, something went wrong, so return an error message
00074         spaceball_usage(interp);
00075         return TCL_ERROR;
00076       }
00077     } else {
00078       // if here, something went wrong, so return an error message
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         // if here, something went wrong, so return an error message
00087         spaceball_usage(interp);
00088         return TCL_ERROR;
00089       }
00090     } else {
00091       // if here, something went wrong, so return an error message
00092       spaceball_usage(interp);
00093       return TCL_ERROR;
00094     }
00095   } else {
00096     // if here, something went wrong, so return an error message
00097     spaceball_usage(interp);
00098     return TCL_ERROR;
00099   }
00100   
00101   // if here, everything worked out ok
00102   return TCL_OK;
00103 }
00104 

Generated on Fri Nov 8 02:43:59 2024 for VMD (current) by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002