Exemple #1
0
int
XformPen::tap_cb(CGESTUREptr& tap, DrawState*& s)
{
   assert(tap);
   if (tap->is_double_tap()) {
      // should never happen given order of arcs in XformPen constructor
      cerr << "XformPen::tap_cb: error: gesture is double tap"
           << endl;
      return 0;
   }

   // tap on cursor?
   BMESHray ray(tap->center());
   _view->intersect(ray);
   Cursor3D* c = Cursor3D::upcast(ray.geom());
   if (c) {
      err_adv(debug, "XformPen::tap_cb: hit axis");
      c->handle_gesture(tap);
      return 0;
   }

   // tap on mesh?
   _mesh = 0;
   Bface* f = cur_face();
   if (!f) {
      err_adv(debug, "XformPen::tap_cb: missed face");
      return cancel_cb(tap, s);
   }
   BMESH* m = f->mesh();
   if (!m) {
      err_adv(debug, "XformPen::tap_cb: hit face, no mesh");
      return cancel_cb(tap, s);
   }
   GEOMptr g = bmesh_to_geom(m);
   if (!g) {
      err_adv(debug, "XformPen::tap_cb: hit mesh, no geom");
      return cancel_cb(tap, s);
   }
   // skip floor:
   if (FLOOR::isa(g)) {
      err_adv(debug, "XformPen::tap_cb: hit floor, skipping...");
      return cancel_cb(tap, s);
   }

   // tap on ordinary mesh (not floor):
   _mesh = m;
   assert(_mesh);
   BMESH::set_focus(_mesh, f->patch());
   FLOOR::show();
   FLOOR::realign(_mesh,0); // 0 = no undo command

   Cursor3D::attach(g);

   return 0;
}