Example #1
0
    def __init__(self, config):
        super(VolumeStage, self).__init__()
        self.config = config
        self.ui = config.ui
        self.p = self.ui.get_object("volume-wrapper")

        # Set up touch events linked to the viewport
        self.vp = self.ui.get_object("volume-viewport")
        self.vp.set_reactive(True)
        self.vp.connect("scroll-event", self.scroll)
        self.rotation = int(config.screen_rot)

        self.angle_max = config.getfloat("System", "angle_max")
        self.angle_min = config.getfloat("System", "angle_min")
        self.scale_max = config.getfloat("System", "scale_max")
        self.scale_min = config.getfloat("System", "scale_min")

        self.spinner = self.ui.get_object("spinner")
        self.clicked = False
        self.scale = 1.2

        if hasattr(Clutter, 'Matrix'):
            m = Clutter.Matrix.alloc()
            m.init_from_array(
                [-1, 0, 0, 0, 0, 1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1])
        else:
            cm = Cogl.Matrix()
            m = Clutter.matrix_init_from_array(
                cm, [-1, 0, 0, 0, 0, 1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1])

        self.ui.get_object("content-flip").set_transform(m)

        zoom = Clutter.ZoomAction()
        self.vp.add_action(zoom)
        zoom.connect("zoom", self.zoom)
        zoom.connect("gesture-begin", self.zoom_begin)
        zoom.connect("gesture-end", self.zoom_end)

        pan = Clutter.PanAction()
        self.vp.add_action(pan)
        pan.connect("pan", self.pan)
        pan.connect("gesture-begin", self.pan_begin)
        pan.connect("gesture-end", self.pan_end)
        pan.connect("gesture-cancel", self.pan_cancel)

        #self.config.stage.connect("motion-event", self.motion)

        self.zoom_start = self.scale
        self.zooming = False
        self.last_x = 0
        self.last_y = 0

        self.panning = False
Example #2
0
    def __init__(self, config):
        super(Model, self).__init__()

        self.config = config
        self.model = config.ui.get_object("model")
        color_str = config.get("System", "model-color")
        self.color = Clutter.Color.from_string(color_str)[1]
        self.loader = config.ui.get_object("loader")
        self.loader.set_from_file(config.get("System", "loader"))

        self.model_data = Mash.Data()
        self.model.set_data(self.model_data)
        self.v_min = Clutter.Vertex()
        self.v_max = Clutter.Vertex()
        self.depth = 0

        self.t = Clutter.PropertyTransition(property_name='rotation-angle-z')
        self.t.set_from(0)
        self.t.set_to(360)
        self.t.set_duration(3000)
        self.t.set_animatable(self.loader)
        self.t.set_repeat_count(-1)
        self.t.start()

        #Set up the light
        self.light_set = Mash.LightSet()
        vp = config.ui.get_object("volume-viewport")

        # Directional
        self.light_directional = Mash.DirectionalLight()
        self.light_set.add_light(self.light_directional)

        # Point light
        self.light_point = Mash.PointLight()
        self.light_set.add_light(self.light_point)
        
        # Add the model the lights to the volume viewport
        vp.add_child(self.light_directional);
        vp.add_child(self.light_point);

        cm = Cogl.Matrix()
        m = Clutter.matrix_init_from_array(cm, [
             1, 0, 0, 0,
             0, -1, 0, 0,
             0, 0, 1, 0,
             0, 0, 0, 1])
        config.ui.get_object("model-flipper").set_transform(m)

        self.model.connect("show", self.model_loaded)

        self.model.set_light_set(self.light_set)
        self.model.set_color(self.color)