Beispiel #1
0
 def load(self):
     name = self.archive.getName()
     min = self.min_time()
     max = self.max_time()
     log.debug("GLScene.load: %s (min: %s, max %s)" % (name, min, max))
     self.loaded = True
     self.visible = True
Beispiel #2
0
 def add_camera(self, camera):
     """
     :param: GLCamera
     """
     log.debug("Session.add_camera: %s" % camera)
     if camera.name not in self.__cameras:
         self.__cameras[camera.name] = camera
Beispiel #3
0
 def remove_camera(self, camera):
     """
     :param: GLCamera
     """
     log.debug("Session.remove_camera: %s" % camera)
     if camera.name in self.__cameras:
         del self.__cameras[camera.name]
Beispiel #4
0
 def add_camera(self, camera):
     """
     :param camera: GLCamera object
     """
     log.debug("GLWidget.add_camera: %s" % camera)
     self.state.add_camera(camera)
     self.signal_new_camera.emit(camera)
Beispiel #5
0
 def add_camera(self, camera):
     """
     :param camera: GLCamera object
     """
     log.debug("GLWidget.add_camera: %s" % camera)
     self.state.add_camera(camera)
     self.signal_new_camera.emit(camera)
Beispiel #6
0
 def remove_camera(self, camera):
     """
     :param: GLCamera
     """
     log.debug("Session.remove_camera: %s" % camera)
     if camera.name in self.__cameras:
         del self.__cameras[camera.name]
Beispiel #7
0
 def save(self, filepath=None):
     """
     Saves a session to a .io file.
     """
     if filepath is None and self.filepath:
         filepath = self.filepath
     if not filepath:
         raise AbcViewError("File path not set")
     elif not filepath.endswith(self.EXT):
         filepath += self.EXT
     self.date = time.time()
     log.debug("saving: %s" % filepath)
     state = {
         "app": {
             "program": self.program,
             "version": self.version,
             "module": os.path.dirname(__file__),
         },
         "env": {
             "user": os.environ.get("USERNAME"),
             "host": os.environ.get("HOSTNAME"),
             "platform": sys.platform,
         },
         "date":
         self.date,
         "properties":
         self.properties,
         "cameras": [
             camera.serialize() for camera in self.__cameras.values()
             if camera.name != "interactive"
         ],
         "data":
         self.serialize()
     }
     json.dump(state, open(filepath, "w"), sort_keys=True, indent=4)
Beispiel #8
0
 def load(self):
     name = self.archive.getName()
     min = self.min_time()
     max = self.max_time()
     log.debug("GLScene.load: %s (min: %s, max %s)" % (name, min, max))
     self.loaded = True
     self.visible = True
Beispiel #9
0
 def add_camera(self, camera):
     """
     :param: GLCamera
     """
     log.debug("Session.add_camera: %s" % camera)
     if camera.name not in self.__cameras:
         self.__cameras[camera.name] = camera
Beispiel #10
0
 def remove_camera(self, camera):
     """
     :param: GLCamera
     """
     log.debug("[%s.remove_camera] %s" % (self, camera))
     if camera.name in self.__cameras:
         del self.__cameras[camera.name]
Beispiel #11
0
 def save(self, filepath=None):
     """
     Saves a session to a .io file.
     """
     if filepath is None and self.filepath:
         filepath = self.filepath
     if not filepath:
         raise AbcViewError("File path not set")
     elif not filepath.endswith(self.EXT):
         filepath += self.EXT
     self.filepath = filepath
     self.date = time.time()
     log.debug("[%s.save] %s" % (self, filepath))
     state = {
         "app": {
             "program": self.program,
             "version": self.version,
             "module": os.path.dirname(__file__),
         },
         "env": {
             "user": os.environ.get("USER", os.environ.get("USERNAME")),
             "host": os.environ.get("HOST", os.environ.get("HOSTNAME")),
             "platform": sys.platform,
         },
         "date": self.date,
         "min_time": self.min_time,
         "max_time": self.max_time,
         "current_time": self.current_time,
         "frames_per_second": self.frames_per_second,
         "properties": self.properties,
         "cameras": [camera.serialize() for camera in self.__cameras.values()],
         "data": self.serialize()
     }
     json.dump(state, open(filepath, "w"), sort_keys=True, indent=4)
Beispiel #12
0
 def add_camera(self, camera):
     """
     :param: GLCamera
     """
     log.debug("[%s.add_camera] %s" % (self, camera))
     if camera.name not in self.__cameras:
         self.__cameras[camera.name] = camera
