コード例 #1
0
    def __init__(self, config):
        super(Plate, self).__init__()
        self.config = config
        # I want to subclass this, but I'm uncertain how to..
        self.plate = self.config.ui.get_object("plate")
        self.plate_data = Mash.Data()
        self.plate_data.load(0, config.get("System", "plate"))
        self.plate.set_data(self.plate_data)
        color_str = config.get("System", "plate-color")
        self.color = Clutter.Color.from_string(color_str)[1]
        self.plate.set_color(self.color)

        # Position it
        (width, height) = self.plate.get_size()
        v_min = Clutter.Vertex()
        v_max = Clutter.Vertex()
        self.plate_data.get_extents(v_min, v_max)
        depth = v_max.z - v_min.z
        self.plate.set_y(depth / 2.0)
        self.plate.set_x(-width / 2.0)
        self.plate.set_z_position(height / 2.0)

        self.plate.set_light_set(self.config.loader.model.light_set)

        self.probe_points = []
        self.scale_points = []
        self.plate.set_culling(1)
コード例 #2
0
ファイル: Plate.py プロジェクト: intelligent-agent/toggle
    def __init__(self, config):
        super(Plate, self).__init__()
        self.config = config
        # I want to subclass this, but I'm uncertain how to..
        self.plate = self.config.ui.get_object("plate")
        plate_file = config.style.get_plate_filename()
        self.plate_data = Mash.Data()
        self.plate_data.load(0, plate_file)
        self.plate.set_data(self.plate_data)
        self.color = self.plate.get_background_color()
        self.plate.set_color(self.color)
        self.scale_created = False

        # Position it
        (width, height) = self.plate.get_size()
        v_min = Clutter.Vertex()
        v_max = Clutter.Vertex()
        self.plate_data.get_extents(v_min, v_max)
        depth = v_max.z - v_min.z
        self.plate.set_y(depth / 2.0)
        self.plate.set_x(-width / 2.0)
        self.plate.set_z_position(height / 2.0)

        self.plate.set_light_set(self.config.model.light_set)

        self.probe_points = []
        self.scale_points = []
        self.plate.set_culling(1)
コード例 #3
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)
コード例 #4
0
    def add_point_to_bed(self, point):
        probe = Mash.Model.new_from_file(0, self.config.get("System", "probe-point"))
        probe.set_size(10, 10)
        (width, height) = probe.get_size()
        v_min = Clutter.Vertex()
        v_max = Clutter.Vertex()
        data = probe.get_property("data")
        data.get_extents(v_min, v_max)
        depth = v_max.z - v_min.z

        probe.set_y(-depth/2.0-point[2])
        probe.set_x(-width/2.0-point[0])
        probe.set_z_position(-height/2.0+point[1])
        probe.z = point[2] # Store z-value for rescaling

        probe.set_light_set(self.config.loader.model.light_set)
        probe.set_rotation_angle(Clutter.RotateAxis.X_AXIS, 90.0)
        self.config.ui.get_object("model-flipper").add_actor(probe)
        self.probe_points.append(probe)
コード例 #5
0
ファイル: banner.py プロジェクト: rmatam/vivo
from gi.repository import Clutter, GLib, GObject

text = Text("Vivo Live Programming Environment", "inconsolata 24")
text.color = Color.from_str("black")
text.actor.set_anchor_point(text.width / 2, text.height / 2)
text.x = Screen.width / 2
text.y = Screen.height / 2

v = Clutter.Vertex()
v.x = text.width / 2
v.y = text.width / 2
v.z = 0

props = {"fixed::rotation-center-y": v, "rotation-angle-y": 360.0}
a = text.animate(Clutter.AnimationMode.LINEAR, 3000, props)

a.set_loop(True)
Screen.put(text)
コード例 #6
0
gi.require_version('Mash', '0.3')
from gi.repository import Clutter, Mx, Mash, Cogl, GObject

# Set up logging
logging.basicConfig(
    level=logging.DEBUG,
    format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s',
    datefmt='%m-%d %H:%M')

if __name__ == '__main__':
    Clutter.init(None)

    stage = Clutter.Stage()
    model = Mash.Model()
    data = Mash.Data()
    model.set_data(data)
    data.load(0, "/home/root/.octoprint/uploads/reel2.stl")
    v1 = Clutter.Vertex()
    v2 = Clutter.Vertex()
    data.get_extents(v1, v2)
    print v1.z
    print v2.z

    print model.get_depth()

    color = Clutter.Color.from_string("#F00F")[1]
    model.set_color(color)
    model.set_progress(1)

    p = model.get_pipeline()