00001 // -*- C++ -*- 00002 /*************************************************************************** 00003 * 00004 * The IPPL Framework 00005 * 00006 * 00007 * Visit http://people.web.psi.ch/adelmann/ for more details 00008 * 00009 ***************************************************************************/ 00010 00011 #ifndef ACLVIS_INTERACT_H 00012 #define ACLVIS_INTERACT_H 00013 00014 #include "aclvis/Tool.h" 00015 #include "aclvis/InterpTcl.h" 00016 #include "aclvis/InterpCmdACLVIS.h" 00017 00018 #ifdef IPPL_USE_STANDARD_HEADERS 00019 #include <iostream> 00020 using namespace std; 00021 #else 00022 #include <iostream.h> 00023 #endif 00024 00025 #include <vtk.h> 00026 00027 enum ConnectDataType {FieldDataType, ParticleDataType}; 00028 00030 class VizRecord : public vtkObject { 00031 public: 00032 VizRecord(); 00033 00034 void Print(); 00035 00036 void *caller; 00037 char name[80]; 00038 int id; 00039 void *tool; 00040 ToolType tooltype; 00041 }; 00042 00044 class VizCollection : public vtkCollection { 00045 public: 00046 int MatchTest(VizRecord *, VizRecord *); 00047 VizRecord *FindItem(VizRecord *); 00048 VizRecord *FindNextItem(VizRecord *); 00049 }; 00050 00052 class VizTool { 00053 public: 00054 VizTool(); 00055 00056 // API methods to execute an interpreted command, or to hand off 00057 // control to the interpreter 00058 void InterpretCommand(const char *); 00059 void InterpretInteract(int timeoutseconds = (-1)); 00060 00061 void SetSelectedTool(ToolType, Tool *); 00062 00063 int GetUniqueToolId(ToolType); 00064 Tool *GetSelectedTool(ToolType); 00065 VizCollection *GetVizDB(); 00066 00067 void InitToolIds(); 00068 void Interact(int); 00069 void InteractExit(); // Give conrol to the app 00070 void InteractGoFlow(); // When app gives control to viz, 00071 // update and return control 00072 void InteractStopFlow(); // Keep control when given control by app 00073 void connect(void *caller, char *, void *data, ConnectDataType ctype); 00074 void disconnect(void *caller); 00075 void update(void *caller); 00076 00077 // methods used to modify how image files are written out 00078 void SetImageFileBase(const char *); 00079 void SetImageFileExt(const char *); 00080 void SetImageNextNum(unsigned int); 00081 00082 private: 00083 int InteractFlag; 00084 VizCollection *viz_db; 00085 int ToolId[NUM_OF_TOOL_TYPES]; 00086 Tool *SelectedTool[NUM_OF_TOOL_TYPES]; 00087 00088 int interactIter; // tracks the number of interactions 00089 int goFlag; // controls weather the control 00090 // is given back to the app as soon 00091 // as the data has been updated 00092 00093 // a TCL-based interpreter, and associated commands 00094 InterpTcl interpreter; 00095 InterpCmdTool *toolcmd; 00096 00097 // info for writing out image files 00098 char *image_file_base; 00099 char *image_file_ext; 00100 unsigned int image_next_num; 00101 00102 // from these names, get the next image filename, and put it in the 00103 // provided buffer 00104 bool GetImageName(char *); 00105 }; 00106 00107 00108 #endif // ACLVIS_INTERACT_H 00109 00110 /*************************************************************************** 00111 * $RCSfile: Interact.h,v $ $Author: adelmann $ 00112 * $Revision: 1.1.1.1 $ $Date: 2003/01/23 07:40:34 $ 00113 * IPPL_VERSION_ID: $Id: Interact.h,v 1.1.1.1 2003/01/23 07:40:34 adelmann Exp $ 00114 ***************************************************************************/ 00115 00116