• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ CTX_wm_space_node函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: node_group_insert_exec

static int node_group_insert_exec(bContext *C, wmOperator *op)
{
	SpaceNode *snode = CTX_wm_space_node(C);
	bNodeTree *ntree = snode->edittree;
	bNodeTree *ngroup;
	const char *node_idname = group_node_idname(C);
	bNode *gnode;
	Main *bmain = CTX_data_main(C);
	
	ED_preview_kill_jobs(C);
	
	gnode = node_group_get_active(C, node_idname);
	
	if (!gnode || !gnode->id)
		return OPERATOR_CANCELLED;
	
	ngroup = (bNodeTree *)gnode->id;
	if (!node_group_make_test_selected(ntree, gnode, ngroup->idname, op->reports))
		return OPERATOR_CANCELLED;
	
	node_group_make_insert_selected(C, ntree, gnode);
	
	nodeSetActive(ntree, gnode);
	ED_node_tree_push(snode, ngroup, gnode);
	ntreeUpdateTree(bmain, ngroup);
	
	ntreeUpdateTree(bmain, ntree);
	
	snode_notify(C, snode);
	snode_dag_update(C, snode);
	
	return OPERATOR_FINISHED;
}
开发者ID:244xiao,项目名称:blender,代码行数:33,代码来源:node_group.c


示例2: active_node_panel

/* active node */
static void active_node_panel(const bContext *C, Panel *pa)
{
	SpaceNode *snode= CTX_wm_space_node(C);
	bNodeTree *ntree= (snode) ? snode->edittree : NULL;
	bNode *node = (ntree) ? nodeGetActive(ntree) : NULL; // xxx... for editing group nodes
	uiLayout *layout= pa->layout;
	uiBlock *block;
	PointerRNA ptr;
	
	/* verify pointers, and create RNA pointer for the node */
	if ELEM(NULL, ntree, node)
		return;
	//if (node->id) /* for group nodes */
	//	RNA_pointer_create(node->id, &RNA_Node, node, &ptr);
	//else
		RNA_pointer_create(&ntree->id, &RNA_Node, node, &ptr); 
	
	/* set update callback */
	// xxx is this really needed
	block= uiLayoutGetBlock(layout);
	uiBlockSetHandleFunc(block, do_node_region_buttons, NULL);
	
	/* draw this node's name, etc. */
	uiItemR(layout, &ptr, "label", 0, NULL, ICON_NODE);
	uiItemS(layout);
	uiItemR(layout, &ptr, "name", 0, NULL, ICON_NODE);
	uiItemS(layout);

	/* draw this node's settings */
	if (node->typeinfo && node->typeinfo->uifuncbut)
		node->typeinfo->uifuncbut(layout, (bContext *)C, &ptr);
	else if (node->typeinfo && node->typeinfo->uifunc)
		node->typeinfo->uifunc(layout, (bContext *)C, &ptr);
}
开发者ID:BHCLL,项目名称:blendocv,代码行数:35,代码来源:node_buttons.c


示例3: do_node_add_group

static void do_node_add_group(bContext *C, void *UNUSED(arg), int event)
{
	SpaceNode *snode = CTX_wm_space_node(C);
	Main *bmain = CTX_data_main(C);
	Scene *scene = CTX_data_scene(C);
	bNodeTemplate ntemp;
	
	if (event >= 0) {
		ntemp.ngroup = BLI_findlink(&G.main->nodetree, event);
		ntemp.type = ntemp.ngroup->nodetype;
	}
	else {
		ntemp.type = -event;
		switch (ntemp.type) {
			case NODE_GROUP:
				ntemp.ngroup = ntreeAddTree("Group", snode->treetype, ntemp.type);
				break;
			default:
				ntemp.ngroup = NULL;
		}
	}
	if (!ntemp.ngroup)
		return;
	
	ntemp.main = bmain;
	ntemp.scene = scene;
	
	do_node_add(C, &ntemp);
}
开发者ID:danielmarg,项目名称:blender-main,代码行数:29,代码来源:node_header.c


