예제 #1
0
파일: PortionDrawer.cpp 프로젝트: 8l/oovcde
void PortionDrawer::drawGraph(DiagramDrawer &drawer)
    {
    if(mGraph)
        {
        // This must be set for svg
        drawer.setDiagramSize(getDrawingSize(drawer));

        drawNodes(drawer);
        drawer.groupShapes(true, Color(0,0,0), Color(245,245,255));
        drawConnections(drawer);
        drawer.groupShapes(false, 0, 0);

        std::vector<DrawString> drawStrings;
        std::vector<bool> virtOpers;
        getNodeText(drawer, drawStrings, virtOpers);

        drawer.groupText(true, false);
        drawNodeText(drawer, false, drawStrings, virtOpers);
        drawer.groupText(false, false);

        drawer.groupText(true, true);
        drawNodeText(drawer, true, drawStrings, virtOpers);
        drawer.groupText(false, false);
        }
    }
예제 #2
0
String getChildText(MSXML2::IXMLDOMNodePtr& parent, const String& childNodeName) {
  MSXML2::IXMLDOMNodePtr child = parent->selectSingleNode(childNodeName.c_str());
  if (child == NULL) {
    throw XMLUtils::ParseError();
  }

  return getNodeText(child);
}
예제 #3
0
파일: svg.c 프로젝트: Melab/gvmt
static void drawNode(Node p, int x, int y) {
    int textSize = getTextSize(p);
    print("<rect style=\"stroke: black; fill: white;\" x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" rx=\"%d\" ry=\"%d\" ",
            x + X_OFFSET - X_SCALE/4 - CHAR_SIZE * textSize, y, 2 * CHAR_SIZE * textSize + X_SCALE/2, Y_SPACING, X_SCALE/4, X_SCALE/4);
    print("/>\n");
    print("<text ");
    print("style=\"font-size:%d;font-style:normal;font-weight:normal;text-anchor:start;fill:#000000;font-family:sans\" ", FONT_SIZE);
    print("x=\"%d\" ", (x + X_OFFSET - CHAR_SIZE * textSize));
    print("y=\"%d\" ", (y  + Y_OFFSET + CHAR));
    print("id=\"id%d\">", next_id++);
    print(getNodeText(p));
    print(" [%s]" , type_name(p->x.exact_type));
    print_type_set(p->x.type_set);
    if (p->x.ptype)
        print(" %t ", p->x.ptype);
    if (p->x.eliminated)
        print(" ELIMINATED ");
    print("</text>\n");
}
예제 #4
0
파일: svg.c 프로젝트: Melab/gvmt
int getTextSize(Node p) {
    return strlen(getNodeText(p)); 
}
예제 #5
0
void GraphicsItemNode::paint(QPainter * painter, const QStyleOptionGraphicsItem *, QWidget *)
{
    QPainterPath outlinePath = shape();

    //Fill the node's colour
    QBrush brush(m_colour);
    painter->fillPath(outlinePath, brush);

    //If the node contains a BLAST hit, draw that on top.
    if (g_settings->nodeColourScheme == BLAST_HITS_COLOUR)
    {
        std::vector<BlastHitPart> parts;

        if (g_settings->doubleMode)
        {
            if (m_deBruijnNode->thisNodeHasBlastHits())
                parts = m_deBruijnNode->getBlastHitPartsForThisNode();
        }
        else
        {
            if (m_deBruijnNode->thisNodeOrReverseComplementHasBlastHits())
                parts = m_deBruijnNode->getBlastHitPartsForThisNodeOrReverseComplement();
        }

        if (parts.size() > 0)
        {
            QPen partPen;
            partPen.setWidthF(m_width);
            partPen.setCapStyle(Qt::FlatCap);
            partPen.setJoinStyle(Qt::BevelJoin);

            for (size_t i = 0; i < parts.size(); ++i)
            {
                partPen.setColor(parts[i].m_colour);
                painter->setPen(partPen);

                painter->drawPath(makePartialPath(parts[i].m_nodeFractionStart, parts[i].m_nodeFractionEnd));
            }
        }
    }

    //Draw the node outline
    QColor outlineColour = g_settings->outlineColour;
    double outlineThickness = g_settings->outlineThickness;
    if (isSelected())
    {
        outlineColour = g_settings->selectionColour;
        outlineThickness = g_settings->selectionThickness;
    }
    if (outlineThickness > 0.0)
    {
        outlinePath = outlinePath.simplified();
        QPen outlinePen(QBrush(outlineColour), outlineThickness, Qt::SolidLine, Qt::FlatCap, Qt::RoundJoin);
        painter->setPen(outlinePen);
        painter->drawPath(outlinePath);
    }


    //Draw text if there is any to display.
    if (g_settings->anyNodeDisplayText())
    {
        //The text should always be displayed upright, so
        //counter the view's rotation here.

        painter->setRenderHint(QPainter::TextAntialiasing, true);
        painter->setFont(g_settings->labelFont);
        QString displayText = getNodeText();
        QSize textSize = getNodeTextSize(displayText);

        double textWidth = textSize.width();
        double textHeight = textSize.height();

        //The text outline is made by drawing the text first in white at a slight offset
        //at many angles.  The larger the text outline, the more angles are needed to
        //make the outline look nice.
        if (g_settings->textOutline)
        {
            int offsetSteps = 8;
            if (g_settings->textOutlineThickness > 0.5)
                offsetSteps = 16;
            if (g_settings->textOutlineThickness > 1.0)
                offsetSteps = 32;

            double offsetDistance = g_settings->textOutlineThickness;

            painter->translate(getCentre());
            painter->rotate(-g_graphicsView->m_rotation);

            for (int i = 0; i < offsetSteps; ++i)
            {
                double offsetAngle = 6.2832 * (double(i) / offsetSteps);
                double xOffset = offsetDistance * cos(offsetAngle);
                double yOffset = offsetDistance * sin(offsetAngle);
                QRectF shadowTextRectangle(-textWidth / 2.0 + xOffset,
                                           -textHeight / 2.0 + yOffset,
                                           textWidth, textHeight);
                painter->setPen(Qt::white);
                painter->drawText(shadowTextRectangle, Qt::AlignCenter, displayText);
            }

            painter->rotate(g_graphicsView->m_rotation);
            painter->translate(-1.0 * getCentre());
        }

        QRectF textRectangle(-textWidth / 2.0, -textHeight / 2.0,
                             textWidth, textHeight);
        painter->setPen(g_settings->textColour);

        painter->translate(getCentre());
        painter->rotate(-g_graphicsView->m_rotation);
        painter->drawText(textRectangle, Qt::AlignCenter, displayText);
        painter->rotate(g_graphicsView->m_rotation);
        painter->translate(-1.0 * getCentre());
    }
}