PH Logo
Logo intepreter modeled after UCB Logo.
/Users/paul/Documents/phlogo/core/Turtle.h
00001 /*
00002  *  Turtle.h
00003  *
00004  *  Author: Paul Hamilton
00005  *      Date: 7 Aug 2011
00006  *
00007  */
00008 #ifndef _TURTLE_H
00009 #define _TURTLE_H
00010 
00011 #include <string>
00012 #include <sstream>
00013 
00014 namespace phlogo {
00015 
00053 class Turtle {
00054         
00055 public:
00056     
00057     // graphics
00058     virtual void clear() = 0;
00059     virtual void moveTo(int x, int y) = 0;
00060     virtual void lineTo(int x, int y) = 0;
00061     virtual void stroke() = 0;
00062     
00063     // cursor details
00064     void home();
00065     double getX() { return _x; }
00066     double getY() { return _y; }
00067     void setXY(double x, double y) { _x = x; _y = y; }
00068     double getHeading() { return _heading; }
00069     void setHeading(double heading) { _heading = heading; }
00070     void setPendown(bool pendown) { _pendown = pendown; }
00071     bool getPendown() { return _pendown; }
00072     
00073 protected:
00074     friend class World;
00075     bool _firstop;
00076     bool _pendown;
00077     double _x;
00078     double _y;
00079     double _heading;
00080 };
00081 
00082 class JSONTurtle : public Turtle {
00083  
00084 public:
00085     JSONTurtle();
00086     
00087     // Turtle overrides
00088     virtual void clear();
00089     virtual void moveTo(int x, int y);
00090     virtual void lineTo(int x, int y);
00091     virtual void stroke();
00092 
00093     void startGData();
00094     std::string endGData();
00095     
00096 private:
00097     std::stringstream _gdata;
00098 };
00099     
00100 }
00101 
00102 #endif // _TURTLE_H
 All Classes Functions