本文整理汇总了C++中CEvent::view方法的典型用法代码示例。如果您正苦于以下问题:C++ CEvent::view方法的具体用法?C++ CEvent::view怎么用?C++ CEvent::view使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CEvent
的用法示例。
在下文中一共展示了CEvent::view方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: curpt
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;
}
示例2: data
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;
}
示例3: view
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;
}
示例4: data
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;
}
示例5: CamFocus
int
Cam_int::iconup(
CEvent &e,
State *&s
)
{
if (debug_fsa)
cerr << "Cam_int::iconup"
<< endl;
if (_resizing) {
_resizing = false;
const int retval = _icon->resize_up(e, s);
_icon = nullptr;
return retval;
}
DEVice_buttons *btns=(DEVice_buttons *)e._d;
DEVice_2d *ptr=btns->ptr2d();
PIXEL curpt(ptr->cur());
// Delete
if (the_time() - _dtime < 0.25 && _icon &&
(curpt - _start_pix).length() > 20 &&
(curpt - _start_pix).normalized() * VEXEL(1,1).normalized() > 0.5) {
_icon->remove_icon();
_icon = nullptr;
return 0;
}
if (_icon->intersect_icon(ptr->cur())) {
new CamFocus(e.view(), _icon->cam());
}
return 0;
}
示例6: move
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;
}
示例7: r
int
Pen::check_interactive(CEvent &e, State *&s)
{
DEVice_buttons *btns=(DEVice_buttons *)e._d;
DEVice_2d *ptr=btns->ptr2d();
RAYhit r(ptr->cur());
return (e.view()->intersect(r).success() &&
ray_geom(r,GEOM::null) &&
ray_geom(r,GEOM::null)->interactive(e,s));
}
示例8:
int
Cam_int::focus(
CEvent &e,
State *&
)
{
if (debug_fsa)
cerr << "Cam_int::focus"
<< endl;
GEOM::find_cam_focus(e.view(), DEVice_2d::last->cur());
return 0;
}
示例9: cam
int
Cam_int_edit::rot2(
CEvent &e,
State *&
)
{
CAMptr cam(e.view()->cam());
cam->set_zoom(1);
cam->set_min(NDCpt(XYpt(-1,-1)));
cam->data()->changed();
return 0;
}
示例10: up
int
Cam_int::dragup(
CEvent &e,
State *&s
)
{
if (debug_fsa)
cerr << "Cam_int::dragup"
<< endl;
DEVice_buttons *btns=(DEVice_buttons *)e._d;
DEVice_2d *ptr=btns->ptr2d();
VIEWptr view(e.view());
CAMptr cam (view->cam());
PIXEL curpt(ptr->cur());
double elapsed = the_time() - _dtime;
// Are we close to the cam globe?
if (ptr->cur().dist(_camwidg.anchor_pos()) < DOT_DIST && elapsed < 0.25)
return up(e,s);
reset(1);
set<UPobs*>::iterator i;
for (i = _up_obs.begin(); i != _up_obs.end(); ++i)
(*i)->reset(_do_reset); // reset everyone watching us
if ((curpt - _start_pix).length() > 20 &&
(curpt - _start_pix).normalized() * VEXEL(-1,0).normalized() > 0.5)
return 0;
RAYhit ray(view->intersect(_camwidg.anchor_pos()));
if (!ray.success())
return 0;
CAMdataptr data(cam->data());
double dist = _camwidg.anchor_size() * 2*data->focal()/data->height();
Wvec dirvec((data->from() - ray.surf()).normalized());
Wpt from = ray.surf() + dist * dirvec;
new CamFocus(view,
from, // from
ray.surf(), // at
from + Wvec::Y(), // up
ray.surf(), // center
data->width(), data->height());
return 0;
}
示例11: cam
int
Cam_int::rot2(
CEvent &e,
State *&
)
{
if (debug_fsa)
cerr << "Cam_int::rot2"
<< endl;
CAMptr cam(e.view()->cam());
cam->set_zoom(1);
cam->set_min(NDCpt(XYpt(-1,-1)));
cam->data()->changed();
return 0;
}
示例12: ray
int
Cam_int::up(
CEvent &e,
State *&s
)
{
if (debug_fsa)
cerr << "Cam_int::up"
<< endl;
DEVice_buttons *btns=(DEVice_buttons *)e._d;
DEVice_2d *ptr=btns->ptr2d();
VIEWptr view(e.view());
CAMptr cam (view->cam());
set<UPobs*>::iterator i;
for (i = _up_obs.begin(); i != _up_obs.end(); ++i)
(*i)->reset(_do_reset); // reset everyone watching us
if (_camwidg.anchor_displayed()) {
if (ptr->cur().dist(_camwidg.anchor_pos()) < DOT_DIST)
focus(e,s);
reset(1);
} else if (ptr->cur().dist(_down_pt_2d) < DOT_DIST) {
RAYhit ray(view->intersect(ptr->cur()));
if (ray.success()) {
// Create the anchor (blue ball) on the surface:
_camwidg.display_anchor(ray.surf());
// If clicked on a mesh, make it the "focus":
BMESHptr m = gel_to_bmesh(ray.geom());
if (m)
BMESH::set_focus(m, dynamic_cast<Patch*>(ray.appear()));
} else {
Wplane hitp(cam->data()->center(), cam->data()->at_v());
_camwidg.display_anchor(hitp.intersect(ray.screen_point()));
}
}
cam->data()->end_manip();
return 0;
}
示例13: r
int
FilmTrans::down(
CEvent &e,
State *&s
)
{
DEVice_buttons *btns=(DEVice_buttons *)e._d;
DEVice_2d *ptr=btns->ptr2d();
RAYhit r(ptr->cur());
GEOMptr geom;
_view = e.view();
if (_view->intersect(r,VIEW::H_TEXT).success() && GEOM::isa(r.geom())) {
geom = ray_geom(r, GEOM::null);
if (geom->interactive(e, s, &r)) {
_obj = 0;
_no_xform = 1;
return 1; // Interactive - return....
}
}
// interactive() could have changed r so that now !success(),
// so we have to check again
if (!r.success() || (geom && NO_XFORM_MOD.get(geom))) {
_no_xform = 1;
_obj = geom;
} else {
if (CONSTRAINT.get(geom) == GEOM::SCREEN_WIDGET)
_down_pt = geom->xform();
else _down_pt = r.surf();
_down_norm = r.norm();
_obj = geom;
if (_call_xform_obs)
XFORMobs::notify_xform_obs(_obj, XFORMobs::START);
_no_xform = 0;
}
return 0;
}
示例14: move
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)
示例15: ray
int
DrawManip::down(CEvent& e, State*& s)
{
err_adv(debug, "DrawManip::down");
_down_pix = ptr_cur(); // used in choose_cb()
// special handling for active curve sketch
// XXX - needs comments
CRV_SKETCHptr cs = CRV_SKETCH::get_instance();
if (cs && cs->is_active()) {
PIXEL_list pix = cs->shadow_pix();
if (pix[0].dist(_down_pix) < 8) {
_down = true;
_first = true;
} else if (pix.last().dist(_down_pix) < 8) {
_down = true;
_first = false;
}
}
assert(e.view() != 0);
BMESHray ray(ptr_cur());
e.view()->intersect(ray);
GEOMptr geom;
if (ray.success()) {
geom = GEOM::upcast(ray.geom());
if (geom && geom->interactive(e, s, &ray)) {
return 1; // geom is taking over remaining events until up event
}
_down_pt = ray.surf();
_vec = ray.norm();
}
if (init_point(Bpoint::hit_ctrl_point(ptr_cur()),s) ||
init_curve(Bcurve::hit_ctrl_curve(ptr_cur(), 6, _down_pt),s)) {
return 0; // all set
}
if (FLOOR::isa(geom)) {
// XXX - should handle floor manipulation
return 0;
}
// this part seems to crash on windows in some cases...
// turning it off for now:
bool find_components = false;
Bvert_list verts;
if (find_components)
verts = Bvert_list::connected_verts(VisRefImage::get_simplex(ptr_cur()));
// map vertices to Bbase controllers at top level of subdiv hierarchy:
Bbase_list bbases = Bbase::find_controllers(verts).get_ctrl_list();
if (debug) {
cerr << " found " << bbases.num() << " controllers:" << endl << " ";
bbases.print_identifiers();
}
err_adv(debug, " same mesh: %s", bbases.same_mesh() ? "true" : "false");
if (bbases.empty() && !geom)
return 0;
_cmd = bbases.empty() ? new MOVE_CMD(geom) : new MOVE_CMD(bbases);
assert(_cmd);
WORLD::add_command(_cmd);
_cmd->notify_xf_obs(XFORMobs::START);
return 0;
}