示例#1
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]
示例#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)
示例#3
0
class DetailGrainline(MxMyMixin, VisibleRotationMixin, XmlObjectAdaptator):

    # <grainline arrows="0" mx="0" length="0" visible="false" rotation="90" my="0"/>

    __attributes__ = (
        IntAttribute('arrows'),
        IntAttribute('length'),
    )
示例#4
0
class ModelingItemMixin:

    __attributes__ = (
        IntAttribute('id'),
        IntAttribute('object_id', 'idObject'),
        StringAttribute('type'),
        BoolAttribute('in_use', 'inUse'),
    )
示例#5
0
class CalculationMixin:

    __attributes__ = (
        IntAttribute('id'),
    )

    __operation__ = None # operation's class

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

    def call_operation_function(self, sketch, kwargs):
        # Fixme: map valentina name -> ...
        method = getattr(sketch, self.__operation__.__name__)
        return method(**kwargs)

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

    def to_operation(self, sketch):
        raise NotImplementedError

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

    @classmethod
    def from_operation(operation):
        raise NotImplementedError
示例#6
0
class ShoulderPoint(PointLinePropertiesMixin, Line1Mixin, LengthMixin,
                    XmlObjectAdaptator):

    # <point id="21" typeLine="hair" mx="0.7" p2Line="14" length="Line_X_XY*2" pShoulder="20" name="Sh"
    # p1Line="5" lineColor="lightsalmon" type="shoulder" my="-1.3"/>

    __type__ = 'shoulder'
    # __operation__ = SketchOperation.ShoulderPoint
    __attributes__ = (IntAttribute('shoulder_point', 'pShoulder'), )
示例#7
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'),
    )
示例#8
0
class FontSizeMixin:

    __attributes__ = (IntAttribute('fontSize'), )
示例#9
0
class HeightWidthMixin:

    __attributes__ = (
        IntAttribute('height'),
        IntAttribute('width'),
    )
示例#10
0
class VisibleRotationMixin:

    __attributes__ = (
        BoolAttribute('visible'),
        IntAttribute('rotation'),
    )
示例#11
0
class CenterRadiusMixin:
    __attributes__ = (
        IntAttribute('center'),  # center point
        StringAttribute('radius'),
    )
示例#12
0
class Line2Mixin:
    __attributes__ = (
        IntAttribute('point1_line2', 'p1Line2'),
        IntAttribute('point2_line2', 'p2Line2'),
    )
示例#13
0
class BasePointMixin:
    __attributes__ = (IntAttribute('base_point', 'basePoint'), )
示例#14
0
class FirstSecondThirdPointMixin(FirstSecondPointMixin):
    __attributes__ = (IntAttribute('third_point', 'thirdPoint'), )
示例#15
0
class FirstSecondPointMixin:
    __attributes__ = (
        IntAttribute('first_point', 'firstPoint'),
        IntAttribute('second_point', 'secondPoint'),
    )