示例4: node_select_exec

static int node_select_exec(bContext *C, wmOperator *op)
{
	Main *bmain = CTX_data_main(C);
	SpaceNode *snode = CTX_wm_space_node(C);
	ARegion *ar = CTX_wm_region(C);
	int mval[2];
	short extend;
	
	/* get settings from RNA properties for operator */
	mval[0] = RNA_int_get(op->ptr, "mouse_x");
	mval[1] = RNA_int_get(op->ptr, "mouse_y");
	
	extend = RNA_boolean_get(op->ptr, "extend");
	
	/* perform the select */
	if (node_mouse_select(bmain, snode, ar, mval, extend)) {
		/* send notifiers */
		WM_event_add_notifier(C, NC_NODE | NA_SELECTED, NULL);
		
		/* allow tweak event to work too */
		return OPERATOR_FINISHED | OPERATOR_PASS_THROUGH;
	}
	else {
		/* allow tweak event to work too */
		return OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH;
	}
}
开发者ID:bitfusionio,项目名称:blender,代码行数:27,代码来源:node_select.c


示例5: 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;
}
开发者ID:bitfusionio,项目名称:blender,代码行数:30,代码来源:node_select.c


示例6: 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;
	rctf rectf;
	int gesture_mode = RNA_int_get(op->ptr, "gesture_mode");
	const bool extend = RNA_boolean_get(op->ptr, "extend");
	
	WM_operator_properties_border_to_rctf(op, &rectf);
	UI_view2d_region_to_view_rctf(&ar->v2d, &rectf, &rectf);
	
	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;
}
开发者ID:bitfusionio,项目名称:blender,代码行数:27,代码来源:node_select.c


示例7: do_lasso_select_node

static bool do_lasso_select_node(bContext *C, const int mcords[][2], short moves, short select)
{
	SpaceNode *snode = CTX_wm_space_node(C);
	bNode *node;

	ARegion *ar = CTX_wm_region(C);

	rcti rect;
	bool changed = false;

	/* get rectangle from operator */
	BLI_lasso_boundbox(&rect, mcords, moves);

	/* do actual selection */
	for (node = snode->edittree->nodes.first; node; node = node->next) {
		int screen_co[2];
		const float cent[2] = {BLI_rctf_cent_x(&node->totr),
		                       BLI_rctf_cent_y(&node->totr)};

		/* marker in screen coords */
		if (UI_view2d_view_to_region_clip(&ar->v2d, cent[0], cent[1], &screen_co[0], &screen_co[1]) &&
		    BLI_rcti_isect_pt(&rect, screen_co[0], screen_co[1]) &&
		    BLI_lasso_is_point_inside(mcords, moves, screen_co[0], screen_co[1], INT_MAX))
		{
			nodeSetSelected(node, select);
			changed = true;
		}
	}

	if (changed) {
		WM_event_add_notifier(C, NC_NODE | NA_SELECTED, NULL);
	}

	return changed;
}
开发者ID:bitfusionio,项目名称:blender,代码行数:35,代码来源:node_select.c


示例8: node_select_linked_from_exec

static int node_select_linked_from_exec(bContext *C, wmOperator *UNUSED(op))
{
	SpaceNode *snode = CTX_wm_space_node(C);
	bNodeLink *link;
	bNode *node;
	
	for (node = snode->edittree->nodes.first; node; node = node->next)
		node->flag &= ~NODE_TEST;

	for (link = snode->edittree->links.first; link; link = link->next) {
		if (nodeLinkIsHidden(link))
			continue;
		if (link->fromnode && link->tonode && (link->tonode->flag & NODE_SELECT))
			link->fromnode->flag |= NODE_TEST;
	}
	
	for (node = snode->edittree->nodes.first; node; node = node->next) {
		if (node->flag & NODE_TEST)
			nodeSetSelected(node, true);
	}
	
	ED_node_sort(snode->edittree);
	
	WM_event_add_notifier(C, NC_NODE | NA_SELECTED, NULL);
	return OPERATOR_FINISHED;
}
开发者ID:bitfusionio,项目名称:blender,代码行数:26,代码来源:node_select.c


