Exemple #1
0
class StrokeMixin:

    __attributes__ = (
        StringAttribute('stroke_line_cap', 'stroke-linecap'),
        StringAttribute('stroke_line_join', 'stroke-linejoin'),
        NumberAttribute('stroke_miter_limit', 'stroke-miterlimit'),
        PercentLengthAttribute('stroke_width', 'stroke-width'),
        FloatListAttribute(
            'stroke_dasharray',
            'stroke-dasharray')  # stroke-dasharray="20,10,5,5,5,10"
    )

    LINE_CAP_STYLE = (
        'butt',
        'round',
        'square',
        'inherit',
    )

    LINE_JOIN_STYLE = (
        'miter',
        'round',
        'bevel',
        'inherit',
    )
Exemple #2
0
class SimpleInteractiveSpline(SplineMixin, XmlObjectAdaptator):

    # <spline id="53" angle2="138.403" length2="14.0301" angle1="329.987" length1="18.2062"
    # point4="52" type="simpleInteractive" point1="51" color="blue"/>

    __type__ = 'simpleInteractive'
    __attributes__ = (
        IntAttribute('first_point', 'point1'),
        IntAttribute('second_point', 'point4'),
        StringAttribute('length1'),
        StringAttribute('length2'),
        StringAttribute('angle1'),
        StringAttribute('angle2'),
        StringAttribute('line_color', 'color'),
    )
    __operation__ = SketchOperation.SimpleInteractiveSpline

    ##############################################

    def to_operation(self, sketch):
        return self.call_operation_function(sketch,
                                            self.to_dict())  # exclude=('id')

    ##############################################

    @classmethod
    def from_operation(cls, operation):
        kwargs = cls.get_dict(operation)
        return cls(**kwargs)
Exemple #3
0
class XmlMeasurement(XmlObjectAdaptator):

    __tag__ = 'm'
    __attributes__ = (
        StringAttribute('name'),
        StringAttribute('value'),
        StringAttribute('full_name', default=''),
        StringAttribute('description', default=''),
    )
Exemple #4
0
class Group(FontMixin, PathMixin, SvgElementMixin, XmlObjectAdaptator):
    """Used to group together elements"""

    __tag__ = 'g'

    __attributes__ = (
        StringAttribute('clip_path', 'clip-path', None),
        StringAttribute('data_name', 'data-name'),
        #fill="the fill color for the group"
        #opacity="the opacity for the group"
    )
Exemple #5
0
class PointMixin(CalculationTypeMixin, MxMyMixin):

    __tag__ = 'point'
    __attributes__ = (
        StringAttribute('name'),
    )

    ##############################################

    def to_operation(self, sketch):

        kwargs = self.to_dict(exclude=('mx', 'my')) # id'
        kwargs['label_offset'] = Vector2D(self.mx, self.my)
        return self.call_operation_function(sketch, kwargs)

    ##############################################

    @classmethod
    def from_operation(cls, operation):

        kwargs = cls.get_dict(operation, exclude=('mx', 'my'))
        label_offset = operation.label_offset
        kwargs['mx'] = label_offset.x
        kwargs['my'] = label_offset.y
        return cls(**kwargs)
Exemple #6
0
class Detail(MxMyMixin, XmlObjectAdaptator):

    # <detail id="118" version="2" forbidFlipping="false" width="1" united="false" mx="0"
    #  name="Devant" inLayout="true" seamAllowance="true" my="0">

    __attributes__ = (
        IntAttribute('id'),
        IntAttribute('version'),
        BoolAttribute('forbidFlipping'),
        IntAttribute('width'),
        BoolAttribute('united'),
        StringAttribute('name'),
        BoolAttribute('inLayout'),
        BoolAttribute('seamAllowance'),
    )

    ##############################################

    def __init__(self, modeling, *args, **kwargs):

        XmlObjectAdaptator.__init__(self, *args, **kwargs)
        self._modeling = modeling
        self._nodes = []

    ##############################################

    def append_node(self, node):
        self._nodes.append(node)

    ##############################################

    def iter_on_nodes(self):
        for node in self._nodes:
            yield node, self._modeling[node.object_id]
