Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Examples

gnuplottext.h

Go to the documentation of this file.
00001 #ifndef GNUPLOTTEXT_H 00002 #define GNUPLOTTEXT_H 00003 00004 #include "gnuplot.h" 00005 #include <stdio.h> 00006 00009 00010 00011 00016 template <class T> class GnuplotText 00017 { 00018 // static const char* ascii_letters="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; 00019 00020 protected: 00021 Gnuplot<T> * gg; 00022 typename Gnuplot<T>::nameslist names; 00023 bool sh[52]; 00024 00026 int getIndex(char c){ 00027 // zwei verschiedene Varianten 00028 if(0){ 00029 // char *s=ascii_letters; 00030 // for(int i=0;*s;i++){ 00031 // if(*s==c) return i; 00032 // } 00033 } else { 00034 if (c>='a' && c<='z') return c-'a'; 00035 if (c>='A' && c<='Z') return c-'A'+('z'-'a'+1); 00036 } 00037 return -1; 00038 }; 00039 00041 char getChar(int i){ 00042 // zwei verschiedene Varianten 00043 if(0){ 00044 // if(i>=strlen(ascii_letters) || i<0) 00045 // return ' '; 00046 // return ascii_letters[i]; 00047 } else { 00048 if (i<=('z'-'a')) return 'a'+i; 00049 return 'A'+i-('z'-'a'+1); 00050 } 00051 }; 00052 00054 void show(int n, bool on){ 00055 if(n<names.size()){ 00056 sh[n]=on; 00057 typename Gnuplot<T>::nameslist::iterator i; 00058 i=names.begin(); 00059 for(int a=0;a<n;a++,i++) 00060 /* nichts weiter zu tun */; 00061 gg->show(*i,on); 00062 } 00063 }; 00064 00065 public: 00066 00067 GnuplotText(Gnuplot<T> *gp){ 00068 gg=gp; 00069 for (int i=0;i<52;i++) 00070 sh[i]=true; 00071 }; 00072 00073 virtual ~GnuplotText(){}; 00074 00076 virtual void command(const char *c){ 00077 names = gg->getNames(); 00078 bool on = true; 00079 switch (*c){ 00080 case 'h': 00081 on=false; 00082 // fall through 00083 case 's': 00084 { 00085 int index=0; 00086 c++; 00087 for(;*c;c++){ 00088 if(*c=='*'){ 00089 gg->show_all(on); 00090 for (int i=0;i<52;i++) sh[i]=on; 00091 } else { 00092 index=getIndex(*c); 00093 if(index>=0) 00094 this->show(index,on); 00095 } 00096 } 00097 gg->plot(); 00098 } 00099 break; 00100 00101 case 'l': 00102 default: 00103 break; 00104 } 00105 this->list(); 00106 }; 00107 00109 virtual void list()=0; 00110 }; 00111 00112 #endif

Generated on Wed Apr 6 10:22:14 2005 for Gnuplot by doxygen 1.3.8