当前位置: 首页>>代码示例>>C++>>正文


C++ BLI_snprintf函数代码示例

本文整理汇总了C++中BLI_snprintf函数的典型用法代码示例。如果您正苦于以下问题:C++ BLI_snprintf函数的具体用法?C++ BLI_snprintf怎么用?C++ BLI_snprintf使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了BLI_snprintf函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: nla_draw_strip_frames_text

/* add frame extents to cache of text-strings to draw in pixelspace
 * for now, only used when transforming strips
 */
static void nla_draw_strip_frames_text(NlaTrack *UNUSED(nlt), NlaStrip *strip, View2D *v2d, float UNUSED(yminc), float ymaxc)
{
	const float ytol = 1.0f; /* small offset to vertical positioning of text, for legibility */
	const char col[4] = {220, 220, 220, 255}; /* light gray */
	char numstr[32] = "";
	
	
	/* Always draw times above the strip, whereas sequencer drew below + above.
	 * However, we should be fine having everything on top, since these tend to be 
	 * quite spaced out. 
	 *	- 1 dp is compromise between lack of precision (ints only, as per sequencer)
	 *	  while also preserving some accuracy, since we do use floats
	 */
	/* start frame */
	BLI_snprintf(numstr, sizeof(numstr), "%.1f", strip->start);
	UI_view2d_text_cache_add(v2d, strip->start - 1.0f, ymaxc + ytol, numstr, col);
	
	/* end frame */
	BLI_snprintf(numstr, sizeof(numstr), "%.1f", strip->end);
	UI_view2d_text_cache_add(v2d, strip->end, ymaxc + ytol, numstr, col);
}
开发者ID:YasirArafath,项目名称:blender-git,代码行数:24,代码来源:nla_draw.c

示例2: initglobals

void initglobals(void)
{
	memset(&G, 0, sizeof(Global));
	
	U.savetime = 1;

	G.main = BKE_main_new();

	strcpy(G.ima, "//");

	if (BLENDER_SUBVERSION)
		BLI_snprintf(versionstr, sizeof(versionstr), "v%d.%02d.%d", BLENDER_VERSION / 100, BLENDER_VERSION % 100, BLENDER_SUBVERSION);
	else
		BLI_snprintf(versionstr, sizeof(versionstr), "v%d.%02d", BLENDER_VERSION / 100, BLENDER_VERSION % 100);

#ifndef WITH_PYTHON_SECURITY /* default */
	G.f |= G_SCRIPT_AUTOEXEC;
#else
	G.f &= ~G_SCRIPT_AUTOEXEC;
#endif
}
开发者ID:akonneker,项目名称:blensor,代码行数:21,代码来源:blender.c

示例3: unpack_generate_paths

static void unpack_generate_paths(
        const char *name, ID *id, char *r_abspath, char *r_relpath, size_t abspathlen, size_t relpathlen)
{
	char tempname[FILE_MAX];
	char tempdir[FILE_MAXDIR];

	BLI_split_dirfile(name, tempdir, tempname, sizeof(tempdir), sizeof(tempname));

	if (tempname[0] == '\0') {
		/* Note: we do not have any real way to re-create extension out of data... */
		BLI_strncpy(tempname, id->name + 2, sizeof(tempname));
		printf("%s\n", tempname);
		BLI_filename_make_safe(tempname);
		printf("%s\n", tempname);
	}

	if (tempdir[0] == '\0') {
		/* Fallback to relative dir. */
		BLI_strncpy(tempdir, "//", sizeof(tempdir));
	}

	switch (GS(id->name)) {
		case ID_VF:
			BLI_snprintf(r_relpath, relpathlen, "//fonts/%s", tempname);
			break;
		case ID_SO:
			BLI_snprintf(r_relpath, relpathlen, "//sounds/%s", tempname);
			break;
		case ID_IM:
			BLI_snprintf(r_relpath, relpathlen, "//textures/%s", tempname);
			break;
		default:
			break;
	}

	{
		size_t len = BLI_strncpy_rlen(r_abspath, tempdir, abspathlen);
		BLI_strncpy(r_abspath + len, tempname, abspathlen - len);
	}
}
开发者ID:wchargin,项目名称:blender,代码行数:40,代码来源:packedFile.c

