Пример #1
0
ClosedKnot::ClosedKnot(const KnotStyle &knotStyle,
                       int windowWidth, int windowHeight)
    :   inherited(knotStyle, windowWidth, windowHeight, 12)
{
    // Set boundary conditions for a closed knot.

    // The left and right border must consist of vertical...
    for (int i = 0; i < mVSections; ++i) {
        sectionType(0, i) = sectionType(mHSections-1, i) = V;
    }

    // ... half sections.
    for (int i = 0; i <= mVSections; ++i) {
        sectionCorner(0, i) = sectionCorner(mHSections, i) = N;
    }

    // The top and bottom border must have horizontal corners.
    for (int i = 1; i < mHSections; ++i) {
        sectionCorner(i, 0) = sectionCorner(i, mVSections) = H;
    }

    // Assign colors to the knot.
    assignColors();
}
Пример #2
0
QDomElement DetailSection::xml(QDomDocument doc, QList<Container *> &usedItems, QMap<QString, bool> &querys, QList<Section*> sectionPool)
{
    QDomElement node = doc.createElement("Section");
    node.setAttribute("id",sectionType());
    node.setAttribute("size",(int)rect().height());
    node.setAttribute("name",m_SectionName);
    node.setAttribute("SqlGlobal",m_SqlGlobal);
    node.setAttribute("SqlInterno",m_SqlInterno);
    node.setAttribute("ClausulaInterna",m_ClausulaInterna);
    node.setAttribute("haveSqlInterno",m_header || m_foot);
    node.setAttribute("colored",m_colorear);
    node.setAttribute("color1",ColorString(m_color1));
    node.setAttribute("alternative",m_use2Colors);
    node.setAttribute("color2",ColorString(m_color2));

    QPointF br(rect().bottomRight().x(),rect().bottomRight().y());
    QPointF tl(rect().topLeft().x(),rect().topLeft().y());
    if(m_header)
    {
        QDomElement headerNode = doc.createElement("Header");
        headerNode.setAttribute("size",m_headerSize);
        QRectF aux(tl,QPointF(br.x(),tl.y()+m_headerSize));
        QRectF headerRect(mapRectToScene(aux));

        QList<QGraphicsItem*>items =this->scene()->items(headerRect);
        QListIterator<QGraphicsItem*> it(items);
        while (it.hasNext())
        {
            QGraphicsItem* c = it.next();
            Container* cont = qgraphicsitem_cast<Container*>(c);
            if(cont)
            {
                if(!usedItems.contains(cont))
                {
                    headerNode.appendChild(cont->xml(doc,marginPoint(),sectionPool));
                    usedItems.append(cont);
                }
            }
        }
        node.appendChild(headerNode);
    }
    QDomElement bodyNode = doc.createElement("Body");
    bodyNode.setAttribute("size",this->rect().height() - m_headerSize - m_footSize);
    QRectF bodyRect(mapToScene(QPointF(tl.x(),tl.y()+m_headerSize)),mapToScene(QPointF(br.x(),br.y()-m_footSize)));
    QList<QGraphicsItem*>items =this->scene()->items(bodyRect);
    QListIterator<QGraphicsItem*> it(items);
    while (it.hasNext())
    {
        QGraphicsItem* c = it.next();
        Container* cont = qgraphicsitem_cast<Container*>(c);
        if(cont)
        {
            if(!usedItems.contains(cont))
            {
                bodyNode.appendChild(cont->xml(doc,mapToScene(QPointF(tl.x(),tl.y()+m_headerSize)),sectionPool));
                usedItems.append(cont);
            }
        }
    }
    node.appendChild(bodyNode);
    if(m_foot)
    {
        QDomElement footNode = doc.createElement("Foot");
        footNode.setAttribute("size",m_footSize);
        QRectF footRect(mapToScene(QPointF(tl.x(),br.y()-m_footSize+1)),mapToScene(QPointF(br)));
        QList<QGraphicsItem*>items =this->scene()->items(footRect);
        QListIterator<QGraphicsItem*> it(items);
        while (it.hasNext())
        {
            QGraphicsItem* c = it.next();
            Container* cont = qgraphicsitem_cast<Container*>(c);
            if(cont)
            {
                if(!usedItems.contains(cont))
                {
                    footNode.appendChild(cont->xml(doc,mapToScene(QPointF(tl.x(),br.y()-m_footSize)),sectionPool));
                    usedItems.append(cont);
                }
            }
        }
        node.appendChild(footNode);
    }
    return node;
}