Beispiel #13
0
 def add_camera(self, camera):
     """
     :param: GLCamera
     """
     log.debug("[%s.add_camera] %s" % (self, camera))
     if camera.name not in self.__cameras:
         self.__cameras[camera.name] = camera
Beispiel #14
0
 def remove_camera(self, camera):
     """
     :param: GLCamera
     """
     log.debug("[%s.remove_camera] %s" % (self, camera))
     if camera.name in self.__cameras:
         del self.__cameras[camera.name]
Beispiel #15
0
 def save(self, filepath=None):
     """
     Saves a session to a .io file.
     """
     if filepath is None and self.filepath:
         filepath = self.filepath
     if not filepath:
         raise AbcViewError("File path not set")
     elif not filepath.endswith(self.EXT):
         filepath += self.EXT
     self.date = time.time()
     log.debug("saving: %s" % filepath)
     state = {
         "app": {
             "program": self.program,
             "version": self.version,
             "module": os.path.dirname(__file__),
         },
         "env": {
             "user": os.environ.get("USERNAME"),
             "host": os.environ.get("HOSTNAME"),
             "platform": sys.platform,
         },
         "date": self.date,
         "properties": self.properties,
         "cameras": [camera.serialize() for camera in self.__cameras.values() if camera.name != "interactive"],
         "data": self.serialize()
     }
     json.dump(state, open(filepath, "w"), sort_keys=True, indent=4)
Beispiel #16
0
 def save(self, filepath=None):
     """
     Saves a session to a .io file.
     """
     if filepath is None and self.filepath:
         filepath = self.filepath
     if not filepath:
         raise AbcViewError("File path not set")
     elif not filepath.endswith(self.EXT):
         filepath += self.EXT
     self.filepath = filepath
     self.date = time.time()
     log.debug("[%s.save] %s" % (self, filepath))
     state = {
         "app": {
             "program": self.program,
             "version": self.version,
             "module": os.path.dirname(__file__),
         },
         "env": {
             "user": os.environ.get("USER", os.environ.get("USERNAME")),
             "host": os.environ.get("HOST", os.environ.get("HOSTNAME")),
             "platform": sys.platform,
         },
         "date": self.date,
         "min_time": self.min_time,
         "max_time": self.max_time,
         "current_time": self.current_time,
         "frames_per_second": self.frames_per_second,
         "properties": self.properties.local,
         "cameras":
         [camera.serialize() for camera in self.__cameras.values()],
         "data": self.serialize()
     }
     json.dump(state, open(filepath, "w"), sort_keys=True, indent=4)
Beispiel #17
0
def get_archive(filepath):
    """
    caches alembic archives
    """
    if filepath not in ARCHIVES:
        log.debug("[get_archive] %s" % filepath)
        ARCHIVES[filepath] = IArchive(str(filepath))
    return ARCHIVES[filepath]
Beispiel #18
0
def get_archive(filepath):
    """
    caches alembic archives
    """
    if filepath not in ARCHIVES:
        log.debug("[get_archive] %s" % filepath)
        ARCHIVES[filepath] = IArchive(str(filepath))
    return ARCHIVES[filepath]
Beispiel #19
0
    def remove_item(self, item):
        """
        Removes an item from the session

        :param item: Scene or Session object
        """
        if item in self.__items:
            self.__items.remove(item)
        else:
            log.debug("Item not in session: %s" % item)
Beispiel #20
0
    def remove_item(self, item):
        """
        Removes an item from the session

        :param item: Scene or Session object
        """
        if item in self.__items:
            self.__items.remove(item)
        else:
            log.debug("Item not in session: %s" % item)
Beispiel #21
0
 def add_view(self, viewer):
     """
     Adds a new view for this camera.
     """
     log.debug("[GLCameraMixin.add_view] %s %s" % (self.name, viewer))
     self.views[viewer] = AbcGLCamera(self)
     self.views[viewer].setTranslation(self._translation)
     self.views[viewer].setRotation(self._rotation)
     self.views[viewer].setScale(self._scale)
     self.views[viewer].setCenterOfInterest(self._center)
     self.views[viewer].setClippingPlanes(self._near, self._far)
Beispiel #22
0
 def remove_view(self, viewer):
     """
     Removes a view (glcamera) from this camera.
     """
     log.debug("[GLCameraMixin.remove_view] %s %s" % (self.name, viewer))
     if viewer in self.views:
         del self.views[viewer]
     # switch the default viewer for this camera
     for viewer in self.views:
         if viewer != self.viewer:
             self.viewer = viewer
Beispiel #23
0
 def remove_view(self, viewer):
     """
     Removes a view (glcamera) from this camera.
     """
     log.debug("[GLCameraMixin.remove_view] %s %s" % (self.name, viewer))
     if viewer in self.views:
         del self.views[viewer]
     # switch the default viewer for this camera
     for viewer in self.views:
         if viewer != self.viewer:
             self.viewer = viewer
Beispiel #24
0
 def add_view(self, viewer):
     """
     Adds a new view for this camera.
     """
     log.debug("[GLCameraMixin.add_view] %s %s" % (self.name, viewer))
     self.views[viewer] = AbcGLCamera(self)
     self.views[viewer].setTranslation(self._translation)
     self.views[viewer].setRotation(self._rotation)
     self.views[viewer].setScale(self._scale)
     self.views[viewer].setCenterOfInterest(self._center)
     self.views[viewer].setClippingPlanes(self._near, self._far)
Beispiel #25
0
 def load(self, func_name="load"):
     """
     Defers actually loading the scene until necessary.
     """
     if not self.loaded and not self.bad:
         log.debug("[%s] reading %s" % (func_name, self.filepath))
         try:
             super(SceneWrapper, self).__init__(self.filepath)
             self.loaded = True
         except Exception, e:
             log.warn("BAD ARCHIVE: %s\n%s" % (self.filepath, str(e)))
             self.bad = True
Beispiel #26
0
 def load(self, func_name="load"):
     """
     Defers actually loading the scene until necessary.
     """
     if not self.loaded and not self.bad:
         log.debug("[%s] reading %s" % (func_name, self.filepath))
         try:
             super(SceneWrapper, self).__init__(self.filepath)
             self.loaded = True
         except Exception, e:
             log.warn("BAD ARCHIVE: %s\n%s" % (self.filepath, str(e)))
             self.bad = True
Beispiel #27
0
    def set_camera(self, camera):
        """
        Sets the "active" camera for a given session.

        :param: GLCamera
        """
        log.debug("Session.set_camera: %s" % camera)
        if camera.name not in self.__cameras:
            self.__cameras[camera.name] = camera
        for name, cam in self.__cameras.items():
            cam.loaded = False
        self.__cameras[camera.name].loaded = True
Beispiel #28
0
    def set_camera(self, camera):
        """
        Sets the "active" camera for a given session.

        :param: GLCamera
        """
        log.debug("[%s.set_camera] %s" % (self, camera))
        if camera.name not in self.__cameras:
            self.__cameras[camera.name] = camera
        for name, cam in self.__cameras.items():
            cam.loaded = False
        self.__cameras[camera.name].loaded = True
Beispiel #29
0
    def add_item(self, item):
        """
        Adds and item to the session

        :param item: Scene or Session object
        """
        log.debug("[%s.add_item] %s" % (self, item))
        found_instances = [i.filepath for i in self.items if i.filepath == item.filepath]
        item.instance = len(found_instances) + 1
        item.parent = self
        self.apply_overrides(item)
        self.__items.append(item)
Beispiel #30
0
    def add_file(self, filepath):
        """
        Adds a filepath to the session

        :param filepath: path to file
        """
        log.debug("[%s.add_file] %s" % (self, filepath))
        if filepath.endswith(self.EXT):
            item = Session(filepath)
        elif filepath.endswith(Scene.EXT):
            item = Scene(filepath)
        else:
            raise AbcViewError("Unsupported file type: %s" % filepath)
        self.add_item(item)
        return item
Beispiel #31
0
    def add_file(self, filepath):
        """
        Adds a filepath to the session

        :param filepath: path to file
        """
        log.debug("[%s.add_file] %s" % (self, filepath))
        if filepath.endswith(self.EXT):
            item = Session(filepath)
        elif filepath.endswith(Scene.EXT):
            item = Scene(filepath)
        else:
            raise AbcViewError("Unsupported file type: %s" % filepath)
        self.add_item(item)
        return item
Beispiel #32
0
    def add_item(self, item):
        """
        Adds and item to the session

        :param item: Scene or Session object
        """
        log.debug("[%s.add_item] %s" % (self, item))
        found_instances = [i.filepath for i in self.items if i.filepath == item.filepath]
        item.instance = len(found_instances) + 1

        # TODO: replace with session deserialization
        if type(item) == Session:
            temp = copy.deepcopy(item.properties.local)
            item.properties = idict()
            item.properties.inherited.update(temp)

        self.__items.append(item)
