Back to index

texmacs  1.0.7.15
Public Member Functions | Public Attributes | Protected Attributes
cartesian_rep Struct Reference
Inheritance diagram for cartesian_rep:
Inheritance graph
[legend]
Collaboration diagram for cartesian_rep:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 cartesian_rep (array< SI > subd, array< string > col, point o, double st)
 operator tree ()
array< grid_curveget_curves (point lim1, point lim2, bool b)
array< grid_curveget_curves_around (point p, double delta, frame f)
point find_closest_point (point p, point pmin, point pmax)
virtual void set_aspect (tree aspect)
virtual point find_point_around (point p, double delta, frame f)

Public Attributes

double step
int ref_count

Protected Attributes

array< SIsubd
array< stringcol
point center

Detailed Description

Definition at line 117 of file grid.cpp.


Constructor & Destructor Documentation

cartesian_rep::cartesian_rep ( array< SI subd,
array< string col,
point  o,
double  st 
) [inline]

Definition at line 119 of file grid.cpp.

                                                                       :
    grid_rep (subd, col, o), step (st) {}

Member Function Documentation

point cartesian_rep::find_closest_point ( point  p,
point  pmin,
point  pmax 
) [virtual]

Implements grid_rep.

Definition at line 221 of file grid.cpp.

                                                                  {
  double x, y, oldx=0, oldy= 0, ssubd;
  point res= p;
  p= p-center;
  int i;
  for (i=1; i<N(subd); i++) {
    ssubd= ((double) subd[i]) / step;
    if (ssubd==0) continue;
    x= nearest (p[0]*ssubd);
    y= nearest (p[1]*ssubd);
    res= center + point (x/ssubd, y/ssubd);
    if (i!=1) {
      if (inside_rectangle (point (oldx, res[1]), pmin, pmax))
        return point (oldx, res[1]);
      if (inside_rectangle (point (res[0], oldy), pmin, pmax))
        return point (res[0], oldy);
    }
    oldx= res[0];
    oldy= res[1];
    if (inside_rectangle (res, pmin, pmax))
      return res;
  }
  return res;
}

Here is the call graph for this function:

point grid_rep::find_point_around ( point  p,
double  delta,
frame  f 
) [virtual, inherited]

Definition at line 76 of file grid.cpp.

                                                           {
  point p2= f (p);
  point pmin, pmax;
  pmin= f[point (p2[0]-delta, p2[1]-delta)];
  pmax= f[point (p2[0]+delta, p2[1]+delta)];
  return find_closest_point (p, pmin, pmax);
}

Here is the call graph for this function:

array< grid_curve > cartesian_rep::get_curves ( point  lim1,
point  lim2,
bool  b 
) [virtual]

Implements grid_rep.

Definition at line 138 of file grid.cpp.

                                                         {
  array<grid_curve> res;
  if (N(subd)<1) return res;
  double x1= min (lim1[0], lim2[0]);
  double y1= min (lim1[1], lim2[1]);
  double x2= max (lim1[0], lim2[0]);
  double y2= max (lim1[1], lim2[1]);
  double xo= center[0];
  double yo= center[1];
  int i;
  for (i= N(subd)-1; i>=1; i--) {
     SI nsub;
     nsub= subd[i];
     if (nsub!=0) {
       double x, y, s;
       s= max (step/nsub, 1.0e-6);
       for (x= xo; x<=x2; x+=s)
         if (x>=x1) {
           res << create_line (x, y1, x, y2, col[i]);
           if (b) break;
         }
       for (x= xo-s; x>=x1; x-=s)
         if (x<=x2) {
           res << create_line (x, y1, x, y2, col[i]);
           if (b) break;
         }
       for (y= yo; y<=y2; y+=s)
         if (y>=y1) {
           res << create_line (x1, y, x2, y, col[i]);
           if (b) break;
         }
       for (y= yo-s; y>=y1; y-=s)
         if (y<=y2) {
           res << create_line (x1, y, x2, y, col[i]);
           if (b) break;
         }
     }
  }
  if (!b && yo>=y1 && yo<=y2)
    res << create_line (x1, yo, x2, yo, col[0]);
  if (!b && xo>=x1 && xo<=x2)
    res << create_line (xo, y1, xo, y2, col[0]);
  return res;
}