示例4: handle_subversion_warning

static int handle_subversion_warning(Main *main)
{
    if(main->minversionfile > BLENDER_VERSION ||
            (main->minversionfile == BLENDER_VERSION &&
             main->minsubversionfile > BLENDER_SUBVERSION)) {

        char str[128];

        BLI_snprintf(str, sizeof(str), "File written by newer Blender binary: %d.%d , expect loss of data!", main->minversionfile, main->minsubversionfile);
// XXX		error(str);
    }
    return 1;
}
开发者ID:OldBrunet,项目名称:BGERTPS,代码行数:13,代码来源:blender.c

示例5: get_proxy_filename

static void get_proxy_filename(struct anim *anim, IMB_Proxy_Size preview_size,
                               char *fname, bool temp)
{
	char index_dir[FILE_MAXDIR];
	int i = IMB_proxy_size_to_array_index(preview_size);

	char proxy_name[256];
	char stream_suffix[20];
	const char *name = (temp) ? "proxy_%d%s_part.avi" : "proxy_%d%s.avi";
	
	stream_suffix[0] = 0;

	if (anim->streamindex > 0) {
		BLI_snprintf(stream_suffix, sizeof(stream_suffix), "_st%d", anim->streamindex);
	}

	BLI_snprintf(proxy_name, sizeof(proxy_name), name,
	             (int) (proxy_fac[i] * 100), stream_suffix, anim->suffix);

	get_index_dir(anim, index_dir, sizeof(index_dir));

	BLI_join_dirfile(fname, FILE_MAXFILE + FILE_MAXDIR, index_dir, proxy_name);
}
开发者ID:mgschwan,项目名称:blensor,代码行数:23,代码来源:indexer.c

示例6: edbm_bevel_update_header

static void edbm_bevel_update_header(wmOperator *op, bContext *C)
{
	const char *str = IFACE_("Confirm: (Enter/LMB), Cancel: (Esc/RMB), Offset: %s, Segments: %d");

	char msg[HEADER_LENGTH];
	ScrArea *sa = CTX_wm_area(C);

	if (sa) {
		BevelData *opdata = op->customdata;
		char offset_str[NUM_STR_REP_LEN];

		if (hasNumInput(&opdata->num_input)) {
			outputNumInput(&opdata->num_input, offset_str);
		}
		else {
			BLI_snprintf(offset_str, NUM_STR_REP_LEN, "%f", RNA_float_get(op->ptr, "offset"));
		}

		BLI_snprintf(msg, HEADER_LENGTH, str, offset_str, RNA_int_get(op->ptr, "segments"));

		ED_area_headerprint(sa, msg);
	}
}
开发者ID:silkentrance,项目名称:blender,代码行数:23,代码来源:editmesh_bevel.c

示例7: set_pass_name

static void set_pass_name(char *passname, int passtype, int channel, const char *view)
{
	const char delims[] = {'.', '\0'};
	const char *sep;
	const char *token;
	size_t len;

	const char *passtype_name = name_from_passtype(passtype, channel);

	if (view == NULL || view[0] == '\0') {
		BLI_strncpy(passname, passtype_name, EXR_PASS_MAXNAME);
		return;
	}

	len = BLI_str_rpartition(passtype_name, delims, &sep, &token);

	if (sep) {
		BLI_snprintf(passname, EXR_PASS_MAXNAME, "%.*s.%s.%s", (int)len, passtype_name, view, token);
	}
	else {
		BLI_snprintf(passname, EXR_PASS_MAXNAME, "%s.%s", passtype_name, view);
	}
}
开发者ID:sntulix,项目名称:blender-api-javascript,代码行数:23,代码来源:render_result.c

示例8: 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);
}
开发者ID:danielmarg,项目名称:blender-main,代码行数:49,代码来源:node_header.c

示例9: get_proxy_fname

