本文整理汇总了C++中BLI_rctf_size_x函数的典型用法代码示例。如果您正苦于以下问题:C++ BLI_rctf_size_x函数的具体用法?C++ BLI_rctf_size_x怎么用?C++ BLI_rctf_size_x使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了BLI_rctf_size_x函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: render_view3d_disprect
static int render_view3d_disprect(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D *rv3d, rcti *disprect)
{
/* copied code from view3d_draw.c */
rctf viewborder;
int draw_border;
if (rv3d->persp == RV3D_CAMOB)
draw_border = (scene->r.mode & R_BORDER) != 0;
else
draw_border = (v3d->flag2 & V3D_RENDER_BORDER) != 0;
if (draw_border) {
if (rv3d->persp == RV3D_CAMOB) {
ED_view3d_calc_camera_border(scene, ar, v3d, rv3d, &viewborder, false);
disprect->xmin = viewborder.xmin + scene->r.border.xmin * BLI_rctf_size_x(&viewborder);
disprect->ymin = viewborder.ymin + scene->r.border.ymin * BLI_rctf_size_y(&viewborder);
disprect->xmax = viewborder.xmin + scene->r.border.xmax * BLI_rctf_size_x(&viewborder);
disprect->ymax = viewborder.ymin + scene->r.border.ymax * BLI_rctf_size_y(&viewborder);
}
else {
disprect->xmin = v3d->render_border.xmin * ar->winx;
disprect->xmax = v3d->render_border.xmax * ar->winx;
disprect->ymin = v3d->render_border.ymin * ar->winy;
disprect->ymax = v3d->render_border.ymax * ar->winy;
}
return 1;
}
BLI_rcti_init(disprect, 0, 0, 0, 0);
return 0;
}
示例2: draw_scope_end
static void draw_scope_end(const rctf *rect, GLint *scissor)
{
float scaler_x1, scaler_x2;
/* restore scissortest */
glScissor(scissor[0], scissor[1], scissor[2], scissor[3]);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
/* scale widget */
scaler_x1 = rect->xmin + BLI_rctf_size_x(rect) / 2 - SCOPE_RESIZE_PAD;
scaler_x2 = rect->xmin + BLI_rctf_size_x(rect) / 2 + SCOPE_RESIZE_PAD;
glColor4f(0.f, 0.f, 0.f, 0.25f);
fdrawline(scaler_x1, rect->ymin - 4, scaler_x2, rect->ymin - 4);
fdrawline(scaler_x1, rect->ymin - 7, scaler_x2, rect->ymin - 7);
glColor4f(1.f, 1.f, 1.f, 0.25f);
fdrawline(scaler_x1, rect->ymin - 5, scaler_x2, rect->ymin - 5);
fdrawline(scaler_x1, rect->ymin - 8, scaler_x2, rect->ymin - 8);
/* outline */
glColor4f(0.f, 0.f, 0.f, 0.5f);
uiSetRoundBox(UI_CNR_ALL);
uiDrawBox(GL_LINE_LOOP, rect->xmin - 1, rect->ymin, rect->xmax + 1, rect->ymax + 1, 3.0f);
}
示例3: view3d_winmatrix_set
/**
* \param rect optional for picking (can be NULL).
*/
void view3d_winmatrix_set(ARegion *ar, View3D *v3d, const rctf *rect)
{
RegionView3D *rv3d = ar->regiondata;
rctf viewplane;
float clipsta, clipend;
bool is_ortho;
is_ortho = ED_view3d_viewplane_get(v3d, rv3d, ar->winx, ar->winy, &viewplane, &clipsta, &clipend, NULL);
rv3d->is_persp = !is_ortho;
#if 0
printf("%s: %d %d %f %f %f %f %f %f\n", __func__, winx, winy,
viewplane.xmin, viewplane.ymin, viewplane.xmax, viewplane.ymax,
clipsta, clipend);
#endif
if (rect) { /* picking */
rctf r;
r.xmin = viewplane.xmin + (BLI_rctf_size_x(&viewplane) * (rect->xmin / (float)ar->winx));
r.ymin = viewplane.ymin + (BLI_rctf_size_y(&viewplane) * (rect->ymin / (float)ar->winy));
r.xmax = viewplane.xmin + (BLI_rctf_size_x(&viewplane) * (rect->xmax / (float)ar->winx));
r.ymax = viewplane.ymin + (BLI_rctf_size_y(&viewplane) * (rect->ymax / (float)ar->winy));
viewplane = r;
}
if (is_ortho) {
wmOrtho(viewplane.xmin, viewplane.xmax, viewplane.ymin, viewplane.ymax, clipsta, clipend);
}
else {
wmFrustum(viewplane.xmin, viewplane.xmax, viewplane.ymin, viewplane.ymax, clipsta, clipend);
}
/* update matrix in 3d view region */
glGetFloatv(GL_PROJECTION_MATRIX, (float *)rv3d->winmat);
}
示例4: logic_view_all_exec
static int logic_view_all_exec(bContext *C, wmOperator *UNUSED(op))
{
ARegion *ar = CTX_wm_region(C);
rctf cur_new = ar->v2d.tot;
float aspect = BLI_rctf_size_y(&ar->v2d.cur) / BLI_rctf_size_x(&ar->v2d.cur);
/* force the view2d code to zoom to width, not height */
cur_new.ymin = cur_new.ymax - BLI_rctf_size_x(&cur_new) * aspect;
UI_view2d_smooth_view(C, ar, &cur_new);
return OPERATOR_FINISHED;
}
示例5: ED_fileselect_layout_numfiles
int ED_fileselect_layout_numfiles(FileLayout *layout, ARegion *ar)
{
int numfiles;
/* Values in pixels.
*
* - *_item: size of each (row|col), (including padding)
* - *_view: (x|y) size of the view.
* - *_over: extra pixels, to take into account, when the fit isnt exact
* (needed since you may see the end of the previous column and the beginning of the next).
*
* Could be more clever and take scrolling into account,
* but for now don't bother.
*/
if (layout->flag & FILE_LAYOUT_HOR) {
const int x_item = layout->tile_w + (2 * layout->tile_border_x);
const int x_view = (int)(BLI_rctf_size_x(&ar->v2d.cur));
const int x_over = x_item - (x_view % x_item);
numfiles = (int)((float)(x_view + x_over) / (float)(x_item));
return numfiles * layout->rows;
}
else {
const int y_item = layout->tile_h + (2 * layout->tile_border_y);
const int y_view = (int)(BLI_rctf_size_y(&ar->v2d.cur));
const int y_over = y_item - (y_view % y_item);
numfiles = (int)((float)(y_view + y_over) / (float)(y_item));
return numfiles * layout->columns;
}
}
示例6: curvemapping_changed
/* note; only does current curvemap! */
void curvemapping_changed(CurveMapping *cumap, int rem_doubles)
{
CurveMap *cuma = cumap->cm + cumap->cur;
CurveMapPoint *cmp = cuma->curve;
rctf *clipr = &cumap->clipr;
float thresh = 0.01f * BLI_rctf_size_x(clipr);
float dx = 0.0f, dy = 0.0f;
int a;
cumap->changed_timestamp++;
/* clamp with clip */
if (cumap->flag & CUMA_DO_CLIP) {
for (a = 0; a < cuma->totpoint; a++) {
if (cmp[a].flag & CUMA_SELECT) {
if (cmp[a].x < clipr->xmin)
dx = min_ff(dx, cmp[a].x - clipr->xmin);
else if (cmp[a].x > clipr->xmax)
dx = max_ff(dx, cmp[a].x - clipr->xmax);
if (cmp[a].y < clipr->ymin)
dy = min_ff(dy, cmp[a].y - clipr->ymin);
else if (cmp[a].y > clipr->ymax)
dy = max_ff(dy, cmp[a].y - clipr->ymax);
}
}
for (a = 0; a < cuma->totpoint; a++) {
if (cmp[a].flag & CUMA_SELECT) {
cmp[a].x -= dx;
cmp[a].y -= dy;
}
}
}
qsort(cmp, cuma->totpoint, sizeof(CurveMapPoint), sort_curvepoints);
/* remove doubles, threshold set on 1% of default range */
if (rem_doubles && cuma->totpoint > 2) {
for (a = 0; a < cuma->totpoint - 1; a++) {
dx = cmp[a].x - cmp[a + 1].x;
dy = cmp[a].y - cmp[a + 1].y;
if (sqrtf(dx * dx + dy * dy) < thresh) {
if (a == 0) {
cmp[a + 1].flag |= CUMA_VECTOR;
if (cmp[a + 1].flag & CUMA_SELECT)
cmp[a].flag |= CUMA_SELECT;
}
else {
cmp[a].flag |= CUMA_VECTOR;
if (cmp[a].flag & CUMA_SELECT)
cmp[a + 1].flag |= CUMA_SELECT;
}
break; /* we assume 1 deletion per edit is ok */
}
}
if (a != cuma->totpoint - 1)
curvemap_remove(cuma, 2);
}
curvemap_make_table(cuma, clipr);
}
示例7: ED_space_image_get_size
void ED_space_image_get_size(SpaceImage *sima, int *width, int *height)
{
Scene *scene = sima->iuser.scene;
ImBuf *ibuf;
void *lock;
ibuf = ED_space_image_acquire_buffer(sima, &lock);
if (ibuf && ibuf->x > 0 && ibuf->y > 0) {
*width = ibuf->x;
*height = ibuf->y;
}
else if (sima->image && sima->image->type == IMA_TYPE_R_RESULT && scene) {
/* not very important, just nice */
*width = (scene->r.xsch * scene->r.size) / 100;
*height = (scene->r.ysch * scene->r.size) / 100;
if ((scene->r.mode & R_BORDER) && (scene->r.mode & R_CROP)) {
*width *= BLI_rctf_size_x(&scene->r.border);
*height *= BLI_rctf_size_y(&scene->r.border);
}
}
/* I know a bit weak... but preview uses not actual image size */
// XXX else if (image_preview_active(sima, width, height));
else {
*width = IMG_SIZE_FALLBACK;
*height = IMG_SIZE_FALLBACK;
}
ED_space_image_release_buffer(sima, ibuf, lock);
}
示例8: blf_font_width_and_height
void blf_font_width_and_height(
FontBLF *font, const char *str, size_t len,
float *r_width, float *r_height, struct ResultBLF *r_info)
{
float xa, ya;
rctf box;
if (font->flags & BLF_ASPECT) {
xa = font->aspect[0];
ya = font->aspect[1];
}
else {
xa = 1.0f;
ya = 1.0f;
}
if (font->flags & BLF_WORD_WRAP) {
blf_font_boundbox__wrap(font, str, len, &box, r_info);
}
else {
blf_font_boundbox(font, str, len, &box, r_info);
}
*r_width = (BLI_rctf_size_x(&box) * xa);
*r_height = (BLI_rctf_size_y(&box) * ya);
}
示例9: dopesheet_view_all_exec
static int dopesheet_view_all_exec(bContext *C, wmOperator *UNUSED(op))
{
SpaceClip *sc = CTX_wm_space_clip(C);
ARegion *ar = CTX_wm_region(C);
View2D *v2d = &ar->v2d;
MovieClip *clip = ED_space_clip_get_clip(sc);
MovieTracking *tracking = &clip->tracking;
MovieTrackingDopesheet *dopesheet = &tracking->dopesheet;
MovieTrackingDopesheetChannel *channel;
int frame_min = INT_MAX, frame_max = INT_MIN;
for (channel = dopesheet->channels.first; channel; channel = channel->next) {
frame_min = min_ii(frame_min, channel->segments[0]);
frame_max = max_ii(frame_max, channel->segments[channel->tot_segment]);
}
if (frame_min < frame_max) {
float extra;
v2d->cur.xmin = frame_min;
v2d->cur.xmax = frame_max;
/* we need an extra "buffer" factor on either side so that the endpoints are visible */
extra = 0.01f * BLI_rctf_size_x(&v2d->cur);
v2d->cur.xmin -= extra;
v2d->cur.xmax += extra;
ED_region_tag_redraw(ar);
}
return OPERATOR_FINISHED;
}
示例10: 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;
}
示例11: BLI_rcti_rctf_copy
void BLI_rcti_rctf_copy(rcti *dst, const rctf *src)
{
dst->xmin = floorf(src->xmin + 0.5f);
dst->xmax = dst->xmin + floorf(BLI_rctf_size_x(src) + 0.5f);
dst->ymin = floorf(src->ymin + 0.5f);
dst->ymax = dst->ymin + floorf(BLI_rctf_size_y(src) + 0.5f);
}
示例12: TargetSnapOffset
static void TargetSnapOffset(TransInfo *t, TransData *td)
{
if (t->spacetype == SPACE_NODE && td != NULL) {
bNode *node = td->extra;
char border = t->tsnap.snapNodeBorder;
float width = BLI_rctf_size_x(&node->totr);
float height = BLI_rctf_size_y(&node->totr);
#ifdef USE_NODE_CENTER
if (border & NODE_LEFT)
t->tsnap.snapTarget[0] -= 0.5f * width;
if (border & NODE_RIGHT)
t->tsnap.snapTarget[0] += 0.5f * width;
if (border & NODE_BOTTOM)
t->tsnap.snapTarget[1] -= 0.5f * height;
if (border & NODE_TOP)
t->tsnap.snapTarget[1] += 0.5f * height;
#else
if (border & NODE_LEFT)
t->tsnap.snapTarget[0] -= 0.0f;
if (border & NODE_RIGHT)
t->tsnap.snapTarget[0] += width;
if (border & NODE_BOTTOM)
t->tsnap.snapTarget[1] -= height;
if (border & NODE_TOP)
t->tsnap.snapTarget[1] += 0.0f;
#endif
}
}
示例13: draw_seq_strips
/* draw the contents of the sequencer strips view */
static void draw_seq_strips(const bContext *C, Editing *ed, ARegion *ar)
{
Scene *scene = CTX_data_scene(C);
View2D *v2d = &ar->v2d;
Sequence *last_seq = BKE_sequencer_active_get(scene);
int sel = 0, j;
float pixelx = BLI_rctf_size_x(&v2d->cur) / BLI_rcti_size_x(&v2d->mask);
/* loop through twice, first unselected, then selected */
for (j = 0; j < 2; j++) {
Sequence *seq;
int outline_tint = (j) ? -60 : -150; /* highlighting around strip edges indicating selection */
/* loop through strips, checking for those that are visible */
for (seq = ed->seqbasep->first; seq; seq = seq->next) {
/* boundbox and selection tests for NOT drawing the strip... */
if ((seq->flag & SELECT) != sel) continue;
else if (seq == last_seq) continue;
else if (min_ii(seq->startdisp, seq->start) > v2d->cur.xmax) continue;
else if (max_ii(seq->enddisp, seq->start + seq->len) < v2d->cur.xmin) continue;
else if (seq->machine + 1.0f < v2d->cur.ymin) continue;
else if (seq->machine > v2d->cur.ymax) continue;
/* strip passed all tests unscathed... so draw it now */
draw_seq_strip(scene, ar, seq, outline_tint, pixelx);
}
/* draw selected next time round */
sel = SELECT;
}
/* draw the last selected last (i.e. 'active' in other parts of Blender), removes some overlapping error */
if (last_seq)
draw_seq_strip(scene, ar, last_seq, 120, pixelx);
}
示例14: gp_strokepoint_convertcoords
/* convert the coordinates from the given stroke point into 3d-coordinates
* - assumes that the active space is the 3D-View
*/
static void gp_strokepoint_convertcoords(bContext *C, bGPDstroke *gps, bGPDspoint *pt, float p3d[3], rctf *subrect)
{
Scene *scene = CTX_data_scene(C);
View3D *v3d = CTX_wm_view3d(C);
ARegion *ar = CTX_wm_region(C);
if (gps->flag & GP_STROKE_3DSPACE) {
/* directly use 3d-coordinates */
copy_v3_v3(p3d, &pt->x);
}
else {
const float *fp = ED_view3d_cursor3d_get(scene, v3d);
float mvalf[2];
/* get screen coordinate */
if (gps->flag & GP_STROKE_2DSPACE) {
View2D *v2d = &ar->v2d;
UI_view2d_view_to_region_fl(v2d, pt->x, pt->y, &mvalf[0], &mvalf[1]);
}
else {
if (subrect) {
mvalf[0] = (((float)pt->x / 100.0f) * BLI_rctf_size_x(subrect)) + subrect->xmin;
mvalf[1] = (((float)pt->y / 100.0f) * BLI_rctf_size_y(subrect)) + subrect->ymin;
}
else {
mvalf[0] = (float)pt->x / 100.0f * ar->winx;
mvalf[1] = (float)pt->y / 100.0f * ar->winy;
}
}
ED_view3d_win_to_3d(ar, fp, mvalf, p3d);
}
}
示例15: square_rctf
static float square_rctf(rctf *rf)
{
float x, y;
x = BLI_rctf_size_x(rf);
y = BLI_rctf_size_y(rf);
return x * y;
}