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);
}
Example #2
0
//  ////////////////////////////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);
    item2->setZValue(spaceZ2);
    item->setOpacity(qreal(0.4));
    item->setData(0, "Space");
    item2->setData(0, "SectionBorder");

}