示例9: node_select_all_exec

static int node_select_all_exec(bContext *C, wmOperator *op)
{
	SpaceNode *snode = CTX_wm_space_node(C);
	ListBase *node_lb = &snode->edittree->nodes;
	bNode *node;
	int action = RNA_enum_get(op->ptr, "action");

	if (action == SEL_TOGGLE) {
		if (ED_node_select_check(node_lb))
			action = SEL_DESELECT;
		else
			action = SEL_SELECT;
	}

	for (node = node_lb->first; node; node = node->next) {
		switch (action) {
			case SEL_SELECT:
				nodeSetSelected(node, true);
				break;
			case SEL_DESELECT:
				nodeSetSelected(node, false);
				break;
			case SEL_INVERT:
				nodeSetSelected(node, !(node->flag & SELECT));
				break;
		}
	}

	ED_node_sort(snode->edittree);
	
	WM_event_add_notifier(C, NC_NODE | NA_SELECTED, NULL);
	return OPERATOR_FINISHED;
}
开发者ID:bitfusionio,项目名称:blender,代码行数:33,代码来源:node_select.c


示例10: do_node_add_group

static void do_node_add_group(bContext *C, void *UNUSED(arg), int event)
{
	SpaceNode *snode= CTX_wm_space_node(C);
	bNodeTemplate ntemp;
	
	if (event>=0) {
		ntemp.ngroup= BLI_findlink(&G.main->nodetree, event);
		ntemp.type = ntemp.ngroup->nodetype;
	}
	else {
		ntemp.type = -event;
		switch (ntemp.type) {
		case NODE_GROUP:
			ntemp.ngroup = ntreeAddTree("Group", snode->treetype, ntemp.type);
			break;
		case NODE_FORLOOP:
			ntemp.ngroup = ntreeAddTree("For Loop", snode->treetype, ntemp.type);
			break;
		case NODE_WHILELOOP:
			ntemp.ngroup = ntreeAddTree("While Loop", snode->treetype, ntemp.type);
			break;
		default:
			ntemp.ngroup = NULL;
		}
	}
	if (!ntemp.ngroup)
		return;
	
	do_node_add(C, &ntemp);
}
开发者ID:xinkang,项目名称:blendocv,代码行数:30,代码来源:node_header.c


示例11: node_group_ungroup_exec

static int node_group_ungroup_exec(bContext *C, wmOperator *op)
{
	SpaceNode *snode = CTX_wm_space_node(C);
	const char *node_idname = group_node_idname(C);
	bNode *gnode;

	ED_preview_kill_jobs(C);

	gnode = node_group_get_active(C, node_idname);
	if (!gnode)
		return OPERATOR_CANCELLED;
	
	if (gnode->id && node_group_ungroup(snode->edittree, gnode)) {
		ntreeUpdateTree(CTX_data_main(C), snode->nodetree);
	}
	else {
		BKE_report(op->reports, RPT_WARNING, "Cannot ungroup");
		return OPERATOR_CANCELLED;
	}

	snode_notify(C, snode);
	snode_dag_update(C, snode);

	return OPERATOR_FINISHED;
}
开发者ID:244xiao,项目名称:blender,代码行数:25,代码来源:node_group.c


示例12: shader_get_from_context

