Ejemplo n.º 1
0
    def __init__(self, ui, num_tabs):
        self.ui = ui
        self.num_tabs = num_tabs
        self.duration = 1000
        self.tgs = [None] * num_tabs
        self.current_side = 0
        self.sides = [None] * num_tabs
        self.selected_callbacks = [None] * num_tabs
        self.appear_callbacks = [None] * num_tabs

        self.box = self.ui.get_object("box")

        for i in range(self.num_tabs):
            self.sides[i] = self.ui.get_object("side" + str(i))
            btn_prev = self.ui.get_object("side" + str(i) + "-btn-prev")
            tap_prev = Clutter.TapAction()
            btn_prev.add_action(tap_prev)
            tap_prev.connect("tap", self.btn_prev)

            btn_next = self.ui.get_object("side" + str(i) + "-btn-next")
            tap_next = Clutter.TapAction()
            btn_next.add_action(tap_next)
            tap_next.connect("tap", self.btn_next)

            t = Clutter.PropertyTransition(property_name='rotation-angle-y')
            t.set_from(i * -90)
            t.set_to(i * -90 - 90)
            t.add_marker("appear", 0.5)
            t.connect("marker-reached::appear", self.appear)
            t.connect("completed", self.completed)
            t.set_duration(self.duration)
            t.set_animatable(self.box)
            t.set_progress_mode(Clutter.AnimationMode.EASE_IN_OUT_CUBIC)
            self.tgs[i] = t

        btn_next = self.ui.get_object("side5-btn-next")
        tap_next = Clutter.TapAction()
        btn_next.add_action(tap_next)
        tap_next.connect("tap", self.btn_next)

        btn_next = self.ui.get_object("side5-btn-prev")
        tap_next = Clutter.TapAction()
        btn_next.add_action(tap_next)
        tap_next.connect("tap", self.btn_prev)

        self.tg = self.tgs[0]

        # Set up page 0 to page 2 transition
        self.t2 = Clutter.PropertyTransition(property_name='rotation-angle-y')
        self.t2.set_from(0)
        self.t2.set_to(180)
        self.t2.add_marker("appear", 0.5)
        self.t2.connect("marker-reached::appear", self.appear)
        self.t2.connect("completed", self.intro_completed)
        self.t2.set_duration(self.duration)
        self.t2.set_animatable(self.box)
        self.t2.set_progress_mode(Clutter.AnimationMode.EASE_IN_OUT_CUBIC)

        self.preload = Clutter.Timeline.new(500)
        self.preload.connect("completed", self.preload_complete)
Ejemplo n.º 2
0
    def __init__(self, config):
        self.ui = config.ui
        self.scroller = config.ui.get_object("scroll-pane")
        self.scroller.set_reactive(True)
        self.header_y = config.ui.get_object("scroll-header").get_height()
        self.scroller.connect("scroll-event", self.on_scroll_event)
        pan = Clutter.PanAction()
        self.scroller.add_action(pan)
        pan.connect("pan", self.pan)

        ok_tap = Clutter.TapAction()
        config.ui.get_object("wifi-ok").add_action(ok_tap)
        ok_tap.connect("tap", self.ok_tap)
        cancel_tap = Clutter.TapAction()
        config.ui.get_object("wifi-cancel").add_action(cancel_tap)
        cancel_tap.connect("tap", self.cancel_tap)

        self.wifi_password = ""
        self.selected_ap = None

        self.y = self.header_y
        config.tabs.set_pane_selected_callback(0, self.on_select_callback)
        self.config = config
        self.enable_sliders()
        self.setup_wifi_tab()
        self.scroller_height = self.scroller.get_height()
        self.stage_height = self.config.ui.get_object("box").get_height()
