Back to index

texmacs  1.0.7.15
grid.hpp
Go to the documentation of this file.
00001 
00002 /******************************************************************************
00003 * MODULE     : grid.hpp
00004 * DESCRIPTION: grids for the graphics
00005 * COPYRIGHT  : (C) 2003  Henri Lesourd
00006 *******************************************************************************
00007 * This software falls under the GNU general public license version 3 or later.
00008 * It comes WITHOUT ANY WARRANTY WHATSOEVER. For details, see the file LICENSE
00009 * in the root directory or <http://www.gnu.org/licenses/gpl-3.0.html>.
00010 ******************************************************************************/
00011 
00012 #ifndef GRID_H
00013 #define GRID_H
00014 #include "frame.hpp"
00015 #include "curve.hpp"
00016 #include "renderer.hpp"
00017 
00018 class grid_curve_rep: public concrete_struct {
00019 public:
00020   string col;
00021   curve c;
00022   inline grid_curve_rep () {}
00023   inline grid_curve_rep (string col2, curve c2):
00024     col(col2), c(c2) {}
00025 };
00026 
00027 class grid_curve {
00028   CONCRETE_NULL(grid_curve);
00029   inline grid_curve (string col, curve c):
00030     rep (tm_new<grid_curve_rep> (col, c)) {}
00031 };
00032 CONCRETE_NULL_CODE(grid_curve);
00033 
00034 class grid_rep: public abstract_struct {
00035 protected:
00036   array<SI> subd;
00037   array<string> col;
00038   point center;
00039 public:
00040   inline grid_rep () {}
00041   inline grid_rep (array<SI> subd2, array<string> col2, point o):
00042     subd(subd2), col(col2), center(o) {}
00043   inline virtual ~grid_rep () {}
00044 
00045   virtual void set_aspect (tree aspect);
00046 
00047   virtual operator tree () = 0;
00048   virtual array<grid_curve> get_curves (
00049     point lim1, point lim2, bool b= false) = 0;
00050   virtual array<grid_curve> get_curves_around (
00051     point p, double delta, frame f);
00052   virtual point find_closest_point (point p, point pmin, point pmax) = 0;
00053   virtual point find_point_around (point p, double delta, frame f);
00054 };
00055 
00056 class grid {
00057   ABSTRACT_NULL(grid);
00058   operator tree () { return (tree)*rep; }
00059 };
00060 ABSTRACT_NULL_CODE(grid);
00061 
00062 grid empty_grid();
00063 grid cartesian (array<SI> subd, array<string> col, point o, double step);
00064 grid polar (array<SI> subd, array<string> col, point o, double step, SI astep);
00065 grid logarithmic (array<SI> subd, array<string> col, point o,
00066                 double step, SI base);
00067 
00068 grid as_grid (tree t);
00069 tree as_tree (grid g);
00070 
00071 inline bool operator == (grid g1, grid g2) {
00072   return as_tree (g1) == as_tree(g2); }
00073 inline bool operator != (grid g1, grid g2) {
00074   return as_tree (g1) != as_tree(g2); }
00075 
00076 #endif // defined GRID_H