static void shader_get_from_context(const bContext *C, bNodeTreeType *UNUSED(treetype), bNodeTree **r_ntree, ID **r_id, ID **r_from)
{
	SpaceNode *snode = CTX_wm_space_node(C);
	Scene *scene = CTX_data_scene(C);
	Object *ob = OBACT;
	
	if (!BKE_scene_use_new_shading_nodes(scene) || snode->shaderfrom == SNODE_SHADER_OBJECT) {
		if (ob) {
			*r_from = &ob->id;
			if (ob->type == OB_LAMP) {
				*r_id = ob->data;
				*r_ntree = ((Lamp *)ob->data)->nodetree;
			}
			else {
				Material *ma = give_current_material(ob, ob->actcol);
				if (ma) {
					*r_id = &ma->id;
					*r_ntree = ma->nodetree;
				}
			}
		}
	}
	else { /* SNODE_SHADER_WORLD */
		if (scene->world) {
			*r_from = NULL;
			*r_id = &scene->world->id;
			*r_ntree = scene->world->nodetree;
		}
	}
}
开发者ID:Walid-Shouman,项目名称:Blender,代码行数:30,代码来源:node_shader_tree.c


示例13: do_node_internal_buttons

static void do_node_internal_buttons(bContext *C, void *node_v, int event)
{
	if(event==B_NODE_EXEC) {
		SpaceNode *snode= CTX_wm_space_node(C);
		if(snode && snode->id)
			ED_node_changed_update(snode->id, node_v);
	}
}
开发者ID:mik0001,项目名称:Blender,代码行数:8,代码来源:node_draw.c


示例14: CTX_wm_space_node

static bNode *node_group_get_active(bContext *C, const char *node_idname)
{
	SpaceNode *snode = CTX_wm_space_node(C);
	bNode *node = nodeGetActive(snode->edittree);
	
	if (node && STREQ(node->idname, node_idname))
		return node;
	else
		return NULL;
}
开发者ID:244xiao,项目名称:blender,代码行数:10,代码来源:node_group.c


示例15: node_select_same_type_exec

static int node_select_same_type_exec(bContext *C, wmOperator *UNUSED(op))
{
	SpaceNode *snode = CTX_wm_space_node(C);

	node_select_same_type(snode);

	ED_node_sort(snode->edittree);

	WM_event_add_notifier(C, NC_NODE | NA_SELECTED, NULL);
	return OPERATOR_FINISHED;
}
开发者ID:ideasman42,项目名称:blender-wayland,代码行数:11,代码来源:node_select.c


示例16: node_add_menu

static void node_add_menu(bContext *C, uiLayout *layout, void *arg_nodeclass)
{
	Main *bmain = CTX_data_main(C);
	Scene *scene = CTX_data_scene(C);
	SpaceNode *snode = CTX_wm_space_node(C);
	bNodeTree *ntree;
	int nodeclass = GET_INT_FROM_POINTER(arg_nodeclass);
	int event, compatibility = 0;
	
	ntree = snode->nodetree;
	
	if (!ntree) {
		uiItemS(layout);
		return;
	}

	if (ntree->type == NTREE_SHADER) {
		if (BKE_scene_use_new_shading_nodes(scene))
			compatibility = NODE_NEW_SHADING;
		else
			compatibility = NODE_OLD_SHADING;
	}
	
	if (nodeclass == NODE_CLASS_GROUP) {
		bNodeTree *ngroup;
		
		uiLayoutSetFunc(layout, do_node_add_group, NULL);
		
		/* XXX hack: negative numbers used for empty group types */
		if (node_tree_has_type(ntree->type, NODE_GROUP))
			uiItemV(layout, IFACE_("New Group"), 0, -NODE_GROUP);
		uiItemS(layout);
		
		for (ngroup = bmain->nodetree.first, event = 0; ngroup; ngroup = ngroup->id.next, ++event) {
			/* only use group trees */
			if (ngroup->type == ntree->type && ngroup->nodetype == NODE_GROUP) {
				uiItemV(layout, ngroup->id.name + 2, 0, event);
			}
		}
	}
	else {
		bNodeType *ntype;
		
		uiLayoutSetFunc(layout, do_node_add_static, NULL);
		
		for (ntype = ntreeGetType(ntree->type)->node_types.first; ntype; ntype = ntype->next) {
			if (ntype->nclass == nodeclass && ntype->name) {
				if (!compatibility || (ntype->compatibility & compatibility)) {
					uiItemV(layout, IFACE_(ntype->name), 0, ntype->type);
				}
			}
		}
	}
}
开发者ID:danielmarg,项目名称:blender-main,代码行数:54,代码来源:node_header.c


