コード例 #1
0
ファイル: inflate.C プロジェクト: ArnaudGastinel/jot-lib
int
INFLATE::tap_cb(CGESTUREptr& gest, DrawState*& state)
{
   err_adv(debug, "INFLATE::tap_cb");

   // Tracks if the tap was near a guideline
   bool near_guidelines = false;

   PIXEL pdummy;
   int idummy;
   if ( PIXEL_list(_lines).closest( PIXEL(gest->start()), pdummy, idummy ) < 5 )
      near_guidelines = true;

   // Check if gesture hits a BFace
   Bface* face = 0;
   Bsurface::hit_ctrl_surface(gest->start(), 1, &face);

   // Fail if Gesture missed guidelines and geometry
   if ( !face && !near_guidelines )
      return cancel_cb(gest,state);

   // Check that we are trying to inflate
   if ( _orig_face ) {

      // Find the reachable faces from the starting point
      Bface_list set
         = _mode ? _faces : Bface_list::reachable_faces(_orig_face);

      // verify that the user tapped a face that is part of the inflation region
      if ( face && !set.contains( face ) ) {
         return cancel_cb(gest,state);
      }

      // Attempt to inflate the surface
      INFLATE_CMDptr cmd = _mode ? (new INFLATE_CMD( _faces, _preview_dist )) :
         (new INFLATE_CMD( _orig_face, _preview_dist ));
      WORLD::add_command(cmd);
   }

   // On fail, cancel
   return cancel_cb(gest,state);
}