//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; }
Evd::DEVmod DEVmod_gen::mods() { Evd::DEVmod mods = Evd::EMPTY; for (int m = 0; m < _mods.num(); m++) { DEVice_buttons *btns = _mods[m].ice(); if (btns->get(_mods[m].btn_ind())) mods = Evd::DEVmod(((int)mods) | (int)(_mods[m].mod())); } Evd::DEVmod gmods = Evd::EMPTY; if (_gen) gmods = _gen->gen_mods(); mods = Evd::DEVmod(((int)mods) | ((int)gmods) | ((int)_forced_mods)); if (mods == Evd::EMPTY) mods = Evd::NONE; return mods; }
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; }