proj home

Files   Classes   Functions   Hierarchy  

primitivewindow.cpp

Go to the documentation of this file.
00001 
00002 #include <string>
00003 #include <vector>
00004 #include <iostream>
00005 #include <sstream>
00006 using namespace std;
00007 
00008 
00009 
00010 #include <primitivewindow.h>
00011 
00012 
00013 
00014 void primitiveWindow::addparagraph
00015 (
00016   string const & s, 
00017   uintc len
00018 )
00019 {
00020   uint slen = s.size();
00021   uint k=0;
00022   uint k2;
00023   uint k3;
00024   uint k4;
00025 
00026   for ( ; k<slen; )
00027   {
00028     k4 = k + len;
00029     // Test if at the end of the iteration.
00030     //if (slen-k <= len )
00031     if (k4 >= slen)
00032     {
00033       addline(s.substr(k));
00034       return;
00035     }
00036 
00037     k2 = s.find(" ",k4);
00038     if (k2==string::npos)
00039     {
00040       addline(s.substr(k));
00041       return;
00042     }
00043 
00044     addline(s.substr(k,k2-k));
00045 
00046     k=k2;
00047 
00048     k3 = s.find_first_not_of(" ",k);
00049     if (k3==string::npos)
00050       return;
00051 
00052     k = k3;
00053   }
00054 }
00055 
00056 
00057 
00058 
00059 
00060 
00061 
00062 
00063 primitiveWindow::primitiveWindow
00064 (
00065   point3<double> const & X0_,
00066   doublec columnchange_,
00067   void * font_
00068 )
00069   : gobjContainer(true), X0(X0_), X(X0), columnchange(columnchange_), font(font_)  
00070 {
00071 
00072 }
00073 
00074 
00075 void primitiveWindow::eval(string const & s)
00076 {
00077   nuke();
00078 
00079   vector<string> vs;
00080   interpretString(vs,s);
00081   uintc sz=vs.size();
00082   for (uint i=0; i<sz; ++i)
00083   {
00084     push( new gobjMyBitmapCharacter(vs[i],X,font) );
00085     X.y -= columnchange;
00086   }
00087 }
00088 
00089 
00090 void primitiveWindow::interpretString(vector<string> &v, string const & s)
00091 {
00092   v.clear();
00093 
00094   if (s.empty())
00095     return;
00096 
00097   int delimeter=10;
00098 
00099   uint sz = s.size();
00100 //cout << "sz=" << sz << endl;
00101   uint i0=0;
00102   uint i=0;
00103   for ( ; i<sz; ++i)
00104   {
00105     if (s[i]!=delimeter)
00106       continue;
00107 
00108     if (i0==i)
00109     {
00110       i0=i+1;
00111       continue;
00112     }
00113 
00114     v.push_back( s.substr(i0,i-i0) );
00115     i0=i+1;
00116 
00117     if (i+1<sz)
00118     {
00119       if( s[i+1]==delimeter )
00120       {
00121         v.push_back("");
00122         i0=i+2;
00123         ++i;
00124       }
00125     }
00126   }
00127 
00128   if (i0==0)
00129     v.push_back(s);
00130 
00131 //cout << "Test" << endl;
00132 //cout << SHOW(v.size());
00133 //for (uint i=0; i<v.size(); ++i)
00134 //{
00135 //  cout << "*" << v[i] << "*" << endl;
00136 //}
00137 
00138 }
00139 
00140 
00141 

Generated on Fri Mar 4 00:49:27 2011 for Chelton Evans Source by  doxygen 1.5.8