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

C++ ELEM函数代码示例

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

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



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

示例1: ui_draw_but_WAVEFORM

void ui_draw_but_WAVEFORM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol), rcti *recti)
{
	Scopes *scopes = (Scopes *)but->poin;
	rctf rect;
	int i, c;
	float w, w3, h, alpha, yofs;
	GLint scissor[4];
	float colors[3][3] = MAT3_UNITY;
	float colorsycc[3][3] = {{1, 0, 1}, {1, 1, 0}, {0, 1, 1}};
	float colors_alpha[3][3], colorsycc_alpha[3][3]; /* colors  pre multiplied by alpha for speed up */
	float min, max;
	
	if (scopes == NULL) return;
	
	rect.xmin = (float)recti->xmin + 1;
	rect.xmax = (float)recti->xmax - 1;
	rect.ymin = (float)recti->ymin + SCOPE_RESIZE_PAD + 2;
	rect.ymax = (float)recti->ymax - 1;

	if (scopes->wavefrm_yfac < 0.5f)
		scopes->wavefrm_yfac = 0.98f;
	w = BLI_rctf_size_x(&rect) - 7;
	h = BLI_rctf_size_y(&rect) * scopes->wavefrm_yfac;
	yofs = rect.ymin + (BLI_rctf_size_y(&rect) - h) / 2.0f;
	w3 = w / 3.0f;
	
	/* log scale for alpha */
	alpha = scopes->wavefrm_alpha * scopes->wavefrm_alpha;
	
	for (c = 0; c < 3; c++) {
		for (i = 0; i < 3; i++) {
			colors_alpha[c][i] = colors[c][i] * alpha;
			colorsycc_alpha[c][i] = colorsycc[c][i] * alpha;
		}
	}
			
	glEnable(GL_BLEND);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
	
	glColor4f(0.f, 0.f, 0.f, 0.3f);
	uiSetRoundBox(UI_CNR_ALL);
	uiDrawBox(GL_POLYGON, rect.xmin - 1, rect.ymin - 1, rect.xmax + 1, rect.ymax + 1, 3.0f);
	

	/* need scissor test, waveform can draw outside of boundary */
	glGetIntegerv(GL_VIEWPORT, scissor);
	glScissor(ar->winrct.xmin + (rect.xmin - 1),
	          ar->winrct.ymin + (rect.ymin - 1),
	          (rect.xmax + 1) - (rect.xmin - 1),
	          (rect.ymax + 1) - (rect.ymin - 1));

	glColor4f(1.f, 1.f, 1.f, 0.08f);
	/* draw grid lines here */
	for (i = 0; i < 6; i++) {
		char str[4];
		BLI_snprintf(str, sizeof(str), "%-3d", i * 20);
		str[3] = '\0';
		fdrawline(rect.xmin + 22, yofs + (i / 5.f) * h, rect.xmax + 1, yofs + (i / 5.f) * h);
		BLF_draw_default(rect.xmin + 1, yofs - 5 + (i / 5.f) * h, 0, str, sizeof(str) - 1);
		/* in the loop because blf_draw reset it */
		glEnable(GL_BLEND);
		glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
	}
	/* 3 vertical separation */
	if (scopes->wavefrm_mode != SCOPES_WAVEFRM_LUMA) {
		for (i = 1; i < 3; i++) {
			fdrawline(rect.xmin + i * w3, rect.ymin, rect.xmin + i * w3, rect.ymax);
		}
	}
	
	/* separate min max zone on the right */
	fdrawline(rect.xmin + w, rect.ymin, rect.xmin + w, rect.ymax);
	/* 16-235-240 level in case of ITU-R BT601/709 */
	glColor4f(1.f, 0.4f, 0.f, 0.2f);
	if (ELEM(scopes->wavefrm_mode, SCOPES_WAVEFRM_YCC_601, SCOPES_WAVEFRM_YCC_709)) {
		fdrawline(rect.xmin + 22, yofs + h * 16.0f / 255.0f, rect.xmax + 1, yofs + h * 16.0f / 255.0f);
		fdrawline(rect.xmin + 22, yofs + h * 235.0f / 255.0f, rect.xmin + w3, yofs + h * 235.0f / 255.0f);
		fdrawline(rect.xmin + 3 * w3, yofs + h * 235.0f / 255.0f, rect.xmax + 1, yofs + h * 235.0f / 255.0f);
		fdrawline(rect.xmin + w3, yofs + h * 240.0f / 255.0f, rect.xmax + 1, yofs + h * 240.0f / 255.0f);
	}
	/* 7.5 IRE black point level for NTSC */
	if (scopes->wavefrm_mode == SCOPES_WAVEFRM_LUMA)
		fdrawline(rect.xmin, yofs + h * 0.075f, rect.xmax + 1, yofs + h * 0.075f);

	if (scopes->ok && scopes->waveform_1 != NULL) {
		
		/* LUMA (1 channel) */
		glBlendFunc(GL_ONE, GL_ONE);
		glColor3f(alpha, alpha, alpha);
		if (scopes->wavefrm_mode == SCOPES_WAVEFRM_LUMA) {

			glBlendFunc(GL_ONE, GL_ONE);
			
			glPushMatrix();
			glEnableClientState(GL_VERTEX_ARRAY);
			
			glTranslatef(rect.xmin, yofs, 0.f);
			glScalef(w, h, 0.f);
			glVertexPointer(2, GL_FLOAT, 0, scopes->waveform_1);
			glDrawArrays(GL_POINTS, 0, scopes->waveform_tot);
//.........这里部分代码省略.........
开发者ID:Eibriel,项目名称:kiriblender,代码行数:101,代码来源:interface_draw.c


示例2: borderselect_action

static void borderselect_action(bAnimContext *ac, const rcti rect, short mode, short selectmode)
{
	ListBase anim_data = {NULL, NULL};
	bAnimListElem *ale;
	int filter;

	KeyframeEditData ked;
	KeyframeEditFunc ok_cb, select_cb;
	View2D *v2d = &ac->ar->v2d;
	rctf rectf;
	float ymin = 0, ymax = (float)(-ACHANNEL_HEIGHT_HALF(ac));

	/* convert mouse coordinates to frame ranges and channel coordinates corrected for view pan/zoom */
	UI_view2d_region_to_view(v2d, rect.xmin, rect.ymin + 2, &rectf.xmin, &rectf.ymin);
	UI_view2d_region_to_view(v2d, rect.xmax, rect.ymax - 2, &rectf.xmax, &rectf.ymax);

	/* filter data */
	filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS);
	ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);

	/* get beztriple editing/validation funcs  */
	select_cb = ANIM_editkeyframes_select(selectmode);

	if (ELEM(mode, ACTKEYS_BORDERSEL_FRAMERANGE, ACTKEYS_BORDERSEL_ALLKEYS))
		ok_cb = ANIM_editkeyframes_ok(BEZT_OK_FRAMERANGE);
	else
		ok_cb = NULL;

	/* init editing data */
	memset(&ked, 0, sizeof(KeyframeEditData));

	/* loop over data, doing border select */
	for (ale = anim_data.first; ale; ale = ale->next) {
		AnimData *adt = ANIM_nla_mapping_get(ac, ale);

		/* get new vertical minimum extent of channel */
		ymin = ymax - ACHANNEL_STEP(ac);

		/* set horizontal range (if applicable) */
		if (ELEM(mode, ACTKEYS_BORDERSEL_FRAMERANGE, ACTKEYS_BORDERSEL_ALLKEYS)) {
			/* if channel is mapped in NLA, apply correction */
			if (adt) {
				ked.iterflags &= ~(KED_F1_NLA_UNMAP | KED_F2_NLA_UNMAP);
				ked.f1 = BKE_nla_tweakedit_remap(adt, rectf.xmin, NLATIME_CONVERT_UNMAP);
				ked.f2 = BKE_nla_tweakedit_remap(adt, rectf.xmax, NLATIME_CONVERT_UNMAP);
			}
			else {
				ked.iterflags |= (KED_F1_NLA_UNMAP | KED_F2_NLA_UNMAP); /* for summary tracks */
				ked.f1 = rectf.xmin;
				ked.f2 = rectf.xmax;
			}
		}

		/* perform vertical suitability check (if applicable) */
		if ((mode == ACTKEYS_BORDERSEL_FRAMERANGE) ||
		    !((ymax < rectf.ymin) || (ymin > rectf.ymax)))
		{
			/* loop over data selecting */
			switch (ale->type) {
#if 0 /* XXX: Keyframes are not currently shown here */
				case ANIMTYPE_GPDATABLOCK:
				{
					bGPdata *gpd = ale->data;
					bGPDlayer *gpl;
					for (gpl = gpd->layers.first; gpl; gpl = gpl->next) {
						ED_gplayer_frames_select_border(gpl, rectf.xmin, rectf.xmax, selectmode);
					}
					break;
				}
#endif
				case ANIMTYPE_GPLAYER:
					ED_gplayer_frames_select_border(ale->data, rectf.xmin, rectf.xmax, selectmode);
					break;
				case ANIMTYPE_MASKDATABLOCK:
				{
					Mask *mask = ale->data;
					MaskLayer *masklay;
					for (masklay = mask->masklayers.first; masklay; masklay = masklay->next) {
						ED_masklayer_frames_select_border(masklay, rectf.xmin, rectf.xmax, selectmode);
					}
					break;
				}
				case ANIMTYPE_MASKLAYER:
					ED_masklayer_frames_select_border(ale->data, rectf.xmin, rectf.xmax, selectmode);
					break;
				default:
					ANIM_animchannel_keyframes_loop(&ked, ac->ads, ale, ok_cb, select_cb, NULL);
					break;
			}
		}

		/* set minimum extent to be the maximum of the next channel */
		ymax = ymin;
	}

	/* cleanup */
	ANIM_animdata_freelist(&anim_data);
}
开发者ID:bdancer,项目名称:blender-for-vray,代码行数:98,代码来源:action_select.c


示例3: deselect_action_keys

/* Deselects keyframes in the action editor
 * - This is called by the deselect all operator, as well as other ones!
 *
 * - test: check if select or deselect all
 * - sel: how to select keyframes (SELECT_*)
 */
static void deselect_action_keys(bAnimContext *ac, short test, short sel)
{
	ListBase anim_data = {NULL, NULL};
	bAnimListElem *ale;
	int filter;

	KeyframeEditData ked = {{NULL}};
	KeyframeEditFunc test_cb, sel_cb;

	/* determine type-based settings */
	if (ELEM(ac->datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK))
		filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_NODUPLIS);
	else
		filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS);

	/* filter data */
	ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);

	/* init BezTriple looping data */
	test_cb = ANIM_editkeyframes_ok(BEZT_OK_SELECTED);

	/* See if we should be selecting or deselecting */
	if (test) {
		for (ale = anim_data.first; ale; ale = ale->next) {
			if (ale->type == ANIMTYPE_GPLAYER) {
				if (ED_gplayer_frame_select_check(ale->data)) {
					sel = SELECT_SUBTRACT;
					break;
				}
			}
			else if (ale->type == ANIMTYPE_MASKLAYER) {
				if (ED_masklayer_frame_select_check(ale->data)) {
					sel = SELECT_SUBTRACT;
					break;
				}
			}
			else {
				if (ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, test_cb, NULL)) {
					sel = SELECT_SUBTRACT;
					break;
				}
			}
		}
	}

	/* convert sel to selectmode, and use that to get editor */
	sel_cb = ANIM_editkeyframes_select(sel);

	/* Now set the flags */
	for (ale = anim_data.first; ale; ale = ale->next) {
		if (ale->type == ANIMTYPE_GPLAYER)
			ED_gplayer_frame_select_set(ale->data, sel);
		else if (ale->type == ANIMTYPE_MASKLAYER)
			ED_masklayer_frame_select_set(ale->data, sel);
		else
			ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, sel_cb, NULL);
	}

	/* Cleanup */
	ANIM_animdata_freelist(&anim_data);
}
开发者ID:bdancer,项目名称:blender-for-vray,代码行数:67,代码来源:action_select.c


示例4: smooth_fcurve

// TODO: introduce scaling factor for weighting falloff
void smooth_fcurve(FCurve *fcu)
{
	BezTriple *bezt;
	int i, x, totSel = 0;

	if (fcu->bezt == NULL) {
		return;
	}

	/* first loop through - count how many verts are selected */
	bezt = fcu->bezt;
	for (i = 0; i < fcu->totvert; i++, bezt++) {
		if (BEZT_ISSEL_ANY(bezt))
			totSel++;
	}
	
	/* if any points were selected, allocate tSmooth_Bezt points to work on */
	if (totSel >= 3) {
		tSmooth_Bezt *tarray, *tsb;
		
		/* allocate memory in one go */
		tsb = tarray = MEM_callocN(totSel * sizeof(tSmooth_Bezt), "tSmooth_Bezt Array");
		
		/* populate tarray with data of selected points */
		bezt = fcu->bezt;
		for (i = 0, x = 0; (i < fcu->totvert) && (x < totSel); i++, bezt++) {
			if (BEZT_ISSEL_ANY(bezt)) {
				/* tsb simply needs pointer to vec, and index */
				tsb->h1 = &bezt->vec[0][1];
				tsb->h2 = &bezt->vec[1][1];
				tsb->h3 = &bezt->vec[2][1];
				
				/* advance to the next tsb to populate */
				if (x < totSel - 1)
					tsb++;
				else
					break;
			}
		}
			
		/* calculate the new smoothed F-Curve's with weighted averages:
		 *	- this is done with two passes to avoid progressive corruption errors
		 *	- uses 5 points for each operation (which stores in the relevant handles)
		 *	-   previous: w/a ratio = 3:5:2:1:1
		 *	-   next: w/a ratio = 1:1:2:5:3
		 */
		
		/* round 1: calculate smoothing deltas and new values */ 
		tsb = tarray;
		for (i = 0; i < totSel; i++, tsb++) {
			/* don't touch end points (otherwise, curves slowly explode, as we don't have enough data there) */
			if (ELEM(i, 0, (totSel - 1)) == 0) {
				const tSmooth_Bezt *tP1 = tsb - 1;
				const tSmooth_Bezt *tP2 = (i - 2 > 0) ? (tsb - 2) : (NULL);
				const tSmooth_Bezt *tN1 = tsb + 1;
				const tSmooth_Bezt *tN2 = (i + 2 < totSel) ? (tsb + 2) : (NULL);
				
				const float p1 = *tP1->h2;
				const float p2 = (tP2) ? (*tP2->h2) : (*tP1->h2);
				const float c1 = *tsb->h2;
				const float n1 = *tN1->h2;
				const float n2 = (tN2) ? (*tN2->h2) : (*tN1->h2);
				
				/* calculate previous and next, then new position by averaging these */
				tsb->y1 = (3 * p2 + 5 * p1 + 2 * c1 + n1 + n2) / 12;
				tsb->y3 = (p2 + p1 + 2 * c1 + 5 * n1 + 3 * n2) / 12;
				
				tsb->y2 = (tsb->y1 + tsb->y3) / 2;
			}
		}
		
		/* round 2: apply new values */
		tsb = tarray;
		for (i = 0; i < totSel; i++, tsb++) {
			/* don't touch end points, as their values weren't touched above */
			if (ELEM(i, 0, (totSel - 1)) == 0) {
				/* y2 takes the average of the 2 points */
				*tsb->h2 = tsb->y2;
				
				/* handles are weighted between their original values and the averaged values */
				*tsb->h1 = ((*tsb->h1) * 0.7f) + (tsb->y1 * 0.3f); 
				*tsb->h3 = ((*tsb->h3) * 0.7f) + (tsb->y3 * 0.3f);
			}
		}
		
		/* free memory required for tarray */
		MEM_freeN(tarray);
	}
	
	/* recalculate handles */
	calchandles_fcurve(fcu);
}
开发者ID:Moguri,项目名称:blender,代码行数:93,代码来源:keyframes_general.c


示例5: actkeys_select_leftright

static void actkeys_select_leftright(bAnimContext *ac, short leftright, short select_mode)
{
	ListBase anim_data = {NULL, NULL};
	bAnimListElem *ale;
	int filter;

	KeyframeEditFunc ok_cb, select_cb;
	KeyframeEditData ked = {{NULL}};
	Scene *scene = ac->scene;

	/* if select mode is replace, deselect all keyframes (and channels) first */
	if (select_mode == SELECT_REPLACE) {
		select_mode = SELECT_ADD;

		/* - deselect all other keyframes, so that just the newly selected remain
		 * - channels aren't deselected, since we don't re-select any as a consequence
		 */
		deselect_action_keys(ac, 0, SELECT_SUBTRACT);
	}

	/* set callbacks and editing data */
	ok_cb = ANIM_editkeyframes_ok(BEZT_OK_FRAMERANGE);
	select_cb = ANIM_editkeyframes_select(select_mode);

	if (leftright == ACTKEYS_LRSEL_LEFT) {
		ked.f1 = MINAFRAMEF;
		ked.f2 = (float)(CFRA + 0.1f);
	}
	else {
		ked.f1 = (float)(CFRA - 0.1f);
		ked.f2 = MAXFRAMEF;
	}

	/* filter data */
	if (ELEM(ac->datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK))
		filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_NODUPLIS);
	else
		filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS);
	ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);

	/* select keys */
	for (ale = anim_data.first; ale; ale = ale->next) {
		AnimData *adt = ANIM_nla_mapping_get(ac, ale);

		if (adt) {
			ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1);
			ANIM_fcurve_keyframes_loop(&ked, ale->key_data, ok_cb, select_cb, NULL);
			ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1);
		}
		else if (ale->type == ANIMTYPE_GPLAYER)
			ED_gplayer_frames_select_border(ale->data, ked.f1, ked.f2, select_mode);
		else if (ale->type == ANIMTYPE_MASKLAYER)
			ED_masklayer_frames_select_border(ale->data, ked.f1, ked.f2, select_mode);
		else
			ANIM_fcurve_keyframes_loop(&ked, ale->key_data, ok_cb, select_cb, NULL);
	}

	/* Sync marker support */
	if (select_mode == SELECT_ADD) {
		SpaceAction *saction = (SpaceAction *)ac->sl;

		if ((saction) && (saction->flag & SACTION_MARKERS_MOVE)) {
			ListBase *markers = ED_animcontext_get_markers(ac);
			TimeMarker *marker;

			for (marker = markers->first; marker; marker = marker->next) {
				if (((leftright == ACTKEYS_LRSEL_LEFT)  && (marker->frame <  CFRA)) ||
				    ((leftright == ACTKEYS_LRSEL_RIGHT) && (marker->frame >= CFRA)))
				{
					marker->flag |= SELECT;
				}
				else {
					marker->flag &= ~SELECT;
				}
			}
		}
	}

	/* Cleanup */
	ANIM_animdata_freelist(&anim_data);
}
开发者ID:bdancer,项目名称:blender-for-vray,代码行数:81,代码来源:action_select.c


示例6: RNA_struct_find_property

static char *rna_ColorRampElement_path(PointerRNA *ptr)
{
	PointerRNA ramp_ptr;
	PropertyRNA *prop;
	char *path = NULL;
	int index;
	
	/* helper macro for use here to try and get the path
	 *	- this calls the standard code for getting a path to a texture...
	 */

#define COLRAMP_GETPATH                                                       \
{                                                                             \
	prop = RNA_struct_find_property(&ramp_ptr, "elements");                   \
	if (prop) {                                                               \
		index = RNA_property_collection_lookup_index(&ramp_ptr, prop, ptr);   \
		if (index != -1) {                                                    \
			char *texture_path = rna_ColorRamp_path(&ramp_ptr);               \
			path = BLI_sprintfN("%s.elements[%d]", texture_path, index);      \
			MEM_freeN(texture_path);                                          \
		}                                                                     \
	}                                                                         \
} (void)0

	/* determine the path from the ID-block to the ramp */
	/* FIXME: this is a very slow way to do it, but it will have to suffice... */
	if (ptr->id.data) {
		ID *id = ptr->id.data;
		
		switch (GS(id->name)) {
			case ID_MA: /* 2 cases for material - diffuse and spec */
			{
				Material *ma = (Material *)id;
				
				/* try diffuse first */
				if (ma->ramp_col) {
					RNA_pointer_create(id, &RNA_ColorRamp, ma->ramp_col, &ramp_ptr);
					COLRAMP_GETPATH;
				}
				/* try specular if not diffuse */
				if (!path && ma->ramp_spec) {
					RNA_pointer_create(id, &RNA_ColorRamp, ma->ramp_spec, &ramp_ptr);
					COLRAMP_GETPATH;
				}
				break;
			}
			case ID_NT:
			{
				bNodeTree *ntree = (bNodeTree *)id;
				bNode *node;
				
				for (node = ntree->nodes.first; node; node = node->next) {
					if (ELEM(node->type, SH_NODE_VALTORGB, CMP_NODE_VALTORGB, TEX_NODE_VALTORGB)) {
						RNA_pointer_create(id, &RNA_ColorRamp, node->storage, &ramp_ptr);
						COLRAMP_GETPATH;
					}
				}
				break;
			}
			case ID_LS:
			{
				ListBase listbase;
				LinkData *link;

				BKE_linestyle_modifier_list_color_ramps((FreestyleLineStyle *)id, &listbase);
				for (link = (LinkData *)listbase.first; link; link = link->next) {
					RNA_pointer_create(id, &RNA_ColorRamp, link->data, &ramp_ptr);
					COLRAMP_GETPATH;
				}
				BLI_freelistN(&listbase);
				break;
			}

			default: /* everything else should have a "color_ramp" property */
			{
				/* create pointer to the ID block, and try to resolve "color_ramp" pointer */
				RNA_id_pointer_create(id, &ramp_ptr);
				if (RNA_path_resolve(&ramp_ptr, "color_ramp", &ramp_ptr, &prop)) {
					COLRAMP_GETPATH;
				}
				break;
			}
		}
	}
	
	/* cleanup the macro we defined */
#undef COLRAMP_GETPATH
	
	return path;
}
开发者ID:flair2005,项目名称:mechanical-blender,代码行数:90,代码来源:rna_color.c


示例7: bp_parseBook

bp_Book * bp_parseBook(bp_Context * context, xmlNodePtr node) {
	bp_Book * result = malloc(sizeof(bp_Book));
	bp_Node * const parent = &result->node;
	bp_Node * page;
	xmlAttrPtr attr;
	xmlNodePtr child;
	bp_Page ** pages;
	st_data * fontSym;

	context->blockOutside = (void *) &bp_defaultBlockOutsideAttributes;
	context->blockBorder  = (void *) &bp_defaultBlockBorderAttributes;
	context->blockInside  = (void *) &bp_defaultBlockInsideAttributes;
	context->inlineAttr      = (void *) &bp_defaultInlineAttributes;

	bp_pushBlockOutside(context);
	bp_pushBlockBorder(context);
	bp_pushBlockInside(context);
	bp_pushInline(context);

	bp_initNode(&result->node, BPE_BOOK);
	result->width = 528;
	result->height = 320;
	result->background = load_texture_cache_deferred("textures/book1.bmp",0);
	fontSym = st_lookup (bp_fonts, "default");
	if (fontSym != NULL) {
		result->fontFace = fontSym->num;
	} else {
		LOG_ERROR("FATAL: default font missing in font symbol table\n");
		exit(1);
	}
	result->layout = BPL_BOOK;
	result->blockProgression = BPD_DOWN;
	result->inlineProgression = BPD_RIGHT;
	result->pages = NULL;
	result->nPages = 0;

	for (attr = node->properties; attr; attr = attr->next) {
		bp_parseBlockOutsideAttribute(context, context->blockOutside, attr);
		bp_parseBlockBorderAttribute(context, context->blockBorder, attr);
		bp_parseBlockInsideAttribute(context, context->blockInside, attr);
		bp_parseInlineAttribute(context, context->inlineAttr, attr);
	}

	for (child = node->children; child; child = child->next) {
		switch(ELEM(child)) {
			case BPE_PAGE:
				result->nPages++;
				ADD(bp_parsePage(context, child));
				break;
			default:
				DISCARD(child);
		}
	}

	bp_popBlockOutside(context);
	bp_popBlockBorder(context);
	bp_popBlockInside(context);
	bp_popInline(context);

	/* create page index */
	pages = calloc(result->nPages, sizeof(bp_Page *));
	result->pages = pages;
	for (page = parent->children; page; page = page->next) {
		*pages++ = (bp_Page *) page;
	}
	
	return result;
}
开发者ID:Adamantinus,项目名称:Eternal-Lands,代码行数:68,代码来源:parser.c


示例8: bp_parsePage

bp_Page * bp_parsePage(bp_Context * context, xmlNodePtr node) {
	bp_Page * result = malloc(sizeof(bp_Page));
	bp_Node * const parent = &result->node;
	xmlAttrPtr attr;
	xmlNodePtr child;

	bp_pushBlockOutside(context);
	bp_pushBlockBorder(context);
	bp_pushBlockInside(context);
	bp_pushInline(context);

	bp_initNode(&result->node, BPE_PAGE);
	result->title = NULL;

	for (attr = node->properties; attr; attr = attr->next) {
		bp_parseBlockOutsideAttribute(context, context->blockOutside, attr);
		bp_parseBlockBorderAttribute(context, context->blockBorder, attr);
		bp_parseBlockInsideAttribute(context, context->blockInside, attr);
		bp_parseInlineAttribute(context, context->inlineAttr, attr);
	}

	for (child = node->children; child; child = child->next) {
		switch(ELEM(child)) {
			case BPE_TITLE:
				if (!result->title) {
					xmlNodePtr grandchild = child->children;
					if (ELEM(grandchild) == BPE_TEXT) {
						int len = strlen(grandchild->content);
						char * title_string = malloc(++len);
						memcpy(title_string, grandchild->content, len);
						result->title = title_string;
					} else {
						DISCARD(grandchild);
					}
				} else {
					DISCARD(child);
				}
				break;
			case BPE_REF:
				bp_parseNavRef(context, child, result);
				break;
			case BPE_BLOCK:
				ADD(bp_parseBlock(context, child));
				break;
			case BPE_IMAGE:
				ADD(bp_parseImage(context, child));
				break;
			case BPE_TABLE:
				ADD(bp_parseTable(context, child));
				break;
			case BPE_LABEL:
				ADD(bp_parseLabel(context, child));
				break;
			default:
				DISCARD(child);
		}
	}

	bp_popBlockOutside(context);
	bp_popBlockBorder(context);
	bp_popBlockInside(context);
	bp_popInline(context);

	return result;
}
开发者ID:Adamantinus,项目名称:Eternal-Lands,代码行数:65,代码来源:parser.c


示例9: armature_fill_bones_exec

/* bone adding between selected joints */
static int armature_fill_bones_exec(bContext *C, wmOperator *op)
{
	Object *obedit = CTX_data_edit_object(C);
	bArmature *arm = (obedit) ? obedit->data : NULL;
	Scene *scene = CTX_data_scene(C);
	View3D *v3d = CTX_wm_view3d(C);
	ListBase points = {NULL, NULL};
	EditBone *newbone = NULL;
	int count;

	/* sanity checks */
	if (ELEM(NULL, obedit, arm))
		return OPERATOR_CANCELLED;

	/* loop over all bones, and only consider if visible */
	CTX_DATA_BEGIN(C, EditBone *, ebone, visible_bones)
	{
		if (!(ebone->flag & BONE_CONNECTED) && (ebone->flag & BONE_ROOTSEL))
			fill_add_joint(ebone, 0, &points);
		if (ebone->flag & BONE_TIPSEL)
			fill_add_joint(ebone, 1, &points);
	}
	CTX_DATA_END;

	/* the number of joints determines how we fill:
	 *  1) between joint and cursor (joint=head, cursor=tail)
	 *  2) between the two joints (order is dependent on active-bone/hierarchy)
	 *  3+) error (a smarter method involving finding chains needs to be worked out
	 */
	count = BLI_listbase_count(&points);

	if (count == 0) {
		BKE_report(op->reports, RPT_ERROR, "No joints selected");
		return OPERATOR_CANCELLED;
	}
	else if (count == 1) {
		EditBonePoint *ebp;
		float curs[3];

		/* Get Points - selected joint */
		ebp = points.first;

		/* Get points - cursor (tail) */
		invert_m4_m4(obedit->imat, obedit->obmat);
		mul_v3_m4v3(curs, obedit->imat, ED_view3d_cursor3d_get(scene, v3d));

		/* Create a bone */
		newbone = add_points_bone(obedit, ebp->vec, curs);
	}
	else if (count == 2) {
		EditBonePoint *ebp_a, *ebp_b;
		float head[3], tail[3];
		short headtail = 0;

		/* check that the points don't belong to the same bone */
		ebp_a = (EditBonePoint *)points.first;
		ebp_b = ebp_a->next;

		if (((ebp_a->head_owner == ebp_b->tail_owner) && (ebp_a->head_owner != NULL)) ||
		    ((ebp_a->tail_owner == ebp_b->head_owner) && (ebp_a->tail_owner != NULL)))
		{
			BKE_report(op->reports, RPT_ERROR, "Same bone selected...");
			BLI_freelistN(&points);
			return OPERATOR_CANCELLED;
		}

		/* find which one should be the 'head' */
		if ((ebp_a->head_owner && ebp_b->head_owner) || (ebp_a->tail_owner && ebp_b->tail_owner)) {
			/* use active, nice predictable */
			if (arm->act_edbone && ELEM(arm->act_edbone, ebp_a->head_owner, ebp_a->tail_owner)) {
				headtail = 1;
			}
			else if (arm->act_edbone && ELEM(arm->act_edbone, ebp_b->head_owner, ebp_b->tail_owner)) {
				headtail = 2;
			}
			else {
				/* rule: whichever one is closer to 3d-cursor */
				float curs[3];
				float dist_sq_a, dist_sq_b;

				/* get cursor location */
				invert_m4_m4(obedit->imat, obedit->obmat);
				mul_v3_m4v3(curs, obedit->imat, ED_view3d_cursor3d_get(scene, v3d));

				/* get distances */
				dist_sq_a = len_squared_v3v3(ebp_a->vec, curs);
				dist_sq_b = len_squared_v3v3(ebp_b->vec, curs);

				/* compare distances - closer one therefore acts as direction for bone to go */
				headtail = (dist_sq_a < dist_sq_b) ? 2 : 1;
			}
		}
		else if (ebp_a->head_owner) {
			headtail = 1;
		}
		else if (ebp_b->head_owner) {
			headtail = 2;
		}

//.........这里部分代码省略.........
开发者ID:Ichthyostega,项目名称:blender,代码行数:101,代码来源:armature_edit.c


示例10: armature_merge_exec

static int armature_merge_exec(bContext *C, wmOperator *op)
{
	Object *obedit = CTX_data_edit_object(C);
	bArmature *arm = (obedit) ? obedit->data : NULL;
	short type = RNA_enum_get(op->ptr, "type");

	/* sanity checks */
	if (ELEM(NULL, obedit, arm))
		return OPERATOR_CANCELLED;

	/* for now, there's only really one type of merging that's performed... */
	if (type == 1) {
		/* go down chains, merging bones */
		ListBase chains = {NULL, NULL};
		LinkData *chain, *nchain;
		EditBone *ebo;

		armature_tag_select_mirrored(arm);

		/* get chains (ends on chains) */
		chains_find_tips(arm->edbo, &chains);
		if (BLI_listbase_is_empty(&chains)) return OPERATOR_CANCELLED;

		/* each 'chain' is the last bone in the chain (with no children) */
		for (chain = chains.first; chain; chain = nchain) {
			EditBone *bstart = NULL, *bend = NULL;
			EditBone *bchild = NULL, *child = NULL;

			/* temporarily remove chain from list of chains */
			nchain = chain->next;
			BLI_remlink(&chains, chain);

			/* only consider bones that are visible and selected */
			for (ebo = chain->data; ebo; child = ebo, ebo = ebo->parent) {
				/* check if visible + selected */
				if (EBONE_VISIBLE(arm, ebo) &&
				    ((ebo->flag & BONE_CONNECTED) || (ebo->parent == NULL)) &&
				    (ebo->flag & BONE_SELECTED) )
				{
					/* set either end or start (end gets priority, unless it is already set) */
					if (bend == NULL) {
						bend = ebo;
						bchild = child;
					}
					else
						bstart = ebo;
				}
				else {
					/* chain is broken... merge any continuous segments then clear */
					if (bstart && bend)
						bones_merge(obedit, bstart, bend, bchild, &chains);

					bstart = NULL;
					bend = NULL;
					bchild = NULL;
				}
			}

			/* merge from bstart to bend if something not merged */
			if (bstart && bend)
				bones_merge(obedit, bstart, bend, bchild, &chains);

			/* put back link */
			BLI_insertlinkbefore(&chains, nchain, chain);
		}

		armature_tag_unselect(arm);

		BLI_freelistN(&chains);
	}

	/* updates */
	ED_armature_edit_sync_selection(arm->edbo);
	WM_event_add_notifier(C, NC_OBJECT | ND_POSE, obedit);

	return OPERATOR_FINISHED;
}
开发者ID:Ichthyostega,项目名称:blender,代码行数:77,代码来源:armature_edit.c


示例11: armature_calc_roll_exec

static int armature_calc_roll_exec(bContext *C, wmOperator *op)
{
	Object *ob = CTX_data_edit_object(C);
	eCalcRollTypes type = RNA_enum_get(op->ptr, "type");
	const bool axis_only = RNA_boolean_get(op->ptr, "axis_only");
	/* axis_flip when matching the active bone never makes sense */
	bool axis_flip = ((type >= CALC_ROLL_ACTIVE) ? RNA_boolean_get(op->ptr, "axis_flip") :
	                  (type >= CALC_ROLL_TAN_NEG_X) ? true : false);

	float imat[3][3];

	bArmature *arm = ob->data;
	EditBone *ebone;

	if ((type >= CALC_ROLL_NEG_X) && (type <= CALC_ROLL_TAN_NEG_Z)) {
		type -= (CALC_ROLL_ACTIVE - CALC_ROLL_NEG_X);
		axis_flip = true;
	}

	copy_m3_m4(imat, ob->obmat);
	invert_m3(imat);

	if (type == CALC_ROLL_CURSOR) { /* Cursor */
		Scene *scene = CTX_data_scene(C);
		View3D *v3d = CTX_wm_view3d(C); /* can be NULL */
		float cursor_local[3];
		const float   *cursor = ED_view3d_cursor3d_get(scene, v3d);

		invert_m4_m4(ob->imat, ob->obmat);
		copy_v3_v3(cursor_local, cursor);
		mul_m4_v3(ob->imat, cursor_local);


		/* cursor */
		for (ebone = arm->edbo->first; ebone; ebone = ebone->next) {
			if (EBONE_VISIBLE(arm, ebone) && EBONE_EDITABLE(ebone)) {
				float cursor_rel[3];
				sub_v3_v3v3(cursor_rel, cursor_local, ebone->head);
				if (axis_flip) negate_v3(cursor_rel);
				if (normalize_v3(cursor_rel) != 0.0f) {
					ebone->roll = ED_armature_ebone_roll_to_vector(ebone, cursor_rel, axis_only);
				}
			}
		}
	}
	else if (ELEM(type, CALC_ROLL_TAN_POS_X, CALC_ROLL_TAN_POS_Z)) {
		for (ebone = arm->edbo->first; ebone; ebone = ebone->next) {
			if (ebone->parent) {
				bool is_edit        = (EBONE_VISIBLE(arm, ebone)         && EBONE_EDITABLE(ebone));
				bool is_edit_parent = (EBONE_VISIBLE(arm, ebone->parent) && EBONE_EDITABLE(ebone->parent));

				if (is_edit || is_edit_parent) {
					EditBone *ebone_other = ebone->parent;
					float dir_a[3];
					float dir_b[3];
					float vec[3];
					bool is_vec_zero;

					sub_v3_v3v3(dir_a, ebone->tail, ebone->head);
					normalize_v3(dir_a);

					/* find the first bone in the chane with a different direction */
					do {
						sub_v3_v3v3(dir_b, ebone_other->head, ebone_other->tail);
						normalize_v3(dir_b);

						if (type == CALC_ROLL_TAN_POS_Z) {
							cross_v3_v3v3(vec, dir_a, dir_b);
						}
						else {
							add_v3_v3v3(vec, dir_a, dir_b);
						}
					} while ((is_vec_zero = (normalize_v3(vec) < 0.00001f)) &&
					         (ebone_other = ebone_other->parent));

					if (!is_vec_zero) {
						if (axis_flip) negate_v3(vec);

						if (is_edit) {
							ebone->roll = ED_armature_ebone_roll_to_vector(ebone, vec, axis_only);
						}

						/* parentless bones use cross product with child */
						if (is_edit_parent) {
							if (ebone->parent->parent == NULL) {
								ebone->parent->roll = ED_armature_ebone_roll_to_vector(ebone->parent, vec, axis_only);
							}
						}
					}
				}
			}
		}
	}
	else {
		float vec[3] = {0.0f, 0.0f, 0.0f};
		if (type == CALC_ROLL_VIEW) { /* View */
			RegionView3D *rv3d = CTX_wm_region_view3d(C);
			if (rv3d == NULL) {
				BKE_report(op->reports, RPT_ERROR, "No region view3d available");
				return OPERATOR_CANCELLED;
//.........这里部分代码省略.........
开发者ID:Ichthyostega,项目名称:blender,代码行数:101,代码来源:armature_edit.c


示例12: armature_align_bones_exec

static int armature_align_bones_exec(bContext *C, wmOperator *op)
{
	Object *ob = CTX_data_edit_object(C);
	bArmature *arm = (bArmature *)ob->data;
	EditBone *actbone = CTX_data_active_bone(C);
	EditBone *actmirb = NULL;
	int num_selected_bones;

	/* there must be an active bone */
	if (actbone == NULL) {
		BKE_report(op->reports, RPT_ERROR, "Operation requires an active bone");
		return OPERATOR_CANCELLED;
	}
	else if (arm->flag & ARM_MIRROR_EDIT) {
		/* For X-Axis Mirror Editing option, we may need a mirror copy of actbone
		 * - if there's a mirrored copy of selbone, try to find a mirrored copy of actbone
		 *   (i.e.  selbone="child.L" and actbone="parent.L", find "child.R" and "parent.R").
		 *   This is useful for arm-chains, for example parenting lower arm to upper arm
		 * - if there's no mirrored copy of actbone (i.e. actbone = "parent.C" or "parent")
		 *   then just use actbone. Useful when doing upper arm to spine.
		 */
		actmirb = ED_armature_ebone_get_mirrored(arm->edbo, actbone);
		if (actmirb == NULL)
			actmirb = actbone;
	}

	/* if there is only 1 selected bone, we assume that that is the active bone,
	 * since a user will need to have clicked on a bone (thus selecting it) to make it active
	 */
	num_selected_bones = CTX_DATA_COUNT(C, selected_editable_bones);
	if (num_selected_bones <= 1) {
		/* When only the active bone is selected, and it has a parent,
		 * align it to the parent, as that is the only possible outcome.
		 */
		if (actbone->parent) {
			bone_align_to_bone(arm->edbo, actbone, actbone->parent);

			if ((arm->flag & ARM_MIRROR_EDIT) && (actmirb->parent))
				bone_align_to_bone(arm->edbo, actmirb, actmirb->parent);

			BKE_reportf(op->reports, RPT_INFO, "Aligned bone '%s' to parent", actbone->name);
		}
	}
	else {
		/* Align 'selected' bones to the active one
		 * - the context iterator contains both selected bones and their mirrored copies,
		 *   so we assume that unselected bones are mirrored copies of some selected bone
		 * - since the active one (and/or its mirror) will also be selected, we also need
		 *   to check that we are not trying to operate on them, since such an operation
		 *   would cause errors
		 */

		/* align selected bones to the active one */
		CTX_DATA_BEGIN(C, EditBone *, ebone, selected_editable_bones)
		{
			if (ELEM(ebone, actbone, actmirb) == 0) {
				if (ebone->flag & BONE_SELECTED)
					bone_align_to_bone(arm->edbo, ebone, actbone);
				else
					bone_align_to_bone(arm->edbo, ebone, actmirb);
			}
		}
		CTX_DATA_END;

		BKE_reportf(op->reports, RPT_INFO, "%d bones aligned to bone '%s'", num_selected_bones, actbone->name);
	}

	/* note, notifier might evolve */
	WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob);

	return OPERATOR_FINISHED;
}
开发者ID:Ichthyostega,项目名称:blender,代码行数:72,代码来源:armature_edit.c


示例13: bwlabel

int bwlabel(IplImage* img, int n, int* labels)
{
	if(n != 4 && n != 8)
		n = 4;
	int nr = img->height;
	int nc = img->width;
	int total = nr * nc;
	// results
	memset(labels, 0, total * sizeof(int));
	int nobj = 0;                               // number of objects found in image
	// other variables                             
	int* lset = new int[total];   // label table
	memset(lset, 0, total * sizeof(int));
	int ntable = 0;
	for( int r = 0; r < nr; r++ ) 
	{
		for( int c = 0; c < nc; c++ ) 
		{            
			if ( ELEM(img, r, c) )   // if A is an object
			{               
				// get the neighboring pixels B, C, D, and E
				int B, C, D, E;
				if ( c == 0 ) 
					B = 0; 
				else 
					B = find( lset, ONETWO(labels, r, c - 1, nc) );
				if ( r == 0 ) 
					C = 0; 
				else 
					C = find( lset, ONETWO(labels, r - 1, c, nc) );
				if ( r == 0 || c == 0 ) 
					D = 0; 
				else 
					D = find( lset, ONETWO(labels, r - 1, c - 1, nc) );
				if ( r == 0 || c == nc - 1 ) 
					E = 0;
				else 
					E = find( lset, ONETWO(labels, r - 1, c + 1, nc) );
				if ( n == 4 ) 
				{
					// apply 4 connectedness
					if ( B && C ) 
					{        // B and C are labeled
						if ( B == C )
							ONETWO(labels, r, c, nc) = B;
						else {
							lset[C] = B;
							ONETWO(labels, r, c, nc) = B;
						}
					} 
					else if ( B )             // B is object but C is not
						ONETWO(labels, r, c, nc) = B;
					else if ( C )               // C is object but B is not
						ONETWO(labels, r, c, nc) = C;
					else 
					{                      // B, C, D not object - new object
						//   label and put into table
						ntable++;
						ONETWO(labels, r, c, nc) = lset[ ntable ] = ntable;
					}
				} 
				else if ( n == 6 ) 
				{
					// apply 6 connected ness
					if ( D )                    // D object, copy label and move on
						ONETWO(labels, r, c, nc) = D;
					else if ( B && C ) 
					{        // B and C are labeled
						if ( B == C )
							ONETWO(labels, r, c, nc) = B;
						else 
						{
							int tlabel = MIN(B,C);
							lset[B] = tlabel;
							lset[C] = tlabel;
							ONETWO(labels, r, c, nc) = tlabel;
						}
					} 
					else if ( B )             // B is object but C is not
						ONETWO(labels, r, c, nc) = B;
					else if ( C )               // C is object but B is not
						ONETWO(labels, r, c, nc) = C;
					else 
					{                      // B, C, D not object - new object
						//   label and put into table
						ntable++;
						ONETWO(labels, r, c, nc) = lset[ ntable ] = ntable;
					}
				}
				else if ( n == 8 ) 
				{
					// apply 8 connectedness
					if ( B || C || D || E ) 
					{
						int tlabel = B;
						if ( B ) 
							tlabel = B;
						else if ( C ) 
							tlabel = C;
						else if ( D ) 
//.........这里部分代码省略.........
开发者ID:LinaW,项目名称:sentence-training,代码行数:101,代码来源:bwlabel.cpp


示例14: switch

uiBut *uiDefAutoButR(uiBlock *block, PointerRNA *ptr, PropertyRNA *prop, int index, const char *name, int icon, int x1, int y1, int x2, int y2)
{
	uiBut *but = NULL;

	switch (RNA_property_type(prop)) {
		case PROP_BOOLEAN:
		{
			int arraylen = RNA_property_array_length(ptr, prop);

			if (arraylen && index == -1)
				return NULL;
			
			if (icon && name && name[0] == '\0')
				but = uiDefIconButR_prop(block, UI_BTYPE_ICON_TOGGLE, 0, icon, x1, y1, x2, y2, ptr, prop, index, 0, 0, -1, -1, NULL);
			else if (icon)
				but = uiDefIconTextButR_prop(block, UI_BTYPE_ICON_TOGGLE, 0, icon, name, x1, y1, x2, y2, ptr, prop, index, 0, 0, -1, -1, NULL);
			else
				but = uiDefButR_prop(block, UI_BTYPE_CHECKBOX, 0, name, x1, y1, x2, y2, ptr, prop, index, 0, 0, -1, -1, NULL);
			break;
		}
		case PROP_INT:
		case PROP_FLOAT:
		{
			int arraylen = RNA_property_array_length(ptr, prop);

			if (arraylen && index == -1) {
				if (ELEM(RNA_property_subtype(prop), PROP_COLOR, PROP_COLOR_GAMMA)) {
					but = uiDefButR_prop(block, UI_BTYPE_COLOR, 0, name, x1, y1, x2, y2, ptr, prop, -1, 0, 0, -1, -1, NULL);
				}
				else {
					return NULL;
				}
			}
			else if (RNA_property_subtype(prop) == PROP_PERCENTAGE || RNA_property_subtype(prop) == PROP_FACTOR)
				but = uiDefButR_prop(block, UI_BTYPE_NUM_SLIDER, 0, name, x1, y1, x2, y2, ptr, prop, index, 0, 0, -1, -1, NULL);
			else
				but = uiDefButR_prop(block, UI_BTYPE_NUM, 0, name, x1, y1, x2, y2, ptr, prop, index, 0, 0, -1, -1, NULL);

			if (RNA_property_flag(prop) & PROP_TEXTEDIT_UPDATE) {
				UI_but_flag_enable(but, UI_BUT_TEXTEDIT_UPDATE);
			}
			break;
		}
		case PROP_ENUM:
			if (icon && name && name[0] == '\0')
				but = uiDefIconButR_prop(block, UI_BTYPE_MENU, 0, icon, x1, y1, x2, y2, ptr, prop, index, 0, 0, -1, -1, NULL);
			else if (icon)
				but = uiDefIconTextButR_prop(block, UI_BTYPE_MENU, 0, icon, NULL, x1, y1, x2, y2, ptr, prop, index, 0, 0, -1, -1, NULL);
			else
				but = uiDefButR_prop(block, UI_BTYPE_MENU, 0, name, x1, y1, x2, y2, ptr, prop, index, 0, 0, -1, -1, NULL);
			break;
		case PROP_STRING:
			if (icon && name && name[0] == '\0')
				but = uiDefIconButR_prop(block, UI_BTYPE_TEXT, 0, icon, x1, y1, x2, y2, ptr, prop, index, 0, 0, -1, -1, NULL);
			else if (icon)
				but = uiDefIconTextButR_prop(block, UI_BTYPE_TEXT, 0, icon, name, x1, y1, x2, y2, ptr, prop, index, 0, 0, -1, -1, NULL);
			else
				but = uiDefButR_prop(block, UI_BTYPE_TEXT, 0, name, x1, y1, x2, y2, ptr, prop, index, 0, 0, -1, -1, NULL);

			PropertySubType subtype = RNA_property_subtype(prop);
			if (!(ELEM(subtype, PROP_FILEPATH, PROP_DIRPATH, PROP_FILENAME) || (block->flag & UI_BLOCK_LIST_ITEM))) {
				UI_but_flag_enable(but, UI_BUT_VALUE_CLEAR);
			}
			if (RNA_property_flag(prop) & PROP_TEXTEDIT_UPDATE) {
				UI_but_flag_enable(but, UI_BUT_TEXTEDIT_UPDATE);
			}
			break;
		case PROP_POINTER:
		{
			PointerRNA pptr;

			pptr = RNA_property_pointer_get(ptr, prop);
			if (!pptr.type)
				pptr.type = RNA_property_pointer_type(ptr, prop);
			icon = RNA_struct_ui_icon(pptr.type);
			if (icon == ICON_DOT)
				icon = 0;

			but = uiDefIconTextButR_prop(block, UI_BTYPE_SEARCH_MENU, 0, icon, name, x1, y1, x2, y2, ptr, prop, index, 0, 0, -1, -1, NULL);
			break;
		}
		case PROP_COLLECTION:
		{
			char text[256];
			BLI_snprintf(text, sizeof(text), IFACE_("%d items"), RNA_property_collection_length(ptr, prop));
			but = uiDefBut(block, UI_BTYPE_LABEL, 0, text, x1, y1, x2, y2, NULL, 0, 0, 0, 0, NULL);
			UI_but_flag_enable(but, UI_BUT_DISABLED);
			break;
		}
		default:
			but = NULL;
			break;
	}

	return but;
}
开发者ID:UPBGE,项目名称:blender,代码行数:96,代码来源:interface_utils.c


示例15: bp_parseTable

bp_Table * bp_parseTable(bp_Context * context, xmlNodePtr node) {
	bp_Table * result = malloc(sizeof(bp_Table));
	bp_Node * const parent = &result->node;
	xmlAttrPtr attr;
	xmlNodePtr child, grand;

	bp_pushBlockBorder(context);
	bp_pushBlockInside(context);
	bp_pushInline(context);

	bp_initNode(&result->node, BPE_TABLE);
	result->_float = bp_defaultFloatAttributes;
	result->blockOutside = *(context->blockOutside);
	result->caption = NULL;
	result->nCols = 0;
	result->nRows = 0;
	
	for (attr = node->properties; attr; attr = attr->next) {
		bp_parseFloatAttribute(context, &result->_float, attr);
		bp_parseBlockOutsideAttribute(context, &result->blockOutside, attr);
		bp_parseBlockBorderAttribute(context, context->blockBorder, attr);
		bp_parseBlockInsideAttribute(context, context->blockInside, attr);
		bp_parseInlineAttribute(context, context->inlineAttr, attr);
	}

	result->blockBorder = *(context->blockBorder); // shared with children

	for (child = node->children; child; child = child->next) {
		switch(ELEM(child)) {
			case BPE_TR: result->nRows++; break;
			case BPE_TC: result->nCols++; break;
			case BPE_CAPTION:
				result->caption = bp_parseCaption(context, child);
			default: DISCARD(child);
		}
	}

	if (result->nRows) {
		int * colHeights = NULL; 
		int col, row = 0;
		result->nCols = 0;

		for (child = node->children; child; child = child->next) {
			if(ELEM(child) == BPE_TR) {
				bp_pushBlockBorder(context);
				bp_pushBlockInside(context);
				bp_pushInline(context);

				for (attr = child->properties; attr; attr = attr->next) {
					bp_parseBlockBorderAttribute(context, context->blockBorder, attr);
					bp_parseBlockInsideAttribute(context, context->blockInside, attr);
					bp_parseInlineAttribute(context, context->inlineAttr, attr);
				}
				
				col = 0;
				for (grand = child->children; grand; grand = grand->next) {
					while ((col < result->nCols) && (colHeights[col] >= row)) col++;
							
					if(ELEM(grand) == BPE_TD) {
						bp_Cell * cell = bp_parseCell(context, grand, row, col);

						ADD(cell);
						
						if (cell->endCol >= result->nCols) {
							result->nCols = cell->endCol + 1;
							colHeights = realloc(colHeights, result->nCols * sizeof(int));
						}
						
						for (col=cell->startCol; col <= cell->endCol; col++) {
							colHeights[col] = cell->endRow;
						}
					} else {
						DISCARD(grand);
					}
				}

				bp_popBlockBorder(context);
				bp_popBlockInside(context);
				bp_popInline(context);
				row++;
			}
		}

		if(colHeights) free(colHeights);
	} else if (result->nCols) {
		int * rowWidths = NULL; 
		int col = 0, row;
		result->nRows = 0;

		for (child = node->children; child; child = child->next) {
			if(ELEM(child) == BPE_TC) {
				bp_pushBlockBorder(context);
				bp_pushBlockInside(context);
				bp_pushInline(context);

				for (attr = child->properties; attr; attr = attr->next) {
					bp_parseBlockBorderAttribute(context, context->blockBorder, attr);
					bp_parseBlockInsideAttribute(context, co 

鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ ELEMENTS函数代码示例发布时间:2022-05-30
下一篇:
C++ EJSVAL_TO_OBJECT函数代码示例发布时间: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