示例17: node_menu_add

static void node_menu_add(const bContext *C, Menu *menu)
{
	SpaceNode *snode= CTX_wm_space_node(C);
	uiLayout *layout= menu->layout;

	if(!snode->nodetree)
		uiLayoutSetActive(layout, 0);

	if(snode->treetype==NTREE_SHADER) {
		uiItemMenuF(layout, IFACE_(N_("Input")), 0, node_add_menu, SET_INT_IN_POINTER(NODE_CLASS_INPUT));
		uiItemMenuF(layout, IFACE_(N_("Output")), 0, node_add_menu, SET_INT_IN_POINTER(NODE_CLASS_OUTPUT));
		uiItemMenuF(layout, IFACE_(N_("Color")), 0, node_add_menu, SET_INT_IN_POINTER(NODE_CLASS_OP_COLOR));
		uiItemMenuF(layout, IFACE_(N_("Vector")), 0, node_add_menu, SET_INT_IN_POINTER(NODE_CLASS_OP_VECTOR));
		uiItemMenuF(layout, IFACE_(N_("Convertor")), 0, node_add_menu, SET_INT_IN_POINTER(NODE_CLASS_CONVERTOR));
		uiItemMenuF(layout, IFACE_(N_("Group")), 0, node_add_menu, SET_INT_IN_POINTER(NODE_CLASS_GROUP));
		uiItemMenuF(layout, IFACE_(N_("Dynamic")), 0, node_add_menu, SET_INT_IN_POINTER(NODE_CLASS_OP_DYNAMIC));
		uiItemMenuF(layout, IFACE_(N_("Layout")), 0, node_add_menu, SET_INT_IN_POINTER(NODE_CLASS_LAYOUT));
	}
	else if(snode->treetype==NTREE_COMPOSIT) {
		uiItemMenuF(layout, IFACE_(N_("Input")), 0, node_add_menu, SET_INT_IN_POINTER(NODE_CLASS_INPUT));
		uiItemMenuF(layout, IFACE_(N_("Output")), 0, node_add_menu, SET_INT_IN_POINTER(NODE_CLASS_OUTPUT));
		
                uiItemMenuF(layout, "OpenCV Input", 0, node_add_menu, SET_INT_IN_POINTER(NODE_CLASS_OCV_INPUT));
                uiItemMenuF(layout, "OpenCV Output", 0, node_add_menu, SET_INT_IN_POINTER(NODE_CLASS_OCV_OUTPUT));
                uiItemMenuF(layout, "Array operations", 0, node_add_menu, SET_INT_IN_POINTER(NODE_CLASS_OCV_ARRAY));
                uiItemMenuF(layout, "Drawing functions", 0, node_add_menu, SET_INT_IN_POINTER(NODE_CLASS_OCV_DRAW));
                uiItemMenuF(layout, "Data persistent", 0, node_add_menu, SET_INT_IN_POINTER(NODE_CLASS_OCV_DATAPERSIST));
                uiItemMenuF(layout, "Miscelllaneous", 0, node_add_menu, SET_INT_IN_POINTER(NODE_CLASS_OCV_MISC));
                uiItemMenuF(layout, "Image processing", 0, node_add_menu, SET_INT_IN_POINTER(NODE_CLASS_OCV_IMAGEPROCESS));
                uiItemMenuF(layout, "Structural analysis", 0, node_add_menu, SET_INT_IN_POINTER(NODE_CLASS_OCV_STRUCTANALYSIS));
                uiItemMenuF(layout, "Motion analysis and object tracking", 0, node_add_menu, SET_INT_IN_POINTER(NODE_CLASS_OCV_MOTIONANALYSIS));
                uiItemMenuF(layout, "Pattern recognition", 0, node_add_menu, SET_INT_IN_POINTER(NODE_CLASS_OCV_PATTERNRECOGNITION));
                uiItemMenuF(layout, "Camera calibration and 3D reconstruction", 0, node_add_menu, SET_INT_IN_POINTER(NODE_CLASS_OCV_CAMERACALIBRATION));
                uiItemMenuF(layout, "Machine learning", 0, node_add_menu, SET_INT_IN_POINTER(NODE_CLASS_OCV_MACHINELEARNING));
                
                uiItemMenuF(layout, IFACE_(N_("Group")), 0, node_add_menu, SET_INT_IN_POINTER(NODE_CLASS_GROUP));
		uiItemMenuF(layout, IFACE_(N_("Layout")), 0, node_add_menu, SET_INT_IN_POINTER(NODE_CLASS_LAYOUT));
                //uiItemMenuF(layout, "OpenCV", 0, node_add_sub_menu_opencv, SET_INT_IN_POINTER(NODE_CLASS_OPENCV));
                uiItemMenuF(layout, "OpenCV", 0, node_add_sub_menu_blender, SET_INT_IN_POINTER(NODE_CLASS_BLENDERSUB));
                
	}
	else if(snode->treetype==NTREE_TEXTURE) {
		uiItemMenuF(layout, IFACE_(N_("Input")), 0, node_add_menu, SET_INT_IN_POINTER(NODE_CLASS_INPUT));
		uiItemMenuF(layout, IFACE_(N_("Output")), 0, node_add_menu, SET_INT_IN_POINTER(NODE_CLASS_OUTPUT));
		uiItemMenuF(layout, IFACE_(N_("Color")), 0, node_add_menu, SET_INT_IN_POINTER(NODE_CLASS_OP_COLOR));
		uiItemMenuF(layout, IFACE_(N_("Patterns")), 0, node_add_menu, SET_INT_IN_POINTER(NODE_CLASS_PATTERN));
		uiItemMenuF(layout, IFACE_(N_("Textures")), 0, node_add_menu, SET_INT_IN_POINTER(NODE_CLASS_TEXTURE));
		uiItemMenuF(layout, IFACE_(N_("Convertor")), 0, node_add_menu, SET_INT_IN_POINTER(NODE_CLASS_CONVERTOR));
		uiItemMenuF(layout, IFACE_(N_("Distort")), 0, node_add_menu, SET_INT_IN_POINTER(NODE_CLASS_DISTORT));
		uiItemMenuF(layout, IFACE_(N_("Group")), 0, node_add_menu, SET_INT_IN_POINTER(NODE_CLASS_GROUP));
		uiItemMenuF(layout, IFACE_(N_("Layout")), 0, node_add_menu, SET_INT_IN_POINTER(NODE_CLASS_LAYOUT));
	}
}
开发者ID:xinkang,项目名称:blendocv,代码行数:53,代码来源:node_header.c


