def dstyle(self, name=''):
     if not name:
         raise SketchLoadError(_("unnamed style"))
     style = self.style.AsDynamicStyle()
     style.SetName(name)
     self.style_dict[name] = style
     self.style = Style()
    def load_LTYPE(self):
        param = {
            '2': '',  # Linetype name
            '3': '',  # Descriptive text for linetype
            #'73': 0, # The number of linetype elements
            #'40': 0, # Total pattern length
            '49': [],  # Dash, dot or space length (one entry per element)
        }
        param = self.read_param(param, [0])

        name = upper(param['2'])
        if name:
            self.ltype_dict[name] = param
            dashes = []
            for i in xrange(len(param['49'])):
                dashes.append(abs(param['49'][i]) * self.unit_to_pt)

            name3 = param['3']
            #print name3, dashes
            if name3 and dashes:
                style = Style()
                style.line_dashes = tuple(dashes)
                style = style.AsDynamicStyle()
                style.SetName(name + name3)
                self.dynamic_style_dict[name] = style
 def use_style(self, name=''):
     if not name:
         raise SketchLoadError(_("unnamed style"))
     if not self.style.IsEmpty():
         self.prop_stack.load_AddStyle(self.style)
         self.style = Style()
     style = self.style_dict[name]
     self.prop_stack.load_AddStyle(style)
	def __init__(self, file, filename, match):
		GenericLoader.__init__(self, file, filename, match)
		self.file = file
		self.curstyle = Style()
		self.verbosity = 0
		self.gdiobjects = []
		self.dcstack = []
		self.curpoint = Point(0, 0)
 def get_prop_stack(self):
     stack = self.prop_stack
     if not self.style.IsEmpty():
         stack.load_AddStyle(self.style)
     stack.condense()
     if self.base_style is not None:
         self.prop_stack = PropertyStack(base=self.base_style.Duplicate())
     else:
         self.prop_stack = PropertyStack()
     self.style = Style()
     return stack
 def __init__(self, file, filename, match):
     LoaderWithComposites.__init__(self)
     self.file = file
     self.filename = filename
     self.match = match
     self.style = Style()
     if self.base_style is not None:
         self.prop_stack = PropertyStack(base=self.base_style.Duplicate())
     else:
         self.prop_stack = PropertyStack()
     self.messages = {}
 def initialize(self):
     self.curstyle = Style()
     self.curstyle.line_join = JoinRound
     self.curstyle.line_cap = CapRound
     self.cur_x = 0.0
     self.cur_y = 0.0
     self.draw = 0
     self.absolute = 1
     self.path = CreatePath()
     self.curpen = None
     self.penwidth = {}
     self.select_pen()
Example #8
0
 def initialize(self):
     self.draw = 0
     self.scale = .283464566929
     self.cur_x = 0.0
     self.cur_y = 0.0
     self.palette = Palette(self.basename)
     self.path = CreatePath()
     self.cur_style = Style()
     self.cur_style.line_width = 0.6
     self.cur_style.line_join = const.JoinRound
     self.cur_style.line_cap = const.CapRound
     self.cur_style.line_pattern = self.palette.next_color(1)
    def __init__(self, file, filename, match):
        GenericLoader.__init__(self, file, filename, match)

        self.file = file

        self.DWGCODEPAGE = 'latin1'
        self.unit_to_pt = 2.83464566929
        self.dynamic_style_dict = {}
        self.style_dict = {}
        self.ltype_dict = {
            'CONTINUOUS': {
                '2': 'CONTINUOUS',  # Linetype name
                '3': 'Solid line',  # Descriptive text for linetype
                '49': [],  # Dash, dot or space length 
                #(one entry per element)
            }
        }
        self.layer_dict = {
            '0': {
                '2': '0',  # Layer name
                '6': 'CONTINUOUS',  #Linetype name
                '62': 0,  # Color number
                '370': None,  #Line weight
            }
        }
        self.block_dict = {}
        self.stack = []
        self.stack_trafo = []
        self.default_layer = '0'
        self.default_style = 'STANDARD'
        self.default_block = None
        self.default_line_width = 30
        self.EXTMIN = (1e+20, 1e+20)
        self.EXTMAX = (-1e+20, -1e+20)
        self.PEXTMIN = (1e+20, 1e+20)
        self.PEXTMAX = (-1e+20, -1e+20)

        self.general_param = {
            '8': self.default_layer,  # Layer name
            '6': 'BYLAYER',  # Linetype name 
            '62': 256,  # Color number 
            '48': 1.0,  # Linetype scale 
            #'60': 0, # Object visibility. If 1 Invisible
        }

        self.curstyle = Style()
        self.update_trafo()