Ejemplo n.º 3
0
    def __init__(self, config):
        self.config = config
        self.btn_print = self.config.ui.get_object("btn-print")
        self.btn_pause = self.config.ui.get_object("btn-pause")
        self.btn_cancel = self.config.ui.get_object("btn-cancel")

        self.btn_next = self.config.ui.get_object("btn-next")
        self.btn_prev = self.config.ui.get_object("btn-prev")

        tap_next = Clutter.TapAction()
        self.btn_next.add_action(tap_next)
        tap_next.connect("tap", self.tap_next, None)

        tap_prev = Clutter.TapAction()
        self.btn_prev.add_action(tap_prev)
        tap_prev.connect("tap", self.tap_prev, None)

        tap_print = Clutter.TapAction()
        self.btn_print.add_action(tap_print)
        tap_print.connect("tap", self.start_print, None)

        tap_pause = Clutter.TapAction()
        self.btn_pause.add_action(tap_pause)
        tap_pause.connect("tap", self.pause_print, None)

        tap_cancel = Clutter.TapAction()
        self.btn_cancel.add_action(tap_cancel)
        tap_cancel.connect("tap", self.cancel_print, None)

        self.progress = self.config.ui.get_object("progress-bar")
        self.progress_max = self.config.ui.get_object(
            "progress-bar-undone").get_width()
        self.time_gone = self.config.ui.get_object("time-gone")
        self.time_left = self.config.ui.get_object("time-left")

        self.lbl_stat = self.config.ui.get_object("lbl-stat")
        self.lbl_model = self.config.ui.get_object("lbl-model")

        self.heartbeat = self.config.ui.get_object("heartbeat")
        self.connection = self.config.ui.get_object("connection")
        self.connection_disabled = self.config.ui.get_object(
            "connection-disabled")
        self.printing = self.config.ui.get_object("printing")
        self.paused = self.config.ui.get_object("paused")
        #self.lbl_temp   = self.config.ui.get_object("lbl-temp")

        self.flags = {
            "operational": False,
            "paused": False,
            "printing": False,
            "sdReady": False,
            "error": False,
            "ready": False,
            "closedOrError": False
        }
Ejemplo n.º 4
0
    def __init__(self, config):
        self.config = config
        super(SecretAgent, self).__init__(SecretAgent.ID)

        ok_tap = Clutter.TapAction()
        config.ui.get_object("wifi-ok").add_action(ok_tap)
        ok_tap.connect("tap", self.ok_button_tap)
        cancel_tap = Clutter.TapAction()
        config.ui.get_object("wifi-cancel").add_action(cancel_tap)
        cancel_tap.connect("tap", self.cancel_button_tap)
        overlay = self.config.ui.get_object("wifi-overlay")
        overlay.set_reactive(True)
        overlay.connect("event", self.overlay_catcher)
        self.wifi_password = ""
Ejemplo n.º 5
0
    def on_select_callback(self):
        # add local IP
        local_ip = self.config.ui.get_object("local-ip")
        local_ip.set_text(self.config.network.get_connected_ip())

        # Add local hostname
        hostname = os.uname()
        local_host_name = self.config.ui.get_object("local-hostname")
        local_host_name.set_text(hostname[1])

        # Add remote address
        remote_host_name = self.config.ui.get_object("remote-hostname")
        remote_host_name.set_text(self.config.get("Server", "host"))

        # Add Slicer height
        slicer_layer_height = self.config.ui.get_object("slicer-layer-height")
        slicer_layer_height.set_text(self.config.get("Slicer", "layer_height"))

        # Add Slicer print temp
        slicer_print_temp = self.config.ui.get_object("slicer-print-temp")
        slicer_print_temp.set_text(
            self.config.get("Slicer", "print_temperature"))

        # Add the button for calibrating the bed
        calibrate_bed_button = self.config.ui.get_object(
            "printer-calibrate-bed")
        tap = Clutter.TapAction()
        calibrate_bed_button.add_action(tap)
        tap.connect("tap", self.calibrate_bed)
