def convert_from_skp(self, skp_doc): skp_model = skp_doc.model namesize = JCW_NAMESIZE for item in skp_model.colors: namesize = max(namesize, len(item[3])) if skp_model.colors[0][0] == uc2const.COLOR_CMYK: colorspace = JCW_CMYK else: colorspace = JCW_RGB self.model = JCW_Palette(colorspace, namesize) for color in skp_model.colors: if colorspace == JCW_CMYK: clr = self.cms.get_cmyk_color(color) else: clr = self.cms.get_rgb_color(color) if clr[3]: clr[3] = clr[3].encode('iso-8859-1', errors='ignore') if not clr[3]: if colorspace == JCW_CMYK: clr[3] += cms.cmyk_to_hexcolor(color[1]) else: clr[3] += cms.rgb_to_hexcolor(color[1]) self.model.childs.append(JCW_Color(colorspace, namesize, color)) self.model.update_for_save()
def do_load(self): self.model = JCW_Palette() self.model.parse(self) if not self.model.name and self.filepath: filename = os.path.basename(self.filepath).split('.')[0] if filename in PALETTE_NAMES: self.model.name = PALETTE_NAMES[filename] else: self.model.name = '%s palette' % filename
class JCW_Loader(AbstractBinaryLoader): name = 'JCW_Loader' def do_load(self): self.model = JCW_Palette() self.model.parse(self) if not self.model.name and self.filepath: filename = os.path.basename(self.filepath).split('.')[0] if filename in PALETTE_NAMES: self.model.name = PALETTE_NAMES[filename] else: self.model.name = '%s palette' % filename
def convert_from_skp(self, skp_doc): skp_model = skp_doc.model namesize = JCW_NAMESIZE for item in skp_model.colors: namesize = max(namesize, len(item[3])) if skp_model.colors[0][0] == uc2const.COLOR_CMYK: colorspace = JCW_CMYK else: colorspace = JCW_RGB self.model = JCW_Palette(colorspace, namesize) for color in skp_model.colors: if colorspace == JCW_CMYK: clr = self.cms.get_cmyk_color(color) else: clr = self.cms.get_rgb_color(color) if clr[3]: try: txt = clr[3].encode("iso-8859-1") except: clr[3] = "" if not clr[3]: if colorspace == JCW_CMYK: clr[3] += cms.cmyk_to_hexcolor(color[1]) else: clr[3] += cms.rgb_to_hexcolor(color[1]) self.model.childs.append(JCW_Color(colorspace, namesize, color)) self.model.update_for_save()
def new(self): self.model = JCW_Palette()
class JCW_Presenter(BinaryModelPresenter): cid = uc2const.JCW config = None doc_file = '' model = None def __init__(self, appdata, cnf=None): cnf = cnf or {} self.config = JCW_Config() config_file = os.path.join(appdata.app_config_dir, self.config.filename) self.config.load(config_file) self.config.update(cnf) self.appdata = appdata self.cms = self.appdata.app.default_cms self.loader = JCW_Loader() self.saver = JCW_Saver() self.new() def new(self): self.model = JCW_Palette() def convert_from_skp(self, skp_doc): skp_model = skp_doc.model namesize = JCW_NAMESIZE for item in skp_model.colors: namesize = max(namesize, len(item[3])) if skp_model.colors[0][0] == uc2const.COLOR_CMYK: colorspace = JCW_CMYK else: colorspace = JCW_RGB self.model = JCW_Palette(colorspace, namesize) for color in skp_model.colors: if colorspace == JCW_CMYK: clr = self.cms.get_cmyk_color(color) else: clr = self.cms.get_rgb_color(color) if clr[3]: clr[3] = clr[3].encode('iso-8859-1', errors='ignore') if not clr[3]: if colorspace == JCW_CMYK: clr[3] += cms.cmyk_to_hexcolor(color[1]) else: clr[3] += cms.rgb_to_hexcolor(color[1]) self.model.childs.append(JCW_Color(colorspace, namesize, color)) self.model.update_for_save() def convert_to_skp(self, skp_doc): skp_model = skp_doc.model if self.model.name: skp_model.name = self.model.name else: skp_model.name = self.model.resolve_name skp_model.source = self.config.source if self.doc_file: filename = os.path.basename(self.doc_file) if skp_model.comments: skp_model.comments += 'n' skp_model.comments += 'Converted from %s' % filename for item in self.model.childs: clr = item.get_color() if clr: skp_model.colors.append(clr)
class JCW_Presenter(BinaryModelPresenter): cid = uc2const.JCW config = None doc_file = "" model = None def __init__(self, appdata, cnf={}): self.config = JCW_Config() config_file = os.path.join(appdata.app_config_dir, self.config.filename) self.config.load(config_file) self.config.update(cnf) self.appdata = appdata self.cms = self.appdata.app.default_cms self.loader = JCW_Loader() self.saver = JCW_Saver() self.new() def new(self): self.model = JCW_Palette() def convert_from_skp(self, skp_doc): skp_model = skp_doc.model namesize = JCW_NAMESIZE for item in skp_model.colors: namesize = max(namesize, len(item[3])) if skp_model.colors[0][0] == uc2const.COLOR_CMYK: colorspace = JCW_CMYK else: colorspace = JCW_RGB self.model = JCW_Palette(colorspace, namesize) for color in skp_model.colors: if colorspace == JCW_CMYK: clr = self.cms.get_cmyk_color(color) else: clr = self.cms.get_rgb_color(color) if clr[3]: try: txt = clr[3].encode("iso-8859-1") except: clr[3] = "" if not clr[3]: if colorspace == JCW_CMYK: clr[3] += cms.cmyk_to_hexcolor(color[1]) else: clr[3] += cms.rgb_to_hexcolor(color[1]) self.model.childs.append(JCW_Color(colorspace, namesize, color)) self.model.update_for_save() def convert_to_skp(self, skp_doc): skp_model = skp_doc.model if self.model.name: skp_model.name = "" + self.model.name else: skp_model.name = "" + self.model.resolve_name skp_model.source = "" + self.config.source if self.doc_file: filename = os.path.basename(self.doc_file) if skp_model.comments: skp_model.comments += "n" skp_model.comments += "Converted from %s" % filename for item in self.model.childs: clr = item.get_color() if clr: skp_model.colors.append(clr)