示例#1
0
/* 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);
}
示例#2
0
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
}
示例#3
0
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);
	}
}
示例#4
0
static void template_texture_user_menu(bContext *C, uiLayout *layout, void *UNUSED(arg))
{
    /* callback when opening texture user selection menu, to create buttons. */
    SpaceButs *sbuts = CTX_wm_space_buts(C);
    ButsContextTexture *ct = sbuts->texuser;
    ButsTextureUser *user;
    uiBlock *block = uiLayoutGetBlock(layout);
    const char *last_category = NULL;

    for (user = ct->users.first; user; user = user->next) {
        uiBut *but;
        char name[UI_MAX_NAME_STR];

        /* add label per category */
        if (!last_category || strcmp(last_category, user->category) != 0) {
            uiItemL(layout, user->category, ICON_NONE);
            but = block->buttons.last;
            but->flag = UI_TEXT_LEFT;
        }

        /* create button */
        if (user->prop) {
            PointerRNA texptr = RNA_property_pointer_get(&user->ptr, user->prop);
            Tex *tex = texptr.data;

            if (tex)
                BLI_snprintf(name, UI_MAX_NAME_STR, "  %s - %s", user->name, tex->id.name + 2);
            else
                BLI_snprintf(name, UI_MAX_NAME_STR, "  %s", user->name);
        }
        else
            BLI_snprintf(name, UI_MAX_NAME_STR, "  %s", user->name);

        but = uiDefIconTextBut(block, BUT, 0, user->icon, name, 0, 0, UI_UNIT_X * 4, UI_UNIT_Y,
                               NULL, 0.0, 0.0, 0.0, 0.0, "");
        uiButSetNFunc(but, template_texture_select, MEM_dupallocN(user), NULL);

        last_category = user->category;
    }
}
示例#5
0
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;
}
示例#6
0
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);
}
示例#7
0
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);
	}
}
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);
	}
}
示例#9
0
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);
}
示例#10
0
/* add the relevant text to the cache of text-strings to draw in pixelspace */
static void nla_draw_strip_text(AnimData *adt, NlaTrack *nlt, NlaStrip *strip, int index, View2D *v2d, float yminc, float ymaxc)
{
	short notSolo = ((adt && (adt->flag & ADT_NLA_SOLO_TRACK)) && (nlt->flag & NLATRACK_SOLO) == 0);
	char str[256];
	size_t str_len;
	char col[4];
	float xofs;
	rctf rect;
	
	/* just print the name and the range */
	if (strip->flag & NLASTRIP_FLAG_TEMP_META) {
		str_len = BLI_snprintf(str, sizeof(str), "%d) Temp-Meta", index);
	}
	else {
		str_len = BLI_strncpy_rlen(str, strip->name, sizeof(str));
	}
	
	/* set text color - if colors (see above) are light, draw black text, otherwise draw white */
	if (strip->flag & (NLASTRIP_FLAG_ACTIVE | NLASTRIP_FLAG_SELECT | NLASTRIP_FLAG_TWEAKUSER)) {
		col[0] = col[1] = col[2] = 0;
	}
	else {
		col[0] = col[1] = col[2] = 255;
	}
	
	/* text opacity depends on whether if there's a solo'd track, this isn't it */
	if (notSolo == 0)
		col[3] = 255;
	else
		col[3] = 128;
	
	/* determine the amount of padding required - cannot be constant otherwise looks weird in some cases */
	if ((strip->end - strip->start) <= 5.0f)
		xofs = 0.5f;
	else
		xofs = 1.0f;
	
	/* set bounding-box for text 
	 *	- padding of 2 'units' on either side
	 */
	// TODO: make this centered?
	rect.xmin = strip->start + xofs;
	rect.ymin = yminc;
	rect.xmax = strip->end - xofs;
	rect.ymax = ymaxc;
	
	/* add this string to the cache of texts to draw */
	UI_view2d_text_cache_add_rectf(v2d, &rect, str, str_len, col);
}
示例#11
0
/* 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");
}
示例#12
0
/* 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);
}
示例#13
0
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;
}
示例#14
0
static void add_hook_object(Main *bmain, Scene *scene, Object *obedit, Object *ob, int mode)
{
	ModifierData *md=NULL;
	HookModifierData *hmd = NULL;
	float cent[3];
	int tot, ok, *indexar;
	char name[32];
	
	ok = object_hook_index_array(obedit, &tot, &indexar, name, cent);
	
	if (!ok) return;	// XXX error("Requires selected vertices or active Vertex Group");
	
	if (mode==OBJECT_ADDHOOK_NEWOB && !ob) {
		
		ob = add_hook_object_new(scene, obedit);
		
		/* transform cent to global coords for loc */
		mul_v3_m4v3(ob->loc, obedit->obmat, cent);
	}
	
	md = obedit->modifiers.first;
	while (md && modifierType_getInfo(md->type)->type==eModifierTypeType_OnlyDeform) {
		md = md->next;
	}
	
	hmd = (HookModifierData*) modifier_new(eModifierType_Hook);
	BLI_insertlinkbefore(&obedit->modifiers, md, hmd);
	BLI_snprintf(hmd->modifier.name, sizeof(hmd->modifier.name), "Hook-%s", ob->id.name+2);
	modifier_unique_name(&obedit->modifiers, (ModifierData*)hmd);
	
	hmd->object= ob;
	hmd->indexar= indexar;
	copy_v3_v3(hmd->cent, cent);
	hmd->totindex= tot;
	BLI_strncpy(hmd->name, name, sizeof(hmd->name));
	
	/* matrix calculus */
	/* vert x (obmat x hook->imat) x hook->obmat x ob->imat */
	/*        (parentinv         )                          */
	where_is_object(scene, ob);
	
	invert_m4_m4(ob->imat, ob->obmat);
	/* apparently this call goes from right to left... */
	mul_serie_m4(hmd->parentinv, ob->imat, obedit->obmat, NULL, 
				 NULL, NULL, NULL, NULL, NULL);
	
	DAG_scene_sort(bmain, scene);
}
示例#15
0
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;
}
示例#16
0
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--;
  }
}
示例#17
0
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);
}
示例#18
0
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;
}
示例#19
0
/**
 * EditTranslation utility funcs and operator,
 * \note: this includes utility functions and button matching checks.
 * this only works in conjunction with a py operator!
 */
