def __init__(self, policy=None): self.sobject = None self.snapshot = None self.policy = policy self.options = {} # by default, just render the first frame self.frame_range = FrameRange(1, 1, 1)
def get_text_value(my): sobject = my.get_current_sobject() if isinstance(sobject, Shot): frame_range = sobject.get_frame_range() frame_start = frame_range.frame_start frame_end = frame_range.frame_end frame_in, frame_out = sobject.get_frame_handles() else: from pyasm.prod.biz import FrameRange frame_start = my._get_frame_num(sobject, "tc_frame_start") frame_end = my._get_frame_num(sobject, "tc_frame_end") frame_range = FrameRange(frame_start, frame_end, 1) frame_in, frame_out = my._get_frame_handles(sobject) if frame_range.frame_end == frame_range.frame_start == 0: return 'n/a' total = frame_range.frame_end - frame_range.frame_start + 1 result = '%s - %s (%s)' % (frame_start, frame_end, total) if frame_in: handle_total = frame_out - frame_in + 1 result += ', %s - %s (%s)' % (frame_in, frame_out, handle_total) return result
def __init__(my, policy=None): my.sobject = None my.snapshot = None my.policy = policy my.options = {} # by default, just render the first frame my.frame_range = FrameRange(1, 1, 1)
def __init__(self, policy=None): self.sobject = None self.snapshot = None self.policy = policy self.options = {} # by default, just render the first frame self.frame_range = FrameRange(1,1,1)
def __init__(self, policy=None): self.sobject = None self.snapshot = None self.snapshot_xml = None self.snapshot_sobject = None self.context = None self.policy = policy # by default, just render the first frame self.frame_range = FrameRange(1, 1, 1) # FIXME: this is maya specific self.camera = "persp" self.layer_names = [] self.override = "" # FIXME: not general enough self.shot = None
def __init__(my, policy=None): my.sobject = None my.snapshot = None my.snapshot_xml = None my.snapshot_sobject = None my.context = None my.policy = policy # by default, just render the first frame my.frame_range = FrameRange(1, 1, 1) # FIXME: this is maya specific my.camera = "persp" my.layer_names = [] my.override = "" # FIXME: not general enough my.shot = None
def __init__(self, policy=None): self.sobject = None self.snapshot = None self.snapshot_xml = None self.snapshot_sobject = None self.context = None self.policy = policy # by default, just render the first frame self.frame_range = FrameRange(1,1,1) # FIXME: this is maya specific self.camera = "persp" self.layer_names = [] self.override = "" # FIXME: not general enough self.shot = None
def set_frame_range_values(my, start, end, by): frame_range = FrameRange(start, end, by) my.set_frame_range(frame_range)
def set_frame_range_values(self, start, end, by): frame_range = FrameRange(start, end, by) self.set_frame_range(frame_range)
class RenderPackage(Base): '''A package that is delivered to render submissions which contains all the information needed to render''' def __init__(self, policy=None): self.sobject = None self.snapshot = None self.policy = policy self.options = {} # by default, just render the first frame self.frame_range = FrameRange(1, 1, 1) def set_policy(self, policy): self.policy = policy def get_policy(self): return self.policy def set_sobject(self, sobject): '''set the sobject that is being rendered''' self.sobject = sobject def get_sobject(self): return self.sobject def set_snapshot(self, snapshot): '''set the snapshot that is being rendered''' self.snapshot = snapshot def get_snapshot(self): return self.snapshot def set_option(self, name, value): self.options[name] = str(value) def get_option(self, name, no_exception=False): value = self.options.get(name) if not no_exception and not value: raise TacticException( "Mandatory option [%s] not found in render package" % name) return value def set_options(self, options): self.options = options def get_options(self): return self.options def set_frame_range(self, frame_range): self.frame_range = frame_range # if the policy sets a frame by, then use it frame_by = self.policy.get_value("frame_by") if frame_by: self.frame_range.set_frame_by(int(frame_by)) def set_frame_range_values(self, start, end, by): frame_range = FrameRange(start, end, by) self.set_frame_range(frame_range) def get_frame_range(self): return self.frame_range
def get_display(my): sobject = my.get_current_sobject() if isinstance(sobject, Shot): frame_range = sobject.get_frame_range() frame_in, frame_out = sobject.get_frame_handles() frame_notes = sobject.get_frame_notes() else: from pyasm.prod.biz import FrameRange frame_start = my._get_frame_num(sobject, "tc_frame_start") frame_end = my._get_frame_num(sobject, "tc_frame_end") frame_range = FrameRange(frame_start, frame_end, 1 ) frame_in, frame_out = my._get_frame_handles(sobject) frame_notes = sobject.get_value("frame_note", no_exception=True) frame_notes = WikiUtil().convert(frame_notes) if frame_range.frame_end == frame_range.frame_start == 0: return 'n/a' widget = SpanWdg() widget.set_attr("nowrap", "1") offset = 2 label_width = 16 if frame_range.frame_start > 99: label_width = 20 # start / end frame duration_color = '#969353' div = DivWdg() div.add_tip('START -- END (TOTAL)') wdg_width = 150 div.add_style('width', wdg_width) total = frame_range.frame_end - frame_range.frame_start + 1 start_frame = SpanWdg(str(frame_range.frame_start)) end_frame = SpanWdg(str(frame_range.frame_end)) end_div = FloatDivWdg(end_frame) duration_width = wdg_width * 0.2 - offset #spacer_width = float('%.2f' %((duration_width + offset) * (frame_range.frame_start -1 ) /\ # frame_range.frame_end)) spacer_width = 0 start_div = FloatDivWdg(start_frame, width=label_width+spacer_width ) start_div.add_class('right_content') duration = FloatDivWdg( width=duration_width ) duration.add_style("border: 1px dotted %s" % duration_color) duration.add_style("margin-top: 3px") duration.add_style("margin-left: 5px") duration.add_style("margin-right: 5px") duration.add_style("height: 3px") duration.add_style("line-height: 3px") div.add(start_div) div.add(duration) div.add(end_div) dur_text = FloatDivWdg('<i>(%s)</i>' %total) dur_text.add_style("opacity", "0.3") div.add(dur_text) widget.add(div) widget.add(HtmlElement.br()) if frame_in: # in / out frame duration_color = '#b8b365' div = DivWdg() div.add_tip('IN -- OUT') div.add_style('width', wdg_width) handle_total = frame_out - frame_in + 1 in_frame = SpanWdg(str(frame_in)) out_frame = SpanWdg(str(frame_out)) if frame_range.frame_start == 0: frame_range.frame_start = 0.001 spacer_width = float('%.2f' % ((spacer_width) * \ float(frame_in) /frame_range.frame_start )) in_div = FloatDivWdg(in_frame, width=label_width + spacer_width) in_div.add_class('right_content') out_div = FloatDivWdg(out_frame) factor = float(handle_total) / total if factor > 1: factor = 1 duration_width = (duration_width + offset) * factor - offset duration = FloatDivWdg( width=duration_width ) duration.add_style("border: 1px solid %s" % duration_color) duration.add_style("background", duration_color) duration.add_style("margin-top: 5px") duration.add_style("margin-left: 5px") duration.add_style("margin-right: 5px") duration.add_style("line-height: 1px") duration.add(' ') # IE needs that to draw a 1px wide div bar = FloatDivWdg('<!-- -->', width=1) bar.add_style("margin-top: 1px") bar.add_style("line-height: 10px") bar.add_style("background", duration_color) div.add(in_div) div.add(bar) div.add(duration) div.add(bar) div.add(out_div) dur_text = SpanWdg('<i>(%s)</i>' %handle_total) dur_text.add_style("opacity", "0.3") div.add(dur_text) widget.add(div) if frame_notes: widget.add(HtmlElement.br()) widget.add(frame_notes) return widget
class RenderPackage(Base): '''A package that is delivered to render submissions which contains all the information needed to render''' def __init__(self, policy=None): self.sobject = None self.snapshot = None self.policy = policy self.options = {} # by default, just render the first frame self.frame_range = FrameRange(1,1,1) def set_policy(self, policy): self.policy = policy def get_policy(self): return self.policy def set_sobject(self, sobject): '''set the sobject that is being rendered''' self.sobject = sobject def get_sobject(self): return self.sobject def set_snapshot(self, snapshot): '''set the snapshot that is being rendered''' self.snapshot = snapshot def get_snapshot(self): return self.snapshot def set_option(self, name, value): self.options[name] = str(value) def get_option(self, name, no_exception=False): value = self.options.get(name) if not no_exception and not value: raise TacticException("Mandatory option [%s] not found in render package" % name) return value def set_options(self, options): self.options = options def get_options(self): return self.options def set_frame_range(self, frame_range): self.frame_range = frame_range # if the policy sets a frame by, then use it frame_by = self.policy.get_value("frame_by") if frame_by: self.frame_range.set_frame_by(int(frame_by)) def set_frame_range_values(self, start, end, by): frame_range = FrameRange(start, end, by) self.set_frame_range(frame_range) def get_frame_range(self): return self.frame_range
def get_display(my): sobject = my.get_current_sobject() if isinstance(sobject, Shot): frame_range = sobject.get_frame_range() frame_in, frame_out = sobject.get_frame_handles() frame_notes = sobject.get_frame_notes() else: from pyasm.prod.biz import FrameRange frame_start = my._get_frame_num(sobject, "tc_frame_start") frame_end = my._get_frame_num(sobject, "tc_frame_end") frame_range = FrameRange(frame_start, frame_end, 1) frame_in, frame_out = my._get_frame_handles(sobject) frame_notes = sobject.get_value("frame_note", no_exception=True) frame_notes = WikiUtil().convert(frame_notes) if frame_range.frame_end == frame_range.frame_start == 0: return 'n/a' widget = SpanWdg() widget.set_attr("nowrap", "1") offset = 2 label_width = 16 if frame_range.frame_start > 99: label_width = 20 # start / end frame duration_color = '#969353' div = DivWdg() div.add_tip('START -- END (TOTAL)') wdg_width = 100 div.add_style('width', wdg_width) total = frame_range.frame_end - frame_range.frame_start + 1 start_frame = SpanWdg(str(frame_range.frame_start)) end_frame = SpanWdg(str(frame_range.frame_end)) end_div = FloatDivWdg(end_frame) duration_width = wdg_width * 0.2 - offset spacer_width = float('%.2f' %((duration_width + offset) * (frame_range.frame_start -1 ) /\ frame_range.frame_end)) start_div = FloatDivWdg(start_frame, width=label_width + spacer_width) start_div.add_class('right_content') duration = FloatDivWdg(width=duration_width) duration.add_style("border: 1px dotted %s" % duration_color) duration.add_style("margin-top: 3px") duration.add_style("margin-left: 5px") duration.add_style("margin-right: 5px") duration.add_style("height: 3px") duration.add_style("line-height: 3px") div.add(start_div) div.add(duration) div.add(end_div) dur_text = FloatDivWdg('(%s)' % total) dur_text.add_style("opacity", "0.5") div.add(dur_text) widget.add(div) widget.add(HtmlElement.br()) if frame_in: # in / out frame duration_color = '#b8b365' div = DivWdg() div.add_tip('IN -- OUT') div.add_style('width', wdg_width) handle_total = frame_out - frame_in + 1 in_frame = SpanWdg(str(frame_in)) out_frame = SpanWdg(str(frame_out)) if frame_range.frame_start == 0: frame_range.frame_start = 0.001 spacer_width = float('%.2f' % ((spacer_width) * \ float(frame_in) /frame_range.frame_start )) in_div = FloatDivWdg(in_frame, width=label_width + spacer_width) in_div.add_class('right_content') out_div = FloatDivWdg(out_frame) factor = float(handle_total) / total if factor > 1: factor = 1 duration_width = (duration_width + offset) * factor - offset duration = FloatDivWdg(width=duration_width) duration.add_style("border: 1px solid %s" % duration_color) duration.add_style("background", duration_color) duration.add_style("margin-top: 5px") duration.add_style("margin-left: 5px") duration.add_style("margin-right: 5px") duration.add_style("line-height: 1px") duration.add(' ') # IE needs that to draw a 1px wide div bar = FloatDivWdg('<!-- -->', width=1) bar.add_style("margin-top: 1px") bar.add_style("height: 10px") bar.add_style("line-height: 10px") bar.add_style("background", duration_color) div.add(in_div) div.add(bar) div.add(duration) div.add(bar) div.add(out_div) dur_text = SpanWdg('(%s)' % handle_total) div.add(dur_text) widget.add(div) if frame_notes: widget.add(HtmlElement.br()) widget.add(frame_notes) return widget
class BaseRenderContext(Base): '''The context under which a render take place. This includes all of the settings and specific flags for a particular render''' def __init__(self, policy=None): self.sobject = None self.snapshot = None self.snapshot_xml = None self.snapshot_sobject = None self.context = None self.policy = policy # by default, just render the first frame self.frame_range = FrameRange(1, 1, 1) # FIXME: this is maya specific self.camera = "persp" self.layer_names = [] self.override = "" # FIXME: not general enough self.shot = None def set_policy(self, policy): self.policy = policy def set_override(self, override): '''set overrides to render parameters''' self.override = override def get_override(self): return self.override # information from policy def get_resolution(self): return self.policy.get_resolution() def get_layer_names(self): return self.layer_names def add_layer(self, layer_name): self.layer_names.append(layer_name) def get_input_path(self): '''gets the input file to be rendered''' snapshot = self.get_snapshot() lib_dir = snapshot.get_lib_dir() # FIXME: big assumption that snapshot type == file_type # FIXME: maya files only ???? filename = snapshot.get_file_name_by_type("maya") if not filename: filename = snapshot.get_file_name_by_type("xsi") if not filename: filename = snapshot.get_file_name_by_type("main") if not filename: raise TacticException( "Cannot render snapshot [%s] because file is not supported" % snapshot.get_code()) input_path = "%s/%s" % (lib_dir, filename) return input_path def get_output_prefix(self): # FIXME: should get this from naming conventions return "image_test" def get_output_ext(self): # FIXME: should take this from render policy return "png" def get_output_padding(self): return 4 def get_output_pattern(self): # ie: "image.jpg.####" return "%s.%s.####" % (self.get_output_prefix(), self.get_output_ext()) def get_render_dir(self): ticket = Environment.get_security().get_ticket_key() tmpdir = Environment.get_tmp_dir() render_dir = "%s/temp/%s" % (tmpdir, ticket) System().makedirs(render_dir) return render_dir def set_shot(self, shot): self.shot = shot # setting the shot always sets the frames self.frame_range = shot.get_frame_range() def get_shot(self): return self.shot def set_sobject(self, sobject): '''set the sobject that is being rendered''' self.sobject = sobject def get_sobject(self): return self.sobject def set_camera(self, camera): print "Overriding camera: ", camera self.camera = camera def get_camera(self): return self.camera def set_frame_range(self, frame_range): self.frame_range = frame_range # if the policy sets a frame by, then use it frame_by = self.policy.get_value("frame_by") if frame_by: self.frame_range.set_frame_by(int(frame_by)) def set_frame_range_values(self, start, end, by): frame_range = FrameRange(start, end, by) self.set_frame_range(frame_range) def get_frame_range(self): return self.frame_range def set_snapshot(self, snapshot): assert snapshot != None self.snapshot = snapshot self.snapshot_xml = snapshot.get_value("snapshot") #self.sobject = self.snapshot.get_sobject() self.snapshot_sobject = self.snapshot.get_sobject() def set_snapshot_xml(self, snapshot_xml): self.snapshot_xml = snapshot_xml def get_snapshot(self): return self.snapshot def get_snapshot_xml(self): return self.snapshot_xml def set_context(self, context): self.context = context def get_context(self): return self.context def set_policy(self, policy): self.policy = policy def get_extra_settings(self): # these extra settings are determined by the policy return self.policy.get_value("extra_settings") def get_name(self): return self.__class__.__name__ def get_xml_data(self): '''create an XML document which can be stored in the queue for for informaiton about this render context.''' xml = Xml() xml.create_doc("data") root = xml.get_root_node() if self.snapshot: element = xml.create_text_element("search_key", self.sobject.get_search_key()) root.appendChild(element) element = xml.create_text_element("snapshot_code", self.snapshot.get_code()) root.appendChild(element) elif self.sobject: element = xml.create_text_element("search_key", self.sobject.get_search_key()) root.appendChild(element) # add information about the frames element = xml.create_text_element("prefix", self.get_output_prefix()) root.appendChild(element) element = xml.create_text_element("ext", self.get_output_ext()) root.appendChild(element) element = xml.create_text_element("padding", str(self.get_output_padding())) root.appendChild(element) element = xml.create_text_element("file_range", self.frame_range.get_key()) root.appendChild(element) element = xml.create_text_element("pattern", self.get_output_pattern()) root.appendChild(element) # add layer information for layer_name in self.layer_names: element = xml.create_text_element("layer_name", layer_name) root.appendChild(element) return xml.to_string()
class BaseRenderContext(Base): '''The context under which a render take place. This includes all of the settings and specific flags for a particular render''' def __init__(self, policy=None): self.sobject = None self.snapshot = None self.snapshot_xml = None self.snapshot_sobject = None self.context = None self.policy = policy # by default, just render the first frame self.frame_range = FrameRange(1,1,1) # FIXME: this is maya specific self.camera = "persp" self.layer_names = [] self.override = "" # FIXME: not general enough self.shot = None def set_policy(self, policy): self.policy = policy def set_override(self, override): '''set overrides to render parameters''' self.override = override def get_override(self): return self.override # information from policy def get_resolution(self): return self.policy.get_resolution() def get_layer_names(self): return self.layer_names def add_layer(self, layer_name): self.layer_names.append(layer_name) def get_input_path(self): '''gets the input file to be rendered''' snapshot = self.get_snapshot() lib_dir = snapshot.get_lib_dir() # FIXME: big assumption that snapshot type == file_type # FIXME: maya files only ???? filename = snapshot.get_file_name_by_type("maya") if not filename: filename = snapshot.get_file_name_by_type("xsi") if not filename: filename = snapshot.get_file_name_by_type("main") if not filename: raise TacticException("Cannot render snapshot [%s] because file is not supported" % snapshot.get_code() ) input_path = "%s/%s" % (lib_dir,filename) return input_path def get_output_prefix(self): # FIXME: should get this from naming conventions return "image_test" def get_output_ext(self): # FIXME: should take this from render policy return "png" def get_output_padding(self): return 4 def get_output_pattern(self): # ie: "image.jpg.####" return "%s.%s.####" % (self.get_output_prefix(), self.get_output_ext() ) def get_render_dir(self): ticket = Environment.get_security().get_ticket_key() tmpdir = Environment.get_tmp_dir() render_dir = "%s/temp/%s" % (tmpdir, ticket) System().makedirs(render_dir) return render_dir def set_shot(self, shot): self.shot = shot # setting the shot always sets the frames self.frame_range = shot.get_frame_range() def get_shot(self): return self.shot def set_sobject(self, sobject): '''set the sobject that is being rendered''' self.sobject = sobject def get_sobject(self): return self.sobject def set_camera(self, camera): print "Overriding camera: ", camera self.camera = camera def get_camera(self): return self.camera def set_frame_range(self, frame_range): self.frame_range = frame_range # if the policy sets a frame by, then use it frame_by = self.policy.get_value("frame_by") if frame_by: self.frame_range.set_frame_by(int(frame_by)) def set_frame_range_values(self, start, end, by): frame_range = FrameRange(start, end, by) self.set_frame_range(frame_range) def get_frame_range(self): return self.frame_range def set_snapshot(self, snapshot): assert snapshot != None self.snapshot = snapshot self.snapshot_xml = snapshot.get_value("snapshot") #self.sobject = self.snapshot.get_sobject() self.snapshot_sobject = self.snapshot.get_sobject() def set_snapshot_xml(self, snapshot_xml): self.snapshot_xml = snapshot_xml def get_snapshot(self): return self.snapshot def get_snapshot_xml(self): return self.snapshot_xml def set_context(self, context): self.context = context def get_context(self): return self.context def set_policy(self, policy): self.policy = policy def get_extra_settings(self): # these extra settings are determined by the policy return self.policy.get_value("extra_settings") def get_name(self): return self.__class__.__name__ def get_xml_data(self): '''create an XML document which can be stored in the queue for for informaiton about this render context.''' xml = Xml() xml.create_doc("data") root = xml.get_root_node() if self.snapshot: element = xml.create_text_element("search_key", self.sobject.get_search_key()) root.appendChild(element) element = xml.create_text_element("snapshot_code", self.snapshot.get_code()) root.appendChild(element) elif self.sobject: element = xml.create_text_element("search_key", self.sobject.get_search_key()) root.appendChild(element) # add information about the frames element = xml.create_text_element("prefix", self.get_output_prefix() ) root.appendChild(element) element = xml.create_text_element("ext", self.get_output_ext() ) root.appendChild(element) element = xml.create_text_element("padding", str(self.get_output_padding() )) root.appendChild(element) element = xml.create_text_element("file_range", self.frame_range.get_key() ) root.appendChild(element) element = xml.create_text_element("pattern", self.get_output_pattern() ) root.appendChild(element) # add layer information for layer_name in self.layer_names: element = xml.create_text_element("layer_name", layer_name ) root.appendChild(element) return xml.to_string()