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


C++ QPolygon::subtracted方法代码示例

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


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

示例1: highlightItems

void OverviewDockWidget::highlightItems(QList<OwlClass *> cls)
{
    if(this->highlightpolygon!=NULL)m_scene->removeItem(highlightpolygon);
    QColor grey(0, 0, 0, 60);
    QPolygon polygon = QPolygon(m_scene->sceneRect().toRect());
    for(int i=0;i<cls.size();i++){
        double x = cls[i]->overviewshape->pos().rx() - 10;
        double y = cls[i]->overviewshape->pos().ry() - 10;
        QRectF viewRect = QRectF(x,y,20,20);
        polygon = polygon.subtracted(QPolygon(viewRect.toRect()));
    }

    highlightpolygon = m_scene->addPolygon(polygon,QPen(Qt::transparent),QBrush(grey));
    lines.append(highlightpolygon);
}
开发者ID:ZongleiJiao,项目名称:OntologyViewer,代码行数:15,代码来源:overviewdockwidget.cpp

示例2: drawSpace

//  ////////////////////////////Drawing the inactive intersection space////////////////////////////////////
void LvlScene::drawSpace()
{
    const long padding = 400000;

    WriteToLog(QtDebugMsg, QString("Draw intersection space-> Find and remove current"));
    foreach(QGraphicsItem * spaceItem, items())
    {
        if(spaceItem->data(0).toString()=="Space")
        {
            removeItem(spaceItem);
            delete spaceItem;
            continue;
        }
        if(spaceItem->data(0).toString()=="SectionBorder")
        {
            removeItem(spaceItem);
            delete spaceItem;
            continue;
        }
    }

    QPolygon bigSpace;
    QGraphicsItem * item;
    QGraphicsItem * item2;
    QVector<QPoint > drawing;

    int i, j;
    long l, r, t, b;
    //x, y, h, w;

    WriteToLog(QtDebugMsg, QString("Draw intersection space-> Find minimal"));
    j=-1;
    do
    {
        j++;
        l = LvlData->sections[j].size_left;
        r = LvlData->sections[j].size_right;
        t = LvlData->sections[j].size_top;
        b = LvlData->sections[j].size_bottom;
    }
    while(
        ((LvlData->sections[j].size_left==0) &&
         (LvlData->sections[j].size_right==0) &&
         (LvlData->sections[j].size_top==0) &&
         (LvlData->sections[j].size_bottom==0)) && (j<LvlData->sections.size())
    );

    for(i=0; i<LvlData->sections.size(); i++)
    {

        if(
            (LvlData->sections[i].size_left==0) &&
            (LvlData->sections[i].size_right==0) &&
            (LvlData->sections[i].size_top==0) &&
            (LvlData->sections[i].size_bottom==0))
            continue;

        if(LvlData->sections[i].size_left < l)
            l = LvlData->sections[i].size_left;
        if(LvlData->sections[i].size_right > r)
            r = LvlData->sections[i].size_right;
        if(LvlData->sections[i].size_top < t)
            t = LvlData->sections[i].size_top;
        if(LvlData->sections[i].size_bottom > b)
            b = LvlData->sections[i].size_bottom;
    }

    WriteToLog(QtDebugMsg, QString("Draw intersection space-> Draw polygon"));

    drawing.clear();
    drawing.push_back(QPoint(l-padding, t-padding));
    drawing.push_back(QPoint(r+padding, t-padding));
    drawing.push_back(QPoint(r+padding, b+padding));
    drawing.push_back(QPoint(l-padding, b+padding));
    drawing.push_back(QPoint(l-padding, t+padding));

    bigSpace = QPolygon(drawing);


    l = LvlData->sections[LvlData->CurSection].size_left;
    r = LvlData->sections[LvlData->CurSection].size_right;
    t = LvlData->sections[LvlData->CurSection].size_top;
    b = LvlData->sections[LvlData->CurSection].size_bottom;


    WriteToLog(QtDebugMsg, QString("Draw intersection space-> Draw editing hole"));
    drawing.clear();
    drawing.push_back(QPoint(l-1, t-1));
    drawing.push_back(QPoint(r+1, t-1));
    drawing.push_back(QPoint(r+1, b+1));
    drawing.push_back(QPoint(l-1, b+1));
    drawing.push_back(QPoint(l-1, t-1));

    bigSpace = bigSpace.subtracted(QPolygon(drawing));

    WriteToLog(QtDebugMsg, QString("Draw intersection space-> add polygon to Item"));
    item = addPolygon(bigSpace, QPen(Qt::NoPen), QBrush(Qt::black));//Add inactive space
    item2 = addPolygon(QPolygon(drawing), QPen(Qt::red, 2));
    item->setZValue(spaceZ1);
//.........这里部分代码省略.........
开发者ID:nexia29,项目名称:PlatGEnWohl,代码行数:101,代码来源:lvl_section.cpp


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