/* supposed to work with sequences only */
static void get_proxy_fname(MovieClip *clip, int proxy_render_size, int undistorted, int framenr, char *name)
{
    int size = rendersize_to_number(proxy_render_size);
    char dir[FILE_MAX], clipdir[FILE_MAX], clipfile[FILE_MAX];

    BLI_split_dirfile(clip->name, clipdir, clipfile, FILE_MAX, FILE_MAX);

    if (clip->flag & MCLIP_USE_PROXY_CUSTOM_DIR) {
        BLI_strncpy(dir, clip->proxy.dir, sizeof(dir));
    }
    else {
        BLI_snprintf(dir, FILE_MAX, "%s/BL_proxy", clipdir);
    }

    if (undistorted)
        BLI_snprintf(name, FILE_MAX, "%s/%s/proxy_%d_undistorted/%08d", dir, clipfile, size, framenr);
    else
        BLI_snprintf(name, FILE_MAX, "%s/%s/proxy_%d/%08d", dir, clipfile, size, framenr);

    BLI_path_abs(name, G.main->name);
    BLI_path_frame(name, 1, 0);

    strcat(name, ".jpg");
}
开发者ID:nttputus,项目名称:blensor,代码行数:25,代码来源:movieclip.c

示例10: pose_slide_draw_status

/* draw percentage indicator in header */
static void pose_slide_draw_status(tPoseSlideOp *pso)
{
	char status_str[UI_MAX_DRAW_STR];
	char mode_str[32];
	
	switch (pso->mode) {
		case POSESLIDE_PUSH:
			strcpy(mode_str, "Push Pose");
			break;
		case POSESLIDE_RELAX:
			strcpy(mode_str, "Relax Pose");
			break;
		case POSESLIDE_BREAKDOWN:
			strcpy(mode_str, "Breakdown");
			break;
		
		default:
			/* unknown */
			strcpy(mode_str, "Sliding-Tool");
			break;
	}
	
	if (hasNumInput(&pso->num)) {
		Scene *scene = pso->scene;
		char str_offs[NUM_STR_REP_LEN];
		
		outputNumInput(&pso->num, str_offs, &scene->unit);
		
		BLI_snprintf(status_str, sizeof(status_str), "%s: %s", mode_str, str_offs);
	}
	else {
		BLI_snprintf(status_str, sizeof(status_str), "%s: %d %%", mode_str, (int)(pso->percentage * 100.0f));
	}
	
	ED_area_headerprint(pso->sa, status_str);
}
开发者ID:UPBGE,项目名称:blender,代码行数:37,代码来源:pose_slide.c

示例11: fluidsim_find_lastframe

static int fluidsim_find_lastframe(FluidsimSettings *fss)
{
	char targetDir[FILE_MAXFILE+FILE_MAXDIR], targetFile[FILE_MAXFILE+FILE_MAXDIR];
	int curFrame = 1;

	BLI_snprintf(targetDir, sizeof(targetDir), "%sfluidsurface_final_####.bobj.gz", fss->surfdataPath);
	BLI_path_abs(targetDir, G.main->name);

	do {
		BLI_strncpy(targetFile, targetDir, sizeof(targetFile));
		BLI_path_frame(targetFile, curFrame++, 0);
	} while(BLI_exist(targetFile));

	return curFrame - 1;
}
开发者ID:BHCLL,项目名称:blendocv,代码行数:15,代码来源:rna_fluidsim.c

示例12: unit_scale_str

static int unit_scale_str(char *str, int len_max, char *str_tmp, double scale_pref, bUnitDef *unit,
                          const char *replace_str)
{
	char *str_found;

	if ((len_max > 0) && (str_found = (char *)unit_find_str(str, replace_str))) {
		/* XXX - investigate, does not respect len_max properly  */

		int len, len_num, len_name, len_move, found_ofs;

		found_ofs = (int)(str_found - str);

		len = strlen(str);

		len_name = strlen(replace_str);
		len_move = (len - (found_ofs + len_name)) + 1; /* 1+ to copy the string terminator */
		len_num = BLI_snprintf(str_tmp, TEMP_STR_SIZE, "*%g"SEP_STR, unit->scalar / scale_pref); /* # removed later */

		if (len_num > len_max)
			len_num = len_max;

		if (found_ofs + len_num + len_move > len_max) {
			/* can't move the whole string, move just as much as will fit */
			len_move -= (found_ofs + len_num + len_move) - len_max;
		}

		if (len_move > 0) {
			/* resize the last part of the string */
			memmove(str_found + len_num, str_found + len_name, len_move); /* may grow or shrink the string */
		}

		if (found_ofs + len_num > len_max) {
			/* not even the number will fit into the string, only copy part of it */
			len_num -= (found_ofs + len_num) - len_max;
		}

		if (len_num > 0) {
			/* its possible none of the number could be copied in */
			memcpy(str_found, str_tmp, len_num); /* without the string terminator */
		}

		/* since the null terminator wont be moved if the stringlen_max
		 * was not long enough to fit everything in it */
		str[len_max - 1] = '\0';
		return found_ofs + len_num;
	}
	return 0;
}
开发者ID:Walid-Shouman,项目名称:Blender,代码行数:48,代码来源:unit.c

