Esempio n. 1
0
//----------------------------------------------------------------------------------------
// Check ok to move
//----------------------------------------------------------------------------------------
void Camera::CheckCamera()
{
	if (MoveFBOK()) MoveFB();
	if (MoveLROK()) MoveLR();
	if (MoveUDOK()) MoveUD();
	if (RotateLROK()) RotateLR();
	if (LookUDOK()) LookUD();
}
Esempio n. 2
0
void do_SetRegion(struct work_item *p) {
  double new_xstep;
  double new_ystep;
  new_x_left   = p->u.set_region.new_x_left;
  new_y_top    = p->u.set_region.new_y_top;
  new_x_right  = p->u.set_region.new_x_right;
  new_y_bottom = p->u.set_region.new_y_bottom;

  new_xstep = (new_x_right - new_x_left) / canvas_width;
  new_ystep = (new_y_bottom - new_y_top) / canvas_width;

  if (new_x_left == x_left && new_x_right == x_right) {
    if (new_y_top == y_top && new_y_bottom == y_bottom) {
      /* No change */
    } else if (new_ystep == ystep) {
      /* Vertical pan */
      /* Note that ystep is negative */
      MoveUD(-(new_y_top - y_top) / ystep);
      y_top = new_y_top;
      y_bottom = new_y_bottom;
    } else {
      /* Vertical zoom (and possibly pan) */
      y_top = new_y_top;
      y_bottom = new_y_bottom;
      ystep = new_ystep;
      Compute(0, canvas_width, x_left,
              0, canvas_width, y_top,
              (int) canvas_width, pixmap);
    }
  } else if (new_y_top == y_top && new_y_bottom == y_bottom) {
    if (new_x_left == x_left && new_x_right == x_right) {
      /* No change */
    } else if (new_xstep == xstep) {
      /* Horizontal pan */
      MoveLR((new_x_right - x_right) / xstep);
      x_left = new_x_left;
      x_right = new_x_right;
    } else {
      /* Horizontal zoom (and possibly pan) */
      x_left = new_x_left;
      x_right = new_x_right;
      xstep = new_xstep;
      Compute(0, canvas_width, x_left,
              0, canvas_width, y_top,
              (int) canvas_width, pixmap);
    }
  } else if (FPEQUAL((x_right - x_left) / (y_top - y_bottom),
                     (new_x_right - new_x_left) / (new_y_top - new_y_bottom)) &&
             ((x_right - x_left) / (y_top - y_bottom) >=
              (new_x_right - new_x_left) / (new_y_top - new_y_bottom))) {
    /* Uniform zoom. */
    BuildMask(canvas_width, pixmap, mask);
    x_left = new_x_left;
    y_top = new_y_top;
    x_right = new_x_right;
    y_bottom = new_y_bottom;
    xstep = new_xstep;
    ystep = new_ystep;
    Compute(0, canvas_width, x_left,
            0, canvas_width, y_top,
            (int) canvas_width, pixmap);
  } else {
    /* General move. */
    x_left = new_x_left;
    y_top = new_y_top;
    x_right = new_x_right;
    y_bottom = new_y_bottom;
    xstep = new_xstep;
    ystep = new_ystep;
    Compute(0, canvas_width, x_left,
            0, canvas_width, y_top,
            (int) canvas_width, pixmap);
  }
}