Ejemplo n.º 6
0
    def make_keyboard(self, keyset=0):
        # yapf: disable
        keys = [[["q", "w", "e", "r", "t", "y", "u", "i", "o", "p", " << "],
                 ["a", "s", "d", "f", "g", "h", "j", "k", "l", "'"],
                 [" ^", "z", "x", "c", "v", "b", "n", "m", ",", ".", " ^"],
                 [" 123 ", "                                        ", " }]? "]
                ],
                [["1", "2", "3", "4", "5", "6", "7", "8", "9", "0", " << "],
                 ["=", "-", "+", "*", "/", "\\", ":", ";", "'", "\""],
                 ["(", ")", "#", "$", "!", "?", "@", "m", ",", "."],
                 [" ABC ", "                                        ", " ABC "]
                ],
                [["Q", "W", "E", "R", "T", "Y", "U", "I", "O", "P", " << "],
                 ["A", "S", "D", "F", "G", "H", "J", "K", "L", "'"],
                 ["^ ", "Z", "X", "C", "V", "B", "N", "M", ",", ".", "^ "],
                 [" 123 ", "                                        ", " }]? "]
               ]]
        # yapf: enable

        for i, row in enumerate(keys[keyset]):
            key_row = self.config.ui.get_object("row-" + str(i))
            key_row.remove_all_children()
            for letter in row:
                key = Mx.Button()
                key.set_style_class("keyboard")
                key.set_label(letter)
                key.letter = letter
                key_row.add_actor(key)
                tap = Clutter.TapAction()
                key.add_action(tap)
                tap.connect("tap", self.keyboard_tap)

        self.config.ui.get_object("wifi-overlay").show()
Ejemplo n.º 7
0
    def __init__(self, config):
        self.config = config

        # Set up filament graph
        self.graph = Graph(800, 380)
        self.filament = config.ui.get_object("graph")
        self.filament.add_child(self.graph)
        self.graph.hide()

        tap = Clutter.TapAction()
        self.graph.add_action(tap)
        tap.connect("tap", self.change_to_temperature)
        self.graph.set_reactive(True)

        self.graphs = {
            "E": {
                "actual": GraphPlot("E", (1, 0, 0), -165, 165)
            },
            "H": {
                "actual": GraphPlot("H", (1, 0.64, 0), -165, 165)
            },
            "A": {
                "actual": GraphPlot("A", (0, 0, 1), -165, 165)
            }
        }

        for tool in self.graphs:
            for source in self.graphs[tool]:
                #logging.debug(self.graphs[tool][source])
                self.graph.add_plot(self.graphs[tool][source])

        # Add a scale to the plot
        scale = GraphScale(-165, 165, [-150, -100, -50, 0, 50, 100, 150])
        scale.set_title("Filament")
        self.graph.add_plot(scale)
Ejemplo n.º 8
0
 def enable_sliders(self):
     for box in ["network", "wifi", "slicer", "printer"]:
         header = self.config.ui.get_object(box + "-header")
         header.set_reactive(True)
         tap = Clutter.TapAction()
         header.add_action(tap)
         tap.connect("tap", self.tap)
         body = self.config.ui.get_object(box + "-body")
         body.set_height(5)
         header.is_open = False
         header.body = body
Ejemplo n.º 9
0
 def add_wifi_tab(self, ap):
     actor = Clutter.Text()
     actor.set_selectable(False)
     actor.set_font_description(self.ap_font)
     actor.set_color(self.ap_color)
     actor.set_width(self.ap_width)
     actor.set_margin_left(self.ap_margin_left)
     self.set_text(actor, ap)
     tap = Clutter.TapAction()
     actor.add_action(tap)
     actor.ap = ap
     tap.connect("tap", self.ap_tap)
     actor.set_reactive(True)
     self.tabs_by_path[ap["object_path"]] = actor
     return actor
Ejemplo n.º 10
0
    def load_models(self):
        self.models = bidirectional_cycle([
            f for f in listdir(self.path)
            if isfile(join(self.path, f)) and (".stl" in f or ".STL" in f)
        ])

        # Load the first model
        if self.models.count() > 0:
            logging.debug("Found " + str(self.models.count()) + " models in " +
                          self.path)
            btn_next = self.config.ui.get_object("btn-next")
            tap_next = Clutter.TapAction()
            btn_next.add_action(tap_next)
            tap_next.connect("tap", self.tap_next, None)

            btn_prev = self.config.ui.get_object("btn-prev")
            tap_prev = Clutter.TapAction()
            btn_prev.add_action(tap_prev)
            tap_prev.connect("tap", self.tap_prev, None)

            self.config.printer.set_model("")
        else:
            logging.warning("No models in " + self.path)
            self.config.printer.set_model("No models found")
