|
我在vs2010开发一个程序,用的是MFC的框架,我用了两个事件回调来监听两个相机下的模型,然后我直接单击VS2010运行按钮,里面的控件按钮都没有什么问题,也就是都可以响应事件,但是在运行生成的Debug文件夹下的EXE文件,结果是有些按钮事件响应不了,这到底是什么原因,貌似我在ActiveX控件好像也是有问题的。。有些事件响应不了。。下面是我事件回调的函数:
-
- class CameraListener : public osg::NodeCallback
- {
- public:
- CameraListener(CArtPicture* aa);
- ~CameraListener(void);
- virtual void operator()(osg::Node* n, osg::NodeVisitor* nv)
- {
- osgGA::EventVisitor* eventVisitor=dynamic_cast<osgGA::EventVisitor*>(nv);
- osg::Camera* node=dynamic_cast<osg::Camera*>(n);
- if (!eventVisitor || !node)
- {
- std::cout<<"Camera listener fail"<<std::endl;
- return;
- }
- osgGA::EventQueue::Events& events=eventVisitor->getEvents();
- for (osgGA::EventQueue::Events::const_iterator ite = events.begin(); ite != events.end(); ite++)
- {
- double mx;
- double my;
- double w;
- double h;
- osgUtil::PolytopeIntersector* intersector = NULL;
- osgUtil::IntersectionVisitor iv;
- osgUtil::PolytopeIntersector* intersector1 = NULL;
- osgUtil::IntersectionVisitor iv1;
- switch ((*ite)->getEventType())
- {
- case osgGA::GUIEventAdapter::PUSH:
- {
- mx = (*ite)->getXnormalized();
- my = (*ite)->getYnormalized();
- w = 0.005;
- h = 0.005;
- intersector = new osgUtil::PolytopeIntersector( osgUtil::Intersector::PROJECTION, mx-w, my-h, mx+w, my+h );
- iv.setIntersector(intersector);
- node->accept(iv);
- if (intersector->containsIntersections())
- {
- osgUtil::PolytopeIntersector::Intersection intersection = intersector->getFirstIntersection();
- osg::NodePath& nodePath = intersection.nodePath;
- osg::Node* internode = (nodePath.size()>=1)?nodePath[nodePath.size()-1]:0;
- std::string name = internode->getName();
- std::string classname = internode->className();
- art->mousePush(name);
- }
- }
- break;
- case osgGA::GUIEventAdapter::MOVE:
- {
- mx = (*ite)->getXnormalized();
- my = (*ite)->getYnormalized();
- w = 0.005;
- h = 0.005;
- intersector1 = new osgUtil::PolytopeIntersector( osgUtil::Intersector::PROJECTION, mx-w, my-h, mx+w, my+h );
- iv1.setIntersector(intersector1);
- node->accept(iv1);
- if (intersector1->containsIntersections())
- {
- osgUtil::PolytopeIntersector::Intersection intersection = intersector1->getFirstIntersection();
- osg::NodePath& nodePath = intersection.nodePath;
- osg::Node* internode = (nodePath.size()>=1)?nodePath[nodePath.size()-1]:0;
- std::string name = internode->getName();
- std::string classname = internode->className();
- art->mouseEnter(name);
- }
- }
- break;
- default:
- break;
- }
- }
- traverse(n,nv);
- }
- public:
- CArtPicture* art;
- };
复制代码
这里面有什么问题嘛? |
|