Logo Search packages:      
Sourcecode: gaia version File versions  Download package

void GridLayer::Overdraw ( Region rgn  )  [virtual]

Render layer data as region

Parameters:
rgn region to render
This function is similar to MasterLayer::RenderRegion, and is called when slave layer has OVERDRAW capability set.

Reimplemented from SlaveLayer.

Definition at line 31 of file GridLayer.cc.

References Region::proj_length(), Region::v, Region::w, Vector3< T >::x, Vector2< T >::x, Vector3< T >::y, Vector2< T >::y, and Vector3< T >::z.

                                    {
      double xstep = min2(GetGridStep(rgn->w[1].x - rgn->w[0].x, rgn->proj_length(0,1)), GetGridStep(rgn->w[1].x - rgn->w[0].x, rgn->proj_length(2,3)));
      double ystep = min2(GetGridStep(rgn->w[1].y - rgn->w[0].y, rgn->proj_length(1,2)), GetGridStep(rgn->w[1].y - rgn->w[0].y, rgn->proj_length(3,0)));

      int i;

      int left = (int)((rgn->w[0].x + 0.5) / xstep + 1.0 - EPSILON);
      int right = (int)((rgn->w[1].x + 0.5) / xstep + EPSILON);

      int bottom = (int)((rgn->w[0].y + 0.5) / ystep + 1.0 - EPSILON);
      int top = (int)((rgn->w[1].y + 0.5) / ystep + EPSILON);

      glBegin(GL_LINES);
      glColor3f(1.0, 1.0, 0.0);
      for (i = left; i <= right; i++) {
            double x = (double)i * xstep - 0.5;
            double k = (x - rgn->w[0].x)/(rgn->w[1].x - rgn->w[0].x);

            Vector3d point0 = rgn->v[0] * (1.0 - k) + rgn->v[1] * k;
            Vector3d point1 = rgn->v[3] * (1.0 - k) + rgn->v[2] * k;

            glVertex3d(point0.x, point0.y, point0.z);
            glVertex3d(point1.x, point1.y, point1.z);
      }
      for (i = bottom; i <= top; i++) {
            double y = (double)i * ystep - 0.5;
            double k = (y - rgn->w[0].y)/(rgn->w[1].y - rgn->w[0].y);

            Vector3d point0 = rgn->v[0] * (1.0 - k) + rgn->v[3] * k;
            Vector3d point1 = rgn->v[1] * (1.0 - k) + rgn->v[2] * k;

            glVertex3d(point0.x, point0.y, point0.z);
            glVertex3d(point1.x, point1.y, point1.z);
      }
      glEnd();
}


Generated by  Doxygen 1.6.0   Back to index