changeset 5:d691ce98f406

OK. This is the first release. Honest.
author Eris Caffee <discordia@eldalin.com>
date Fri, 12 Nov 2010 23:58:48 -0600
parents df02a7de7fe2
children 6fe9214af151
files CMakeLists.txt include/App.h include/EventHandler.h include/Fractal.h include/Julia.h include/Mandelbrot.h include/Options.h src/App.cpp src/EventHandler.cpp src/Fractal.cpp src/Julia.cpp src/Mandelbrot.cpp src/Options.cpp src/main.cpp
diffstat 14 files changed, 805 insertions(+), 542 deletions(-) [+]
line diff
     1.1 --- a/CMakeLists.txt	Tue Oct 26 02:03:47 2010 -0500
     1.2 +++ b/CMakeLists.txt	Fri Nov 12 23:58:48 2010 -0600
     1.3 @@ -2,22 +2,23 @@
     1.4  #
     1.5  # A generalized cmake file for developing cross-platform games.
     1.6  #
     1.7 -# Copyright (c) 2010 Eris Caffee
     1.8 -# Permission is hereby granted, free of charge, to any person obtaining a copy
     1.9 -#  of this software and associated documentation files (the "Software"), to deal
    1.10 -#  in the Software without restriction, including without limitation the rights
    1.11 -#  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    1.12 -#  copies of the Software, and to permit persons to whom the Software is
    1.13 -#  furnished to do so, subject to the following conditions:
    1.14 -# The above copyright notice and this permission notice shall be included in
    1.15 -#  all copies or substantial portions of the Software.
    1.16 -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    1.17 -#  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    1.18 -#  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    1.19 -#  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    1.20 -#  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    1.21 -#  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    1.22 -#  THE SOFTWARE.
    1.23 +# Copyright (C) 2010 Sarah Eris Horsley Caffee
    1.24 +#
    1.25 +# This file is part of Fracter.
    1.26 +#
    1.27 +# Fracter is free software: you can redistribute it and/or modify
    1.28 +# it under the terms of the GNU General Public License as published by
    1.29 +# the Free Software Foundation, either version 3 of the License, or
    1.30 +# (at your option) any later version.
    1.31 +#
    1.32 +# This program is distributed in the hope that it will be useful,
    1.33 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
    1.34 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    1.35 +# GNU General Public License for more details.
    1.36 +#
    1.37 +# You should have received a copy of the GNU General Public License
    1.38 +# along with this program.  If not, see <http://www.gnu.org/licenses/>.
    1.39 +#
    1.40  #
    1.41  # Instructions:
    1.42  # This cmake file assumes that your source files are laid in out in the 
    1.43 @@ -67,7 +68,7 @@
    1.44  #set (CMAKE_VERBOSE_MAKEFILE ON)
    1.45  
    1.46  # Name your program!
    1.47 -set (App_Name "mandelbrot")
    1.48 +set (App_Name "fracter")
    1.49  if (App_Name STREQUAL "") 
    1.50    message (FATAL_ERROR "You must set the App_Name variable!")
    1.51  endif ()
    1.52 @@ -107,6 +108,8 @@
    1.53  endif ()
    1.54  
    1.55  
    1.56 +add_definitions(-pedantic -Wall -Weffc++)
    1.57 +
    1.58  ################################################################################
    1.59  # The core project files 
    1.60  
    1.61 @@ -141,7 +144,6 @@
    1.62  # Although we listed the library  directories above, we also need to list the
    1.63  # individual libraries we will be linking against.
    1.64  target_link_libraries (${App_Name}
    1.65 -  png
    1.66  )
    1.67  
    1.68  
    1.69 @@ -161,12 +163,9 @@
    1.70  
    1.71  if (WIN32)
    1.72    set (ENV{SDLDIR} "c:/gamedev/deps/sdl/SDL-1.2.14")
    1.73 -  set (ENV{SDLIMAGEDIR} "c:/gamedev/deps/sdl/SDL_image-1.2.10")
    1.74 -# else ()
    1.75 -#   set (ENV{SDLDIR} "/home/eris/gamedev/deps/sdl/SDL-build")
    1.76  endif ()
    1.77  
    1.78 -option(Option_SDL_Dev "Build an SDL application." OFF)
    1.79 +option(Option_SDL_Dev "Build an SDL application." ON)
    1.80  
    1.81  if (Option_SDL_Dev)
    1.82  
    1.83 @@ -186,25 +185,6 @@
    1.84      ${TARGET_LINK_LIBRARIES}
    1.85      )
    1.86  
    1.87 -  # SDL_image
    1.88 -  # Environment variables SDLIMAGEDIR and SDLDIR will be checked in that order
    1.89 -  # and if set cmake will try to find SDL_image in the specified directory.
    1.90 -  OPTION(Option_SDL_Dev_SDL_image "Use SDL_image." OFF)
    1.91 -  IF (Option_SDL_Dev_SDL_image)
    1.92 -    FIND_PACKAGE (SDL_image)
    1.93 -    IF (NOT SDLIMAGE_FOUND)
    1.94 -      MESSAGE (FATAL_ERROR "SDL_image not found!")
    1.95 -    ENDIF (NOT SDLIMAGE_FOUND)
    1.96 -    INCLUDE_DIRECTORIES(
    1.97 -      ${SDLIMAGE_INCLUDE_DIR}
    1.98 -      ${INCLUDE_DIRECTORIES}
    1.99 -      )
   1.100 -    TARGET_LINK_LIBRARIES(${App_Name}
   1.101 -      ${SDLIMAGE_LIBRARY}
   1.102 -      ${TARGET_LINK_LIBRARIES}
   1.103 -      )
   1.104 -  ENDIF (Option_SDL_Dev_SDL_image)
   1.105 -
   1.106  endif (Option_SDL_Dev)
   1.107  
   1.108  
     2.1 --- a/include/App.h	Tue Oct 26 02:03:47 2010 -0500
     2.2 +++ b/include/App.h	Fri Nov 12 23:58:48 2010 -0600
     2.3 @@ -1,8 +1,24 @@
     2.4  ////////////////////////////////////////////////////////////////////////////////
     2.5  //
     2.6 -// (C) 2010 Sarah Eris Horsley Caffee
     2.7 +// Fracter - A simple Mandelbrot Set viewer.
     2.8  //
     2.9 -// mandelbrot - A simple Mandelbrot Set viewer.
    2.10 +// Copyright (C) 2010 Sarah Eris Horsley Caffee
    2.11 +//
    2.12 +// This file is part of Fracter.
    2.13 +//
    2.14 +// Fracter is free software: you can redistribute it and/or modify
    2.15 +// it under the terms of the GNU General Public License as published by
    2.16 +// the Free Software Foundation, either version 3 of the License, or
    2.17 +// (at your option) any later version.
    2.18 +//
    2.19 +// This program is distributed in the hope that it will be useful,
    2.20 +// but WITHOUT ANY WARRANTY; without even the implied warranty of
    2.21 +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    2.22 +// GNU General Public License for more details.
    2.23 +//
    2.24 +// You should have received a copy of the GNU General Public License
    2.25 +// along with this program.  If not, see <http://www.gnu.org/licenses/>.
    2.26 +//
    2.27  //
    2.28  // App.h
    2.29  // Application class definition
    2.30 @@ -29,40 +45,36 @@
    2.31     int run();
    2.32  
    2.33  
    2.34 +   private:
    2.35 +   // Disallow copy constructor and operator=
    2.36 +   App(const App &);
    2.37 +   App & operator=(const App &);
    2.38  
    2.39 -   private:
    2.40 -
    2.41 +   // main loop functions
    2.42     bool init();
    2.43     void update();
    2.44     void render();
    2.45     void cleanup();
    2.46  
    2.47 +
    2.48     // Overrides of EventHandler:
    2.49 -   void on_event(SDL_Event * event);
    2.50 -   void on_KeyDown(SDLKey sym, SDLMod mod, Uint16 unicode);
    2.51 -   void on_KeyUp(SDLKey sym, SDLMod mod, Uint16 unicode);
    2.52 -   void on_Exit();
    2.53 -   void on_LButtonDown(int mx, int my);
    2.54 -   void on_LButtonUp(int mx, int my);
    2.55 -   void on_RButtonDown(int mx, int my);
    2.56 -   void on_MouseMove(int mx, int my, 
    2.57 -		     int relx, int rely, 
    2.58 -		     bool left, bool right, bool middle);
    2.59 -   void on_Resize(int w, int h);
    2.60 +   void on_KeyDown(SDL_KeyboardEvent key);
    2.61 +   void on_KeyUp(SDL_KeyboardEvent key);
    2.62 +   void on_MouseMove(SDL_MouseMotionEvent motion);
    2.63 +   void on_LButtonDown(SDL_MouseButtonEvent button);
    2.64 +   void on_LButtonUp(SDL_MouseButtonEvent button);
    2.65 +   void on_Resize(SDL_ResizeEvent resize);
    2.66     void on_Expose();
    2.67 +   void on_Quit();
    2.68  
    2.69  
    2.70 +   // utility functions
    2.71     int mouse_move_width(int mx, int my);
    2.72 -
    2.73     bool create_new_surface(SDL_Surface * &surface);
    2.74 -
    2.75     void set_julia_k(int x, int y);
    2.76 -
    2.77     void restore_view();
    2.78     void save_view();
    2.79 -
    2.80     void set_caption();
    2.81 -
    2.82     bool save_image();
    2.83  
    2.84     static Uint32 timer_callback(Uint32 interval, void *param);
    2.85 @@ -73,6 +85,8 @@
    2.86     static int scandir_filter(const struct dirent * d);
    2.87  #endif
    2.88  
    2.89 +
    2.90 +   // data members
    2.91     bool running;
    2.92     bool redraw;
    2.93  
    2.94 @@ -85,13 +99,7 @@
    2.95     bool can_set_julia_k;
    2.96     bool setting_julia_k;
    2.97  
    2.98 -   struct view
    2.99 -      {
   2.100 -      std::string type;
   2.101 -      double re_min, im_max, size;
   2.102 -      unsigned int max_iter;
   2.103 -      };
   2.104 -   static std::vector<view *> old_views;
   2.105 +   static std::vector<View *> old_views;
   2.106  
   2.107     Fractal * fractal;
   2.108     };
     3.1 --- a/include/EventHandler.h	Tue Oct 26 02:03:47 2010 -0500
     3.2 +++ b/include/EventHandler.h	Fri Nov 12 23:58:48 2010 -0600
     3.3 @@ -1,8 +1,24 @@
     3.4  ////////////////////////////////////////////////////////////////////////////////
     3.5  //
     3.6 -// (C) 2010 Sarah Eris Horsley Caffee
     3.7 +// Fracter - A simple Mandelbrot Set viewer.
     3.8  //
     3.9 -// mandelbrot - A simple Mandelbrot Set viewer.
    3.10 +// Copyright (C) 2010 Sarah Eris Horsley Caffee
    3.11 +//
    3.12 +// This file is part of Fracter.
    3.13 +//
    3.14 +// Fracter is free software: you can redistribute it and/or modify
    3.15 +// it under the terms of the GNU General Public License as published by
    3.16 +// the Free Software Foundation, either version 3 of the License, or
    3.17 +// (at your option) any later version.
    3.18 +//
    3.19 +// This program is distributed in the hope that it will be useful,
    3.20 +// but WITHOUT ANY WARRANTY; without even the implied warranty of
    3.21 +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    3.22 +// GNU General Public License for more details.
    3.23 +//
    3.24 +// You should have received a copy of the GNU General Public License
    3.25 +// along with this program.  If not, see <http://www.gnu.org/licenses/>.
    3.26 +//
    3.27  //
    3.28  // EventHandler.h
    3.29  // EventHandler class definition.  This is a virtual class that is meant to be
    3.30 @@ -24,37 +40,46 @@
    3.31     EventHandler();
    3.32     virtual ~EventHandler();
    3.33  
    3.34 -#ifndef USE_SDL_WAITEVENT
    3.35 -   virtual int wait_event_timeout(SDL_Event * event, Uint32 timeout);
    3.36 -#endif
    3.37 -
    3.38     virtual void on_event(SDL_Event * event);
    3.39  
    3.40 +   // Active events
    3.41 +   virtual void on_MouseFocus();
    3.42 +   virtual void on_MouseBlur();
    3.43     virtual void on_InputFocus();
    3.44     virtual void on_InputBlur();
    3.45 -   virtual void on_KeyDown(SDLKey sym, SDLMod mod, Uint16 unicode);
    3.46 -   virtual void on_KeyUp(SDLKey sym, SDLMod mod, Uint16 unicode);
    3.47 -   virtual void on_MouseFocus();
    3.48 -   virtual void on_MouseBlur();
    3.49 -   virtual void on_MouseMove(int mx, int my, int relx, int rely, bool left, bool right, bool middle);
    3.50 -   virtual void on_MouseWheel(bool up, bool down);
    3.51 -   virtual void on_LButtonDown(int mx, int my);
    3.52 -   virtual void on_LButtonUp(int mx, int my);
    3.53 -   virtual void on_RButtonDown(int mx, int my);
    3.54 -   virtual void on_RButtonUp(int mx, int my);
    3.55 -   virtual void on_MButtonDown(int mx, int my);
    3.56 -   virtual void on_MButtonUp(int mx, int my);
    3.57 -   virtual void on_JoyAxis(Uint8 ehich, Uint8 axis, Sint16 value);
    3.58 -   virtual void on_JoyButtonDown(Uint8 which, Uint8 button);
    3.59 -   virtual void on_JoyButtonUp(Uint8 which, Uint8 button);
    3.60 -   virtual void on_JoyHat(Uint8 which, Uint8 hat, Uint8 value);
    3.61 -   virtual void on_JoyBall(Uint8 which, Uint8 ball, Sint16 xrel, Sint16 yrel);
    3.62     virtual void on_Minimize();
    3.63     virtual void on_Restore();
    3.64 -   virtual void on_Resize(int w, int h);
    3.65 +
    3.66 +
    3.67 +   // Keyboard events
    3.68 +   virtual void on_KeyDown(SDL_KeyboardEvent key);
    3.69 +   virtual void on_KeyUp(SDL_KeyboardEvent key);
    3.70 +
    3.71 +   // Mouse events
    3.72 +   virtual void on_MouseMove(SDL_MouseMotionEvent motion);
    3.73 +   virtual void on_LButtonDown(SDL_MouseButtonEvent button);
    3.74 +   virtual void on_LButtonUp(SDL_MouseButtonEvent button);
    3.75 +   virtual void on_RButtonDown(SDL_MouseButtonEvent button);
    3.76 +   virtual void on_RButtonUp(SDL_MouseButtonEvent button);
    3.77 +   virtual void on_MButtonDown(SDL_MouseButtonEvent button);
    3.78 +   virtual void on_MButtonUp(SDL_MouseButtonEvent button);
    3.79 +   virtual void on_MouseWheelDown(SDL_MouseButtonEvent motion);
    3.80 +   virtual void on_MouseWheelUp(SDL_MouseButtonEvent motion);
    3.81 +
    3.82 +   // Joystick events
    3.83 +   virtual void on_JoyAxis(SDL_JoyAxisEvent jaxis);
    3.84 +   virtual void on_JoyButtonDown(SDL_JoyButtonEvent jbutton);
    3.85 +   virtual void on_JoyButtonUp(SDL_JoyButtonEvent jbutton);
    3.86 +   virtual void on_JoyHat(SDL_JoyHatEvent jhat);
    3.87 +   virtual void on_JoyBall(SDL_JoyBallEvent jball);
    3.88 +
    3.89 +   // Misc events
    3.90 +   virtual void on_Resize(SDL_ResizeEvent resize);
    3.91     virtual void on_Expose();
    3.92 -   virtual void on_Exit();
    3.93 -   virtual void on_User(Uint8 type, int code, void * data1, void * data2);
    3.94 +   virtual void on_Quit();
    3.95 +   virtual void on_User(SDL_UserEvent user);
    3.96 +   virtual void on_SysWM(SDL_SysWMEvent syswm);
    3.97 +
    3.98     };
    3.99  
   3.100  #endif
     4.1 --- a/include/Fractal.h	Tue Oct 26 02:03:47 2010 -0500
     4.2 +++ b/include/Fractal.h	Fri Nov 12 23:58:48 2010 -0600
     4.3 @@ -1,8 +1,25 @@
     4.4  ////////////////////////////////////////////////////////////////////////////////
     4.5  //
     4.6 -// (C) 2010 Sarah Eris Horsley Caffee
     4.7 +// Fracter - A simple Mandelbrot Set viewer.
     4.8  //
     4.9 -// mandelbrot - A simple Mandelbrot Set viewer.
    4.10 +// Copyright (C) 2010 Sarah Eris Horsley Caffee
    4.11 +//
    4.12 +// This file is part of Fracter.
    4.13 +//
    4.14 +// Fracter is free software: you can redistribute it and/or modify
    4.15 +// it under the terms of the GNU General Public License as published by
    4.16 +// the Free Software Foundation, either version 3 of the License, or
    4.17 +// (at your option) any later version.
    4.18 +//
    4.19 +// This program is distributed in the hope that it will be useful,
    4.20 +// but WITHOUT ANY WARRANTY; without even the implied warranty of
    4.21 +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    4.22 +// GNU General Public License for more details.
    4.23 +//
    4.24 +// You should have received a copy of the GNU General Public License
    4.25 +// along with this program.  If not, see <http://www.gnu.org/licenses/>.
    4.26 +//
    4.27 +//
    4.28  //
    4.29  // Fractal.h
    4.30  // Fractal calculator virtual class definition.  Actual fractals should 
    4.31 @@ -15,19 +32,43 @@
    4.32  
    4.33  #include <map>
    4.34  #include <string>
    4.35 +#include <typeinfo>
    4.36  
    4.37 -// Need to define this via the pre-processor because if it's a staticaly
    4.38 -// initialized const string we still have no guarantee that it will be 
    4.39 -// initialized before it is needed by a FractalCreator class.
    4.40 -// Do the same in all derived classes.
    4.41 +#include "SDL.h"
    4.42  
    4.43 +////////////////////////////////////////////////////////////////////////////////
    4.44 +class View
    4.45 +   {
    4.46 +   public:
    4.47 +   View(std::string t, 
    4.48 +	double re, double im, double s, 
    4.49 +	unsigned int max);
    4.50 +   virtual ~View();
    4.51 +
    4.52 +   std::string const & get_type() const;
    4.53 +
    4.54 +
    4.55 +   private:
    4.56 +   friend class Fractal;
    4.57 +
    4.58 +   View();
    4.59 +   View & operator=(const View &);
    4.60 +
    4.61 +   std::string type;
    4.62 +   double re_min, im_max, size;
    4.63 +   unsigned int max_iter;
    4.64 +   };
    4.65 +
    4.66 +
    4.67 +////////////////////////////////////////////////////////////////////////////////
    4.68  class Fractal
    4.69     {
    4.70     public:
    4.71     Fractal();
    4.72 +   virtual ~Fractal();
    4.73  
    4.74     virtual bool calc_set() = 0;
    4.75 -   virtual bool init(SDL_Surface * surf) = 0;
    4.76 +   virtual bool init(SDL_Surface * surf);
    4.77  
    4.78     double get_re_min() const;
    4.79     double set_re_min(const double r_min);
    4.80 @@ -49,10 +90,11 @@
    4.81     virtual std::string const & get_fractal_name() const;
    4.82  
    4.83  
    4.84 -   virtual bool get_option(std::string option, void * value) const {};
    4.85 -   virtual bool set_option(std::string option, void * value) {};
    4.86 +   virtual bool get_option(std::string option, void * value) const;
    4.87 +   virtual bool set_option(std::string option, void * value);
    4.88  
    4.89 -
    4.90 +   virtual View * save_view();
    4.91 +   virtual void restore_view(View * v);
    4.92  
    4.93     protected:
    4.94  
    4.95 @@ -65,22 +107,41 @@
    4.96     std::string display_name;
    4.97     std::string fractal_name;
    4.98     
    4.99 +
   4.100 +   // The dimensions in the complex plane of the calculated image.  
   4.101 +   // Square image only with die of length "size".
   4.102 +   // Upper left corner of the region is (re_min, im_max)
   4.103     double re_min;
   4.104     double im_max;
   4.105     double size;
   4.106 +
   4.107 +   // Number of iterations to perform when calculating.
   4.108     unsigned int max_iter;
   4.109 +
   4.110 +   // Set to true if the image needs to be recalculated.
   4.111     bool calc_needed;
   4.112     
   4.113 +   // Our drawing surface.
   4.114     SDL_Surface * surface;
   4.115 -   
   4.116 +
   4.117 +   private:
   4.118 +   // Disallow copy constructor and operator=
   4.119 +   Fractal(const Fractal &);
   4.120 +   Fractal & operator=(const Fractal &);
   4.121     };
   4.122  
   4.123 -class FractalCreator
   4.124 +
   4.125 +
   4.126 +////////////////////////////////////////////////////////////////////////////////
   4.127 +// Abstract Factory class.
   4.128 +// A singleton, but it's not thread safe.
   4.129 +class FractalFactory
   4.130     {
   4.131     public:
   4.132 +   virtual ~FractalFactory();
   4.133     virtual Fractal * create() const = 0;
   4.134     };
   4.135  
   4.136 -std::map <std::string, FractalCreator *> & get_Fractal_map();
   4.137 +std::map <std::string, FractalFactory *> & get_Fractal_map();
   4.138  
   4.139  #endif
     5.1 --- a/include/Julia.h	Tue Oct 26 02:03:47 2010 -0500
     5.2 +++ b/include/Julia.h	Fri Nov 12 23:58:48 2010 -0600
     5.3 @@ -1,8 +1,24 @@
     5.4  ////////////////////////////////////////////////////////////////////////////////
     5.5  //
     5.6 -// (C) 2010 Sarah Eris Horsley Caffee
     5.7 +// Fracter - A simple Mandelbrot Set viewer.
     5.8  //
     5.9 -// mandelbrot - A simple Mandelbrot Set viewer.
    5.10 +// Copyright (C) 2010 Sarah Eris Horsley Caffee
    5.11 +//
    5.12 +// This file is part of Fracter.
    5.13 +//
    5.14 +// Fracter is free software: you can redistribute it and/or modify
    5.15 +// it under the terms of the GNU General Public License as published by
    5.16 +// the Free Software Foundation, either version 3 of the License, or
    5.17 +// (at your option) any later version.
    5.18 +//
    5.19 +// This program is distributed in the hope that it will be useful,
    5.20 +// but WITHOUT ANY WARRANTY; without even the implied warranty of
    5.21 +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    5.22 +// GNU General Public License for more details.
    5.23 +//
    5.24 +// You should have received a copy of the GNU General Public License
    5.25 +// along with this program.  If not, see <http://www.gnu.org/licenses/>.
    5.26 +//
    5.27  //
    5.28  // Julia.h
    5.29  // Julia set calculator class definition
    5.30 @@ -13,29 +29,43 @@
    5.31  #define JULIA_H
    5.32  
    5.33  #include <iostream>
    5.34 +
    5.35  #include <string>
    5.36 -#include <typeinfo>
    5.37 -
    5.38 -#include "SDL.h"
    5.39  
    5.40  #include "Fractal.h"
    5.41  
    5.42 +////////////////////////////////////////////////////////////////////////////////
    5.43 +class ViewJulia : public View
    5.44 +   {
    5.45 +   public:
    5.46 +   ViewJulia(std::string t, 
    5.47 +	     double re, double im, double s, 
    5.48 +	     unsigned int max,
    5.49 +	     double kr, double ki);
    5.50 +
    5.51 +   private:
    5.52 +   friend class Julia;
    5.53 +
    5.54 +   double k_re;
    5.55 +   double k_im;
    5.56 +
    5.57 +   };
    5.58 +
    5.59 +////////////////////////////////////////////////////////////////////////////////
    5.60  class Julia : public Fractal
    5.61     {
    5.62     public:
    5.63     Julia();
    5.64  
    5.65     bool calc_set();
    5.66 -   bool init(SDL_Surface * surf);
    5.67  
    5.68     bool get_option(std::string option, void * value) const;
    5.69     bool set_option(std::string option, void * value);
    5.70 -
    5.71 -   std::string const & get_fractal_name() const;
    5.72 +   ViewJulia * save_view();
    5.73 +   void restore_view(View * v);
    5.74  
    5.75     private:
    5.76  
    5.77 -   void draw_pixel(int x, int y, Uint32 * color);
    5.78     void set_display_name();
    5.79  
    5.80     double k_re;
    5.81 @@ -43,21 +73,21 @@
    5.82  
    5.83     };
    5.84  
    5.85 +////////////////////////////////////////////////////////////////////////////////
    5.86  namespace
    5.87     {
    5.88 -   class JuliaCreator : public FractalCreator
    5.89 +   class JuliaFactory : public FractalFactory
    5.90        {
    5.91        public:
    5.92 -      JuliaCreator()
    5.93 +      JuliaFactory()
    5.94  	 {
    5.95 -	 std::cerr << "Julia is called >" << typeid(Julia).name() << "<" << std::endl;
    5.96  	 get_Fractal_map()[typeid(Julia).name()]=this;
    5.97  	 }
    5.98  
    5.99 -      virtual Fractal * create() const
   5.100 +      Fractal * create() const
   5.101  	 {
   5.102  	 return new Julia;
   5.103  	 }
   5.104 -      } the_Julia_creator;
   5.105 +      } the_Julia_factory;
   5.106     }
   5.107  #endif
     6.1 --- a/include/Mandelbrot.h	Tue Oct 26 02:03:47 2010 -0500
     6.2 +++ b/include/Mandelbrot.h	Fri Nov 12 23:58:48 2010 -0600
     6.3 @@ -1,8 +1,24 @@
     6.4  ////////////////////////////////////////////////////////////////////////////////
     6.5  //
     6.6 -// (C) 2010 Sarah Eris Horsley Caffee
     6.7 +// Fracter - A simple Mandelbrot Set viewer.
     6.8  //
     6.9 -// mandelbrot - A simple Mandelbrot Set viewer.
    6.10 +// Copyright (C) 2010 Sarah Eris Horsley Caffee
    6.11 +//
    6.12 +// This file is part of Fracter.
    6.13 +//
    6.14 +// Fracter is free software: you can redistribute it and/or modify
    6.15 +// it under the terms of the GNU General Public License as published by
    6.16 +// the Free Software Foundation, either version 3 of the License, or
    6.17 +// (at your option) any later version.
    6.18 +//
    6.19 +// This program is distributed in the hope that it will be useful,
    6.20 +// but WITHOUT ANY WARRANTY; without even the implied warranty of
    6.21 +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    6.22 +// GNU General Public License for more details.
    6.23 +//
    6.24 +// You should have received a copy of the GNU General Public License
    6.25 +// along with this program.  If not, see <http://www.gnu.org/licenses/>.
    6.26 +//
    6.27  //
    6.28  // Mandelbrot.h
    6.29  // Mandelbrot set calculator class definition
    6.30 @@ -12,43 +28,54 @@
    6.31  #ifndef MANDELBROT_H
    6.32  #define MANDELBROT_H
    6.33  
    6.34 -#include <string>
    6.35 -#include <typeinfo>
    6.36 -
    6.37 -#include "SDL.h"
    6.38 +#include <iostream>
    6.39  
    6.40  #include "Fractal.h"
    6.41  
    6.42 +////////////////////////////////////////////////////////////////////////////////
    6.43 +class ViewMandelbrot : public View
    6.44 +   {
    6.45 +   public:
    6.46 +   ViewMandelbrot(std::string t, 
    6.47 +		  double re, double im, double s, 
    6.48 +		  unsigned int max);
    6.49 +
    6.50 +   private:
    6.51 +   friend class Mandelbrot;
    6.52 +
    6.53 +   };
    6.54 +
    6.55 +////////////////////////////////////////////////////////////////////////////////
    6.56  class Mandelbrot : public Fractal
    6.57     {
    6.58     public:
    6.59     Mandelbrot();
    6.60  
    6.61     bool calc_set();
    6.62 -   bool init(SDL_Surface * surf);
    6.63  
    6.64 -   std::string const & get_fractal_name() const;
    6.65 +   ViewMandelbrot * save_view();
    6.66 +   void restore_view(View * v);
    6.67  
    6.68     private:
    6.69  
    6.70 -   void draw_pixel(int x, int y, Uint32 * color);
    6.71     };
    6.72  
    6.73 +////////////////////////////////////////////////////////////////////////////////
    6.74  namespace
    6.75     {
    6.76 -   class MandelbrotCreator : public FractalCreator
    6.77 +   class MandelbrotFactory : public FractalFactory
    6.78        {
    6.79        public:
    6.80 -      MandelbrotCreator()
    6.81 +      MandelbrotFactory()
    6.82  	 {
    6.83  	 get_Fractal_map()[typeid(Mandelbrot).name()]=this;
    6.84  	 }
    6.85  
    6.86 -      virtual Fractal * create() const
    6.87 +      Fractal * create() const
    6.88  	 {
    6.89  	 return new Mandelbrot;
    6.90  	 }
    6.91 -      } the_Mandelbrot_creator;
    6.92 +      } the_Mandelbrot_factory;
    6.93     }
    6.94  
    6.95  #endif
     7.1 --- a/include/Options.h	Tue Oct 26 02:03:47 2010 -0500
     7.2 +++ b/include/Options.h	Fri Nov 12 23:58:48 2010 -0600
     7.3 @@ -1,10 +1,26 @@
     7.4  ////////////////////////////////////////////////////////////////////////////////
     7.5  //
     7.6 -// (C) 2010 Sarah Eris Horsley Caffee
     7.7 +// Fracter - A simple Mandelbrot Set viewer.
     7.8  //
     7.9 -// mandelbrot - A simple Mandelbrot Set viewer.
    7.10 +// Copyright (C) 2010 Sarah Eris Horsley Caffee
    7.11  //
    7.12 -// options.h
    7.13 +// This file is part of Fracter.
    7.14 +//
    7.15 +// Fracter is free software: you can redistribute it and/or modify
    7.16 +// it under the terms of the GNU General Public License as published by
    7.17 +// the Free Software Foundation, either version 3 of the License, or
    7.18 +// (at your option) any later version.
    7.19 +//
    7.20 +// This program is distributed in the hope that it will be useful,
    7.21 +// but WITHOUT ANY WARRANTY; without even the implied warranty of
    7.22 +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    7.23 +// GNU General Public License for more details.
    7.24 +//
    7.25 +// You should have received a copy of the GNU General Public License
    7.26 +// along with this program.  If not, see <http://www.gnu.org/licenses/>.
    7.27 +//
    7.28 +//
    7.29 +// Options.h
    7.30  // global variables and definitions
    7.31  //
    7.32  ////////////////////////////////////////////////////////////////////////////////
    7.33 @@ -12,8 +28,8 @@
    7.34  #ifndef OPTIONS_H
    7.35  #define OPTIONS_H
    7.36  
    7.37 -#include <string>
    7.38  
    7.39 +// No real reason to make this a class, except in planning for the future.
    7.40  class Options
    7.41     {
    7.42     public:
     8.1 --- a/src/App.cpp	Tue Oct 26 02:03:47 2010 -0500
     8.2 +++ b/src/App.cpp	Fri Nov 12 23:58:48 2010 -0600
     8.3 @@ -1,8 +1,24 @@
     8.4  ////////////////////////////////////////////////////////////////////////////////
     8.5  //
     8.6 -// (C) 2010 Sarah Eris Horsley Caffee
     8.7 +// Fracter - A simple Mandelbrot Set viewer.
     8.8  //
     8.9 -// mandelbrot - A simple Mandelbrot Set viewer.
    8.10 +// Copyright (C) 2010 Sarah Eris Horsley Caffee
    8.11 +//
    8.12 +// This file is part of Fracter.
    8.13 +//
    8.14 +// Fracter is free software: you can redistribute it and/or modify
    8.15 +// it under the terms of the GNU General Public License as published by
    8.16 +// the Free Software Foundation, either version 3 of the License, or
    8.17 +// (at your option) any later version.
    8.18 +//
    8.19 +// This program is distributed in the hope that it will be useful,
    8.20 +// but WITHOUT ANY WARRANTY; without even the implied warranty of
    8.21 +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    8.22 +// GNU General Public License for more details.
    8.23 +//
    8.24 +// You should have received a copy of the GNU General Public License
    8.25 +// along with this program.  If not, see <http://www.gnu.org/licenses/>.
    8.26 +//
    8.27  //
    8.28  // App.cpp
    8.29  // Application class implementation
    8.30 @@ -38,8 +54,7 @@
    8.31  #include "Julia.h"
    8.32  
    8.33  
    8.34 -
    8.35 -std::vector<App::view *> App::old_views;
    8.36 +std::vector<View *> App::old_views;
    8.37  
    8.38  ////////////////////////////////////////////////////////////////////////////////
    8.39  
    8.40 @@ -54,7 +69,8 @@
    8.41     selection_width (-1),
    8.42     setting_zoom (false),
    8.43     can_set_julia_k (false),
    8.44 -   setting_julia_k (false)
    8.45 +   setting_julia_k (false),
    8.46 +   fractal (NULL)
    8.47     {
    8.48     }
    8.49  
    8.50 @@ -123,19 +139,19 @@
    8.51  
    8.52  
    8.53     std::cerr << "Available fractal types are" << std::endl;
    8.54 -   std::map <std::string, FractalCreator *> mymap = get_Fractal_map();
    8.55 -   std::map <std::string, FractalCreator *>::iterator it;
    8.56 +   std::map <std::string, FractalFactory *> mymap = get_Fractal_map();
    8.57 +   std::map <std::string, FractalFactory *>::iterator it;
    8.58     for ( it=mymap.begin() ; it != mymap.end(); it++ )
    8.59        std::cerr << "  " << (*it).first << std::endl;
    8.60  
    8.61 -   FractalCreator * fractal_creator = 
    8.62 +   FractalFactory * fractal_factory = 
    8.63  	 get_Fractal_map()[typeid(Mandelbrot).name()];
    8.64 -   if (!fractal_creator)
    8.65 +   if (!fractal_factory)
    8.66        {
    8.67        std::cerr << "Mandelbrot set not available!" << std::endl;
    8.68        return false;
    8.69        }
    8.70 -   fractal = fractal_creator->create();
    8.71 +   fractal = fractal_factory->create();
    8.72     fractal->init(surf_fractal);
    8.73     redraw = true;
    8.74  
    8.75 @@ -144,7 +160,7 @@
    8.76  
    8.77     set_caption();
    8.78  
    8.79 -   SDL_TimerID timer_id = SDL_AddTimer(10, App::timer_callback, NULL);
    8.80 +   SDL_AddTimer(10, App::timer_callback, NULL);
    8.81  
    8.82     return true;
    8.83     }
    8.84 @@ -206,17 +222,9 @@
    8.85  
    8.86  ////////////////////////////////////////////////////////////////////////////////
    8.87  
    8.88 -void App::on_event(SDL_Event * event)
    8.89 +void App::on_KeyDown(SDL_KeyboardEvent key)
    8.90     {
    8.91 -   EventHandler::on_event(event);
    8.92 -   }
    8.93 -
    8.94 -
    8.95 -////////////////////////////////////////////////////////////////////////////////
    8.96 -
    8.97 -void App::on_KeyDown(SDLKey sym, SDLMod mod, Uint16 unicode)
    8.98 -   {
    8.99 -   switch (sym)
   8.100 +   switch (key.keysym.sym)
   8.101        {
   8.102        case SDLK_ESCAPE:
   8.103        case SDLK_q:
   8.104 @@ -248,32 +256,34 @@
   8.105        case SDLK_m:
   8.106  	 if (fractal)
   8.107  	    {
   8.108 -	    save_view();
   8.109 -	    delete fractal;
   8.110 -	    FractalCreator * fractal_creator = 
   8.111 +	    FractalFactory * fractal_factory = 
   8.112  		  get_Fractal_map()[typeid(Mandelbrot).name()];
   8.113 -	    if (!fractal_creator)
   8.114 +	    if (!fractal_factory)
   8.115  	       {
   8.116  	       std::cerr << "Mandelbrot set not available!" << std::endl;
   8.117  	       SDL_Event event;
   8.118  	       event.type = SDL_QUIT;
   8.119  	       SDL_PushEvent(&event);
   8.120 -	       break;
   8.121  	       }
   8.122 -	    fractal = fractal_creator->create();
   8.123 -	    fractal->init(surf_fractal);
   8.124 -	    fractal->set_calc_needed();
   8.125 -	    redraw = true;
   8.126 -	    set_caption();
   8.127 -	    can_set_julia_k = true;
   8.128 +	    else
   8.129 +	       {
   8.130 +	       save_view();
   8.131 +	       delete fractal;
   8.132 +	       fractal = fractal_factory->create();
   8.133 +	       fractal->init(surf_fractal);
   8.134 +	       redraw = true;
   8.135 +	       set_caption();
   8.136 +	       can_set_julia_k = true;
   8.137 +	       }
   8.138  	    }
   8.139  	 break;
   8.140 +
   8.141        case SDLK_j:
   8.142  	 if (fractal)
   8.143  	    {
   8.144 -	    FractalCreator * fractal_creator = 
   8.145 +	    FractalFactory * fractal_factory = 
   8.146  		  get_Fractal_map()[typeid(Julia).name()];
   8.147 -	    if (!fractal_creator)
   8.148 +	    if (!fractal_factory)
   8.149  	       {
   8.150  	       std::cerr << "Julia set not available!" << std::endl;
   8.151  	       }
   8.152 @@ -281,9 +291,8 @@
   8.153  	       {
   8.154  	       save_view();
   8.155  	       delete fractal;
   8.156 -	       fractal = fractal_creator->create();
   8.157 +	       fractal = fractal_factory->create();
   8.158  	       fractal->init(surf_fractal);
   8.159 -	       fractal->set_calc_needed();
   8.160  	       redraw = true;
   8.161  	       set_caption();
   8.162  	       can_set_julia_k = false;
   8.163 @@ -306,9 +315,9 @@
   8.164  
   8.165  
   8.166  ////////////////////////////////////////////////////////////////////////////////
   8.167 -void App::on_KeyUp(SDLKey sym, SDLMod mod, Uint16 unicode)
   8.168 +void App::on_KeyUp(SDL_KeyboardEvent key)
   8.169     {
   8.170 -   switch (sym)
   8.171 +   switch (key.keysym.sym)
   8.172        {
   8.173        case SDLK_UP:
   8.174  	 fractal->set_calc_needed();
   8.175 @@ -318,30 +327,54 @@
   8.176  	 fractal->set_calc_needed();
   8.177  	 redraw = true;
   8.178  	 break;
   8.179 +      default:
   8.180 +	 break;
   8.181        }   
   8.182     }
   8.183  
   8.184  
   8.185  ////////////////////////////////////////////////////////////////////////////////
   8.186 +void App::on_MouseMove(SDL_MouseMotionEvent motion)
   8.187 +   {
   8.188 +   if (setting_zoom)
   8.189 +      {
   8.190 +      Uint32 clear = SDL_MapRGBA(surf_selection->format, 
   8.191 +				 0, 0, 0, SDL_ALPHA_TRANSPARENT);
   8.192 +      Uint32 white = SDL_MapRGBA(surf_selection->format, 
   8.193 +				 255, 255, 255, SDL_ALPHA_OPAQUE);
   8.194  
   8.195 -void App::on_Exit()
   8.196 -   {
   8.197 -   running = false;
   8.198 +      SDL_FillRect(surf_selection, &surf_selection->clip_rect, clear);
   8.199 +
   8.200 +      SDL_Rect rect;
   8.201 +      rect.x = selection_x;
   8.202 +      rect.y = selection_y;
   8.203 +      int w = mouse_move_width(motion.x, motion.y);
   8.204 +      rect.w = rect.h = w;
   8.205 +
   8.206 +      SDL_FillRect(surf_selection, &rect, white);
   8.207 +
   8.208 +      rect.x = selection_x + 1;
   8.209 +      rect.y = selection_y + 1;
   8.210 +      rect.w = rect.h = w - 2;
   8.211 +
   8.212 +      SDL_FillRect(surf_selection, &rect, clear);
   8.213 +
   8.214 +      redraw = true;
   8.215 +      }
   8.216     }
   8.217  
   8.218 -
   8.219  ////////////////////////////////////////////////////////////////////////////////
   8.220  
   8.221 -void App::on_LButtonDown(int mx, int my)
   8.222 +void App::on_LButtonDown(SDL_MouseButtonEvent button)
   8.223     {
   8.224     if (setting_julia_k)
   8.225        {
   8.226 -      set_julia_k(mx, my);
   8.227 +      set_julia_k(button.x, button.y);
   8.228        }
   8.229     else
   8.230        {
   8.231 -      selection_x = mx;
   8.232 -      selection_y = my;
   8.233 +      selection_x = button.x;
   8.234 +      selection_y = button.y;
   8.235        setting_zoom = true;
   8.236        }
   8.237     }
   8.238 @@ -349,22 +382,22 @@
   8.239  
   8.240  ////////////////////////////////////////////////////////////////////////////////
   8.241  
   8.242 -void App::on_LButtonUp(int mx, int my)
   8.243 +void App::on_LButtonUp(SDL_MouseButtonEvent button)
   8.244     {
   8.245     if (setting_zoom)
   8.246        {
   8.247 -      if ( (mx <= 0) || 
   8.248 -	   (mx >= surf_display->w - 1) || 
   8.249 -	   (my <= 0) || 
   8.250 -	   (my >= surf_display->h - 1))
   8.251 +      selection_width = mouse_move_width(button.x, button.y);
   8.252 +      if ( (button.x <= 0) || 
   8.253 +	   (button.x >= surf_display->w - 1) || 
   8.254 +	   (button.y <= 0) || 
   8.255 +	   (button.y >= surf_display->h - 1) ||
   8.256 +	   (selection_width == 0))
   8.257  	 {
   8.258  	 // Selection cancelled
   8.259  	 setting_zoom = false;
   8.260  	 return;
   8.261  	 }
   8.262  
   8.263 -      selection_width = mouse_move_width(mx, my);
   8.264 -
   8.265        // calculate new min/max re/im
   8.266        double Re_scale = (fractal->get_size())/(surf_fractal->w - 1);
   8.267        double Im_scale = (fractal->get_size())/(surf_fractal->h - 1);
   8.268 @@ -373,7 +406,6 @@
   8.269        double new_im_max = fractal->get_im_max() - (selection_y) * Im_scale;
   8.270        double new_size = selection_width * Re_scale;
   8.271  
   8.272 -
   8.273        save_view();
   8.274  
   8.275        fractal->set_re_min(new_re_min);
   8.276 @@ -390,51 +422,7 @@
   8.277  
   8.278  
   8.279  ////////////////////////////////////////////////////////////////////////////////
   8.280 -
   8.281 -void App::on_RButtonDown(int mx, int my)
   8.282 -   {
   8.283 -   if (can_set_julia_k)
   8.284 -      {
   8.285 -      set_julia_k(mx, my);
   8.286 -      }
   8.287 -   }
   8.288 -
   8.289 -
   8.290 -////////////////////////////////////////////////////////////////////////////////
   8.291 -void App::on_MouseMove(int mx, int my, 
   8.292 -		       int relx, int rely, 
   8.293 -		       bool left, bool right, bool middle)
   8.294 -   {
   8.295 -   if (setting_zoom)
   8.296 -      {
   8.297 -      Uint32 clear = SDL_MapRGBA(surf_selection->format, 
   8.298 -				0, 0, 0, SDL_ALPHA_TRANSPARENT);
   8.299 -      Uint32 white = SDL_MapRGBA(surf_selection->format, 
   8.300 -				 255, 255, 255, SDL_ALPHA_OPAQUE);
   8.301 -
   8.302 -      SDL_FillRect(surf_selection, &surf_selection->clip_rect, clear);
   8.303 -
   8.304 -      SDL_Rect rect;
   8.305 -      rect.x = selection_x;
   8.306 -      rect.y = selection_y;
   8.307 -      int w = mouse_move_width(mx, my);
   8.308 -      rect.w = rect.h = w;
   8.309 -
   8.310 -      SDL_FillRect(surf_selection, &rect, white);
   8.311 -
   8.312 -      rect.x = selection_x + 1;
   8.313 -      rect.y = selection_y + 1;
   8.314 -      rect.w = rect.h = w - 2;
   8.315 -
   8.316 -      SDL_FillRect(surf_selection, &rect, clear);
   8.317 -
   8.318 -      redraw = true;
   8.319 -      }
   8.320 -   }
   8.321 -
   8.322 -
   8.323 -////////////////////////////////////////////////////////////////////////////////
   8.324 -void App::on_Resize(int w, int h)
   8.325 +void App::on_Resize(SDL_ResizeEvent resize)
   8.326     {
   8.327     redraw = true;
   8.328     }
   8.329 @@ -448,6 +436,14 @@
   8.330  
   8.331  
   8.332  ////////////////////////////////////////////////////////////////////////////////
   8.333 +
   8.334 +void App::on_Quit()
   8.335 +   {
   8.336 +   running = false;
   8.337 +   }
   8.338 +
   8.339 +
   8.340 +////////////////////////////////////////////////////////////////////////////////
   8.341  int App::mouse_move_width(int mx, int my)
   8.342     {
   8.343     int move_width = (mx - selection_x);
   8.344 @@ -500,25 +496,26 @@
   8.345  ////////////////////////////////////////////////////////////////////////////////
   8.346  void App::set_julia_k(int x, int y)
   8.347     {
   8.348 -   save_view();
   8.349 -   
   8.350 -   double k[2];
   8.351 -   k[0]= fractal->get_re_min() + x * 
   8.352 -	 (fractal->get_size())/(surf_fractal->w - 1);
   8.353 -   k[1] = fractal->get_im_max() - y * 
   8.354 -	 (fractal->get_size())/(surf_fractal->h - 1);
   8.355 -      
   8.356 -   FractalCreator * fractal_creator = get_Fractal_map()[typeid(Julia).name()];
   8.357 -   if (!fractal_creator)
   8.358 +   FractalFactory * fractal_factory = get_Fractal_map()[typeid(Julia).name()];
   8.359 +   if (!fractal_factory)
   8.360        {
   8.361        std::cerr << "Julia set not available!" << std::endl;
   8.362        return;
   8.363        }
   8.364     else
   8.365        {
   8.366 +      save_view();
   8.367 +   
   8.368        delete fractal;
   8.369 -      fractal = fractal_creator->create();
   8.370 +      fractal = fractal_factory->create();
   8.371        fractal->init(surf_fractal);
   8.372 +
   8.373 +      double k[2];
   8.374 +      k[0]= fractal->get_re_min() + x * 
   8.375 +	    (fractal->get_size())/(surf_fractal->w - 1);
   8.376 +      k[1] = fractal->get_im_max() - y * 
   8.377 +	    (fractal->get_size())/(surf_fractal->h - 1);
   8.378 +      
   8.379        fractal->set_option("k", k);
   8.380        fractal->set_calc_needed();
   8.381        redraw = true;
   8.382 @@ -535,39 +532,27 @@
   8.383     {
   8.384     if (old_views.size() > 0)
   8.385        {
   8.386 -      view * v = old_views.back();
   8.387 +      View * v = old_views.back();
   8.388        old_views.pop_back();
   8.389  
   8.390 -      if (v->type.compare(fractal->get_fractal_name()) != 0)
   8.391 +      if (v->get_type().compare(fractal->get_fractal_name()) != 0)
   8.392  	 {
   8.393  	 delete fractal;
   8.394 -	 FractalCreator * fractal_creator = get_Fractal_map()[v->type];
   8.395 -	 if (!fractal_creator)
   8.396 +	 FractalFactory * fractal_factory = get_Fractal_map()[v->get_type()];
   8.397 +	 if (!fractal_factory)
   8.398  	    {
   8.399  	    std::cerr << "Cannot restore old view: unknown Fractal type " 
   8.400 -		      << v->type << std::endl;
   8.401 +		      << v->get_type() << std::endl;
   8.402  	    SDL_Event event;
   8.403  	    event.type = SDL_QUIT;
   8.404  	    SDL_PushEvent(&event);
   8.405  	    return;
   8.406  	    }
   8.407 -	 fractal = fractal_creator->create();
   8.408 +	 fractal = fractal_factory->create();
   8.409  	 fractal->init(surf_fractal);
   8.410  	 }
   8.411  
   8.412 -      fractal->set_re_min(v->re_min);
   8.413 -      fractal->set_im_max(v->im_max);
   8.414 -      fractal->set_size(v->size);
   8.415 -      fractal->set_max_iter(v->max_iter);
   8.416 -      fractal->set_calc_needed();
   8.417 -
   8.418 -      std::cerr << "Restored view:" << std::endl
   8.419 -		<< "  type     " << v->type << std::endl
   8.420 -		<< "  re_min   " << v->re_min << std::endl
   8.421 -		<< "  im_max   " << v->im_max << std::endl
   8.422 -		<< "  size     " << v->size << std::endl
   8.423 -		<< "  max_iter " << v->max_iter << std::endl
   8.424 -		<< std::endl;
   8.425 +      fractal->restore_view(v);
   8.426        delete v;
   8.427        }
   8.428     }
   8.429 @@ -576,21 +561,8 @@
   8.430  ////////////////////////////////////////////////////////////////////////////////
   8.431  void App::save_view()
   8.432     {
   8.433 -   view * v = new view;
   8.434 -   v->type = typeid(*fractal).name();
   8.435 -   v->re_min = fractal->get_re_min();
   8.436 -   v->im_max = fractal->get_im_max();
   8.437 -   v->size = fractal->get_size();
   8.438 -   v->max_iter = fractal->get_max_iter();
   8.439 +   View * v = fractal->save_view();
   8.440     old_views.push_back(v);
   8.441 -
   8.442 -   std::cerr << "Saved view:" << std::endl
   8.443 -	     << "  type     " << v->type << std::endl
   8.444 -	     << "  re_min   " << v->re_min << std::endl
   8.445 -	     << "  im_max   " << v->im_max << std::endl
   8.446 -	     << "  size     " << v->size << std::endl
   8.447 -	     << "  max_iter " << v->max_iter << std::endl
   8.448 -	     << std::endl;
   8.449     }
   8.450  
   8.451  
   8.452 @@ -613,7 +585,7 @@
   8.453     {
   8.454     int i = App::get_next_file_num();
   8.455     std::stringstream name;
   8.456 -   name << "mandelbrot-" << std::setw(3) << std::setfill('0') << i << ".bmp";
   8.457 +   name << "fracter-" << std::setw(3) << std::setfill('0') << i << ".bmp";
   8.458  
   8.459     if (SDL_SaveBMP(surf_display, name.str().c_str()) != 0)
   8.460        {
   8.461 @@ -654,7 +626,7 @@
   8.462        WIN32_FIND_DATA ffd;
   8.463        HANDLE hFind = INVALID_HANDLE_VALUE;
   8.464  
   8.465 -      char * file_spec = "mandelbrot-???.bmp";
   8.466 +      char * file_spec = "fracter-???.bmp";
   8.467        hFind = FindFirstFile(file_spec, &ffd);
   8.468        if (hFind != INVALID_HANDLE_VALUE)
   8.469  	 {
   8.470 @@ -667,7 +639,7 @@
   8.471  	    if (ss.str().size() == 18)
   8.472  	       {
   8.473  	       s = ss.str().substr(0, 11);
   8.474 -	       if ( StrCmpI(s.c_str(), "mandelbrot-") == 0 )
   8.475 +	       if ( StrCmpI(s.c_str(), "fracter-") == 0 )
   8.476  		  {
   8.477  		  s = ss.str().substr(14, 4);
   8.478  		  if (StrCmpI(s.c_str(), ".bmp") == 0)
   8.479 @@ -695,11 +667,11 @@
   8.480  
   8.481  int App::scandir_filter(const struct dirent * d)
   8.482     {
   8.483 -   if (memcmp(d->d_name, "mandelbrot-", 11) != 0) return 0;
   8.484 -   if (memcmp(d->d_name+14, ".bmp", 4) != 0) return 0;
   8.485 -   if (isdigit(d->d_name[11]) 
   8.486 -       && isdigit(d->d_name[12]) 
   8.487 -       && isdigit(d->d_name[13])) 
   8.488 +   if (memcmp(d->d_name, "fracter-", 8) != 0) return 0;
   8.489 +   if (memcmp(d->d_name+11, ".bmp", 4) != 0) return 0;
   8.490 +   if (isdigit(d->d_name[8]) 
   8.491 +       && isdigit(d->d_name[9]) 
   8.492 +       && isdigit(d->d_name[10])) 
   8.493        return 1;
   8.494     return 0;
   8.495     }
   8.496 @@ -714,7 +686,7 @@
   8.497        struct dirent ** file_list;
   8.498        int num_files = scandir(".", &file_list, scandir_filter, alphasort);
   8.499        if (num_files != 0)
   8.500 -	 sscanf(file_list[num_files-1]->d_name, "mandelbrot-%03d.bmp", &i);
   8.501 +	 sscanf(file_list[num_files-1]->d_name, "fracter-%03d.bmp", &i);
   8.502        }
   8.503     i++;
   8.504  
     9.1 --- a/src/EventHandler.cpp	Tue Oct 26 02:03:47 2010 -0500
     9.2 +++ b/src/EventHandler.cpp	Fri Nov 12 23:58:48 2010 -0600
     9.3 @@ -1,14 +1,29 @@
     9.4  ////////////////////////////////////////////////////////////////////////////////
     9.5  //
     9.6 -// (C) 2010 Sarah Eris Horsley Caffee
     9.7 +// Fracter - A simple Mandelbrot Set viewer.
     9.8  //
     9.9 -// mandelbrot - A simple Mandelbrot Set viewer.
    9.10 +// Copyright (C) 2010 Sarah Eris Horsley Caffee
    9.11 +//
    9.12 +// This file is part of Fracter.
    9.13 +//
    9.14 +// Fracter is free software: you can redistribute it and/or modify
    9.15 +// it under the terms of the GNU General Public License as published by
    9.16 +// the Free Software Foundation, either version 3 of the License, or
    9.17 +// (at your option) any later version.
    9.18 +//
    9.19 +// This program is distributed in the hope that it will be useful,
    9.20 +// but WITHOUT ANY WARRANTY; without even the implied warranty of
    9.21 +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    9.22 +// GNU General Public License for more details.
    9.23 +//
    9.24 +// You should have received a copy of the GNU General Public License
    9.25 +// along with this program.  If not, see <http://www.gnu.org/licenses/>.
    9.26 +//
    9.27  //
    9.28  // EventHandler.cpp
    9.29  // EventHandler class implementation.
    9.30  //
    9.31  ////////////////////////////////////////////////////////////////////////////////
    9.32 -#include <iostream>
    9.33  
    9.34  #include "EventHandler.h"
    9.35  
    9.36 @@ -19,45 +34,12 @@
    9.37     }
    9.38  
    9.39  
    9.40 -
    9.41  ////////////////////////////////////////////////////////////////////////////////
    9.42  EventHandler::~EventHandler()
    9.43     {
    9.44     }
    9.45  
    9.46  
    9.47 -
    9.48 -////////////////////////////////////////////////////////////////////////////////
    9.49 -// Note: SDL 1.3 adds an official SDL_WaitEventTimeout function.
    9.50 -#ifndef USE_SDL_WAIEVENT
    9.51 -int EventHandler::wait_event_timeout(SDL_Event * event, Uint32 timeout)
    9.52 -   {
    9.53 -   Uint32 end = SDL_GetTicks() + timeout;
    9.54 -   int i;
    9.55 -
    9.56 -   for (;;) 
    9.57 -      {
    9.58 -      SDL_PumpEvents();
    9.59 -      i = SDL_PeepEvents(event, 1, SDL_GETEVENT, SDL_ALLEVENTS);
    9.60 -      switch (i) 
    9.61 -	 {
    9.62 -	 case -1:
    9.63 -	    return 0;
    9.64 -	 case 1:
    9.65 -	    return 1;
    9.66 -	 case 0:
    9.67 -	    if (SDL_GetTicks() >= end)
    9.68 -	       {
    9.69 -	       return 0;
    9.70 -	       }
    9.71 -	    SDL_Delay(10);
    9.72 -	    break;
    9.73 -	 }
    9.74 -      }
    9.75 -   }
    9.76 -#endif
    9.77 -
    9.78 -
    9.79  ////////////////////////////////////////////////////////////////////////////////
    9.80  void EventHandler::on_event(SDL_Event * event)
    9.81     {
    9.82 @@ -88,27 +70,21 @@
    9.83  	    }
    9.84  	 break;
    9.85  	 }
    9.86 +
    9.87        case SDL_KEYDOWN:
    9.88  	 {
    9.89 -	 on_KeyDown(event->key.keysym.sym, event->key.keysym.mod, 
    9.90 -		    event->key.keysym.unicode);
    9.91 +	 on_KeyDown(event->key);
    9.92  	 break;
    9.93  	 }
    9.94        case SDL_KEYUP:
    9.95  	 {
    9.96 -	 on_KeyUp(event->key.keysym.sym, event->key.keysym.mod, 
    9.97 -		    event->key.keysym.unicode);
    9.98 +	 on_KeyUp(event->key);
    9.99  	 break;
   9.100  	 }
   9.101 +
   9.102        case SDL_MOUSEMOTION: 
   9.103  	 {
   9.104 -	 on_MouseMove(event->motion.x,
   9.105 -		      event->motion.y,
   9.106 -		      event->motion.xrel,
   9.107 -		      event->motion.yrel,
   9.108 -		      (event->motion.state & SDL_BUTTON(SDL_BUTTON_LEFT)) !=0,
   9.109 -		      (event->motion.state & SDL_BUTTON(SDL_BUTTON_RIGHT)) !=0,
   9.110 -		      (event->motion.state & SDL_BUTTON(SDL_BUTTON_MIDDLE))!=0);
   9.111 +	 on_MouseMove(event->motion);
   9.112  	 break;
   9.113  	 }
   9.114        case SDL_MOUSEBUTTONDOWN:
   9.115 @@ -117,17 +93,22 @@
   9.116  	    {
   9.117  	    case SDL_BUTTON_LEFT:
   9.118  	       {
   9.119 -	       on_LButtonDown(event->button.x, event->button.y);
   9.120 +	       on_LButtonDown(event->button);
   9.121  	       break;
   9.122  	       }
   9.123  	    case SDL_BUTTON_RIGHT:
   9.124  	       {
   9.125 -	       on_RButtonDown(event->button.x, event->button.y);
   9.126 +	       on_RButtonDown(event->button);
   9.127  	       break;
   9.128  	       }
   9.129  	    case SDL_BUTTON_MIDDLE:
   9.130  	       {
   9.131 -	       on_MButtonDown(event->button.x, event->button.y);
   9.132 +	       on_MButtonDown(event->button);
   9.133 +	       break;
   9.134 +	       }
   9.135 +	    case SDL_BUTTON_WHEELDOWN:
   9.136 +	       {
   9.137 +	       on_MouseWheelDown(event->button);
   9.138  	       break;
   9.139  	       }
   9.140  	    }
   9.141 @@ -139,61 +120,57 @@
   9.142  	    {
   9.143  	    case SDL_BUTTON_LEFT:
   9.144  	       {
   9.145 -	       on_LButtonUp(event->button.x, event->button.y);
   9.146 +	       on_LButtonUp(event->button);
   9.147  	       break;
   9.148  	       }
   9.149  	    case SDL_BUTTON_RIGHT:
   9.150  	       {
   9.151 -	       on_RButtonUp(event->button.x, event->button.y);
   9.152 +	       on_RButtonUp(event->button);
   9.153  	       break;
   9.154  	       }
   9.155  	    case SDL_BUTTON_MIDDLE:
   9.156  	       {
   9.157 -	       on_MButtonUp(event->button.x, event->button.y);
   9.158 +	       on_MButtonUp(event->button);
   9.159 +	       break;
   9.160 +	       }
   9.161 +	    case SDL_BUTTON_WHEELUP:
   9.162 +	       {
   9.163 +	       on_MouseWheelUp(event->button);
   9.164  	       break;
   9.165  	       }
   9.166  	    }
   9.167  	 break;
   9.168  	 }
   9.169 +
   9.170        case SDL_JOYAXISMOTION:
   9.171  	 {
   9.172 -	 on_JoyAxis(event->jaxis.which, event->jaxis.axis, event->jaxis.value);
   9.173 +	 on_JoyAxis(event->jaxis);
   9.174  	 break;
   9.175  	 }
   9.176        case SDL_JOYBALLMOTION:
   9.177  	 {
   9.178 -	 on_JoyBall(event->jball.which, event->jball.ball, 
   9.179 -		    event->jball.xrel, event->jball.yrel);
   9.180 +	 on_JoyBall(event->jball);
   9.181  	 break;
   9.182  	 }
   9.183        case SDL_JOYHATMOTION:
   9.184  	 {
   9.185 -	 on_JoyHat(event->jhat.which, event->jhat.hat, event->jhat.value);
   9.186 +	 on_JoyHat(event->jhat);
   9.187  	 break;
   9.188  	 }
   9.189        case SDL_JOYBUTTONDOWN:
   9.190  	 {
   9.191 -	 on_JoyButtonDown(event->jbutton.which, event->jbutton.button);
   9.192 +	 on_JoyButtonDown(event->jbutton);
   9.193  	 break;
   9.194  	 }
   9.195        case SDL_JOYBUTTONUP:
   9.196  	 {
   9.197 -	 on_JoyButtonUp(event->jbutton.which, event->jbutton.button);
   9.198 +	 on_JoyButtonUp(event->jbutton);
   9.199  	 break;
   9.200  	 }
   9.201 -      case SDL_QUIT:
   9.202 -	 {
   9.203 -	 on_Exit();
   9.204 -	 break;
   9.205 -	 }
   9.206 -      case SDL_SYSWMEVENT:
   9.207 -	 {
   9.208 -	 // Ignore
   9.209 -	 break;
   9.210 -	 }
   9.211 +
   9.212        case SDL_VIDEORESIZE:
   9.213  	 {
   9.214 -	 on_Resize(event->resize.w, event->resize.h);
   9.215 +	 on_Resize(event->resize);
   9.216  	 break;
   9.217  	 }
   9.218        case SDL_VIDEOEXPOSE:
   9.219 @@ -201,10 +178,36 @@
   9.220  	 on_Expose();
   9.221  	 break;
   9.222  	 }
   9.223 +      case SDL_QUIT:
   9.224 +	 {
   9.225 +	 on_Quit();
   9.226 +	 break;
   9.227 +	 }
   9.228 +      case SDL_SYSWMEVENT:
   9.229 +	 {
   9.230 +	 on_SysWM(event->syswm);
   9.231 +	 break;
   9.232 +	 }
   9.233 +
   9.234 +      case SDL_NOEVENT:
   9.235 +      case SDL_EVENT_RESERVEDA:
   9.236 +      case SDL_EVENT_RESERVEDB:
   9.237 +      case SDL_EVENT_RESERVED2:
   9.238 +      case SDL_EVENT_RESERVED3:
   9.239 +      case SDL_EVENT_RESERVED4:
   9.240 +      case SDL_EVENT_RESERVED5:
   9.241 +      case SDL_EVENT_RESERVED6:
   9.242 +      case SDL_EVENT_RESERVED7:
   9.243 +      case SDL_NUMEVENTS:
   9.244 +	 {
   9.245 +	 // Reserved events are silently ignored.
   9.246 +	 break;
   9.247 +	 }
   9.248 +
   9.249        default:
   9.250  	 {
   9.251 -	 on_User(event->user.type, event->user.code, 
   9.252 -		 event->user.data1, event->user.data2);
   9.253 +	 // All other events are user events.
   9.254 +	 on_User(event->user);
   9.255  	 break;
   9.256  	 }
   9.257        }
   9.258 @@ -213,129 +216,125 @@
   9.259  
   9.260  
   9.261  ////////////////////////////////////////////////////////////////////////////////
   9.262 +
   9.263 +// Active events
   9.264 +
   9.265 +void EventHandler::on_MouseFocus()
   9.266 +   {
   9.267 +   }
   9.268 +
   9.269 +void EventHandler::on_MouseBlur()
   9.270 +   {
   9.271 +   }
   9.272 +
   9.273  void EventHandler::on_InputFocus()
   9.274     {
   9.275     }
   9.276  
   9.277 -
   9.278  void EventHandler::on_InputBlur()
   9.279     {
   9.280     }
   9.281  
   9.282 -
   9.283 -void EventHandler::on_KeyDown(SDLKey sym, SDLMod mod, Uint16 unicode)
   9.284 -   {
   9.285 -   }
   9.286 -
   9.287 -
   9.288 -void EventHandler::on_KeyUp(SDLKey sym, SDLMod mod, Uint16 unicode)
   9.289 -   {
   9.290 -   }
   9.291 -
   9.292 -
   9.293 -void EventHandler::on_MouseFocus()
   9.294 -   {
   9.295 -   }
   9.296 -
   9.297 -
   9.298 -void EventHandler::on_MouseBlur()
   9.299 -   {
   9.300 -   }
   9.301 -
   9.302 -void EventHandler::on_MouseMove(int mx, int my, 
   9.303 -			 int relx, int rely, 
   9.304 -			 bool left, bool right, bool middle)
   9.305 -   {
   9.306 -   }
   9.307 -
   9.308 -
   9.309 -void EventHandler::on_MouseWheel(bool up, bool down)
   9.310 -   {
   9.311 -   }
   9.312 -
   9.313 -
   9.314 -void EventHandler::on_LButtonDown(int mx, int my)
   9.315 -   {
   9.316 -   }
   9.317 -
   9.318 -
   9.319 -void EventHandler::on_LButtonUp(int mx, int my)
   9.320 -   {
   9.321 -   }
   9.322 -
   9.323 -
   9.324 -void EventHandler::on_RButtonDown(int mx, int my)
   9.325 -   {
   9.326 -   }
   9.327 -
   9.328 -
   9.329 -void EventHandler::on_RButtonUp(int mx, int my)
   9.330 -   {
   9.331 -   }
   9.332 -
   9.333 -
   9.334 -void EventHandler::on_MButtonDown(int mx, int my)
   9.335 -   {
   9.336 -   }
   9.337 -
   9.338 -
   9.339 -void EventHandler::on_MButtonUp(int mx, int my)
   9.340 -   {
   9.341 -   }
   9.342 -
   9.343 -
   9.344 -void EventHandler::on_JoyAxis(Uint8 ehich, Uint8 axis, Sint16 value)
   9.345 -   {
   9.346 -   }
   9.347 -
   9.348 -
   9.349 -void EventHandler::on_JoyButtonDown(Uint8 which, Uint8 button)
   9.350 -   {
   9.351 -   }
   9.352 -
   9.353 -
   9.354 -void EventHandler::on_JoyButtonUp(Uint8 which, Uint8 button)
   9.355 -   {
   9.356 -   }
   9.357 -
   9.358 -
   9.359 -void EventHandler::on_JoyHat(Uint8 which, Uint8 hat, Uint8 value)
   9.360 -   {
   9.361 -   }
   9.362 -
   9.363 -
   9.364 -void EventHandler::on_JoyBall(Uint8 which, Uint8 ball, Sint16 xrel, Sint16 yrel)
   9.365 -   {
   9.366 -   }
   9.367 -
   9.368 -
   9.369  void EventHandler::on_Minimize()
   9.370     {
   9.371     }
   9.372  
   9.373 -
   9.374  void EventHandler::on_Restore()
   9.375     {
   9.376     }
   9.377  
   9.378  
   9.379 -void EventHandler::on_Resize(int w, int h)
   9.380 +// Keyboard events
   9.381 +
   9.382 +void EventHandler::on_KeyDown(SDL_KeyboardEvent key)
   9.383     {
   9.384     }
   9.385  
   9.386 +void EventHandler::on_KeyUp(SDL_KeyboardEvent key)
   9.387 +   {
   9.388 +   }
   9.389 +
   9.390 +
   9.391 +// Mouse events
   9.392 +
   9.393 +void EventHandler::on_MouseMove(SDL_MouseMotionEvent motion)
   9.394 +   {
   9.395 +   }
   9.396 +
   9.397 +void EventHandler::on_LButtonDown(SDL_MouseButtonEvent button)
   9.398 +   {
   9.399 +   }
   9.400 +
   9.401 +void EventHandler::on_LButtonUp(SDL_MouseButtonEvent button)
   9.402 +   {
   9.403 +   }
   9.404 +
   9.405 +void EventHandler::on_RButtonDown(SDL_MouseButtonEvent button)
   9.406 +   {
   9.407 +   }
   9.408 +
   9.409 +void EventHandler::on_RButtonUp(SDL_MouseButtonEvent button)
   9.410 +   {
   9.411 +   }
   9.412 +
   9.413 +void EventHandler::on_MButtonDown(SDL_MouseButtonEvent button)
   9.414 +   {
   9.415 +   }
   9.416 +
   9.417 +void EventHandler::on_MButtonUp(SDL_MouseButtonEvent button)
   9.418 +   {
   9.419 +   }
   9.420 +
   9.421 +void EventHandler::on_MouseWheelDown(SDL_MouseButtonEvent button)
   9.422 +   {
   9.423 +   }
   9.424 +
   9.425 +void EventHandler::on_MouseWheelUp(SDL_MouseButtonEvent button)
   9.426 +   {
   9.427 +   }
   9.428 +
   9.429 +
   9.430 +// Joystick events
   9.431 +
   9.432 +void EventHandler::on_JoyAxis(SDL_JoyAxisEvent jaxis)
   9.433 +   {
   9.434 +   }
   9.435 +
   9.436 +void EventHandler::on_JoyButtonDown(SDL_JoyButtonEvent jbutton)
   9.437 +   {
   9.438 +   }
   9.439 +
   9.440 +void EventHandler::on_JoyButtonUp(SDL_JoyButtonEvent jbutton)
   9.441 +   {
   9.442 +   }
   9.443 +
   9.444 +void EventHandler::on_JoyHat(SDL_JoyHatEvent jhat)
   9.445 +   {
   9.446 +   }
   9.447 +
   9.448 +void EventHandler::on_JoyBall(SDL_JoyBallEvent jball)
   9.449 +   {
   9.450 +   }
   9.451 +
   9.452 +
   9.453 +// Misc events
   9.454 +
   9.455 +void EventHandler::on_Resize(SDL_ResizeEvent resize)
   9.456 +   {
   9.457 +   }
   9.458  
   9.459  void EventHandler::on_Expose()
   9.460     {
   9.461     }
   9.462  
   9.463 -
   9.464 -void EventHandler::on_Exit()
   9.465 +void EventHandler::on_Quit()
   9.466     {
   9.467     }
   9.468  
   9.469 -
   9.470 -void EventHandler::on_User(Uint8 type, int code, void * data1, void * data2)
   9.471 +void EventHandler::on_User(SDL_UserEvent user)
   9.472     {
   9.473     }
   9.474  
   9.475 -
   9.476 +void EventHandler::on_SysWM(SDL_SysWMEvent syswm)
   9.477 +   {
   9.478 +   }
    10.1 --- a/src/Fractal.cpp	Tue Oct 26 02:03:47 2010 -0500
    10.2 +++ b/src/Fractal.cpp	Fri Nov 12 23:58:48 2010 -0600
    10.3 @@ -1,8 +1,25 @@
    10.4  ////////////////////////////////////////////////////////////////////////////////
    10.5  //
    10.6 -// (C) 2010 Sarah Eris Horsley Caffee
    10.7 +// Fracter - A simple Mandelbrot Set viewer.
    10.8  //
    10.9 -// mandelbrot - A simple Mandelbrot Set viewer.
   10.10 +// Copyright (C) 2010 Sarah Eris Horsley Caffee
   10.11 +//
   10.12 +// This file is part of Fracter.
   10.13 +//
   10.14 +// Fracter is free software: you can redistribute it and/or modify
   10.15 +// it under the terms of the GNU General Public License as published by
   10.16 +// the Free Software Foundation, either version 3 of the License, or
   10.17 +// (at your option) any later version.
   10.18 +//
   10.19 +// This program is distributed in the hope that it will be useful,
   10.20 +// but WITHOUT ANY WARRANTY; without even the implied warranty of
   10.21 +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   10.22 +// GNU General Public License for more details.
   10.23 +//
   10.24 +// You should have received a copy of the GNU General Public License
   10.25 +// along with this program.  If not, see <http://www.gnu.org/licenses/>.
   10.26 +//
   10.27 +//
   10.28  //
   10.29  // Fractal.cpp
   10.30  // Fractal calculator virtual class implementation.  Actual fractals should 
   10.31 @@ -10,12 +27,30 @@
   10.32  //
   10.33  ////////////////////////////////////////////////////////////////////////////////
   10.34  
   10.35 -#include <string>
   10.36 -
   10.37 -#include "SDL.h"
   10.38 -
   10.39  #include "Fractal.h"
   10.40  
   10.41 +////////////////////////////////////////////////////////////////////////////////
   10.42 +View::View(std::string t, 
   10.43 +	   double re, double im, double s, 
   10.44 +	   unsigned int max) :
   10.45 +   type (t),
   10.46 +   re_min (re),
   10.47 +   im_max (im),
   10.48 +   size (s),
   10.49 +   max_iter (max)
   10.50 +   {
   10.51 +   }
   10.52 +
   10.53 +////////////////////////////////////////////////////////////////////////////////
   10.54 +View::~View()
   10.55 +   {
   10.56 +   }
   10.57 +
   10.58 +////////////////////////////////////////////////////////////////////////////////
   10.59 +std::string const & View::get_type() const
   10.60 +   {
   10.61 +   return type;
   10.62 +   }
   10.63  
   10.64  ////////////////////////////////////////////////////////////////////////////////
   10.65  
   10.66 @@ -26,11 +61,34 @@
   10.67     im_max (0),
   10.68     size (0),
   10.69     max_iter (0),
   10.70 -   surface (NULL),
   10.71 -   calc_needed (false)
   10.72 +   calc_needed (false),
   10.73 +   surface (NULL)
   10.74     {
   10.75     }
   10.76  
   10.77 +
   10.78 +////////////////////////////////////////////////////////////////////////////////
   10.79 +Fractal::~Fractal()
   10.80 +   {
   10.81 +   }
   10.82 +
   10.83 +
   10.84 +////////////////////////////////////////////////////////////////////////////////
   10.85 +bool Fractal::init(SDL_Surface * surf)
   10.86 +   {
   10.87 +   if (!surf)
   10.88 +      {
   10.89 +      return false;
   10.90 +      }
   10.91 +   else
   10.92 +      {
   10.93 +      surface = surf;
   10.94 +      }
   10.95 +   calc_needed = true;
   10.96 +   return true;
   10.97 +   }
   10.98 +
   10.99 +
  10.100  ////////////////////////////////////////////////////////////////////////////////
  10.101  double Fractal::get_re_min() const
  10.102     {
  10.103 @@ -73,7 +131,7 @@
  10.104  ////////////////////////////////////////////////////////////////////////////////
  10.105  double Fractal::set_size(const double s)
  10.106     {
  10.107 -   double t;
  10.108 +   double t = size;
  10.109     if (s > 0.0)
  10.110        size = s;
  10.111     else
  10.112 @@ -92,7 +150,7 @@
  10.113  ////////////////////////////////////////////////////////////////////////////////
  10.114  unsigned int Fractal::set_max_iter(const unsigned int iter)
  10.115     {
  10.116 -   unsigned int t;
  10.117 +   unsigned int t = max_iter;
  10.118     if (iter > 0)
  10.119        max_iter = iter;
  10.120     else
  10.121 @@ -104,7 +162,7 @@
  10.122  ////////////////////////////////////////////////////////////////////////////////
  10.123  unsigned int Fractal::inc_max_iter()
  10.124     {
  10.125 -   unsigned int t;
  10.126 +   unsigned int t = max_iter;
  10.127     max_iter++;
  10.128     return t;
  10.129     }
  10.130 @@ -113,7 +171,7 @@
  10.131  ////////////////////////////////////////////////////////////////////////////////
  10.132  unsigned int Fractal::dec_max_iter()
  10.133     {
  10.134 -   unsigned int t;
  10.135 +   unsigned int t = max_iter;
  10.136     if (max_iter > 0)
  10.137        max_iter--;
  10.138     return t;
  10.139 @@ -142,6 +200,36 @@
  10.140  
  10.141  
  10.142  ////////////////////////////////////////////////////////////////////////////////
  10.143 +bool Fractal::get_option(std::string option, void * value) const 
  10.144 +   {
  10.145 +   return false; 
  10.146 +   }
  10.147 +
  10.148 +////////////////////////////////////////////////////////////////////////////////
  10.149 +bool Fractal::set_option(std::string option, void * value) 
  10.150 +   { 
  10.151 +   return false; 
  10.152 +   }
  10.153 +
  10.154 +////////////////////////////////////////////////////////////////////////////////
  10.155 +View * Fractal::save_view()
  10.156 +   {
  10.157 +   return new View(typeid(*this).name(), re_min, im_max, size, max_iter);
  10.158 +   }
  10.159 +
  10.160 +////////////////////////////////////////////////////////////////////////////////
  10.161 +void Fractal::restore_view(View * v)
  10.162 +   {
  10.163 +   fractal_name = v->type;
  10.164 +   re_min = v->re_min;
  10.165 +   im_max = v->im_max;
  10.166 +   size = v->size;
  10.167 +   max_iter = v->max_iter;
  10.168 +   calc_needed = true;
  10.169 +   }
  10.170 +
  10.171 +
  10.172 +////////////////////////////////////////////////////////////////////////////////
  10.173  void Fractal::draw_pixel(int x, int y, Uint32 * color)
  10.174     {
  10.175     static char * data;
  10.176 @@ -156,10 +244,19 @@
  10.177     if (SDL_MUSTLOCK(surface)) SDL_UnlockSurface(surface);
  10.178     }
  10.179  
  10.180 +
  10.181 +////////////////////////////////////////////////////////////////////////////////
  10.182 +FractalFactory::~FractalFactory()
  10.183 +   {
  10.184 +   get_Fractal_map().clear();
  10.185 +   }
  10.186 +
  10.187 +
  10.188  ////////////////////////////////////////////////////////////////////////////////
  10.189  
  10.190 -std::map <std::string, FractalCreator *> & get_Fractal_map()
  10.191 +std::map <std::string, FractalFactory *> & get_Fractal_map()
  10.192     {
  10.193 -   static std::map <std::string, FractalCreator *> the_Fractal_map;
  10.194 +   static std::map <std::string, FractalFactory *> the_Fractal_map;
  10.195     return the_Fractal_map;
  10.196     }
  10.197 +
    11.1 --- a/src/Julia.cpp	Tue Oct 26 02:03:47 2010 -0500
    11.2 +++ b/src/Julia.cpp	Fri Nov 12 23:58:48 2010 -0600
    11.3 @@ -1,21 +1,49 @@
    11.4  ////////////////////////////////////////////////////////////////////////////////
    11.5  //
    11.6 -// (C) 2010 Sarah Eris Horsley Caffee
    11.7 +// Fracter - A simple Mandelbrot Set viewer.
    11.8  //
    11.9 -// mandelbrot - A simple Mandelbrot Set viewer.
   11.10 +// Copyright (C) 2010 Sarah Eris Horsley Caffee
   11.11 +//
   11.12 +// This file is part of Fracter.
   11.13 +//
   11.14 +// Fracter is free software: you can redistribute it and/or modify
   11.15 +// it under the terms of the GNU General Public License as published by
   11.16 +// the Free Software Foundation, either version 3 of the License, or
   11.17 +// (at your option) any later version.
   11.18 +//
   11.19 +// This program is distributed in the hope that it will be useful,
   11.20 +// but WITHOUT ANY WARRANTY; without even the implied warranty of
   11.21 +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   11.22 +// GNU General Public License for more details.
   11.23 +//
   11.24 +// You should have received a copy of the GNU General Public License
   11.25 +// along with this program.  If not, see <http://www.gnu.org/licenses/>.
   11.26 +//
   11.27  //
   11.28  // Julia.cpp
   11.29  // Julia set calculator class implementation
   11.30  //
   11.31  ////////////////////////////////////////////////////////////////////////////////
   11.32  
   11.33 -#include <string>
   11.34 +#include <cmath>
   11.35  #include <sstream>
   11.36 +#include <typeinfo>
   11.37  
   11.38  #include "Julia.h"
   11.39  
   11.40  
   11.41  ////////////////////////////////////////////////////////////////////////////////
   11.42 +ViewJulia::ViewJulia(std::string t, 
   11.43 +		     double re, double im, double s, 
   11.44 +		     unsigned int max,
   11.45 +		     double kr, double ki) : 
   11.46 +   View(t, re, im, s, max),
   11.47 +   k_re (kr),
   11.48 +   k_im (ki)
   11.49 +   {
   11.50 +   }
   11.51 +
   11.52 +////////////////////////////////////////////////////////////////////////////////
   11.53  
   11.54  Julia::Julia() :
   11.55     k_re (-0.565072),
   11.56 @@ -26,8 +54,8 @@
   11.57     size = 4.0;
   11.58     max_iter = 50;
   11.59     calc_needed = true;
   11.60 +   fractal_name = "Julia set";
   11.61     set_display_name();
   11.62 -   fractal_name = "Julia set";
   11.63     }
   11.64  
   11.65  
   11.66 @@ -37,7 +65,7 @@
   11.67     {
   11.68     if (!surface) return false;
   11.69  
   11.70 -   // Code from http://warp.povusers.org/Julia/
   11.71 +   // See http://warp.povusers.org/Julia/ for explanation of algorithm.
   11.72  
   11.73     if (calc_needed)
   11.74        {
   11.75 @@ -51,7 +79,7 @@
   11.76        int halfway = max_iter/2 - 1;
   11.77        float step = (float) 255 / halfway;
   11.78  
   11.79 -      unsigned x, y, n;
   11.80 +      int x, y, n;
   11.81  
   11.82        for(y = 0; y < surface->h; ++y)
   11.83  	 {
   11.84 @@ -62,7 +90,7 @@
   11.85  
   11.86  	    double z_re = c_re, z_im = c_im;
   11.87  	    bool in_set = true;
   11.88 -	    for(n = 0; n < max_iter; ++n)
   11.89 +	    for(n = 0; n < (int) max_iter; ++n)
   11.90  	       {
   11.91  	       double z_re2 = z_re * z_re, z_im2 = z_im * z_im;
   11.92  	       if(z_re2 + z_im2 > 4)
   11.93 @@ -102,22 +130,6 @@
   11.94  
   11.95  
   11.96  ////////////////////////////////////////////////////////////////////////////////
   11.97 -bool Julia::init(SDL_Surface * surf)
   11.98 -   {
   11.99 -   if (!surf)
  11.100 -      {
  11.101 -      return false;
  11.102 -      }
  11.103 -   else
  11.104 -      {
  11.105 -      surface = surf;
  11.106 -      }
  11.107 -   calc_needed = true;
  11.108 -   return true;
  11.109 -   }
  11.110 -
  11.111 -
  11.112 -////////////////////////////////////////////////////////////////////////////////
  11.113  bool Julia::get_option(std::string option, void * value) const
  11.114     {
  11.115     if (option.compare("k") == 0)
  11.116 @@ -148,30 +160,31 @@
  11.117        return false;
  11.118        }
  11.119  
  11.120 -
  11.121     return true;
  11.122     }
  11.123  
  11.124  
  11.125  ////////////////////////////////////////////////////////////////////////////////
  11.126 -std::string const & Julia::get_fractal_name() const
  11.127 +ViewJulia * Julia::save_view()
  11.128     {
  11.129 -   return fractal_name;
  11.130 +   return new ViewJulia(typeid(*this).name(), re_min, im_max, size, max_iter, 
  11.131 +			k_re, k_im);
  11.132     }
  11.133  
  11.134 -
  11.135  ////////////////////////////////////////////////////////////////////////////////
  11.136 -
  11.137 -void Julia::draw_pixel(int x, int y, Uint32 * color)
  11.138 +void Julia::restore_view(View * v)
  11.139     {
  11.140 -   Fractal::draw_pixel(x, y, color);
  11.141 +   Fractal::restore_view(v);
  11.142 +   k_re = static_cast<ViewJulia *>(v)->k_re;
  11.143 +   k_im = static_cast<ViewJulia *>(v)->k_im;
  11.144 +   set_display_name();
  11.145     }
  11.146  
  11.147 -
  11.148  ////////////////////////////////////////////////////////////////////////////////
  11.149  void Julia::set_display_name()
  11.150     {
  11.151     std::stringstream ss;
  11.152 -   ss << "Julia set K = (" << k_re << "," << k_im << ")";
  11.153 +   ss << display_name << " K = (" << k_re << "," << k_im << ")";
  11.154     display_name = ss.str();
  11.155     }
  11.156 +
    12.1 --- a/src/Mandelbrot.cpp	Tue Oct 26 02:03:47 2010 -0500
    12.2 +++ b/src/Mandelbrot.cpp	Fri Nov 12 23:58:48 2010 -0600
    12.3 @@ -1,18 +1,40 @@
    12.4  ////////////////////////////////////////////////////////////////////////////////
    12.5  //
    12.6 -// (C) 2010 Sarah Eris Horsley Caffee
    12.7 +// Fracter - A simple Mandelbrot Set viewer.
    12.8  //
    12.9 -// mandelbrot - A simple Mandelbrot Set viewer.
   12.10 +// Copyright (C) 2010 Sarah Eris Horsley Caffee
   12.11 +//
   12.12 +// This file is part of Fracter.
   12.13 +//
   12.14 +// Fracter is free software: you can redistribute it and/or modify
   12.15 +// it under the terms of the GNU General Public License as published by
   12.16 +// the Free Software Foundation, either version 3 of the License, or
   12.17 +// (at your option) any later version.
   12.18 +//
   12.19 +// This program is distributed in the hope that it will be useful,
   12.20 +// but WITHOUT ANY WARRANTY; without even the implied warranty of
   12.21 +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   12.22 +// GNU General Public License for more details.
   12.23 +//
   12.24 +// You should have received a copy of the GNU General Public License
   12.25 +// along with this program.  If not, see <http://www.gnu.org/licenses/>.
   12.26 +//
   12.27  //
   12.28  // Mandelbrot.cpp
   12.29  // Mandelbrot set calculator class implementation
   12.30  //
   12.31  ////////////////////////////////////////////////////////////////////////////////
   12.32  
   12.33 -#include <string>
   12.34 +#include "Mandelbrot.h"
   12.35 +#include <typeinfo>
   12.36  
   12.37 -#include "Mandelbrot.h"
   12.38 -
   12.39 +////////////////////////////////////////////////////////////////////////////////
   12.40 +ViewMandelbrot::ViewMandelbrot(std::string t, 
   12.41 +			       double re, double im, double s, 
   12.42 +			       unsigned int max) : 
   12.43 +   View(t, re, im, s, max)
   12.44 +   {
   12.45 +   }
   12.46  
   12.47  ////////////////////////////////////////////////////////////////////////////////
   12.48  
   12.49 @@ -23,24 +45,8 @@
   12.50     size = 5.0;
   12.51     max_iter = 50;
   12.52     calc_needed = true;
   12.53 -   display_name = "Mandelbrot set";
   12.54     fractal_name = "Mandelbrot set";
   12.55 -   }
   12.56 -
   12.57 -
   12.58 -////////////////////////////////////////////////////////////////////////////////
   12.59 -bool Mandelbrot::init(SDL_Surface * surf)
   12.60 -   {
   12.61 -   if (!surf)
   12.62 -      {
   12.63 -      return false;
   12.64 -      }
   12.65 -   else
   12.66 -      {
   12.67 -      surface = surf;
   12.68 -      }
   12.69 -   calc_needed = true;
   12.70 -   return true;
   12.71 +   display_name = fractal_name;
   12.72     }
   12.73  
   12.74  
   12.75 @@ -50,7 +56,7 @@
   12.76     {
   12.77     if (!surface) return false;
   12.78  
   12.79 -   // Code from http://warp.povusers.org/Mandelbrot/
   12.80 +   // See http://warp.povusers.org/Mandelbrot/ for explanation of the algorithm.
   12.81  
   12.82     if (calc_needed)
   12.83        {
   12.84 @@ -64,7 +70,7 @@
   12.85        int halfway = max_iter/2 - 1;
   12.86        float step = (float) 255 / halfway;
   12.87  
   12.88 -      unsigned x, y, n;
   12.89 +      int x, y, n;
   12.90  
   12.91        for(y = 0; y < surface->h; ++y)
   12.92  	 {
   12.93 @@ -75,7 +81,7 @@
   12.94  
   12.95  	    double z_re = c_re, z_im = c_im;
   12.96  	    bool in_set = true;
   12.97 -	    for(n=0; n < max_iter; ++n)
   12.98 +	    for(n=0; n < (int) max_iter; ++n)
   12.99  	       {
  12.100  	       double z_re2 = z_re * z_re, z_im2 = z_im * z_im;
  12.101  	       if(z_re2 + z_im2 > 4)
  12.102 @@ -115,17 +121,15 @@
  12.103  
  12.104  
  12.105  ////////////////////////////////////////////////////////////////////////////////
  12.106 -std::string const & Mandelbrot::get_fractal_name() const
  12.107 +ViewMandelbrot * Mandelbrot::save_view()
  12.108     {
  12.109 -   return fractal_name;
  12.110 +   return new ViewMandelbrot(typeid(*this).name(), re_min, im_max, size, 
  12.111 +			     max_iter);
  12.112     }
  12.113  
  12.114 -
  12.115  ////////////////////////////////////////////////////////////////////////////////
  12.116 -
  12.117 -void Mandelbrot::draw_pixel(int x, int y, Uint32 * color)
  12.118 +void Mandelbrot::restore_view(View * v)
  12.119     {
  12.120 -   Fractal::draw_pixel(x, y, color);
  12.121 +   Fractal::restore_view(v);
  12.122     }
  12.123  
  12.124 -
    13.1 --- a/src/Options.cpp	Tue Oct 26 02:03:47 2010 -0500
    13.2 +++ b/src/Options.cpp	Fri Nov 12 23:58:48 2010 -0600
    13.3 @@ -1,10 +1,26 @@
    13.4  ////////////////////////////////////////////////////////////////////////////////
    13.5  //
    13.6 -// (C) 2010 Sarah Eris Horsley Caffee
    13.7 +// Fracter - A simple Mandelbrot Set viewer.
    13.8  //
    13.9 -// mandelbrot - A simple Mandelbrot Set viewer.
   13.10 +// Copyright (C) 2010 Sarah Eris Horsley Caffee
   13.11  //
   13.12 -// options.cpp
   13.13 +// This file is part of Fracter.
   13.14 +//
   13.15 +// Fracter is free software: you can redistribute it and/or modify
   13.16 +// it under the terms of the GNU General Public License as published by
   13.17 +// the Free Software Foundation, either version 3 of the License, or
   13.18 +// (at your option) any later version.
   13.19 +//
   13.20 +// This program is distributed in the hope that it will be useful,
   13.21 +// but WITHOUT ANY WARRANTY; without even the implied warranty of
   13.22 +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   13.23 +// GNU General Public License for more details.
   13.24 +//
   13.25 +// You should have received a copy of the GNU General Public License
   13.26 +// along with this program.  If not, see <http://www.gnu.org/licenses/>.
   13.27 +//
   13.28 +//
   13.29 +// Options.cpp
   13.30  // global variables and definitions
   13.31  //
   13.32  ////////////////////////////////////////////////////////////////////////////////
    14.1 --- a/src/main.cpp	Tue Oct 26 02:03:47 2010 -0500
    14.2 +++ b/src/main.cpp	Fri Nov 12 23:58:48 2010 -0600
    14.3 @@ -1,11 +1,23 @@
    14.4  ////////////////////////////////////////////////////////////////////////////////
    14.5  //
    14.6 -// (C) 2010 Sarah Eris Horsley Caffee
    14.7 +// Fracter - A simple Mandelbrot Set viewer.
    14.8  //
    14.9 -// mandelbrot
   14.10 +// Copyright (C) 2010 Sarah Eris Horsley Caffee
   14.11  //
   14.12 -// A simple Mandelbrot Set viewer.   Written in honor of Benoit Mandelbrot,
   14.13 -// who died two days ago on Oct 14, 2010.
   14.14 +// This file is part of Fracter.
   14.15 +//
   14.16 +// Fracter is free software: you can redistribute it and/or modify
   14.17 +// it under the terms of the GNU General Public License as published by
   14.18 +// the Free Software Foundation, either version 3 of the License, or
   14.19 +// (at your option) any later version.
   14.20 +//
   14.21 +// This program is distributed in the hope that it will be useful,
   14.22 +// but WITHOUT ANY WARRANTY; without even the implied warranty of
   14.23 +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   14.24 +// GNU General Public License for more details.
   14.25 +//
   14.26 +// You should have received a copy of the GNU General Public License
   14.27 +// along with this program.  If not, see <http://www.gnu.org/licenses/>.
   14.28  //
   14.29  // main.cpp
   14.30  //
   14.31 @@ -22,6 +34,9 @@
   14.32     {
   14.33     int retval = 0;
   14.34  
   14.35 +   std::cout << "Copyright (C) 2010 Sarah Eris Horsley Caffee" << std::endl
   14.36 +	     << "This program comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to redistribute it under certain conditions. It is licensed under the GNU GPL v3. For details see the COPYING file that you should have received along with this program, or see http://www.gnu.org/licenses/gpl-3.0.html" << std::endl << std::endl;;
   14.37 +
   14.38     try
   14.39        {
   14.40        App the_app;