Show
Ignore:
Timestamp:
03/21/12 18:36:20 (3 years ago)
Author:
robert
Message:

Ran script to remove trailing spaces and tabs

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • OpenSceneGraph/trunk/src/osgText/Text.cpp

    r13001 r13041  
    1 /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield  
     1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield 
    22 * 
    3  * This library is open source and may be redistributed and/or modified under   
    4  * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or  
     3 * This library is open source and may be redistributed and/or modified under 
     4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
    55 * (at your option) any later version.  The full license is in LICENSE file 
    66 * included with this distribution, and on the openscenegraph.org website. 
    7  *  
     7 * 
    88 * This library is distributed in the hope that it will be useful, 
    99 * but WITHOUT ANY WARRANTY; without even the implied warranty of 
    10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the  
     10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
    1111 * OpenSceneGraph Public License for more details. 
    1212*/ 
     
    107107    { 
    108108        unsigned int charcode = *lastChar; 
    109          
     109 
    110110        if (charcode=='\n') 
    111111        { 
     
    166166                break; 
    167167            } 
    168              
     168 
    169169            // => word boundary detection & wrapping 
    170170            if (outOfSpace) break; 
     
    227227    Font* activefont = getActiveFont(); 
    228228    if (!activefont) return; 
    229      
     229 
    230230    _textureGlyphQuadMap.clear(); 
    231231    _lineCount = 0; 
    232      
    233     if (_text.empty())  
     232 
     233    if (_text.empty()) 
    234234    { 
    235235        _textBB.set(0,0,0,0,0,0);//no size text 
     
    237237        return; 
    238238    } 
    239      
     239 
    240240    //OpenThreads::ScopedLock<Font::FontMutex> lock(*(activefont->getSerializeFontCallsMutex())); 
    241241 
     
    246246    osg::Vec2 cursor(startOfLine_coords); 
    247247    osg::Vec2 local(0.0f,0.0f); 
    248      
     248 
    249249    unsigned int previous_charcode = 0; 
    250250    unsigned int linelength = 0; 
    251251    bool horizontal = _layout!=VERTICAL; 
    252252    bool kerning = true; 
    253      
     253 
    254254    unsigned int lineNumber = 0; 
    255255 
     
    486486            ++itr; 
    487487        } 
    488                                  
    489                  
     488 
     489 
    490490        // move to new line. 
    491491        switch(_layout) 
     
    517517          break; 
    518518        } 
    519          
     519 
    520520        ++lineNumber; 
    521521 
    522522    } 
    523     
     523 
    524524    TextBase::computePositions(); 
    525525    computeBackdropBoundingBox(); 
     
    530530// Returns false if there are no glyphs and the width/height values are invalid. 
    531531// Also sets avg_width and avg_height to 0.0f if the value is invalid. 
    532 // This method is used several times in a loop for the same object which will produce the same values.  
     532// This method is used several times in a loop for the same object which will produce the same values. 
    533533// Further optimization may try saving these values instead of recomputing them. 
    534534bool Text::computeAverageGlyphWidthAndHeight(float& avg_width, float& avg_height) const 
     
    544544    bool is_valid_size = true; 
    545545    // This section is going to try to compute the average width and height 
    546     // for a character among the text. The reason I shift by an  
    547     // average amount per-character instead of shifting each character  
    548     // by its per-instance amount is because it may look strange to see  
    549     // the individual backdrop text letters not space themselves the same  
     546    // for a character among the text. The reason I shift by an 
     547    // average amount per-character instead of shifting each character 
     548    // by its per-instance amount is because it may look strange to see 
     549    // the individual backdrop text letters not space themselves the same 
    550550    // way the foreground text does. Using one value gives uniformity. 
    551551    // Note: This loop is repeated for each context. I think it may produce 
     
    600600    case CENTER_BASE_LINE:  _offset.set((_textBB.xMax()+_textBB.xMin())*0.5f,0.0f,0.0f); break; 
    601601    case RIGHT_BASE_LINE:  _offset.set(_textBB.xMax(),0.0f,0.0f); break; 
    602      
     602 
    603603    case LEFT_BOTTOM_BASE_LINE:  _offset.set(0.0f,-_characterHeight*(1.0 + _lineSpacing)*(_lineCount-1),0.0f); break; 
    604604    case CENTER_BOTTOM_BASE_LINE:  _offset.set((_textBB.xMax()+_textBB.xMin())*0.5f,-_characterHeight*(1.0 + _lineSpacing)*(_lineCount-1),0.0f); break; 
    605605    case RIGHT_BOTTOM_BASE_LINE:  _offset.set(_textBB.xMax(),-_characterHeight*(1.0 + _lineSpacing)*(_lineCount-1),0.0f); break; 
    606606    } 
    607      
     607 
    608608    AutoTransformCache& atc = _autoTransformCache[contextID]; 
    609609    osg::Matrix& matrix = atc._matrix; 
     
    614614        matrix.makeTranslate(-_offset); 
    615615 
    616         osg::Matrix rotate_matrix;  
    617         if (_autoRotateToScreen)  
     616        osg::Matrix rotate_matrix; 
     617        if (_autoRotateToScreen) 
    618618        { 
    619619            osg::Vec3d trans(atc._modelview.getTrans()); 
     
    634634            M.postMult(atc._modelview); 
    635635            osg::Matrix& P = atc._projection; 
    636              
     636 
    637637            // compute the pixel size vector. 
    638                          
     638 
    639639            // pre adjust P00,P20,P23,P33 by multiplying them by the viewport window matrix. 
    640640            // here we do it in short hand with the knowledge of how the window matrix is formed 
     
    687687        } 
    688688 
    689         if (_autoRotateToScreen)  
     689        if (_autoRotateToScreen) 
    690690        { 
    691691            matrix.postMult(rotate_matrix); 
     
    713713        GlyphQuads::Coords2& coords2 = glyphquad._coords; 
    714714        GlyphQuads::Coords3& transformedCoords = glyphquad._transformedCoords[contextID]; 
    715          
     715 
    716716        unsigned int numCoords = coords2.size(); 
    717717        if (numCoords!=transformedCoords.size()) 
     
    719719            transformedCoords.resize(numCoords); 
    720720        } 
    721          
     721 
    722722        for(unsigned int i=0;i<numCoords;++i) 
    723723        { 
     
    731731    _normal.normalize(); 
    732732 
    733     const_cast<Text*>(this)->dirtyBound();     
     733    const_cast<Text*>(this)->dirtyBound(); 
    734734} 
    735735 
     
    746746    unsigned int i; 
    747747    bool is_valid_size; 
    748      
     748 
    749749    AutoTransformCache& atc = _autoTransformCache[contextID]; 
    750750    osg::Matrix& matrix = atc._matrix; 
     
    756756 
    757757    if (!is_valid_size) return; 
    758      
     758 
    759759    // now apply matrix to the glyphs. 
    760760    for(TextureGlyphQuadMap::iterator titr=_textureGlyphQuadMap.begin(); 
     
    832832                            vertical_shift_direction = 1.0f; 
    833833                            break; 
    834                         }                                 
     834                        } 
    835835                    case DROP_SHADOW_BOTTOM_LEFT: 
    836836                        { 
     
    863863} 
    864864 
    865 // This method adjusts the bounding box to account for the expanded area caused by the backdrop.  
     865// This method adjusts the bounding box to account for the expanded area caused by the backdrop. 
    866866// This assumes that the bounding box has already been computed for the text without the backdrop. 
    867867void Text::computeBackdropBoundingBox() const 
     
    875875    float avg_height = 0.0f; 
    876876    bool is_valid_size; 
    877      
     877 
    878878    // FIXME: OPTIMIZE: It is possible that this value has already been computed before 
    879879    // from previous calls to this function. This might be worth optimizing. 
     
    887887        return; 
    888888    } 
    889      
     889 
    890890    // Finally, we have one more issue to deal with. 
    891891    // Now that the text takes more space, we need 
     
    952952                ); 
    953953                break; 
    954             }                                 
     954            } 
    955955        case DROP_SHADOW_BOTTOM_LEFT: 
    956956            { 
     
    10071007} 
    10081008 
    1009 // This method expands the bounding box to a settable margin when a bounding box drawing mode is active.  
     1009// This method expands the bounding box to a settable margin when a bounding box drawing mode is active. 
    10101010void Text::computeBoundingBoxMargin() const 
    10111011{ 
     
    10581058 
    10591059        for(i=0;i<coords2.size();++i) 
    1060         {   
     1060        { 
    10611061            // Min and Max are needed for color gradients 
    10621062            if(coords2[i].x() > max_x) 
     
    10751075            { 
    10761076                min_y = coords2[i].y(); 
    1077             }         
     1077            } 
    10781078 
    10791079        } 
     
    11341134                _colorGradientTopRight[2] 
    11351135            ); 
    1136             // Alpha does not convert to HSV             
     1136            // Alpha does not convert to HSV 
    11371137            float alpha = bilinearInterpolate( 
    11381138                min_x, 
     
    11461146                _colorGradientBottomRight[3], 
    11471147                _colorGradientTopRight[3] 
    1148             );                                     
     1148            ); 
    11491149 
    11501150            colorCoords[i] = osg::Vec4(red,green,blue,alpha); 
     
    12511251            } 
    12521252        } 
    1253          
     1253 
    12541254        atc._traversalNumber = frameNumber; 
    12551255        atc._width = width; 
    12561256        atc._height = height; 
    1257          
     1257 
    12581258        if (doUpdate) 
    1259         {     
     1259        { 
    12601260            atc._transformedPosition = newTransformedPosition; 
    12611261            atc._projection = projection; 
     
    12641264            computePositions(contextID); 
    12651265        } 
    1266          
    1267     } 
    1268      
    1269      
     1266 
     1267    } 
     1268 
     1269 
    12701270    // Ensure that the glyph coordinates have been transformed for 
    12711271    // this context id. 
     
    13451345        #endif 
    13461346        } 
    1347     }     
     1347    } 
    13481348 
    13491349#if defined(OSG_GL_FIXED_FUNCTION_AVAILABLE) 
     
    14021402            osg::Vec3 c01(osg::Vec3(_textBB.xMin(),_textBB.yMax(),_textBB.zMin())*matrix); 
    14031403 
    1404          
     1404 
    14051405            gl.Color4f(colorMultiplier.r()*_textBBColor.r(),colorMultiplier.g()*_textBBColor.g(),colorMultiplier.b()*_textBBColor.b(),colorMultiplier.a()*_textBBColor.a()); 
    14061406            gl.Begin(GL_LINE_LOOP); 
     
    14271427 
    14281428        state.applyTextureMode(0,GL_TEXTURE_2D,osg::StateAttribute::OFF); 
    1429          
     1429 
    14301430        gl.Begin(GL_LINES); 
    14311431            gl.Vertex3fv(hl.ptr()); 
     
    14341434            gl.Vertex3fv(vb.ptr()); 
    14351435        gl.End(); 
    1436          
    1437     }     
     1436 
     1437    } 
    14381438} 
    14391439 
     
    14601460        pf.setVertexArray(glyphquad._transformedCoords[0].size(),&(glyphquad._transformedCoords[0].front())); 
    14611461        pf.drawArrays(GL_QUADS,0,glyphquad._transformedCoords[0].size()); 
    1462              
    1463     } 
    1464      
     1462 
     1463    } 
     1464 
    14651465} 
    14661466 
     
    14761476{ 
    14771477    TextBase::resizeGLObjectBuffers(maxSize); 
    1478      
     1478 
    14791479    getActiveFont()->resizeGLObjectBuffers(maxSize); 
    14801480} 
     
    15571557 
    15581558    const GlyphQuads::Coords3& transformedCoords = glyphquad._transformedCoords[contextID]; 
    1559     if (!transformedCoords.empty())  
     1559    if (!transformedCoords.empty()) 
    15601560    { 
    15611561        state.setVertexPointer( 3, GL_FLOAT, 0, &(transformedCoords.front())); 
     
    16551655            { 
    16561656                const GlyphQuads::Coords3& transformedBackdropCoords = glyphquad._transformedBackdropCoords[backdrop_index][contextID]; 
    1657                 if (!transformedBackdropCoords.empty())  
     1657                if (!transformedBackdropCoords.empty()) 
    16581658                { 
    16591659                    state.setVertexPointer( 3, GL_FLOAT, 0, &(transformedBackdropCoords.front())); 
     
    17111711        { 
    17121712            const GlyphQuads::Coords3& transformedBackdropCoords = glyphquad._transformedBackdropCoords[backdrop_index][contextID]; 
    1713             if (!transformedBackdropCoords.empty())  
     1713            if (!transformedBackdropCoords.empty()) 
    17141714            { 
    17151715                state.setVertexPointer( 3, GL_FLOAT, 0, &(transformedBackdropCoords.front())); 
     
    17311731#endif 
    17321732} 
    1733      
     1733 
    17341734 
    17351735void Text::renderWithNoDepthBuffer(osg::State& state, const osg::Vec4& colorMultiplier) const 
     
    17701770        { 
    17711771            const GlyphQuads::Coords3& transformedBackdropCoords = glyphquad._transformedBackdropCoords[backdrop_index][contextID]; 
    1772             if (!transformedBackdropCoords.empty())  
     1772            if (!transformedBackdropCoords.empty()) 
    17731773            { 
    17741774                state.setVertexPointer( 3, GL_FLOAT, 0, &(transformedBackdropCoords.front())); 
     
    18261826        { 
    18271827            const GlyphQuads::Coords3& transformedBackdropCoords = glyphquad._transformedBackdropCoords[backdrop_index][contextID]; 
    1828             if (!transformedBackdropCoords.empty())  
     1828            if (!transformedBackdropCoords.empty()) 
    18291829            { 
    18301830                state.setVertexPointer( 3, GL_FLOAT, 0, &(transformedBackdropCoords.front())); 
     
    18651865    unsigned int contextID = state.getContextID(); 
    18661866    TextureGlyphQuadMap::iterator titr; // Moved up here for VC6 
    1867      
     1867 
    18681868    glPushAttrib(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT | GL_STENCIL_TEST); 
    18691869 
     
    18801880    glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE); 
    18811881 
    1882     // Disable writing to the color buffer so we only write to the stencil  
     1882    // Disable writing to the color buffer so we only write to the stencil 
    18831883    // buffer and the depth buffer 
    18841884    glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); 
     
    18911891    // Arrrgh! Why does the code only seem to work correctly if I call this? 
    18921892    glDepthMask(GL_FALSE); 
    1893      
     1893 
    18941894 
    18951895    // Draw all the text to the stencil buffer to mark out the region 
    18961896    // that we can write too. 
    1897      
     1897 
    18981898    for(titr=_textureGlyphQuadMap.begin(); 
    18991899        titr!=_textureGlyphQuadMap.end(); 
     
    19241924        { 
    19251925            const GlyphQuads::Coords3& transformedBackdropCoords = glyphquad._transformedBackdropCoords[backdrop_index][contextID]; 
    1926             if (!transformedBackdropCoords.empty())  
     1926            if (!transformedBackdropCoords.empty()) 
    19271927            { 
    19281928                state.setVertexPointer( 3, GL_FLOAT, 0, &(transformedBackdropCoords.front())); 
     
    19331933        // Draw the foreground text 
    19341934        const GlyphQuads::Coords3& transformedCoords = glyphquad._transformedCoords[contextID]; 
    1935         if (!transformedCoords.empty())  
     1935        if (!transformedCoords.empty()) 
    19361936        { 
    19371937            state.setVertexPointer( 3, GL_FLOAT, 0, &(transformedCoords.front())); 
     
    19921992        { 
    19931993            const GlyphQuads::Coords3& transformedBackdropCoords = glyphquad._transformedBackdropCoords[backdrop_index][contextID]; 
    1994             if (!transformedBackdropCoords.empty())  
     1994            if (!transformedBackdropCoords.empty()) 
    19951995            { 
    19961996                state.setVertexPointer( 3, GL_FLOAT, 0, &(transformedBackdropCoords.front()));