コード例 #1
0
void BubbleMenuButtonGeometry::updateGeometry()
{
    MenuButton * button = dynamic_cast<MenuButton*>(_item);
    if(!button)
    {
        return;
    }

    if(_geode->getNumDrawables())
    {
        osgText::Text * text = dynamic_cast<osgText::Text*>(_geode->getDrawable(
                0));
        if(text)
        {
            if(text->getText().createUTF8EncodedString() != button->getText())
            {
                text->setText(button->getText());
                osg::BoundingBox bb = text->getBound();
                _width = bb.xMax() - bb.xMin() + _iconHeight + _border;
                text = dynamic_cast<osgText::Text*>(_geodeSelected->getDrawable(
                        0));
                if(text)
                {
                    text->setText(button->getText());
                }
            }
        }

    }
}
コード例 #2
0
void BoardMenuButtonGeometry::createGeometry(MenuItem * item)
{
    _node = new osg::MatrixTransform();
    _geode = new osg::Geode();
    _geodeSelected = new osg::Geode();
    _intersect = new osg::Geode();
    _node->addChild(_intersect);
    _node->addChild(_geode);
    _item = item;

    MenuButton * mb = dynamic_cast<MenuButton*>(item);

    osgText::Text * textNode = makeText(mb->getText(),_textSize,
            osg::Vec3(_iconHeight + _border,-2,-_iconHeight / 2.0),_textColor);
    /*osgText::Text * textNode = new osgText::Text();
     textNode->setCharacterSize(_textSize);
     textNode->setAlignment(osgText::Text::LEFT_CENTER);
     textNode->setPosition(osg::Vec3(_iconHeight + _border, -2, -_iconHeight
     / 2.0));
     textNode->setColor(_textColor);
     textNode->setBackdropColor(osg::Vec4(0, 0, 0, 0));
     textNode->setAxisAlignment(osgText::Text::XZ_PLANE);
     textNode->setText(mb->getText());*/

    osg::BoundingBox bb = textNode->getBound();
    _width = bb.xMax() - bb.xMin() + _iconHeight + _border;
    //mg->height = bb.zMax() - bb.zMin();
    _height = _iconHeight;

    _geode->addDrawable(textNode);

    textNode = makeText(mb->getText(),_textSize,
            osg::Vec3(_iconHeight + _border,-2,-_iconHeight / 2.0),
            _textColorSelected);
    /*textNode = new osgText::Text();
     textNode->setCharacterSize(_textSize);
     textNode->setAlignment(osgText::Text::LEFT_CENTER);
     textNode->setPosition(osg::Vec3(_iconHeight + _border, -2, -_iconHeight
     / 2.0));
     textNode->setColor(_textColorSelected);
     textNode->setBackdropColor(osg::Vec4(0, 0, 0, 0));
     textNode->setAxisAlignment(osgText::Text::XZ_PLANE);
     textNode->setText(mb->getText());*/

    _geodeSelected->addDrawable(textNode);
}
コード例 #3
0
ファイル: TextInputPanel.cpp プロジェクト: CalVR/calvr
void TextInputPanel::menuCallback(MenuItem * item)
{
    if(item == _shiftButton)
    {
	for(int i = 0; i < _colGroups.size(); ++i)
	{
	    for(int j = 0; j < _colGroups[i]->getChildren().size(); ++j)
	    {
		MenuButton * mb = dynamic_cast<MenuButton*>(_colGroups[i]->getChild(j));
		if(mb)
		{
		    if(mb->getText().size() == 1 && isalpha(mb->getText()[0]))
		    {
			std::string temptxt;
			if(isupper(mb->getText()[0]))
			{
			    temptxt = tolower(mb->getText()[0]);
			}
			else
			{
			    temptxt = toupper(mb->getText()[0]);
			}
			mb->setText(temptxt);
		    }
		}
	    }
	}
	return;
    }

    if(item == _spaceButton)
    {
	_text += " ";
	_textItem->setText(_text);
	updateListDisplay();
	return;
    }

    if(item == _backButton)
    {
	if(_text.size())
	{
	    _text.erase(_text.size()-1);
	    _textItem->setText(_text);
	    updateListDisplay();
	}
	return;
    }

    for(int i = 0; i < _searchListButtons.size(); ++i)
    {
	if(item == _searchListButtons[i])
	{
	    _text = _searchListButtons[i]->getText();
	    _textItem->setText(_text);
	    updateListDisplay();
	    return;
	}
    }

    MenuButton * button = dynamic_cast<MenuButton*>(item);
    if(button)
    {
	_text += button->getText();
	_textItem->setText(_text);
	updateListDisplay();
	return;
    }

    PopupMenu::menuCallback(item);
}
コード例 #4
0
void BubbleMenuButtonGeometry::createGeometry(MenuItem * item)
{
    _node = new osg::MatrixTransform();
    _geode = new osg::Geode();
    _geodeSelected = new osg::Geode();
    _intersect = new osg::Geode();
    _node->addChild(_intersect);
    _node->addChild(_geode);
    _item = item;

    MenuButton * mb = dynamic_cast<MenuButton*>(item);

    osg::Vec4 color = osg::Vec4(0,1,0,1);

    // Unselected text
    osgText::Text3D * textNode = make3DText(mb->getText(), _textSize,
            osg::Vec3(0,0,0), _textColor);
    _geode->addDrawable(textNode);

    osg::BoundingBox bb = textNode->getBound();
    _width = bb.xMax() - bb.xMin();
    _height = bb.yMax() - bb.yMin();
    
    textNode->setPosition(osg::Vec3(_radius/2, 0, 0));

    // Selected text
    textNode = make3DText(mb->getText(),_textSize, osg::Vec3(0,0,0),
            _textColorSelected);
    _geodeSelected->addDrawable(textNode);
    textNode->setPosition(osg::Vec3(_radius/2, 0, 0));
       
    // Unselected sphere
    osg::Geometry * sphereGeom = makeSphere(osg::Vec3(_radius/2,0,0),
        _radius, color);
    osg::PolygonMode * polygonMode = new osg::PolygonMode();
    polygonMode->setMode(osg::PolygonMode::FRONT_AND_BACK, osg::PolygonMode::LINE);
    sphereGeom->getOrCreateStateSet()->setAttribute(polygonMode, 
        osg::StateAttribute::ON);
    _geode->addDrawable(sphereGeom);
    
    // Selected sphere
    osg::Geometry * sphereSelectedGeom = makeSphere(osg::Vec3(_radius/2,0,0),
        _radius, color);
    sphereSelectedGeom->getOrCreateStateSet()->setAttribute(polygonMode,
        osg::StateAttribute::ON);
    osg::LineWidth * lineWidth = new osg::LineWidth();
    lineWidth->setWidth(3);
    sphereSelectedGeom->getOrCreateStateSet()->setAttribute(lineWidth, 
        osg::StateAttribute::ON);
    _geodeSelected->addDrawable(sphereSelectedGeom);


    // Hover text
    _textGeode = new osg::Geode();
    osgText::Text * hoverTextNode = makeText(item->getHoverText(), _textSize,
//        osg::Vec3(0,0,_radius), osg::Vec4(1,1,1,1), osgText::Text::LEFT_CENTER);
        osg::Vec3(_radius/2,0,1.5*_radius), osg::Vec4(1,1,1,1), osgText::Text::CENTER_CENTER);

    osg::StateSet * ss = _textGeode->getOrCreateStateSet();
    ss->setMode(GL_BLEND, osg::StateAttribute::ON);
    ss->setMode(GL_DEPTH_TEST, osg::StateAttribute::OFF);
    ss->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
    ss->setRenderBinDetails(11, "Render Bin");

    hoverTextNode->setFont(_font);
    _textGeode->addDrawable(hoverTextNode);
}