Ejemplo n.º 11
0
    def __init__(self, config=None):
        self.config = config

        buttons = [
            "jog_x_minus", "jog_x_plus", "jog_y_minus", "jog_y_plus",
            "jog_z_minus", "jog_z_plus", "jog_home", "jog_z_home",
            "jog_e_extrude", "jog_e_retract", "jog_e_toggle"
        ]

        for name in buttons:
            print name
            if hasattr(self, name):
                btn = config.ui.get_object(name)
                func = getattr(self, name)
                tap = Clutter.TapAction()
                btn.add_action(tap)
                tap.connect("tap", func, None)
            else:
                print "missing function " + str(name)
Ejemplo n.º 12
0
 def on_select_callback(self):
     local_ip = self.config.ui.get_object("local-ip")
     local_ip.set_text(self.config.network.get_connected_ip())
     hostname = os.uname()
     local_host_name = self.config.ui.get_object("local-hostname")
     local_host_name.set_text(hostname[1])
     remote_host_name = self.config.ui.get_object("remote-hostname")
     remote_host_name.set_text(self.config.get("Server", "host"))
     slicer_layer_height = self.config.ui.get_object("slicer-layer-height")
     slicer_layer_height.set_text(self.config.get("Slicer", "layer_height"))
     slicer_print_temp = self.config.ui.get_object("slicer-print-temp")
     slicer_print_temp.set_text(
         self.config.get("Slicer", "print_temperature"))
     calibrate_bed_button = self.config.ui.get_object(
         "printer-calibrate-bed")
     tap = Clutter.TapAction()
     calibrate_bed_button.add_action(tap)
     tap.connect("tap", self.calibrate_bed)
     self.setup_wifi_tab()
Ejemplo n.º 13
0
    def make_wifi_tab(self, ap):
        logging.debug("make_wifi")
        actor = Clutter.Actor()
        actor.set_size(self.actor_width, 40)
        text = Mx.Label()
        text.set_position(120, 0)
        apName = ap["service"][1]["Name"]
        if ap["active"]:
            text.set_text("* " + apName)
        else:
            text.set_text(
                "  " + apName
            )  # the space is to keep the names aligned on the display
        text.set_style_class("wifi")
        actor.add_actor(text)
        tap = Clutter.TapAction()
        actor.add_action(tap)
        actor.ap = ap
        tap.connect("tap", self.ap_tap)
        actor.set_reactive(True)

        return actor
Ejemplo n.º 14
0
  def __init__(self, config=None):
    self.config = config
    self.jog_xy_amount = 10    # 10 mm default jog amount
    self.jog_z_amount = 10
    self.jog_eh_amount = 10    # 10 mm deafult extrude amount

    self.amount_list = [0.1, 1, 10, 100]

    buttons = [
        "jog_x_minus", "jog_x_plus", "jog_y_minus", "jog_y_plus", "jog_z_minus", "jog_z_plus",
        "jog_home", "jog_z_home", "jog_e_extrude", "jog_e_retract", "jog_e_toggle", "travel_xy",
        "travel_z", "travel_eh", "fan_on", "fan_off", "motors_off"
    ]

    for name in buttons:
      if hasattr(self, name):
        btn = config.ui.get_object(name)
        func = getattr(self, name)
        tap = Clutter.TapAction()
        btn.add_action(tap)
        tap.connect("tap", func, None)
      else:
        logging.warning("Jog: Missing function " + str(name))
