Main Page | Namespace List | Class Hierarchy | Class List | File List | Class Members | File Members

src/aclvis/InterpCmdACLVIS.cpp

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 /***************************************************************************
00003  *
00004  * The IPPL Framework
00005  * 
00006  * This program was prepared by PSI. 
00007  * All rights in the program are reserved by PSI.
00008  * Neither PSI nor the author(s)
00009  * makes any warranty, express or implied, or assumes any liability or
00010  * responsibility for the use of this software
00011  *
00012  * Visit http://www.acl.lanl.gov/POOMS for more details
00013  *
00014  ***************************************************************************/
00015 
00016 // -*- C++ -*-
00017 /***************************************************************************
00018  *
00019  * The IPPL Framework
00020  * 
00021  *
00022  * Visit http://people.web.psi.ch/adelmann/ for more details
00023  *
00024  ***************************************************************************/
00025 
00026 #include "aclvis/InterpCmdACLVIS.h"
00027 #include "aclvis/aclvis.h"
00028 #include "aclvis/MainWindow.h"
00029 #include "aclvis/vizCallbackImpl.h"
00030 #include <string.h>
00031 #ifndef IPPL_NO_STRINGSTREAM
00032 #include <sstream>
00033 using namespace std;
00034 #else
00035 #include <strstream.h>
00036 #endif
00037 
00038 extern MainWindow *mainWindow;
00039 
00040 
00042 // The function which is called when this command should
00043 // actually be run.  Return the result as a string, and
00044 // set the final boolean to true if OK, false if error.
00045 char *InterpCmdTool::process(int argc, char *argv[], bool& status) {
00046   // set up stream for output
00047 #ifndef IPPL_NO_STRINGSTREAM
00048   static string returnbuf;
00049   returnbuf = "\0";
00050   ostringstream retmsg(returnbuf, ios::out);
00051 #else
00052   static char returnbuf[1024];
00053   *returnbuf = 0;
00054   ostrstream retmsg(returnbuf, 1023, ios::out);
00055 #endif
00056 
00057   // check the second word for what to do
00058   bool cmdok = false;
00059   bool cmdunknown = false;
00060   bool cmdworked = true;
00061   if (argc > 1 && !strcmp(argv[1], "stop")) {
00062     // set the viztool mode to stop and continually process events
00063     // during the next interact
00064     if ((cmdok = (argc == 2)))
00065       vizStop(viztool);
00066 
00067   } else if (argc > 1 && !strcmp(argv[1], "go")) {
00068     // set the viztool mode to not pause during interacts
00069     if ((cmdok = (argc == 2)))
00070       vizGo(viztool);
00071 
00072   } else if (argc > 1 && !strcmp(argv[1], "step")) {
00073     // set the viztool to step to the next iteration
00074     if ((cmdok = (argc == 2)))
00075       vizStep(viztool);
00076 
00077   } else if (argc > 1 && !strcmp(argv[1], "reset")) {
00078     // set the viztool to step to the next iteration
00079     if ((cmdok = (argc == 2)))
00080       vizResetRenderer(viztool);
00081 
00082   } else if (argc > 1 && !strcmp(argv[1], "image")) {
00083     // set the viztool to start writing out image dumps
00084     // format: image [base <string>] [num <num>] [ext <string>]
00085     cmdok = true;
00086     if (argc > 2) {
00087       cmdworked = vizImageCmd(viztool, argc - 2, argv + 2);
00088     } else {
00089       cmdworked = vizImageCmd(viztool, 0, 0);
00090     }
00091 
00092   } else if (argc > 1 && !strcmp(argv[1], "newtool")) {
00093     // create a new tool
00094     if ((cmdok = (argc > 2))) {
00095       // get tool type and data name
00096       char *tooltype = argv[2];
00097       char *dataname = (argc > 3 ? argv[3] : 0);
00098  
00099       // create new tool
00100       cmdworked = vizCreateTool(viztool, mainWindow, tooltype, dataname,
00101                                 argc - (dataname != 0 ? 4 : 3),
00102                                 argv + (dataname != 0 ? 4 : 3));
00103 
00104       // determine if any other arguments specify parameter values, and
00105       // set them
00106       if (cmdworked) {
00107         retmsg << "Created new " << tooltype << " for data object ";
00108         retmsg << dataname;
00109       }
00110     }
00111 
00112   } else {
00113     cmdunknown = true;
00114   }
00115 
00116   // determine error code/return value, if any
00117   status = (!cmdunknown) && cmdok && cmdworked;
00118   if (cmdunknown) {
00119     retmsg << "Unknown command '" << argv[0];
00120     if (argc > 1)
00121       retmsg << " " << argv[1];
00122     retmsg << "'.";
00123   } else if (!cmdok) {
00124     retmsg << "Error in format for command '" << argv[0];
00125     if (argc > 1)
00126       retmsg << " " << argv[1];
00127     retmsg << "'.";
00128   }
00129 
00130   // return message
00131   retmsg << ends;
00132 
00133 #ifndef IPPL_NO_STRINGSTREAM
00134   return const_cast<char *>(returnbuf.c_str());
00135 #else
00136   return returnbuf;
00137 #endif
00138 }
00139 
00140 
00141 /***************************************************************************
00142  * $RCSfile: InterpCmdACLVIS.cpp,v $   $Author: adelmann $
00143  * $Revision: 1.1.1.1 $   $Date: 2003/01/23 07:40:34 $
00144  * IPPL_VERSION_ID: $Id: InterpCmdACLVIS.cpp,v 1.1.1.1 2003/01/23 07:40:34 adelmann Exp $ 
00145  ***************************************************************************/
00146 

Generated on Fri Nov 2 01:25:53 2007 for IPPL by doxygen 1.3.5