示例13: ui_imageuser_slot_menu

static void ui_imageuser_slot_menu(bContext *UNUSED(C), uiLayout *layout, void *image_p)
{
  uiBlock *block = uiLayoutGetBlock(layout);
  Image *image = image_p;
  int slot_id;

  uiDefBut(block,
           UI_BTYPE_LABEL,
           0,
           IFACE_("Slot"),
           0,
           0,
           UI_UNIT_X * 5,
           UI_UNIT_Y,
           NULL,
           0.0,
           0.0,
           0,
           0,
           "");
  uiItemS(layout);

  slot_id = BLI_listbase_count(&image->renderslots) - 1;
  for (RenderSlot *slot = image->renderslots.last; slot; slot = slot->prev) {
    char str[64];
    if (slot->name[0] != '\0') {
      BLI_strncpy(str, slot->name, sizeof(str));
    }
    else {
      BLI_snprintf(str, sizeof(str), IFACE_("Slot %d"), slot_id + 1);
    }
    uiDefButS(block,
              UI_BTYPE_BUT_MENU,
              B_NOP,
              str,
              0,
              0,
              UI_UNIT_X * 5,
              UI_UNIT_X,
              &image->render_slot,
              (float)slot_id,
              0.0,
              0,
              -1,
              "");
    slot_id--;
  }
}
开发者ID:dfelinto,项目名称:blender,代码行数:48,代码来源:image_buttons.c

示例14: BPY_modules_load_user

void BPY_modules_load_user(bContext *C)
{
	PyGILState_STATE gilstate;
	Main *bmain = CTX_data_main(C);
	Text *text;

	/* can happen on file load */
	if (bmain == NULL)
		return;

	/* update pointers since this can run from a nested script
	 * on file load */
	if (py_call_level) {
		BPY_context_update(C);
	}

	bpy_context_set(C, &gilstate);

	for (text = bmain->text.first; text; text = text->id.next) {
		if (text->flags & TXT_ISSCRIPT && BLI_testextensie(text->id.name + 2, ".py")) {
			if (!(G.f & G_SCRIPT_AUTOEXEC)) {
				if (!(G.f & G_SCRIPT_AUTOEXEC_FAIL_QUIET)) {
					G.f |= G_SCRIPT_AUTOEXEC_FAIL;
					BLI_snprintf(G.autoexec_fail, sizeof(G.autoexec_fail), "Text '%s'", text->id.name + 2);

					printf("scripts disabled for \"%s\", skipping '%s'\n", bmain->name, text->id.name + 2);
				}
			}
			else {
				PyObject *module = bpy_text_import(text);

				if (module == NULL) {
					PyErr_Print();
					PyErr_Clear();
				}
				else {
					Py_DECREF(module);
				}

				/* check if the script loaded a new file */
				if (bmain != CTX_data_main(C)) {
					break;
				}
			}
		}
	}
	bpy_context_clear(C, &gilstate);
}
开发者ID:UPBGE,项目名称:blender,代码行数:48,代码来源:bpy_interface.c

示例15: MEM_callocN

BoidState *boid_new_state(BoidSettings *boids)
{
	BoidState *state = MEM_callocN(sizeof(BoidState), "BoidState");

	state->id = boids->last_state_id++;
	if (state->id)
		BLI_snprintf(state->name, sizeof(state->name), "State %i", state->id);
	else
		strcpy(state->name, "State");

	state->rule_fuzziness = 0.5;
	state->volume = 1.0f;
	state->channels |= ~0;

	return state;
}
开发者ID:Andrewson3D,项目名称:blender-for-vray,代码行数:16,代码来源:boids.c


注:本文中的BLI_snprintf函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。