本文整理汇总了C++中UI_view2d_region_to_view函数的典型用法代码示例。如果您正苦于以下问题:C++ UI_view2d_region_to_view函数的具体用法?C++ UI_view2d_region_to_view怎么用?C++ UI_view2d_region_to_view使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了UI_view2d_region_to_view函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: node_borderselect_exec
static int node_borderselect_exec(bContext *C, wmOperator *op)
{
SpaceNode *snode = CTX_wm_space_node(C);
ARegion *ar = CTX_wm_region(C);
bNode *node;
rcti rect;
rctf rectf;
int gesture_mode = RNA_int_get(op->ptr, "gesture_mode");
int extend = RNA_boolean_get(op->ptr, "extend");
WM_operator_properties_border_to_rcti(op, &rect);
UI_view2d_region_to_view(&ar->v2d, rect.xmin, rect.ymin, &rectf.xmin, &rectf.ymin);
UI_view2d_region_to_view(&ar->v2d, rect.xmax, rect.ymax, &rectf.xmax, &rectf.ymax);
for (node = snode->edittree->nodes.first; node; node = node->next) {
if (BLI_rctf_isect(&rectf, &node->totr, NULL)) {
nodeSetSelected(node, (gesture_mode == GESTURE_MODAL_SELECT));
}
else if (!extend) {
nodeSetSelected(node, FALSE);
}
}
ED_node_sort(snode->edittree);
WM_event_add_notifier(C, NC_NODE | NA_SELECTED, NULL);
return OPERATOR_FINISHED;
}
示例2: previewrange_define_exec
static int previewrange_define_exec(bContext *C, wmOperator *op)
{
Scene *scene= CTX_data_scene(C);
ARegion *ar= CTX_wm_region(C);
float sfra, efra;
int xmin, xmax;
/* get min/max values from border select rect (already in region coordinates, not screen) */
xmin= RNA_int_get(op->ptr, "xmin");
xmax= RNA_int_get(op->ptr, "xmax");
/* convert min/max values to frames (i.e. region to 'tot' rect) */
UI_view2d_region_to_view(&ar->v2d, xmin, 0, &sfra, NULL);
UI_view2d_region_to_view(&ar->v2d, xmax, 0, &efra, NULL);
/* set start/end frames for preview-range
* - must clamp within allowable limits
* - end must not be before start (though this won't occur most of the time)
*/
FRAMENUMBER_MIN_CLAMP(sfra);
FRAMENUMBER_MIN_CLAMP(efra);
if (efra < sfra) efra= sfra;
scene->r.flag |= SCER_PRV_RANGE;
scene->r.psfra= (int)floor(sfra + 0.5f);
scene->r.pefra= (int)floor(efra + 0.5f);
/* send notifiers */
WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene);
return OPERATOR_FINISHED;
}
示例3: borderselect_nla_strips
static void borderselect_nla_strips(bAnimContext *ac, rcti rect, short mode, short selectmode)
{
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
SpaceNla *snla = (SpaceNla *)ac->sl;
View2D *v2d = &ac->ar->v2d;
rctf rectf;
float ymin /* =(float)(-NLACHANNEL_HEIGHT(snla)) */ /* UNUSED */, ymax = 0;
/* convert border-region to view coordinates */
UI_view2d_region_to_view(v2d, rect.xmin, rect.ymin + 2, &rectf.xmin, &rectf.ymin);
UI_view2d_region_to_view(v2d, rect.xmax, rect.ymax - 2, &rectf.xmax, &rectf.ymax);
/* filter data */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
/* convert selection modes to selection modes */
selectmode = selmodes_to_flagmodes(selectmode);
/* loop over data, doing border select */
for (ale = anim_data.first; ale; ale = ale->next) {
ymin = ymax - NLACHANNEL_STEP(snla);
/* perform vertical suitability check (if applicable) */
if ((mode == NLA_BORDERSEL_FRAMERANGE) ||
!((ymax < rectf.ymin) || (ymin > rectf.ymax)))
{
/* loop over data selecting (only if NLA-Track) */
if (ale->type == ANIMTYPE_NLATRACK) {
NlaTrack *nlt = (NlaTrack *)ale->data;
NlaStrip *strip;
/* only select strips if they fall within the required ranges (if applicable) */
for (strip = nlt->strips.first; strip; strip = strip->next) {
if ((mode == NLA_BORDERSEL_CHANNELS) ||
BKE_nlastrip_within_bounds(strip, rectf.xmin, rectf.xmax))
{
/* set selection */
ACHANNEL_SET_FLAG(strip, selectmode, NLASTRIP_FLAG_SELECT);
/* clear active flag */
strip->flag &= ~NLASTRIP_FLAG_ACTIVE;
}
}
}
}
/* set minimum extent to be the maximum of the next channel */
ymax = ymin;
}
/* cleanup */
ANIM_animdata_freelist(&anim_data);
}
示例4: node_circleselect_exec
static int node_circleselect_exec(bContext *C, wmOperator *op)
{
SpaceNode *snode = CTX_wm_space_node(C);
ARegion *ar = CTX_wm_region(C);
bNode *node;
int x, y, radius, gesture_mode;
float offset[2];
float zoom = (float)(BLI_rcti_size_x(&ar->winrct)) / (float)(BLI_rctf_size_x(&ar->v2d.cur));
gesture_mode = RNA_int_get(op->ptr, "gesture_mode");
/* get operator properties */
x = RNA_int_get(op->ptr, "x");
y = RNA_int_get(op->ptr, "y");
radius = RNA_int_get(op->ptr, "radius");
UI_view2d_region_to_view(&ar->v2d, x, y, &offset[0], &offset[1]);
for (node = snode->edittree->nodes.first; node; node = node->next) {
if (BLI_rctf_isect_circle(&node->totr, offset, radius / zoom)) {
nodeSetSelected(node, (gesture_mode == GESTURE_MODAL_SELECT));
}
}
WM_event_add_notifier(C, NC_NODE | NA_SELECTED, NULL);
return OPERATOR_FINISHED;
}
示例5: ED_mask_mouse_pos
/* takes event->mval */
void ED_mask_mouse_pos(ScrArea *sa, ARegion *ar, const int mval[2], float co[2])
{
if (sa) {
switch (sa->spacetype) {
case SPACE_CLIP:
{
SpaceClip *sc = sa->spacedata.first;
ED_clip_mouse_pos(sc, ar, mval, co);
BKE_mask_coord_from_movieclip(sc->clip, &sc->user, co, co);
break;
}
case SPACE_SEQ:
{
UI_view2d_region_to_view(&ar->v2d, mval[0], mval[1], &co[0], &co[1]);
break;
}
case SPACE_IMAGE:
{
SpaceImage *sima = sa->spacedata.first;
ED_image_mouse_pos(sima, ar, mval, co);
BKE_mask_coord_from_image(sima->image, &sima->iuser, co, co);
break;
}
default:
/* possible other spaces from which mask editing is available */
BLI_assert(0);
zero_v2(co);
break;
}
}
else {
BLI_assert(0);
zero_v2(co);
}
}
示例6: file_highlight_set
int file_highlight_set(SpaceFile *sfile, ARegion *ar, int mx, int my)
{
View2D *v2d = &ar->v2d;
FileSelectParams *params;
int numfiles, origfile;
if (sfile == NULL || sfile->files == NULL) return 0;
numfiles = filelist_numfiles(sfile->files);
params = ED_fileselect_get_params(sfile);
origfile = params->active_file;
mx -= ar->winrct.xmin;
my -= ar->winrct.ymin;
if (BLI_rcti_isect_pt(&ar->v2d.mask, mx, my)) {
float fx, fy;
int active_file;
UI_view2d_region_to_view(v2d, mx, my, &fx, &fy);
active_file = ED_fileselect_layout_offset(sfile->layout, (int)(v2d->tot.xmin + fx), (int)(v2d->tot.ymax - fy));
if ((active_file >= 0) && (active_file < numfiles))
params->active_file = active_file;
else
params->active_file = -1;
}
else
params->active_file = -1;
return (params->active_file != origfile);
}
示例7: paintcurve_cursor_invoke
static int paintcurve_cursor_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *event)
{
ePaintMode mode = BKE_paintmode_get_active_from_context(C);
switch (mode) {
case PAINT_MODE_TEXTURE_2D: {
ARegion *ar = CTX_wm_region(C);
SpaceImage *sima = CTX_wm_space_image(C);
float location[2];
if (!sima) {
return OPERATOR_CANCELLED;
}
UI_view2d_region_to_view(
&ar->v2d, event->mval[0], event->mval[1], &location[0], &location[1]);
copy_v2_v2(sima->cursor, location);
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_IMAGE, NULL);
break;
}
default:
ED_view3d_cursor3d_update(C, event->mval, true, V3D_CURSOR_ORIENT_VIEW);
break;
}
return OPERATOR_FINISHED;
}
示例8: ed_marker_select
static int ed_marker_select(bContext *C, wmEvent *evt, int extend)
{
ListBase *markers= context_get_markers(C);
View2D *v2d= UI_view2d_fromcontext(C);
float viewx;
int x, y, cfra;
if(markers == NULL)
return OPERATOR_PASS_THROUGH;
x= evt->x - CTX_wm_region(C)->winrct.xmin;
y= evt->y - CTX_wm_region(C)->winrct.ymin;
UI_view2d_region_to_view(v2d, x, y, &viewx, NULL);
cfra= ED_markers_find_nearest_marker_time(markers, viewx);
if (extend)
select_timeline_marker_frame(markers, cfra, 1);
else
select_timeline_marker_frame(markers, cfra, 0);
WM_event_add_notifier(C, NC_SCENE|ND_MARKERS, NULL);
/* allowing tweaks */
return OPERATOR_PASS_THROUGH;
}
示例9: graphview_cursor_setprops
/* set the operator properties from the initial event */
static void graphview_cursor_setprops(bContext *C, wmOperator *op, const wmEvent *event)
{
Scene *scene = CTX_data_scene(C);
ARegion *ar = CTX_wm_region(C);
float viewx, viewy;
int frame;
/* abort if not active region (should not really be possible) */
if (ar == NULL)
return;
/* convert from region coordinates to View2D 'tot' space */
UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &viewx, &viewy);
/* frame is rounded to the nearest int, since frames are ints */
frame = iroundf(viewx);
if (scene->r.flag & SCER_LOCK_FRAME_SELECTION) {
CLAMP(frame, PSFRA, PEFRA);
}
/* store the values in the operator properties */
RNA_int_set(op->ptr, "frame", frame);
RNA_float_set(op->ptr, "value", viewy);
}
示例10: actkeys_select_leftright_invoke
static int actkeys_select_leftright_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
bAnimContext ac;
short leftright = RNA_enum_get(op->ptr, "mode");
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
/* handle mode-based testing */
if (leftright == ACTKEYS_LRSEL_TEST) {
Scene *scene = ac.scene;
ARegion *ar = ac.ar;
View2D *v2d = &ar->v2d;
float x;
/* determine which side of the current frame mouse is on */
UI_view2d_region_to_view(v2d, event->mval[0], event->mval[1], &x, NULL);
if (x < CFRA)
RNA_enum_set(op->ptr, "mode", ACTKEYS_LRSEL_LEFT);
else
RNA_enum_set(op->ptr, "mode", ACTKEYS_LRSEL_RIGHT);
}
/* perform selection */
return actkeys_select_leftright_exec(C, op);
}
示例11: find_file_mouse_rect
/* ---------- FILE SELECTION ------------ */
static FileSelection find_file_mouse_rect(SpaceFile *sfile, struct ARegion* ar, const rcti* rect)
{
FileSelection sel;
float fxmin,fymin,fxmax, fymax;
View2D* v2d = &ar->v2d;
rcti rect_view;
UI_view2d_region_to_view(v2d, rect->xmin, rect->ymin, &fxmin, &fymin);
UI_view2d_region_to_view(v2d, rect->xmax, rect->ymax, &fxmax, &fymax);
BLI_init_rcti(&rect_view, (int)(v2d->tot.xmin + fxmin), (int)(v2d->tot.xmin + fxmax), (int)(v2d->tot.ymax - fymin), (int)(v2d->tot.ymax - fymax));
sel = ED_fileselect_layout_offset_rect(sfile->layout, &rect_view);
return sel;
}
示例12: select_invoke
static int select_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
ARegion *ar = CTX_wm_region(C);
float co[2];
UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &co[0], &co[1]);
RNA_float_set_array(op->ptr, "location", co);
return select_exec(C, op);
}
示例13: ed_marker_border_select_exec
static int ed_marker_border_select_exec(bContext *C, wmOperator *op)
{
View2D *v2d= UI_view2d_fromcontext(C);
ListBase *markers= context_get_markers(C);
TimeMarker *marker;
float xminf, xmaxf, yminf, ymaxf;
int event_type= RNA_int_get(op->ptr, "event_type");
int xmin= RNA_int_get(op->ptr, "xmin");
int xmax= RNA_int_get(op->ptr, "xmax");
int ymin= RNA_int_get(op->ptr, "ymin");
int ymax= RNA_int_get(op->ptr, "ymax");
UI_view2d_region_to_view(v2d, xmin, ymin, &xminf, &yminf);
UI_view2d_region_to_view(v2d, xmax, ymax, &xmaxf, &ymaxf);
/* XXX disputable */
if(yminf > 30.0f || ymaxf < 0.0f)
return 0;
if(markers == NULL)
return 0;
/* XXX marker context */
for(marker= markers->first; marker; marker= marker->next) {
if ((marker->frame > xminf) && (marker->frame <= xmaxf)) {
/* XXX weak... */
switch (event_type) {
case LEFTMOUSE:
if ((marker->flag & SELECT) == 0)
marker->flag |= SELECT;
break;
case RIGHTMOUSE:
if (marker->flag & SELECT)
marker->flag &= ~SELECT;
break;
}
}
}
WM_event_add_notifier(C, NC_SCENE|ND_MARKERS, NULL);
return 1;
}
示例14: frame_from_event
/* Get frame from mouse coordinates */
static int frame_from_event(bContext *C, wmEvent *event)
{
ARegion *region= CTX_wm_region(C);
float viewx;
/* convert from region coordinates to View2D 'tot' space */
UI_view2d_region_to_view(®ion->v2d, event->mval[0], event->mval[1], &viewx, NULL);
/* round result to nearest int (frames are ints!) */
return (int)floor(viewx+0.5f);
}
示例15: do_node_add
static void do_node_add(bContext *C, bNodeTemplate *ntemp)
{
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
SpaceNode *snode = CTX_wm_space_node(C);
ScrArea *sa = CTX_wm_area(C);
ARegion *ar;
bNode *node, *node_new;
/* get location to add node at mouse */
for (ar = sa->regionbase.first; ar; ar = ar->next) {
if (ar->regiontype == RGN_TYPE_WINDOW) {
wmWindow *win = CTX_wm_window(C);
int x = win->eventstate->x - ar->winrct.xmin;
int y = win->eventstate->y - ar->winrct.ymin;
if (y < 60) y += 60;
UI_view2d_region_to_view(&ar->v2d, x, y, &snode->cursor[0], &snode->cursor[1]);
}
}
/* store selection in temp test flag */
for (node = snode->edittree->nodes.first; node; node = node->next) {
if (node->flag & NODE_SELECT) node->flag |= NODE_TEST;
else node->flag &= ~NODE_TEST;
}
node_new = node_add_node(snode, bmain, scene, ntemp, snode->cursor[0], snode->cursor[1]);
/* select previous selection before autoconnect */
for (node = snode->edittree->nodes.first; node; node = node->next) {
if (node->flag & NODE_TEST) node->flag |= NODE_SELECT;
}
/* deselect after autoconnection */
for (node = snode->edittree->nodes.first; node; node = node->next) {
if (node->flag & NODE_TEST) node->flag &= ~NODE_SELECT;
}
/* once this is called from an operator, this should be removed */
if (node_new) {
char undostr[BKE_UNDO_STR_MAX];
BLI_snprintf(undostr, sizeof(undostr), "Add Node %s", nodeLabel(node_new));
BKE_write_undo(C, undostr);
}
snode_notify(C, snode);
snode_dag_update(C, snode);
}