示例#1
0
    def setLabel(name, x, y):

        
        ea = osgGA.GUIEventAdapter()
        ea.setEventType(osgGA.GUIEventAdapter.USER)
        ea.setName("pick-result")
        ea.setUserValue("name", name)
        ea.setUserValue("x", x)
        ea.setUserValue("y", y)

        _device.sendEvent(*ea)
class EventProperty (gsc.UpdateProperty) :

    EventProperty() 
    EventProperty(osgGA.GUIEventAdapter* event):_event(event) 
    EventProperty( EventProperty cpp,  osg.CopyOp copyop=osg.CopyOp.SHALLOW_COPY) 

    META_Object(gsc, EventProperty)

    def setEvent(ea):

         _event = ea 
    def getEvent():
         return _event 
    def getEvent():
         return _event 
    
    update = virtual void(osgViewer.View* view)

    virtual ~EventProperty() 

    _previousFrameTime = double()
    _event = osgGA.GUIEventAdapter()
示例#3
0
class TestManipulator (osgGA.CameraManipulator) :

        TestManipulator()
        virtual ~TestManipulator()

        #* set the position of the matrix manipulator using a 4x4 Matrix.
        setByMatrix = virtual void( osg.Matrixd matrix)

        #* set the position of the matrix manipulator using a 4x4 Matrix.
        def setByInverseMatrix(matrix):
             setByMatrix(osg.Matrixd.inverse(matrix)) 

        #* get the position of the manipulator as 4x4 Matrix.
        virtual osg.Matrixd getMatrix() 

        #* get the position of the manipulator as a inverse matrix of the manipulator, typically used as a model view matrix.
        virtual osg.Matrixd getInverseMatrix() 

        #* Attach a node to the manipulator. 
#            Automatically detaches previously attached node.
#            setNode(NULL) detaches previously nodes.
#            Is ignored by manipulators which do not require a reference model.
        setNode = virtual void(osg.Node*)

        #* Return node if attached.
        virtual  osg.Node* getNode() 

        #* Return node if attached.
        getNode = virtual osg.Node*()

        #* Move the camera to the default position. 
#            May be ignored by manipulators if home functionality is not appropriate.
        home = virtual void( osgGA.GUIEventAdapter ea,osgGA.GUIActionAdapter us)
        
        #* Start/restart the manipulator.
        init = virtual void( osgGA.GUIEventAdapter ea,osgGA.GUIActionAdapter us)


        #* handle events, return True if handled, False otherwise.
        handle = virtual bool( osgGA.GUIEventAdapter ea,osgGA.GUIActionAdapter us)

        #* Reset the internal GUIEvent stack.
        flushMouseEventStack = void()
        #* Add the current mouse GUIEvent to internal stack.
        addMouseEvent = void( osgGA.GUIEventAdapter ea)

        computePosition = void( osg.Vec3 eye, osg.Vec3 lv, osg.Vec3 up)

        #* For the give mouse movement calculate the movement of the camera.
#            Return True is camera has moved and a redraw is required.
        calcMovement = bool()
        
        #* Check the speed at which the mouse is moving.
#            If speed is below a threshold then return False, otherwise return True.
        isMouseMoving = bool()

        # Internal event stack comprising last three mouse events.
        _ga_t1 =  osgGA.GUIEventAdapter()
        _ga_t0 =  osgGA.GUIEventAdapter()

        _node = osg.Node()

        _modelScale = float()
        _minimumZoomScale = float()

        _thrown = bool()
        
        _center = osg.Vec3()
        _rotation = osg.Quat()
        _distance = float()
示例#4
0
        
        if _updateText : _updateText.setText(name)

    _updateText = osgText.Text()


bool PickHandler.handle( osgGA.GUIEventAdapter ea,osgGA.GUIActionAdapter aa)
    switch(ea.getEventType())
        case(osgGA.GUIEventAdapter.PUSH):
            view = dynamic_cast<osgViewer.View*>(aa)
            if view : pick(view,ea)
            return False
        case(osgGA.GUIEventAdapter.KEYDOWN):
            if ea.getKey()==ord("c") :
                view = dynamic_cast<osgViewer.View*>(aa)
                event = osgGA.GUIEventAdapter(ea)
                event.setX((ea.getXmin()+ea.getXmax())*0.5)
                event.setY((ea.getYmin()+ea.getYmax())*0.5)
                if view : pick(view,*event)
            return False
        default:
            return False

void PickHandler.pick(osgViewer.View* view,  osgGA.GUIEventAdapter ea)
    intersections = osgUtil.LineSegmentIntersector.Intersections()

    gdlist = ""

    if view.computeIntersections(ea,intersections) :
        for(osgUtil.LineSegmentIntersector.Intersections.iterator hitr = intersections.begin()
            not = intersections.end()
示例#5
0
        _device.sendEvent(*ea)

    _device = osgGA.Device()


bool PickHandler.handle( osgGA.GUIEventAdapter ea,osgGA.GUIActionAdapter aa)
    switch(ea.getEventType())
        case(osgGA.GUIEventAdapter.PUSH):
            view = dynamic_cast<osgViewer.View*>(aa)
            if view : pick(view,ea)
            return False

        case(osgGA.GUIEventAdapter.KEYUP):
            if ea.getKey() == ord("t") :
                user_event = osgGA.GUIEventAdapter()
                user_event.setEventType(osgGA.GUIEventAdapter.USER)
                user_event.setUserValue("vec2f", osg.Vec2f(1.0,2.0))
                user_event.setUserValue("vec3f", osg.Vec3f(1.0,2.0, 3.0))
                user_event.setUserValue("vec4f", osg.Vec4f(1.0,2.0, 3.0, 4.0))

                user_event.setUserValue("vec2d", osg.Vec2d(1.0,2.0))
                user_event.setUserValue("vec3d", osg.Vec3d(1.0,2.0, 3.0))
                user_event.setUserValue("vec4d", osg.Vec4d(1.0,2.0, 3.0, 4.0))

                user_event.setName("osc_test_1")

                _device.sendEvent(*user_event)


        default: