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; }
//left-click:test for any buttons used in this camera mode int Cam_int::down2( CEvent &e, State *&s ) { if (debug_fsa) cerr << "Cam_int::down2" << endl; DEVice_buttons *btns = (DEVice_buttons *)e._d; DEVice_2d *ptr = btns->ptr2d(); _view = e.view(); CAMdataptr data(_view->cam()->data()); RAYhit r (_view->intersect(ptr->cur())); if (r.success()) { if(r.geom()->name() == "eye_button") { s = (State *)-1; BaseJOTapp::cam_switch(e,s); } } return 0; }
int Cam_int::predown( CEvent &e, State *& ) { // de-activate current CamFocus, if any: CamFocus::cancel_cur(); DEVice_buttons *btns = (DEVice_buttons *)e._d; DEVice_2d *ptr = btns->ptr2d(); _view = e.view(); _do_reset = 0; _dtime = the_time(); _dist = 0; _scale_pt = ptr->cur(); _start_pix= ptr->cur(); CAMdataptr data(_view->cam()->data()); RAYhit r (_view->intersect(ptr->cur())); if (r.success()) { _down_pt = r.surf(); } else { _down_pt = Wplane(data->center(),data->at_v()).intersect(ptr->cur()); } _down_pt_2d = _down_pt; //Notify all the CAMobs's of the start of mouse down data->start_manip(); return 0; }
int Cam_int_edit::down( CEvent &e, State *&s ) { DEVice_buttons *btns = (DEVice_buttons *)e._d; DEVice_2d *ptr = btns->ptr2d(); VIEWptr view(e.view()); int x, y; view->get_size(x,y); PIXEL curpix(ptr->cur()); XYpt curpt (curpix[0]/x*2-1, curpix[1]/y*2-1); predown(e,s); //if the user clicks at the edge of the screen rotate if (fabs(curpt[0]) > .85 || fabs(curpt[1]) > .9) { s = &_cam_rot; return 0; } // } return 0; }
int Cam_int_edit::predown( CEvent &e, State *& ) { DEVice_buttons *btns = (DEVice_buttons *)e._d; DEVice_2d *ptr = btns->ptr2d(); _view = e.view(); _do_reset = 0; _dtime = the_time(); _dist = 0; _scale_pt = ptr->cur(); _start_pix= ptr->cur(); CAMdataptr data(_view->cam()->data()); RAYhit r (_view->intersect(ptr->cur())); if (r.success()) { double dist = r.dist(); _down_pt = r.point() + dist * r.vec(); } else { _down_pt = Wplane(data->center(),data->at_v()).intersect(ptr->cur()); } _down_pt_2d = _down_pt; //Notify all the CAMobs's of the start of mouse down data->start_manip(); return 0; }
int Cam_int::down( CEvent &e, State *&s ) { if (debug_fsa) cerr << "Cam_int::down" << endl; DEVice_buttons *btns = (DEVice_buttons *)e._d; DEVice_2d *ptr = btns->ptr2d(); VIEWptr view(e.view()); bool is_dot = _camwidg.anchor_displayed(); int x, y; view->get_size(x,y); PIXEL curpix(ptr->cur()); XYpt curpt (curpix[0]/x*2-1, curpix[1]/y*2-1); predown(e,s); // Did we click on a camera icon? CamIcon *icon = CamIcon::intersect_all(ptr->cur()); if (icon) { // XXX - fix _icon = icon; switch (icon->test_down(e, s)) { case CamIcon::RESIZE : _resizing = true; // drops through to next case: case CamIcon::FOCUS : s = &_icon_click; break; case CamIcon::MOVE : s = &_move_view; return move(e, s); } return 0; } else if ((fabs(curpt[0]) > .85 || fabs(curpt[1]) > .9) || is_dot) { if (is_dot) view->cam()->data()->set_center(_camwidg.anchor_wpt()); _do_reset = is_dot; if (!is_dot){ /* alexni- is there a better way to handle this? we want to * save the camera if we're going to enter a mode that causes * change to the camera */ _view->save_cam(); } s = &_cam_rot; return 0; } return 0; }
//////////////////////////////////////////////////// //edit_down: grabs the model that is clicked on for // editing ///////////////////////////////////////////////////// int Cam_int_edit::edit_down ( CEvent &e, State *&s) { DEVice_buttons *btns = (DEVice_buttons *)e._d; DEVice_2d *ptr = btns->ptr2d(); _view = e.view(); CAMdataptr data(_view->cam()->data()); RAYhit r (_view->intersect(ptr->cur())); if (r.success()) _model = (ray_geom(r,GEOM::null)); return 0; }
int FilmTrans::move( CEvent &e, State *& ) { DEVice_2d* ptr = dynamic_cast<DEVice_2d*>(e._d); assert(ptr); if (_obj) { Wpt cur(Wpt(ptr->cur(),_down_pt)); Wpt old(Wpt(ptr->old(),_down_pt)); _obj->mult_by(Wtransf::translation(cur-old)); if (_call_xform_obs) XFORMobs::notify_xform_obs(_obj, XFORMobs::MIDDLE); } return 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; }
int Cam_int_fp::down( CEvent &e, State *&s ) { DEVice_buttons *btns = (DEVice_buttons *)e._d; DEVice_2d *ptr = btns->ptr2d(); VIEWptr view(e.view()); int is_dot = _camwidg.anchor_displayed(); int x, y; view->get_size(x,y); PIXEL curpix(ptr->cur()); XYpt curpt (curpix[0]/x*2-1, curpix[1]/y*2-1); //set timer... _clock.set(); predown(e,s); if(CamBreathe::cur()) CamBreathe::cur()->pause(); // Did we click on a camera icon? CamIcon *icon = CamIcon::intersect_all(ptr->cur()); if (icon) { // XXX - fix _icon = icon; switch (icon->test_down(e, s)) { case CamIcon::RESIZE : _resizing = true; case CamIcon::FOCUS : s = &_icon_click; brcase CamIcon::MOVE : { s = &_move_view; return move(e, s); } } return 0; } else { if (is_dot)
int Cam_int_edit::down2( CEvent &e, State *&s ) { DEVice_buttons *btns = (DEVice_buttons *)e._d; DEVice_2d *ptr = btns->ptr2d(); _view = e.view(); CAMdataptr data(_view->cam()->data()); RAYhit r (_view->intersect(ptr->cur())); if (r.success()) { ////////////////// //Scale Button ////////////////// if(r.geom()->name() == "scale") { BaseJOTapp::deactivate_button(); if(s == &_scale) s = (State *)-1; else { BaseJOTapp::activate_button("scale"); s = &_scale; } } ////////////////// //ScaleX Button ////////////////// if(r.geom()->name() == "scalex") { BaseJOTapp::deactivate_button(); if(s == &_scalex) s = (State *)-1; else { BaseJOTapp::activate_button("scalex"); s = &_scalex; } } ////////////////// //ScaleY Button ////////////////// if(r.geom()->name() == "scaley") { BaseJOTapp::deactivate_button(); if(s == &_scaley) s = (State *)-1; else { BaseJOTapp::activate_button("scaley"); s = &_scaley; } } ////////////////// //ScaleZ Button ////////////////// if(r.geom()->name() == "scalez") { BaseJOTapp::deactivate_button(); if(s == &_scalez) s = (State *)-1; else { BaseJOTapp::activate_button("scalez"); s = &_scalez; } } ////////////////// //Rotate Button ////////////////// if(r.geom()->name() == "rotateX") { BaseJOTapp::deactivate_button(); if(s == &_rot_x) s = (State *)-1; else { BaseJOTapp::activate_button("rotateX"); s = &_rot_x; } } ////////////////// //RotateY Button ////////////////// if(r.geom()->name() == "rotateY") { BaseJOTapp::deactivate_button(); if(s == &_rot_y) s = (State *)-1; else { BaseJOTapp::activate_button("rotateY"); s = &_rot_y; } } ////////////////// //Rotate Button ////////////////// if(r.geom()->name() == "rotateZ") { BaseJOTapp::deactivate_button(); if(s == &_rot_z) s = (State *)-1; else { BaseJOTapp::activate_button("rotateZ"); s = &_rot_z; } } ///////////////// //Eye Button //////////////// else if(r.geom()->name() == "eye_button") { s = (State *)-1; BaseJOTapp::cam_switch(e,s); } } return 0; }