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


C++ QArray::append方法代码示例

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


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

示例1: picking

ViewportPrivate::ViewportPrivate()
    : picking(true)
    , showPicking(false)
    , navigation(true)
    , blending(false)
    , itemsInitialized(false)
    , needsPick(true)
    , camera(0)
    , lightModel(0)
    , backdrop(0)
    , backgroundColor(Qt::black)
    , view(0)
    , viewWidget(0)
    , pickId(1)
    , pickFbo(0)
{
    // Construct the vertices for a quad with (0, 0) as the
    // texture co-ordinate for the bottom-left of the screen
    // and (1, 1) as the texture co-ordinate for the top-right.
    backdropVertices.setPackingHint(QGLVertexBuffer::Append);

    QArray<QVector2D> pos;
    pos.append(QVector2D(-1.0f, -1.0f));
    pos.append(QVector2D(-1.0f,  1.0f));
    pos.append(QVector2D( 1.0f,  1.0f));
    pos.append(QVector2D( 1.0f, -1.0f));

    QArray<QVector2D> tex;
    pos.append(QVector2D(0.0f, 0.0f));
    pos.append(QVector2D(0.0f, 1.0f));
    pos.append(QVector2D(1.0f, 1.0f));
    pos.append(QVector2D(1.0f, 0.0f));

    backdropVertices.addAttribute(QGL::Position, pos);
    backdropVertices.addAttribute(QGL::TextureCoord0, tex);

    //backdropVertices.append(-1.0f, -1.0f);
    //backdropVertices.append(0.0f, 0.0f);
    //backdropVertices.append(-1.0f, 1.0f);
    //backdropVertices.append(0.0f, 1.0f);
    //backdropVertices.append(1.0f, 1.0f);
    //backdropVertices.append(1.0f, 1.0f);
    //backdropVertices.append(1.0f, -1.0f);
    //backdropVertices.append(1.0f, 0.0f);
}
开发者ID:slavablind91,项目名称:code,代码行数:45,代码来源:viewport.cpp

示例2: while

void QGLIndexBufferPrivate::append
    (const QGLIndexBufferPrivate *other, uint offset, int start)
{
    if (elementType == GL_UNSIGNED_SHORT &&
            other->elementType == GL_UNSIGNED_SHORT) {
        // Both buffers are ushort.
        const ushort *data = other->indexesShort.constData() + start;
        int count = other->indexesShort.count() - start;
        indexesShort.reserve(indexesShort.count() + count);
        indexCount += count;
        while (count-- > 0)
            indexesShort.append(ushort(*data++ + offset));
    } else if (elementType == GL_UNSIGNED_SHORT) {
        // Only first buffer is ushort: convert it to int first.
        const ushort *indexes = indexesShort.constData();
        int count = indexesShort.count();
        indexesInt.reserve(count + other->indexesInt.count());
        while (count-- > 0)
            indexesInt.append(*indexes++);
        indexesShort = QArray<ushort>();
        elementType = GL_UNSIGNED_INT;
        const uint *data = other->indexesInt.constData() + start;
        count = other->indexesInt.count() - start;
        indexCount += count;
        while (count-- > 0)
            indexesInt.append(*data++ + offset);
    } else if (other->elementType == GL_UNSIGNED_SHORT) {
        // Only second buffer is ushort.
        const ushort *data = other->indexesShort.constData() + start;
        int count = other->indexesShort.count() - start;
        indexesInt.reserve(indexesInt.count() + count);
        indexCount += count;
        while (count-- > 0)
            indexesInt.append(*data++ + offset);
    } else {
        // Neither buffer is ushort.
        const uint *data = other->indexesInt.constData() + start;
        int count = other->indexesInt.count() - start;
        indexesInt.reserve(indexesInt.count() + count);
        indexCount += count;
        while (count-- > 0)
            indexesInt.append(*data++ + offset);
    }
}
开发者ID:slavablind91,项目名称:code,代码行数:44,代码来源:qglindexbuffer.cpp

示例3: processFloatList

/*!
  \internal
    Processes a list of floating point numbers.  If the list contains only 1
    element, a QVariant<float> is returned.  If the list containst 2, 3 or 4
    elements, they are converted into a QVariant containing a QVector2D,
    QVector3D, or QVector4D respectively.
    If the list containst more elements than that, they are returned as a
    QArray<float>.

*/
QVariant QGLColladaFxEffectFactory::processFloatList( QXmlStreamReader& xml )
{
    QArray<float> floats;
    QString elementString = xml.readElementText();
    QStringList list = elementString.split( QRegExp( "\\s+" ), QString::SkipEmptyParts );
    bool ok;
    float f;
    foreach( QString string, list )
    {
        f = string.toFloat( &ok );
        if( ok )
            floats.append(string.toFloat());
        else
        {
            qWarning() << "Warning: malformed float ( line" << xml.lineNumber() << ")";
        }
    }
开发者ID:slavablind91,项目名称:code,代码行数:27,代码来源:qglcolladafxeffectfactory.cpp

示例4: genSurfacePerVertex

void BrainView::genSurfacePerVertex()
{
    if(m_SurfaceSet.size() == 0)
        return;

    if(m_pSceneNode)
    {
        delete m_pSceneNode;
        m_pSceneNode = NULL;
    }

    // in the constructor construct a builder on the stack
    QGLBuilder builder;

    float fac = 100.0f; // too small vertices distances cause clipping errors --> 100 is a good value for freesurfer brain measures

    builder << QGL::Smooth;//QGL::Faceted;
    m_pSceneNodeBrain = builder.currentNode();

    builder.pushNode();

    //
    // get bounding box
    //
    calcBoundingBox();

    //
    // Build each surface in its separate node
    //
    QMap<qint32, Surface>::const_iterator it = m_SurfaceSet.data().constBegin();
    for (it = m_SurfaceSet.data().begin(); it != m_SurfaceSet.data().end(); ++it)
    {
        builder.pushNode();
        {
            Matrix3Xf rr = it.value().rr().transpose();

            //Centralize
            for(qint32 i = 0; i < 3; ++i)
                rr.row(i) = rr.row(i).array() - (m_vecBoundingBoxCenter[i] + it.value().offset()[i]);


            QGeometryData t_GeometryDataTri;

            MatrixXf t_TriCoords = MatrixXf::Zero(3,3*(it.value().tris().rows()));
            QArray<QColor4ub> cdata;
            for(qint32 i = 0; i < it.value().tris().rows(); ++i)
            {
                for(qint32 j = 0; j < 3; ++j)
                {
                    t_TriCoords.col(i*3+j) = rr.col( it.value().tris()(i,j) );

                    if(it.value().curv()[it.value().tris()(i,j)] >= 0)
                        cdata.append(QColor( 50, 50, 50, 230));//Sulci
                    else
                        cdata.append(QColor( 200, 200, 200, 230));//Gyri
                }
            }

            t_TriCoords *= fac;
            t_GeometryDataTri.appendVertexArray(QArray<QVector3D>::fromRawData( reinterpret_cast<const QVector3D*>(t_TriCoords.data()), t_TriCoords.cols() ));

            t_GeometryDataTri.appendColorArray(cdata);

            //
            //  Add triangles to current node
            //
            builder.addTriangles(t_GeometryDataTri);
        }
        // Go one level up
        builder.popNode();
    }

    m_bRenderPerVertex = true;

    // Optimze current scene for display and calculate lightning normals
    m_pSceneNode = builder.finalizedSceneNode();

    m_pSceneNode->setParent(this);
}
开发者ID:BulatSuleymanoff,项目名称:mne-cpp,代码行数:79,代码来源:brainview.cpp

示例5: stream

PlyLoader::PlyLoader( const std::string& file, boost::optional< QColor4ub > color, double scale ) : color_( color ), scale_( scale )
{
    std::ifstream stream( file.c_str() );
    std::string line;
    std::getline( stream, line );
    if( line != "ply" ) { COMMA_THROW( comma::exception, "expected ply file; got \"" << line << "\" in " << file ); }
    unsigned int numVertex = 0;
    unsigned int numFace = 0;
    bool has_normals = false;

    std::vector< std::string > fields;
    while( stream.good() && !stream.eof() && line != "end_header" )
    {
        std::getline( stream, line );
        if( line.empty() ) { continue; }
        std::vector< std::string > v = comma::split( comma::strip( line ), ' ' );
        if( v[0] == "element" ) // quick and dirty
        {
            if( v[1] == "vertex" ) { numVertex = boost::lexical_cast< unsigned int >( v[2] ); }
            else if( v[1] == "face" ) { numFace = boost::lexical_cast< unsigned int >( v[2] ); }
        }
        else if( v[0] == "format" && v[1] != "ascii" ) { COMMA_THROW( comma::exception, "only ascii supported; got: " << v[1] ); }
        else if( line == "property float x" ) { fields.push_back( "point/x" ); }
        else if( line == "property float y" ) { fields.push_back( "point/y" ); }
        else if( line == "property float z" ) { fields.push_back( "point/z" ); }
        else if( line == "property float nx" ) { fields.push_back( "normal/x" ); has_normals = true; }
        else if( line == "property float ny" ) { fields.push_back( "normal/y" ); }
        else if( line == "property float nz" ) { fields.push_back( "normal/z" ); }
        else if( line == "property uchar red" ) { fields.push_back( "r" ); }
        else if( line == "property uchar green" ) { fields.push_back( "g" ); }
        else if( line == "property uchar blue" ) { fields.push_back( "b" ); }
        else if( line == "property uchar alpha" ) { fields.push_back( "a" ); }
    }
    comma::csv::options csv;
    csv.fields = comma::join( fields, ',' );
    csv.full_xpath = true;
    csv.delimiter = ' ';
    comma::csv::ascii< ply_vertex > ascii( csv );
    QGeometryData geometry;
    QArray< QVector3D > vertices;
    QArray< QColor4ub > colors;

    for( unsigned int i = 0; i < numVertex; i++ )
    {
        std::string s;
        if( stream.eof() ) { break; }
        std::getline( stream, s );
        if( s.empty() ) { continue; }
        ply_vertex v;
        if( color_ ) { v.color = *color_; } // quick and dirty
        ascii.get( v, s );
        if( numFace > 0 )
        {
            geometry.appendVertex( QVector3D( v.point.x() * scale_, v.point.y() * scale_, v.point.z() * scale_ ) );
            if( has_normals ) { geometry.appendNormal( QVector3D( v.normal.x(), v.normal.y(), v.normal.z() ) ); }
            geometry.appendColor( v.color );
        }
        else
        {
            vertices.append( QVector3D( v.point.x() * scale_, v.point.y() * scale_, v.point.z() * scale_ ) );
            // todo: normals?
            colors.append( v.color );
        }
    }
    if( numFace > 0 )
    {
        for( unsigned int i = 0; i < numFace; i++ ) // quick and dirty
        {
            std::string s;
            if( stream.eof() ) { break; }
            std::getline( stream, s );
            if( s.empty() ) { continue; }
            std::vector< std::string > v = comma::split( comma::strip( s ), ' ' );
            unsigned int vertices_per_face = boost::lexical_cast< unsigned int >( v[0] );
            if( ( vertices_per_face + 1 ) != v.size() ) { COMMA_THROW( comma::exception, "invalid line \"" << s << "\"" ); }
            QGL::IndexArray indices;
            switch( vertices_per_face )
            {
                case 3:
                    for( unsigned int i = 0; i < 3; ++i ) { indices.append( boost::lexical_cast< unsigned int >( v[i+1] ) ); }
                    break;
                case 4: // quick and dirty for now: triangulate
                    boost::array< unsigned int, 4 > a;
                    for( unsigned int i = 0; i < 4; ++i ) { a[i] = boost::lexical_cast< unsigned int >( v[i+1] ); }
                    indices.append( a[0] );
                    indices.append( a[1] );
                    indices.append( a[2] );
                    indices.append( a[0] );
                    indices.append( a[2] );
                    indices.append( a[3] );
                    break;
                default: // never here
                    break;
            }
            geometry.appendIndices( indices );
        }
        QGLBuilder builder;
        builder.addTriangles( geometry );
        //switch( vertices_per_face )
        //{
//.........这里部分代码省略.........
开发者ID:acfr,项目名称:snark,代码行数:101,代码来源:ply_loader.cpp


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