示例#1
0
void QSGTextNode::addTextDecorations(Decoration decorations, const QPointF &position,
                                     const QColor &color, qreal width, qreal lineThickness,
                                     qreal underlinePos, qreal ascent)
{
    QRectF line(position.x(), position.y() - lineThickness / 2.0, width, lineThickness);

    if (decorations & Underline) {
        int underlinePosition = qCeil(underlinePos);
        QRectF underline(line);
        underline.translate(0.0, underlinePosition);
        appendChildNode(new QSGSimpleRectNode(underline, color));
    }

    if (decorations & Overline) {
        QRectF overline(line);
        overline.translate(0.0, -ascent);
        appendChildNode(new QSGSimpleRectNode(overline, color));
    }

    if (decorations & StrikeOut) {
        QRectF strikeOut(line);
        strikeOut.translate(0.0, ascent / -3.0);
        appendChildNode(new QSGSimpleRectNode(strikeOut, color));
    }
}
示例#2
0
//TODO updateMoons and destructor
void PlanetMoonsNode::updateMoons() {
    //In order to get the z-order right for the moons and the planet,
    //we need to first append the planet (both m_point and m_planetPic) then append all nodes for moons
    //that are nearer than the planet and then prepend nodes for moons that are further than the planet
    if(pmoons) {
        int nmoons = pmoons->nMoons();
        if(m_labelType == LabelsItem::label_t::NO_LABEL) {
            m_labelType = LabelsItem::label_t::JUPITER_MOON_LABEL;
        }

        if(!m_moonNodes.length()) { //Initialize PointSourceNodes used for drawing moons
            for ( int i=0; i<nmoons; ++i ) {
                m_moonNodes.append(new PointSourceNode(pmoons->moon(i), m_rootNode,m_labelType));
            }
        }

        removeAllChildNodes(); // Clear all child nodes so that we can render moons according to z-order

        // We need to reappend node that draws the planet
        appendChildNode(m_planetNode);

        bool drawLabel = true;

        if ( ! (Options::showPlanetNames() && Options::zoomFactor() > 50.*MINZOOM) ) {
            drawLabel = false;
        }

        for ( int i=0; i<nmoons; ++i ) {
            if ( pmoons->z(i) < 0.0 ) { //Moon is nearer than the planet
                appendChildNode(m_moonNodes[i]);
                m_moonNodes[i]->SkyNode::update(drawLabel);
            } else {
                //Draw Moons that are further than the planet
                //skyp->drawPointSource( pmoons->moon(i), pmoons->moon(i)->mag() );
                prependChildNode(m_moonNodes[i]);
                m_moonNodes[i]->SkyNode::update(drawLabel);
            }
        }

        /*  //Draw Moon name labels if at high zoom
     return;
    for ( int i=0; i<nmoons; ++i ) {

        if (planet ==KSPlanetBase::SATURN)
            SkyLabeler::AddLabel( pmoons->moon(i), SkyLabeler::SATURN_MOON_LABEL );
        else

        SkyLabeler::AddLabel( pmoons->moon(i), SkyLabeler::JUPITER_MOON_LABEL );
    }*/
    }
}
QcLocationCircleNode::QcLocationCircleNode(const QcViewport * viewport)
  : QSGOpacityNode(),
    m_viewport(viewport),
    m_geometry_node(new QSGGeometryNode())
{
  setOpacity(.25); // 1. black

  QSGGeometry * geometry = new QSGGeometry(LocationCirclePoint2D_AttributeSet, 0); // Fixme:
  geometry->setDrawingMode(GL_TRIANGLE_STRIP);
  m_geometry_node->setGeometry(geometry);
  m_geometry_node->setFlag(QSGNode::OwnsGeometry);

  QSGSimpleMaterial<QcLocationCircleMaterialShaderState> * material = QcLocationCircleMaterialShader::createMaterial();
  material->state()->cone_r = 0; // Fixme: QColor
  material->state()->cone_g = 0;
  material->state()->cone_b = 1;
  material->state()->cone_a = 1.;
  material->state()->accuracy_r = 1;
  material->state()->accuracy_g = 0;
  material->state()->accuracy_b = 0;
  material->state()->accuracy_a = 1.;
  // QSGFlatColorMaterial * material = new QSGFlatColorMaterial();
  // material->setColor(QColor("black"));
  material->setFlag(QSGMaterial::Blending);
  m_geometry_node->setMaterial(material);
  m_geometry_node->setFlag(QSGNode::OwnsMaterial);

  appendChildNode(m_geometry_node);
}
示例#4
0
PlanetMoonsNode::PlanetMoonsNode(KSPlanetBase* planet, RootNode* parentNode)
    :SkyNode(planet), m_rootNode(parentNode), pmoons(0),
      m_planetNode(new PlanetNode(planet, parentNode)), m_labelType(LabelsItem::label_t::NO_LABEL)
    //For now we consider labels only in case of Jupiter
{    
    appendChildNode(m_planetNode);
}
示例#5
0
QtWebPageSGNode::QtWebPageSGNode()
    : m_contentsNode(0)
    , m_backgroundNode(new QSGSimpleRectNode)
    , m_devicePixelRatio(1)
{
    appendChildNode(m_backgroundNode);
}
示例#6
0
 void setUnicodeText(const QString &text, const QFont &font, const QColor &color)
 {
     deleteContent();
     QRawFont raw_font = QRawFont::fromFont(font, QFontDatabase::Latin);
     qreal line_width = raw_font.averageCharWidth() * text.size();
     QSGRenderContext *sgr = QQuickItemPrivate::get(m_owner)->sceneGraphRenderContext();
     QTextLayout layout(text,font);
     layout.beginLayout();
     QTextLine line = layout.createLine();
     line.setLineWidth(line_width);
     //Q_ASSERT(!layout.createLine().isValid());
     layout.endLayout();
     QList<QGlyphRun> glyphRuns = line.glyphRuns();
     qreal xpos = 0;
     for (int i = 0; i < glyphRuns.size(); i++) {
         QSGGlyphNode *node = sgr->sceneGraphContext()->createGlyphNode(sgr, false);
         node->setOwnerElement(m_owner);
         node->geometry()->setIndexDataPattern(QSGGeometry::StaticPattern);
         node->geometry()->setVertexDataPattern(QSGGeometry::StaticPattern);
         node->setGlyphs(QPointF(xpos, raw_font.ascent()), glyphRuns.at(i));
         node->setStyle(QQuickText::Normal);
         node->setColor(color);
         xpos += raw_font.averageCharWidth() * glyphRuns.at(i).positions().size();
         node->update();
         appendChildNode(node);
     }
 }
示例#7
0
QgsSGGeometry::QgsSGGeometry( const QgsGeometry& geom, const QColor& color , int width )
{
  //TODO: Fix const-correcteness upstream
  QgsGeometry& gg = const_cast<QgsGeometry&>( geom );

  mMaterial.setColor( color );

  switch ( gg.type() )
  {
    case QgsWkbTypes::PointGeometry:
      if ( gg.isMultipart() )
      {
        const QgsMultiPoint& points = gg.asMultiPoint();

        Q_FOREACH( const QgsPoint& point, points )
        {
          QSGGeometryNode* geomNode = new QSGGeometryNode;
          geomNode->setGeometry( qgsPointToQSGGeometry ( point, width ) );
          geomNode->setFlag( QSGNode::OwnsGeometry );
          applyStyle( geomNode );
          appendChildNode( geomNode );
        }
      }
      else
      {
void RenderObjectChildList::insertChildNode(RenderObject* owner, RenderObject* child, RenderObject* beforeChild, bool fullInsert)
{
    if (!beforeChild) {
        appendChildNode(owner, child, fullInsert);
        return;
    }

    ASSERT(!child->parent());
    while (beforeChild->parent() != owner && beforeChild->parent()->isAnonymousBlock())
        beforeChild = beforeChild->parent();
    ASSERT(beforeChild->parent() == owner);

    ASSERT(!owner->isBlockFlow() || (!child->isTableSection() && !child->isTableRow() && !child->isTableCell()));

    if (beforeChild == firstChild())
        setFirstChild(child);

    RenderObject* prev = beforeChild->previousSibling();
    child->setNextSibling(beforeChild);
    beforeChild->setPreviousSibling(child);
    if (prev)
        prev->setNextSibling(child);
    child->setPreviousSibling(prev);

    child->setParent(owner);
    
    if (fullInsert) {
        // Keep our layer hierarchy updated.  Optimize for the common case where we don't have any children
        // and don't have a layer attached to ourselves.
        RenderLayer* layer = 0;
        if (child->firstChild() || child->hasLayer()) {
            layer = owner->enclosingLayer();
            child->addLayers(layer, child);
        }

        // if the new child is visible but this object was not, tell the layer it has some visible content
        // that needs to be drawn and layer visibility optimization can't be used
        if (owner->style()->visibility() != VISIBLE && child->style()->visibility() == VISIBLE && !child->hasLayer()) {
            if (!layer)
                layer = owner->enclosingLayer();
            if (layer)
                layer->setHasVisibleContent(true);
        }

        if (child->isListItem())
            toRenderListItem(child)->updateListMarkerNumbers();

        if (!child->isFloating() && owner->childrenInline())
            owner->dirtyLinesFromChangedChild(child);
    }

    RenderCounter::rendererSubtreeAttached(child);
    RenderQuote::rendererSubtreeAttached(child);
    child->setNeedsLayoutAndPrefWidthsRecalc();
    if (!owner->normalChildNeedsLayout())
        owner->setChildNeedsLayout(true); // We may supply the static position for an absolute positioned child.
    
    if (AXObjectCache::accessibilityEnabled())
        owner->document()->axObjectCache()->childrenChanged(owner);
}
void RenderSVGContainer::insertChildNode(RenderObject* child, RenderObject* beforeChild, bool)
{
    if (!beforeChild) {
        appendChildNode(child);
        return;
    }

    ASSERT(!child->parent());
    ASSERT(beforeChild->parent() == this);
    ASSERT(child->element()->isSVGElement());

    if (beforeChild == m_firstChild)
        m_firstChild = child;

    RenderObject* prev = beforeChild->previousSibling();
    child->setNextSibling(beforeChild);
    beforeChild->setPreviousSibling(child);
    if (prev)
        prev->setNextSibling(child);
    child->setPreviousSibling(prev);

    child->setParent(this);

    child->setNeedsLayoutAndPrefWidthsRecalc();
    if (!normalChildNeedsLayout())
        setChildNeedsLayout(true); // We may supply the static position for an absolute positioned child.

    if (AXObjectCache::accessibilityEnabled())
        document()->axObjectCache()->childrenChanged(this);
}
示例#10
0
void QQuickTextNode::setCursor(const QRectF &rect, const QColor &color)
{
    if (m_cursorNode != 0)
        delete m_cursorNode;

    QSGRenderContext *sg = QQuickItemPrivate::get(m_ownerElement)->sceneGraphRenderContext();
    m_cursorNode =  sg->sceneGraphContext()->createRectangleNode(rect, color);
    appendChildNode(m_cursorNode);
}
示例#11
0
XYPlotter::XYPlotter():
    m_width(1.0),
    m_height(1.0),
    m_x_scaling(1.0),
    m_y_scaling(1.0)
{
    m_geom_node = new PlotNode2D;
    appendChildNode( m_geom_node );
}
示例#12
0
void SatellitesItem::recreateList() {
    QList<SatelliteGroup*> list = m_satComp->groups();
    for(int i = 0; i < list.size(); ++i) {
        SatelliteGroup *group = list.at(i);
        for(int c = 0; c < group->size(); ++c) {
            appendChildNode(new SatelliteNode(group->at(c), rootNode()));
        }
    }
}
示例#13
0
int main(){
	//pNode root = createNode(88);
	//appendChildNode(root, createNode(90));
	//appendChildNode(root, createNode(80));
	//appendChildNode(root, createNode(94));
	//appendChildNode(root, createNode(74));
	//appendChildNode(root->leftChild, createNode(60));
	//appendChildNode(root->leftChild->rightSibling, createNode(55));
	//appendChildNode(root->leftChild->rightSibling, createNode(50));
	//appendChildNode(root->leftChild->rightSibling->rightSibling->rightSibling, createNode(30));
	////printTree(root, 0);
	//printNodesAtLevel(root, 0);
	//destroyNode(root);
	Node* Root = createNode('A');
	Node* B = createNode('B');
	Node* C = createNode('C');
	Node* D = createNode('D');
	Node* E = createNode('E');
	Node* F = createNode('F');
	Node* G = createNode('G');
	Node* H = createNode('H');
	Node* I = createNode('I');
	Node* J = createNode('J');
	Node* K = createNode('K');

	appendChildNode(Root, B);
	appendChildNode(B,C);
	appendChildNode(B, D);
	appendChildNode(D, E);
	appendChildNode(D, F);
	appendChildNode(Root, G);
	appendChildNode(G, H);
	appendChildNode(Root, I);
	appendChildNode(I, J);
	appendChildNode(J, K);

	//printTree(Root, 0);

	printNodesAtLevel(Root, 2);

	destroyNode(Root);

	return 0;
}
示例#14
0
void QtWebPageSGNode::setCoordinatedGraphicsScene(PassRefPtr<WebCore::CoordinatedGraphicsScene> scene)
{
    if (m_contentsNode && m_contentsNode->coordinatedGraphicsScene() == scene)
        return;

    delete m_contentsNode;
    m_contentsNode = new ContentsSGNode(scene);
    // This sets the parent node of the content to QtWebPageSGNode.
    appendChildNode(m_contentsNode);
}
MapPolygonNode::MapPolygonNode() :
    border_(new MapPolylineNode()),
    geometry_(QSGGeometry::defaultAttributes_Point2D(), 0),
    blocked_(true)
{
    geometry_.setDrawingMode(GL_TRIANGLES);
    QSGGeometryNode::setMaterial(&fill_material_);
    QSGGeometryNode::setGeometry(&geometry_);

    appendChildNode(border_);
}
示例#16
0
void QQuickTextNode::addImage(const QRectF &rect, const QImage &image)
{
    QSGRenderContext *sg = QQuickItemPrivate::get(m_ownerElement)->sceneGraphRenderContext();
    QSGImageNode *node = sg->sceneGraphContext()->createImageNode();
    QSGTexture *texture = sg->createTexture(image);
    m_textures.append(texture);
    node->setTargetRect(rect);
    node->setInnerTargetRect(rect);
    node->setTexture(texture);
    appendChildNode(node);
    node->update();
}
示例#17
0
PlanetsItem::PlanetsItem(QList<SolarSystemSingleComponent *> planets, QList<PlanetMoonsComponent *> moons, RootNode *rootNode)
    :SkyItem(LabelsItem::label_t::PLANET_LABEL, rootNode), m_planetComponents(planets), m_moonsComponents(moons)
{
    foreach(SolarSystemSingleComponent * planetComp, m_planetComponents) {
        KSPlanetBase *planet = planetComp->planet();
        PlanetMoonsNode *pNode = new PlanetMoonsNode(planet, rootNode);
        appendChildNode(pNode);

        foreach(PlanetMoonsComponent * moonsComp, m_moonsComponents) {
            // Find planet of moons
            if(planet == moonsComp->getPlanet()) {
                pNode->addMoons(moonsComp->getMoons());
            }
        }
    }
示例#18
0
    void setLatinText(const QString &text, const QFont &font, const QColor &color) {
        QRawFont raw_font = QRawFont::fromFont(font, QFontDatabase::Latin);

        if (raw_font != m_raw_font) {
            m_raw_font = raw_font;
            m_positions.clear();
        }

        if (m_positions.size() < text.size()) {
            qreal x_pos = 0;
            qreal max_char_width = raw_font.averageCharWidth();
            qreal ascent = raw_font.ascent();
            if (m_positions.size())
                x_pos = m_positions.last().x() + max_char_width;
            int to_add = text.size() - m_positions.size();
            for (int i = 0; i < to_add; i++) {
                m_positions << QPointF(x_pos, ascent);
                x_pos += max_char_width;
            }
        }

        deleteContent();

        QSGRenderContext *sgr = QQuickItemPrivate::get(m_owner)->sceneGraphRenderContext();
        QSGGlyphNode *node = sgr->sceneGraphContext()->createGlyphNode(sgr, false);
        node->setOwnerElement(m_owner);
        node->geometry()->setIndexDataPattern(QSGGeometry::StaticPattern);
        node->geometry()->setVertexDataPattern(QSGGeometry::StaticPattern);
        node->setStyle(QQuickText::Normal);

        node->setColor(color);
        QGlyphRun glyphrun;
        glyphrun.setRawFont(raw_font);
        glyphrun.setGlyphIndexes(raw_font.glyphIndexesForString(text));

        glyphrun.setPositions(m_positions);
        node->setGlyphs(QPointF(0, raw_font.ascent()), glyphrun);
        node->update();
        appendChildNode(node);
    }
示例#19
0
void RenderObjectChildList::insertChildNode(RenderObject* owner, RenderObject* child, RenderObject* beforeChild, bool notifyRenderer)
{
    if (!beforeChild) {
        appendChildNode(owner, child, notifyRenderer);
        return;
    }

    ASSERT(!child->parent());
    while (beforeChild->parent() != owner && beforeChild->parent()->isAnonymousBlock())
        beforeChild = beforeChild->parent();
    ASSERT(beforeChild->parent() == owner);

    ASSERT(!owner->isBlockFlow() || (!child->isTableSection() && !child->isTableRow() && !child->isTableCell()));

    if (beforeChild == firstChild())
        setFirstChild(child);

    RenderObject* prev = beforeChild->previousSibling();
    child->setNextSibling(beforeChild);
    beforeChild->setPreviousSibling(child);
    if (prev)
        prev->setNextSibling(child);
    child->setPreviousSibling(prev);

    child->setParent(owner);
    
    if (!owner->documentBeingDestroyed() && notifyRenderer)
        child->insertedIntoTree();

    if (!owner->documentBeingDestroyed()) {
        RenderCounter::rendererSubtreeAttached(child);
    }
    child->setNeedsLayoutAndPrefWidthsRecalc();
    if (!owner->normalChildNeedsLayout())
        owner->setChildNeedsLayout(true); // We may supply the static position for an absolute positioned child.
    
    if (AXObjectCache::accessibilityEnabled())
        owner->document()->axObjectCache()->childrenChanged(owner);
}
示例#20
0
QSGGlyphNode *QSGTextNode::addGlyphs(const QPointF &position, const QGlyphRun &glyphs, const QColor &color,
                                           QSGText::TextStyle style, const QColor &styleColor, QSGGlyphNode *prevNode)
{
    QSGGlyphNode *node = prevNode;

    if (!node)
        node = m_context->createGlyphNode();

    node->setGlyphs(position, glyphs);

    if (node != prevNode) {
        node->setStyle(style);
        node->setStyleColor(styleColor);
        node->setColor(color);
    }

    node->update();

    if (node != prevNode)
        appendChildNode(node);

    return node;
}
示例#21
0
GuideLabelNode::GuideLabelNode(QString name, LabelsItem::label_t type)
    :m_textTexture(new QSGSimpleTextureNode), m_name(name)
{
    appendChildNode(&debugRect);
    debugRect.setColor(QColor("green"));
    QColor color;
    switch(type) {
        case LabelsItem::label_t::CONSTEL_NAME_LABEL:
            color = KStarsData::Instance()->colorScheme()->colorNamed( "CNameColor" );
            break;
        case LabelsItem::label_t::HORIZON_LABEL:
            color = KStarsData::Instance()->colorScheme()->colorNamed( "CompassColor" );
            break;
        default:
            color = KStarsData::Instance()->colorScheme()->colorNamed( "UserLabelColor" );
    }

    m_textTexture->setTexture(SkyMapLite::Instance()->textToTexture(name, color));
    m_opacity->appendChildNode(m_textTexture);

    m_textSize = m_textTexture->texture()->textureSize();
    QRectF oldRect = m_textTexture->rect();
    m_textTexture->setRect(QRect(oldRect.x(),oldRect.y(),m_textSize.width(),m_textSize.height()));
}
示例#22
0
void QQuickTextNode::addRectangleNode(const QRectF &rect, const QColor &color)
{
    QSGRenderContext *sg = QQuickItemPrivate::get(m_ownerElement)->sceneGraphRenderContext();
    appendChildNode(sg->sceneGraphContext()->createRectangleNode(rect, color));
}