Ejemplo n.º 15
0
    def __init__(self, config):
        self.config = config

        # Set up temperature graph
        self.temp = config.ui.get_object("graph")
        self.graph = Graph(self.temp.get_width(), self.temp.get_height())
        self.temp.add_child(self.graph)
        self.temp.set_reactive(True)

        tap = Clutter.TapAction()
        self.temp.add_action(tap)
        tap.connect("tap", self.change_to_filament)

        self.temps = {
            "tool0": {
                "g_actual": GraphPlot("E", (1, 0, 0)),
                "g_target": GraphPlot("T_E", (1, 0.4, 0.4)),
                "t_actual": 0,
                "t_target": 0,
                "t_preheat": 220,
                "heating": False,
                "state": "cold",
                "btn-name": "heat-tool0",
                "func-name": self.on_preheat_tool0,
                "btn": None
            },
            "tool1": {
                "g_actual": GraphPlot("H", (1, 0.64, 0)),
                "g_target": GraphPlot("T_H", (1, 0.8, 0.5)),
                "t_actual": 0,
                "t_target": 0,
                "t_preheat": 220,
                "heating": False,
                "state": "cold",
                "btn-name": "heat-tool1",
                "func-name": self.on_preheat_tool1,
                "btn": None
            },
            "tool2": {
                "g_actual": GraphPlot("A", (1, 0.64, 0)),
                "g_target": GraphPlot("T_A", (1, 0.8, 0.5)),
                "t_actual": 0,
                "t_target": 0,
                "t_preheat": 220,
                "heating": False,
                "state": "cold",
                "btn-name": "heat-tool2",
                "func-name": self.on_preheat_tool2,
                "btn": None
            },
            "bed": {
                "g_actual": GraphPlot("BED", (0, 0, 1)),
                "g_target": GraphPlot("T_BED", (0.2, 0.8, 0.8)),
                "t_actual": 0,
                "t_target": 0,
                "t_preheat": 65,
                "heating": False,
                "state": "cold",
                "btn-name": "heat-bed",
                "func-name": self.on_preheat_bed,
                "btn": None
            }
        }

        for tool in self.temps:
            # Add graphs
            self.graph.add_plot(self.temps[tool]["g_actual"])
            self.graph.add_plot(self.temps[tool]["g_target"])

            # Set up buttons
            btn = self.config.ui.get_object(self.temps[tool]["btn-name"])
            tap = Clutter.TapAction()
            btn.add_action(tap)
            tap.connect("tap", self.temps[tool]["func-name"])
            self.temps[tool]["btn"] = btn

        # Add a scale to the plot
        scale = GraphScale(0, 320, [0, 50, 100, 150, 200, 250, 300])
        scale.set_title("Temperature")
        self.graph.add_plot(scale)

        # set up temp label
        self.lbl_temp = self.config.ui.get_object("lbl-temp")
        self.ok_range = 4.0
Ejemplo n.º 16
0
    pixel_format = Cogl.PixelFormat.RGB_888
    if pixbuf.get_has_alpha():
        pixel_format = Cogl.PixelFormat.RGBA_8888

    data = pixbuf.read_pixel_bytes()
    width = pixbuf.get_width()
    height = pixbuf.get_height()
    stride = pixbuf.get_rowstride()

    # The Image content knows how to draw texture data
    image = Clutter.Image()
    image.set_bytes(data, pixel_format, width, height, stride)

    # A Stage is like any other actor, and can paint a Content
    stage.set_content_gravity(Clutter.ContentGravity.RESIZE_ASPECT)
    stage.set_content_scaling_filters(Clutter.ScalingFilter.TRILINEAR, Clutter.ScalingFilter.LINEAR)
    stage.set_content(image)

    # Show a label with the current content gravity
    label = 'Content Gravity: Resize Aspect'
    text = Clutter.Text(text=label)
    text.add_constraint(Clutter.AlignConstraint(source=stage, align_axis=Clutter.AlignAxis.BOTH, factor=0.5))
    stage.add_child(text)

    # Change the content gravity on tap/click
    action = Clutter.TapAction()
    action.connect('tap', on_tap, text)
    stage.add_action(action)

    Clutter.main()