本文整理汇总了C++中osgga::GUIEventAdapter::getModKeyMask方法的典型用法代码示例。如果您正苦于以下问题:C++ GUIEventAdapter::getModKeyMask方法的具体用法?C++ GUIEventAdapter::getModKeyMask怎么用?C++ GUIEventAdapter::getModKeyMask使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类osgga::GUIEventAdapter
的用法示例。
在下文中一共展示了GUIEventAdapter::getModKeyMask方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: handle
bool QueryCoordinatesHandler::handle( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa )
{
if ( ea.getEventType() == osgGA::GUIEventAdapter::MOVE )
{
osgViewer::View* view = static_cast<osgViewer::View*>( aa.asView() );
osg::Vec3d coords = getCoords( ea.getX(), ea.getY(), view, false );
mGlobe->showCurrentCoordinates( coords.x(), coords.y() );
}
if ( ea.getEventType() == osgGA::GUIEventAdapter::PUSH
&& ea.getButtonMask() == osgGA::GUIEventAdapter::RIGHT_MOUSE_BUTTON )
{
osgViewer::View* view = static_cast<osgViewer::View*>( aa.asView() );
osg::Vec3d coords = getCoords( ea.getX(), ea.getY(), view, false );
OE_NOTICE << "SelectedCoordinates set to:\nLon: " << coords.x() << " Lat: " << coords.y()
<< " Ele: " << coords.z() << std::endl;
mGlobe->setSelectedCoordinates( coords );
if ( ea.getModKeyMask() == osgGA::GUIEventAdapter::MODKEY_CTRL )
//ctrl + rightclick pops up a QMessageBox
{
mGlobe->showSelectedCoordinates();
}
}
return false;
}
示例2: handle
virtual bool handle( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa )
{
if ( ea.getEventType()!=osgGA::GUIEventAdapter::RELEASE ||
ea.getButton()!=osgGA::GUIEventAdapter::LEFT_MOUSE_BUTTON ||
!(ea.getModKeyMask()&osgGA::GUIEventAdapter::MODKEY_CTRL) )
return false;
osgViewer::Viewer* viewer = dynamic_cast<osgViewer::Viewer*>(&aa);
if ( viewer )
{
osg::ref_ptr<osgUtil::LineSegmentIntersector> intersector =
new osgUtil::LineSegmentIntersector(osgUtil::Intersector::WINDOW, ea.getX(), ea.getY());
osgUtil::IntersectionVisitor iv( intersector.get() );
iv.setTraversalMask( ~DO_NOT_PICK_NODE_MASK );
viewer->getCamera()->accept( iv );
if ( intersector->containsIntersections() )
{
const osgUtil::LineSegmentIntersector::Intersection& result =
*(intersector->getIntersections().begin());
osg::BoundingBox bb = result.drawable->getBound();
osg::Vec3 worldCenter = bb.center() * osg::computeLocalToWorld(result.nodePath);
_selectionBox->setMatrix(
osg::Matrix::scale(bb.xMax()-bb.xMin(), bb.yMax()-bb.yMin(), bb.zMax()-bb.zMin()) *
osg::Matrix::translate(worldCenter) );
}
}
return false;
}
示例3: handle
virtual bool handle( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa )
{
osgViewer::View* view = dynamic_cast<osgViewer::View*>( &aa );
if ( ea.getEventType()==osgGA::GUIEventAdapter::FRAME )
{
double time = ea.getTime();
_recast->update( time - _lastSimulationTime );
_lastSimulationTime = time;
}
else if ( ea.getEventType()==osgGA::GUIEventAdapter::RELEASE ||
ea.getEventType()==osgGA::GUIEventAdapter::DOUBLECLICK )
{
osgUtil::LineSegmentIntersector::Intersections intersections;
if ( view->computeIntersections(ea.getX(), ea.getY(), intersections) )
{
const osgUtil::LineSegmentIntersector::Intersection& result = *(intersections.begin());
osg::Vec3 pt = result.getWorldIntersectPoint();
if ( ea.getModKeyMask()&osgGA::GUIEventAdapter::MODKEY_CTRL )
{
osg::ref_ptr<osg::MatrixTransform> agent = new osg::MatrixTransform;
agent->setMatrix( osg::Matrix::translate(pt) );
agent->addChild( _agentShape.get() );
_scene->addChild( agent.get() );
_recast->addAgent( pt, agent.get() );
}
else if ( ea.getEventType()==osgGA::GUIEventAdapter::DOUBLECLICK )
_recast->moveTo( pt );
}
}
return false;
}
示例4: handle
virtual bool handle( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa )
{
if( ( ea.getModKeyMask() & osgGA::GUIEventAdapter::MODKEY_CTRL ) == 0 )
{
return( false );
}
else if( ea.getEventType() == osgGA::GUIEventAdapter::PUSH )
{
_lastX = ea.getXnormalized();
_lastY = ea.getYnormalized();
return( true );
}
else if( ea.getEventType() == osgGA::GUIEventAdapter::DRAG )
{
double deltaX = ea.getXnormalized() - _lastX;
double deltaY = ea.getYnormalized() - _lastY;
_lastX = ea.getXnormalized();
_lastY = ea.getYnormalized();
deltaX *= 6.;
deltaY *= 6.;
osg::Matrix trans = osgbCollision::asOsgMatrix( _co->getWorldTransform() );
trans = trans * osg::Matrix::translate( deltaX, 0., deltaY );
_mt->setMatrix( trans );
_co->setWorldTransform( osgbCollision::asBtTransform( trans ) );
return( true );
}
return( false );
}
示例5: handle
bool Handler::handle(const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &aa, osg::Object *object, osg::NodeVisitor *visitor) {
osg::Vec2 pos(ea.getX(), ea.getY());
switch (ea.getModKeyMask()) {
case osgGA::GUIEventAdapter::ModKeyMask::MODKEY_SHIFT:
this->m_indicator->setFillColor(osg::Vec4(0.0f, 0.0f, 1.0f, 0.2f));
this->m_indicator->setBorderColor(osg::Vec4(0.0f, 0.0f, 1.0f, 1.0f));
break;
case osgGA::GUIEventAdapter::ModKeyMask::MODKEY_ALT:
this->m_indicator->setFillColor(osg::Vec4(1.0f, 0.0f, 0.0f, 0.2f));
this->m_indicator->setBorderColor(osg::Vec4(1.0f, 0.0f, 0.0f, 1.0f));
break;
default:
return (false);
}
switch (ea.getEventType()) {
case osgGA::GUIEventAdapter::EventType::PUSH:
this->m_beginPos = pos;
this->m_lastPos = pos;
this->m_start = pos;
this->m_stop = pos;
this->m_indicator->setGeometry(this->m_start, this->m_stop - this->m_start);
break;
case osgGA::GUIEventAdapter::EventType::RELEASE:
this->m_lastPos = pos;
this->m_selector->operator ()(this->m_start, this->m_stop, ea.getModKeyMask() == osgGA::GUIEventAdapter::ModKeyMask::MODKEY_SHIFT);
this->m_indicator->setGeometry(osg::Vec2(0.0f, 0.0f), osg::Vec2(0.0f, 0.0f));
break;
case osgGA::GUIEventAdapter::EventType::DRAG:
this->m_lastPos = pos;
this->m_start = osg::Vec2(
std::min<float>(this->m_beginPos.x(), this->m_lastPos.x()),
std::min<float>(this->m_beginPos.y(), this->m_lastPos.y()));
this->m_stop = osg::Vec2(
std::max<float>(this->m_beginPos.x(), this->m_lastPos.x()),
std::max<float>(this->m_beginPos.y(), this->m_lastPos.y()));
this->m_indicator->setGeometry(this->m_start, this->m_stop - this->m_start);
break;
default:
return (false);
}
return (true);
}
示例6: handle
bool handle( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa )
{
if ( ea.getHandled() ) return false;
if ( ea.getEventType() == osgGA::GUIEventAdapter::PUSH &&
ea.getButtonMask() == osgGA::GUIEventAdapter::LEFT_MOUSE_BUTTON &&
(ea.getModKeyMask() & osgGA::GUIEventAdapter::MODKEY_CTRL) != 0 &&
terrain_srs.valid() &&
layer.valid() )
{
osgViewer::View* view = dynamic_cast<osgViewer::View*>( &aa );
if ( !view ) return false;
osgUtil::LineSegmentIntersector::Intersections hits;
if ( view->computeIntersections( ea.getX(), ea.getY(), hits ) )
{
osgUtil::LineSegmentIntersector::Intersection first = *hits.begin();
osg::Vec3d hit = first.getWorldIntersectPoint() - first.getWorldIntersectNormal()*0.2;
osgGIS::GeoPoint world( hit, terrain_srs.get() );
osgGIS::GeoPoint result = terrain_srs->getGeographicSRS()->transform( world );
osgGIS::FeatureCursor cursor = layer->getCursor( result );
highlight( cursor );
std::stringstream buf;
buf << "World: " << world.toString() << std::endl
<< "Geo: " << result.toString() << std::endl
<< "SRS: " << terrain_srs->getName() << std::endl;
int line_count = 2;
for( cursor.reset(); cursor.hasNext(); )
{
osgGIS::Feature* f = cursor.next();
osgGIS::AttributeList attrs = f->getAttributes();
for( osgGIS::AttributeList::const_iterator i = attrs.begin(); i != attrs.end(); i++ )
{
std::string key = i->getKey();
if ( key.length() > 0 )
{
buf << key << " : " << i->asString() << std::endl;
line_count++;
}
}
break;
}
if ( buf.str().length() == 0 )
{
buf << "Control-Left-Click to query";
line_count++;
}
hud_text->setText( buf.str() );
hud_text->setPosition( osg::Vec3( 10, line_count*TEXT_SIZE*1.1f, 0 ) );
hud_text->dirtyDisplayList();
}
}
return false; // never "handled"
}
示例7: handle
bool QOsgEventHandler::handle(
const osgGA::GUIEventAdapter &ea
, osgGA::GUIActionAdapter &)
{
if(ea.getEventType() == osgGA::GUIEventAdapter::FRAME
|| ea.getEventType() == osgGA::GUIEventAdapter::MOVE)
return false;
switch(ea.getEventType())
{
case(osgGA::GUIEventAdapter::KEYDOWN):
{
if(ea.getKey() == '-'
|| ea.getKey() == '+')
{
const float f = 1.00f
+ (ea.getKey() == '+' ? +0.004f : -0.004f);
if(m_fov * f >= 1.f && m_fov * f <= 179.f)
m_fov *= f;
emit fovChanged(m_fov);
}
}
break;
case(osgGA::GUIEventAdapter::SCROLL):
{
const float f = 1.00f
+ (ea.getScrollingMotion() == osgGA::GUIEventAdapter::SCROLL_DOWN ? -0.08f : +0.08f);
if(m_fov * f >= 1.f && m_fov * f <= 179.f)
m_fov *= f;
emit fovChanged(m_fov);
return true;
}
break;
case(osgGA::GUIEventAdapter::RELEASE):
if(ea.getButton() == osgGA::GUIEventAdapter::MIDDLE_MOUSE_BUTTON
&& (ea.getModKeyMask() & osgGA::GUIEventAdapter::MODKEY_CTRL) != 0)
{
m_fov = m_fovBackup;
emit fovChanged(m_fov);
return true;
}
break;
default:
break;
};
return false;
}
示例8: ProcessMouseInput
bool ManipulatorControl::ProcessMouseInput(const osgGA::GUIEventAdapter &ea) {
if (ea.getEventType() == osgGA::GUIEventAdapter::PUSH) {
lastX = ea.getX();
lastY = ea.getY();
}
else if (ea.getEventType() == osgGA::GUIEventAdapter::DRAG) {
const bool ctrl( ( ea.getModKeyMask() & osgGA::GUIEventAdapter::MODKEY_CTRL ) != 0 );
if (!ctrl) return false;
// drag the active manipulator in the plane of view
// get our current view
float dx = ea.getX() - lastX;
lastX = ea.getX();
float dy = ea.getY() - lastY;
lastY = ea.getY();
Vec3d from, to, up;
m_viewer->m_handler->getTransformation(from, to, up);
up.normalize();
Vec3d depthdir = (to - from); depthdir.normalize();
osg::Vec3 ydir = up;
osg::Vec3 xdir = depthdir ^ ydir;
OpenRAVE::Transform T = m_manip->GetEndEffectorTransform();
float depth = (toOsgVec3(T.trans)-from) * depthdir;
osg::Vec3 dragvec = xdir*(depth*dx/ea.getWindowWidth()) + ydir*(depth*dy/ea.getWindowHeight());
cout << toRave(dragvec) << endl;
T.trans += toRave(dragvec);
vector<double> iksoln;
m_manip->FindIKSolution(OR::IkParameterization(T), iksoln, 18);
if (iksoln.empty()) {
cerr << "no ik solution found" << endl;
}
else {
cout << "ik succeeded!" << endl;
m_manip->GetRobot()->SetDOFValues(iksoln, false, m_manip->GetArmIndices());
m_viewer->UpdateSceneData();
}
return true;
}
return false;
}
示例9: handle
bool PickHandler::handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter& aa)
{
switch(ea.getEventType())
{
case(osgGA::GUIEventAdapter::PUSH):
{
if (ea.getModKeyMask() == 0)
return false;
osgViewer::View* view = dynamic_cast<osgViewer::View*>(&aa);
if (view == NULL)
return false;
osgUtil::LineSegmentIntersector::Intersection intersection;
osg::NodePath node_path;
Renderable* renderable = NULL;
if (ea.getButtonMask() == osgGA::GUIEventAdapter::LEFT_MOUSE_BUTTON)
renderable = computeIntersection<Renderable>(view, ea, intersection, node_path);
else if (ea.getButtonMask() == osgGA::GUIEventAdapter::RIGHT_MOUSE_BUTTON)
renderable = computePointIntersection<Renderable>(view, ea, intersection, node_path);
else
return false;
if (renderable == NULL)
return false;
renderable->pickEvent(ea.getModKeyMask(), intersection.getWorldIntersectPoint());
return true;
}
break;
default:
return false;
}
return false;
}
示例10: getName
bool
GeometrySelector::handle( const osgGA::GUIEventAdapter& ea
, osgGA::GUIActionAdapter& aa
)
{
// RECORD_INFO("reaching here");
osgViewer::View* viewer = dynamic_cast<osgViewer::View*>(&aa);
if ( !viewer )
{
return false;
}
bool drag_event_occurred = ea.getEventType() & osgGA::GUIEventAdapter::DRAG;
bool push_event_occurred = ea.getEventType() & osgGA::GUIEventAdapter::PUSH;
bool release_event_occurred = ea.getEventType() & osgGA::GUIEventAdapter::RELEASE;
bool left_mouse_button_pressed = ea.getButton() == osgGA::GUIEventAdapter::LEFT_MOUSE_BUTTON;
bool ctrl_key_pressed = ea.getModKeyMask() & osgGA::GUIEventAdapter::MODKEY_CTRL;
if(left_mouse_button_pressed && push_event_occurred)
{
Geometry * geometry = _get_intersection(ea,viewer);
bool blank_click = geometry == nullptr;
if(blank_click)
{
id = "";
selected = false;
RECORD_INFO("not selected");
}
else
{
id = geometry -> getName();
selected = true;
RECORD_INFO(std::string("Selected") + geometry -> getName() );
}
}
else
{
selected = false;
}
return false;
}
示例11: write
void write(const osgGA::GUIEventAdapter& event)
{
writeUInt(event.getEventType());
writeUInt(event.getKey());
writeUInt(event.getButton());
writeInt(event.getWindowX());
writeInt(event.getWindowY());
writeUInt(event.getWindowWidth());
writeUInt(event.getWindowHeight());
writeFloat(event.getXmin());
writeFloat(event.getYmin());
writeFloat(event.getXmax());
writeFloat(event.getYmax());
writeFloat(event.getX());
writeFloat(event.getY());
writeUInt(event.getButtonMask());
writeUInt(event.getModKeyMask());
writeDouble(event.getTime());
}
示例12: handle
bool SaveRestoreHandler::handle( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa )
{
if( ea.getEventType() != osgGA::GUIEventAdapter::KEYDOWN )
return( false );
const bool ctrl( ( ea.getModKeyMask() & osgGA::GUIEventAdapter::MODKEY_CTRL ) != 0 );
if( ea.getKey() == osgGA::GUIEventAdapter::KEY_Insert )
{
if( _pt != NULL )
_pt->pause( true );
capture();
if( _pt != NULL )
_pt->pause( false );
return( true );
}
else if( ea.getKey() == osgGA::GUIEventAdapter::KEY_Delete )
{
if( _pt != NULL )
_pt->pause( true );
reset();
if( _pt != NULL )
_pt->pause( false );
return( true );
}
else if( ea.getKey() == osgGA::GUIEventAdapter::KEY_F1 )
{
save();
return( true );
}
else if( ea.getKey() == osgGA::GUIEventAdapter::KEY_F2 )
{
if( _pt != NULL )
_pt->pause( true );
capture();
if( _pt != NULL )
_pt->pause( false );
save();
return( true );
}
return( false );
}
示例13: handle
bool OsgKeyboardHandler::handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter&)
{
bool result = false;
switch (ea.getEventType())
{
case (osgGA::GUIEventAdapter::KEYDOWN) :
{
// Note that we are setting the modifier mask here instead of the modifier itself
m_keyboardScaffold.lock()->updateDevice(ea.getUnmodifiedKey(), ea.getModKeyMask());
result = true;
break;
}
case (osgGA::GUIEventAdapter::KEYUP) :
{
m_keyboardScaffold.lock()->updateDevice(KeyCode::NONE, ModKeyMask::MODKEY_NONE);
result = true;
break;
}
default:
result = false;
break;
}
// We wan to to support some of the osg viewer keys, pass these through, we will still receive the event, but osg
// will also react here
int key = ea.getUnmodifiedKey();
if (key == 's' || key == 't' || key == 'v' || key == 'w')
{
// s: Stats Display
// t: texturing
// v: vsync
// w: wireframe
result = false;
}
return result;
}
示例14: handle
bool MouseEventHandler::handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa) {
if (ea.getEventType()!=osgGA::GUIEventAdapter::RELEASE ||
ea.getButton()!=osgGA::GUIEventAdapter::LEFT_MOUSE_BUTTON ||
!(ea.getModKeyMask()&osgGA::GUIEventAdapter::MODKEY_CTRL))
return false;
osgViewer::Viewer* viewer= dynamic_cast<osgViewer::Viewer*>(&aa);
if (viewer) {
osg::ref_ptr<osgUtil::LineSegmentIntersector> intersector=
new osgUtil::LineSegmentIntersector(osgUtil::Intersector::WINDOW, ea.getX(), ea.getY());
osgUtil::IntersectionVisitor iv(intersector.get());
// Sólo recorrer aquellos nodos con nodeMask=0x1
iv.setTraversalMask(~0x1);
viewer->getCamera()->accept(iv);
if (intersector->containsIntersections()) {
//osgUtil::LineSegmentIntersector::Intersection& elegido= *(intersector->getIntersections().begin());
//orbita= elegido.;
//std::cout<<"ola k ase\n";
// Hagamos lo que tengamos que hacer...
}
}
return false;
}
示例15: handle
bool Dragger::handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa)
{
if (ea.getHandled()) return false;
osgViewer::View* view = dynamic_cast<osgViewer::View*>(&aa);
if (!view) return false;
if (!_mapNode.valid()) return false;
if (ea.getEventType() == osgGA::GUIEventAdapter::PUSH)
{
Picker picker( view, this );
Picker::Hits hits;
if ( picker.pick( ea.getX(), ea.getY(), hits ) )
{
_dragging = true;
//Check for and handle vertical dragging if necessary
bool pressedAlt = _modKeyMask && (ea.getModKeyMask() & _modKeyMask) > 0;
_elevationDragging = (_defaultMode == Dragger::DRAGMODE_VERTICAL && !pressedAlt) || (_defaultMode == Dragger::DRAGMODE_HORIZONTAL && pressedAlt);
if (_elevationDragging)
{
_pointer.reset();
// set movement range
// TODO: values 0.0 and 300000.0 are rather experimental
GeoPoint posStart(_position.getSRS(), _position.x(), _position.y(), 0.0, ALTMODE_ABSOLUTE);
osg::Vec3d posStartXYZ;
posStart.toWorld(posStartXYZ);
GeoPoint posEnd(_position.getSRS(), _position.x(), _position.y(), 300000.0, ALTMODE_ABSOLUTE);
osg::Vec3d posEndXYZ;
posEnd.toWorld(posEndXYZ);
_projector->setLine(posStartXYZ, posEndXYZ);
// set camera
osgUtil::LineSegmentIntersector::Intersections intersections;
osg::Node::NodeMask intersectionMask = 0xffffffff;
osgViewer::View* view = dynamic_cast<osgViewer::View*>(&aa);
if (view->computeIntersections(ea.getX(),ea.getY(),intersections, intersectionMask))
{
for (osgUtil::LineSegmentIntersector::Intersections::iterator hitr = intersections.begin(); hitr != intersections.end(); ++hitr)
{
_pointer.addIntersection(hitr->nodePath, hitr->getLocalIntersectPoint());
}
bool draggerFound = false;
for (osgManipulator::PointerInfo::IntersectionList::iterator piit = _pointer._hitList.begin(); piit != _pointer._hitList.end(); ++piit)
{
for (osg::NodePath::iterator itr = piit->first.begin(); itr != piit->first.end(); ++itr)
{
Dragger* dragger = dynamic_cast<Dragger*>(*itr);
if (dragger==this)
{
draggerFound = true;
osg::Camera *rootCamera = view->getCamera();
osg::NodePath nodePath = _pointer._hitList.front().first;
osg::NodePath::reverse_iterator ritr;
for (ritr = nodePath.rbegin(); ritr != nodePath.rend(); ++ritr)
{
osg::Camera* camera = dynamic_cast<osg::Camera*>(*ritr);
if (camera && (camera->getReferenceFrame()!=osg::Transform::RELATIVE_RF || camera->getParents().empty()))
{
rootCamera = camera;
break;
}
}
_pointer.setCamera(rootCamera);
_pointer.setMousePosition(ea.getX(), ea.getY());
break;
}
}
if (draggerFound)
break;
}
}
}
aa.requestRedraw();
return true;
}
}
else if (ea.getEventType() == osgGA::GUIEventAdapter::RELEASE)
{
_elevationDragging = false;
if ( _dragging )
{
_dragging = false;
firePositionChanged();
}
aa.requestRedraw();
}
else if (ea.getEventType() == osgGA::GUIEventAdapter::DRAG)
{
//.........这里部分代码省略.........