예제 #1
0
    def test_convert_circle(self):
        """ Tests converting Circle objects to circle commands."""
        circle = shape.Circle(0, 0, 300)
        command = self.geda_writer._convert_circle(circle)

        self.assertEquals(command,
                          ['V 0 0 3000 3 10 0 0 -1 -1 0 -1 -1 -1 -1 -1'])

        circle = shape.Circle(10, 30, 10)
        command = self.geda_writer._convert_circle(circle)

        self.assertEquals(command,
                          ['V 100 300 100 3 10 0 0 -1 -1 0 -1 -1 -1 -1 -1'])
예제 #2
0
    def test_is_valid_path(self):
        """ Tests if SBody objects contain valid paths."""
        shapes = [
            shape.Line((10, 10), (50, 10)),  #L 500,100
            shape.BezierCurve((70, 10), (80, 30), (50, 10),
                              (80, 40)),  #C 700,100 800,300 800,400
            shape.BezierCurve((80, 50), (70, 70), (80, 40),
                              (50, 70)),  #C 800,500 700,700 500,700
            shape.Line((50, 70), (10, 70)),  #L 100,700
        ]

        body = components.SBody()
        body.shapes = shapes
        self.assertTrue(self.geda_writer.is_valid_path(body))

        body.add_shape(shape.Line((10, 70), (10, 10)))
        self.assertTrue(self.geda_writer.is_valid_path(body))

        shapes = [
            shape.Line((10, 10), (50, 10)),  #L 500,100
            shape.BezierCurve((70, 10), (80, 30), (50, 10),
                              (80, 40)),  #C 700,100 800,300 800,400
            shape.Line((50, 70), (10, 70)),  #L 100,700
        ]
        body.shapes = shapes
        self.assertFalse(self.geda_writer.is_valid_path(body))

        body.add_shape(shape.Circle(0, 0, 10))
        self.assertFalse(self.geda_writer.is_valid_path(body))
예제 #3
0
 def test_generating_geda_commands_for_toplevel_shapes(self):
     design = Design()
     design.shapes = [
         shape.Line((0, 0), (0, 50)),
         shape.Circle(0, 0, 300),
     ]
     design.pins = [
         components.Pin('E', (0, 0), (0, 30)),
         components.Pin('E', (0, 0), (0, 30)),
     ]
     commands = self.geda_writer.generate_body_commands(design)
     ## default pins require 6 commands, shapes require 1 command
     self.assertEquals(len(commands), 2 * 6 + 2 * 1)
예제 #4
0
    def _parse_V(self, stream, params):
        """ Creates a Circle object from the gEDA parameters in *params. All
            style related parameters are ignored.
            Returns a Circle object.
        """
        vertex_x = params['x']
        if self._is_mirrored_command(params):
            vertex_x = 0 - vertex_x

        circle = shape.Circle(
            self.x_to_px(vertex_x),
            self.y_to_px(params['y']),
            self.to_px(params['radius']),
        )
        ## store style data for arc in 'style' dict
        self._save_parameters_to_object(circle, params)
        return circle