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


C++ RNA_struct_find_property函数代码示例

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


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

示例1: file_panel_operator

static void file_panel_operator(const bContext *C, Panel *pa)
{
    SpaceFile *sfile = CTX_wm_space_file(C);
    wmOperator *op = sfile->op;

    UI_block_func_set(uiLayoutGetBlock(pa->layout), file_draw_check_cb, NULL, NULL);

    /* Hack: temporary hide.*/
    const char *hide[] = {"filepath", "directory", "filename", "files"};
    for (int i = 0; i < ARRAY_SIZE(hide); i++) {
        PropertyRNA *prop = RNA_struct_find_property(op->ptr, hide[i]);
        if (prop) {
            RNA_def_property_flag(prop, PROP_HIDDEN);
        }
    }

    uiTemplateOperatorPropertyButs(C, pa->layout, op, '\0', UI_TEMPLATE_OP_PROPS_SHOW_EMPTY);

    for (int i = 0; i < ARRAY_SIZE(hide); i++) {
        PropertyRNA *prop = RNA_struct_find_property(op->ptr, hide[i]);
        if (prop) {
            RNA_def_property_clear_flag(prop, PROP_HIDDEN);
        }
    }

    UI_block_func_set(uiLayoutGetBlock(pa->layout), NULL, NULL, NULL);
}
开发者ID:Ichthyostega,项目名称:blender,代码行数:27,代码来源:file_panels.c

示例2: file_operator_to_sfile

void file_operator_to_sfile(SpaceFile *sfile, wmOperator *op)
{
    PropertyRNA *prop;

    /* If neither of the above are set, split the filepath back */
    if ((prop = RNA_struct_find_property(op->ptr, "filepath"))) {
        char filepath[FILE_MAX];
        RNA_property_string_get(op->ptr, prop, filepath);
        BLI_split_dirfile(filepath, sfile->params->dir, sfile->params->file, sizeof(sfile->params->dir), sizeof(sfile->params->file));
    }
    else {
        if ((prop = RNA_struct_find_property(op->ptr, "filename"))) {
            RNA_property_string_get(op->ptr, prop, sfile->params->file);
        }
        if ((prop = RNA_struct_find_property(op->ptr, "directory"))) {
            RNA_property_string_get(op->ptr, prop, sfile->params->dir);
        }
    }
    
    /* we could check for relative_path property which is used when converting
     * in the other direction but doesnt hurt to do this every time */
    BLI_path_abs(sfile->params->dir, G.main->name);

    /* XXX, files and dirs updates missing, not really so important though */
}
开发者ID:manwapastorelli,项目名称:blender-git,代码行数:25,代码来源:file_ops.c

示例3: initSnapping

