}
-osg::Vec2d eventToWindowCoords(const osgGA::GUIEventAdapter* ea)
+osg::Vec2d eventToWindowCoords(const osgGA::GUIEventAdapter& ea)
{
using namespace osg;
- const GraphicsContext* gc = ea->getGraphicsContext();
+ const GraphicsContext* gc = ea.getGraphicsContext();
const GraphicsContext::Traits* traits = gc->getTraits() ;
// Scale x, y to the dimensions of the window
- double x = (((ea->getX() - ea->getXmin()) / (ea->getXmax() - ea->getXmin()))
+ double x = (((ea.getX() - ea.getXmin()) / (ea.getXmax() - ea.getXmin()))
* (double)traits->width);
- double y = (((ea->getY() - ea->getYmin()) / (ea->getYmax() - ea->getYmin()))
+ double y = (((ea.getY() - ea.getYmin()) / (ea.getYmax() - ea.getYmin()))
* (double)traits->height);
- if (ea->getMouseYOrientation() == osgGA::GUIEventAdapter::Y_INCREASING_DOWNWARDS)
+ if (ea.getMouseYOrientation() == osgGA::GUIEventAdapter::Y_INCREASING_DOWNWARDS)
y = (double)traits->height - y;
return osg::Vec2d(x, y);
_hover = readBindingList(hoverNode->getChildren("binding"), modelRoot);
}
- virtual bool buttonPressed(int button, const osgGA::GUIEventAdapter* ea, const Info&)
+ virtual bool buttonPressed( int button,
+ const osgGA::GUIEventAdapter&,
+ const Info& )
{
if (_buttons.find(button) == _buttons.end()) {
return false;
_repeatTime = -_repeatInterval; // anti-bobble: delay start of repeat
return true;
}
- virtual void buttonReleased(int keyModState)
+ virtual void buttonReleased( int keyModState,
+ const osgGA::GUIEventAdapter&,
+ const Info* )
{
SG_UNUSED(keyModState);
fireBindingList(_bindingsUp);
}
}
- virtual bool hover(const osg::Vec2d& windowPos, const Info& info)
+ virtual bool hover( const osg::Vec2d& windowPos,
+ const Info& )
{
if (_hover.empty()) {
return false;
_squaredDown = dot(_toDown, _toDown);
}
- virtual bool buttonPressed(int button, const osgGA::GUIEventAdapter* ea, const Info& info)
+ virtual bool buttonPressed( int button,
+ const osgGA::GUIEventAdapter&,
+ const Info& info )
{
SGVec3d loc(info.local);
SG_LOG(SG_INPUT, SG_DEBUG, "VNC pressed " << button << ": " << loc);
return vv.wasSuccessful();
}
- virtual void buttonReleased(int keyModState)
+ virtual void buttonReleased( int keyModState,
+ const osgGA::GUIEventAdapter&,
+ const Info* )
{
SG_UNUSED(keyModState);
SG_LOG(SG_INPUT, SG_DEBUG, "VNC release");
void
SGPickAnimation::apply(osg::Group& group)
{
- if (_objectNames.empty()) {
+ if (_objectNames.empty() && _proxyNames.empty()) {
return;
}
- osg::ref_ptr<osg::Group> renderGroup, proxyGroup, pickGroup;
group.traverse(*this);
- SGSceneUserData* ud = NULL;
// iterate over all group children
int i = group.getNumChildren() - 1;
std::list<std::string>::iterator it = std::find(_objectNames.begin(), _objectNames.end(), child->getName());
if (it != _objectNames.end()) {
- _objectNames.erase(it);
+ //_objectNames.erase(it);
install(*child);
-//////
- if (!pickGroup) {
- osg::Group* mainGroup = createMainGroup(&group);
- mainGroup->setName(child->getName());
-
- if (getConfig()->getBoolValue("visible", true)) {
- renderGroup = new osg::Group;
- renderGroup->setName("pick render group");
- mainGroup->addChild(renderGroup);
- }
-
- pickGroup = new osg::Group;
- pickGroup->setName("pick highlight group");
- pickGroup->setNodeMask(simgear::PICK_BIT);
- pickGroup->setStateSet(sharedHighlightStateSet());
- mainGroup->addChild(pickGroup);
-
- if (!ud) {
- ud = SGSceneUserData::getOrCreateSceneUserData(pickGroup);
- setupCallbacks(ud, &group);
- } else {
- pickGroup->setUserData(ud);
- }
- } // of pick group setup
+ osg::ref_ptr<osg::Group> renderGroup, pickGroup;
+ osg::Group* mainGroup = createMainGroup(&group);
+ mainGroup->setName(child->getName());
+ child->setName(""); // don't apply other animations twice
-////////
- child->setName("");
- if (renderGroup.valid()) {
- renderGroup->addChild(child);
+ if (getConfig()->getBoolValue("visible", true)) {
+ renderGroup = new osg::Group;
+ renderGroup->setName("pick render group");
+ renderGroup->addChild(child);
+ mainGroup->addChild(renderGroup);
}
+ pickGroup = new osg::Group;
+ pickGroup->setName("pick highlight group");
+ pickGroup->setNodeMask(simgear::PICK_BIT);
+ pickGroup->setStateSet(sharedHighlightStateSet());
+ mainGroup->addChild(pickGroup);
+
+ setupCallbacks(SGSceneUserData::getOrCreateSceneUserData(mainGroup), mainGroup);
+
pickGroup->addChild(child);
group.removeChild(child);
continue;
}
_proxyNames.erase(j);
- if (!proxyGroup) {
- proxyGroup = new osg::Group;
- group.addChild(proxyGroup);
- proxyGroup->setStateSet(sharedHighlightStateSet());
- proxyGroup->setNodeMask(simgear::PICK_BIT);
+ osg::ref_ptr<osg::Group> proxyGroup = new osg::Group;
+ group.addChild(proxyGroup);
+ proxyGroup->setStateSet(sharedHighlightStateSet());
+ proxyGroup->setNodeMask(simgear::PICK_BIT);
- if (!ud) {
- ud = SGSceneUserData::getOrCreateSceneUserData(proxyGroup);
- setupCallbacks(ud, &group);
- } else {
- proxyGroup->setUserData(ud);
- }
- } // of proxy group setup
-
+ setupCallbacks(SGSceneUserData::getOrCreateSceneUserData(proxyGroup), proxyGroup);
proxyGroup->addChild(child);
group.removeChild(child);
} // of group children iteration
}
}
- virtual bool buttonPressed(int button, const osgGA::GUIEventAdapter* ea, const Info&)
+ virtual bool buttonPressed( int button,
+ const osgGA::GUIEventAdapter& ea,
+ const Info& )
{
// the 'be nice to Mac / laptop' users option; alt-clicking spins the
// opposite direction. Should make this configurable
- if ((button == 0) && (ea->getModKeyMask() & osgGA::GUIEventAdapter::MODKEY_ALT)) {
+ if ((button == 0) && (ea.getModKeyMask() & osgGA::GUIEventAdapter::MODKEY_ALT)) {
button = 1;
}
return true;
}
- virtual void buttonReleased(int keyModState)
+ virtual void buttonReleased( int keyModState,
+ const osgGA::GUIEventAdapter&,
+ const Info* )
{
// for *clicks*, we only fire on button release
if (!_hasDragged) {
return _dragDirection;
}
- virtual void mouseMoved(const osgGA::GUIEventAdapter* ea)
+ virtual void mouseMoved( const osgGA::GUIEventAdapter& ea,
+ const Info* )
{
_mousePos = eventToWindowCoords(ea);
osg::Vec2d deltaMouse = _mousePos - _lastFirePos;
if (fabs(delta) >= 1.0) {
// determine direction from sign of delta
Direction dir = (delta > 0.0) ? DIRECTION_INCREASE : DIRECTION_DECREASE;
- fire(ea->getModKeyMask() & osgGA::GUIEventAdapter::MODKEY_SHIFT, dir);
+ fire(ea.getModKeyMask() & osgGA::GUIEventAdapter::MODKEY_SHIFT, dir);
_lastFirePos = _mousePos;
}
}
} // of repeat iteration
}
- virtual bool hover(const osg::Vec2d& windowPos, const Info& info)
+ virtual bool hover( const osg::Vec2d& windowPos,
+ const Info& )
{
if (_hover.empty()) {
return false;
_animationValue = value->simplify();
- readRotationCenterAndAxis(configNode, _center, _axis);
+ readRotationCenterAndAxis(_center, _axis);
}
osg::Group*