static void edittranslation_find_po_file(const char *root,
                                         const char *uilng,
                                         char *path,
                                         const size_t maxlen)
{
  char tstr[32]; /* Should be more than enough! */

  /* First, full lang code. */
  BLI_snprintf(tstr, sizeof(tstr), "%s.po", uilng);
  BLI_join_dirfile(path, maxlen, root, uilng);
  BLI_path_append(path, maxlen, tstr);
  if (BLI_is_file(path)) {
    return;
  }

  /* Now try without the second iso code part (_ES in es_ES). */
  {
    const char *tc = NULL;
    size_t szt = 0;
    tstr[0] = '\0';

    tc = strchr(uilng, '_');
    if (tc) {
      szt = tc - uilng;
      if (szt < sizeof(tstr)) {            /* Paranoid, should always be true! */
        BLI_strncpy(tstr, uilng, szt + 1); /* +1 for '\0' char! */
      }
    }
    if (tstr[0]) {
      /* Because of some codes like sr_SR@latin... */
      tc = strchr(uilng, '@');
      if (tc) {
        BLI_strncpy(tstr + szt, tc, sizeof(tstr) - szt);
      }

      BLI_join_dirfile(path, maxlen, root, tstr);
      strcat(tstr, ".po");
      BLI_path_append(path, maxlen, tstr);
      if (BLI_is_file(path)) {
        return;
      }
    }
  }

  /* Else no po file! */
  path[0] = '\0';
}
示例#20
0
/* This function updates the header of the UV editor when the stitch tool updates its settings */
static void stitch_update_header(StitchState *stitch_state, bContext *C)
{
	static char str[] = "(S)nap %s, (M)idpoints %s, (L)imit %.2f (Alt Wheel adjust) %s, Switch (I)sland, shift select vertices";

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

	if (sa) {
		BLI_snprintf(msg, HEADER_LENGTH, str,
		             stitch_state->snap_islands ? "On" : "Off",
		             stitch_state->midpoints    ? "On" : "Off",
		             stitch_state->limit_dist,
		             stitch_state->use_limit    ? "On" : "Off");

		ED_area_headerprint(sa, msg);
	}
}
示例#21
0
int BLI_path_frame_range(char *path, int sta, int end, int digits)
{
	int ch_sta, ch_end;

	if (digits)
		ensure_digits(path, digits);

	if (stringframe_chars(path, &ch_sta, &ch_end)) { /* warning, ch_end is the last # +1 */
		char tmp[FILE_MAX];
		BLI_snprintf(tmp, sizeof(tmp),
		             "%.*s%.*d-%.*d%s",
		             ch_sta, path, ch_end - ch_sta, sta, ch_end - ch_sta, end, path + ch_end);
		BLI_strncpy(path, tmp, FILE_MAX);
		return 1;
	}
	return 0;
}
示例#22
0
void clip_delete_track(bContext *C, MovieClip *clip, MovieTrackingTrack *track)
{
	MovieTracking *tracking = &clip->tracking;
	MovieTrackingStabilization *stab = &tracking->stabilization;
	MovieTrackingTrack *act_track = BKE_tracking_track_get_active(tracking);
	ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking);
	bool has_bundle = false, update_stab = false;
	char track_name_escaped[MAX_NAME], prefix[MAX_NAME * 2];

	if (track == act_track)
		tracking->act_track = NULL;

	if (track == stab->rot_track) {
		stab->rot_track = NULL;

		update_stab = true;
	}

	/* handle reconstruction display in 3d viewport */
	if (track->flag & TRACK_HAS_BUNDLE)
		has_bundle = true;

	/* Make sure no plane will use freed track */
	BKE_tracking_plane_tracks_remove_point_track(tracking, track);

	/* Delete f-curves associated with the track (such as weight, i.e.) */
	BLI_strescape(track_name_escaped, track->name, sizeof(track_name_escaped));
	BLI_snprintf(prefix, sizeof(prefix), "tracks[\"%s\"]", track_name_escaped);
	BKE_animdata_fix_paths_remove(&clip->id, prefix);

	BKE_tracking_track_free(track);
	BLI_freelinkN(tracksbase, track);

	WM_event_add_notifier(C, NC_MOVIECLIP | NA_EDITED, clip);

	if (update_stab) {
		tracking->stabilization.ok = false;
		WM_event_add_notifier(C, NC_MOVIECLIP | ND_DISPLAY, clip);
	}

	DAG_id_tag_update(&clip->id, 0);

	if (has_bundle)
		WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, NULL);
}
示例#23
0
static void walk_update_header(bContext *C, wmOperator *op, WalkInfo *walk)
{
  const bool gravity = (walk->navigation_mode == WALK_MODE_GRAVITY) ||
                       ((walk->teleport.state == WALK_TELEPORT_STATE_ON) &&
                        (walk->teleport.navigation_mode == WALK_MODE_GRAVITY));
  char header[UI_MAX_DRAW_STR];
  char buf[UI_MAX_DRAW_STR];

  char *p = buf;
  int available_len = sizeof(buf);

#define WM_MODALKEY(_id) \
  WM_modalkeymap_operator_items_to_string_buf( \
      op->type, (_id), true, UI_MAX_SHORTCUT_STR, &available_len, &p)

  BLI_snprintf(header,
               sizeof(header),
               IFACE_("%s: confirm, %s: cancel, "
                      "%s: gravity (%s), "
                      "%s|%s|%s|%s: move around, "
                      "%s: fast, %s: slow, "
                      "%s|%s: up and down, "
                      "%s: teleport, %s: jump, "
                      "%s: increase speed, %s: decrease speed"),
               WM_MODALKEY(WALK_MODAL_CONFIRM),
               WM_MODALKEY(WALK_MODAL_CANCEL),
               WM_MODALKEY(WALK_MODAL_TOGGLE),
               WM_bool_as_string(gravity),
               WM_MODALKEY(WALK_MODAL_DIR_FORWARD),
               WM_MODALKEY(WALK_MODAL_DIR_LEFT),
               WM_MODALKEY(WALK_MODAL_DIR_BACKWARD),
               WM_MODALKEY(WALK_MODAL_DIR_RIGHT),
               WM_MODALKEY(WALK_MODAL_FAST_ENABLE),
               WM_MODALKEY(WALK_MODAL_SLOW_ENABLE),
               WM_MODALKEY(WALK_MODAL_DIR_UP),
               WM_MODALKEY(WALK_MODAL_DIR_DOWN),
               WM_MODALKEY(WALK_MODAL_TELEPORT),
               WM_MODALKEY(WALK_MODAL_JUMP),
               WM_MODALKEY(WALK_MODAL_ACCELERATE),
               WM_MODALKEY(WALK_MODAL_DECELERATE));

#undef WM_MODALKEY

  ED_workspace_status_text(C, header);
}
示例#24
0
/* create a new, non-existing folder name, returns 1 if successful, 0 if name couldn't be created.
 * The actual name is returned in 'name', 'folder' contains the complete path, including the new folder name.
 */