void initSnapping(TransInfo *t, wmOperator *op)
{
    ToolSettings *ts = t->settings;
    short snap_target = t->settings->snap_target;
    
    resetSnapping(t);
    
    /* if snap property exists */
    if (op && RNA_struct_find_property(op->ptr, "snap") && RNA_struct_property_is_set(op->ptr, "snap")) {
        if (RNA_boolean_get(op->ptr, "snap")) {
            t->modifiers |= MOD_SNAP;

            if (RNA_struct_property_is_set(op->ptr, "snap_target")) {
                snap_target = RNA_enum_get(op->ptr, "snap_target");
            }
            
            if (RNA_struct_property_is_set(op->ptr, "snap_point")) {
                RNA_float_get_array(op->ptr, "snap_point", t->tsnap.snapPoint);
                t->tsnap.status |= SNAP_FORCED | POINT_INIT;
            }
            
            /* snap align only defined in specific cases */
            if (RNA_struct_find_property(op->ptr, "snap_align")) {
                t->tsnap.align = RNA_boolean_get(op->ptr, "snap_align");
                RNA_float_get_array(op->ptr, "snap_normal", t->tsnap.snapNormal);
                normalize_v3(t->tsnap.snapNormal);
            }

            if (RNA_struct_find_property(op->ptr, "use_snap_project")) {
                t->tsnap.project = RNA_boolean_get(op->ptr, "use_snap_project");
            }

            if (RNA_struct_find_property(op->ptr, "use_snap_self")) {
                t->tsnap.snap_self = RNA_boolean_get(op->ptr, "use_snap_self");
            }
        }
    }
    /* use scene defaults only when transform is modal */
    else if (t->flag & T_MODAL) {
        if (ELEM(t->spacetype, SPACE_VIEW3D, SPACE_IMAGE, SPACE_NODE)) {
            if (ts->snap_flag & SCE_SNAP) {
                t->modifiers |= MOD_SNAP;
            }

            t->tsnap.align = ((t->settings->snap_flag & SCE_SNAP_ROTATE) != 0);
            t->tsnap.project = ((t->settings->snap_flag & SCE_SNAP_PROJECT) != 0);
            t->tsnap.snap_self = !((t->settings->snap_flag & SCE_SNAP_NO_SELF) != 0);
            t->tsnap.peel = ((t->settings->snap_flag & SCE_SNAP_PROJECT) != 0);
        }

        /* for now only 3d view (others can be added if we want) */
        if (t->spacetype == SPACE_VIEW3D) {
            t->tsnap.snap_spatial_grid = ((t->settings->snap_flag & SCE_SNAP_ABS_GRID) != 0);
        }
    }
    
    t->tsnap.target = snap_target;

    initSnappingMode(t);
}
开发者ID:diekev,项目名称:blender,代码行数:60,代码来源:transform_snap.c

示例4: RNA_id_pointer_create

void UnitConverter::calculate_scale(Scene &sce)
{
    PointerRNA scene_ptr, unit_settings;
    PropertyRNA *system_ptr, *scale_ptr;
    RNA_id_pointer_create(&sce.id, &scene_ptr);

    unit_settings = RNA_pointer_get(&scene_ptr, "unit_settings");
    system_ptr    = RNA_struct_find_property(&unit_settings, "system");
    scale_ptr     = RNA_struct_find_property(&unit_settings, "scale_length");

    int   type    = RNA_property_enum_get(&unit_settings, system_ptr);

    float bl_scale;

    switch (type) {
        case USER_UNIT_NONE:
            bl_scale = 1.0; // map 1 Blender unit to 1 Meter
            break;

        case USER_UNIT_METRIC:
            bl_scale = RNA_property_float_get(&unit_settings, scale_ptr);
            break;

        default :
            bl_scale = RNA_property_float_get(&unit_settings, scale_ptr);
            // it looks like the conversion to Imperial is done implicitly.
            // So nothing to do here.
            break;
    }

    float rescale[3];
    rescale[0] = rescale[1] = rescale[2] = getLinearMeter() / bl_scale;

    size_to_mat4(scale_mat4, rescale);
}
开发者ID:SuriyaaKudoIsc,项目名称:blender-git,代码行数:35,代码来源:collada_internal.cpp

示例5: ED_view3d_gizmo_mesh_preselect_get_active

void ED_view3d_gizmo_mesh_preselect_get_active(bContext *C,
                                               wmGizmo *gz,
                                               Base **r_base,
                                               BMElem **r_ele)
{
  ViewLayer *view_layer = CTX_data_view_layer(C);

  const int object_index = RNA_int_get(gz->ptr, "object_index");

  /* weak, allocate an array just to access the index. */
  Base *base = NULL;
  Object *obedit = NULL;
  {
    uint bases_len;
    Base **bases = BKE_view_layer_array_from_bases_in_edit_mode(
        view_layer, CTX_wm_view3d(C), &bases_len);
    if (object_index < bases_len) {
      base = bases[object_index];
      obedit = base->object;
    }
    MEM_freeN(bases);
  }

  *r_base = base;
  *r_ele = NULL;

  if (obedit) {
    BMEditMesh *em = BKE_editmesh_from_object(obedit);
    BMesh *bm = em->bm;
    PropertyRNA *prop;

    /* Ring select only defines edge, check properties exist first. */
    prop = RNA_struct_find_property(gz->ptr, "vert_index");
    const int vert_index = prop ? RNA_property_int_get(gz->ptr, prop) : -1;
    prop = RNA_struct_find_property(gz->ptr, "edge_index");
    const int edge_index = prop ? RNA_property_int_get(gz->ptr, prop) : -1;
    prop = RNA_struct_find_property(gz->ptr, "face_index");
    const int face_index = prop ? RNA_property_int_get(gz->ptr, prop) : -1;

    if (vert_index != -1) {
      *r_ele = (BMElem *)BM_vert_at_index_find(bm, vert_index);
    }
    else if (edge_index != -1) {
      *r_ele = (BMElem *)BM_edge_at_index_find(bm, edge_index);
    }
    else if (face_index != -1) {
      *r_ele = (BMElem *)BM_face_at_index_find(bm, face_index);
    }
  }
}
开发者ID:dfelinto,项目名称:blender,代码行数:50,代码来源:view3d_gizmo_preselect_type.c

