本文整理汇总了C++中TrackedButtonInteractionEvent::getTransform方法的典型用法代码示例。如果您正苦于以下问题:C++ TrackedButtonInteractionEvent::getTransform方法的具体用法?C++ TrackedButtonInteractionEvent::getTransform怎么用?C++ TrackedButtonInteractionEvent::getTransform使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TrackedButtonInteractionEvent
的用法示例。
在下文中一共展示了TrackedButtonInteractionEvent::getTransform方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: processEvent
bool MicrobeBarGraphObject::processEvent(InteractionEvent * ie)
{
if(ie->asTrackedButtonEvent() && ie->asTrackedButtonEvent()->getButton() == 0 && (ie->getInteraction() == BUTTON_DOWN || ie->getInteraction() == BUTTON_DOUBLE_CLICK))
{
TrackedButtonInteractionEvent * tie = (TrackedButtonInteractionEvent*)ie;
GraphLayoutObject * layout = dynamic_cast<GraphLayoutObject*>(_parent);
if(!layout)
{
return false;
}
std::string selectedGroup;
std::vector<std::string> selectedKeys;
osg::Vec3 start, end(0,1000,0);
start = start * tie->getTransform() * getWorldToObjectMatrix();
end = end * tie->getTransform() * getWorldToObjectMatrix();
osg::Vec3 planePoint;
osg::Vec3 planeNormal(0,-1,0);
osg::Vec3 intersect;
float w;
bool clickUsed = false;
bool selectValid = false;
if(linePlaneIntersectionRef(start,end,planePoint,planeNormal,intersect,w))
{
if(_graph->processClick(intersect,selectedKeys,selectValid))
{
clickUsed = true;
}
}
if(selectValid && _microbeCount)
{
if(selectedKeys.size())
{
for(int i = 0; i < _microbeCount; ++i)
{
if(!strcmp(selectedKeys[0].c_str(),_microbeList[i].species))
{
selectedGroup = _microbeList[i].phylum;
break;
}
}
}
layout->selectMicrobes(selectedGroup,selectedKeys);
}
if(clickUsed)
{
return true;
}
}
return TiledWallSceneObject::processEvent(ie);
}
示例2: eventCallback
bool GraphKeyObject::eventCallback(InteractionEvent * ie)
{
TrackedButtonInteractionEvent * tie = ie->asTrackedButtonEvent();
if(tie)
{
if(tie->getButton() == 0 && (tie->getInteraction() == BUTTON_DOWN || tie->getInteraction() == BUTTON_DOUBLE_CLICK))
{
osg::Vec3 point1, point2(0,1000.0,0);
point1 = point1 * tie->getTransform() * getWorldToObjectMatrix();
point2 = point2 * tie->getTransform() * getWorldToObjectMatrix();
osg::Vec3 planePoint, planeNormal(0,-1,0), intersect;
float w;
if(linePlaneIntersectionRef(point1,point2,planePoint,planeNormal,intersect,w))
{
for(int i = 0; i < _rangeList.size(); ++i)
{
if(intersect.x() >= _rangeList[i].first && intersect.x() <= _rangeList[i].second)
{
std::string group = _labels[i];
std::vector<std::string> emptyList;
GraphLayoutObject * layout = dynamic_cast<GraphLayoutObject*>(_parent);
if(layout)
{
layout->selectPatients(group,emptyList);
}
return true;
}
}
}
}
}
return false;
}
示例3: processEvent
//.........这里部分代码省略.........
{
newValue = pow(mrv->getLogBase(),current + change);
newValue = std::min(newValue,mrv->getMax());
}
else
{
newValue = std::min(mrv->getValue() + change,
mrv->getMax());
}
mrv->setValue(newValue);
valueUpdated = true;
}
}
if(valueUpdated)
{
if(mrv->getCallback())
{
mrv->getCallback()->menuCallback(_item);
}
}
_lastMouseY = y;
_lastMouseX = x;
return;
}
}
else if(event->asTrackedButtonEvent())
{
TrackedButtonInteractionEvent * tie = event->asTrackedButtonEvent();
if(event->getInteraction() == BUTTON_DOWN
|| event->getInteraction() == BUTTON_DOUBLE_CLICK)
{
_point = tie->getTransform().getTrans();
osg::Vec3 forward = osg::Vec3(0,1.0,0) * tie->getTransform();
forward = forward - _point;
_normal = forward ^ osg::Vec3(0,0,1.0);
_normal.normalize();
_lastDistance = 0.0;
return;
}
if(event->getInteraction() == BUTTON_DRAG
|| event->getInteraction() == BUTTON_UP)
{
MenuRangeValueCompact * mrv = (MenuRangeValueCompact*)_item;
float min, max, current;
if(mrv->getIsLog())
{
min = log(mrv->getMin()) / log(mrv->getLogBase());
max = log(mrv->getMax()) / log(mrv->getLogBase());
current = log(mrv->getValue()) / log(mrv->getLogBase());
}
else
{
min = mrv->getMin();
max = mrv->getMax();
current = mrv->getValue();
}
osg::Vec3 vec = tie->getTransform().getTrans();
vec = vec - _point;
float newDistance = vec * _normal;
float range = 1000;
示例4: processEvent
bool Sketch::processEvent(InteractionEvent * event)
{
TrackedButtonInteractionEvent * tie = event->asTrackedButtonEvent();
if(!tie)
{
return false;
}
if(tie->getHand() == 0 && tie->getButton() == 0)
{
if(_csCB->getValue())
{
if(_colorSelector->buttonEvent(tie->getInteraction(),
tie->getTransform()))
{
_color = _colorSelector->getColor();
if(_activeObject)
{
_activeObject->setColor(_color);
}
return true;
}
}
osg::Vec3 point(0,Sketch::instance()->getPointerDistance(),0);
point = point * TrackingManager::instance()->getHandMat(0);
osg::Vec3 distance;
if (!_freezeCB->getValue())
{
point = point * PluginHelper::getWorldToObjectTransform();
}
else
{
}
if (_snapToGridCB->getValue())
{
for (int i = 0; i < 3; ++i)
{
int diff = (int)floor(point[i]) % _gridSize;
point[i] -= diff;
}
distance = point - _lastPoint;
distance[0] = (int)distance[0];
distance[1] = (int)distance[1];
distance[2] = (int)distance[2];
}
else
{
distance = point - _lastPoint;
}
_lastPoint = point;
if (_mode == MOVE)
{
if (tie->getInteraction() == BUTTON_DOWN)
{
bool inSphere = false;
for (int i = 0; i < _shapeList.size(); ++i)
{
if (_shapeList[i]->containsPoint(_lastPoint))
{
_movingList.push_back(_shapeList[i]->getPat());
_movingLayout = false;
inSphere = true;
}
}
for (int i = 0; i < _layoutList.size(); ++i)
{
if (_layoutList[i]->shape->containsPoint(_lastPoint))
{
if (!inSphere)
{
_movingLayout = true;
_movingList.push_back(_layoutList[i]->getPat());
for (int j = 0; j < _layoutList[i]->children.size(); ++j)
{
_movingList.push_back(_layoutList[i]->children[j]);
}
}
}
}
return !_movingList.empty();
}
else if (tie->getInteraction() == BUTTON_DRAG)
{
for (int i = 0; i < _movingList.size(); ++i)
{
// remove child shapes that are dragged out of layouts
if (!_movingLayout)
{
//.........这里部分代码省略.........
示例5: processEvent
bool SceneObject::processEvent(InteractionEvent * ie)
{
TrackedButtonInteractionEvent * tie = ie->asTrackedButtonEvent();
if(tie)
{
if(_eventActive && _activeHand != tie->getHand())
{
return false;
}
if(_movable && tie->getButton() == _moveButton)
{
if(tie->getInteraction() == BUTTON_DOWN)
{
_lastHandInv = osg::Matrix::inverse(tie->getTransform());
_lastHandMat = tie->getTransform();
_lastobj2world = getObjectToWorldMatrix();
_eventActive = true;
_moving = true;
_activeHand = tie->getHand();
return true;
}
else if(_moving
&& (tie->getInteraction() == BUTTON_DRAG
|| tie->getInteraction() == BUTTON_UP))
{
processMove(tie->getTransform());
if(tie->getInteraction() == BUTTON_UP)
{
_eventActive = false;
_moving = false;
_activeHand = -2;
}
return true;
}
}
if(_contextMenu && tie->getButton() == _menuButton)
{
if(tie->getInteraction() == BUTTON_DOWN)
{
if(!_myMenu->isVisible())
{
_myMenu->setVisible(true);
osg::Vec3 start(0,0,0), end(0,1000,0);
start = start * tie->getTransform();
end = end * tie->getTransform();
osg::Vec3 p1, p2;
bool n1, n2;
float dist = 0;
if(intersects(start,end,p1,n1,p2,n2))
{
float d1 = (p1 - start).length();
if(n1)
{
d1 = -d1;
}
float d2 = (p2 - start).length();
if(n2)
{
d2 = -d2;
}
if(n1)
{
dist = d2;
}
else if(n2)
{
dist = d1;
}
else
{
if(d1 < d2)
{
dist = d1;
}
else
{
dist = d2;
}
}
}
dist = std::min(dist,
SceneManager::instance()->_menuMaxDistance);
dist = std::max(dist,
SceneManager::instance()->_menuMinDistance);
osg::Vec3 menuPoint(0,dist,0);
menuPoint = menuPoint * tie->getTransform();
osg::Vec3 viewerPoint =
TrackingManager::instance()->getHeadMat(0).getTrans();
osg::Vec3 viewerDir = viewerPoint - menuPoint;
viewerDir.z() = 0.0;
//.........这里部分代码省略.........
示例6: processEvent
bool Sketch::processEvent(InteractionEvent * event)
{
TrackedButtonInteractionEvent * tie = event->asTrackedButtonEvent();
if(!tie)
{
return false;
}
if(tie->getHand() == 0 && tie->getButton() == 0)
{
if(_csCB->getValue())
{
if(_colorSelector->buttonEvent(tie->getInteraction(), tie->getTransform()))
{
_color = _colorSelector->getColor();
if(_activeObject)
{
_activeObject->setColor(_color);
}
return true;
}
}
if(_activeObject)
{
bool ret = _activeObject->buttonEvent(tie->getInteraction(), tie->getTransform());
if(_activeObject->isDone())
{
finishGeometry();
createGeometry();
}
return ret;
}
}
/*if(hand == 0 && button == 0 && type == BUTTON_DOWN && _mode >= 0)
{
//std::cerr << "Start drawing." << std::endl;
if(_mode == RIBBON)
{
_verts = new Vec3Array(0);
_colors = new Vec4Array(1);
_normals = new Vec3Array(0);
_primitive = new DrawArrays(PrimitiveSet::TRIANGLE_STRIP, 0, 0);
_currentGeometry = new osg::Geometry();
(*_colors)[0] = _color;
_currentGeometry->setVertexArray(_verts);
_currentGeometry->setColorArray(_colors);
_currentGeometry->setNormalArray(_normals);
_currentGeometry->setNormalBinding(Geometry::BIND_PER_VERTEX);
_currentGeometry->setColorBinding(Geometry::BIND_OVERALL);
_currentGeometry->setUseDisplayList(false);
//_currentGeometry->setUseVertexBufferObjects(true);
_currentGeometry->addPrimitiveSet(_primitive);
_sketchGeode->addDrawable(_currentGeometry);
MyComputeBounds * mcb = new MyComputeBounds();
_currentBound = &mcb->_bound;
_currentGeometry->setComputeBoundingBoxCallback(mcb);
osg::Vec3 point(-50.0 * _sizeRV->getValue(), _pointerDistance, 0);
point = point * mat * PluginHelper::getWorldToObjectTransform();
_verts->push_back(point);
_normals->push_back(osg::Vec3(0,0,1));
_currentBound->expandBy(point);
point = osg::Vec3(50.0 * _sizeRV->getValue(), _pointerDistance, 0);
point = point * mat * PluginHelper::getWorldToObjectTransform();
_verts->push_back(point);
_normals->push_back(osg::Vec3(0,0,1));
_currentBound->expandBy(point);
_lastTransform = mat * PluginHelper::getWorldToObjectTransform();
_count = 2;
_primitive->setCount(_count);
_currentGeometry->dirtyBound();
_drawing = true;
}
else if(_mode == LINE)
{
if(_lt == LINE_NONE)
{
//std::cerr << "LINE_NONE" << std::endl;
return false;
}
if(!_drawing)
{
//std::cerr << "Starting Line." << std::endl;
_verts = new Vec3Array(0);
_colors = new Vec4Array(1);
_primitive = new DrawArrays(PrimitiveSet::LINE_STRIP, 0, 0);
//.........这里部分代码省略.........
示例7: processEvent
void BoardMenuListGeometry::processEvent(InteractionEvent * event)
{
if(event->getInteraction() == BUTTON_UP)
{
_geodeSelected->removeDrawables(0,_geodeSelected->getNumDrawables());
_geodeSelected->addDrawable(_valuesSelected[_listItem->getFocus()]);
_clicked = false;
_listItem->setDirty(true);
}
if(event->asMouseEvent())
{
MouseInteractionEvent * mie = event->asMouseEvent();
if(event->getInteraction() == BUTTON_DOWN
|| event->getInteraction() == BUTTON_DOUBLE_CLICK)
{
int y = mie->getY();
_lastMouseY = y;
_clicked = true;
_listItem->setDirty(true);
return;
}
if(event->getInteraction() == BUTTON_DRAG
|| event->getInteraction() == BUTTON_UP)
{
int y = mie->getY();
float pixelRange = 400;
bool valueUpdated = false;
int valueMax = _listItem->getListSize();
int index = _listItem->getIndex();
if(y != _lastMouseY)
{
int change = (int)((y - _lastMouseY)
* _listItem->getSensitivity() / pixelRange);
if(change)
{
index -= change;
if(index > valueMax)
index = valueMax;
else if(index < 0)
index = 0;
_listItem->setIndex(index);
valueUpdated = true;
}
}
if(valueUpdated)
{
if(_listItem->getCallback())
{
_listItem->getCallback()->menuCallback(_item);
}
_lastMouseY = y;
}
return;
}
}
else if(event->asTrackedButtonEvent())
{
TrackedButtonInteractionEvent * tie = event->asTrackedButtonEvent();
if(event->getInteraction() == BUTTON_DOWN
|| event->getInteraction() == BUTTON_DOUBLE_CLICK)
{
_point = tie->getTransform().getTrans();
_lastDistance = 0.0;
_clicked = true;
_listItem->setDirty(true);
return;
}
if(event->getInteraction() == BUTTON_DRAG
|| event->getInteraction() == BUTTON_UP)
{
MenuList * _listItem = (MenuList*)_item;
osg::Vec3 vec = tie->getTransform().getTrans();
;
vec = vec - _point;
float newDistance = vec.z();
float range = 400;
bool valueUpdated = false;
int valueMax = _listItem->getListSize();
int index = _listItem->getIndex();
if(newDistance != _lastDistance)
{
int change = (int)((newDistance - _lastDistance)
* _listItem->getSensitivity() / range);
if(change)
{
index -= change;
if(index > valueMax)
//.........这里部分代码省略.........
示例8: processEvent
bool BoardPopupMenu::processEvent(InteractionEvent * event)
{
if(!_menuActive || !_myMenu || !event->asTrackedButtonEvent())
{
return false;
}
TrackedButtonInteractionEvent * tie = event->asTrackedButtonEvent();
if(_clickActive)
{
if(tie->getHand() == _activeHand)
{
if(tie->getInteraction() == BUTTON_DRAG
|| tie->getInteraction() == BUTTON_UP)
{
if(tie->getButton() == _primaryButton)
{
BoardMenuSubMenuGeometry * smg =
dynamic_cast<BoardMenuSubMenuGeometry *>(_activeItem);
if(smg && smg->isMenuHead())
{
updateMovement(tie);
}
_activeItem->processEvent(event);
if(tie->getInteraction() == BUTTON_UP)
{
_clickActive = false;
}
return true;
}
}
}
return false;
}
else if(tie->getHand() == _activeHand && tie->getButton() == _primaryButton)
{
if(tie->getInteraction() == BUTTON_DOWN
|| tie->getInteraction() == BUTTON_DOUBLE_CLICK)
{
if(_activeItem)
{
BoardMenuSubMenuGeometry * smg =
dynamic_cast<BoardMenuSubMenuGeometry *>(_activeItem);
if(smg && smg->isMenuHead())
{
osg::Vec3 ray;
ray = _currentPoint[tie->getHand()]
- tie->getTransform().getTrans();
if(!tie->asPointerEvent())
{
_moveDistance = ray.length();
}
else
{
_moveDistance = ray.y();
}
_menuPoint = _currentPoint[tie->getHand()]
* osg::Matrix::inverse(_menuRoot->getMatrix());
updateMovement(tie);
}
else if(smg && !smg->isMenuHead())
{
if(smg->isMenuOpen())
{
closeMenu((SubMenu*)smg->getMenuItem());
}
else
{
openMenu(smg);
}
}
_clickActive = true;
_activeItem->processEvent(event);
return true;
}
return false;
}
}
return false;
}
示例9: processEvent
bool FPTiledWallSceneObject::processEvent(InteractionEvent * ie)
{
if(!_tiledWallMovement)
{
return SceneObject::processEvent(ie);
}
TrackedButtonInteractionEvent * tie = ie->asTrackedButtonEvent();
if(tie)
{
if(_eventActive && _activeHand != tie->getHand())
{
return false;
}
if(_movable && tie->getButton() == _moveButton)
{
//sort of a hack, need to find a better way to disable navigation for this object type
if(getNavigationOn())
{
setNavigationOn(false);
}
if(tie->getInteraction() == BUTTON_DOWN || (_moving
&& (tie->getInteraction() == BUTTON_DRAG
|| tie->getInteraction() == BUTTON_UP)))
{
if(tie->getInteraction() == BUTTON_DOWN)
{
osg::Vec3 lineP1,lineP2(0,1000.0,0),planePoint,planeNormal(0,-1,0);
float w;
lineP1 = lineP1 * tie->getTransform() * getWorldToObjectMatrix();
lineP2 = lineP2 * tie->getTransform() * getWorldToObjectMatrix();
linePlaneIntersectionRef(lineP1,lineP2,planePoint,planeNormal,_movePoint,w);
_eventActive = true;
_moving = true;
_activeHand = tie->getHand();
return true;
}
if(!_moving)
{
return false;
}
// top level
if(!_parent)
{
osg::Vec3 wallPoint;
if(SceneManager::instance()->getPointOnTiledWall(tie->getTransform(),wallPoint))
{
osg::Vec3 soPoint = _movePoint * getObjectToWorldMatrix();
osg::Matrix m;
m.makeTranslate(wallPoint - soPoint);
setTransform(getTransform() * m);
}
}
else
{
osg::Vec3 lineP1,lineP2(0,1000.0,0),planePoint,planeNormal(0,-1,0),intersect;
float w;
lineP1 = lineP1 * tie->getTransform() * _parent->getWorldToObjectMatrix();
lineP2 = lineP2 * tie->getTransform() * _parent->getWorldToObjectMatrix();
if(linePlaneIntersectionRef(lineP1,lineP2,planePoint,planeNormal,intersect,w))
{
osg::Vec3 soPoint = _movePoint * getTransform();
osg::Matrix m;
m.makeTranslate(intersect - soPoint);
setTransform(getTransform() * m);
}
}
if(tie->getInteraction() == BUTTON_UP)
{
_eventActive = false;
_moving = false;
_activeHand = -2;
}
return true;
}
}
}
return SceneObject::processEvent(ie);
}