本文整理汇总了C++中CTX_wm_space_node函数的典型用法代码示例。如果您正苦于以下问题:C++ CTX_wm_space_node函数的具体用法?C++ CTX_wm_space_node怎么用?C++ CTX_wm_space_node使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CTX_wm_space_node函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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);
}
示例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);
}
示例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;
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
}
}
示例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);
}
}
示例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;
}
示例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;
}