示例6: poselib_remove_exec

static int poselib_remove_exec(bContext *C, wmOperator *op)
{
    Object *ob = get_poselib_object(C);
    bAction *act = (ob) ? ob->poselib : NULL;
    TimeMarker *marker;
    int marker_index;
    FCurve *fcu;
    PropertyRNA *prop;

    /* check if valid poselib */
    if (act == NULL) {
        BKE_report(op->reports, RPT_ERROR, "Object does not have pose lib data");
        return OPERATOR_CANCELLED;
    }

    prop = RNA_struct_find_property(op->ptr, "pose");
    if (RNA_property_is_set(op->ptr, prop)) {
        marker_index = RNA_property_enum_get(op->ptr, prop);
    }
    else {
        marker_index = act->active_marker - 1;
    }

    /* get index (and pointer) of pose to remove */
    marker = BLI_findlink(&act->markers, marker_index);
    if (marker == NULL) {
        BKE_reportf(op->reports, RPT_ERROR, "Invalid pose specified %d", marker_index);
        return OPERATOR_CANCELLED;
    }
    
    /* remove relevant keyframes */
    for (fcu = act->curves.first; fcu; fcu = fcu->next) {
        BezTriple *bezt;
        unsigned int i;
        
        if (fcu->bezt) {
            for (i = 0, bezt = fcu->bezt; i < fcu->totvert; i++, bezt++) {
                /* check if remove */
                if (IS_EQF(bezt->vec[1][0], (float)marker->frame)) {
                    delete_fcurve_key(fcu, i, 1);
                    break;
                }
            }
        }
    }
    
    /* remove poselib from list */
    BLI_freelinkN(&act->markers, marker);
    
    /* fix active pose number */
    act->active_marker = 0;
    
    /* send notifiers for this - using keyframe editing notifiers, since action 
     * may be being shown in anim editors as active action 
     */
    WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
    
    /* done */
    return OPERATOR_FINISHED;
}
开发者ID:castlelore,项目名称:blender-git,代码行数:60,代码来源:pose_lib.c

示例7: rna_ui_get_enum_icon

static int rna_ui_get_enum_icon(bContext *C, PointerRNA *ptr, const char *propname, const char *identifier)
{
    PropertyRNA *prop = NULL;
    EnumPropertyItem *items = NULL, *item;
    bool free;
    int icon = ICON_NONE;

    prop = RNA_struct_find_property(ptr, propname);
    if (!prop || (RNA_property_type(prop) != PROP_ENUM)) {
        RNA_warning("Property not found or not an enum: %s.%s", RNA_struct_identifier(ptr->type), propname);
        return icon;
    }

    RNA_property_enum_items(C, ptr, prop, &items, NULL, &free);

    if (items) {
        for (item = items; item->identifier; item++) {
            if (item->identifier[0] && STREQ(item->identifier, identifier)) {
                icon = item->icon;
                break;
            }
        }
        if (free) {
            MEM_freeN(items);
        }
    }

    return icon;
}
开发者ID:flair2005,项目名称:mechanical-blender,代码行数:29,代码来源:rna_ui_api.c