示例18: node_tree_interface_panel

static void node_tree_interface_panel(const bContext *C, Panel *pa)
{
	SpaceNode *snode = CTX_wm_space_node(C);
	bNodeTree *ntree = (snode) ? snode->edittree : NULL;
	bNodeSocket *sock;
	int in_out;
	uiLayout *layout = pa->layout, *row, *split, *col;
	PointerRNA ptr, sockptr, opptr;

	if (!ntree)
		return;
	
	RNA_id_pointer_create((ID *)ntree, &ptr);
	
	node_tree_find_active_socket(ntree, &sock, &in_out);
	RNA_pointer_create((ID *)ntree, &RNA_NodeSocketInterface, sock, &sockptr);
	
	row = uiLayoutRow(layout, false);
	
	split = uiLayoutRow(row, true);
	col = uiLayoutColumn(split, true);
	uiItemL(col, IFACE_("Inputs:"), ICON_NONE);
	uiTemplateList(col, (bContext *)C, "NODE_UL_interface_sockets", "inputs", &ptr, "inputs", &ptr, "active_input",
	               NULL, 0, 0, 0, 0);
	opptr = uiItemFullO(col, "NODE_OT_tree_socket_add", "", ICON_PLUS, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS);
	RNA_enum_set(&opptr, "in_out", SOCK_IN);
	
	col = uiLayoutColumn(split, true);
	uiItemL(col, IFACE_("Outputs:"), ICON_NONE);
	uiTemplateList(col, (bContext *)C, "NODE_UL_interface_sockets", "outputs", &ptr, "outputs", &ptr, "active_output",
	               NULL, 0, 0, 0, 0);
	opptr = uiItemFullO(col, "NODE_OT_tree_socket_add", "", ICON_PLUS, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS);
	RNA_enum_set(&opptr, "in_out", SOCK_OUT);
	
	col = uiLayoutColumn(row, true);
	opptr = uiItemFullO(col, "NODE_OT_tree_socket_move", "", ICON_TRIA_UP, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS);
	RNA_enum_set(&opptr, "direction", 1);
	opptr = uiItemFullO(col, "NODE_OT_tree_socket_move", "", ICON_TRIA_DOWN, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS);
	RNA_enum_set(&opptr, "direction", 2);
	
	if (sock) {
		row = uiLayoutRow(layout, true);
		uiItemR(row, &sockptr, "name", 0, NULL, ICON_NONE);
		uiItemO(row, "", ICON_X, "NODE_OT_tree_socket_remove");
		
		if (sock->typeinfo->interface_draw) {
			uiItemS(layout);
			sock->typeinfo->interface_draw((bContext *)C, layout, &sockptr);
		}
	}
}
开发者ID:Andrewson3D,项目名称:blender-for-vray,代码行数:51,代码来源:node_buttons.c


