proj home

Files   Classes   Functions   Hierarchy  

primitiveWindow Class Reference

Write text to the screen with a primitive window. More...

#include <primitivewindow.h>

Inheritance diagram for primitiveWindow:
Collaboration diagram for primitiveWindow:

List of all members.

Public Member Functions

 primitiveWindow (point3< double > const &X0_, doublec columnchange_, void *font_=GLUT_BITMAP_HELVETICA_10)
 Construct with an initial position, height and font.
void reset ()
 Clear the graphics and return to the cursor to the initial position.
void setfont10 ()
 Set a 10 point font size.
void setfont12 ()
 Set a 12 point font size.
void addparagraph (string const &s, uintc len)
 Interpret the string as a paragraph with minimum len character width.
template<typename T >
void eval (T &x)
 Reads the object into a stream and interprets it.
void addline (string const &s)
 Write a line to the screen.

Static Public Member Functions

static void interpretString (vector< string > &v, string const &s)
 Expecting a string from stringstream.str() where the return characters delimet the string s.

Public Attributes

point3< double > X0
 Initial Position.
point3< double > X
 Current Position.
double columnchange
 Line height change.
void * font
 GLUT font.


Detailed Description

Write text to the screen with a primitive window.

This is a primitive state machine with a font and a current position.

Definition at line 24 of file primitivewindow.h.


Constructor & Destructor Documentation

primitiveWindow::primitiveWindow ( point3< double > const &  X0_,
doublec  columnchange_,
void *  font_ = GLUT_BITMAP_HELVETICA_10 
)

Construct with an initial position, height and font.

Definition at line 64 of file primitivewindow.cpp.

00069   : gobjContainer(true), X0(X0_), X(X0), columnchange(columnchange_), font(font_)  
00070 {
00071 
00072 }


Member Function Documentation

void primitiveWindow::addline ( string const &  s  )  [inline]

Write a line to the screen.

Definition at line 82 of file primitivewindow.h.

References columnchange, font, gobjContainer::push(), X, and point3< T >::y.

00083   {
00084     push( new gobjMyBitmapCharacter(s,X,font) );
00085     X.y -= columnchange;
00086   }

void primitiveWindow::addparagraph ( string const &  s,
uintc  len 
)

Interpret the string as a paragraph with minimum len character width.

Definition at line 15 of file primitivewindow.cpp.

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 }

template<typename T >
void primitiveWindow::eval ( T x  )  [inline]

Reads the object into a stream and interprets it.

Definition at line 64 of file primitivewindow.h.

00065   {
00066     stringstream ss;
00067     ss << x;
00068 
00069     eval(ss.str());
00070 //    return *this;  //--problem with bad cast.
00071   }

void primitiveWindow::interpretString ( vector< string > &  v,
string const &  s 
) [static]

Expecting a string from stringstream.str() where the return characters delimet the string s.

Definition at line 90 of file primitivewindow.cpp.

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 }

void primitiveWindow::reset (  )  [inline]

Clear the graphics and return to the cursor to the initial position.

Definition at line 49 of file primitivewindow.h.

References gobjContainer::nuke(), X, and X0.

Referenced by menu01< T >::readImmediate().

00050     { nuke(); X=X0; }

void primitiveWindow::setfont10 (  )  [inline]

Set a 10 point font size.

Definition at line 53 of file primitivewindow.h.

References font.

00054     { font=GLUT_BITMAP_HELVETICA_10; }

void primitiveWindow::setfont12 (  )  [inline]

Set a 12 point font size.

Definition at line 56 of file primitivewindow.h.

References font.

00057     { font=GLUT_BITMAP_HELVETICA_12; }


Member Data Documentation

Line height change.

Definition at line 35 of file primitivewindow.h.

Referenced by addline().

GLUT font.

Definition at line 37 of file primitivewindow.h.

Referenced by addline(), setfont10(), and setfont12().

Current Position.

Definition at line 33 of file primitivewindow.h.

Referenced by addline(), and reset().

Initial Position.

Definition at line 31 of file primitivewindow.h.

Referenced by reset().


The documentation for this class was generated from the following files:

Generated on Fri Mar 4 00:50:10 2011 for Chelton Evans Source by  doxygen 1.5.8