Exemple #7
0
class DetailData(HeightWidthMixin, MxMyMixin, FontSizeMixin, VisibleRotationMixin, XmlObjectAdaptator):

    # <data letter="" width="0" mx="0" height="0" fontSize="0" visible="false" rotation="0" my="0"/>

    __attributes__ = (
        StringAttribute('letter'),
    )
Exemple #8
0
class ModelingItemMixin:

    __attributes__ = (
        IntAttribute('id'),
        IntAttribute('object_id', 'idObject'),
        StringAttribute('type'),
        BoolAttribute('in_use', 'inUse'),
    )
Exemple #9
0
class DetailNode(XmlObjectAdaptator):

    # <node idObject="108" type="NodePoint"/>
    # <node idObject="120" reverse="1" type="NodeSpline"/>

    __attributes__ = (
        IntAttribute('object_id', 'idObject'),
        StringAttribute('type'),
        BoolAttribute('reverse'),
    )
Exemple #10
0
class Text(PositionMixin, DeltaMixin, FontMixin, ColorMixin, SvgElementMixin,
           TextXmlObjectAdaptator):
    """Defines a text"""

    __tag__ = 'text'

    # x="a list of x-axis positions. The nth x-axis position is given to the nth character in the text. If there are additional characters after the positions run out they are placed after the last character. 0 is default"
    # y="a list of y-axis positions. (see x). 0 is default"
    # dx="a list of lengths which moves the characters relative to the absolute position of the last glyph drawn. (see x)"
    # dy="a list of lengths which moves the characters relative to the absolute position of the last glyph drawn. (see x)"
    # rotate="a list of rotations. The nth rotation is performed on the nth character. Additional characters are NOT given the last rotation value"
    # textLength="a target length for the text that the SVG viewer will attempt to display the text between by adjusting the spacing and/or the glyphs. (default: The text's normal length)"
    # lengthAdjust="tells the viewer what to adjust to try to accomplish rendering the text if the length is specified. The two values are 'spacing' and 'spacingAndGlyphs'"

    __attributes__ = (
        # Fixme: common ???
        StringAttribute('_class', 'class', None),
        StringAttribute('style'),
    )
Exemple #11
0
class Svg(PositionMixin, SizeMixin, XmlObjectAdaptator):
    """Creates an SVG document fragment"""

    __tag__ = 'svg'

    # xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve"

    __attributes__ = (
        StringAttribute('version'),
        FloatListAttribute('view_box', 'viewBox'),
        # the points "seen" in this SVG drawing area. 4 values separated by white space or
        # commas. (min x, min y, width, height)
        StringAttribute('preserve_aspect_ratio', 'preserveAspectRatio'),
        # 'none' or any of the 9 combinations of 'xVALYVAL' where VAL is 'min', 'mid' or 'max'.
        # (default xMidYMid)
        StringAttribute('zoom_and_pan', 'zoomAndPan')
        # 'magnify' or 'disable'. Magnify option allows users to pan and zoom your file
        # (default magnify)
    )
Exemple #12
0
class IdMixin:
    """Core attribute"""

    __attributes__ = (StringAttribute('id'), )
Exemple #13
0
class ColorMixin:

    __attributes__ = (
        StringAttribute('fill'),  # none inherit red #ffbb00
        StringAttribute('stroke'),
    )
Exemple #14
0
class CenterRadiusMixin:
    __attributes__ = (
        IntAttribute('center'),  # center point
        StringAttribute('radius'),
    )
Exemple #15
0
class AngleMixin:
    __attributes__ = (StringAttribute('angle'), )
Exemple #16
0
class LengthMixin:
    __attributes__ = (StringAttribute('length'), )
Exemple #17
0
class XyMixin:
    __attributes__ = (
        StringAttribute('x'),
        StringAttribute('y'),
    )
Exemple #18
0
class FontMixin:

    __attributes__ = (
        StringAttribute('font_size', 'font-size'),
        StringAttribute('font_family', 'font-family'),
    )
Exemple #19
0
class SizeMixin:

    __attributes__ = (
        StringAttribute('height'),
        StringAttribute('width'),
    )
Exemple #20
0
class PointsMixin:

    __attributes__ = (
        StringAttribute('points'),  # points="200,10 250,190 160,210"
    )
Exemple #21
0
class StyleMixin:

    __attributes__ = (StringAttribute('style'), )