Beispiel #33
0
    def add_item(self, item):
        """
        Adds and item to the session

        :param item: Scene or Session object
        """
        log.debug("[%s.add_item] %s" % (self, item))
        found_instances = [
            i.filepath for i in self.items if i.filepath == item.filepath
        ]
        item.instance = len(found_instances) + 1
        item.parent = self

        def apply_overrides(item):
            """applies item overrides to children"""
            if item.type() == Camera.type():
                return

            for path, overs in item.overrides.items():

                if item.type() == Scene.type():
                    if path == item.instancepath():
                        item.name = overs.get("name", item.name)
                        item.loaded = overs.get("loaded", item.loaded)
                        item.filepath = overs.get("filepath", item.filepath)
                        item.properties.update(overs.get("properties", {}))

                elif item.type() == Session.type():
                    for child in item.walk():
                        if child.type() == Camera.type():
                            continue
                        elif not path.startswith(child.instancepath()):
                            continue
                        elif path == child.instancepath():
                            child.name = overs.get("name", child.name)
                            child.loaded = overs.get("loaded", child.loaded)
                            child.filepath = overs.get("filepath",
                                                       child.filepath)
                            child.properties.update(overs.get(
                                "properties", {}))
                        elif child.type() == Session.type():
                            apply_overrides(child)

        apply_overrides(item)
        self.__items.append(item)
Beispiel #34
0
    def add_item(self, item):
        """
        Adds and item to the session

        :param item: Scene or Session object
        """
        log.debug("[%s.add_item] %s" % (self, item))
        found_instances = [
            i.filepath for i in self.items if i.filepath == item.filepath
        ]
        item.instance = len(found_instances) + 1

        # TODO: replace with session deserialization
        if type(item) == Session:
            temp = copy.deepcopy(item.properties.local)
            item.properties = idict()
            item.properties.inherited.update(temp)

        self.__items.append(item)
Beispiel #35
0
    def add_item(self, item):
        """
        Adds and item to the session

        :param item: Scene or Session object
        """
        log.debug("[%s.add_item] %s" % (self, item))
        found_instances = [i.filepath for i in self.items if i.filepath == item.filepath]
        item.instance = len(found_instances) + 1
        item.parent = self
      
        def apply_overrides(item):
            """applies item overrides to children"""
            if item.type() == Camera.type():
                return

            for path, overs in item.overrides.items():

                if item.type() == Scene.type():
                    if path == item.instancepath():
                        item.name = overs.get("name", item.name)
                        item.loaded = overs.get("loaded", item.loaded)
                        item.filepath = overs.get("filepath", item.filepath)
                        item.properties.update(overs.get("properties", {}))

                elif item.type() == Session.type():
                    for child in item.walk():
                        if child.type() == Camera.type():
                            continue
                        elif not path.startswith(child.instancepath()):
                            continue
                        elif path == child.instancepath():
                            child.name = overs.get("name", child.name)
                            child.loaded = overs.get("loaded", child.loaded)
                            child.filepath = overs.get("filepath", child.filepath)
                            child.properties.update(overs.get("properties", {}))
                        elif child.type() == Session.type():
                            apply_overrides(child)

        apply_overrides(item)
        self.__items.append(item)
Beispiel #36
0
 def _set_scenes(self):
     log.debug("use add_scene() to add scenes")
Beispiel #37
0
 def set_bad(self, bad):
     """
     Set this tree widget item as being "bad" for some reason, e.g. an 
     undrawable scene, with a visual indicator.
     """
     log.debug("[%s.set_bad] %s" % (self, bad))
Beispiel #38
0
 def set_bad(self, bad):
     """
     Set this tree widget item as being "bad" for some reason, e.g. an 
     undrawable scene, with a visual indicator.
     """
     log.debug("[%s.set_bad] %s" % (self, bad))
Beispiel #39
0
 def _not_settable(self, value):
     log.debug("GLICamera immutable attribute")
Beispiel #40
0
 def _not_settable(self, value):
     log.debug("ICamera name is immutable")
Beispiel #41
0
 def _not_settable(self, value):
     log.debug("GLICamera immutable attribute")
Beispiel #42
0
 def selection(self, x, y, camera):
     log.debug("[%s.selection] %s %s %s" % (self, x, y, camera))
     if camera:
         return self.scene.selection(int(x), int(y), camera)
     return None
Beispiel #43
0
 def selection(self, x, y, camera):
     log.debug("[%s.selection] %s %s %s" % (self, x, y, camera))
     if camera:
         return self.scene.selection(int(x), int(y), camera)
     return None
Beispiel #44
0
 def _set_cameras(self):
     log.debug("use add_camera()")
Beispiel #45
0
 def _set_scenes(self):
     log.debug("use add_scene() to add scenes")
Beispiel #46
0
 def _set_cameras(self):
     log.debug("use add_camera()")
Beispiel #47
0
 def _not_settable(self, value):
     log.debug("ICamera name is immutable")