示例19: node_add_menu

static void node_add_menu(bContext *C, uiLayout *layout, void *arg_nodeclass)
{
	Main *bmain= CTX_data_main(C);
	SpaceNode *snode= CTX_wm_space_node(C);
	bNodeTree *ntree;
	int nodeclass= GET_INT_FROM_POINTER(arg_nodeclass);
	int event;
	
	ntree = snode->nodetree;
	
	if(!ntree) {
		uiItemS(layout);
		return;
	}
	
	if (nodeclass==NODE_CLASS_GROUP) {
		bNodeTree *ngroup;
		
		uiLayoutSetFunc(layout, do_node_add_group, NULL);
		
		/* XXX hack: negative numbers used for empty group types */
		if (node_tree_has_type(ntree->type, NODE_GROUP))
			uiItemV(layout, "New Group", 0, -NODE_GROUP);
		if (node_tree_has_type(ntree->type, NODE_FORLOOP))
			uiItemV(layout, "New For Loop", 0, -NODE_FORLOOP);
		if (node_tree_has_type(ntree->type, NODE_WHILELOOP))
			uiItemV(layout, "New While Loop", 0, -NODE_WHILELOOP);
		uiItemS(layout);
		
		for(ngroup=bmain->nodetree.first, event=0; ngroup; ngroup= ngroup->id.next, ++event) {
			/* only use group trees */
			if (ngroup->type==ntree->type && ELEM3(ngroup->nodetype, NODE_GROUP, NODE_FORLOOP, NODE_WHILELOOP)) {
				uiItemV(layout, ngroup->id.name+2, 0, event);
			}
		}
	}
	else if (nodeclass==NODE_DYNAMIC) {
		/* disabled */
	}
	else {
		bNodeType *ntype;
		
		uiLayoutSetFunc(layout, do_node_add_static, NULL);
		
		for (ntype=ntreeGetType(ntree->type)->node_types.first; ntype; ntype=ntype->next) {
			if(ntype->nclass==nodeclass && ntype->name)
				uiItemV(layout, ntype->name, 0, ntype->type);
		}
	}
}
开发者ID:xinkang,项目名称:blendocv,代码行数:50,代码来源:node_header.c


示例20: 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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ CTX_wm_view3d函数代码示例发布时间:2022-05-30
下一篇:
C++ CTX_wm_space_file函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap