예제 #1
0
void IconTask::run()
{
	assert(NULL != ctxp);
	IconTaskCtx ctx = *ctxp;
	assert(ctx.nlabels > 0);
	assert(ctx.nlabels == ctx.colors.size());
	assert(ctx.colors.size() == ctx.nlabels);
	assert(ctx.icons.size() == 0); // we do the allocation
	assert(IconSizeMin <= ctx.iconSize.width() &&
		   ctx.iconSize.width() <= IconSizeMax);
	assert(IconSizeMin <= ctx.iconSize.height() &&
		   ctx.iconSize.height() <= IconSizeMax);


	// init result vector
	ctx.icons = QVector<QImage>(ctx.nlabels);

	tbb::auto_partitioner partitioner;

	if (abortFlag) {
		return;
	}

	tbb::parallel_for(tbb::blocked_range<short>(0, ctx.nlabels),
					  ComputeIconMasks(ctx), partitioner, tbbTaskGroupContext);

	if (!abortFlag) {
		emit labelIconsComputed(ctx.icons);
	}
	//GGDBGM("return" << endl);
}
예제 #2
0
void LabelingModel::processLabelIconsComputed(const QVector<QImage> &icons)
{
	// The reference argument icons is valid, since the icon task will be
	// deleted only after this function leaves its scope.
	//GGDBGM("IconTask finished successfully" << endl);

	// store the result and emit
	this->icons = icons;
	emit labelIconsComputed(icons);
	discardIconTask();
}