コード例 #1
0
ファイル: jcw_presenter.py プロジェクト: raboof/sk1-wx
    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()
コード例 #2
0
 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
コード例 #3
0
ファイル: jcw_filters.py プロジェクト: Scrik/sk1-wx
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
コード例 #4
0
ファイル: jcw_presenter.py プロジェクト: sk1project/sk1-wx
    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()
コード例 #5
0
ファイル: jcw_presenter.py プロジェクト: raboof/sk1-wx
 def new(self):
     self.model = JCW_Palette()
コード例 #6
0
ファイル: jcw_presenter.py プロジェクト: raboof/sk1-wx
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)
コード例 #7
0
ファイル: jcw_presenter.py プロジェクト: sk1project/sk1-wx
 def new(self):
     self.model = JCW_Palette()
コード例 #8
0
ファイル: jcw_presenter.py プロジェクト: sk1project/sk1-wx
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)