示例8: wm_homefile_read_exec

int wm_homefile_read_exec(bContext *C, wmOperator *op)
{
    const bool from_memory = (STREQ(op->type->idname, "WM_OT_read_factory_settings"));
    char filepath_buf[FILE_MAX];
    const char *filepath = NULL;

    if (!from_memory) {
        PropertyRNA *prop = RNA_struct_find_property(op->ptr, "filepath");

        /* This can be used when loading of a start-up file should only change
         * the scene content but keep the blender UI as it is. */
        wm_open_init_load_ui(op, true);
        BKE_BIT_TEST_SET(G.fileflags, !RNA_boolean_get(op->ptr, "load_ui"), G_FILE_NO_UI);

        if (RNA_property_is_set(op->ptr, prop)) {
            RNA_property_string_get(op->ptr, prop, filepath_buf);
            filepath = filepath_buf;
            if (BLI_access(filepath, R_OK)) {
                BKE_reportf(op->reports, RPT_ERROR, "Can't read alternative start-up file: '%s'", filepath);
                return OPERATOR_CANCELLED;
            }
        }
    }
    else {
        /* always load UI for factory settings (prefs will re-init) */
        G.fileflags &= ~G_FILE_NO_UI;
    }

    return wm_homefile_read(C, op->reports, from_memory, filepath) ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
}
开发者ID:ChunHungLiu,项目名称:blender,代码行数:30,代码来源:wm_files.c

示例9: edbm_bevel_update_header

