Пример #1
0
 def __init__(self):
     super(test, self).__init__()
     self.events = coin.SoEventCallback()
     self += self.events
     self.cb = self.events.addEventCallback(
         coin.SoLocation2Event.getClassTypeId(), self.my_cb)
     self.cb1 = self.events.addEventCallback(coin.SoEvent.getClassTypeId(),
                                             self.my_cb_1)
Пример #2
0
    def __init__(self):

        super().init(name='Drag Tracker')

        self.start = ()

        self.drag_switch = coin.SoSwitch()
        self.drag_node = coin.SoSeparator()
        self.drag_event_callback = coin.SoEventCallback()
        self.full_group = coin.SoSeparator()
        self.manual_group = coin.SoSeparator()

        self.drag_transform = coin.SoTransform()
        self.drag_tracker_node = None
        self.drag_point = None

        self.update_translate = True
        self.update_rotate = True

        self.drag_line_coord = coin.SoCoordinate3()

        self.drag_event_callback.setPath(None)

        self.drag_node.addChild(self.drag_event_callback)
        self.drag_node.addChild(self.manual_group)
        self.drag_node.addChild(self.drag_transform)
        self.drag_node.addChild(self.full_group)

        self.drag_switch.addChild(self._build_drag_line())
        self.drag_switch.addChild(self.drag_node)
        self.drag_switch.whichChild = -3

        self.abort = False

        #coordinate tracking properties
        self.delta = ()
        self.coordinates = ()

        #cumulate angle, center of rotation and current drag rotation
        self.angle = 0.0
        self.rotation_center = None
        self.rotation = 0.0

        #flag indicating scenegraph updates are complete
        self.sg_ok = False

        #reference to scenegrapg root node (used internally)
        self._sg_root = None

        #set to indicate to base tracker not to push updates during on_drag()
        self.override = False
Пример #3
0
    def __init__(self, render_manager):
        super(InteractionSeparator, self).__init__()
        self.render_manager = render_manager
        self.objects = coin.SoSeparator()
        self.dynamic_objects = []
        self.static_objects = []
        self.over_object = None
        self.selected_objects = []
        self.drag_objects = []

        self.on_drag = []
        self.on_drag_release = []
        self.on_drag_start = []

        self._direction = None

        self.events = coin.SoEventCallback()
        self += self.events, self.objects
Пример #4
0
    def __init__(self, colorLights=True):
        QWidget.__init__(self)
        self.setupSoQt()
        # camera defaults
        self.camera_point_at = [coin.SbVec3f(0, 0, 0), coin.SbVec3f(0, 0, 1)]
        self.camera_position = (7, 7, 7)
        # call viewAll when switching to a new page
        self.camera_viewAll = True
        # the scene root

        self.initializeViewer()
        self.setInitialCameraPosition()
        self.mouseEventCB = coin.SoEventCallback()
        self.getSRoot().addChild(self.mouseEventCB)
        if colorLights:
            self.addLights()
            self.setColorLightOn(True)
            # no need the default headlight in this case
            self.examiner.setHeadlight(False)
Пример #5
0
    def __init__(self, use_path=True):
        """docstring"""
        self.node = coin.SoSeparator()
        self.event_cb = coin.SoEventCallback()
        self.coordinate = coin.SoCoordinate3()
        self.marker = coin.SoMarkerSet()
        self.event_cb_switch = coin.SoSwitch()

        self.coordinate.point.setValue((0.0, 0.0, 0.0))
        self.coordinate.setName('coordinate')
        self.event_cb.setName('event_cb')
        self.marker.setName('marker')

        self.cb_sigs = [
            self.event_cb.addEventCallback(
                coin.SoLocation2Event.getClassTypeId(), self.on_mouse_cb),
            self.event_cb.addEventCallback(
                coin.SoMouseButtonEvent.getClassTypeId(), self.on_button_cb)
        ]

        self.event_cb_switch.addChild(self.event_cb)
        self.node.addChild(self.event_cb_switch)
        self.node.addChild(self.coordinate)
        self.node.addChild(self.marker)

        ViewState().sg_root.insertChild(self.node, 0)

        if not use_path:
            return

        _sa = coin.SoSearchAction()
        _sa.setNode(self.marker)
        _sa.apply(ViewState().sg_root)

        self.event_cb.setPath(_sa.getPath())

        self.toggle_events()