Example #10
0
	def get_line_style(self, **kw):
		if kw['8'] in self.layer_dict:
			self.default_layer = layer_name = kw['8']
		else:
			layer_name = self.default_layer

		linetype_name = upper(kw['6'])
		scale = kw['48']
		color_index = kw['62']
		
		
		style = Style()
		style.line_width = self.get_line_width()
		style.line_join = const.JoinRound
		style.line_cap = const.CapRound
		style.line_dashes = self.get_line_type(linetype_name = linetype_name, scale = scale, width = style.line_width)
		style.line_pattern = self.get_pattern(color_index)

		return style
Example #11
0
def styleFromFolder(path):
    print(path)
    assert (os.path.exists(path + "cfg.txt"))
    with open(path + "cfg.txt", "r") as f:
        lines = list(f)
        name = lines[0].strip()
        descr = lines[1].strip()
        if lines[2] == "CONV_NN":
            alg = Algorithms.Conv_NN
        else:
            alg = Algorithms.Cycle_GAN
        styleDir = path + lines[3].strip()
    styleImage = path + "style.jpg"
    if (os.path.exists(path + "preview.jpg")):
        previewImage = path + "preview.jpg"
    else:
        previewImage = None
    return Style(name=name,
                 descr=descr,
                 alg=alg,
                 styleDir=styleDir,
                 styleImage=styleImage,
                 computed=True,
                 previewImage=previewImage)
from app.io import load
from app.conf import const
from app.Graphics.color import ParseSketchColor, CreateCMYKColor, CreateRGBColor, CreateSPOTColor, \
   CreateRGBAColor, CreateCMYKAColor, CreateSPOTAColor
from app import SolidPattern, HatchingPattern,EmptyPattern, \
  LinearGradient, ConicalGradient, RadialGradient, ImageTilePattern, \
  Style, MultiGradient, Trafo, Translation, Point, \
  GridLayer, GuideLayer, GuideLine, Arrow, CreatePath, StandardColors, \
  GetFont

from app.io.load import GenericLoader

from app.Graphics import pagelayout, plugobj, blendgroup, text, image, eps,\
  properties

base_style = Style()
base_style.fill_pattern = EmptyPattern
base_style.fill_transform = 1
base_style.line_pattern = SolidPattern(StandardColors.black)
base_style.line_width = 0.0
base_style.line_join = const.JoinMiter
base_style.line_cap = const.CapButt
base_style.line_dashes = ()
base_style.line_arrow1 = None
base_style.line_arrow2 = None
base_style.font = None
base_style.font_size = 12.0

# sanity check: does base_style have all properties?
for key in dir(properties.factory_defaults):
    if not hasattr(base_style, key):
import struct
import operator
import copy
import types

from app import _, Trafo, Scale, Translation, Point, Polar, CreatePath, \
		CreateRGBColor, SolidPattern, EmptyPattern, LinearGradient, \
		MultiGradient, Style, const, StandardColors, GridLayer, GetFont, \
		HatchingPattern

from app.events.warn import INTERNAL, warn_tb
from app.io.load import GenericLoader, SketchLoadError
import uniconvertor
from app.Graphics import text

basestyle = Style()
basestyle.fill_pattern = EmptyPattern
basestyle.fill_transform = 1
basestyle.line_pattern = EmptyPattern
basestyle.line_width = 1.0
basestyle.line_join = const.JoinMiter
basestyle.line_cap = const.CapButt
basestyle.line_dashes = ()
basestyle.line_arrow1 = None
basestyle.line_arrow2 = None
basestyle.font = None
basestyle.font_size = 12.0


CGM_ID = {
	0x0020: 'BEGMF',