static void edbm_bevel_update_header(bContext *C, wmOperator *op)
{
    const char *str = IFACE_("Confirm: (Enter/LMB), Cancel: (Esc/RMB), Mode: %s (M), Clamp Overlap: %s (C), "
                             "Vertex Only: %s (V), Profile Control: %s (P), Offset: %s, Segments: %d, Profile: %.3f");

    char msg[UI_MAX_DRAW_STR];
    ScrArea *sa = CTX_wm_area(C);
    Scene *sce = CTX_data_scene(C);

    if (sa) {
        BevelData *opdata = op->customdata;
        char offset_str[NUM_STR_REP_LEN];
        const char *type_str;
        PropertyRNA *prop = RNA_struct_find_property(op->ptr, "offset_type");

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

        RNA_property_enum_name_gettexted(C, op->ptr, prop, RNA_property_enum_get(op->ptr, prop), &type_str);

        BLI_snprintf(msg, sizeof(msg), str, type_str,
                     WM_bool_as_string(RNA_boolean_get(op->ptr, "clamp_overlap")),
                     WM_bool_as_string(RNA_boolean_get(op->ptr, "vertex_only")),
                     WM_bool_as_string(opdata->value_mode == PROFILE_VALUE),
                     offset_str, RNA_int_get(op->ptr, "segments"), RNA_float_get(op->ptr, "profile"));

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

示例10: transformops_loopsel_hack

/**
 * Special hack for MESH_OT_loopcut_slide so we get back to the selection mode
 */
static void transformops_loopsel_hack(bContext *C, wmOperator *op)
{
    if (op->type->idname == OP_EDGE_SLIDE) {
        if (op->opm && op->opm->opm && op->opm->opm->prev) {
            wmOperator *op_prev = op->opm->opm->prev;
            Scene *scene = CTX_data_scene(C);
            int mesh_select_mode[3];
            PropertyRNA *prop = RNA_struct_find_property(op_prev->ptr, "mesh_select_mode_init");

            if (prop && RNA_property_is_set(op_prev->ptr, prop)) {
                ToolSettings *ts = scene->toolsettings;
                short selectmode_orig;

                RNA_property_boolean_get_array(op_prev->ptr, prop, mesh_select_mode);
                selectmode_orig = ((mesh_select_mode[0] ? SCE_SELECT_VERTEX : 0) |
                                   (mesh_select_mode[1] ? SCE_SELECT_EDGE   : 0) |
                                   (mesh_select_mode[2] ? SCE_SELECT_FACE   : 0));

                /* still switch if we were originally in face select mode */
                if ((ts->selectmode != selectmode_orig) && (selectmode_orig != SCE_SELECT_FACE)) {
                    BMEditMesh *em = BKE_editmesh_from_object(scene->obedit);
                    em->selectmode = ts->selectmode = selectmode_orig;
                    EDBM_selectmode_set(em);
                }
            }
        }
    }
}
开发者ID:LucaRood,项目名称:Blender,代码行数:31,代码来源:transform_ops.c

示例11: RNA_struct_find_property

static const char *rna_ui_get_enum_description(
        bContext *C, PointerRNA *ptr, const char *propname,
        const char *identifier)
{
    PropertyRNA *prop = NULL;
    const EnumPropertyItem *items = NULL, *item;
    bool free;
    const char *desc = "";

    prop = RNA_struct_find_property(ptr, propname);
    if (!prop || (RNA_property_type(prop) != PROP_ENUM)) {
        RNA_warning("Property not found or not an enum: %s.%s", RNA_struct_identifier(ptr->type), propname);
        return desc;
    }

    RNA_property_enum_items_gettexted(C, ptr, prop, &items, NULL, &free);

    if (items) {
        for (item = items; item->identifier; item++) {
            if (item->identifier[0] && STREQ(item->identifier, identifier)) {
                desc = item->description;
                break;
            }
        }
        if (free) {
            MEM_freeN((void *)items);
        }
    }

    return desc;
}
开发者ID:Ichthyostega,项目名称:blender,代码行数:31,代码来源:rna_ui_api.c

示例12: rna_uiItemR

static void rna_uiItemR(uiLayout *layout, PointerRNA *ptr, const char *propname, const char *name, const char *text_ctxt,
                        int translate, int icon, int expand, int slider, int toggle, int icon_only, int event,
                        int full_event, int emboss, int index, int icon_value)
{
    PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
    int flag = 0;

    if (!prop) {
        RNA_warning("property not found: %s.%s", RNA_struct_identifier(ptr->type), propname);
        return;
    }

    if (icon_value && !icon) {
        icon = icon_value;
    }

    /* Get translated name (label). */
    name = rna_translate_ui_text(name, text_ctxt, NULL, prop, translate);

    flag |= (slider) ? UI_ITEM_R_SLIDER : 0;
    flag |= (expand) ? UI_ITEM_R_EXPAND : 0;
    flag |= (toggle) ? UI_ITEM_R_TOGGLE : 0;
    flag |= (icon_only) ? UI_ITEM_R_ICON_ONLY : 0;
    flag |= (event) ? UI_ITEM_R_EVENT : 0;
    flag |= (full_event) ? UI_ITEM_R_FULL_EVENT : 0;
    flag |= (emboss) ? 0 : UI_ITEM_R_NO_BG;

    uiItemFullR(layout, ptr, prop, index, 0, flag, name, icon);
}
开发者ID:flair2005,项目名称:mechanical-blender,代码行数:29,代码来源:rna_ui_api.c

示例13: ui_pie_menu_level_invoke

/**
 * Invokes a new pie menu for a new level.
 */
static void ui_pie_menu_level_invoke(bContext *C, void *argN, void *arg2)
{
    EnumPropertyItem *item_array = (EnumPropertyItem *)argN;
    PieMenuLevelData *lvl = (PieMenuLevelData *)arg2;
    wmWindow *win = CTX_wm_window(C);

    uiPieMenu *pie = UI_pie_menu_begin(C, IFACE_(lvl->title), lvl->icon, win->eventstate);
    uiLayout *layout = UI_pie_menu_layout(pie);

    layout = uiLayoutRadial(layout);

    PointerRNA ptr;

    WM_operator_properties_create_ptr(&ptr, lvl->ot);
    /* so the context is passed to itemf functions (some need it) */
    WM_operator_properties_sanitize(&ptr, false);
    PropertyRNA *prop = RNA_struct_find_property(&ptr, lvl->propname);

    if (prop) {
        uiItemsFullEnumO_items(
                layout, lvl->ot, ptr, prop, lvl->properties, lvl->context, lvl->flag,
                item_array, lvl->totitem);
    }
    else {
        RNA_warning("%s.%s not found", RNA_struct_identifier(ptr.type), lvl->propname);
    }

    UI_pie_menu_end(C, pie);
}
开发者ID:wisaac407,项目名称:blender,代码行数:32,代码来源:interface_region_menu_pie.c

示例14: node_animation_properties

static int node_animation_properties(bNodeTree *ntree, bNode *node)
{
    bNodeSocket *sock;
    const ListBase *lb;
    Link *link;
    PointerRNA ptr;
    PropertyRNA *prop;

    /* check to see if any of the node's properties have fcurves */
    RNA_pointer_create((ID *)ntree, &RNA_Node, node, &ptr);
    lb = RNA_struct_type_properties(ptr.type);

    for (link = lb->first; link; link = link->next) {
        prop = (PropertyRNA *)link;

        if (RNA_property_animated(&ptr, prop)) {
            nodeUpdate(ntree, node);
            return 1;
        }
    }

    /* now check node sockets */
    for (sock = node->inputs.first; sock; sock = sock->next) {
        RNA_pointer_create((ID *)ntree, &RNA_NodeSocket, sock, &ptr);
        prop = RNA_struct_find_property(&ptr, "default_value");

        if (RNA_property_animated(&ptr, prop)) {
            nodeUpdate(ntree, node);
            return 1;
        }
    }

    return 0;
}
开发者ID:greg100795,项目名称:blender-git,代码行数:34,代码来源:node_composite_tree.c

示例15: pose_slide_apply_props

/* helper for apply() - perform sliding for custom properties */
static void pose_slide_apply_props(tPoseSlideOp *pso, tPChanFCurveLink *pfl)
{
    PointerRNA ptr = {{NULL}};
    LinkData *ld;
    int len = strlen(pfl->pchan_path);
    
    /* setup pointer RNA for resolving paths */
    RNA_pointer_create(NULL, &RNA_PoseBone, pfl->pchan, &ptr);
    
    /* custom properties are just denoted using ["..."][etc.] after the end of the base path, 
     * so just check for opening pair after the end of the path
     */
    for (ld = pfl->fcurves.first; ld; ld = ld->next) {
        FCurve *fcu = (FCurve *)ld->data;
        char *bPtr, *pPtr;
        
        if (fcu->rna_path == NULL)
            continue;
        
        /* do we have a match? 
         *	- bPtr is the RNA Path with the standard part chopped off
         *	- pPtr is the chunk of the path which is left over
         */
        bPtr = strstr(fcu->rna_path, pfl->pchan_path) + len;
        pPtr = strstr(bPtr, "[\"");   /* dummy " for texteditor bugs */
        
        if (pPtr) {
            /* use RNA to try and get a handle on this property, then, assuming that it is just
             * numerical, try and grab the value as a float for temp editing before setting back
             */
            PropertyRNA *prop = RNA_struct_find_property(&ptr, pPtr);
            
            if (prop) {
                switch (RNA_property_type(prop)) {
                    case PROP_FLOAT:
                    {
                        float tval = RNA_property_float_get(&ptr, prop);
                        pose_slide_apply_val(pso, fcu, &tval);
                        RNA_property_float_set(&ptr, prop, tval);
                        break;
                    }
                    case PROP_BOOLEAN:
                    case PROP_ENUM:
                    case PROP_INT:
                    {
                        float tval = (float)RNA_property_int_get(&ptr, prop);
                        pose_slide_apply_val(pso, fcu, &tval);
                        RNA_property_int_set(&ptr, prop, (int)tval);
                        break;
                    }
                    default:
                        /* cannot handle */
                        //printf("Cannot Pose Slide non-numerical property\n");
                        break;
                }
            }
        }
    }
}
开发者ID:Walid-Shouman,项目名称:Blender,代码行数:60,代码来源:pose_slide.c


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