+/**
+ * Clear the model
+ */
+void Model::clear()
+{
+ glDeleteLists(_displayList, 1);
+ _displayList = glGenLists(1);
+
+ setColorIndex(0);
+
+ _diameter = 0.1;
+ _diameterFactor = 0.8;
+}
+
+
+
+/**
+ * Render to screen
+ */
+void Model::draw()
+{
+ glCallList(_displayList);
+}
+
+
+
/**
* Create a segment
* @param x1 x start point
-/**
- * Render to screen
- */
-void Model::draw()
-{
- glCallList(_displayList);
-}
-
-
-
-/**
- * Clear the model
- */
-void Model::clear()
-{
- glDeleteLists(_displayList, 1);
- _displayList = glGenLists(1);
-
- setColorIndex(0);
-
- _diameter = 0.1;
- _diameterFactor = 0.8;
-}
-
-
-
/**
* Begin a modelling session
*/
/**
- * Decrement diameter of segment
+ * Decrement segment diameter
*/
void Model::decrementDiameter()
{
/**
- * Set current diameter of segment
+ * Set current segment diameter
* @param diameter the diameter
*/
void Model::setDiameter(double diameter)
/**
- * Set diameter factor
+ * Set segment diameter factor
* @param diameter the diameter factor
*/
void Model::setDiameterFactor(double diameterFactor)
/**
- * Get current diameter of segment
- * @return diameter of segment
+ * Get current segment diameter
+ * @return the diameter
*/
double Model::getDiameter()
{
return _diameter;
}
+
+
+
+/**
+ * Get segment diameter factor
+ * @return the diameter factor
+ */
+double Model::getDiameterFactor()
+{
+ return _diameterFactor;
+}
class Model
{
public:
+
/**
* Constructor
*/
*/
~Model();
+
+ /**
+ * Clear the model
+ */
+ void clear();
+
+ /**
+ * Render to screen
+ */
+ void draw();
+
/**
* Create a segment
* @param x1 x start point
*/
void normal(double x, double y, double z);
- /**
- * Render to screen
- */
- void draw();
-
- /**
- * Clear the model
- */
- void clear();
-
/**
* Begin a modelling session
*/
void prevColor();
/**
- * Decrement diameter of segment
+ * Decrement segment diameter
*/
void decrementDiameter();
+
/**
* Set current color index
* @param index the color index
void setColorIndex(int index);
/**
- * Set current diameter of segment
+ * Set current segment diameter
* @param diameter the diameter
*/
void setDiameter(double diameter);
/**
- * Set diameter factor
+ * Set segment diameter factor
* @param diameter the diameter factor
*/
void setDiameterFactor(double diameterFactor);
+
/**
* Get current color index
* @return color index
int getColorIndex();
/**
- * Get current diameter of segment
- * @return diameter of segment
+ * Get current segment diameter
+ * @return the diameter
*/
double getDiameter();
+ /**
+ * Get segment diameter factor
+ * @return the diameter factor
+ */
+ double getDiameterFactor();
+
protected:
GLuint _displayList; // All drawing operations
vector<Color> _colorTable; // Color table
int _colorIndex; // Current index to color table
- double _diameter; // Current diameter of segment
+ double _diameter; // Current segment diameter
double _diameterFactor; // Diameter factor // TODO: "Diameter factor"?
};
ID_CANVAS = FXMainWindow::ID_LAST,
ID_LAST
};
-
+
+
/**
* Constructor
- * @param application the FOX application object
- * @param lsystem the Lindenmayer-system
+ * @param application the application object
*/
- RenderingSurface(FXApp *application, LindenmayerSystem *lsystem);
-
+ RenderingSurface(FXApp *application);
+
+ /**
+ * Destructor
+ */
+ virtual ~RenderingSurface();
+
+
/**
* Create and initialize the window
*/
- void create();
+ virtual void create();
/**
* Initialize OpenGL
*/
void draw();
+
/**
* Called by the system when the left mouse button is pressed
* @param sender the sender object
* @return
*/
long onRepaint(FXObject *sender, FXSelector selector, void *data);
+
+ /**
+ * Called by the system when the close button is pressed
+ * @param sender the sender object
+ * @param selector message type and id
+ * @param data event related data
+ * @return
+ */
+ long onQuit(FXObject *sender, FXSelector selector, void *data);
+
+
+ /**
+ * Set current L-system generator
+ * @param lsystem the L-system generator
+ */
+ void setLSystem(LindenmayerSystem *lsystem);
protected:
*/
RenderingSurface() {}
-private:
FXGLVisual *_visual; // Pixel format info
FXGLCanvas *_canvas; // OpenGL-capable drawing area
- LindenmayerSystem *_lsystem; // The Lindenmayer System
+ LindenmayerSystem *_lsystem; // The Lindenmayer system generator
+
// Model position
double _modelX,
*/
~Rule();
+
/**
* Clear rule
*/
*/
string toString();
+
/**
* Set rule name
* @param name the name
*/
void setProbability(double probability);
+
/**
* Get rule name
* @return the rule name
*/
~RuleSet();
+
/**
* Clear rule set
*/
*/
Rule findRule(string ruleName);
+
/**
* Get all rules
* @return the rules
+/**
+ * Reset to default state
+ */
+void Turtle::reset()
+{
+ // put turtle at (0,0,0), head upwards, back towards camera
+
+ _position.setXYZ(0.0, 0.0, 0.0);
+
+ _heading.setXYZ(0.0, 1.0, 0.0);
+ _left.setXYZ(1.0, 0.0, 0.0);
+ _up.setXYZ(0.0, 0.0, 1.0);
+
+
+ // empty the stacks
+ _positionStack = stack<Coordinate>();
+ _headingStack = stack<Vector>();
+ _leftStack = stack<Vector>();
+ _upStack = stack<Vector>();
+ _diameterStack = stack<double>();
+ _colorIndexStack = stack<int>();
+}
+
+
+
/**
* Turn left
*/
-/**
- * Reset to default state
- */
-void Turtle::reset()
-{
- // put turtle at (0,0,0), head upwards, back towards camera
-
- _position.setXYZ(0.0, 0.0, 0.0);
-
- _heading.setXYZ(0.0, 1.0, 0.0);
- _left.setXYZ(1.0, 0.0, 0.0);
- _up.setXYZ(0.0, 0.0, 1.0);
-
-
- // empty the stacks
- _positionStack = stack<Coordinate>();
- _headingStack = stack<Vector>();
- _leftStack = stack<Vector>();
- _upStack = stack<Vector>();
- _diameterStack = stack<double>();
- _colorIndexStack = stack<int>();
-}
-
-
-
/**
* Set turn/pitch/roll angle
* @param angle the angle, in radians
class Turtle
{
public:
+
/**
* Constructor
* @param model create this model
*/
~Turtle();
+
+ /**
+ * Reset to default state
+ */
+ void reset();
+
/**
* Turn left
*/
*/
void pop();
- /**
- * Reset to default state
- */
- void reset();
/**
* Set turn/pitch/roll angle
*/
void setAngle(double radians);
+
/**
* Get turn/pitch/roll angle
* @return the angle, in radians
+/**
+ * Normalize vector
+ */
+void Vector::normalize()
+{
+ double length = sqrt(_x * _x + _y * _y + _z * _z);
+
+ if (length != 0)
+ {
+ _x /= length;
+ _y /= length;
+ _z /= length;
+ }
+}
+
+
+
/**
* Rotate around another vector
* @param angle rotation angle
-/**
- * Normalize vector
- */
-void Vector::normalize()
-{
- double length = sqrt(_x * _x + _y * _y + _z * _z);
-
- if (length != 0)
- {
- _x /= length;
- _y /= length;
- _z /= length;
- }
-}
-
-
-
/**
* Get scalar product of two vectors
* @param vector arbitrary vector
class Vector : public Coordinate
{
public:
+
/**
* Constructor
* @param x the x-coordinate
*/
~Vector();
+
+ /**
+ * Normalize vector
+ */
+ void normalize();
+
/**
* Rotate around another vector
* @param angle rotation angle
*/
void rotate(double angle, Vector vector);
- /**
- * Normalize vector
- */
- void normalize();
/**
* Get scalar product of two vectors
class XMLStructure
{
public:
+
/**
* Constructor
*/
protected:
// Saver
- // -----
/**
* Create new document with root node
// Loader
- // ------
/**
* Load document from file
*/
string getAttribute(string name);
+
+ /**
+ * Convert double to string
+ * @param doubleValue the double value
+ * @return the corresponding string
+ */
+ string doubleToString(double doubleValue);
+
private:
// Saver