Example #1
0
int
Cam_int::zoom2(
   CEvent &e,
   State *&
   )
{
   if (debug_fsa)
      cerr << "Cam_int::zoom2"
           << endl;

   DEVice_2d  *ptr =  (DEVice_2d *)e._d;
   CAMptr      cam    (e.view()->cam());
   PIXEL       curpt  (ptr->cur());
   XYpt        startpt(_start_pix);
   int w,h;    e.view()->get_size(w,h);

   double zoom_factor =  1 + Sign(ptr->delta()[0]) * 
      (PIXEL(ptr->cur())-PIXEL(ptr->old())).length()/(w/4);

   cam->set_zoom(cam->zoom() * zoom_factor);
   cam->set_min (cam->min() + NDCvec(XYpt(_start_pix) - startpt));

   ptr->set_cur(curpt);
   cam->data()->changed();
   
   return 0;
}
Example #2
0
int 
Cam_int_edit::choose(
   CEvent &e,
   State *&s
   )
{
   DEVice_2d *ptr =(DEVice_2d *)e._d;
   PIXEL      te   (ptr->cur());
   XYvec      delta(ptr->delta());
   double     tdelt(the_time() - _dtime);
   
   _dist += sqrt(delta * delta);

   VEXEL sdelt(te - _start_pix);

   int xa=0,ya=1;
   if (Config::get_var_bool("FLIP_CAM_MANIP",false,true))
      swap(xa,ya);
     
   if (fabs(sdelt[ya])/sdelt.length() > 0.9 && tdelt > 0.05) {
      s = &_cam_zoom;
      ptr->set_old(_start_pix);
   } else if (tdelt < 0.1 && _dist < 0.03)
      return 0;
   else {
      if (fabs(sdelt[xa])/sdelt.length() > 0.6 )
         s = &_cam_pan;
      else s = &_cam_zoom;
      ptr->set_old(_start_pix);
   }
   /* if we got this far, we actually have a valid choice, so save the camera */   VIEWptr         view(e.view());
   view->save_cam();

   return 0;
}