Ejemplo n.º 1
0
int
SELECT_WIDGET::tap_cb(CGESTUREptr& g, DrawState*& s)
{
   err_adv(debug, "SELECT_WIDGET::tap_cb()");

   assert(g && g->is_tap());


   if (_mode==SLASH_SEL)
   {
	   //pattern editing
		Bface* f = find_face(g->start(),0.25,MIN_PIX_AREA);
		if (f) {
			if (select_list.contains(f)||select_list.contains(f->quad_partner()))
			{
	
				//get whichever part of the quad is in the selection list
				int temp = select_list.contains(f) ? select_list.get_index(f)+1 : select_list.get_index(f->quad_partner())+1 ;


				if (temp>end_face) //user selected the end face
				{
					end_face=temp;
				}
				else //user is selecting a pattern
				{
					if (pattern<temp)
						pattern=temp;

					//select/deselect face
					if (temp < MAX_PATTERN_SIZE)
					pattern_array[temp]=!pattern_array[temp];

				}
				return 1;
			}
			else
				cerr << "tap found a NULL face !" << endl;
		}

		return cancel_cb(g,s);


   }
   else
   {
   // Tap a selected face near the middle to deselect it:
	if (try_deselect_face(g->center(), 0.25))
		  return 1;

   // Tap edge to deselect
	if (try_deselect_edge(g->center()))
		  return 1;

   }
   // Otherwise, turn off SELECT_WIDGET
   
   return cancel_cb(g,s);
}
Ejemplo n.º 2
0
int
SELECT_WIDGET::sm_circle_cb(CGESTUREptr& g, DrawState*& s)
{
   err_adv(debug, "SELECT_WIDGET::sm_circle_cb()");

   try_select_face(g->center(), 0.25) || try_select_edge(g->center());

   return 1;
}
Ejemplo n.º 3
0
int
NPRPen::tap_cb(CGESTUREptr& gest, DrawState*&)
{
   cerr << "NPRPen::tap_cb" << endl;

   Bface *f = VisRefImage::Intersect(gest->center());
   Patch* p = get_ctrl_patch(f);
   if (!(f && p)) {
      if (_curr_npr_tex)
         deselect_current_texture();
      return 0;
   }

   // Set the selected face's patch to using NPRTexture
   // It might already be doing this, but who cares!
   p->set_texture(NPRTexture::static_name());

   GTexture* cur_texture = p->cur_tex();
   NPRTexture* nt = dynamic_cast<NPRTexture*>(cur_texture);
   if (nt == nullptr)
      return 0; //Shouldn't happen

   if (_curr_npr_tex)
      {
         if (_curr_npr_tex != nt)
            {
               deselect_current_texture();
               select_current_texture(nt);
            }
      }
   else
      select_current_texture(nt);

   return 0;
}
Ejemplo n.º 4
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;
}
Ejemplo n.º 5
0
//! Currently checks to see that the gesture was a small circle.
//! If so, this may be an indication that the user wants to go 
//! into edge selection mode. It then executes try_select_edge() 
//! to try to find the edge. When successful, the widget enters 
//! edge selection mode.
bool 
SELECT_WIDGET::init_select_edge(CGESTUREptr& g)
{
   if (!g->is_small_circle())
      return false;
   if (!try_select_edge(g->center()))
      return false;
   _mode = SEL_EDGE;
   reset_timeout();
   activate();
   return true;
}
Ejemplo n.º 6
0
int
PatternPen::tap_cb(CGESTUREptr& gest, DrawState*& s){
//   err_msg("PatternPen::tap_cb()");
   if (_mode == PROXY){
      Bface* f;
      f = VisRefImage::Intersect(gest->center());
      if(f)
         init_proxy(f);
   } else {
      return stroke_cb(gest, s);  
   }
   return 1;
}
Ejemplo n.º 7
0
int
SWEEP_BASE::tap_cb(CGESTUREptr& g, DrawState*& s)
{
   err_adv(debug_all, "SWEEP_BASE::tap_cb");

   // tap near end of guideline: do uniform sweep based
   // on guideline length:
   if (g->center().dist(sweep_end()) < DIST_THRESH_PIXELS)
      return do_uniform_sweep(sweep_vec());

   // tap elsewhere on the guideline: do uniform sweep based
   // on tap location:
   if (hits_line(g->end()))
      return do_uniform_sweep(project_to_guideline(g->end()) - sweep_origin());

   // tap elsewhere: cancel:
   return cancel_cb(g,s);
}
Ejemplo n.º 8
0
 /// pixel-space distance between this gesture and the one provided, computed as distance between centers
  double dist(CGESTUREptr& g)  const { return center().dist(g->center()); }