Пример #1
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'),
    )
    __calculation__ = Calculation.SimpleInteractiveSpline

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

    def to_calculation(self, pattern):

        return self.call_calculation_function(pattern,
                                              self.to_dict())  # exclude=('id')

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

    @classmethod
    def from_calculation(cls, calculation):

        kwargs = cls.get_dict(calculation)
        return cls(**kwargs)
Пример #2
0
class LinePropertiesMixin:

    __attributes__ = (
        StringAttribute('line_color', 'lineColor'),
        StringAttribute('line_style', 'typeLine'),
    )

    __COLORS__ = (
        'black',
        'blue',
        'cornflowerblue',
        'darkBlue',
        'darkGreen',
        'darkRed',
        'darkviolet',
        'deeppink',
        'deepskyblue',
        'goldenrod',
        'green',
        'lightsalmon',
        'lime',
        'mediumseagreen',
        'orange',
        'violet',
        'yellow',
    )

    __LINE_STYLE__ = (
        'dashDotDotLine',
        'dashDotLine',
        'dashLine',
        'dotLine',
        'hair',  # should be solid
        'none',
    )
Пример #3
0
class XmlMeasurement(XmlObjectAdaptator):

    __tag__ = 'm'
    __attributes__ = (
        StringAttribute('name'),
        StringAttribute('value'),
        StringAttribute('full_name', default=''),
        StringAttribute('description', default=''),
    )
Пример #4
0
class ModelingItemMixin:

    __attributes__ = (
        IntAttribute('id'),
        IntAttribute('object_id', 'idObject'),
        StringAttribute('type'),
        BoolAttribute('in_use', 'inUse'),
    )
Пример #5
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'),
    )
Пример #6
0
class PointMixin(CalculationTypeMixin, MxMyMixin):

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

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

    def to_calculation(self, pattern):

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

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

    @classmethod
    def from_calculation(cls, calculation):

        kwargs = cls.get_dict(calculation, exclude=('mx', 'my'))
        label_offset = calculation.label_offset
        kwargs['mx'] = label_offset.x
        kwargs['my'] = label_offset.y
        return cls(**kwargs)
Пример #7
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]
Пример #8
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'), )
Пример #9
0
class AngleMixin:
    __attributes__ = (StringAttribute('angle'), )
Пример #10
0
class LengthMixin:
    __attributes__ = (StringAttribute('length'), )
Пример #11
0
class XyMixin:
    __attributes__ = (
        StringAttribute('x'),
        StringAttribute('y'),
    )