Here is the call graph for this function:

array< grid_curve > cartesian_rep::get_curves_around ( point  p,
double  delta,
frame  f 
) [virtual]

Reimplemented from grid_rep.

Definition at line 184 of file grid.cpp.

                                                                {
  double nsub= 0;
  string c;
  for (int i=0; i<N(subd); i++)
    if (subd[i] != 0) { nsub= subd[i]; c= col[i]; }
  if (nsub == 0) return array<grid_curve> (0);

  point p2  = f (p);
  point lim1= f[point (p2[0]-delta, p2[1]-delta)];
  point lim2= f[point (p2[0]+delta, p2[1]+delta)];
 
  double x1= min (lim1[0], lim2[0]);
  double y1= min (lim1[1], lim2[1]);
  double x2= max (lim1[0], lim2[0]);
  double y2= max (lim1[1], lim2[1]);
  double xo= center[0];
  double yo= center[1];
  double s = step / nsub;

  double X1= xo + floor ((p[0] - xo) / s) * s;
  double Y1= yo + floor ((p[1] - yo) / s) * s;
  double X2= xo + ceil  ((p[0] - xo) / s) * s;
  double Y2= yo + ceil  ((p[1] - yo) / s) * s;
  x1= min (x1, X1 - s / 10);
  y1= min (y1, Y1 - s / 10);
  x2= max (x2, X2 + s / 10);
  y2= max (y2, Y2 + s / 10);

  array<grid_curve> res;
  res << create_line (X1, y1, X1, y2, c);
  res << create_line (x1, Y1, x2, Y1, c);
  if (X2 > X1) res << create_line (X2, y1, X2, y2, c);
  if (Y2 > Y1) res << create_line (x1, Y2, x2, Y2, c);
  return res;
}

Here is the call graph for this function:

cartesian_rep::operator tree ( ) [inline, virtual]

Implements grid_rep.

Definition at line 121 of file grid.cpp.

{ return "cartesian"; }
void grid_rep::set_aspect ( tree  aspect) [virtual, inherited]

Definition at line 21 of file grid.cpp.

                                 {
  subd= array<SI> (2);
  subd[0]= 0;
  subd[1]= 1;
  col= array<string> (2);
  col[0]= "#808080";
  col[1]= "#c0c0c0";
  if (is_tuple (aspect)) {
    int i;
    bool b= false;
    subd= array<SI> (N(aspect));
    col= array<string> (N(aspect));
    for (i=0; i<N(aspect); i++) {
       if (is_tuple (aspect[i], "axes", 1)) {
         subd[i]= 0;
         b= true;
       }
       else {
         subd[i]= as_int (aspect[i][0]);
       }
       col[i]= as_string (aspect[i][1]);
    }
    if (!b) {
      array<SI> subd0 (1);
      array<string> col0 (1);
      subd0[0]= 0;
      col0[0]= "#e0e0ff";
      subd= subd0 << subd;
      col= col0 << col;
    }
    do {
      b= true;
      for (i=1; i<N(subd); i++)
         if (subd[i-1]>subd[i]) {
           SI j;
           string c;
           j= subd[i-1];subd[i-1]= subd[i];subd[i]= j;
           c= col[i-1];col[i-1]= col[i];col[i]= c;
           b= false;
         }
    }
    while (!b);
  }
}

Here is the call graph for this function:


Member Data Documentation

point grid_rep::center [protected, inherited]

Definition at line 38 of file grid.hpp.

array<string> grid_rep::col [protected, inherited]

Definition at line 37 of file grid.hpp.

int abstract_struct::ref_count [inherited]

Definition at line 142 of file basic.hpp.

Definition at line 118 of file grid.cpp.

array<SI> grid_rep::subd [protected, inherited]

Definition at line 36 of file grid.hpp.


The documentation for this struct was generated from the following file: