Show
Ignore:
Timestamp:
10/20/03 11:01:16 (11 years ago)
Author:
robert
Message:

Fixed print on scalar bar example.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • OpenSceneGraph/trunk/examples/osgscalarbar/osgscalarbar.cpp

    r2213 r2390  
    2828osg::Node* createScalarBar() 
    2929{ 
    30 //     ScalarsToColors* stc = new ScalarsToColors(0.0f,1.0f); 
    31 //      ScalarBar* sb = new ScalarBar(2,3,stc); 
    32 // 
    33 //     // Create a custom color set 
    34 //     std::vector<osg::Vec4> cs; 
    35 //     cs.push_back(osg::Vec4(1.0f,0.0f,0.0f,1.0f));   // R 
    36 //     cs.push_back(osg::Vec4(0.0f,0.0f,1.0f,1.0f));   // B 
    37 // 
    38 //      // Create a custom scalar printer 
    39 //     struct MyScalarPrinter: public ScalarBar::ScalarPrinter 
    40 //      { 
    41 //         std::string printScalar(float scalar) 
    42 //              { 
    43 //                  std::cout<<"In MyScalarPrinter::printScalar"<<std::endl; 
    44 //             if(scalar==0.0f) return "Hello"; 
    45 //                      else if(scalar==1.0f) return "Goodbye"; 
    46 //                      else return ScalarBar::ScalarPrinter::printScalar(scalar); 
    47 //              } 
    48 //      }; 
    49 // 
    50 //     ColorRange* stc = new ColorRange(0.0f,1.0f,cs); 
    51 //      //ScalarBar* sb = new ScalarBar(2, 2, stc, "ScalarBar", ScalarBar::HORIZONTAL, 0.25f, new MyScalarPrinter); 
    52 //      ScalarBar* sb = new ScalarBar(2, 2, stc, "ScalarBar", ScalarBar::VERTICAL, 4.0f, new MyScalarPrinter); 
    53 //      sb->setScalarPrinter(new MyScalarPrinter); 
    54 // 
    55 //      return sb; 
     30#if 1 
     31    //ScalarsToColors* stc = new ScalarsToColors(0.0f,1.0f); 
     32    //ScalarBar* sb = new ScalarBar(2,3,stc,"STC_ScalarBar"); 
    5633 
     34    // Create a custom color set 
     35    std::vector<osg::Vec4> cs; 
     36    cs.push_back(osg::Vec4(1.0f,0.0f,0.0f,1.0f));   // R 
     37    cs.push_back(osg::Vec4(0.0f,1.0f,0.0f,1.0f));   // G 
     38    cs.push_back(osg::Vec4(1.0f,1.0f,0.0f,1.0f));   // G 
     39    cs.push_back(osg::Vec4(0.0f,0.0f,1.0f,1.0f));   // B 
     40    cs.push_back(osg::Vec4(0.0f,1.0f,1.0f,1.0f));   // R 
     41 
     42    // Create a custom scalar printer 
     43    struct MyScalarPrinter: public ScalarBar::ScalarPrinter 
     44    { 
     45        std::string printScalar(float scalar) 
     46        { 
     47            std::cout<<"In MyScalarPrinter::printScalar"<<std::endl; 
     48            if(scalar==0.0f) return ScalarBar::ScalarPrinter::printScalar(scalar)+" Bottom"; 
     49            else if(scalar==0.5f) return ScalarBar::ScalarPrinter::printScalar(scalar)+" Middle"; 
     50            else if(scalar==1.0f) return ScalarBar::ScalarPrinter::printScalar(scalar)+" Top"; 
     51            else return ScalarBar::ScalarPrinter::printScalar(scalar); 
     52        } 
     53    }; 
     54 
     55    ColorRange* cr = new ColorRange(0.0f,1.0f,cs); 
     56    ScalarBar* sb = new ScalarBar(20, 11, cr, "ScalarBar", ScalarBar::VERTICAL, 4.0f, new MyScalarPrinter); 
     57    sb->setScalarPrinter(new MyScalarPrinter); 
     58 
     59    return sb; 
     60#else 
    5761    ScalarBar *sb = new ScalarBar; 
    5862    ScalarBar::TextProperties tp; 
    59         tp._fontFile = "fonts/times.ttf"; 
     63    tp._fontFile = "fonts/times.ttf"; 
    6064 
    61         sb->setTextProperties(tp); 
     65    sb->setTextProperties(tp); 
    6266 
    6367    return sb; 
     68#endif 
    6469 
    6570}