Beispiel #1
0
/* evaluation settings for active NLA-Strip */
static void nla_panel_evaluation(const bContext *C, Panel *pa)
{
	PointerRNA strip_ptr;
	uiLayout *layout = pa->layout;
	uiLayout *col, *sub;
	uiBlock *block;

	/* check context and also validity of pointer */
	if (!nla_panel_context(C, NULL, NULL, &strip_ptr))
		return;
		
	block = uiLayoutGetBlock(layout);
	UI_block_func_handle_set(block, do_nla_region_buttons, NULL);
		
	col = uiLayoutColumn(layout, true);
	uiItemR(col, &strip_ptr, "use_animated_influence", 0, NULL, ICON_NONE);
	
	sub = uiLayoutColumn(col, true);
	uiLayoutSetEnabled(sub, RNA_boolean_get(&strip_ptr, "use_animated_influence"));
	uiItemR(sub, &strip_ptr, "influence", 0, NULL, ICON_NONE);

	col = uiLayoutColumn(layout, true);
	sub = uiLayoutRow(col, false);
	uiItemR(sub, &strip_ptr, "use_animated_time", 0, NULL, ICON_NONE);
	uiItemR(sub, &strip_ptr, "use_animated_time_cyclic", 0, NULL, ICON_NONE);

	sub = uiLayoutRow(col, false);
	uiLayoutSetEnabled(sub, RNA_boolean_get(&strip_ptr, "use_animated_time"));
	uiItemR(sub, &strip_ptr, "strip_time", 0, NULL, ICON_NONE);
}
Beispiel #2
0
/* evaluation settings for active NLA-Strip */
static void nla_panel_evaluation(const bContext *C, Panel *pa)
{
	PointerRNA strip_ptr;
	uiLayout *layout= pa->layout;
	uiLayout *column, *subcolumn, *subrow;
	uiBlock *block;

	/* check context and also validity of pointer */
	if (!nla_panel_context(C, NULL, NULL, &strip_ptr))
		return;
		
	block= uiLayoutGetBlock(layout);
	uiBlockSetHandleFunc(block, do_nla_region_buttons, NULL);
		
	column= uiLayoutColumn(layout, 1);
		uiItemR(column, &strip_ptr, "use_animated_influence", 0, NULL, ICON_NULL);
		
		subcolumn= uiLayoutColumn(column, 1);
		uiLayoutSetEnabled(subcolumn, RNA_boolean_get(&strip_ptr, "use_animated_influence"));	
			uiItemR(subcolumn, &strip_ptr, "influence", 0, NULL, ICON_NULL);
		
	
	column= uiLayoutColumn(layout, 1);
		subrow= uiLayoutRow(column, 0);
		uiItemR(subrow, &strip_ptr, "use_animated_time", 0, NULL, ICON_NULL);
		uiItemR(subrow, &strip_ptr, "use_animated_time_cyclic", 0, NULL, ICON_NULL);

		subcolumn= uiLayoutColumn(column, 1);
		subrow= uiLayoutRow(subcolumn, 0);
		uiLayoutSetEnabled(subrow, RNA_boolean_get(&strip_ptr, "use_animated_time"));
			uiItemR(subcolumn, &strip_ptr, "strip_time", 0, NULL, ICON_NULL);
}
/* TODO de-duplicate redo panel functions - campbell */
static void view3d_panel_operator_redo(const bContext *C, Panel *pa)
{
	wmOperator *op = WM_operator_last_redo(C);
	ARegion *ar;
	ARegion *ar1;

	if (op == NULL) {
		return;
	}

	/* keep in sync with logic in ED_undo_operator_repeat() */
	ar = CTX_wm_region(C);
	ar1 = BKE_area_find_region_active_win(CTX_wm_area(C));
	if (ar1)
		CTX_wm_region_set((bContext *)C, ar1);

	if (WM_operator_poll((bContext *)C, op->type)) {
		uiBlock *block = uiLayoutGetBlock(pa->layout);

		if (!WM_operator_check_ui_enabled(C, op->type->name))
			uiLayoutSetEnabled(pa->layout, false);

		/* note, blockfunc is a default but->func, use Handle func to allow button callbacks too */
		UI_block_func_handle_set(block, ED_undo_operator_repeat_cb_evt, op);

		view3d_panel_operator_redo_operator(C, pa, op);
	}

	/* set region back */
	CTX_wm_region_set((bContext *)C, ar);
}
static void graph_panel_properties(const bContext *C, Panel *pa)
{
	bAnimListElem *ale;
	FCurve *fcu;
	PointerRNA fcu_ptr;
	uiLayout *layout = pa->layout;
	uiLayout *col, *row, *sub;
	// uiBlock *block;  // UNUSED
	char name[256];
	int icon = 0;

	if (!graph_panel_context(C, &ale, &fcu))
		return;
	
	// UNUSED
	// block = uiLayoutGetBlock(layout);
	// uiBlockSetHandleFunc(block, do_graph_region_buttons, NULL);
	
	/* F-Curve pointer */
	RNA_pointer_create(ale->id, &RNA_FCurve, fcu, &fcu_ptr);
	
	/* user-friendly 'name' for F-Curve */
	/* TODO: only show the path if this is invalid? */
	col = uiLayoutColumn(layout, false);
	icon = getname_anim_fcurve(name, ale->id, fcu);
	uiItemL(col, name, icon);
		
	/* RNA-Path Editing - only really should be enabled when things aren't working */
	col = uiLayoutColumn(layout, true);
	uiLayoutSetEnabled(col, (fcu->flag & FCURVE_DISABLED) != 0);
	uiItemR(col, &fcu_ptr, "data_path", 0, "", ICON_RNA);
	uiItemR(col, &fcu_ptr, "array_index", 0, NULL, ICON_NONE);
		
	/* color settings */
	col = uiLayoutColumn(layout, true);
	uiItemL(col, IFACE_("Display Color:"), ICON_NONE);
		
	row = uiLayoutRow(col, true);
	uiItemR(row, &fcu_ptr, "color_mode", 0, "", ICON_NONE);
			
	sub = uiLayoutRow(row, true);
	uiLayoutSetEnabled(sub, (fcu->color_mode == FCURVE_COLOR_CUSTOM));
	uiItemR(sub, &fcu_ptr, "color", 0, "", ICON_NONE);
	
	MEM_freeN(ale);
}
Beispiel #5
0
static void view3d_panel_operator_redo(const bContext *C, Panel *pa)
{
	wmOperator *op= view3d_last_operator(C);
	uiBlock *block;
	
	if(op==NULL)
		return;
	if(WM_operator_poll((bContext*)C, op->type) == 0)
		return;
	
	block= uiLayoutGetBlock(pa->layout);
	
	if(ED_undo_valid(C, op->type->name)==0)
		uiLayoutSetEnabled(pa->layout, 0);

	/* note, blockfunc is a default but->func, use Handle func to allow button callbacks too */
	uiBlockSetHandleFunc(block, ED_undo_operator_repeat_cb_evt, op);
	
	view3d_panel_operator_redo_operator(C, pa, op);
}
Beispiel #6
0
void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char *propname, PointerRNA *userptr, int compact)
{
#define MAX_INFO_LEN  128

	PropertyRNA *prop;
	PointerRNA imaptr;
	RNAUpdateCb *cb;
	Image *ima;
	ImageUser *iuser;
	Scene *scene = CTX_data_scene(C);
	uiLayout *row, *split, *col;
	uiBlock *block;
	char str[MAX_INFO_LEN];

	void *lock;

	if (!ptr->data)
		return;

	prop = RNA_struct_find_property(ptr, propname);
	if (!prop) {
		printf("%s: property not found: %s.%s\n",
		       __func__, RNA_struct_identifier(ptr->type), propname);
		return;
	}

	if (RNA_property_type(prop) != PROP_POINTER) {
		printf("%s: expected pointer property for %s.%s\n",
		       __func__, RNA_struct_identifier(ptr->type), propname);
		return;
	}

	block = uiLayoutGetBlock(layout);

	imaptr = RNA_property_pointer_get(ptr, prop);
	ima = imaptr.data;
	iuser = userptr->data;

	BKE_image_user_check_frame_calc(iuser, (int)scene->r.cfra, 0);

	cb = MEM_callocN(sizeof(RNAUpdateCb), "RNAUpdateCb");
	cb->ptr = *ptr;
	cb->prop = prop;
	cb->iuser = iuser;

	uiLayoutSetContextPointer(layout, "edit_image", &imaptr);
	uiLayoutSetContextPointer(layout, "edit_image_user", userptr);

	if (!compact)
		uiTemplateID(layout, C, ptr, propname, "IMAGE_OT_new", "IMAGE_OT_open", NULL);

	if (ima) {
		uiBlockSetNFunc(block, rna_update_cb, MEM_dupallocN(cb), NULL);

		if (ima->source == IMA_SRC_VIEWER) {
			ImBuf *ibuf = BKE_image_acquire_ibuf(ima, iuser, &lock);
			image_info(scene, iuser, ima, ibuf, str, MAX_INFO_LEN);
			BKE_image_release_ibuf(ima, ibuf, lock);

			uiItemL(layout, ima->id.name + 2, ICON_NONE);
			uiItemL(layout, str, ICON_NONE);

			if (ima->type == IMA_TYPE_COMPOSITE) {
				// XXX not working yet
#if 0
				iuser = ntree_get_active_iuser(scene->nodetree);
				if (iuser) {
					uiBlockBeginAlign(block);
					uiDefIconTextBut(block, BUT, B_SIMA_RECORD, ICON_REC, "Record", 10, 120, 100, 20, 0, 0, 0, 0, 0, "");
					uiDefIconTextBut(block, BUT, B_SIMA_PLAY, ICON_PLAY, "Play",    110, 120, 100, 20, 0, 0, 0, 0, 0, "");
					but = uiDefBut(block, BUT, B_NOP, "Free Cache", 210, 120, 100, 20, 0, 0, 0, 0, 0, "");
					uiButSetFunc(but, image_freecache_cb, ima, NULL);
					
					if (iuser->frames)
						BLI_snprintf(str, sizeof(str), "(%d) Frames:", iuser->framenr);
					else strcpy(str, "Frames:");
					uiBlockBeginAlign(block);
					uiDefButI(block, NUM, imagechanged, str,        10, 90, 150, 20, &iuser->frames, 0.0, MAXFRAMEF, 0, 0, "Number of images of a movie to use");
					uiDefButI(block, NUM, imagechanged, "StartFr:", 160, 90, 150, 20, &iuser->sfra, 1.0, MAXFRAMEF, 0, 0, "Global starting frame of the movie");
				}
#endif
			}
			else if (ima->type == IMA_TYPE_R_RESULT) {
				/* browse layer/passes */
				RenderResult *rr;

				/* use BKE_image_acquire_renderresult  so we get the correct slot in the menu */
				rr = BKE_image_acquire_renderresult(scene, ima);
				uiblock_layer_pass_arrow_buttons(layout, rr, iuser, &ima->render_slot);
				BKE_image_release_renderresult(scene, ima);
			}
		}
		else {
			uiItemR(layout, &imaptr, "source", 0, NULL, ICON_NONE);

			if (ima->source != IMA_SRC_GENERATED) {
				row = uiLayoutRow(layout, TRUE);
				if (ima->packedfile)
					uiItemO(row, "", ICON_PACKAGE, "image.unpack");
				else
					uiItemO(row, "", ICON_UGLYPACKAGE, "image.pack");
				
				row = uiLayoutRow(row, TRUE);
				uiLayoutSetEnabled(row, ima->packedfile == NULL);
				uiItemR(row, &imaptr, "filepath", 0, "", ICON_NONE);
				uiItemO(row, "", ICON_FILE_REFRESH, "image.reload");
			}

			// XXX what was this for?
#if 0
			/* check for re-render, only buttons */
			if (imagechanged == B_IMAGECHANGED) {
				if (iuser->flag & IMA_ANIM_REFRESHED) {
					iuser->flag &= ~IMA_ANIM_REFRESHED;
					WM_event_add_notifier(C, NC_IMAGE, ima);
				}
			}
#endif

			/* multilayer? */
			if (ima->type == IMA_TYPE_MULTILAYER && ima->rr) {
				uiblock_layer_pass_arrow_buttons(layout, ima->rr, iuser, NULL);
			}
			else if (ima->source != IMA_SRC_GENERATED) {
				if (compact == 0) {
					ImBuf *ibuf = BKE_image_acquire_ibuf(ima, iuser, &lock);
					image_info(scene, iuser, ima, ibuf, str, MAX_INFO_LEN);
					BKE_image_release_ibuf(ima, ibuf, lock);
					uiItemL(layout, str, ICON_NONE);
				}
			}

			col = uiLayoutColumn(layout, FALSE);
			uiTemplateColorspaceSettings(col, &imaptr, "colorspace_settings");
			uiItemR(col, &imaptr, "use_view_as_render", 0, NULL, ICON_NONE);

			if (ima->source != IMA_SRC_GENERATED) {
				if (compact == 0) { /* background image view doesnt need these */
					ImBuf *ibuf = BKE_image_acquire_ibuf(ima, iuser, NULL);
					int has_alpha = TRUE;

					if (ibuf) {
						int imtype = BKE_ftype_to_imtype(ibuf->ftype);
						char valid_channels = BKE_imtype_valid_channels(imtype);

						has_alpha = valid_channels & IMA_CHAN_FLAG_ALPHA;

						BKE_image_release_ibuf(ima, ibuf, NULL);
					}

					if (has_alpha) {
						col = uiLayoutColumn(layout, FALSE);
						uiItemR(col, &imaptr, "use_alpha", 0, NULL, ICON_NONE);
						uiItemR(col, &imaptr, "alpha_mode", 0, "Alpha", ICON_NONE);
					}

					uiItemS(layout);

					split = uiLayoutSplit(layout, 0.0f, FALSE);

					col = uiLayoutColumn(split, FALSE);
					/* XXX Why only display fields_per_frame only for video image types?
					 *     And why allow fields for non-video image types at all??? */
					if (ELEM(ima->source, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE)) {
						uiLayout *subsplit = uiLayoutSplit(col, 0.0f, FALSE);
						uiLayout *subcol = uiLayoutColumn(subsplit, FALSE);
						uiItemR(subcol, &imaptr, "use_fields", 0, NULL, ICON_NONE);
						subcol = uiLayoutColumn(subsplit, FALSE);
						uiLayoutSetActive(subcol, RNA_boolean_get(&imaptr, "use_fields"));
						uiItemR(subcol, userptr, "fields_per_frame", 0, IFACE_("Fields"), ICON_NONE);
					}
					else
						uiItemR(col, &imaptr, "use_fields", 0, NULL, ICON_NONE);
					row = uiLayoutRow(col, FALSE);
					uiLayoutSetActive(row, RNA_boolean_get(&imaptr, "use_fields"));
					uiItemR(row, &imaptr, "field_order", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
				}
			}

			if (ELEM(ima->source, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE)) {
				uiItemS(layout);

				split = uiLayoutSplit(layout, 0.0f, FALSE);

				col = uiLayoutColumn(split, FALSE);

				BLI_snprintf(str, sizeof(str), IFACE_("(%d) Frames"), iuser->framenr);
				uiItemR(col, userptr, "frame_duration", 0, str, ICON_NONE);
				uiItemR(col, userptr, "frame_start", 0, IFACE_("Start"), ICON_NONE);
				uiItemR(col, userptr, "frame_offset", 0, NULL, ICON_NONE);

				col = uiLayoutColumn(split, FALSE);
				uiItemO(col, NULL, ICON_NONE, "IMAGE_OT_match_movie_length");
				uiItemR(col, userptr, "use_auto_refresh", 0, NULL, ICON_NONE);
				uiItemR(col, userptr, "use_cyclic", 0, NULL, ICON_NONE);
			}
			else if (ima->source == IMA_SRC_GENERATED) {
				split = uiLayoutSplit(layout, 0.0f, FALSE);

				col = uiLayoutColumn(split, TRUE);
				uiItemR(col, &imaptr, "generated_width", 0, "X", ICON_NONE);
				uiItemR(col, &imaptr, "generated_height", 0, "Y", ICON_NONE);
				
				uiItemR(col, &imaptr, "use_generated_float", 0, NULL, ICON_NONE);

				uiItemR(split, &imaptr, "generated_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
			}

		}

		uiBlockSetNFunc(block, NULL, NULL, NULL);
	}

	MEM_freeN(cb);

#undef MAX_INFO_LEN
}
Beispiel #7
0
static void uiCollada_exportSettings(uiLayout *layout, PointerRNA *imfptr)
{
    uiLayout *box, *row, *col, *split;

    /* Export Options: */
    box = uiLayoutBox(layout);
    row = uiLayoutRow(box, false);
    uiItemL(row, IFACE_("Export Data Options:"), ICON_MESH_DATA);

    row = uiLayoutRow(box, false);
    split = uiLayoutSplit(row, 0.6f, UI_LAYOUT_ALIGN_RIGHT);
    col   = uiLayoutColumn(split, false);
    uiItemR(col, imfptr, "apply_modifiers", 0, NULL, ICON_NONE);
    col   = uiLayoutColumn(split, false);
    uiItemR(col, imfptr, "export_mesh_type_selection", 0, "", ICON_NONE);
    uiLayoutSetEnabled(col, RNA_boolean_get(imfptr, "apply_modifiers"));

    row = uiLayoutRow(box, false);
    uiItemR(row, imfptr, "selected", 0, NULL, ICON_NONE);

    row = uiLayoutRow(box, false);
    uiItemR(row, imfptr, "include_children", 0, NULL, ICON_NONE);
    uiLayoutSetEnabled(row, RNA_boolean_get(imfptr, "selected"));

    row = uiLayoutRow(box, false);
    uiItemR(row, imfptr, "include_armatures", 0, NULL, ICON_NONE);
    uiLayoutSetEnabled(row, RNA_boolean_get(imfptr, "selected"));

    row = uiLayoutRow(box, false);
    uiItemR(row, imfptr, "include_shapekeys", 0, NULL, ICON_NONE);
    uiLayoutSetEnabled(row, RNA_boolean_get(imfptr, "selected"));

    /* Texture options */
    box = uiLayoutBox(layout);
    row = uiLayoutRow(box, false);
    uiItemL(row, IFACE_("Texture Options:"), ICON_TEXTURE_DATA);

    row = uiLayoutRow(box, false);
    uiItemR(row, imfptr, "active_uv_only", 0, NULL, ICON_NONE);

    row = uiLayoutRow(box, false);
    uiItemR(row, imfptr, "include_uv_textures", 0, NULL, ICON_NONE);

    row = uiLayoutRow(box, false);
    uiItemR(row, imfptr, "include_material_textures", 0, NULL, ICON_NONE);

    row = uiLayoutRow(box, false);
    uiItemR(row, imfptr, "use_texture_copies", 1, NULL, ICON_NONE);


    /* Armature options */
    box = uiLayoutBox(layout);
    row = uiLayoutRow(box, false);
    uiItemL(row, IFACE_("Armature Options:"), ICON_ARMATURE_DATA);

    row = uiLayoutRow(box, false);
    uiItemR(row, imfptr, "deform_bones_only", 0, NULL, ICON_NONE);
    row = uiLayoutRow(box, false);
    uiItemR(row, imfptr, "open_sim", 0, NULL, ICON_NONE);

    /* Collada options: */
    box = uiLayoutBox(layout);
    row = uiLayoutRow(box, false);
    uiItemL(row, IFACE_("Collada Options:"), ICON_MODIFIER);

    row = uiLayoutRow(box, false);
    uiItemR(row, imfptr, "triangulate", 0, NULL, ICON_NONE);
    row = uiLayoutRow(box, false);
    uiItemR(row, imfptr, "use_object_instantiation", 0, NULL, ICON_NONE);

    row = uiLayoutRow(box, false);
    split = uiLayoutSplit(row, 0.6f, UI_LAYOUT_ALIGN_RIGHT);
    uiItemL(split, IFACE_("Transformation Type"), ICON_NONE);
    uiItemR(split, imfptr, "export_transformation_type_selection", 0, "", ICON_NONE);

    row = uiLayoutRow(box, false);
    uiItemR(row, imfptr, "sort_by_name", 0, NULL, ICON_NONE);

}
Beispiel #8
0
static void rna_UILayout_enabled_set(PointerRNA *ptr, bool value)
{
	uiLayoutSetEnabled(ptr->data, value);
}
Beispiel #9
0
static int wm_alembic_export_exec(bContext *C, wmOperator *op)
{
	if (!RNA_struct_property_is_set(op->ptr, "filepath")) {
		BKE_report(op->reports, RPT_ERROR, "No filename given");
		return OPERATOR_CANCELLED;
	}

	char filename[FILE_MAX];
	RNA_string_get(op->ptr, "filepath", filename);

	struct AlembicExportParams params = {
	    .frame_start = RNA_int_get(op->ptr, "start"),
	    .frame_end = RNA_int_get(op->ptr, "end"),

	    .frame_samples_xform = RNA_int_get(op->ptr, "xsamples"),
	    .frame_samples_shape = RNA_int_get(op->ptr, "gsamples"),

	    .shutter_open = RNA_float_get(op->ptr, "sh_open"),
	    .shutter_close = RNA_float_get(op->ptr, "sh_close"),

	    .selected_only = RNA_boolean_get(op->ptr, "selected"),
	    .uvs = RNA_boolean_get(op->ptr, "uvs"),
	    .normals = RNA_boolean_get(op->ptr, "normals"),
	    .vcolors = RNA_boolean_get(op->ptr, "vcolors"),
	    .apply_subdiv = RNA_boolean_get(op->ptr, "apply_subdiv"),
	    .flatten_hierarchy = RNA_boolean_get(op->ptr, "flatten"),
	    .visible_layers_only = RNA_boolean_get(op->ptr, "visible_layers_only"),
	    .renderable_only = RNA_boolean_get(op->ptr, "renderable_only"),
	    .face_sets = RNA_boolean_get(op->ptr, "face_sets"),
	    .use_subdiv_schema = RNA_boolean_get(op->ptr, "subdiv_schema"),
	    .export_hair = RNA_boolean_get(op->ptr, "export_hair"),
	    .export_particles = RNA_boolean_get(op->ptr, "export_particles"),
	    .compression_type = RNA_enum_get(op->ptr, "compression_type"),
	    .packuv = RNA_boolean_get(op->ptr, "packuv"),
	    .triangulate = RNA_boolean_get(op->ptr, "triangulate"),
	    .quad_method = RNA_enum_get(op->ptr, "quad_method"),
	    .ngon_method = RNA_enum_get(op->ptr, "ngon_method"),

	    .global_scale = RNA_float_get(op->ptr, "global_scale"),
	};

	/* Take some defaults from the scene, if not specified explicitly. */
	Scene *scene = CTX_data_scene(C);
	if (params.frame_start == INT_MIN) {
		params.frame_start = SFRA;
	}
	if (params.frame_end == INT_MIN) {
		params.frame_end = EFRA;
	}

	const bool as_background_job = RNA_boolean_get(op->ptr, "as_background_job");
	bool ok = ABC_export(scene, C, filename, &params, as_background_job);

	return as_background_job || ok ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
}

static void ui_alembic_export_settings(uiLayout *layout, PointerRNA *imfptr)
{
	uiLayout *box;
	uiLayout *row;
	uiLayout *col;

#ifdef WITH_ALEMBIC_HDF5
	box = uiLayoutBox(layout);
	row = uiLayoutRow(box, false);
	uiItemL(row, IFACE_("Archive Options:"), ICON_NONE);

	row = uiLayoutRow(box, false);
	uiItemR(row, imfptr, "compression_type", 0, NULL, ICON_NONE);
#endif

	box = uiLayoutBox(layout);
	row = uiLayoutRow(box, false);
	uiItemL(row, IFACE_("Manual Transform:"), ICON_NONE);

	row = uiLayoutRow(box, false);
	uiItemR(row, imfptr, "global_scale", 0, NULL, ICON_NONE);

	/* Scene Options */
	box = uiLayoutBox(layout);
	row = uiLayoutRow(box, false);
	uiItemL(row, IFACE_("Scene Options:"), ICON_SCENE_DATA);

	row = uiLayoutRow(box, false);
	uiItemR(row, imfptr, "start", 0, NULL, ICON_NONE);

	row = uiLayoutRow(box, false);
	uiItemR(row, imfptr, "end", 0, NULL, ICON_NONE);

	row = uiLayoutRow(box, false);
	uiItemR(row, imfptr, "xsamples", 0, NULL, ICON_NONE);

	row = uiLayoutRow(box, false);
	uiItemR(row, imfptr, "gsamples", 0, NULL, ICON_NONE);

	row = uiLayoutRow(box, false);
	uiItemR(row, imfptr, "sh_open", 0, NULL, ICON_NONE);

	row = uiLayoutRow(box, false);
	uiItemR(row, imfptr, "sh_close", 0, NULL, ICON_NONE);

	row = uiLayoutRow(box, false);
	uiItemR(row, imfptr, "selected", 0, NULL, ICON_NONE);

	row = uiLayoutRow(box, false);
	uiItemR(row, imfptr, "renderable_only", 0, NULL, ICON_NONE);

	row = uiLayoutRow(box, false);
	uiItemR(row, imfptr, "visible_layers_only", 0, NULL, ICON_NONE);

	row = uiLayoutRow(box, false);
	uiItemR(row, imfptr, "flatten", 0, NULL, ICON_NONE);

	/* Object Data */
	box = uiLayoutBox(layout);
	row = uiLayoutRow(box, false);
	uiItemL(row, IFACE_("Object Options:"), ICON_OBJECT_DATA);

	row = uiLayoutRow(box, false);
	uiItemR(row, imfptr, "uvs", 0, NULL, ICON_NONE);

	row = uiLayoutRow(box, false);
	uiItemR(row, imfptr, "packuv", 0, NULL, ICON_NONE);
	uiLayoutSetEnabled(row, RNA_boolean_get(imfptr, "uvs"));

	row = uiLayoutRow(box, false);
	uiItemR(row, imfptr, "normals", 0, NULL, ICON_NONE);

	row = uiLayoutRow(box, false);
	uiItemR(row, imfptr, "vcolors", 0, NULL, ICON_NONE);

	row = uiLayoutRow(box, false);
	uiItemR(row, imfptr, "face_sets", 0, NULL, ICON_NONE);

	row = uiLayoutRow(box, false);
	uiItemR(row, imfptr, "subdiv_schema", 0, NULL, ICON_NONE);

	row = uiLayoutRow(box, false);
	uiItemR(row, imfptr, "apply_subdiv", 0, NULL, ICON_NONE);

	row = uiLayoutRow(box, false);
	uiItemR(row, imfptr, "triangulate", 0, NULL, ICON_NONE);

	const bool triangulate = RNA_boolean_get(imfptr, "triangulate");

	row = uiLayoutRow(box, false);
	uiLayoutSetEnabled(row, triangulate);
	uiItemR(row, imfptr, "quad_method", 0, NULL, ICON_NONE);

	row = uiLayoutRow(box, false);
	uiLayoutSetEnabled(row, triangulate);
	uiItemR(row, imfptr, "ngon_method", 0, NULL, ICON_NONE);

	/* Object Data */
	box = uiLayoutBox(layout);
	row = uiLayoutRow(box, false);
	uiItemL(row, IFACE_("Particle Systems:"), ICON_PARTICLE_DATA);

	col = uiLayoutColumn(box, true);
	uiItemR(col, imfptr, "export_hair", 0, NULL, ICON_NONE);
	uiItemR(col, imfptr, "export_particles", 0, NULL, ICON_NONE);
}
Beispiel #10
0
static int wm_alembic_export_exec(bContext *C, wmOperator *op)
{
	if (!RNA_struct_property_is_set(op->ptr, "filepath")) {
		BKE_report(op->reports, RPT_ERROR, "No filename given");
		return OPERATOR_CANCELLED;
	}

	char filename[FILE_MAX];
	RNA_string_get(op->ptr, "filepath", filename);

	const struct AlembicExportParams params = {
	    .frame_start = RNA_int_get(op->ptr, "start"),
	    .frame_end = RNA_int_get(op->ptr, "end"),

	    .frame_step_xform = 1.0 / (double)RNA_int_get(op->ptr, "xsamples"),
	    .frame_step_shape = 1.0 / (double)RNA_int_get(op->ptr, "gsamples"),

	    .shutter_open = RNA_float_get(op->ptr, "sh_open"),
	    .shutter_close = RNA_float_get(op->ptr, "sh_close"),

	    .selected_only = RNA_boolean_get(op->ptr, "selected"),
	    .uvs = RNA_boolean_get(op->ptr, "uvs"),
	    .normals = RNA_boolean_get(op->ptr, "normals"),
	    .vcolors = RNA_boolean_get(op->ptr, "vcolors"),
	    .apply_subdiv = RNA_boolean_get(op->ptr, "apply_subdiv"),
	    .flatten_hierarchy = RNA_boolean_get(op->ptr, "flatten"),
	    .visible_layers_only = RNA_boolean_get(op->ptr, "visible_layers_only"),
	    .renderable_only = RNA_boolean_get(op->ptr, "renderable_only"),
	    .face_sets = RNA_boolean_get(op->ptr, "face_sets"),
	    .use_subdiv_schema = RNA_boolean_get(op->ptr, "subdiv_schema"),
	    .compression_type = RNA_enum_get(op->ptr, "compression_type"),
	    .packuv = RNA_boolean_get(op->ptr, "packuv"),
		.triangulate = RNA_boolean_get(op->ptr, "triangulate"),
		.quad_method = RNA_enum_get(op->ptr, "quad_method"),
		.ngon_method = RNA_enum_get(op->ptr, "ngon_method"),

	    .global_scale = RNA_float_get(op->ptr, "global_scale"),
	};

	ABC_export(CTX_data_scene(C), C, filename, &params);

	return OPERATOR_FINISHED;
}

static void ui_alembic_export_settings(uiLayout *layout, PointerRNA *imfptr)
{
	uiLayout *box;
	uiLayout *row;

#ifdef WITH_ALEMBIC_HDF5
	box = uiLayoutBox(layout);
	row = uiLayoutRow(box, false);
	uiItemL(row, IFACE_("Archive Options:"), ICON_NONE);

	row = uiLayoutRow(box, false);
	uiItemR(row, imfptr, "compression_type", 0, NULL, ICON_NONE);
#endif

	box = uiLayoutBox(layout);
	row = uiLayoutRow(box, false);
	uiItemL(row, IFACE_("Manual Transform:"), ICON_NONE);

	row = uiLayoutRow(box, false);
	uiItemR(row, imfptr, "global_scale", 0, NULL, ICON_NONE);

	/* Scene Options */
	box = uiLayoutBox(layout);
	row = uiLayoutRow(box, false);
	uiItemL(row, IFACE_("Scene Options:"), ICON_SCENE_DATA);

	row = uiLayoutRow(box, false);
	uiItemR(row, imfptr, "start", 0, NULL, ICON_NONE);

	row = uiLayoutRow(box, false);
	uiItemR(row, imfptr, "end", 0, NULL, ICON_NONE);

	row = uiLayoutRow(box, false);
	uiItemR(row, imfptr, "xsamples", 0, NULL, ICON_NONE);

	row = uiLayoutRow(box, false);
	uiItemR(row, imfptr, "gsamples", 0, NULL, ICON_NONE);

	row = uiLayoutRow(box, false);
	uiItemR(row, imfptr, "sh_open", 0, NULL, ICON_NONE);

	row = uiLayoutRow(box, false);
	uiItemR(row, imfptr, "sh_close", 0, NULL, ICON_NONE);

	row = uiLayoutRow(box, false);
	uiItemR(row, imfptr, "selected", 0, NULL, ICON_NONE);

	row = uiLayoutRow(box, false);
	uiItemR(row, imfptr, "renderable_only", 0, NULL, ICON_NONE);

	row = uiLayoutRow(box, false);
	uiItemR(row, imfptr, "visible_layers_only", 0, NULL, ICON_NONE);

	row = uiLayoutRow(box, false);
	uiItemR(row, imfptr, "flatten", 0, NULL, ICON_NONE);

	/* Object Data */
	box = uiLayoutBox(layout);
	row = uiLayoutRow(box, false);
	uiItemL(row, IFACE_("Object Options:"), ICON_OBJECT_DATA);

	row = uiLayoutRow(box, false);
	uiItemR(row, imfptr, "uvs", 0, NULL, ICON_NONE);

	row = uiLayoutRow(box, false);
	uiItemR(row, imfptr, "packuv", 0, NULL, ICON_NONE);
	uiLayoutSetEnabled(row, RNA_boolean_get(imfptr, "uvs"));

	row = uiLayoutRow(box, false);
	uiItemR(row, imfptr, "normals", 0, NULL, ICON_NONE);

	row = uiLayoutRow(box, false);
	uiItemR(row, imfptr, "vcolors", 0, NULL, ICON_NONE);

	row = uiLayoutRow(box, false);
	uiItemR(row, imfptr, "face_sets", 0, NULL, ICON_NONE);

	row = uiLayoutRow(box, false);
	uiItemR(row, imfptr, "subdiv_schema", 0, NULL, ICON_NONE);

	row = uiLayoutRow(box, false);
	uiItemR(row, imfptr, "apply_subdiv", 0, NULL, ICON_NONE);

	row = uiLayoutRow(box, false);
	uiItemR(row, imfptr, "triangulate", 0, NULL, ICON_NONE);

	const bool triangulate = RNA_boolean_get(imfptr, "triangulate");

	row = uiLayoutRow(box, false);
	uiLayoutSetEnabled(row, triangulate);
	uiItemR(row, imfptr, "quad_method", 0, NULL, ICON_NONE);

	row = uiLayoutRow(box, false);
	uiLayoutSetEnabled(row, triangulate);
	uiItemR(row, imfptr, "ngon_method", 0, NULL, ICON_NONE);
}
Beispiel #11
0
void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char *propname, PointerRNA *userptr, int compact)
{
	PropertyRNA *prop;
	PointerRNA imaptr;
	RNAUpdateCb *cb;
	Image *ima;
	ImageUser *iuser;
	ImBuf *ibuf;
	Scene *scene = CTX_data_scene(C);
	uiLayout *row, *split, *col;
	uiBlock *block;
	uiBut *but;
	char str[128];
	void *lock;

	if (!ptr->data)
		return;

	prop = RNA_struct_find_property(ptr, propname);
	if (!prop) {
		printf("%s: property not found: %s.%s\n",
		       __func__, RNA_struct_identifier(ptr->type), propname);
		return;
	}

	if (RNA_property_type(prop) != PROP_POINTER) {
		printf("%s: expected pointer property for %s.%s\n",
		       __func__, RNA_struct_identifier(ptr->type), propname);
		return;
	}

	block = uiLayoutGetBlock(layout);

	imaptr = RNA_property_pointer_get(ptr, prop);
	ima = imaptr.data;
	iuser = userptr->data;

	cb = MEM_callocN(sizeof(RNAUpdateCb), "RNAUpdateCb");
	cb->ptr = *ptr;
	cb->prop = prop;
	cb->iuser = iuser;

	uiLayoutSetContextPointer(layout, "edit_image", &imaptr);

	if (!compact)
		uiTemplateID(layout, C, ptr, propname, "IMAGE_OT_new", "IMAGE_OT_open", NULL);

	if (ima) {
		uiBlockSetNFunc(block, rna_update_cb, MEM_dupallocN(cb), NULL);

		if (ima->source == IMA_SRC_VIEWER) {
			ibuf = BKE_image_acquire_ibuf(ima, iuser, &lock);
			image_info(scene, iuser, ima, ibuf, str);
			BKE_image_release_ibuf(ima, lock);

			uiItemL(layout, ima->id.name + 2, ICON_NONE);
			uiItemL(layout, str, ICON_NONE);

			if (ima->type == IMA_TYPE_COMPOSITE) {
				// XXX not working yet
#if 0
				iuser = ntree_get_active_iuser(scene->nodetree);
				if (iuser) {
					uiBlockBeginAlign(block);
					uiDefIconTextBut(block, BUT, B_SIMA_RECORD, ICON_REC, "Record", 10, 120, 100, 20, 0, 0, 0, 0, 0, "");
					uiDefIconTextBut(block, BUT, B_SIMA_PLAY, ICON_PLAY, "Play",    110, 120, 100, 20, 0, 0, 0, 0, 0, "");
					but = uiDefBut(block, BUT, B_NOP, "Free Cache", 210, 120, 100, 20, 0, 0, 0, 0, 0, "");
					uiButSetFunc(but, image_freecache_cb, ima, NULL);
					
					if (iuser->frames)
						BLI_snprintf(str, sizeof(str), "(%d) Frames:", iuser->framenr);
					else strcpy(str, "Frames:");
					uiBlockBeginAlign(block);
					uiDefButI(block, NUM, imagechanged, str,        10, 90, 150, 20, &iuser->frames, 0.0, MAXFRAMEF, 0, 0, "Number of images of a movie to use");
					uiDefButI(block, NUM, imagechanged, "StartFr:", 160, 90, 150, 20, &iuser->sfra, 1.0, MAXFRAMEF, 0, 0, "Global starting frame of the movie");
				}
#endif
			}
			else if (ima->type == IMA_TYPE_R_RESULT) {
				/* browse layer/passes */
				Render *re = RE_GetRender(scene->id.name);
				RenderResult *rr = RE_AcquireResultRead(re);
				uiblock_layer_pass_arrow_buttons(layout, rr, iuser, &ima->render_slot);
				RE_ReleaseResult(re);
			}
		}
		else {
			uiItemR(layout, &imaptr, "source", 0, NULL, ICON_NONE);

			if (ima->source != IMA_SRC_GENERATED) {
				row = uiLayoutRow(layout, 1);
				if (ima->packedfile)
					uiItemO(row, "", ICON_PACKAGE, "image.unpack");
				else
					uiItemO(row, "", ICON_UGLYPACKAGE, "image.pack");
				
				row = uiLayoutRow(row, 0);
				uiLayoutSetEnabled(row, ima->packedfile == NULL);
				uiItemR(row, &imaptr, "filepath", 0, "", ICON_NONE);
				uiItemO(row, "", ICON_FILE_REFRESH, "image.reload");
			}

			// XXX what was this for?
#if 0
			/* check for re-render, only buttons */
			if (imagechanged == B_IMAGECHANGED) {
				if (iuser->flag & IMA_ANIM_REFRESHED) {
					iuser->flag &= ~IMA_ANIM_REFRESHED;
					WM_event_add_notifier(C, NC_IMAGE, ima);
				}
			}
#endif

			/* multilayer? */
			if (ima->type == IMA_TYPE_MULTILAYER && ima->rr) {
				uiblock_layer_pass_arrow_buttons(layout, ima->rr, iuser, NULL);
			}
			else if (ima->source != IMA_SRC_GENERATED) {
				if (compact == 0) {
					ibuf = BKE_image_acquire_ibuf(ima, iuser, &lock);
					image_info(scene, iuser, ima, ibuf, str);
					BKE_image_release_ibuf(ima, lock);
					uiItemL(layout, str, ICON_NONE);
				}
			}
			
			if (ima->source != IMA_SRC_GENERATED) {
				if (compact == 0) { /* background image view doesnt need these */
					uiItemS(layout);

					split = uiLayoutSplit(layout, 0, 0);

					col = uiLayoutColumn(split, 0);
					uiItemR(col, &imaptr, "use_fields", 0, NULL, ICON_NONE);
					row = uiLayoutRow(col, 0);
					uiLayoutSetActive(row, RNA_boolean_get(&imaptr, "use_fields"));
					uiItemR(row, &imaptr, "field_order", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
					
					row = uiLayoutRow(layout, 0);
					uiItemR(row, &imaptr, "use_premultiply", 0, NULL, ICON_NONE);
					uiItemR(row, &imaptr, "use_color_unpremultiply", 0, NULL, ICON_NONE);
				}
			}

			if (ELEM(ima->source, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE)) {
				uiItemS(layout);
				
				split = uiLayoutSplit(layout, 0, 0);

				col = uiLayoutColumn(split, 0);
				 
				BLI_snprintf(str, sizeof(str), "(%d) Frames", iuser->framenr);
				uiItemR(col, userptr, "frame_duration", 0, str, ICON_NONE);
				if (ima->anim) {
					block = uiLayoutGetBlock(col);
					but = uiDefBut(block, BUT, 0, "Match Movie Length", 0, 0, UI_UNIT_X * 2, UI_UNIT_Y, NULL, 0, 0, 0, 0, "Set the number of frames to match the movie or sequence");
					uiButSetFunc(but, set_frames_cb, ima, iuser);
				}

				uiItemR(col, userptr, "frame_start", 0, "Start", ICON_NONE);
				uiItemR(col, userptr, "frame_offset", 0, NULL, ICON_NONE);

				col = uiLayoutColumn(split, 0);
				row = uiLayoutRow(col, 0);
				uiLayoutSetActive(row, RNA_boolean_get(&imaptr, "use_fields"));
				uiItemR(row, userptr, "fields_per_frame", 0, "Fields", ICON_NONE);
				uiItemR(col, userptr, "use_auto_refresh", 0, NULL, ICON_NONE);
				uiItemR(col, userptr, "use_cyclic", 0, NULL, ICON_NONE);
			}
			else if (ima->source == IMA_SRC_GENERATED) {
				split = uiLayoutSplit(layout, 0, 0);

				col = uiLayoutColumn(split, 1);
				uiItemR(col, &imaptr, "generated_width", 0, "X", ICON_NONE);
				uiItemR(col, &imaptr, "generated_height", 0, "Y", ICON_NONE);
				uiItemR(col, &imaptr, "use_generated_float", 0, NULL, ICON_NONE);

				uiItemR(split, &imaptr, "generated_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
			}

		}

		uiBlockSetNFunc(block, NULL, NULL, NULL);
	}

	MEM_freeN(cb);
}
Beispiel #12
0
static void graph_panel_properties(const bContext *C, Panel *pa)
{
	bAnimListElem *ale;
	FCurve *fcu;
	PointerRNA fcu_ptr;
	uiLayout *layout = pa->layout;
	uiLayout *col, *row, *sub;
	// uiBlock *block;  // UNUSED
	char name[256];
	int icon = 0;

	if (!graph_panel_context(C, &ale, &fcu))
		return;
	
	// UNUSED
	// block = uiLayoutGetBlock(layout);
	// UI_block_func_handle_set(block, do_graph_region_buttons, NULL);
	
	/* F-Curve pointer */
	RNA_pointer_create(ale->id, &RNA_FCurve, fcu, &fcu_ptr);
	
	/* user-friendly 'name' for F-Curve */
	col = uiLayoutColumn(layout, false);
	if (ale->type == ANIMTYPE_FCURVE) {
		/* get user-friendly name for F-Curve */
		icon = getname_anim_fcurve(name, ale->id, fcu);
	}
	else {
		/* NLA Control Curve, etc. */
		const bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale);
		
		/* get name */
		if (acf && acf->name) {
			acf->name(ale, name);
		}
		else {
			strcpy(name, IFACE_("<invalid>"));
			icon = ICON_ERROR;
		}
		
		/* icon */
		if (ale->type == ANIMTYPE_NLACURVE)
			icon = ICON_NLA;
	}
	uiItemL(col, name, icon);
		
	/* RNA-Path Editing - only really should be enabled when things aren't working */
	col = uiLayoutColumn(layout, true);
	uiLayoutSetEnabled(col, (fcu->flag & FCURVE_DISABLED) != 0);
	uiItemR(col, &fcu_ptr, "data_path", 0, "", ICON_RNA);
	uiItemR(col, &fcu_ptr, "array_index", 0, NULL, ICON_NONE);
		
	/* color settings */
	col = uiLayoutColumn(layout, true);
	uiItemL(col, IFACE_("Display Color:"), ICON_NONE);
		
	row = uiLayoutRow(col, true);
	uiItemR(row, &fcu_ptr, "color_mode", 0, "", ICON_NONE);
			
	sub = uiLayoutRow(row, true);
	uiLayoutSetEnabled(sub, (fcu->color_mode == FCURVE_COLOR_CUSTOM));
	uiItemR(sub, &fcu_ptr, "color", 0, "", ICON_NONE);
	
	MEM_freeN(ale);
}