Show
Ignore:
Timestamp:
12/16/08 21:29:00 (6 years ago)
Author:
robert
Message:

From Cedric Pinson and Jeremey Moles, Changes to OpenSceneGraph-osgWidget-dev branch.

Notes from Robert Osfield, Merged changes to OpenSceneGraph-osgWidget-dev r9367 (prior to my botched attempt at merged svn/trunk into the branch).

Files:
1 modified

Legend:

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

    r9289 r9370  
    1717 
    1818struct ColorWidget: public osgWidget::Widget { 
    19         ColorWidget(): 
    20         osgWidget::Widget("", 256.0f, 256.0f) { 
    21         } 
     19    ColorWidget(): 
     20    osgWidget::Widget("", 256.0f, 256.0f) { 
     21    } 
    2222 
    23         bool mouseEnter(double, double, osgWidget::WindowManager*) { 
    24                 addColor(-osgWidget::Color(0.4f, 0.4f, 0.4f, 0.0f)); 
    25                  
    26                 // osgWidget::warn() << "enter: " << getColor() << std::endl; 
     23    bool mouseEnter(double, double, osgWidget::WindowManager*) { 
     24        addColor(-osgWidget::Color(0.4f, 0.4f, 0.4f, 0.0f)); 
     25         
     26        // osgWidget::warn() << "enter: " << getColor() << std::endl; 
    2727 
    28                 return true; 
    29         } 
     28        return true; 
     29    } 
    3030 
    31         bool mouseLeave(double, double, osgWidget::WindowManager*) { 
    32                 addColor(osgWidget::Color(0.4f, 0.4f, 0.4f, 0.0f)); 
    33                  
    34                 // osgWidget::warn() << "leave: " << getColor() << std::endl; 
    35                  
    36                 return true; 
    37         } 
     31    bool mouseLeave(double, double, osgWidget::WindowManager*) { 
     32        addColor(osgWidget::Color(0.4f, 0.4f, 0.4f, 0.0f)); 
     33         
     34        // osgWidget::warn() << "leave: " << getColor() << std::endl; 
     35         
     36        return true; 
     37    } 
    3838 
    39         bool mouseOver(double x, double y, osgWidget::WindowManager*) { 
    40                 osgWidget::Color c = getImageColorAtPointerXY(x, y); 
     39    bool mouseOver(double x, double y, osgWidget::WindowManager*) { 
     40        osgWidget::Color c = getImageColorAtPointerXY(x, y); 
    4141 
    42                 if(c.a() < 0.001f) { 
    43                         // osgWidget::warn() << "Transparent Pixel: " << x << " " << y << std::endl; 
     42        if(c.a() < 0.001f) { 
     43            // osgWidget::warn() << "Transparent Pixel: " << x << " " << y << std::endl; 
    4444 
    45                         return false; 
    46                 } 
     45            return false; 
     46        } 
    4747 
    48                 return true; 
    49         } 
     48        return true; 
     49    } 
    5050 
    51         bool keyUp(int key, int keyMask, osgWidget::WindowManager*) { 
    52                 // osgWidget::warn() << "..." << key << " - " << keyMask << std::endl; 
     51    bool keyUp(int key, int keyMask, osgWidget::WindowManager*) { 
     52        // osgWidget::warn() << "..." << key << " - " << keyMask << std::endl; 
    5353 
    54                 return true; 
    55         } 
     54        return true; 
     55    } 
    5656}; 
    5757 
    5858osgWidget::Box* createBox(const std::string& name, osgWidget::Box::BoxType bt) { 
    59         osgWidget::Box*    box     = new osgWidget::Box(name, bt, true); 
    60         osgWidget::Widget* widget1 = new osgWidget::Widget(name + "_widget1", 100.0f, 100.0f); 
    61         osgWidget::Widget* widget2 = new osgWidget::Widget(name + "_widget2", 100.0f, 100.0f); 
    62         osgWidget::Widget* widget3 = new ColorWidget(); 
     59    osgWidget::Box*    box     = new osgWidget::Box(name, bt, true); 
     60    osgWidget::Widget* widget1 = new osgWidget::Widget(name + "_widget1", 100.0f, 100.0f); 
     61    osgWidget::Widget* widget2 = new osgWidget::Widget(name + "_widget2", 100.0f, 100.0f); 
     62    osgWidget::Widget* widget3 = new ColorWidget(); 
    6363 
    64         widget1->setColor(0.3f, 0.3f, 0.3f, 1.0f); 
    65         widget2->setColor(0.6f, 0.6f, 0.6f, 1.0f); 
     64    widget1->setColor(0.3f, 0.3f, 0.3f, 1.0f); 
     65    widget2->setColor(0.6f, 0.6f, 0.6f, 1.0f); 
    6666 
    67         widget3->setImage("osgWidget/natascha.png"); 
    68         widget3->setTexCoord(0.0f, 0.0f, osgWidget::Widget::LOWER_LEFT); 
    69         widget3->setTexCoord(1.0f, 0.0f, osgWidget::Widget::LOWER_RIGHT); 
    70         widget3->setTexCoord(1.0f, 1.0f, osgWidget::Widget::UPPER_RIGHT); 
    71         widget3->setTexCoord(0.0f, 1.0f, osgWidget::Widget::UPPER_LEFT); 
     67    widget3->setImage("osgWidget/natascha.png"); 
     68    widget3->setTexCoord(0.0f, 0.0f, osgWidget::Widget::LOWER_LEFT); 
     69    widget3->setTexCoord(1.0f, 0.0f, osgWidget::Widget::LOWER_RIGHT); 
     70    widget3->setTexCoord(1.0f, 1.0f, osgWidget::Widget::UPPER_RIGHT); 
     71    widget3->setTexCoord(0.0f, 1.0f, osgWidget::Widget::UPPER_LEFT); 
    7272 
    73         box->addWidget(widget1); 
    74         box->addWidget(widget2); 
    75         box->addWidget(widget3); 
     73    box->addWidget(widget1); 
     74    box->addWidget(widget2); 
     75    box->addWidget(widget3); 
    7676 
    77         return box; 
     77    return box; 
    7878} 
    7979 
    8080int main(int argc, char** argv) { 
    81         osgViewer::Viewer viewer; 
     81    osgViewer::Viewer viewer; 
    8282 
    83         osgWidget::WindowManager* wm = new osgWidget::WindowManager( 
    84                 &viewer, 
    85                 1280.0f, 
    86                 1024.0f, 
    87                 MASK_2D, 
    88                 osgWidget::WindowManager::WM_PICK_DEBUG 
    89         ); 
    90          
    91         wm->setPointerFocusMode(osgWidget::WindowManager::PFM_SLOPPY); 
     83    osgWidget::WindowManager* wm = new osgWidget::WindowManager( 
     84        &viewer, 
     85        1280.0f, 
     86        1024.0f, 
     87        MASK_2D, 
     88        osgWidget::WindowManager::WM_PICK_DEBUG 
     89    ); 
     90     
     91    wm->setPointerFocusMode(osgWidget::WindowManager::PFM_SLOPPY); 
    9292 
    93         osgWidget::Window* box1 = createBox("HBOX", osgWidget::Box::HORIZONTAL); 
    94         osgWidget::Window* box2 = createBox("VBOX", osgWidget::Box::VERTICAL); 
    95         osgWidget::Window* box3 = createBox("HBOX2", osgWidget::Box::HORIZONTAL); 
    96         osgWidget::Window* box4 = createBox("VBOX2", osgWidget::Box::VERTICAL); 
     93    osgWidget::Window* box1 = createBox("HBOX", osgWidget::Box::HORIZONTAL); 
     94    osgWidget::Window* box2 = createBox("VBOX", osgWidget::Box::VERTICAL); 
     95    osgWidget::Window* box3 = createBox("HBOX2", osgWidget::Box::HORIZONTAL); 
     96    osgWidget::Window* box4 = createBox("VBOX2", osgWidget::Box::VERTICAL); 
    9797 
    98         box1->getBackground()->setColor(1.0f, 0.0f, 0.0f, 0.8f); 
    99         box1->attachMoveCallback(); 
     98    box1->getBackground()->setColor(1.0f, 0.0f, 0.0f, 0.8f); 
     99    box1->attachMoveCallback(); 
    100100 
    101         box2->getBackground()->setColor(0.0f, 1.0f, 0.0f, 0.8f); 
    102         box2->attachMoveCallback(); 
     101    box2->getBackground()->setColor(0.0f, 1.0f, 0.0f, 0.8f); 
     102    box2->attachMoveCallback(); 
    103103 
    104         box3->getBackground()->setColor(0.0f, 0.0f, 1.0f, 0.8f); 
    105         box3->attachMoveCallback(); 
     104    box3->getBackground()->setColor(0.0f, 0.0f, 1.0f, 0.8f); 
     105    box3->attachMoveCallback(); 
    106106 
    107         wm->addChild(box1); 
    108         wm->addChild(box2); 
    109         wm->addChild(box3); 
    110         wm->addChild(box4); 
     107    wm->addChild(box1); 
     108    wm->addChild(box2); 
     109    wm->addChild(box3); 
     110    wm->addChild(box4); 
    111111 
    112         box4->hide(); 
     112    box4->hide(); 
    113113 
    114         osg::Node* model = osgDB::readNodeFile("spaceship.osg"); 
     114    osg::Node* model = osgDB::readNodeFile("spaceship.osg"); 
    115115 
    116         model->setNodeMask(MASK_3D); 
     116    model->setNodeMask(MASK_3D); 
    117117 
    118         return osgWidget::createExample(viewer, wm, model); 
     118    return osgWidget::createExample(viewer, wm, model); 
    119119}