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


C++ ImageItem::setAlpha方法代码示例

本文整理汇总了C++中ImageItem::setAlpha方法的典型用法代码示例。如果您正苦于以下问题:C++ ImageItem::setAlpha方法的具体用法?C++ ImageItem::setAlpha怎么用?C++ ImageItem::setAlpha使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ImageItem的用法示例。


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

示例1: onOptimizeGeometryClicked

void StitcherWorkspace::onOptimizeGeometryClicked() {
    geometrically_constrained_system * gc = geometrically_constrained_system_alloc();

    /* create positioned images */
    QMap<ImageItem *, positioned_image *> pos_image_map;
    QList<QGraphicsItem *> graphicsItems = _stitcherView->items();
    for(int i = 0; i < graphicsItems.size(); i++) {
        if(ImageItem * item = qgraphicsitem_cast<ImageItem *>(graphicsItems[i])) {
            positioned_image * p = create_positioned_image(item->getImage());
            set_image_position(p,DeltaX,item->dx());
            if(!item->dxLocked()) {
                geometrically_constrained_system_add_variable(gc,create_geometry_variable(p,DeltaX));
            }
            set_image_position(p,DeltaY,item->dy());
            if(!item->dyLocked()) {
                geometrically_constrained_system_add_variable(gc,create_geometry_variable(p,DeltaY));
            }
            set_image_position(p,Zoom,1.0/item->dz());
            if(!item->dzLocked()) {
                geometrically_constrained_system_add_variable(gc,create_geometry_variable(p,Zoom));
            }

            set_image_position(p,Theta,item->theta());
            if(!item->thetaLocked()) {
                geometrically_constrained_system_add_variable(gc,create_geometry_variable(p,Theta));
            }
            set_image_position(p,Alpha,item->alpha());
            if(!item->alphaLocked()) {
                geometrically_constrained_system_add_variable(gc,create_geometry_variable(p,Alpha));
            }

            pos_image_map.insert(item,p);
        }
    }


    QStandardItemModel * model = qobject_cast<QStandardItemModel *>(constraintsTree->model());
    int total_points = 0;
    for(int i = 0; i<model->rowCount(); i++) {

        QStandardItem * it = model->item(i,0);
        geometric_constraint c =  geometric_constraint_init((GeometryConstraintType)it->data(Qt::UserRole + 3).toInt(),0);
        QList<QVariant> item_details = it->data(Qt::UserRole + 1).value<QList<QVariant> >();
        QList<QVariant> point_details = it->data(Qt::UserRole + 2).value<QList<QVariant> >();
        total_points += item_details.size();
        for(int i = 0; i<item_details.size(); i++) {
            ImageItem * item = item_details[i].value<ImageItem *>();
            QPointF pos = point_details[i].value<QPointF>();
            positioned_image * a = pos_image_map.value(item);
            control_point cp = create_control_point(a,pos.x(),pos.y());
            geometric_constraint_add_point(&c,cp);
        }
        geometrically_constrained_system_add_constraint(gc,c);
    }
    if(total_points < gc->n_variables+gc->n_constraints) {
        QMessageBox::warning(this,"Geometry Optimization","<p>Too few control points."
                             " The number of control points must be equal or greater to the degrees of freedom.</p>"
                             "<p>Optimization aborted!</p>");
        return ;
    }
    if(model->rowCount()) {
        geometry_contraint_minimizer(gc);
    }
    _stitcherView->clearConstraintFits();
    for(int i = 0; i<model->rowCount(); i++) {
        QStandardItem * it = model->item(i,0);
        for(int j = 0; j<it->rowCount()-1; j++) {
            it->child(j,1)->setText(QString("%0").arg(gc->constraints[i].error[j]));
        }
        it->child(it->rowCount()-1,1)->setText(QString("%0").arg(gc->constraints[i].best_fit));
        _stitcherView->drawConstraintFit(gc);
    }

    for(int i = 0; i<gc->n_variables; i++) {
        ImageItem * item = pos_image_map.keys(gc->variables[i].parent).first();
        if(gc->variables[i].type == DeltaX) {
            item->setDx(gc->variables[i].parent->pos[DeltaX]);
        }
        if(gc->variables[i].type == DeltaY) {
            item->setDy(gc->variables[i].parent->pos[DeltaY]);
        }
        if(gc->variables[i].type == Zoom) {
            item->setDz(1.0/gc->variables[i].parent->pos[Zoom]);
        }
        if(gc->variables[i].type == Theta) {
            item->setTheta(gc->variables[i].parent->pos[Theta]);
        }
        if(gc->variables[i].type == Alpha) {
            item->setAlpha(gc->variables[i].parent->pos[Alpha]);
        }
    }
    loadGeometry();
}
开发者ID:ng110,项目名称:hawk,代码行数:93,代码来源:stitcherworkspace.cpp


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