Exemplo n.º 1
0
    def retrieve_animation(self, name):
        """ Function to locate and extract animation-data

        First tries locate the file,
        then extracts and returns the data if possible

        :param name: name of the animation
        :return: The retrieved data, empty list if nothing could be retrieved.
        """
        try:
            search = "/home/darwin/%s.json" % name
            filename = find(search)
        except IOError:
            self.log.debug('animation not found in %s ' % search)
            try:
                search = os.path.join(os.path.expanduser('~'), name + ".json")
                filename = find(search)
            except IOError:
                self.log.debug('animation not found in %s ' % search)
                try:
                    filename = find_animation(name)
                except IOError:
                    self.log.warn(
                        "Animation %s konnte nirgendwo gefunden werden!" % name)
                    return False
        self.log.info("Animation unter %s gefunden" % filename)

        data = []
        with open(filename) as fp:
            try:
                data = json.load(fp)
            except ValueError as e:
                self.log.error("Animation %s ist fehlerhaft:\n %s" %
                               (filename, e.message.partition('\n')[0]))
        return data
    def add_new_robot(self, name):
        self.robots.append(name)
        self.make_callbacks(name)
        """
        view_int = gtk.Viewport()
        image_int = gtk.Image()
        view_ext = gtk.Viewport()
        image_ext = gtk.Image()
        view_int.add(image_int)
        view_ext.add(image_ext)
        view_int = gtk.TreeView()
        view_ext = gtk.TreeView()
        self.add_notebook_page(name, view_int, view_ext)

        """
        builder_int = gtk.Builder()
        builder_int.add_objects_from_file(
            find("VisionView.glade"), ("ImageView",))
        motor_view_int = builder_int.get_object('ImageView')
        builder_ext = gtk.Builder()
        builder_ext.add_objects_from_file(
            find("VisionView.glade"), ("ImageView",))
        motor_view_ext = builder_ext.get_object('ImageView')

        self.add_notebook_page(name, motor_view_int, motor_view_ext)

        self.imageviewdict[name + "_int"] = builder_int.get_object("Image")
        self.imageviewdict[name + "_ext"] = builder_ext.get_object("Image")

        pass
def beep():
    """
    Global method, implemented to give an acoustic signal when a warning
    pops up.
    """
    if platform == 'win32':
        winsound.PlaySound(find("sound/beepPing.wav"), winsound.SND_ASYNC)
    elif platform == 'linux2':
        os.system('aplay %s' % find("sound/beepPing.wav"))
    print("Beep!")
 def setup_ui(self):
     # .ui-files can be edited using "glade" 
     builder = gtk.Builder()
     builder.add_from_file(find("debug.motor.ui"))
     builder.connect_signals(self)
     
     self.ui = make_ui_proxy(builder)
     self.ui.window.show()
    def __init__(self, name, data_callback, view_calback):
        """
        Initialises the external window and internal widgets

        :param name: The name of the View
        :type name: String
        """
        super(GenericView, self).__init__()

        self.view_name = name
        self.view_calback = view_calback
        self.data_callback = data_callback
        self.extern_window_shown = False

        # skalierung des
        self.set_property("xalign", 0)
        self.set_property("yalign", 0)
        self.set_property("xscale", 1)
        self.set_property("yscale", 1)

        #View elemente bauen
        self.builder = gtk.Builder()
        self.builder.add_objects_from_file(
            find("GenericView.glade"), ("View",))
        self.builder.get_object(
            'Name').set_markup("<b>%s</b>" % self.view_name)
        super(GenericView, self).add(self.builder.get_object("View"))
        # und anzeigen (nur sicherheitshalber)
        self.show_all()

        # externes Fenster erstellen, aber nicht anzeigen
        self.ext_builder = gtk.Builder()
        self.ext_builder.add_from_file(
            find("GenericViewExtern.glade"))
        self.ext_builder.get_object(
            "Name").set_markup("<b>%s</b>" % self.view_name)
        self.external_window = self.ext_builder.get_object("GenericExternView")

        # signals connecten
        self.builder.connect_signals(self)
        self.ext_builder.connect_signals(self)
    :members:

:members:
"""
from genericView import GenericNotebookView

import gtk

from bitbots.util import generate_find, find
import numpy as np
from math import sin, cos

import cv2

try:
    find('share/debug-ui-neu')
    find = generate_find('share/debug-ui-neu')
except:
    find = generate_find('tools/debug-ui-neu/share/debug-ui-neu')


class VisionView(GenericNotebookView):

    FACTOR = 5  # has to be 5, due to downscale on sender side
    FACTOR2 = 0.5  # downscale vor better view

    def __init__(self, data_callback, view_calback, name="Vision View"):
        super(VisionView, self).__init__(name,
                                         data_callback, view_calback)

        self.last_image = None
    def setup_ui(self):
        builder = gtk.Builder()
        builder.add_from_file(find("debug.ui"))
        builder.connect_signals(self)

        self.ui = make_ui_proxy(builder)