示例#1
0
	cell type() const {
		cell tag = TAG(value_);
		if(tag == OBJECT_TYPE)
			return untagged()->h.hi_tag();
		else
			return tag;
	}
示例#2
0
void TagViewer::mousePressEvent(
    QMouseEvent* e
)
{
    if( e->button() != Qt::LeftButton ) {
        return;
    }

    if( tagging_ ) {
        tag_start_ = e->pos();
        enforce_boundary_conditions( tag_start_ );
        tag_end_ = tag_start_;

    } else if( untagging_ ) {
        // searches the closest rectangle to the picked point
        // removes it only if point is deemed close enough
        // there won't be tons of label per image, so a brute force search
        // is perfectly acceptable, no need to go into quad-tree
        float scale_f = scale_factor();
        QRect rect_found;
        QString label_found;
        int distance_min = 200. / scale_f;
        QPoint p = e->pos();
        enforce_boundary_conditions( p );
        p /= scale_f;

        for( QList<TagDisplayElement>::iterator tag_itr = elts_.begin(); tag_itr != elts_.end(); ++tag_itr ) {
            const TagDisplayElement& tag = *tag_itr;
            const QList<QRect>& bbox = tag._bbox;

            for( QList<QRect>::const_iterator bbox_itr = bbox.begin(); bbox_itr != bbox.end(); ++bbox_itr ) {
                int d = shortest_distance( p, *bbox_itr );
                if( d < distance_min ) {
                    distance_min = d;
                    label_found = tag._label;
                    rect_found = *bbox_itr;
                }
            }
        }
        if( !label_found.isEmpty() && rect_found.isValid() ) {
            emit( untagged( label_found, rect_found ) );
        }
    }
}
示例#3
0
	TYPE *operator->() const { return untagged(); }
示例#4
0
	TYPE *untag_check(factorvm *myvm) const {
		if(TYPE::type_number != TYPE_COUNT && !type_p(TYPE::type_number))
			myvm->type_error(TYPE::type_number,value_);
		return untagged();
	}
示例#5
0
	Type *untag_check(factor_vm *parent) const
	{
		if(!type_p())
			parent->type_error(Type::type_number,value_);
		return untagged();
	}