⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 annotations.cpp.svn-base

📁 okular
💻 SVN-BASE
📖 第 1 页 / 共 2 页
字号:
    {        QDomElement escapedText = document.createElement( "escapedText" );        textElement.appendChild( escapedText );        QDomCDATASection textCData = document.createCDATASection( inplaceText );        escapedText.appendChild( textCData );    }    // Sub-Node-2 - callout    if ( inplaceCallout[0].x != 0.0 )    {        QDomElement calloutElement = document.createElement( "callout" );        textElement.appendChild( calloutElement );        calloutElement.setAttribute( "ax", inplaceCallout[0].x );        calloutElement.setAttribute( "ay", inplaceCallout[0].y );        calloutElement.setAttribute( "bx", inplaceCallout[1].x );        calloutElement.setAttribute( "by", inplaceCallout[1].y );        calloutElement.setAttribute( "cx", inplaceCallout[2].x );        calloutElement.setAttribute( "cy", inplaceCallout[2].y );    }}/** LineAnnotation [Annotation] */LineAnnotation::LineAnnotation()    : Annotation(), lineStartStyle( None ), lineEndStyle( None ),    lineClosed( false ), lineLeadingFwdPt( 0 ), lineLeadingBackPt( 0 ),    lineShowCaption( false ), lineIntent( Unknown ){}LineAnnotation::LineAnnotation( const QDomNode & node )    : Annotation( node ), lineStartStyle( None ), lineEndStyle( None ),    lineClosed( false ), lineLeadingFwdPt( 0 ), lineLeadingBackPt( 0 ),    lineShowCaption( false ), lineIntent( Unknown ){    // loop through the whole children looking for a 'line' element    QDomNode subNode = node.firstChild();    while( subNode.isElement() )    {        QDomElement e = subNode.toElement();        subNode = subNode.nextSibling();        if ( e.tagName() != "line" )            continue;        // parse the attributes        if ( e.hasAttribute( "startStyle" ) )            lineStartStyle = (LineAnnotation::TermStyle)e.attribute( "startStyle" ).toInt();        if ( e.hasAttribute( "endStyle" ) )            lineEndStyle = (LineAnnotation::TermStyle)e.attribute( "endStyle" ).toInt();        if ( e.hasAttribute( "closed" ) )            lineClosed = e.attribute( "closed" ).toInt();        if ( e.hasAttribute( "innerColor" ) )            lineInnerColor = QColor( e.attribute( "innerColor" ) );        if ( e.hasAttribute( "leadFwd" ) )            lineLeadingFwdPt = e.attribute( "leadFwd" ).toDouble();        if ( e.hasAttribute( "leadBack" ) )            lineLeadingBackPt = e.attribute( "leadBack" ).toDouble();        if ( e.hasAttribute( "showCaption" ) )            lineShowCaption = e.attribute( "showCaption" ).toInt();        if ( e.hasAttribute( "intent" ) )            lineIntent = (LineAnnotation::LineIntent)e.attribute( "intent" ).toInt();        // parse all 'point' subnodes        QDomNode pointNode = e.firstChild();        while ( pointNode.isElement() )        {            QDomElement pe = pointNode.toElement();            pointNode = pointNode.nextSibling();            if ( pe.tagName() != "point" )                continue;            NormalizedPoint p;            p.x = pe.attribute( "x", "0.0" ).toDouble();            p.y = pe.attribute( "y", "0.0" ).toDouble();            linePoints.append( p );        }        // loading complete        break;    }}void LineAnnotation::store( QDomNode & node, QDomDocument & document ) const{    // recurse to parent objects storing properties    Annotation::store( node, document );    // create [line] element    QDomElement lineElement = document.createElement( "line" );    node.appendChild( lineElement );    // store the attributes    if ( lineStartStyle != None )        lineElement.setAttribute( "startStyle", (int)lineStartStyle );    if ( lineEndStyle != None )        lineElement.setAttribute( "endStyle", (int)lineEndStyle );    if ( lineClosed )        lineElement.setAttribute( "closed", lineClosed );    if ( lineInnerColor.isValid() )        lineElement.setAttribute( "innerColor", lineInnerColor.name() );    if ( lineLeadingFwdPt != 0.0 )        lineElement.setAttribute( "leadFwd", lineLeadingFwdPt );    if ( lineLeadingBackPt != 0.0 )        lineElement.setAttribute( "leadBack", lineLeadingBackPt );    if ( lineShowCaption )        lineElement.setAttribute( "showCaption", lineShowCaption );    if ( lineIntent != Unknown )        lineElement.setAttribute( "intent", lineIntent );    // append the list of points    int points = linePoints.count();    if ( points > 1 )    {        QLinkedList<NormalizedPoint>::const_iterator it = linePoints.begin(), end = linePoints.end();        while ( it != end )        {            const NormalizedPoint & p = *it;            QDomElement pElement = document.createElement( "point" );            lineElement.appendChild( pElement );            pElement.setAttribute( "x", p.x );            pElement.setAttribute( "y", p.y );			it++; //to avoid loop        }    }}/** GeomAnnotation [Annotation] */GeomAnnotation::GeomAnnotation()    : Annotation(), geomType( InscribedSquare ), geomWidthPt( 18 ){}GeomAnnotation::GeomAnnotation( const QDomNode & node )    : Annotation( node ), geomType( InscribedSquare ), geomWidthPt( 18 ){    // loop through the whole children looking for a 'geom' element    QDomNode subNode = node.firstChild();    while( subNode.isElement() )    {        QDomElement e = subNode.toElement();        subNode = subNode.nextSibling();        if ( e.tagName() != "geom" )            continue;        // parse the attributes        if ( e.hasAttribute( "type" ) )            geomType = (GeomAnnotation::GeomType)e.attribute( "type" ).toInt();        if ( e.hasAttribute( "color" ) )            geomInnerColor = QColor( e.attribute( "color" ) );        if ( e.hasAttribute( "width" ) )            geomWidthPt = e.attribute( "width" ).toInt();        // loading complete        break;    }}void GeomAnnotation::store( QDomNode & node, QDomDocument & document ) const{    // recurse to parent objects storing properties    Annotation::store( node, document );    // create [geom] element    QDomElement geomElement = document.createElement( "geom" );    node.appendChild( geomElement );    // append the optional attributes    if ( geomType != InscribedSquare )        geomElement.setAttribute( "type", (int)geomType );    if ( geomInnerColor.isValid() )        geomElement.setAttribute( "color", geomInnerColor.name() );    if ( geomWidthPt != 18 )        geomElement.setAttribute( "width", geomWidthPt );}/** HighlightAnnotation [Annotation] */HighlightAnnotation::HighlightAnnotation()    : Annotation(), highlightType( Highlight ){}HighlightAnnotation::HighlightAnnotation( const QDomNode & node )    : Annotation( node ), highlightType( Highlight ){    // loop through the whole children looking for a 'hl' element    QDomNode subNode = node.firstChild();    while( subNode.isElement() )    {        QDomElement e = subNode.toElement();        subNode = subNode.nextSibling();        if ( e.tagName() != "hl" )            continue;        // parse the attributes        if ( e.hasAttribute( "type" ) )            highlightType = (HighlightAnnotation::HighlightType)e.attribute( "type" ).toInt();        // parse all 'quad' subnodes        QDomNode quadNode = e.firstChild();        for ( ; quadNode.isElement(); quadNode = quadNode.nextSibling() )        {            QDomElement qe = quadNode.toElement();            if ( qe.tagName() != "quad" )                continue;            Quad q;            q.points[0].x = qe.attribute( "ax", "0.0" ).toDouble();            q.points[0].y = qe.attribute( "ay", "0.0" ).toDouble();            q.points[1].x = qe.attribute( "bx", "0.0" ).toDouble();            q.points[1].y = qe.attribute( "by", "0.0" ).toDouble();            q.points[2].x = qe.attribute( "cx", "0.0" ).toDouble();            q.points[2].y = qe.attribute( "cy", "0.0" ).toDouble();            q.points[3].x = qe.attribute( "dx", "0.0" ).toDouble();            q.points[3].y = qe.attribute( "dy", "0.0" ).toDouble();            q.capStart = qe.hasAttribute( "start" );            q.capEnd = qe.hasAttribute( "end" );            q.feather = qe.attribute( "feather", "0.1" ).toDouble();            highlightQuads.append( q );        }        // loading complete        break;    }}void HighlightAnnotation::store( QDomNode & node, QDomDocument & document ) const{    // recurse to parent objects storing properties    Annotation::store( node, document );    // create [hl] element    QDomElement hlElement = document.createElement( "hl" );    node.appendChild( hlElement );    // append the optional attributes    if ( highlightType != Highlight )        hlElement.setAttribute( "type", (int)highlightType );    if ( highlightQuads.count() < 1 )        return;    // append highlight quads, all children describe quads    QList< Quad >::const_iterator it = highlightQuads.begin(), end = highlightQuads.end();    for ( ; it != end; ++it )    {        QDomElement quadElement = document.createElement( "quad" );        hlElement.appendChild( quadElement );        const Quad & q = *it;        quadElement.setAttribute( "ax", q.points[0].x );        quadElement.setAttribute( "ay", q.points[0].y );        quadElement.setAttribute( "bx", q.points[1].x );        quadElement.setAttribute( "by", q.points[1].y );        quadElement.setAttribute( "cx", q.points[2].x );        quadElement.setAttribute( "cy", q.points[2].y );        quadElement.setAttribute( "dx", q.points[3].x );        quadElement.setAttribute( "dy", q.points[3].y );        if ( q.capStart )            quadElement.setAttribute( "start", 1 );        if ( q.capEnd )            quadElement.setAttribute( "end", 1 );        quadElement.setAttribute( "feather", q.feather );    }}/** StampAnnotation [Annotation] */StampAnnotation::StampAnnotation()    : Annotation(), stampIconName( "okular" ){}StampAnnotation::StampAnnotation( const QDomNode & node )    : Annotation( node ), stampIconName( "okular" ){    // loop through the whole children looking for a 'stamp' element    QDomNode subNode = node.firstChild();    while( subNode.isElement() )    {        QDomElement e = subNode.toElement();        subNode = subNode.nextSibling();        if ( e.tagName() != "stamp" )            continue;        // parse the attributes        if ( e.hasAttribute( "icon" ) )            stampIconName = e.attribute( "icon" );        // loading complete        break;    }}void StampAnnotation::store( QDomNode & node, QDomDocument & document ) const{    // recurse to parent objects storing properties    Annotation::store( node, document );    // create [stamp] element    QDomElement stampElement = document.createElement( "stamp" );    node.appendChild( stampElement );    // append the optional attributes    if ( stampIconName != "okular" )        stampElement.setAttribute( "icon", stampIconName );}/** InkAnnotation [Annotation] */InkAnnotation::InkAnnotation()    : Annotation(){}InkAnnotation::InkAnnotation( const QDomNode & node )    : Annotation( node ){    // loop through the whole children looking for a 'ink' element    QDomNode subNode = node.firstChild();    while( subNode.isElement() )    {        QDomElement e = subNode.toElement();        subNode = subNode.nextSibling();        if ( e.tagName() != "ink" )            continue;        // parse the 'path' subnodes        QDomNode pathNode = e.firstChild();        while ( pathNode.isElement() )        {            QDomElement pathElement = pathNode.toElement();            pathNode = pathNode.nextSibling();            if ( pathElement.tagName() != "path" )                continue;            // build each path parsing 'point' subnodes            QLinkedList<NormalizedPoint> path;            QDomNode pointNode = pathElement.firstChild();            while ( pointNode.isElement() )            {                QDomElement pointElement = pointNode.toElement();                pointNode = pointNode.nextSibling();                if ( pointElement.tagName() != "point" )                    continue;                NormalizedPoint p;                p.x = pointElement.attribute( "x", "0.0" ).toDouble();                p.y = pointElement.attribute( "y", "0.0" ).toDouble();                path.append( p );            }            // add the path to the path list if it contains at least 2 nodes            if ( path.count() >= 2 )                inkPaths.append( path );        }        // loading complete        break;    }}void InkAnnotation::store( QDomNode & node, QDomDocument & document ) const{    // recurse to parent objects storing properties    Annotation::store( node, document );    // create [ink] element    QDomElement inkElement = document.createElement( "ink" );    node.appendChild( inkElement );    // append the optional attributes    if ( inkPaths.count() < 1 )        return;    QList< QLinkedList<NormalizedPoint> >::const_iterator pIt = inkPaths.begin(), pEnd = inkPaths.end();    for ( ; pIt != pEnd; ++pIt )    {        QDomElement pathElement = document.createElement( "path" );        inkElement.appendChild( pathElement );        const QLinkedList<NormalizedPoint> & path = *pIt;        QLinkedList<NormalizedPoint>::const_iterator iIt = path.begin(), iEnd = path.end();        for ( ; iIt != iEnd; ++iIt )        {            const NormalizedPoint & point = *iIt;            QDomElement pointElement = document.createElement( "point" );            pathElement.appendChild( pointElement );            pointElement.setAttribute( "x", point.x );            pointElement.setAttribute( "y", point.y );        }    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -