From acf054bffd0737f5bef7fc3eba35d6a912e7c801 Mon Sep 17 00:00:00 2001 From: spixx Date: Sun, 26 Nov 2006 14:09:37 +0000 Subject: [PATCH] Minor cleanup. --- src/lindenmayersystem.cpp | 42 +++++++++++++++++++++++++++++---------- src/lindenmayersystem.h | 34 ++++++++++++++++++++++--------- src/lsystem3d.cpp | 7 ++++--- src/lsystemparameters.h | 4 +++- 4 files changed, 64 insertions(+), 23 deletions(-) diff --git a/src/lindenmayersystem.cpp b/src/lindenmayersystem.cpp index 394f22a..1833912 100644 --- a/src/lindenmayersystem.cpp +++ b/src/lindenmayersystem.cpp @@ -87,6 +87,16 @@ void LindenmayerSystem::generate() +/** + * Render L-system data + */ +void LindenmayerSystem::render() +{ + _model->draw(); +} + + + /** * Set the initial rule (the axiom) * @param axiom the axiom @@ -124,7 +134,7 @@ void LindenmayerSystem::setAngle(double degrees) /** - * Set depth of recursion + * Set recursion depth * @param depth depth of recursion */ void LindenmayerSystem::setDepth(int depth) @@ -135,18 +145,19 @@ void LindenmayerSystem::setDepth(int depth) /** - * Set diameter of segment + * Set initial segment diameter * @param diameter the diameter */ void LindenmayerSystem::setDiameter(double diameter) { + _segmentDiameter = diameter; _model->setDiameter(diameter); } /** - * Set diameter factor + * Set segment diameter factor * @param diameterFactor the diameter factor */ void LindenmayerSystem::setDiameterFactor(double diameterFactor) @@ -195,7 +206,7 @@ double LindenmayerSystem::getAngle() /** - * Get depth of recursion + * Get recursion depth * @return depth of recursion */ int LindenmayerSystem::getDepth() @@ -206,19 +217,30 @@ int LindenmayerSystem::getDepth() /** - * Get the generated model - * @return generated model + * Get initial segment diameter + * @return the diameter */ -Model *LindenmayerSystem::getModel() +double LindenmayerSystem::getDiameter() { - return _model; + return _segmentDiameter; +} + + + +/** + * Get segment diameter factor + * @return the diameter factor + */ +double LindenmayerSystem::getDiameterFactor() +{ + return _model->getDiameterFactor(); } /** * Recursively apply the replacement rules - * @param rule rule + * @param rule the rule * @param level recursion level */ void LindenmayerSystem::recursiveWalk(string rule, int level) @@ -348,7 +370,7 @@ void LindenmayerSystem::recursiveWalk(string rule, int level) break; - // decrement diameter of segment + // decrement segment diameter case '!': _model->decrementDiameter(); diff --git a/src/lindenmayersystem.h b/src/lindenmayersystem.h index b937e72..77c8ec0 100644 --- a/src/lindenmayersystem.h +++ b/src/lindenmayersystem.h @@ -34,7 +34,7 @@ using namespace std; /** - * Lindenmayer System + * Lindenmayer system generator */ class LindenmayerSystem { @@ -51,6 +51,7 @@ public: */ ~LindenmayerSystem(); + /** * Clear all parameters */ @@ -61,6 +62,12 @@ public: */ void generate(); + /** + * Render L-system data + */ + void render(); + + /** * Set the initial rule (the axiom) * @param axiom the axiom @@ -80,23 +87,24 @@ public: void setAngle(double degrees); /** - * Set depth of recursion + * Set recursion depth * @param depth depth of recursion */ void setDepth(int depth); /** - * Set diameter of segment + * Set initial segment diameter * @param diameter the diameter */ void setDiameter(double diameter); /** - * Set diameter factor + * Set segment diameter factor * @param diameterFactor the diameter factor */ void setDiameterFactor(double diameterFactor); + /** * Get the initial rule (the axiom) * @return the axiom @@ -116,30 +124,38 @@ public: double getAngle(); /** - * Get depth of recursion + * Get recursion depth * @return depth of recursion */ int getDepth(); /** - * Get the generated model - * @return generated model + * Get initial segment diameter + * @return the diameter */ - Model *getModel(); + double getDiameter(); + + /** + * Get segment diameter factor + * @return the diameter factor + */ + double getDiameterFactor(); protected: /** * Recursively apply the replacement rules - * @param rule rule + * @param rule the rule * @param level recursion level */ void recursiveWalk(string rule, int level); + // Parameters Rule _axiom; RuleSet _rules; int _depth; + double _segmentDiameter; Model *_model; // The active model Turtle *_turtle; // The rendering turtle diff --git a/src/lsystem3d.cpp b/src/lsystem3d.cpp index 37d4ab2..a856028 100644 --- a/src/lsystem3d.cpp +++ b/src/lsystem3d.cpp @@ -38,12 +38,13 @@ LSystem3D::LSystem3D(int argc, char *argv[]) FXApp *application = new FXApp("LSystem3D"); application->init(argc, argv); + // create the windows + RenderingSurface *surface = new RenderingSurface(application); Model model; LindenmayerSystem lsystem(&model); - - // create the windows and run the application - RenderingSurface *surface = new RenderingSurface(application, &lsystem); + surface->setLSystem(&lsystem); new GUI(application, surface, &lsystem); + application->create(); application->run(); } diff --git a/src/lsystemparameters.h b/src/lsystemparameters.h index 2fabdd3..b9dccaf 100644 --- a/src/lsystemparameters.h +++ b/src/lsystemparameters.h @@ -32,11 +32,12 @@ using namespace std; /** - * Save and load a L-system specification + * Saver and loader for L-system parameters */ class LSystemParameters : protected XMLStructure { public: + /** * Constructor */ @@ -47,6 +48,7 @@ public: */ ~LSystemParameters(); + /** * Load parameters from xml file * @param lsystem put parameters into this L-system -- 2.34.1