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
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
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]
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)
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)
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]
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)
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
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)
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)
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]
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)
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)
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
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
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
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
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)
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
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)
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)
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)
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)
def _set_scenes(self): log.debug("use add_scene() to add scenes")
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))
def _not_settable(self, value): log.debug("GLICamera immutable attribute")
def _not_settable(self, value): log.debug("ICamera name is immutable")
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
def _set_cameras(self): log.debug("use add_camera()")