static int new_folder_path(const char *parent, char *folder, char *name)
{
	int i = 1;
	int len = 0;

	BLI_strncpy(name, "New Folder", FILE_MAXFILE);
	BLI_join_dirfile(folder, FILE_MAX, parent, name); /* XXX, not real length */
	/* check whether folder with the name already exists, in this case
	 * add number to the name. Check length of generated name to avoid
	 * crazy case of huge number of folders each named 'New Folder (x)' */
	while (BLI_exists(folder) && (len < FILE_MAXFILE)) {
		len = BLI_snprintf(name, FILE_MAXFILE, "New Folder(%d)", i);
		BLI_join_dirfile(folder, FILE_MAX, parent, name); /* XXX, not real length */
		i++;
	}

	return (len < FILE_MAXFILE);
}
示例#25
0
static void walk_update_header(bContext *C, WalkInfo *walk)
{
	bool gravity = walk->navigation_mode == WALK_MODE_GRAVITY ||
	(walk->teleport.state == WALK_TELEPORT_STATE_ON &&
	 walk->teleport.navigation_mode == WALK_MODE_GRAVITY);

#define HEADER_LENGTH 256
	char header[HEADER_LENGTH];

	BLI_snprintf(header, HEADER_LENGTH, IFACE_("LMB/Return: confirm, Esc/RMB: cancel, "
                                               "Tab: gravity (%s), "
	                                           "WASD: move around, "
	                                           "QE: up and down, MMB/Space: teleport, V: jump, "
	                                           "Pad +/Wheel Up: increase speed, Pad -/Wheel Down: decrease speed"),
	             WM_bool_as_string(gravity));
	ED_area_headerprint(CTX_wm_area(C), header);
#undef HEADER_LENGTH
}
示例#26
0
static void ui_imageuser_slot_menu(bContext *UNUSED(C), uiLayout *layout, void *render_slot_p)
{
	uiBlock *block = uiLayoutGetBlock(layout);
	short *render_slot = render_slot_p;
	int slot;

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

	slot = IMA_MAX_RENDER_SLOT;
	while (slot--) {
		char str[32];
		BLI_snprintf(str, sizeof(str), IFACE_("Slot %d"), slot + 1);
		uiDefButS(block, BUTM, B_NOP, str, 0, 0,
		          UI_UNIT_X * 5, UI_UNIT_X, render_slot, (float) slot, 0.0, 0, -1, "");
	}
}
示例#27
0
void unique_property(bProperty *first, bProperty *prop, int force)
{
	bProperty *p;

	/* set the first if its not set */
	if (first == NULL) {
		first = prop;
		while (first->prev) {
			first = first->prev;
		}
	}

	if (force) {
		/* change other names to make them unique */
		while ((p = get_property__internal(first, prop, prop->name))) {
			unique_property(first, p, 0);
		}
	}
	else {
		/* change our own name until its unique */
		if (get_property__internal(first, prop, prop->name)) {
			/* there is a collision */
			char new_name[sizeof(prop->name)];
			char base_name[sizeof(prop->name)];
			char num[sizeof(prop->name)];
			int i = 0;

			/* strip numbers */
			BLI_strncpy(base_name, prop->name, sizeof(base_name));
			for (i = strlen(base_name) - 1; (i >= 0 && isdigit(base_name[i])); i--) {
				base_name[i] = '\0';
			}
			i = 0;

			do { /* ensure we have enough chars for the new number in the name */
				BLI_snprintf(num, sizeof(num), "%d", i++);
				BLI_strncpy(new_name, base_name, sizeof(prop->name) - strlen(num));
				strcat(new_name, num);
			} while (get_property__internal(first, prop, new_name));

			BLI_strncpy(prop->name, new_name, sizeof(prop->name));
		}
	}
}
示例#28
0
static char *find_new_name(char *name)
{
	char tempname[FILE_MAX];
	char *newname;
	size_t len;
	
	if (fop_exists(name)) {
		for (number = 1; number <= 999; number++) {
			BLI_snprintf(tempname, sizeof(tempname), "%s.%03d", name, number);
			if (! fop_exists(tempname)) {
				break;
			}
		}
	}
	len= strlen(tempname) + 1;
	newname = MEM_mallocN(len, "find_new_name");
	memcpy(newname, tempname, len * sizeof(char));
	return newname;
}
示例#29
0
/* generic  search invoke */
static void node_find_cb(const struct bContext *C, void *UNUSED(arg), const char *str, uiSearchItems *items)
{
	SpaceNode *snode = CTX_wm_space_node(C);
	bNode *node;
	
	for (node = snode->edittree->nodes.first; node; node = node->next) {
		
		if (BLI_strcasestr(node->name, str) || BLI_strcasestr(node->label, str)) {
			char name[256];
			
			if (node->label[0])
				BLI_snprintf(name, 256, "%s (%s)", node->name, node->label);
			else
				BLI_strncpy(name, node->name, 256);
			if (false == UI_search_item_add(items, name, node, 0))
				break;
		}
	}
}
示例#30
0
void clip_draw_curfra_label(SpaceClip *sc, float x, float y)
{
	uiStyle *style = UI_GetStyle();
	int fontid = style->widget.uifont_id;
	char numstr[32];
	float font_dims[2] = {0.0f, 0.0f};

	/* frame number */
	BLF_size(fontid, 11.0f, U.dpi);
	BLI_snprintf(numstr, sizeof(numstr), "%d", sc->user.framenr);

	BLF_width_and_height(fontid, numstr, &font_dims[0], &font_dims[1]);

	glRecti(x, y, x + font_dims[0] + 6.0f, y + font_dims[1] + 4.0f);

	UI_ThemeColor(TH_TEXT);
	BLF_position(fontid, x + 2.0f, y + 2.0f, 0.0f);
	BLF_draw(fontid, numstr, sizeof(numstr));
}