本文整理汇总了C++中CGESTUREptr类的典型用法代码示例。如果您正苦于以下问题:C++ CGESTUREptr类的具体用法?C++ CGESTUREptr怎么用?C++ CGESTUREptr使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CGESTUREptr类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: assert
int
TRACE::tap_cb(CGESTUREptr& gest, DrawState*& s)
{
assert (gest->is_tap());
if (_calib_mode_flag) {
// we are in calibration point
XYpt sample = gest->end();
_samples[_cur_calib_pt_index] = sample;
cerr << "recorded sample " << _cur_calib_pt_index << endl;
_cur_calib_pt_index++;
/* seems impractical to distort image, leaving this at 2 - alexni
if (_cur_calib_pt_index == 4) {
*/
if (_cur_calib_pt_index == 2) {
// if we have sampled four points, we are done with calibration
_calib_mode_flag = false;
_calibrated = true;
WORLD::message("Calibration complete");
}
return 1;
} else return 0;
}
开发者ID:QuLogic,项目名称:jot-lib,代码行数:25,代码来源:trace.cpp
示例2: cancel_cb
int
CIRCLE_WIDGET::tap_cb(CGESTUREptr& g, DrawState*& s)
{
err_adv(debug_all, "CIRCLE_WIDGET::tap_cb()");
PIXEL pdummy;
int idummy;
if( _suggest_active ) {
_preview.update_length();
_literal_shape.update_length();
double preview_dist = PIXEL_list(_preview).closest( PIXEL(g->start()), pdummy, idummy );
double literal_dist = PIXEL_list(_literal_shape).closest( PIXEL(g->start()), pdummy, idummy );
if( preview_dist < literal_dist && preview_dist < PIXEL_DIST_THRESH ) {
_suggest_active = false;
make_preview();
return 1;
} else if( literal_dist < preview_dist && literal_dist < PIXEL_DIST_THRESH ) {
finish_literal();
return cancel_cb(g,s);
} else {
return cancel_cb(g,s);
}
}
if (_cmd)
WORLD::add_command(_cmd);
return cancel_cb(g,s);
}
开发者ID:Benignoperez,项目名称:jot-lib,代码行数:29,代码来源:circle_widget.C
示例3: create_rect
//! Draw a straight line cross-ways to an existing
//! straight Bcurve to create a rectangle:
bool
SWEEP_LINE::create_rect(CGESTUREptr& gest)
{
static bool debug =
Config::get_var_bool("DEBUG_CREATE_RECT",false) || debug_all;
err_adv(debug, "SWEEP_LINE::create_rect");
if (!(gest && gest->is_line())) {
err_adv(debug, "SWEEP_LINE::create_rect: gesture is not a line");
return false;
}
// central axis must be on-screen
if (!sweep_origin().in_frustum()) {
err_adv(debug_all, "SWEEP_LINE::stroke_cb: error: sweep origin off-screen");
return false;
}
if (!from_center(gest)) {
WORLD::message("Stroke must begin on curve at guideline");
return false;
}
if (!hits_line(gest->end())) {
WORLD::message("Line must follow axis");
return false;
}
// compute vector along guideline, based on input stroke:
Wvec v = project_to_guideline(gest->end()) - sweep_origin();
return create_rect(v);
}
开发者ID:QuLogic,项目名称:jot-lib,代码行数:35,代码来源:sweep.cpp
示例4: cancel_cb
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);
}
开发者ID:ArnaudGastinel,项目名称:jot-lib,代码行数:59,代码来源:select_widget.C
示例5:
//! Given a set of enclosed face, activate the widget to sweep out a
//! shape. Checks for errors, returns true on success.
bool
SWEEP_DISK::setup(CGESTUREptr& gest, double dur)
{
static bool debug =
Config::get_var_bool("DEBUG_SWEEP_SETUP",false) || debug_all;
if (!(gest && gest->is_dslash())) {
err_adv(debug, "SWEEP_DISK::setup: bad gesture");
return false;
}
// XXX - shouldn't require it is a Panel:
Panel* p = dynamic_cast<Panel*>(Bsurface::hit_ctrl_surface(gest->start()));
if (!p) {
err_adv(debug, "SWEEP_DISK::setup: non-panel");
return false;
}
Bface_list faces = p->bfaces();
_boundary = faces.get_boundary();
if (_boundary.num_line_strips() != 1) {
err_adv(debug, "SWEEP_DISK::setup: error: boundary is not a single piece");
return false;
}
// Get the best-fit plane, rejecting if the boundary Wpt_list
// doesn't lie within 0.1 of its total length from the plane:
if (!_boundary.verts().pts().get_plane(_plane, 0.1)) {
err_adv(debug,"SWEEP_DISK::setup: Error: can't find plane");
return false;
}
// Find the center
Wpt o = _boundary.verts().pts().average();
// decide guideline direction (normal to plane):
Wvec n = _plane.normal();
if (VIEW::eye_vec(o) * n > 0)
n = -n;
// decide the length for the guideline:
double len = world_length(o, GUIDE_LEN);
// compute guideline endpoint:
Wpt b = o + n.normalized()*len;
// try basic setup
if (!SWEEP_BASE::setup(dynamic_pointer_cast<LMESH>(faces.mesh()), o, b, dur))
return false;
// ******** From here on we accept it ********
_enclosed_faces = faces;
return true;
}
开发者ID:QuLogic,项目名称:jot-lib,代码行数:60,代码来源:sweep.cpp
示例6: assert
int
SELECT_WIDGET::stroke_cb(CGESTUREptr& g, DrawState*&)
{
assert(g);
select_faces(g->pts()) || select_edges(g->pts());
return 1;
}
开发者ID:ArnaudGastinel,项目名称:jot-lib,代码行数:9,代码来源:select_widget.C
示例7:
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;
}
开发者ID:ArnaudGastinel,项目名称:jot-lib,代码行数:9,代码来源:select_widget.C
示例8: ray
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;
}
开发者ID:ArnaudGastinel,项目名称:jot-lib,代码行数:55,代码来源:xform_pen.C
示例9: VEXEL
int
INFLATE::stroke_cb(CGESTUREptr& gest, DrawState*& s)
{
err_adv(debug, "INFLATE::stroke_cb");
reset_timeout();
// Verify that we have a starting face
if ( _orig_face ) {
Bface* face = 0;
// Check that the stroke is straight enough to represent a line
if (!(gest->straightness() > 0.8)) {
err_adv(debug, "INFLATE::stroke_cb: gesture not straight");
return false;
}
// Check that the gesture starts on the mesh
Bsurface::hit_ctrl_surface(gest->start(), 1, &face);
if (!(face)) {
err_adv(debug, "INFLATE::stroke_cb: can't get hit face");
return false;
}
// create VEXELs for the gesture and the face normal
VEXEL fvec = VEXEL(face->v1()->loc(), face->norm());
VEXEL fgest = gest->endpt_vec();
// If gesture nearly parallel to normal:
double a = rad2deg(line_angle(fvec,fgest));
err_adv(debug, "INFLATE::stroke_cb: angle: %f %s",
a, (a > 15) ? "(bad)" : "(good)");
if (a > 15) {
// Fail if angle is too extreme
WORLD::message("Bad angle");
return 0;
}
// calculate extrude width
double dist = fgest.length()/fvec.length();
err_adv(debug, "INFLATE::stroke_cb: strong_edge_len: %f, gest_len: %f, \
fvect_len: %f", avg_strong_edge_len(face), fgest.length(), fvec.length() );
// Convert to relative to local edge length
dist /= avg_strong_edge_len(face);
if (fvec*fgest<0)
dist=-dist; // Get the sign right
// Store the new inflate distance
_preview_dist = dist;
}
return 1; // we used up the gesture...
}
开发者ID:ArnaudGastinel,项目名称:jot-lib,代码行数:55,代码来源:inflate.C
示例10: assert
bool
PAPER_DOLL::init(CGESTUREptr& g)
{
if (!(g && g->is_stroke()))
return false;
if (g->below_min_length() || g->below_min_spread())
return false;
if (!g->is_ellipse()) {
err_adv(debug, "PAPER_DOLL::init: non-ellipse");
return false;
}
Panel* p = dynamic_cast<Panel*>(
Bsurface::get_surface(get_top_level(VisRefImage::get_faces(g->pts())))
);
err_adv(debug, "PAPER_DOLL::init: %s panel", p?"found":"could not find");
if (!(p && p->is_selected())) {
err_adv(debug, "PAPER_DOLL::init: ellipse not over selected panel");
return false;
}
assert(p && p->bfaces().size() > 0);
Bface_list faces = Bface_list::reachable_faces(p->bfaces().front());
assert(!faces.empty());
if (!faces.is_planar(deg2rad(1.0))) {
err_adv(debug, "PAPER_DOLL::init: region is not planar");
return false;
}
EdgeStrip boundary = faces.get_boundary();
if (boundary.empty()) {
err_adv(debug, "PAPER_DOLL::init: region has no boundary");
return false;
}
Bsurface_list surfs = Bsurface::get_surfaces(faces);
if (!are_all_bsurfaces<Panel>(surfs)) {
err_adv(debug, "PAPER_DOLL::init: region not all panels");
return 0;
}
err_adv(debug, "PAPER_DOLL::init: proceeding...");
err_adv(debug, " boundary edges: %d, components: %d, panels: %d",
boundary.edges().size(), boundary.num_line_strips(), surfs.num()
);
if (get_instance()->build_primitive(faces)) {
err_adv(debug, " ... succeeded");
return true;
}
err_adv(debug, " ... failed");
return false;
}
开发者ID:QuLogic,项目名称:jot-lib,代码行数:54,代码来源:paper_doll.cpp
示例11: activate
//! 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;
}
开发者ID:ArnaudGastinel,项目名称:jot-lib,代码行数:17,代码来源:select_widget.C
示例12:
void
Pen::notify_gesture(GEST_INT* gi, CGESTUREptr& gest)
{
if (Config::get_var_bool("DEBUG_GESTURES",false)) {
gest->print_stats();
gest->print_types();
}
_fsa.handle_event(gest);
if (_fsa.is_reset())
gi->reset();
}
开发者ID:ArnaudGastinel,项目名称:jot-lib,代码行数:13,代码来源:pen.C
示例13: find_matching_sil
bool
OVERSKETCH::find_matching_sil(CGESTUREptr& g)
{
err_adv(debug, "OVERSKETCH::find_matching_sil");
const size_t MIN_GEST_PTS = 10;
if (!(g && g->pts().size() >= MIN_GEST_PTS))
return false;
if (BMESH::_freeze_sils)
return false;
VisRefImage *vis_ref = VisRefImage::lookup(VIEW::peek());
if (!vis_ref)
return false;
// 1. see if the gesture runs along a silhouette
// of a single mesh.
SilEdgeFilter sil_filter;
const PIXEL_list& pts = g->pts();
BMESHptr mesh = nullptr;
for (PIXEL_list::size_type i=0; i<pts.size(); i++) {
Bedge* e = (Bedge*)
vis_ref->find_near_simplex(pts[i], SIL_SEARCH_RAD, sil_filter);
if (!(e && e->mesh())) {
err_adv(debug, " gesture too far from silhouette");
return false;
}
if (mesh && mesh != e->mesh()) {
err_adv(debug, " found a second mesh, rejecting");
return false;
}
mesh = e->mesh();
}
if (!dynamic_pointer_cast<LMESH>(mesh)) {
err_adv(debug, " found non-LMESH, rejecting");
return false;
}
err_adv(debug, " gesture aligns with silhouette");
err_adv(debug, " mesh level %d", mesh->subdiv_level());
// 2. extract the portion of the silhouette that matches
// the gesture, store in _selected_sils
return find_matching_sil(pts, mesh->sil_strip());
}
开发者ID:QuLogic,项目名称:jot-lib,代码行数:48,代码来源:oversketch.cpp
示例14:
bool
OVERSKETCH::init(CGESTUREptr& g)
{
if (!(g && g->is_stroke()))
return false;
if (g->below_min_length() || g->below_min_spread())
return false;
if (get_instance()->find_matching_sil(g))
return true;
// add more cases here...
return false;
}
开发者ID:QuLogic,项目名称:jot-lib,代码行数:16,代码来源:oversketch.cpp
示例15:
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;
}
开发者ID:QuLogic,项目名称:jot-lib,代码行数:35,代码来源:npr_pen.cpp
示例16: BBoxCell
bool
PatternPen::compute_target_cell(CGESTUREptr& gest){
if (_target_cell) {
print_target_cell();
}
int nb_pts = gest->pts().num();
if (nb_pts < 2) return false;
if (_current_cell_type == BBOX_CELL){
_target_cell = new BBoxCell(gest->pts()[0], gest->pts()[nb_pts-1]);
} else if (_current_cell_type == RECT_CELL){
double thickness;
GESTUREptr axis_gesture;
update_rect_drawer(gest, axis_gesture, thickness);
if (axis_gesture) {
_target_cell = new RectCell(axis_gesture, thickness);
} else {
return false;
}
} else if (_current_cell_type == PATH_CELL){
double thickness;
GESTUREptr axis_gesture;
update_path_drawer(gest, axis_gesture, thickness);
if (axis_gesture) {
_target_cell = new PathCell(axis_gesture, thickness);
} else {
return false;
}
} else if (_current_cell_type == CARRIER_CELL){
GESTUREptr first_gesture;
GESTUREptr second_gesture;
update_carrier_drawer(gest, first_gesture, second_gesture);
if (first_gesture) {
_target_cell = new CarriersCell(first_gesture, second_gesture);
} else {
return false;
}
} else {
return false;
}
_target_cell->set_global_scale(_current_global_scale);
return true;
}
开发者ID:ArnaudGastinel,项目名称:jot-lib,代码行数:45,代码来源:pattern_pen.C
示例17: do_uniform_sweep
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);
}
开发者ID:QuLogic,项目名称:jot-lib,代码行数:18,代码来源:sweep.cpp
示例18: assert
int
OVERSKETCH::stroke_cb(CGESTUREptr& gest, DrawState*& s)
{
err_adv(debug, "OVERSKETCH::stroke_cb");
assert(gest);
try_oversketch(gest->pts());
return 1; // This means we did use up the gesture
}
开发者ID:QuLogic,项目名称:jot-lib,代码行数:10,代码来源:oversketch.cpp
示例19: cancel_cb
int
INFLATE::tap_cb(CGESTUREptr& gest, DrawState*& state)
{
err_adv(debug, "INFLATE::tap_cb");
// Tracks if the tap was near a guideline
bool near_guidelines = false;
PIXEL pdummy;
int idummy;
if ( PIXEL_list(_lines).closest( PIXEL(gest->start()), pdummy, idummy ) < 5 )
near_guidelines = true;
// Check if gesture hits a BFace
Bface* face = 0;
Bsurface::hit_ctrl_surface(gest->start(), 1, &face);
// Fail if Gesture missed guidelines and geometry
if ( !face && !near_guidelines )
return cancel_cb(gest,state);
// Check that we are trying to inflate
if ( _orig_face ) {
// Find the reachable faces from the starting point
Bface_list set
= _mode ? _faces : Bface_list::reachable_faces(_orig_face);
// verify that the user tapped a face that is part of the inflation region
if ( face && !set.contains( face ) ) {
return cancel_cb(gest,state);
}
// Attempt to inflate the surface
INFLATE_CMDptr cmd = _mode ? (new INFLATE_CMD( _faces, _preview_dist )) :
(new INFLATE_CMD( _orig_face, _preview_dist ));
WORLD::add_command(cmd);
}
// On fail, cancel
return cancel_cb(gest,state);
}
开发者ID:ArnaudGastinel,项目名称:jot-lib,代码行数:42,代码来源:inflate.C
示例20: stroke
///////////////////
// Proxy methods
///////////////////
void
PatternPen::add_stroke_to_proxy(CGESTUREptr& gest)
{
if (gest->pts().num() < 2) {
WORLD::message("Failed to generate hatch stroke (too few samples)...");
return;
}
//NDCpt_list ndcpts = gest->pts();
//if (_pattern_texture)
//_pattern_texture->proxy_surface()->add(
// gest->pts(),gest->pressures(), _gesture_drawer->base_stroke_proto());
}
开发者ID:ArnaudGastinel,项目名称:jot-lib,代码行数:15,代码来源:pattern_pen.C
注:本文中的CGESTUREptr类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论